/Source/QtIFW/

ba2_2_1_base_synthetic Tk is a free and open-source, cross-platform widget toolkit that provides a library of basic elements of GUI widgets for building a graphical user interface (GUI) in many programming languages.
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorstanton <stanton>1998-09-30 02:19:04 (GMT)
committerstanton <stanton>1998-09-30 02:19:04 (GMT)
commitda9d3d17d12952676d1c5a7a8424221f708d4a0e (patch)
tree2ab332f7ff062a2df7010439c8d332e4f71ade6d
parent139cae1fba039b0ff1c8d5e8f563903d2fd52c72 (diff)
downloadtk-da9d3d17d12952676d1c5a7a8424221f708d4a0e.zip
tk-da9d3d17d12952676d1c5a7a8424221f708d4a0e.tar.gz
tk-da9d3d17d12952676d1c5a7a8424221f708d4a0e.tar.bz2
Merged 8.0.3 changes into 8.1
Diffstat
-rw-r--r--README393
-rw-r--r--bitmaps/error.bmp8
-rw-r--r--bitmaps/gray12.bmp6
-rw-r--r--bitmaps/gray25.bmp6
-rw-r--r--bitmaps/gray50.bmp6
-rw-r--r--bitmaps/gray75.bmp6
-rw-r--r--bitmaps/hourglass.bmp9
-rw-r--r--bitmaps/info.bmp5
-rw-r--r--bitmaps/questhead.bmp9
-rw-r--r--bitmaps/question.bmp10
-rw-r--r--bitmaps/warning.bmp5
-rw-r--r--changes4252
-rw-r--r--compat/limits.h24
-rw-r--r--compat/stdlib.h45
-rw-r--r--compat/unistd.h84
-rw-r--r--deleted_files/xlib/ximage.c115
-rw-r--r--doc/3DBorder.3262
-rw-r--r--doc/BindTable.3157
-rw-r--r--doc/CanvPsY.3122
-rw-r--r--doc/CanvTkwin.3161
-rw-r--r--doc/CanvTxtInfo.3104
-rw-r--r--doc/Clipboard.380
-rw-r--r--doc/ClrSelect.342
-rw-r--r--doc/ConfigWidg.3618
-rw-r--r--doc/ConfigWind.3153
-rw-r--r--doc/CoordToWin.351
-rw-r--r--doc/CrtErrHdlr.3145
-rw-r--r--doc/CrtGenHdlr.384
-rw-r--r--doc/CrtImgType.3255
-rw-r--r--doc/CrtItemType.3626
-rw-r--r--doc/CrtPhImgFmt.3235
-rw-r--r--doc/CrtSelHdlr.3120
-rw-r--r--doc/CrtWindow.3142
-rw-r--r--doc/DeleteImg.335
-rw-r--r--doc/DrawFocHlt.340
-rw-r--r--doc/EventHndlr.379
-rw-r--r--doc/FindPhoto.3202
-rw-r--r--doc/FontId.395
-rw-r--r--doc/FreeXId.352
-rw-r--r--doc/GeomReq.369
-rw-r--r--doc/GetAnchor.364
-rw-r--r--doc/GetBitmap.3266
-rw-r--r--doc/GetCapStyl.363
-rw-r--r--doc/GetClrmap.373
-rw-r--r--doc/GetColor.3146
-rw-r--r--doc/GetCursor.3188
-rw-r--r--doc/GetFont.374
-rw-r--r--doc/GetGC.374
-rw-r--r--doc/GetImage.3135
-rw-r--r--doc/GetJoinStl.362
-rw-r--r--doc/GetJustify.369
-rw-r--r--doc/GetOption.346
-rw-r--r--doc/GetPixels.376
-rw-r--r--doc/GetPixmap.356
-rw-r--r--doc/GetRelief.359
-rw-r--r--doc/GetRootCrd.343
-rw-r--r--doc/GetScroll.365
-rw-r--r--doc/GetSelect.379
-rw-r--r--doc/GetUid.350
-rw-r--r--doc/GetVRoot.349
-rw-r--r--doc/GetVisual.398
-rw-r--r--doc/HandleEvent.349
-rw-r--r--doc/IdToWindow.336
-rw-r--r--doc/ImgChanged.369
-rw-r--r--doc/InternAtom.358
-rw-r--r--doc/MainLoop.332
-rw-r--r--doc/MainWin.336
-rw-r--r--doc/MaintGeom.3102
-rw-r--r--doc/ManageGeom.394
-rw-r--r--doc/MapWindow.353
-rw-r--r--doc/MeasureChar.3130
-rw-r--r--doc/MoveToplev.355
-rw-r--r--doc/Name.382
-rw-r--r--doc/NameOfImg.334
-rw-r--r--doc/OwnSelect.352
-rw-r--r--doc/ParseArgv.3351
-rw-r--r--doc/QWinEvent.342
-rw-r--r--doc/Restack.349
-rw-r--r--doc/RestrictEv.381
-rw-r--r--doc/SetAppName.365
-rw-r--r--doc/SetClass.361
-rw-r--r--doc/SetGrid.367
-rw-r--r--doc/SetVisual.354
-rw-r--r--doc/StrictMotif.341
-rw-r--r--doc/TextLayout.3270
-rw-r--r--doc/Tk_Init.347
-rw-r--r--doc/Tk_Main.361
-rw-r--r--doc/WindowId.3151
-rw-r--r--doc/bell.n34
-rw-r--r--doc/bind.n474
-rw-r--r--doc/bindtags.n81
-rw-r--r--doc/bitmap.n114
-rw-r--r--doc/button.n176
-rw-r--r--doc/canvas.n1576
-rw-r--r--doc/checkbutton.n238
-rw-r--r--doc/chooseColor.n49
-rw-r--r--doc/clipboard.n81
-rw-r--r--doc/destroy.n34
-rw-r--r--doc/dialog.n65
-rw-r--r--doc/entry.n417
-rw-r--r--doc/event.n338
-rw-r--r--doc/focus.n113
-rw-r--r--doc/focusNext.n60
-rw-r--r--doc/font.n285
-rw-r--r--doc/frame.n134
-rw-r--r--doc/getOpenFile.n157
-rw-r--r--doc/grab.n122
-rw-r--r--doc/grid.n337
-rw-r--r--doc/image.n90
-rw-r--r--doc/label.n103
-rw-r--r--doc/listbox.n491
-rw-r--r--doc/loadTk.n76
-rw-r--r--doc/lower.n38
-rw-r--r--doc/menu.n757
-rw-r--r--doc/menubar.n33
-rw-r--r--doc/menubutton.n193
-rw-r--r--doc/message.n147
-rw-r--r--doc/messageBox.n90
-rw-r--r--doc/option.n91
-rw-r--r--doc/optionMenu.n40
-rw-r--r--doc/options.n328
-rw-r--r--doc/pack-old.n196
-rw-r--r--doc/pack.n266
-rw-r--r--doc/palette.n73
-rw-r--r--doc/photo.n344
-rw-r--r--doc/place.n237
-rw-r--r--doc/popup.n33
-rw-r--r--doc/radiobutton.n233
-rw-r--r--doc/raise.n38
-rw-r--r--doc/scale.n246
-rw-r--r--doc/scrollbar.n340
-rw-r--r--doc/selection.n128
-rw-r--r--doc/send.n92
-rw-r--r--doc/text.n1621
-rw-r--r--doc/tk.n72
-rw-r--r--doc/tk4.0.ps4602
-rw-r--r--doc/tkerror.n38
-rw-r--r--doc/tkvars.n72
-rw-r--r--doc/tkwait.n51
-rw-r--r--doc/toplevel.n163
-rw-r--r--doc/winfo.n330
-rw-r--r--doc/wish.1186
-rw-r--r--doc/wm.n503
-rw-r--r--generic/README5
-rw-r--r--generic/default.h29
-rw-r--r--generic/ks_names.h921
-rw-r--r--generic/tk.h1558
-rw-r--r--generic/tk3d.c949
-rw-r--r--generic/tk3d.h87
-rw-r--r--generic/tkArgv.c433
-rw-r--r--generic/tkAtom.c217
-rw-r--r--generic/tkBind.c4533
-rw-r--r--generic/tkBitmap.c630
-rw-r--r--generic/tkButton.c1347
-rw-r--r--generic/tkButton.h249
-rw-r--r--generic/tkCanvArc.c1716
-rw-r--r--generic/tkCanvBmap.c800
-rw-r--r--generic/tkCanvImg.c677
-rw-r--r--generic/tkCanvLine.c1623
-rw-r--r--generic/tkCanvPoly.c998
-rw-r--r--generic/tkCanvPs.c1386
-rw-r--r--generic/tkCanvText.c1313
-rw-r--r--generic/tkCanvUtil.c376
-rw-r--r--generic/tkCanvWind.c862
-rw-r--r--generic/tkCanvas.c3791
-rw-r--r--generic/tkCanvas.h257
-rw-r--r--generic/tkClipboard.c606
-rw-r--r--generic/tkCmds.c1646
-rw-r--r--generic/tkColor.c397
-rw-r--r--generic/tkColor.h68
-rw-r--r--generic/tkConfig.c990
-rw-r--r--generic/tkConsole.c616
-rw-r--r--generic/tkCursor.c384
-rw-r--r--generic/tkEntry.c2313
-rw-r--r--generic/tkError.c307
-rw-r--r--generic/tkEvent.c1038
-rw-r--r--generic/tkFileFilter.c486
-rw-r--r--generic/tkFileFilter.h92
-rw-r--r--generic/tkFocus.c998
-rw-r--r--generic/tkFont.c3008
-rw-r--r--generic/tkFont.h216
-rw-r--r--generic/tkFrame.c939
-rw-r--r--generic/tkGC.c363
-rw-r--r--generic/tkGeometry.c582
-rw-r--r--generic/tkGet.c586
-rw-r--r--generic/tkGrab.c1535
-rw-r--r--generic/tkGrid.c2615
-rw-r--r--generic/tkImage.c789
-rw-r--r--generic/tkImgBmap.c1068
-rw-r--r--generic/tkImgGIF.c1059
-rw-r--r--generic/tkImgPPM.c421
-rw-r--r--generic/tkImgPhoto.c4144
-rw-r--r--generic/tkImgUtil.c78
-rw-r--r--generic/tkInitScript.h56
-rw-r--r--generic/tkInt.h1008
-rw-r--r--generic/tkListbox.c2335
-rw-r--r--generic/tkMacWinMenu.c134
-rw-r--r--generic/tkMain.c390
-rw-r--r--generic/tkMenu.c3057
-rw-r--r--generic/tkMenu.h549
-rw-r--r--generic/tkMenuDraw.c1018
-rw-r--r--generic/tkMenubutton.c865
-rw-r--r--generic/tkMenubutton.h215
-rw-r--r--generic/tkMessage.c848
-rw-r--r--generic/tkOption.c1397
-rw-r--r--generic/tkPack.c1727
-rw-r--r--generic/tkPlace.c1060
-rw-r--r--generic/tkPointer.c623
-rw-r--r--generic/tkPort.h36
-rw-r--r--generic/tkRectOval.c1030
-rw-r--r--generic/tkScale.c1143
-rw-r--r--generic/tkScale.h233
-rw-r--r--generic/tkScrollbar.c691
-rw-r--r--generic/tkScrollbar.h208
-rw-r--r--generic/tkSelect.c1341
-rw-r--r--generic/tkSelect.h184
-rw-r--r--generic/tkSquare.c587
-rw-r--r--generic/tkTest.c1134
-rw-r--r--generic/tkText.c2264
-rw-r--r--generic/tkText.h848
-rw-r--r--generic/tkTextBTree.c3594
-rw-r--r--generic/tkTextDisp.c5015
-rw-r--r--generic/tkTextImage.c898
-rw-r--r--generic/tkTextIndex.c840
-rw-r--r--generic/tkTextMark.c775
-rw-r--r--generic/tkTextTag.c1376
-rw-r--r--generic/tkTextWind.c1176
-rw-r--r--generic/tkTrig.c1467
-rw-r--r--generic/tkUtil.c348
-rw-r--r--generic/tkVisual.c540
-rw-r--r--generic/tkWindow.c2836
-rw-r--r--library/bgerror.tcl99
-rw-r--r--library/button.tcl456
-rw-r--r--library/clrpick.tcl691
-rw-r--r--library/comdlg.tcl308
-rw-r--r--library/console.tcl481
-rw-r--r--library/demos/README46
-rw-r--r--library/demos/arrow.tcl238
-rw-r--r--library/demos/bind.tcl79
-rw-r--r--library/demos/bitmap.tcl55
-rw-r--r--library/demos/browse56
-rw-r--r--library/demos/button.tcl36
-rw-r--r--library/demos/check.tcl33
-rw-r--r--library/demos/clrpick.tcl56
-rw-r--r--library/demos/colors.tcl101
-rw-r--r--library/demos/cscroll.tcl96
-rw-r--r--library/demos/ctext.tcl146
-rw-r--r--library/demos/dialog1.tcl15
-rw-r--r--library/demos/dialog2.tcl19
-rw-r--r--library/demos/entry1.tcl36
-rw-r--r--library/demos/entry2.tcl48
-rw-r--r--library/demos/filebox.tcl70
-rw-r--r--library/demos/floor.tcl1370
-rw-r--r--library/demos/form.tcl40
-rw-r--r--library/demos/hello18
-rw-r--r--library/demos/hscale.tcl47
-rw-r--r--library/demos/icon.tcl52
-rw-r--r--library/demos/image1.tcl36
-rw-r--r--library/demos/image2.tcl80
-rw-r--r--library/demos/images/earth.gifbin51712 -> 0 bytes
-rw-r--r--library/demos/images/earthris.gifbin6343 -> 0 bytes
-rw-r--r--library/demos/images/face.bmp173
-rw-r--r--library/demos/images/flagdown.bmp27
-rw-r--r--library/demos/images/flagup.bmp27
-rw-r--r--library/demos/images/gray25.bmp6
-rw-r--r--library/demos/images/letters.bmp27
-rw-r--r--library/demos/images/noletter.bmp27
-rw-r--r--library/demos/images/pattern.bmp6
-rw-r--r--library/demos/images/tcllogo.gifbin2341 -> 0 bytes
-rw-r--r--library/demos/images/teapot.ppm31
-rw-r--r--library/demos/items.tcl285
-rw-r--r--library/demos/ixset312
-rw-r--r--library/demos/label.tcl40
-rw-r--r--library/demos/menu.tcl152
-rw-r--r--library/demos/menubu.tcl93
-rw-r--r--library/demos/msgbox.tcl65
-rw-r--r--library/demos/plot.tcl98
-rw-r--r--library/demos/puzzle.tcl73
-rw-r--r--library/demos/radio.tcl44
-rw-r--r--library/demos/rmt205
-rw-r--r--library/demos/rolodex196
-rw-r--r--library/demos/ruler.tcl173
-rw-r--r--library/demos/sayings.tcl46
-rw-r--r--library/demos/search.tcl141
-rw-r--r--library/demos/square55
-rw-r--r--library/demos/states.tcl45
-rw-r--r--library/demos/style.tcl152
-rw-r--r--library/demos/tclIndex67
-rw-r--r--library/demos/tcolor358
-rw-r--r--library/demos/text.tcl76
-rw-r--r--library/demos/timer40
-rw-r--r--library/demos/twind.tcl196
-rw-r--r--library/demos/vscale.tcl48
-rw-r--r--library/demos/widget391
-rw-r--r--library/dialog.tcl174
-rw-r--r--library/entry.tcl610
-rw-r--r--library/focus.tcl180
-rw-r--r--library/images/README12
-rw-r--r--library/images/logo100.gifbin2341 -> 0 bytes
-rw-r--r--library/images/logo64.gifbin1670 -> 0 bytes
-rw-r--r--library/images/logoLarge.gifbin11000 -> 0 bytes
-rw-r--r--library/images/logoMed.gifbin3889 -> 0 bytes
-rw-r--r--library/images/pwrdLogo100.gifbin4147 -> 0 bytes
-rw-r--r--library/images/pwrdLogo150.gifbin6809 -> 0 bytes
-rw-r--r--library/images/pwrdLogo175.gifbin7964 -> 0 bytes
-rw-r--r--library/images/pwrdLogo200.gifbin8964 -> 0 bytes
-rw-r--r--library/images/pwrdLogo75.gifbin3189 -> 0 bytes
-rw-r--r--library/listbox.tcl452
-rw-r--r--library/menu.tcl1235
-rw-r--r--library/msgbox.tcl257
-rw-r--r--library/obsolete.tcl21
-rw-r--r--library/optMenu.tcl45
-rw-r--r--library/palette.tcl222
-rw-r--r--library/prolog.ps284
-rw-r--r--library/safetk.tcl204
-rw-r--r--library/scale.tcl265
-rw-r--r--library/scrlbar.tcl417
-rw-r--r--library/tclIndex244
-rw-r--r--library/tearoff.tcl145
-rw-r--r--library/text.tcl1010
-rw-r--r--library/tk.tcl192
-rw-r--r--library/tkfbox.tcl1456
-rw-r--r--library/xmfbox.tcl650
-rw-r--r--license.terms39
-rw-r--r--mac/MW_TkHeader.pch129
-rw-r--r--mac/README304
-rw-r--r--mac/bugs.doc40
-rw-r--r--mac/tclets.tcl215
-rw-r--r--mac/tkMac.h81
-rw-r--r--mac/tkMacAppInit.c386
-rw-r--r--mac/tkMacApplication.r267
-rw-r--r--mac/tkMacBitmap.c268
-rw-r--r--mac/tkMacButton.c1443
-rw-r--r--mac/tkMacClipboard.c293
-rw-r--r--mac/tkMacColor.c485
-rw-r--r--mac/tkMacCursor.c392
-rw-r--r--mac/tkMacCursors.r130
-rw-r--r--mac/tkMacDefault.h461
-rw-r--r--mac/tkMacDialog.c939
-rw-r--r--mac/tkMacDraw.c1130
-rw-r--r--mac/tkMacEmbed.c1192
-rw-r--r--mac/tkMacFont.c678
-rw-r--r--mac/tkMacHLEvents.c437
-rw-r--r--mac/tkMacInit.c240
-rw-r--r--mac/tkMacInt.h301
-rw-r--r--mac/tkMacKeyboard.c384
-rw-r--r--mac/tkMacLibrary.r508
-rw-r--r--mac/tkMacMDEF.c116
-rw-r--r--mac/tkMacMDEF.r45
-rw-r--r--mac/tkMacMenu.c4038
-rw-r--r--mac/tkMacMenu.r47
-rw-r--r--mac/tkMacMenubutton.c339
-rw-r--r--mac/tkMacMenus.c346
-rw-r--r--mac/tkMacPort.h145
-rw-r--r--mac/tkMacProjects.sea.hqx1210
-rw-r--r--mac/tkMacProlog.c61
-rw-r--r--mac/tkMacRegion.c217
-rw-r--r--mac/tkMacResource.r505
-rw-r--r--mac/tkMacScale.c603
-rw-r--r--mac/tkMacScrlbr.c1057
-rw-r--r--mac/tkMacSend.c358
-rw-r--r--mac/tkMacShLib.exp765
-rw-r--r--mac/tkMacSubwindows.c1245
-rw-r--r--mac/tkMacTest.c81
-rw-r--r--mac/tkMacWindowMgr.c1630
-rw-r--r--mac/tkMacWm.c4226
-rw-r--r--mac/tkMacXCursors.r961
-rw-r--r--mac/tkMacXStubs.c709
-rw-r--r--tests/README30
-rw-r--r--tests/all57
-rw-r--r--tests/arc.tcl140
-rw-r--r--tests/bell.test34
-rw-r--r--tests/bevel.tcl128
-rw-r--r--tests/bgerror.test59
-rw-r--r--tests/bind.test2536
-rw-r--r--tests/bugs.tcl30
-rw-r--r--tests/butGeom.tcl115
-rw-r--r--tests/butGeom2.tcl113
-rw-r--r--tests/button.test822
-rw-r--r--tests/canvImg.test397
-rw-r--r--tests/canvPs.test105
-rw-r--r--tests/canvPsArc.tcl45
-rw-r--r--tests/canvPsBmap.tcl71
-rw-r--r--tests/canvPsGrph.tcl87
-rw-r--r--tests/canvPsText.tcl83
-rw-r--r--tests/canvRect.test329
-rw-r--r--tests/canvText.test492
-rw-r--r--tests/canvWind.test133
-rw-r--r--tests/canvas.test204
-rw-r--r--tests/clipboard.test234
-rw-r--r--tests/clrpick.test215
-rw-r--r--tests/cmap.tcl61
-rw-r--r--tests/cmds.test43
-rw-r--r--tests/color.test167
-rw-r--r--tests/defs367
-rw-r--r--tests/entry.test1269
-rw-r--r--tests/event.test41
-rw-r--r--tests/filebox.test298
-rw-r--r--tests/focus.test636
-rw-r--r--tests/focusTcl.test279
-rw-r--r--tests/font.test1092
-rw-r--r--tests/frame.test617
-rw-r--r--tests/geometry.test251
-rw-r--r--tests/grid.test1205
-rw-r--r--tests/id.test102
-rw-r--r--tests/image.test357
-rw-r--r--tests/imgBmap.test474
-rw-r--r--tests/imgPPM.test156
-rw-r--r--tests/imgPhoto.test423
-rw-r--r--tests/listbox.test1658
-rw-r--r--tests/macEmbed.test297
-rw-r--r--tests/macFont.test182
-rw-r--r--tests/macMenu.test1565
-rw-r--r--tests/macWinMenu.test117
-rw-r--r--tests/macscrollbar.test101
-rw-r--r--tests/main.test31
-rw-r--r--tests/menu.test2385
-rw-r--r--tests/menuDraw.test546
-rw-r--r--tests/menubut.test352
-rw-r--r--tests/msgbox.test157
-rw-r--r--tests/oldpack.test508
-rw-r--r--tests/option.file117
-rw-r--r--tests/option.file22
-rw-r--r--tests/option.test232
-rw-r--r--tests/pack.test969
-rw-r--r--tests/place.test221
-rw-r--r--tests/raise.test299
-rw-r--r--tests/safe.test169
-rw-r--r--tests/scale.test801
-rw-r--r--tests/scrollbar.test665
-rw-r--r--tests/select.test987
-rw-r--r--tests/send.test656
-rw-r--r--tests/text.test1262
-rw-r--r--tests/textBTree.test897
-rw-r--r--tests/textDisp.test2868
-rw-r--r--tests/textImage.test353
-rw-r--r--tests/textIndex.test349
-rw-r--r--tests/textMark.test222
-rw-r--r--tests/textTag.test756
-rw-r--r--tests/textWind.test826
-rw-r--r--tests/tk.test80
-rw-r--r--tests/unixButton.test182
-rw-r--r--tests/unixEmbed.test627
-rw-r--r--tests/unixFont.test293
-rw-r--r--tests/unixMenu.test969
-rw-r--r--tests/unixWm.test2358
-rw-r--r--tests/util.test70
-rw-r--r--tests/visual2
-rw-r--r--tests/visual.test312
-rw-r--r--tests/winButton.test154
-rw-r--r--tests/winClipboard.test44
-rw-r--r--tests/winFont.test185
-rw-r--r--tests/winMenu.test1030
-rw-r--r--tests/winWm.test219
-rw-r--r--tests/window.test137
-rw-r--r--tests/winfo.test367
-rw-r--r--unix/Makefile.in1031
-rw-r--r--unix/README125
-rw-r--r--unix/configure.in444
-rw-r--r--unix/install-sh119
-rw-r--r--unix/mkLinks878
-rw-r--r--unix/porting.notes86
-rw-r--r--unix/porting.old324
-rw-r--r--unix/tkAppInit.c120
-rw-r--r--unix/tkConfig.sh.in74
-rw-r--r--unix/tkUnix.c79
-rw-r--r--unix/tkUnix3d.c448
-rw-r--r--unix/tkUnixButton.c478
-rw-r--r--unix/tkUnixColor.c424
-rw-r--r--unix/tkUnixCursor.c407
-rw-r--r--unix/tkUnixDefault.h450
-rw-r--r--unix/tkUnixDialog.c207
-rw-r--r--unix/tkUnixDraw.c171
-rw-r--r--unix/tkUnixEmbed.c1001
-rw-r--r--unix/tkUnixEvent.c498
-rw-r--r--unix/tkUnixFocus.c149
-rw-r--r--unix/tkUnixFont.c998
-rw-r--r--unix/tkUnixInit.c117
-rw-r--r--unix/tkUnixInt.h32
-rw-r--r--unix/tkUnixMenu.c1603
-rw-r--r--unix/tkUnixMenubu.c307
-rw-r--r--unix/tkUnixPort.h235
-rw-r--r--unix/tkUnixScale.c828
-rw-r--r--unix/tkUnixScrlbr.c476
-rw-r--r--unix/tkUnixSelect.c1189
-rw-r--r--unix/tkUnixSend.c1851
-rw-r--r--unix/tkUnixWm.c4813
-rw-r--r--unix/tkUnixXId.c537
-rw-r--r--win/README122
-rw-r--r--win/makefile.bc340
-rw-r--r--win/makefile.vc440
-rw-r--r--win/mkd.bat20
-rw-r--r--win/rc/buttons.bmpbin846 -> 0 bytes
-rw-r--r--win/rc/cursor00.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor02.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor04.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor06.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor08.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor0a.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor0c.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor0e.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor10.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor12.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor14.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor16.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor18.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor1a.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor1c.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor1e.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor20.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor22.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor24.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor26.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor28.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor2a.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor2c.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor2e.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor30.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor32.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor34.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor36.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor38.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor3a.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor3c.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor3e.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor40.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor42.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor44.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor46.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor48.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor4a.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor4c.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor4e.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor50.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor52.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor54.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor56.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor58.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor5a.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor5c.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor5e.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor60.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor62.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor64.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor66.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor68.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor6a.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor6c.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor6e.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor70.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor72.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor74.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor76.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor78.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor7a.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor7c.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor7e.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor80.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor82.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor84.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor86.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor88.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor8a.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor8c.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor8e.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor90.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor92.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor94.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor96.curbin326 -> 0 bytes
-rw-r--r--win/rc/cursor98.curbin326 -> 0 bytes
-rw-r--r--win/rc/tk.icobin1398 -> 0 bytes
-rw-r--r--win/rc/tk.rc132
-rw-r--r--win/rc/wish.icobin1398 -> 0 bytes
-rw-r--r--win/rmd.bat20
-rw-r--r--win/stubs.c397
-rw-r--r--win/tkWin.h64
-rw-r--r--win/tkWin32Dll.c85
-rw-r--r--win/tkWin3d.c535
-rw-r--r--win/tkWinButton.c811
-rw-r--r--win/tkWinClipboard.c291
-rw-r--r--win/tkWinColor.c615
-rw-r--r--win/tkWinCursor.c210
-rw-r--r--win/tkWinDefault.h456
-rw-r--r--win/tkWinDialog.c1050
-rw-r--r--win/tkWinDraw.c1264
-rw-r--r--win/tkWinEmbed.c645
-rw-r--r--win/tkWinFont.c628
-rw-r--r--win/tkWinImage.c329
-rw-r--r--win/tkWinInit.c121
-rw-r--r--win/tkWinInt.h194
-rw-r--r--win/tkWinKey.c370
-rw-r--r--win/tkWinMenu.c2692
-rw-r--r--win/tkWinPixmap.c184
-rw-r--r--win/tkWinPointer.c466
-rw-r--r--win/tkWinPort.h117
-rw-r--r--win/tkWinRegion.c179
-rw-r--r--win/tkWinScrlbr.c745
-rw-r--r--win/tkWinSend.c86
-rw-r--r--win/tkWinWindow.c801
-rw-r--r--win/tkWinWm.c4217
-rw-r--r--win/tkWinX.c1034
-rw-r--r--win/winMain.c321
-rw-r--r--xlib/X11/X.h669
-rw-r--r--xlib/X11/Xatom.h79
-rw-r--r--xlib/X11/Xfuncproto.h60
-rw-r--r--xlib/X11/Xlib.h4311
-rw-r--r--xlib/X11/Xutil.h879
-rw-r--r--xlib/X11/cursorfont.h79
-rw-r--r--xlib/X11/keysym.h39
-rw-r--r--xlib/X11/keysymdef.h1169
-rw-r--r--xlib/xbytes.h58
-rw-r--r--xlib/xcolors.c911
-rw-r--r--xlib/xdraw.c82
-rw-r--r--xlib/xgc.c353
-rw-r--r--xlib/ximage.c71
-rw-r--r--xlib/xutil.c116
616 files changed, 1 insertions, 263277 deletions
diff --git a/README b/README
deleted file mode 100644
index b7a4d44..0000000
--- a/README
+++ /dev/null
@@ -1,393 +0,0 @@
-The Tk Toolkit
-
-RCS: @(#) $Id: README,v 1.9 1998/09/14 18:22:43 stanton Exp $
-
-1. Introduction
----------------
-
-This directory and its descendants contain the sources and documentation
-for Tk, an X11 toolkit implemented with the Tcl scripting language. The
-information here corresponds to Tk 8.0.3, which is the third patch update
-for Tk 8.0. This release is designed to work with Tcl 8.0.3 and may not
-work with any other version of Tcl.
-
-Tk 8.0 is a major release with significant new features such as native
-look and feel on Macintoshes and PCs, a new font mechanism, application
-embedding, and proper support for Safe-Tcl. See below for details.
-There should be no backward incompatibilities in Tk 8.0 that affect
-scripts. This patch release fixes various bugs in Tk 8.0; there are no
-feature changes relative to Tk 8.0.
-
-Note: with Tk 8.0 the Tk version number skipped from 4.2 to 8.0. The
-jump was made in order to synchronize the Tcl and Tk version numbers.
-
-2. Documentation
-----------------
-
-The best way to get started with Tk is to read one of the introductory
-books on Tcl and Tk:
-
- Practical Programming in Tcl and Tk, 2nd Edition, by Brent Welch,
- Prentice-Hall, 1997, ISBN 0-13-616830-2
-
- Tcl and the Tk Toolkit, by John Ousterhout,
- Addison-Wesley, 1994, ISBN 0-201-63337-X
-
- Exploring Expect, by Don Libes,
- O'Reilly and Associates, 1995, ISBN 1-56592-090-2
-
-Other books are listed at
-http://www.scriptics.com/resource/doc/books/
-http://www.tclconsortium.org/resources/books.html
-
-The "doc" subdirectory in this release contains a complete set of
-reference manual entries for Tk. Files with extension ".1" are for
-programs such as wish; files with extension ".3" are for C library
-procedures; and files with extension ".n" describe Tcl commands. To
-print any of the manual entries, cd to the "doc" directory and invoke
-your favorite variant of troff using the normal -man macros, for example
-
- ditroff -man wish.1
-
-to print wish.1. If Tk has been installed correctly and your "man"
-program supports it, you should be able to access the Tcl manual entries
-using the normal "man" mechanisms, such as
-
- man wish
-
-If you are porting Tk 3.6 scripts to Tk 4.0 or later releases, you may
-find the Postscript file doc/tk4.0.ps useful. It is a porting guide
-that summarizes the new features and discusses how to deal with the
-changes in Tk 4.0 that are not backwards compatible.
-
-There is also an official home for Tcl and Tk on the Web:
- http://www.scriptics.com/
-These Web pages include release updates, reports on bug fixes and porting
-issues, HTML versions of the manual pages, and pointers to many other
-Tcl/Tk Web pages at other sites. Check them out!
-
-3. Compiling and installing Tk
-------------------------------
-
-This release contains everything you should need to compile and run
-Tk under UNIX, Macintoshes, and PCs (either Windows NT, Windows 95,
-or Windows 98.)
-
-Before trying to compile Tk you should do the following things:
-
- (a) Check for a binary release. Pre-compiled binary releases are
- available now for PCs and Macintoshes, and several flavors of
- UNIX. Binary releases are much easier to install than source
- releases. To find out whether a binary release is available for
- your platform, check the home page for Tcl/Tk
- (http://www.scriptics.com/) and also check in the FTP
- directory from which you retrieved the base distribution.
-
- (b) Make sure you have the most recent patch release. Look in the
- FTP directory from which you retrieved this distribution to see
- if it has been updated with patches. Patch releases fix bugs
- without changing any features, so you should normally use the
- latest patch release for the version of Tk that you want.
- Patch releases are available in two forms. A file like
- tk8.0p1.tar.Z is a complete release for patch level 1 of Tk
- version 8.0. If there is a file with a higher patch level than
- this release, just fetch the file with the highest patch level
- and use it.
-
- Patches are also available in the form of patch files that just
- contain the changes from one patch level to another. These
- files have names like tk8.0p1.patch, tk8.0p2.patch, etc. They
- may also have .gz or .Z extensions to indicate compression. To
- use one of these files, you apply it to an existing release with
- the "patch" program. Patches must be applied in order:
- tk8.0p1.patch must be applied to an unpatched Tk 8.0 release
- to produce a Tk 8.0p1 release; tk8.0p2.patch can then be
- applied to Tk 8.0p1 to produce Tk 8.0p2, and so on. To apply an
- uncompressed patch file such as tk8.0p1.patch, invoke a shell
- command like the following from the directory containing this
- file (you may need to replace "patch -p" with "patch -p0"
- depending on your version of the patch program):
- patch -p < tk8.0p1.patch
- If the patch file has a .gz extension, it was compressed with
- gzip. To apply it, invoke a command like the following:
- gunzip -c tk8.0p1.patch.gz | patch -p
- If the patch file has a .Z extension, it was compressed with
- compress. To apply it, invoke a command like the following:
- zcat tk8.0p1.patch.Z | patch -p
- If you're applying a patch to a release that has already been
- compiled, then before applying the patch you should cd to the
- "unix" subdirectory and type "make distclean" to restore the
- directory to a pristine state.
-
-Once you've done this, change to the "unix" subdirectory if you're
-compiling under UNIX, "win" if you're compiling under Windows, or
-"mac" if you're compiling on a Macintosh. Then follow the instructions
-in the README file in that directory for compiling Tk, installing it,
-and running the test suite.
-
-4. Getting started
-------------------
-
-The best way to get started with Tk is by reading one of the introductory
-books.
-
-The subdirectory library/demos contains a number of pre-canned scripts
-that demonstrate various features of Tk. See the README file in the
-directory for a description of what's available. The file
-library/demos/widget is a script that you can use to invoke many individual
-demonstrations of Tk's facilities, see the code that produced the demos,
-and modify the code to try out alternatives.
-
-5. Summary of changes in Tk 8.0
--------------------------------
-
-Here is a list of the most important new features in Tk 8.0. The
-release also includes several smaller feature changes and bug fixes.
-See the "changes" file for a complete list of all changes.
-
- 1. Native look and feel. The widgets have been rewritten to provide
- (nearly?) native look and feel on the Macintosh and PC. Many
- widgets, including scrollbars, menus, and the button family, are
- implemented with native platform widgets. Others, such as entries
- and texts, have been modified to emulate native look and feel.
- These changes are backwards compatible except that (a) some
- configuration options are now ignored on some platforms and (b) you
- must use the new menu mechanism described below to native look and
- feel for menus.
-
- 2. There is a new interface for creating menus, where a menubar is
- implemented as a menu widget instead of a frame containing menubuttons.
- The -menu option for a toplevel is used to specify the name of the
- menubar; the menu will be displayed *outside* the toplevel using
- different mechanisms on each platform (e.g. on the Macintosh the menu
- will appear at the top of the screen). See the menu demos in the
- widget demo for examples. The old style of menu still works, but
- does not provide native look and feel. Menus have several new
- features:
- - New "-columnbreak" and "-hideMargin" options make it possible
- to create multi-column menus.
- - It is now possible to manipulate the Apple and Help menus on
- the Macintosh, and the system menu on Windows. It is also
- possible to have a right justified Help menu on Unix.
- - Menus now issue the virtual event <<MenuSelect>> whenever the
- current item changes. Applications can use this to generate
- help messages.
- - There is a new "-direction" option for menubuttons, which
- controls where the menu pops up revenues to the button.
-
- 3. The font mechanism in Tk has been completely reworked:
- - Font names need not be nasty X LFDs: more intuitive names
- like {Times 12 Bold} can also be used. See the manual entry
- font.n for details.
- - Font requests always succeed now. If the requested font is
- not available, Tk finds the closest available font and uses
- that one.
- - Tk now supports named fonts whose precise attributes can be
- changed dynamically. If a named font is changed, any widget
- using that font updates itself to reflect the change.
- - There is a new command "font" for creating named fonts and
- querying various information about fonts.
- - There are now officially supported C APIs for measuring and
- displaying text. If you use these APIs now, your code will
- automatically handle international text when internationalization
- is added to Tk in a future release. See the manual entries
- MeasureChar.3, TextLayout.3, and FontId.3.
- - The old C procedures Tk_GetFontStruct, Tk_NameOfFontStruct,
- and Tk_FreeFontStruct have been replaced with more portable
- procedures Tk_GetFont, Tk_NameOfFont, and Tk_FreeFont.
-
- 4. Application embedding. It is now possible to embedded one Tcl/Tk
- application inside another, using the -container option on frame
- widgets and the -use option for toplevel widgets or on the command
- line for wish. Embedding should be fully functional under Unix,
- but the implementation is incomplete on the Macintosh and PC.
-
- 5. Tk now works correctly with Safe-Tcl: it can be loaded into
- safe interpreters using safe::loadTk.
-
- 6. Text widgets now allow images to be embedded directly in the
- text without using embedded windows. This is more efficient and
- provides smoother scrolling.
-
- 7. Buttons have a new -default option for drawing default rings in
- a platform-specific manner.
-
- 8. There is a new "gray75" bitmap, and the "gray25" bitmap is now
- really 25% on (due to an ancient mistake, it had been only 12% on).
- The Macintosh now supports native bitmaps, including new builtin
- bitmaps "stop", "caution", and "note", plus the ability to use
- bitmaps in the application's resource fork.
-
- 9. The "destroy" command now ignores windows that don't exist
- instead of generating an error.
-
-Tk 8.0 introduces the following incompatibilities that may affect Tcl/Tk
-scripts that worked under Tk 4.2 and earlier releases:
-
- 1. Font specifications such as "Times 12" now interpret the size
- as points, whereas it used to be pixels (this was actually a bug,
- since the behavior was documented as points). To get pixels now,
- use a negative size such as "Times -12".
-
- 2. The -transient option for menus is no longer supported. You can
- achieve the same effect with the -type field.
-
- 3. In the canvas "coords" command, polygons now return only the
- points that were explicitly specified when the polygon was created
- (they used to return an extra point if the polygon wasn't originally
- closed). Internally, polygons are still closed automatically for
- purposes of display and hit detection; the extra point just isn't
- returned by the "coords" command.
-
- 4. The photo image mechanism now uses Tcl_Channels instead of FILEs,
- in order to make it portable. FILEs are no longer used anywhere
- in Tk. The procedure Tk_FindPhoto now requires an extra "interp"
- argument in order to fix a bug where images in different interpreters
- with the same name could get confused.
-
- 5. The procedures Tk_GetFontStruct, Tk_NameOfFontStruct,
- and Tk_FreeFontStruct have been removed.
-
-Note: the new compiler in Tcl 8.0 may also affect Tcl/Tk scripts; check
-the Tcl documentation for information on incompatibilities introduced by
-Tcl 8.0.
-
-6. Tcl/Tk newsgroup
--------------------
-
-There is a network news group "comp.lang.tcl" intended for the exchange
-of information about Tcl, Tk, and related applications. Feel free to use
-this newsgroup both for general information questions and for bug reports.
-We read the newsgroup and will attempt to fix bugs and problems reported
-to it.
-
-When using comp.lang.tcl, please be sure that your e-mail return address
-is correctly set in your postings. This allows people to respond directly
-to you, rather than the entire newsgroup, for answers that are not of
-general interest. A bad e-mail return address may prevent you from
-getting answers to your questions. You may have to reconfigure your news
-reading software to ensure that it is supplying valid e-mail addresses.
-
-7. Mailing lists
-----------------
-
-A couple of Mailing List have been set up to discuss Macintosh or
-Windows related Tcl issues. In order to use these Mailing Lists you
-must have access to the internet. To subscribe send a message to:
-
- wintcl-request@tclconsorium.org
- or
- mactcl-request@tclconsorium.org
-
-In the body of the message (the subject will be ignored) put:
-
- subscribe mactcl Joe Blow
-
-Replacing Joe Blow with your real name, of course. (Use wintcl
-instead of mactcl if your interested in the Windows list.) If you
-would just like to receive more information about the list without
-subscribing but the line:
-
- information mactcl
-
-in the body instead (or wintcl).
-
-8. Tcl/Tk contributed archive
---------------------------
-
-Many people have created exciting packages and applications based on Tcl
-and/or Tk and made them freely available to the Tcl community. An archive
-of these contributions is kept on the machine ftp.neosoft.com. You
-can access the archive using anonymous FTP; the Tcl contributed archive is
-in the directory "/pub/tcl". The archive also contains several FAQ
-("frequently asked questions") documents that provide solutions to problems
-that are commonly encountered by TCL newcomers.
-
-9. Tcl Resource Center
-----------------------
-Visit http://www.scritics.com/resource/ to see an annotated index of
-many Tcl resources available on the World Wide Web. This includes
-papers, books, and FAQs, as well as extensions, applications, binary
-releases, and patches. You can contribute patches by sending them
-to <patches@scriptics.com>. You can also recommend more URLs for the
-resource center using the forms labeled "Add a Resource".
-
-10. Support and bug fixes
-------------------------
-
-We're very interested in receiving bug reports and suggestions for
-improvements. We prefer that you send this information to the
-comp.lang.tcl newsgroup rather than to any of us at Scriptics. We'll see
-anything on comp.lang.tcl, and in addition someone else who reads
-comp.lang.tcl may be able to offer a solution. The normal turn-around
-time for bugs is 3-6 weeks. Enhancements may take longer and may not
-happen at all unless there is widespread support for them (we're
-trying to slow the rate at which Tk turns into a kitchen sink). It's
-very difficult to make incompatible changes to Tcl at this point, due
-to the size of the installed base.
-
-When reporting bugs, please provide a short wish script that we can
-use to reproduce the bug. Make sure that the script runs with a
-bare-bones wish and doesn't depend on any extensions or other
-programs, particularly those that exist only at your site. Also,
-please include three additional pieces of information with the
-script:
- (a) how do we use the script to make the problem happen (e.g.
- what things do we click on, in what order)?
- (b) what happens when you do these things (presumably this is
- undesirable)?
- (c) what did you expect to happen instead?
-
-The Tcl/Tk community is too large for us to provide much individual
-support for users. If you need help we suggest that you post questions
-to comp.lang.tcl. We read the newsgroup and will attempt to answer
-esoteric questions for which no-one else is likely to know the answer.
-In addition, Tcl/Tk support and training are available commercially from
-Scriptics (info@scriptics.com), NeoSoft (info@neosoft.com),
-Computerized Processes Unlimited (gwl@cpu.com),
-and Data Kinetics (education@dkl.com).
-
-11. Release organization
-------------------------
-
-The version numbers described below are available to Tcl scripts
-as the tk_version and tk_patchLevel Tcl variables.
-
-Each Tk release is identified by two numbers separated by a dot, e.g.
-3.2 or 3.3. If a new release contains changes that are likely to break
-existing C code or Tcl scripts then the major release number increments
-and the minor number resets to zero: 3.0, 4.0, etc. If a new release
-contains only bug fixes and compatible changes, then the minor number
-increments without changing the major number, e.g. 3.1, 3.2, etc. If
-you have C code or Tcl scripts that work with release X.Y, then they
-should also work with any release X.Z as long as Z > Y.
-
-Alpha and beta releases have an additional suffix of the form a2 or b1.
-For example, Tk 3.3b1 is the first beta release of Tk version 3.3,
-Tk 3.3b2 is the second beta release, and so on. A beta release is an
-initial version of a new release, used to fix bugs and bad features
-before declaring the release stable. An alpha release is like a beta
-release, except it's likely to need even more work before it's "ready
-for prime time". New releases are normally preceded by one or more
-alpha and beta releases. We hope that lots of people will try out
-the alpha and beta releases and report problems. We'll make new alpha/
-beta releases to fix the problems, until eventually there is a beta
-release that appears to be stable. Once this occurs we'll make the
-final release.
-
-We can't promise to maintain compatibility among alpha and beta releases.
-For example, release 4.1b2 may not be backward compatible with 4.1b1, even
-though the final 4.1 release will be backward compatible with 4.0. This
-allows us to change new features as we find problems during beta testing.
-We'll try to minimize incompatibilities between beta releases, but if a
-major problem turns up then we'll fix it even if it introduces an
-incompatibility. Once the official release is made then there won't
-be any more incompatibilities until the next release with a new major
-version number.
-
-Patch releases used to have a suffix such as p1 or p2. Now we use
-a 3-part version number: major.minor.patchlevel. (e.g., 8.0.3)
-These releases contain bug fixes only. A patch release (e.g Tk 4.1p2)
-should be completely compatible with the base release from which it is
-derived (e.g. Tk 4.1), and you should normally use the highest available
-patch release.
diff --git a/bitmaps/error.bmp b/bitmaps/error.bmp
deleted file mode 100644
index 5a1331f..0000000
--- a/bitmaps/error.bmp
+++ /dev/null
@@ -1,8 +0,0 @@
-#define error_width 17
-#define error_height 17
-static unsigned char error_bits[] = {
- 0xf0, 0x0f, 0x00, 0x58, 0x15, 0x00, 0xac, 0x2a, 0x00, 0x16, 0x50, 0x00,
- 0x2b, 0xa0, 0x00, 0x55, 0x40, 0x01, 0xa3, 0xc0, 0x00, 0x45, 0x41, 0x01,
- 0x83, 0xc2, 0x00, 0x05, 0x45, 0x01, 0x03, 0xca, 0x00, 0x05, 0x74, 0x01,
- 0x0a, 0xa8, 0x00, 0x14, 0x58, 0x00, 0xe8, 0x2f, 0x00, 0x50, 0x15, 0x00,
- 0xa0, 0x0a, 0x00};
diff --git a/bitmaps/gray12.bmp b/bitmaps/gray12.bmp
deleted file mode 100644
index a0eafa1..0000000
--- a/bitmaps/gray12.bmp
+++ /dev/null
@@ -1,6 +0,0 @@
-#define gray12_width 16
-#define gray12_height 16
-static unsigned char gray12_bits[] = {
- 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x22, 0x22,
- 0x00, 0x00, 0x88, 0x88, 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, 0x88, 0x88,
- 0x00, 0x00, 0x22, 0x22, 0x00, 0x00, 0x88, 0x88};
diff --git a/bitmaps/gray25.bmp b/bitmaps/gray25.bmp
deleted file mode 100644
index fdaef49..0000000
--- a/bitmaps/gray25.bmp
+++ /dev/null
@@ -1,6 +0,0 @@
-#define gray25_width 16
-#define gray25_height 16
-static unsigned char gray25_bits[] = {
- 0x88, 0x88, 0x22, 0x22, 0x88, 0x88, 0x22, 0x22, 0x88, 0x88, 0x22, 0x22,
- 0x88, 0x88, 0x22, 0x22, 0x88, 0x88, 0x22, 0x22, 0x88, 0x88, 0x22, 0x22,
- 0x88, 0x88, 0x22, 0x22, 0x88, 0x88, 0x22, 0x22};
diff --git a/bitmaps/gray50.bmp b/bitmaps/gray50.bmp
deleted file mode 100644
index 1f9fbc0..0000000
--- a/bitmaps/gray50.bmp
+++ /dev/null
@@ -1,6 +0,0 @@
-#define gray50_width 16
-#define gray50_height 16
-static unsigned char gray50_bits[] = {
- 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa,
- 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa,
- 0x55, 0x55, 0xaa, 0xaa, 0x55, 0x55, 0xaa, 0xaa};
diff --git a/bitmaps/gray75.bmp b/bitmaps/gray75.bmp
deleted file mode 100644
index f700b2c..0000000
--- a/bitmaps/gray75.bmp
+++ /dev/null
@@ -1,6 +0,0 @@
-#define gray75_width 16
-#define gray75_height 16
-static unsigned char gray75_bits[] = {
- 0x77, 0x77, 0xdd, 0xdd, 0x77, 0x77, 0xdd, 0xdd, 0x77, 0x77, 0xdd, 0xdd,
- 0x77, 0x77, 0xdd, 0xdd, 0x77, 0x77, 0xdd, 0xdd, 0x77, 0x77, 0xdd, 0xdd,
- 0x77, 0x77, 0xdd, 0xdd, 0x77, 0x77, 0xdd, 0xdd};
diff --git a/bitmaps/hourglass.bmp b/bitmaps/hourglass.bmp
deleted file mode 100644
index bb1d8ad..0000000
--- a/bitmaps/hourglass.bmp
+++ /dev/null
@@ -1,9 +0,0 @@
-#define hourglass_width 19
-#define hourglass_height 21
-static unsigned char hourglass_bits[] = {
- 0xff, 0xff, 0x07, 0x55, 0x55, 0x05, 0xa2, 0x2a, 0x03, 0x66, 0x15, 0x01,
- 0xa2, 0x2a, 0x03, 0x66, 0x15, 0x01, 0xc2, 0x0a, 0x03, 0x46, 0x05, 0x01,
- 0x82, 0x0a, 0x03, 0x06, 0x05, 0x01, 0x02, 0x03, 0x03, 0x86, 0x05, 0x01,
- 0xc2, 0x0a, 0x03, 0x66, 0x15, 0x01, 0xa2, 0x2a, 0x03, 0x66, 0x15, 0x01,
- 0xa2, 0x2a, 0x03, 0x66, 0x15, 0x01, 0xa2, 0x2a, 0x03, 0xff, 0xff, 0x07,
- 0xab, 0xaa, 0x02};
diff --git a/bitmaps/info.bmp b/bitmaps/info.bmp
deleted file mode 100644
index 801476e..0000000
--- a/bitmaps/info.bmp
+++ /dev/null
@@ -1,5 +0,0 @@
-#define info_width 8
-#define info_height 21
-static unsigned char info_bits[] = {
- 0x3c, 0x2a, 0x16, 0x2a, 0x14, 0x00, 0x00, 0x3f, 0x15, 0x2e, 0x14, 0x2c,
- 0x14, 0x2c, 0x14, 0x2c, 0x14, 0x2c, 0xd7, 0xab, 0x55};
diff --git a/bitmaps/questhead.bmp b/bitmaps/questhead.bmp
deleted file mode 100644
index 17b2929..0000000
--- a/bitmaps/questhead.bmp
+++ /dev/null
@@ -1,9 +0,0 @@
-#define questhead_width 20
-#define questhead_height 22
-static unsigned char questhead_bits[] = {
- 0xf8, 0x1f, 0x00, 0xac, 0x2a, 0x00, 0x56, 0x55, 0x00, 0xeb, 0xaf, 0x00,
- 0xf5, 0x5f, 0x01, 0xfb, 0xbf, 0x00, 0x75, 0x5d, 0x01, 0xfb, 0xbe, 0x02,
- 0x75, 0x5d, 0x05, 0xab, 0xbe, 0x0a, 0x55, 0x5f, 0x07, 0xab, 0xaf, 0x00,
- 0xd6, 0x57, 0x01, 0xac, 0xab, 0x00, 0xd8, 0x57, 0x00, 0xb0, 0xaa, 0x00,
- 0x50, 0x55, 0x00, 0xb0, 0x0b, 0x00, 0xd0, 0x17, 0x00, 0xb0, 0x0b, 0x00,
- 0x58, 0x15, 0x00, 0xa8, 0x2a, 0x00};
diff --git a/bitmaps/question.bmp b/bitmaps/question.bmp
deleted file mode 100644
index ceba2ab..0000000
--- a/bitmaps/question.bmp
+++ /dev/null
@@ -1,10 +0,0 @@
-#define question_width 17
-#define question_height 27
-static unsigned char question_bits[] = {
- 0xf0, 0x0f, 0x00, 0x58, 0x15, 0x00, 0xac, 0x2a, 0x00, 0x56, 0x55, 0x00,
- 0x2b, 0xa8, 0x00, 0x15, 0x50, 0x01, 0x0b, 0xa0, 0x00, 0x05, 0x60, 0x01,
- 0x0b, 0xa0, 0x00, 0x05, 0x60, 0x01, 0x0b, 0xb0, 0x00, 0x00, 0x58, 0x01,
- 0x00, 0xaf, 0x00, 0x80, 0x55, 0x00, 0xc0, 0x2a, 0x00, 0x40, 0x15, 0x00,
- 0xc0, 0x02, 0x00, 0x40, 0x01, 0x00, 0xc0, 0x02, 0x00, 0x40, 0x01, 0x00,
- 0xc0, 0x02, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0xc0, 0x02, 0x00,
- 0x40, 0x01, 0x00, 0xc0, 0x02, 0x00, 0x00, 0x01, 0x00};
diff --git a/bitmaps/warning.bmp b/bitmaps/warning.bmp
deleted file mode 100644
index 7925440..0000000
--- a/bitmaps/warning.bmp
+++ /dev/null
@@ -1,5 +0,0 @@
-#define warning_width 6
-#define warning_height 19
-static unsigned char warning_bits[] = {
- 0x0c, 0x16, 0x2b, 0x15, 0x2b, 0x15, 0x2b, 0x16, 0x0a, 0x16, 0x0a, 0x16,
- 0x0a, 0x00, 0x00, 0x1e, 0x0a, 0x16, 0x0a};
diff --git a/changes b/changes
deleted file mode 100644
index 508f128..0000000
--- a/changes
+++ /dev/null
@@ -1,4252 +0,0 @@
-This file summarizes all changes made to Tk since version 1.0 was
-released on March 13, 1991. Changes that aren't backward compatible
-are marked specially.
-
-RCS: @(#) $Id: changes,v 1.21 1998/09/14 18:22:44 stanton Exp $
-
-3/16/91 (bug fix) Modified tkWindow.c to remove Tk's Tcl commands from
-the interpreter when the main window is deleted (otherwise there will
-be dangling pointers to the non-existent window).
-
-3/16/91 (bug fix) Modified tkColor.c not to free black or white colors:
-some X servers get upset at this.
-
-3/18/91 (bug fix) Modified tkShare.c to fix bug causing "DeleteGroup
-couldn't find group on shareList" panic.
-
-3/18/91 (bug fix) Several changes to tkListbox.c and tkScrollbar.c to
-handle listboxes (and scrollbars) with zero total entries in them.
-
-3/22/91 (bug fix) Fixed a few ='s in tkListbox.c that should be ==.
-
-3/22/91 (bug fix) Fixed error in main.c that caused BadWindow errors
-in some cases where wish scripts invoke "destroy .".
-
-3/23/91 (new feature) Added Tk_CancelIdleCall to remove Tk_DoWhenIdle
-handler.
-
-3/23/91 (bug fix and new feature) Added -name option to main.c, made
-it more clever about choosing name (was always using the name "wish"
-on most Unix systems).
-
-3/23/91 (new feature) Added TK_CONFIG_STRING option to Tk_ConfigureWidget,
-used it to malloc strings for various widget options that used to be
-Tk_Uid's (e.g. button text, message strings, etc.). Eliminates core
-leaks when values change in continuous non-repeating fashion.
-
-3/29/91 (new feature) Added Tk_Preserve, Tk_Release, and
-Tk_EventuallyFree procedures to help manage widget records and avoid
-premature memory free-ing.
-
-4/4/91 (bug fix) Fixed problem in tkWm.c where top-level window geometry
-wasn't tracking correctly when wm-induced size change also changed window
-position (e.g. menus wouldn't be displayed at the right places).
-
-4/5/91 (new feature) Added "invoke" option to widget command for buttons,
-check buttons, and radio buttons.
-
-4/5/91 (new feature) Added "unpack" option to "pack" command.
-
-4/5/91 (bug fix) Changed tkPack.c to use new Tk_Preserve code and be
-more careful about window deletions that occur while repacking is in
-progress.
-
-4/6/91 (bug fix) Major overhaul of deletion code in all widgets to use
-Tk_Preserve and Tk_Release. Should fix many problems.
-
-4/6/91 (bug fix) Changed "winfo children" to generate correct lists
-when child names have embedded spaces.
-
-4/6/91 (new feature) Added "screenheight" and "screenwidth" options to
-"winfo".
-
-4/18/91 (bug fix) Binding mechanism didn't correctly handle very long
-%-substitutions in commands (e.g. long path names) and caused memory
-to be overwritten. Modified tkBind.c to fix.
-
----------------------- Release 1.1, 4/18/91 -------------------------
-
-4/19/91 (bug fix) Inconsistent ICCCM handling of coordinates of reparented
-windows causes windows to gradually walk south when moved or resized.
-Fixed tkWm.c to patch around the problem.
-
----------------------- Release 1.2, 4/24/91 -------------------------
-
-4/26/91 (new feature) Added -geometry and -display switches to wish.
-Also wrote wish manual entry.
-
-5/3/91 (bug fix) Fixed bug in tkListbox.c that caused garbage to appear
-at right edge of window when strings were to large to fit in window.
-
-5/3/91 (bug fix) Fixed bug in tkListbox.c where topIndex wasn't getting
-updated when elements were deleted: tended to cause errors in
-communication with scrollbars.
-
-5/16/91 (bug fix) Fixed bug in tk3d.c, which caused core dumps when
-consecutive points in a polygon were the same (happened with some
-configurations of radio buttons, for example).
-
-5/16/91 (bug fix) Fixed main.c to allow stdin to be redirected.
-
-6/1/91 (bug fix) Make sure that pointers are never used after being
-freed.
-
-6/15/91 (bug fix) Fixed bug in tkBind.c that caused current binding
-values to not always be printed correctly.
-
-6/15/91 (bug fix) Make sure that interpreters are always unregistered
-when their main windows are deleted, and make wish delete the main
-window before exiting.
-
-8/21/91 (misfeature correction) Automatically set source of window
-position to "user" in "wm geometry" command, unless it has been
-explicitly set to "program".
-
-9/5/91 (bug fix) Modified option code to accept '#' as a comment
-character in .Xdefaults files, in addition to '!'.
-
-9/10/91 (misfeature correction) Changed binding mechanism so that
-numeric %-sequences are output in decimal instead of hex.
-
-9/19/91 (bug fix) Fixed bug in Tk_DoOneEvent(1) where it wasn't
-checking files and X connections properly so it missed events.
-
-10/6/91 (new feature) Reorganized tkBind.c to provide generic "binding
-table" structure, which can be used to create bindings on items in
-canvases as well as windows.
-
-10/6/91 (new feature) Upgraded buttons and menus to use new tracing
-code in Tcl 6.0. Allows radio buttons and check buttons to both set
-and clear themselves when associated variable changes.
-
-10/17/91 (bug fix) Fixed 2 bugs in listboxes: accidentally advanced the
-selection when new entries were inserted in the listbox after the location
-of the selected item(s), and goofed up on redisplay if selected item
-was deleted and then selection was immediately lost.
-
-10/27/91 (bug fix) "pack unpack" wasn't telling Tk that it no longer
-manages window; this led to core dumps in some situations.
-
-10/31/91 (reorganization) Renamed manual entries so that they are no
-more than 14 characters in length.
-
-10/31/91 (reorganization) Changed tk.h and tkInt.h so that tkInt.h
-doesn't needed to be included by tk.h.
-
-11/3/91 (portability improvement) Eliminated use of "class" as a variable
-name, since it's a reserved word in C++.
-
-11/7/91 (reorganization) Many changes to upgrade for Tcl 6.1 including
-use of Tcl hash tables instead of separate "Hash_" module. The "lib"
-subdirectory is no longer needed in Tk.
-
----------------------- Release 1.3, 11/7/91 -------------------------
-
-11/24/91 (bug fix) Fixed bug causing occasional errors if existing bindings
-are modified (FindSequence in tkBind.c forget to set *maskPtr).
-
-11/24/91 (bug fix) Used wrong hash table in Tk_GetColorByValue. Could
-cause new entries to get created unnecessarily.
-
-12/2/91 (bug fix) Changed "bind" code to put backslashes in front of
-special characters (e.g. [ or \) that appear in %-replacements, so that
-they can be parsed cleanly.
-
-12/10/91 (bug fix) Manual entries had first lines that caused "man" program
-to try weird preprocessor. Added blank comment lines to fix problem.
-
-1/2/92 (documentation cleanup) Changed manual entries for Tk_GetBitmap
-and the like to make it more clear that the argument must be a Tk_Uid
-and not a string.
-
-1/2/92 (bug fix) Fixed problem where scrollbars that were very short or
-very narrow (too small to hold both arrows) could cause negative values
-in calls to XClearArea, which crashed some servers.
-
-1/2/92 (bug fix) Fixed bug in TkMeasureChars occurring when maxChars
-is 0. Occasionally affected things like message window geometry.
-
-1/3/92 (new feature) Added procedures Tk_GetJustify, Tk_GetAnchor,
-Tk_GetCapStyle, and Tk_GetJoinStyle, plus support for these things
-in Tk_ConfigureWidget.
-
----------------------- Release 1.4, 1/10/92 -------------------------
-
-1/12/92 (bug fix) TkMenubutton.c wasn't cleaning up mbPtr->varName
-properly during menubutton cleanup if an error occurred during
-menubutton creation.
-
-1/19/92 (bug fix) Fixed off-by-one bug in tkListbox.c that caused
-scrollbars to display a slider that was too large.
-
-2/10/92 (bug fix) Tk_CreateFileHandler didn't correctly handle case
-where new mask was specified for existing handler.
-
-2/13/92 (bug fix) Tk_DeleteAllBindings wasn't correctly removing
-bindings from the pattern table: only did the removal for the
-first pattern in a pattern list.
-
-2/15/92 (new feature) Added procedures Tk_DefineBitmap and
-Tk_SizeOfBitmap. Tk_GetBitmapFromData is now considered obsolete
-and probably shouldn't be used anymore. Tk_GetBitmapFromData
-is now implemented by calling Tk_DefineBitmap and Tk_GetBitmap.
-
-2/15/92 (new feature) Added "curselection" and "select clear" options
-to widget command for listboxes.
-
-2/15/92 (new feature) Added Tk_3DBorderColor procedure.
-
-2/17/92 (relaxed limitations) Changed scrollbars so they no longer limit
-the slider position to lie within the object's range: can scroll off the
-end of an object, if the object permits it. Changed listboxes and
-entries to explicitly prevent viewing off the ends. Also relaxed
-listbox index checks so that out-of-range indices are automatically
-adjust to fit within the listbox range.
-
-2/19/92 (bug fix) tkWindow.c tended to leave half-created windows around
-if a new window's name was found to be in use already. Fixed to clean
-them up.
-
-2/22/92 (new feature) Added -anchor, -bitmap, -height, -textvariable,
--width options to labels, buttons, check buttons, menu buttons, and radio
-buttons. This means that (a) size can be controlled better, (b) bitmaps
-can be displayed in any buttons, (c) the position of the text within the
-button can be controlled, and (d) a button can be made to display the value
-of a variable, continuously updating itself. Also changed -selector option
-so that if it's specified as an empty string then no selector is drawn
-for the button.
-
-2/22/92 (new feature) Changed menus to support bitmaps in menu entries:
-added new -bitmap option for entries.
-
-2/26/92 (bug fix) "after" command, when invoked with just one argument,
-called Tk_Sleep rather than registering a timer handler and looping on
-Tk_DoOneEvent. As a result, it caused the application to become non-
-responsive to X events during the sleep. Changed to use a Tk_DoOneEvent
-loop so that it is responsive.
-
-2/26/92 (bug fix) Tk's main program didn't map the main window until
-after the startup script returned. Changed to map the window as a
-do-when-idle handler, so that scripts can cause the window to be
-mapped immediately with a call to "update" or "after".
-
-2/28/92 (bug fix) "wm withdraw" wasn't working if invoked before window
-was originally mapped: window got mapped anyway. Fixed so that the
-window doesn't get mapped as long as it's withdrawn.
-
-2/29/92 (new feature) Can use "focus none" to clear input focus.
-
-2/29/92 (bug fix) Fixed tkEvent.c to generate SubstructureNotify events
-properly. These weren't being generated previously.
-
-2/29/92 (bug fix) Fixed entries so that newline characters can be properly
-displayed (as `\x0a'). Had to change interface to TkDisplayChars in order
-to do this (added flags argument).
-
-2/29/92 (bug fix) Change Tk not to update size and position of top-level
-windows directly during calls like Tk_ResizeWindow. Instead, wait until
-actual event is received. This makes updates happen at same time as
-callbacks.
-
-3/6/92 (bug fix) TkMenubutton.c was dumping core when a menubutton was
-pressed at a time when there was no associated menu for the button.
-
-3/6/92 (new feature) Added Tk script library directory with official
-Tk initialization file "tk.tcl". Other procedures used by Tk are in
-other files. Tk procedures and variables all have names starting
-with "tk_". Also added Wish startup script "wish.tcl", which sources
-both the Tk and Tcl startup scripts. This means that things like
-auto-loading and abbreviation expansion are now available in wish.
-Added new variables tk_library, tk_priv, and tk_version.
-
-3/6/92 (new feature) It's now possible to set bindings for whole
-classes by using the class name in the bind command. For example,
-"bind Button <Enter> {puts stdout Hi!}" will cause a message to be
-printed whenever any mouse button is entered. Can also use "all"
-to set bindings for all widgets. Widget-specific bindings override
-class bindings which override "all" bindings.
-
-3/6/92 (reorganization) Changed buttons (all flavors) and listboxes to
-eliminate all hard-wired behavior. Instead, default behavior is set
-by class bindings in tk.tcl. Also set up class bindings for menus,
-menubuttons, and entries, which previously had no default behavior at
-all. Scrollbars and scales still have hard-wired behavior that can't
-be overridden.
-
-3/7/92 (look-and-feel change) Changed listboxes and entries and menus
-to use button 2 for scanning instead of button 3. This is more consistent
-with the official Motif use of button 2 for dragging.
-
-3/10/92 (new features) Added more options to "winfo" command: screencells,
-screendepth, screenmmheight, screenmmwidth, and screenvisual.
-
-3/13/92 (bug fix) Event sharing mechanism (tkShare.c) wasn't checking
-to see whether window was mapped before sharing events with it.
-
-3/16/92 (bug fix) Tk_SetInternalBorderWidth was passing wrong window to
-geometry-management procedures, causing core-dumps when menu buttons
-had their border widths changed.
-
-3/16/92 (bug fix) Menus were setting their geometry directory rather
-than using Tk_GeometryRequest mechanism.
-
-3/17/92 (new feature) Added -cursor option to all widgets to set the
-active cursor for the widget. Also added TK_CONFIG_ACTIVE_CURSOR
-configure type.
-
-3/18/92 (new feature) Implemented generalized screen coordinates to
-allow resolution-independent specification in many cases (but pixel-
-based coordinates are still OK). Added Tk_GetScreenMM(),
-Tk_GetPixels(), new configure types TK_CONFIG_SCREEN_MM and
-TK_CONFIG_PIXELS. Changed widgets to use this new configure types
-wherever possible (a few of the more complex cases still haven't
-been taken care of yet). Added "pixels" and "fpixels" options to
-"winfo" command.
-
-3/18/92 (new feature) First cut at canvas widgets is done and part of
-the official Tk now. Canvases display text and structured graphics,
-and allow you to bind commands to events related to the text and
-graphics.
-
-3/21/92 (new feature) Added new "place" command. It implements a
-new geometry manager that provides fixed placement, rubber-sheet
-placement, and combinations of the two. Eliminated the commands
-"move", "resize", and "map" that were provided by main.c but never
-officially supported; the placer provides all of this functionality.
-
-3/23/92 (bug fix) Fixed bug in tkWm.c where top-level windows were
-occasionally not being given the right size. The problem occurred
-when a string of resizes happened all in a row (such as deleting all
-the windows in an application and then recreating them).
-
-3/23/92 (new feature) Added Tk_CoordsToWindow procedure and
-"winfo containing" command. These may be used to locate the window
-containing a given point.
-
-3/28/92 (new feature) Added "-exportselection" option to listboxes,
-so that listbox selection need not necessarily be the X selection.
-
-4/12/92 (bug fix) Changed menu buttons to store name of menubutton
-in the associated variable, rather than the name of the menu. This
-is necessary in order to allow several menu buttons to share the
-same menu.
-*** POTENTIAL INCOMPATIBILITY ***
-
-4/12/92 (bug fix) Fixed core dump that occurred in tkError.c when
-removing the first error record from the error list.
-
-4/15/92 (bug fix) Fixed bug in tkBind.c that prevented <KeyPress-1>
-event specifications from being processed correctly: the "1" was
-treated as a button name rather than a keysym.
-
-4/18/92 (new feature) Added Tk_DefineCursor and Tk_UndefineCursor
-procedures.
-
-4/18/92 (new feature) Major revision to listboxes. Can now scroll and
-scan in both x and y, plus -exportselection option allows selection not
-to be exported. The "view" widget command has been replaced by "xview"
-and "yview", and the "scan" widget command has a new syntax.
-*** POTENTIAL INCOMPATIBILITY ***
-
-4/18/92 (new feature) Added -exportselection option to entries, so you
-can select whether you want the entry selection to be the X selection
-or not.
-
-4/24/92 (new features) Added TK_CONFIG_CUSTOM type to Tk_ConfigureWidget,
-plus added new flags TK_CONFIG_NULL_OK, TK_CONFIG_DONT_SET_DEFAULT,
-and TK_CONFIG_OPTION_SPECIFIED. Several other new types, such as
-TK_CONFIG_CAP_STYLE, were also added as part of implementing canvases.
-
-4/29/92 (bug fix) Changed "-selector" default for menus to have separate
-values for mono and color.
-
-4/30/92 (bug fix) Fixed bug in tkListbox.c where it occasionally generated
-bogus scroll commands (last index less than first).
-
-4/30/92 (reorganization) Moved demos directory to "library/demos".
-
----------------------- Release 2.0, 5/1/92 -------------------------
-
-5/2/92 (bug fix) Fixed problem in tkListbox.c where it was doing too many
-redisplays after repeated insertions. Also reduced number of invocations
-of scrollbar commands.
-
-5/7/92 (portability improvement) Changed main.c not to use TK_EXCEPTION
-flag; it isn't needed and it causes problems on some systems.
-
-5/9/92 (bug fix) Plugged core leaks in tkListbox.c and tkBind.c
-
-5/9/92 (bug fix) TkBind.c was accidentally deleting bindings during
-attempts to print non-existent bindings.
-
-5/11/92 (bug fix) Maximum name length for applications (name used in
-"send" commands) was too short (only 20); increased to 1000. Also
-fixed bug related to over-long names that caused core dumps.
-
-5/13/92 (bug fix) tkShare.c was using a dangling pointer if a share
-group was deleted as a side-effect of a shared event.
-
-5/13/92 (bug fix) Various initialization and core leak problems in
-tkGC.c, tkSend.c, tkMenu.c, tkEvent.c, tkCanvas.c, tkCanvPoly.c,
-tkCanvLine.c, tkListbox.c, tkEntry.c.
-
-5/13/92 (bug fix) Empty entries could be scanned off the left edge,
-displaying a garbage character.
-
-5/13/92 (bug fix) Fixed a few problems with window manager interactions,
-such as tendency for windows to spontaneously shrink in size. By no
-means are all of the problems fixed, though.
-
-5/13/92 (performance optimization) Changed Tk_GeometryRequest not to
-invoke geometry manager unless requested size has changed.
-
----------------------- Release 2.1, 5/14/92 -------------------------
-
-5/1/92 (new features) Added flags like TK_IDLE_EVENTS to Tk_DoWhenIdle,
-plus added "idletasks" option to "update" command. Tk_DoWhenIdle arguments
-look different now, but the change should be upward-compatible.
-
-5/17/92 (new feature/bug fix) Added support for VisibilityNotify events
-to the "bind" command. For some reason they weren't supported previously.
-
-5/17/92 (new feature) Added "tkwait" command.
-
-5/17/92 (new feature) Added "grab" command.
-
-5/17/92 (new feature) Added "-width" option to messages. Also changed
-messages to use the computed (i.e. desired) line length when displaying,
-not the actual width of the window.
-
-5/17/92 (bug fixes) Did some more fiddling with tkWm.c in the hopes
-of improving window manager interactions. Now there won't be more than
-one configure request outstanding to the wm at a time.
-
-5/17/92 (bug fix) Arrowheads on canvas lines weren't being translated
-or scaled correctly.
-
-5/20/92 (bug fix) Page-mode scrolling didn't work correctly for canvases
-(wrong windowUnits was passed to scrollbars).
-
-5/20/92 (bug fix) Changed scrollbars not to lose highlight when pointer
-leaves window with button down. Also changed redisplay to double-buffer
-for smoother redraws.
-
-5/21/92 (new feature) Added "gray50" and "gray25" as predefined bitmaps.
-
-5/22/92 (new feature) Buttons can now be disabled using the "-state" and
-"-disabledforeground configuration options. The "activate" and "deactivate"
-widget commands for buttons are now obsolete and will go away soon.
-Please change Tcl scripts not to use them.
-
-5/23/92 (new feature) Entries can now be disabled using the "-state"
-config option. Also improved class bindings for entries to keep the
-cursor visible in the window when operations occur. Also made slight
-improvements in the way redisplay is done.
-
-5/23/92 (new feature) Added "-textvariable" option to entries so that
-the text in an entry can be tied to the value of a global variable in
-a fashion similar to buttons.
-
-5/27/92 (new feature) Added "-textvariable" and "-anchor" options to
-messages.
-
-5/28/92 (new feature) Added "-padx" and "-pady" and "-underline" options
-to menubuttons.
-
-5/28/92 (feature change) Changed "-width" and "-height" options on
-all flavors of buttons and menubuttons so that they are orthogonal
-to "-padx" and "-pady". It used to be that -width overrode -padx
-(no padding). Now they accumulate.
-
-5/29/92 (new feature) Added "-disabledforeground" option to menus and
-all flavors of buttons (can specify color for disabled things rather
-than just using stipple to gray out).
-
-5/29/92 (new features) Added many new options to menu entries:
--activebackground, -background, -font, -state, -underline. The
-"disable" and "enable" widget commands for menus are now obsolete
-and will go away soon. Please change Tcl scripts not to use them.
-
-5/29/92 (new features) Added "atom" and "atomname" options to "winfo"
-command.
-
-5/29/92 (new feature) Wrote tk_listboxSingleSelect procedure, which
-can be used to change listbox behavior so that only a single item is
-selected at once.
-
-6/1/92 (new feature) Added new modifier names "Meta" and "Alt" for
-"bind" command.
-
-6/3/92 (new feature) Added "winfo toplevel" command.
-
-6/3/92 (new feature) Made several changes for greater Motif compliance,
-including:
- - menu retention if you click and release in the menu button,
- - keyboard traversal of menus (see traversal.man)
- - no widget flashing if you set $tk_strictMotif to 1
-
-6/15/92 (bug fix) Fixed problem in tkBind.c where command string for a
-binding could get reallocated while the command was being executed (e.g.
-bindings that delete or change themselves).
-
-6/15/92 (bug fix) Don't allow "tabWidth" field to become zero in tkFont.c:
-can cause core dumps for fonts that don't enough information to compute
-tab widths.
-
-6/19/92 (bug fix) Fixed bug in binding mechanism that caused structure-
-related events to be reported both to the correct window and its parent.
-
-7/14/92 (bug fix) Changed tkColor.c not to free colors for visual types
-StaticGray or StaticColor.
-
-7/15/92 (new feature) Text widgets now exist. They display any number of
-lines of text with a variety of display formats, and include hypertext
-facilities. See the manual page for details.
-
-7/20/92 (bug fix) If a top-level window was put in the iconic state to
-begin with, it could be deiconified with "wm deiconify .foo" until it had
-first been deiconified by hand from the window manager. Tk was getting
-confused and thought the window was mapped when it wasn't.
-
-7/29/92 (bug fix) Don't permit rectangles or ovals to have zero-sized
-dimensions. Round up to at least one pixel.
-
-7/29/92 (new features) Major upgrade to canvases:
- - new item types: arc, window, bitmap
- - added Bezier spline support for lines and polygons
- - rectangles and ovals now center their outlines on the shape,
- rather than drawing them entirely inside the shape
- - new "coords" and "bbox" widget commands
- - new "-tags" option for all item types.
- - new "-confine" option to prevent scrolling off edge of canvas.
-
-8/6/92 (new feature) Added "-width" and "-height" options to frames.
-The "-geometry" option is now obsolete and should be removed from Tcl
-scripts: it may go away in the future.
-
-8/7/92 (bug fix) Error messages in Tk_ParseArgv were sometimes including
-the option name where they should have included its value.
-
----------------------- Release 2.2, 8/7/92 -------------------------
-
-8/7/92 (bug fix) Changed tkCanvas.c to be more conservative in the area
-it passes to XCopyArea.
-
-8/8/92 (bug fix) Fixed bug in tkTextDisp.c that sometimes caused core
-dumps when text views changed (e.g. typing return on last line of screen).
-
-8/8/92 (bug fix) Fixed bug in menu.tcl that caused errors when using
-keyboard to traverse over separator menu entries.
-
-8/10/92 (bug fix) Changed to use OPEN_MAX instead of MAX_FD to compute
-maximum # of open files.
-
-8/10/92 (bug fix) Canvases weren't updating scrollbars on window size
-changes. They also weren't recentering canvases on window size changes.
-
-8/10/92 (bug fix) There were still a few places where commands were being
-invoked at local level instead of global level (e.g. commands associated
-with buttons and menu entries).
-
-8/10/92 (bug fix) TkBind.c used to ignore explicit shift modifiers for
-all keys (i.e. <Shift-Tab> was treated the same as <Tab>). Modified to
-allow explicit request for shift modifier, like <Shift-Tab>.
-
-8/13/92 (feature change) Changed default fonts to request "Adobe" fonts
-explicitly.
-
-8/16/92 (bug fixes) Modified tkCanvArc.c and tkTrig.c to increase slightly
-the bounding boxes for arcs, in order to make sure that proper redisplay
-occurs when arcs are moved (little turds were getting left behind).
-
-8/16/92 (bug fix) Modified tkCanvas.c not to redraw at all if the redisplay
-area is off the screen. Also, only do a background clear for the portion
-of the redraw area that is on-screen. Also, reduced size of off-screen
-pixmaps used for redisplaying, which speeds up redisplay in some cases.
-
-8/19/92 (bug fix) Canvases that were taller than wide were not being
-redisplayed properly.
-
-8/20/92 (new feature) Added Tk_CreateGenericHandler procedure for trapping
-all X events (useful for tracing, watching non-Tk windows, etc.).
-
-8/21/92 (bug fix) Widgets weren't always being notified when they got
-the focus back again (the problem had to do with grabs and menus in
-particular).
-
-8/21/92 (new feature) Added "-state" option to scale widgets.
-
-8/22/92 (new feature) Changed tkBitmap.c to allow tilde-substitution
-to occur in bitmap file names.
-
----------------------- Release 2.3, 8/24/92 -------------------------
-
-8/27/92 (bug fix) Changes to -activebackground and -activeforeground options
-for menubuttons were being lost.
-
-8/27/92 (bug fix) Entries were selecting last character when a B1-drag
-occurred past the right edge of the text.
-
-8/28/92 (bug fix) Fixed bug in canvases where a grab during a button
-press caused the canvas state to lock up so that it didn't select a
-new current item.
-
-9/7/92 (bug fix) Changed tkMenu.c to accept numerical menu indices that
-are out of range; now it just rounds them off to the nearest existing
-entry.
-
-9/7/92 (bug fix) Fixed bug in tkTextDisp.c that caused core dumps when
-invoking "yview -pickplace" widget command on texts that are too small
-to hold any lines at all.
-
-9/11/92 (bug fix) Fixed bug in tkTextDisp.c that caused core dumps
-when adding tags to non-existent lines.
-
-9/11/92 (bug fix) Line items in canvases didn't permit an empty fill
-color (i.e. couldn't make them transparent).
-
-9/14/92 (reorganization) Changed manual entries to use .1, .3, and .n
-extensions. Added "install" target to Makefile to suggest how Tk should
-be installed.
-
-9/16/92 (bug fix) Changed tkSend.c to always specify the root window of
-screen 0 rather than using DefaultRootWindow. DefaultRootWindow doesn't
-always go to screen 0 on displays with multiple screens, which can result
-in send's not being possible between the screens.
-
-9/18/92 (new feature) Added three new options to "wm" command: "protocol",
-"client", and "command". These provide support for window manager protocols
-such as WM_DELETE_WINDOW and WM_TAKE_FOCUS, plus support for the
-WM_CLIENT_MACHINE and WM_COMMAND properties.
-
-9/30/92 (new feature) Implemented color model support, including
-"tk colormodel" command and Tk_GetColorModel and Tk_SetColorModel
-procedures. These allow you to force mono operation even on a color
-display. Also changed color allocation not to give errors when colors
-run out, but just to switch to a mono color model.
-
-10/1/92 (bug fixes) Fixed two bugs in tkTextBTree.c that caused core dumps
-during text deletion.
-
-10/5/92 (bug work-around) Changed tkColor.c to ignore errors when freeing
-colors. This is needed to work around improper reference count management
-for colormap entries under X11/NeWS.
-
-10/7/92 (new feature) Added support for different visual types, including
-procedures Tk_SetWindowVisual and Tk_SetWindowColormap, plus macros
-Tk_Visual, Tk_Depth, and Tk_Colormap. The code for this was contributed
-by Paul Mackerras.
-
-10/7/92 (new feature) Added Tk_IsTopLevel macro.
-
-10/12/92 (bug fix) Fixed bug in tk.tcl that caused torn-off menus with
-cascaded children not to track mouse motion correctly (the cascade
-switched in response to mouse motions within the cascaded child).
-
-10/12/92 (new feature) Major changes to focus handling:
-(a) Tk watches FocusIn and FocusOut events for focus changes, not Enter
- and Leave, so it will work better with explicit-focus-model window
- managers (e.g. mwm in default mode).
-(b) Tk generates FocusIn and FocusOut events for the focus window now.
- The old procedural interface (via Tk_CreateFocusHandler) is obsolete
- and is no longer used inside Tk. It is still supported for
- compatibility, but won't be for long. You should change your code
- to use FocusIn and FocusOut events instead.
-(c) The model for FocusIn and FocusOut events is different than the
- one described in Xlib documentation. See the "focus" manual entry
- for details.
-(d) If there is no input focus then keyboard events are discarded. They
- used to be directed to the mouse pointer window, although this wasn't
- documented. The focus now defaults to the root window.
-*** POTENTIAL INCOMPATIBILITY ***
-
-10/15/92 (bug fix) Fixed text items in canvases where they didn't
-display the insertion cursor if the item had no characters in it.
-
-10/26/92 (bug fix) Fixed bug in tkSelect.c that occasionally caused
-BadWindow X protocol errors when retrieving the selection. Tk wasn't
-making sure that a window existed before using it to retrieve the
-selection.
-
-10/30/92 (feature change) Changed canvases so that if the scroll region
-is smaller than the window and -confine is on, the scroll region isn't
-forced to be centered in the window; it can be anywhere that meets the
-confinement restrictions.
-
-11/2/92 (new feature) Added "winfo exists" command.
-
-11/5/92 (new feature) Changed DoWhenIdle handlers so that if a new
-when-idle handler is created as a side-effect of another when-idle
-handler, the new handler isn't invoked until Tk has first checked
-for other events to process.
-
-11/6/92 (bug fixes, new features) Major overhaul of window manager
-interface:
-(a) Tk should now work with virtual-root window managers;
-(b) windows will now place more accurately on the screen and stay where
- they're supposed to;
-(c) size changes handled more reliably;
-(d) code now works robustly in the face of withdrawals followed
- immediately by deiconifications.
-(e) Added new procedure Tk_GetVRootInfo and new options to "winfo" command:
- vrootx, vrooty, vrootwidth, vrootheight.
-(f) Added "overrideredirect" option to "wm".
-(g) Fixed bug where change in width-only via "wm geom" didn't always work
- (min and max window sizes weren't being set properly for the wm).
-
-11/6/92 (bug fixes) Modified menus so that they work correctly with
-virtual root window managers. Also fixed bug where menus didn't move
-along with their associated windows, so that the menu popped up at
-the old location of the window rather than its new location.
-
-11/9/92 (new constraint) Made it illegal to give windows names that
-start with upper-case letters, since such names will goof up the
-option database by appearing to be classes rather than names.
-*** POTENTIAL INCOMPATIBILITY ***
-
-11/10/92 (new feature) Added Postscript output to canvases.
-
-11/13/92 (bug fix) Changed default for maximum size passed to window
-manager from 1000000 (which causes some wm's to make windows too large
-when "maximized") to the size of the display.
-
-11/14/92 (feature change) Major overhaul of menubuttons and pull-down
-menus. Removed event-sharing code, including Tk_ShareEvents and
-Tk_UnshareEvents. The -variable option for menubuttons has been
-removed,and the "post" and "unpost" widget commands for menubuttons
-no longer exist. The "post" widget command for menus no longer
-allows a group option. The procedure tk_menus has been replaced
-with a new procedure, tk_menuBar, which has a slightly different
-interface.
-*** POTENTIAL INCOMPATIBILITY ***
-
-11/20/92 (new features, feature changes) Major overhaul of grab
-mechanism to produce more correct event streams. Also changed Tcl
-commands to require explicit window for grab releases (makes it
-possible for grabs to work on multiple displays simultaneously).
-The old "grab none" command no longer exists, but new options
-have been added: "current", "release", "set", and "status".
-*** POTENTIAL INCOMPATIBILITY ***
-
-11/20/92 (new feature) Use TK_LIBRARY environment variable to set library
-directory location, if it is defined. Otherwise fall back on usual
-compiled-in value.
-
-11/25/92 (bug fix) "wm grid" command was using wrong window.
-
-11/29/92 (bug fix) Fixed core dump that occurred when trying to use
-placer on top-level windows: return error instead.
-
-11/29/92 (bug fix) Selection retrieval wasn't making sure that the window
-on whose behalf selection is being retrieved actually exists.
-
-12/3/92 (new feature) Added support for Mode_switch key to support the
-full ISO character set. Also added event handlers for MappingNotify
-events so that Tk updates itself in response to keycode and modifier
-changes.
-
-12/6/92 (bug fix) Ignore recursive attempts to destroy window.
-
-12/9/92 (new demos) Added "tcolor" and "rmt" demos.
-
-12/10/92 (new features) Added "yposition" widget command for menus,
-changed "delete" widget command to take an optional second index,
-and changed -command option for cascade entries so that it is
-invoked when the entry is activated rather than when it is invoked.
-*** POTENTIAL INCOMPATIBILITY ***
-
-12/12/92 (implementation change) Changed the procedures Tk_FreeBitmap,
-Tk_NameOfBitmap, Tk_SizeOfBitmap, Tk_FreeCursor, Tk_NameOfCursor, and
-Tk_FreeGC to require an addition Display argument. This is needed for
-Tk to function correctly when an application has windows on multiple
-displays.
-*** POTENTIAL INCOMPATIBILITY ***
-
-12/12/92 (new feature) Started creating a test suite. Right now it
-only has a few tests.
-
-12/12/92 (new feature) Modified the packer so that a window can be
-packed in descendants of its parent (used to be restricted to the
-parent alone). This makes it possible to hide extra windows used
-for geometry management. Also, can use generalized screen distances
-in the "pack" command.
-
-12/16/92 (feature change) Boolean options such as -exportselection now
-print as 0/1 rather than true/false (both the default and current values
-print this way). This makes it easier to use these values in expressions.
-*** POTENTIAL INCOMPATIBILITY ***
-
-12/16/92 (name change) The classes "RadioButton" and "CheckButton" have
-been renamed "Radiobutton" and "Checkbutton" for consistency. From now
-on widget class names will have exactly one capital letter.
-*** POTENTIAL INCOMPATIBILITY ***
-
-12/16/92 (new feature) Added -setgrid option to listboxes.
-
-12/16/92 (new feature) The "destroy" command, and the "delete" widget
-command for canvases, now accept any number of arguments, including
-zero.
-
-12/16/92 (new feature) Changed internal TkBindError procedure to
-Tk_BackgroundError and exported it to Tk clients.
-
-12/16/92 (option name change) Changed the place command's "dependents"
-option to "slaves" for better consistency with documentation.
-*** POTENTIAL INCOMPATIBILITY ***
-
-12/16/92 (name changes) Renamed the "cursor*" options in entries and
-canvases to "insert*". Also renamed the "cursor" index to "insert" and
-the "cursor" widget command to "icursor". This was done to avoid
-confusion between the mouse cursor and the insertion cursor.
-*** POTENTIAL INCOMPATIBILITY ***
-
----------------------- Release 3.0, 12/17/92 -------------------------
-
-12/17/92 (bug fix) Fixed dangling-pointer bug in canvases that occurred
-if a <LeaveNotify> binding deleted the current item.
-
-12/18/92 (bug fix) Core dump occurred if "wm" invoked with no arguments.
-Also, tkWm.c wasn't properly setting WM_CLASS property on application
-startup.
-
-12/18/92 (incorrect documentation) Updated manual entries for Tk_FreeGC,
-Tk_FreeCursor, and Tk_FreeBitmap to reflect new interface that requires
-"display" argument.
-
-12/18/92 (missing documentation) Added documentation for the canvas
-"postscript" command, which was missing in the 3.0 release.
-
-12/21/92 (bug fixes) There were lots of problems with the new installation
-targets in the Makefiles, such as using "cp -f" and not installing
-prolog.ps. Made several other miscellaneous improvements to Makefile.
-
-12/21/92 (bug fix) Arrowheads on canvas line items weren't moving properly
-after coordinate changes made with the "coords" widget command.
-
-12/21/92 (bug fix) If top-level window was initially withdrawn, couldn't
-ever deiconify it again.
-
-12/21/92 (bug fix) Double-button event sequences didn't always trigger
-properly when grabs were in effect.
-
-12/22/92 (bug fix) The packer didn't display any top or bottom windows
-after a left or right expanded window, and vice versa. Also made the
-distribution of space among expanded windows more even.
-
-12/28/92 (new features) Several improvements to selection:
-(a) Added procedures Tk_ClearSelection and Tk_DeleteSelHandler.
-(b) Added "clear" and "own" options to "selection" command, extended
- "handle" option to delete handlers.
-(c) Error returns from "selection handle" scripts are now turned into
- selection retrieval errors ("no such selection") rather than an
- empty selection.
-(d) Tk responds automatically for targets APPLICATION (name of application,
- so you can "send" to it) and WINDOW_NAME (name of window within
- application.
-(e) Added test file "select.test" to test suite.
-
-12/28/92 (bug fix) Fixed problem with flashing menus that occurred
-because menu.tcl was willing to unpost and then immediately repost
-the same menu.
-
-1/6/93 (bug fix) Test for UnmapNotify events in tkPack.c used = instead
-of ==.
-
-1/21/93 (bug fix) Changed many widgets to eliminate use of
-DefaultVisualofScreen, DefaultColormap, etc. and use the visuals
-and colormaps for the actual windows instead. Also changed to
-inherit colormaps and windows from parent by default.
-
-1/21/93 (new features) Added new winfo options "cells", "depth", and
-"visual".
-
-1/23/93 (bug fix) Fixed problem with text display that could result
-in negative XCopyArea heights being sent to X server. This causes some
-servers (e.g. some versions of OpenWindows) to crash.
-
-1/25/93 (new feature) Added -postcommand option to menus, so that menus
-can be reconfigured before each posting.
-
-1/29/93 (feature change) Changed %X and %Y in bindings so that they
-refer to the virtual root rather than the true root. Although
-potentially incompatible, this change should almost always "do the
-right thing".
-*** POTENTIAL INCOMPATIBILITY ***
-
-1/31/93 (bug fix) Changed "send" code to grab server while updating
-the registry property (before this fix, two programs could allocate
-the same interpreter name if they started up simultaneously). In
-order to make this fix I had to change the code for reclaiming
-names of dead interpreters in a way that sometimes allows dead
-interpreters to persist in the registry.
-
-2/1/93 (feature change) Changed entries to allow leftmost "visible"
-character to be the end of the text (i.e. no characters actually visible).
-This is needed so that the cursor can be displayed even if the last
-actual character is too wide to fit in the window.
-
-2/3/93 (bug fix) Fixed two bugs in tkFocus.c: (a) FocusIn events
-were getting lost in some cases because the focus window hadn't been
-created yet (e.g. new top-level window pops up underneath the mouse);
-(b) Tk was accidentally triggering FocusOut events when the mouse
-moved from a top-level window to one of its children.
-
-2/4/93 (new feature) Added "visibility" option to "tkwait" command to make
-it easier to wait for a new window to appear on the screen.
-
----------------------- Release 3.1, 2/5/93 -------------------------
-
-2/10/93 (installation improvements) Makefile improvements: added RANLIB
-variable for easier Sys-V installation, changed to use INCLUDE_DIR
-properly, and added SHELL variable for SGI systems.
-
----------------------- Release 3.2, 2/11/93 -------------------------
-
-2/11/93 (new feature) Added "wm state" command, and improved wm so that
-the right thing will happen if you invoke "wm iconify" when a window is
-withdrawn.
-
-2/14/93 (bug fix) When -colormap option was used in generating Postscript
-for canvases, Tk didn't add an extra space after the color command.
-
-2/14/93 (new feature) Changed "extern" declarations in tk.h to "EXTERN",
-which will use the definition of EXTERN from tcl.h and work correctly
-in C++ programs.
-
-2/18/93 (bug fix) Item-specific bindings weren't getting deleted from
-canvas items when the items were deleted. As a result, they could
-suddenly re-appear for new items if the new items were allocated a
-record at the same addresses as the old ones.
-
-2/18/93 (feature reversal) Changed "after" back again, so that it sleeps
-*without* responding to events when it is invoked with just one argument;
-can always use tkwait plus after with additional arguments to achieve
-the effect of responding to events.
-*** POTENTIAL INCOMPATIBILITY ***
-
-2/20/93 (bug fix) Fixed bug in tkWindow.c where colormaps weren't being
-set correctly for new top-level windows on different screens than their
-parents (the bug results in X protocol errors: "invalid Colormap
-parameter").
-
-2/22/93 (bug fix) Changed "#!/usr/local/wish" in demo scripts to
-"#!/usr/local/bin/wish" to reflect new location of binary.
-
-2/22/93 (new feature) Added new reliefs "groove" and "ridge".
-
-2/25/93 (new feature) Added new built-in bitmaps: "error", "hourglass",
-"info", "question", "questhead", and "warning". Also added new demo in
-"widget" to display all of these (under the Miscellaneous menu).
-
-2/25/93 (improved implementation) Changed DrawText procedure in
-prolog for outputting Postscript from canvases to use stringwidth
-instead of charpath+pathbbox: avoids limitcheck problems with long
-strings, and also properly includes space characters in calculation.
-
-2/25/93 (bug fix) Fixed several bugs in library/menu.tcl that caused
-menu traversal to mis-behave when menu had no entries.
-
-2/26/93 (new feature) Added "wm frame" command.
-
-3/6/93 (bug fix) Mwm in click-to-focus mode was goofing up grabs so that
-pull-down menus were sometimes unresponsive. Modified tk.tcl to ignore
-the spurious B1-Enter events generated by mwm, plus modified tkGrab.c to
-release simulated button grabs correctly.
-
-3/8/93 (bug fix) Tk had wrong interpretation of "lbearing" font metric,
-which caused text to be displayed at the wrong horizontal position in
-several places (labels/buttons, listboxes, canvas text, scales). This
-change will cause slight changes in the way certain widgets are
-displayed.
-
-3/12/93 (bug fix) Fixed core dumps that occurred in tkEntry.c because of
-zero values in entryPtr->avgWidth.
-
-3/12/93 (bug fix) Tk_CoordsToWindow was using root coordinates always.
-Changed to use virtual-root coordinates when a virtual-root window
-manager is being used. Before this fix, "winfo containing" didn't
-return the correct window under virtual-root window managers.
-
-3/18/93 (bug fix) Modified tkWm.c so that Tk doesn't fight with window
-manager over position of window; it just takes what the window manager
-gives it.
-
-3/21/93 (new feature) Changed menus to display cascade entries with
-standard Motif arrows at right side.a
-
-3/22/93 (bug fix) Fixed bug in tkPack.c that was causing memory to
-get trashed with the integer value 1.
-
-3/22/93 (bug fix) Canvas text didn't print correctly if it contained
-an open paren (or other special character) immediately followed by
-an octal digit.
-
-3/22/93 (bug fix) Text widgets didn't redisplay properly in cases
-where two or more groups of lines both got taller at the same time
-(e.g. from tag changes), causing two separate bit copies where the
-first bit copy's target area overlapped the source area for
-the second bit copy.
-
-4/1/93 (bug fix) Changed canvases to use ISO Latin-1 font encoding
-if that's supported by the Postscript interpreter. Also added workaround
-for bug in NeWSprint related to stipple fills.
-
-4/1/93 (bug fixes) Made various changes to focusing and grabs to
-eliminate extraneous focus events and generally improve behavior.
-
-4/2/93 (bug fix) Modified tkWm.c not to wait indefinitely for the window
-manager to map or reconfigure a window: this led to deadlock in some
-situations, such as creating a new top-level window with a grab held.
-
-4/19/93 (bug fix) Fixed another bug in tkWm.c that caused windows to walk
-across the screen in some situations. Also fixed problem where rapid
-posting and unposting of cascaded submenus (or menus?) could cause Tk
-to become confused about whether or not a window is mapped (added
-TkWmUnmapWindow procedure to make top-level unmaps synchronous).
-
-4/24/93 (feature change) Changed the "after" command to allow times
-less than or equal to 0, and to use 0 whenever they occur.
-
-4/26/93 (new feature) Implemented security check for "send" as proposed
-by Bennett Todd: incoming sends are now rejected unless (a) xhost-style
-access control is enabled and (b) the list of authorized hosts is
-empty. In other words, you have to use xauth to use send. This feature
-can be disabled by setting the TK_NO_SECURITY flag at compile-time.
-
-5/15/93 (improvement) Switched to use Tcl_PrintDouble whenever returning
-real values as Tcl results. This potentially allows higher precision.
-Switched to use %.15g whenever printing reals in Postscript files.
-However, the change Tcl_PrintDouble causes incompatibilities. For
-now, it's disabled with a macro in tclInt.h that redefines Tcl_PrintDouble.
-Tk 4.0 will delete the macro, and you can also delete it now if you
-want the better (but incompatible) behavior.
-
-5/19/93 (bug fix) Fixed divide-by-zero problem that could occur in
-closeness calculations for canvas oval items.
-
-5/30/93 (bug fix) PROP and CONFIG were accidentally #defined to the same
-value in tkBind.c, which could cause incorrect %-substitutions in event
-bindings in a few exotic cases.
-
-6/4/93 (improvement) Changed to use GNU autoconfig for configuration.
-Makefile format changed, and Tcl is no longer automatically included
-in Tk releases.
-
-6/7/93 (bug fix) Fixed off-by-one error in rounding negative coordinates
-during redisplay of canvases.
-
-6/9/93 (feature improvement) Modified default bindings for entries to
-keep one character visible to the left of the cursor during backspaces.
-
-6/18/93 (feature improvement) Added patchlevel.h, for use in coordinating
-future patch releases, and also added tk_patchLevel variable to make the
-patch level available in scripts.
-
-6/26/93 (bug fix) Fixed numeric problems in scales that occurred with
-very large scale values.
-
-6/26/93 (bug fix) Polygon items in canvases could cause core dumps if
-the "coords" widget command was used to add one new coordinate.
-
-6/26/93 (bug fix) Changed canvases to handle large stipple patterns
-gracefully (stipples used to jump around during redisplay and lose
-coherency).
-
-7/1/93 (syntax change, new feature) Implemented the new packer syntax
-as described in the book. For now the old syntax will continue to be
-supported too. Converting over is straightforward except (a) use
-"-anchor" instead of "frame", and (b) padding is different (separate
-internal and external padding, plus pad amounts are *on each side*
-instead of total). Also added "pack propagate" command for keeping
-the packer from setting the master's requested size.
-
-7/1/93 Changed copyright notices. The effect is the same as with the
-old notices, but the new notices more clearly disclaim liability.
-
-7/7/93 (new feature) Added support for window stacking order. Windows
-will now stack in the order created (most recent on top), plus "raise"
-and "lower" commands may be used to restack (Tk_RestackWindow procedure
-is available from C level).
-
-7/7/93 (reorganization) Moved main.c to tkMain.c, reorganized it to
-call Tcl_AppInit just like tclsh does, and added argv0 variable to contain
-application name, and added default Tcl_AppInit procedure for wish.
-Also added tkTest.c to hold C code for testing.
-
-7/7/93 (new feature) Added new Tk-specific "exit" command, which cleans
-up properly before exiting. It replaces the Tcl "exit" command, and
-can be used in place of "destroy .".
-
-7/9/93 (new features) Added tk_dialog library procedure that creates
-dialogs with a bitmap, message, and any number of buttons. Also changed
-default tkerror procedure to use tk_dialog plus offer the user a chance
-to see a Tcl stack trace.
-
--------------------- Release 3.3 Beta 1, 7/9/93 -------------------------
-
-7/12/93 (configuration changes) Eliminated leading blank line in
-configure script; provided separate targets in Makefile for installing
-binary and non-binary information; fixed -lnsl and -lsocket handling
-in configure; added autoconf support for fd_set type; check for various
-typedefs like mode_t and size_t, and provide substitutes if they
-don't exist; don't include tkAppInit.o in libtk.a; try to locate the
-X includes and library in all of the standard places for various systems.
-
-7/14/93 (new feature) Modified tkMain.c so that it stores the value
-of the -display command-line option into the DISPLAY environment
-variable, if it is specified.
-
-7/15/93 (feature removal) Removed auto-initialization feature from
-Tk_ConfigureWidget, so that you must once again initialize all fields
-of a widget record before calling Tk_ConfigureWidget. This restores
-the behavior back to what it was in Tk 3.2.
-
-7/16/93 (bug fix) Modified tkBind.c to ignore the Caps Lock modifier
-unless it is explicitly requested in a binding. Without this fix,
-buttons and menus and other things didn't work if the Caps Lock key
-was active.
-
--------------------- Release 3.3 Beta 2, 7/21/93 -------------------------
-
-7/21/93 (new feature) Change "make install" so that it will modify the
-#! lines on demo scripts to reflect the place where the wish binary
-is installed.
-
-7/23/93 (new feature) Added Tk_MainWindow procedure that returns the
-main window associated with a Tcl interpreter. This is intended for
-use by Tcl_AppInit and other initialization procedures.
-
-7/24/93 (configuration improvements) Changed configure script not to
-omplain about "fd_set" missing if it's defined in <sys/select.h>.
-
-7/28/93 (bug fix) "Bad Match - parameter mismatch" errors were
-sometimes occurring when several top-level windows got created
-at the same time, due to wrong choice of sibling when stacking
-windows.
-
-8/14/93 (new feature) Added support for tcl_prompt1 and tcl_prompt2
-to wish main program: makes prompts user-settable.
-
-8/19/93 (bug fix) Bindings to event sequences like "aD" never matched
-because the Shift key has to be pressed before D. Modified Tk to
-ignore extraneous keypresses if they are for modifier keys.
-
-8/26/93 (configuration changes) Added Tk_Init, modified Tcl_AppInit
-procedures to use it and Tcl_Init. Added support for .wishrc file.
-
-8/28/93 (new feature) The main window is now a legitimate toplevel
-widget.
-
--------------------- Release 3.3 Beta 3, 8/30/93 -------------------------
-
-9/2/93 (bug fix) The packer wasn't always relaying out a master after
-changes to some of the configuration options of its slaves.
-
-9/2/93 (bug fix) The binding mechanism made it impossible for patterns
-like <Double-ButtonRelease-1> to ever match.
-
-9/2/93 (bug fix) Fixed core dump that occurred for bitmap canvas items
-if Postscript is generated but no -bitmap option has been specified.
-
-9/4/93 (enhancement) Slight improvements to menu traversal: set menu
-traversal bindings for menubar window in tk_menuBar, plus trigger
-traversal on <Any-Alt-Keypress> instead of <Alt-Keypress>.
-
-9/9/93 (bug fix) Changed tkBind.c so that the Num_Lock key doesn't
-prevent events from triggering bindings.
-
-9/9/93 (bug fix) Changed tkOption.c to always fetch RESOURCE_MANAGER
-property from root window of screen 0, rather than using default
-screen.
-
-9/9/93 (bug fix) Entry widgets weren't allocating quite enough width
-for themselves. Fixed this and changed the size computation to match
-what's done for buttons and texts.
-
-9/16/93 (bug fix) Changed tkMain.c not to call exit C procedure directly;
-instead always invoke "exit" Tcl command so that application can redefine
-the command to do additional cleanup.
-
--------------------- Release 3.3, 9/29/93 -------------------------
-
-9/30/93 (bug fix) Packer wasn't unmapping slaves when master got deleted.
-
-9/30/93 (bug fix) Binding event sequences such as <Right> were being
-misprinted as ASCII characters such as "S".
-
-10/6/93 (bug fix) Canvases weren't unmapping window items when the canvas
-got unmapped, which caused problems for window items whose windows weren't
-descendants of the canvas (they got left on the screen).
-
-10/7/93 (feature change) NULL proc arguments to Tk_CreateFileHandler used
-to have a special undocumented meaning (fd was display); eliminated this
-special interpretation.
-
-10/7/93 (configuration change) Eliminated dependency of tkMain.c on
-tkInt.h and tkConfig.h, so that it's easier for people to copy the file
-out of the source directory to make modified versions.
-
-10/8/93 (bug fix) 3.0 introduced a bug where the class of the application
-wasn't being set properly, so options based on the application class
-weren't triggering. Fixed by adding new argument to Tk_CreateMainWindow.
-
-10/11/93 (bug fix) Fixed bug in tkTextBTree.c where some deletions would
-cause core dumps due to halfwayLinePtr not getting set correctly.
-
-10/18/93 (bug fix) Fixed a couple of bugs that made it hard to actually
-display N characters in an entry with "-width N" (tended to scroll the
-entry so that only N-1 characters were visible at once).
-
-10/22/93 (bug fix) During configuration, XINCLUDE_DIR and XLIBRARY_DIR
-weren't overriding xmkmf like they were supposed to.
-
-10/23/93 (new feature) Allow negative scale factors in canvas "scale"
-widget command.
-
-10/23/93 (bug fix) Grabs weren't being cleaned up right if the grab
-window was deleted, causing core-dumps in some cases.
-
-10/23/93 (bug fix) tk_TextSelectTo wasn't checking to be sure that
-the "anchor" mark exists.
-
-10/27/93 (bug fix) Fixed core dump that could occur in a text widget if
-the scroll command modifies the text.
-
-11/1/93 (bug fix) Change texts so that the -yscrollcommand option is
-invoked at display time, not when the window is re-layed out. This
-eliminated various core dumps that could occur if -yscrollcommand modified
-the text.
-
--------------------- Release 3.4, 11/04/93 -------------------------
-
-Note: there is no 3.5 release. It was flawed and was thus withdrawn
-shortly after it was released.
-
-11/12/93 (bug fix) TkMain.c didn't compile on some systems because of
-R_OK in call to "access". Changed to eliminate call to "access".
-
--------------------- Release 3.6, 11/26/93 -------------------------
-
-11/10/93 (bug fix) Packer and placer didn't always reposition a window
-correctly if it was managed inside a neice or lower descendant (using
-"-in" option) and the neice's parent moved.
-
-11/24/93 (bug fix) Fixed time problem in selection (retrievals could
-fail if retriever hasn't received any X events since selection was
-made, so that time of retrieval appears to be older than time of
-selection). Selection code is now much less picky about times, both
-on retrieving and supplying sides.
-
-12/2/93 (new feature) Changed arrow-head drawing code for canvas
-lines to draw a 0-width outline in addition to filling the area:
-this produces much nicer, more symmetrical displays.
-
-12/2/93 (bug fix) When colors ran out, Tk was invoking "tkerror"
-when its state was internally inconsistent, which could cause
-core dumps in some situations (e.g. if tkerror used the same color
-that caused colors to run out). Changed notification to occur
-as a when-idle handler.
-
-12/3/93 (bug fix) During a global grab, Tk wasn't including PointerMotion
-in the list of grabbed events, so pointer motion couldn't be tracked
-outside the grabbing application.
-
-12/3/93 (bug fix) Canvases didn't handle smoothed lines correctly
-when they only contained two points.
-
-12/3/93 (bug fix) Fixed bug in tkWindow.c where certain kinds of
-errors during window creation could cause Destroy events to be generated
-for a window that was never completely initialized.
-
-12/13/93 (bug fix) Fixed bug in tkTextDisp.c that resulted in core
-dumps at line 1467 under exmh. The exact situation is that a text
-widget was being redisplayed at a time when it had a -yscrollcommand
-option but hadn't yet been mapped onto the screen.
-
-12/17/93 (bug fix) Fixed bug in tkWindow.c whereby new top-level windows
-with non-default visuals still inherited border pixmap from parent (root),
-which could cause visual clash and X error.
-
-12/17/93 (bug fix) Fixed bug in tkTextDisp.c that caused round-off
-error in the information passed to scroll commands.
-
-12/18/93 (bug fix) Fixed bug in tkPack.c that caused core dumps in
-some situations if a master with siblings packed "-in" it was deleted.
-
-12/18/93 (bug fix) Added "compat" directory to distribution, since it's
-referenced by tkConfig.h on some systems.
-
-12/18/93 (performance improvement) Improved performance of appending to
-a listbox, so that inserting N items doesn't take N**2 time.
-
-12/20/93 (bug fix) Fixed bug in canvas ovals that caused the fill color
-for the oval to stick out past the outline.
-
-1/2/94 (fixed Xlib bug) Added code to reuse X resource identifiers so
-that they won't run out in long running applications. There are three
-new library procedures: Tk_FreeXId, Tk_GetPixmap, and Tk_FreePixmap.
-Modified all Tk code to use these procedures, so wish applications should
-now be able to run forever without running out of identifiers.
-
-1/10/94 (bug fix) tkCursor wasn't freeing pixmaps used to create
-cursors, which caused memory leaks in programs that changed cursors
-frequently.
-
-1/21/94 (bug fix) Fixed bug in scales that caused them to loop
-infinitely drawing tick-marks when -from and -to were the same.
-
-2/2/94 (bug fix) Fixed problem where messages that contained tabs
-didn't always compute the correct size, so that text spilled off
-the right edge. The fix adds an extra "tabOrigin" parameter to
-the internal procedures TkMeasureChars, TkDisplayChars, and
-TkUnderlineChars.
-
-2/4/94 (bug fix) Fixed off-by-one problem in tkBind.c that caused
-it to read past the initialized part of dispPtr->modKeyCodes.
-
-2/7/94 (bug fix) Text widgets didn't handle grabs correctly, such
-that the "current" character got stuck if a grab occurred while a
-mouse button was down. It would get unstuck until after the
-next button press and release.
-
-2/19/94 (bug fix) Fixed prolog.ps (prolog for Postscript printing from
-canvases) so that it correctly prints all of the characters in the
-ISO Latin-1 character set.
-
-2/19/94 (bug fix) Modified tkBind.c to save and restore the interpreter's
-result across the execution of binding scripts. Otherwise if an event
-triggers in the middle of some other script (e.g. a destroy event during
-window creation, because there was an error in the creation command),
-the intepreter's result gets lost.
-
-2/19/94 (bug fix) Fixed bug in dealing with results of sent command
-that could cause them to get lost in some situations.
-
-2/21/94 (bug fix) Don't let user close a dialog window created by
-tk_dialog, since this would cause tk_dialog to hang: force the user
-to select one of the dialog's buttons.
-
-2/21/94 (bug fix) Fixed bug in canvas polygons whereby they didn't
-correctly handle changes in the number of points (via "coords"
-widget command).
-
-2/23/94 (bug fix) Large bitmaps in canvases didn't print correctly
-because they overflowed the 64-KB limit on strings in Postscript.
-Changed canvas printing to split up large bitmaps into mutliple
-smaller ones for printing.
-
-2/25/94 (bug fix) The "." window was being set up with -width
-and -height options, which interfered with geometry management (any
-configuration change on "." causes the window to change size to
-200x200, then change back again).
-
-2/26/94 (bug fix) Fixed several bugs that occurred when a Destroy
-event handler for a window deleted the window's parent.
-
-3/3/94 (new features) Changes to binding mechanism:
- - The modifiers for "Alt", "Meta", and "M" are now computed by
- examining the modifier map, rather than being hardwired to
- M2, M1, and M1.
- - When processing events, one script is invoked for each object
- in the list passed to Tk_BindEvent, rather than stopping as
- soon as a script is invoked for some object. The "break" and
- "continue" commands can be used within a script to abort all
- scripts for the event or the current one.
- *** POTENTIAL INCOMPATIBILITY ***
- - Added "bindtags" command so that new binding groups can be
- defined for widgets and the evaluation order can be changed.
- - When matching events to bindings, extra modifiers are now ignored,
- as if "Any" were specified for every event. The "Any" modifier
- is still recognized, but it is ignored and is deprecated.
- *** POTENTIAL INCOMPATIBILITY ***
- - In % sequences that print window identifiers (e.g. %a and %S), print
- in hexadecimal rather than decimal, for consistence with "winfo id".
- *** POTENTIAL INCOMPATIBILITY ***
- - The "bind" command no longer supports the event types CirculateRequest,
- ConfigureRequest, MapRequest, or ResizeRequest. These event types
- are somewhat dangerous, and they never worked anyway.
-
-3/13/94 (bug fix) Fixed numerous problems with the "wm iconwindow" command.
-It appears that this command never really worked at all, but it should
-work OK now.
-
-3/14/94 (feature changes) Removed several obsolete features:
- - Eliminated "enable" and "disable" widget commands for menus.
- *** POTENTIAL INCOMPATIBILITY ***
- - Eliminated "activate" and "deactivate" widget commands for buttons,
- checkbuttons, radiobuttons, and menubuttons.
- *** POTENTIAL INCOMPATIBILITY ***
- - Removed -geometry option for frames and toplevels: it causes
- problems when .Xdefaults files contain entries like
- "*geometry: +0+0". Must use -width and -height instead.
- *** POTENTIAL INCOMPATIBILITY ***
- - Desupported "tkVersion" variable: use "tk_version" instead.
- *** POTENTIAL INCOMPATIBILITY ***
-
-3/16/94 (feature changes) Changes to listboxes:
- - Eliminated -geometry option (it causes problems when .Xdefaults
- files contain entries like "*geometry: +0+0"). Added -width
- and -height options to use instead.
- *** POTENTIAL INCOMPATIBILITY ***
-
-3/21/94 (bug fix) Fixed bug in tkOption.c where the option cache wasn't
-properly cleaned up after window deletion; this could cause the wrong
-value from the option database to be used under some conditions.
-
-3/25/94 (new features) Changes to geometry management:
- - Added Tk_MaintainGeometry and Tk_UnmaintainGeometry procedures
- to solve problems with -in windows. Modified the packer, the
- placer, and canvases to use them.
- - Changed 2nd argument to Tk_ManageGeometry from Tk_GeometryProc *
- to a pointer to a structure with additional information about
- the geometry manager, such as name and procedure to call when
- slaves are stolen.
- *** POTENTIAL INCOMPATIBILITY ***
-
-3/28/94 (new feature) Overhauled event management:
- - Added "cancel" option to the "after" command so that you can
- cancel previously-scheduled commands.
- - Separated X-specific stuff from generic event management. The
- file tkEvent.c can now be used stand-alone without the rest of Tk.
- See the manual entry for Tk_EventInit for information on which
- procedures are available this way.
- - Added Tk_CreateFileHandler2 procedure, which provides a lower-level
- and more powerful form of file event handler.
- - Fixed bug in Tk_DoOneEvent where an infinite loop could occur if
- the TK_FILE_EVENT and TK_DONT_WAIT flags were set simultaneously
- (there were bugs with several other combinations too; all should
- be fixed now).
-
-3/28/94 (new feature) Added "fileevent" command, which allows event-
-driven I/O in the style of Mark Diekhans' "addinput" command.
-
-4/11/94 (new feature) Better support for colormaps and visuals:
- - Added new -colormap and -visual options to toplevels and frames.
- - Added "winfo visualsavailable" command.
- - Added "wm colormapwindows" command, plus support for WM_COLORMAP_WINDOWS
- to Tk_SetWindowColormap.
- - Added new library procedures Tk_GetVisual, Tk_GetColormap,
- and Tk_FreeColormap.
-
-4/11/94 (bug fix) Fixed core dump that used to occur when specifying
-an iconwindow ("wm iconwindow") for a toplevel on a different screen
-than the main window.
-
-4/23/94 (new feature) Added support for images, including the following:
- - New "image" command for creating images.
- - Built-in image type: bitmap.
- - New "image" item type in canvases.
- - Labels, buttons, checkbuttons, radiobuttons, menubuttons, and
- menu entries now support a -image option for displaying images.
- - Tk_CreateImageType and Tk_ImageChanged procedures, for defining
- new types of images in C.
- - Tk_GetImage, Tk_FreeImage, Tk_RedrawImage, and Tk_SizeOfImage
- procedures, for using images in widgets.
-
-5/1/94 (new features) Added new procedures Tk_3DVerticalBevel and
-Tk_3DHorizontalBevel.
-
-5/11/94 (new features) Major overhaul of text widgets:
- - Implemented embedded windows and "window" widget command.
- - Added new configuration options for tags: -justify, -lmargin1,
- -lmargin2, -rmargin, -offset, -spacing1, -spacing2, and -spacing3.
- See the "Display styles" widget demo for examples.
- - Added new configuration options for texts: -spacing1, -spacing2,
- and -spacing3.
- - Added "tagList" option to "insert" widget command to control
- tags on new text. Made tagged regions so they aren't sticky on
- either side: new characters get a tag only if the old chars. on
- both sides had it.
- *** POTENTIAL INCOMPATIBILITY ***
- - Added gravity for marks, and "mark gravity" widget command.
- - Added horizontal scrolling, "xview" widget command, -xscrollcommand
- option. Changed "scan" widget commands to support horizontal
- scrolling.
- *** POTENTIAL INCOMPATIBILITY ***
- - Added "search" widget command for searching (either exact matches
- or regular expressions).
- - New widget commands: bbox, dlineinfo, and see.
- - Changed implementation of bindings so that Enter and Leave
- events are not generated unless the tag has just become present
- (or just ceased to be present) on the current character. Also
- changed bindings to process separately for each tag, rather than
- having high-priority tags override low-priority ones.
- - The "end" index now refers to the character after the last newline
- rather than the newline itself. You can now tag the final newline
- and set a mark after the final newline.
- - Deletions of the "sel" tag and the "insert" and "current" marks
- are now ignored silently, rather than generating errors. This means
- you can do things like "eval .t tag delete [.t tag names]".
-
-5/19/94 (bug fix) Canvases didn't generate proper Postscript for stippled
-text.
-
-5/20/94 (new feature) Added "bell" command to ring the display's bell.
-
-5/20/94 (new feature) Incorporated "square" demonstration widget into
-tktest application.
-
-5/20/94 (new features) Changed wish application (tkMain.c):
- - wish no longer processes the -help option.
- *** POTENTIAL INCOMPATIBILITY ***
- - The wish main program is now called Tk_Main; tkAppInit.c has a
- "main" procedure that calls Tk_Main. This makes it easier to use
- Tk with C++ programs, which need their own main programs, and it
- also allows an application to prefilter the argument list before
- calling Tk_Main.
- *** POTENTIAL INCOMPATIBILITY ***
- - The application's class is now the same as its name (except the
- first letter is capitalized), instead of "Tk".
- *** POTENTIAL INCOMPATIBILITY ***
- - The -file keyword is no longer required: the script file name can
- be provided as the first argument without being preceded by "-file",
- as in tclsh. For backward compatibility the "-file" keyword is
- ignored if it is the first argument, but it is deprecated.
-
-5/26/94 (feature removed) Removed support for "fill" justify mode from
-Tk_GetJustify and from the TK_CONFIG_JUSTIFY configuration option. None
-of the built-in widgets ever supported this mode anyway.
-*** POTENTIAL INCOMPATIBILITY ***
-
-5/27/94 (feature change) Changed Tk to use Tk_PrintDouble everywhere
-that it converts reals to strings. This means that floating-point
-values will be generated in some cases where integer-like values were
-generated before.
-*** POTENTIAL INCOMPATIBILITY ***
-
-6/1/94 (feature change) Renamed "pack newinfo" command to "pack info".
-The old "pack info" command is no longer available.
-*** POTENTIAL INCOMPATIBILITY ***
-
-6/20/94 (feature changes) Overhaul of entry widgets:
- - Added "-justify" option.
- - Added "-show" option to make entries easier to use for passwords.
- - Added "cget" widget command.
- - Added "selection range" and "selection present" widget commands.
- - Added "anchor" symbolic index.
- - Changed "-scrollcommand" option to "-xscrollcommand", "view"
- widget command to "xview", for compatibility with other widgets.
- *** POTENTIAL INCOMPATIBILITY ***
- - Changed sel.last to refer to character just *after* last one
- selected, again for compatibility with other widgets.
- *** POTENTIAL INCOMPATIBILITY ***
- - For "delete" widget command, second index now refers to character
- just *after* last one to delete.
- *** POTENTIAL INCOMPATIBILITY ***
- - Overhauled bindings to be more Motif-compatible and to include
- common Emacs bindings for editing.
- - Changed -width option: if specified as 0, widget sizes to fit
- its current text.
-
-6/11/94 (new features) Improved Motif compatibility:
- - Added "-highlightwidth" and "-highlightcolor" options to all widgets.
-
-6/27/94 (bug fix) Postscript generation for text items in canvases was
-not justifying the text properly when a -width was specified that was
-longer than the longest line.
-
-6/27/94 (bug fix) "winfo exists" used to report a window as existing
-if it was in the process of being destroyed (i.e., a destroy handler
-is in the middle of execution). Changed to report it as non-existent
-under these conditions.
-*** POTENTIAL INCOMPATIBILITY ***
-
-7/11/94 (bug fix) Selections claimed via "selection own" weren't always
-being cleared properly when the selection was claimed away. Also fixed
-bug where Tk wasn't properly claiming the selection, if there haven't
-been any recent X events at the time of the claim.
-
-7/13/94 (feature changes) Overhaul of scrollbar widgets:
- - New widget commands: "activate", "cget", "fraction", and "identify".
- - New options: -activebackground, -activerelief, -highlightcolor,
- -jump, -highlightthickness, and -troughcolor. What used to be
- -background is now -troughcolor, -foreground is now -background,
- and -activeforeground is now -activebackground.
- *** POTENTIAL INCOMPATIBILITY ***
- - Added new syntax for "set" command, "get" result, and generated
- commands. Changed other widgets to use the new syntax.
- - Moved the bindings out of C and into Tcl scripts, using the new
- options and widget commands. Added support for all Motif
- bindings, plus jump scrolling and cancelling of slider drags.
-
-7/16/94 (bug fix) Canvases assumed that the Leave event for one item
-didn't modify or delete the next current item; this could cause core
-dumps under some conditions.
-
-7/23/94 (feature change) Modified Tk_BackgroundError so that tkerror
-is invoked as an idle handler. If tkerror generates a break exception
-then all other queued reports are aborted.
-
-8/14/94 (bug fix) "cursorOffTime" and "cursorOnTime" were confused in
-canvases, resulting in the same time being used for both.
-
-8/16/94 (bug fix) "tkwait variable" command didn't detect errors in
-variable name, such as trying to wait for an entire array.
-
-9/2/94 (new features) Overhaul of scale widgets:
- - Floating-point values are supported now, following Paul Mackerras'
- "fscale" widget. Added "-resolution" and "-digits" options.
- - Added "-variable" option to link scale to variable, following
- Henning Schulzrinne's implementation.
- - Added focus highlight (-highlightthickness and -highlightcolor
- options).
- - Added new widget commands "cget", "coords", "identify", plus
- improved "get"; removed wired-in bindings, added complete set
- of Motif bindings via Tcl scripts.
- - Changed -sliderforeground option to -background, -background to
- -troughColor, -activeforeground to -activebackground.
- *** POTENTIAL INCOMPATIBILITY ***
- - Moved value label from below horizontal scales to above the scale,
- for Motif compliance.
-
-9/9/94 (bug fix) Fixed bug in tkWm.c that caused long delays in "raise"
-command under some conditions (window already at the top of the stack).
-
-9/10/94 (new features) Overhaul of label/button/checkbutton/radiobutton
-widgets:
- - Added focus highlight (-highlightthickness and -highlightcolor
- options).
- - Added new widget command "cget".
- - Changed -selector option to -selectcolor, and changed its meaning
- too: empty no longer means don't draw the indicator; it means
- don't use a special color when selected.
- *** POTENTIAL INCOMPATIBILITY ***
- - Added -indicatoron (controls whether indicator is displayed) and
- -selectimage (gives special image to display when selected) options.
- - Modified bindings to be more Motif-like, added binding for space
- key.
- - Changed padding defaults to give widgets correct Motif appearance
- by default. Also, changed to ignore padding options when displaying
- an image or bitmap.
- *** POTENTIAL INCOMPATIBILITY ***
- - Can now display text on multiple lines: newlines cause line breaks,
- and word wrapping can be requested with -wraplength option. Also
- added -justify and -underline options.
- - The -value option for radiobuttons can now have an empty string as
- its value; it no longer defaults to the name of the widget.
- *** POTENTIAL INCOMPATIBILITY ***
-
-9/13/94 (new features) Modified both canvases and messages to support
--highlightthickness and -highlightcolor options plus "cget" widget
-command.
-
-9/19/94 (new features) Added Tk_UnsetGrid procedure, modified widgets
-to use it. Also changed Tk_SetGrid so that at most one window per
-toplevel can have gridding enabled.
-
-9/23/94 (new features) Major overhaul of listbox widgets:
- - Added focus highlight (-highlightthickness and -highlightcolor
- options).
- - Added new widget command "cget".
- - Revised selection commands to support single selections as well
- as multiple disjoint selections; syntax of "selection" widget
- command has changed to support this. Added new option -selectmode
- for specifying which mode to use. Default is single selection;
- tk_listboxSingleSelect procedure no longer exists. Selections
- now return as items separated by newlines instead of a list whose
- elements are the items.
- *** POTENTIAL INCOMPATIBILITY ***
- - Extended "get" widget command to allow many items to be retrieved
- at once.
- - Added "bbox" widget command for finding position of an element on
- screen.
- - Added "activate" command to mark element with traversal focus.
- - Extended index mechanism to support new types of indices:
- "active", "anchor", "@x,y".
- - Added "see" widget command.
- - Revised bindings to include all Motif features except for AddMode.
- - If -width or -height option is <= 0, the widget requests a size just
- large enough to hold all of its text.
-
-10/6/94 (new features) Overhaul of menubuttons:
- - Added focus highlight (-highlightthickness and -highlightcolor
- options).
- - Added new widget command "cget".
- - Added -indicatoron option to display option menu indicator.
- - The -menu option must be a child of the menubutton.
- *** POTENTIAL INCOMPATIBILITY ***
-
-10/6/94 (new features) Overhaul of menu widgets:
- - Added new widget commands "cget" and "entrycget".
- - Changed the implementation of tear-off menus to be more
- Motif-like; added -tearoff option for specifying whether
- tearoff entry is displayed.
- - Changed interpretation of "@y" index: it now returns the
- closest entry, rather than "none" if y is outside the menu's
- range.
- *** POTENTIAL INCOMPATIBILITY ***
- - The -menu option for a cascade entry must now be a child of
- the menu.
- *** POTENTIAL INCOMPATIBILITY ***
- - Added "type" widget command, so that you can query the type of
- an entry.
- - Added -foreground, -activeforeground, -selectcolor, -indicatoron,
- -image, and -selectimage options to menu entries.
- - Changed "selector" menu option to "selectColor" for Motif compliance.
- *** POTENTIAL INCOMPATIBILITY ***
- - Added -relief option for menus, just for consistency with other
- widgets (it was implicitly "raised" before).
-
-10/6/94 (feature change) Completely overhauled the bindings for menus
-and menubuttons. They now fit better with other Tk 4.0 facilities,
-such as the new binding mechanism, and they provide better Motif
-compliance (e.g. keyboard traversal of submenus). Also, the bindings
-now support option menus, popup menus, and proper Motif tear-off
-menus.
-
-10/6/94 (obsolete features) The procedures tk_menuBar and
-tk_bindForTraversal are no longer needed in Tk 4.0. They still exist
-for compability, but they do nothing.
-
-10/6/94 (new procedures) Added "tk_popup" procedure for posting a
-popup menu, and "tk_optionMenu" for creating an option menubutton
-and its associated menu.
-
-10/6/94 (change in name) The variable "tk_priv" has been renamed
-to "tkPriv" to reflect that fact that it is private to Tk now.
-This shouldn't cause any problems, since no-one except Tk should
-have been using it before anyway (right?).
-
-10/6/94 (bug fix) Fixed bug in texts where sometimes the text would
-stop tracking mouse motion (the "current" item wouldn't get updated)
-because the text widget missed a ButtonRelease event.
-
-10/20/94 (new features) Overhauled selection code to support multiple
-selections (primary, secondary, etc.) and multiple displays:
- - Changed "selection" command to support new options such as
- "-displayof" and "-selection". Old command formats are still
- supported for compatibility, but they are no longer documented
- and are deprecated.
- - Changed procedures Tk_GetSelection, Tk_CreateSelHandler, and
- Tk_ClearSelection to take additional "selection" argument.
- *** POTENTIAL INCOMPATIBILITY ***
- - Selection targets APPLICATION and WINDOW_NAME have been replaced
- by TK_APPLICATION and TK_WINDOW.
- *** POTENTIAL INCOMPATIBILITY ***
-
-10/20/94 (new features) Added support for clipboard:
- - New "clipboard" command.
- - C procedures Tk_ClipboardClear and Tk_ClipboardAppend.
- - Bindings for "cut", "paste", and "copy" for text and entry widgets,
- plus "copy" binding for listboxes.
-
-10/24/94 (bug fix) Button widgets weren't checking for errors when
-setting the values of associated variables.
-
-11/3/94 (bug fix) Fixed bug whereby Tk would hang if "exit" was invoked
-from inside a <Destroy> binding.
-
-11/15/94 (new features) Overhaul of focus mechanism:
- - Added support for multiple displays: separate focus windows are
- kept for each display.
- - Added support for keyboard traversal.
- - Changed focus model so Tk keeps track of a focus window for each
- top-level window and automatically sets the focus on Enter to the
- top-level. Tk no longer synthesizes FocusIn and FocusOut events,
- but just uses the standard X mechanisms. There is no "default"
- focus window anymore; the focus reverts to top-levels by default.
- *** POTENTIAL INCOMPATIBILITY ***
- - Changed focus command: eliminated "focus default" and "focus none",
- added "-displayof" and "-lastfor" options. An empty string is now
- used to signify "no focus" instead of "none".
- *** POTENTIAL INCOMPATIBILITY ***
- - Added library procedures tk_focusNext, tk_focusPrev, and
- tk_focusFollowsMouse.
- - Removed obsolete Tk_CreateFocusHandler: must use FocusIn and
- FocusOut events now.
- *** POTENTIAL INCOMPATIBILITY ***
-
-11/23/94 (new features) Overhaul of "send" command:
- - Added support for multiple displays: -displayof option to "send".
- - Added asynchronous sends: -async option to "send".
- - Eliminated fixed timeouts on sends: as long as the target
- application appears to exist, the send will wait for it.
- - Stale entries get removed from the application registry now,
- so "winfo interps" should never return non-existent applications.
- - Can change the name of an application with "tk appname" command.
- This is also the preferred way of querying the application name
- now.
- - The errorCode and errorInfo variables are now propagated back to
- the sender now, so a full stack trace is available.
- - Tk checks display security on each send now, instead of just during
- initialization, so changes in the security status are seen immediately
- by all applications.
- - The above changes required changes to the data formats used for
- communication between source and target applications, so Tk 4.0
- applications cannot send to, or be sent from, Tk 3.6 applications.
- *** POTENTIAL INCOMPATIBILITY ***
- - The procedure Tk_RegisterInterp has been replaced with Tk_SetAppName.
- *** POTENTIAL INCOMPATIBILITY ***
-
-12/6/94 (cleanup) Eliminated "interp" argument to Tk_GetColorByValue,
-since it is no longer needed.
-*** POTENTIAL INCOMPATIBILITY ***
-
-12/7/94 (feature change) Changed the "wm" command so that top-level
-windows are now resizable by default. You can no longer specify
-empty arguments to "wm maxsize" and "wm minsize".
-*** POTENTIAL INCOMPATIBILITY ***
-
-12/8/94 (new feature) Added new "photo" image type using code provided
-by Paul Mackerras: currently supports only PPM "P6" format images.
-
-12/14/94 (new features) Canvas modifications:
- - Modified the interfaces between generic canvas code and the item
- types so that it's easy for people to write new item types outside
- of Tk.
- - Added support for transparent bitmap items: just specify an
- empty string as the background color.
- - Changed the "xview" and "yview" commands for canvases to use the
- new scrolling syntax.
- - Eliminated -scrollincrement option.
- *** POTENTIAL INCOMPATIBILITY ***
-
-12/14/94 (bug fix) Fixed bug where the dimensions of canvas arrowheads
-scaled during a "scale" widget command, but the scaling was only
-temporary and got lost on the next re-configure of the item. The
-correct behavior is for the arrowheads not to scale.
-
--------------------- Release 4.0b1, 12/23/94 -------------------------
-
-12/26/94 (bug fix) Removed obsolete demos from Makefile (color, dialog,
-size), fixed "install" target.
-
-1/3/95 (bug fix) Fixed all procedure calls to explicitly cast arguments:
-implicit conversions from prototypes don't work when compiling under
-non-ANSI compilers. Tk is now clean under gcc -Wconversion.
-
-1/4/95 (bug fix) Used "screenX" without ever setting it in DisplayText
-in tkCanvText.c: caused tabs in canvas text items to get messed up.
-
-1/4/95 (bug fix) Canvases forgot to register the built-in types if
-Tk_CreateItemType was called before a canvas widget was created.
-
-1/4/95 (bug fixes) Fixed glitches in various text bindings:
- - Up used to do nothing if the cursor was at 2.0.
- - Right used to make the cursor invisible if it was just before
- the final newline of the text.
- - Control-t didn't conform to Emacs; made it conform to GNU Emacs.
- - Deleted Control-x binding, since it doesn't conform to anything and
- is confusing for Emacs users.
-
-1/4/95 (bug fixes) Changed Control-t for entries just as for texts (see
-above) an deleted Control-x for entries (see above).
-
-1/4/95 (bug fix) The packer didn't map slaves unless the master was mapped;
-this could cause slaves to get "lost" so that they weren't mapped until the
-master resized.
-
-1/5/95 (bug fix) Scrollbars weren't executing the proper code the first time
-the mouse entered the widget; this caused problems if tk_strictMotif was
-set.
-
-1/6/95 (bug fix) Fixed label/button/checkbutton/radiobutton/menubutton
-widgets to allow arbitrary screen distances when specifying -width and
--height for an image or bitmap (the manual pages already documented this
-but the code didn't implement it).
-
-1/6/95 (new feature) Added very primitive support for input methods,
-as suggested by Martin Forssen. This should be enough for European
-character sets (Compose key) but it isn't near enough for Asian
-character sets.
-
-1/8/95 (bug fix) Fixed problem in canvas "xview" and "yview" commands
-where divide-by-zero errors could sometimes occur.
-
-1/8/95 (bug fix) New event handler didn't properly handle files for
-which both TK_READABLE and TK_WRITABLE were specified.
-
-1/11/95 (bug fix) Fixed bug with text selections: was returning count
-too high for data, causing bogus garbage to appear when selection was
-copied.
-
--------------------- Release 4.0b2, 1/12/95 -------------------------
-
-1/27/95 (feature removal) Removed %D substitution from binding scripts:
-wasn't portable, shouldn't be used anyway.
-*** POTENTIAL INCOMPATIBILITY ***
-
-1/27/95 (new features) Added -displayof options to the commands
-"winfo atom", "winfo atomname", "winfo containing", "winfo interps",
-and "winfo pathname".
-
-1/27/95 (new feature) Added "idle" option to "after" command to run
-scripts as idle handlers.
-
-1/28/95 (new feature) Modified placer to make -x and -relx additive
-if you specify both. Same for -y and -rely, -width and -relwidth,
-and -height and -relheight. This makes it easy to make request such
-as "make .a 2 pixels larger than .b".
-*** POTENTIAL INCOMPATIBILITY ***
-
-1/28/95 (new feature) Improved auto-grab mechanism in canvases (which
-prevents current item from changing while a button is down): changed
-to report Enter and Leave events for the current item while a button
-is down. However, as before, no Enter events are reported for other
-items until the button goes up.
-
-1/28/95 (new feature) Bitmap images are now transparent if the -background
-is specified as an empty string (-maskdata and -maskfile are ignored in
-this case). This is also the default.
-
-1/28/95 (bug fix) Tk didn't support manufacturer- or site-specific keysyms
-such as SunAudioMute. Modified tkBind.c so that it uses XStringToKeysym
-in addition to its own hash table, so that all keysyms are now available.
-
-1/30/95 (feature change) Modified "clipboard append" so that it reclaims
-the clipboard selection if it had been previously lost, rather than just
-generating an error. This handles certain race conditions more cleanly,
-and also allows the use of programs like "xclipboard".
-
-1/30/95 (new feature) Added -xscrollincrement and -yscrollincrement
-options to canvases.
-
-1/31/95 (bug fix) Geometry management was broken if a particular geometry
-manager claimed a slave away from itself.
-
-1/31/95 (bug fix) Fixed bug in tkVisual.c where a visual with fewer bits
-than requested was being selected in preference to one with just the right
-number of bits.
-
-1/31/95 (bug fix) Texts weren't redisplaying the padding region properly
-after changes in -padx or -pady.
-
-1/31/95 (new features) More text improvements:
- - Extended "insert" widget command for texts to allow multiple
- text-tagList pairs in the same command.
- - Added -nocase option to "search" widget command.
- - Added -overstrike option to tags.
- - Added tab stops, via -tabs option for widget and for tags.
-
-2/10/95 (bug fix) Modified all widgets to allow renaming of widget
-commands. Deleting a widget command will delete the widget.
-
-2/11/95 (new feature) Added -highlightbackground option to all widgets.
-
-2/14/95 (new feature) Added "insert" widget command for menus.
-
-2/15/95 (new feature) Modified text display code (for all widgets) to
-display well-known control characters like newline and backspace as
-\n or \b instead of \xa.
-
-2/15/95 (bug fix) Modified bitmap and photo image managers to delete
-the image command when the image is deleted. Also modified them to
-allow renaming of the image command, and to delete the image if the
-image command is deleted.
-
-2/15/95 (bug fix) Fixed text widgets to allow horizontal scrolling
-even if wrapping was enabled, if a line isn't entirely visible due to
-a large character or embedded window.
-
-2/16/95 (feature change) Added "postcascade" widget command to menus,
-changed "invoke" and "activate" not to post or unpost submenus. Also
-fixed bug in redisplay that tended to leave bits of garbage on menu
-when submenu unposted.
-*** POTENTIAL INCOMPATIBILITY ***
-
-2/16/95 (feature removal) Removed "snap back" behavior (slider
-snaps back to old position if you move the mouse outside the widet
-before releasing the button) from scrollbars and scales.
-
-2/16/95 (bug fix) The last line of a listbox wasn't being displayed if
-it was only partially visible.
-
-2/16/95 (new features) Added support for "-resolution 0" (no rounding
-of values) to scale widgets, plus smarter computation of how many digits
-to display.
-
-2/17/95 (bug fix) Fixed bug in text bindings for things like Shift-Left:
-didn't properly set the anchor position.
-
-2/20/95 (bug fix) Changed management of COLORMAP_WINDOWS property to
-add the toplevel implicitly to the end of the list if it wasn't already
-on the list somewhere. Without this, some window managers implicitly
-put it at the front of the list, so that colormaps in internal windows
-are never used.
-
-2/20/95 (bug fix) Changed to use separate command procedures for
-button, checkbutton, label, and radiobutton commands. This allows the
-class commands to be renamed without breaking their behavior.
-
-2/20/95 (removed feature) The "bind" command no longer supports
-"Keymap" events; they never worked anyway.
-
-2/20/95 (bug fix) The text "search" widget command looped infinitely
-when searching an empty text.
-
-2/20/95 (bug fix) Canvases weren't redrawing their borders after
-configuration changes.
-
-2/20/95 (upgrade) Changed to use autoconf version 2.2.
-
-2/21/95 (bug fix) Fixed several bug fixes in menu bindings that occur
-when menus have no entries.
-
-2/21/95 (bug fix) Fixed bug in geometry management that caused windows
-packed -in siblings to not always be mapped and unmapped properly
-(particularly when the toplevel got unmapped and mapped).
-
-2/22/95 (bug fix) Fixed resource leak problem in tkTextDisp.c that
-caused embedded windows not to be unmapped when off-screen.
-
-2/23/95 (bug fix) "After cancel" dumped core when the script for an
-after event cancelled itself.
-
-2/24/95 (bug fix) Text and entry widgets weren't properly ignoring
-Alt-, Control-, and Meta- keystrokes, so a widget-specific binding
-for one of these resulted in the character also being inserted.
-
-2/24/95 (bug fix) Several widgets accidentally performed unsigned
-division on negative numbers, thereby losing the sign bit. This
-mostly affected the display of images and bitmaps in buttons,
-menubuttons, and messages.
-
-2/24/95 (feature reversal) Restored old behavior of %A so that it
-returns non-printing characters as well as printing ones now.
-*** POTENTIAL INCOMPATIBILITY with Tk 4.0b2, but not with Tk 3.6 ***
-
-2/24/95 (bug fix) Duplicate "leave" events could occur for canvas
-items under some conditions, due to recursive calls to PickCurrentItem.
-Added code to detect and skip the nested calls.
-
-2/24/95 (bug fix) Fixed bug where an error could occur during the first
-keystroke in an application if its binding invoked "break".
-
-2/25/95 (new feature) Modified syntax of "search" widget command for
-texts. The -nowrap switch and the "variable" final argument are no
-longer supported. Instead, there is a -count switch to replace
-the final argument; if the final argument is specified, it is now
-a stopping index for the search. The features of -nowrap can be
-achieved now with the stopping index.
-*** POTENTIAL INCOMPATIBILITY with Tk 4.0b2, but not with Tk 3.6 ***
-
-2/27/95 (bug fix) Fixed problem that appears to prevent keyboard
-input for working under IRIX: tkBind.c was ignoring XmbLookupString
-calls that returned a status of XLookupBoth.
-
-2/27/95 (new feature) Added Tk_GetItemTypes procedure to return
-information about available canvas item types.
-
-2/27/95 (feature change) Changed Makefile to always use install-sh
-for installations: there's just too much variation among "install"
-system programs, which makes installation flakey.
-
-2/27/95 (bug fix) Fixed bug in tkSend.c that caused core dumps if
-the app's main window was destroyed by a destroy handler on a
-child.
-
-3/5/95 (feature change) Change separator character used in "bind +..."
-bindings from semi-colon to newline (permits bindings that are
-comments, for what that's worth).
-
-3/7/95 (bug fix/feature change) Overhauled focus code, both in C
-and in Tcl:
- - Tk won't move the X focus in response to the "focus" command
- unless either the application already has the focus or the
- -force switch is specified.
- - Tk no longer sets the X focus to anything other than top-levels;
- it synthesizes events for FocusIn and FocusOut to children.
- - A window no longer has to be viewable when focussed to; Tk will
- set the X focus later, when the window becomes viewable.
- - Added -takefocus option to all widgets.
- - Rewrote tk_focusPrev and tk_focusNext to use the -takefocus option.
- These procedures no longer set the focus; they just return the
- next window in focus order.
- *** POTENTIAL INCOMPATIBILITY with Tk 4.0b2, but not with Tk 3.6 ***
- - Eliminated tk_focusContinue.
- *** POTENTIAL INCOMPATIBILITY with Tk 4.0b2, but not with Tk 3.6 ***
-
-3/8/95 (new feature, bug fix) Added support for tk_strictMotif variable
-in C: Tk_StrictMotif library procedure. Modified buttons, menubuttons,
-menus to use it. This fixes the problem with menus not supporting
-tk_strictMotif properly in Tk4.0b1 and b2.
-
-3/16/95 (feature overhaul) Overhauled color management:
- - Changed Tk so it never denies a color request because a colormap
- filled up. Instead, it allocates the closest available color.
- - Eliminated "color model" mechanism. The "tk colormodel" command
- is gone, as are the procedures Tk_GetColorModel and Tk_SetColorModel.
- *** POTENTIAL INCOMPATIBILITY ***
- - Changed 3D border implementation to allocate colors for shadows
- lazily, so they're never allocated if they're never used. Also
- added new feature whereby stippling is used for borders when
- the colormap has run out of entries. Changed arguments to many
- of Tk_3D C procedures to take a Tk_Window as argument instead of
- a (Display *). This is needed to do lazy color allocation.
- *** POTENTIAL INCOMPATIBILITY ***
- - Eliminated colormap argument to Tk_GetColor, Tk_GetColorByValue,
- and Tk_Get3DBorder.
- *** POTENTIAL INCOMPATIBILITY ***
-
-3/16/95 (feature change) Event bindings created from Tcl will now ignore
-Enter, Leave, FocusIn, and FocusOut events with detail NotifyInferior.
-This is done in anticipation of mega-widgets, so that the user of a
-mega-widget can create Enter/Leave bindings on the mega-widget without
-seeing spurious events as the mouse moves among the windows in the
-mega-widget.
-*** POTENTIAL INCOMPATIBILITY ***
-
-3/17/95 (feature change) Changed C interfaces throughout Tk to use ints
-instead of unsigneds: the unsigneds turn out to cause subtle problems
-with arithmetic in some places, and using ints everywhere is just
-simpler.
-*** POTENTIAL INCOMPATIBILITY ***
-
-3/23/95 (bug fix) Selections longer than 4000 bytes were being
-truncated to 4000 bytes.
-
--------------------- Release 4.0b3, 3/24/95 -------------------------
-
-3/25/95 (bug fix) Changed "install" to "./install" in Makefile so that
-"make install" will work even when "." isn't in the search path.
-
-3/25/95 (bug fix) Modified Tk's selection mechanism to prevent core
-dumps in other applications during retrievals of large selections
-(this is actually a bug in the other apps, but I've patched Tk to
-keep it from getting triggered).
-
-3/25/95 (bug fix) Fixed bug where X window for "." wasn't being
-deleted.
-
-3/27/95 (bug fix) Fixed many bugs associated with having more than
-one application in a single process.
-
-3/28/95 (bug fix) The "search" widget command for texts didn't
-return the correct index and count if there were embedded widgets
-on the same line as the returned range but before the end of
-the range.
-
-3/28/95 (bug fix) Changed pasting via button 2 in text and entries
-so that it inserts at the pointer location, not the location of
-the insertion cursor.
-
-3/28/95 (bug fix) Fixed several bugs related to <Destroy> bindings
-that delete ancestors in the window hierarchy. Also eliminated
-extraneous calls to XDestroyWindow, which speeds up window deletion
-by about 3x.
-
-3/28/95 (bug fix) Several widgets (buttons, menubuttons, menus) didn't
-properly handle image deletions that occurred while the widget was
-being deleted (caused core dumps).
-
-3/29/95 (bug fix) When retrieving long selections from text widgets,
-parts of lines were getting duplicated in the selection information.
-
-4/1/95 (bug fix) Fixed bug that caused infinite loop in horizontal
-scales with 0 range.
-
-4/1/95 (bug fix) Fixed problem with -command option for scrollbars and
--takefocus option that caused commands to be evaluated in the wrong
-context.
-
-4/1/95 (bug fix) Fixed problem with option database that caused it to
-sometimes use the wrong option (wasn't flushing the database properly
-after a change in a window's class).
-
-4/1/95 (bug fix) If a line in a text widget just barely fit in the window,
-Tk was allocating a second screen line just for the newline character.
-
-4/1/95 (new feature) When backspacing in an entry widget, when you reach
-the left edge of the widget, the insertion cursor gets recentered.
-
-4/1/95 (new features) Added "winfo pointerx" and "winfo pointery" commands
-to fetch the current pointer position.
-
-4/6/95 (bug fix) If the last line of a text widget was only partially
-visible, it was counted as visible for purposes of the scrollbar. Now
-it is treated as if it were off-screen for scrolling purposes.
-
-4/6/95 (new feature) Modified "bell" command to reset screen saver as well.
-
-4/6/95 (feature change) Modified menu scanning (where menus pull down
-as you drag across their menubuttons) so it only works among menus
-in the same toplevel; it used to work for any menubuttons in the
-application.
-
-4/6/95 (bug fix) Canvas text items weren't allowing real numbers in
-"@x,y" notation for specifying indices.
-
-4/7/95 (bug fix) Menus didn't display correctly when -activeborderwidth
-was large.
-
-4/7/95 (bug fix) Changed "clipboard append" command to support -- option
-and to always treat the last argument as data, even if it starts with
-"-".
-
-4/17/95 (new feature) Added -wrap option to text tags.
-
-4/18/95 (bug fix) Listboxes and texts weren't updating their grid information
-when -width or -height changed.
-
-4/18/95 (bug fix) "Down" didn't work right in text widgets if the last
-line was only partially visible in the window.
-
-4/19/95 (bug fix) Listboxes didn't handle partially visible last lines
-right: couldn't scroll it into full visibility, for example.
-
-4/20/95 (bug fix) If a toplevel was positioned with a command like
-"wm geometry . -0-0", the window didn't reposition itself to maintain
-that geometry after a size change.
-
-4/21/95 (feature change) Changed order of binding tags so widget bindings
-fire before class bindings. New order is: widget, class, toplevel, all.
-*** POTENTIAL INCOMPATIBILITY with Tk 4.0b3, but not with Tk 3.6 ***
-
-4/23/95 (new feature) Added "winfo colormapfull" command.
-
-4/23/95 (new feature) Buttons and radiobuttons and checkbuttons now
-treat Return the same as Space, unless tk_strictMotif is set.
-
-4/23/95 (bug fix) Modified menu tear-off procedure to duplicate the
-binding tags and bindings of the original in the copy.
-
-4/25/95 (bug fix and feature change) Modified mechanism for choosing
-"best" visual to fix a bug where depth wasn't really getting highest
-priority in all situations.
-
-4/28/95 (bug fix) Failed text searches starting at "end" could result
-in an infinite loop in Tk.
-
-4/30/95 (new feature) Added "wm resizable" command to enable and
-disable interactive resizing.
-
-4/30/95 (new feature) Added "window names" widget command to texts:
-returns a list of all embedded windows.
-
-5/2/95 (feature change) Changed text searches so that forward searches
-start at the given index, rather than the character just after the
-given index.
-*** POTENTIAL INCOMPATIBILITY with Tk 4.0b3, but not with Tk 3.6 ***
-
-5/4/95 (bug fix) Default bit gravity for windows was wrong (it was
-ForgetGravity) causing unnecessary flashing when windows were resized.
-
-5/4/95 (feature change) Modified Tk_DoOneEvent so that it doesn't
-sleep if there's nothing that will wake it up again (e.g. no file
-or timer handlers). Returns 0 immediately.
-
-5/5/95 (configuration change) Changed to use BSDgettimeofday instead
-of gettimeofday on systems like IRIX where BSDgettimeofday is
-available. This avoids compilation problems due to the different
-interface to gettimeofday provided by IRIX.
-
-5/5/95 (feature change) Changed binding mechanism so that all bindings
-are created immediately at initialization time, rather than waiting
-until the first FocusIn or Enter event for a class.
-
-5/6/95 (feature change) Changed default text for labels, buttons,
-checkbuttons, radiobuttons, menubuttons, and messages from " " to
-"".
-
-5/6/95 (bug fix) If the application was destroyed in the middle of
-an "update" command, Tk would dump core.
-
-5/6/95 (bug fix) Changed manual entries to use the standard .TH
-macro instead of a custom .HS macro; the .HS macro confuses index
-generators like makewhatis.
-
-5/6/95 (bug fix) Change "wm iconwindow" command to disable button
-presses for the icon window. This is needed so that the window
-manager can get those events (X only allows button presses to go
-to one client for a given window).
-
-5/9/95 (new feature) When specifying visuals, can now use "best"
-with a depth, e.g. "-visual {best 8}" to get the best 8-bit visual.
-
-5/18/95 (bug fix) Fixed bug with -spacing* options for text widget:
-screen distances weren't allowed, only integers.
-
-5/20/95 (bug fix) Eliminated memory leaks in tkTextDisp.c and elsewhere.
-
-5/22/95 (color change) Changed the Tk color palette to a gray scheme.
-Also added a library procedure tk_setPalette that makes it easy to
-change colors on the fly, and a procedure tk_bisque that restores the
-previous light brown scheme.
-
-5/28/95 (bug fix) Modified canvases so that the -width and -height
-options refer to the space inside the borders, not the total widget
-space. Also changed "xview" and "yview" commands and scroll-increment
-rounding to use the pixel just inside the borders, rather than (0,0).
-
-5/28/95 (bug fix) Several widgets (e.g. entries, buttons, and menus)
-didn't properly handle unsets of variables they were tracing, if the
-variables were reference through upvars in procedures.
-
-6/4/95 (bug fix) The placer wasn't rounding window widths right when
-both -relx and -relwidth were specified (or -rely and -relheight) so
-that rounding errors accumulated.
-
-6/4/95 (feature improvement) Change parsing of text indices to handle
-weird mark and tag names better (e.g. any string ending with ".first"
-will now be parsed as a tag name, even if it contains embedded spaces,
-etc.).
-
-6/4/95 (feature change) If a font defines glyphs for control characters,
-they are now displayed, instead of translating the character to a
-backslash sequence (however, tabs and newlines are still treated
-specially; glyphs are not displayed for these characters).
-
-6/4/95 (bug fix) Modify the implementation of "raise" and "lower" for
-toplevels so that it now works under olwm and olvwm. It didn't use to
-work, and the problem is really in the window manager, but Tk now
-patches around it. However, only "total" raises and lowers work:
-raising and lowering relative to a sibling still don't work under
-olvwm and olwm.
-
-6/4/95 (feature change) Modified tab code in texts so that a tab always
-occupies at least as much space as a space character.
-
-6/4/95 (bug fix) The "%t" substitution wasn't being made properly in
-Enter and Leave event bindings.
-
-6/7/95 (new feature) Added support for GIF images. Unfortunately it's
-a bit fragile: certain kinds of badly formed images can cause core
-dumps; I don't know enough about the GIF reader (taken from giftoppm)
-to figure this out.
-
-6/7/95 (bug fix and feature change) Fixed PPM image reader to be more
-flexible about header formats, and added support for PGM images.
-
-6/7/95 (feature change) Added -outlinestipple option to canvas arc
-items, changed "-style arc" to use -outline as the color instead of
--fill (the old approach was pretty quirky).
-*** POTENTIAL INCOMPATIBILITY ***
-
-6/8/95 (feature change) Modified interface to Tk_Main to pass in the
-address of the application-specific initialization procedure.
-Tcl_AppInit is no longer hardwired into Tk_Main. This is needed
-in order to make Tcl a shared library.
-
-6/8/95 (feature change) Modified Makefile so that the installed versions
-of wish and libtk.a have version number in them (e.g. wish4.0 and
-libtk4.0.a) and the library directory name also has an embedded version
-number (e.g., /usr/local/lib/tk4.0). This should make it easier for
-Tk 4.0 to coexist with earlier versions.
-
-6/9/95 (new feature) Added -outline and -width options to canvas polygon
-items.
-
-6/9/95 (feature changed) Renamed -decimate in photo widget to -subsample
-(decimate wasn't technically correct).
-*** POTENTIAL INCOMPATIBILITY with Tk 4.0b3, but not with Tk 3.6 ***
-
--------------------- Release 4.0b4, 6/16/95 -------------------------
-
-6/19/95 (bug fix) Colors weren't being rounded correctly in canvas
-Postscript generation: caused "white" to appear slightly gray when
-the display of the canvas used only 8 bits per color.
-
-6/20/95 (bug fix) "bbox" widget command for texts didn't return
-proper width for tabs.
-
-6/20/95 (bug fix) Scrollbars didn't always work right for texts:
-couldn't scroll all the way to the bottom of the text in a single
-drag of the slider.
-
-6/20/95 (new feature) Added "delta" widget command for scrollbars
-(needed for above bug fix).
-
-6/23/95 (bug fix) Listboxes weren't properly redisplaying their
-borders when the were configured to a smaller size.
-
-6/23/95 (new feature) Added "winfo server" command.
-
-6/23/95 (bug fix) If a menu was posted, couldn't switch to another
-menu with an Alt- key.
-
-6/24/95 (new feature) Added "winfo pointerxy" command.
-
-6/25/95 (bug fix) Tk_ParseArgv referenced beyond the end of 0-length
-option names.
-
-6/25/95 (bug fix) Fixed problem in tkOption.c where "cachedWindow"
-could get garbage in it if the main window's class was changed by
-calling Tk_SetClass.
-
-6/25/95 (bug fix) Fixed two bugs in menus, one where errors in
-variable traces weren't propagated correctly and one where "invoke"
-was invoked at the wrong stack level, with the result that variable
-traces didn't have access to the right variables.
-
-6/27/95 (bug fix) tk3d.c wasn't using all the right information
-when deciding whether or not to stipple borders, so it stippled
-borders even on 16-bit true-color displays.
-
-6/28/95 (bug fix) Page up and down operations in texts could cause
-insertion cursor to drift to the right. Changed tkTextScrollPages
-to use upper-left corner of current character, rather than center
-of character.
-
-6/28/95 (bug fix) Changed text widget so that you can't put the
-insertion cursor after the last newline in the text.
-
-6/28/95 (bug fix) Bitmap images didn't allow ~'s in file names.
-
-6/28/95 (bug fix) Fixed problem that could cause core dumps in the
-text widget when dealing with embedded windows (there were problems
-if the act of redisplaying caused the window layout to change, which
-can happen with embedded windows).
-
-6/28/95 (bug fix) Texts didn't handle indices with double negatives,
-such as ".t mark set insert {insert + -20 chars}".
-
-6/28/95 (bug fix) Fixed problem where focus didn't always revert to
-its prior window after a dialog box was dismissed.
-
-6/28/95 (bug fix) Fixed problem with "search" widget command returning
-incorrect length on some backwards regexp searches.
-
-6/28/95 (bug fix) Successive "wm iconbitmap . {}" commands could cause
-a core dump.
-
-6/29/95 (new feature) Added -elementborderwidth option for scrollbars
-so the -borderwidth can be set to 0 without flattening the arrows and
-slider.
-
--------------------- Release 4.0, 7/1/95 -------------------------
-
-7/18/95 (bug fix) %t in event bindings didn't work properly for some
-events (e.g. PropertyNotify).
-
-7/18/95 (bug fix) Changed "exec wish" lines in demo scripts to
-"exec wish4.0" to avoid version conflicts.
-
-7/18/95 (bug fix) Fixed round-off errors in scrolling for texts,
-canvases, listboxes, and entries. The error could cause the view
-to shift up in a command like "$w yview moveto [lindex [$w yview] 0]".
-
-7/19/95 (bug fix) Canvases weren't always redrawing borders correctly
-when they became unobscured. There were also some problems with
-improper refresh after size changes.
-
-7/19/95 (bug fix) Fixed bug in text index processing that causes
-tests textIndex-11.1 and textIndex12.1 to fail on some platforms.
-
-7/19/95 (bug fix) Fixed bug where 2-second delays were ocurring during
-"raise" and "lower" commands for toplevel windows under some window
-managers (such as fvwm).
-
-7/20/95 (bug fix) Text searches were misbehaving when there were embedded
-windows on the starting line of the search. The most common symptom is
-that Tk would fail to find a match at the starting position for the
-search.
-
-7/22/95 (bug fix) Fixed core dump that could occur in menus if a checkbutton
-entry's -variable option referred to an array (or couldn't be read
-by the menu C code for some other reason).
-
-7/22/95 (bug fix) Text widgets didn't update their scrollbars when
-changes were made to information that was off-screen.
-
-7/25/95 (bug fix) Fixed core-dump in tkListbox.c that used to happen
-in the command ".l bbox end" if the listbox was empty.
-
-7/25/95 (bug fix) Page-up and page-down bindings for listboxes didn't
-move active element to remain on the screen.
-
-7/25/95 (bug fix) Patched around H-P compiler problem that results in
-core-dumps in tkImgPhoto.c during image handling.
-
-7/25/95 (bug fix) Fixed bug in tkImgPhoto.c that caused core dumps
-(during Tk self-tests and other image uses) on AIX and other machines
-where "schar" in tkImgPhoto.c was being defined as "short" instead of
-"char".
-
-7/26/95 (bug fix) The PPM image reader couldn't handle maximum intensity
-values other than 255.
-
-7/26/95 (bug fix) Canvases didn't redraw their borders when the relief
-changed from raised to flat.
-
-7/27/95 (bug fix) Canvases didn't set the scrolling values correctly
-when no scroll region was specified.
-
-7/28/95 (bug fix) Modified menu and tk_dialog scripts to restore any
-old grab that might have been in effect before a menu or dialog was
-posted.
-
------------------ Released patch 4.0p1, 7/29/95 ----------------------
-
-8/4/95 (bug fix) Calls to toupper and tolower weren't using the UCHAR
-macro, so they didn't always work in non-U.S. locales. (JO)
-
-8/14/95 (new feature) Added -tearoffcommand option for menus.
-
-8/16/95 (bug fix) Canvases didn't generate proper Enter and Leave
-events if the Leave handler for an item reconfigured the canvas in
-a way that made the old current item the new current item again. (JO)
-
-8/21/95 (bug fix/feature change) When -takefocus was a script, Tk
-was allowing window viewability to override it. Changed so that
-viewability is now ignored when -takefocus is a script. (JO)
-
-8/21/95 (bug fixes) Fixed memory leaks in tkSend.c, tkSelect.c, and
-tkUnixWm.c (JO).
-
-8/21/95 (bug fix) Text widgets didn't handle commands like
-".t search -backwards foo end 1.0" properly: never found foo. (JO)
-
-8/23/95 (new feature) Added Makefile and configure.in support for
-dynamic loading. (JO)
-
-8/25/95 (bug fix) The "frame" and "toplevel" commands couldn't safely
-be renamed, due to a kludgy way that they shared a single command
-procedure. Split into separate procedures. (JO)
-
-8/25/95 (bug fix) Fixed bug in libary/menu.tcl that caused "grab
-window not visible" errors for popup menus (and perhaps elsewhere?). (JO)
-
-8/25/95 (bug fix / new feature) The "gray25" bitmap was really only
-12.5% on, not 25%. Added new "gray12" bitmap that is the same as the
-old "gray25". "Gray25" is still supported for compatibility, but its
-use is deprecated. (JO)
-
-8/25/95 (bug fix) Scrollbar bindings didn't properly handle case where
-B2 is clicked while B1 is already down. (JO)
-
-8/26/95 (bug fix) Menus were ignoring -activebackground if tk_strictMotif
-was set, but not -activeforeground. Changed to ignore both. (JO)
-
-8/26/95 (bug fix) Scales and scrollbars didn't properly handle a
--repeatdelay value of 0 (they shouldn't auto-repeat in this case). (JO)
-
-8/28/95 (bug fix) Tcl errors were occurring for tkPriv(oldGrab) when
-clicking on a disabled option menu. (JO)
-
-8/28/95 (bug fix) Changed event-handling code to use FD_SETSIZE instead
-of OPEN_MAX, since OPEN_MAX is incorrect on some systems (e.g., IRIX). (JO)
-
-8/28/95 (bug fix) Fixed bug in photo images that caused garbling of
-image data in the "put" and "copy" commands if the source data had
-only one scan line but had a width less than the width of the target
-image. (JO)
-
-8/29/95 (bug fix) Tk used to refuse to post menus if they had no
-entries. This made it impossible for a menu to fill itself the first
-time it is posted. Changed to allow menus with no entries to be
-posted. (JO)
-
-8/30/95 (bug fix) If there was extra space at the bottom of a menu,
-it wasn't being redisplayed properly.
-
-8/30/95 (new feature) Added -transient option to menus.
-
-8/30/95 (new features) Added proper button 2 support to both scrollbars
-and scales (it sets the slider position from the mouse position). (JO)
-
-8/30/95 (bug fix) Fixed potential core dump that could occur in
-photo images (ReadPPMFileHeader could overflow buffer under some bad
-inputs, such as certain GIF images). (JO)
-
-8/30/95 (bug fix) Errors of the form `syntax error in expression "!"'
-could occasionally happen in tkScaleDrag. (JO)
-
-8/31/95 (new feature) Changed man page installation (with "mkLinks"
-script) to create additional links for manual pages corresponding to
-each of the procedure and command names described in the pages. (JO)
-
-9/1/95 (new feature) Added "after info" command. Also added checks
-so that one interpreter can't cancel another's "after" events. (JO)
-
-9/8/95 (bug fix) Fixed bug that could cause memory corruption and core
-dumps if a "fileevent" handler was deleted while the handler was
-active. (JO)
-
-9/11/95 Reorganized Tk sources for Windows and Mac ports. All sources
-are now in subdirectories: "generic" contains sources that work on all
-platforms, "windows", "mac", and "unix" directories contain platform-
-specific sources. (SS)
-
-9/11/95 (new feature) Added new "notifier" mechanism to allow multiple
-implementations of the mechanisms for finding out about events. This
-change was necessary to support Mac and PC platforms, but it may also
-allow other goodies such as combining Xt and Tk widgets in a single
-application. See the new manual entry Notifier.3 for details. (SS)
-
-9/11/95 (feature change) Changed interface to Tk_RestrictProc so that
-(a) it takes a clientData argument instead of display and arg, and
-(b) it returns a value that can ask for the event to be discarded as well
-as deferred or processed. (SS)
-*** POTENTIAL INCOMPATIBILITY ***
-
-9/11/95 (new feature) Added TK_WINDOW_EVENTS #define, which is equivalent
-to TK_X_EVENTS but is now preferred, since it applies to all platforms. (SS)
-
-9/11/95 (feature change) Can't export variables anymore because this doesn't
-work under Windows DLLs. Eliminated tk_NumMainWindows variable and replaced
-with procedure Tk_GetNumMainWindows. (SS)
-*** POTENTIAL INCOMPATIBILITY ***
-
-9/11/95 (new feature) Added procedure Tk_PreserveColormap to increment
-the reference count on colormaps. Used in photo widgets. (SS)
-
------------------ Released patch 4.0p2, 9/15/95 ----------------------
-
------------------ Released 4.1a1, 9/15/95 ----------------------
-
-9/22/95 (renamed files) Changed the names of the bitmap images in the
-$tk_library/demos/images directory to use the .bmap file extension. (RJ)
-
-9/22/95 (bug fix) Fixed bug where text widgets could occasionally
-display the insertion cursor both at the end of one line and the
-beginning of the next. (JO)
-
-9/25/95 (bug fix) Fixed bug that could cause core dumps when an
-application uses multiple screens and a binding destroys the main
-window (bind code was using MainInfo structure after it had been
-freed). (JO)
-
-9/25/95 (bug fix) Text widgets sometimes scrolled backwards on
-occasion if you dragged down past the bottom of the scrollbar. (JO)
-
-9/25/95 (bug fix) Fixed bug in menus where a cascaded submenu posted
-from a torn-off menu could be left posted if mouse was pulled off the
-end of the cascade and released. (JO)
-
-9/25/95 (new feature) Added "--" switch to wish, so that you can
-pass arguments like -n through to a script without having wish
-interpret them. (JO)
-
-9/25/95 (bug fix) Fixed core dump that could occur for radiobuttons
-and selectbuttons if -selectcolor was an empty string. (JO)
-
-9/26/95 (bug fix) Entries didn't used to notice if a trace procedure
-on the -textvariable overrode a new value set by the entry. This
-could cause the variable to get out of sync with the contents of the
-entry. (JO)
-
-9/26/95 (new feature) Added -sliderrelief option to scales, changed
-default bindings to change the slider's relief to sunken while it's
-being dragged with the mouse. (JO)
-
-9/26/95 (bug fix) TkColor.c wasn't computing colormap size correctly;
-could result in X Protocol error for QueryColors when colormaps run
-out of colors. (JO)
-
-9/26/95 (bug fix) Wish couldn't handle script files with spaces in
-their names. (JO)
-
-9/27/95 (cosmetic clean-up) Removed extraneous spaces to make error
-messages consistent: ": should be" is now ": should be". (JO)
-
-9/27/95 (feature change) Modified tk_dialog so that it uses the
-option database for the -wraplength option on the message. This
-allows the option to be overridden by the caller. (JO)
-
-9/28/95 (bug fix) Wish incorrectly parsed the command line under
-Windows, causing backslashes to be substituted. (SS)
-
-9/28/95 (bug fix) Wish now sources wishrc.tcl instead of .wishrc. (SS)
-
-9/28/95 (bug fix) Tk_DoOneEvent returned 0 under some circumstances
-when it was possible to find more work to do. For example, if a
-signal interrupted select(), but no event handlers were triggered, it
-would return 0 even though it could still detect events by reentering
-select(). (SS)
-
-9/29/95 (bug fix) "winfo interps" caused a crash under Windows. (SS)
-
-10/1/95 (feature change) Eliminated Tk_NotifyIdle interface in favor of
-Tk_IdlePending. (SS)
-
-10/1/95 (bug fix) Turned motion event collapsing into an idle handler
-so it will be easier to move the event loop into Tcl. (SS)
-
-10/1/95 (bug fix) Fixed several problems with negative coordinates
-in canvases. One example: dragging a canvas rectangle with a wide
-border and fractional coordinates could leave junk on the screen
-if the rectangle was in negative coordinate space. (JO)
-
-10/2/95 (bug fix) Tk was improperly handling Enter/Leave events
-during a button grab. (SS)
-
-10/2/95 (new feature) Added support for the Macintosh do script
-('dosc') event. Available only on the Macintosh. (RJ)
-
-10/4/95 (new feature) Added support for compiling with VC++.
-Resulting binaries work under Win32s through NT.
-
------------------ Released 4.1a2, 10/6/95 ----------------------
-
-10/10/95 (new feature) Macintosh Tk now supports the complete set
-of X cursors that Unix Tk supports. (RJ)
-
-10/11/95 (bug fix) Tk now supports all of the X11 cursors under
-Windows. (SS)
-
-10/11/95 (bug fix) The "wm resizable" command was missing from the
-Windows version of Tk. (SS)
-
-10/12/95 (bug fix) Macintosh Tk had problems with clipping toplevel
-windows that children of any frame other than another toplevel. (RJ)
-
-10/13/95 (bug fix) Eliminated dependency on MKS toolkit for generating
-the tk.def file from Borland object files. (SS)
-
-10/16/95 (bug fix) Fixed clipping and update problems relating to
-the raising and lowering of overlapping windows on Mac. (RJ)
-
-10/30/95 (bug fix) When focus-follows-mode (invoked via tk_focusFollowsMouse),
-was focussing on windows even in situations where keyboard traversal would
-skip the window. Changed to use the tkFocusOK procedure so that the
-criteria for focussing are the same in both modes. (JO)
-
-11/2/95 (bug fix) Changed listbox bindings to ignore double-clicks.
-This avoids errors that used to occur if a user defined a binding
-for double-click that deleted the listbox. (JO)
-
-11/3/95 (feature change) Moved most of the Tk event loop to Tcl. Many
-Tk_ names have become Tcl names now:
-
-TK_READABLE => TCL_READABLE
-TK_WRITABLE => TCL_WRITABLE
-TK_EXCEPTION => TCL_EXCEPTION
-TK_DONT_WAIT => TCL_DONT_WAIT
-TK_WINDOW_EVENTS => TCL_WINDOW_EVENTS
-TK_FILE_EVENTS => TCL_FILE_EVENTS
-TK_TIMER_EVENTS => TCL_TIMER_EVENTS
-TK_IDLE_EVENTS => TCL_IDLE_EVENTS
-TK_ALL_EVENTS => TCL_ALL_EVENTS
-Tk_IdleProc => Tcl_IdleProc
-Tk_FileProc => Tcl_FileProc
-Tk_TimerProc => Tcl_TimerProc
-Tk_TimerToken => Tcl_TimerToken
-Tk_BackgroundError => Tcl_BackgroundError
-Tk_CancelIdleCall => Tcl_CancelIdleCall
-Tk_CreateFileHandler => Tcl_CreateFileHandler
-Tk_CreateTimerHandler =>Tcl_CreateTimerHandler
-Tk_DeleteFileHandler => Tcl_DeleteFileHandler
-Tk_DeleteTimerHandler =>Tk_DeleteTimerHandler
-Tk_DoOneEvent => Tcl_DoOneEvent
-Tk_DoWhenIdle => Tcl_DoWhenIdle
-Tk_Sleep => Tcl_Sleep
-tkerror => bgerror
-
-Other than the name changes, the functions are the same. In addition,
-there are #defines in tk.h so that the old Tk names will still work.
-tkerror and bgerror are specially hacked as synonyms, so it should be
-safe to use either one. You should switch to the new Tcl names ASAP,
-though, since the old Tk names will eventually be desupported. (JO)
-
-11/7/95 (features removed) As part of moving the event loop to Tcl,
-the following procedures were deleted:
- - Tk_EventInit (the presence of the event loop in Tcl should
- make this unneccessary).
- - Tk_CreatFileHandler2 (you can get the same effect by using event
- sources in Tcl, but you have to modify your code to use the new
- Tcl APIs).
- - All of the stuff in the manual entries Notifer.3 and QueueEvent.3;
- this has changed because the notifier got reworked when it was
- moved to Tcl.
-*** POTENTIAL INCOMPATIBILITY ***
-
-11/7/95 (feature change) Changed to use exit handler to cleanup windows
-in Tk, so Tk no longer needs to have a private copy of the "exit" command.
-(JO)
-
-11/7/95 (bug fix) If wish was invoked with a command-line geometry and
-a script file (e.g. "wish foo.tcl -geometry 30x20"), and if one of
-the windows created by the script used the -setgrid option, then the
-width and height from the command line were lost. (JO)
-
-11/8/95 (bug fix) The "see" command didn't work quite right for texts:
-if the window was small and you try to "see" a line just offscreen,
-Tk centered the line (actually, mis-centered it) when it should have
-aligned it at the top or bottom. (JO)
-
-11/9/95 (bug fix) The "send" command crashed if you tried to send to
-a different display with "-displayof". (JO)
-
-11/9/95 (bug fix) The Symbol font didn't print right in Postscript
-output, because of changes made to re-encode fonts to get proper
-ISO Latin1 behavior. Changed the code not to re-encode the Symbol
-font. (JO)
-
-11/13/95 (bug fix) Fixed Makefile.in and configure.in for UNIX so that
-configure can be run from a clean directory separate from the Tcl source
-tree, and compilations can be performed there. (JO)
-
-11/17/95 (bug fix) If a window was gridded, Tk still computed the
-default maximum dimensions in pixel units, which resulted in windows
-that could grow much larger than the screen. (JO)
-
-11/17/95 (bug fix) If a menus entries were all disabled, posting
-the menu and typing Up or Down caused an infinite loop, locking
-up the screen (JO).
-
-11/19/95 (bug fix) The focus wasn't being restored properly after a
-menu selection in a cascaded menu. (JO)
-
-11/19/95 (bug fix) Menubutton's didn't stipple display their images
-differently when disabled. Change to have the same behavior as buttons:
-the image is stippled over in the background color when the menubutton
-is disabled. (JO)
-
-11/21/95 (bug fix) Changes in display attributes such as font could
-cause core dumps in the text widget under some circumstances involving
-line wrapping. (JO)
-
-11/22/95 (bug fix/new feature) Changed both the placer and the packer
-to ensure that slaves are unmapped whenever the master is unmapped.
-This saves time that slaves might otherwise spend trying to redisplay
-themselves when they're unmapped. (JO)
-
-11/22/95 (bug fix) Space and return keys didn't work for menus if
-they were posted via Alt-x keystrokes. (JO)
-
-11/24/95 (bug fix) tk_dialog procedure had binding for <Return> that
-always activated default binding, even if input focus was in some
-other binding. Removed this feature, since existing focus support
-will already "do the right thing". (JO)
-
-11/24/95 (bug fix) Both canvases and texts could dump core if a binding
-(such as ButtonRelease on an internal item) deleted the widget. (JO)
-
-11/24/95 (feature change) Replaced "configInfo" file with tkConfig.sh,
-which is more complete and uses slightly different names. Also
-arranged for tkConfig.sh to be installed in the platform-specific
-library directory. (JO)
-
-11/24/95 (bug fix) It was possible for a slave to be placed or packed
--in itself, with unpleasant consequences. It is now an error for the
-slave to be its own master for geometry management. (JO)
-
-11/25/95 (bug fix) The -command option of scales was sometimes being
-invoked spuriously (e.g. when the mouse moved in the scale without a
-button down). This was because the scale wasn't rounding properly
-when setting the scale value from its associated variable. (JO)
-
------------------ Released patch 4.0p3, 11/28/95 ----------------------
-
-12/18/95 (feature change) Moved Tk_Preserve, Tk_Release, and
-Tk_EventuallyFree to Tcl, renamed to Tcl_Preserve etc. Added #defines
-to tk.h so that the old names still work. (JO)
-
-12/23/95 (bug fix) If a single process had > 1 Tk application, Tk
-didn't guarantee that the application names were unique, which could
-cause all sorts of confusion with "send". (JO)
-
-12/23/95 (feature change) Eliminated Tk_CreateMainWindow and moved
-all of its functionality to Tk_Init. All that you need to do now
-to get Tk in an application is to call Tk_Init. Improved Tk_Init
-so that -colormap and -visual command-line arguments are now passed
-through to TkCreateFrame. Tk_Main is much simpler now, since a lot
-of its functionality has moved to Tk_Init. (JO)
-*** POTENTIAL INCOMPATIBILITY ***
-
-12/23/95 (new feature) Added support for Tcl_StaticPackage so
-that Tk can now be loaded into slave interpreters with the "load"
-command to create new applications. (JO)
-
-12/23/95 (new features) Added support for -colormap and -visual command-
-line options for wish. (JO)
-
-1/4/95 (bug fix) Fixed keyboard code to properly handle alt-key
-sequences for international keyboards and menu-accelerators. (SS)
-
-1/5/96 (bug fix) Scrollbar code sometimes generated errors on accesses
-to tkPriv(relief) during control-clicks. (JO)
-
-1/9/96 (new feature) added the "grid" command to provide a table based
-geometry manager. (SU)
-
-1/12/96 (performance optimization) Changed the way tag information is kept
-in the text's Btree so the cost of adding and removing tag ranges is no longer
-proportional to the number of unique tags in the text. In the old system
-the cost of adding N unique tags was O(N-squared). The new implementation is
-optimized for tags that only cover a small amount of text, measuring from
-their earliest tag range to the end of their last range. In the best case the
-cost of adding a tag range is unrelated to the number of unique tags, so the
-cost of adding N tags is only O(N). In the worst case, where all tags
-cover all the text, the cost is still O(N-squared) to add N such tags.
-Deleting tags still has an O(N) cost (so deleting N tags is O(N-squared),
-but it is now a factor of 2 faster than the old system. (BW)
-
-1/12/96 (new feature) added the text "dump" operation that returns information
-about all elements in a text widget: text, tags, marks, and windows. (BW)
-
-1/12/96 (new feature) added the text "mark next" and "mark previous" operations
-to search forward and backwards for the next (previous) mark in the text. (BW)
-
-1/12/96 (new feature) added the text "tag prevrange" operation to search
-backwards for the current or previous range of a tag. (BW)
-
-1/16/96 (new feature) Added support for relative widget placement on
-the "grid" command. (SU)
-
-1/17/96 (new feature) Modified the Makefile/configure setup to support
-compiling Tk as a shared library. Use the --enable-shared option to
-the "configure" script. (JO)
-
------------------ Released 4.1b1, 1/26/96 -----------------------
-
-2/2/96 (bug fix) Frames were getting a default size of 200x200, whereas
-there should be no default. (JO)
-
-2/2/96 (bug fix) Argc wasn't getting reset properly after Tk removed
-the arguments it understood from those on the command line. (JO)
-
-2/6/96 (bug fix) Fixed off by one error in argument parsing code under
-Windows. (SS)
-
-2/6/96 (bug fix) "wm transient" now works under Windows. The resulting
-toplevel is created with a modal dialog box frame and will not appear
-in the taskbar under Windows '95. (SS)
-
-2/9/96 (bug fix) Changed Makefile.in to use -L and -l for Tcl and Tk
-libraries so that shared libraries are more likely to be found correctly
-on more platforms. (JO)
-
-2/14/96 (feature change) Eliminated tk_CanvasTagsOption variable because
-it can't be exported safely across DLL boundaries. Instead, exported
-Tk_CanvasTagsParseProc and Tk_CanvasTagsPrintProc procedures for
-use by canvas type managers in creating their own custom options. (JO)
-*** POTENTIAL INCOMPATIBILITY ***
-
-2/14/96 (bug fix) "winfo pointerxy" when applied to a non-toplevel window
-crashed wish. (SS)
-
-2/14/96 (bug fix) "tkwait visibility" would hang under Windows. (SS)
-
-2/14/96 (bug fix) Cursors were not being updated until an enter event.
-In cases where the cursor left the toplevel and reentered before Tk
-noticed, the cursor would get "stuck" until the next enter event.
-Similarly, if the cursor attribute of a window was updated while the
-mouse was in the window, the cursor would not change until the next
-time the mouse entered the window. (SS)
-
-2/15/96 (bug fix) If a top-level was resizable in one direction
-(e.g. "wm resizable . 0 1"), once the user resized it any changes
-in the internally requested size (by the widgets) were ignored,
-even for the non-resizable dimension. Fixed to handle the two
-dimensions totally independently, so the widget's requests are
-honored as long as that dimension hasn't been set by the user. (JO)
-
-2/17/96 (bug fix) If a text widget had very long lines (e.g. more than
-32K pixels), integer overflow could occur, resulting in parts of the
-line not being visible. (JO)
-
-2/20/96 (feature change) Changed the -minsize option of grid to take
-screen units instead of pixels. (SU)
-
-2/20/96 (bug fix) grid row and column weights are compared against
-MINWEIGHT (0.001) instead of 0.0 to guard against divide by zero errors
-during weight normalization. (SU)
-
-2/20/96 (bug fix) Menu commands were not being invoked sometimes.
-There was a race condition that caused events to be processed while a
-menu was being unposted. (SS)
-
------------------ Released 4.1b2, 2/23/96 -----------------------
-
-2/23/96 (bug fix) Alt-keys invoked in torn-off and popped up menus
-caused menus to be posted in the parent toplevel. (JO)
-
-2/23/96 (bug fix) Canvases weren't always updating their scrollbars
-when they should. (JO)
-
-2/23/96 (bug fix) Fixed core dump that could occur if a WM_DELETE_PROTOCOL
-handler generated an error. (JO)
-
-2/24/96 (bug fix) Removed dependencies on Makefile in the UNIX Makefile:
-this caused problems on some platforms (like Linux?). (JO)
-
-2/24/96 (feature change) Changed text and entry widgets so that they
-set the insertion cursor before inserting during a button-2 click.
-Also made optional bindings check for tk_strictMotif at the time of
-the event, rather than at the time the bindings are created. (JO)
-
-2/24/96 (bug fix) Tk tended to crash with an X error when unsetting
-an icon window (e.g. "wm iconwindow . {}"). (JO)
-
-2/25/96 (bug fix) Wasn't removing windows from the WM_COLORMAP_WINDOWS
-property when they were deleted. (JO)
-
-3/1/96 (new feature) Added new "bbox" widget command for entries.
-Also modified mouse bindings for entries and texts so that the
-mouse position rounds to the nearest inter-character gap, rather
-than the left edge of the character under the mouse. This provides
-more natural selection behavior. (JO)
-
-3/1/96 (bug fix) Fixed core dump that could occur in image code if an
-image was deleted while in use in a widet, then re-used in another
-widget while "deleted". (JO)
-
-3/1/96 (bug fix) Calling wish with a single argument caused a crash
-under Windows due to an off-by-one error in the argument parsing code. (SS)
-
-3/1/96 (bug fix) Palette management was broken and resulted in
-incorrect palette realization and refresh behavior. Also, images were
-being drawn incorrectly if they were attached to widgets that had a
-private colormap. (SS)
-
-3/2/96 (bug fix) It was possible to press the mouse button over an
-option menu, drag to a pulldown menu, and have the pulldown menu
-popup in place of the option menu. Fixed this so that option menus
-are isolated from each other and from pulldowns. (JO)
-
-3/2/96 (bug fix) Fixed yet another bug that caused long delays when
-raising toplevel windows. (JO)
-
-3/2/96 (bug fix) Fixed bug in canvases where zero-sized rectangles
-and ovals didn't always redisplay right (could leave trailing
-garbage on screen when moved). (JO)
-
-3/2/96 (bug fix) Entry widgets reset their insertion cursor, selection,
-and view whenever the text variable changed, plus whenever a "configure"
-widget command was invoked and there was a text variable for the
-widget. Fixed to preserve this information as much as possible. (JO)
-
-3/5/96 (new feature) Added version suffix to shared library names so that
-Tk will compile under NetBSD and FreeBSD (I hope). (JO)
-
-3/6/96 (bug fix) Changed the way certain configure & motion events are
-reported. This fixes several bugs in menus & "winfo rootx". (RJ)
-
-3/7/96 (bug fix) Fixed tag remove bug that showed up when draging out a
-selection. If you had dragged left, then tried to drag back right, the
-left edge of the selection wasn't being updated because the tag remove
-wasn't doing anything. (BW)
-
-3/7/96 (bug fix) Fixed the boundary conditions of tag prevrange. The second
-index argument wasn't effecting in stopping the search if it fell within
-a range. The second index has to come at or before the start of a range
-for the range to be found by tag prevrange. (BW)
-
-3/7/96 (bug fix) "puts" to stdout or stderr when running from a script
-caused wish41.exe to exit silently. Now the output is silently
-discarded without generating an error. (SS)
-
-3/7/96 (bug fix) Fixed bug where wish was treating empty lines in the input
-as end of input, if the input came from stdin. This would cause it to
-complain about missing closing braces etc. (JL)
-
------------------ Released 4.1b3, 3/8/96 -----------------------
-
-3/9/96 (bug fix) Fixed bug in text.tcl that could cause errors in text
-widgets of the form 'can't use non-numeric string as operand of "-"'. (JO)
-
-3/12/96 (feature improvement) Modified startup script to look in several
-different places for the Tcl library directory. This should allow tk
-to find the libraries under all but the weirdest conditions, even without
-the TK_LIBRARY environment variable being set. (JO)
-
-3/14/96 (bug fix) "wish bogus_file_name" didn't print an error message. (JO)
-
-3/14/96 (bug fix) Button-2 wasn't claiming the focus during paste
-operations. (JO)
-
-3/14/96 (bug fix) "tkwait visibility" use to hang forever if its window
-was deleted. Now it detects this condition and returns an error. (JO)
-
-3/16/96 (bug fix) Changed configuration stuff to get dynamic loading and
-shared libraries working under AIX. (JO)
-
-3/16/96 (bug fix) Fixed core dumps that could occur when a slave interpreter
-was deleted in the middle of executin bindings. (JO)
-
-3/18/96 (new feature) Added support for Activate/Deactivate events.
-Currently, these new X events will generated only on the Macintosh. (RJ/CS)
-
-3/21/96 (bug fix) The "tag prevrange" command would fail to return the current
-range if it began at 1.0 and the starting point of the search was within
-the range. (BW)
-
-3/21/96 (configuration improvement) Changed configure script so it
-doesn't use version numbers (as in -ltk4.1 and libtk4.1.so) under
-SunOS 4.1, where they don't work anyway. (JO)
-
-3/22/96 (bug fix) Made Tk more robust against interpreter deletion. Now it
-should be safe to delete an interpreter with a Tk application inside it,
-without first deleting the Tk application. (JL)
-
-3/26/96 (bug fix) Tk now returns results from a "send" to an interpreter
-in which the Tk application is destroyed, if the interpreter continues
-computing after the Tk application is destroyed. Previously any results
-computed after '.' was destroyed in the target interpreter were discarded
-by the "send". (JL)
-
-3/26/96 (new feature) Tk now provides a static Tktest package which is
-present only in test versions of Tk; this allows the testing commands to
-be loaded into new interpreters besides the main one. (JL)
-
-3/28/96 (bug fix) Changed the tk_dialog procedure *not* to make the
-dialog a transient for its parent. The old behavior meant that the
-dialog did not get posted if the parent was iconified. (JO)
-
-4/5/96 (bug fix) Tk would occasionally crash when destroying toplevels
-under Windows. (SS)
-
-4/5/96 (bug fix) Fonts were not being properly deallocated, causing
-GDI resources to be consumed and never released under Windows. (SS)
-
-4/11/96 (bug fix) Toplevel windows with no specified geometry were
-always appearing in the upper left corner of the screen under
-Windows. (SS)
-
-4/11/96 (bug fix) "wm minsize" did not properly report the minimum
-size imposed by the Windows window manager. (SS)
-
-4/13/96 (bug fix) Text widgets could dump core in some cases where
-text was inserted on the top visible line. (JO)
-
-4/16/96 (bug fix) Changed menu code to ignore errors that occur when
-restoring a grab: the old grab window might not be visible anymore. (JO)
-
------------------ Released 4.1, 4/21/96 -----------------------
-
-5/1/96 (bug fix) "option readfile" did not handle files with CRLF
-line termination. (SS)
-
-5/1/96 (bug fix) Changed to install tkConfig.sh under "make install-binaries",
-not "make install-libraries". (JO)
-
-5/7/96 (bug fix) Moved initScript in tkUnixInit.c to writable memory to
-avoid potential core dumps. (JO)
-
-5/7/96 (bug fix) Changed tk_dialog back so that the dialog box is a
-transient window again. This is needed to make sure that the dialog
-box doesn't get obscured. Also changed it to return -1 if the dialog
-window is deleted before the user presses a button. (JO)
-
-5/16/96 (bug fix) Fixed bug that caused core-dumps if a text widget
-with -setgrid 1 was deleted by removing its command. (JO)
-
-5/16/96 (bug fix) Fixed bug that caused Tk initialization to use improperly
-initialized variables left over from previous invocation of Tk_Init on
-another interpreter. (JL)
-
-5/16/96 (new feature) Implemented application embedding on Windows
-platforms (only Tk inside another application, not the other way yet). (JL)
-
-5/16/96 (new feature) Added C API Tk_SafeInit that adds Tk to a safe
-interpreter. (JL)
-
-5/16/96 (bug fix) Fixed bug that caused Tk initialization to use improperly
-initialized variables left over from previous invocation of Tk_Init on
-another interpreter. (JL)
-
-5/16/96 (new feature) Implemented application embedding on Windows
-platforms (only Tk inside another application, not the other way yet). (JL)
-
-5/16/96 (new feature) Added C API Tk_SafeInit that adds Tk to a safe
-interpreter. (JL)
-
-5/22/96 (bug fix) Listboxes weren't properly ignoring double clicks on
-button 1. (JO)
-
-6/12/96 (bug fix) Focus was automatically placed on new toplevels.
-This caused the titlebar to flash during menubar traversal. (SS)
-
-6/12/96 (bug fix) Iconification of a window with a specified geometry
-by using the minimize button would leave the window in an inconsistent
-state. When the window was deiconified using "wm deiconify", the
-window would continue to display as an icon with the deiconified
-geometry. (SS)
-
-6/12/96 (bug fix) Fixed a resource leak where the text widget was not
-freeing all of the TkRegions it created. This fix affects all
-platforms, but is particularly important for Win32s. (SS)
-
-6/21/96 (configuration change) Added --enable-gcc switch to configure
-script to make Tk just like Tcl. Now Tk will not use gcc unless you
-request it explicitly. (JO)
-
-7/18/96 (bug fix) Changed "configure" script to add an extra -R switch
-(or whatever is appropriate to the platform) if the X library is in a
-nonstandard place. This guarantees that the shared library can be
-found at runtime without having to set the LD_LIBRARY_PATH variable. (JO)
-
-7/19/96 (bug fix) Fixed bug in tkImgGIF.c that cause core dumps if a
-GIF file contained multiple images. (JO)
-
-7/20/96 (bug fix) Deadlock could occur if a recursive series of send
-operations involved multiple displays. (JO)
-
-7/23/96 (bug fix) Fixed a resource leak where deallocated XIDs were
-taking up memory on Windows and Macintosh platforms. (SS)
-
-7/30/96 (bug fix) A core dump could occur if a <Destroy> handler for
-a window tried to create a child in the half-dead window. Fixed by
-making the window's name disappear from the name table once it starts
-to be deleted. (JO)
-
------------------ Released patch 4.1p1, 8/2/96 -----------------------
-
-4/30/96 (new feature) Added support for named virtual events. New "event"
-command to define/destroy named virtual events and to programmatically
-send both real and virtual events to Tk. (CS)
-
-8/6/96 (bug fix) Entry widgets were invoking scrollbar update functions
-too often. (JO)
-
-8/9/96 (bug fix) 7/30 change above for <Destroy> handlers broke many
-things by making window available during Destroy handler. Reworked
-fix for core dump to simply disallow creating children of half-dead
-parents. (JO)
-
-8/12/96 (bug fix) Fixed bug where using the Copy menu item on the
-Macintosh would append a NULL character at the end of the text. (RJ)
-
-8/15/96 (bug fix) Fixed Mac code so garbage wouldn't be printed in
-text and entry widgets when function & other non-printing keys were
-pressed. (RJ)
-
-8/15/96 (configuration improvement) Changed the file patchlevel.h
-to be tkPatch.h. This avoids conflict with the Tcl file and is now
-in 8.3 format on the Windows platform. (RJ)
-
-8/19/96 (bug fix) Fixed a bug under Windows where the initial window
-position for a toplevel window was reported as +0+0, regardless of the
-actual position. (SS)
-
-8/21/96 (bug fix) If the last character on a line in a text widget was
-a space character that didn't completely fit, the text widget would
-sometimes add an extra wrap line. (JO)
-
-8/22/96 (feature change) Complete rewrite of the grid geometry manager.
-There is a new layout algorithm that produces better (but different)
-layouts in many common cases. (SU)
-
-8/22/96 (new feature) There are two new options for the grid geometry
-manager, "grid update" which forces an immediate layout calculation,
-and a "-pad" option to rowconfigure and columnconfigure that allows for
-extra space around widgets. (SU)
-
-8/22/96 (feature change) The order in which the grid geometry manager
-reports slaves is now last-managed first. (SU)
-
-8/22/96 (feature change) The column and row weights in the grid
-geometry manager are kept internally as integers, instead of floating
-point values. Floating point values are still accepted on the command line,
-but are truncated to integers. (SU)
-
-8/22/96 (new feature) There are four new commands for opening common
-dialog boxes: tk_chooseColor, tk_getOpenFile, tk_getSaveFile and
-tk_messageBox. Native dialog boxes are used wherever available. (IL)
-
-8/22/96 (new demos) Added "fsbox", "msgbox" and "clrpick" demos. (IL)
-
-8/23/96 (feature change) Invoking the edit menu on the Macintosh now
-generates the following virtual events <<Cut>>, <<Copy>>, <<Paste>>,
-and <<Clear>> instead of faking key events. (RJ)
-*** POTENTIAL INCOMPATIBILITY ***
-
-8/25/96 (bug fix) Fixed a bug that would cause "grid x" to dump core. (SU)
-
-8/26/96 (new feature) Added the "unsupported1" command to the
-Macintosh version of Tk. This command will allow you to set the style
-of a new toplevel Window (much like overrideredirect). You can use
-this to get access to all of the Native Mac window styles. This is to
-hold you over until we get a more general solution added to the
-toplevel command. (RJ)
-
-8/26/96 (new feature) Added support to handle the zoom box on a
-Macintosh window. (Currently, you can only get a Tk window with a
-zoom box by using the "unsupported1" command. (RJ)
-
-8/27/96 (documentation change) Removed old change bars (for changes in
-Tk 4.1 and earlier releases) from manual entries. (JO)
-
------------------ Released 4.2b1, 8/30/96 -----------------------
-
-9/5/96 (bug fixes) Fixed several bugs in file dialogs: individual files
-could be listed twice, if a long list of files were shown, and the view
-scrolled to the right, and then a different file file was shown, the
-scrollregion on the canvas wasn't being reset, so the file dialog was
-broken from then on, added an update idletasks so that the watch
-cursor was shown when the dialog was thinking. For the motif file
-dialog, fixed the weights for resizing. On the clrpicker, fixed the
-finalColor variable which caused problems when the OK button was
-"clicked" before the dialog was mapped (in the test suite). Added Ioi's
-last changes from before he left. For message boxes, if a single button
-message box is shown (currently only 'ok'), it is set to be the default
-even if not specified. (KC)
-
-9/5/96 (bug fix) Fixed bug on Macintosh where menus would appear in a
-seemingly random location. (RJ)
-
-9/5/96 (bug fix) Text widgets had rounding problems with the "yview"
-command that caused them sometimes to round to the line before the
-correct one. (JO)
-
-9/5/96 (bug fix) Changed grab code to retry grabs after errors where
-another application already has the grab. This is needed to get
-around race conditions with some window managers and will hopefully
-solve the grab errors that people see occasionally. (JO)
-
-9/6/96 (bug fix) Fixed x-y coordinate confusion problem with scaling
-of window items in canvases. (JO)
-
-9/11/96 (bug fix) The open and save file dialogs would change the
-current working directory under Windows. (SS)
-
-9/12/96 (bug fix) The Tk event system was delivering events to dead
-windows, if the event handler got reentered during a Destroy event
-handler. This could cause core dumps and other problems. (JO)
-
-9/20/96 (bug fix) In XFillRectangles under Windows, a brush was not
-being deallocated. (SS)
-
-9/20/96 (bug fix) The Mac window manager used to generate a mouseUp
-event for a top level that was recently raised to the front/active
-window which often caused a tk(priv) error. The up event is no
-longer generated with solves several problems. (RJ)
-
-9/25/96 (bug fix) The font code under Windows was leaking memory
-whenever a new font was referenced using the three part font names. (SS)
-
-9/26/96 (bug fix) The tests for the common dialogs still used the 'testevent'
-function. I updated these calls in clrpick.test, msgbox.test, filebox.test
-to use the new event gereating mechanism.
-
-9/18/96 (bug fix) Long-standing bug in bind where <Button-1><Button-1> was
-reported as <Double-Button-1>, but <Double-Key-a> was reported as "aa". (CS)
-
-9/27/96 (bug fix) Bindings didn't work on 64-bit machines due to changes
-made for virtual events. (CS)
-
-9/30/96 (feature change) Binding for new virtual events included both
-lower and upper-case, e.g., <<Copy>> was defined as <Control-c> and
-<Control-C>. Previously, widgets were directly bound to only lower-case
-bindings. The upper-case binding caused incompatibility with some existing
-Tcl programs, so the upper case bindings for <<Cut>>, <<Copy>>, and <<Paste>>
-were removed. (CS)
-
-9/30/96 (bug fix) The postscript code in the canvas widget now uses
-channels to get and write .ps files which fixed a bug on the Mac where
-an output file would have mixed EOL characters. In addition, I added
-the ability for the prolog to come from the Tk shared library on the
-Mac which makes it possible to have a standalone application. (RJ)
-
-10/1/96 (feature change) "grid forget" was renamed "grid remove". A new
-command "grid forget" was added whose semantics are the same as "pack forget"
-(SAU)
-*** POTENTIAL INCOMPATIBILITY ***
-
-10/1/96 (feature change) grid no longer accepts floating point values for
-row or column weights, integers must be used. (SAU)
-*** POTENTIAL INCOMPATIBILITY ***
-
-10/1/96 (feature change) "grid {column,row}configure <master> <index>"
-returns a list of option value pairs for all of the row or column
-constraints. It used to return an error. (SAU)
-
-10/1/96 (bug fix) "The way grid handles '^' short-cuts was re-written
-to eliminate core dumps. (SAU)
-
-10/3/96 (feature change) A virtual event binding associated with a
-given physical event is now considered less specific than a binding for
-that same physical event, all other things being equal. (CS).
-
-10/3/96 (bug fix) Under Windows text placed on the clipboard did not
-undergo CRLF translation when delivered to other applications. (SS)
-
-10/3/96 (bug fix) Copying an image onto itself with a zoom factor that
-caused the image to grow was accessing freed memory. (SS)
-
-10/3/96 (bug fix) Under Windows, the image blank subcommand did not
-work. (SS)
-
-10/10/96 (bug fix) Under Windows & Macintosh, XSetFont and XChangeGC
-were not implemented, and XSetLineAttributes did not correctly update
-the GC. (SS)
-
-10/10/96 (bug fix) Under Windows, 8-bit non-palette displays were not
-handled properly. (SS)
-
-10/10/96 (bug fix) Under Windows, images of depth other than 8 or 24
-bits were not being rendered properly. (SS)
-
-10/10/96 (bug fix) Under Windows, bitmap subimages were not correctly
-displayed. (SS)
-
-10/14/96 (bug fix) Under Window, wm resizable would constrain both
-programatic resizes as well as user resizes. (SS)
-
------------------ Released 4.2, 10/16/96 -----------------------
-
-10/17/96 (bug fix) XCopyPlane was broken under Windows and would cause
-a crash when used with a clipping bitmap. (SS)
-
-10/21/96 (bug fix) Added missing resources needed by tk_getOpenDialog
-on the Macintosh to the shared library for Tk. (RJ)
-
-10/22/96 (bug fix) Invoking a menu with an Alt key sequence caused an
-error due to a misplaced common in library/menu.tcl. (JO)
-
-10/23/96 (bug fix) Errors in files sourced by the Macintosh
-"Source..." menu are now correctly reported via the background
-error mechanism. (RJ)
-
-10/23/96 (bug fix) Fixed a bug in the Mac subwindow implementation
-that caused refreshes to not occur for canvases with embedded
-windows. (RJ)
-
-10/24/96 (bug fix) Provided workaround for Apple bug that doesn't
-handle zooming correctly for floating windows. (RJ)
-
-10/24/96 (bug fix) Macintosh tearoff menus are now correctly
-displayed as Mac floating windows. (RJ)
-
-11/1/96 (bug fix) Restored manual page for procedures like
-Tk_CreateWindowFromPath and Tk_DestroyWindow; was accidentally deleted
-when Tk_CreateMainWindow procedure was decommissioned. (JO)
-
-11/19/96 (bug fix) Fixed bugs in postscript code that would cause the
-prefix to not be included and the output file to have the wrong
-permissions. (RJ)
-
-12/2/96 (bug fix) Fixed problem with canvas lines where it didn't
-compute bounding boxes correctly for zero-width lines: this could
-potentially leave garbage on the screen when items were deleted or
-moved. (JO)
-
-12/5/96 (bug fix) Fixed the Macintosh implementation of pointer x/y
-which was returning garbage. (RJ)
-
-12/6/96 (bug fix) Fixed grid bug where the positioning of slaves was
-incorrect for non-zero values of ipadx and ipady (SU)
-
-12/6/96 (bug fix) Fixed grid bug where slaves got "lost" when an
-already managed slave is re-managed in a different master. (SAU)
-
------------------ Released 4.2p1, 12/8/96 (Mac only) --------------
-
-1/17/97 (bug fix) Fixed bug where the Tk clipboard was not in sync
-with the Macintosh clipboard on start-up. (RJ)
-
------------------ Released 4.2p2, 1/31/97 --------------
-
-----------------------------------------------------------
-Changes for Tk 4.2 go above this line.
-Changes for Tk 4.3 go below this line.
-----------------------------------------------------------
-
-9/19/96 (improvement) Implemented table driven mechanism for deciding
-whether a command is safe. If it is added by Tk_Init and it appears in the
-table then it is kept, otherwise it is removed in a safe interpreter. (JL)
-
-10/18/96 (new feature) Added support for application embedding:
- - Frame and toplevel widgets now have a -container option, which
- turns the widget into a container.
- - Toplevel widgets have a -use option for requesting that the
- widget be embedded in another application.
- - Wish also supports a -use command-line option.
-Embedding is fully supported under Unix, but the implementation is
-not complete under Windows or the Macintosh (it works just well
-enough to support the Tcl/Tk plugin). (JO)
-
-10/22/96 (bug fix) The commands "winfo rootx" and "winfo rooty" didn't
-work for non-toplevel windows in embedded applications: they returned
-the coordinates of the nearest toplevel. (JO)
-
-12/02/96 (new feature) Implemented Safe Tk. Tk can now be loaded into a
-safe interpreter that has been created with tcl_safeCreateInterp, by
-calling load {} Tk interpname. (JL)
-
-12/02/96 (new feature) A safe Tk interpreter can no longer generate
-postscript output from a canvas. (JL)
-
-12/02/96 (new feature) Added -channel option to photo command to allow
-image data to be read from a channel. This is useful in safe Tk
-interpreters where the data cannot be read directly from a file. (JL)
-
-----------------------------------------------------------
-Changes for Tk 4.3 go above this line.
-Changes for Tk 8.0 go below this line.
-----------------------------------------------------------
-
-9/1/96 (new features) The font mechanism in Tk has been completely
-reworked:
- - Font names need not be nasty X LFDs: more intuitive names like
- {Times 12 Bold} can also be used. See the manual entry font.n
- for details.
- - Font requests always succeed now. If the requested font is not
- available, Tk finds the closest available font and uses that one.
- - Tk now supports named fonts whose precise attributes can be
- changed dynamically. If a named font is changed, any widget
- using that font updates itself to reflect the change.
- - There is a new command "font" for creating named fonts and querying
- various information about fonts.
- - There are now officially supported C APIs for measuring and
- displaying text. If you use these APIs now, your code will
- automatically handle international text when internationalization
- is added to Tk in a future release. See the manual entries
- MeasureChar.3, TextLayout.3, and FontId.3.
- - The old C procedures Tk_GetFontStruct, Tk_NameOfFontStruct, and
- Tk_FreeFontStruct have been replaced with more portable procedures
- Tk_GetFont, Tk_NameOfFont, and Tk_FreeFont.
- *** POTENTIAL INCOMPATIBILITY ***
-(CS)
-
-9/24/96 (bug fix) Under Windows, transient windows would be destroyed
-if their master was destroyed, even if the transient window was not a
-child of the master. (SS)
-
-10/18/96 (new features) A -menu option has been added to the toplevel
-widget command, which allows a menu to operate as a menubar. On the
-Macintosh, the menubar is displayed accross the top of the main monitor,
-just like with other applications. Under Windows and Unix, the menu is
-attached to the toplevel window. Also, changed some semantics.
-Tearoff menus will now reflect changes to the menu it was
-torn off from, and are deleted when the master menu is
-deleted. Tearoffs also reflect more look-and-feel of the
-platforms they are running on. (SRP)
-
-10/31/96 (bug fix) Under Windows, missing system cursors would
-generate an error instead of falling through to the Tk cursor of the
-same name. (SS)
-
-11/7/96 (feature change) Under Unix, default borderwidth is now 1 to
-more closely approximate CDE. (SS)
-Note: this change was undone on 6/12/97, restoring the default border
-width to 2 again. (JO)
-
-11/7/96 (new feature) The button widget now supports a -default option
-that draws a platform specific default ring around the widget. (SS)
-
-11/7/96 (feature change) Under Windows, buttons and scrollbars now
-have native look and feel. This affects the default class bindings
-and the way the some configuration options are interpreted. Refer to
-the widget manual pages for more details. (SS)
-*** POTENTIAL INCOMPATIBILITY ***
-
-11/19/96 (bug fix) Under Windows, images were incorrectly drawn on
-16-bit displays. (SS)
-
-11/19/96 (bug fix) Under Windows, the class name for the main window
-(.) was not properly generated from argv0. (SS)
-
-11/20/96 (bug fix) Fixed a couple of bugs in the Canvas widget. The
-postscript file is now created with the correct permissions. Also,
-the prolog is now properly included in all cases. (RJ)
-
-11/22/96 (bug fix) Under Windows, the initial directory and file names
-were not properly translated before being passed to the system
-open/save file dialogs. So forward slashes were not converted to
-backslashes, and tilde substitution was not performed. (SS)
-
-11/25/96 (feature change) Under Windows and Macintosh, the selection
-highlight is now hidden whenever an entry or text widget loses focus.
-Also, the previous selection information is not lost when a new
-selection is made in a different widget. (SS)
-
-11/26/96 (new feature) Added support for images as primitive types in
-text widgets. (SU)
-
-11/30/96 (configuration improvement) Modified configure.in to handle the
-case where Tcl and Tk are installed in different places by including both
-their library directories in the library search path for Tk. (JO)
-
-12/3/96 (bug fixes) Fixed two bugs related to canvas lines that caused
-the screen to be incorrectly refreshed, leaving garbage on the screen.
-One bug was related to lines with width zero, and the other was
-related to lines with very long miters. (JO)
-
-12/4/96 (bug fix) The "update" command was only syncing the display
-for its main window. Changed to sync all displays. (JO)
-
-12/5/96 (bug fix) Color deallocation would occasionally cause a panic
-under Windows. (SS)
-
-12/5/96 (bug fix) Errors during startup were silently discarded under
-Windows. (SS)
-
-12/5/96 (bug fix) Errors during startup were silently discarded under
-Windows. (SS)
-
-12/11/96 (bug fix) Text widgets weren't considering the -spacing1
-and -spacing2 options when computing their desired geometry. (JO)
-
-12/12/96 (feature change) Option menus using tk_optionMenu were
-created with command entries that set the option menu's variable in a
-command string. This has been changed so that the option menu's
-entries are now radiobutton entries so that the entries that matches
-the variable is now checked when the menu is posted. (SRP)
-
-12/12/96 (feature change) The destroy command no longer returns an
-error when a window does not exist. (SRP)
-
-12/13/96 (new feature) grid row/column-configure accepts a list of
-indices in addition to a single index. (SU)
-
-12/17/96 (bug fix) Under Windows, command line was not being parsed
-correctly if it contained the literal characters \" (CS)
-
-12/17/96 (feature change) Native Windows labels do not get a focus-ring
-border. (CS)
-
-12/17/96 (bug fix) Under Windows, colors specified as "#XXYYZZ" where XX, YY,
-or ZZ were not valid hex digits were getting a random color value instead of
-being an error. (CS)
-
------------------ Released 8.0a1, 12/17/96 -----------------------
-
-12/23/96 (bug fix) Fixed two menu bugs:
- - Menus could get stacked below other windows so that they weren't
- visible when posted (especially under olvwm and fvwm).
- - Under olvwm if you pressed button 1 over an entry in a new-style
- menubar, the menu didn't appear until you moved the mouse slightly.
-(JO)
-
-1/6/97 (bug fix) Focus could accidentally get grabbed by an application
-away from the rightful focus owner if the focus recently changed from one
-application to another. (JO)
-
-1/6/97 (bug fix) Under Windows, the console was appearing even for
-non-interactive applications. This was a side effect of a general
-problem with the wm state of windows that were being mapped for the
-first time. (SS)
-
-1/6/97 (bug fix) Under Windows, the initialization code was not
-looking in the right directory for the Tk libraries when the program
-being run was not in the Tcl installation heirarchy. (SS)
-
-1/8/97 (bug fix) Under Windows, the windows were not being unmapped
-properly, which led to strange packer behavior. (SS)
-
-1/8/97 (bug fix) The "winfo containing" command (and the Tk_CoordsToWindow
-procedure) didn't work properly on Unix in the presence of embedding or
-menubars. (JO)
-
-1/15/97 (bug fix) Invoking "destroy ." as the command from a menu would
-cause Tk to crash because TkMainInfo was freed before menu released its
-resources. This bug had already been fixed for scrollbars and buttons. (CS)
-
-1/15/97 (bug fix) Tk is now working under Win32s again, including Win32
-version 1.25. Fixed separate problems in fonts and dialogs. (CS)
-
-1/15/97 (feature change) Under Windows, font sizes are now specified in
-points, not pixels. The mapping between pointsize and pixels depends on
-Windows having accurate metrics for the monitor (plug&play helps). Font
-metrics are still reported in pixels. (CS)
-
-1/21/97 (bug fix) Grid no longer reports rows or columns "out of range"
-when requesting their constraints. (SAU)
-
-1/21/97 (bug fix) Fixed some window manager related bugs on the
-Macintosh. Now better support global grabs. (RJ)
-
-1/21/97 (bug fix) For Windows: Fixed problems with canvas items that
-used end caps. Fixed arc implementation to more closely approximate
-X. Stippling now works properly on fat lines. (SS)
-
-1/21/97 (bug fix) Small interlaced GIF images were not properly
-decoded. (SS)
-
-1/21/97 (bug fix) More changes to image code to try to handle 16-bit
-displays properly under Windows. (SS)
-
-1/21/97 (bug fix) Numerous display bugs on Unix and Macintosh are now
-fixed. Numerous binding problems for menubars under Unix are now
-fixed. Deletion of menu separators under Windows is now fixed. (SRP)
-
------------------ Released 8.0a2, 1/24/97 -----------------------
-
-1/29/97 (feature change) The -transient field for menus is no longer
-supported. There is now a -type field which is used to achieve the
-same purpose that the -transient field accomplished. When a menu is
-created, the -type field controls whether the menu is a normal
-pull-down menu, a floating tearoff menu or a menubar. This option is
-normally only used by the library code and internally by the menubar
-code. (SRP)
-*** POTENTIAL INCOMPATIBILITY ***
-
-2/5/97 (feature change) Changed the photo image mechanism to use
-Tcl_Channels instead of FILE * as an argument to image matching
-functions. The change will make it much easier to write cross
-platform image types in Tk. Note: FILE * is no longer used anywhere
-in Tk. (RJ)
-*** POTENTIAL INCOMPATIBILITY ***
-
-2/7/97 (enhancement) Were not allowed to bind to virtual events inside of
-canvas or text widget (e.g., "$canvas bind all <<foo>> {script}" or
-"$text tag bind sel <<foo>> {script}"); it would return an error
-disallowing that binding. Now _can_ bind to a virtual event, but that
-binding inside of the canvas or text widget will only fire if the
-underlying virtual event definition is of type key, button, motion,
-enter, or leave; all other physical event types get filtered out by the
-widget before the virtual event mapping is done. (CS)
-
-2/22/97 (bug fix) Under Unix, "wm geometry +-20+-30" didn't work. (JO)
-
-2/24/97 (bug fix) The photo image didn't always zero out enough of its
-pixel and dither correction arrays. (JO)
-
-2/25/97 (bug fix) Fixed focus problem that could cause "BadMatch (invalid
-parameter attributes)" in X_SetInputFocus requests on Unix. (JO)
-
-2/25/97 (bug fix and new feature) Added new "gray75" bitmap, fixed
-"gray25" bitmap to really be 25% on (due to an ancient mistake, it
-had been only 12% on). (JO)
-
-2/28/97 (bug fix) Windows: made embedding work again on Win32 platform.
-Prevent iconification, deiconinification on embedded windows. (JL)
-
-3/4/97 (new feature) Added the ability to manipulate the Apple and
-Help menus on the Macintosh; the system menu on Windows; and to have a
-right justified Help menu on Unix. See the documentation for menu.n
-for more details. (SRP)
-
-3/4/97 (bug fix) Prevented core dump at exit if a <Destroy> binding on "."
-gets invoked from destroying a nested widget and the binding causes the
-interpreter to be deleted. The core dump was being caused by the
-interpreter not being Tcl_Preserve'd during the destroy of ".". (JL)
-
-3/4/97 (bug fix) Under Unix, when embedded Tk is running in a separate
-process, correctly handle a race condition: ignore cross-over messages from
-the X server for windows that Tk thinks it had already deleted, when the
-containing process deletes its container window. Some other race conditions
-still remain, e.g. with pixmaps, colormaps and images. (JL)
-
-3/10/97 (bug fix) Prevented core dump in generic console code due to
-following a NULL pointer when the console interpreter was already deleted.
-This may happen due to different orders of deletion possible at exit. (JL)
-
-3/10/97 (bug fix) Fixed bug on Mac and Windows that caused time to be
-ignored when considering if a single click was actually a double
-click. (RJ)
-
-3/11/97 (feature change) A major oversight has been that although it was
-documented that the Tk programmer was asking for a font in points (1/72 of an
-inch), under Unix and Mac Tk was actually asking for a font in pixels, while
-only under Windows was it using points. This caused applications to appear
-much larger when run under Windows. Now, on all platforms the (purportedly)
-correct size in points is used when asking for fonts. However, for
-compatibility with existing tk4.2 applications that depend on fonts being of
-specified pixel size, XLFDs retain their incorrect behavior of getting a
-font in pixels. (CCS)
-*** POTENTIAL INCOMPATIBILITY ***
-
-3/13/97 (new feature) "tk scaling" command to setup the mapping between
-pixels and points. This scaling factor is used by all widgets that accept
-ruler distances, not just fonts. (CCS)
-
-3/24/97 (new feature) Added "-columnbreak" option to menu
-entries. When this value is "1", the entry will appear at the top of a
-new column in a non-menubar menu. Also added "-hideMargin". Together
-with "-columnBreak", menus with palettes are now possible. (SRP)
-
-3/26/97 (new features and bug fix) Titles for tearoff menus were
-broken on the Mac and Windows. Added the ability to set the title of a
-menu when it gets torn off and override Tk's automatic generation of
-the title. On the Macintosh, whenever a menu
-label contains three dots in a row "...", the menu will instead
-display the elipses character 'É'. (SRP)
-
-3/27/97 (bug fixes) When a menu had an error executing a postcommand,
-the error information was getting lost. On Windows, a set of
-menubuttons was not highligting properly when clicking between
-windows. On Windows, post commands were getting executed twice for
-popup menus. On Macintosh, fixed problem where menubars were not
-always current. (SRP)
-
-4/11/97 (new feature) Menubuttons now have a direction flag which
-controls where the menu popups up relative to the button. (SRP)
-
-4/24/97 (bug fix) Transient windows did not obey the resizable setting
-under Windows. (SS)
-
-4/24/97 (bug fix) wm geometry did not correctly parse negative
-coordinates. (SS)
-
-4/29/97 (bug fix) Changed the canvas polygon implementation to only
-report the coordinates specified by the end user not the automatically
-generated end point of a self closing polygon. (RJ)
-*** POTENTIAL INCOMPATIBILITY ***
-
-4/23/97 (feature change) Loosened the rules on parsing font names so that
-unix-centric fonts in scripts don't break when run on Windows or Mac.
-(1) Previously, an XLFD had to specify font name, weight, slant, and size;
-now, a minimal XLFD (such as "*-times-*") will be accepted, and all
-unspecified attributes will be given default values. (2) Previously, in the
-{name size style ...} format, only the style was optional; now both the size
-and the style are optional; this solves the problem of old scripts that
-contain specifications of the form "-font fixed" or "-font times". (CCS)
-
-5/7/97 (new feature) Menus now send a virtual event <<MenuSelect>>
-when an item is highlighted in a menu. Applications can use this to
-implement context-sensitive help. (SRP)
-
-5/14/97 (bug fix) Fixed a race condition in the focus code where focus
-could be taken away from a window incorrectly. Scenario is that the main
-window creates a toplevel and assigns focus to it. When the user moves the
-mouse from the main window into the toplevel there was a race between
-two different kinds of focus events. (BW)
-
-5/20/97 (bug fix) Fixed bug where the clipboard was not rendered before
-the application exited. (SS)
-
-5/22/97 (feature change) When a Tk8.0 menu is configured, all menus
-derived from it (menubars, tearoff) mirror the changes. This was not
-true for the "-tearoff" flag. In Tk4.6, tearoff menus had the
-"-tearoff" flag turned off. Now, the "-tearoff" flag is tracked just
-as the other options are. Tearoff menus and menubars with the
-"-tearoff" option set will not display the tearoff item. This means
-that a given menu entry for a menu and a tearoff of that menu will
-match now. (SRP)
-*** POTENTIAL INCOMPATIBILITY ***
-
------------------ Released 8.0b1, 5/27/97 -----------------------
-
-5/30/97 (bug fix) Made the options to the grid command shortcut-able.
-Ie. You can now use -stick, in addition to -sticky. (RJ)
-
-6/2/97 (bug fix) Fixed bug in startup code that caused a problem in
-finding the library files when they are installed in a directory
-containing a space in the name. (SS)
-
-6/2/97 (bug fix) Virtual events associated with <Enter>/<Leave> in text
-widget tag caused panic. (CCS)
-
-6/6/97 (bug fix) On some systems, struct timeval.tv_sec is unsigned. (SS)
-
-6/6/97 (feature change) Changed -default option on buttons to take
-three states: normal, active, disabled. This allows apps to have a
-row of buttons where the default ring moves between buttons without
-changing the geometry of the buttons. See the button.n manual page
-for more details. (SS)
-*** POTENTIAL INCOMPATIBILITY with Tk 8.0b1, but not with Tk 4.2 ***
-
-6/9/97 (bug fix) Canvas postscript printing now works for bitmaps
-under Windows. (SS)
-
-6/10/97 (bug fix) Fixed bug in bindings for listboxes where state wasn't
-being properly initialized on Shift-1 button presses. (JO)
-
-6/11/97 (bug fix) Text widget display code did not include internal
-padding in the damage calculation for borders leading to unrefreshed
-sections on Windows and Mac. (SS)
-
-6/12/97 (feature reversal) Changed default border widths under Unix
-back to 2 again. This reverses the change made on 11/7/96. (JO)
-
-6/13/97 (bug fixes) In canvas text item: the insertion cursor wasn't shown
-if insertion point was at end of text item, it was impossible to click to
-position the insertion point after the last character, and @x,y indices were
-computed incorrectly if -scrollregion had been specified and canvas was
-scrolled. (CCS)
-
-6/13/97 (bug fix) Hitting up/down arrows in a text widget packed in a
-toplevel window created with the "-screen" option would cause an error dialog
-to pop up. (CCS)
-
-6/12/97 (bug fix) Fixed bug in canvas text items where multi-line
-selections were not highlighted properly. This bug existed only in
-earlier releases of Tk 8.0. (JO)
-
-6/16/97 (bug fix) In some obscure cases, canvas window items could
-accidentally specified a 0x0 size for the window, which caused a
-BadValue error under X. (JO)
-
-6/17/97 (bug fix) Tk buttons on the Macintosh will now correctly
-draw under MacOS 8.0. (RJ)
-
-6/18/97 (feature change) Changed the way highlights are drawn in text
-widgets so that the empty space to the left of a line is highlighted
-whenever the leftmost character of the line is highlighted (the empty
-space didn't used to be highlighted). This produces a neater left
-edge when several lines are selected. (JO)
-
-6/18/97 (bug fix) Tk was using the wrong system colors to draw various
-widgets under Windows. (SS)
-
-6/19/97 (bug fix) Under Windows, the "wm transient" and "wm overrideredirect"
-subcommands can now be applied to a toplevel to change its window
-style at any time during the life of the window. (SS)
-
-6/19/97 (feature change) All GIF and XBM images needed for the "TK"
-file dialog box are included in-line in tkfbox.tcl. (IL)
-
-6/27/97 (bug fix) Revamped focus code to eliminate most XSetInputFocus
-calls from the FilterEvent procedure. This moves the implementation back
-towards the Tk 4.2 implementation, but adds embedding support. There is
-still a known bug with twm's NoTitleFocus and embedded windows. However,
-the races in a2 and the funny focus stealing in b1 are gone. (BW)
-
-6/25/97 (bug fix) Error message was not properly reported when using
-button 'toggle'. (DL)
-
-6/25/97 (bug fix) Removed one source of memory corruption in tkGrid.c code
-(fixes what was exercised by "grid col . 0 -w 1; grid col . 0 -w 25") (DL)
-
------------------ Released 8.0b2, 6/30/97 -----------------------
-
-7/1/97 (bug fix) Menu shortcut and tearoff reported problem fixed. (DL)
-
-7/1/97 (new feature) TK_BUILD_SHARED flag set in tkConfig.sh
-when Tk has been built with --enable-shared. TK_SRC_DIR added.
-A new tkLibObjs make target, echoing the list of the .o's needed
-to build a tk library, is now provided. (DL)
-
-7/9/97 (bug fix) Fixed Tk_CreateFileHandler and Tk_DeleteFileHandler
-macros to directly call the Tcl equivalents. (JL)
-
-7/10/97 (bug fix) On the Mac, if the binding for <<MenuSelect>> was
-drawing, the drawing could bleed over into the menus. This is now
-fixed. (SRP)
-
-7/10/97 (bug fixes) Removed duplicate code related to Tk_SafeInit,
-made a single init script handling both cases. (DL)
-
-7/10/97 (feature change) On Unix, to be able to load Tk into a safe
-interp you need to set the env(DISPLAY) var. Some API should be
-added to allow master crontrol over Tk instantiation. (DL)
-
-7/11/97 (new feature) On the Mac, menus that are too big for the
-screen will now scroll. This is part of the interface on the Mac,
-impossible under Windows, and is not done for Unix. (SRP)
-
-7/21/97 (bug fix) After fixing the bug that in canvas text item the insertion
-cursor wasn't shown if insertion point was at end of text item, introduced a
-different bug in where clicking in entry widget with 0 characters would
-crash or display garbage. (CCS)
-
-7/22/97 (bug fix) If there were a whole bunch of returns or tabs in a row in
-a canvas text item, then the temporary buffer used when outputting
-postscript could overflow and overwrite the stack. (CCS)
-
-7/23/97 (feature change) Reenabled "tkwait" in the Safe Tk base. (JL)
-
-7/24/97 (bug fix) Single init script for both Win and Unix.
-new library/safetk.tcl using features from new tcl safe.tcl (DL)
-
-7/30/97 (feature change) As a result of native menus, you can no
-longer drag through a frame of menubuttons on Macintosh and Windows
-and have the menus pop down. You can still click on individual
-menubuttons and their menus will pop down. Applications needing to
-present a menubar should consider using the new "-menu" configuration
-of the toplevel widget to set up menubar which behaves correctly on
-Macintosh, Windows and X Windows. (SRP)
-
-7/31/97 (bug fix) Tk widget commands can now safely be hidden commands.
-Previously destroying the widget would potentially leave dangling pointers
-and destroy an exposed command instead of a hidden one if an exposed
-command by that name existed. (JL)
-
-7/31/97 (bug fix) On Windows, popup menus were not tracking the right mouse
-button correctly if it was used to invoke the menu. On Unix, tearoff
-menus were stealing focus when the mouse moving over them even when
-focus following was turned off. (SRP)
-
-8/4/97 (bug fix) Fixed problem under USENIX where raising a toplevel
-window could cause an X error if the window had just been withdrawn. (JO)
-
-8/4/97 (feature change) tkerror and bgerror are not anymore hard links
-maintained by the Tcl core. The implementation of bgerror provided by
-Tk tries, for backward compatibility only, to to call "tkerror" and
-if that fails, falls back to the usual dialog and stack trace option
-posting. You can thus still use either "bgerror" or "tkerror" as your
-application error handling proc, but using "bgerror" is strongly
-recommended as support for "tkerror" will eventually vanish in upcoming
-releases. (DL)
-*** POTENTIAL INCOMPATIBILITY with scripts that were using
- the actual hardlink implementation 'features' and with
- scripts (if any) that would be calling the default "tkerror" to
- simulate error messages (use "bgerror" instead) ***
-
-8/7/97 (feature change/addition) Removed the gif files used for the
-Open dialog box on UNIX (they were previously made inline). Added a
-new images directory that includes several images of the Tcl and Tcl
-Powered logos. (RJ)
-
-8/7/97 (bug fix) Fixed focus to deal with embedding when there is
-no window manager. (BW)
-
-8/8/97 (bug fix) Fixed bug in photo image code where photo images from
-different interpreters could get confused if they had the same name. (JO)
-
-8/8/97 (new feature) Added new procedure Tk_GetImageMasterData for
-mapping image names to master data. (JO)
-
-8/8/97 (feature change) Modified Tk_FindPhoto procedure to require
-extra "interp" argument (needed for bug fix above). (JO)
-*** POTENTIAL INCOMPATIBILITY ***
-
-8/8/97 (bug fix) Fixed problems under Windows renaming toplevels with
-menubars. Fixed problems on all platforms renaming menu widgets and
-using new menus of the same name as an old one as cascades. Fixed a
-cosmetic problem with tearoff menus. (SRP)
-
-8/13/97 (bug fixes) Fixed "-from" option for the "image create" and
-"imageName read" commands for GIF images, which didn't used to work
-correctly. Also made transparency work correctly for GIF images
-without the TRANSPARENT_GIF_COLOR hack; TRANSPARENT_GIF_COLOR is
-now ignored. These fixes were provided by Jan Nijtmans. (JO)
-
-8/13/97 (new feature) added safe::loadTk command to load Tk in a
-safe slave interpreter. See the loadTk.n manual page for more
-details. (DL)
-
------------------ Released 8.0, 8/18/97 -----------------------
-
-8/22/97 - (bug fix) Fixed syntax error in tk_popup; option menus now
-popup over their selected items like they did in tk4.2. Fixed problem
-where cascades sometimes did not work on X. On X, menubars with
-checkbuttons and radiobuttons in them would infinite loop when
-mappped. (SRP)
-
-8/27/97 (new feature) Added support for new X11R6 colors under Windows
-and Mac platforms. (SS)
-
-8/29/97 (bug fix) Wish crashed if stdin was closed. (SS)
-
-9/10/97 (bug fix) "font actual {helvetica 10} -displayof ." wasn't taking
-into account the "-displayof" option. This problem also existed for the
-"font metrics" and "font measure" commands. (CCS)
-
-9/16/97 (new feature) Added "resource delete" and "resource files"
-command to the Mac. Also fixed "resource write" when the resource
-was specified by id and already existed. (JI)
-
-9/16/97 (bug fix) Added null bindings to <Command-KeyPress> for the
-text and entry widget on the Macintosh. This prevents unbound command
-key sequences from having the character echoed to the widget. Also
-fixed Cut & Copy bindings. (JI) (RJ)
-
-9/18/97 (bug fix) Revamped Macintosh focus code. Cut, Copy & Paste
-virtual events now go to the correct (focus) window. (RJ)
-
-9/19/97 (bug fix) Made Macintosh tearoff menus non-resizable. (RJ)
-
-10/9/97 (bug fix) Image code could cause crashes during "exit" under
-some conditions (such as an image named "place"). (JO)
-
-10/9/97 (bug fix) Fixed bug that sometimes prevented listboxes from
-scrolling far enough horizontally to see the rightmost character. (JO)
-
-10/9/97 (bug fix) Default font for new canvas text items was hardcoded to
-"Helvetica 12" instead of using DEF_CANVTEXT_FONT defined in
-tk{platform}Default.h like all the other widget settings. (CCS)
-
-10/10/97 (bug fix) In canvas text items, if the text ended with a \n, it
-was not counted in the bbox height, as it did in tk4.2. This caused
-"hello\n" to be the same height as "hello" and you couldn't see the
-cursor positioned on the next line. (CCS)
-
-10/10/97 (bug fix) The grid geometry manager didn't always properly
-forget about windows after a "grid forget" or "grid remove" command:
-the windows could reappear on the screen later. (JO)
-
-10/13/97 (bug fix) Selection could not be restored to a text widget
-after "selection clear" on Windows. (SS)
-
-10/14/97 (bug fix) If a canvas had contained windows that were off-screen,
-the windows could sometimes reappear (in the wrong place) if the canvas was
-enlarged. (JO)
-
-10/20/97 (bug fix) Omitting the arguments to the text widget "mark
-gravity" option caused a crash. (SS)
-
-10/21/97 (bug fix) Tk did not reset the result after native dialog
-modal loops on Window so background events could perturb the dialog
-result. (SS)
-
-10/23/97 (bug fix) Memory leak in unix's TkpGetFontFamilies. Thanks
-to James Bonfield for the fix. (DL)
-
-10/27/97 (bug fix) Fixed event reporting for the Mac during a grab
-when the pointer was out of the toplevel window. (RJ)
-
-10/28/97 (bug fix) Under Unix, override-redirect was getting set
-incorrectly for menus, so that "wm overrideredirect" returned 0. (JO)
-
-10/28/97 (bug fix) Under Unix, focus code could sometimes cause the
-display to deadlock (it wasn't flushing the output buffer after issuing
-an ungrab command). (JO)
-
-10/28/97 (bug fix) If a PPM image file wasn't complete (e.g. it
-consisted of nothing but space characters) Tk entered an infinite loop
-reading the header. (JO)
-
-10/28/97 (bug fixes) On the Mac, menubars assigned to toplevels would
-disappear after a menu item was invoked from them. On Windows,
-clicking a system menu with added items and then again with a
-different set of added items would crash. On all platforms, a command
-menu entry that caused the entry to be deleted, another one created in
-its place, and the replacement deleted would cause a panic. On Unix,
-<<MenuSelect>> event bindings were firing every time the mouse moved,
-instead of everytime the active menu item changed. (SRP)
-
-10/27/97 (bug fix) If a particular race condition occurred under Windows,
-Tk would crash complaining about trying to free a color that wasn't
-allocated. (SS)
-
-10/28/97 (bug fix) Under Windows, button grabs did not report motion
-events that occurred outside of Tk windows. (SS)
-
-10/28/97 (bug fix) Fixed incorrect display of transparent images on
-the Macintosh. (JI)
-
-10/29/97 (bug fix) Reworked the handling of out-of-range indices in
-the widget command for listboxes: there were all sorts of quirks
-before (e.g., ".l delete -1" actually deleted the first element
-of the listbox). (JO)
-
-10/29/97 (bug fix) Fixed crash on the Macintosh that could occur if a
-window is moved before it is mapped where the X window was created but
-the Macintosh port was not. (RJ)
-
-10/29/97 (bug fix) Fixed several errors in how wm state was maintained
-on the Macintosh. Tk now also will iconify a toplevel window on the
-Mac if the new Appearance Manager is present. (RJ)
-
-10/28/97 (bug fixes) In canvas' postscript command: User name
-information was leaked in safe interpreters on Unix (security fix).
-Errors while reading prolog.ps were not propagated and the error
-message was mixed with partial data. Note: postscript output does
-not work in safe interpreters on unix and windows. (DL)
-
-10/28/97 (bug fix) Safe Tk interps on unix were leaking env(DISPLAY). (DL)
-
-10/31/97 (bug fix) Fixed problems related to the input focus when one
-application had windows open simultaneously on several displays. (JO)
-
-10/31/97 (bug fix) Fixed several problems with traversal of menus via
-the keyboard under Unix. (SRP)
-
-11/4/97 (bug fix) Fixed various word-size related problems for 64-bit
-architectures. (SS)
-
-11/5/97 (bug fix) Embedding on Windows was using freed data (crashing
-in safe.test with TCL_MEM_DEBUG). NB: Embedding is still not fully
-implemented on Windows ! (It works mostly when Tk is embeded into it's
-own Tk frame (safe::loadTk case), but not well with respect to resizing
-with a toplevel container or with an external process). (DL)
-
------------------ Released 8.0p1, 11/7/97 -----------------------
-
-11/20/97 (bug fix) Fixed bug on the Mac where the "package require"
-command caused menus to stop working. (JI)
-
-11/20/97 (bug fix) Fixed bug in rendering transparent gifs on Text
-widgets. (JI)
-
-11/20/97 (enhancement) Made the changes required to work with the new
-Apple Universal Headers V. 3.0 so we can compile with CW Pro 2.0 (JI)
-
------------------ Released 8.0p2, 11/25/97 -----------------------
-
-11/25/97 (security bug fix + added feature) Tk Safe Init now asks
-the master's safe::TkInit for the 'argv' to use. This is transparently
-dealt with by the safe::loadTk API. New optional "-display displayName"
-argument to safe::loadTk, and the "-use" argument accepts both window
-Ids and Tk window names: see loadTk(n). Made the ":0.0" default display
-work on the Mac as it works on Windows and Unix. (DL)
-
-12/3/97 (bug fix/optimization) Removed unneeded and potentially dangerous
-instances of double evaluations if "if" and "expr" statements from
-the library files. It is recommended that unless you need a double
-evaluation you always use "expr {...}" instead of "expr ..." and
-"if {...} ..." instead of "if ... ...". It will also be faster
-thanks to the byte compiler. (DL)
-
-12/3/97 (new feature) Added support for browser/plugin style embedding,
-and made various other fixes to get the plugin working on the Mac. (JI)
-
-12/8/97 (bug fix) on Windows, using "winfo pathname" before "." was mapped
-was crashing. (DL)
-
----- Shipped as part of the plugin2.0b5 as 8.0p2Plugin1, Dec 8th 97 ----
-
-12/97 (bug fix) more Macintosh embeding fixes needed for the plugin. (JI)
-
-Jan/9/98 (improvement) Allow applications to have custom init script
-without having to patch the Tk core: Tk_Init will use an existing
-"tkInit" proc if one exists in the interp where one tries to install Tk
-instead of defining it's own (tkInit is the transient proc defined in
-generic/tkInitScript.h that searches and sources tk.tcl and defines
-the 'correct' tk_library). (DL)
-
----- Shipped as part of the plugin2.0 as 8.0p2Plugin2, Jan 15th 98 ----
-
-6/3/98 (bug fix) Fixed bugs in the tk_getOpenFile under Unix.
- 1) If the -initialdir option was "." the result would be "././foo.tcl"
- instead of an absolute path, like the Windows interface.
- 2) There is a traceVar on the data(selectPath) where the script was
- assumes the window exists. (BS)
-
-6/12/98 (feature change) Focus -force now sets the foreground window
-on Windows platforms in addition to moving the focus. (SS)
-
-6/12/98 (bug fix) Fixed bug in Windows font measurement that did not
-take kerning into account. (BS)
-
-6/24/98 (bug fix) On Unix, fixed -initialdir switch to tk_getOpenFile
-and tk_getSaveFile to convert the specified directory to an absolute
-path and to use the current working directory if the specified
-directory does not exist. (SS)
-
-6/25/98 (bug fix) On Unix, both the Tk and the Motif file dialogs
-would fail if the -parent flag changed between two parent windows that
-had been previously used as file dialog parents. (SS)
-
-6/29/98 (compatibility patch) Added reserved fields to several Tk
-structures to match additions made by Jan Nijtmans dash patch. This
-means that extensions can be compiled against the dash patch
-and still work with unpatched Tk, and vice versa.
-
-7/6/98 (bug fix) Added keysym definitions for the new keys on the
-Microsoft keyboards. You can bind to <App>, <Win_L>, and <Win_R>,
-but you cannot use the Win keys as modifiers. (SS, BW)
-
-7/6/98 (new feature) Added support for the Macintosh Appearance Manager. (JI)
-
-7/24/98 (feature change) Eliminated the static variable that sets
-tk_library and simplified search order for tk.tcl. The tk_library
-variable can now be set before calling Tk_Init to avoid doing any
-searches. If it isn't set, then Tk checks env(TK_LIBRARY), relative
-to tcl_library, an install directory relative to the executable, a
-source directory relative to the executable, and a tk directory
-relative to the source heirarchy containing the executable. See the
-comment at the top of generic/tkInitScript.h for more details. (SS)
-
-7/27/98 (bug fix) The bbox for coords in the canvas were incorrectly
-including the center of the coord as part of the bound area. (RJ)
-
-8/4/98 (bug fix) Fixed memory leak in Windows menu code. (SS)
-
-8/4/98 (bug fix) Fixed bug where bgerror's were not being generated
-from menu callbacks on Windows. (SS)
-
-8/4/98 (bug fix) Alt-key bindings were not being handled properly
-under Windows, resulting in annoying beeps. (SS)
-
-8/4/98 (bug fix) Fixed bug in Windows menubar handling that allowed
-a shared menubar to be deleted when any window using it was deleted. (SS)
-
-8/4/98 (feature change) Introduced TkReadBitmapFile to replace
-XReadBitmapFile so that all Tk file opens go through the Tcl channel
-mechanism. This lets us wrap applications that define their own
-bitmaps and cursors. Note that XReadBitmapFile is no longer
-emulated for non-unix platforms platforms (RJ, BW)
-
-8/5/98 (bug fix) <Insert> binding in entries was masking the virtual
-event <<Paste>> binding to Shift-Insert on Windows. (SS)
-
-8/5/98 (bug fix) wm frame would crash if the window had not been
-mapped yet on Windows. (SS)
-
-8/5/98 (bug fix) Local grabs did not exclude menus or the caption bar
-under Windows. (SS)
-
-8/5/98 (bug fix) Reduced message traffic by setting
-WS_EX_NOPARENTNOTIFY on TkChild windows. (SS)
-
-8/6/98 (feature change) Changed tkInitScript.h to use the new
-tcl_findLibrary procedure to locate its script library. (BW)
-
-8/10/98 (bug fix) Added special case to font code to limit the
-length of displayed strings to avoid wrap-around bugs in some
-PC X servers when the pixel length of the string exceeds 0x7fff. (SS)
-
-8/12/98 (bug fix) Macintosh, lock down some of the resources
-associated with menus to try and stabilise the menu system
-on memory limited machines. (JI)
-
-8/12/98 (windows build change) Moved the tkConsole.obj into the tk80.dll
-on windows. If you build your own Tk main program, you no longer
-need to compile and link this yourself. (SKS)
-
--------- Released 8.0.3 to the Tcl Consortium CD-ROM project, 8/13/98 ------
diff --git a/compat/limits.h b/compat/limits.h
deleted file mode 100644
index 1ffa1fb..0000000
--- a/compat/limits.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * limits.h --
- *
- * This is a dummy header file to #include in Tcl when there
- * is no limits.h in /usr/include. There are only a few
- * definitions here; also see tclPort.h, which already
- * #defines some of the things here if they're not arleady
- * defined.
- *
- * Copyright (c) 1991 The Regents of the University of California.
- * Copyright (c) 1994 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: limits.h,v 1.2 1998/09/14 18:03:09 stanton Exp $
- */
-
-#define LONG_MIN 0x80000000
-#define LONG_MAX 0x7fffffff
-#define INT_MIN 0x80000000
-#define INT_MAX 0x7fffffff
-#define SHRT_MIN 0x8000
-#define SHRT_MAX 0x7fff
diff --git a/compat/stdlib.h b/compat/stdlib.h
deleted file mode 100644
index 650750d..0000000
--- a/compat/stdlib.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * stdlib.h --
- *
- * Declares facilities exported by the "stdlib" portion of
- * the C library. This file isn't complete in the ANSI-C
- * sense; it only declares things that are needed by Tcl.
- * This file is needed even on many systems with their own
- * stdlib.h (e.g. SunOS) because not all stdlib.h files
- * declare all the procedures needed here (such as strtod).
- *
- * Copyright (c) 1991 The Regents of the University of California.
- * Copyright (c) 1994 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: stdlib.h,v 1.2 1998/09/14 18:03:09 stanton Exp $
- */
-
-#ifndef _STDLIB
-#define _STDLIB
-
-#include <tcl.h>
-
-extern void abort _ANSI_ARGS_((void));
-extern double atof _ANSI_ARGS_((CONST char *string));
-extern int atoi _ANSI_ARGS_((CONST char *string));
-extern long atol _ANSI_ARGS_((CONST char *string));
-extern char * calloc _ANSI_ARGS_((unsigned int numElements,
- unsigned int size));
-extern void exit _ANSI_ARGS_((int status));
-extern int free _ANSI_ARGS_((char *blockPtr));
-extern char * getenv _ANSI_ARGS_((CONST char *name));
-extern char * malloc _ANSI_ARGS_((unsigned int numBytes));
-extern void qsort _ANSI_ARGS_((VOID *base, int n, int size,
- int (*compar)(CONST VOID *element1, CONST VOID
- *element2)));
-extern char * realloc _ANSI_ARGS_((char *ptr, unsigned int numBytes));
-extern double strtod _ANSI_ARGS_((CONST char *string, char **endPtr));
-extern long strtol _ANSI_ARGS_((CONST char *string, char **endPtr,
- int base));
-extern unsigned long strtoul _ANSI_ARGS_((CONST char *string,
- char **endPtr, int base));
-
-#endif /* _STDLIB */
diff --git a/compat/unistd.h b/compat/unistd.h
deleted file mode 100644
index a7ec148..0000000
--- a/compat/unistd.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * unistd.h --
- *
- * Macros, CONSTants and prototypes for Posix conformance.
- *
- * Copyright 1989 Regents of the University of California
- * Permission to use, copy, modify, and distribute this
- * software and its documentation for any purpose and without
- * fee is hereby granted, provided that the above copyright
- * notice appear in all copies. The University of California
- * makes no representations about the suitability of this
- * software for any purpose. It is provided "as is" without
- * express or implied warranty.
- *
- * RCS: @(#) $Id: unistd.h,v 1.2 1998/09/14 18:03:09 stanton Exp $
- */
-
-#ifndef _UNISTD
-#define _UNISTD
-
-#include <sys/types.h>
-#ifndef _TCL
-# include "tcl.h"
-#endif
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-/*
- * Strict POSIX stuff goes here. Extensions go down below, in the
- * ifndef _POSIX_SOURCE section.
- */
-
-extern void _exit _ANSI_ARGS_((int status));
-extern int access _ANSI_ARGS_((CONST char *path, int mode));
-extern int chdir _ANSI_ARGS_((CONST char *path));
-extern int chown _ANSI_ARGS_((CONST char *path, uid_t owner, gid_t group));
-extern int close _ANSI_ARGS_((int fd));
-extern int dup _ANSI_ARGS_((int oldfd));
-extern int dup2 _ANSI_ARGS_((int oldfd, int newfd));
-extern int execl _ANSI_ARGS_((CONST char *path, ...));
-extern int execle _ANSI_ARGS_((CONST char *path, ...));
-extern int execlp _ANSI_ARGS_((CONST char *file, ...));
-extern int execv _ANSI_ARGS_((CONST char *path, char **argv));
-extern int execve _ANSI_ARGS_((CONST char *path, char **argv, char **envp));
-extern int execvp _ANSI_ARGS_((CONST char *file, char **argv));
-extern pid_t fork _ANSI_ARGS_((void));
-extern char *getcwd _ANSI_ARGS_((char *buf, size_t size));
-extern gid_t getegid _ANSI_ARGS_((void));
-extern uid_t geteuid _ANSI_ARGS_((void));
-extern gid_t getgid _ANSI_ARGS_((void));
-extern int getgroups _ANSI_ARGS_((int bufSize, int *buffer));
-extern pid_t getpid _ANSI_ARGS_((void));
-extern uid_t getuid _ANSI_ARGS_((void));
-extern int isatty _ANSI_ARGS_((int fd));
-extern long lseek _ANSI_ARGS_((int fd, long offset, int whence));
-extern int pipe _ANSI_ARGS_((int *fildes));
-extern int read _ANSI_ARGS_((int fd, char *buf, size_t size));
-extern int setgid _ANSI_ARGS_((gid_t group));
-extern int setuid _ANSI_ARGS_((uid_t user));
-extern unsigned sleep _ANSI_ARGS_ ((unsigned seconds));
-extern char *ttyname _ANSI_ARGS_((int fd));
-extern int unlink _ANSI_ARGS_((CONST char *path));
-extern int write _ANSI_ARGS_((int fd, CONST char *buf, size_t size));
-
-#ifndef _POSIX_SOURCE
-extern char *crypt _ANSI_ARGS_((CONST char *, CONST char *));
-extern int fchown _ANSI_ARGS_((int fd, uid_t owner, gid_t group));
-extern int flock _ANSI_ARGS_((int fd, int operation));
-extern int ftruncate _ANSI_ARGS_((int fd, unsigned long length));
-extern int ioctl _ANSI_ARGS_((int fd, int request, ...));
-extern int readlink _ANSI_ARGS_((CONST char *path, char *buf, int bufsize));
-extern int setegid _ANSI_ARGS_((gid_t group));
-extern int seteuid _ANSI_ARGS_((uid_t user));
-extern int setreuid _ANSI_ARGS_((int ruid, int euid));
-extern int symlink _ANSI_ARGS_((CONST char *, CONST char *));
-extern int ttyslot _ANSI_ARGS_((void));
-extern int truncate _ANSI_ARGS_((CONST char *path, unsigned long length));
-extern int vfork _ANSI_ARGS_((void));
-#endif /* _POSIX_SOURCE */
-
-#endif /* _UNISTD */
-
diff --git a/deleted_files/xlib/ximage.c b/deleted_files/xlib/ximage.c
deleted file mode 100644
index 057e973..0000000
--- a/deleted_files/xlib/ximage.c
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * ximage.c --
- *
- * X bitmap and image routines.
- *
- * Copyright (c) 1995 Sun Microsystems, Inc.
- *
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- *
- * SCCS: @(#) ximage.c 1.6 96/07/23 16:59:10
- */
-
-#include "tkInt.h"
-
-
-/*
- *----------------------------------------------------------------------
- *
- * XCreateBitmapFromData --
- *
- * Construct a single plane pixmap from bitmap data.
- *
- * Results:
- * Returns a new Pixmap.
- *
- * Side effects:
- * Allocates a new bitmap and drawable.
- *
- *----------------------------------------------------------------------
- */
-
-Pixmap
-XCreateBitmapFromData(display, d, data, width, height)
- Display* display;
- Drawable d;
- _Xconst char* data;
- unsigned int width;
- unsigned int height;
-{
- XImage ximage;
- GC gc;
- Pixmap pix;
-
- pix = Tk_GetPixmap(display, d, width, height, 1);
- gc = XCreateGC(display, pix, 0, NULL);
- if (gc == NULL) {
- return None;
- }
- ximage.height = height;
- ximage.width = width;
- ximage.depth = 1;
- ximage.bits_per_pixel = 1;
- ximage.xoffset = 0;
- ximage.format = XYBitmap;
- ximage.data = (char *)data;
- ximage.byte_order = LSBFirst;
- ximage.bitmap_unit = 8;
- ximage.bitmap_bit_order = LSBFirst;
- ximage.bitmap_pad = 8;
- ximage.bytes_per_line = (width+7)/8;
-
- TkPutImage(NULL, 0, display, pix, gc, &ximage, 0, 0, 0, 0, width, height);
- XFreeGC(display, gc);
- return pix;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * XReadBitmapFile --
- *
- * Loads a bitmap image in X bitmap format into the specified
- * drawable.
- *
- * Results:
- * Sets the size, hotspot, and bitmap on success.
- *
- * Side effects:
- * Creates a new bitmap from the file data.
- *
- *----------------------------------------------------------------------
- */
-
-int
-XReadBitmapFile(display, d, filename, width_return, height_return,
- bitmap_return, x_hot_return, y_hot_return)
- Display* display;
- Drawable d;
- _Xconst char* filename;
- unsigned int* width_return;
- unsigned int* height_return;
- Pixmap* bitmap_return;
- int* x_hot_return;
- int* y_hot_return;
-{
- Tcl_Interp *dummy;
- char *data;
-
- dummy = Tcl_CreateInterp();
-
- data = TkGetBitmapData(dummy, NULL, (char *) filename,
- (int *) width_return, (int *) height_return, x_hot_return,
- y_hot_return);
- if (data == NULL) {
- return BitmapFileInvalid;
- }
-
- *bitmap_return = XCreateBitmapFromData(display, d, data, *width_return,
- *height_return);
-
- Tcl_DeleteInterp(dummy);
- ckfree(data);
- return BitmapSuccess;
-}
diff --git a/doc/3DBorder.3 b/doc/3DBorder.3
deleted file mode 100644
index ea1a629..0000000
--- a/doc/3DBorder.3
+++ /dev/null
@@ -1,262 +0,0 @@
-'\"
-'\" Copyright (c) 1990-1993 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: 3DBorder.3,v 1.2 1998/09/14 18:22:45 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_Get3DBorder 3 4.0 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_Get3DBorder, Tk_Draw3DRectangle, Tk_Fill3DRectangle, Tk_Draw3DPolygon, Tk_Fill3DPolygon, Tk_3DVerticalBevel, Tk_3DHorizontalBevel, Tk_SetBackgroundFromBorder, Tk_NameOf3DBorder, Tk_3DBorderColor, Tk_3DBorderGC, Tk_Free3DBorder \- draw borders with three-dimensional appearance
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-Tk_3DBorder
-\fBTk_Get3DBorder(\fIinterp, tkwin, colorName\fB)\fR
-.sp
-void
-\fBTk_Draw3DRectangle(\fItkwin, drawable, border, x, y, width, height, borderWidth, relief\fB)\fR
-.sp
-void
-\fBTk_Fill3DRectangle(\fItkwin, drawable, border, x, y, width, height, borderWidth, relief\fB)\fR
-.sp
-void
-\fBTk_Draw3DPolygon(\fItkwin, drawable, border, pointPtr, numPoints, polyBorderWidth, leftRelief\fB)\fR
-.sp
-void
-\fBTk_Fill3DPolygon(\fItkwin, drawable, border, pointPtr, numPoints, polyBorderWidth, leftRelief\fB)\fR
-.sp
-void
-\fBTk_3DVerticalBevel\fR(\fItkwin, drawable, border, x, y, width, height, leftBevel, relief\fB)\fR
-.sp
-void
-\fBTk_3DHorizontalBevel\fR(\fItkwin, drawable, border, x, y, width, height, leftIn, rightIn, topBevel, relief\fB)\fR
-.sp
-void
-\fBTk_SetBackgroundFromBorder(\fItkwin, border\fB)\fR
-.sp
-char *
-\fBTk_NameOf3DBorder(\fIborder\fB)\fR
-.sp
-XColor *
-\fBTk_3DBorderColor(\fIborder\fB)\fR
-.sp
-GC *
-\fBTk_3DBorderGC(\fItkwin, border, which\fB)\fR
-.sp
-\fBTk_Free3DBorder(\fIborder\fB)\fR
-.SH ARGUMENTS
-.AS "Tk_3DBorder" borderWidth
-.AP Tcl_Interp *interp in
-Interpreter to use for error reporting.
-.AP Tk_Window tkwin in
-Token for window (for all procedures except \fBTk_Get3DBorder\fR,
-must be the window for which the border was allocated).
-.AP Tk_Uid colorName in
-Textual description of color corresponding to background (flat areas).
-Illuminated edges will be brighter than this and shadowed edges will
-be darker than this.
-.AP Drawable drawable in
-X token for window or pixmap; indicates where graphics are to be drawn.
-Must either be the X window for \fItkwin\fR or a pixmap with the
-same screen and depth as \fItkwin\fR.
-.AP Tk_3DBorder border in
-Token for border previously allocated in call to \fBTk_Get3DBorder\fR.
-.AP int x in
-X-coordinate of upper-left corner of rectangle describing border
-or bevel, in pixels.
-.AP int y in
-Y-coordinate of upper-left corner of rectangle describing border or
-bevel, in pixels.
-.AP int width in
-Width of rectangle describing border or bevel, in pixels.
-.AP int height in
-Height of rectangle describing border or bevel, in pixels.
-.AP int borderWidth in
-Width of border in pixels. Positive means border is inside rectangle
-given by \fIx\fR, \fIy\fR, \fIwidth\fR, \fIheight\fR, negative means
-border is outside rectangle.
-.AP int relief in
-Indicates 3-D position of interior of object relative to exterior;
-should be TK_RELIEF_RAISED, TK_RELIEF_SUNKEN, TK_RELIEF_GROOVE,
-TK_RELIEF_SOLID, or TK_RELIEF_RIDGE (may also be TK_RELIEF_FLAT
-for \fBTk_Fill3DRectangle\fR).
-.AP XPoint *pointPtr in
-Pointer to array of points describing the set of vertices in a polygon.
-The polygon need not be closed (it will be closed automatically if it
-isn't).
-.AP int numPoints in
-Number of points at \fI*pointPtr\fR.
-.AP int polyBorderWidth in
-Width of border in pixels. If positive, border is drawn to left of
-trajectory given by \fIpointPtr\fR; if negative, border is drawn to
-right of trajectory. If \fIleftRelief\fR is TK_RELIEF_GROOVE or
-TK_RELIEF_RIDGE then the border is centered on the trajectory.
-.AP int leftRelief in
-Height of left side of polygon's path relative to right. TK_RELIEF_RAISED
-means left side should appear higher and TK_RELIEF_SUNKEN means right side
-should appear higher;
-TK_RELIEF_GROOVE and TK_RELIEF_RIDGE mean the obvious things.
-For \fBTk_Fill3DPolygon\fR, TK_RELIEF_FLAT may also be specified to
-indicate no difference in height.
-.AP int leftBevel in
-Non-zero means this bevel forms the left side of the object; zero means
-it forms the right side.
-.AP int leftIn in
-Non-zero means that the left edge of the horizontal bevel angles in,
-so that the bottom of the edge is farther to the right than
-the top.
-Zero means the edge angles out, so that the bottom is farther to the
-left than the top.
-.AP int rightIn in
-Non-zero means that the right edge of the horizontal bevel angles in,
-so that the bottom of the edge is farther to the left than the top.
-Zero means the edge angles out, so that the bottom is farther to the
-right than the top.
-.AP int topBevel in
-Non-zero means this bevel forms the top side of the object; zero means
-it forms the bottom side.
-.AP int which in
-Specifies which of the border's graphics contexts is desired.
-Must be TK_3D_FLAT_GC, TK_3D_LIGHT_GC, or TK_3D_DARK_GC.
-.BE
-
-.SH DESCRIPTION
-.PP
-These procedures provide facilities for drawing window borders in a
-way that produces a three-dimensional appearance. \fBTk_Get3DBorder\fR
-allocates colors and Pixmaps needed to draw a border in the window
-given by the \fItkwin\fR argument. The \fIcolorName\fR
-argument indicates what colors should be used in the border.
-\fIColorName\fR may be any value acceptable to \fBTk_GetColor\fR.
-The color indicated by \fIcolorName\fR will not actually be used in
-the border; it indicates the background color for the window
-(i.e. a color for flat surfaces).
-The illuminated portions of the border will appear brighter than indicated
-by \fIcolorName\fR, and the shadowed portions of the border will appear
-darker than \fIcolorName\fR.
-.PP
-\fBTk_Get3DBorder\fR returns a token that may be used in later calls
-to \fBTk_Draw3DRectangle\fR. If an error occurs in allocating information
-for the border (e.g. \fIcolorName\fR isn't a legal color specifier),
-then NULL is returned and an error message is left in \fIinterp->result\fR.
-.PP
-Once a border structure has been created, \fBTk_Draw3DRectangle\fR may be
-invoked to draw the border.
-The \fItkwin\fR argument specifies the
-window for which the border was allocated, and \fIdrawable\fR
-specifies a window or pixmap in which the border is to be drawn.
-\fIDrawable\fR need not refer to the same window as \fItkwin\fR, but it
-must refer to a compatible
-pixmap or window: one associated with the same screen and with the
-same depth as \fItkwin\fR.
-The \fIx\fR, \fIy\fR, \fIwidth\fR, and
-\fIheight\fR arguments define the bounding box of the border region
-within \fIdrawable\fR (usually \fIx\fR and \fIy\fR are zero and
-\fIwidth\fR and \fIheight\fR are the dimensions of the window), and
-\fIborderWidth\fR specifies the number of pixels actually
-occupied by the border. The \fIrelief\fR argument indicates
-which of several three-dimensional effects is desired:
-TK_RELIEF_RAISED means that the interior of the rectangle should appear raised
-relative to the exterior of the rectangle, and
-TK_RELIEF_SUNKEN means that the interior should appear depressed.
-TK_RELIEF_GROOVE and TK_RELIEF_RIDGE mean that there should appear to be
-a groove or ridge around the exterior of the rectangle.
-.PP
-\fBTk_Fill3DRectangle\fR is somewhat like \fBTk_Draw3DRectangle\fR except
-that it first fills the rectangular area with the background color
-(one corresponding
-to the \fIcolorName\fR used to create \fIborder\fR). Then it calls
-\fBTk_Draw3DRectangle\fR to draw a border just inside the outer edge of
-the rectangular area. The argument \fIrelief\fR indicates the desired
-effect (TK_RELIEF_FLAT means no border should be drawn; all that
-happens is to fill the rectangle with the background color).
-.PP
-The procedure \fBTk_Draw3DPolygon\fR may be used to draw more complex
-shapes with a three-dimensional appearance. The \fIpointPtr\fR and
-\fInumPoints\fR arguments define a trajectory, \fIpolyBorderWidth\fR
-indicates how wide the border should be (and on which side of the
-trajectory to draw it), and \fIleftRelief\fR indicates which side
-of the trajectory should appear raised. \fBTk_Draw3DPolygon\fR
-draws a border around the given trajectory using the colors from
-\fIborder\fR to produce a three-dimensional appearance. If the trajectory is
-non-self-intersecting, the appearance will be a raised or sunken
-polygon shape. The trajectory may be self-intersecting, although
-it's not clear how useful this is.
-.PP
-\fBTk_Fill3DPolygon\fR is to \fBTk_Draw3DPolygon\fR what
-\fBTk_Fill3DRectangle\fR is to \fBTk_Draw3DRectangle\fR: it fills
-the polygonal area with the background color from \fIborder\fR,
-then calls \fBTk_Draw3DPolygon\fR to draw a border around the
-area (unless \fIleftRelief\fR is TK_RELIEF_FLAT; in this case no
-border is drawn).
-.PP
-The procedures \fBTk_3DVerticalBevel\fR and \fBTk_3DHorizontalBevel\fR
-provide lower-level drawing primitives that are used by
-procedures such as \fBTk_Draw3DRectangle\fR.
-These procedures are also useful in their own right for drawing
-rectilinear border shapes.
-\fBTk_3DVerticalBevel\fR draws a vertical beveled edge, such as the
-left or right side of a rectangle, and \fBTk_3DHorizontalBevel\fR
-draws a horizontal beveled edge, such as the top or bottom of a
-rectangle.
-Each procedure takes \fIx\fR, \fIy\fR, \fIwidth\fR, and \fIheight\fR
-arguments that describe the rectangular area of the beveled edge
-(e.g., \fIwidth\fR is the border width for \fBTk_3DVerticalBevel\fR).
-The \fIleftBorder\fR and \fItopBorder\fR arguments indicate the
-position of the border relative to the ``inside'' of the object, and
-\fIrelief\fR indicates the relief of the inside of the object relative
-to the outside.
-\fBTk_3DVerticalBevel\fR just draws a rectangular region.
-\fBTk_3DHorizontalBevel\fR draws a trapezoidal region to generate
-mitered corners; it should be called after \fBTk_3DVerticalBevel\fR
-(otherwise \fBTk_3DVerticalBevel\fR will overwrite the mitering in
-the corner).
-The \fIleftIn\fR and \fIrightIn\fR arguments to \fBTk_3DHorizontalBevel\fR
-describe the mitering at the corners; a value of 1 means that the bottom
-edge of the trapezoid will be shorter than the top, 0 means it will
-be longer.
-For example, to draw a rectangular border the top bevel should be
-drawn with 1 for both \fIleftIn\fR and \fIrightIn\fR, and the
-bottom bevel should be drawn with 0 for both arguments.
-.PP
-The procedure \fBTk_SetBackgroundFromBorder\fR will modify the background
-pixel and/or pixmap of \fItkwin\fR to produce a result compatible
-with \fIborder\fR. For color displays, the resulting background will
-just be the color given by the \fIcolorName\fR argument passed to
-\fBTk_Get3DBorder\fR when \fIborder\fR was created; for monochrome
-displays, the resulting background
-will be a light stipple pattern, in order to distinguish the background from
-the illuminated portion of the border.
-.PP
-Given a token for a border, the procedure \fBTk_NameOf3DBorder\fR
-will return the \fIcolorName\fR string that was passed to
-\fBTk_Get3DBorder\fR to create the border.
-.PP
-The procedure \fBTk_3DBorderColor\fR returns the XColor structure
-that will be used for flat surfaces drawn for its \fIborder\fR
-argument by procedures like \fBTk_Fill3DRectangle\fR.
-The return value corresponds to the \fIcolorName\fR passed to
-\fBTk_Get3DBorder\fR.
-The XColor, and its associated pixel value, will remain allocated
-as long as \fIborder\fR exists.
-.PP
-The procedure \fBTk_3DBorderGC\fR returns one of the X graphics contexts
-that are used to draw the border.
-The argument \fIwhich\fR selects which one of the three possible GC's:
-TK_3D_FLAT_GC returns the context used for flat surfaces,
-TK_3D_LIGHT_GC returns the context for light shadows,
-and TK_3D_DARK_GC returns the context for dark shadows.
-.PP
-When a border is no longer needed, \fBTk_Free3DBorder\fR should
-be called to release the resources associated with the border.
-There should be exactly one call to \fBTk_Free3DBorder\fR for
-each call to \fBTk_Get3DBorder\fR.
-
-.SH KEYWORDS
-3D, background, border, color, depressed, illumination, polygon, raised, shadow, three-dimensional effect
diff --git a/doc/BindTable.3 b/doc/BindTable.3
deleted file mode 100644
index a2cfbf9..0000000
--- a/doc/BindTable.3
+++ /dev/null
@@ -1,157 +0,0 @@
-'\"
-'\" Copyright (c) 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: BindTable.3,v 1.2 1998/09/14 18:22:45 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_CreateBindingTable 3 4.0 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_CreateBindingTable, Tk_DeleteBindingTable, Tk_CreateBinding, Tk_DeleteBinding, Tk_GetBinding, Tk_GetAllBindings, Tk_DeleteAllBindings, Tk_BindEvent \- invoke scripts in response to X events
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-Tk_BindingTable
-\fBTk_CreateBindingTable(\fIinterp\fB)\fR
-.sp
-\fBTk_DeleteBindingTable(\fIbindingTable\fB)\fR
-.sp
-unsigned long
-\fBTk_CreateBinding(\fIinterp, bindingTable, object, eventString, script, append\fB)\fR
-.sp
-int
-\fBTk_DeleteBinding(\fIinterp, bindingTable, object, eventString\fB)\fR
-.sp
-char *
-\fBTk_GetBinding(\fIinterp, bindingTable, object, eventString\fB)\fR
-.sp
-\fBTk_GetAllBindings(\fIinterp, bindingTable, object\fB)\fR
-.sp
-\fBTk_DeleteAllBindings(\fIbindingTable, object\fB)\fR
-.sp
-\fBTk_BindEvent(\fIbindingTable, eventPtr, tkwin, numObjects, objectPtr\fB)\fR
-.SH ARGUMENTS
-.AS Tk_BindingTable bindingTable
-.AP Tcl_Interp *interp in
-Interpreter to use when invoking bindings in binding table. Also
-used for returning results and errors from binding procedures.
-.AP Tk_BindingTable bindingTable in
-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
-String describing event sequence.
-.AP char *script in
-Tcl script to invoke when binding triggers.
-.AP int append in
-Non-zero means append \fIscript\fR to existing script for binding,
-if any; zero means replace existing script with new one.
-.AP XEvent *eventPtr in
-X event to match against bindings in \fIbindingTable\fR.
-.AP Tk_Window tkwin in
-Identifier for any window on the display where the event occurred.
-Used to find display-related information such as key maps.
-.AP int numObjects in
-Number of object identifiers pointed to by \fIobjectPtr\fR.
-.AP ClientData *objectPtr in
-Points to an array of object identifiers: bindings will be considered
-for each of these objects in order from first to last.
-.BE
-
-.SH DESCRIPTION
-.PP
-These procedures provide a general-purpose mechanism for creating
-and invoking bindings.
-Bindings are organized in terms of \fIbinding tables\fR.
-A binding table consists of a collection of bindings plus a history
-of recent events.
-Within a binding table, bindings are associated with \fIobjects\fR.
-The meaning of an object is defined by clients of the binding package.
-For example, Tk keeps uses one binding table to hold all of the bindings
-created by the \fBbind\fR command.
-For this table, objects are pointers to strings such as window names, class
-names, or other binding tags such as \fBall\fR.
-Tk also keeps a separate binding table for each canvas widget, which manages
-bindings created by the canvas's \fBbind\fR widget command; within
-this table, an object is either a pointer to the internal structure for a
-canvas item or a Tk_Uid identifying a tag.
-.PP
-The procedure \fBTk_CreateBindingTable\fR creates a new binding
-table and associates \fIinterp\fR with it (when bindings in the
-table are invoked, the scripts will be evaluated in \fIinterp\fR).
-\fBTk_CreateBindingTable\fR returns a token for the table, which
-must be used in calls to other procedures such as \fBTk_CreateBinding\fR
-or \fBTk_BindEvent\fR.
-.PP
-\fBTk_DeleteBindingTable\fR frees all of the state associated
-with a binding table.
-Once it returns the caller should not use the \fIbindingTable\fR
-token again.
-.PP
-\fBTk_CreateBinding\fR adds a new binding to an existing table.
-The \fIobject\fR argument identifies the object with which the
-binding is to be associated, and it may be any one-word value.
-Typically it is a pointer to a string or data structure.
-The \fIeventString\fR argument identifies the event or sequence
-of events for the binding; see the documentation for the
-\fBbind\fR command for a description of its format.
-\fIscript\fR is the Tcl script to be evaluated when the binding
-triggers.
-\fIappend\fR indicates what to do if there already
-exists a binding for \fIobject\fR and \fIeventString\fR: if \fIappend\fR
-is zero then \fIscript\fR replaces the old script; if \fIappend\fR
-is non-zero then the new script is appended to the old one.
-\fBTk_CreateBinding\fR returns an X event mask for all the events
-associated with the bindings.
-This information may be useful to invoke \fBXSelectInput\fR to
-select relevant events, or to disallow the use of certain events
-in bindings.
-If an error occurred while creating the binding (e.g., \fIeventString\fR
-refers to a non-existent event), then 0 is returned and an error
-message is left in \fIinterp->result\fR.
-.PP
-\fBTk_DeleteBinding\fR removes from \fIbindingTable\fR the
-binding given by \fIobject\fR and \fIeventString\fR, if
-such a binding exists.
-\fBTk_DeleteBinding\fR always returns TCL_OK.
-In some cases it may reset \fIinterp->result\fR to the default
-empty value.
-.PP
-\fBTk_GetBinding\fR returns a pointer to the script associated
-with \fIeventString\fR and \fIobject\fR in \fIbindingTable\fR.
-If no such binding exists then NULL is returned and an error
-message is left in \fIinterp->result\fR.
-.PP
-\fBTk_GetAllBindings\fR returns in \fIinterp->result\fR a list
-of all the event strings for which there are bindings in
-\fIbindingTable\fR associated with \fIobject\fR.
-If there are no bindings for \fIobject\fR then an empty
-string is returned in \fIinterp->result\fR.
-.PP
-\fBTk_DeleteAllBindings\fR deletes all of the bindings in
-\fIbindingTable\fR that are associated with \fIobject\fR.
-.PP
-\fBTk_BindEvent\fR is called to process an event.
-It makes a copy of the event in an internal history list associated
-with the binding table, then it checks for bindings that match
-the event.
-\fBTk_BindEvent\fR processes each of the objects pointed to
-by \fIobjectPtr\fR in turn.
-For each object, it finds all the bindings that match the current
-event history, selects the most specific binding using the priority
-mechanism described in the documentation for \fBbind\fR,
-and invokes the script for that binding.
-If there are no matching bindings for a particular object, then
-the object is skipped.
-\fBTk_BindEvent\fR continues through all of the objects, handling
-exceptions such as errors, \fBbreak\fR, and \fBcontinue\fR as
-described in the documentation for \fBbind\fR.
-
-.SH KEYWORDS
-binding, event, object, script
diff --git a/doc/CanvPsY.3 b/doc/CanvPsY.3
deleted file mode 100644
index 17e4a05..0000000
--- a/doc/CanvPsY.3
+++ /dev/null
@@ -1,122 +0,0 @@
-'\"
-'\" 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: CanvPsY.3,v 1.2 1998/09/14 18:22:45 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_CanvasPsY 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
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-double
-\fBTk_CanvasPsY\fR(\fIcanvas, canvasY\fR)
-.sp
-int
-\fBTk_CanvasPsBitmap\fR(\fIinterp, canvas, bitmap, x, y, width, height\fR)
-.sp
-int
-\fBTk_CanvasPsColor\fR(\fIinterp, canvas, colorPtr\fR)
-.sp
-int
-\fBTk_CanvasPsFont\fR(\fIinterp, canvas, fontStructPtr\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
-.AP Tk_Canvas canvas in
-A token that identifies a canvas widget for which Postscript is
-being generated.
-.AP double canvasY in
-Y-coordinate in the space of the canvas.
-.AP Tcl_Interp *interp in/out
-A Tcl interpreter; Postscript is appended to its result, or the
-result may be replaced with an error message.
-.AP Pixmap bitmap in
-Bitmap to use for generating Postscript.
-.AP int x in
-X-coordinate within \fIbitmap\fR of left edge of region to output.
-.AP int y in
-Y-coordinate within \fIbitmap\fR of top edge of region to output.
-.AP "int" width in
-Width of region of bitmap to output, in pixels.
-.AP "int" height in
-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
-Font for which Postscript is to be generated.
-.AP double *coordPtr in
-Pointer to an array of coordinates for one or more
-points specified in canvas coordinates.
-The order of values in \fIcoordPtr\fR is x1, y1, x2, y2, x3, y3,
-and so on.
-.AP int numPoints in
-Number of points at \fIcoordPtr\fR.
-.BE
-
-.SH DESCRIPTION
-.PP
-These procedures are called by canvas type managers to carry out
-common functions related to generating Postscript.
-Most of the procedures take a \fIcanvas\fR argument, which
-refers to a canvas widget for which Postscript is being
-generated.
-.PP
-\fBTk_CanvasY\fR takes as argument a y-coordinate in the space of
-a canvas and returns the value that should be used for that point
-in the Postscript currently being generated for \fIcanvas\fR.
-Y coordinates require transformation because Postscript uses an
-origin at the lower-left corner whereas X uses an origin at the
-upper-left corner.
-Canvas x coordinates can be used directly in Postscript without
-transformation.
-.PP
-\fBTk_CanvasPsBitmap\fR generates Postscript to describe a region
-of a bitmap.
-The Postscript is generated in proper image data format for Postscript,
-i.e., as data between angle brackets, one bit per pixel.
-The Postscript is appended to \fIinterp->result\fR and TCL_OK is returned
-unless an error occurs, in which case TCL_ERROR is returned and
-\fIinterp->result\fR is overwritten with an error message.
-.PP
-\fBTk_CanvasPsColor\fR generates Postscript to set the current color
-to correspond to its \fIcolorPtr\fR argument, taking into account any
-color map specified in the \fBpostscript\fR command.
-It appends the Postscript to \fIinterp->result\fR and returns
-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.
-\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.
-It appends the Postscript to \fIinterp->result\fR and returns 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_CanvasPsPath\fR generates Postscript to set the current path
-to the set of points given by \fIcoordPtr\fR and \fInumPoints\fR.
-It appends the resulting Postscript to \fIinterp->result\fR.
-.PP
-\fBTk_CanvasPsStipple\fR generates Postscript that will fill the
-current path in stippled fashion.
-It uses \fIbitmap\fR as the stipple pattern and the current Postscript
-color; ones in the stipple bitmap are drawn in the current color, and
-zeroes are not drawn at all.
-The Postscript is appended to \fIinterp->result\fR and TCL_OK is
-returned, unless an error occurs, in which case TCL_ERROR is returned and
-\fIinterp->result\fR is overwritten with an error message.
-
-.SH KEYWORDS
-bitmap, canvas, color, font, path, Postscript, stipple
diff --git a/doc/CanvTkwin.3 b/doc/CanvTkwin.3
deleted file mode 100644
index bc9490c..0000000
--- a/doc/CanvTkwin.3
+++ /dev/null
@@ -1,161 +0,0 @@
-'\"
-'\" 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: CanvTkwin.3,v 1.2 1998/09/14 18:22:45 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_CanvasTkwin 3 4.1 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_CanvasTkwin, Tk_CanvasGetCoord, Tk_CanvasDrawableCoords, Tk_CanvasSetStippleOrigin, Tk_CanvasWindowCoords, Tk_CanvasEventuallyRedraw, Tk_CanvasTagsOption \- utility procedures for canvas type managers
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-Tk_Window
-\fBTk_CanvasTkwin\fR(\fIcanvas\fR)
-.sp
-int
-\fBTk_CanvasGetCoord\fR(\fIinterp, canvas, string, doublePtr\fR)
-.sp
-\fBTk_CanvasDrawableCoords\fR(\fIcanvas, x, y, drawableXPtr, drawableYPtr\fR)
-.sp
-\fBTk_CanvasSetStippleOrigin\fR(\fIcanvas, gc\fR)
-.sp
-\fBTk_CanvasWindowCoords\fR(\fIcanvas, x, y, screenXPtr, screenYPtr\fR)
-.sp
-\fBTk_CanvasEventuallyRedraw\fR(\fIcanvas, x1, y1, x2, y2\fR)
-.sp
-Tk_OptionParseProc *\fBTk_CanvasTagsParseProc\fR;
-.sp
-Tk_OptionPrintProc *\fBTk_CanvasTagsPrintProc\fR;
-.SH ARGUMENTS
-.AS Tk_ItemType *drawableXPtr
-.AP Tk_Canvas canvas in
-A token that identifies a canvas widget.
-.AP Tcl_Interp *interp in/out
-Interpreter to use for error reporting.
-.AP char *string in
-Textual description of a canvas coordinate.
-.AP double *doublePtr out
-Points to place to store a converted coordinate.
-.AP double x in
-An x coordinate in the space of the canvas.
-.AP double y in
-A y coordinate in the space of the canvas.
-.AP short *drawableXPtr out
-Pointer to a location in which to store an x coordinate in the space
-of the drawable currently being used to redisplay the canvas.
-.AP short *drawableYPtr out
-Pointer to a location in which to store a y coordinate in the space
-of the drawable currently being used to redisplay the canvas.
-.AP GC gc out
-Graphics context to modify.
-.AP short *screenXPtr out
-Points to a location in which to store the screen coordinate in the
-canvas window that corresponds to \fIx\fR.
-.AP short *screenYPtr out
-Points to a location in which to store the screen coordinate in the
-canvas window that corresponds to \fIy\fR.
-.AP int x1 in
-Left edge of the region that needs redisplay. Only pixels at or to
-the right of this coordinate need to be redisplayed.
-.AP int y1 in
-Top edge of the region that needs redisplay. Only pixels at or below
-this coordinate need to be redisplayed.
-.AP int x2 in
-Right edge of the region that needs redisplay. Only pixels to
-the left of this coordinate need to be redisplayed.
-.AP int y2 in
-Bottom edge of the region that needs redisplay. Only pixels above
-this coordinate need to be redisplayed.
-.BE
-
-.SH DESCRIPTION
-.PP
-These procedures are called by canvas type managers to perform various
-utility functions.
-.PP
-\fBTk_CanvasTkwin\fR returns the Tk_Window associated with a particular
-canvas.
-.PP
-\fBTk_CanvasGetCoord\fR translates a string specification of a
-coordinate (such as \fB2p\fR or \fB1.6c\fR) into a double-precision
-canvas coordinate.
-If \fIstring\fR is a valid coordinate description then \fBTk_CanvasGetCoord\fR
-stores the corresponding canvas coordinate at *\fIdoublePtr\fR
-and returns TCL_OK.
-Otherwise it stores an error message in \fIinterp->result\fR and
-returns TCL_ERROR.
-.PP
-\fBTk_CanvasDrawableCoords\fR is called by type managers during
-redisplay to compute where to draw things.
-Given \fIx\fR and \fIy\fR coordinates in the space of the
-canvas, \fBTk_CanvasDrawableCoords\fR computes the corresponding
-pixel in the drawable that is currently being used for redisplay;
-it returns those coordinates in *\fIdrawableXPtr\fR and *\fIdrawableYPtr\fR.
-This procedure should not be invoked except during redisplay.
-.PP
-\fBTk_CanvasSetStippleOrigin\fR is also used during redisplay.
-It sets the stipple origin in \fIgc\fR so that stipples drawn
-with \fIgc\fR in the current offscreen pixmap will line up
-with stipples drawn with origin (0,0) in the canvas's actual
-window.
-\fBTk_CanvasSetStippleOrigin\fR is needed in order to guarantee
-that stipple patterns line up properly when the canvas is
-redisplayed in small pieces.
-Redisplays are carried out in double-buffered fashion where a
-piece of the canvas is redrawn in an offscreen pixmap and then
-copied back onto the screen.
-In this approach the stipple origins in graphics contexts need to
-be adjusted during each redisplay to compensate for the position
-of the off-screen pixmap relative to the window.
-If an item is being drawn with stipples, its type manager typically
-calls \fBTk_CanvasSetStippleOrigin\fR just before using \fIgc\fR
-to draw something; after it is finished drawing, the type manager
-calls \fBXSetTSOrigin\fR to restore the origin in \fIgc\fR back to (0,0)
-(the restore is needed because graphics contexts are shared, so
-they cannot be modified permanently).
-.PP
-\fBTk_CanvasWindowCoords\fR is similar to \fBTk_CanvasDrawableCoords\fR
-except that it returns coordinates in the canvas's window on the
-screen, instead of coordinates in an off-screen pixmap.
-.PP
-\fBTk_CanvasEventuallyRedraw\fR may be invoked by a type manager
-to inform Tk that a portion of a canvas needs to be redrawn.
-The \fIx1\fR, \fIy1\fR, \fIx2\fR, and \fIy2\fR arguments
-specify the region that needs to be redrawn, in canvas coordinates.
-Type managers rarely need to invoke \fBTk_CanvasEventuallyRedraw\fR,
-since Tk can normally figure out when an item has changed and make
-the redisplay request on its behalf (this happens, for example
-whenever Tk calls a \fIconfigureProc\fR or \fIscaleProc\fR).
-The only time that a type manager needs to call
-\fBTk_CanvasEventuallyRedraw\fR is if an item has changed on its own
-without being invoked through one of the procedures in its Tk_ItemType;
-this could happen, for example, in an image item if the image is
-modified using image commands.
-.PP
-\fBTk_CanvasTagsParseProc\fR and \fBTk_CanvasTagsPrintProc\fR are
-procedures that handle the \fB\-tags\fR option for canvas items.
-The code of a canvas type manager won't call these procedures
-directly, but will use their addresses to create a \fBTk_CustomOption\fR
-structure for the \fB\-tags\fR option. The code typically looks
-like this:
-.CS
-static Tk_CustomOption tagsOption = {Tk_CanvasTagsParseProc,
- Tk_CanvasTagsPrintProc, (ClientData) NULL
-};
-
-static Tk_ConfigSpec configSpecs[] = {
- ...
- {TK_CONFIG_CUSTOM, "\-tags", (char *) NULL, (char *) NULL,
- (char *) NULL, 0, TK_CONFIG_NULL_OK, &tagsOption},
- ...
-};
-.CE
-
-.SH KEYWORDS
-canvas, focus, item type, redisplay, selection, type manager
diff --git a/doc/CanvTxtInfo.3 b/doc/CanvTxtInfo.3
deleted file mode 100644
index 0d9f829..0000000
--- a/doc/CanvTxtInfo.3
+++ /dev/null
@@ -1,104 +0,0 @@
-'\"
-'\" 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: CanvTxtInfo.3,v 1.2 1998/09/14 18:22:46 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_CanvasTextInfo 3 4.0 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_CanvasTextInfo \- additional information for managing text items in canvases
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-Tk_CanvasTextInfo *
-\fBTk_CanvasGetTextInfo\fR(\fIcanvas\fR)
-.SH ARGUMENTS
-.AS Tk_Canvas canvas
-.AP Tk_Canvas canvas in
-A token that identifies a particular canvas widget.
-.BE
-
-.SH DESCRIPTION
-.PP
-Textual canvas items are somewhat more complicated to manage than
-other items, due to things like the selection and the input focus.
-\fBTk_CanvasGetTextInfo\fR may be invoked by a type manager
-to obtain additional information needed for items that display text.
-The return value from \fBTk_CanvasGetTextInfo\fR is a pointer to
-a structure that is shared between Tk and all the items that display
-text.
-The structure has the following form:
-.CS
-typedef struct Tk_CanvasTextInfo {
- Tk_3DBorder \fIselBorder\fR;
- int \fIselBorderWidth\fR;
- XColor *\fIselFgColorPtr\fR;
- Tk_Item *\fIselItemPtr\fR;
- int \fIselectFirst\fR;
- int \fIselectLast\fR;
- Tk_Item *\fIanchorItemPtr\fR;
- int \fIselectAnchor\fR;
- Tk_3DBorder \fIinsertBorder\fR;
- int \fIinsertWidth\fR;
- int \fIinsertBorderWidth\fR;
- Tk_Item *\fIfocusItemPtr\fR;
- int \fIgotFocus\fR;
- int \fIcursorOn\fR;
-} Tk_CanvasTextInfo;
-.CE
-The \fBselBorder\fR field identifies a Tk_3DBorder that should be
-used for drawing the background under selected text.
-\fIselBorderWidth\fR gives the width of the raised border around
-selected text, in pixels.
-\fIselFgColorPtr\fR points to an XColor that describes the foreground
-color to be used when drawing selected text.
-\fIselItemPtr\fR points to the item that is currently selected, or
-NULL if there is no item selected or if the canvas doesn't have the
-selection.
-\fIselectFirst\fR and \fIselectLast\fR give the indices of the first
-and last selected characters in \fIselItemPtr\fR, as returned by the
-\fIindexProc\fR for that item.
-\fIanchorItemPtr\fR points to the item that currently has the selection
-anchor; this is not necessarily the same as \fIselItemPtr\fR.
-\fIselectAnchor\fR is an index that identifies the anchor position
-within \fIanchorItemPtr\fR.
-\fIinsertBorder\fR contains a Tk_3DBorder to use when drawing the
-insertion cursor; \fIinsertWidth\fR gives the total width of the
-insertion cursor in pixels, and \fIinsertBorderWidth\fR gives the
-width of the raised border around the insertion cursor.
-\fIfocusItemPtr\fR identifies the item that currently has the input
-focus, or NULL if there is no such item.
-\fIgotFocus\fR is 1 if the canvas widget has the input focus and
-0 otherwise.
-\fIcursorOn\fR is 1 if the insertion cursor should be drawn in
-\fIfocusItemPtr\fR and 0 if it should not be drawn; this field
-is toggled on and off by Tk to make the cursor blink.
-.PP
-The structure returned by \fBTk_CanvasGetTextInfo\fR
-is shared between Tk and the type managers; typically the type manager
-calls \fBTk_CanvasGetTextInfo\fR once when an item is created and
-then saves the pointer in the item's record.
-Tk will update information in the Tk_CanvasTextInfo; for example,
-a \fBconfigure\fR widget command might change the \fIselBorder\fR
-field, or a \fBselect\fR widget command might change the \fIselectFirst\fR
-field, or Tk might change \fIcursorOn\fR in order to make the insertion
-cursor flash on and off during successive redisplays.
-.PP
-Type managers should treat all of the fields of the Tk_CanvasTextInfo
-structure as read-only, except for \fIselItemPtr\fR, \fIselectFirst\fR,
-\fIselectLast\fR, and \fIselectAnchor\fR.
-Type managers may change \fIselectFirst\fR, \fIselectLast\fR, and
-\fIselectAnchor\fR to adjust for insertions and deletions in the
-item (but only if the item is the current owner of the selection or
-anchor, as determined by \fIselItemPtr\fR or \fIanchorItemPtr\fR).
-If all of the selected text in the item is deleted, the item should
-set \fIselItemPtr\fR to NULL to indicate that there is no longer a
-selection.
-
-.SH KEYWORDS
-canvas, focus, insertion cursor, selection, selection anchor, text
diff --git a/doc/Clipboard.3 b/doc/Clipboard.3
deleted file mode 100644
index d3f35d8..0000000
--- a/doc/Clipboard.3
+++ /dev/null
@@ -1,80 +0,0 @@
-'\"
-'\" Copyright (c) 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: Clipboard.3,v 1.2 1998/09/14 18:22:46 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_ClipboardClear 3 4.0 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_ClipboardClear, Tk_ClipboardAppend \- Manage the clipboard
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-int
-\fBTk_ClipboardClear\fR(\fIinterp, tkwin\fR)
-.sp
-int
-\fBTk_ClipboardAppend\fR(\fIinterp, tkwin, target, format, buffer\fR)
-.SH ARGUMENTS
-.AS Tk_ClipboardClear tkwin
-.AP Tcl_Interp *interp in
-Interpreter to use for reporting errors.
-.AP Tk_Window tkwin in
-Window that determines which display's clipboard to manipulate.
-.AP Atom target in
-Conversion type for this clipboard item; has same meaning as
-\fItarget\fR argument to \fBTk_CreateSelHandler\fR.
-.AP Atom format in
-Representation to use when data is retrieved; has same meaning as
-\fIformat\fR argument to \fBTk_CreateSelHandler\fR.
-.AP char *buffer in
-Null terminated string containing the data to be appended to the clipboard.
-.BE
-
-.SH DESCRIPTION
-.PP
-These two procedures manage the clipboard for Tk.
-The clipboard is typically managed by calling \fBTk_ClipboardClear\fR
-once, then calling \fBTk_ClipboardAppend\fR to add data for any
-number of targets.
-.PP
-\fBTk_ClipboardClear\fR claims the CLIPBOARD selection and frees any
-data items previously stored on the clipboard in this application.
-It normally returns TCL_OK, but if an error occurs it returns
-TCL_ERROR and leaves an error message in \fIinterp->result\fR.
-\fBTk_ClipboardClear\fR must be called before a sequence of
-\fBTk_ClipboardAppend\fR calls can be issued.
-.PP
-\fBTk_ClipboardAppend\fR appends a buffer of data to the clipboard.
-The first buffer for a given \fItarget\fR determines the \fIformat\fR
-for that \fItarget\fR.
-Any successive appends for that \fItarget\fR must have
-the same format or an error will be returned.
-\fBTk_ClipboardAppend\fR returns TCL_OK if the buffer is
-successfully copied onto the clipboard. If the clipboard is not
-currently owned by the application, either
-because \fBTk_ClipboardClear\fR has not been called or because
-ownership of the clipboard has changed since the last call to
-\fBTk_ClipboardClear\fR,
-\fBTk_ClipboardAppend\fR returns TCL_ERROR and leaves an error message in
-\fIinterp->result\fR.
-.PP
-In order to guarantee atomicity, no event handling should occur
-between \fBTk_ClipboardClear\fR and the following
-\fBTk_ClipboardAppend\fR calls (otherwise someone could retrieve
-a partially completed clipboard or claim ownership away from
-this application).
-.PP
-\fBTk_ClipboardClear\fR may invoke callbacks, including arbitrary
-Tcl scripts, as a result of losing the CLIPBOARD selection, so
-any calling function should take care to be reentrant at the point
-\fBTk_ClipboardClear\fR is invoked.
-
-.SH KEYWORDS
-append, clipboard, clear, format, type
diff --git a/doc/ClrSelect.3 b/doc/ClrSelect.3
deleted file mode 100644
index 1736848..0000000
--- a/doc/ClrSelect.3
+++ /dev/null
@@ -1,42 +0,0 @@
-'\"
-'\" 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.
-'\"
-'\" RCS: @(#) $Id: ClrSelect.3,v 1.2 1998/09/14 18:22:46 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_ClearSelection 3 4.0 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_ClearSelection \- Deselect a selection
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-\fBTk_ClearSelection\fR(\fItkwin, selection\fR)
-.SH ARGUMENTS
-.AS Tk_Window tkwin
-.AP Tk_Window tkwin in
-The selection will be cleared from the display containing this
-window.
-.AP Atom selection in
-The name of selection to be cleared.
-.BE
-
-.SH DESCRIPTION
-.PP
-\fBTk_ClearSelection\fR cancels the selection specified by the atom
-\fIselection\fR for the display containing \fItkwin\fR.
-The selection need not be in \fItkwin\fR itself or even in
-\fItkwin\fR's application.
-If there is a window anywhere on \fItkwin\fR's display that
-owns \fIselection\fR, the window will be notified and the
-selection will be cleared.
-If there is no owner for \fIselection\fR on the display, then the
-procedure has no effect.
-
-.SH KEYWORDS
-clear, selection
diff --git a/doc/ConfigWidg.3 b/doc/ConfigWidg.3
deleted file mode 100644
index 04daead..0000000
--- a/doc/ConfigWidg.3
+++ /dev/null
@@ -1,618 +0,0 @@
-'\"
-'\" 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: ConfigWidg.3,v 1.2 1998/09/14 18:22:46 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_ConfigureWidget 3 4.1 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_ConfigureWidget, Tk_Offset, Tk_ConfigureInfo, Tk_ConfigureValue, Tk_FreeOptions \- process configuration options for widgets
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-int
-\fBTk_ConfigureWidget(\fIinterp, tkwin, specs, argc, argv, widgRec, flags\fB)\fR
-.sp
-int
-\fBTk_Offset(\fItype, field\fB)\fR
-.sp
-int
-\fBTk_ConfigureInfo(\fIinterp, tkwin, specs, widgRec, argvName, flags\fB)\fR
-.sp
-int
-.sp
-\fBTk_FreeOptions(\fIspecs, widgRec, display, flags\fB)\fR
-.SH ARGUMENTS
-.AS Tk_ConfigSpec *widgRec
-.AP Tcl_Interp *interp in
-Interpreter to use for returning error messages.
-.AP Tk_Window tkwin in
-Window used to represent widget (needed to set up X resources).
-.AP Tk_ConfigSpec *specs in
-Pointer to table specifying legal configuration options for this
-widget.
-.AP int argc in
-Number of arguments in \fIargv\fR.
-.AP char **argv in
-Command-line options for configuring widget.
-.AP char *widgRec in/out
-Points to widget record structure. Fields in this structure get
-modified by \fBTk_ConfigureWidget\fR to hold configuration information.
-.AP int flags in
-If non-zero, then it specifies an OR-ed combination of flags that
-control the processing of configuration information.
-TK_CONFIG_ARGV_ONLY causes the option database and defaults to be
-ignored, and flag bits TK_CONFIG_USER_BIT and higher are used to
-selectively disable entries in \fIspecs\fR.
-.AP "type name" type in
-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
-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
-option. If NULL, then information is returned for all available
-options.
-.AP Display *display in
-Display containing widget whose record is being freed; needed in
-order to free up resources.
-.BE
-.SH DESCRIPTION
-.PP
-\fBTk_ConfigureWidget\fR is called to configure various aspects of a
-widget, such as colors, fonts, border width, etc.
-It is intended as a convenience procedure to reduce the amount
-of code that must be written in individual widget managers to
-handle configuration information.
-It is typically
-invoked when widgets are created, and again when the \fBconfigure\fR
-command is invoked for a widget.
-Although intended primarily for widgets, \fBTk_ConfigureWidget\fR
-can be used in other situations where \fIargc-argv\fR information
-is to be used to fill in a record structure, such as configuring
-graphical elements for a canvas widget or entries of a menu.
-.PP
-\fBTk_ConfigureWidget\fR processes
-a table specifying the configuration options that are supported
-(\fIspecs\fR) and a collection of command-line arguments (\fIargc\fR and
-\fIargv\fR) to fill in fields of a record (\fIwidgRec\fR).
-It uses the option database and defaults specified in \fIspecs\fR
-to fill in fields of \fIwidgRec\fR that are not specified in \fIargv\fR.
-\fBTk_ConfigureWidget\fR normally returns the value TCL_OK; in this
-case it does not modify \fIinterp\fR.
-If an error
-occurs then TCL_ERROR is returned and \fBTk_ConfigureWidget\fR will
-leave an error message in \fIinterp->result\fR in the standard Tcl
-fashion.
-In the event of an error return, some of the fields of \fIwidgRec\fR
-could already have been set, if configuration information for them
-was successfully processed before the error occurred.
-The other fields will be set to reasonable initial values so that
-\fBTk_FreeOptions\fR can be called for cleanup.
-.PP
-The \fIspecs\fR array specifies the kinds of configuration options
-expected by the widget. Each of its entries specifies one configuration
-option and has the following structure:
-.CS
-typedef struct {
- int \fItype\fR;
- char *\fIargvName\fR;
- char *\fIdbName\fR;
- char *\fIdbClass\fR;
- char *\fIdefValue\fR;
- int \fIoffset\fR;
- int \fIspecFlags\fR;
- Tk_CustomOption *\fIcustomPtr\fR;
-} Tk_ConfigSpec;
-.CE
-The \fItype\fR field indicates what type of configuration option this is
-(e.g. TK_CONFIG_COLOR for a color value, or TK_CONFIG_INT for
-an integer value). The \fItype\fR field indicates how to use the
-value of the option (more on this below).
-The \fIargvName\fR field is a string such as ``\-font'' or ``\-bg'',
-which is compared with the values in \fIargv\fR (if \fIargvName\fR is
-NULL it means this is a grouped entry; see GROUPED ENTRIES below). The
-\fIdbName\fR and \fIdbClass\fR fields are used to look up a value
-for this option in the option database. The \fIdefValue\fR field
-specifies a default value for this configuration option if no
-value is specified in either \fIargv\fR or the option database.
-\fIOffset\fR indicates where in \fIwidgRec\fR to store information
-about this option, and \fIspecFlags\fR contains additional information
-to control the processing of this configuration option (see FLAGS
-below).
-The last field, \fIcustomPtr\fR, is only used if \fItype\fR is
-TK_CONFIG_CUSTOM; see CUSTOM OPTION TYPES below.
-.PP
-\fBTk_ConfigureWidget\fR first processes \fIargv\fR to see which
-(if any) configuration options are specified there. \fIArgv\fR
-must contain an even number of fields; the first of each pair
-of fields must match the \fIargvName\fR of some entry in \fIspecs\fR
-(unique abbreviations are acceptable),
-and the second field of the pair contains the value for that
-configuration option. If there are entries in \fIspec\fR for which
-there were no matching entries in \fIargv\fR,
-\fBTk_ConfigureWidget\fR uses the \fIdbName\fR and \fIdbClass\fR
-fields of the \fIspecs\fR entry to probe the option database; if
-a value is found, then it is used as the value for the option.
-Finally, if no entry is found in the option database, the
-\fIdefValue\fR field of the \fIspecs\fR entry is used as the
-value for the configuration option. If the \fIdefValue\fR is
-NULL, or if the TK_CONFIG_DONT_SET_DEFAULT bit is set in
-\fIflags\fR, then there is no default value and this \fIspecs\fR entry
-will be ignored if no value is specified in \fIargv\fR or the
-option database.
-.PP
-Once a string value has been determined for a configuration option,
-\fBTk_ConfigureWidget\fR translates the string value into a more useful
-form, such as a color if \fItype\fR is TK_CONFIG_COLOR or an integer
-if \fItype\fR is TK_CONFIG_INT. This value is then stored in the
-record pointed to by \fIwidgRec\fR. This record is assumed to
-contain information relevant to the manager of the widget; its exact
-type is unknown to \fBTk_ConfigureWidget\fR. The \fIoffset\fR field
-of each \fIspecs\fR entry indicates where in \fIwidgRec\fR to store
-the information about this configuration option. You should use the
-\fBTk_Offset\fR macro to generate \fIoffset\fR values (see below for
-a description of \fBTk_Offset\fR). The location indicated by
-\fIwidgRec\fR and \fIoffset\fR will be referred to as the ``target''
-in the descriptions below.
-.PP
-The \fItype\fR field of each entry in \fIspecs\fR determines what
-to do with the string value of that configuration option. The
-legal values for \fItype\fR, and the corresponding actions, are:
-.TP
-\fBTK_CONFIG_ACTIVE_CURSOR\fR
-The value
-must be an ASCII string identifying a cursor in a form
-suitable for passing to \fBTk_GetCursor\fR.
-The value is converted to a \fBTk_Cursor\fR by calling
-\fBTk_GetCursor\fR and the result is stored in the target.
-In addition, the resulting cursor is made the active cursor
-for \fItkwin\fR by calling \fBXDefineCursor\fR.
-If TK_CONFIG_NULL_OK is specified in \fIspecFlags\fR then the value
-may be an empty string, in which case the target and \fItkwin\fR's
-active cursor will be set to \fBNone\fR.
-If the previous value of the target
-wasn't \fBNone\fR, then it is freed by passing it to \fBTk_FreeCursor\fR.
-.TP
-\fBTK_CONFIG_ANCHOR\fR
-The value must be an ASCII string identifying an anchor point in one of the ways
-accepted by \fBTk_GetAnchor\fR.
-The string is converted to a \fBTk_Anchor\fR by calling
-\fBTk_GetAnchor\fR and the result is stored in the target.
-.TP
-\fBTK_CONFIG_BITMAP\fR
-The value must be an ASCII string identifying a bitmap in a form
-suitable for passing to \fBTk_GetBitmap\fR. The value is converted
-to a \fBPixmap\fR by calling \fBTk_GetBitmap\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 is set to \fBNone\fR.
-If the previous value of the target
-wasn't \fBNone\fR, then it is freed by passing it to \fBTk_FreeBitmap\fR.
-.TP
-\fBTK_CONFIG_BOOLEAN\fR
-The value must be an ASCII string specifying a boolean value. Any
-of the values ``true'', ``yes'', ``on'', or ``1'',
-or an abbreviation of one of these values, means true;
-any of the values ``false'', ``no'', ``off'', or ``0'', or an abbreviation of
-one of these values, means false.
-The target is expected to be an integer; for true values it will
-be set to 1 and for false values it will be set to 0.
-.TP
-\fBTK_CONFIG_BORDER\fR
-The value must be an ASCII string identifying a border color in a form
-suitable for passing to \fBTk_Get3DBorder\fR. The value is converted
-to a (\fBTk_3DBorder *\fR) by calling \fBTk_Get3DBorder\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.
-If the previous value of the target
-wasn't NULL, then it is freed by passing it to \fBTk_Free3DBorder\fR.
-.TP
-\fBTK_CONFIG_CAP_STYLE\fR
-The value must be
-an ASCII string identifying a cap style in one of the ways
-accepted by \fBTk_GetCapStyle\fR.
-The string is converted to an integer value corresponding
-to the cap style by calling
-\fBTk_GetCapStyle\fR and the result is stored in the target.
-.TP
-\fBTK_CONFIG_COLOR\fR
-The value must be an ASCII string identifying a color in a form
-suitable for passing to \fBTk_GetColor\fR. The value is converted
-to an (\fBXColor *\fR) by calling \fBTk_GetColor\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 \fBNone\fR.
-If the previous value of the target
-wasn't NULL, then it is freed by passing it to \fBTk_FreeColor\fR.
-.TP
-\fBTK_CONFIG_CURSOR\fR
-This option is identical to \fBTK_CONFIG_ACTIVE_CURSOR\fR except
-that the new cursor is not made the active one for \fItkwin\fR.
-.TP
-\fBTK_CONFIG_CUSTOM\fR
-This option allows applications to define new option types.
-The \fIcustomPtr\fR field of the entry points to a structure
-defining the new option type.
-See the section CUSTOM OPTION TYPES below for details.
-.TP
-\fBTK_CONFIG_DOUBLE\fR
-The value must be an ASCII floating-point number in
-the format accepted by \fBstrtol\fR. The string is converted
-to a \fBdouble\fR value, and the value is stored in the
-target.
-.TP
-\fBTK_CONFIG_END\fR
-Marks the end of the table. The last entry in \fIspecs\fR
-must have this type; all of its other fields are ignored and it
-will never match any arguments.
-.TP
-\fBTK_CONFIG_FONT\fR
-The value must be an ASCII string identifying a font in a form
-suitable for passing to \fBTk_GetFontStruct\fR. The value is converted
-to an (\fBXFontStruct *\fR) by calling \fBTk_GetFontStruct\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.
-If the previous value of the target
-wasn't NULL, then it is freed by passing it to \fBTk_FreeFontStruct\fR.
-.TP
-\fBTK_CONFIG_INT\fR
-The value must be an ASCII integer string
-in the format accepted by \fBstrtol\fR (e.g. ``0''
-and ``0x'' prefixes may be used to specify octal or hexadecimal
-numbers, respectively). The string is converted to an integer
-value and the integer is stored in the target.
-.TP
-\fBTK_CONFIG_JOIN_STYLE\fR
-The value must be
-an ASCII string identifying a join style in one of the ways
-accepted by \fBTk_GetJoinStyle\fR.
-The string is converted to an integer value corresponding
-to the join style by calling
-\fBTk_GetJoinStyle\fR and the result is stored in the target.
-.TP
-\fBTK_CONFIG_JUSTIFY\fR
-The value must be
-an ASCII string identifying a justification method in one of the
-ways accepted by \fBTk_GetJustify\fR.
-The string is converted to a \fBTk_Justify\fR by calling
-\fBTk_GetJustify\fR and the result is stored in the target.
-.TP
-\fBTK_CONFIG_MM\fR
-The value must specify a screen distance in one of the forms acceptable
-to \fBTk_GetScreenMM\fR.
-The string is converted to double-precision floating-point distance
-in millimeters and the value is stored in the target.
-.TP
-\fBTK_CONFIG_PIXELS\fR
-The value must specify screen units in one of the forms acceptable
-to \fBTk_GetPixels\fR.
-The string is converted to an integer distance in pixels and the
-value is stored in the target.
-.TP
-\fBTK_CONFIG_RELIEF\fR
-The value must be an ASCII string identifying a relief in a form
-suitable for passing to \fBTk_GetRelief\fR. The value is converted
-to an integer relief value by calling \fBTk_GetRelief\fR and the result
-is stored in the target.
-.TP
-\fBTK_CONFIG_STRING\fR
-A copy
-of the value is made by allocating memory space with
-\fBmalloc\fR and copying the value into the dynamically-allocated
-space. A pointer to the new string 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.
-If the previous value of the target wasn't NULL, then it is
-freed by passing it to \fBfree\fR.
-.TP
-\fBTK_CONFIG_SYNONYM\fR
-This \fItype\fR value identifies special entries in \fIspecs\fR that
-are synonyms for other entries. If an \fIargv\fR value matches the
-\fIargvName\fR of a TK_CONFIG_SYNONYM entry, the entry isn't used
-directly. Instead, \fBTk_ConfigureWidget\fR searches \fIspecs\fR
-for another entry whose \fIargvName\fR is the same as the \fIdbName\fR
-field in the TK_CONFIG_SYNONYM entry; this new entry is used just
-as if its \fIargvName\fR had matched the \fIargv\fR value. The
-synonym mechanism allows multiple \fIargv\fR values to be used for
-a single configuration option, such as ``\-background'' and ``\-bg''.
-.TP
-\fBTK_CONFIG_UID\fR
-The value is translated to a \fBTk_Uid\fR
-(by passing it to \fBTk_GetUid\fR). The resulting value
-is stored in the target.
-If TK_CONFIG_NULL_OK is specified in \fIspecFlags\fR and the value
-is an empty string then the target will be set to NULL.
-.TP
-\fBTK_CONFIG_WINDOW\fR
-The value must be a window path name. It is translated to a
-\fBTk_Window\fR token and the token is stored in the target.
-
-.SH "GROUPED ENTRIES"
-.PP
-In some cases it is useful to generate multiple resources from
-a single configuration value. For example, a color name might
-be used both to generate the background color for a widget (using
-TK_CONFIG_COLOR) and to generate a 3-D border to draw around the
-widget (using TK_CONFIG_BORDER). In cases like this it is possible
-to specify that several consecutive entries in \fIspecs\fR are to
-be treated as a group. The first entry is used to determine a value
-(using its \fIargvName\fR, \fIdbName\fR,
-\fIdbClass\fR, and \fIdefValue\fR fields). The value will be processed
-several times (one for each entry in the group), generating multiple
-different resources and modifying multiple targets within \fIwidgRec\fR.
-Each of the entries after the first must have a NULL value in its
-\fIargvName\fR field; this indicates that the entry is to be grouped
-with the entry that precedes it. Only the \fItype\fR and \fIoffset\fR
-fields are used from these follow-on entries.
-
-.SH "FLAGS"
-.PP
-The \fIflags\fR argument passed to \fBTk_ConfigureWidget\fR is used
-in conjunction with the \fIspecFlags\fR fields in the entries of \fIspecs\fR
-to provide additional control over the processing of configuration
-options. These values are used in three different ways as
-described below.
-.PP
-First, if the \fIflags\fR argument to \fBTk_ConfigureWidget\fR has
-the TK_CONFIG_ARGV_ONLY bit set (i.e., \fIflags\fR | TK_CONFIG_ARGV_ONLY != 0),
-then the option database and
-\fIdefValue\fR fields are not used. In this case, if an entry in
-\fIspecs\fR doesn't match a field in \fIargv\fR then nothing happens:
-the corresponding target isn't modified. This feature is useful
-when the goal is to modify certain configuration options while
-leaving others in their current state, such as when a \fBconfigure\fR
-widget command is being processed.
-.PP
-Second, the \fIspecFlags\fR field of an entry in \fIspecs\fR may be used
-to control the processing of that entry. Each \fIspecFlags\fR
-field may consists of an OR-ed combination of the following values:
-.TP
-\fBTK_CONFIG_COLOR_ONLY\fR
-If this bit is set then the entry will only be considered if the
-display for \fItkwin\fR has more than one bit plane. If the display
-is monochromatic then this \fIspecs\fR entry will be ignored.
-.TP
-\fBTK_CONFIG_MONO_ONLY\fR
-If this bit is set then the entry will only be considered if the
-display for \fItkwin\fR has exactly one bit plane. If the display
-is not monochromatic then this \fIspecs\fR entry will be ignored.
-.TP
-\fBTK_CONFIG_NULL_OK\fR
-This bit is only relevant for some types of entries (see the
-descriptions of the various entry types above).
-If this bit is set, it indicates that an empty string value
-for the field is acceptable and if it occurs then the
-target should be set to NULL or \fBNone\fR, depending
-on the type of the target.
-This flag is typically used to allow a
-feature to be turned off entirely, e.g. set a cursor value to
-\fBNone\fR so that a window simply inherits its parent's cursor.
-If this bit isn't set then empty strings are processed as strings,
-which generally results in an error.
-.TP
-\fBTK_CONFIG_DONT_SET_DEFAULT\fR
-If this bit is one, it means that the \fIdefValue\fR field of the
-entry should only be used for returning the default value in
-\fBTk_ConfigureInfo\fR.
-In calls to \fBTk_ConfigureWidget\fR no default will be supplied
-for entries with this flag set; it is assumed that the
-caller has already supplied a default value in the target location.
-This flag provides a performance optimization where it is expensive
-to process the default string: the client can compute the default
-once, save the value, and provide it before calling
-\fBTk_ConfigureWidget\fR.
-.TP
-\fBTK_CONFIG_OPTION_SPECIFIED\fR
-This bit is set and cleared by \fBTk_ConfigureWidget\fR. Whenever
-\fBTk_ConfigureWidget\fR returns, this bit will be set in all the
-entries where a value was specified in \fIargv\fR.
-It will be zero in all other entries.
-This bit provides a way for clients to determine which values
-actually changed in a call to \fBTk_ConfigureWidget\fR.
-.PP
-The TK_CONFIG_MONO_ONLY and TK_CONFIG_COLOR_ONLY flags are typically
-used to specify different default values for
-monochrome and color displays. This is done by creating two
-entries in \fIspecs\fR that are identical except for their
-\fIdefValue\fR and \fIspecFlags\fR fields. One entry should have
-the value TK_CONFIG_MONO_ONLY in its \fIspecFlags\fR and the
-default value for monochrome displays in its \fIdefValue\fR; the
-other entry entry should have the value TK_CONFIG_COLOR_ONLY in
-its \fIspecFlags\fR and the appropriate \fIdefValue\fR for
-color displays.
-.PP
-Third, it is possible to use \fIflags\fR and \fIspecFlags\fR
-together to selectively disable some entries. This feature is
-not needed very often. It is useful in cases where several
-similar kinds of widgets are implemented in one place. It allows
-a single \fIspecs\fR table to be created with all the configuration
-options for all the widget types. When processing a particular
-widget type, only entries relevant to that type will be used. This
-effect is achieved by setting the high-order bits (those in positions
-equal to or greater than TK_CONFIG_USER_BIT) in \fIspecFlags\fR
-values or in \fIflags\fR. In order for a particular entry in
-\fIspecs\fR to be used, its high-order bits must match exactly
-the high-order bits of the \fIflags\fR value passed to
-\fBTk_ConfigureWidget\fR. If a \fIspecs\fR table is being used
-for N different widget types, then N of the high-order bits will
-be used. Each \fIspecs\fR entry will have one of more of those
-bits set in its \fIspecFlags\fR field to indicate the widget types
-for which this entry is valid. When calling \fBTk_ConfigureWidget\fR,
-\fIflags\fR will have a single one of these bits set to select the
-entries for the desired widget type. For a working example of
-this feature, see the code in tkButton.c.
-
-.SH TK_OFFSET
-.PP
-The \fBTk_Offset\fR macro is provided as a safe way of generating
-the \fIoffset\fR values for entries in Tk_ConfigSpec structures.
-It takes two arguments: the name of a type of record, and the
-name of a field in that record. It returns the byte offset of
-the named field in records of the given type.
-
-.SH TK_CONFIGUREINFO
-.PP
-The \fBTk_ConfigureInfo\fR procedure may be used to obtain
-information about one or all of the options for a given widget.
-Given a token for a window (\fItkwin\fR), a table describing the
-configuration options for a class of widgets (\fIspecs\fR), a
-pointer to a widget record containing the current information for
-a widget (\fIwidgRec\fR), and a NULL \fIargvName\fR argument,
-\fBTk_ConfigureInfo\fR generates a string describing all of the
-configuration options for the window. The string is placed
-in \fIinterp->result\fR. Under normal circumstances
-it returns TCL_OK; if an error occurs then it returns TCL_ERROR
-and \fIinterp->result\fR contains an error message.
-.PP
-If \fIargvName\fR is NULL, then the value left in
-\fIinterp->result\fR by \fBTk_ConfigureInfo\fR
-consists of a list of one or more entries, each of which describes
-one configuration option (i.e. one entry in \fIspecs\fR). Each
-entry in the list will contain either two or five values. If the
-corresponding entry in \fIspecs\fR has type TK_CONFIG_SYNONYM, then
-the list will contain two values: the \fIargvName\fR for the entry
-and the \fIdbName\fR (synonym name). Otherwise the list will contain
-five values: \fIargvName\fR, \fIdbName\fR, \fIdbClass\fR, \fIdefValue\fR,
-and current value. The current value is computed from the appropriate
-field of \fIwidgRec\fR by calling procedures like \fBTk_NameOfColor\fR.
-.PP
-If the \fIargvName\fR argument to \fBTk_ConfigureInfo\fR is non-NULL,
-then it indicates a single option, and information is returned only
-for that option. The string placed in \fIinterp->result\fR will be
-a list containing two or five values as described above; this will
-be identical to the corresponding sublist that would have been returned
-if \fIargvName\fR had been NULL.
-.PP
-The \fIflags\fR argument to \fBTk_ConfigureInfo\fR is used to restrict
-the \fIspecs\fR entries to consider, just as for \fBTk_ConfigureWidget\fR.
-
-.SH TK_CONFIGUREVALUE
-.PP
-\fBTk_ConfigureValue\fR takes arguments similar to \fBTk_ConfigureInfo\fR;
-instead of returning a list of values, it just returns the current value
-of the option given by \fIargvName\fR (\fIargvName\fR must not be NULL).
-The value is returned in \fIinterp->result\fR and TCL_OK is
-normally returned as the procedure's result.
-If an error occurs in \fBTk_ConfigureValue\fR (e.g., \fIargvName\fR is
-not a valid option name), TCL_ERROR is returned and an error message
-is left in \fIinterp->result\fR.
-This procedure is typically called to implement \fBcget\fR widget
-commands.
-
-.SH TK_FREEOPTIONS
-.PP
-The \fBTk_FreeOptions\fR procedure may be invoked during widget cleanup
-to release all of the resources associated with configuration options.
-It scans through \fIspecs\fR and for each entry corresponding to a
-resource that must be explicitly freed (e.g. those with
-type TK_CONFIG_COLOR), it frees the resource in the widget record.
-If the field in the widget record doesn't refer to a resource (e.g.
-it contains a null pointer) then no resource is freed for that
-entry.
-After freeing a resource, \fBTk_FreeOptions\fR sets the
-corresponding field of the widget record to null.
-
-.SH "CUSTOM OPTION TYPES"
-.PP
-Applications can extend the built-in configuration types with additional
-configuration types by writing procedures to parse and print options
-of the a type and creating a structure pointing to those procedures:
-.CS
-typedef struct Tk_CustomOption {
- Tk_OptionParseProc *\fIparseProc\fR;
- Tk_OptionPrintProc *\fIprintProc\fR;
- ClientData \fIclientData\fR;
-} Tk_CustomOption;
-
-typedef int Tk_OptionParseProc(
- ClientData \fIclientData\fR,
- Tcl_Interp *\fIinterp\fR,
- Tk_Window \fItkwin\fR,
- char *\fIvalue\fR,
- char *\fIwidgRec\fR,
- int \fIoffset\fR);
-
-typedef char *Tk_OptionPrintProc(
- ClientData \fIclientData\fR,
- Tk_Window \fItkwin\fR,
- char *\fIwidgRec\fR,
- int \fIoffset\fR,
- Tcl_FreeProc **\fIfreeProcPtr\fR);
-.CE
-The Tk_CustomOption structure contains three fields, which are pointers
-to the two 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.
-.PP
-The \fIparseProc\fR procedure is invoked by
-\fBTk_ConfigureWidget\fR to parse a string and store the resulting
-value in the widget record.
-The \fIclientData\fR argument is a copy of the \fIclientData\fR
-field in the Tk_CustomOption structure.
-The \fIinterp\fR argument points to a Tcl interpreter used for
-error reporting. \fITkwin\fR is a copy of the \fItkwin\fR argument
-to \fBTk_ConfigureWidget\fR. The \fIvalue\fR argument is a string
-describing the value for the option; it could have been specified
-explicitly in the call to \fBTk_ConfigureWidget\fR or it could
-come from the option database or a default.
-\fIValue\fR will never be a null pointer but it may point to
-an empty string.
-\fIRecordPtr\fR is the same as the \fIwidgRec\fR argument to
-\fBTk_ConfigureWidget\fR; it points to the start of the widget
-record to modify.
-The last argument, \fIoffset\fR, gives the offset in bytes from the start
-of the widget record to the location where the option value is to
-be placed. The procedure should translate the string to whatever
-form is appropriate for the option and store the value in the widget
-record. It should normally return TCL_OK, but if an error occurs
-in translating the string to a value then it should return TCL_ERROR
-and store an error message in \fIinterp->result\fR.
-.PP
-The \fIprintProc\fR procedure is called
-by \fBTk_ConfigureInfo\fR to produce a string value describing an
-existing option.
-Its \fIclientData\fR, \fItkwin\fR, \fIwidgRec\fR, and \fIoffset\fR
-arguments all have the same meaning as for Tk_OptionParseProc
-procedures.
-The \fIprintProc\fR procedure should examine the option whose value
-is stored at \fIoffset\fR in \fIwidgRec\fR, produce a string describing
-that option, and return a pointer to the string.
-If the string is stored in dynamically-allocated memory, then
-the procedure must set \fI*freeProcPtr\fR to the address of
-a procedure to call to free the string's memory; \fBTk_ConfigureInfo\fR
-will call this procedure when it is finished with the string.
-If the result string is stored in static memory then \fIprintProc\fR
-need not do anything with the \fIfreeProcPtr\fR argument.
-.PP
-Once \fIparseProc\fR and \fIprintProc\fR have been defined and a
-Tk_CustomOption structure has been created for them, options of this
-new type may be manipulated with Tk_ConfigSpec entries whose \fItype\fR
-fields are TK_CONFIG_CUSTOM and whose \fIcustomPtr\fR fields point
-to the Tk_CustomOption structure.
-
-.SH EXAMPLES
-.PP
-Although the explanation of \fBTk_ConfigureWidget\fR is fairly
-complicated, its actual use is pretty straightforward.
-The easiest way to get started is to copy the code
-from an existing widget.
-The library implementation of frames
-(tkFrame.c) has a simple configuration table, and the library
-implementation of buttons (tkButton.c) has a much more complex
-table that uses many of the fancy \fIspecFlags\fR mechanisms.
-
-.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/doc/ConfigWind.3 b/doc/ConfigWind.3
deleted file mode 100644
index c9f0089..0000000
--- a/doc/ConfigWind.3
+++ /dev/null
@@ -1,153 +0,0 @@
-'\"
-'\" Copyright (c) 1990-1993 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: ConfigWind.3,v 1.2 1998/09/14 18:22:46 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_ConfigureWindow 3 4.0 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_ConfigureWindow, Tk_MoveWindow, Tk_ResizeWindow, Tk_MoveResizeWindow, Tk_SetWindowBorderWidth, Tk_ChangeWindowAttributes, Tk_SetWindowBackground, Tk_SetWindowBackgroundPixmap, Tk_SetWindowBorder, Tk_SetWindowBorderPixmap, Tk_SetWindowColormap, Tk_DefineCursor, Tk_UndefineCursor \- change window configuration or attributes
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-\fBTk_ConfigureWindow\fR(\fItkwin, valueMask, valuePtr\fR)
-.sp
-\fBTk_MoveWindow\fR(\fItkwin, x, y\fR)
-.sp
-\fBTk_ResizeWindow\fR(\fItkwin, width, height\fR)
-.sp
-\fBTk_MoveResizeWindow\fR(\fItkwin, x, y, width, height\fR)
-.sp
-\fBTk_SetWindowBorderWidth\fR(\fItkwin, borderWidth\fR)
-.sp
-\fBTk_ChangeWindowAttributes\fR(\fItkwin, valueMask, attsPtr\fR)
-.sp
-\fBTk_SetWindowBackground\fR(\fItkwin, pixel\fR)
-.sp
-\fBTk_SetWindowBackgroundPixmap\fR(\fItkwin, pixmap\fR)
-.sp
-\fBTk_SetWindowBorder\fR(\fItkwin, pixel\fR)
-.sp
-\fBTk_SetWindowBorderPixmap\fR(\fItkwin, pixmap\fR)
-.sp
-\fBTk_SetWindowColormap\fR(\fItkwin, colormap\fR)
-.sp
-\fBTk_DefineCursor\fR(\fItkwin, cursor\fR)
-.sp
-\fBTk_UndefineCursor\fR(\fItkwin\fR)
-.SH ARGUMENTS
-.AS XSetWindowAttributes borderWidth
-.AP Tk_Window tkwin in
-Token for window.
-.AP "unsigned int" valueMask in
-OR-ed mask of values like \fBCWX\fR or \fBCWBorderPixel\fR,
-indicating which fields of \fI*valuePtr\fR or \fI*attsPtr\fR to use.
-.AP XWindowChanges *valuePtr in
-Points to a structure containing new values for the configuration
-parameters selected by \fIvalueMask\fR. Fields not selected
-by \fIvalueMask\fR are ignored.
-.AP int x in
-New x-coordinate for \fItkwin\fR's top left pixel (including
-border, if any) within tkwin's parent.
-.AP int y in
-New y-coordinate for \fItkwin\fR's top left pixel (including
-border, if any) within tkwin's parent.
-.AP "int" width in
-New width for \fItkwin\fR (interior, not including border).
-.AP "int" height in
-New height for \fItkwin\fR (interior, not including border).
-.AP "int" borderWidth in
-New width for \fItkwin\fR's border.
-.AP XSetWindowAttributes *attsPtr in
-Points to a structure containing new values for the attributes
-given by the \fIvalueMask\fR argument. Attributes not selected
-by \fIvalueMask\fR are ignored.
-.AP "unsigned long" pixel in
-New background or border color for window.
-.AP Pixmap pixmap in
-New pixmap to use for background or border of \fItkwin\fR. WARNING:
-cannot necessarily be deleted immediately, as for Xlib calls. See
-note below.
-.AP Colormap colormap in
-New colormap to use for \fItkwin\fR.
-.AP Tk_Cursor cursor in
-New cursor to use for \fItkwin\fR. If \fBNone\fR is specified, then
-\fItkwin\fR will not have its own cursor; it will use the cursor
-of its parent.
-.BE
-
-.SH DESCRIPTION
-.PP
-These procedures are analogous to the X library procedures
-with similar names, such as \fBXConfigureWindow\fR. Each
-one of the above procedures calls the corresponding X procedure
-and also saves the configuration information in Tk's local
-structure for the window. This allows the information to
-be retrieved quickly by the application (using macros such
-as \fBTk_X\fR and \fBTk_Height\fR) without having to contact
-the X server. In addition, if no X window has actually been
-created for \fItkwin\fR yet, these procedures do not issue
-X operations or cause event handlers to be invoked; they save
-the information in Tk's local
-structure for the window; when the window is created later,
-the saved information will be used to configure the window.
-.PP
-See the X library documentation for details on what these
-procedures do and how they use their arguments.
-.PP
-In the procedures \fBTk_ConfigureWindow\fR, \fBTk_MoveWindow\fR,
-\fBTk_ResizeWindow\fR, \fBTk_MoveResizeWindow\fR, and
-\fBTk_SetWindowBorderWidth\fR,
-if \fItkwin\fR is an internal window then event handlers interested
-in configure events are invoked immediately, before the procedure
-returns. If \fItkwin\fR is a top-level window
-then the event handlers will be invoked later, after X has seen
-the request and returned an event for it.
-.PP
-Applications using Tk should never call procedures like
-\fBXConfigureWindow\fR directly; they should always use the
-corresponding Tk procedures.
-.PP
-The size and location of a window should only be modified by the
-appropriate geometry manager for that window and never by a window
-itself (but see \fBTk_MoveToplevelWindow\fR for moving a top-level
-window).
-.PP
-You may not use \fBTk_ConfigureWindow\fR to change the
-stacking order of a window (\fIvalueMask\fR may not contain the
-\fBCWSibling\fR or \fBCWStackMode\fR bits).
-To change the stacking order, use the procedure \fBTk_RestackWindow\fR.
-.PP
-The procedure \fBTk_SetWindowColormap\fR will automatically add
-\fItkwin\fR to the \fBTK_COLORMAP_WINDOWS\fR property of its
-nearest top-level ancestor if the new colormap is different from
-that of \fItkwin\fR's parent and \fItkwin\fR isn't already in
-the \fBTK_COLORMAP_WINDOWS\fR property.
-
-.SH BUGS
-.PP
-\fBTk_SetWindowBackgroundPixmap\fR and \fBTk_SetWindowBorderPixmap\fR
-differ slightly from their Xlib counterparts in that the \fIpixmap\fR
-argument may not necessarily be deleted immediately after calling
-one of these procedures. This is because \fItkwin\fR's window
-may not exist yet at the time of the call, in which case \fIpixmap\fR
-is merely saved and used later when \fItkwin\fR's window is actually
-created. If you wish to delete \fIpixmap\fR, then call
-\fBTk_MakeWindowExist\fR first to be sure that \fItkwin\fR's window exists
-and \fIpixmap\fR has been passed to the X server.
-.PP
-A similar problem occurs for the \fIcursor\fR argument passed to
-\fBTk_DefineCursor\fR. The solution is the same as for pixmaps above:
-call \fBTk_MakeWindowExist\fR before freeing the cursor.
-
-.SH "SEE ALSO"
-Tk_MoveToplevelWindow, Tk_RestackWindow
-
-.SH KEYWORDS
-attributes, border, color, configure, height, pixel, pixmap, width, window, x, y
diff --git a/doc/CoordToWin.3 b/doc/CoordToWin.3
deleted file mode 100644
index 93f81ee..0000000
--- a/doc/CoordToWin.3
+++ /dev/null
@@ -1,51 +0,0 @@
-'\"
-'\" Copyright (c) 1990-1993 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: CoordToWin.3,v 1.2 1998/09/14 18:22:46 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_CoordsToWindow 3 "" Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_CoordsToWindow \- Find window containing a point
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-Tk_Window
-\fBTk_CoordsToWindow\fR(\fIrootX, rootY, tkwin\fR)
-.SH ARGUMENTS
-.AS Tk_Window tkwin
-.AP int rootX in
-X-coordinate (in root window coordinates).
-.AP int rootY in
-Y-coordinate (in root window coordinates).
-.AP Tk_Window tkwin in
-Token for window that identifies application.
-.BE
-
-.SH DESCRIPTION
-.PP
-\fBTk_CoordsToWindow\fR locates the window that contains a given point.
-The point is specified in root coordinates with \fIrootX\fR and
-\fIrootY\fR (if a virtual-root window manager is in use then
-\fIrootX\fR and \fIrootY\fR are in the coordinate system of the
-virtual root window).
-The return value from the procedure is a token for the window that
-contains the given point.
-If the point is not in any window, or if the containing window
-is not in the same application as \fItkwin\fR, then NULL is
-returned.
-.PP
-The containing window is decided using the same rules that determine
-which window contains the mouse cursor: if a parent and a child both
-contain the point then the child gets preference, and if two siblings
-both contain the point then the highest one in the stacking order
-(i.e. the one that's visible on the screen) gets preference.
-
-.SH KEYWORDS
-containing, coordinates, root window
diff --git a/doc/CrtErrHdlr.3 b/doc/CrtErrHdlr.3
deleted file mode 100644
index bde4f14..0000000
--- a/doc/CrtErrHdlr.3
+++ /dev/null
@@ -1,145 +0,0 @@
-'\"
-'\" Copyright (c) 1990 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: CrtErrHdlr.3,v 1.2 1998/09/14 18:22:46 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_CreateErrorHandler 3 "" Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_CreateErrorHandler, Tk_DeleteErrorHandler \- handle X protocol errors
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-Tk_ErrorHandler
-\fBTk_CreateErrorHandler\fR(\fIdisplay, error, request, minor, proc, clientData\fR)
-.sp
-\fBTk_DeleteErrorHandler\fR(\fIhandler\fR)
-.SH ARGUMENTS
-.AS "Tk_ErrorHandler" clientData
-.AP Display *display in
-Display whose errors are to be handled.
-.AP int error in
-Match only error events with this value in the \fIerror_code\fR
-field. If -1, then match any \fIerror_code\fR value.
-.AP int request in
-Match only error events with this value in the \fIrequest_code\fR
-field. If -1, then match any \fIrequest_code\fR value.
-.AP int minor in
-Match only error events with this value in the \fIminor_code\fR
-field. If -1, then match any \fIminor_code\fR value.
-.AP Tk_ErrorProc *proc in
-Procedure to invoke whenever an error event is received for
-\fIdisplay\fR and matches \fIerror\fR, \fIrequest\fR, and \fIminor\fR.
-NULL means ignore any matching errors.
-.AP ClientData clientData in
-Arbitrary one-word value to pass to \fIproc\fR.
-.AP Tk_ErrorHandler handler in
-Token for error handler to delete (return value from a previous
-call to \fBTk_CreateErrorHandler\fR).
-.BE
-
-.SH DESCRIPTION
-.PP
-\fBTk_CreateErrorHandler\fR arranges for a particular procedure
-(\fIproc\fR) to be called whenever certain protocol errors occur on a
-particular display (\fIdisplay\fR). Protocol errors occur when
-the X protocol is used incorrectly, such as attempting to map a window
-that doesn't exist. See the Xlib documentation for \fBXSetErrorHandler\fR
-for more information on the kinds of errors that can occur.
-For \fIproc\fR to be invoked
-to handle a particular error, five things must occur:
-.IP [1]
-The error must pertain to \fIdisplay\fR.
-.IP [2]
-Either the \fIerror\fR argument to \fBTk_CreateErrorHandler\fR
-must have been -1, or the \fIerror\fR argument must match
-the \fIerror_code\fR field from the error event.
-.IP [3]
-Either the \fIrequest\fR argument to \fBTk_CreateErrorHandler\fR
-must have been -1, or the \fIrequest\fR argument must match
-the \fIrequest_code\fR field from the error event.
-.IP [4]
-Either the \fIminor\fR argument to \fBTk_CreateErrorHandler\fR
-must have been -1, or the \fIminor\fR argument must match
-the \fIminor_code\fR field from the error event.
-.IP [5]
-The protocol request to which the error pertains must have been
-made when the handler was active (see below for more information).
-.PP
-\fIProc\fR should have arguments and result that match the
-following type:
-.CS
-typedef int Tk_ErrorProc(
- ClientData \fIclientData\fR,
- XErrorEvent *\fIerrEventPtr\fR);
-.CE
-The \fIclientData\fR parameter to \fIproc\fR is a copy of the \fIclientData\fR
-argument given to \fBTcl_CreateErrorHandler\fR when the callback
-was created. Typically, \fIclientData\fR points to a data
-structure containing application-specific information that is
-needed to deal with the error. \fIErrEventPtr\fR is
-a pointer to the X error event.
-The procedure \fIproc\fR should return an integer value. If it
-returns 0 it means that \fIproc\fR handled the error completely and there
-is no need to take any other action for the error. If it returns
-non-zero it means \fIproc\fR was unable to handle the error.
-.PP
-If a value of NULL is specified for \fIproc\fR, all matching errors
-will be ignored: this will produce the same result as if a procedure
-had been specified that always returns 0.
-.PP
-If more than more than one handler matches a particular error, then
-they are invoked in turn. The handlers will be invoked in reverse
-order of creation: most recently declared handler first.
-If any handler returns 0, then subsequent (older) handlers will
-not be invoked. If no handler returns 0, then Tk invokes X'es
-default error handler, which prints an error message and aborts the
-program. If you wish to have a default handler that deals with errors
-that no other handler can deal with, then declare it first.
-.PP
-The X documentation states that ``the error handler should not call
-any functions (directly or indirectly) on the display that will
-generate protocol requests or that will look for input events.''
-This restriction applies to handlers declared by \fBTk_CreateErrorHandler\fR;
-disobey it at your own risk.
-.PP
-\fBTk_DeleteErrorHandler\fR may be called to delete a
-previously-created error handler. The \fIhandler\fR argument
-identifies the error handler, and should be a value returned by
-a previous call to \fBTk_CreateEventHandler\fR.
-.PP
-A particular error handler applies to errors resulting
-from protocol requests generated between
-the call to \fBTk_CreateErrorHandler\fR and the call to
-\fBTk_DeleteErrorHandler\fR. However, the actual callback
-to \fIproc\fR may not occur until after the \fBTk_DeleteErrorHandler\fR
-call, due to buffering in the client and server.
-If an error event pertains to
-a protocol request made just before calling \fBTk_DeleteErrorHandler\fR,
-then the error event may not have been processed
-before the \fBTk_DeleteErrorHandler\fR
-call. When this situation arises, Tk will save information about
-the handler and
-invoke the handler's \fIproc\fR later when the error event
-finally arrives.
-If an application wishes to delete an error handler and know
-for certain that all relevant errors have been processed,
-it should first call \fBTk_DeleteErrorHandler\fR and then
-call \fBXSync\fR; this will flush out any buffered requests and errors,
-but will result in a performance penalty because
-it requires communication to and from the X server. After the
-\fBXSync\fR call Tk is guaranteed not to call any error
-handlers deleted before the \fBXSync\fR call.
-.PP
-For the Tk error handling mechanism to work properly, it is essential
-that application code never calls \fBXSetErrorHandler\fR directly;
-applications should use only \fBTk_CreateErrorHandler\fR.
-
-.SH KEYWORDS
-callback, error, event, handler
diff --git a/doc/CrtGenHdlr.3 b/doc/CrtGenHdlr.3
deleted file mode 100644
index be761b6..0000000
--- a/doc/CrtGenHdlr.3
+++ /dev/null
@@ -1,84 +0,0 @@
-'\"
-'\" 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.
-'\"
-'\" RCS: @(#) $Id: CrtGenHdlr.3,v 1.2 1998/09/14 18:22:46 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_CreateGenericHandler 3 "" Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_CreateGenericHandler, Tk_DeleteGenericHandler \- associate procedure callback with all X events
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-\fBTk_CreateGenericHandler\fR(\fIproc, clientData\fR)
-.sp
-\fBTk_DeleteGenericHandler\fR(\fIproc, clientData\fR)
-.SH ARGUMENTS
-.AS "Tk_GenericProc" clientData
-.AP Tk_GenericProc *proc in
-Procedure to invoke whenever any X event occurs on any display.
-.AP ClientData clientData in
-Arbitrary one-word value to pass to \fIproc\fR.
-.BE
-
-.SH DESCRIPTION
-.PP
-\fBTk_CreateGenericHandler\fR arranges for \fIproc\fR to be
-invoked in the future whenever any X event occurs. This mechanism is
-\fInot\fR intended for dispatching X events on windows managed by Tk
-(you should use \fBTk_CreateEventHandler\fR for this purpose).
-\fBTk_CreateGenericHandler\fR is intended for other purposes, such
-as tracing X events, monitoring events on windows not owned by Tk,
-accessing X-related libraries that were not originally designed for
-use with Tk, and so on.
-.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_GenericProc\fR:
-.CS
-typedef int Tk_GenericProc(
- ClientData \fIclientData\fR,
- XEvent *\fIeventPtr\fR);
-.CE
-The \fIclientData\fR parameter to \fIproc\fR is a copy of the \fIclientData\fR
-argument given to \fBTk_CreateGenericHandler\fR when the callback
-was created. Typically, \fIclientData\fR points to a data
-structure containing application-specific information about
-how to handle events.
-\fIEventPtr\fR is a pointer to the X event.
-.PP
-Whenever an X event is processed by \fBTk_HandleEvent\fR, \fIproc\fR
-is called. 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 generic event handlers, each one is called
-for each event, in the order in which they were established.
-.PP
-\fBTk_DeleteGenericHandler\fR may be called to delete a
-previously-created generic event handler: it deletes each handler
-it finds that matches the \fIproc\fR and \fIclientData\fR arguments. If
-no such handler exists, then \fBTk_DeleteGenericHandler\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 and \fIclientData\fR arguments.
-.PP
-Establishing a generic event handler does nothing to ensure that the
-process will actually receive the X events that the handler wants to
-process.
-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/doc/CrtImgType.3 b/doc/CrtImgType.3
deleted file mode 100644
index e705f95..0000000
--- a/doc/CrtImgType.3
+++ /dev/null
@@ -1,255 +0,0 @@
-'\"
-'\" Copyright (c) 1994 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: CrtImgType.3,v 1.2 1998/09/14 18:22:46 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_CreateImageType 3 8.0 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_CreateImageType, Tk_GetImageMasterData \- define new kind of image
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-\fBTk_CreateImageType\fR(\fItypePtr\fR)
-ClientData
-.sp
-.VS
-\fBTk_GetImageMasterData\fR(\fIinterp, name, typePtrPtr\fR)
-.SH ARGUMENTS
-.AS Tk_ImageType *typePtrPtr
-.AP Tk_ImageType *typePtr in
-Structure that defines the new type of image.
-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
-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.
-.VE
-.BE
-
-.SH DESCRIPTION
-.PP
-\fBTk_CreateImageType\fR is invoked to define a new kind of image.
-An image type corresponds to a particular value of the \fItype\fR
-argument for the \fBimage create\fR command. There may exist
-any number of different image types, and new types may be defined
-dynamically by calling \fBTk_CreateImageType\fR.
-For example, there might be one type for 2-color bitmaps,
-another for multi-color images, another for dithered images,
-another for video, and so on.
-.PP
-The code that implements a new image type is called an
-\fIimage manager\fR.
-It consists of a collection of procedures plus three different
-kinds of data structures.
-The first data structure is a Tk_ImageType structure, which contains
-the name of the image type and pointers to five procedures provided
-by the image manager to deal with images of this type:
-.CS
-typedef struct Tk_ImageType {
- char *\fIname\fR;
- Tk_ImageCreateProc *\fIcreateProc\fR;
- Tk_ImageGetProc *\fIgetProc\fR;
- Tk_ImageDisplayProc *\fIdisplayProc\fR;
- Tk_ImageFreeProc *\fIfreeProc\fR;
- Tk_ImageDeleteProc *\fIdeleteProc\fR;
-} Tk_ImageType;
-.CE
-The fields of this structure will be described in later subsections
-of this entry.
-.PP
-The second major data structure manipulated by an image manager
-is called an \fIimage master\fR; it contains overall information
-about a particular image, such as the values of the configuration
-options specified in an \fBimage create\fR command.
-There will usually be one of these structures for each
-invocation of the \fBimage create\fR command.
-.PP
-The third data structure related to images is an \fIimage instance\fR.
-There will usually be one of these structures for each usage of an
-image in a particular widget.
-It is possible for a single image to appear simultaneously
-in multiple widgets, or even multiple times in the same widget.
-Furthermore, different instances may be on different screens
-or displays.
-The image instance data structure describes things that may
-vary from instance to instance, such as colors and graphics
-contexts for redisplay.
-There is usually one instance structure for each \fB\-image\fR
-option specified for a widget or canvas item.
-.PP
-The following subsections describe the fields of a Tk_ImageType
-in more detail.
-
-.SH NAME
-.PP
-\fItypePtr->name\fR provides a name for the image type.
-Once \fBTk_CreateImageType\fR returns, this name may be used
-in \fBimage create\fR commands to create images of the new
-type.
-If there already existed an image type by this name then
-the new image type replaces the old one.
-
-.SH CREATEPROC
-\fItypePtr->createProc\fR provides the address of a procedure for
-Tk to call whenever \fBimage create\fR is invoked to create
-an image of the new type.
-\fItypePtr->createProc\fR must match the following prototype:
-.CS
-typedef int Tk_ImageCreateProc(
- Tcl_Interp *\fIinterp\fR,
- char *\fIname\fR,
- int \fIargc\fR,
- char **\fIargv\fR,
- Tk_ImageType *\fItypePtr\fR,
- Tk_ImageMaster \fImaster\fR,
- ClientData *\fImasterDataPtr\fR);
-.CE
-The \fIinterp\fR argument is the interpreter in which the \fBimage\fR
-command was invoked, and \fIname\fR is the name for the new image,
-which was either specified explicitly in the \fBimage\fR command
-or generated automatically by the \fBimage\fR command.
-The \fIargc\fR and \fIargv\fR arguments describe all the configuration
-options for the new image (everything after the name argument to
-\fBimage\fR).
-The \fImaster\fR argument is a token that refers to Tk's information
-about this image; the image manager must return this token to
-Tk when invoking the \fBTk_ImageChanged\fR procedure.
-Typically \fIcreateProc\fR will parse \fIargc\fR and \fIargv\fR
-and create an image master data structure for the new image.
-\fIcreateProc\fR may store an arbitrary one-word value at
-*\fImasterDataPtr\fR, which will be passed back to the
-image manager when other callbacks are invoked.
-Typically the value is a pointer to the master data
-structure for the image.
-.PP
-If \fIcreateProc\fR encounters an error, it should leave an error
-message in \fIinterp->result\fR and return \fBTCL_ERROR\fR; otherwise
-it should return \fBTCL_OK\fR.
-.PP
-\fIcreateProc\fR should call \fBTk_ImageChanged\fR in order to set the
-size of the image and request an initial redisplay.
-
-.SH GETPROC
-.PP
-\fItypePtr->getProc\fR is invoked by Tk whenever a widget
-calls \fBTk_GetImage\fR to use a particular image.
-This procedure must match the following prototype:
-.CS
-typedef ClientData Tk_ImageGetProc(
- Tk_Window \fItkwin\fR,
- ClientData \fImasterData\fR);
-.CE
-The \fItkwin\fR argument identifies the window in which the
-image will be used and \fImasterData\fR is the value
-returned by \fIcreateProc\fR when the image master was created.
-\fIgetProc\fR will usually create a data structure for the new
-instance, including such things as the resources needed to
-display the image in the given window.
-\fIgetProc\fR returns a one-word token for the instance, which
-is typically the address of the instance data structure.
-Tk will pass this value back to the image manager when invoking
-its \fIdisplayProc\fR and \fIfreeProc\fR procedures.
-
-.SH DISPLAYPROC
-.PP
-\fItypePtr->displayProc\fR is invoked by Tk whenever an image needs
-to be displayed (i.e., whenever a widget calls \fBTk_RedrawImage\fR).
-\fIdisplayProc\fR must match the following prototype:
-.CS
-typedef void Tk_ImageDisplayProc(
- ClientData \fIinstanceData\fR,
- Display *\fIdisplay\fR,
- Drawable \fIdrawable\fR,
- int \fIimageX\fR,
- int \fIimageY\fR,
- int \fIwidth\fR,
- int \fIheight\fR,
- int \fIdrawableX\fR,
- int \fIdrawableY\fR);
-.CE
-The \fIinstanceData\fR will be the same as the value returned by
-\fIgetProc\fR when the instance was created.
-\fIdisplay\fR and \fIdrawable\fR indicate where to display the
-image; \fIdrawable\fR may be a pixmap rather than
-the window specified to \fIgetProc\fR (this is usually the case,
-since most widgets double-buffer their redisplay to get smoother
-visual effects).
-\fIimageX\fR, \fIimageY\fR, \fIwidth\fR, and \fIheight\fR
-identify the region of the image that must be redisplayed.
-This region will always be within the size of the image
-as specified in the most recent call to \fBTk_ImageChanged\fR.
-\fIdrawableX\fR and \fIdrawableY\fR indicate where in \fIdrawable\fR
-the image should be displayed; \fIdisplayProc\fR should display
-the given region of the image so that point (\fIimageX\fR, \fIimageY\fR)
-in the image appears at (\fIdrawableX\fR, \fIdrawableY\fR) in \fIdrawable\fR.
-
-.SH FREEPROC
-.PP
-\fItypePtr->freeProc\fR contains the address of a procedure that
-Tk will invoke when an image instance is released (i.e., when
-\fBTk_FreeImage\fR is invoked).
-This can happen, for example, when a widget is deleted or a image item
-in a canvas is deleted, or when the image displayed in a widget or
-canvas item is changed.
-\fIfreeProc\fR must match the following prototype:
-.CS
-typedef void Tk_ImageFreeProc(
- ClientData \fIinstanceData\fR,
- Display *\fIdisplay\fR);
-.CE
-The \fIinstanceData\fR will be the same as the value returned by
-\fIgetProc\fR when the instance was created, and \fIdisplay\fR
-is the display containing the window for the instance.
-\fIfreeProc\fR should release any resources associated with the
-image instance, since the instance will never be used again.
-
-.SH DELETEPROC
-.PP
-\fItypePtr->deleteProc\fR is a procedure that Tk invokes when an
-image is being deleted (i.e. when the \fBimage delete\fR command
-is invoked).
-Before invoking \fIdeleteProc\fR Tk will invoke \fIfreeProc\fR for
-each of the image's instances.
-\fIdeleteProc\fR must match the following prototype:
-.CS
-typedef void Tk_ImageDeleteProc(
- ClientData \fImasterData\fR);
-.CE
-The \fImasterData\fR argument will be the same as the value
-stored in \fI*masterDataPtr\fR by \fIcreateProc\fR when the
-image was created.
-\fIdeleteProc\fR should release any resources associated with
-the image.
-
-.SH TK_GETIMAGEMASTERDATA
-.VS
-.PP
-The procedure \fBTk_GetImageMasterData\fR may be invoked to retrieve
-information about an image. For example, an image manager can use this
-procedure to locate its image master data for an image.
-If there exists an image named \fIname\fR
-in the interpreter given by \fIinterp\fR, then \fI*typePtrPtr\fR is
-filled in with type information for the image (the \fItypePtr\fR value
-passed to \fBTk_CreateImageType\fR when the image type was registered)
-and the return value is the ClientData value returned by the
-\fIcreateProc\fR when the image was created (this is typically a
-pointer to the image master data structure). If no such image exists
-then NULL is returned and NULL is stored at \fI*typePtrPtr\fR.
-.VE
-
-.SH "SEE ALSO"
-Tk_ImageChanged, Tk_GetImage, Tk_FreeImage, Tk_RedrawImage, Tk_SizeOfImage
-
-.SH KEYWORDS
-image manager, image type, instance, master
diff --git a/doc/CrtItemType.3 b/doc/CrtItemType.3
deleted file mode 100644
index 3c11ceb..0000000
--- a/doc/CrtItemType.3
+++ /dev/null
@@ -1,626 +0,0 @@
-'\"
-'\" Copyright (c) 1994-1995 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: CrtItemType.3,v 1.2 1998/09/14 18:22:47 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_CreateItemType 3 4.0 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_CreateItemType, Tk_GetItemTypes \- define new kind of canvas item
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-\fBTk_CreateItemType\fR(\fItypePtr\fR)
-.sp
-Tk_ItemType *
-\fBTk_GetItemTypes\fR()
-.SH ARGUMENTS
-.AS Tk_ItemType *typePtr
-.AP Tk_ItemType *typePtr in
-Structure that defines the new type of canvas item.
-.BE
-
-.SH INTRODUCTION
-.PP
-\fBTk_CreateItemType\fR is invoked to define a new kind of canvas item
-described by the \fItypePtr\fR argument.
-An item type corresponds to a particular value of the \fItype\fR
-argument to the \fBcreate\fR widget command for canvases, and
-the code that implements a canvas item type is called a \fItype manager\fR.
-Tk defines several built-in item types, such as \fBrectangle\fR
-and \fBtext\fR and \fBimage\fR, but \fBTk_CreateItemType\fR
-allows additional item types to be defined.
-Once \fBTk_CreateItemType\fR returns, the new item type may be used
-in new or existing canvas widgets just like the built-in item
-types.
-.PP
-\fBTk_GetItemTypes\fR returns a pointer to the first in the list
-of all item types currently defined for canvases.
-The entries in the list are linked together through their
-\fInextPtr\fR fields, with the end of the list marked by a
-NULL \fInextPtr\fR.
-.PP
-You may find it easier to understand the rest of this manual entry
-by looking at the code for an existing canvas item type such as
-bitmap (file tkCanvBmap.c) or text (tkCanvText.c).
-The easiest way to create a new type manager is to copy the code
-for an existing type and modify it for the new type.
-.PP
-Tk provides a number of utility procedures for the use of canvas
-type managers, such as \fBTk_CanvasCoords\fR and \fBTk_CanvasPsColor\fR;
-these are described in separate manual entries.
-
-.SH "DATA STRUCTURES"
-.PP
-A type manager consists of a collection of procedures that provide a
-standard set of operations on items of that type.
-The type manager deals with three kinds of data
-structures.
-The first data structure is a Tk_ItemType; it contains
-information such as the name of the type and pointers to
-the standard procedures implemented by the type manager:
-.CS
-typedef struct Tk_ItemType {
- char *\fIname\fR;
- int \fIitemSize\fR;
- Tk_ItemCreateProc *\fIcreateProc\fR;
- Tk_ConfigSpec *\fIconfigSpecs\fR;
- Tk_ItemConfigureProc *\fIconfigProc\fR;
- Tk_ItemCoordProc *\fIcoordProc\fR;
- Tk_ItemDeleteProc *\fIdeleteProc\fR;
- Tk_ItemDisplayProc *\fIdisplayProc\fR;
- int \fIalwaysRedraw\fR;
- Tk_ItemPointProc *\fIpointProc\fR;
- Tk_ItemAreaProc *\fIareaProc\fR;
- Tk_ItemPostscriptProc *\fIpostscriptProc\fR;
- Tk_ItemScaleProc *\fIscaleProc\fR;
- Tk_ItemTranslateProc *\fItranslateProc\fR;
- Tk_ItemIndexProc *\fIindexProc\fR;
- Tk_ItemCursorProc *\fIicursorProc\fR;
- Tk_ItemSelectionProc *\fIselectionProc\fR;
- Tk_ItemInsertProc *\fIinsertProc\fR;
- Tk_ItemDCharsProc *\fIdCharsProc\fR;
- Tk_ItemType *\fInextPtr\fR;
-} Tk_ItemType;
-.CE
-.PP
-The fields of a Tk_ItemType structure are described in more detail
-later in this manual entry.
-When \fBTk_CreateItemType\fR is called, its \fItypePtr\fR
-argument must point to a structure with all of the fields initialized
-except \fInextPtr\fR, which Tk sets to link all the types together
-into a list.
-The structure must be in permanent memory (either statically
-allocated or dynamically allocated but never freed); Tk retains
-a pointer to this structure.
-.PP
-The second data structure manipulated by a type manager is an
-\fIitem record\fR.
-For each item in a canvas there exists one item record.
-All of the items of a given type generally have item records with
-the same structure, but different types usually have different
-formats for their item records.
-The first part of each item record is a header with a standard structure
-defined by Tk via the type Tk_Item; the rest of the item
-record is defined by the type manager.
-A type manager must define its item records with a Tk_Item as
-the first field.
-For example, the item record for bitmap items is defined as follows:
-.CS
-typedef struct BitmapItem {
- Tk_Item \fIheader\fR;
- double \fIx\fR, \fIy\fR;
- Tk_Anchor \fIanchor\fR;
- Pixmap \fIbitmap\fR;
- XColor *\fIfgColor\fR;
- XColor *\fIbgColor\fR;
- GC \fIgc\fR;
-} BitmapItem;
-.CE
-The \fIheader\fR substructure contains information used by Tk
-to manage the item, such as its identifier, its tags, its type,
-and its bounding box.
-The fields starting with \fIx\fR belong to the type manager:
-Tk will never read or write them.
-The type manager should not need to read or write any of the
-fields in the header except for four fields
-whose names are \fIx1\fR, \fIy1\fR, \fIx2\fR, and \fIy2\fR.
-These fields give a bounding box for the items using integer
-canvas coordinates: the item should not cover any pixels
-with x-coordinate lower than \fIx1\fR or y-coordinate
-lower than \fIy1\fR, nor should it cover any pixels with
-x-coordinate greater than or equal to \fIx2\fR or y-coordinate
-greater than or equal to \fIy2\fR.
-It is up to the type manager to keep the bounding box up to
-date as the item is moved and reconfigured.
-.PP
-Whenever Tk calls a procedure in a type manager it passes in a pointer
-to an item record.
-The argument is always passed as a pointer to a Tk_Item; the type
-manager will typically cast this into a pointer to its own specific
-type, such as BitmapItem.
-.PP
-The third data structure used by type managers has type
-Tk_Canvas; it serves as an opaque handle for the canvas widget
-as a whole.
-Type managers need not know anything about the contents of this
-structure.
-A Tk_Canvas handle is typically passed in to the
-procedures of a type manager, and the type manager can pass the
-handle back to library procedures such as Tk_CanvasTkwin
-to fetch information about the canvas.
-
-.SH NAME
-.PP
-This section and the ones that follow describe each of the fields
-in a Tk_ItemType structure in detail.
-The \fIname\fR field provides a string name for the item type.
-Once \fBTk_CreateImageType\fR returns, this name may be used
-in \fBcreate\fR widget commands to create items of the new
-type.
-If there already existed an item type by this name then
-the new item type replaces the old one.
-
-.SH ITEMSIZE
-\fItypePtr->itemSize\fR gives the size in bytes of item records
-of this type, including the Tk_Item header.
-Tk uses this size to allocate memory space for items of the type.
-All of the item records for a given type must have the same size.
-If variable length fields are needed for an item (such as a list
-of points for a polygon), the type manager can allocate a separate
-object of variable length and keep a pointer to it in the item record.
-
-.SH CREATEPROC
-.PP
-\fItypePtr->createProc\fR points to a procedure for
-Tk to call whenever a new item of this type is created.
-\fItypePtr->createProc\fR must match the following prototype:
-.CS
-typedef int Tk_ItemCreateProc(
- Tcl_Interp *\fIinterp\fR,
- Tk_Canvas \fIcanvas\fR,
- Tk_Item *\fIitemPtr\fR,
- int \fIargc\fR,
- char **\fIargv\fR);
-.CE
-The \fIinterp\fR argument is the interpreter in which the canvas's
-\fBcreate\fR widget command was invoked, and \fIcanvas\fR is a
-handle for the canvas widget.
-\fIitemPtr\fR is a pointer to a newly-allocated item of
-size \fItypePtr->itemSize\fR.
-Tk has already initialized the item's header (the first
-\fBsizeof(Tk_ItemType)\fR bytes).
-The \fIargc\fR and \fIargv\fR arguments describe all of the
-arguments to the \fBcreate\fR command after the \fItype\fR
-argument.
-For example, in the widget command
-.CS
-\fB\&.c create rectangle 10 20 50 50 \-fill black\fR
-.CE
-\fIargc\fR will be \fB6\fR and \fIargv\fR[0] will contain the
-string \fB10\fR.
-.PP
-\fIcreateProc\fR should use \fIargc\fR and \fIargv\fR to initialize
-the type-specific parts of the item record and set an initial value
-for the bounding box in the item's header.
-It should return a standard Tcl completion code and leave an
-error message in \fIinterp->result\fR if an error occurs.
-If an error occurs Tk will free the item record, so \fIcreateProc\fR
-must be sure to leave the item record in a clean state if it returns an error
-(e.g., it must free any additional memory that it allocated for
-the item).
-
-.SH CONFIGSPECS
-.PP
-Each type manager must provide a standard table describing its
-configuration options, in a form suitable for use with
-\fBTk_ConfigureWidget\fR.
-This table will normally be used by \fItypePtr->createProc\fR
-and \fItypePtr->configProc\fR, but Tk also uses it directly
-to retrieve option information in the \fBitemcget\fR and
-\fBitemconfigure\fR widget commands.
-\fItypePtr->configSpecs\fR must point to the configuration table
-for this type.
-Note: Tk provides a custom option type \fBtk_CanvasTagsOption\fR
-for implementing the \fB\-tags\fR option; see an existing type
-manager for an example of how to use it in \fIconfigSpecs\fR.
-
-.SH CONFIGPROC
-.PP
-\fItypePtr->configProc\fR is called by Tk whenever the
-\fBitemconfigure\fR widget command is invoked to change the
-configuration options for a canvas item.
-This procedure must match the following prototype:
-.CS
-typedef int Tk_ItemConfigureProc(
- Tcl_Interp *\fIinterp\fR,
- Tk_Canvas \fIcanvas\fR,
- Tk_Item *\fIitemPtr\fR,
- int \fIargc\fR,
- char **\fIargv\fR,
- int \fIflags\fR);
-.CE
-The \fIinterp\fR argument identifies the interpreter in which the
-widget command was invoked, \fIcanvas\fR is a handle for the canvas
-widget, and \fIitemPtr\fR is a pointer to the item being configured.
-\fIargc\fR and \fIargv\fR contain the configuration options. For
-example, if the following command is invoked:
-.CS
-\fB\&.c itemconfigure 2 \-fill red \-outline black\fR
-.CE
-\fIargc\fR is \fB4\fR and \fIargv\fR contains the strings \fB\-fill\fR
-through \fBblack\fR.
-\fIargc\fR will always be an even value.
-The \fIflags\fR argument contains flags to pass to \fBTk_ConfigureWidget\fR;
-currently this value is always TK_CONFIG_ARGV_ONLY when Tk
-invokes \fItypePtr->configProc\fR, but the type manager's \fIcreateProc\fR
-procedure will usually invoke \fIconfigProc\fR with different flag values.
-.PP
-\fItypePtr->configProc\fR returns a standard Tcl completion code and
-leaves an error message in \fIinterp->result\fR if an error occurs.
-It must update the item's bounding box to reflect the new configuration
-options.
-
-.SH COORDPROC
-.PP
-\fItypePtr->coordProc\fR is invoked by Tk to implement the \fBcoords\fR
-widget command for an item.
-It must match the following prototype:
-.CS
-typedef int Tk_ItemCoordProc(
- Tcl_Interp *\fIinterp\fR,
- Tk_Canvas \fIcanvas\fR,
- Tk_Item *\fIitemPtr\fR,
- int \fIargc\fR,
- char **\fIargv\fR);
-.CE
-The arguments \fIinterp\fR, \fIcanvas\fR, and \fIitemPtr\fR
-all have the standard meanings, and \fIargc\fR and \fIargv\fR
-describe the coordinate arguments.
-For example, if the following widget command is invoked:
-.CS
-\fB\&.c coords 2 30 90\fR
-.CE
-\fIargc\fR will be \fB2\fR and \fBargv\fR will contain the string values
-\fB30\fR and \fB90\fR.
-.PP
-The \fIcoordProc\fR procedure should process the new coordinates,
-update the item appropriately (e.g., it must reset the bounding
-box in the item's header), and return a standard Tcl completion
-code.
-If an error occurs, \fIcoordProc\fR must leave an error message in
-\fIinterp->result\fR.
-
-.SH DELETEPROC
-.PP
-\fItypePtr->deleteProc\fR is invoked by Tk to delete an item
-and free any resources allocated to it.
-It must match the following prototype:
-.CS
-typedef void Tk_ItemDeleteProc(
- Tk_Canvas \fIcanvas\fR,
- Tk_Item *\fIitemPtr\fR,
- Display *\fIdisplay\fR);
-.CE
-The \fIcanvas\fR and \fIitemPtr\fR arguments have the usual
-interpretations, and \fIdisplay\fR identifies the X display containing
-the canvas.
-\fIdeleteProc\fR must free up any resources allocated for the item,
-so that Tk can free the item record.
-\fIdeleteProc\fR should not actually free the item record; this will
-be done by Tk when \fIdeleteProc\fR returns.
-
-.SH "DISPLAYPROC AND ALWAYSREDRAW"
-.PP
-\fItypePtr->displayProc\fR is invoked by Tk to redraw an item
-on the screen.
-It must match the following prototype:
-.CS
-typedef void Tk_ItemDisplayProc(
- Tk_Canvas \fIcanvas\fR,
- Tk_Item *\fIitemPtr\fR,
- Display *\fIdisplay\fR,
- Drawable \fIdst\fR,
- int \fIx\fR,
- int \fIy\fR,
- int \fIwidth\fR,
- int \fIheight\fR);
-.CE
-The \fIcanvas\fR and \fIitemPtr\fR arguments have the usual meaning.
-\fIdisplay\fR identifies the display containing the canvas, and
-\fIdst\fR specifies a drawable in which the item should be rendered;
-typically this is an off-screen pixmap, which Tk will copy into
-the canvas's window once all relevant items have been drawn.
-\fIx\fR, \fIy\fR, \fIwidth\fR, and \fIheight\fR specify a rectangular
-region in canvas coordinates, which is the area to be redrawn;
-only information that overlaps this area needs to be redrawn.
-Tk will not call \fIdisplayProc\fR unless the item's bounding box
-overlaps the redraw area, but the type manager may wish to use
-the redraw area to optimize the redisplay of the item.
-.PP
-Because of scrolling and the use of off-screen pixmaps for
-double-buffered redisplay, the item's coordinates in \fIdst\fR
-will not necessarily be the same as those in the canvas.
-\fIdisplayProc\fR should call \fBTk_CanvasDrawableCoords\fR
-to transform coordinates from those of the canvas to those
-of \fIdst\fR.
-.PP
-Normally an item's \fIdisplayProc\fR is only invoked if the item
-overlaps the area being displayed.
-However, if \fItypePtr->alwaysRedraw\fR has a non-zero value, then
-\fIdisplayProc\fR is invoked during every redisplay operation,
-even if the item doesn't overlap the area of redisplay.
-\fIalwaysRedraw\fR should normally be set to 0; it is only
-set to 1 in special cases such as window items that need to be
-unmapped when they are off-screen.
-
-.SH POINTPROC
-.PP
-\fItypePtr->pointProc\fR is invoked by Tk to find out how close
-a given point is to a canvas item.
-Tk uses this procedure for purposes such as locating the item
-under the mouse or finding the closest item to a given point.
-The procedure must match the following prototype:
-.CS
-typedef double Tk_ItemPointProc(
- Tk_Canvas \fIcanvas\fR,
- Tk_Item *\fIitemPtr\fR,
- double *\fIpointPtr\fR);
-.CE
-\fIcanvas\fR and \fIitemPtr\fR have the usual meaning.
-\fIpointPtr\fR points to an array of two numbers giving
-the x and y coordinates of a point.
-\fIpointProc\fR must return a real value giving the distance
-from the point to the item, or 0 if the point lies inside
-the item.
-
-.SH AREAPROC
-.PP
-\fItypePtr->areaProc\fR is invoked by Tk to find out the relationship
-between an item and a rectangular area.
-It must match the following prototype:
-.CS
-typedef int Tk_ItemAreaProc(
- Tk_Canvas \fIcanvas\fR,
- Tk_Item *\fIitemPtr\fR,
- double *\fIrectPtr\fR);
-.CE
-\fIcanvas\fR and \fIitemPtr\fR have the usual meaning.
-\fIrectPtr\fR points to an array of four real numbers;
-the first two give the x and y coordinates of the upper left
-corner of a rectangle, and the second two give the x and y
-coordinates of the lower right corner.
-\fIareaProc\fR must return \-1 if the item lies entirely outside
-the given area, 0 if it lies partially inside and partially
-outside the area, and 1 if it lies entirely inside the area.
-
-.SH POSTSCRIPTPROC
-.PP
-\fItypePtr->postscriptProc\fR is invoked by Tk to generate
-Postcript for an item during the \fBpostscript\fR widget command.
-If the type manager is not capable of generating Postscript then
-\fItypePtr->postscriptProc\fR should be NULL.
-The procedure must match the following prototype:
-.CS
-typedef int Tk_ItemPostscriptProc(
- Tcl_Interp *\fIinterp\fR,
- Tk_Canvas \fIcanvas\fR,
- Tk_Item *\fIitemPtr\fR,
- int \fIprepass\fR);
-.CE
-The \fIinterp\fR, \fIcanvas\fR, and \fIitemPtr\fR arguments all have
-standard meanings; \fIprepass\fR will be described below.
-If \fIpostscriptProc\fR completes successfully, it should append
-Postscript for the item to the information in \fIinterp->result\fR
-(e.g. by calling \fBTcl_AppendResult\fR, not \fBTcl_SetResult\fR)
-and return TCL_OK.
-If an error occurs, \fIpostscriptProc\fR should clear the result
-and replace its contents with an error message; then it should
-return TCL_ERROR.
-.PP
-Tk provides a collection of utility procedures to simplify
-\fIpostscriptProc\fR.
-For example, \fBTk_CanvasPsColor\fR will generate Postscript to set
-the current color to a given Tk color and \fBTk_CanvasPsFont\fR will
-set up font information.
-When generating Postscript, the type manager is free to change the
-graphics state of the Postscript interpreter, since Tk places
-\fBgsave\fR and \fBgrestore\fR commands around the Postscript for
-the item.
-The type manager can use canvas x coordinates directly in its Postscript,
-but it must call \fBTk_CanvasPsY\fR to convert y coordinates from
-the space of the canvas (where the origin is at the
-upper left) to the space of Postscript (where the origin is at the
-lower left).
-.PP
-In order to generate Postscript that complies with the Adobe Document
-Structuring Conventions, Tk actually generates Postscript in two passes.
-It calls each item's \fIpostscriptProc\fR in each pass.
-The only purpose of the first pass is to collect font information
-(which is done by \fBTk_CanvPsFont\fR); the actual Postscript is
-discarded.
-Tk sets the \fIprepass\fR argument to \fIpostscriptProc\fR to 1
-during the first pass; the type manager can use \fIprepass\fR to skip
-all Postscript generation except for calls to \fBTk_CanvasPsFont\fR.
-During the second pass \fIprepass\fR will be 0, so the type manager
-must generate complete Postscript.
-
-.SH SCALEPROC
-\fItypePtr->scaleProc\fR is invoked by Tk to rescale a canvas item
-during the \fBscale\fR widget command.
-The procedure must match the following prototype:
-.CS
-typedef void Tk_ItemScaleProc(
- Tk_Canvas \fIcanvas\fR,
- Tk_Item *\fIitemPtr\fR,
- double \fIoriginX\fR,
- double \fIoriginY\fR,
- double \fIscaleX\fR,
- double \fIscaleY\fR);
-.CE
-The \fIcanvas\fR and \fIitemPtr\fR arguments have the usual meaning.
-\fIoriginX\fR and \fIoriginY\fR specify an origin relative to which
-the item is to be scaled, and \fIscaleX\fR and \fIscaleY\fR give the
-x and y scale factors.
-The item should adjust its coordinates so that a point in the item
-that used to have coordinates \fIx\fR and \fIy\fR will have new
-coordinates \fIx'\fR and \fIy'\fR, where
-.CS
-\fIx' = originX + scaleX*(x-originX)
-y' = originY + scaleY*(y-originY)\fR
-.CE
-\fIscaleProc\fR must also update the bounding box in the item's
-header.
-
-.SH TRANSLATEPROC
-\fItypePtr->translateProc\fR is invoked by Tk to translate a canvas item
-during the \fBmove\fR widget command.
-The procedure must match the following prototype:
-.CS
-typedef void Tk_ItemTranslateProc(
- Tk_Canvas \fIcanvas\fR,
- Tk_Item *\fIitemPtr\fR,
- double \fIdeltaX\fR,
- double \fIdeltaY\fR);
-.CE
-The \fIcanvas\fR and \fIitemPtr\fR arguments have the usual meaning,
-and \fIdeltaX\fR and \fIdeltaY\fR give the amounts that should be
-added to each x and y coordinate within the item.
-The type manager should adjust the item's coordinates and
-update the bounding box in the item's header.
-
-.SH INDEXPROC
-\fItypePtr->indexProc\fR is invoked by Tk to translate a string
-index specification into a numerical index, for example during the
-\fBindex\fR widget command.
-It is only relevant for item types that support indexable text;
-\fItypePtr->indexProc\fR may be specified as NULL for non-textual
-item types.
-The procedure must match the following prototype:
-.CS
-typedef int Tk_ItemIndexProc(
- Tcl_Interp *\fIinterp\fR,
- Tk_Canvas \fIcanvas\fR,
- Tk_Item *\fIitemPtr\fR,
- char \fIindexString\fR,
- int *\fIindexPtr\fR);
-.CE
-The \fIinterp\fR, \fIcanvas\fR, and \fIitemPtr\fR arguments all
-have the usual meaning.
-\fIindexString\fR contains a textual description of an index,
-and \fIindexPtr\fR points to an integer value that should be
-filled in with a numerical index.
-It is up to the type manager to decide what forms of index
-are supported (e.g., numbers, \fBinsert\fR, \fBsel.first\fR,
-\fBend\fR, etc.).
-\fIindexProc\fR should return a Tcl completion code and set
-\fIinterp->result\fR in the event of an error.
-
-.SH ICURSORPROC
-.PP
-\fItypePtr->icursorProc\fR is invoked by Tk during
-the \fBicursor\fR widget command to set the position of the
-insertion cursor in a textual item.
-It is only relevant for item types that support an insertion cursor;
-\fItypePtr->icursorProc\fR may be specified as NULL for item types
-that don't support an insertion cursor.
-The procedure must match the following prototype:
-.CS
-typedef void Tk_ItemIndexProc(
- Tk_Canvas \fIcanvas\fR,
- Tk_Item *\fIitemPtr\fR,
- int \fIindex\fR);
-.CE
-\fIcanvas\fR and \fIitemPtr\fR have the usual meanings, and
-\fIindex\fR is an index into the item's text, as returned by a
-previous call to \fItypePtr->insertProc\fR.
-The type manager should position the insertion cursor in the
-item just before the character given by \fIindex\fR.
-Whether or not to actually display the insertion cursor is
-determined by other information provided by \fBTk_CanvasGetTextInfo\fR.
-
-.SH SELECTIONPROC
-.PP
-\fItypePtr->selectionProc\fR is invoked by Tk during selection
-retrievals; it must return part or all of the selected text in
-the item (if any).
-It is only relevant for item types that support text;
-\fItypePtr->selectionProc\fR may be specified as NULL for non-textual
-item types.
-The procedure must match the following prototype:
-.CS
-typedef int Tk_ItemSelectionProc(
- Tk_Canvas \fIcanvas\fR,
- Tk_Item *\fIitemPtr\fR,
- int \fIoffset\fR,
- char *\fIbuffer\fR,
- int \fImaxBytes\fR);
-.CE
-\fIcanvas\fR and \fIitemPtr\fR have the usual meanings.
-\fIoffset\fR is an offset in bytes into the selection where 0 refers
-to the first byte of the selection; it identifies
-the first character that is to be returned in this call.
-\fIbuffer\fR points to an area of memory in which to store the
-requested bytes, and \fImaxBytes\fR specifies the maximum number
-of bytes to return.
-\fIselectionProc\fR should extract up to \fImaxBytes\fR characters
-from the selection and copy them to \fImaxBytes\fR; it should
-return a count of the number of bytes actually copied, which may
-be less than \fImaxBytes\fR if there aren't \fIoffset+maxBytes\fR bytes
-in the selection.
-
-.SH INSERTPROC
-.PP
-\fItypePtr->insertProc\fR is invoked by Tk during
-the \fBinsert\fR widget command to insert new text into a
-canvas item.
-It is only relevant for item types that support text;
-\fItypePtr->insertProc\fR may be specified as NULL for non-textual
-item types.
-The procedure must match the following prototype:
-.CS
-typedef void Tk_ItemInsertProc(
- Tk_Canvas \fIcanvas\fR,
- Tk_Item *\fIitemPtr\fR,
- int \fIindex\fR,
- char *\fIstring\fR);
-.CE
-\fIcanvas\fR and \fIitemPtr\fR have the usual meanings.
-\fIindex\fR is an index into the item's text, as returned by a
-previous call to \fItypePtr->insertProc\fR, and \fIstring\fR
-contains new text to insert just before the character given
-by \fIindex\fR.
-The type manager should insert the text and recompute the bounding
-box in the item's header.
-
-.SH DCHARSPROC
-.PP
-\fItypePtr->dCharsProc\fR is invoked by Tk during the \fBdchars\fR
-widget command to delete a range of text from a canvas item.
-It is only relevant for item types that support text;
-\fItypePtr->dCharsProc\fR may be specified as NULL for non-textual
-item types.
-The procedure must match the following prototype:
-.CS
-typedef void Tk_ItemDCharsProc(
- Tk_Canvas \fIcanvas\fR,
- Tk_Item *\fIitemPtr\fR,
- int \fIfirst\fR,
- int \fIlast\fR);
-.CE
-\fIcanvas\fR and \fIitemPtr\fR have the usual meanings.
-\fIfirst\fR and \fIlast\fR give the indices of the first and last bytes
-to be deleted, as returned by previous calls to \fItypePtr->indexProc\fR.
-The type manager should delete the specified characters and update
-the bounding box in the item's header.
-
-.SH "SEE ALSO"
-Tk_CanvasPsY, Tk_CanvasTextInfo, Tk_CanvasTkwin
-
-.SH KEYWORDS
-canvas, focus, item type, selection, type manager
diff --git a/doc/CrtPhImgFmt.3 b/doc/CrtPhImgFmt.3
deleted file mode 100644
index 0689387..0000000
--- a/doc/CrtPhImgFmt.3
+++ /dev/null
@@ -1,235 +0,0 @@
-'\"
-'\" Copyright (c) 1994 The Australian National University
-'\" 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.
-'\"
-'\" Author: Paul Mackerras (paulus@cs.anu.edu.au),
-'\" Department of Computer Science,
-'\" Australian National University.
-'\"
-'\" RCS: @(#) $Id: CrtPhImgFmt.3,v 1.2 1998/09/14 18:22:47 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_CreatePhotoImageFormat 3 4.0 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_CreatePhotoImageFormat \- define new file format for photo images
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-\fB#include <tkPhoto.h>\fR
-.sp
-\fBTk_CreatePhotoImageFormat\fR(\fIformatPtr\fR)
-.SH ARGUMENTS
-.AS Tk_PhotoImageFormat *formatPtr
-.AP Tk_PhotoImageFormat *formatPtr in
-Structure that defines the new file format.
-.BE
-
-.SH DESCRIPTION
-.PP
-\fBTk_CreatePhotoImageFormat\fR is invoked to define a new file format
-for image data for use with photo images. The code that implements an
-image file format is called an image file format handler, or
-handler for short. The photo image code
-maintains a list of handlers that can be used to read and
-write data to or from a file. Some handlers may also
-support reading image data from a string or converting image data to a
-string format.
-The user can specify which handler to use with the \fB\-format\fR
-image configuration option or the \fB\-format\fR option to the
-\fBread\fR and \fBwrite\fR photo image subcommands.
-.PP
-An image file format handler consists of a collection of procedures
-plus a Tk_PhotoImageFormat structure, which contains the name of the
-image file format and pointers to six procedures provided by the
-handler to deal with files and strings in this format. The
-Tk_PhotoImageFormat structure contains the following fields:
-.CS
-typedef struct Tk_PhotoImageFormat {
- char *\fIname\fR;
- Tk_ImageFileMatchProc *\fIfileMatchProc\fR;
- Tk_ImageStringMatchProc *\fIstringMatchProc\fR;
- Tk_ImageFileReadProc *\fIfileReadProc\fR;
- Tk_ImageStringReadProc *\fIstringReadProc\fR;
- Tk_ImageFileWriteProc *\fIfileWriteProc\fR;
- Tk_ImageStringWriteProc *\fIstringWriteProc\fR;
-} Tk_PhotoImageFormat;
-.CE
-.PP
-The handler need not provide implementations of all six procedures.
-For example, the procedures that handle string data would not be
-provided for a format in which the image data are stored in binary,
-and could therefore contain null characters. If any procedure is not
-implemented, the corresponding pointer in the Tk_PhotoImageFormat
-structure should be set to NULL. The handler must provide the
-\fIfileMatchProc\fR procedure if it provides the \fIfileReadProc\fR
-procedure, and the \fIstringMatchProc\fR procedure if it provides the
-\fIstringReadProc\fR procedure.
-
-.SH NAME
-.PP
-\fIformatPtr->name\fR provides a name for the image type.
-Once \fBTk_CreatePhotoImageFormat\fR returns, this name may be used
-in the \fB\-format\fR photo image configuration and subcommand option.
-The manual page for the photo image (photo(n)) describes how image
-file formats are chosen based on their names and the value given to
-the \fB\-format\fR option.
-
-.SH FILEMATCHPROC
-\fIformatPtr->fileMatchProc\fR provides the address of a procedure for
-Tk to call when it is searching for an image file format handler
-suitable for reading data in a given file.
-\fIformatPtr->fileMatchProc\fR must match the following prototype:
-.CS
-typedef int Tk_ImageFileMatchProc(
- Tcl_Channel \fIchan\fR,
- char *\fIfileName\fR,
- char *\fIformatString\fR,
- int *\fIwidthPtr\fR,
- int *\fIheightPtr\fR);
-.CE
-The \fIfileName\fR argument is the name of the file containing the
-image data, which is open for reading as \fIchan\fR. The
-\fIformatString\fR argument contains the value given for the
-\fB\-format\fR option, or NULL if the option was not specified.
-If the data in the file appears to be in the format supported by this
-handler, the \fIformatPtr->fileMatchProc\fR procedure should store the
-width and height of the image in *\fIwidthPtr\fR and *\fIheightPtr\fR
-respectively, and return 1. Otherwise it should return 0.
-
-.SH STRINGMATCHPROC
-\fIformatPtr->stringMatchProc\fR provides the address of a procedure for
-Tk to call when it is searching for an image file format handler for
-suitable for reading data from a given string.
-\fIformatPtr->stringMatchProc\fR must match the following prototype:
-.CS
-typedef int Tk_ImageStringMatchProc(
- char *\fIstring\fR,
- char *\fIformatString\fR,
- int *\fIwidthPtr\fR,
- int *\fIheightPtr\fR);
-.CE
-The \fIstring\fR argument points to the string containing the image
-data. The \fIformatString\fR argument contains the value given for
-the \fB\-format\fR option, or NULL if the option was not specified.
-If the data in the string appears to be in the format supported by
-this handler, the \fIformatPtr->stringMatchProc\fR procedure should
-store the width and height of the image in *\fIwidthPtr\fR and
-*\fIheightPtr\fR respectively, and return 1. Otherwise it should
-return 0.
-
-.SH FILEREADPROC
-\fIformatPtr->fileReadProc\fR provides the address of a procedure for
-Tk to call to read data from an image file into a photo image.
-\fIformatPtr->fileReadProc\fR must match the following prototype:
-.CS
-typedef int Tk_ImageFileReadProc(
- Tcl_Interp *\fIinterp\fR,
- Tcl_Channel \fIchan\fR,
- char *\fIfileName\fR,
- char *\fIformatString\fR,
- PhotoHandle \fIimageHandle\fR,
- int \fIdestX\fR, int \fIdestY\fR,
- int \fIwidth\fR, int \fIheight\fR,
- int \fIsrcX\fR, int \fIsrcY\fR);
-.CE
-The \fIinterp\fR argument is the interpreter in which the command was
-invoked to read the image; it should be used for reporting errors.
-The image data is in the file named \fIfileName\fR, which is open for
-reading as \fIchan\fR. The \fIformatString\fR argument contains the
-value given for the \fB\-format\fR option, or NULL if the option was
-not specified. The image data in the file, or a subimage of it, is to
-be read into the photo image identified by the handle
-\fIimageHandle\fR. The subimage of the data in the file is of
-dimensions \fIwidth\fR x \fIheight\fR and has its top-left corner at
-coordinates (\fIsrcX\fR,\fIsrcY\fR). It is to be stored in the photo
-image with its top-left corner at coordinates
-(\fIdestX\fR,\fIdestY\fR) using the \fBTk_PhotoPutBlock\fR procedure.
-The return value is a standard Tcl return value.
-
-.SH STRINGREADPROC
-\fIformatPtr->stringReadProc\fR provides the address of a procedure for
-Tk to call to read data from a string into a photo image.
-\fIformatPtr->stringReadProc\fR must match the following prototype:
-.CS
-typedef int Tk_ImageStringReadProc(
- Tcl_Interp *\fIinterp\fR,
- char *\fIstring\fR,
- char *\fIformatString\fR,
- PhotoHandle \fIimageHandle\fR,
- int \fIdestX\fR, int \fIdestY\fR,
- int \fIwidth\fR, int \fIheight\fR,
- int \fIsrcX\fR, int \fIsrcY\fR);
-.CE
-The \fIinterp\fR argument is the interpreter in which the command was
-invoked to read the image; it should be used for reporting errors.
-The \fIstring\fR argument points to the image data in string form.
-The \fIformatString\fR argument contains the
-value given for the \fB\-format\fR option, or NULL if the option was
-not specified. The image data in the string, or a subimage of it, is to
-be read into the photo image identified by the handle
-\fIimageHandle\fR. The subimage of the data in the string is of
-dimensions \fIwidth\fR x \fIheight\fR and has its top-left corner at
-coordinates (\fIsrcX\fR,\fIsrcY\fR). It is to be stored in the photo
-image with its top-left corner at coordinates
-(\fIdestX\fR,\fIdestY\fR) using the \fBTk_PhotoPutBlock\fR procedure.
-The return value is a standard Tcl return value.
-
-.SH FILEWRITEPROC
-\fIformatPtr->fileWriteProc\fR provides the address of a procedure for
-Tk to call to write data from a photo image to a file.
-\fIformatPtr->fileWriteProc\fR must match the following prototype:
-.CS
-typedef int Tk_ImageFileWriteProc(
- Tcl_Interp *\fIinterp\fR,
- char *\fIfileName\fR,
- char *\fIformatString\fR,
- Tk_PhotoImageBlock *\fIblockPtr\fR);
-.CE
-The \fIinterp\fR argument is the interpreter in which the command was
-invoked to write the image; it should be used for reporting errors.
-The image data to be written are in memory and are described by the
-Tk_PhotoImageBlock structure pointed to by \fIblockPtr\fR; see the
-manual page FindPhoto(3) for details. The \fIfileName\fR argument
-points to the string giving the name of the file in which to write the
-image data. The \fIformatString\fR argument contains the
-value given for the \fB\-format\fR option, or NULL if the option was
-not specified. The format string can contain extra characters
-after the name of the format. If appropriate, the
-\fIformatPtr->fileWriteProc\fR procedure may interpret these
-characters to specify further details about the image file.
-The return value is a standard Tcl return value.
-
-.SH STRINGWRITEPROC
-\fIformatPtr->stringWriteProc\fR provides the address of a procedure for
-Tk to call to translate image data from a photo image into a string.
-\fIformatPtr->stringWriteProc\fR must match the following prototype:
-.CS
-typedef int Tk_ImageStringWriteProc(
- Tcl_Interp *\fIinterp\fR,
- Tcl_DString *\fIdataPtr\fR,
- char *\fIformatString\fR,
- Tk_PhotoImageBlock *\fIblockPtr\fR);
-.CE
-The \fIinterp\fR argument is the interpreter in which the command was
-invoked to convert the image; it should be used for reporting errors.
-The image data to be converted are in memory and are described by the
-Tk_PhotoImageBlock structure pointed to by \fIblockPtr\fR; see the
-manual page FindPhoto(3) for details. The data for the string
-should be appended to the dynamic string given by \fIdataPtr\fR.
-The \fIformatString\fR argument contains the
-value given for the \fB\-format\fR option, or NULL if the option was
-not specified. The format string can contain extra characters
-after the name of the format. If appropriate, the
-\fIformatPtr->stringWriteProc\fR procedure may interpret these
-characters to specify further details about the image file.
-The return value is a standard Tcl return value.
-
-.SH "SEE ALSO"
-Tk_FindPhoto, Tk_PhotoPutBlock
-
-.SH KEYWORDS
-photo image, image file
diff --git a/doc/CrtSelHdlr.3 b/doc/CrtSelHdlr.3
deleted file mode 100644
index 0e801a4..0000000
--- a/doc/CrtSelHdlr.3
+++ /dev/null
@@ -1,120 +0,0 @@
-'\"
-'\" 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: CrtSelHdlr.3,v 1.2 1998/09/14 18:22:47 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_CreateSelHandler 3 4.0 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_CreateSelHandler, Tk_DeleteSelHandler \- arrange to handle requests for a selection
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-\fBTk_CreateSelHandler\fR(\fItkwin, selection, target, proc, clientData, format\fR)
-.sp
-\fBTk_DeleteSelHandler\fR(\fItkwin, selection, target\fR)
-.SH ARGUMENTS
-.AS Tk_SelectionProc clientData
-.AP Tk_Window tkwin in
-Window for which \fIproc\fR will provide selection information.
-.AP Atom selection in
-The name of the selection for which \fIproc\fR will provide
-selection information.
-.AP Atom target in
-Form in which \fIproc\fR can provide the selection (e.g. STRING
-or FILE_NAME). Corresponds to \fItype\fR arguments in \fBselection\fR
-commands.
-.AP Tk_SelectionProc *proc in
-Procedure to invoke whenever the selection is owned by \fItkwin\fR
-and the selection contents are requested in the format given by
-\fItarget\fR.
-.AP ClientData clientData in
-Arbitrary one-word value to pass to \fIproc\fR.
-.AP Atom format in
-If the selection requestor isn't in this process, \fIformat\fR determines
-the representation used to transmit the selection to its
-requestor.
-.BE
-
-.SH DESCRIPTION
-.PP
-\fBTk_CreateSelHandler\fR arranges for a particular procedure
-(\fIproc\fR) to be called whenever \fIselection\fR is owned by
-\fItkwin\fR and the selection contents are requested in the
-form given by \fItarget\fR.
-\fITarget\fR should be one of
-the entries defined in the left column of Table 2 of the
-X Inter-Client Communication Conventions Manual (ICCCM) or
-any other form in which an application is willing to present
-the selection. The most common form is STRING.
-.PP
-\fIProc\fR should have arguments and result that match the
-type \fBTk_SelectionProc\fR:
-.CS
-typedef int Tk_SelectionProc(
- ClientData \fIclientData\fR,
- int \fIoffset\fR,
- char *\fIbuffer\fR,
- int \fImaxBytes\fR);
-.CE
-The \fIclientData\fR parameter to \fIproc\fR is a copy of the
-\fIclientData\fR argument given to \fBTk_CreateSelHandler\fR.
-Typically, \fIclientData\fR points to a data
-structure containing application-specific information that is
-needed to retrieve the selection. \fIOffset\fR specifies an
-offset position into the selection, \fIbuffer\fR specifies a
-location at which to copy information about the selection, and
-\fImaxBytes\fR specifies the amount of space available at
-\fIbuffer\fR. \fIProc\fR should place a NULL-terminated string
-at \fIbuffer\fR containing \fImaxBytes\fR or fewer characters
-(not including the terminating NULL), and it should return a
-count of the number of non-NULL characters stored at
-\fIbuffer\fR. If the selection no longer exists (e.g. it once
-existed but the user deleted the range of characters containing
-it), then \fIproc\fR should return -1.
-.PP
-When transferring large selections, Tk will break them up into
-smaller pieces (typically a few thousand bytes each) for more
-efficient transmission. It will do this by calling \fIproc\fR
-one or more times, using successively higher values of \fIoffset\fR
-to retrieve successive portions of the selection. If \fIproc\fR
-returns a count less than \fImaxBytes\fR it means that the entire
-remainder of the selection has been returned. If \fIproc\fR's return
-value is \fImaxBytes\fR it means there may be additional information
-in the selection, so Tk must make another call to \fIproc\fR to
-retrieve the next portion.
-.PP
-\fIProc\fR always returns selection information in the form of a
-character string. However, the ICCCM allows for information to
-be transmitted from the selection owner to the selection requestor
-in any of several formats, such as a string, an array of atoms, an
-array of integers, etc. The \fIformat\fR argument to
-\fBTk_CreateSelHandler\fR indicates what format should be used to
-transmit the selection to its requestor (see the middle column of
-Table 2 of the ICCCM for examples). If \fIformat\fR is not
-STRING, then Tk will take the value returned by \fIproc\fR and divided
-it into fields separated by white space. If \fIformat\fR is ATOM,
-then Tk will return the selection as an array of atoms, with each
-field in \fIproc\fR's result treated as the name of one atom. For
-any other value of \fIformat\fR, Tk will return the selection as an
-array of 32-bit values where each field of \fIproc\fR's result is
-treated as a number and translated to a 32-bit value. In any event,
-the \fIformat\fR atom is returned to the selection requestor along
-with the contents of the selection.
-.PP
-If \fBTk_CreateSelHandler\fR is called when there already exists a
-handler for \fIselection\fR and \fItarget\fR on \fItkwin\fR, then the
-existing handler is replaced with a new one.
-.PP
-\fBTk_DeleteSelHandler\fR removes the handler given by \fItkwin\fR,
-\fIselection\fR, and \fItarget\fR, if such a handler exists.
-If there is no such handler then it has no effect.
-
-.SH KEYWORDS
-format, handler, selection, target
diff --git a/doc/CrtWindow.3 b/doc/CrtWindow.3
deleted file mode 100644
index b5f0e29..0000000
--- a/doc/CrtWindow.3
+++ /dev/null
@@ -1,142 +0,0 @@
-'\"
-'\" Copyright (c) 1990 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: CrtWindow.3,v 1.2 1998/09/14 18:22:47 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_CreateWindow 3 4.2 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_CreateWindow, Tk_CreateWindowFromPath, Tk_DestroyWindow, Tk_MakeWindowExist \- create or delete window
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-Tk_Window
-\fBTk_CreateWindow\fR(\fIinterp, parent, name, topLevScreen\fR)
-.sp
-Tk_Window
-\fBTk_CreateWindowFromPath\fR(\fIinterp, tkwin, pathName, topLevScreen\fR)
-.sp
-\fBTk_DestroyWindow\fR(\fItkwin\fR)
-.sp
-\fBTk_MakeWindowExist\fR(\fItkwin\fR)
-.SH ARGUMENTS
-.AS Tcl_Interp *topLevScreen
-.AP Tcl_Interp *interp out
-Tcl interpreter to use for error reporting. If no error occurs,
-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
-Name to use for this window. Must be unique among all children of
-the same \fIparent\fR.
-.AP 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
-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
-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
-.VS
-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
-library. If the window couldn't be created successfully, then NULL
-is returned and \fIinterp->result\fR is modified to hold an error
-message.
-.PP
-Tk supports two different kinds of windows: internal
-windows and top-level windows.
-.VE
-An internal window is an interior window of a Tk application, such as a
-scrollbar or menu bar or button. A top-level window is one that is
-created as a child of a screen's root window, rather than as an
-interior window, but which is logically part of some existing main
-window. Examples of top-level windows are pop-up menus and dialog boxes.
-.PP
-New windows may be created by calling
-\fBTk_CreateWindow\fR. If the \fItopLevScreen\fR argument is
-NULL, then the new window will be an internal window. If
-\fItopLevScreen\fR is non-NULL, then the new window will be a
-top-level window: \fItopLevScreen\fR indicates the name of
-a screen and the new window will be created as a child of the
-root window of \fItopLevScreen\fR. In either case Tk will
-consider the new window to be the logical child of \fIparent\fR:
-the new window's path name will reflect this fact, options may
-be specified for the new window under this assumption, and so on.
-The only difference is that new X window for a top-level window
-will not be a child of \fIparent\fR's X window. For example, a pull-down
-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_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
-application (\fItkwin\fR), plus a path name for the new window.
-It produces the same effect as \fBTk_CreateWindow\fR and allows
-both top-level and internal windows to be created, depending on
-the value of \fItopLevScreen\fR. In calls to \fBTk_CreateWindowFromPath\fR,
-as in calls to \fBTk_CreateWindow\fR, the parent of the new window
-must exist at the time of the call, but the new window must not
-already exist.
-.PP
-The window creation procedures don't
-actually issue the command to X to create a window.
-Instead, they create a local data structure associated with
-the window and defer the creation of the X window.
-The window will actually be created by the first call to
-\fBTk_MapWindow\fR. Deferred window creation allows various
-aspects of the window (such as its size, background color,
-etc.) to be modified after its creation without incurring
-any overhead in the X server. When the window is finally
-mapped all of the window attributes can be set while creating
-the window.
-.PP
-The value returned by a window-creation procedure is not the
-X token for the window (it can't be, since X hasn't been
-asked to create the window yet). Instead, it is a token
-for Tk's local data structure for the window. Most
-of the Tk library procedures take Tk_Window tokens, rather
-than X identifiers. The actual
-X window identifier can be retrieved from the local
-data structure using the \fBTk_WindowId\fR macro; see
-the manual entry for \fBTk_WindowId\fR for details.
-.PP
-\fBTk_DestroyWindow\fR deletes a window and all the data
-structures associated with it, including any event handlers
-created with \fBTk_CreateEventHandler\fR. In addition,
-\fBTk_DestroyWindow\fR will delete any children of \fItkwin\fR
-recursively (where children are defined in the Tk sense, consisting
-of all windows that were created with the given window as \fIparent\fR).
-If \fItkwin\fR was created by \fBTk_CreateInternalWindow\fR then event
-handlers interested in destroy events
-are invoked immediately. If \fItkwin\fR is a top-level or main window,
-then the event handlers will be invoked later, after X has seen
-the request and returned an event for it.
-.PP
-If a window has been created
-but hasn't been mapped, so no X window exists, it is
-possible to force the creation of the X window by
-calling \fBTk_MakeWindowExist\fR. This procedure issues
-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/doc/DeleteImg.3 b/doc/DeleteImg.3
deleted file mode 100644
index bf569af..0000000
--- a/doc/DeleteImg.3
+++ /dev/null
@@ -1,35 +0,0 @@
-'\"
-'\" Copyright (c) 1995-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: DeleteImg.3,v 1.2 1998/09/14 18:22:47 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_DeleteImage 3 4.0 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_DeleteImage \- Destroy an image.
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-\fBTk_DeleteImage\fR(\fIinterp, name\fR)
-.SH ARGUMENTS
-.AS Tcl_Interp *interp
-.AP Tcl_Interp *interp in
-Interpreter for which the image was created.
-.AP char *name in
-Name of the image.
-.BE
-
-.SH DESCRIPTION
-.PP
-\fBTk_DeleteImage\fR deletes the image given by \fIinterp\fR
-and \fIname\fR, if there is one. All instances of that image
-will redisplay as empty regions. If the given image does not
-exist then the procedure has no effect.
-
-.SH KEYWORDS
-delete image, image manager
diff --git a/doc/DrawFocHlt.3 b/doc/DrawFocHlt.3
deleted file mode 100644
index 575f69c..0000000
--- a/doc/DrawFocHlt.3
+++ /dev/null
@@ -1,40 +0,0 @@
-'\"
-'\" Copyright (c) 1995-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: DrawFocHlt.3,v 1.2 1998/09/14 18:22:47 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_DrawFocusHighlight 3 4.0 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_DrawFocusHighlight \- draw the traversal highlight ring for a widget
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-\fBTk_GetPixels(\fItkwin, gc, width, drawable\fB)\fR
-.SH ARGUMENTS
-.AS "Tcl_Interp" *joinPtr
-.AP Tk_Window tkwin in
-Window for which the highlight is being drawn. Used to retrieve
-the window's dimensions, among other things.
-.AP GC gc in
-Graphics context to use for drawing the highlight.
-.AP int width in
-Width of the highlight ring, in pixels.
-.AP Drawable drawable in
-Drawable in which to draw the highlight; usually an offscreen
-pixmap for double buffering.
-.BE
-
-.SH DESCRIPTION
-.PP
-\fBTk_DrawFocusHighlight\fR is a utility procedure that draws the
-traversal highlight ring for a widget.
-It is typically invoked by widgets during redisplay.
-
-.SH KEYWORDS
-focus, traversal highlight
diff --git a/doc/EventHndlr.3 b/doc/EventHndlr.3
deleted file mode 100644
index cbe7c3b..0000000
--- a/doc/EventHndlr.3
+++ /dev/null
@@ -1,79 +0,0 @@
-'\"
-'\" Copyright (c) 1990 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: EventHndlr.3,v 1.2 1998/09/14 18:22:47 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_CreateEventHandler 3 "" Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_CreateEventHandler, Tk_DeleteEventHandler \- associate procedure callback with an X event
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-\fBTk_CreateEventHandler\fR(\fItkwin, mask, proc, clientData\fR)
-.sp
-\fBTk_DeleteEventHandler\fR(\fItkwin, mask, proc, clientData\fR)
-.SH ARGUMENTS
-.AS "unsigned long" clientData
-.AP Tk_Window tkwin in
-Token for window in which events may occur.
-.AP "unsigned long" mask in
-Bit-mask of events (such as \fBButtonPressMask\fR)
-for which \fIproc\fR should be called.
-.AP Tk_EventProc *proc in
-Procedure to invoke whenever an event in \fImask\fR occurs
-in the window given by \fItkwin\fR.
-.AP ClientData clientData in
-Arbitrary one-word value to pass to \fIproc\fR.
-.BE
-
-.SH DESCRIPTION
-.PP
-\fBTk_CreateEventHandler\fR arranges for \fIproc\fR to be
-invoked in the future whenever one of the event types specified
-by \fImask\fR occurs in the window specified by \fItkwin\fR.
-The callback to \fIproc\fR will be made by \fBTk_HandleEvent\fR;
-this mechanism only works in programs that dispatch events
-through \fBTk_HandleEvent\fR (or through other Tk procedures that
-call \fBTk_HandleEvent\fR, such as \fBTk_DoOneEvent\fR or
-\fBTk_MainLoop\fR).
-.PP
-\fIProc\fR should have arguments and result that match the
-type \fBTk_EventProc\fR:
-.CS
-typedef void Tk_EventProc(
- ClientData \fIclientData\fR,
- XEvent *\fIeventPtr\fR);
-.CE
-The \fIclientData\fR parameter to \fIproc\fR is a copy of the \fIclientData\fR
-argument given to \fBTk_CreateEventHandler\fR when the callback
-was created. Typically, \fIclientData\fR points to a data
-structure containing application-specific information about
-the window in which the event occurred. \fIEventPtr\fR is
-a pointer to the X event, which will be one of the ones
-specified in the \fImask\fR argument to \fBTk_CreateEventHandler\fR.
-.PP
-\fBTk_DeleteEventHandler\fR may be called to delete a
-previously-created event handler: it deletes the first handler
-it finds that is associated with \fItkwin\fR and matches the
-\fImask\fR, \fIproc\fR, and \fIclientData\fR arguments. If
-no such handler exists, then \fBTk_EventHandler\fR returns
-without doing anything. Although Tk supports it, it's probably
-a bad idea to have more than one callback with the same \fImask\fR,
-\fIproc\fR, and \fIclientData\fR arguments.
-When a window is deleted all of its handlers will be deleted
-automatically; in this case there is no need to call
-\fBTk_DeleteEventHandler\fR.
-.PP
-If multiple handlers are declared for the same type of X event
-on the same window, then the handlers will be invoked in the
-order they were created.
-
-.SH KEYWORDS
-bind, callback, event, handler
diff --git a/doc/FindPhoto.3 b/doc/FindPhoto.3
deleted file mode 100644
index 0673efb..0000000
--- a/doc/FindPhoto.3
+++ /dev/null
@@ -1,202 +0,0 @@
-'\"
-'\" Copyright (c) 1994 The Australian National University
-'\" 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.
-'\"
-'\" Author: Paul Mackerras (paulus@cs.anu.edu.au),
-'\" Department of Computer Science,
-'\" Australian National University.
-'\"
-'\" RCS: @(#) $Id: FindPhoto.3,v 1.2 1998/09/14 18:22:47 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_FindPhoto 3 8.0 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_FindPhoto, Tk_PhotoPutBlock, Tk_PhotoPutZoomedBlock, Tk_PhotoGetImage, Tk_PhotoBlank, Tk_PhotoExpand, Tk_PhotoGetSize, Tk_PhotoSetSize \- manipulate the image data stored in a photo image.
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-\fB#include <tkPhoto.h>\fR
-.sp
-Tk_PhotoHandle
-.VS 8.0 br
-\fBTk_FindPhoto\fR(\fIinterp, imageName\fR)
-.VE
-.sp
-void
-\fBTk_PhotoPutBlock\fR(\fIhandle, blockPtr, x, y, width, height\fR)
-.sp
-void
-\fBTk_PhotoPutZoomedBlock\fR(\fIhandle, blockPtr, x, y, width, height,\
-zoomX, zoomY, subsampleX, subsampleY\fR)
-.sp
-int
-\fBTk_PhotoGetImage\fR(\fIhandle, blockPtr\fR)
-.sp
-void
-\fBTk_PhotoBlank\fR(\fIhandle\fR)
-.sp
-void
-\fBTk_PhotoExpand\fR(\fIhandle, width, height\fR)
-.sp
-void
-\fBTk_PhotoGetSize\fR(\fIhandle, widthPtr, heightPtr\fR)
-.sp
-void
-\fBTk_PhotoSetSize\fR(\fIhandle, width, height\fR)
-.SH ARGUMENTS
-.AS Tk_PhotoImageBlock window_path
-.AP Tcl_Interp *interp in
-.VS
-Interpreter in which image was created.
-.VE
-.AP char *imageName in
-Name of the photo image.
-.AP Tk_PhotoHandle handle in
-Opaque handle identifying the photo image to be affected.
-.AP Tk_PhotoImageBlock *blockPtr in
-Specifies the address and storage layout of image data.
-.AP int x in
-Specifies the X coordinate where the top-left corner of the block is
-to be placed within the image.
-.AP int y in
-Specifies the Y coordinate where the top-left corner of the block is
-to be placed within the image.
-.AP int width in
-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).
-.AP int height in
-Specifies the height of the image area to be affected (for
-\fBTk_PhotoPutBlock\fR) or the desired image height (for
-\fBTk_PhotoExpand\fR and \fBTk_PhotoSetSize\fR).
-.AP int *widthPtr out
-Pointer to location in which to store the image width.
-.AP int *heightPtr out
-Pointer to location in which to store the image height.
-.AP int subsampleX in
-Specifies the subsampling factor in the X direction for input
-image data.
-.AP int subsampleY in
-Specifies the subsampling factor in the Y direction for input
-image data.
-.AP int zoomX in
-Specifies the zoom factor to be applied in the X direction to pixels
-being written to the photo image.
-.AP int zoomY in
-Specifies the zoom factor to be applied in the Y direction to pixels
-being written to the photo image.
-.BE
-
-.SH DESCRIPTION
-.PP
-\fBTk_FindPhoto\fR returns an opaque handle that is used to identify a
-particular photo image to the other procedures. The parameter is the
-name of the image, that is, the name specified to the \fBimage create
-photo\fR command, or assigned by that command if no name was specified.
-.PP
-\fBTk_PhotoPutBlock\fR is used to supply blocks of image data to be
-displayed. The call affects an area of the image of size
-\fIwidth\fR x \fIheight\fR pixels, with its top-left corner at
-coordinates (\fIx\fR,\fIy\fR). All of \fIwidth\fR, \fIheight\fR,
-\fIx\fR, and \fIy\fR must be non-negative.
-If part of this area lies outside the
-current bounds of the image, the image will be expanded to include the
-area, unless the user has specified an explicit image size with the
-\fB\-width\fR and/or \fB\-height\fR widget configuration options
-(see photo(n)); in that
-case the area is silently clipped to the image boundaries.
-.PP
-The \fIblock\fR parameter is a pointer to a
-\fBTk_PhotoImageBlock\fR structure, defined as follows:
-.CS
-typedef struct {
- unsigned char *\fIpixelPtr\fR;
- int \fIwidth\fR;
- int \fIheight\fR;
- int \fIpitch\fR;
- int \fIpixelSize\fR;
- int \fIoffset[3]\fR;
-} Tk_PhotoImageBlock;
-.CE
-The \fIpixelPtr\fR field points to the first pixel, that is, the
-top-left pixel in the block.
-The \fIwidth\fR and \fIheight\fR fields specify the dimensions of the
-block of pixels. The \fIpixelSize\fR field specifies the address
-difference between two horizontally adjacent pixels. Often it is 3
-or 4, but it can have any value. The \fIpitch\fR field specifies the
-address difference between two vertically adjacent pixels. The
-\fIoffset\fR array contains the offsets from the address of a pixel
-to the addresses of the bytes containing the red, green and blue
-components. These are normally 0, 1 and 2, but can have other values,
-e.g., for images that are stored as separate red, green and blue
-planes.
-.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
-sub-block from the image data supplied. If they are larger, the data
-given are replicated (in a tiled fashion) to fill the specified area.
-These rules operate independently in the horizontal and vertical
-directions.
-.PP
-\fBTk_PhotoPutZoomedBlock\fR works like \fBTk_PhotoPutBlock\fR except that
-the image can be reduced or enlarged for display. The
-\fIsubsampleX\fR and \fIsubsampleY\fR parameters allow the size of the
-image to be reduced by subsampling.
-\fBTk_PhotoPutZoomedBlock\fR will use only pixels from the input image
-whose X coordinates are multiples of \fIsubsampleX\fR, and whose Y
-coordinates are multiples of \fIsubsampleY\fR. For example, an image
-of 512x512 pixels can be reduced to 256x256 by setting
-\fIsubsampleX\fR and \fIsubsampleY\fR to 2.
-.PP
-The \fIzoomX\fR and \fIzoomY\fR parameters allow the image to be
-enlarged by pixel replication. Each pixel of the (possibly subsampled)
-input image will be written to a block \fIzoomX\fR pixels wide and
-\fIzoomY\fR pixels high of the displayed image. Subsampling and
-zooming can be used together for special effects.
-.PP
-\fBTk_PhotoGetImage\fR can be used to retrieve image data from a photo
-image. \fBTk_PhotoGetImage\fR fills
-in the structure pointed to by the \fIblockPtr\fR parameter with values
-that describe the address and layout of the image data that the
-photo image has stored internally. The values are valid
-until the image is destroyed or its size is changed.
-\fBTk_PhotoGetImage\fR returns 1 for compatibility with the
-corresponding procedure in the old photo widget.
-.PP
-\fBTk_PhotoBlank\fR blanks the entire area of the
-photo image. Blank areas of a photo image are transparent.
-.PP
-\fBTk_PhotoExpand\fR requests that the widget's image be expanded to be
-at least \fIwidth\fR x \fIheight\fR pixels in size. The width and/or
-height are unchanged if the user has specified an explicit image width
-or height with the \fB\-width\fR and/or \fB\-height\fR configuration
-options, respectively.
-If the image data
-are being supplied in many small blocks, it is more efficient to use
-\fBTk_PhotoExpand\fR or \fBTk_PhotoSetSize\fR at the beginning rather than
-allowing the image to expand in many small increments as image blocks
-are supplied.
-.PP
-\fBTk_PhotoSetSize\fR specifies the size of the image, as if the user
-had specified the given \fIwidth\fR and \fIheight\fR values to the
-\fB\-width\fR and \fB\-height\fR configuration options. A value of
-zero for \fIwidth\fR or \fIheight\fR does not change the image's width
-or height, but allows the width or height to be changed by subsequent
-calls to \fBTk_PhotoPutBlock\fR, \fBTk_PhotoPutZoomedBlock\fR or
-\fBTk_PhotoExpand\fR.
-.PP
-\fBTk_PhotoGetSize\fR returns the dimensions of the image in
-*\fIwidthPtr\fR and *\fIheightPtr\fR.
-
-.SH CREDITS
-.PP
-The code for the photo image type was developed by Paul Mackerras,
-based on his earlier photo widget code.
-
-.SH KEYWORDS
-photo, image
diff --git a/doc/FontId.3 b/doc/FontId.3
deleted file mode 100644
index 80b0390..0000000
--- a/doc/FontId.3
+++ /dev/null
@@ -1,95 +0,0 @@
-'\"
-'\" Copyright (c) 1996 Sun Microsystems, Inc.
-'\"
-'\" See the file "license.terms" for information on usage and redistribution
-'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-'\"
-'\" RCS: @(#) $Id: FontId.3,v 1.2 1998/09/14 18:22:47 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_FontId 3 8.0 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_FontId, Tk_FontMetrics, Tk_PostscriptFontName \- accessor functions for
-fonts
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-Font
-\fBTk_FontId(\fItkfont\fB)\fR
-.sp
-void
-\fBTk_GetFontMetrics(\fItkfont, fmPtr\fB)\fR
-.sp
-int
-\fBTk_PostscriptFontName(\fItkfont, dsPtr\fB)\fR
-
-.SH ARGUMENTS
-.AS Tk_FontMetrics *dsPtr
-.AP Tk_Font tkfont in
-Opaque font token being queried. Must have been returned by a previous
-call to \fBTk_GetFont\fR.
-.AP Tk_FontMetrics *fmPtr out
-Pointer to structure in which the font metrics for \fItkfont\fR will
-be stored.
-.AP Tcl_DString *dsPtr out
-Pointer to an initialized \fBTcl_DString\fR to which the name of the
-Postscript font that corresponds to \fItkfont\fR will be appended.
-.BE
-
-.SH DESCRIPTION
-.PP
-Given a \fItkfont\fR, \fBTk_FontId\fR returns the token that should be
-selected into an XGCValues structure in order to construct a graphics
-context that can be used to draw text in the specified font.
-.PP
-\fBTk_GetFontMetrics\fR computes the ascent, descent, and linespace of the
-\fItkfont\fR in pixels and stores those values in the structure pointer to by
-\fIfmPtr\fR. These values can be used in computations such as to space
-multiple lines of text, to align the baselines of text in different
-fonts, and to vertically align text in a given region. See the
-documentation for the \fBfont\fR command for definitions of the terms
-ascent, descent, and linespace, used in font metrics.
-.PP
-\fBTk_PostscriptFontName\fR maps a \fItkfont\fR to the corresponding
-Postcript font name that should be used when printing. The return value
-is the size in points of the \fItkfont\fR and the Postscript font name is
-appended to \fIdsPtr\fR. \fIDsPtr\fR must refer to an initialized
-\fBTcl_DString\fR. Given a ``reasonable'' Postscript printer, the
-following screen font families should print correctly:
-.IP
-\fBAvant Garde\fR, \fBArial\fR, \fBBookman\fR, \fBCourier\fR,
-\fBCourier New\fR, \fBGeneva\fR, \fBHelvetica\fR, \fBMonaco\fR,
-\fBNew Century Schoolbook\fR, \fBNew York\fR, \fBPalatino\fR, \fBSymbol\fR,
-\fBTimes\fR, \fBTimes New Roman\fR, \fBZapf Chancery\fR, and
-\fBZapf Dingbats\fR.
-.PP
-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
-The Tk_FontMetrics data structure is used by Tk_GetFontMetrics to return
-information about a font and is defined as follows:
-.CS
-typedef struct Tk_FontMetrics {
- int ascent;
- int descent;
- int linespace;
-} Tk_FontMetrics;
-.CE
-The \fIlinespace\fR field is the amount in pixels that the tallest
-letter sticks up above the baseline, plus any extra blank space added
-by the designer of the font.
-.PP
-The \fIdescent\fR is the largest amount in pixels that any letter
-sticks below the baseline, plus any extra blank space added by the
-designer of the font.
-.PP
-The \fIlinespace\fR is the sum of the ascent and descent. How far
-apart two lines of text in the same font should be placed so that none
-of the characters in one line overlap any of the characters in the
-other line.
-.VE
-.SH KEYWORDS
-font
diff --git a/doc/FreeXId.3 b/doc/FreeXId.3
deleted file mode 100644
index 5d8024a..0000000
--- a/doc/FreeXId.3
+++ /dev/null
@@ -1,52 +0,0 @@
-'\"
-'\" Copyright (c) 1990 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: FreeXId.3,v 1.2 1998/09/14 18:22:48 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_FreeXId 3 4.0 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_FreeXId \- make X resource identifier available for reuse
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-\fBTk_FreeXId(\fIdisplay, id\fB)\fR
-.SH ARGUMENTS
-.AS Display *display out
-.AP Display *display in
-Display for which \fIid\fR was allocated.
-.AP XID id in
-Identifier of X resource (window, font, pixmap, cursor, graphics
-context, or colormap) that is no longer in use.
-.BE
-
-.SH DESCRIPTION
-.PP
-The default allocator for resource identifiers provided by Xlib is very
-simple-minded and does not allow resource identifiers to be re-used.
-If a long-running application reaches the end of the resource id
-space, it will generate an X protocol error and crash.
-Tk replaces the default id allocator with its own allocator, which
-allows identifiers to be reused.
-In order for this to work, \fBTk_FreeXId\fR must be called to
-tell the allocator about resources that have been freed.
-Tk automatically calls \fBTk_FreeXId\fR whenever it frees a
-resource, so if you use procedures like \fBTk_GetFontStruct\fR,
-\fBTk_GetGC\fR, and \fBTk_GetPixmap\fR then you need not call
-\fBTk_FreeXId\fR.
-However, if you allocate resources directly from Xlib, for example
-by calling \fBXCreatePixmap\fR, then you should call \fBTk_FreeXId\fR
-when you call the corresponding Xlib free procedure, such as
-\fBXFreePixmap\fR.
-If you don't call \fBTk_FreeXId\fR then the resource identifier will
-be lost, which could cause problems if the application runs long enough
-to lose all of the available identifiers.
-
-.SH KEYWORDS
-resource identifier
diff --git a/doc/GeomReq.3 b/doc/GeomReq.3
deleted file mode 100644
index b77ce34..0000000
--- a/doc/GeomReq.3
+++ /dev/null
@@ -1,69 +0,0 @@
-'\"
-'\" 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: GeomReq.3,v 1.2 1998/09/14 18:22:48 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_GeometryRequest 3 "" Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_GeometryRequest, Tk_SetInternalBorder \- specify desired geometry or internal border for a window
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-\fBTk_GeometryRequest\fR(\fItkwin, reqWidth, reqHeight\fR)
-.sp
-\fBTk_SetInternalBorder\fR(\fItkwin, width\fR)
-.SH ARGUMENTS
-.AS baseHeight clientData
-.AP Tk_Window tkwin in
-Window for which geometry is being requested.
-.AP int reqWidth in
-Desired width for \fItkwin\fR, in pixel units.
-.AP int reqHeight in
-Desired height for \fItkwin\fR, in pixel units.
-.AP int width in
-Space to leave for internal border for \fItkwin\fR, in pixel units.
-.BE
-
-.SH DESCRIPTION
-.PP
-\fBTk_GeometryRequest\fR is called by widget code to indicate its
-preference for the dimensions of a particular window. The arguments
-to \fBTk_GeometryRequest\fR are made available to the geometry
-manager for the window, which then decides on the actual geometry
-for the window. Although geometry managers generally try to satisfy
-requests made to \fBTk_GeometryRequest\fR, there is no guarantee that
-this will always be possible. Widget code should not assume that
-a geometry request will be satisfied until it receives a
-\fBConfigureNotify\fR event indicating that the geometry change has
-occurred. Widget code should never call procedures like
-\fBTk_ResizeWindow\fR directly. Instead, it should invoke
-\fBTk_GeometryRequest\fR and leave the final geometry decisions to
-the geometry manager.
-.PP
-If \fItkwin\fR is a top-level window, then the geometry information
-will be passed to the window manager using the standard ICCCM protocol.
-.PP
-\fBTk_SetInternalBorder\fR is called by widget code to indicate that
-the widget has an internal border. This means that the widget draws
-a decorative border inside the window instead of using the standard
-X borders, which are external to the window's area. For example,
-internal borders are used to draw 3-D effects. \fIWidth\fR
-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.
-See the \fBTk_WindowId\fR manual entry for details.
-
-.SH KEYWORDS
-geometry, request
diff --git a/doc/GetAnchor.3 b/doc/GetAnchor.3
deleted file mode 100644
index 5342ea5..0000000
--- a/doc/GetAnchor.3
+++ /dev/null
@@ -1,64 +0,0 @@
-'\"
-'\" Copyright (c) 1990 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: GetAnchor.3,v 1.2 1998/09/14 18:22:48 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_GetAnchor 3 "" Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_GetAnchor, Tk_NameOfAnchor \- translate between strings and anchor positions
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-int
-\fBTk_GetAnchor(\fIinterp, string, anchorPtr\fB)\fR
-.sp
-char *
-\fBTk_NameOfAnchor(\fIanchor\fB)\fR
-.SH ARGUMENTS
-.AS "Tk_Anchor" *anchorPtr
-.AP Tcl_Interp *interp in
-Interpreter to use for error reporting.
-.AP char *string in
-String containing name of anchor point: one of ``n'', ``ne'', ``e'', ``se'',
-``s'', ``sw'', ``w'', ``nw'', or ``center''.
-.AP int *anchorPtr out
-Pointer to location in which to store anchor position corresponding to
-\fIstring\fR.
-.AP Tk_Anchor anchor in
-Anchor position, e.g. \fBTCL_ANCHOR_CENTER\fR.
-.BE
-
-.SH DESCRIPTION
-.PP
-\fBTk_GetAnchor\fR places in \fI*anchorPtr\fR an anchor position
-(enumerated type \fBTk_Anchor\fR)
-corresponding to \fIstring\fR, which will be one of
-\fBTK_ANCHOR_N\fR, \fBTK_ANCHOR_NE\fR, \fBTK_ANCHOR_E\fR, \fBTK_ANCHOR_SE\fR,
-\fBTK_ANCHOR_S\fR, \fBTK_ANCHOR_SW\fR, \fBTK_ANCHOR_W\fR, \fBTK_ANCHOR_NW\fR,
-or \fBTK_ANCHOR_CENTER\fR.
-Anchor positions are typically used for indicating a point on an object
-that will be used to position that object, e.g. \fBTK_ANCHOR_N\fR means
-position the top center point of the object at a particular place.
-.PP
-Under normal circumstances the return value is \fBTCL_OK\fR and
-\fIinterp\fR is unused.
-If \fIstring\fR doesn't contain a valid anchor position
-or an abbreviation of one of these names, then an error message is
-stored in \fIinterp->result\fR, \fBTCL_ERROR\fR is returned, and
-\fI*anchorPtr\fR is unmodified.
-.PP
-\fBTk_NameOfAnchor\fR is the logical inverse of \fBTk_GetAnchor\fR.
-Given an anchor position such as \fBTK_ANCHOR_N\fR it returns a
-statically-allocated string corresponding to \fIanchor\fR.
-If \fIanchor\fR isn't a legal anchor value, then
-``unknown anchor position'' is returned.
-
-.SH KEYWORDS
-anchor position
diff --git a/doc/GetBitmap.3 b/doc/GetBitmap.3
deleted file mode 100644
index 4321cce..0000000
--- a/doc/GetBitmap.3
+++ /dev/null
@@ -1,266 +0,0 @@
-'\"
-'\" Copyright (c) 1990 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: GetBitmap.3,v 1.2 1998/09/14 18:22:48 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_GetBitmap 3 8.0 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_GetBitmap, Tk_DefineBitmap, Tk_NameOfBitmap, Tk_SizeOfBitmap, Tk_FreeBitmap, Tk_GetBitmapFromData \- maintain database of single-plane pixmaps
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-Pixmap
-\fBTk_GetBitmap(\fIinterp, tkwin, id\fB)\fR
-.sp
-int
-\fBTk_DefineBitmap(\fIinterp, nameId, source, width, height\fB)\fR
-.sp
-Tk_Uid
-\fBTk_NameOfBitmap(\fIdisplay, bitmap\fB)\fR
-.sp
-\fBTk_SizeOfBitmap(\fIdisplay, bitmap, widthPtr, heightPtr\fB)\fR
-.sp
-\fBTk_FreeBitmap(\fIdisplay, bitmap\fB)\fR
-.SH ARGUMENTS
-.AS "unsigned long" *pixelPtr
-.AP Tcl_Interp *interp in
-Interpreter to use for error reporting.
-.AP Tk_Window tkwin in
-Token for window in which the bitmap will be used.
-.AP Tk_Uid id in
-Description of bitmap; see below for possible values.
-.AP Tk_Uid nameId in
-Name for new bitmap to be defined.
-.AP 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
-Width of bitmap.
-.AP "int" height in
-Height of bitmap.
-.AP "int" *widthPtr out
-Pointer to word to fill in with \fIbitmap\fR's width.
-.AP "int" *heightPtr out
-Pointer to word to fill in with \fIbitmap\fR's height.
-.AP Display *display in
-Display for which \fIbitmap\fR was allocated.
-.AP Pixmap bitmap in
-Identifier for a bitmap allocated by \fBTk_GetBitmap\fR.
-.BE
-
-.SH DESCRIPTION
-.PP
-These procedures manage a collection of bitmaps (one-plane pixmaps)
-being used by an application. The procedures allow bitmaps to be
-re-used efficiently, thereby avoiding server overhead, and also
-allow bitmaps to be named with character strings.
-.PP
-\fBTk_GetBitmap\fR takes as argument a Tk_Uid describing a bitmap.
-It returns a Pixmap identifier for a bitmap corresponding to the
-description. It re-uses an existing bitmap, if possible, and
-creates a new one otherwise. At present, \fIid\fR must have
-one of the following forms:
-.TP 20
-\fB@\fIfileName\fR
-\fIFileName\fR must be the name of a file containing a bitmap
-description in the standard X11 or X10 format.
-.TP 20
-\fIname\fR
-\fIName\fR must be the name of a bitmap defined previously with
-a call to \fBTk_DefineBitmap\fR. The following names are pre-defined
-by Tk:
-.RS
-.TP 12
-\fBerror\fR
-The international "don't" symbol: a circle with a diagonal line
-across it.
-.VS "" br
-.TP 12
-\fBgray75\fR
-75% gray: a checkerboard pattern where three out of four bits are on.
-.VE
-.TP 12
-\fBgray50\fR
-50% gray: a checkerboard pattern where every other bit is on.
-.VS "" br
-.TP 12
-\fBgray25\fR
-25% gray: a checkerboard pattern where one out of every four bits is on.
-.VE
-.TP 12
-\fBgray12\fR
-12.5% gray: a pattern where one-eighth of the bits are on, consisting of
-every fourth pixel in every other row.
-.TP 12
-\fBhourglass\fR
-An hourglass symbol.
-.TP 12
-\fBinfo\fR
-A large letter ``i''.
-.TP 12
-\fBquesthead\fR
-The silhouette of a human head, with a question mark in it.
-.TP 12
-\fBquestion\fR
-A large question-mark.
-.TP 12
-\fBwarning\fR
-A large exclamation point.
-.PP
-In addition, the following pre-defined names are available only on the
-\fBMacintosh\fR platform:
-.TP 12
-\fBdocument\fR
-A generic document.
-.TP 12
-\fBstationery\fR
-Document stationery.
-.TP 12
-\fBedition\fR
-The \fIedition\fR symbol.
-.TP 12
-\fBapplication\fR
-Generic application icon.
-.TP 12
-\fBaccessory\fR
-A desk accessory.
-.TP 12
-\fBfolder\fR
-Generic folder icon.
-.TP 12
-\fBpfolder\fR
-A locked folder.
-.TP 12
-\fBtrash\fR
-A trash can.
-.TP 12
-\fBfloppy\fR
-A floppy disk.
-.TP 12
-\fBramdisk\fR
-A floppy disk with chip.
-.TP 12
-\fBcdrom\fR
-A cd disk icon.
-.TP 12
-\fBpreferences\fR
-A folder with prefs symbol.
-.TP 12
-\fBquerydoc\fR
-A database document icon.
-.TP 12
-\fBstop\fR
-A stop sign.
-.TP 12
-\fBnote\fR
-A face with ballon words.
-.TP 12
-\fBcaution\fR
-A triangle with an exclamation point.
-.RE
-.LP
-Under normal conditions, \fBTk_GetBitmap\fR
-returns an identifier for the requested bitmap. If an error
-occurs in creating the bitmap, such as when \fIid\fR refers
-to a non-existent file, then \fBNone\fR is returned and an error
-message is left in \fIinterp->result\fR.
-.PP
-\fBTk_DefineBitmap\fR associates a name with
-in-memory bitmap data so that the name can be used in later
-calls to \fBTk_GetBitmap\fR. The \fInameId\fR
-argument gives a name for the bitmap; it must not previously
-have been used in a call to \fBTk_DefineBitmap\fR.
-The arguments \fIsource\fR, \fIwidth\fR, and \fIheight\fR
-describe the bitmap.
-\fBTk_DefineBitmap\fR normally returns TCL_OK; if an error occurs
-(e.g. a bitmap named \fInameId\fR has already been defined) then
-TCL_ERROR is returned and an error message is left in
-\fIinterp->result\fR.
-Note: \fBTk_DefineBitmap\fR expects the memory pointed to by
-\fIsource\fR to be static: \fBTk_DefineBitmap\fR doesn't make
-a private copy of this memory, but uses the bytes pointed to
-by \fIsource\fR later in calls to \fBTk_GetBitmap\fR.
-.PP
-Typically \fBTk_DefineBitmap\fR is used by \fB#include\fR-ing a
-bitmap file directly into a C program and then referencing
-the variables defined by the file.
-For example, suppose there exists a file \fBstip.bitmap\fR,
-which was created by the \fBbitmap\fR program and contains
-a stipple pattern.
-The following code uses \fBTk_DefineBitmap\fR to define a
-new bitmap named \fBfoo\fR:
-.CS
-Pixmap bitmap;
-#include "stip.bitmap"
-Tk_DefineBitmap(interp, Tk_GetUid("foo"), stip_bits,
- stip_width, stip_height);
-\&...
-bitmap = Tk_GetBitmap(interp, tkwin, Tk_GetUid("foo"));
-.CE
-This code causes the bitmap file to be read
-at compile-time and incorporates the bitmap information into
-the program's executable image. The same bitmap file could be
-read at run-time using \fBTk_GetBitmap\fR:
-.CS
-Pixmap bitmap;
-bitmap = Tk_GetBitmap(interp, tkwin, Tk_GetUid("@stip.bitmap"));
-.CE
-The second form is a bit more flexible (the file could be modified
-after the program has been compiled, or a different string could be
-provided to read a different file), but it is a little slower and
-requires the bitmap file to exist separately from the program.
-.PP
-\fBTk_GetBitmap\fR maintains a
-database of all the bitmaps that are currently in use.
-Whenever possible, it will return an existing bitmap rather
-than creating a new one.
-This approach can substantially reduce server overhead, so
-\fBTk_GetBitmap\fR should generally be used in preference to Xlib
-procedures like \fBXReadBitmapFile\fR.
-.PP
-The bitmaps returned by \fBTk_GetBitmap\fR
-are shared, so callers should never modify them.
-If a bitmap must be modified dynamically, then it should be
-created by calling Xlib procedures such as \fBXReadBitmapFile\fR
-or \fBXCreatePixmap\fR directly.
-.PP
-The procedure \fBTk_NameOfBitmap\fR is roughly the inverse of
-\fBTk_GetBitmap\fR.
-Given an X Pixmap argument, it returns the \fIid\fR that was
-passed to \fBTk_GetBitmap\fR when the bitmap was created.
-\fIBitmap\fR must have been the return value from a previous
-call to \fBTk_GetBitmap\fR.
-.PP
-\fBTk_SizeOfBitmap\fR returns the dimensions of its \fIbitmap\fR
-argument in the words pointed to by the \fIwidthPtr\fR and
-\fIheightPtr\fR arguments. As with \fBTk_NameOfBitmap\fR,
-\fIbitmap\fR must have been created by \fBTk_GetBitmap\fR.
-.PP
-When a bitmap returned by \fBTk_GetBitmap\fR
-is no longer needed, \fBTk_FreeBitmap\fR should be called to release it.
-There should be exactly one call to \fBTk_FreeBitmap\fR for
-each call to \fBTk_GetBitmap\fR.
-When a bitmap is no longer in use anywhere (i.e. it has been freed as
-many times as it has been gotten) \fBTk_FreeBitmap\fR will release
-it to the X server and delete it from the database.
-
-.SH BUGS
-In determining whether an existing bitmap can be used to satisfy
-a new request, \fBTk_GetBitmap\fR
-considers only the immediate value of its \fIid\fR argument. For
-example, when a file name is passed to \fBTk_GetBitmap\fR,
-\fBTk_GetBitmap\fR will assume it is safe to re-use an existing
-bitmap created from the same file name: it will not check to
-see whether the file itself has changed, or whether the current
-directory has changed, thereby causing the name to refer to
-a different file.
-
-.SH KEYWORDS
-bitmap, pixmap
diff --git a/doc/GetCapStyl.3 b/doc/GetCapStyl.3
deleted file mode 100644
index e25c2d6..0000000
--- a/doc/GetCapStyl.3
+++ /dev/null
@@ -1,63 +0,0 @@
-'\"
-'\" Copyright (c) 1990 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: GetCapStyl.3,v 1.2 1998/09/14 18:22:48 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_GetCapStyle 3 "" Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_GetCapStyle, Tk_NameOfCapStyle \- translate between strings and cap styles
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-int
-\fBTk_GetCapStyle(\fIinterp, string, capPtr\fB)\fR
-.sp
-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
-String containing name of cap style: one of ```butt'', ``projecting'',
-or ``round''.
-.AP int *capPtr out
-Pointer to location in which to store X cap style corresponding to
-\fIstring\fR.
-.AP int cap in
-Cap style: one of \fBCapButt\fR, \fBCapProjecting\fR, or \fBCapRound\fR.
-.BE
-
-.SH DESCRIPTION
-.PP
-\fBTk_GetCapStyle\fR places in \fI*capPtr\fR the X cap style
-corresponding to \fIstring\fR.
-This will be one of the values
-\fBCapButt\fR, \fBCapProjecting\fR, or \fBCapRound\fR.
-Cap styles are typically used in X graphics contexts to indicate
-how the end-points of lines should be capped.
-See the X documentation for information on what each style
-implies.
-.PP
-Under normal circumstances the return value is \fBTCL_OK\fR and
-\fIinterp\fR is unused.
-If \fIstring\fR doesn't contain a valid cap style
-or an abbreviation of one of these names, then an error message is
-stored in \fIinterp->result\fR, \fBTCL_ERROR\fR is returned, and
-\fI*capPtr\fR is unmodified.
-.PP
-\fBTk_NameOfCapStyle\fR is the logical inverse of \fBTk_GetCapStyle\fR.
-Given a cap style such as \fBCapButt\fR it returns a
-statically-allocated string corresponding to \fIcap\fR.
-If \fIcap\fR isn't a legal cap style, then
-``unknown cap style'' is returned.
-
-.SH KEYWORDS
-butt, cap style, projecting, round
diff --git a/doc/GetClrmap.3 b/doc/GetClrmap.3
deleted file mode 100644
index 625fdb4..0000000
--- a/doc/GetClrmap.3
+++ /dev/null
@@ -1,73 +0,0 @@
-'\"
-'\" Copyright (c) 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: GetClrmap.3,v 1.2 1998/09/14 18:22:48 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_GetColormap 3 4.0 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_GetColormap, Tk_FreeColormap \- allocate and free colormaps
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-Colormap
-\fBTk_GetColormap(\fIinterp, tkwin, string\fB)\fR
-.sp
-\fBTk_FreeColormap(\fIdisplay, colormap\fB)\fR
-.SH ARGUMENTS
-.AS "Colormap" colormap
-.AP Tcl_Interp *interp in
-Interpreter to use for error reporting.
-.AP Tk_Window tkwin in
-Token for window in which colormap will be used.
-.AP 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
-Display for which \fIcolormap\fR was allocated.
-.AP Colormap colormap in
-Colormap to free; must have been returned by a previous
-call to \fBTk_GetColormap\fR or \fBTk_GetVisual\fR.
-.BE
-
-.SH DESCRIPTION
-.PP
-These procedures are used to manage colormaps.
-\fBTk_GetColormap\fR returns a colormap suitable for use in \fItkwin\fR.
-If its \fIstring\fR argument is \fBnew\fR then a new colormap is
-created; otherwise \fIstring\fR must be the name of another window
-with the same screen and visual as \fItkwin\fR, and the colormap from that
-window is returned.
-If \fIstring\fR doesn't make sense, or if it refers to a window on
-a different screen from \fItkwin\fR or with
-a different visual than \fItkwin\fR, then \fBTk_GetColormap\fR returns
-\fBNone\fR and leaves an error message in \fIinterp->result\fR.
-.PP
-\fBTk_FreeColormap\fR should be called when a colormap returned by
-\fBTk_GetColormap\fR is no longer needed.
-Tk maintains a reference count for each colormap returned by
-\fBTk_GetColormap\fR, so there should eventually be one call to
-\fBTk_FreeColormap\fR for each call to \fBTk_GetColormap\fR.
-When a colormap's reference count becomes zero, Tk releases the
-X colormap.
-.PP
-\fBTk_GetVisual\fR and \fBTk_GetColormap\fR work together, in that
-a new colormap created by \fBTk_GetVisual\fR may later be returned
-by \fBTk_GetColormap\fR.
-The reference counting mechanism for colormaps includes both procedures,
-so callers of \fBTk_GetVisual\fR must also call \fBTk_FreeColormap\fR
-to release the colormap.
-If \fBTk_GetColormap\fR is called with a \fIstring\fR value of
-\fBnew\fR then the resulting colormap will never
-be returned by \fBTk_GetVisual\fR; however, it can be used in other
-windows by calling \fBTk_GetColormap\fR with the original window's
-name as \fIstring\fR.
-
-.SH KEYWORDS
-colormap
diff --git a/doc/GetColor.3 b/doc/GetColor.3
deleted file mode 100644
index 4b551f2..0000000
--- a/doc/GetColor.3
+++ /dev/null
@@ -1,146 +0,0 @@
-'\"
-'\" Copyright (c) 1990, 1991 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: GetColor.3,v 1.2 1998/09/14 18:22:48 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_GetColor 3 4.0 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_GetColor, Tk_GetColorByValue, Tk_NameOfColor, Tk_FreeColor \- maintain database of colors
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-XColor *
-\fBTk_GetColor\fR(\fIinterp, tkwin, nameId\fB)\fR
-.sp
-XColor *
-\fBTk_GetColorByValue\fR(\fItkwin, prefPtr\fB)\fR
-.sp
-char *
-\fBTk_NameOfColor(\fIcolorPtr\fB)\fR
-.sp
-GC
-\fBTk_GCForColor\fR(\fIcolorPtr, drawable\fR)
-.sp
-\fBTk_FreeColor(\fIcolorPtr\fB)\fR
-.SH ARGUMENTS
-.AS "Tcl_Interp" *colorPtr
-.AP Tcl_Interp *interp in
-Interpreter to use for error reporting.
-.AP Tk_Window tkwin in
-Token for window in which color will be used.
-.AP Tk_Uid nameId in
-Textual description of desired color.
-.AP XColor *prefPtr in
-Indicates red, green, and blue intensities of desired
-color.
-.AP XColor *colorPtr in
-Pointer to X color information. Must have been allocated by previous
-call to \fBTk_GetColor\fR or \fBTk_GetColorByValue\fR, except when passed
-to \fBTk_NameOfColor\fR.
-.AP Drawable drawable in
-Drawable in which the result graphics context will be used. Must have
-same screen and depth as the window for which the color was allocated.
-.BE
-
-.SH DESCRIPTION
-.PP
-The \fBTk_GetColor\fR and \fBTk_GetColorByValue\fR procedures
-locate pixel values that may be used to render particular
-colors in the window given by \fItkwin\fR. In \fBTk_GetColor\fR
-the desired color is specified with a Tk_Uid (\fInameId\fR), which
-may have any of the following forms:
-.TP 20
-\fIcolorname\fR
-Any of the valid textual names for a color defined in the
-server's color database file, such as \fBred\fR or \fBPeachPuff\fR.
-.TP 20
-\fB#\fIRGB\fR
-.TP 20
-\fB#\fIRRGGBB\fR
-.TP 20
-\fB#\fIRRRGGGBBB\fR
-.TP 20
-\fB#\fIRRRRGGGGBBBB\fR
-A numeric specification of the red, green, and blue intensities
-to use to display the color. Each \fIR\fR, \fIG\fR, or \fIB\fR
-represents a single hexadecimal digit. The four forms permit
-colors to be specified with 4-bit, 8-bit, 12-bit or 16-bit values.
-When fewer than 16 bits are provided for each color, they represent
-the most significant bits of the color. For example, #3a7 is the
-same as #3000a0007000.
-.PP
-In \fBTk_GetColorByValue\fR, the desired color is indicated with
-the \fIred\fR, \fIgreen\fR, and \fIblue\fR fields of the structure
-pointed to by \fIcolorPtr\fR.
-.PP
-If \fBTk_GetColor\fR or \fBTk_GetColorByValue\fR is successful
-in allocating the desired color, then it returns a pointer to
-an XColor structure; the structure indicates the exact intensities of
-the allocated color (which may differ slightly from those requested,
-depending on the limitations of the screen) and a pixel value
-that may be used to draw in the color.
-If the colormap for \fItkwin\fR is full, \fBTk_GetColor\fR
-and \fBTk_GetColorByValue\fR will use the closest existing color
-in the colormap.
-If \fBTk_GetColor\fR encounters an error while allocating
-the color (such as an unknown color name) then NULL is returned and
-an error message is stored in \fIinterp->result\fR;
-\fBTk_GetColorByValue\fR never returns an error.
-.PP
-\fBTk_GetColor\fR and \fBTk_GetColorByValue\fR maintain a database
-of all the colors currently in use.
-If the same \fInameId\fR is requested multiple times from
-\fBTk_GetColor\fR (e.g. by different windows), or if the
-same intensities are requested multiple times from
-\fBTk_GetColorByValue\fR, then existing pixel values will
-be re-used. Re-using an existing pixel avoids any interaction
-with the X server, which makes the allocation much more
-efficient. For this reason, you should generally use
-\fBTk_GetColor\fR or \fBTk_GetColorByValue\fR
-instead of Xlib procedures like \fBXAllocColor\fR,
-\fBXAllocNamedColor\fR, or \fBXParseColor\fR.
-.PP
-Since different calls to \fBTk_GetColor\fR or \fBTk_GetColorByValue\fR
-may return the same shared
-pixel value, callers should never change the color of a pixel
-returned by the procedures.
-If you need to change a color value dynamically, you should use
-\fBXAllocColorCells\fR to allocate the pixel value for the color.
-.PP
-The procedure \fBTk_NameOfColor\fR is roughly the inverse of
-\fBTk_GetColor\fR. If its \fIcolorPtr\fR argument was created
-by \fBTk_GetColor\fR, then the return value is the \fInameId\fR
-string that was passed to \fBTk_GetColor\fR to create the
-color. If \fIcolorPtr\fR was created by a call to \fBTk_GetColorByValue\fR,
-or by any other mechanism, then the return value is a string
-that could be passed to \fBTk_GetColor\fR to return the same
-color. Note: the string returned by \fBTk_NameOfColor\fR is
-only guaranteed to persist until the next call to \fBTk_NameOfColor\fR.
-.PP
-\fBTk_GCForColor\fR returns a graphics context whose \fBForeground\fR
-field is the pixel allocated for \fIcolorPtr\fR and whose other fields
-all have default values.
-This provides an easy way to do basic drawing with a color.
-The graphics context is cached with the color and will exist only as
-long as \fIcolorPtr\fR exists; it is freed when the last reference
-to \fIcolorPtr\fR is freed by calling \fBTk_FreeColor\fR.
-.PP
-When a pixel value returned by \fBTk_GetColor\fR or
-\fBTk_GetColorByValue\fR is no longer
-needed, \fBTk_FreeColor\fR should be called to release the color.
-There should be exactly one call to \fBTk_FreeColor\fR for
-each call to \fBTk_GetColor\fR or \fBTk_GetColorByValue\fR.
-When a pixel value is no longer in
-use anywhere (i.e. it has been freed as many times as it has been gotten)
-\fBTk_FreeColor\fR will release it to the X server and delete it from
-the database.
-
-.SH KEYWORDS
-color, intensity, pixel value
diff --git a/doc/GetCursor.3 b/doc/GetCursor.3
deleted file mode 100644
index dca27ad..0000000
--- a/doc/GetCursor.3
+++ /dev/null
@@ -1,188 +0,0 @@
-'\"
-'\" Copyright (c) 1990 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: GetCursor.3,v 1.2 1998/09/14 18:22:49 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_GetCursor 3 4.1 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_GetCursor, Tk_GetCursorFromData, Tk_NameOfCursor, Tk_FreeCursor \- maintain database of cursors
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-Tk_Cursor
-\fBTk_GetCursor(\fIinterp, tkwin, nameId\fB)\fR
-.sp
-Tk_Cursor
-\fBTk_GetCursorFromData(\fIinterp, tkwin, source, mask, width, height, xHot, yHot, fg, bg\fB)\fR
-.sp
-char *
-\fBTk_NameOfCursor(\fIdisplay, cursor\fB)\fR
-.sp
-\fBTk_FreeCursor(\fIdisplay, cursor\fB)\fR
-.SH ARGUMENTS
-.AS "unsigned long" *pixelPtr
-.AP Tcl_Interp *interp in
-Interpreter to use for error reporting.
-.AP Tk_Window tkwin in
-Token for window in which the cursor will be used.
-.AP Tk_Uid nameId in
-Description of cursor; see below for possible values.
-.AP char *source in
-Data for cursor bitmap, in standard bitmap format.
-.AP char *mask in
-Data for mask bitmap, in standard bitmap format.
-.AP "int" width in
-Width of \fIsource\fR and \fImask\fR.
-.AP "int" height in
-Height of \fIsource\fR and \fImask\fR.
-.AP "int" xHot in
-X-location of cursor hot-spot.
-.AP "int" yHot in
-Y-location of cursor hot-spot.
-.AP Tk_Uid fg in
-Textual description of foreground color for cursor.
-.AP Tk_Uid bg in
-Textual description of background color for cursor.
-.AP Display *display in
-Display for which \fIcursor\fR was allocated.
-.AP Tk_Cursor cursor in
-Opaque Tk identifier for cursor. If passed to\fBTk_FreeCursor\fR, must
-have been returned by some previous call to \fBTk_GetCursor\fR or
-\fBTk_GetCursorFromData\fR.
-.BE
-
-.SH DESCRIPTION
-.PP
-These procedures manage a collection of cursors
-being used by an application. The procedures allow cursors to be
-re-used efficiently, thereby avoiding server overhead, and also
-allow cursors to be named with character strings (actually Tk_Uids).
-.PP
-\fBTk_GetCursor\fR takes as argument a Tk_Uid describing a cursor,
-and returns an opaque Tk identifier for a cursor corresponding to the
-description.
-It re-uses an existing cursor if possible and
-creates a new one otherwise. \fINameId\fR must be a standard Tcl
-list with one of the following forms:
-.TP
-\fIname\fR\0[\fIfgColor\fR\0[\fIbgColor\fR]]
-\fIName\fR is the name of a cursor in the standard X cursor font,
-i.e., any of the names defined in \fBcursorfont.h\fR, without
-the \fBXC_\fR. Some example values are \fBX_cursor\fR, \fBhand2\fR,
-or \fBleft_ptr\fR. Appendix B of ``The X Window System''
-by Scheifler & Gettys has illustrations showing what each of these
-cursors looks like. If \fIfgColor\fR and \fIbgColor\fR are both
-specified, they give the foreground and background colors to use
-for the cursor (any of the forms acceptable to \fBTk_GetColor\fR
-may be used). If only \fIfgColor\fR is specified, then there
-will be no background color: the background will be transparent.
-If no colors are specified, then the cursor
-will use black for its foreground color and white for its background
-color.
-
-The Macintosh version of Tk also supports all of the X cursors.
-Tk on the Mac will also accept any of the standard Mac cursors
-including \fBibeam\fR, \fBcrosshair\fR, \fBwatch\fR, \fBplus\fR, and
-\fBarrow\fR. In addition, Tk will load Macintosh cursor resources of
-the types \fBcrsr\fR (color) and \fBCURS\fR (black and white) by the
-name of the of the resource. The application and all its open
-dynamic library's resource files will be searched for the named
-cursor. If there are conflicts color cursors will always be loaded
-in preference to black and white cursors.
-.TP
-\fB@\fIsourceName\0maskName\0fgColor\0bgColor\fR
-In this form, \fIsourceName\fR and \fImaskName\fR are the names of
-files describing bitmaps for the cursor's source bits and mask.
-Each file must be in standard X11 or X10 bitmap format.
-\fIFgColor\fR and \fIbgColor\fR
-indicate the colors to use for the
-cursor, in any of the forms acceptable to \fBTk_GetColor\fR. This
-form of the command will not work on Macintosh or Windows computers.
-.TP
-\fB@\fIsourceName\0fgColor\fR
-This form is similar to the one above, except that the source is
-used as mask also. This means that the cursor's background is
-transparent. This form of the command will not work on Macintosh
-or Windows computers.
-.PP
-\fBTk_GetCursorFromData\fR allows cursors to be created from
-in-memory descriptions of their source and mask bitmaps. \fISource\fR
-points to standard bitmap data for the cursor's source bits, and
-\fImask\fR points to standard bitmap data describing
-which pixels of \fIsource\fR are to be drawn and which are to be
-considered transparent. \fIWidth\fR and \fIheight\fR give the
-dimensions of the cursor, \fIxHot\fR and \fIyHot\fR indicate the
-location of the cursor's hot-spot (the point that is reported when
-an event occurs), and \fIfg\fR and \fIbg\fR describe the cursor's
-foreground and background colors textually (any of the forms
-suitable for \fBTk_GetColor\fR may be used). Typically, the
-arguments to \fBTk_GetCursorFromData\fR are created by including
-a cursor file directly into the source code for a program, as in
-the following example:
-.CS
-Tk_Cursor cursor;
-#include "source.cursor"
-#include "mask.cursor"
-cursor = Tk_GetCursorFromData(interp, tkwin, source_bits,
- mask_bits, source_width, source_height, source_x_hot,
- source_y_hot, Tk_GetUid("red"), Tk_GetUid("blue"));
-.CE
-.PP
-Under normal conditions, \fBTk_GetCursor\fR and \fBTk_GetCursorFromData\fR
-will return an identifier for the requested cursor. If an error
-occurs in creating the cursor, such as when \fInameId\fR refers
-to a non-existent file, then \fBNone\fR is returned and an error
-message will be stored in \fIinterp->result\fR.
-.PP
-\fBTk_GetCursor\fR and \fBTk_GetCursorFromData\fR maintain a
-database of all the cursors they have created. Whenever possible,
-a call to \fBTk_GetCursor\fR or \fBTk_GetCursorFromData\fR will
-return an existing cursor rather than creating a new one. This
-approach can substantially reduce server overhead, so the Tk
-procedures should generally be used in preference to Xlib procedures
-like \fBXCreateFontCursor\fR or \fBXCreatePixmapCursor\fR, which
-create a new cursor on each call.
-.PP
-The procedure \fBTk_NameOfCursor\fR is roughly the inverse of
-\fBTk_GetCursor\fR. If its \fIcursor\fR argument was created
-by \fBTk_GetCursor\fR, then the return value is the \fInameId\fR
-argument that was passed to \fBTk_GetCursor\fR to create the
-cursor. If \fIcursor\fR was created by a call to \fBTk_GetCursorFromData\fR,
-or by any other mechanism, then the return value is a hexadecimal string
-giving the X identifier for the cursor.
-Note: the string returned by \fBTk_NameOfCursor\fR is
-only guaranteed to persist until the next call to
-\fBTk_NameOfCursor\fR. Also, this call is not portable except for
-cursors returned by \fBTk_GetCursor\fR.
-.PP
-When a cursor returned by \fBTk_GetCursor\fR or \fBTk_GetCursorFromData\fR
-is no longer needed, \fBTk_FreeCursor\fR should be called to release it.
-There should be exactly one call to \fBTk_FreeCursor\fR for
-each call to \fBTk_GetCursor\fR or \fBTk_GetCursorFromData\fR.
-When a cursor is no longer in use anywhere (i.e. it has been freed as
-many times as it has been gotten) \fBTk_FreeCursor\fR will release
-it to the X server and remove it from the database.
-
-.SH BUGS
-In determining whether an existing cursor can be used to satisfy
-a new request, \fBTk_GetCursor\fR and \fBTk_GetCursorFromData\fR
-consider only the immediate values of their arguments. For
-example, when a file name is passed to \fBTk_GetCursor\fR,
-\fBTk_GetCursor\fR will assume it is safe to re-use an existing
-cursor created from the same file name: it will not check to
-see whether the file itself has changed, or whether the current
-directory has changed, thereby causing the name to refer to
-a different file. Similarly, \fBTk_GetCursorFromData\fR assumes
-that if the same \fIsource\fR pointer is used in two different calls,
-then the pointers refer to the same data; it does not check to
-see if the actual data values have changed.
-
-.SH KEYWORDS
-cursor
diff --git a/doc/GetFont.3 b/doc/GetFont.3
deleted file mode 100644
index 8971913..0000000
--- a/doc/GetFont.3
+++ /dev/null
@@ -1,74 +0,0 @@
-'\"
-'\" Copyright (c) 1990-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: GetFont.3,v 1.2 1998/09/14 18:22:49 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_GetFont 3 "" Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_GetFont, Tk_NameOfFont, Tk_FreeFont \- maintain database of fonts
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-Tk_Font
-\fBTk_GetFont(\fIinterp, tkwin, string\fB)\fR
-.sp
-char *
-\fBTk_NameOfFont(\fItkfont\fB)\fR
-.sp
-void
-\fBTk_FreeFont(\fItkfont\fB)\fR
-
-.SH ARGUMENTS
-.AS "const char" *tkfont
-.AP "Tcl_Interp" *interp in
-Interpreter to use for error reporting.
-.AP Tk_Window tkwin in
-Token for window on the display in which font will be used.
-.AP "const char" *string in
-Name or description of desired font. See documentation for the \fBfont\fR
-command for details on acceptable formats.
-.AP Tk_Font tkfont in
-Opaque font token.
-.BE
-.SH DESCRIPTION
-.PP
-\fBTk_GetFont\fR finds the font indicated by \fIstring\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, \fBTk_MeasureChars\fR, and
-\fBTk_FreeFont\fR. The token returned by \fBTk_GetFont\fR will remain
-valid until \fBTk_FreeFont\fR is called to release it. \fIString\fR can
-be either a symbolic name or a font description; see the documentation for
-the \fBfont\fR command for a description of the valid formats. If
-\fBTk_GetFont\fR is unsuccessful (because, for example, \fIstring\fR was
-not a valid font specification) then it returns \fBNULL\fR and stores an
-error message in \fIinterp->result\fR.
-.PP
-\fBTk_GetFont\fR maintains a database of all fonts it has allocated. If
-the same \fIstring\fR is requested multiple times (e.g. by different
-windows or for different purposes), then additional calls for the same
-\fIstring\fR will be handled without involving the platform-specific
-graphics server.
-.PP
-The procedure \fBTk_NameOfFont\fR is roughly the inverse of
-\fBTk_GetFont\fR. Given a \fItkfont\fR that was created by
-\fBTk_GetFont\fR, the return value is the \fIstring\fR argument that was
-passed to \fBTk_GetFont\fR to create the font. The string returned by
-\fBTk_NameOfFont\fR is only guaranteed to persist until the \fItkfont\fR
-is deleted. The caller must not modify this string.
-.PP
-When a font returned by \fBTk_GetFont\fR is no longer needed,
-\fBTk_FreeFont\fR should be called to release it. There should be
-exactly one call to \fBTk_FreeFont\fR for each call to \fBTk_GetFont\fR.
-When a font is no longer in use anywhere (i.e. it has been freed as many
-times as it has been gotten) \fBTk_FreeFont\fR will release any
-platform-specific storage and delete it from the database.
-
-.SH KEYWORDS
-font
diff --git a/doc/GetGC.3 b/doc/GetGC.3
deleted file mode 100644
index 471bdfc..0000000
--- a/doc/GetGC.3
+++ /dev/null
@@ -1,74 +0,0 @@
-'\"
-'\" Copyright (c) 1990 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: GetGC.3,v 1.2 1998/09/14 18:22:49 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_GetGC 3 "" Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_GetGC, Tk_FreeGC \- maintain database of read-only graphics contexts
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-GC
-\fBTk_GetGC\fR(\fItkwin, valueMask, valuePtr\fR)
-.sp
-\fBTk_FreeGC(\fIdisplay, gc\fR)
-.SH ARGUMENTS
-.AS "unsigned long" valueMask
-.AP Tk_Window tkwin in
-Token for window in which the graphics context will be used.
-.AP "unsigned long" valueMask in
-Mask of bits (such as \fBGCForeground\fR or \fBGCStipple\fR)
-indicating which fields of \fI*valuePtr\fR are valid.
-.AP XGCValues *valuePtr in
-Pointer to structure describing the desired values for the
-graphics context.
-.AP Display *display in
-Display for which \fIgc\fR was allocated.
-.AP GC gc in
-X identifier for graphics context that is no longer needed.
-Must have been allocated by \fBTk_GetGC\fR.
-.BE
-
-.SH DESCRIPTION
-.PP
-\fBTk_GetGC\fR and \fBTk_FreeGC\fR manage a collection of graphics contexts
-being used by an application. The procedures allow graphics contexts to be
-shared, thereby avoiding the server overhead that would be incurred
-if a separate GC were created for each use. \fBTk_GetGC\fR takes arguments
-describing the desired graphics context and returns an X identifier
-for a GC that fits the description. The graphics context that is returned
-will have default values in all of the fields not specified explicitly
-by \fIvalueMask\fR and \fIvaluePtr\fR.
-.PP
-\fBTk_GetGC\fR maintains a
-database of all the graphics contexts it has created. Whenever possible,
-a call to \fBTk_GetGC\fR will
-return an existing graphics context rather than creating a new one. This
-approach can substantially reduce server overhead, so \fBTk_GetGC\fR
-should generally be used in preference to the Xlib procedure
-\fBXCreateGC\fR, which creates a new graphics context on each call.
-.PP
-Since the return values of \fBTk_GetGC\fR
-are shared, callers should never modify the graphics contexts
-returned by \fBTk_GetGC\fR.
-If a graphics context must be modified dynamically, then it should be
-created by calling \fBXCreateGC\fR instead of \fBTk_GetGC\fR.
-.PP
-When a graphics context
-is no longer needed, \fBTk_FreeGC\fR should be called to release it.
-There should be exactly one call to \fBTk_FreeGC\fR for
-each call to \fBTk_GetGC\fR.
-When a graphics context is no longer in use anywhere (i.e. it has
-been freed as many times as it has been gotten) \fBTk_FreeGC\fR
-will release it to the X server and delete it from the database.
-
-.SH KEYWORDS
-graphics context
diff --git a/doc/GetImage.3 b/doc/GetImage.3
deleted file mode 100644
index 53d31d5..0000000
--- a/doc/GetImage.3
+++ /dev/null
@@ -1,135 +0,0 @@
-'\"
-'\" Copyright (c) 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: GetImage.3,v 1.2 1998/09/14 18:22:49 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_GetImage 3 4.0 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_GetImage, Tk_RedrawImage, Tk_SizeOfImage, Tk_FreeImage \- use an image in a widget
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-Tk_Image
-\fBTk_GetImage\fR(\fIinterp, tkwin, name, changeProc, clientData\fR)
-.sp
-\fBTk_RedrawImage\fR(\fIimage, imageX, imageY, width, height, drawable, drawableX, drawableY\fR)
-.sp
-\fBTk_SizeOfImage\fR(\fIimage, widthPtr, heightPtr\fR)
-.sp
-\fBTk_FreeImage\fR(\fIimage\fR)
-.SH ARGUMENTS
-.AS Tk_ImageChangedProc *changeProc
-.AP Tcl_Interp *interp in
-Place to leave error message.
-.AP Tk_Window tkwin in
-Window in which image will be used.
-.AP char *name in
-Name of image.
-.AP Tk_ImageChangedProc *changeProc in
-Procedure for Tk to invoke whenever image content or size changes.
-.AP ClientData clientData in
-One-word value for Tk to pass to \fIchangeProc\fR.
-.AP Tk_Image image in
-Token for image instance; must have been returned by a previous
-call to \fBTk_GetImage\fR.
-.AP int imageX in
-X-coordinate of upper-left corner of region of image to redisplay
-(measured in pixels from the image's upper-left corner).
-.AP int imageY in
-Y-coordinate of upper-left corner of region of image to redisplay
-(measured in pixels from the image's upper-left corner).
-.AP "int" width (in)
-Width of region of image to redisplay.
-.AP "int" height (in)
-Height of region of image to redisplay.
-.AP Drawable drawable in
-Where to display image. Must either be window specified to
-\fBTk_GetImage\fR or a pixmap compatible with that window.
-.AP int drawableX in
-Where to display image in \fIdrawable\fR: this is the x-coordinate
-in \fIdrawable\fR where x-coordinate \fIimageX\fR of the image
-should be displayed.
-.AP int drawableY in
-Where to display image in \fIdrawable\fR: this is the y-coordinate
-in \fIdrawable\fR where y-coordinate \fIimageY\fR of the image
-should be displayed.
-.AP "int" widthPtr out
-Store width of \fIimage\fR (in pixels) here.
-.AP "int" heightPtr out
-Store height of \fIimage\fR (in pixels) here.
-.BE
-
-.SH DESCRIPTION
-.PP
-These procedures are invoked by widgets that wish to display images.
-\fBTk_GetImage\fR is invoked by a widget when it first decides to
-display an image.
-\fIname\fR gives the name of the desired image and \fItkwin\fR
-identifies the window where the image will be displayed.
-\fBTk_GetImage\fR looks up the image in the table of existing
-images and returns a token for a new instance of the image.
-If the image doesn't exist then \fBTk_GetImage\fR returns NULL
-and leaves an error message in \fIinterp->result\fR.
-.PP
-When a widget wishes to actually display an image it must
-call \fBTk_RedrawWidget\fR, identifying the image (\fIimage\fR),
-a region within the image to redisplay (\fIimageX\fR, \fIimageY\fR,
-\fIwidth\fR, and \fIheight\fR), and a place to display the
-image (\fIdrawable\fR, \fIdrawableX\fR, and \fIdrawableY\fR).
-Tk will then invoke the appropriate image manager, which will
-display the requested portion of the image before returning.
-.PP
-A widget can find out the dimensions of an image by calling
-\fBTk_SizeOfImage\fR: the width and height will be stored
-in the locations given by \fIwidthPtr\fR and \fIheightPtr\fR,
-respectively.
-.PP
-When a widget is finished with an image (e.g., the widget is
-being deleted or it is going to use a different image instead
-of the current one), it must call \fBTk_FreeImage\fR to
-release the image instance.
-The widget should never again use the image token after passing
-it to \fBTk_FreeImage\fR.
-There must be exactly one call to \fBTk_FreeImage\fR for each
-call to \fBTk_GetImage\fR.
-.PP
-If the contents or size of an image changes, then any widgets
-using the image will need to find out about the changes so that
-they can redisplay themselves.
-The \fIchangeProc\fR and \fIclientData\fR arguments to
-\fBTk_GetImage\fR are used for this purpose.
-\fIchangeProc\fR will be called by Tk whenever a change occurs
-in the image; it must match the following prototype:
-.CS
-typedef void Tk_ImageChangedProc(
- ClientData \fIclientData\fR,
- int \fIx\fR,
- int \fIy\fR,
- int \fIwidth\fR,
- int \fIheight\fR,
- int \fIimageWidth\fR,
- int \fIimageHeight\fR);
-.CE
-The \fIclientData\fR argument to \fIchangeProc\fR is the same as the
-\fIclientData\fR argument to \fBTk_GetImage\fR.
-It is usually a pointer to the widget record for the widget or
-some other data structure managed by the widget.
-The arguments \fIx\fR, \fIy\fR, \fIwidth\fR, and \fIheight\fR
-identify a region within the image that must be redisplayed;
-they are specified in pixels measured from the upper-left
-corner of the image.
-The arguments \fIimageWidth\fR and \fIimageHeight\fR give
-the image's (new) size.
-
-.SH "SEE ALSO"
-Tk_CreateImageType
-
-.SH KEYWORDS
-images, redisplay
diff --git a/doc/GetJoinStl.3 b/doc/GetJoinStl.3
deleted file mode 100644
index 757adde..0000000
--- a/doc/GetJoinStl.3
+++ /dev/null
@@ -1,62 +0,0 @@
-'\"
-'\" Copyright (c) 1990 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: GetJoinStl.3,v 1.2 1998/09/14 18:22:49 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_GetJoinStyle 3 "" Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_GetJoinStyle, Tk_NameOfJoinStyle \- translate between strings and join styles
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-int
-\fBTk_GetJoinStyle(\fIinterp, string, joinPtr\fB)\fR
-.sp
-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
-String containing name of join style: one of ``bevel'', ``miter'',
-or ``round''.
-.AP int *joinPtr out
-Pointer to location in which to store X join style corresponding to
-\fIstring\fR.
-.AP int join in
-Join style: one of \fBJoinBevel\fR, \fBJoinMiter\fR, \fBJoinRound\fR.
-.BE
-
-.SH DESCRIPTION
-.PP
-\fBTk_GetJoinStyle\fR places in \fI*joinPtr\fR the X join style
-corresponding to \fIstring\fR, which will be one of
-\fBJoinBevel\fR, \fBJoinMiter\fR, or \fBJoinRound\fR.
-Join styles are typically used in X graphics contexts to indicate
-how adjacent line segments should be joined together.
-See the X documentation for information on what each style
-implies.
-.PP
-Under normal circumstances the return value is \fBTCL_OK\fR and
-\fIinterp\fR is unused.
-If \fIstring\fR doesn't contain a valid join style
-or an abbreviation of one of these names, then an error message is
-stored in \fIinterp->result\fR, \fBTCL_ERROR\fR is returned, and
-\fI*joinPtr\fR is unmodified.
-.PP
-\fBTk_NameOfJoinStyle\fR is the logical inverse of \fBTk_GetJoinStyle\fR.
-Given a join style such as \fBJoinBevel\fR it returns a
-statically-allocated string corresponding to \fIjoin\fR.
-If \fIjoin\fR isn't a legal join style, then
-``unknown join style'' is returned.
-
-.SH KEYWORDS
-bevel, join style, miter, round
diff --git a/doc/GetJustify.3 b/doc/GetJustify.3
deleted file mode 100644
index 6b12be1..0000000
--- a/doc/GetJustify.3
+++ /dev/null
@@ -1,69 +0,0 @@
-'\"
-'\" 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: GetJustify.3,v 1.2 1998/09/14 18:22:49 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_GetJustify 3 4.0 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_GetJustify, Tk_NameOfJustify \- translate between strings and justification styles
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-Tk_Justify
-\fBTk_GetJustify(\fIinterp, string, justifyPtr\fB)\fR
-.sp
-char *
-\fBTk_NameOfJustify(\fIjustify\fB)\fR
-.SH ARGUMENTS
-.AS "Tk_Justify" *justifyPtr
-.AP Tcl_Interp *interp in
-Interpreter to use for error reporting.
-.AP char *string in
-String containing name of justification style (``left'', ``right'', or
-``center'').
-.AP int *justifyPtr out
-Pointer to location in which to store justify value corresponding to
-\fIstring\fR.
-.AP Tk_Justify justify in
-Justification style (one of the values listed below).
-.BE
-
-.SH DESCRIPTION
-.PP
-\fBTk_GetJustify\fR places in \fI*justifyPtr\fR the justify value
-corresponding to \fIstring\fR. This value will be one of the following:
-.TP
-\fBTK_JUSTIFY_LEFT\fR
-Means that the text on each line should start at the left edge of
-the line; as a result, the right edges of lines may be ragged.
-.TP
-\fBTK_JUSTIFY_RIGHT\fR
-Means that the text on each line should end at the right edge of
-the line; as a result, the left edges of lines may be ragged.
-.TP
-\fBTK_JUSTIFY_CENTER\fR
-Means that the text on each line should be centered; as a result,
-both the left and right edges of lines may be ragged.
-.PP
-Under normal circumstances the return value is \fBTCL_OK\fR and
-\fIinterp\fR is unused.
-If \fIstring\fR doesn't contain a valid justification style
-or an abbreviation of one of these names, then an error message is
-stored in \fIinterp->result\fR, \fBTCL_ERROR\fR is returned, and
-\fI*justifyPtr\fR is unmodified.
-.PP
-\fBTk_NameOfJustify\fR is the logical inverse of \fBTk_GetJustify\fR.
-Given a justify value it returns a statically-allocated string
-corresponding to \fIjustify\fR.
-If \fIjustify\fR isn't a legal justify value, then
-``unknown justification style'' is returned.
-
-.SH KEYWORDS
-center, fill, justification, string
diff --git a/doc/GetOption.3 b/doc/GetOption.3
deleted file mode 100644
index 54d05fc..0000000
--- a/doc/GetOption.3
+++ /dev/null
@@ -1,46 +0,0 @@
-'\"
-'\" Copyright (c) 1990 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: GetOption.3,v 1.2 1998/09/14 18:22:50 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_GetOption 3 "" Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_GetOption \- retrieve an option from the option database
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-Tk_Uid
-\fBTk_GetOption\fR(\fItkwin, name, class\fR)
-.SH ARGUMENTS
-.AS Tk_Window *class
-.AP Tk_Window tkwin in
-Token for window.
-.AP char *name in
-Name of desired option.
-.AP char *class in
-Class of desired option. Null means there is no class for
-this option; do lookup based on name only.
-.BE
-
-.SH DESCRIPTION
-.PP
-This procedure is invoked to retrieve an option from the database
-associated with \fItkwin\fR's main window. If there is an option
-for \fItkwin\fR that matches the given \fIname\fR or \fIclass\fR,
-then it is returned in the form of a Tk_Uid. If multiple options
-match \fIname\fR and \fIclass\fR, then the highest-priority one
-is returned. If no option matches, then NULL is returned.
-.PP
-\fBTk_GetOption\fR caches options related to \fItkwin\fR so that
-successive calls for the same \fItkwin\fR will execute much more
-quickly than successive calls for different windows.
-
-.SH KEYWORDS
-class, name, option, retrieve
diff --git a/doc/GetPixels.3 b/doc/GetPixels.3
deleted file mode 100644
index 6c271a7..0000000
--- a/doc/GetPixels.3
+++ /dev/null
@@ -1,76 +0,0 @@
-'\"
-'\" Copyright (c) 1990 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: GetPixels.3,v 1.2 1998/09/14 18:22:50 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_GetPixels 3 "" Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_GetPixels, Tk_GetScreenMM \- translate between strings and screen units
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-int
-\fBTk_GetPixels(\fIinterp, tkwin, string, intPtr\fB)\fR
-.sp
-int
-\fBTk_GetScreenMM(\fIinterp, tkwin, string, doublePtr\fB)\fR
-.SH ARGUMENTS
-.AS "Tcl_Interp" *joinPtr
-.AP Tcl_Interp *interp in
-Interpreter to use for error reporting.
-.AP Tk_Window tkwin in
-Window whose screen geometry determines the conversion between absolute
-units and pixels.
-.AP char *string in
-String that specifies a distance on the screen.
-.AP int *intPtr out
-Pointer to location in which to store converted distance in pixels.
-.AP double *doublePtr out
-Pointer to location in which to store converted distance in millimeters.
-.BE
-
-.SH DESCRIPTION
-.PP
-These two procedures take as argument a specification of distance on
-the screen (\fIstring\fR) and compute the corresponding distance
-either in integer pixels or floating-point millimeters.
-In either case, \fIstring\fR specifies a screen distance as a
-floating-point number followed by one of the following characters
-that indicates units:
-.TP
-<none>
-The number specifies a distance in pixels.
-.TP
-\fBc\fR
-The number specifies a distance in centimeters on the screen.
-.TP
-\fBi\fR
-The number specifies a distance in inches on the screen.
-.TP
-\fBm\fR
-The number specifies a distance in millimeters on the screen.
-.TP
-\fBp\fR
-The number specifies a distance in printer's points (1/72 inch)
-on the screen.
-.PP
-\fBTk_GetPixels\fR converts \fIstring\fR to the nearest even
-number of pixels and stores that value at \fI*intPtr\fR.
-\fBTk_GetScreenMM\fR converts \fIstring\fR to millimeters and
-stores the double-precision floating-point result at \fI*doublePtr\fR.
-.PP
-Both procedures return \fBTCL_OK\fR under normal circumstances.
-If an error occurs (e.g. \fIstring\fR contains a number followed
-by a character that isn't one of the ones above) then
-\fBTCL_ERROR\fR is returned and an error message is left
-in \fIinterp->result\fR.
-
-.SH KEYWORDS
-centimeters, convert, inches, millimeters, pixels, points, screen units
diff --git a/doc/GetPixmap.3 b/doc/GetPixmap.3
deleted file mode 100644
index a8cb5e1..0000000
--- a/doc/GetPixmap.3
+++ /dev/null
@@ -1,56 +0,0 @@
-'\"
-'\" Copyright (c) 1990 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: GetPixmap.3,v 1.2 1998/09/14 18:22:50 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_GetPixmap 3 4.0 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_GetPixmap, Tk_FreePixmap \- allocate and free pixmaps
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-Pixmap
-\fBTk_GetPixmap(\fIdisplay, d, width, height, depth\fB)\fR
-.sp
-\fBTk_FreePixmap(\fIdisplay, pixmap\fB)\fR
-.SH ARGUMENTS
-.AS "Drawable" *pixelPtr
-.AP Display *display in
-X display for the pixmap.
-.AP Drawable d in
-Pixmap or window where the new pixmap will be used for drawing.
-.AP "int" width in
-Width of pixmap.
-.AP "int" height in
-Height of pixmap.
-.AP "int" depth in
-Number of bits per pixel in pixmap.
-.AP Pixmap pixmap in
-Pixmap to destroy.
-.BE
-
-.SH DESCRIPTION
-.PP
-These procedures are identical to the Xlib procedures \fBXCreatePixmap\fR
-and \fBXFreePixmap\fR, except that they have extra code to manage X
-resource identifiers so that identifiers for deleted pixmaps can be
-reused in the future.
-It is important for Tk applications to use these procedures rather
-than \fBXCreatePixmap\fR and \fBXFreePixmap\fR; otherwise long-running
-applications may run out of resource identifiers.
-.PP
-\fBTk_GetPixmap\fR creates a pixmap suitable for drawing in \fId\fR,
-with dimensions given by \fIwidth\fR, \fIheight\fR, and \fIdepth\fR,
-and returns its identifier.
-\fBTk_FreePixmap\fR destroys the pixmap given by \fIpixmap\fR and makes
-its resource identifier available for reuse.
-
-.SH KEYWORDS
-pixmap, resource identifier
diff --git a/doc/GetRelief.3 b/doc/GetRelief.3
deleted file mode 100644
index 20d2933..0000000
--- a/doc/GetRelief.3
+++ /dev/null
@@ -1,59 +0,0 @@
-'\"
-'\" Copyright (c) 1990 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: GetRelief.3,v 1.2 1998/09/14 18:22:51 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_GetRelief 3 "" Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_GetRelief, Tk_NameOfRelief \- translate between strings and relief values
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-int
-\fBTk_GetRelief(\fIinterp, name, reliefPtr\fB)\fR
-.sp
-char *
-\fBTk_NameOfRelief(\fIrelief\fB)\fR
-.SH ARGUMENTS
-.AS "Tcl_Interp" *reliefPtr
-.AP Tcl_Interp *interp in
-Interpreter to use for error reporting.
-.AP char *name in
-String containing relief name (one of ``flat'', ``groove'',
-``raised'', ``ridge'', ``solid'', or ``sunken'').
-.AP int *reliefPtr out
-Pointer to location in which to store relief value corresponding to
-\fIname\fR.
-.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).
-.BE
-
-.SH DESCRIPTION
-.PP
-\fBTk_GetRelief\fR places in \fI*reliefPtr\fR the relief value
-corresponding to \fIname\fR. This value will be one of
-TK_RELIEF_FLAT, TK_RELIEF_RAISED, TK_RELIEF_SUNKEN,
-TK_RELIEF_GROOVE, TK_RELIEF_SOLID, or TK_RELIEF_RIDGE.
-Under normal circumstances the return value is TCL_OK and
-\fIinterp\fR is unused.
-If \fIname\fR doesn't contain one of the valid relief names
-or an abbreviation of one of them, then an error message
-is stored in \fIinterp->result\fR,
-TCL_ERROR is returned, and \fI*reliefPtr\fR is unmodified.
-.PP
-\fBTk_NameOfRelief\fR is the logical inverse of \fBTk_GetRelief\fR.
-Given a relief value it returns the corresponding string (``flat'',
-``raised'', ``sunken'', ``groove'', ``solid'', or ``ridge'').
-If \fIrelief\fR isn't a legal relief value, then ``unknown relief''
-is returned.
-
-.SH KEYWORDS
-name, relief, string
diff --git a/doc/GetRootCrd.3 b/doc/GetRootCrd.3
deleted file mode 100644
index 697d339..0000000
--- a/doc/GetRootCrd.3
+++ /dev/null
@@ -1,43 +0,0 @@
-'\"
-'\" Copyright (c) 1990 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: GetRootCrd.3,v 1.2 1998/09/14 18:22:51 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_GetRootCoords 3 "" Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_GetRootCoords \- Compute root-window coordinates of window
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-\fBTk_GetRootCoords\fR(\fItkwin, xPtr, yPtr\fR)
-.SH ARGUMENTS
-.AS Tk_Window tkwin
-.AP Tk_Window tkwin in
-Token for window.
-.AP int *xPtr out
-Pointer to location in which to store root-window x-coordinate
-corresponding to left edge of \fItkwin\fR's border.
-.AP int *yPtr out
-Pointer to location in which to store root-window y-coordinate
-corresponding to top edge of \fItkwin\fR's border.
-.BE
-
-.SH DESCRIPTION
-.PP
-This procedure scans through the structural information maintained
-by Tk to compute the root-window coordinates corresponding to
-the upper-left corner of \fItkwin\fR's border. If \fItkwin\fR has
-no border, then \fBTk_GetRootCoords\fR returns the root-window
-coordinates corresponding to location (0,0) in \fItkwin\fR.
-\fBTk_GetRootCoords\fR is relatively efficient, since it doesn't have to
-communicate with the X server.
-
-.SH KEYWORDS
-coordinates, root window
diff --git a/doc/GetScroll.3 b/doc/GetScroll.3
deleted file mode 100644
index a07e0d0..0000000
--- a/doc/GetScroll.3
+++ /dev/null
@@ -1,65 +0,0 @@
-'\"
-'\" Copyright (c) 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: GetScroll.3,v 1.2 1998/09/14 18:22:51 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_GetScrollInfo 3 4.0 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_GetScrollInfo \- parse arguments for scrolling commands
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-int
-\fBTk_GetScrollInfo(\fIinterp, argc, argv, dblPtr, intPtr\fB)\fR
-.SH ARGUMENTS
-.AS "Tcl_Interp" *dblPtr
-.AP Tcl_Interp *interp in
-Interpreter to use for error reporting.
-.AP int argc in
-Number of strings in \fIargv\fR array.
-.AP 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. This procedure parses
-arguments starting with \fIargv\fR[2].
-.AP double *dblPtr out
-Filled in with fraction from \fBmoveto\fR option, if any.
-.AP int *intPtr out
-Filled in with line or page count from \fBscroll\fR option, if any.
-The value may be negative.
-.BE
-
-.SH DESCRIPTION
-.PP
-\fBTk_GetScrollInfo\fR parses the arguments expected by widget
-scrolling commands such as \fBxview\fR and \fByview\fR.
-It receives the entire list of words that make up a widget command
-and parses the words starting with \fIargv\fR[2].
-The words starting with \fIargv\fR[2] must have one of the following forms:
-.CS
-\fBmoveto \fIfraction\fR
-\fBscroll \fInumber\fB units\fR
-\fBscroll \fInumber\fB pages\fR
-.CE
-.LP
-Any of the \fBmoveto\fR, \fBscroll\fR, \fBunits\fR, and \fBpages\fR
-keywords may be abbreviated.
-If \fIargv\fR has the \fBmoveto\fR form, \fBTK_SCROLL_MOVETO\fR
-is returned as result and \fI*dblPtr\fR is filled in with the
-\fIfraction\fR argument to the command, which must be a proper real
-value.
-If \fIargv\fR has the \fBscroll\fR form, \fBTK_SCROLL_UNITS\fR
-or \fBTK_SCROLL_PAGES\fR is returned and \fI*intPtr\fR is filled
-in with the \fInumber\fR value, which must be a proper integer.
-If an error occurs in parsing the arguments, \fBTK_SCROLL_ERROR\fR
-is returned and an error message is left in \fIinterp->result\fR.
-
-.SH KEYWORDS
-parse, scrollbar, scrolling command, xview, yview
diff --git a/doc/GetSelect.3 b/doc/GetSelect.3
deleted file mode 100644
index d9aa308..0000000
--- a/doc/GetSelect.3
+++ /dev/null
@@ -1,79 +0,0 @@
-'\"
-'\" 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: GetSelect.3,v 1.2 1998/09/14 18:22:51 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_GetSelection 3 4.0 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_GetSelection \- retrieve the contents of a selection
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-int
-\fBTk_GetSelection\fR(\fIinterp, tkwin, selection, target, proc, clientData\fR)
-.SH ARGUMENTS
-.AS Tk_GetSelProc clientData
-.AP Tcl_Interp *interp in
-Interpreter to use for reporting errors.
-.AP Tk_Window tkwin in
-Window on whose behalf to retrieve the selection (determines
-display from which to retrieve).
-.AP Atom selection in
-The name of the selection to be retrieved.
-.AP Atom target in
-Form in which to retrieve selection.
-.AP Tk_GetSelProc *proc in
-Procedure to invoke to process pieces of the selection as they
-are retrieved.
-.AP ClientData clientData in
-Arbitrary one-word value to pass to \fIproc\fR.
-.BE
-
-.SH DESCRIPTION
-.PP
-\fBTk_GetSelection\fR retrieves the selection specified by the atom
-\fIselection\fR in the format specified by \fItarget\fR. The
-selection may actually be retrieved in several pieces; as each piece
-is retrieved, \fIproc\fR is called to process the piece. \fIProc\fR
-should have arguments and result that match the type
-\fBTk_GetSelProc\fR:
-.CS
-typedef int Tk_GetSelProc(
- ClientData \fIclientData\fR,
- Tcl_Interp *\fIinterp\fR,
- char *\fIportion\fR);
-.CE
-The \fIclientData\fR and \fIinterp\fR parameters to \fIproc\fR
-will be copies of the corresponding arguments to
-\fBTk_GetSelection\fR. \fIPortion\fR will be a pointer to
-a string containing part or all of the selection. For large
-selections, \fIproc\fR will be called several times with successive
-portions of the selection. The X Inter-Client Communication
-Conventions Manual allows a selection to be returned in formats
-other than strings, e.g. as an array of atoms or integers. If
-this happens, Tk converts the selection back into a string
-before calling \fIproc\fR. If a selection is returned as an
-array of atoms, Tk converts it to a string containing the atom names
-separated by white space. For any other format besides string,
-Tk converts a selection to a string containing hexadecimal
-values separated by white space.
-.PP
-\fBTk_GetSelection\fR returns to its caller when the selection has
-been completely retrieved and processed by \fIproc\fR, or when a
-fatal error has occurred (e.g. the selection owner didn't respond
-promptly). \fBTk_GetSelection\fR normally returns TCL_OK; if
-an error occurs, it returns TCL_ERROR and leaves an error message
-in \fIinterp->result\fR. \fIProc\fR should also return either
-TCL_OK or TCL_ERROR. If \fIproc\fR encounters an error in dealing with the
-selection, it should leave an error message in \fIinterp->result\fR
-and return TCL_ERROR; this will abort the selection retrieval.
-
-.SH KEYWORDS
-format, get, selection retrieval
diff --git a/doc/GetUid.3 b/doc/GetUid.3
deleted file mode 100644
index b3b0be5..0000000
--- a/doc/GetUid.3
+++ /dev/null
@@ -1,50 +0,0 @@
-'\"
-'\" Copyright (c) 1990 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: GetUid.3,v 1.2 1998/09/14 18:22:51 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_GetUid 3 "" Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_GetUid, Tk_Uid \- convert from string to unique identifier
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-\fB#typedef char *Tk_Uid\fR
-.sp
-Tk_Uid
-\fBTk_GetUid\fR(\fIstring\fR)
-.SH ARGUMENTS
-.AP char *string in
-String for which the corresponding unique identifier is
-desired.
-.BE
-
-.SH DESCRIPTION
-.PP
-\fBTk_GetUid\fR returns the unique identifier corresponding
-to \fIstring\fR.
-Unique identifiers are similar to atoms in Lisp, and are used
-in Tk to speed up comparisons and
-searches. A unique identifier (type Tk_Uid) is a string pointer
-and may be used anywhere that a variable of type ``char *''
-could be used. However, there is guaranteed to be exactly
-one unique identifier for any given string value. If \fBTk_GetUid\fR
-is called twice, once with string \fIa\fR and once with string
-\fIb\fR, and if \fIa\fR and \fIb\fR have the same string value
-(strcmp(a, b) == 0), then \fBTk_GetUid\fR will return exactly
-the same Tk_Uid value for each call (Tk_GetUid(a) == Tk_GetUid(b)).
-This means that variables of type
-Tk_Uid may be compared directly (x == y) without having to call
-\fBstrcmp\fR.
-In addition, the return value from \fBTk_GetUid\fR will have the
-same string value as its argument (strcmp(Tk_GetUid(a), a) == 0).
-
-.SH KEYWORDS
-atom, unique identifier
diff --git a/doc/GetVRoot.3 b/doc/GetVRoot.3
deleted file mode 100644
index ecbe444..0000000
--- a/doc/GetVRoot.3
+++ /dev/null
@@ -1,49 +0,0 @@
-'\"
-'\" Copyright (c) 1990 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: GetVRoot.3,v 1.2 1998/09/14 18:22:51 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_GetVRootGeometry 3 4.0 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_GetVRootGeometry \- Get location and size of virtual root for window
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-\fBTk_GetVRootGeometry(\fItkwin, xPtr, yPtr, widthPtr, heightPtr\fB)\fR
-.SH ARGUMENTS
-.AS Tk_Window heightPtr
-.AP Tk_Window tkwin in
-Token for window whose virtual root is to be queried.
-.AP int xPtr out
-Points to word in which to store x-offset of virtual root.
-.AP int yPtr out
-Points to word in which to store y-offset of virtual root.
-.AP "int" widthPtr out
-Points to word in which to store width of virtual root.
-.AP "int" heightPtr out
-Points to word in which to store height of virtual root.
-.BE
-
-.SH DESCRIPTION
-.PP
-\fBTkGetVRootGeometry\fR returns geometry information about the virtual
-root window associated with \fItkwin\fR. The ``associated'' virtual
-root is the one in which \fItkwin\fR's nearest top-level ancestor (or
-\fItkwin\fR itself if it is a top-level window) has
-been reparented by the window manager. This window is identified by
-a \fB__SWM_ROOT\fR or \fB__WM_ROOT\fR property placed on the top-level
-window by the window manager.
-If \fItkwin\fR is not associated with a virtual root (e.g.
-because the window manager doesn't use virtual roots) then *\fIxPtr\fR and
-*\fIyPtr\fR will be set to 0 and *\fIwidthPtr\fR and *\fIheightPtr\fR
-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/doc/GetVisual.3 b/doc/GetVisual.3
deleted file mode 100644
index 8bb5068..0000000
--- a/doc/GetVisual.3
+++ /dev/null
@@ -1,98 +0,0 @@
-'\"
-'\" Copyright (c) 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: GetVisual.3,v 1.2 1998/09/14 18:22:51 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_GetVisual 3 4.0 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_GetVisual \- translate from string to visual
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-Visual *
-\fBTk_GetVisual(\fIinterp, tkwin, string, depthPtr, colormapPtr\fB)\fR
-.SH ARGUMENTS
-.AS "Tcl_Interp" *colormapPtr
-.AP Tcl_Interp *interp in
-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
-String that identifies the desired visual. See below for
-valid formats.
-.AP int *depthPtr out
-Depth of returned visual gets stored here.
-.AP Colormap *colormapPtr out
-If non-NULL then a suitable colormap for visual is found and its
-identifier is stored here.
-.BE
-
-.SH DESCRIPTION
-.PP
-\fBTk_GetVisual\fR takes a string description of a visual and
-finds a suitable X Visual for use in \fItkwin\fR, if there is one.
-It returns a pointer to the X Visual structure for the visual
-and stores the number of bits per pixel for it at \fI*depthPtr\fR.
-If \fIstring\fR is unrecognizable or if no suitable visual could
-be found, then NULL is returned and \fBTk_GetVisual\fR leaves
-an error message in \fIinterp->result\fR.
-If \fIcolormap\fR is non-NULL then \fBTk_GetVisual\fR
-also locates an appropriate colormap for use with the result visual
-and stores its X identifier at \fI*colormapPtr\fR.
-.PP
-The \fIstring\fR argument specifies the desired visual in one
-of the following ways:
-.TP 15
-\fIclass depth\fR
-The string consists of a class name followed by an integer depth,
-with any amount of white space (including none) in between.
-\fIclass\fR selects what sort of visual is desired and must be one of
-\fBdirectcolor\fR, \fBgrayscale\fR, \fBgreyscale\fR, \fBpseudocolor\fR,
-\fBstaticcolor\fR, \fBstaticgray\fR, \fBstaticgrey\fR, or
-\fBtruecolor\fR, or a unique abbreviation.
-\fIdepth\fR specifies how many bits per pixel are needed for the
-visual.
-If possible, \fBTk_GetVisual\fR will return a visual with this depth;
-if there is no visual of the desired depth then \fBTk_GetVisual\fR
-looks first for a visual with greater depth, then one with less
-depth.
-.TP 15
-\fBdefault\fR
-Use the default visual for \fItkwin\fR's screen.
-.TP 15
-\fIpathName\fR
-Use the visual for the window given by \fIpathName\fR.
-\fIpathName\fR must be the name of a window on the same screen
-as \fItkwin\fR.
-.TP 15
-\fInumber\fR
-Use the visual whose X identifier is \fInumber\fR.
-.TP 15
-\fBbest\fR ?\fIdepth\fR?
-Choose the ``best possible'' visual, using the following rules, in
-decreasing order of priority:
-(a) a visual that has exactly the desired depth is best, followed
-by a visual with greater depth than requested (but as little extra
-as possible), followed by a visual with less depth than requested
-(but as great a depth as possible);
-(b) if no \fIdepth\fR is specified, then the deepest available visual
-is chosen;
-(c) \fBpseudocolor\fR is better than \fBtruecolor\fR or \fBdirectcolor\fR,
-which are better than \fBstaticcolor\fR, which is better than
-\fBstaticgray\fR or \fBgrayscale\fR;
-(d) the default visual for the screen is better than any other visual.
-
-.SH CREDITS
-.PP
-The idea for \fBTk_GetVisual\fR, and the first implementation, came
-from Paul Mackerras.
-
-.SH KEYWORDS
-colormap, screen, visual
diff --git a/doc/HandleEvent.3 b/doc/HandleEvent.3
deleted file mode 100644
index 6117aef..0000000
--- a/doc/HandleEvent.3
+++ /dev/null
@@ -1,49 +0,0 @@
-'\"
-'\" Copyright (c) 1990-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: HandleEvent.3,v 1.2 1998/09/14 18:22:52 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_HandleEvent 3 "" Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_HandleEvent \- invoke event handlers for window system events
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-\fBTk_HandleEvent\fR(\fIeventPtr\fR)
-.SH ARGUMENTS
-.AS XEvent *eventPtr
-.AP XEvent *eventPtr in
-Pointer to X event to dispatch to relevant handler(s).
-.BE
-
-.SH DESCRIPTION
-.PP
-\fBTk_HandleEvent\fR is a lower-level procedure that deals with window
-events. It is called by \fBTk_ServiceEvent\fR (and indirectly by
-\fBTk_DoOneEvent\fR), and in a few other cases within Tk.
-It makes callbacks to any window event
-handlers (created by calls to \fBTk_CreateEventHandler\fR)
-that match \fIeventPtr\fR and then returns. In some cases
-it may be useful for an application to bypass the Tk event
-queue and call \fBTk_HandleEvent\fR directly instead of
-calling \fBTk_QueueEvent\fR followed by
-\fBTk_ServiceEvent\fR.
-.PP
-This procedure may be invoked recursively. For example,
-it is possible to invoke \fBTk_HandleEvent\fR recursively
-from a handler called by \fBTk_HandleEvent\fR. This sort
-of operation is useful in some modal situations, such
-as when a
-notifier has been popped up and an application wishes to
-wait for the user to click a button in the notifier before
-doing anything else.
-
-.SH KEYWORDS
-callback, event, handler, window
diff --git a/doc/IdToWindow.3 b/doc/IdToWindow.3
deleted file mode 100644
index 61146c8..0000000
--- a/doc/IdToWindow.3
+++ /dev/null
@@ -1,36 +0,0 @@
-'\"
-'\" Copyright (c) 1995-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: IdToWindow.3,v 1.2 1998/09/14 18:22:52 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_IdToWindow 3 4.0 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_IdToWindow \- Find Tk's window information for an X window
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-Tk_Window
-\fBTk_IdToWindow\fR(\fIdisplay, window\fR)
-.SH ARGUMENTS
-.AS Tk_Window display
-.AP Display *display in
-X display containing the window.
-.AP Window window in
-X id for window.
-.BE
-
-.SH DESCRIPTION
-.PP
-Given an X window identifier and the X display it corresponds to,
-this procedure returns the corresponding Tk_Window handle.
-If there is no Tk_Window corresponding to \fIwindow\fR then
-NULL is returned.
-
-.SH KEYWORDS
-X window id
diff --git a/doc/ImgChanged.3 b/doc/ImgChanged.3
deleted file mode 100644
index bc4f9a4..0000000
--- a/doc/ImgChanged.3
+++ /dev/null
@@ -1,69 +0,0 @@
-'\"
-'\" Copyright (c) 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: ImgChanged.3,v 1.2 1998/09/14 18:22:52 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_ImageChanged 3 4.0 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_ImageChanged \- notify widgets that image needs to be redrawn
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-\fBTk_ImageChanged\fR(\fIimageMaster, x, y, width, height, imageWidth, imageHeight\fR)
-.SH ARGUMENTS
-.AS Tk_ImageMaster imageHeight
-.AP Tk_ImageMaster imageMaster in
-Token for image, which was passed to image's \fIcreateProc\fR when
-the image was created.
-.AP int x in
-X-coordinate of upper-left corner of region that needs redisplay (measured
-from upper-left corner of image).
-.AP int y in
-Y-coordinate of upper-left corner of region that needs redisplay (measured
-from upper-left corner of image).
-.AP "int" width in
-Width of region that needs to be redrawn, in pixels.
-.AP "int" height in
-Height of region that needs to be redrawn, in pixels.
-.AP "int" imageWidth in
-Current width of image, in pixels.
-.AP "int" imageHeight in
-Current height of image, in pixels.
-.BE
-
-.SH DESCRIPTION
-.PP
-An image manager calls \fBTk_ImageChanged\fR for an image
-whenever anything happens that requires the image to be redrawn.
-As a result of calling \fBTk_ImageChanged\fR, any widgets using
-the image are notified so that they can redisplay themselves
-appropriately.
-The \fIimageMaster\fR argument identifies the image, and
-\fIx\fR, \fIy\fR, \fIwidth\fR, and \fIheight\fR
-specify a rectangular region within the image that needs to
-be redrawn.
-\fIimageWidth\fR and \fIimageHeight\fR specify the image's (new) size.
-.PP
-An image manager should call \fBTk_ImageChanged\fR during
-its \fIcreateProc\fR to specify the image's initial size and to
-force redisplay if there are existing instances for the image.
-If any of the pixel values in the image should change later on,
-\fBTk_ImageChanged\fR should be called again with \fIx\fR, \fIy\fR,
-\fIwidth\fR, and \fIheight\fR values that cover all the pixels
-that changed.
-If the size of the image should change, then \fBTk_ImageChanged\fR
-must be called to indicate the new size, even if no pixels
-need to be redisplayed.
-
-.SH "SEE ALSO"
-Tk_CreateImageType
-
-.SH KEYWORDS
-images, redisplay, image size changes
diff --git a/doc/InternAtom.3 b/doc/InternAtom.3
deleted file mode 100644
index 3e50fae..0000000
--- a/doc/InternAtom.3
+++ /dev/null
@@ -1,58 +0,0 @@
-'\"
-'\" Copyright (c) 1990 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: InternAtom.3,v 1.2 1998/09/14 18:22:52 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_InternAtom 3 "" Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_InternAtom, Tk_GetAtomName \- manage cache of X atoms
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-Atom
-\fBTk_InternAtom(\fItkwin, name\fR)
-.sp
-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
-String name for which atom is desired.
-.AP Atom atom in
-Atom for which corresponding string name is desired.
-.BE
-
-.SH DESCRIPTION
-.PP
-These procedures are similar to the Xlib procedures
-\fBXInternAtom\fR and \fBXGetAtomName\fR. \fBTk_InternAtom\fR
-returns the atom identifier associated with string given by
-\fIname\fR; the atom identifier is only valid for the display
-associated with \fItkwin\fR.
-\fBTk_GetAtomName\fR returns the string associated
-with \fIatom\fR on \fItkwin\fR's display. The string returned
-by \fBTk_GetAtomName\fR is in Tk's storage: the caller need
-not free this space when finished with the string, and the caller
-should not modify the contents of the returned string.
-If there is no atom \fIatom\fR on \fItkwin\fR's display,
-then \fBTk_GetAtomName\fR returns the string ``?bad atom?''.
-.PP
-Tk caches
-the information returned by \fBTk_InternAtom\fR and \fBTk_GetAtomName\fR
-so that future calls
-for the same information can be serviced from the cache without
-contacting the server. Thus \fBTk_InternAtom\fR and \fBTk_GetAtomName\fR
-are generally much faster than their Xlib counterparts, and they
-should be used in place of the Xlib procedures.
-
-.SH KEYWORDS
-atom, cache, display
diff --git a/doc/MainLoop.3 b/doc/MainLoop.3
deleted file mode 100644
index de6dbe5..0000000
--- a/doc/MainLoop.3
+++ /dev/null
@@ -1,32 +0,0 @@
-'\"
-'\" Copyright (c) 1990-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: MainLoop.3,v 1.2 1998/09/14 18:22:52 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_MainLoop 3 "" Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_MainLoop \- loop for events until all windows are deleted
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-\fBTk_MainLoop\fR()
-.BE
-
-.SH DESCRIPTION
-.PP
-\fBTk_MainLoop\fR is a procedure that loops repeatedly calling
-\fBTcl_DoOneEvent\fR. It returns only when there are no applications
-left in this process (i.e. no main windows exist anymore). Most
-windowing applications will call \fBTk_MainLoop\fR after
-initialization; the main execution of the application will consist
-entirely of callbacks invoked via \fBTcl_DoOneEvent\fR.
-
-.SH KEYWORDS
-application, event, main loop
diff --git a/doc/MainWin.3 b/doc/MainWin.3
deleted file mode 100644
index c913b29..0000000
--- a/doc/MainWin.3
+++ /dev/null
@@ -1,36 +0,0 @@
-'\"
-'\" Copyright (c) 1990 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: MainWin.3,v 1.2 1998/09/14 18:22:52 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_MainWindow 3 7.0 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_MainWindow \- find the main window for an application
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-Tk_Window
-\fBTk_MainWindow\fR(\fIinterp\fR)
-.SH ARGUMENTS
-.AS Tcl_Interp *pathName
-.AP Tcl_Interp *interp in/out
-Interpreter associated with the application.
-.BE
-
-.SH DESCRIPTION
-.PP
-If \fIinterp\fR is associated with a Tk application then \fBTk_MainWindow\fR
-returns the application's main window.
-If there is no Tk application associated with \fIinterp\fR then
-\fBTk_MainWindow\fR returns NULL and leaves an error message
-in \fIinterp->result\fR.
-
-.SH KEYWORDS
-application, main window
diff --git a/doc/MaintGeom.3 b/doc/MaintGeom.3
deleted file mode 100644
index b9f882d..0000000
--- a/doc/MaintGeom.3
+++ /dev/null
@@ -1,102 +0,0 @@
-'\"
-'\" Copyright (c) 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: MaintGeom.3,v 1.2 1998/09/14 18:22:52 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_MaintainGeometry 3 4.0 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_MaintainGeometry, Tk_UnmaintainGeometry \- maintain geometry of one window relative to another
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-\fBTk_MaintainGeometry\fR(\fIslave, master, x, y, width, height\fR)
-.sp
-\fBTk_UnmaintainGeometry\fR(\fIslave, master\fR)
-.SH ARGUMENTS
-.AS Tk_Window master
-.AP Tk_Window slave in
-Window whose geometry is to be controlled.
-.AP Tk_Window master in
-Window relative to which \fIslave\fR's geometry will be controlled.
-.AP int x in
-Desired x-coordinate of \fIslave\fR in \fImaster\fR, measured in pixels
-from the inside of \fImaster\fR's left border to the outside of
-\fIslave\fR's left border.
-.AP int y in
-Desired y-coordinate of \fIslave\fR in \fImaster\fR, measured in pixels
-from the inside of \fImaster\fR's top border to the outside of
-\fIslave\fR's top border.
-.AP int width in
-Desired width for \fIslave\fR, in pixels.
-.AP int height in
-Desired height for \fIslave\fR, in pixels.
-.BE
-
-.SH DESCRIPTION
-.PP
-\fBTk_MaintainGeometry\fR and \fBTk_UnmaintainGeometry\fR make it
-easier for geometry managers to deal with slaves whose masters are not
-their parents.
-Three problems arise if the master for a slave is not its parent:
-.IP [1]
-The x- and y-position of the slave must be translated from the
-coordinate system of the master to that of the parent before
-positioning the slave.
-.IP [2]
-If the master window, or any of its ancestors up to the slave's
-parent, is moved, then the slave must be repositioned within its
-parent in order to maintain the correct position relative to the
-master.
-.IP [3]
-If the master or one of its ancestors is mapped or unmapped, then
-the slave must be mapped or unmapped to correspond.
-.LP
-None of these problems is an issue if the parent and master are
-the same. For example, if the master or one of its ancestors
-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.
-\fBTk_MaintainGeometry\fR is typically called by a window manager
-once it has decided where a slave should be positioned relative
-to its master.
-\fBTk_MaintainGeometry\fR translates the coordinates to the
-coordinate system of \fIslave\fR's parent and then moves and
-resizes the slave appropriately.
-Furthermore, it remembers the desired position and creates event
-handlers to monitor the master and all of its ancestors up
-to (but not including) the slave's parent.
-If any of these windows is moved, mapped, or unmapped,
-the slave will be adjusted so that it is mapped only when the
-master is mapped and its geometry relative to the master
-remains as specified by \fIx\fR, \fIy\fR, \fIwidth\fR, and
-\fIheight\fR.
-.PP
-When a window manager relinquishes control over a window, or
-if it decides that it does not want the window to appear on the
-screen under any conditions, it calls \fBTk_UnmaintainGeometry\fR.
-\fBTk_UnmaintainGeometry\fR unmaps the window and cancels any
-previous calls to \fBTk_MaintainGeometry\fR for the
-\fImaster\fR\-\fIslave\fR pair, so that the slave's
-geometry and mapped state are no longer maintained
-automatically.
-\fBTk_UnmaintainGeometry\fR need not be called by a geometry
-manager if the slave, the master, or any of the master's ancestors
-is destroyed: Tk will call it automatically.
-.PP
-If \fBTk_MaintainGeometry\fR is called repeatedly for the same
-\fImaster\fR\-\fIslave\fR pair, the information from the most
-recent call supersedes any older information.
-If \fBTk_UnmaintainGeometry\fR is called for a \fImaster\fR\-\fIslave\fR
-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/doc/ManageGeom.3 b/doc/ManageGeom.3
deleted file mode 100644
index b5b348d..0000000
--- a/doc/ManageGeom.3
+++ /dev/null
@@ -1,94 +0,0 @@
-'\"
-'\" 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: ManageGeom.3,v 1.2 1998/09/14 18:22:52 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_ManageGeometry 3 4.0 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_ManageGeometry \- arrange to handle geometry requests for a window
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-\fBTk_ManageGeometry\fR(\fItkwin, mgrPtr, clientData\fR)
-.SH ARGUMENTS
-.AS Tk_GeometryProc clientData
-.AP Tk_Window tkwin in
-Token for window to be managed.
-.AP Tk_GeomMgr *mgrPtr in
-Pointer to data structure containing information about the
-geometry manager, or NULL to indicate that \fItkwin\fR's geometry
-shouldn't be managed anymore.
-The data structure pointed to by \fImgrPtr\fR must be static:
-Tk keeps a reference to it as long as the window is managed.
-.AP ClientData clientData in
-Arbitrary one-word value to pass to geometry manager callbacks.
-.BE
-
-.SH DESCRIPTION
-.PP
-\fBTk_ManageGeometry\fR arranges for a particular geometry manager,
-described by the \fImgrPtr\fR argument, to control the geometry
-of a particular slave window, given by \fItkwin\fR.
-If \fItkwin\fR was previously managed by some other geometry manager,
-the previous manager loses control in favor of the new one.
-If \fImgrPtr\fR is NULL, geometry management is cancelled for
-\fItkwin\fR.
-.PP
-The structure pointed to by \fImgrPtr\fR contains information about
-the geometry manager:
-.CS
-typedef struct {
- char *\fIname\fR;
- Tk_GeomRequestProc *\fIrequestProc\fR;
- Tk_GeomLostSlaveProc *\fIlostSlaveProc\fR;
-} Tk_GeomMgr;
-.CE
-The \fIname\fR field is the textual name for the geometry manager,
-such as \fBpack\fR or \fBplace\fR; this value will be returned
-by the command \fBwinfo manager\fR.
-.PP
-\fIrequestProc\fR is a procedure in the geometry manager that
-will be invoked whenever \fBTk_GeometryRequest\fR is called by the
-slave to change its desired geometry.
-\fIrequestProc\fR should have arguments and results that match the
-type \fBTk_GeomRequestProc\fR:
-.CS
-typedef void Tk_GeomRequestProc(
- ClientData \fIclientData\fR,
- Tk_Window \fItkwin\fR);
-.CE
-The parameters to \fIrequestProc\fR will be identical to the
-corresponding parameters passed to \fBTk_ManageGeometry\fR.
-\fIclientData\fR usually points to a data
-structure containing application-specific information about
-how to manage \fItkwin\fR's geometry.
-.PP
-The \fIlostSlaveProc\fR field of \fImgrPtr\fR points to another
-procedure in the geometry manager.
-Tk will invoke \fIlostSlaveProc\fR if some other manager
-calls \fBTk_ManageGeometry\fR to claim
-\fItkwin\fR away from the current geometry manager.
-\fIlostSlaveProc\fR is not invoked if \fBTk_ManageGeometry\fR is
-called with a NULL value for \fImgrPtr\fR (presumably the current
-geometry manager has made this call, so it already knows that the
-window is no longer managed), nor is it called if \fImgrPtr\fR
-is the same as the window's current geometry manager.
-\fIlostSlaveProc\fR should have
-arguments and results that match the following prototype:
-.CS
-typedef void Tk_GeomLostSlaveProc(
- ClientData \fIclientData\fR,
- Tk_Window \fItkwin\fR);
-.CE
-The parameters to \fIlostSlaveProc\fR will be identical to the
-corresponding parameters passed to \fBTk_ManageGeometry\fR.
-
-.SH KEYWORDS
-callback, geometry, managed, request, unmanaged
diff --git a/doc/MapWindow.3 b/doc/MapWindow.3
deleted file mode 100644
index f2cfc4e..0000000
--- a/doc/MapWindow.3
+++ /dev/null
@@ -1,53 +0,0 @@
-'\"
-'\" Copyright (c) 1990 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: MapWindow.3,v 1.2 1998/09/14 18:22:52 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_MapWindow 3 "" Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_MapWindow, Tk_UnmapWindow \- map or unmap a window
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-Tk_Window
-\fBTk_MapWindow\fR(\fItkwin\fR)
-.sp
-\fBTk_UnmapWindow\fR(\fItkwin\fR)
-.SH ARGUMENTS
-.AS Tk_Window parent
-.AP Tk_Window tkwin in
-Token for window.
-.BE
-
-.SH DESCRIPTION
-.PP
-These procedures may be used to map and unmap windows
-managed by Tk. \fBTk_MapWindow\fR maps the window given
-by \fItkwin\fR, and also creates an X window corresponding
-to \fItkwin\fR if it doesn't already exist. See the
-\fBTk_CreateWindow\fR manual entry for information on
-deferred window creation.
-\fBTk_UnmapWindow\fR unmaps \fItkwin\fR's window
-from the screen.
-.PP
-If \fItkwin\fR is a child window (i.e. \fBTk_CreateChildWindow\fR was
-used to create it), then event handlers interested in map and unmap events
-are invoked immediately. If \fItkwin\fR isn't an internal window,
-then the event handlers will be invoked later, after X has seen
-the request and returned an event for it.
-.PP
-These procedures should be used in place of the X procedures
-\fBXMapWindow\fR and \fBXUnmapWindow\fR, since they update
-Tk's local data structure for \fItkwin\fR. Applications
-using Tk should not invoke \fBXMapWindow\fR and \fBXUnmapWindow\fR
-directly.
-
-.SH KEYWORDS
-map, unmap, window
diff --git a/doc/MeasureChar.3 b/doc/MeasureChar.3
deleted file mode 100644
index 53baf88..0000000
--- a/doc/MeasureChar.3
+++ /dev/null
@@ -1,130 +0,0 @@
-'\"
-'\" Copyright (c) 1996 Sun Microsystems, Inc.
-'\"
-'\" See the file "license.terms" for information on usage and redistribution
-'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-'\"
-'\" RCS: @(#) $Id: MeasureChar.3,v 1.2 1998/09/14 18:22:52 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_MeasureChars 3 "" Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_MeasureChars, Tk_TextWidth, Tk_DrawChars, Tk_UnderlineChars \- routines to measure and display simple single-line strings.
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-int
-\fBTk_MeasureChars(\fItkfont, string, maxChars, maxPixels, flags, lengthPtr\fB)\fR
-.sp
-int
-\fBTk_TextWidth(\fItkfont, string, numChars\fB)\fR
-.sp
-void
-\fBTk_DrawChars(\fIdisplay, drawable, gc, tkfont, string, numChars, x, y\fB)\fR
-.sp
-void
-\fBTk_UnderlineChars(\fIdisplay, drawable, gc, tkfont, string, x, y, firstChar, lastChar\fB)\fR
-.sp
-.SH ARGUMENTS
-.AS "const char" firstChar
-.AP Tk_Font tkfont in
-Token for font in which text is to be drawn or measured. Must have been
-returned by a previous call to \fBTk_GetFont\fR.
-.AP "const char" *string in
-Text to be measured or displayed. Need not be null terminated. Any
-non-printing meta-characters in the string (such as tabs, newlines, and
-other control characters) will be measured or displayed in a
-platform-dependent manner.
-.AP int maxChars in
-The maximum number of characters to consider when measuring \fIstring\fR.
-Must be greater than or equal to 0.
-.AP int maxPixels in
-If \fImaxPixels\fR is greater than 0, it specifies the longest permissible
-line length in pixels. Characters from \fIstring\fR are processed only
-until this many pixels have been covered. If \fImaxPixels\fR is <= 0, then
-the line length is unbounded and the \fIflags\fR argument is ignored.
-.AP int flags in
-Various flag bits OR-ed together: TK_PARTIAL_OK means include a character
-as long as any part of it fits in the length given by \fImaxPixels\fR;
-otherwise, a character must fit completely to be considered.
-TK_WHOLE_WORDS means stop on a word boundary, if possible. If
-TK_AT_LEAST_ONE is set, it means return at least one character even if no
-characters could fit in the length given by \fImaxPixels\fR. If
-TK_AT_LEAST_ONE is set and TK_WHOLE_WORDS is also set, it means that if
-not even one word fits on the line, return the first few letters of the
-word that did fit; if not even one letter of the word fit, then the first
-letter will still be returned.
-.AP int *lengthPtr out
-Filled with the number of pixels occupied by the number of characters
-returned as the result of \fBTk_MeasureChars\fR.
-.AP int numChars in
-The total number of characters to measure or draw from \fIstring\fR. Must
-be greater than or equal to 0.
-.AP Display *display in
-Display on which to draw.
-.AP Drawable drawable in
-Window or pixmap in which to draw.
-.AP GC gc in
-Graphics context for drawing characters. The font selected into this GC
-must be the same as the \fItkfont\fR.
-.AP int "x, y" in
-Coordinates at which to place the left edge of the baseline when displaying
-\fIstring\fR.
-.AP int firstChar in
-The index of the first character to underline in the \fIstring\fR.
-Underlining begins at the left edge of this character.
-.AP int lastChar in
-The index of the last character up to which the underline will
-be drawn. The character specified by \fIlastChar\fR will not itself be
-underlined.
-.BE
-
-.SH DESCRIPTION
-.PP
-These routines are for measuring and displaying simple single-font,
-single-line, strings. To measure and display single-font, multi-line,
-justified text, refer to the documentation for \fBTk_ComputeTextLayout\fR.
-There is no programming interface in the core of Tk that supports
-multi-font, multi-line text; support for that behavior must be built on
-top of simpler layers.
-.PP
-A glyph is the displayable picture of a letter, number, or some other
-symbol. Not all character codes in a given font have a glyph.
-Characters such as tabs, newlines/returns, and control characters that
-have no glyph are measured and displayed by these procedures in a
-platform-dependent manner; under X, they are replaced with backslashed
-escape sequences, while under Windows and Macintosh hollow or solid boxes
-may be substituted. Refer to the documentation for
-\fBTk_ComputeTextLayout\fR for a programming interface that supports the
-platform-independent expansion of tab characters into columns and
-newlines/returns into multi-line text.
-.PP
-\fBTk_MeasureChars\fR is used both to compute the length of a given
-string and to compute how many characters from a string fit in a given
-amount of space. The return value is the number of characters from
-\fIstring\fR that fit in the space specified by \fImaxPixels\fR subject to
-the conditions described by \fIflags\fR. If all characters fit, the return
-value will be \fImaxChars\fR. \fI*lengthPtr\fR is filled with the computed
-width, in pixels, of the portion of the string that was measured. For
-example, if the return value is 5, then \fI*lengthPtr\fR is filled with the
-distance between the left edge of \fIstring\fR[0] and the right edge of
-\fIstring\fR[4].
-.PP
-\fBTk_TextWidth\fR is a wrapper function that provides a simpler interface
-to the \fBTk_MeasureChars\fR function. The return value is how much
-space in pixels the given \fIstring\fR needs.
-.PP
-\fBTk_DrawChars\fR draws the \fIstring\fR at the given location in the
-given \fIdrawable\fR.
-.PP
-\fBTk_UnderlineChars\fR underlines the given range of characters in the
-given \fIstring\fR. It doesn't draw the characters (which are assumed to
-have been displayed previously by \fBTk_DrawChars\fR); it just draws the
-underline. This procedure is used to underline a few characters without
-having to construct an underlined font. To produce natively underlined
-text, the appropriate underlined font should be constructed and used.
-
-.SH KEYWORDS
-font
diff --git a/doc/MoveToplev.3 b/doc/MoveToplev.3
deleted file mode 100644
index f87cf51..0000000
--- a/doc/MoveToplev.3
+++ /dev/null
@@ -1,55 +0,0 @@
-'\"
-'\" Copyright (c) 1990-1993 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: MoveToplev.3,v 1.2 1998/09/14 18:22:52 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_MoveToplevelWindow 3 "" Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_MoveToplevelWindow \- Adjust the position of a top-level window
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-\fBTk_MoveToplevelWindow(\fItkwin, x, y\fB)\fR
-.SH ARGUMENTS
-.AS Tk_Window tkwin
-.AP Tk_Window tkwin in
-Token for top-level window to move.
-.AP int x in
-New x-coordinate for the top-left pixel of \fItkwin\fR's border, or the
-top-left pixel of the decorative border supplied for \fItkwin\fR by the
-window manager, if there is one.
-.AP int y in
-New y-coordinate for the top-left pixel of \fItkwin\fR's border, or the
-top-left pixel of the decorative border supplied for \fItkwin\fR by the
-window manager, if there is one.
-.BE
-
-.SH DESCRIPTION
-.PP
-In general, a window should never set its own position; this should be
-done only by the geometry manger that is responsible for the window.
-For top-level windows the window manager is effectively the geometry
-manager; Tk provides interface code between the application and the
-window manager to convey the application's desires to the geometry
-manager. The desired size for a top-level window is conveyed using
-the usual \fBTk_GeometryRequest\fR mechanism. The procedure
-\fBTk_MoveToplevelWindow\fR may be used by an application to request
-a particular position for a top-level window; this procedure is
-similar in function to the \fBwm geometry\fR Tcl command except that
-negative offsets cannot be specified. It is invoked by widgets such as
-menus that want to appear at a particular place on the screen.
-.PP
-When \fBTk_MoveToplevelWindow\fR is called it doesn't immediately
-pass on the new desired location to the window manager; it defers
-this action until all other outstanding work has been completed,
-using the \fBTk_DoWhenIdle\fR mechanism.
-
-.SH KEYWORDS
-position, top-level window, window manager
diff --git a/doc/Name.3 b/doc/Name.3
deleted file mode 100644
index 0dd4c2a..0000000
--- a/doc/Name.3
+++ /dev/null
@@ -1,82 +0,0 @@
-'\"
-'\" Copyright (c) 1990 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: Name.3,v 1.2 1998/09/14 18:22:52 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_Name 3 "" Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_Name, Tk_PathName, Tk_NameToWindow \- convert between names and window tokens
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-Tk_Uid
-\fBTk_Name\fR(\fItkwin\fR)
-.sp
-char *
-\fBTk_PathName\fR(\fItkwin\fR)
-.sp
-Tk_Window
-\fBTk_NameToWindow\fR(\fIinterp, pathName, tkwin\fR)
-.SH ARGUMENTS
-.AS Tcl_Interp *pathName
-.AP Tk_Window tkwin in
-Token for window.
-.AP Tcl_Interp *interp out
-Interpreter to use for error reporting.
-.AP char *pathName in
-Character string containing path name of window.
-.BE
-
-.SH DESCRIPTION
-.PP
-Each window managed by Tk has two names, a short name that identifies
-a window among children of the same parent, and a path name that
-identifies the window uniquely among all the windows belonging to the
-same main window. The path name is used more often in Tk than the
-short name; many commands, like \fBbind\fR, expect path names as
-arguments.
-.PP
-The \fBTk_Name\fR macro returns a window's
-short name, which is the same as the \fIname\fR argument
-passed to \fBTk_CreateWindow\fR when
-the window was created. The value is returned
-as a Tk_Uid, which may be used just like a string pointer but also has
-the properties of a unique identifier (see the manual entry for
-\fBTk_GetUid\fR for details).
-.PP
-The \fBTk_PathName\fR macro returns a
-hierarchical name for \fItkwin\fR.
-Path names have a structure similar to file names in Unix but with
-dots between elements instead of slashes: the main window for
-an application has the path name ``.''; its children have names like
-``.a'' and ``.b''; their children have names like ``.a.aa'' and
-``.b.bb''; and so on. A window is considered to be be a child of
-another window for naming purposes if the second window was named
-as the first window's \fIparent\fR when the first window was created.
-This is not always the same as the X window hierarchy. For
-example, a pop-up
-is created as a child of the root window, but its logical parent will
-usually be a window within the application.
-.PP
-The procedure \fBTk_NameToWindow\fR returns the token for a window
-given its path name (the \fIpathName\fR argument) and another window
-belonging to the same main window (\fItkwin\fR). It normally
-returns a token for the named window, but if no such window exists
-\fBTk_NameToWindow\fR leaves an error message in \fIinterp->result\fR
-and returns NULL. The \fItkwin\fR argument to \fBTk_NameToWindow\fR
-is needed because path names are only unique within a single
-application hierarchy. If, for example, a single process has opened
-two main windows, each will have a separate naming hierarchy and the
-same path name might appear in each of the hierarchies. Normally
-\fItkwin\fR is the main window of the desired hierarchy, but this
-need not be the case: any window in the desired hierarchy may be used.
-
-.SH KEYWORDS
-name, path name, token, window
diff --git a/doc/NameOfImg.3 b/doc/NameOfImg.3
deleted file mode 100644
index 4ca60de..0000000
--- a/doc/NameOfImg.3
+++ /dev/null
@@ -1,34 +0,0 @@
-'\"
-'\" Copyright (c) 1995-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: NameOfImg.3,v 1.2 1998/09/14 18:22:53 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_NameOfImage 3 4.0 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_NameOfImage \- Return name of image.
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-char *
-\fBTk_NameOfImage\fR(\fItypePtr\fR)
-.SH ARGUMENTS
-.AS Tk_ImageMaster *masterPtr
-.AP Tk_ImageMaster *masterPtr in
-Token for image, which was passed to image manager's \fIcreateProc\fR when
-the image was created.
-.BE
-
-.SH DESCRIPTION
-.PP
-This procedure is invoked by image managers to find out the name
-of an image. Given the token for the image, it returns the
-string name for the image.
-
-.SH KEYWORDS
-image manager, image name
diff --git a/doc/OwnSelect.3 b/doc/OwnSelect.3
deleted file mode 100644
index 0cd541c..0000000
--- a/doc/OwnSelect.3
+++ /dev/null
@@ -1,52 +0,0 @@
-'\"
-'\" 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: OwnSelect.3,v 1.2 1998/09/14 18:22:53 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_OwnSelection 3 4.0 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_OwnSelection \- make a window the owner of the primary selection
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-\fBTk_OwnSelection\fR(\fItkwin, selection, proc, clientData\fR)
-.SH ARGUMENTS
-.AS Tk_LostSelProc clientData
-.AP Tk_Window tkwin in
-Window that is to become new selection owner.
-.AP Atom selection in
-The name of the selection to be owned, such as XA_PRIMARY.
-.AP Tk_LostSelProc *proc in
-Procedure to invoke when \fItkwin\fR loses selection ownership later.
-.AP ClientData clientData in
-Arbitrary one-word value to pass to \fIproc\fR.
-.BE
-
-.SH DESCRIPTION
-.PP
-\fBTk_OwnSelection\fR arranges for \fItkwin\fR to become the
-new owner of the selection specified by the atom
-\fIselection\fR. After this call completes, future requests
-for the selection will be directed to handlers created for
-\fItkwin\fR using \fBTk_CreateSelHandler\fR. When \fItkwin\fR
-eventually loses the selection ownership, \fIproc\fR will be
-invoked so that the window can clean itself up (e.g. by
-unhighlighting the selection). \fIProc\fR should have arguments and
-result that match the type \fBTk_LostSelProc\fR:
-.CS
-typedef void Tk_LostSelProc(ClientData \fIclientData\fR);
-.CE
-The \fIclientData\fR parameter to \fIproc\fR is a copy of the
-\fIclientData\fR argument given to \fBTk_OwnSelection\fR, and is
-usually a pointer to a data structure containing application-specific
-information about \fItkwin\fR.
-
-.SH KEYWORDS
-own, selection owner
diff --git a/doc/ParseArgv.3 b/doc/ParseArgv.3
deleted file mode 100644
index 2ed9034..0000000
--- a/doc/ParseArgv.3
+++ /dev/null
@@ -1,351 +0,0 @@
-'\"
-'\" Copyright (c) 1990-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: ParseArgv.3,v 1.2 1998/09/14 18:22:53 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_ParseArgv 3 "" Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_ParseArgv \- process command-line options
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-int
-\fBTk_ParseArgv\fR(\fIinterp, tkwin, argcPtr, argv, argTable, flags\fR)
-.SH ARGUMENTS
-.AS Tk_ArgvInfo *argTable
-.AP Tcl_Interp *interp in
-Interpreter to use for returning error messages.
-.AP Tk_Window tkwin in
-Window to use when arguments specify Tk options. If NULL, then
-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
-Command line arguments passed to main program. Modified to
-hold unprocessed arguments that remain after the call.
-.AP Tk_ArgvInfo *argTable in
-Array of argument descriptors, terminated by element with
-type TK_ARGV_END.
-.AP int flags in
-If non-zero, then it specifies one or more flags that control the
-parsing of arguments. Different flags may be OR'ed together.
-The flags currently defined are TK_ARGV_DONT_SKIP_FIRST_ARG,
-TK_ARGV_NO_ABBREV, TK_ARGV_NO_LEFTOVERS, and TK_ARGV_NO_DEFAULTS.
-.BE
-.SH DESCRIPTION
-.PP
-\fBTk_ParseArgv\fR processes an array of command-line arguments according
-to a table describing the kinds of arguments that are expected.
-Each of the arguments in \fIargv\fR is processed in turn: if it matches
-one of the entries in \fIargTable\fR, the argument is processed
-according to that entry and discarded. The arguments that do not
-match anything in \fIargTable\fR are copied down to the beginning
-of \fIargv\fR (retaining their original order) and returned to
-the caller. At the end of the call
-\fBTk_ParseArgv\fR sets \fI*argcPtr\fR to hold the number of
-arguments that are left in \fIargv\fR, and \fIargv[*argcPtr]\fR
-will hold the value NULL. Normally, \fBTk_ParseArgv\fR
-assumes that \fIargv[0]\fR is a command name, so it is treated like
-an argument that doesn't match \fIargTable\fR and returned to the
-caller; however, if the TK_ARGV_DONT_SKIP_FIRST_ARG bit is set in
-\fIflags\fR then \fIargv[0]\fR will be processed just like the other
-elements of \fIargv\fR.
-.PP
-\fBTk_ParseArgv\fR normally returns the value TCL_OK. If an error
-occurs while parsing the arguments, then TCL_ERROR is returned and
-\fBTk_ParseArgv\fR will leave an error message in \fIinterp->result\fR
-in the standard Tcl fashion. In
-the event of an error return, \fI*argvPtr\fR will not have been
-modified, but \fIargv\fR could have been partially modified. The
-possible causes of errors are explained below.
-.PP
-The \fIargTable\fR array specifies the kinds of arguments that are
-expected; each of its entries has the following structure:
-.CS
-typedef struct {
- char *\fIkey\fR;
- int \fItype\fR;
- char *\fIsrc\fR;
- char *\fIdst\fR;
- char *\fIhelp\fR;
-} Tk_ArgvInfo;
-.CE
-The \fIkey\fR field is a string such as ``\-display'' or ``\-bg''
-that is compared with the values in \fIargv\fR. \fIType\fR
-indicates how to process an argument that matches \fIkey\fR
-(more on this below). \fISrc\fR and \fIdst\fR are additional
-values used in processing the argument. Their exact usage
-depends on \fItype\fR, but typically \fIsrc\fR indicates
-a value and \fIdst\fR indicates where to store the
-value. The \fBchar *\fR declarations for \fIsrc\fR and \fIdst\fR
-are placeholders: the actual types may be different. Lastly,
-\fIhelp\fR is a string giving a brief description
-of this option; this string is printed when users ask for help
-about command-line options.
-.PP
-When processing an argument in \fIargv\fR, \fBTk_ParseArgv\fR
-compares the argument to each of the \fIkey\fR's in \fIargTable\fR.
-\fBTk_ParseArgv\fR selects the first specifier whose \fIkey\fR matches
-the argument exactly, if such a specifier exists. Otherwise
-\fBTk_ParseArgv\fR selects a specifier for which the argument
-is a unique abbreviation. If the argument is a unique abbreviation
-for more than one specifier, then an error is returned. If there
-is no matching entry in \fIargTable\fR, then the argument is
-skipped and returned to the caller.
-.PP
-Once a matching argument specifier is found, \fBTk_ParseArgv\fR
-processes the argument according to the \fItype\fR field of the
-specifier. The argument that matched \fIkey\fR is called ``the matching
-argument'' in the descriptions below. As part of the processing,
-\fBTk_ParseArgv\fR may also use the next argument in \fIargv\fR
-after the matching argument, which is called ``the following
-argument''. The legal values for \fItype\fR, and the processing
-that they cause, are as follows:
-.TP
-\fBTK_ARGV_END\fR
-Marks the end of the table. The last entry in \fIargTable\fR
-must have this type; all of its other fields are ignored and it
-will never match any arguments.
-.TP
-\fBTK_ARGV_CONSTANT\fR
-\fISrc\fR is treated as an integer and \fIdst\fR is treated
-as a pointer to an integer. \fISrc\fR is stored at \fI*dst\fR.
-The matching argument is discarded.
-.TP
-\fBTK_ARGV_INT\fR
-The following argument must contain an
-integer string in the format accepted by \fBstrtol\fR (e.g. ``0''
-and ``0x'' prefixes may be used to specify octal or hexadecimal
-numbers, respectively). \fIDst\fR is treated as a pointer to an
-integer; the following argument is converted to an integer value
-and stored at \fI*dst\fR. \fISrc\fR is ignored. The matching
-and following arguments are discarded from \fIargv\fR.
-.TP
-\fBTK_ARGV_FLOAT\fR
-The following argument must contain a floating-point number in
-the format accepted by \fBstrtol\fR.
-\fIDst\fR is treated as the address of an double-precision
-floating point value; the following argument is converted to a
-double-precision value and stored at \fI*dst\fR. The matching
-and following arguments are discarded from \fIargv\fR.
-.TP
-\fBTK_ARGV_STRING\fR
-In this form, \fIdst\fR is treated as a pointer to a (char *);
-\fBTk_ParseArgv\fR stores at \fI*dst\fR a pointer to the following
-argument, and discards the matching and following arguments from
-\fIargv\fR. \fISrc\fR is ignored.
-.TP
-\fBTK_ARGV_UID\fR
-This form is similar to TK_ARGV_STRING, except that the argument
-is turned into a Tk_Uid by calling \fBTk_GetUid\fR.
-\fIDst\fR is treated as a pointer to a
-Tk_Uid; \fBTk_ParseArgv\fR stores at \fI*dst\fR the Tk_Uid
-corresponding to the following
-argument, and discards the matching and following arguments from
-\fIargv\fR. \fISrc\fR is ignored.
-.TP
-\fBTK_ARGV_CONST_OPTION\fR
-This form causes a Tk option to be set (as if the \fBoption\fR
-command had been invoked). The \fIsrc\fR field is treated as a
-pointer to a string giving the value of an option, and \fIdst\fR
-is treated as a pointer to the name of the option. The matching
-argument is discarded. If \fItkwin\fR is NULL, then argument
-specifiers of this type are ignored (as if they did not exist).
-.TP
-\fBTK_ARGV_OPTION_VALUE\fR
-This form is similar to TK_ARGV_CONST_OPTION, except that the
-value of the option is taken from the following argument instead
-of from \fIsrc\fR. \fIDst\fR is used as the name of the option.
-\fISrc\fR is ignored. The matching and following arguments
-are discarded. If \fItkwin\fR is NULL, then argument
-specifiers of this type are ignored (as if they did not exist).
-.TP
-\fBTK_ARGV_OPTION_NAME_VALUE\fR
-In this case the following argument is taken as the name of a Tk
-option and the argument after that is taken as the value for that
-option. Both \fIsrc\fR and \fIdst\fR are ignored. All three
-arguments are discarded from \fIargv\fR. If \fItkwin\fR is NULL,
-then argument
-specifiers of this type are ignored (as if they did not exist).
-.TP
-\fBTK_ARGV_HELP\fR
-When this kind of option is encountered, \fBTk_ParseArgv\fR uses the
-\fIhelp\fR fields of \fIargTable\fR to format a message describing
-all the valid arguments. The message is placed in \fIinterp->result\fR
-and \fBTk_ParseArgv\fR returns TCL_ERROR. When this happens, the
-caller normally prints the help message and aborts. If the \fIkey\fR
-field of a TK_ARGV_HELP specifier is NULL, then the specifier will
-never match any arguments; in this case the specifier simply provides
-extra documentation, which will be included when some other
-TK_ARGV_HELP entry causes help information to be returned.
-.TP
-\fBTK_ARGV_REST\fR
-This option is used by programs or commands that allow the last
-several of their options to be the name and/or options for some
-other program. If a \fBTK_ARGV_REST\fR argument is found, then
-\fBTk_ParseArgv\fR doesn't process any
-of the remaining arguments; it returns them all at
-the beginning of \fIargv\fR (along with any other unprocessed arguments).
-In addition, \fBTk_ParseArgv\fR treats \fIdst\fR as the address of an
-integer value, and stores at \fI*dst\fR the index of the first of the
-\fBTK_ARGV_REST\fR options in the returned \fIargv\fR. This allows the
-program to distinguish the \fBTK_ARGV_REST\fR options from other
-unprocessed options that preceded the \fBTK_ARGV_REST\fR.
-.TP
-\fBTK_ARGV_FUNC\fR
-For this kind of argument, \fIsrc\fR is treated as the address of
-a procedure, which is invoked to process the following argument.
-The procedure should have the following structure:
-.RS
-.CS
-int
-\fIfunc\fR(\fIdst\fR, \fIkey\fR, \fInextArg\fR)
- char *\fIdst\fR;
- char *\fIkey\fR;
- char *\fInextArg\fR;
-{
-}
-.CE
-The \fIdst\fR and \fIkey\fR parameters will contain the
-corresponding fields from the \fIargTable\fR entry, and
-\fInextArg\fR will point to the following argument from \fIargv\fR
-(or NULL if there aren't any more arguments left in \fIargv\fR).
-If \fIfunc\fR uses \fInextArg\fR (so that
-\fBTk_ParseArgv\fR should discard it), then it should return 1. Otherwise it
-should return 0 and \fBTkParseArgv\fR will process the following
-argument in the normal fashion. In either event the matching argument
-is discarded.
-.RE
-.TP
-\fBTK_ARGV_GENFUNC\fR
-This form provides a more general procedural escape. It treats
-\fIsrc\fR as the address of a procedure, and passes that procedure
-all of the remaining arguments. The procedure should have the following
-form:
-.RS
-.CS
-int
-\fIgenfunc\fR(dst, interp, key, argc, argv)
- char *\fIdst\fR;
- Tcl_Interp *\fIinterp\fR;
- char *\fIkey\fR;
- int \fIargc\fR;
- char **\fIargv\fR;
-{
-}
-.CE
-The \fIdst\fR and \fIkey\fR parameters will contain the
-corresponding fields from the \fIargTable\fR entry. \fIInterp\fR
-will be the same as the \fIinterp\fR argument to \fBTcl_ParseArgv\fR.
-\fIArgc\fR and \fIargv\fR refer to all of the options after the
-matching one. \fIGenfunc\fR should behave in a fashion similar
-to \fBTk_ParseArgv\fR: parse as many of the remaining arguments as it can,
-then return any that are left by compacting them to the beginning of
-\fIargv\fR (starting at \fIargv\fR[0]). \fIGenfunc\fR
-should return a count of how many arguments are left in \fIargv\fR;
-\fBTk_ParseArgv\fR will process them. If \fIgenfunc\fR encounters
-an error then it should leave an error message in \fIinterp->result\fR,
-in the usual Tcl fashion, and return -1; when this happens
-\fBTk_ParseArgv\fR will abort its processing and return TCL_ERROR.
-.RE
-
-.SH "FLAGS"
-.TP
-\fBTK_ARGV_DONT_SKIP_FIRST_ARG\fR
-\fBTk_ParseArgv\fR normally treats \fIargv[0]\fR as a program
-or command name, and returns it to the caller just as if it
-hadn't matched \fIargTable\fR. If this flag is given, then
-\fIargv[0]\fR is not given special treatment.
-.TP
-\fBTK_ARGV_NO_ABBREV\fR
-Normally, \fBTk_ParseArgv\fR accepts unique abbreviations for
-\fIkey\fR values in \fIargTable\fR. If this flag is given then
-only exact matches will be acceptable.
-.TP
-\fBTK_ARGV_NO_LEFTOVERS\fR
-Normally, \fBTk_ParseArgv\fR returns unrecognized arguments to the
-caller. If this bit is set in \fIflags\fR then \fBTk_ParseArgv\fR
-will return an error if it encounters any argument that doesn't
-match \fIargTable\fR. The only exception to this rule is \fIargv[0]\fR,
-which will be returned to the caller with no errors as
-long as TK_ARGV_DONT_SKIP_FIRST_ARG isn't specified.
-.TP
-\fBTK_ARGV_NO_DEFAULTS\fR
-Normally, \fBTk_ParseArgv\fR searches an internal table of
-standard argument specifiers in addition to \fIargTable\fR. If
-this bit is set in \fIflags\fR, then \fBTk_ParseArgv\fR will
-use only \fIargTable\fR and not its default table.
-
-.SH EXAMPLE
-.PP
-Here is an example definition of an \fIargTable\fR and
-some sample command lines that use the options. Note the effect
-on \fIargc\fR and \fIargv\fR; arguments processed by \fBTk_ParseArgv\fR
-are eliminated from \fIargv\fR, and \fIargc\fR
-is updated to reflect reduced number of arguments.
-.CS
-/*
- * Define and set default values for globals.
- */
-int debugFlag = 0;
-int numReps = 100;
-char defaultFileName[] = "out";
-char *fileName = defaultFileName;
-Boolean exec = FALSE;
-
-/*
- * Define option descriptions.
- */
-Tk_ArgvInfo argTable[] = {
- {"-X", TK_ARGV_CONSTANT, (char *) 1, (char *) &debugFlag,
- "Turn on debugging printfs"},
- {"-N", TK_ARGV_INT, (char *) NULL, (char *) &numReps,
- "Number of repetitions"},
- {"-of", TK_ARGV_STRING, (char *) NULL, (char *) &fileName,
- "Name of file for output"},
- {"x", TK_ARGV_REST, (char *) NULL, (char *) &exec,
- "File to exec, followed by any arguments (must be last argument)."},
- {(char *) NULL, TK_ARGV_END, (char *) NULL, (char *) NULL,
- (char *) NULL}
-};
-
-main(argc, argv)
- int argc;
- char *argv[];
-{
- \&...
-
- if (Tk_ParseArgv(interp, tkwin, &argc, argv, argTable, 0) != TCL_OK) {
- fprintf(stderr, "%s\en", interp->result);
- exit(1);
- }
-
- /*
- * Remainder of the program.
- */
-}
-.CE
-.PP
-Note that default values can be assigned to variables named in
-\fIargTable\fR: the variables will only be overwritten if the
-particular arguments are present in \fIargv\fR.
-Here are some example command lines and their effects.
-.CS
-prog -N 200 infile # just sets the numReps variable to 200
-prog -of out200 infile # sets fileName to reference "out200"
-prog -XN 10 infile # sets the debug flag, also sets numReps
-.CE
-In all of the above examples, \fIargc\fR will be set by \fBTk_ParseArgv\fR to 2,
-\fIargv\fR[0] will be ``prog'', \fIargv\fR[1] will be ``infile'',
-and \fIargv\fR[2] will be NULL.
-
-.SH KEYWORDS
-arguments, command line, options
diff --git a/doc/QWinEvent.3 b/doc/QWinEvent.3
deleted file mode 100644
index cd80f71..0000000
--- a/doc/QWinEvent.3
+++ /dev/null
@@ -1,42 +0,0 @@
-'\"
-'\" Copyright (c) 1995-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: QWinEvent.3,v 1.2 1998/09/14 18:22:53 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_QueueWindowEvent 3 7.5 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_QueueWindowEvent \- Add a window event to the Tcl event queue
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-\fBTk_QueueWindowEvent\fR(\fIeventPtr, position\fR)
-.SH ARGUMENTS
-.AS Tcl_QueuePosition position
-.AP XEvent *eventPtr in
-An event to add to the event queue.
-.AP Tcl_QueuePosition position in
-Where to add the new event in the queue: \fBTCL_QUEUE_TAIL\fR,
-\fBTCL_QUEUE_HEAD\fR, or \fBTCL_QUEUE_MARK\fR.
-.BE
-
-.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
-processed just like all window events.
-.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
diff --git a/doc/Restack.3 b/doc/Restack.3
deleted file mode 100644
index 6f8024e..0000000
--- a/doc/Restack.3
+++ /dev/null
@@ -1,49 +0,0 @@
-'\"
-'\" Copyright (c) 1990 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: Restack.3,v 1.2 1998/09/14 18:22:53 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_RestackWindow 3 "" Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_RestackWindow \- Change a window's position in the stacking order
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-int
-\fBTk_RestackWindow\fR(\fItkwin, aboveBelow, other\fR)
-.SH ARGUMENTS
-.AS Tk_Window aboveBelow
-.AP Tk_Window tkwin in
-Token for window to restack.
-.AP int aboveBelow in
-Indicates new position of \fItkwin\fR relative to \fIother\fR;
-must be \fBAbove\fR or \fBBelow\fR.
-.AP Tk_Window other in
-\fITkwin\fR will be repositioned just above or below this window.
-Must be a sibling of \fItkwin\fR or a descendant of a sibling.
-If NULL then \fItkwin\fR is restacked above or below all siblings.
-.BE
-
-.SH DESCRIPTION
-.PP
-\fBTk_RestackWindow\fR changes the stacking order of \fIwindow\fR relative
-to its siblings.
-If \fIother\fR is specified as NULL then \fIwindow\fR is repositioned
-at the top or bottom of its stacking order, depending on whether
-\fIaboveBelow\fR is \fBAbove\fR or \fBBelow\fR.
-If \fIother\fR has a non-NULL value then \fIwindow\fR is repositioned
-just above or below \fIother\fR.
-.PP
-The \fIaboveBelow\fR argument must have one of the symbolic values
-\fBAbove\fR or \fBBelow\fR.
-Both of these values are defined by the include file <X11/Xlib.h>.
-
-.SH KEYWORDS
-above, below, obscure, stacking order
diff --git a/doc/RestrictEv.3 b/doc/RestrictEv.3
deleted file mode 100644
index 5af42a5..0000000
--- a/doc/RestrictEv.3
+++ /dev/null
@@ -1,81 +0,0 @@
-'\"
-'\" Copyright (c) 1990 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: RestrictEv.3,v 1.2 1998/09/14 18:22:53 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_RestrictEvents 3 "" Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_RestrictEvents \- filter and selectively delay X events
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-Tk_RestrictProc *
-\fBTk_RestrictEvents\fR(\fIproc, clientData, prevClientDataPtr\fR)
-.SH ARGUMENTS
-.AS Tk_RestrictProc **prevClientDataPtr
-.AP Tk_RestrictProc *proc in
-Predicate procedure to call to filter incoming X events.
-NULL means do not restrict events at all.
-.AP ClientData clientData in
-Arbitrary argument to pass to \fIproc\fR.
-.AP ClientData *prevClientDataPtr out
-Pointer to place to save argument to previous restrict procedure.
-.BE
-
-.SH DESCRIPTION
-.PP
-This procedure is useful in certain situations where applications
-are only prepared to receive certain X events. After
-\fBTk_RestrictEvents\fR is called, \fBTk_DoOneEvent\fR (and
-hence \fBTk_MainLoop\fR) will filter X input events through
-\fIproc\fR. \fIProc\fR indicates whether a
-given event is to be processed immediately, deferred until some
-later time (e.g. when the event restriction is lifted), or discarded.
-\fIProc\fR
-is a procedure with arguments and result that match
-the type \fBTk_RestrictProc\fR:
-.CS
-typedef Tk_RestrictAction Tk_RestrictProc(
- ClientData \fIclientData\fR,
- XEvent *\fIeventPtr\fR);
-.CE
-The \fIclientData\fR argument is a copy of the \fIclientData\fR passed
-to \fBTk_RestrictEvents\fR; it may be used to provide \fIproc\fR with
-information it needs to filter events. The \fIeventPtr\fR points to
-an event under consideration. \fIProc\fR returns a restrict action
-(enumerated type \fBTk_RestrictAction\fR) that indicates what
-\fBTk_DoOneEvent\fR should do with the event. If the return value is
-\fBTK_PROCESS_EVENT\fR, then the event will be handled immediately.
-If the return value is \fBTK_DEFER_EVENT\fR, then the event will be
-left on the event queue for later processing. If the return value is
-\fBTK_DISCARD_EVENT\fR, then the event will be removed from the event
-queue and discarded without being processed.
-.PP
-\fBTk_RestrictEvents\fR uses its return value and \fIprevClientDataPtr\fR
-to return information about the current event restriction procedure
-(a NULL return value means there are currently no restrictions).
-These values may be used to restore the previous restriction state
-when there is no longer any need for the current restriction.
-.PP
-There are very few places where \fBTk_RestrictEvents\fR is needed.
-In most cases, the best way to restrict events is by changing the
-bindings with the \fBbind\fR Tcl command or by calling
-\fBTk_CreateEventHandler\fR and \fBTk_DeleteEventHandler\fR from C.
-The main place where \fBTk_RestrictEvents\fR must be used is when
-performing synchronous actions (for example, if you need to wait
-for a particular event to occur on a particular window but you don't
-want to invoke any handlers for any other events). The ``obvious''
-solution in these situations is to call \fBXNextEvent\fR or
-\fBXWindowEvent\fR, but these procedures cannot be used because
-Tk keeps its own event queue that is separate from the X event
-queue. Instead, call \fBTk_RestrictEvents\fR to set up a filter,
-then call \fBTk_DoOneEvent\fR to retrieve the desired event(s).
-.SH KEYWORDS
-delay, event, filter, restriction
diff --git a/doc/SetAppName.3 b/doc/SetAppName.3
deleted file mode 100644
index c22b780..0000000
--- a/doc/SetAppName.3
+++ /dev/null
@@ -1,65 +0,0 @@
-'\"
-'\" Copyright (c) 1994 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: SetAppName.3,v 1.2 1998/09/14 18:22:53 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_SetAppName 3 4.0 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_SetAppName \- Set the name of an application for ``send'' commands
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-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
-Name under which to register the application.
-.BE
-
-.SH DESCRIPTION
-.PP
-\fBTk_SetAppName\fR associates a name with a given application and
-records that association on the display containing with the application's
-main window.
-After this procedure has been invoked, other applications on the
-display will be able to use the \fBsend\fR command to invoke operations
-in the application.
-If \fIname\fR is already in use by some other application on the
-display, then a new name will be generated by appending
-``\fB #2\fR'' to \fIname\fR; if this name is also in use,
-the number will be incremented until an unused name is found.
-The return value from the procedure is a pointer to the name actually
-used.
-.PP
-If the application already has a name when \fBTk_SetAppName\fR is
-called, then the new name replaces the old name.
-.PP
-\fBTk_SetAppName\fR also adds a \fBsend\fR command to the application's
-interpreter, which can be used to send commands from this application
-to others on any of the displays where the application has windows.
-.PP
-The application's name registration persists until the interpreter is
-deleted or the \fBsend\fR command is deleted from \fIinterp\fR, at which
-point the name is automatically unregistered and the application
-becomes inaccessible via \fBsend\fR.
-The application can be made accessible again by calling \fBTk_SetAppName\fR.
-.PP
-\fBTk_SetAppName\fR is called automatically by \fBTk_Init\fR,
-so applications don't normally need to call it explicitly.
-.PP
-The command \fBtk appname\fR provides Tcl-level access to the
-functionality of \fBTk_SetAppName\fR.
-
-.SH KEYWORDS
-application, name, register, send command
diff --git a/doc/SetClass.3 b/doc/SetClass.3
deleted file mode 100644
index 68a21a1..0000000
--- a/doc/SetClass.3
+++ /dev/null
@@ -1,61 +0,0 @@
-'\"
-'\" Copyright (c) 1990 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: SetClass.3,v 1.2 1998/09/14 18:22:53 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_SetClass 3 "" Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_SetClass, Tk_Class \- set or retrieve a window's class
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-\fBTk_SetClass\fR(\fItkwin, class\fR)
-.sp
-Tk_Uid
-\fBTk_Class\fR(\fItkwin\fR)
-.SH ARGUMENTS
-.AS Tk_Window parent
-.AP Tk_Window tkwin in
-Token for window.
-.AP char *class in
-New class name for window.
-.BE
-
-.SH DESCRIPTION
-.PP
-\fBTk_SetClass\fR is called to associate a class with a particular
-window. The \fIclass\fR string identifies the type of the
-window; all windows with the same general class of behavior
-(button, menu, etc.) should have the same class. By
-convention all class names start with a capital letter, and
-there exists a Tcl command with the same name as
-each class (except all in lower-case) which can be used to
-create and manipulate windows of that class.
-A window's class string is initialized to NULL
-when the window is created.
-.PP
-For main windows, Tk automatically propagates the name and class
-to the WM_CLASS property used by window managers. This happens
-either when a main window is actually created (e.g. in
-\fBTk_MakeWindowExist\fR), or when \fBTk_SetClass\fR
-is called, whichever occurs later. If a main window has not been
-assigned a class then Tk will not set the WM_CLASS property for
-the window.
-.PP
-\fBTk_Class\fR is a macro that returns the
-current value of \fItkwin\fR's class. The value is returned
-as a Tk_Uid, which may be used just like a string pointer but also has
-the properties of a unique identifier (see the manual entry for
-\fBTk_GetUid\fR for details).
-If \fItkwin\fR has not yet been given a class, then
-\fBTk_Class\fR will return NULL.
-
-.SH KEYWORDS
-class, unique identifier, window, window manager
diff --git a/doc/SetGrid.3 b/doc/SetGrid.3
deleted file mode 100644
index 965864c..0000000
--- a/doc/SetGrid.3
+++ /dev/null
@@ -1,67 +0,0 @@
-'\"
-'\" 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: SetGrid.3,v 1.2 1998/09/14 18:22:53 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_SetGrid 3 4.0 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_SetGrid, Tk_UnsetGrid \- control the grid for interactive resizing
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-\fBTk_SetGrid\fR(\fItkwin, reqWidth, reqHeight, widthInc, heightInc\fR)
-.sp
-\fBTk_UnsetGrid\fR(\fItkwin\fR)
-.SH ARGUMENTS
-.AS Tk_Window heightInc
-.AP Tk_Window tkwin in
-Token for window.
-.AP int reqWidth in
-Width in grid units that corresponds to the pixel dimension \fItkwin\fR
-has requested via \fBTk_GeometryRequest\fR.
-.AP int reqHeight in
-Height in grid units that corresponds to the pixel dimension \fItkwin\fR
-has requested via \fBTk_GeometryRequest\fR.
-.AP int widthInc in
-Width of one grid unit, in pixels.
-.AP int heightInc in
-Height of one grid unit, in pixels.
-.BE
-
-.SH DESCRIPTION
-.PP
-\fBTk_SetGrid\fR turns on gridded geometry management for \fItkwin\fR's
-toplevel window and specifies the geometry of the grid.
-\fBTk_SetGrid\fR is typically invoked by a widget when its \fBsetGrid\fR
-option is true.
-It restricts interactive resizing of \fItkwin\fR's toplevel window so
-that the space allocated to the toplevel is equal to its requested
-size plus or minus even multiples of \fIwidthInc\fR and \fIheightInc\fR.
-Furthermore, the \fIreqWidth\fR and \fIreqHeight\fR values are
-passed to the window manager so that it can report the window's
-size in grid units during interactive resizes.
-If \fItkwin\fR's configuration changes (e.g., the size of a grid unit
-changes) then the widget should invoke \fBTk_SetGrid\fR again with the new
-information.
-.PP
-\fBTk_UnsetGrid\fR cancels gridded geometry management for
-\fItkwin\fR's toplevel window.
-.PP
-For each toplevel window there can be at most one internal window
-with gridding enabled.
-If \fBTk_SetGrid\fR or \fBTk_UnsetGrid\fR is invoked when some
-other window is already controlling gridding for \fItkwin\fR's
-toplevel, the calls for the new window have no effect.
-.PP
-See the \fBwm\fR manual entry for additional information on gridded geometry
-management.
-
-.SH KEYWORDS
-grid, window, window manager
diff --git a/doc/SetVisual.3 b/doc/SetVisual.3
deleted file mode 100644
index c95145a..0000000
--- a/doc/SetVisual.3
+++ /dev/null
@@ -1,54 +0,0 @@
-'\"
-'\" 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: SetVisual.3,v 1.2 1998/09/14 18:22:53 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_SetWindowVisual 3 4.0 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_SetWindowVisual \- change visual characteristics of window
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-int
-\fBTk_SetWindowVisual\fR(\fItkwin, visual, depth, colormap\fR)
-.SH ARGUMENTS
-.AS "Tk_Window int" colormap
-.AP Tk_Window tkwin in
-Token for window.
-.AP Visual *visual in
-New visual type to use for \fItkwin\fR.
-.AP "int" depth in
-Number of bits per pixel desired for \fItkwin\fR.
-.AP Colormap colormap in
-New colormap for \fItkwin\fR, which must be compatible with
-\fIvisual\fR and \fIdepth\fR.
-.BE
-
-.SH DESCRIPTION
-.PP
-When Tk creates a new window it assigns it the default visual
-characteristics (visual, depth, and colormap) for its screen.
-\fBTk_SetWindowVisual\fR may be called to change them.
-\fBTk_SetWindowVisual\fR must be called before the window has
-actually been created in X (e.g. before \fBTk_MapWindow\fR or
-\fBTk_MakeWindowExist\fR has been invoked for the window).
-The safest thing is to call \fBTk_SetWindowVisual\fR immediately
-after calling \fBTk_CreateWindow\fR.
-If \fItkwin\fR has already been created before \fBTk_SetWindowVisual\fR
-is called then it returns 0 and doesn't make any changes; otherwise
-it returns 1 to signify that the operation
-completed successfully.
-.PP
-Note: \fBTk_SetWindowVisual\fR should not be called if you just want
-to change a window's colormap without changing its visual or depth;
-call \fBTk_SetWindowColormap\fR instead.
-
-.SH KEYWORDS
-colormap, depth, visual
diff --git a/doc/StrictMotif.3 b/doc/StrictMotif.3
deleted file mode 100644
index ab80c33..0000000
--- a/doc/StrictMotif.3
+++ /dev/null
@@ -1,41 +0,0 @@
-'\"
-'\" Copyright (c) 1995-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: StrictMotif.3,v 1.2 1998/09/14 18:22:54 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_StrictMotif 3 4.0 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_StrictMotif \- Return value of tk_strictMotif variable
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-int
-\fBTk_StrictMotif\fR(\fItkwin\fR)
-.SH ARGUMENTS
-.AS Tk_Window tkwin
-.AP Tk_Window tkwin in
-Token for window.
-.BE
-
-.SH DESCRIPTION
-.PP
-This procedure returns the current value of the \fBtk_strictMotif\fR
-variable in the interpreter associated with \fItkwin\fR's application.
-The value is returned as an integer that is either 0 or 1.
-1 means that strict Motif compliance has been requested, so anything
-that is not part of the Motif specification should be avoided.
-0 means that ``Motif-like'' is good enough, and extra features
-are welcome.
-.PP
-This procedure uses a link to the Tcl variable to provide much
-faster access to the variable's value than could be had by calling
-\fBTcl_GetVar\fR.
-
-.SH KEYWORDS
-Motif compliance, tk_strictMotif variable
diff --git a/doc/TextLayout.3 b/doc/TextLayout.3
deleted file mode 100644
index 35eaf34..0000000
--- a/doc/TextLayout.3
+++ /dev/null
@@ -1,270 +0,0 @@
-'\"
-'\" Copyright (c) 1996 Sun Microsystems, Inc.
-'\"
-'\" See the file "license.terms" for information on usage and redistribution
-'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-'\"
-'\" RCS: @(#) $Id: TextLayout.3,v 1.2 1998/09/14 18:22:54 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_ComputeTextLayout 3 "" Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_ComputeTextLayout, Tk_FreeTextLayout, Tk_DrawTextLayout, Tk_UnderlineTextLayout, Tk_PointToChar, Tk_CharBbox, Tk_DistanceToTextLayout, Tk_IntersectTextLayout, Tk_TextLayoutToPostscript \- routines to measure and display single-font, multi-line, justified text.
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-Tk_TextLayout
-\fBTk_ComputeTextLayout(\fItkfont, string, numChars, wrapLength, justify, flags, widthPtr, heightPtr\fB)\fR
-.sp
-void
-\fBTk_FreeTextLayout(\fIlayout\fB)\fR
-.sp
-void
-\fBTk_DrawTextLayout(\fIdisplay, drawable, gc, layout, x, y, firstChar, lastChar\fB)\fR
-.sp
-void
-\fBTk_UnderlineTextLayout(\fIdisplay, drawable, gc, layout, x, y, underline\fB)\fR
-.sp
-int
-\fBTk_PointToChar(\fIlayout, x, y\fB)\fR
-.sp
-int
-\fBTk_CharBbox(\fIlayout, index, xPtr, yPtr, widthPtr, heightPtr\fB)\fR
-.sp
-int
-\fBTk_DistanceToTextLayout(\fIlayout, x, y\fB)\fR
-.sp
-int
-\fBTk_IntersectTextLayout(\fIlayout, x, y, width, height\fB)\fR
-.sp
-void
-\fBTk_TextLayoutToPostscript(\fIinterp, layout\fB)\fR
-
-.SH ARGUMENTS
-.AS Tk_TextLayout "*xPtr, *yPtr"
-.AP Tk_Font tkfont in
-Font to use when constructing and displaying a text layout. The
-\fItkfont\fR must remain valid for the lifetime of the text layout. Must
-have been returned by a previous call to \fBTk_GetFont\fR.
-.AP "const char" *string in
-Potentially multi-line string whose dimensions are to be computed and
-stored in the text layout. The \fIstring\fR must remain valid for the
-lifetime of the text layout.
-.AP int numChars in
-The number of characters to consider from \fIstring\fR. If
-\fInumChars\fR is less than 0, then assumes \fIstring\fR is null
-terminated and uses \fBstrlen(\fIstring\fB)\fR.
-.AP int wrapLength in
-Longest permissible line length, in pixels. Lines in \fIstring\fR will
-automatically be broken at word boundaries and wrapped when they reach
-this length. If \fIwrapLength\fR is too small for even a single
-character to fit on a line, it will be expanded to allow one character to
-fit on each line. If \fIwrapLength\fR is <= 0, there is no automatic
-wrapping; lines will get as long as they need to be and only wrap if a
-newline/return character is encountered.
-.AP Tk_Justify justify in
-How to justify the lines in a multi-line text layout. Possible values
-are TK_JUSTIFY_LEFT, TK_JUSTIFY_CENTER, or TK_JUSTIFY_RIGHT. If the text
-layout only occupies a single line, then \fIjustify\fR is irrelevant.
-.AP int flags in
-Various flag bits OR-ed together. TK_IGNORE_TABS means that tab characters
-should not be expanded to the next tab stop. TK_IGNORE_NEWLINES means that
-newline/return characters should not cause a line break. If either tabs or
-newlines/returns are ignored, then they will be treated as regular
-characters, being measured and displayed in a platform-dependent manner as
-described in \fBTk_MeasureChars\fR, and will not have any special behaviors.
-.AP int *widthPtr out
-If non-NULL, filled with either the width, in pixels, of the widest
-line in the text layout, or the width, in pixels, of the bounding box for the
-character specified by \fIindex\fR.
-.AP int *heightPtr out
-If non-NULL, filled with either the total height, in pixels, of all
-the lines in the text layout, or the height, in pixels, of the bounding
-box for the character specified by \fIindex\fR.
-.AP Tk_TextLayout layout in
-A token that represents the cached layout information about the single-font,
-multi-line, justified piece of text. This token is returned by
-\fBTk_ComputeTextLayout\fR.
-.AP Display *display in
-Display on which to draw.
-.AP Drawable drawable in
-Window or pixmap in which to draw.
-.AP GC gc in
-Graphics context to use for drawing text layout. The font selected in
-this GC must correspond to the \fItkfont\fR used when constructing the
-text layout.
-.AP int "x, y" in
-Point, in pixels, at which to place the upper-left hand corner of the
-text layout when it is being drawn, or the coordinates of a point (with
-respect to the upper-left hand corner of the text layout) to check
-against the text layout.
-.AP int firstChar in
-The index of the first character to draw from the given text layout.
-The number 0 means to draw from the beginning.
-.AP int lastChar in
-The index of the last character up to which to draw. The character
-specified by \fIlastChar\fR itself will not be drawn. A number less
-than 0 means to draw all characters in the text layout.
-.AP int underline in
-Index of the single character to underline in the text layout, or a number
-less than 0 for no underline.
-.AP int index in
-The index of the character whose bounding box is desired. The bounding
-box is computed with respect to the upper-left hand corner of the text layout.
-.AP int "*xPtr, *yPtr" out
-Filled with the upper-left hand corner, in pixels, of the bounding box
-for the character specified by \fIindex\fR. Either or both \fIxPtr\fR
-and \fIyPtr\fR may be NULL, in which case the corresponding value
-is not calculated.
-.AP int "width, height" in
-Specifies the width and height, in pixels, of the rectangular area to
-compare for intersection against the text layout.
-.AP Tcl_Interp *interp out
-Postscript code that will print the text layout is appended to
-\fIinterp->result\fR.
-.BE
-
-.SH DESCRIPTION
-.PP
-These routines are for measuring and displaying single-font, multi-line,
-justified text. To measure and display simple single-font, single-line
-strings, refer to the documentation for \fBTk_MeasureChars\fR. There is
-no programming interface in the core of Tk that supports multi-font,
-multi-line text; support for that behavior must be built on top of
-simpler layers.
-.PP
-The routines described here are built on top of the programming interface
-described in the \fBTk_MeasureChars\fR documentation. Tab characters and
-newline/return characters may be treated specially by these procedures,
-but all other characters are passed through to the lower level.
-.PP
-\fBTk_ComputeTextLayout\fR computes the layout information needed to
-display a single-font, multi-line, justified \fIstring\fR of text and
-returns a Tk_TextLayout token that holds this information. This token is
-used in subsequent calls to procedures such as \fBTk_DrawTextLayout\fR,
-\fBTk_DistanceToTextLayout\fR, and \fBTk_FreeTextLayout\fR. The
-\fIstring\fR and \fItkfont\fR used when computing the layout must remain
-valid for the lifetime of this token.
-.PP
-\fBTk_FreeTextLayout\fR is called to release the storage associated with
-\fIlayout\fR when it is no longer needed. A \fIlayout\fR should not be used
-in any other text layout procedures once it has been released.
-.PP
-\fBTk_DrawTextLayout\fR uses the information in \fIlayout\fR to display a
-single-font, multi-line, justified string of text at the specified location.
-.PP
-\fBTk_UnderlineTextLayout\fR uses the information in \fIlayout\fR to
-display an underline below an individual character. This procedure does
-not draw the text, just the underline. To produce natively underlined
-text, an underlined font should be constructed and used. All characters,
-including tabs, newline/return characters, and spaces at the ends of
-lines, can be underlined using this method. However, the underline will
-never be drawn outside of the computed width of \fIlayout\fR; the
-underline will stop at the edge for any character that would extend
-partially outside of \fIlayout\fR, and the underline will not be visible
-at all for any character that would be located completely outside of the
-layout.
-.PP
-\fBTk_PointToChar\fR uses the information in \fIlayout\fR to determine the
-character closest to the given point. The point is specified with respect
-to the upper-left hand corner of the \fIlayout\fR, which is considered to be
-located at (0, 0). Any point whose \fIy\fR-value is less that 0 will be
-considered closest to the first character in the text layout; any point
-whose \fIy\fR-value is greater than the height of the text layout will be
-considered closest to the last character in the text layout. Any point
-whose \fIx\fR-value is less than 0 will be considered closest to the first
-character on that line; any point whose \fIx\fR-value is greater than the
-width of the text layout will be considered closest to the last character on
-that line. The return value is the index of the character that was closest
-to the point. Given a \fIlayout\fR with no characters, the value 0 will
-always be returned, referring to a hypothetical zero-width placeholder
-character.
-.PP
-\fBTk_CharBBox\fR uses the information in \fIlayout\fR to return the
-bounding box for the character specified by \fIindex\fR. The width of the
-bounding box is the advance width of the character, and does not include any
-left or right bearing. Any character that extends partially outside of
-\fIlayout\fR is considered to be truncated at the edge. Any character
-that would be located completely outside of \fIlayout\fR is considered to
-be zero-width and pegged against the edge. The height of the bounding
-box is the line height for this font, extending from the top of the
-ascent to the bottom of the descent; information about the actual height
-of individual letters is not available. For measurement purposes, a
-\fIlayout\fR that contains no characters is considered to contain a
-single zero-width placeholder character at index 0. If \fIindex\fR was
-not a valid character index, the return value is 0 and \fI*xPtr\fR,
-\fI*yPtr\fR, \fI*widthPtr\fR, and \fI*heightPtr\fR are unmodified.
-Otherwise, if \fIindex\fR did specify a valid, the return value is
-non-zero, and \fI*xPtr\fR, \fI*yPtr\fR, \fI*widthPtr\fR, and
-\fI*heightPtr\fR are filled with the bounding box information for the
-character. If any of \fIxPtr\fR, \fIyPtr\fR, \fIwidthPtr\fR, or
-\fIheightPtr\fR are NULL, the corresponding value is not calculated or
-stored.
-.PP
-\fBTk_DistanceToTextLayout\fR computes the shortest distance in pixels from
-the given point (\fIx, y\fR) to the characters in \fIlayout\fR.
-Newline/return characters and non-displaying space characters that occur at
-the end of individual lines in the text layout are ignored for hit detection
-purposes, but tab characters are not. The return value is 0 if the point
-actually hits the \fIlayout\fR. If the point didn't hit the \fIlayout\fR
-then the return value is the distance in pixels from the point to the
-\fIlayout\fR.
-.PP
-\fBTk_IntersectTextLayout\fR determines whether a \fIlayout\fR lies
-entirely inside, entirely outside, or overlaps a given rectangle.
-Newline/return characters and non-displaying space characters that occur
-at the end of individual lines in the \fIlayout\fR are ignored for
-intersection calculations. The return value is \-1 if the \fIlayout\fR is
-entirely outside of the rectangle, 0 if it overlaps, and 1 if it is
-entirely inside of the rectangle.
-.PP
-\fBTk_TextLayoutToPostscript\fR outputs code consisting of a Postscript
-array of strings that represent the individual lines in \fIlayout\fR. It
-is the responsibility of the caller to take the Postscript array of
-strings and add some Postscript function operate on the array to render
-each of the lines. The code that represents the Postscript array of
-strings is appended to \fIinterp->result\fR.
-.PP
-.SH DISPLAY MODEL
-When measuring a text layout, space characters that occur at the end of a
-line are ignored. The space characters still exist and the insertion point
-can be positioned amongst them, but their additional width is ignored when
-justifying lines or returning the total width of a text layout. All
-end-of-line space characters are considered to be attached to the right edge
-of the line; this behavior is logical for left-justified text and reasonable
-for center-justified text, but not very useful when editing right-justified
-text. Spaces are considered variable width characters; the first space that
-extends past the edge of the text layout is clipped to the edge, and any
-subsequent spaces on the line are considered zero width and pegged against
-the edge. Space characters that occur in the middle of a line of text are
-not suppressed and occupy their normal space width.
-.PP
-Tab characters are not ignored for measurement calculations. If wrapping
-is turned on and there are enough tabs on a line, the next tab will wrap
-to the beginning of the next line. There are some possible strange
-interactions between tabs and justification; tab positions are calculated
-and the line length computed in a left-justified world, and then the
-whole resulting line is shifted so it is centered or right-justified,
-causing the tab columns not to align any more.
-.PP
-When wrapping is turned on, lines may wrap at word breaks (space or tab
-characters) or newline/returns. A dash or hyphen character in the middle
-of a word is not considered a word break. \fBTk_ComputeTextLayout\fR
-always attempts to place at least one word on each line. If it cannot
-because the \fIwrapLength\fR is too small, the word will be broken and as
-much as fits placed on the line and the rest on subsequent line(s). If
-\fIwrapLength\fR is so small that not even one character can fit on a
-given line, the \fIwrapLength\fR is ignored for that line and one
-character will be placed on the line anyhow. When wrapping is turned
-off, only newline/return characters may cause a line break.
-.PP
-When a text layout has been created using an underlined \fItkfont\fR,
-then any space characters that occur at the end of individual lines,
-newlines/returns, and tabs will not be displayed underlined when
-\fBTk_DrawTextLayout\fR is called, because those characters are never
-actually drawn \- they are merely placeholders maintained in the
-\fIlayout\fR.
-.SH KEYWORDS
-font
diff --git a/doc/Tk_Init.3 b/doc/Tk_Init.3
deleted file mode 100644
index badcbe4..0000000
--- a/doc/Tk_Init.3
+++ /dev/null
@@ -1,47 +0,0 @@
-'\"
-'\" Copyright (c) 1995-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: Tk_Init.3,v 1.2 1998/09/14 18:22:54 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_Init 3 4.1 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_Init \- add Tk to an interpreter and make a new Tk application.
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-int
-\fBTk_Init\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.
-.BE
-
-.SH DESCRIPTION
-.PP
-\fBTk_Init\fR is the package initialization procedure for Tk.
-It is normally invoked by the \fBTcl_AppInit\fR procedure
-for an application or by the \fBload\fR command.
-\fBTk_Init\fR adds all of Tk's commands to \fIinterp\fR
-and creates a new Tk application, including its main window.
-If the initialization is successful \fBTk_Init\fR returns
-\fBTCL_OK\fR; if there is an error it returns \fBTCL_ERROR\fR.
-\fBTk_Init\fR also leaves a result or error message
-in \fIinterp->result\fR.
-.PP
-If there is a variable \fBargv\fR in \fIinterp\fR, \fBTk_Init\fR
-treats the contents of this variable as a list of options for the
-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).
-
-.SH KEYWORDS
-application, initialization, load, main window
diff --git a/doc/Tk_Main.3 b/doc/Tk_Main.3
deleted file mode 100644
index aebf8db..0000000
--- a/doc/Tk_Main.3
+++ /dev/null
@@ -1,61 +0,0 @@
-'\"
-'\" Copyright (c) 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: Tk_Main.3,v 1.2 1998/09/14 18:22:54 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_Main 3 4.0 Tk "Tk Library Procedures"
-.BS
-.SH NAME
-Tk_Main \- main program for Tk-based applications
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-\fBTk_Main\fR(\fIargc, argv, appInitProc\fR)
-.SH ARGUMENTS
-.AS Tcl_AppInitProc *appInitProc
-.AP int argc in
-Number of elements in \fIargv\fR.
-.AP char *argv[] in
-Array of strings containing command-line arguments.
-.AP Tcl_AppInitProc *appInitProc in
-Address of an application-specific initialization procedure.
-The value for this argument is usually \fBTcl_AppInit\fR.
-.BE
-
-.SH DESCRIPTION
-.PP
-\fBTk_Main\fR acts as the main program for most Tk-based applications.
-Starting with Tk 4.0 it is not called \fBmain\fR anymore because it
-is part of the Tk library and having a function \fBmain\fR
-in a library (particularly a shared library) causes problems on many
-systems.
-Having \fBmain\fR in the Tk library would also make it hard to use
-Tk in C++ programs, since C++ programs must have special C++
-\fBmain\fR functions.
-.PP
-Normally each application contains a small \fBmain\fR function that does
-nothing but invoke \fBTk_Main\fR.
-\fBTk_Main\fR then does all the work of creating and running a
-\fBwish\fR-like application.
-.PP
-When it is has finished its own initialization, but before
-it processes commands, \fBTk_Main\fR calls the procedure given by
-the \fIappInitProc\fR argument. This procedure provides a ``hook''
-for the application to perform its own initialization, such as defining
-application-specific commands. The procedure must have an interface
-that matches the type \fBTcl_AppInitProc\fR:
-.CS
-typedef int Tcl_AppInitProc(Tcl_Interp *\fIinterp\fR);
-.CE
-\fIAppInitProc\fR is almost always a pointer to \fBTcl_AppInit\fR;
-for more details on this procedure, see the documentation
-for \fBTcl_AppInit\fR.
-
-.SH KEYWORDS
-application-specific initialization, command-line arguments, main program
diff --git a/doc/WindowId.3 b/doc/WindowId.3
deleted file mode 100644
index 41a0ab5..0000000
--- a/doc/WindowId.3
+++ /dev/null
@@ -1,151 +0,0 @@
-'\"
-'\" 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: WindowId.3,v 1.2 1998/09/14 18:22:54 stanton Exp $
-'\"
-.so man.macros
-.TH Tk_WindowId 3 "" 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_IsMapped, Tk_IsTopLevel, Tk_ReqWidth, Tk_ReqHeight, Tk_InternalBorderWidth, Tk_Visual, Tk_Depth, Tk_Colormap \- retrieve information from Tk's local data structure
-.SH SYNOPSIS
-.nf
-\fB#include <tk.h>\fR
-.sp
-Window
-\fBTk_WindowId\fR(\fItkwin\fR)
-.sp
-Tk_Window
-\fBTk_Parent\fR(\fItkwin\fR)
-.sp
-Display *
-\fBTk_Display\fR(\fItkwin\fR)
-.sp
-char *
-\fBTk_DisplayName\fR(\fItkwin\fR)
-.sp
-int
-\fBTk_ScreenNumber\fR(\fItkwin\fR)
-.sp
-Screen *
-\fBTk_Screen\fR(\fItkwin\fR)
-.sp
-int
-\fBTk_X\fR(\fItkwin\fR)
-.sp
-int
-\fBTk_Y\fR(\fItkwin\fR)
-.sp
-int
-\fBTk_Width\fR(\fItkwin\fR)
-.sp
-int
-\fBTk_Height\fR(\fItkwin\fR)
-.sp
-XWindowChanges *
-\fBTk_Changes\fR(\fItkwin\fR)
-.sp
-XSetWindowAttributes *
-\fBTk_Attributes\fR(\fItkwin\fR)
-.sp
-int
-\fBTk_IsMapped\fR(\fItkwin\fR)
-.sp
-int
-\fBTk_IsTopLevel\fR(\fItkwin\fR)
-.sp
-int
-\fBTk_ReqWidth\fR(\fItkwin\fR)
-.sp
-int
-\fBTk_ReqHeight\fR(\fItkwin\fR)
-.sp
-int
-\fBTk_InternalBorderWidth\fR(\fItkwin\fR)
-.sp
-Visual *
-\fBTk_Visual\fR(\fItkwin\fR)
-.sp
-int
-\fBTk_Depth\fR(\fItkwin\fR)
-.sp
-Colormap
-\fBTk_Colormap\fR(\fItkwin\fR)
-.SH ARGUMENTS
-.AS Tk_Window tkwin
-.AP Tk_Window tkwin in
-Token for window.
-.BE
-
-.SH DESCRIPTION
-.PP
-\fBTk_WindowID\fR and the other names listed above are
-all macros that return fields from Tk's local data structure
-for \fItkwin\fR. None of these macros requires any
-interaction with the server; it is safe to assume that
-all are fast.
-.PP
-\fBTk_WindowId\fR returns the X identifier for \fItkwin\fR,
-or \fBNULL\fR if no X window has been created for \fItkwin\fR
-yet.
-.PP
-\fBTk_Parent\fR returns Tk's token for the logical parent of
-\fItkwin\fR. The parent is the token that was specified when
-\fItkwin\fR was created, or NULL for main windows.
-.PP
-\fBTk_Display\fR returns a pointer to the Xlib display structure
-corresponding to \fItkwin\fR. \fBTk_DisplayName\fR returns an
-ASCII string identifying \fItkwin\fR's display. \fBTk_ScreenNumber\fR
-returns the index of \fItkwin\fR's screen among all the screens
-of \fItkwin\fR's display. \fBTk_Screen\fR returns a pointer to
-the Xlib structure corresponding to \fItkwin\fR's screen.
-.PP
-\fBTk_X\fR, \fBTk_Y\fR, \fBTk_Width\fR, and \fBTk_Height\fR
-return information about \fItkwin's\fR location within its
-parent and its size. The location information refers to the
-upper-left pixel in the window, or its border if there is one.
-The width and height information refers to the interior size
-of the window, not including any border. \fBTk_Changes\fR
-returns a pointer to a structure containing all of the above
-information plus a few other fields. \fBTk_Attributes\fR
-returns a pointer to an XSetWindowAttributes structure describing
-all of the attributes of the \fItkwin\fR's window, such as background
-pixmap, event mask, and so on (Tk keeps track of all this information
-as it is changed by the application). Note: it is essential that
-applications use Tk procedures like \fBTk_ResizeWindow\fR instead
-of X procedures like \fBXResizeWindow\fR, so that Tk can keep its
-data structures up-to-date.
-.PP
-\fBTk_IsMapped\fR returns a non-zero value if \fItkwin\fR
-is mapped and zero if \fItkwin\fR isn't mapped.
-.PP
-\fBTk_IsTopLevel\fR returns a non-zero value if \fItkwin\fR
-is a top-level window (its X parent is the root window of the
-screen) and zero if \fItkwin\fR isn't a top-level window.
-.PP
-\fBTk_ReqWidth\fR and \fBTk_ReqHeight\fR return information about
-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.
-.PP
-\fBTk_Visual\fR, \fBTk_Depth\fR, and \fBTk_Colormap\fR return
-information about the visual characteristics of a window.
-\fBTk_Visual\fR returns the visual type for
-the window, \fBTk_Depth\fR returns the number of bits per pixel,
-and \fBTk_Colormap\fR returns the current
-colormap for the window. The visual characteristics are
-normally set from the defaults for the window's screen, but
-they may be overridden by calling \fBTk_SetWindowVisual\fR.
-
-.SH KEYWORDS
-attributes, colormap, depth, display, height, geometry manager,
-identifier, mapped, requested size, screen, top-level,
-visual, width, window, x, y
diff --git a/doc/bell.n b/doc/bell.n
deleted file mode 100644
index c3e0561..0000000
--- a/doc/bell.n
+++ /dev/null
@@ -1,34 +0,0 @@
-'\"
-'\" Copyright (c) 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: bell.n,v 1.2 1998/09/14 18:22:54 stanton Exp $
-'\"
-.so man.macros
-.TH bell n 4.0 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?
-.BE
-
-.SH DESCRIPTION
-.PP
-This command rings the bell on the display for \fIwindow\fR and
-returns an empty string.
-If the \fB\-displayof\fR option is omitted, the display of the
-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.
-
-.SH KEYWORDS
-beep, bell, ring
diff --git a/doc/bind.n b/doc/bind.n
deleted file mode 100644
index 199829c..0000000
--- a/doc/bind.n
+++ /dev/null
@@ -1,474 +0,0 @@
-'\"
-'\" Copyright (c) 1990 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: bind.n,v 1.2 1998/09/14 18:22:54 stanton Exp $
-'\"
-.so man.macros
-.TH bind n 4.1 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-bind \- Arrange for X events to invoke Tcl scripts
-.SH SYNOPSIS
-\fBbind\fI tag\fR
-.sp
-\fBbind\fI tag sequence\fR
-.sp
-\fBbind\fI tag sequence script\fR
-.sp
-\fBbind\fI tag sequence \fB+\fIscript\fR
-.BE
-
-.SH INTRODUCTION
-.PP
-The \fBbind\fR command associates Tcl scripts with X events.
-If all three arguments are specified, \fBbind\fR will
-arrange for \fIscript\fR (a Tcl script) to be evaluated whenever
-the event(s) given by \fIsequence\fR occur in the window(s)
-identified by \fItag\fR.
-If \fIscript\fR is prefixed with a ``+'', then it is appended to
-any existing binding for \fIsequence\fR; otherwise \fIscript\fR replaces
-any existing binding.
-If \fIscript\fR is an empty string then the current binding for
-\fIsequence\fR is destroyed, leaving \fIsequence\fR unbound.
-In all of the cases where a \fIscript\fR argument is provided,
-\fBbind\fR returns an empty string.
-.PP
-If \fIsequence\fR is specified without a \fIscript\fR, then the
-script currently bound to \fIsequence\fR is returned, or
-an empty string is returned if there is no binding for \fIsequence\fR.
-If neither \fIsequence\fR nor \fIscript\fR is specified, then the
-return value is a list whose elements are all the sequences
-for which there exist bindings for \fItag\fR.
-.PP
-The \fItag\fR argument determines which window(s) the binding applies to.
-If \fItag\fR begins with a dot, as in \fB.a.b.c\fR, then it must
-be the path name for a window; otherwise it may be an arbitrary
-string.
-Each window has an associated list of tags, and a binding applies
-to a particular window if its tag is among those specified for
-the window.
-Although the \fBbindtags\fR command may be used to assign an
-arbitrary set of binding tags to a window, the default binding
-tags provide the following behavior:
-.IP
-If a tag is the name of an internal window the binding applies
-to that window.
-.IP
-If the tag is the name of a toplevel window the binding applies
-to the toplevel window and all its internal windows.
-.IP
-If the tag is the name of a class of widgets, such as \fBButton\fR,
-the binding applies to all widgets in that class;
-.IP
-If \fItag\fR has the value \fBall\fR,
-the binding applies to all windows in the application.
-
-.SH "EVENT PATTERNS"
-.PP
-The \fIsequence\fR argument specifies a sequence of one or more
-event patterns, with optional white space between the patterns. Each
-.VS
-event pattern may
-take one of three forms. In the simplest case it is a single
-.VE
-printing ASCII character, such as \fBa\fR or \fB[\fR. The character
-may not be a space character or the character \fB<\fR. This form of
-pattern matches a \fBKeyPress\fR event for the particular
-character. The second form of pattern is longer but more general.
-It has the following syntax:
-.CS
-\fB<\fImodifier-modifier-type-detail\fB>\fR
-.CE
-The entire event pattern is surrounded by angle brackets.
-Inside the angle brackets are zero or more modifiers, an event
-type, and an extra piece of information (\fIdetail\fR) identifying
-a particular button or keysym. Any of the fields may be omitted,
-as long as at least one of \fItype\fR and \fIdetail\fR is present.
-The fields must be separated by white space or dashes.
-.VS
-.PP
-The third form of pattern is used to specify a user-defined, named virtual
-event. It has the following syntax:
-.CS
-\fB<<\fIname\fB>>\fR
-.CE
-The entire virtual event pattern is surrounded by double angle brackets.
-Inside the angle brackets is the user-defined name of the virtual event.
-Modifiers, such as \fBShift\fR or \fBControl\fR, may not be combined with a
-virtual event to modify it. Bindings on a virtual event may be created
-before the virtual event is defined, and if the definition of a virtual
-event changes dynamically, all windows bound to that virtual event will
-respond immediately to the new definition.
-.VE
-.SH "MODIFIERS"
-.PP
-Modifiers consist of any of the following values:
-.DS
-.ta 6c
-\fBControl\fR \fBMod2, M2\fR
-\fBShift\fR \fBMod3, M3\fR
-\fBLock\fR \fBMod4, M4\fR
-\fBButton1, B1\fR \fBMod5, M5\fR
-\fBButton2, B2\fR \fBMeta, M\fR
-\fBButton3, B3\fR \fBAlt\fR
-\fBButton4, B4\fR \fBDouble\fR
-\fBButton5, B5\fR \fBTriple\fR
-\fBMod1, M1\fR
-.DE
-Where more than one value is listed, separated by commas, the values
-are equivalent.
-Most of the modifiers have the obvious X meanings.
-For example, \fBButton1\fR requires that
-button 1 be depressed when the event occurs.
-For a binding to match a given event, the modifiers in the event
-must include all of those specified in the event pattern.
-An event may also contain additional modifiers not specified in
-the binding.
-For example, if button 1 is pressed while the shift and control keys
-are down, the pattern \fB<Control-Button-1>\fR will match
-the event, but \fB<Mod1-Button-1>\fR will not.
-If no modifiers are specified, then any combination of modifiers may
-be present in the event.
-.PP
-\fBMeta\fR and \fBM\fR refer to whichever of the
-\fBM1\fR through \fBM5\fR modifiers is associated with the meta
-key(s) on the keyboard (keysyms \fBMeta_R\fR and \fBMeta_L\fR).
-If there are no meta keys, or if they are not associated with any
-modifiers, then \fBMeta\fR and \fBM\fR will not match any events.
-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<Double-Button-1>\fR
-is equivalent to \fB<Button-1><Button-1>\fR with the extra
-time and space requirement.
-
-.SH "EVENT TYPES"
-.PP
-The \fItype\fR field may be any of the standard X event types, with a
-few extra abbreviations. Below is a list of all the valid types;
-where two names appear together, they are synonyms.
-.DS C
-.ta 5c 10c
-\fBButtonPress, Button Expose Map
-ButtonRelease FocusIn Motion
-Circulate FocusOut Property
-Colormap Gravity Reparent
-Configure KeyPress, Key Unmap
-Destroy KeyRelease Visibility
-Enter Leave Activate
-Deactivate\fR
-.DE
-.PP
-The last part of a long event specification is \fIdetail\fR. In the
-case of a \fBButtonPress\fR or \fBButtonRelease\fR event, it is the
-number of a button (1-5). If a button number is given, then only an
-event on that particular button will match; if no button number is
-given, then an event on any button will match. Note: giving a
-specific button number is different than specifying a button modifier;
-in the first case, it refers to a button being pressed or released,
-while in the second it refers to some other button that is already
-depressed when the matching event occurs. If a button
-number is given then \fItype\fR may be omitted: if will default
-to \fBButtonPress\fR. For example, the specifier \fB<1>\fR
-is equivalent to \fB<ButtonPress-1>\fR.
-.PP
-If the event type is \fBKeyPress\fR or \fBKeyRelease\fR, then
-\fIdetail\fR may be specified in the form of an X keysym. Keysyms
-are textual specifications for particular keys on the keyboard;
-they include all the alphanumeric ASCII characters (e.g. ``a'' is
-the keysym for the ASCII character ``a''), plus descriptions for
-non-alphanumeric characters (``comma'' is the keysym for the comma
-character), plus descriptions for all the non-ASCII keys on the
-keyboard (``Shift_L'' is the keysm for the left shift key, and
-``F1'' is the keysym for the F1 function key, if it exists). The
-complete list of keysyms is not presented here; it is
-available in other X documentation and may vary from system to
-system.
-If necessary, you can use the \fB%K\fR notation described below
-to print out the keysym name for a particular key.
-If a keysym \fIdetail\fR is given, then the
-\fItype\fR field may be omitted; it will default to \fBKeyPress\fR.
-For example, \fB<Control-comma>\fR is equivalent to
-\fB<Control-KeyPress-comma>\fR.
-
-.SH "BINDING SCRIPTS AND SUBSTITUTIONS"
-.PP
-The \fIscript\fR argument to \fBbind\fR is a Tcl script,
-which will be executed whenever the given event sequence occurs.
-\fICommand\fR will be executed in the same interpreter that the
-\fBbind\fR command was executed in, and it will run at global
-level (only global variables will be accessible).
-If \fIscript\fR contains
-any \fB%\fR characters, then the script will not be
-executed directly. Instead, a new script will be
-generated by replacing each \fB%\fR, and the character following
-it, with information from the current event. The replacement
-depends on the character following the \fB%\fR, as defined in the
-list below. Unless otherwise indicated, the
-replacement string is the decimal value of the given field from
-the current event.
-Some of the substitutions are only valid for
-certain types of events; if they are used for other types of events
-the value substituted is undefined.
-.IP \fB%%\fR 5
-Replaced with a single percent.
-.IP \fB%#\fR 5
-The number of the last client request processed by the server
-(the \fIserial\fR field from the event). Valid for all event
-types.
-.IP \fB%a\fR 5
-The \fIabove\fR field from the event,
-formatted as a hexadecimal number.
-Valid only for \fBConfigure\fR events.
-.IP \fB%b\fR 5
-The number of the button that was pressed or released. Valid only
-for \fBButtonPress\fR and \fBButtonRelease\fR events.
-.IP \fB%c\fR 5
-The \fIcount\fR field from the event. Valid only for \fBExpose\fR events.
-.IP \fB%d\fR 5
-The \fIdetail\fR field from the event. The \fB%d\fR is replaced by
-a string identifying the detail. For \fBEnter\fR,
-\fBLeave\fR, \fBFocusIn\fR, and \fBFocusOut\fR events,
-the string will be one of the following:
-.RS
-.DS
-.ta 6c
-\fBNotifyAncestor NotifyNonlinearVirtual
-NotifyDetailNone NotifyPointer
-NotifyInferior NotifyPointerRoot
-NotifyNonlinear NotifyVirtual\fR
-.DE
-For events other than these, the substituted string is undefined.
-.RE
-.IP \fB%f\fR 5
-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 only for \fBConfigure\fR and
-\fBExpose\fR events.
-.VE
-.IP \fB%k\fR 5
-The \fIkeycode\fR field from the event. Valid only for \fBKeyPress\fR
-and \fBKeyRelease\fR events.
-.IP \fB%m\fR 5
-The \fImode\fR field from the event. The substituted string is one of
-\fBNotifyNormal\fR, \fBNotifyGrab\fR, \fBNotifyUngrab\fR, or
-.VS
-\fBNotifyWhileGrabbed\fR. Valid only for \fBEnter\fR,
-\fBFocusIn\fR, \fBFocusOut\fR, and \fBLeave\fR events.
-.VE
-.IP \fB%o\fR 5
-The \fIoverride_redirect\fR field from the event. Valid only for
-\fBMap\fR, \fBReparent\fR, and \fBConfigure\fR events.
-.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.
-.IP \fB%s\fR 5
-The \fIstate\fR field from the event. For \fBButtonPress\fR,
-\fBButtonRelease\fR, \fBEnter\fR, \fBKeyPress\fR, \fBKeyRelease\fR,
-\fBLeave\fR, and \fBMotion\fR events, a decimal string
-is substituted. For \fBVisibility\fR, one of the strings
-\fBVisibilityUnobscured\fR, \fBVisibilityPartiallyObscured\fR,
-and \fBVisibilityFullyObscured\fR is substituted.
-.IP \fB%t\fR 5
-The \fItime\fR field from the event. Valid only for events that
-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.
-.VE
-.IP \fB%x\fR 5
-The \fIx\fR field from the event. Valid only for events containing
-an \fIx\fR field.
-.IP \fB%y\fR 5
-The \fIy\fR field from the event. Valid only for events containing
-a \fIy\fR field.
-.IP \fB%A\fR 5
-Substitutes the ASCII character corresponding to the event, or
-the empty string if the event doesn't correspond to an ASCII character
-(e.g. the shift key was pressed). \fBXLookupString\fR does all the
-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.
-.IP \fB%E\fR 5
-The \fIsend_event\fR field from the event. Valid for all event types.
-.IP \fB%K\fR 5
-The keysym corresponding to the event, substituted as a textual
-string. Valid only for \fBKeyPress\fR and \fBKeyRelease\fR events.
-.IP \fB%N\fR 5
-The keysym corresponding to the event, substituted as a decimal
-number. Valid only for \fBKeyPress\fR and \fBKeyRelease\fR events.
-.IP \fB%R\fR 5
-The \fIroot\fR window identifier from the event. Valid only for
-events containing a \fIroot\fR field.
-.IP \fB%S\fR 5
-The \fIsubwindow\fR window identifier from the event,
-formatted as a hexadecimal number.
-Valid only for events containing a \fIsubwindow\fR field.
-.IP \fB%T\fR 5
-The \fItype\fR field from the event. Valid for all event types.
-.IP \fB%W\fR 5
-The path name of the window to which the event was reported (the
-\fIwindow\fR field from the event). Valid for all event types.
-.IP \fB%X\fR 5
-The \fIx_root\fR field from the event.
-If a virtual-root window manager is being used then the substituted
-value is the corresponding x-coordinate in the virtual root.
-Valid only for
-\fBButtonPress\fR, \fBButtonRelease\fR, \fBKeyPress\fR, \fBKeyRelease\fR,
-and \fBMotion\fR events.
-.IP \fB%Y\fR 5
-The \fIy_root\fR field from the event.
-If a virtual-root window manager is being used then the substituted
-value is the corresponding y-coordinate in the virtual root.
-Valid only for
-\fBButtonPress\fR, \fBButtonRelease\fR, \fBKeyPress\fR, \fBKeyRelease\fR,
-and \fBMotion\fR events.
-.LP
-The replacement string for a %-replacement is formatted as a proper
-Tcl list element.
-This means that it will be surrounded with braces
-if it contains spaces, or special characters such as \fB$\fR and
-\fB{\fR may be preceded by backslashes.
-This guarantees that the string will be passed through the Tcl
-parser when the binding script is evaluated.
-Most replacements are numbers or well-defined strings such
-as \fBAbove\fR; for these replacements no special formatting
-is ever necessary.
-The most common case where reformatting occurs is for the \fB%A\fR
-substitution. For example, if \fIscript\fR is
-.CS
-\fBinsert\0%A\fR
-.CE
-and the character typed is an open square bracket, then the script
-actually executed will be
-.CS
-\fBinsert\0\e[\fR
-.CE
-This will cause the \fBinsert\fR to receive the original replacement
-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
-.PP
-It is possible for several bindings to match a given X event.
-If the bindings are associated with different \fItag\fR's,
-then each of the bindings will be executed, in order.
-By default, a binding for the widget will be executed first, followed
-by a class binding, a binding for its toplevel, and
-an \fBall\fR binding.
-The \fBbindtags\fR command may be used to change this order for
-a particular window or to associate additional binding tags with
-the window.
-.PP
-The \fBcontinue\fR and \fBbreak\fR commands may be used inside a
-binding script to control the processing of matching scripts.
-If \fBcontinue\fR is invoked, then the current binding script
-is terminated but Tk will continue processing binding scripts
-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
-is chosen and its script is evaluated.
-The following tests are applied, in order, to determine which of
-several matching sequences is more specific:
-(a) an event pattern that specifies a specific button or key is more specific
-than one that doesn't;
-(b) a longer sequence (in terms of number
-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.
-(e) given a sequence that matches two or more virtual events, one
-of the virtual events will be chosen, but the order is undefined.
-.PP
-If the matching sequences contain more than one event, then tests
-(c)-(e) are applied in order from the most recent event to the least recent
-event in the sequences. If these tests fail to determine a winner, then the
-most recently registered sequence is the winner.
-.PP
-If there are two (or more) virtual events that are both triggered by the
-same sequence, and both of those virtual events are bound to the same window
-tag, then only one of the virtual events will be triggered, and it will
-be picked at random:
-.CS
-event add <<Paste>> <Control-y>
-event add <<Paste>> <Button-2>
-event add <<Scroll>> <Button-2>
-bind Entry <<Paste>> {puts Paste}
-bind Entry <<Scroll>> {puts Scroll}
-.CE
-If the user types Control-y, the \fB<<Paste>>\fR binding
-will be invoked, but if the user presses button 2 then one of
-either the \fB<<Paste>>\fR or the \fB<<Scroll>>\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.
-An unbound event is not considered to be an error.
-
-.SH "MULTI-EVENT SEQUENCES AND IGNORED EVENTS"
-.PP
-When a \fIsequence\fR specified in a \fBbind\fR command contains
-more than one event pattern, then its script is executed whenever
-the recent events (leading up to and including the current event)
-match the given sequence. This means, for example, that if button 1 is
-clicked repeatedly the sequence \fB<Double-ButtonPress-1>\fR will match
-each button press but the first.
-If extraneous events that would prevent a match occur in the middle
-of an event sequence then the extraneous events are
-ignored unless they are \fBKeyPress\fR or \fBButtonPress\fR events.
-For example, \fB<Double-ButtonPress-1>\fR will match a sequence of
-presses of button 1, even though there will be \fBButtonRelease\fR
-events (and possibly \fBMotion\fR events) between the
-\fBButtonPress\fR events.
-Furthermore, a \fBKeyPress\fR event may be preceded by any number
-of other \fBKeyPress\fR events for modifier keys without the
-modifier keys preventing a match.
-For example, the event sequence \fBaB\fR will match a press of the
-\fBa\fR key, a release of the \fBa\fR key, a press of the \fBShift\fR
-key, and a press of the \fBb\fR key: the press of \fBShift\fR is
-ignored because it is a modifier key.
-Finally, if several \fBMotion\fR events occur in a row, only
-the last one is used for purposes of matching binding sequences.
-
-.SH ERRORS
-.PP
-If an error occurs in executing the script for a binding then the
-\fBbgerror\fR mechanism is used to report the error.
-The \fBbgerror\fR command will be executed at global level
-(outside the context of any Tcl procedure).
-
-.SH "SEE ALSO"
-bgerror
-
-.SH KEYWORDS
-form, manual
diff --git a/doc/bindtags.n b/doc/bindtags.n
deleted file mode 100644
index 7314dc3..0000000
--- a/doc/bindtags.n
+++ /dev/null
@@ -1,81 +0,0 @@
-'\"
-'\" Copyright (c) 1990 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: bindtags.n,v 1.2 1998/09/14 18:22:54 stanton Exp $
-'\"
-.so man.macros
-.TH bindtags n 4.0 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-bindtags \- Determine which bindings apply to a window, and order of evaluation
-.SH SYNOPSIS
-\fBbindtags \fIwindow \fR?\fItagList\fR?
-.BE
-
-.SH DESCRIPTION
-.PP
-When a binding is created with the \fBbind\fR command, it is
-associated either with a particular window such as \fB.a.b.c\fR,
-a class name such as \fBButton\fR, the keyword \fBall\fR, or any
-other string.
-All of these forms are called \fIbinding tags\fR.
-Each window contains a list of binding tags that determine how
-events are processed for the window.
-When an event occurs in a window, it is applied to each of the
-window's tags in order: for each tag, the most specific binding
-that matches the given tag and event is executed.
-See the \fBbind\fR command for more information on the matching
-process.
-.PP
-By default, each window has four binding tags consisting of the
-name of the window, the window's class name, the name of the window's
-nearest toplevel ancestor, and \fBall\fR, in that order.
-Toplevel windows have only three tags by default, since the toplevel
-name is the same as that of the window.
-The \fBbindtags\fR command allows the binding tags for a window to be
-read and modified.
-.PP
-If \fBbindtags\fR is invoked with only one argument, then the
-current set of binding tags for \fIwindow\fR is returned as a list.
-If the \fItagList\fR argument is specified to \fBbindtags\fR,
-then it must be a proper list; the tags for \fIwindow\fR are changed
-to the elements of the list.
-The elements of \fItagList\fR may be arbitrary strings; however,
-any tag starting with a dot is treated as the name of a window; if
-no window by that name exists at the time an event is processed,
-then the tag is ignored for that event.
-The order of the elements in \fItagList\fR determines the order in
-which binding scripts are executed in response to events.
-For example, the command
-.CS
-\fBbindtags .b {all . Button .b}\fR
-.CE
-reverses the order in which binding scripts will be evaluated for
-a button named \fB.b\fR so that \fBall\fR bindings are invoked
-first, following by bindings for \fB.b\fR's toplevel (``.''), followed by
-class bindings, followed by bindings for \fB.b\fR.
-If \fItagList\fR is an empty list then the binding tags for \fIwindow\fR
-are returned to the default state described above.
-.PP
-The \fBbindtags\fR command may be used to introduce arbitrary
-additional binding tags for a window, or to remove standard tags.
-For example, the command
-.CS
-\fBbindtags .b {.b TrickyButton . all}\fR
-.CE
-replaces the \fBButton\fR tag for \fB.b\fR with \fBTrickyButton\fR.
-This means that the default widget bindings for buttons, which are
-associated with the \fBButton\fR tag, will no longer apply to \fB.b\fR,
-but any bindings associated with \fBTrickyButton\fR (perhaps some
-new button behavior) will apply.
-
-.SH "SEE ALSO"
-bind
-
-.SH KEYWORDS
-binding, event, tag
diff --git a/doc/bitmap.n b/doc/bitmap.n
deleted file mode 100644
index 3eb29e6..0000000
--- a/doc/bitmap.n
+++ /dev/null
@@ -1,114 +0,0 @@
-'\"
-'\" Copyright (c) 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: bitmap.n,v 1.2 1998/09/14 18:22:54 stanton Exp $
-'\"
-.so man.macros
-.TH bitmap n 4.0 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-bitmap \- Images that display two colors
-.SH SYNOPSIS
-\fBimage create bitmap \fR?\fIname\fR? ?\fIoptions\fR?
-.BE
-
-.SH DESCRIPTION
-.PP
-A bitmap is an image whose pixels can display either of two colors
-or be transparent.
-A bitmap image is defined by four things: a background color,
-a foreground color, and two bitmaps, called the \fIsource\fR
-and the \fImask\fR.
-Each of the bitmaps specifies 0/1 values for a rectangular
-array of pixels, and the two bitmaps must have the same
-dimensions.
-For pixels where the mask is zero, the image displays nothing,
-producing a transparent effect.
-For other pixels, the image displays the foreground color if
-the source data is one and the background color if the source
-data is zero.
-
-.SH "CREATING BITMAPS"
-.PP
-Like all images, bitmaps are created using the \fBimage create\fR
-command.
-Bitmaps support the following \fIoptions\fR:
-.TP
-\fB\-background \fIcolor\fR
-Specifies a background color for the image in any of the standard
-ways accepted by Tk. If this option is set to an empty string
-then the background pixels will be transparent. This effect
-is achieved by using the source bitmap as the mask bitmap, ignoring
-any \fB\-maskdata\fR or \fB\-maskfile\fR options.
-.TP
-\fB\-data \fIstring\fR
-Specifies the contents of the source bitmap as a string.
-The string must adhere to X11 bitmap format (e.g., as generated
-by the \fBbitmap\fR program).
-If both the \fB\-data\fR and \fB\-file\fR options are specified,
-the \fB\-data\fR option takes precedence.
-.TP
-\fB\-file \fIname\fR
-\fIname\fR gives the name of a file whose contents define the
-source bitmap.
-The file must adhere to X11 bitmap format (e.g., as generated
-by the \fBbitmap\fR program).
-.TP
-\fB\-foreground \fIcolor\fR
-Specifies a foreground color for the image in any of the standard
-ways accepted by Tk.
-.TP
-\fB\-maskdata \fIstring\fR
-Specifies the contents of the mask as a string.
-The string must adhere to X11 bitmap format (e.g., as generated
-by the \fBbitmap\fR program).
-If both the \fB\-maskdata\fR and \fB\-maskfile\fR options are specified,
-the \fB\-maskdata\fR option takes precedence.
-.TP
-\fB\-maskfile \fIname\fR
-\fIname\fR gives the name of a file whose contents define the
-mask.
-The file must adhere to X11 bitmap format (e.g., as generated
-by the \fBbitmap\fR program).
-
-.SH "IMAGE COMMAND"
-.PP
-When a bitmap image is created, Tk also creates a new command
-whose name is the same as the image.
-This command may be used to invoke various operations
-on the image.
-It has the following general form:
-.CS
-\fIimageName option \fR?\fIarg arg ...\fR?
-.CE
-\fIOption\fR and the \fIarg\fRs
-determine the exact behavior of the command. The following
-commands are possible for bitmap images:
-.TP
-\fIimageName \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
-\fBimage create bitmap\fR command.
-.TP
-\fIimageName \fBconfigure\fR ?\fIoption\fR? ?\fIvalue option value ...\fR?
-Query or modify the configuration options for the image.
-If no \fIoption\fR is specified, returns a list describing all of
-the available options for \fIimageName\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 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
-\fBimage create bitmap\fR command.
-
-.SH KEYWORDS
-bitmap, image
diff --git a/doc/button.n b/doc/button.n
deleted file mode 100644
index aecb556..0000000
--- a/doc/button.n
+++ /dev/null
@@ -1,176 +0,0 @@
-'\"
-'\" 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: button.n,v 1.2 1998/09/14 18:22:55 stanton Exp $
-'\"
-.so man.macros
-.TH button n 4.4 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-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
-.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.
-.OP \-default default Default
-.VS
-Specifies one of three states for the default ring: \fBnormal\fR,
-\fBactive\fR, or \fBdisabled\fR. In active state, the button is drawn
-with the platform specific appearance for a default button. In normal
-state, the button is drawn with the platform specific appearance for a
-non-default button, leaving enough space to draw the default button
-appearance. The normal and active states will result in buttons of
-the same size. In disabled state, the button is drawn with the
-non-default button appearance without leaving space for the default
-appearance. The disabled state may result in a smaller button than
-the active state.
-ring.
-.VE
-.OP \-height height Height
-Specifies a desired height for the button.
-If an image or bitmap is being displayed in the button then the value is in
-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.
-.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
-\fBforeground\fR and \fBbackground\fR options. The active state is
-typically used when the pointer is over the button. In active state
-the button is displayed using the \fBactiveForeground\fR and
-\fBactiveBackground\fR options. Disabled state means that the button
-should be insensitive: the default bindings will refuse to activate
-the widget and will ignore mouse button presses.
-In this state the \fBdisabledForeground\fR and
-\fBbackground\fR options determine how the button is displayed.
-.OP \-width width Width
-Specifies a desired width for the button.
-If an image or bitmap is being displayed in the button then the value is in
-screen units (i.e. any of the forms acceptable to \fBTk_GetPixels\fR);
-for text it is in characters.
-If this option isn't specified, the button's desired width is computed
-from the size of the image or bitmap or text being displayed in it.
-.BE
-
-.SH DESCRIPTION
-.PP
-The \fBbutton\fR command creates a new window (given by the
-\fIpathName\fR argument) and makes it into a button widget.
-Additional
-options, described above, may be specified on the command line
-or in the option database
-to configure aspects of the button such as its colors, font,
-text, and initial relief. The \fBbutton\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 button is a widget that displays a textual string, bitmap or image.
-If text is displayed, it must all be in a single font, but it
-can occupy multiple lines on the screen (if it contains newlines
-or if wrapping occurs because of the \fBwrapLength\fR option) and
-one of the characters may optionally be underlined using the
-\fBunderline\fR option.
-It can display itself in either of three different ways, according
-to
-the \fBstate\fR option;
-it can be made to appear raised, sunken, or flat;
-and it can be made to flash. When a user invokes the
-button (by pressing mouse button 1 with the cursor over the
-button), then the Tcl command specified in the \fB\-command\fR
-option is invoked.
-
-.SH "WIDGET COMMAND"
-.PP
-The \fBbutton\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. The following
-commands are possible for button 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 \fBbutton\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 \fBbutton\fR
-command.
-.TP
-\fIpathName \fBflash\fR
-Flash the button. This is accomplished by redisplaying the button
-several times, alternating between active and normal colors. At
-the end of the flash the button is left in the same normal/active
-state as when the command was invoked.
-This command is ignored if the button's state is \fBdisabled\fR.
-.TP
-\fIpathName \fBinvoke\fR
-Invoke the Tcl command associated with the button, if there is one.
-The return value is the return value from the Tcl command, or an
-empty string if there is no command associated with the button.
-This command is ignored if the button's state is \fBdisabled\fR.
-
-.SH "DEFAULT BINDINGS"
-.PP
-Tk automatically creates class bindings for buttons that give them
-default behavior:
-.IP [1]
-A button activates whenever the mouse passes over it and deactivates
-whenever the mouse leaves the button.
-.VS
-Under Windows, this binding is only active when mouse button 1 has
-been pressed over the button.
-.VE
-.IP [2]
-A button's relief is changed to sunken whenever mouse button 1 is
-pressed over the button, and the relief is restored to its original
-value when button 1 is later released.
-.IP [3]
-If mouse button 1 is pressed over a button and later released over
-the button, the button is invoked. However, if the mouse is not
-over the button when button 1 is released, then no invocation occurs.
-.IP [4]
-When a button has the input focus, the space key causes the button
-to be invoked.
-.PP
-If the button's state is \fBdisabled\fR then none of the above
-actions occur: the button is completely non-responsive.
-.PP
-The behavior of buttons can be changed by defining new bindings for
-individual widgets or by redefining the class bindings.
-
-.SH KEYWORDS
-button, widget
diff --git a/doc/canvas.n b/doc/canvas.n
deleted file mode 100644
index 98ba165..0000000
--- a/doc/canvas.n
+++ /dev/null
@@ -1,1576 +0,0 @@
-'\"
-'\" 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.
-'\"
-'\" RCS: @(#) $Id: canvas.n,v 1.2 1998/09/14 18:22:55 stanton Exp $
-'\"
-.so man.macros
-.TH canvas n 4.0 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-canvas \- Create and manipulate canvas widgets
-.SH SYNOPSIS
-\fBcanvas\fR \fIpathName \fR?\fIoptions\fR?
-.SO
-\-background \-highlightthickness \-insertwidth \-takefocus
-\-borderwidth \-insertbackground \-relief \-xscrollcommand
-\-cursor \-insertborderwidth \-selectbackground \-yscrollcommand
-\-highlightbackground \-insertofftime \-selectborderwidth
-\-highlightcolor \-insertontime \-selectforeground
-.SE
-.SH "WIDGET-SPECIFIC OPTIONS"
-.OP \-closeenough closeEnough CloseEnough
-Specifies a floating-point value indicating how close the mouse cursor
-must be to an item before it is considered to be ``inside'' the item.
-Defaults to 1.0.
-.OP \-confine confine Confine
-Specifies a boolean value that indicates whether or not it should be
-allowable to set the canvas's view outside the region defined by the
-\fBscrollRegion\fR argument.
-Defaults to true, which means that the view will
-be constrained within the scroll region.
-.OP \-height height Height
-Specifies a desired window height that the canvas widget should request from
-its geometry manager. The value may be specified in any
-of the forms described in the COORDINATES section below.
-.OP \-scrollregion scrollRegion ScrollRegion
-Specifies a list with four coordinates describing the left, top, right, and
-bottom coordinates of a rectangular region.
-This region is used for scrolling purposes and is considered to be
-the boundary of the information in the canvas.
-Each of the coordinates may be specified
-in any of the forms given in the COORDINATES section below.
-.OP \-width width width
-Specifies a desired window width that the canvas widget should request from
-its geometry manager. The value may be specified in any
-of the forms described in the COORDINATES section below.
-.br
-.OP \-xscrollincrement xScrollIncrement ScrollIncrement
-Specifies an increment for horizontal scrolling, in any of the usual forms
-permitted for screen distances. If the value of this option is greater
-than zero, the horizontal view in the window will be constrained so that
-the canvas x coordinate at the left edge of the window is always an even
-multiple of \fBxScrollIncrement\fR; furthermore, the units for scrolling
-(e.g., the change in view when the left and right arrows of a scrollbar
-are selected) will also be \fBxScrollIncrement\fR. If the value of
-this option is less than or equal to zero, then horizontal scrolling
-is unconstrained.
-.OP \-yscrollincrement yScrollIncrement ScrollIncrement
-Specifies an increment for vertical scrolling, in any of the usual forms
-permitted for screen distances. If the value of this option is greater
-than zero, the vertical view in the window will be constrained so that
-the canvas y coordinate at the top edge of the window is always an even
-multiple of \fByScrollIncrement\fR; furthermore, the units for scrolling
-(e.g., the change in view when the top and bottom arrows of a scrollbar
-are selected) will also be \fByScrollIncrement\fR. If the value of
-this option is less than or equal to zero, then vertical scrolling
-is unconstrained.
-.BE
-
-.SH INTRODUCTION
-.PP
-The \fBcanvas\fR command creates a new window (given
-by the \fIpathName\fR argument) and makes it into a canvas widget.
-Additional options, described above, may be specified on the
-command line or in the option database
-to configure aspects of the canvas such as its colors and 3-D relief.
-The \fBcanvas\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
-Canvas widgets implement structured graphics.
-A canvas displays any number of \fIitems\fR, which may be things like
-rectangles, circles, lines, and text.
-Items may be manipulated (e.g. moved or re-colored) and commands may
-be associated with items in much the same way that the \fBbind\fR
-command allows commands to be bound to widgets. For example,
-a particular command may be associated with the <Button-1> event
-so that the command is invoked whenever button 1 is pressed with
-the mouse cursor over an item.
-This means that items in a canvas can have behaviors defined by
-the Tcl scripts bound to them.
-
-.SH "DISPLAY LIST"
-.PP
-The items in a canvas are ordered for purposes of display,
-with the first item in the display list being displayed
-first, followed by the next item in the list, and so on.
-Items later in the display list obscure those that are
-earlier in the display list and are sometimes referred to
-as being ``on top'' of earlier items.
-When a new item is created it is placed at the end of the
-display list, on top of everything else.
-Widget commands may be used to re-arrange the order of the
-display list.
-.PP
-Window items are an exception to the above rules. The underlying
-window systems require them always to be drawn on top of other items.
-In addition, the stacking order of window items
-is not affected by any of the canvas widget commands; you must use
-the \fBraise\fR and \fBlower\fR Tk commands instead.
-
-.SH "ITEM IDS AND TAGS"
-.PP
-Items in a canvas widget may be named in either of two ways:
-by id or by tag.
-Each item has a unique identifying number which is assigned to
-that item when it is created. The id of an item never changes
-and id numbers are never re-used within the lifetime of a
-canvas widget.
-.PP
-Each item may also have any number of \fItags\fR associated
-with it. A tag is just a string of characters, and it may
-take any form except that of an integer.
-For example, ``x123'' is OK but ``123'' isn't.
-The same tag may be associated with many different items.
-This is commonly done to group items in various interesting
-ways; for example, all selected items might be given the
-tag ``selected''.
-.PP
-The tag \fBall\fR is implicitly associated with every item
-in the canvas; it may be used to invoke operations on
-all the items in the canvas.
-.PP
-The tag \fBcurrent\fR is managed automatically by Tk;
-it applies to the \fIcurrent item\fR, which is the
-topmost item whose drawn area covers the position of
-the mouse cursor.
-If the mouse is not in the canvas widget or is not over
-an item, then no item has the \fBcurrent\fR tag.
-.PP
-When specifying items in canvas widget commands, if the
-specifier is an integer then it is assumed to refer to
-the single item with that id.
-If the specifier is not an integer, then it is assumed to
-refer to all of the items in the canvas that have a tag
-matching the specifier.
-The symbol \fItagOrId\fR is used below to indicate that
-an argument specifies either an id that selects a single
-item or a tag that selects zero or more items.
-Some widget commands only operate on a single item at a
-time; if \fItagOrId\fR is specified in a way that
-names multiple items, then the normal behavior is for
-the command to use the first (lowest) of these items in
-the display list that is suitable for the command.
-Exceptions are noted in the widget command descriptions
-below.
-
-.SH "COORDINATES"
-.PP
-All coordinates related to canvases are stored as floating-point
-numbers.
-Coordinates and distances are specified in screen units,
-which are floating-point numbers optionally followed
-by one of several letters.
-If no letter is supplied then the distance is in pixels.
-If the letter is \fBm\fR then the distance is in millimeters on
-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.
-
-.SH TRANSFORMATIONS
-.PP
-Normally the origin of the canvas coordinate system is at the
-upper-left corner of the window containing the canvas.
-It is possible to adjust the origin of the canvas
-coordinate system relative to the origin of the window using the
-\fBxview\fR and \fByview\fR widget commands; this is typically used
-for scrolling.
-Canvases do not support scaling or rotation of the canvas coordinate
-system relative to the window coordinate system.
-.PP
-Individual items may be moved or scaled using widget commands
-described below, but they may not be rotated.
-
-.SH "INDICES"
-.PP
-Text items support the notion of an \fIindex\fR for identifying
-particular positions within the item.
-Indices are used for commands such as inserting text, deleting
-a range of characters, and setting the insertion cursor position.
-An index may be specified in any of a number of ways, and
-different types of items may support different forms for
-specifying indices.
-Text items support the following forms for an index; if you
-define new types of text-like items, it would be advisable to
-support as many of these forms as practical.
-Note that it is possible to refer to the character just after
-the last one in the text item; this is necessary for such
-tasks as inserting new text at the end of the item.
-.TP 10
-\fInumber\fR
-A decimal number giving the position of the desired character
-within the text item.
-0 refers to the first character, 1 to the next character, and
-so on.
-A number less than 0 is treated as if it were zero, and a
-number greater than the length of the text item is treated
-as if it were equal to the length of the text item.
-.TP 10
-\fBend\fR
-Refers to the character just after the last one in the item
-(same as the number of characters in the item).
-.TP 10
-\fBinsert\fR
-Refers to the character just before which the insertion cursor
-is drawn in this item.
-.TP 10
-\fBsel.first\fR
-Refers to the first selected character in the item.
-If the selection isn't in this item then this form is illegal.
-.TP 10
-\fBsel.last\fR
-Refers to the last selected character in the item.
-If the selection isn't in this item then this form is illegal.
-.TP 10
-\fB@\fIx,y\fR
-Refers to the character at the point given by \fIx\fR and
-\fIy\fR, where \fIx\fR and \fIy\fR are specified in the coordinate
-system of the canvas.
-If \fIx\fR and \fIy\fR lie outside the coordinates covered by the
-text item, then they refer to the first or last character in the
-line that is closest to the given point.
-
-.SH "WIDGET COMMAND"
-.PP
-The \fBcanvas\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.
-The following widget commands are possible for canvas widgets:
-.TP
-\fIpathName \fBaddtag \fItag searchSpec \fR?\fIarg arg ...\fR?
-For each item that meets the constraints specified by
-\fIsearchSpec\fR and the \fIarg\fRs, add
-\fItag\fR to the list of tags associated with the item if it
-isn't already present on that list.
-It is possible that no items will satisfy the constraints
-given by \fIsearchSpec\fR and \fIarg\fRs, in which case the
-command has no effect.
-This command returns an empty string as result.
-\fISearchSpec\fR and \fIarg\fR's may take any of the following
-forms:
-.RS
-.TP
-\fBabove \fItagOrId\fR
-Selects the item just after (above) the one given by \fItagOrId\fR
-in the display list.
-If \fItagOrId\fR denotes more than one item, then the last (topmost)
-of these items in the display list is used.
-.TP
-\fBall\fR
-Selects all the items in the canvas.
-.TP
-\fBbelow \fItagOrId\fR
-Selects the item just before (below) the one given by \fItagOrId\fR
-in the display list.
-If \fItagOrId\fR denotes more than one item, then the first (lowest)
-of these items in the display list is used.
-.TP
-\fBclosest \fIx y \fR?\fIhalo\fR? ?\fIstart\fR?
-Selects the item closest to the point given by \fIx\fR and \fIy\fR.
-If more than one item is at the same closest distance (e.g. two
-items overlap the point), then the top-most of these items (the
-last one in the display list) is used.
-If \fIhalo\fR is specified, then it must be a non-negative
-value.
-Any item closer than \fIhalo\fR to the point is considered to
-overlap it.
-The \fIstart\fR argument may be used to step circularly through
-all the closest items.
-If \fIstart\fR is specified, it names an item using a tag or id
-(if by tag, it selects the first item in the display list with
-the given tag).
-Instead of selecting the topmost closest item, this form will
-select the topmost closest item that is below \fIstart\fR in
-the display list; if no such item exists, then the selection
-behaves as if the \fIstart\fR argument had not been specified.
-.TP
-\fBenclosed\fR \fIx1\fR \fIy1\fR \fIx2\fR \fIy2\fR
-Selects all the items completely enclosed within the rectangular
-region given by \fIx1\fR, \fIy1\fR, \fIx2\fR, and \fIy2\fR.
-\fIX1\fR must be no greater then \fIx2\fR and \fIy1\fR must be
-no greater than \fIy2\fR.
-.TP
-\fBoverlapping\fR \fIx1\fR \fIy1\fR \fIx2\fR \fIy2\fR
-Selects all the items that overlap or are enclosed within the
-rectangular region given by \fIx1\fR, \fIy1\fR, \fIx2\fR,
-and \fIy2\fR.
-\fIX1\fR must be no greater then \fIx2\fR and \fIy1\fR must be
-no greater than \fIy2\fR.
-.TP
-\fBwithtag \fItagOrId\fR
-Selects all the items given by \fItagOrId\fR.
-.RE
-.TP
-\fIpathName \fBbbox \fItagOrId\fR ?\fItagOrId tagOrId ...\fR?
-Returns a list with four elements giving an approximate bounding box
-for all the items named by the \fItagOrId\fR arguments.
-The list has the form ``\fIx1 y1 x2 y2\fR'' such that the drawn
-areas of all the named elements are within the region bounded by
-\fIx1\fR on the left, \fIx2\fR on the right, \fIy1\fR on the top,
-and \fIy2\fR on the bottom.
-The return value may overestimate the actual bounding box by
-a few pixels.
-If no items match any of the \fItagOrId\fR arguments or if the
-matching items have empty bounding boxes (i.e. they have nothing
-to display)
-then an empty string is returned.
-.TP
-\fIpathName \fBbind \fItagOrId\fR ?\fIsequence\fR? ?\fIcommand\fR?
-This command associates \fIcommand\fR with all the items given by
-\fItagOrId\fR such that whenever the event sequence given by
-\fIsequence\fR occurs for one of the items the command will
-be invoked.
-This widget command is similar to the \fBbind\fR command except that
-it operates on items in a canvas rather than entire widgets.
-See the \fBbind\fR manual entry for complete details
-on the syntax of \fIsequence\fR and the substitutions performed
-on \fIcommand\fR before invoking it.
-If all arguments are specified then a new binding is created, replacing
-any existing binding for the same \fIsequence\fR and \fItagOrId\fR
-(if the first character of \fIcommand\fR is ``+'' then \fIcommand\fR
-augments an existing binding rather than replacing it).
-In this case the return value is an empty string.
-If \fIcommand\fR is omitted then the command returns the \fIcommand\fR
-associated with \fItagOrId\fR and \fIsequence\fR (an error occurs
-if there is no such binding).
-If both \fIcommand\fR and \fIsequence\fR are omitted then the command
-returns a list of all the sequences for which bindings have been
-defined for \fItagOrId\fR.
-.RS
-.PP
-.VS
-The only events for which bindings may be specified are those related to
-the mouse and keyboard (such as \fBEnter\fR, \fBLeave\fR,
-\fBButtonPress\fR, \fBMotion\fR, and \fBKeyPress\fR) or virtual events.
-The handling of events in canvases uses the current item defined in ITEM
-IDS AND TAGS above. \fBEnter\fR and \fBLeave\fR events trigger for an
-item when it becomes the current item or ceases to be the current item;
-note that these events are different than \fBEnter\fR and \fBLeave\fR
-events for windows. Mouse-related events are directed to the current
-item, if any. Keyboard-related events are directed to the focus item, if
-any (see the \fBfocus\fR widget command below for more on this). If a
-virtual event is used in a binding, that binding can trigger only if the
-virtual event is defined by an underlying mouse-related or
-keyboard-related event.
-.VE
-.PP
-It is possible for multiple bindings to match a particular event.
-This could occur, for example, if one binding is associated with the
-item's id and another is associated with one of the item's tags.
-When this occurs, all of the matching bindings are invoked.
-A binding associated with the \fBall\fR tag is invoked first,
-followed by one binding for each of the item's tags (in order),
-followed by a binding associated with the item's id.
-If there are multiple matching bindings for a single tag,
-then only the most specific binding is invoked.
-A \fBcontinue\fR command in a binding script terminates that
-script, and a \fBbreak\fR command terminates that script
-and skips any remaining scripts for the event, just as for the
-\fBbind\fR command.
-.PP
-If bindings have been created for a canvas window using the \fBbind\fR
-command, then they are invoked in addition to bindings created for
-the canvas's items using the \fBbind\fR widget command.
-The bindings for items will be invoked before any of the bindings
-for the window as a whole.
-.RE
-.TP
-\fIpathName \fBcanvasx \fIscreenx\fR ?\fIgridspacing\fR?
-Given a window x-coordinate in the canvas \fIscreenx\fR, this command returns
-the canvas x-coordinate that is displayed at that location.
-If \fIgridspacing\fR is specified, then the canvas coordinate is
-rounded to the nearest multiple of \fIgridspacing\fR units.
-.TP
-\fIpathName \fBcanvasy \fIscreeny\fR ?\fIgridspacing\fR?
-Given a window y-coordinate in the canvas \fIscreeny\fR this command returns
-the canvas y-coordinate that is displayed at that location.
-If \fIgridspacing\fR is specified, then the canvas coordinate is
-rounded to the nearest multiple of \fIgridspacing\fR units.
-.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 \fBcanvas\fR
-command.
-.TP
-\fIpathName \fBconfigure ?\fIoption\fR? ?\fIvalue\fR? ?\fIoption 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 \fBcanvas\fR
-command.
-.TP
-\fIpathName\fR \fBcoords \fItagOrId \fR?\fIx0 y0 ...\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
-\fItagOrId\fR.
-If coordinates are specified, then they replace the current
-coordinates for the named item.
-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?
-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
-one or more points, followed by specifications for zero or
-more item options.
-See the subsections on individual item types below for more
-on the syntax of this command.
-This command returns the id for the new item.
-.TP
-\fIpathName \fBdchars \fItagOrId first \fR?\fIlast\fR?
-For each item given by \fItagOrId\fR, delete the characters
-in the range given by \fIfirst\fR and \fIlast\fR,
-inclusive.
-If some of the items given by \fItagOrId\fR don't support
-text operations, then they are ignored.
-\fIFirst\fR and \fIlast\fR are indices of characters
-within the item(s) as described in INDICES above.
-If \fIlast\fR is omitted, it defaults to \fIfirst\fR.
-This command returns an empty string.
-.TP
-\fIpathName \fBdelete \fR?\fItagOrId tagOrId ...\fR?
-Delete each of the items given by each \fItagOrId\fR, and return
-an empty string.
-.TP
-\fIpathName \fBdtag \fItagOrId \fR?\fItagToDelete\fR?
-For each of the items given by \fItagOrId\fR, delete the
-tag given by \fItagToDelete\fR from the list of those
-associated with the item.
-If an item doesn't have the tag \fItagToDelete\fR then
-the item is unaffected by the command.
-If \fItagToDelete\fR is omitted then it defaults to \fItagOrId\fR.
-This command returns an empty string.
-.TP
-\fIpathName \fBfind \fIsearchCommand \fR?\fIarg arg ...\fR?
-This command returns a list consisting of all the items that
-meet the constraints specified by \fIsearchCommand\fR and
-\fIarg\fR's.
-\fISearchCommand\fR and \fIargs\fR have any of the forms
-accepted by the \fBaddtag\fR command.
-The items are returned in stacking order, with the lowest item first.
-.TP
-\fIpathName \fBfocus \fR?\fItagOrId\fR?
-Set the keyboard focus for the canvas widget to the item given by
-\fItagOrId\fR.
-If \fItagOrId\fR refers to several items, then the focus is set
-to the first such item in the display list that supports the
-insertion cursor.
-If \fItagOrId\fR doesn't refer to any items, or if none of them
-support the insertion cursor, then the focus isn't changed.
-If \fItagOrId\fR is an empty
-string, then the focus item is reset so that no item has the focus.
-If \fItagOrId\fR is not specified then the command returns the
-id for the item that currently has the focus, or an empty string
-if no item has the focus.
-.RS
-.PP
-Once the focus has been set to an item, the item will display
-the insertion cursor and all keyboard events will be directed
-to that item.
-The focus item within a canvas and the focus window on the
-screen (set with the \fBfocus\fR command) are totally independent:
-a given item doesn't actually have the input focus unless (a)
-its canvas is the focus window and (b) the item is the focus item
-within the canvas.
-In most cases it is advisable to follow the \fBfocus\fR widget
-command with the \fBfocus\fR command to set the focus window to
-the canvas (if it wasn't there already).
-.RE
-.TP
-\fIpathName \fBgettags\fR \fItagOrId\fR
-Return a list whose elements are the tags associated with the
-item given by \fItagOrId\fR.
-If \fItagOrId\fR refers to more than one item, then the tags
-are returned from the first such item in the display list.
-If \fItagOrId\fR doesn't refer to any items, or if the item
-contains no tags, then an empty string is returned.
-.TP
-\fIpathName \fBicursor \fItagOrId index\fR
-Set the position of the insertion cursor for the item(s)
-given by \fItagOrId\fR
-to just before the character whose position is given by \fIindex\fR.
-If some or all of the items given by \fItagOrId\fR don't support
-an insertion cursor then this command has no effect on them.
-See INDICES above for a description of the
-legal forms for \fIindex\fR.
-Note: the insertion cursor is only displayed in an item if
-that item currently has the keyboard focus (see the widget
-command \fBfocus\fR, below), but the cursor position may
-be set even when the item doesn't have the focus.
-This command returns an empty string.
-.TP
-\fIpathName \fBindex \fItagOrId index\fR
-This command returns a decimal string giving the numerical index
-within \fItagOrId\fR corresponding to \fIindex\fR.
-\fIIndex\fR gives a textual description of the desired position
-as described in INDICES above.
-The return value is guaranteed to lie between 0 and the number
-of characters within the item, inclusive.
-If \fItagOrId\fR refers to multiple items, then the index
-is processed in the first of these items that supports indexing
-operations (in display list order).
-.TP
-\fIpathName \fBinsert \fItagOrId beforeThis string\fR
-For each of the items given by \fItagOrId\fR, if the item supports
-text insertion then \fIstring\fR is inserted into the item's
-text just before the character whose index is \fIbeforeThis\fR.
-See INDICES above for information about the forms allowed
-for \fIbeforeThis\fR.
-This command returns an empty string.
-.TP
-\fIpathName \fBitemcget\fR \fItagOrId\fR \fIoption\fR
-Returns the current value of the configuration option for the
-item given by \fItagOrId\fR whose name is \fIoption\fR.
-This command is similar to the \fBcget\fR widget command except that
-it applies to a particular item rather than the widget as a whole.
-\fIOption\fR may have any of the values accepted by the \fBcreate\fR
-widget command when the item was created.
-If \fItagOrId\fR is a tag that refers to more than one item,
-the first (lowest) such item is used.
-.TP
-\fIpathName \fBitemconfigure \fItagOrId\fR ?\fIoption\fR? ?\fIvalue\fR? ?\fIoption value ...\fR?
-This command is similar to the \fBconfigure\fR widget command except
-that it modifies item-specific options for the items given by
-\fItagOrId\fR instead of modifying options for the overall
-canvas widget.
-If no \fIoption\fR is specified, returns a list describing all of
-the available options for the first item given by \fItagOrId\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
-each of the items given by \fItagOrId\fR; in
-this case the command returns an empty string.
-The \fIoption\fRs and \fIvalue\fRs are the same as those permissible
-in the \fBcreate\fR widget command when the item(s) were created;
-see the sections describing individual item types below for details
-on the legal options.
-.TP
-\fIpathName \fBlower \fItagOrId \fR?\fIbelowThis\fR?
-Move all of the items given by \fItagOrId\fR to a new position
-in the display list just before the item given by \fIbelowThis\fR.
-If \fItagOrId\fR refers to more than one item then all are moved
-but the relative order of the moved items will not be changed.
-\fIBelowThis\fR is a tag or id; if it refers to more than one
-item then the first (lowest) of these items in the display list is used
-as the destination location for the moved items.
-Note: this command has no effect on window items. Window items always
-obscure other item types, and the stacking order of window items is
-determined by the \fBraise\fR and \fBlower\fR commands, not the
-\fBraise\fR and \fBlower\fR widget commands for canvases.
-This command returns an empty string.
-.TP
-\fIpathName \fBmove \fItagOrId xAmount yAmount\fR
-Move each of the items given by \fItagOrId\fR in the canvas coordinate
-space by adding \fIxAmount\fR to the x-coordinate of each point
-associated with the item and \fIyAmount\fR to the y-coordinate of
-each point associated with the item.
-This command returns an empty string.
-.TP
-\fIpathName \fBpostscript \fR?\fIoption value option value ...\fR?
-Generate a Postscript representation for part or all of the canvas.
-If the \fB\-file\fR option is specified then the Postscript is written
-to a file and an empty string is returned; otherwise the Postscript
-is returned as the result of the command.
-.VS
-If the interpreter that owns the canvas is marked as safe, the operation
-will fail because safe interpreters are not allowed to write files.
-If the \fB\-channel\fR option is specified, the argument denotes the name
-of a channel already opened for writing. The Postscript is written to
-that channel, and the channel is left open for further writing at the end
-of the operation.
-.VE
-The Postscript is created in Encapsulated Postscript form using
-version 3.0 of the Document Structuring Conventions.
-Note: by default Postscript is only generated for information that
-appears in the canvas's window on the screen. If the canvas is
-freshly created it may still have its initial size of 1x1 pixel
-so nothing will appear in the Postscript. To get around this problem
-either invoke the "update" command to wait for the canvas window
-to reach its final size, or else use the \fB\-width\fR and \fB\-height\fR
-options to specify the area of the canvas to print.
-The \fIoption\fR\-\fIvalue\fR argument pairs provide additional
-information to control the generation of Postscript. The following
-options are supported:
-.RS
-.TP
-\fB\-colormap \fIvarName\fR
-\fIVarName\fR must be the name of an array variable
-that specifies a color mapping to use in the Postscript.
-Each element of \fIvarName\fR must consist of Postscript
-code to set a particular color value (e.g. ``\fB1.0 1.0 0.0 setrgbcolor\fR'').
-When outputting color information in the Postscript, Tk checks
-to see if there is an element of \fIvarName\fR with the same
-name as the color.
-If so, Tk uses the value of the element as the Postscript command
-to set the color.
-If this option hasn't been specified, or if there isn't an entry
-in \fIvarName\fR for a given color, then Tk uses the red, green,
-and blue intensities from the X color.
-.TP
-\fB\-colormode \fImode\fR
-Specifies how to output color information. \fIMode\fR must be either
-\fBcolor\fR (for full color output), \fBgray\fR (convert all colors
-to their gray-scale equivalents) or \fBmono\fR (convert all colors
-to black or white).
-.TP
-\fB\-file \fIfileName\fR
-Specifies the name of the file in which to write the Postscript.
-If this option isn't specified then the Postscript is returned as the
-result of the command instead of being written to a file.
-.TP
-\fB\-fontmap \fIvarName\fR
-\fIVarName\fR must be the name of an array variable
-that specifies a font mapping to use in the Postscript.
-Each element of \fIvarName\fR must consist of a Tcl list with
-two elements, which are the name and point size of a Postscript font.
-When outputting Postscript commands for a particular font, Tk
-checks to see if \fIvarName\fR contains an element with the same
-name as the font.
-If there is such an element, then the font information contained in
-that element is used in the Postscript.
-Otherwise Tk attempts to guess what Postscript font to use.
-Tk's guesses generally only work for well-known fonts such as
-Times and Helvetica and Courier, and only if the X font name does not
-omit any dashes up through the point size.
-For example, \fB\-*\-Courier\-Bold\-R\-Normal\-\-*\-120\-*\fR will work but
-\fB*Courier\-Bold\-R\-Normal*120*\fR will not; Tk needs the dashes to
-parse the font name).
-.TP
-\fB\-height \fIsize\fR
-Specifies the height of the area of the canvas to print.
-Defaults to the height of the canvas window.
-.TP
-\fB\-pageanchor \fIanchor\fR
-Specifies which point of the printed area of the canvas should appear over
-the positioning point on the page (which is given by the \fB\-pagex\fR
-and \fB\-pagey\fR options).
-For example, \fB\-pageanchor n\fR means that the top center of the
-area of the canvas being printed (as it appears in the canvas window)
-should be over the positioning point. Defaults to \fBcenter\fR.
-.TP
-\fB\-pageheight \fIsize\fR
-Specifies that the Postscript should be scaled in both x and y so
-that the printed area is \fIsize\fR high on the Postscript page.
-\fISize\fR consists of a floating-point number followed by
-\fBc\fR for centimeters, \fBi\fR for inches, \fBm\fR for millimeters,
-or \fBp\fR or nothing for printer's points (1/72 inch).
-Defaults to the height of the printed area on the screen.
-If both \fB\-pageheight\fR and \fB\-pagewidth\fR are specified then
-the scale factor from \fB\-pagewidth\fR is used (non-uniform scaling
-is not implemented).
-.TP
-\fB\-pagewidth \fIsize\fR
-Specifies that the Postscript should be scaled in both x and y so
-that the printed area is \fIsize\fR wide on the Postscript page.
-\fISize\fR has the same form as for \fB\-pageheight\fR.
-Defaults to the width of the printed area on the screen.
-If both \fB\-pageheight\fR and \fB\-pagewidth\fR are specified then
-the scale factor from \fB\-pagewidth\fR is used (non-uniform scaling
-is not implemented).
-.TP
-\fB\-pagex \fIposition\fR
-\fIPosition\fR gives the x-coordinate of the positioning point on
-the Postscript page, using any of the forms allowed for \fB\-pageheight\fR.
-Used in conjunction with the \fB\-pagey\fR and \fB\-pageanchor\fR options
-to determine where the printed area appears on the Postscript page.
-Defaults to the center of the page.
-.TP
-\fB\-pagey \fIposition\fR
-\fIPosition\fR gives the y-coordinate of the positioning point on
-the Postscript page, using any of the forms allowed for \fB\-pageheight\fR.
-Used in conjunction with the \fB\-pagex\fR and \fB\-pageanchor\fR options
-to determine where the printed area appears on the Postscript page.
-Defaults to the center of the page.
-.TP
-\fB\-rotate \fIboolean\fR
-\fIBoolean\fR specifies whether the printed area is to be rotated 90
-degrees.
-In non-rotated output the x-axis of the printed area runs along
-the short dimension of the page (``portrait'' orientation);
-in rotated output the x-axis runs along the long dimension of the
-page (``landscape'' orientation).
-Defaults to non-rotated.
-.TP
-\fB\-width \fIsize\fR
-Specifies the width of the area of the canvas to print.
-Defaults to the width of the canvas window.
-.TP
-\fB\-x \fIposition\fR
-Specifies the x-coordinate of the left edge of the area of the
-canvas that is to be printed, in canvas coordinates, not window
-coordinates.
-Defaults to the coordinate of the left edge of the window.
-.TP
-\fB\-y \fIposition\fR
-Specifies the y-coordinate of the top edge of the area of the
-canvas that is to be printed, in canvas coordinates, not window
-coordinates.
-Defaults to the coordinate of the top edge of the window.
-.RE
-.TP
-\fIpathName \fBraise \fItagOrId \fR?\fIaboveThis\fR?
-Move all of the items given by \fItagOrId\fR to a new position
-in the display list just after the item given by \fIaboveThis\fR.
-If \fItagOrId\fR refers to more than one item then all are moved
-but the relative order of the moved items will not be changed.
-\fIAboveThis\fR is a tag or id; if it refers to more than one
-item then the last (topmost) of these items in the display list is used
-as the destination location for the moved items.
-Note: this command has no effect on window items. Window items always
-obscure other item types, and the stacking order of window items is
-determined by the \fBraise\fR and \fBlower\fR commands, not the
-\fBraise\fR and \fBlower\fR widget commands for canvases.
-This command returns an empty string.
-.TP
-\fIpathName \fBscale \fItagOrId xOrigin yOrigin xScale yScale\fR
-Rescale all of the items given by \fItagOrId\fR in canvas coordinate
-space.
-\fIXOrigin\fR and \fIyOrigin\fR identify the origin for the scaling
-operation and \fIxScale\fR and \fIyScale\fR identify the scale
-factors for x- and y-coordinates, respectively (a scale factor of
-1.0 implies no change to that coordinate).
-For each of the points defining each item, the x-coordinate is
-adjusted to change the distance from \fIxOrigin\fR by a factor
-of \fIxScale\fR.
-Similarly, each y-coordinate is adjusted to change the distance
-from \fIyOrigin\fR by a factor of \fIyScale\fR.
-This command returns an empty string.
-.TP
-\fIpathName \fBscan\fR \fIoption args\fR
-This command is used to implement scanning on canvases. It has
-two forms, depending on \fIoption\fR:
-.RS
-.TP
-\fIpathName \fBscan mark \fIx y\fR
-Records \fIx\fR and \fIy\fR and the canvas's current view; used
-in conjunction with later \fBscan dragto\fR commands.
-Typically this command is associated with a mouse button press in
-the widget and \fIx\fR and \fIy\fR are the coordinates of the
-mouse. It returns an empty string.
-.TP
-\fIpathName \fBscan dragto \fIx y\fR.
-This command computes the difference between its \fIx\fR and \fIy\fR
-arguments (which are typically mouse coordinates) and the \fIx\fR and
-\fIy\fR arguments to the last \fBscan mark\fR command for the widget.
-It then adjusts the view by 10 times the
-difference in coordinates. This command is typically associated
-with mouse motion events in the widget, to produce the effect of
-dragging the canvas at high speed through its window. The return
-value is an empty string.
-.RE
-.TP
-\fIpathName \fBselect \fIoption\fR ?\fItagOrId arg\fR?
-Manipulates the selection in one of several ways, depending on
-\fIoption\fR.
-The command may take any of the forms described below.
-In all of the descriptions below, \fItagOrId\fR must refer to
-an item that supports indexing and selection; if it refers to
-multiple items then the first of
-these that supports indexing and the selection is used.
-\fIIndex\fR gives a textual description of a position
-within \fItagOrId\fR, as described in INDICES above.
-.RS
-.TP
-\fIpathName \fBselect adjust \fItagOrId index\fR
-Locate the end of the selection in \fItagOrId\fR 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 \fItagOrId\fR then
-this command behaves the same as the \fBselect to\fR widget
-command.
-Returns an empty string.
-.TP
-\fIpathName \fBselect clear\fR
-Clear the selection if it is in this widget.
-If the selection isn't in this widget then the command
-has no effect.
-Returns an empty string.
-.TP
-\fIpathName \fBselect from \fItagOrId index\fR
-Set the selection anchor point for the widget to be just
-before the character
-given by \fIindex\fR in the item given by \fItagOrId\fR.
-This command doesn't change the selection; it just sets
-the fixed end of the selection for future \fBselect to\fR
-commands.
-Returns an empty string.
-.TP
-\fIpathName \fBselect item\fR
-Returns the id of the selected item, if the selection is in an
-item in this canvas.
-If the selection is not in this canvas then an empty string
-is returned.
-.TP
-\fIpathName \fBselect to \fItagOrId index\fR
-Set the selection to consist of those characters of \fItagOrId\fR
-between the selection anchor point and
-\fIindex\fR.
-The new selection will include the character given by \fIindex\fR;
-it will include the character given by the anchor point only if
-\fIindex\fR is greater than or equal to the anchor point.
-The anchor point is determined by the most recent \fBselect adjust\fR
-or \fBselect from\fR command for this widget.
-If the selection anchor point for the widget isn't currently in
-\fItagOrId\fR, then it is set to the same character given
-by \fIindex\fR.
-Returns an empty string.
-.RE
-.TP
-\fIpathName \fBtype\fI tagOrId\fR
-Returns the type of the item given by \fItagOrId\fR, such as
-\fBrectangle\fR or \fBtext\fR.
-If \fItagOrId\fR refers to more than one item, then the type
-of the first item in the display list is returned.
-If \fItagOrId\fR doesn't refer to any items at all then
-an empty string is returned.
-.TP
-\fIpathName \fBxview \fR?\fIargs\fR?
-This command is used to query and change the horizontal position of the
-information displayed in the canvas'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 canvas's area (as defined by the \fB\-scrollregion\fR option)
-is off-screen to the left, the middle 40% is visible
-in the window, and 40% of the canvas is off-screen to the right.
-These are the same values passed to scrollbars via the \fB\-xscrollcommand\fR
-option.
-.TP
-\fIpathName \fBxview moveto\fI fraction\fR
-Adjusts the view in the window so that \fIfraction\fR of the
-total width of the canvas is off-screen to the left.
-\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 in units
-of the \fBxScrollIncrement\fR option, if it is greater than zero,
-or in units of one-tenth the window's width otherwise.
-If \fIwhat is \fBpages\fR then the view
-adjusts in units of nine-tenths the window's width.
-If \fInumber\fR is negative then information farther to the left
-becomes visible; if it is positive then information farther to the right
-becomes visible.
-.RE
-.TP
-\fIpathName \fByview \fI?args\fR?
-This command is used to query and change the vertical position of the
-information displayed in the canvas's window.
-It can take any of the following forms:
-.RS
-.TP
-\fIpathName \fByview\fR
-Returns a list containing two elements.
-Each element is a real fraction between 0 and 1; together they describe
-the vertical span that is visible in the window.
-For example, if the first element is .6 and the second element is 1.0,
-the lowest 40% of the canvas's area (as defined by the \fB\-scrollregion\fR
-option) is visible in the window.
-These are the same values passed to scrollbars via the \fB\-yscrollcommand\fR
-option.
-.TP
-\fIpathName \fByview moveto\fI fraction\fR
-Adjusts the view in the window so that \fIfraction\fR of the canvas's
-area is off-screen to the top.
-\fIFraction\fR is a fraction between 0 and 1.
-.TP
-\fIpathName \fByview scroll \fInumber what\fR
-This command adjusts the view in the window up or down according to
-\fInumber\fR and \fIwhat\fR.
-\fINumber\fR must be an integer.
-\fIWhat\fR must be either \fBunits\fR or \fBpages\fR.
-If \fIwhat\fR is \fBunits\fR, the view adjusts up or down in units
-of the \fByScrollIncrement\fR option, if it is greater than zero,
-or in units of one-tenth the window's height otherwise.
-If \fIwhat\fR is \fBpages\fR then
-the view adjusts in units of nine-tenths the window's height.
-If \fInumber\fR is negative then higher information becomes
-visible; if it is positive then lower information
-becomes visible.
-.RE
-
-.SH "OVERVIEW OF ITEM TYPES"
-.PP
-The sections below describe the various types of items supported
-by canvas widgets. Each item type is characterized by two things:
-first, the form of the \fBcreate\fR command used to create
-instances of the type; and second, a set of configuration options
-for items of that type, which may be used in the
-\fBcreate\fR and \fBitemconfigure\fR widget commands.
-Most items don't support indexing or selection or the commands
-related to them, such as \fBindex\fR and \fBinsert\fR.
-Where items do support these facilities, it is noted explicitly
-in the descriptions below (at present, only text items provide
-this support).
-
-.SH "ARC ITEMS"
-.PP
-Items of type \fBarc\fR appear on the display as arc-shaped regions.
-An arc is a section of an oval delimited by two angles (specified
-by the \fB\-start\fR and \fB\-extent\fR options) and displayed in
-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?
-.CE
-The arguments \fIx1\fR, \fIy1\fR, \fIx2\fR, and \fIy2\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
-pairs, each of which sets one of the configuration options
-for the item. These same \fIoption\fR\-\fIvalue\fR pairs may be
-used in \fBitemconfigure\fR widget commands to change the item's
-configuration.
-The following options are supported for arcs:
-.TP
-\fB\-extent \fIdegrees\fR
-Specifies the size of the angular range occupied by the arc.
-The arc's range extends for \fIdegrees\fR degrees counter-clockwise
-from the starting angle given by the \fB\-start\fR option.
-\fIDegrees\fR may be negative.
-If it is greater than 360 or less than -360, then \fIdegrees\fR
-modulo 360 is used as the extent.
-.TP
-\fB\-fill \fIcolor\fR
-Fill the region of the arc with \fIcolor\fR.
-\fIColor\fR may have any of the forms accepted by \fBTk_GetColor\fR.
-If \fIcolor\fR is an empty string (the default), then
-then the arc will not be filled.
-.TP
-\fB\-outline \fIcolor\fR
-\fIColor\fR specifies a color to use for drawing the arc's
-outline; it may have any of the forms accepted by \fBTk_GetColor\fR.
-This option defaults to \fBblack\fR. If \fIcolor\fR is specified
-as an empty string then no outline is drawn for the arc.
-.TP
-\fB\-outlinestipple \fIbitmap\fR
-Indicates that the outline for the arc should be drawn with a stipple pattern;
-\fIbitmap\fR specifies the stipple pattern to use, in any of the
-forms accepted by \fBTk_GetBitmap\fR.
-If the \fB\-outline\fR option hasn't been specified then this option
-has no effect.
-If \fIbitmap\fR is an empty string (the default), then the outline is drawn
-in a solid fashion.
-.TP
-\fB\-start \fIdegrees\fR
-Specifies the beginning of the angular range occupied by the
-arc.
-\fIDegrees\fR is given in units of degrees measured counter-clockwise
-from the 3-o'clock position; it may be either positive or negative.
-.TP
-\fB\-stipple \fIbitmap\fR
-Indicates that the arc should be filled in a stipple pattern;
-\fIbitmap\fR specifies the stipple pattern to use, in any of the
-forms accepted by \fBTk_GetBitmap\fR.
-If the \fB\-fill\fR option hasn't been specified then this option
-has no effect.
-If \fIbitmap\fR is an empty string (the default), then filling is done
-in a solid fashion.
-.TP
-\fB\-style \fItype\fR
-Specifies how to draw the arc. If \fItype\fR is \fBpieslice\fR
-(the default) then the arc's region is defined by a section
-of the oval's perimeter plus two line segments, one between the center
-of the oval and each end of the perimeter section.
-If \fItype\fR is \fBchord\fR then the arc's region is defined
-by a section of the oval's perimeter plus a single line segment
-connecting the two end points of the perimeter section.
-If \fItype\fR is \fBarc\fR then the arc's region consists of
-a section of the perimeter alone.
-In this last case the \fB\-fill\fR option is ignored.
-.TP
-\fB\-tags \fItagList\fR
-Specifies a set of tags to apply to the item.
-\fITagList\fR consists of a list of tag names, which replace any
-existing tags for the item.
-\fITagList\fR may be an empty list.
-.TP
-\fB\-width \fIoutlineWidth\fR
-Specifies the width of the outline to be drawn around
-the arc's region, in any of the forms described in the COORDINATES
-section above.
-If the \fB\-outline\fR option has been specified as an empty string
-then this option has no effect.
-Wide outlines will be drawn centered on the edges of the arc's region.
-This option defaults to 1.0.
-
-.SH "BITMAP ITEMS"
-.PP
-Items of type \fBbitmap\fR appear on the display as images with
-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?
-.CE
-The arguments \fIx\fR and \fIy\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
-pairs, each of which sets one of the configuration options
-for the item. These same \fIoption\fR\-\fIvalue\fR pairs may be
-used in \fBitemconfigure\fR widget commands to change the item's
-configuration.
-The following options are supported for bitmaps:
-.TP
-\fB\-anchor \fIanchorPos\fR
-\fIAnchorPos\fR tells how to position the bitmap relative to the
-positioning point for the item; it may have any of the forms
-accepted by \fBTk_GetAnchor\fR. For example, if \fIanchorPos\fR
-is \fBcenter\fR then the bitmap is centered on the point; if
-\fIanchorPos\fR is \fBn\fR then the bitmap will be drawn so that
-its top center point is at the positioning point.
-This option defaults to \fBcenter\fR.
-.TP
-\fB\-background \fIcolor\fR
-Specifies a color to use for each of the bitmap pixels
-whose value is 0.
-\fIColor\fR may have any of the forms accepted by \fBTk_GetColor\fR.
-If this option isn't specified, or if it is specified as an empty
-string, then nothing is displayed where the bitmap pixels are 0; this
-produces a transparent effect.
-.TP
-\fB\-bitmap \fIbitmap\fR
-Specifies the bitmap to display in the item.
-\fIBitmap\fR may have any of the forms accepted by \fBTk_GetBitmap\fR.
-.TP
-\fB\-foreground \fIcolor\fR
-Specifies a color to use for each of the bitmap pixels
-whose value is 1.
-\fIColor\fR may have any of the forms accepted by \fBTk_GetColor\fR and
-defaults to \fBblack\fR.
-.TP
-\fB\-tags \fItagList\fR
-Specifies a set of tags to apply to the item.
-\fITagList\fR consists of a list of tag names, which replace any
-existing tags for the item.
-\fITagList\fR may be an empty list.
-
-.SH "IMAGE ITEMS"
-.PP
-Items of type \fBimage\fR are used to display images on a
-canvas.
-Images are created with widget commands of the following form:
-.CS
-\fIpathName \fBcreate image \fIx y \fR?\fIoption value option value ...\fR?
-.CE
-The arguments \fIx\fR and \fIy\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
-pairs, each of which sets one of the configuration options
-for the item. These same \fIoption\fR\-\fIvalue\fR pairs may be
-used in \fBitemconfigure\fR widget commands to change the item's
-configuration.
-The following options are supported for images:
-.TP
-\fB\-anchor \fIanchorPos\fR
-\fIAnchorPos\fR tells how to position the image relative to the
-positioning point for the item; it may have any of the forms
-accepted by \fBTk_GetAnchor\fR. For example, if \fIanchorPos\fR
-is \fBcenter\fR then the image is centered on the point; if
-\fIanchorPos\fR is \fBn\fR then the image will be drawn so that
-its top center point is at the positioning point.
-This option defaults to \fBcenter\fR.
-.TP
-\fB\-image \fIname\fR
-Specifies the name of the image to display in the item.
-This image must have been created previously with the
-\fBimage create\fR command.
-.TP
-\fB\-tags \fItagList\fR
-Specifies a set of tags to apply to the item.
-\fITagList\fR consists of a list of tag names, which replace any
-existing tags for the item; it may be an empty list.
-
-.SH "LINE ITEMS"
-.PP
-Items of type \fBline\fR appear on the display as one or more connected
-line segments or curves.
-Lines are created with widget commands of the following form:
-.CS
-\fIpathName \fBcreate line \fIx1 y1... xn yn \fR?\fIoption value option value ...\fR?
-.CE
-The arguments \fIx1\fR through \fIyn\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
-pairs, each of which sets one of the configuration options
-for the item. These same \fIoption\fR\-\fIvalue\fR pairs may be
-used in \fBitemconfigure\fR widget commands to change the item's
-configuration.
-The following options are supported for lines:
-.TP
-\fB\-arrow \fIwhere\fR
-Indicates whether or not arrowheads are to be drawn at one or both
-ends of the line.
-\fIWhere\fR must have one of the values \fBnone\fR (for no arrowheads),
-\fBfirst\fR (for an arrowhead at the first point of the line),
-\fBlast\fR (for an arrowhead at the last point of the line), or
-\fBboth\fR (for arrowheads at both ends).
-This option defaults to \fBnone\fR.
-.TP
-\fB\-arrowshape \fIshape\fR
-This option indicates how to draw arrowheads.
-The \fIshape\fR argument must be a list with three elements, each
-specifying a distance in any of the forms described in
-the COORDINATES section above.
-The first element of the list gives the distance along the line
-from the neck of the arrowhead to its tip.
-The second element gives the distance along the line from the
-trailing points of the arrowhead to the tip, and the third
-element gives the distance from the outside edge of the line to the
-trailing points.
-If this option isn't specified then Tk picks a ``reasonable'' shape.
-.TP
-\fB\-capstyle \fIstyle\fR
-Specifies the ways in which caps are to be drawn at the endpoints
-of the line.
-\fIStyle\fR may have any of the forms accepted by \fBTk_GetCapStyle\fR
-(\fBbutt\fR, \fBprojecting\fR, or \fBround\fR).
-If this option isn't specified then it defaults to \fBbutt\fR.
-Where arrowheads are drawn the cap style is ignored.
-.TP
-\fB\-fill \fIcolor\fR
-\fIColor\fR specifies a color to use for drawing the line; it may have
-any of the forms acceptable to \fBTk_GetColor\fR. It may also be an
-empty string, in which case the line will be transparent.
-This option defaults to \fBblack\fR.
-.TP
-\fB\-joinstyle \fIstyle\fR
-Specifies the ways in which joints are to be drawn at the vertices
-of the line.
-\fIStyle\fR may have any of the forms accepted by \fBTk_GetCapStyle\fR
-(\fBbevel\fR, \fBmiter\fR, or \fBround\fR).
-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.
-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
-and third, and so on. Straight-line segments can be generated within
-a curve by duplicating the end-points of the desired line segment.
-.TP
-\fB\-splinesteps \fInumber\fR
-Specifies the degree of smoothness desired for curves: each spline
-will be approximated with \fInumber\fR line segments. This
-option is ignored unless the \fB\-smooth\fR option is true.
-.TP
-\fB\-stipple \fIbitmap\fR
-Indicates that the line should be filled in a stipple pattern;
-\fIbitmap\fR specifies the stipple pattern to use, in any of the
-forms accepted by \fBTk_GetBitmap\fR.
-If \fIbitmap\fR is an empty string (the default), then filling is
-done in a solid fashion.
-.TP
-\fB\-tags \fItagList\fR
-Specifies a set of tags to apply to the item.
-\fITagList\fR consists of a list of tag names, which replace any
-existing tags for the item.
-\fITagList\fR may be an empty list.
-.TP
-\fB\-width \fIlineWidth\fR
-\fILineWidth\fR specifies the width of the line, in any of the forms
-described in the COORDINATES section above.
-Wide lines will be drawn centered on the path specified by the
-points.
-If this option isn't specified then it defaults to 1.0.
-
-.SH "OVAL ITEMS"
-.PP
-Items of type \fBoval\fR appear as circular or oval regions on
-the display. Each oval may have an outline, a fill, or
-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?
-.CE
-The arguments \fIx1\fR, \fIy1\fR, \fIx2\fR, and \fIy2\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
-not the lower or right edges.
-If the region is square then the resulting oval is circular;
-otherwise it is elongated in shape.
-After the coordinates there may be any number of \fIoption\fR\-\fIvalue\fR
-pairs, each of which sets one of the configuration options
-for the item. These same \fIoption\fR\-\fIvalue\fR pairs may be
-used in \fBitemconfigure\fR widget commands to change the item's
-configuration.
-The following options are supported for ovals:
-.TP
-\fB\-fill \fIcolor\fR
-Fill the area of the oval with \fIcolor\fR.
-\fIColor\fR may have any of the forms accepted by \fBTk_GetColor\fR.
-If \fIcolor\fR is an empty string (the default), then
-then the oval will not be filled.
-.TP
-\fB\-outline \fIcolor\fR
-\fIColor\fR specifies a color to use for drawing the oval's
-outline; it may have any of the forms accepted by \fBTk_GetColor\fR.
-This option defaults to \fBblack\fR.
-If \fIcolor\fR is an empty string then no outline will be
-drawn for the oval.
-.TP
-\fB\-stipple \fIbitmap\fR
-Indicates that the oval should be filled in a stipple pattern;
-\fIbitmap\fR specifies the stipple pattern to use, in any of the
-forms accepted by \fBTk_GetBitmap\fR.
-If the \fB\-fill\fR option hasn't been specified then this option
-has no effect.
-If \fIbitmap\fR is an empty string (the default), then filling is done
-in a solid fashion.
-.TP
-\fB\-tags \fItagList\fR
-Specifies a set of tags to apply to the item.
-\fITagList\fR consists of a list of tag names, which replace any
-existing tags for the item.
-\fITagList\fR may be an empty list.
-.TP
-\fB\-width \fIoutlineWidth\fR
-\fIoutlineWidth\fR specifies the width of the outline to be drawn around
-the oval, in any of the forms described in the COORDINATES section above.
-If the \fB\-outline\fR option hasn't been specified then this option
-has no effect.
-Wide outlines are drawn centered on the oval path defined by
-\fIx1\fR, \fIy1\fR, \fIx2\fR, and \fIy2\fR.
-This option defaults to 1.0.
-
-.SH "POLYGON ITEMS"
-.PP
-Items of type \fBpolygon\fR appear as polygonal or curved filled regions
-on the display.
-Polygons are created with widget commands of the following form:
-.CS
-\fIpathName \fBcreate polygon \fIx1 y1 ... xn yn \fR?\fIoption value option value ...\fR?
-.CE
-The arguments \fIx1\fR through \fIyn\fR specify the coordinates for
-three or more points that define a closed polygon.
-The first and last points may be the same; whether they are or not,
-Tk will draw the polygon as a closed polygon.
-After the coordinates there may be any number of \fIoption\fR\-\fIvalue\fR
-pairs, each of which sets one of the configuration options
-for the item. These same \fIoption\fR\-\fIvalue\fR pairs may be
-used in \fBitemconfigure\fR widget commands to change the item's
-configuration.
-The following options are supported for polygons:
-.TP
-\fB\-fill \fIcolor\fR
-\fIColor\fR specifies a color to use for filling the area of the
-polygon; it may have any of the forms acceptable to \fBTk_GetColor\fR.
-If \fIcolor\fR is an empty string then the polygon will be
-transparent.
-This option defaults to \fBblack\fR.
-.TP
-\fB\-outline \fIcolor\fR
-\fIColor\fR specifies a color to use for drawing the polygon's
-outline; it may have any of the forms accepted by \fBTk_GetColor\fR.
-If \fIcolor\fR is an empty string then no outline will be
-drawn for the polygon.
-This option defaults to empty (no outline).
-.TP
-\fB\-smooth \fIboolean\fR
-\fIBoolean\fR must have one of the forms accepted by \fBTk_GetBoolean\fR
-It indicates whether or not the polygon should be drawn with a
-curved perimeter.
-If so, the outline of the polygon becomes a set of parabolic splines,
-one spline for the first and second line segments, one for the second
-and third, and so on. Straight-line segments can be generated in a
-smoothed polygon by duplicating the end-points of the desired line segment.
-.TP
-\fB\-splinesteps \fInumber\fR
-Specifies the degree of smoothness desired for curves: each spline
-will be approximated with \fInumber\fR line segments. This
-option is ignored unless the \fB\-smooth\fR option is true.
-.TP
-\fB\-stipple \fIbitmap\fR
-Indicates that the polygon should be filled in a stipple pattern;
-\fIbitmap\fR specifies the stipple pattern to use, in any of the
-forms accepted by \fBTk_GetBitmap\fR.
-If \fIbitmap\fR is an empty string (the default), then filling is
-done in a solid fashion.
-.TP
-\fB\-tags \fItagList\fR
-Specifies a set of tags to apply to the item.
-\fITagList\fR consists of a list of tag names, which replace any
-existing tags for the item.
-\fITagList\fR may be an empty list.
-.TP
-\fB\-width \fIoutlineWidth\fR
-\fIOutlineWidth\fR specifies the width of the outline to be drawn around
-the polygon, in any of the forms described in the COORDINATES section above.
-If the \fB\-outline\fR option hasn't been specified then this option
-has no effect. This option defaults to 1.0.
-.PP
-Polygon items are different from other items such as rectangles, ovals
-and arcs in that interior points are considered to be ``inside'' a
-polygon (e.g. for purposes of the \fBfind closest\fR and
-\fBfind overlapping\fR widget commands) even if it is not filled.
-For most other item types, an
-interior point is considered to be inside the item only if the item
-is filled or if it has neither a fill nor an outline. If you would
-like an unfilled polygon whose interior points are not considered
-to be inside the polygon, use a line item instead.
-
-.SH "RECTANGLE ITEMS"
-.PP
-Items of type \fBrectangle\fR appear as rectangular regions on
-the display. Each rectangle may have an outline, a fill, or
-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?
-.CE
-The arguments \fIx1\fR, \fIy1\fR, \fIx2\fR, and \fIy2\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).
-After the coordinates there may be any number of \fIoption\fR\-\fIvalue\fR
-pairs, each of which sets one of the configuration options
-for the item. These same \fIoption\fR\-\fIvalue\fR pairs may be
-used in \fBitemconfigure\fR widget commands to change the item's
-configuration.
-The following options are supported for rectangles:
-.TP
-\fB\-fill \fIcolor\fR
-Fill the area of the rectangle with \fIcolor\fR, which may be
-specified in any of the forms accepted by \fBTk_GetColor\fR.
-If \fIcolor\fR is an empty string (the default),
-then the rectangle will not be filled.
-.TP
-\fB\-outline \fIcolor\fR
-Draw an outline around the edge of the rectangle in \fIcolor\fR.
-\fIColor\fR may have any of the forms accepted by \fBTk_GetColor\fR.
-This option defaults to \fBblack\fR.
-If \fIcolor\fR is an empty string then no outline will be
-drawn for the rectangle.
-.TP
-\fB\-stipple \fIbitmap\fR
-Indicates that the rectangle should be filled in a stipple pattern;
-\fIbitmap\fR specifies the stipple pattern to use, in any of the
-forms accepted by \fBTk_GetBitmap\fR.
-If the \fB\-fill\fR option hasn't been specified then this option
-has no effect.
-If \fIbitmap\fR is an empty string (the default), then filling
-is done in a solid fashion.
-.TP
-\fB\-tags \fItagList\fR
-Specifies a set of tags to apply to the item.
-\fITagList\fR consists of a list of tag names, which replace any
-existing tags for the item.
-\fITagList\fR may be an empty list.
-.TP
-\fB\-width \fIoutlineWidth\fR
-\fIOutlineWidth\fR specifies the width of the outline to be drawn around
-the rectangle, in any of the forms described in the COORDINATES section above.
-If the \fB\-outline\fR option hasn't been specified then this option
-has no effect.
-Wide outlines are drawn centered on the rectangular path
-defined by \fIx1\fR, \fIy1\fR, \fIx2\fR, and \fIy2\fR.
-This option defaults to 1.0.
-
-.SH "TEXT ITEMS"
-.PP
-A text item displays a string of characters on the screen in one
-or more lines.
-Text items support indexing and selection, along with the
-following text-related canvas widget commands: \fBdchars\fR,
-\fBfocus\fR, \fBicursor\fR, \fBindex\fR, \fBinsert\fR,
-\fBselect\fR.
-Text items are created with widget commands of the following
-form:
-.CS
-\fIpathName \fBcreate text \fIx y \fR?\fIoption value option value ...\fR?
-.CE
-The arguments \fIx\fR and \fIy\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
-pairs, each of which sets one of the configuration options
-for the item. These same \fIoption\fR\-\fIvalue\fR pairs may be
-used in \fBitemconfigure\fR widget commands to change the item's
-configuration.
-The following options are supported for text items:
-.TP
-\fB\-anchor \fIanchorPos\fR
-\fIAnchorPos\fR tells how to position the text relative to the
-positioning point for the text; it may have any of the forms
-accepted by \fBTk_GetAnchor\fR. For example, if \fIanchorPos\fR
-is \fBcenter\fR then the text is centered on the point; if
-\fIanchorPos\fR is \fBn\fR then the text will be drawn such that
-the top center point of the rectangular region occupied by the
-text will be at the positioning point.
-This option defaults to \fBcenter\fR.
-.TP
-\fB\-fill \fIcolor\fR
-\fIColor\fR specifies a color to use for filling the text characters;
-it may have any of the forms accepted by \fBTk_GetColor\fR.
-If this option isn't specified then it defaults to \fBblack\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.
-If this option isn't specified, it defaults to a system-dependent
-font.
-.TP
-\fB\-justify \fIhow\fR
-Specifies how to justify the text within its bounding region.
-\fIHow\fR must be one of the values \fBleft\fR, \fBright\fR,
-or \fBcenter\fR.
-This option will only matter if the text is displayed as multiple
-lines.
-If the option is omitted, it defaults to \fBleft\fR.
-.TP
-\fB\-stipple \fIbitmap\fR
-Indicates that the text should be drawn in a stippled pattern
-rather than solid;
-\fIbitmap\fR specifies the stipple pattern to use, in any of the
-forms accepted by \fBTk_GetBitmap\fR.
-If \fIbitmap\fR is an empty string (the default) then the text
-is drawn in a solid fashion.
-.TP
-\fB\-tags \fItagList\fR
-Specifies a set of tags to apply to the item.
-\fITagList\fR consists of a list of tag names, which replace any
-existing tags for the item.
-\fITagList\fR may be an empty list.
-.TP
-\fB\-text \fIstring\fR
-\fIString\fR specifies the characters to be displayed in the text item.
-Newline characters cause line breaks.
-The characters in the item may also be changed with the
-\fBinsert\fR and \fBdelete\fR widget commands.
-This option defaults to an empty string.
-.TP
-\fB\-width \fIlineLength\fR
-Specifies a maximum line length for the text, in any of the forms
-described in the COORDINATES section above.
-If this option is zero (the default) the text is broken into
-lines only at newline characters.
-However, if this option is non-zero then any line that would
-be longer than \fIlineLength\fR is broken just before a space
-character to make the line shorter than \fIlineLength\fR; the
-space character is treated as if it were a newline
-character.
-
-.SH "WINDOW ITEMS"
-.PP
-Items of type \fBwindow\fR cause a particular window to be displayed
-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?
-.CE
-The arguments \fIx\fR and \fIy\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
-pairs, each of which sets one of the configuration options
-for the item. These same \fIoption\fR\-\fIvalue\fR pairs may be
-used in \fBitemconfigure\fR widget commands to change the item's
-configuration.
-The following options are supported for window items:
-.TP
-\fB\-anchor \fIanchorPos\fR
-\fIAnchorPos\fR tells how to position the window relative to the
-positioning point for the item; it may have any of the forms
-accepted by \fBTk_GetAnchor\fR. For example, if \fIanchorPos\fR
-is \fBcenter\fR then the window is centered on the point; if
-\fIanchorPos\fR is \fBn\fR then the window will be drawn so that
-its top center point is at the positioning point.
-This option defaults to \fBcenter\fR.
-.TP
-\fB\-height \fIpixels\fR
-Specifies the height to assign to the item's window.
-\fIPixels\fR may have any of the
-forms described in the COORDINATES section above.
-If this option isn't specified, or if it is specified as an empty
-string, then the window is given whatever height it requests internally.
-.TP
-\fB\-tags \fItagList\fR
-Specifies a set of tags to apply to the item.
-\fITagList\fR consists of a list of tag names, which replace any
-existing tags for the item.
-\fITagList\fR may be an empty list.
-.TP
-\fB\-width \fIpixels\fR
-Specifies the width to assign to the item's window.
-\fIPixels\fR may have any of the
-forms described in the COORDINATES section above.
-If this option isn't specified, or if it is specified as an empty
-string, then the window is given whatever width it requests internally.
-.TP
-\fB\-window \fIpathName\fR
-Specifies the window to associate with this item.
-The window specified by \fIpathName\fR must either be a child of
-the canvas widget or a child of some ancestor of the canvas widget.
-\fIPathName\fR may not refer to a top-level window.
-.PP
-Note: due to restrictions in the ways that windows are managed, it is not
-possible to draw other graphical items (such as lines and images) on top
-of window items. A window item always obscures any graphics that
-overlap it, regardless of their order in the display list.
-
-.SH "APPLICATION-DEFINED ITEM TYPES"
-.PP
-It is possible for individual applications to define new item
-types for canvas widgets using C code.
-See the documentation for \fBTk_CreateItemType\fR.
-
-.SH BINDINGS
-.PP
-In the current implementation, new canvases are not given any
-default behavior: you'll have to execute explicit Tcl commands
-to give the canvas its behavior.
-
-.SH CREDITS
-.PP
-Tk's canvas widget is a blatant ripoff of ideas from Joel Bartlett's
-\fIezd\fR program. \fIEzd\fR provides structured graphics in a Scheme
-environment and preceded canvases by a year or two. Its simple
-mechanisms for placing and animating graphical objects inspired the
-functions of canvases.
-
-.SH KEYWORDS
-canvas, widget
diff --git a/doc/checkbutton.n b/doc/checkbutton.n
deleted file mode 100644
index 822ae26..0000000
--- a/doc/checkbutton.n
+++ /dev/null
@@ -1,238 +0,0 @@
-'\"
-'\" 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: checkbutton.n,v 1.2 1998/09/14 18:22:55 stanton Exp $
-'\"
-.so man.macros
-.TH checkbutton n 4.4 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-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
-.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. The button's global variable (\fB\-variable\fR option) will
-be updated before the command is invoked.
-.OP \-height height Height
-Specifies a desired height for the button.
-If an image or bitmap is being displayed in the button then the value is in
-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.
-.OP \-indicatoron indicatorOn IndicatorOn
-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.
-.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''.
-.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.
-Under Windows, this color is used as the background for the indicator
-regardless of the select state.
-If \fBindicatorOn\fR is false, this color is used as the background
-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.
-.OP \-selectimage selectImage SelectImage
-Specifies an image to display (in place of the \fBimage\fR option)
-when the checkbutton is selected.
-This option is ignored unless the \fBimage\fR option has been
-specified.
-.OP \-state state State
-Specifies one of three states for the checkbutton: \fBnormal\fR, \fBactive\fR,
-or \fBdisabled\fR. In normal state the checkbutton is displayed using the
-\fBforeground\fR and \fBbackground\fR options. The active state is
-typically used when the pointer is over the checkbutton. In active state
-the checkbutton is displayed using the \fBactiveForeground\fR and
-\fBactiveBackground\fR options. Disabled state means that the checkbutton
-should be insensitive: the default bindings will refuse to activate
-the widget and will ignore mouse button presses.
-In this state the \fBdisabledForeground\fR and
-\fBbackground\fR options determine how the checkbutton is displayed.
-.OP \-variable variable Variable
-Specifies name of global variable to set to indicate whether
-or not this button is selected. Defaults to the name of the
-button within its parent (i.e. the last element of the button
-window's path name).
-.OP \-width width Width
-Specifies a desired width for the button.
-If an image or bitmap is being displayed in the button then the value is in
-screen units (i.e. any of the forms acceptable to \fBTk_GetPixels\fR);
-for text it is in characters.
-If this option isn't specified, the button's desired width is computed
-from the size of the image or bitmap or text being displayed in it.
-.BE
-
-.SH DESCRIPTION
-.PP
-The \fBcheckbutton\fR command creates a new window (given by the
-\fIpathName\fR argument) and makes it into a checkbutton widget.
-Additional
-options, described above, may be specified on the command line
-or in the option database
-to configure aspects of the checkbutton such as its colors, font,
-text, and initial relief. The \fBcheckbutton\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 checkbutton is a widget
-that displays a textual string, bitmap or image
-and a square called an \fIindicator\fR.
-If text is displayed, it must all be in a single font, but it
-can occupy multiple lines on the screen (if it contains newlines
-or if wrapping occurs because of the \fBwrapLength\fR option) and
-one of the characters may optionally be underlined using the
-\fBunderline\fR option.
-A checkbutton has
-all of the behavior of a simple button, including the
-following: it can display itself in either of three different
-ways, according to the \fBstate\fR option;
-it can be made to appear
-raised, sunken, or flat; it can be made to flash; and it invokes
-a Tcl command whenever mouse button 1 is clicked over the
-checkbutton.
-.PP
-In addition, checkbuttons can be \fIselected\fR.
-If a checkbutton is selected then the indicator is normally
-.VS
-drawn with a selected appearance, and
-a Tcl variable associated with the checkbutton is set to a particular
-value (normally 1).
-Under Unix, the indicator is drawn with a sunken relief and a special
-color. Under Windows, the indicator is drawn with a check mark inside.
-If the checkbutton is not selected, then the indicator is drawn with a
-deselected appearance, and the associated variable is
-set to a different value (typically 0).
-Under Unix, the indicator is drawn with a raised relief and no special
-color. Under Windows, the indicator is drawn without a check mark inside.
-.VE
-By default, the name of the variable associated with a checkbutton is the
-same as the \fIname\fR used to create the checkbutton.
-The variable name, and the ``on'' and ``off'' values stored in it,
-may be modified with options on the command line or in the option
-database.
-Configuration options may also be used to modify the way the
-indicator is displayed (or whether it is displayed at all).
-By default a checkbutton is configured to select and deselect
-itself on alternate button clicks.
-In addition, each checkbutton monitors its associated variable and
-automatically selects and deselects itself when the variables value
-changes to and from the button's ``on'' value.
-
-.SH "WIDGET COMMAND"
-.PP
-The \fBcheckbutton\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. The following
-commands are possible for checkbutton 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 \fBcheckbutton\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 \fBcheckbutton\fR
-command.
-.TP
-\fIpathName \fBdeselect\fR
-Deselects the checkbutton and sets the associated variable to its ``off''
-value.
-.TP
-\fIpathName \fBflash\fR
-Flashes the checkbutton. This is accomplished by redisplaying the checkbutton
-several times, alternating between active and normal colors. At
-the end of the flash the checkbutton is left in the same normal/active
-state as when the command was invoked.
-This command is ignored if the checkbutton's state is \fBdisabled\fR.
-.TP
-\fIpathName \fBinvoke\fR
-Does just what would have happened if the user invoked the checkbutton
-with the mouse: toggle the selection state of the button and invoke
-the Tcl command associated with the checkbutton, if there is one.
-The return value is the return value from the Tcl command, or an
-empty string if there is no command associated with the checkbutton.
-This command is ignored if the checkbutton's state is \fBdisabled\fR.
-.TP
-\fIpathName \fBselect\fR
-Selects the checkbutton and sets the associated variable to its ``on''
-value.
-.TP
-\fIpathName \fBtoggle\fR
-Toggles the selection state of the button, redisplaying it and
-modifying its associated variable to reflect the new state.
-
-.SH BINDINGS
-.PP
-Tk automatically creates class bindings for checkbuttons that give them
-the following default behavior:
-.VS
-.IP [1]
-On Unix systems, a checkbutton activates whenever the mouse passes
-over it and deactivates whenever the mouse leaves the checkbutton. On
-Mac and Windows systems, when mouse button 1 is pressed over a
-checkbutton, the button activates whenever the mouse pointer is inside
-the button, and deactivates whenever the mouse pointer leaves the
-button.
-.VE
-.IP [2]
-When mouse button 1 is pressed over a checkbutton, it is invoked (its
-selection state toggles and the command associated with the button is
-invoked, if there is one).
-.VS
-.IP [3]
-When a checkbutton has the input focus, the space key causes the checkbutton
-to be invoked. Under Windows, there are additional key bindings; plus
-(+) and equal (=) select the button, and minus (-) deselects the button.
-.VE
-.PP
-If the checkbutton's state is \fBdisabled\fR then none of the above
-actions occur: the checkbutton is completely non-responsive.
-.PP
-The behavior of checkbuttons can be changed by defining new bindings for
-individual widgets or by redefining the class bindings.
-
-.SH KEYWORDS
-checkbutton, widget
diff --git a/doc/chooseColor.n b/doc/chooseColor.n
deleted file mode 100644
index 318db20..0000000
--- a/doc/chooseColor.n
+++ /dev/null
@@ -1,49 +0,0 @@
-'\"
-'\" Copyright (c) 1996 Sun Microsystems, Inc.
-'\"
-'\" See the file "license.terms" for information on usage and redistribution
-'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-'\"
-'\" RCS: @(#) $Id: chooseColor.n,v 1.2 1998/09/14 18:22:55 stanton Exp $
-'\"
-.so man.macros
-.TH tk_chooseColor n 4.2 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-tk_chooseColor \- pops up a dialog box for the user to select a color.
-.PP
-.SH SYNOPSIS
-\fBtk_chooseColor \fR?\fIoption value ...\fR?
-.BE
-
-.SH DESCRIPTION
-.PP
-The procedure \fBtk_chooseColor\fR pops up a dialog box for the
-user to select a color. The following \fIoption\-value\fR pairs are
-possible as command line arguments:
-.TP
-\fB\-initialcolor\fR \fIcolor\fR
-Specifies the color to display in the color dialog when it pops
-up. \fIcolor\fR must be in a form acceptable to the \fBTk_GetColor\fR
-function.
-.TP
-\fB\-parent\fR \fIwindow\fR
-Makes \fIwindow\fR the logical parent of the color dialog. The color
-dialog is displayed on top of its parent window.
-.TP
-\fB\-title\fR \fItitleString\fR
-Specifies a string to display as the title of the dialog box. If this
-option is not specified, then a default title will be displayed.
-.LP
-If the user selects a color, \fBtk_chooseColor\fR will return the
-name of the color in a form acceptable to \fBTk_GetColor\fR. If the
-user cancels the operation, both commands will return the empty
-string.
-.SH EXAMPLE
-.CS
-button .b \-fg [tk_chooseColor \-initialcolor gray \-title "Choose color"]
-.CE
-
-.SH KEYWORDS
-color selection dialog
diff --git a/doc/clipboard.n b/doc/clipboard.n
deleted file mode 100644
index 44bb3bb..0000000
--- a/doc/clipboard.n
+++ /dev/null
@@ -1,81 +0,0 @@
-'\"
-'\" Copyright (c) 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: clipboard.n,v 1.2 1998/09/14 18:22:55 stanton Exp $
-'\"
-.so man.macros
-.TH clipboard n 4.0 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-clipboard \- Manipulate Tk clipboard
-.SH SYNOPSIS
-\fBclipboard \fIoption\fR ?\fIarg arg ...\fR?
-.BE
-
-.SH DESCRIPTION
-.PP
-This command provides a Tcl interface to the Tk clipboard,
-which stores data for later retrieval using the selection mechanism.
-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
-appends should be completed before returning to the event loop.
-.PP
-The first argument to \fBclipboard\fR determines the format of the
-rest of the arguments and the behavior of the command. The following
-forms are currently supported:
-.PP
-.TP
-\fBclipboard clear\fR ?\fB\-displayof\fR \fIwindow\fR?
-Claims ownership of the clipboard on \fIwindow\fR's display and removes
-any previous contents. \fIWindow\fR defaults to ``.''. Returns an
-empty string.
-.TP
-\fBclipboard append\fR ?\fB\-displayof\fR \fIwindow\fR? ?\fB\-format\fR \fIformat\fR? ?\fB\-type\fR \fItype\fR? ?\fB\-\|\-\fR? \fIdata\fR
-Appends \fIdata\fR to the clipboard on \fIwindow\fR's
-display in the form given by \fItype\fR with the representation given
-by \fIformat\fR and claims ownership of the clipboard on \fIwindow\fR's
-display.
-.RS
-.PP
-\fIType\fR specifies the form in which the selection is to be returned
-(the desired ``target'' for conversion, in ICCCM terminology), and
-should be an atom name such as STRING or FILE_NAME; see the
-Inter-Client Communication Conventions Manual for complete details.
-\fIType\fR defaults to STRING.
-.PP
-The \fIformat\fR argument specifies the representation that should be
-used to transmit the selection to the requester (the second column of
-Table 2 of the ICCCM), and defaults to STRING. If \fIformat\fR is
-STRING, the selection is transmitted as 8-bit ASCII characters. If
-\fIformat\fR is ATOM, then the \fIdata\fR is
-divided into fields separated by white space; each field is converted
-to its atom value, and the 32-bit atom value is transmitted instead of
-the atom name. For any other \fIformat\fR, \fIdata\fR is divided
-into fields separated by white space and each
-field is converted to a 32-bit integer; an array of integers is
-transmitted to the selection requester. Note that strings passed to
-\fBclipboard append\fR are concatenated before conversion, so the
-caller must take care to ensure appropriate spacing across string
-boundaries. All items appended to the clipboard with the same
-\fItype\fR must have the same \fIformat\fR.
-.PP
-The \fIformat\fR argument is needed only for compatibility with
-clipboard requesters that don't use Tk. If the Tk toolkit is being
-used to retrieve the CLIPBOARD selection then the value is converted back to
-a string at the requesting end, so \fIformat\fR is
-irrelevant.
-.PP
-A \fB\-\|\-\fR argument may be specified to mark the end of options: the
-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
-
-.SH KEYWORDS
-clear, format, clipboard, append, selection, type
diff --git a/doc/destroy.n b/doc/destroy.n
deleted file mode 100644
index e2cde3d..0000000
--- a/doc/destroy.n
+++ /dev/null
@@ -1,34 +0,0 @@
-'\"
-'\" Copyright (c) 1990 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: destroy.n,v 1.2 1998/09/14 18:22:55 stanton Exp $
-'\"
-.so man.macros
-.TH destroy n "" Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-destroy \- Destroy one or more windows
-.SH SYNOPSIS
-\fBdestroy \fR?\fIwindow window ...\fR?
-.BE
-
-.SH DESCRIPTION
-.VS
-.PP
-This command deletes the windows given by the
-\fIwindow\fR arguments, plus all of their descendants.
-If a \fIwindow\fR ``.'' is deleted then the entire application
-will be destroyed.
-The \fIwindow\fRs are destroyed in order, and if an error occurs
-in destroying a window the command aborts without destroying the
-remaining windows.
-No error is returned if \fIwindow\fR does not exist.
-.VE
-
-.SH KEYWORDS
-application, destroy, window
diff --git a/doc/dialog.n b/doc/dialog.n
deleted file mode 100644
index 0e93888..0000000
--- a/doc/dialog.n
+++ /dev/null
@@ -1,65 +0,0 @@
-'\"
-'\" 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: dialog.n,v 1.2 1998/09/14 18:22:55 stanton Exp $
-'\"
-.so man.macros
-.TH tk_dialog n 4.1 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-tk_dialog \- Create modal dialog and wait for response
-.SH SYNOPSIS
-\fBtk_dialog \fIwindow title text bitmap default string string ...\fR
-.BE
-
-.SH DESCRIPTION
-.PP
-This procedure is part of the Tk script library.
-Its arguments describe a dialog box:
-.TP
-\fIwindow\fR
-Name of top-level window to use for dialog. Any existing window
-by this name is destroyed.
-.TP
-\fItitle\fR
-Text to appear in the window manager's title bar for the dialog.
-.TP
-\fItext\fR
-Message to appear in the top portion of the dialog box.
-.TP
-\fIbitmap\fR
-If non-empty, specifies a bitmap to display in the top portion of
-the dialog, to the left of the text.
-If this is an empty string then no bitmap is displayed in the dialog.
-.TP
-\fIdefault\fR
-If this is an integer greater than or equal to zero, then it gives
-the index of the button that is to be the default button for the dialog
-(0 for the leftmost button, and so on).
-If less than zero or an empty string then there won't be any default
-button.
-.TP
-\fIstring\fR
-There will be one button for each of these arguments.
-Each \fIstring\fR specifies text to display in a button,
-in order from left to right.
-.PP
-After creating a dialog box, \fBtk_dialog\fR waits for the user to
-select one of the buttons either by clicking on the button with the
-mouse or by typing return to invoke the default button (if any).
-Then it returns the index of the selected button: 0 for the leftmost
-button, 1 for the button next to it, and so on.
-If the dialog's window is destroyed before the user selects one
-of the buttons, then -1 is returned.
-.PP
-While waiting for the user to respond, \fBtk_dialog\fR sets a local
-grab. This prevents the user from interacting with the application
-in any way except to invoke the dialog box.
-
-.SH KEYWORDS
-bitmap, dialog, modal
diff --git a/doc/entry.n b/doc/entry.n
deleted file mode 100644
index 27c4fcc..0000000
--- a/doc/entry.n
+++ /dev/null
@@ -1,417 +0,0 @@
-'\"
-'\" 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: entry.n,v 1.2 1998/09/14 18:22:55 stanton Exp $
-'\"
-.so man.macros
-.TH entry n 4.1 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-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
-.SE
-.SH "WIDGET-SPECIFIC OPTIONS"
-.OP \-show show Show
-If this option is specified, then the true contents of the entry
-are not displayed in the window.
-Instead, each character in the entry's value will be displayed as
-the first character in the value of this option, such as ``*''.
-This is useful, for example, if the entry is to be used to enter
-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.
-.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.
-.OP \-width width Width
-Specifies an integer value indicating the desired width of the entry 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.
-.BE
-
-.SH DESCRIPTION
-.PP
-The \fBentry\fR command creates a new window (given by the
-\fIpathName\fR argument) and makes it into an entry widget.
-Additional options, described above, may be specified on the
-command line or in the option database
-to configure aspects of the entry such as its colors, font,
-and relief. The \fBentry\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
-An entry is a widget that displays a one-line text string and
-allows that string to be edited using widget commands described below, which
-are typically bound to keystrokes and mouse actions.
-When first created, an entry's string is empty.
-A portion of the entry may be selected as described below.
-If an entry is exporting its selection (see the \fBexportSelection\fR
-option), then it will observe the standard X11 protocols for handling the
-selection; entry selections are available as type \fBSTRING\fR.
-Entries also observe the standard Tk rules for dealing with the
-input focus. When an entry has the input focus it displays an
-\fIinsertion cursor\fR to indicate where new characters will be
-inserted.
-.PP
-Entries 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. Entries 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 "WIDGET COMMAND"
-.PP
-The \fBentry\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 entries take one or more indices as
-arguments. An index specifies a particular character in the entry'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 entry's string.
-This is equivalent to specifying a numerical index equal to the length
-of the entry'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 entry 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
-entry window.
-.TP 12
-\fB@\fInumber\fR
-In this form, \fInumber\fR is treated as an x-coordinate in the
-entry'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 entry 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 \fBentry\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 \fBentry\fR
-command.
-.TP
-\fIpathName \fBdelete \fIfirst \fR?\fIlast\fR?
-Delete one or more elements of the entry.
-\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 entry'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 \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 \fBscan\fR \fIoption args\fR
-This command is used to implement scanning on entries. It has
-two forms, depending on \fIoption\fR:
-.RS
-.TP
-\fIpathName \fBscan mark \fIx\fR
-Records \fIx\fR and the current view in the entry 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 entry 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 an entry. 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 entry, 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 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 entry,
-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 entry'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 \fBxview \fIargs\fR
-This command is used to query and change the horizontal position of the
-text in the widget's window. It can take any of the following
-forms:
-.RS
-.TP
-\fIpathName \fBxview\fR
-Returns a list containing two elements.
-Each element is a real fraction between 0 and 1; together they describe
-the horizontal span that is visible in the window.
-For example, if the first element is .2 and the second element is .6,
-20% of the entry's text is off-screen to the left, the middle 40% is visible
-in the window, and 40% of the text is off-screen to the right.
-These are the same values passed to scrollbars via the \fB\-xscrollcommand\fR
-option.
-.TP
-\fIpathName \fBxview\fR \fIindex\fR
-Adjusts the view in the window so that the character given by \fIindex\fR
-is displayed at the left edge of the window.
-.TP
-\fIpathName \fBxview moveto\fI fraction\fR
-Adjusts the view in the window so that the character \fIfraction\fR of the
-way through the text appears at the left edge of the window.
-\fIFraction\fR must be a fraction between 0 and 1.
-.TP
-\fIpathName \fBxview scroll \fInumber what\fR
-This command shifts the view in the window left or right according to
-\fInumber\fR and \fIwhat\fR.
-\fINumber\fR must be an integer.
-\fIWhat\fR must be either \fBunits\fR or \fBpages\fR or an abbreviation
-of one of these.
-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 entries 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
-entry 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 entry without affecting the selection.
-.IP [6]
-If any normal printing characters are typed in an entry, they are
-inserted at the point of the insertion cursor.
-.IP [7]
-The view in the entry can be adjusted by dragging with mouse button 2.
-If mouse button 2 is clicked without moving the mouse, the selection
-is copied into the entry at the position of the mouse cursor.
-.IP [8]
-If the mouse is dragged out of the entry on the left or right sides
-while button 1 is pressed, the entry will automatically scroll to
-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 entry 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 entry and clear any selection in the entry.
-Shift-Home moves the insertion cursor to the beginning of the entry
-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 entry and clear any selection in the entry.
-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 entry.
-.IP [14]
-Control-\e clears any selection in the entry.
-.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 entry.
-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 entry.
-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 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.
-.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/doc/event.n b/doc/event.n
deleted file mode 100644
index 0f1ac60..0000000
--- a/doc/event.n
+++ /dev/null
@@ -1,338 +0,0 @@
-'\"
-'\" Copyright (c) 1996 Sun Microsystems, Inc.
-'\"
-'\" See the file "license.terms" for information on usage and redistribution
-'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-'\"
-'\" RCS: @(#) $Id: event.n,v 1.2 1998/09/14 18:22:55 stanton Exp $
-'\"
-.so man.macros
-.TH event n 4.4 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-event \- Miscellaneous event facilities: define virtual events and generate events
-.SH SYNOPSIS
-\fBevent\fI option \fR?\fIarg arg ...\fR?
-.BE
-
-.SH DESCRIPTION
-.PP
-The \fBevent\fR command provides several facilities for dealing with
-window system events, such as defining virtual events and synthesizing
-events. The command has several different forms, determined by the
-first argument. The following forms are currently supported:
-.TP
-\fBevent add <<\fIvirtual\fB>>\fI sequence \fR?\fIsequence ...\fR?
-Associates the virtual event \fIvirtual\fR with the physical
-event sequence(s) given by the \fIsequence\fR arguments, so that
-the virtual event will trigger whenever any one of the \fIsequence\fRs
-occurs.
-\fIVirtual\fR may be any string value and \fIsequence\fR may have
-any of the values allowed for the \fIsequence\fR argument to the
-\fBbind\fR command.
-If \fIvirtual\fR is already defined, the new physical event sequences
-add to the existing sequences for the event.
-.TP
-\fBevent delete <<\fIvirtual\fB>> \fR?\fIsequence\fR \fIsequence ...\fR?
-Deletes each of the \fIsequence\fRs from those associated with
-the virtual event given by \fIvirtual\fR.
-\fIVirtual\fR may be any string value and \fIsequence\fR may have
-any of the values allowed for the \fIsequence\fR argument to the
-\fBbind\fR command.
-Any \fIsequence\fRs not currently associated with \fIvirtual\fR
-are ignored.
-If no \fIsequence\fR argument is provided, all physical event sequences
-are removed for \fIvirtual\fR, so that the virtual event will not
-trigger anymore.
-.TP
-\fBevent generate \fIwindow event \fR?\fIoption value option value ...\fR?
-Generates a window event and arranges for it to be processed just as if
-it had come from the window system.
-\fIWindow\fR gives the path name of the window for which the event
-.VS
-will be generated; it may also be an identifier (such as returned by
-\fBwinfo id\fR) as long as it is for a window in the current application.
-.VE
-\fIEvent\fR provides a basic description of
-the event, such as \fB<Shift-Button-2>\fR or \fB<<Paste>>\fR.
-\fIEvent\fR may have any of the forms allowed for the \fIsequence\fR
-argument of the \fBbind\fR command except that it must consist
-of a single event pattern, not a sequence.
-\fIOption-value\fR pairs may be used to specify additional
-attributes of the event, such as the x and y mouse position; see
-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.
-.TP
-\fBevent info \fR?<<\fIvirtual\fB>>\fR?
-Returns information about virtual events.
-If the \fB<<\fIvirtual\fB>>\fR argument is omitted, the return value
-is a list of all the virtual events that are currently defined.
-If \fB<<\fIvirtual\fB>>\fR is specified then the return value is
-a list whose elements are the physical event sequences currently
-defined for the given virtual event; if the virtual event is
-not defined then an empty string is returned.
-
-.SH "EVENT FIELDS"
-.PP
-The following options are supported for the \fBevent generate\fR
-command. These correspond to the ``%'' expansions
-allowed in binding scripts for the \fBbind\fR command.
-.TP
-\fB\-above\fI window\fR
-\fIWindow\fR specifies the \fIabove\fR field for the event,
-either as a window path name or as an integer window id.
-Valid for \fBConfigure\fR events.
-Corresponds to the \fB%a\fR substitution for binding scripts.
-.TP
-\fB\-borderwidth\fI size\fR
-\fISize\fR must be a screen distance; it specifies the
-\fIborder_width\fR field for the event.
-Valid for \fBConfigure\fR events.
-Corresponds to the \fB%B\fR substitution for binding scripts.
-.TP
-\fB\-button\fI number\fR
-\fINumber\fR must be an integer; it specifies the \fIdetail\fR field
-for a \fBButtonPress\fR or \fBButtonRelease\fR event, overriding
-any button number provided in the base \fIevent\fR argument.
-Corresponds to the \fB%b\fR substitution for binding scripts.
-.TP
-\fB\-count\fI number\fR
-\fINumber\fR must be an integer; it specifies the \fIcount\fR field
-for the event. Valid for \fBExpose\fR events.
-Corresponds to the \fB%c\fR substitution for binding scripts.
-.TP
-\fB\-detail\fI detail\fR
-\fIDetail\fR specifies the \fIdetail\fR field for the event
-and must be one of the following:
-.RS
-.DS
-.ta 6c
-\fBNotifyAncestor NotifyNonlinearVirtual
-NotifyDetailNone NotifyPointer
-NotifyInferior NotifyPointerRoot
-NotifyNonlinear NotifyVirtual\fR
-.DE
-Valid for \fBEnter\fR, \fBLeave\fR, \fBFocusIn\fR and
-\fBFocusOut\fR events.
-Corresponds to the \fB%d\fR substitution for binding scripts.
-.RE
-.TP
-\fB\-focus\fI boolean\fR
-\fIBoolean\fR must be a boolean value; it specifies the \fIfocus\fR
-field for the event.
-Valid for \fBEnter\fR and \fBLeave\fR events.
-Corresponds to the \fB%f\fR substitution for binding scripts.
-.TP
-\fB\-height\fI size\fR
-\fISize\fR must be a screen distance; it specifies the \fIheight\fR
-field for the event. Valid for \fBConfigure\fR events.
-Corresponds to the \fB%h\fR substitution for binding scripts.
-.TP
-\fB\-keycode\fI number\fR
-\fINumber\fR must be an integer; it specifies the \fIkeycode\fR
-field for the event.
-Valid for \fBKeyPress\fR and \fBKeyRelease\fR events.
-Corresponds to the \fB%k\fR substitution for binding scripts.
-.TP
-\fB\-keysym\fI name\fR
-\fIName\fR must be the name of a valid keysym, such as \fBg\fR,
-\fBspace\fR, or \fBReturn\fR; its corresponding
-keycode value is used as the \fIkeycode\fR field for event, overriding
-any detail specified in the base \fIevent\fR argument.
-Valid for \fBKeyPress\fR and \fBKeyRelease\fR events.
-Corresponds to the \fB%K\fR substitution for binding scripts.
-.TP
-\fB\-mode\fI notify\fR
-\fINotify\fR specifies the \fImode\fR field for the event and must be
-one of \fBNotifyNormal\fR, \fBNotifyGrab\fR, \fBNotifyUngrab\fR, or
-\fBNotifyWhileGrabbed\fR.
-Valid for \fBEnter\fR, \fBLeave\fR, \fBFocusIn\fR, and
-\fBFocusOut\fR events.
-Corresponds to the \fB%m\fR substitution for binding scripts.
-.TP
-\fB\-override\fI boolean\fR
-\fIBoolean\fR must be a boolean value; it specifies the
-\fIoverride_redirect\fR field for the event.
-Valid for \fBMap\fR, \fBReparent\fR, and \fBConfigure\fR events.
-Corresponds to the \fB%o\fR substitution for binding scripts.
-.TP
-\fB\-place\fI where\fR
-\fIWhere\fR specifies the \fIplace\fR field for the event; it must be
-either \fBPlaceOnTop\fR or \fBPlaceOnBottom\fR.
-Valid for \fBCirculate\fR events.
-Corresponds to the \fB%p\fR substitution for binding scripts.
-.TP
-\fB\-root\fI window\fR
-\fIWindow\fR must be either a window path name or an integer window
-identifier; it specifies the \fIroot\fR field for the event.
-Valid for \fBKeyPress\fR, \fBKeyRelease\fR, \fBButtonPress\fR,
-\fBButtonRelease\fR, \fBEnter\fR, \fBLeave\fR, and \fBMotion\fR
-events.
-Corresponds to the \fB%R\fR substitution for binding scripts.
-.TP
-\fB\-rootx\fI coord\fR
-\fICoord\fR must be a screen distance; it specifies the \fIx_root\fR
-field for the event.
-Valid for \fBKeyPress\fR, \fBKeyRelease\fR, \fBButtonPress\fR,
-\fBButtonRelease\fR, \fBEnter\fR, \fBLeave\fR, and \fBMotion\fR
-events. Corresponds to the \fB%X\fR substitution for binding scripts.
-.TP
-\fB\-rooty\fI coord\fR
-\fICoord\fR must be a screen distance; it specifies th \fIy_root\fR
-field for the event.
-Valid for \fBKeyPress\fR, \fBKeyRelease\fR, \fBButtonPress\fR,
-\fBButtonRelease\fR, \fBEnter\fR, \fBLeave\fR, and \fBMotion\fR
-events.
-Corresponds to the \fB%Y\fR substitution for binding scripts.
-.TP
-\fB\-sendevent\fI boolean\fR
-\fBBoolean\fR must be a boolean value; it specifies the \fIsend_event\fR
-field for the event. Valid for all events. Corresponds to the
-\fB%E\fR substitution for binding scripts.
-.TP
-\fB\-serial\fI number\fR
-\fINumber\fR must be an integer; it specifies the \fIserial\fR field
-for the event. Valid for all events.
-Corresponds to the \fB%#\fR substitution for binding scripts.
-.TP
-\fB\-state\fI state\fR
-\fIState\fR specifies the \fIstate\fR field for the event.
-For \fBKeyPress\fR, \fBKeyRelease\fR, \fBButtonPress\fR,
-\fBButtonRelease\fR, \fBEnter\fR, \fBLeave\fR, and \fBMotion\fR events
-it must be an integer value.
-For \fBVisibility\fR events it must be one of \fBVisibilityUnobscured\fR,
-\fBVisibilityPartiallyObscured\fR, or \fBVisibilityFullyObscured\fR.
-This option overrides any modifiers such as \fBMeta\fR or \fBControl\fR
-specified in the base \fIevent\fR.
-Corresponds to the \fB%s\fR substitution for binding scripts.
-.TP
-\fB\-subwindow\fI window\fR
-\fIWindow\fR specifies the \fIsubwindow\fR field for the event, either
-as a path name for a Tk widget or as an integer window identifier.
-Valid for \fBKeyPress\fR, \fBKeyRelease\fR, \fBButtonPress\fR,
-\fBButtonRelease\fR, \fBEnter\fR, \fBLeave\fR, and \fBMotion\fR events.
-Similar to \fB%S\fR substitution for binding scripts.
-.TP
-\fB\-time\fI integer\fR
-\fIInteger\fR must be an integer value; it specifies the \fItime\fR field
-for the event.
-Valid for \fBKeyPress\fR, \fBKeyRelease\fR, \fBButtonPress\fR,
-\fBButtonRelease\fR, \fBEnter\fR, \fBLeave\fR, \fBMotion\fR,
-and \fBProperty\fR events.
-Corresponds to the \fB%t\fR substitution for binding scripts.
-.TP
-\fB\-width\fI size\fR
-\fISize\fR must be a screen distance; it specifies the \fIwidth\fR field
-for the event.
-Valid for \fBConfigure\fR events.
-Corresponds to the \fB%w\fR substitution for binding scripts.
-.TP
-\fB\-when\fI when\fR
-\fIWhen\fR determines when the event will be processed; it must have one
-of the following values:
-.RS
-.IP \fBnow\fR 10
-Process the event immediately, before the command returns.
-This also happens if the \fB\-when\fR option is omitted.
-.IP \fBtail\fR 10
-Place the event on Tcl's event queue behind any events already
-queued for this application.
-.IP \fBhead\fR 10
-Place the event at the front of Tcl's event queue, so that it
-will be handled before any other events already queued.
-.IP \fBmark\fR 10
-Place the event at the front of Tcl's event queue but behind any
-other events already queued with \fB\-when mark\fR.
-This option is useful when generating a series of events that should
-be processed in order but at the front of the queue.
-.RE
-.TP
-\fB\-x\fI coord\fR
-\fICoord\fR must be a screen distance; it specifies the \fIx\fR field
-for the event.
-Valid for \fBKeyPress\fR, \fBKeyRelease\fR, \fBButtonPress\fR,
-\fBButtonRelease\fR, \fBMotion\fR, \fBEnter\fR, \fBLeave\fR,
-\fBExpose\fR, \fBConfigure\fR, \fBGravity\fR, and \fBReparent\fR
-events.
-Corresponds to the the \fB%x\fR substitution for binding scripts.
-.TP
-\fB\-y\fI coord\fR
-\fICoord\fR must be a screen distance; it specifies the \fIy\fR
-field for the event.
-Valid for \fBKeyPress\fR, \fBKeyRelease\fR, \fBButtonPress\fR,
-\fBButtonRelease\fR, \fBMotion\fR, \fBEnter\fR, \fBLeave\fR,
-\fBExpose\fR, \fBConfigure\fR, \fBGravity\fR, and \fBReparent\fR
-events.
-Corresponds to the the \fB%y\fR substitution for binding scripts.
-.PP
-Any options that are not specified when generating an event are filled
-with the value 0, except for \fIserial\fR, which is filled with the
-next X event serial number.
-
-.SH "VIRTUAL EVENT EXAMPLES"
-.PP
-In order for a virtual event binding to trigger, two things must
-happen. First, the virtual event must be defined with the
-\fBevent add\fR command. Second, a binding must be created for
-the virtual event with the \fBbind\fR command.
-Consider the following virtual event definitions:
-.CS
-event add <<Paste>> <Control-y>
-event add <<Paste>> <Button-2>
-event add <<Save>> <Control-X><Control-S>
-event add <<Save>> <Shift-F12>
-.CE
-In the \fBbind\fR command, a virtual event can be bound like any other
-builtin event type as follows:
-.CS
-bind Entry <<Paste>> {%W insert [selection get]}
-.CE
-The double angle brackets are used to specify that a virtual event is being
-bound. If the user types Control-y or presses button 2, or if
-a \fB<<Paste>>\fR virtual event is synthesized with \fBevent generate\fR,
-then the \fB<<Paste>>\fR binding will be invoked.
-.PP
-If a virtual binding has the exact same sequence as a separate
-physical binding, then the physical binding will take precedence.
-Consider the following example:
-.CS
-event add <<Paste>> <Control-y> <Meta-Control-y>
-bind Entry <Control-y> {puts Control-y}
-bind Entry <<Paste>> {puts Paste}
-.CE
-When the user types Control-y the \fB<Control-y>\fR binding
-will be invoked, because a physical event is considered
-more specific than a virtual event, all other things being equal.
-However, when the user types Meta-Control-y the
-\fB<<Paste>>\fR binding will be invoked, because the
-\fBMeta\fR modifier in the physical pattern associated with the
-virtual binding is more specific than the \fB<Control-y\fR> sequence for
-the physical event.
-.PP
-Bindings on a virtual event may be created before the virtual event exists.
-Indeed, the virtual event never actually needs to be defined, for instance,
-on platforms where the specific virtual event would meaningless or
-ungeneratable.
-.PP
-When a definition of a virtual event changes at run time, all windows
-will respond immediately to the new definition.
-Starting from the preceding example, if the following code is executed:
-.CS
-bind <Entry> <Control-y> {}
-event add <<Paste>> <Key-F6>
-.CE
-the behavior will change such in two ways. First, the shadowed
-\fB<<Paste>>\fR binding will emerge.
-Typing Control-y will no longer invoke the \fB<Control-y>\fR binding,
-but instead invoke the virtual event \fB<<Paste>>\fR. Second,
-pressing the F6 key will now also invoke the \fB<<Paste>>\fR binding.
-
-.SH "SEE ALSO"
-bind
-
-.SH KEYWORDS
-event, binding, define, handle, virtual event
diff --git a/doc/focus.n b/doc/focus.n
deleted file mode 100644
index bcc11e1..0000000
--- a/doc/focus.n
+++ /dev/null
@@ -1,113 +0,0 @@
-'\"
-'\" 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: focus.n,v 1.2 1998/09/14 18:22:56 stanton Exp $
-'\"
-.so man.macros
-.TH focus n 4.0 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-focus \- Manage the input focus
-.SH SYNOPSIS
-\fBfocus\fR
-.sp
-\fBfocus \fIwindow\fR
-.sp
-\fBfocus \fIoption\fR ?\fIarg arg ...\fR?
-.BE
-
-.SH DESCRIPTION
-.PP
-The \fBfocus\fR command is used to manage the Tk input focus.
-At any given time, one window on each display is designated as
-the \fIfocus window\fR; any key press or key release events for the
-display are sent to that window.
-It is normally up to the window manager to redirect the focus among the
-top-level windows of a display. For example, some window managers
-automatically set the input focus to a top-level window whenever
-the mouse enters it; others redirect the input focus only when
-the user clicks on a window.
-Usually the window manager will set the focus
-only to top-level windows, leaving it up to the application to
-redirect the focus among the children of the top-level.
-.PP
-Tk remembers one focus window for each top-level (the most recent
-descendant of that top-level to receive the focus); when the window
-manager gives the focus
-to a top-level, Tk automatically redirects it to the remembered
-window. Within a top-level Tk uses an \fIexplicit\fR focus model
-by default. Moving the mouse within a top-level does not normally
-change the focus; the focus changes only when a widget
-decides explicitly to claim the focus (e.g., because of a button
-click), or when the user types a key such as Tab that moves the
-focus.
-.PP
-The Tcl procedure \fBtk_focusFollowsMouse\fR may be invoked to
-create an \fIimplicit\fR focus model: it reconfigures Tk so that
-the focus is set to a window whenever the mouse enters it.
-The Tcl procedures \fBtk_focusNext\fR and \fBtk_focusPrev\fR
-implement a focus order among the windows of a top-level; they
-are used in the default bindings for Tab and Shift-Tab, among other
-things.
-.PP
-The \fBfocus\fR command can take any of the following forms:
-.TP
-\fBfocus\fR
-Returns the path name of the focus window on the display containing
-the application's main window, or an empty string if no window in
-this application has the focus on that display. Note: it is
-better to specify the display explicitly using \fB\-displayof\fR
-(see below) so that the code will work in applications using multiple
-displays.
-.TP
-\fBfocus \fIwindow\fR
-If the application currently has the input focus on \fIwindow\fR's
-display, this command resets the input focus for \fIwindow\fR's display
-to \fIwindow\fR and returns an empty string.
-If the application doesn't currently have the input focus on
-\fIwindow\fR's display, \fIwindow\fR will be remembered as the focus
-for its top-level; the next time the focus arrives at the top-level,
-Tk will redirect it to \fIwindow\fR.
-If \fIwindow\fR is an empty string then the command does nothing.
-.TP
-\fBfocus \-displayof\fR \fIwindow\fR
-Returns the name of the focus window on the display containing \fIwindow\fR.
-If the focus window for \fIwindow\fR's display isn't in this
-application, the return value is an empty string.
-.TP
-\fBfocus \-force \fIwindow\fR
-Sets the focus of \fIwindow\fR's display to \fIwindow\fR, even if
-the application doesn't currently have the input focus for the display.
-This command should be used sparingly, if at all.
-In normal usage, an application should not claim the focus for
-itself; instead, it should wait for the window manager to give it
-the focus.
-If \fIwindow\fR is an empty string then the command does nothing.
-.TP
-\fBfocus \-lastfor\fR \fIwindow\fR
-Returns the name of the most recent window to have the input focus
-among all the windows in the same top-level as \fIwindow\fR.
-If no window in that top-level has ever had the input focus, or
-if the most recent focus window has been deleted, then the name
-of the top-level is returned. The return value is the window that
-will receive the input focus the next time the window manager gives
-the focus to the top-level.
-
-.SH "QUIRKS"
-.PP
-When an internal window receives the input focus, Tk doesn't actually
-set the X focus to that window; as far as X is concerned, the focus
-will stay on the top-level window containing the window with the focus.
-However, Tk generates FocusIn and FocusOut events just as if the X
-focus were on the internal window. This approach gets around a
-number of problems that would occur if the X focus were actually moved;
-the fact that the X focus is on the top-level is invisible unless
-you use C code to query the X server directly.
-
-.SH KEYWORDS
-events, focus, keyboard, top-level, window manager
diff --git a/doc/focusNext.n b/doc/focusNext.n
deleted file mode 100644
index fb326b3..0000000
--- a/doc/focusNext.n
+++ /dev/null
@@ -1,60 +0,0 @@
-'\"
-'\" Copyright (c) 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: focusNext.n,v 1.2 1998/09/14 18:22:56 stanton Exp $
-'\"
-.so man.macros
-.TH tk_focusNext n 4.0 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-tk_focusNext, tk_focusPrev, tk_focusFollowsMouse \- Utility procedures for managing the input focus.
-.SH SYNOPSIS
-\fBtk_focusNext \fIwindow\fR
-.sp
-\fBtk_focusPrev \fIwindow\fR
-.sp
-\fBtk_focusFollowsMouse\fR
-.BE
-
-.SH DESCRIPTION
-.PP
-\fBtk_focusNext\fR is a utility procedure used for keyboard traversal.
-It returns the ``next'' window after \fIwindow\fR in focus order.
-The focus order is determined by
-the stacking order of windows and the structure of the window hierarchy.
-Among siblings, the focus order is the same as the stacking order, with the
-lowest window being first.
-If a window has children, the window is visited first, followed by
-its children (recursively), followed by its next sibling.
-Top-level windows other than \fIwindow\fR are skipped, so that
-\fBtk_focusNext\fR never returns a window in a different top-level
-from \fIwindow\fR.
-.PP
-After computing the next window, \fBtk_focusNext\fR examines the
-window's \fB\-takefocus\fR option to see whether it should be skipped.
-If so, \fBtk_focusNext\fR continues on to the next window in the focus
-order, until it eventually finds a window that will accept the focus
-or returns back to \fIwindow\fR.
-.PP
-\fBtk_focusPrev\fR is similar to \fBtk_focusNext\fR except that it
-returns the window just before \fIwindow\fR in the focus order.
-.PP
-\fBtk_focusFollowsMouse\fR changes the focus model for the application
-to an implicit one where the window under the mouse gets the focus.
-After this procedure is called, whenever the mouse enters a window
-Tk will automatically give it the input focus.
-The \fBfocus\fR command may be used to move the focus to a window
-other than the one under the mouse, but as soon as the mouse moves
-into a new window the focus will jump to that window.
-Note: at present there is no built-in support for returning the
-application to an explicit focus model; to do this you'll have
-to write a script that deletes the bindings created by
-\fBtk_focusFollowsMouse\fR.
-
-.SH KEYWORDS
-focus, keyboard traversal, top-level
diff --git a/doc/font.n b/doc/font.n
deleted file mode 100644
index 3677771..0000000
--- a/doc/font.n
+++ /dev/null
@@ -1,285 +0,0 @@
-'\"
-'\" Copyright (c) 1996 Sun Microsystems, Inc.
-'\"
-'\" See the file "license.terms" for information on usage and redistribution
-'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-'\"
-'\" RCS: @(#) $Id: font.n,v 1.2 1998/09/14 18:22:56 stanton Exp $
-'\"
-.so man.macros
-.TH font n 8.0 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-font \- Create and inspect fonts.
-.SH SYNOPSIS
-\fBfont\fI option \fR?\fIarg arg ...\fR?
-.BE
-.SH DESCRIPTION
-.PP
-The \fBfont\fR command provides several facilities for dealing with
-fonts, such as defining named fonts and inspecting the actual attributes of
-a font. The command has several different forms, determined by the
-first argument. The following forms are currently supported:
-.TP
-\fBfont actual \fIfont\fR ?\fB\-displayof \fIwindow\fR? ?\fIoption\fR?
-.
-Returns information about the the actual attributes that are obtained when
-\fIfont\fR is used on \fIwindow\fR's display; the actual attributes obtained
-may differ from the attributes requested due to platform-dependant
-limitations, such as the availability of font families and pointsizes.
-\fIfont\fR is a font description; see FONT DESCRIPTIONS below. If the
-\fIwindow\fR argument is omitted, it defaults to the main window. If
-\fIoption\fR is specified, returns the value of that attribute; if it is
-omitted, the return value is a list of all the attributes and their values.
-See FONT OPTIONS below for a list of the possible attributes.
-.TP
-\fBfont configure \fIfontname\fR ?\fIoption\fR? ?\fIvalue option value ...\fR?
-.
-Query or modify the desired attributes for the named font called
-\fIfontname\fR. If no \fIoption\fR is specified, returns a list describing
-all the options and their values for \fIfontname\fR. If a single \fIoption\fR
-is specified with no \fIvalue\fR, then returns the current value of that
-attribute. If one or more \fIoption\fR\-\fIvalue\fR pairs are specified,
-then the command modifies the given named font to have the given values; in
-this case, all widgets using that font will redisplay themselves using the
-new attributes for the font. See FONT OPTIONS below for a list of the
-possible attributes.
-.TP
-\fBfont create\fR ?\fIfontname\fR? ?\fIoption value ...\fR?
-.
-Creates a new named font and returns its name. \fIfontname\fR specifies the
-name for the font; if it is omitted, then Tk generates a new name of the
-form \fBfont\fIx\fR, where \fIx\fR is an integer. There may be any number
-of \fIoption\fR\-\fIvalue\fR pairs, which provide the desired attributes for
-the new named font. See FONT OPTIONS below for a list of the possible
-attributes.
-.TP
-\fBfont delete\fR \fIfontname\fR ?\fIfontname ...\fR?
-.
-Delete the specified named fonts. If there are widgets using the named font,
-the named font won't actually be deleted until all the instances are
-released. Those widgets will continue to display using the last known values
-for the named font. If a deleted named font is subsequently recreated with
-another call to \fBfont create\fR, the widgets will use the new named font
-and redisplay themselves using the new attributes of that font.
-.TP
-\fBfont families\fR ?\fB\-displayof \fIwindow\fR?
-.
-The return value is a list of the case-insensitive names of all font families
-that exist on \fIwindow\fR's display. If the \fIwindow\fR argument is
-omitted, it defaults to the main window.
-.TP
-\fBfont measure \fIfont\fR ?\fB\-displayof \fIwindow\fR? \fItext\fR
-.
-Measures the amount of space the string \fItext\fR would use in the given
-\fIfont\fR when displayed in \fIwindow\fR. \fIfont\fR is a font description;
-see FONT DESCRIPTIONS below. If the \fIwindow\fR argument is omitted, it
-defaults to the main window. The return value is the total width in pixels
-of \fItext\fR, not including the extra pixels used by highly exagerrated
-characters such as cursive ``f''. If the string contains newlines or tabs,
-those characters are not expanded or treated specially when measuring the
-string.
-.TP
-\fBfont metrics \fIfont\fR ?\fB\-displayof \fIwindow\fR? ?\fIoption\fR?
-.
-Returns information about the metrics (the font-specific data), for
-\fIfont\fR when it is used on \fIwindow\fR's display. \fIfont\fR is a font
-description; see FONT DESCRIPTIONS below. If the \fIwindow\fR argument is
-omitted, it defaults to the main window. If \fIoption\fR is specified,
-returns the value of that metric; if it is omitted, the return value is a
-list of all the metrics and their values. See FONT METRICS below for a list
-of the possible metrics.
-.TP
-\fBfont names\fR
-The return value is a list of all the named fonts that are currently defined.
-.SH "FONT DESCRIPTION"
-.PP
-The following formats are accepted as a font description anywhere
-\fIfont\fR is specified as an argument above; these same forms are also
-permitted when specifying the \fB\-font\fR option for widgets.
-.TP
-[1] \fIfontname\fR
-.
-The name of a named font, created using the \fBfont create\fR command. When
-a widget uses a named font, it is guaranteed that this will never cause an
-error, as long as the named font exists, no matter what potentially invalid
-or meaningless set of attributes the named font has. If the named font
-cannot be displayed with exactly the specified attributes, some other close
-font will be substituted automatically.
-.TP
-[2] \fIsystemfont\fR
-.
-The platform-specific name of a font, interpreted by the graphics server.
-This also includes, under X, an XLFD (see [4]) for which a single ``\fB*\fR''
-character was used to elide more than one field in the middle of the
-name. See PLATFORM-SPECIFIC issues for a list of the system fonts.
-.VS 8.0 br
-.TP
-[3] \fIfamily \fR?\fIsize\fR? ?\fIstyle\fR? ?\fIstyle ...\fR?
-.
-A properly formed list whose first element is the desired font
-\fIfamily\fR and whose optional second element is the desired \fIsize\fR.
-The interpretation of the \fIsize\fR attribute follows the same rules
-described for \fB\-size\fR in FONT OPTIONS below. Any additional optional
-arguments following the \fIsize\fR are font \fIstyle\fRs. Possible values
-for the \fIstyle\fR arguments are as follows:
-.RS
-.DS
-.ta 3c 6c 9c
-\fBnormal bold roman italic
-underline overstrike\fR
-.DE
-.RE
-.TP
-[4] X-font names (XLFD)
-.
-A Unix-centric font name of the form
-\fI-foundry-family-weight-slant-setwidth-addstyle-pixel-point-resx-resy-spacing-width-charset-encoding\fR.
-The ``\fB*\fR'' character may be used to skip individual fields that the
-user does not care about. There must be exactly one ``\fB*\fR'' for each
-field skipped, except that a ``\fB*\fR'' at the end of the XLFD skips any
-remaining fields; the shortest valid XLFD is simply ``\fB*\fR'', signifying
-all fields as defaults. Any fields that were skipped are given default
-values. For compatibility, an XLFD always chooses a font of the specified
-pixel size (not point size); although this interpretation is not strictly
-correct, all existing applications using XLFDs assumed that one ``point''
-was in fact one pixel and would display incorrectly (generally larger) if
-the correct size font were actually used.
-.VE
-.TP
-[5] \fIoption value \fR?\fIoption value ...\fR?
-.
-A properly formed list of \fIoption\fR\-\fIvalue\fR pairs that specify
-the desired attributes of the font, in the same format used when defining
-a named font; see FONT OPTIONS below.
-.LP
-When font description \fIfont\fR is used, the system attempts to parse the
-description according to each of the above five rules, in the order specified.
-Cases [1] and [2] must match the name of an existing named font or of a
-system font. Cases [3], [4], and [5] are accepted on all
-platforms and the closest available font will be used. In some situations
-it may not be possible to find any close font (e.g., the font family was
-a garbage value); in that case, some system-dependant default font is
-chosen. If the font description does not match any of the above patterns,
-an error is generated.
-.SH "FONT METRICS"
-.
-The following options are used by the \fBfont metrics\fR command to query
-font-specific data determined when the font was created. These properties are
-for the whole font itself and not for individual characters drawn in that
-font. In the following definitions, the ``baseline'' of a font is the
-horizontal line where the bottom of most letters line up; certain letters,
-such as lower-case ``g'' stick below the baseline.
-.TP
-\fB\-ascent \0\fR
-.
-The amount in pixels that the tallest letter sticks up above the baseline of
-the font, plus any extra blank space added by the designer of the font.
-.TP
-\fB\-descent \0\fR
-.
-The largest amount in pixels that any letter sticks down below the baseline
-of the font, plus any extra blank space added by the designer of the font.
-.TP
-\fB\-linespace\fR
-.
-Returns how far apart vertically in pixels two lines of text using the same
-font should be placed so that none of the characters in one line overlap any
-of the characters in the other line. This is generally the sum of the ascent
-above the baseline line plus the descent below the baseline.
-.TP
-\fB\-fixed \0\fR
-.
-Returns a boolean flag that is ``\fB1\fR'' if this is a fixed-width font,
-where each normal character is the the same width as all the other
-characters, or is ``\fB0\fR'' if this is a proportionally-spaced font, where
-individual characters have different widths. The widths of control
-characters, tab characters, and other non-printing characters are not
-included when calculating this value.
-.SH "FONT OPTIONS"
-The following options are supported on all platforms, and are used when
-constructing a named font or when specifying a font using style [5] as
-above:
-.TP
-\fB\-family \fIname\fR
-.
-The case-insensitive font family name. Tk guarantees to support the font
-families named \fBCourier\fR (a monospaced ``typewriter'' font), \fBTimes\fR
-(a serifed ``newspaper'' font), and \fBHelvetica\fR (a sans-serif
-``European'' font). The most closely matching native font family will
-automatically be substituted when one of the above font families is used.
-The \fIname\fR may also be the name of a native, platform-specific font
-family; in that case it will work as desired on one platform but may not
-display correctly on other platforms. If the family is unspecified or
-unrecognized, a platform-specific default font will be chosen.
-.VS
-.TP
-\fB\-size \fIsize\fR
-.
-The desired size of the font. If the \fIsize\fR argument is a positive
-number, it is interpreted as a size in points. If \fIsize\fR is a negative
-number, its absolute value is interpreted as a size in pixels. If a
-font cannot be displayed at the specified size, a nearby size will be
-chosen. If \fIsize\fR is unspecified or zero, a platform-dependent default
-size will be chosen.
-.RS
-.PP
-Sizes should normally be specified in points so the application will remain
-the same ruler size on the screen, even when changing screen resolutions or
-moving scripts across platforms. However, specifying pixels is useful in
-certain circumstances such as when a piece of text must line up with respect
-to a fixed-size bitmap. The mapping between points and pixels is set when
-the application starts, based on properties of the installed monitor, but it
-can be overridden by calling the \fBtk scaling\fR command.
-.RE
-.VE
-.TP
-\fB\-weight \fIweight\fR
-.
-The nominal thickness of the characters in the font. The value
-\fBnormal\fR specifies a normal weight font, while \fBbold\fR specifies a
-bold font. The closest available weight to the one specified will
-be chosen. The default weight is \fBnormal\fR.
-.TP
-\fB\-slant \fIslant\fR
-The amount the characters in the font are slanted away from the
-vertical. Valid values for slant are \fBroman\fR and \fBitalic\fR.
-A roman font is the normal, upright appearance of a font, while
-an italic font is one that is tilted some number of degrees from upright.
-The closest available slant to the one specified will be chosen.
-The default slant is \fBroman\fR.
-.TP
-\fB\-underline \fIboolean\fR
-The value is a boolean flag that specifies whether characters in this
-font should be underlined. The default value for underline is \fBfalse\fR.
-.TP
-\fB\-overstrike \fIboolean\fR
-The value is a boolean flag that specifies whether a horizontal line should
-be drawn through the middle of characters in this font. The default value
-for overstrike is \fBfalse\fR.
-
-.SH "PLATFORM-SPECIFIC ISSUES"
-.LP
-The following named system fonts are supported:
-.RS
-.TP
-X Windows:
-All valid X font names, including those listed by xlsfonts(1), are available.
-.TP
-MS Windows:
-.DS
-\fBsystem ansi device
-systemfixed ansifixed oemfixed\fR
-.DE
-.TP
-Macintosh:
-.DS
-\fBsystem application\fR
-.DE
-.RE
-.SH "SEE ALSO"
-options
-
-.SH KEYWORDS
-font
diff --git a/doc/frame.n b/doc/frame.n
deleted file mode 100644
index ff6fa72..0000000
--- a/doc/frame.n
+++ /dev/null
@@ -1,134 +0,0 @@
-'\"
-'\" 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: frame.n,v 1.2 1998/09/14 18:22:56 stanton Exp $
-'\"
-.so man.macros
-.TH frame n 8.0 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-frame \- Create and manipulate frame widgets
-.SH SYNOPSIS
-\fBframe\fR \fIpathName\fR ?\fIoptions\fR?
-.SO
-\-borderwidth \-highlightbackground \-highlightthickness \-takefocus
-\-cursor \-highlightcolor \-relief
-.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.
-.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
-(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.
-.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.
-.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 \fBframe\fR command creates a new window (given by the
-\fIpathName\fR argument) and makes it into a frame widget.
-Additional
-options, described above, may be specified on the command line
-or in the option database
-to configure aspects of the frame such as its background color
-and relief. The \fBframe\fR command returns the
-path name of the new window.
-.PP
-A frame is a simple widget. Its primary purpose is to act as a
-spacer or container for complex window layouts. The only features
-of a frame are its background color and an optional 3-D border to make the
-frame appear raised or sunken.
-
-.SH "WIDGET COMMAND"
-.PP
-The \fBframe\fR command creates a new Tcl command whose
-name is the same as the path name of the frame's window. This
-command may be used to invoke various
-operations on the widget. It has the following general form:
-.CS
-\fIpathName option \fR?\fIarg arg ...\fR?
-.CE
-\fIPathName\fR is the name of the command, which is the same as
-the frame widget's path name. \fIOption\fR and the \fIarg\fRs
-determine the exact behavior of the command. The following
-commands are possible for frame widgets:
-.TP
-\fIpathName \fBcget\fR \fIoption\fR
-Returns the current value of the configuration option given
-by \fIoption\fR.
-\fIOption\fR may have any of the values accepted by the \fBframe\fR
-command.
-.TP
-\fIpathName \fBconfigure\fR ?\fIoption\fR? \fI?value option value ...\fR?
-Query or modify the configuration options of the widget.
-If no \fIoption\fR is specified, returns a list describing all of
-the available options for \fIpathName\fR (see \fBTk_ConfigureInfo\fR for
-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 \fBframe\fR
-command.
-
-.SH BINDINGS
-.PP
-When a new frame is created, it has no default event bindings:
-frames are not intended to be interactive.
-
-.SH KEYWORDS
-frame, widget
diff --git a/doc/getOpenFile.n b/doc/getOpenFile.n
deleted file mode 100644
index ffc86fd..0000000
--- a/doc/getOpenFile.n
+++ /dev/null
@@ -1,157 +0,0 @@
-'\"
-'\" Copyright (c) 1996 Sun Microsystems, Inc.
-'\"
-'\" See the file "license.terms" for information on usage and redistribution
-'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-'\"
-'\" RCS: @(#) $Id: getOpenFile.n,v 1.3 1998/09/14 18:22:56 stanton Exp $
-'\"
-.so man.macros
-.TH tk_getOpenFile n 4.2 Tk "Tk Built-In Commands"
-.BS
-'\" 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
-\fBtk_getSaveFile \fR?\fIoption value ...\fR?
-.BE
-
-.SH DESCRIPTION
-.PP
-The procedures \fBtk_getOpenFile\fR and \fBtk_getSaveFile\fR pop up a
-dialog box for the user to select a file to open or save. The
-\fBtk_getOpenFile\fR command is usually associated with the \fBOpen\fR
-command in the \fBFile\fR menu. Its purpose is for the user to select an
-existing file \fIonly\fR. If the user enters an non-existent file, the
-dialog box gives the user an error prompt and requires the user to give
-an alternative selection. If an application allows the user to create
-new files, it should do so by providing a separate \fBNew\fR menu command.
-.PP
-The \fBtk_getSaveFile\fR command is usually associated with the \fBSave
-as\fR command in the \fBFile\fR menu. If the user enters a file that
-already exists, the dialog box prompts the user for confirmation
-whether the existing file should be overwritten or not.
-.PP
-The following \fIoption\-value\fR pairs are possible as command line
-arguments to these two commands:
-.TP
-\fB\-defaultextension\fR \fIextension\fR
-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.
-.TP
-\fB\-filetypes\fR \fIfilePatternList\fR
-If a \fBFile types\fR listbox exists in the file dialog on the particular
-platform, this option gives the \fIfiletype\fRs in this listbox. When
-the user choose a filetype in the listbox, only the files of that type
-are listed. If this option is unspecified, or if it is set to the
-empty list, or if the \fBFile types\fR listbox is not supported by the
-particular platform then all files are listed regardless of their
-types. See the section SPECIFYING FILE PATTERNS below for a
-discussion on the contents of \fIfilePatternList\fR.
-.TP
-\fB\-initialdir\fR \fIdirectory\fR
-Specifies that the files in \fIdirectory\fR should be displayed
-when the dialog pops up. If this parameter is not specified, then
-the files in the current working directory are displayed. If the
-parameter specifies a relative path, the return value will convert the
-relative path to an absolute path. This option may not always work on
-the Macintosh. This is not a bug. Rather, the \fIGeneral Controls\fR
-control panel on the Mac allows the end user to override the
-application default directory.
-.TP
-\fB\-initialfile\fR \fIfilename\fR
-Specifies a filename to be displayed in the dialog when it pops
-up. This option is ignored by the \fBtk_getOpenFile\fR command.
-.TP
-\fB\-parent\fR \fIwindow\fR
-Makes \fIwindow\fR the logical parent of the file dialog. The file
-dialog is displayed on top of its parent window.
-.TP
-\fB\-title\fR \fItitleString\fR
-Specifies a string to display as the title of the dialog box. If this
-option is not specified, then a default title is displayed. This
-option is ignored on the Macintosh platform.
-.PP
-If the user selects a file, both \fBtk_getOpenFile\fR and
-\fBtk_getSaveFile\fR return the full pathname of this file. If the
-user cancels the operation, both commands return the empty string.
-.SH "SPECIFYING FILE PATTERNS"
-
-The \fIfilePatternList\fR value given by the \fB\-filetypes\fR option
-is a list of file patterns. Each file pattern is a list of the
-form
-.CS
-\fItypeName\fR {\fIextension\fR ?\fIextension ...\fR?} ?{\fImacType\fR ?\fImacType ...\fR?}?
-.CE
-\fItypeName\fR is the name of the file type described by this
-file pattern and is the text string that appears in the \fBFile types\fR
-listbox. \fIextension\fR is a file extension for this file pattern.
-\fImacType\fR is a four-character Macintosh file type. The list of
-\fImacType\fRs is optional and may be omitted for applications that do
-not need to execute on the Macintosh platform.
-.PP
-Several file patterns may have the same \fItypeName,\fR in which case
-they refer to the same file type and share the same entry in the
-listbox. When the user selects an entry in the listbox, all the files
-that match at least one of the file patterns corresponding
-to that entry are listed. Usually, each file pattern corresponds to a
-distinct type of file. The use of more than one file patterns for one
-type of file is necessary on the Macintosh platform only.
-.PP
-On the Macintosh platform, a file matches a file pattern if its
-name matches at least one of the \fIextension\fR(s) AND it
-belongs to at least one of the \fImacType\fR(s) of the
-file pattern. For example, the \fBC Source Files\fR file pattern in the
-sample code matches with files that have a \fB\.c\fR extension AND
-belong to the \fImacType\fR \fBTEXT\fR. To use the OR rule instead,
-you can use two file patterns, one with the \fIextensions\fR only and
-the other with the \fImacType\fR only. The \fBGIF Files\fR file type
-in the sample code matches files that EITHER have a \fB\.gif\fR
-extension OR belong to the \fImacType\fR \fBGIFF\fR.
-.PP
-On the Unix and Windows platforms, a file matches a file pattern
-if its name matches at at least one of the \fIextension\fR(s) of
-the file pattern. The \fImacType\fRs are ignored.
-.SH "SPECIFYING EXTENSIONS"
-.PP
-On the Unix and Macintosh platforms, extensions are matched using
-glob-style pattern matching. On the Windows platforms, extensions are
-matched by the underlying operating system. The types of possible
-extensions are: (1) the special extension * matches any
-file; (2) the special extension "" matches any files that
-do not have an extension (i.e., the filename contains no full stop
-character); (3) any character string that does not contain any wild
-card characters (* and ?).
-.PP
-Due to the different pattern matching rules on the various platforms,
-to ensure portability, wild card characters are not allowed in the
-extensions, except as in the special extension *. Extensions
-without a full stop character (e.g, ~) are allowed but may not
-work on all platforms.
-
-.SH EXAMPLE
-.CS
-set types {
- {{Text Files} {.txt} }
- {{TCL Scripts} {.tcl} }
- {{C Source Files} {.c} TEXT}
- {{GIF Files} {.gif} }
- {{GIF Files} {} GIFF}
- {{All Files} * }
-}
-set filename [tk_getOpenFile -filetypes $types]
-
-if {$filename != ""} {
- # Open the file ...
-}
-.CE
-
-.SH KEYWORDS
-file selection dialog
diff --git a/doc/grab.n b/doc/grab.n
deleted file mode 100644
index 887ae66..0000000
--- a/doc/grab.n
+++ /dev/null
@@ -1,122 +0,0 @@
-'\"
-'\" 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: grab.n,v 1.2 1998/09/14 18:22:56 stanton Exp $
-'\"
-.so man.macros
-.TH grab n "" Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-grab \- Confine pointer and keyboard events to a window sub-tree
-.SH SYNOPSIS
-\fBgrab \fR?\fB\-global\fR? \fIwindow\fR
-.sp
-\fBgrab \fIoption \fR?\fIarg arg \fR...?
-.BE
-
-.SH DESCRIPTION
-.PP
-This command implements simple pointer and keyboard grabs for Tk.
-Tk's grabs are different than the grabs
-described in the Xlib documentation.
-When a grab is set for a particular window, Tk restricts all pointer
-events to the grab window and its descendants in Tk's window hierarchy.
-Whenever the pointer is within the grab window's subtree, the pointer
-will behave exactly the same as if there had been no grab at all
-and all events will be reported in the normal fashion.
-When the pointer is outside \fIwindow\fR's tree, button presses and
-releases and
-mouse motion events are reported to \fIwindow\fR, and window entry
-and window exit events are ignored.
-The grab subtree ``owns'' the pointer:
-windows outside the grab subtree will be visible on the screen
-but they will be insensitive until the grab is released.
-The tree of windows underneath the grab window can include top-level
-windows, in which case all of those top-level windows
-and their descendants will continue to receive mouse events
-during the grab.
-.PP
-Two forms of grabs are possible: local and global.
-A local grab affects only the grabbing application: events will
-be reported to other applications as if the grab had never occurred.
-Grabs are local by default.
-A global grab locks out all applications on the screen,
-so that only the given subtree of the grabbing application will be
-sensitive to pointer events (mouse button presses, mouse button releases,
-pointer motions, window entries, and window exits).
-During global grabs the window manager will not receive pointer
-events either.
-.PP
-During local grabs, keyboard events (key presses and key releases)
-are delivered as usual: the window
-manager controls which application receives keyboard events, and
-if they are sent to any window in the grabbing application then they are
-redirected to the focus window.
-During a global grab Tk grabs the keyboard so that all keyboard events
-are always sent to the grabbing application.
-The \fBfocus\fR command is still used to determine which window in the
-application receives the keyboard events.
-The keyboard grab is released when the grab is released.
-.PP
-Grabs apply to particular displays. If an application has windows
-on multiple displays then it can establish a separate grab on each
-display.
-The grab on a particular display affects only the windows on
-that display.
-It is possible for different applications on a single display to have
-simultaneous local grabs, but only one application can have a global
-grab on a given display at once.
-.PP
-The \fBgrab\fR command can take any of the following forms:
-.TP
-\fBgrab \fR?\fB\-global\fR? \fIwindow\fR
-Same as \fBgrab set\fR, described below.
-.TP
-\fBgrab current \fR?\fIwindow\fR?
-If \fIwindow\fR is specified, returns the name of the current grab
-window in this application for \fIwindow\fR's display, or an empty
-string if there is no such window.
-If \fIwindow\fR is omitted, the command returns a list whose elements
-are all of the windows grabbed by this application for all displays,
-or an empty string if the application has no grabs.
-.TP
-\fBgrab release \fIwindow\fR
-Releases the grab on \fIwindow\fR if there is one, otherwise does
-nothing. Returns an empty string.
-.TP
-\fBgrab set \fR?\fB\-global\fR? \fIwindow\fR
-Sets a grab on \fIwindow\fR. If \fB\-global\fR is specified then the
-grab is global, otherwise it is local.
-If a grab was already in effect for this application on
-\fIwindow\fR's display then it is automatically released.
-If there is already a grab on \fIwindow\fR and it has the same
-global/local form as the requested grab, then the command
-does nothing. Returns an empty string.
-.TP
-\fBgrab status \fIwindow\fR
-Returns \fBnone\fR if no grab is currently set on \fIwindow\fR,
-\fBlocal\fR if a local grab is set on \fIwindow\fR, and
-\fBglobal\fR if a global grab is set.
-
-.SH BUGS
-.PP
-It took an incredibly complex and gross implementation to produce
-the simple grab effect described above.
-Given the current implementation, it isn't safe for applications
-to use the Xlib grab facilities at all except through the Tk grab
-procedures.
-If applications try to manipulate X's grab mechanisms directly,
-things will probably break.
-.PP
-If a single process is managing several different Tk applications,
-only one of those applications can have a local grab for a given
-display at any given time. If the applications are in different
-processes, this restriction doesn't exist.
-
-.SH KEYWORDS
-grab, keyboard events, pointer events, window
diff --git a/doc/grid.n b/doc/grid.n
deleted file mode 100644
index 1bd9121..0000000
--- a/doc/grid.n
+++ /dev/null
@@ -1,337 +0,0 @@
-'\"
-'\" Copyright (c) 1996 Sun Microsystems, Inc.
-'\"
-'\" See the file "license.terms" for information on usage and redistribution
-'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-'\"
-'\" RCS: @(#) $Id: grid.n,v 1.2 1998/09/14 18:22:56 stanton Exp $
-'\"
-.so man.macros
-.TH grid n 4.1 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-grid \- Geometry manager that arranges widgets in a grid
-.SH SYNOPSIS
-\fBgrid \fIoption arg \fR?\fIarg ...\fR?
-.BE
-
-.SH DESCRIPTION
-.PP
-The \fBgrid\fR command is used to communicate with the grid
-geometry manager that arranges widgets in rows and columns inside
-of another window, called the geometry master (or master window).
-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.
-.TP
-\fBgrid bbox \fImaster\fR ?\fIcolumn row\fR? ?\fIcolumn2 row2\fR?
-With no arguments,
-the bounding box (in pixels) of the grid is returned.
-The return value consists of 4 integers. The first two are the pixel
-offset from the master window (x then y) of the top-left corner of the
-grid, and the second two integers are the width and height of the grid,
-also in pixels. If a single \fIcolumn\fP and \fIrow\fP is specified on
-the command line, then the bounding box for that cell is returned, where the
-top left cell is numbered from zero. If both \fIcolumn\fP and \fIrow\fP
-arguments are specified, then the bounding box spanning the rows and columns
-indicated is returned.
-.TP
-\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
-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)
-sets the relative weight for apportioning
-any extra spaces among
-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.
-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.
-If only an option is specified, with no value,
-the current value of that option is returned.
-If only the master window and index is specified, all the current settings
-are returned in an list of "-option value" pairs.
-.TP
-\fBgrid configure \fIslave \fR?\fIslave ...\fR? ?\fIoptions\fR?
-The arguments consist of the names of one or more slave windows
-followed by pairs of arguments that specify how
-to manage the slaves.
-The characters \fB\-\fP, \fBx\fP and \fB^\fP,
-can be specified instead of a window name to alter the default
-location of a \fIslave\fP, as described in the ``RELATIVE PLACEMENT''
-section, below.
-The following options are supported:
-.RS
-.TP
-\fB\-column \fIn\fR
-Insert the slave so that it occupies the \fIn\fPth column in the grid.
-Column numbers start with 0. If this option is not supplied, then the
-slave is arranged just to the right of previous slave specified on this
-call to \fIgrid\fP, or column "0" if it is the first slave. For each
-\fBx\fP that immediately precedes the \fIslave\fP, the column position
-is incremented by one. Thus the \fBx\fP represents a blank column
-for this row in the grid.
-.TP
-\fB\-columnspan \fIn\fR
-Insert the slave so that it occupies \fIn\fP columns in the grid.
-The default is one column, unless the window name is followed by a
-\fB\-\fP, in which case the columnspan is incremented once for each immediately
-following \fB\-\fP.
-.TP
-\fB\-in \fIother\fR
-Insert the slave(s) in the master
-window given by \fIother\fR. The default is the first slave's
-parent window.
-.TP
-\fB\-ipadx \fIamount\fR
-The \fIamount\fR specifies how much horizontal internal padding to
-leave on each side of the slave(s). This is space is added
-inside the slave(s) border.
-The \fIamount\fR must be a valid screen distance, such as \fB2\fR or \fB.5c\fR.
-It defaults to 0.
-.TP
-\fB\-ipady \fIamount\fR
-The \fIamount\fR specifies how much vertical internal padding to
-leave on on the top and bottom of the slave(s).
-This space is added inside the slave(s) border.
-The \fIamount\fR defaults to 0.
-.TP
-\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.
-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.
-The \fIamount\fR defaults to 0.
-This space is added outside the slave(s) border.
-.TP
-\fB\-row \fIn\fR
-Insert the slave so that it occupies the \fIn\fPth row in the grid.
-Row numbers start with 0. If this option is not supplied, then the
-slave is arranged on the same row as the previous slave specified on this
-call to \fBgrid\fP, or the first unoccupied row if this is the first slave.
-.TP
-\fB\-rowspan \fIn\fR
-Insert the slave so that it occupies \fIn\fP rows in the grid.
-The default is one row. If the next \fBgrid\fP command contains
-\fB^\fP characters instead of \fIslaves\fP that line up with the columns
-of this \fIslave\fP, then the \fBrowspan\fP of this \fIslave\fP is
-extended by one.
-.TP
-\fB\-sticky \fIstyle\fR
-If a slave's cell is larger than its requested dimensions, this
-option may be used to position (or stretch) the slave within its cell.
-\fIStyle\fR is a string that contains zero or more of the characters
-\fBn\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 slave will "stick" to. If both \fBn\fP and \fBs\fP (or
-\fBe\fP and \fBw\fP) are specified, the slave will be stretched to fill the entire
-height (or width) of its cavity. The \fBsticky\fP option subsumes the
-combination of \fB\-anchor\fP and \fB\-fill\fP that is used by \fBpack\fP.
-The default is \fB{}\fP, which causes the slave to be centered in its cavity,
-at its requested size.
-.LP
-If any of the slaves are already managed by the geometry manager
-then any unspecified options for them retain their previous values rather
-than receiving default values.
-.RE
-.TP
-\fBgrid forget \fIslave \fR?\fIslave ...\fR?
-Removes each of the \fIslave\fRs from grid for its
-master and unmaps their windows.
-The slaves will no longer be managed by the grid geometry manager.
-The configuration options for that window are forgotten, so that if the
-slave is managed once more by the grid geometry manager, the initial
-default settings are used.
-.TP
-\fBgrid info \fIslave\fR
-Returns a list whose elements are the current configuration state of
-the slave given by \fIslave\fR in the same option-value form that
-might be specified to \fBgrid configure\fR.
-The first two elements of the list are ``\fB\-in \fImaster\fR'' where
-\fImaster\fR is the slave's master.
-.TP
-\fBgrid location \fImaster x y\fR
-Given \fIx\fP and \fIy\fP values in screen units relative to the master window,
-the column and row number at that \fIx\fP and \fIy\fP location is returned.
-For locations that are above or to the left of the grid, \fB-1\fP is returned.
-.TP
-\fBgrid propagate \fImaster\fR ?\fIboolean\fR?
-If \fIboolean\fR has a true boolean value such as \fB1\fR or \fBon\fR
-then propagation is enabled for \fImaster\fR, which must be a window
-name (see ``GEOMETRY PROPAGATION'' below).
-If \fIboolean\fR has a false boolean value then propagation is
-disabled for \fImaster\fR.
-In either of these cases an empty string is returned.
-If \fIboolean\fR is omitted then the command returns \fB0\fR or
-\fB1\fR to indicate whether propagation is currently enabled
-for \fImaster\fR.
-Propagation is enabled by default.
-.TP
-\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
-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)
-sets the relative weight for apportioning
-any extra spaces among
-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.
-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.
-If only an option is specified, with no value,
-the current value of that option is returned.
-If only the master window and index is specified, all the current settings
-are returned in an list of "-option value" pairs.
-.TP
-\fBgrid remove \fIslave \fR?\fIslave ...\fR?
-Removes each of the \fIslave\fRs from grid for its
-master and unmaps their windows.
-The slaves will no longer be managed by the grid geometry manager.
-However, the configuration options for that window are remembered,
-so that if the
-slave is managed once more by the grid geometry manager, the previous
-values are retained.
-.TP
-\fBgrid size \fImaster\fR
-Returns the size of the grid (in columns then rows) for \fImaster\fP.
-The size is determined either by the \fIslave\fP occupying the largest
-row or column, or the largest column or row with a \fBminsize\fP,
-\fBweight\fP, or \fBpad\fP that is non-zero.
-.TP
-\fBgrid slaves \fImaster\fR ?\fI\-option value\fR?
-If no options are supplied, a list of all of the slaves in \fImaster\fR
-are returned, most recently manages first.
-\fIOption\fP can be either \fB\-row\fP or \fB\-column\fP which
-causes only the slaves in the row (or column) specified by \fIvalue\fP
-to be returned.
-.SH "RELATIVE PLACEMENT"
-.PP
-The \fBgrid\fP command contains a limited set of capabilities that
-permit layouts to be created without specifying the row and column
-information for each slave. This permits slaves to be rearranged,
-added, or removed without the need to explicitly specify row and
-column information.
-When no column or row information is specified for a \fIslave\fP,
-default values are chosen for
-\fBcolumn\fP, \fBrow\fP, \fBcolumnspan\fP and \fBrowspan\fP
-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
-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.
-.TP
-\fBx\fP
-This leaves an empty column between the \fIslave\fP on the left and
-the \fIslave\fP on the right.
-.TP
-\fB^\fP
-This extends the \fBrowspan\fP of the \fIslave\fP above the \fB^\fP's
-in the grid. The number of \fB^\fP's in a row must match the number of
-columns spanned by the \fIslave\fP above it.
-.RE
-.SH "THE GRID ALGORITHM"
-.PP
-The grid geometry manager lays out its slaves in three steps.
-In the first step, the minimum size needed to fit all of the slaves
-is computed, then (if propagation is turned on), a request is made
-of the master window to become that size.
-In the second step, the requested size is compared against the actual size
-of the master. If the sizes are different, then spaces is added to or taken
-away from the layout as needed.
-For the final step, each slave is positioned in its row(s) and column(s)
-based on the setting of its \fIsticky\fP flag.
-.PP
-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
-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
-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.
-For masters whose size is smaller than the requested layout, space is taken
-away from columns and rows according to their weights. However, once a
-column or row shrinks to its minsize, its weight is taken to be zero.
-If more space needs to be removed from a layout than would be permitted, as
-when all the rows or columns are at there minimum sizes, the layout is
-clipped on the bottom and right.
-.SH "GEOMETRY PROPAGATION"
-.PP
-The grid geometry manager normally computes how large a master must be to
-just exactly meet the needs of its slaves, and it sets the
-requested width and height of the master to these dimensions.
-This causes geometry information to propagate up through a
-window hierarchy to a top-level window so that the entire
-sub-tree sizes itself to fit the needs of the leaf windows.
-However, the \fBgrid propagate\fR command may be used to
-turn off propagation for one or more masters.
-If propagation is disabled then grid will not set
-the requested width and height of the master window.
-This may be useful if, for example, you wish for a master
-window to have a fixed size that you specify.
-
-.SH "RESTRICTIONS ON MASTER WINDOWS"
-.PP
-The master for each slave must either be the slave's parent
-(the default) or a descendant of the slave's parent.
-This restriction is necessary to guarantee that the
-slave can be placed over any part of its master that is
-visible without danger of the slave being clipped by its parent.
-In addition, all slaves in one call to \fBgrid\fP must have the same master.
-.SH "STACKING ORDER"
-.PP
-If the master for a slave is not its parent then you must make sure
-that the slave is higher in the stacking order than the master.
-Otherwise the master will obscure the slave and it will appear as
-if the slave hasn't been managed correctly.
-The easiest way to make sure the slave is higher than the master is
-to create the master window first: the most recently created window
-will be highest in the stacking order.
-.SH CREDITS
-.PP
-The \fBgrid\fP command is based on ideas taken from the \fIGridBag\fP
-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/doc/image.n b/doc/image.n
deleted file mode 100644
index 4c55018..0000000
--- a/doc/image.n
+++ /dev/null
@@ -1,90 +0,0 @@
-'\"
-'\" Copyright (c) 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: image.n,v 1.2 1998/09/14 18:22:57 stanton Exp $
-'\"
-.so man.macros
-.TH image n 4.0 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-image \- Create and manipulate images
-.SH SYNOPSIS
-\fBimage\fR \fIoption \fR?\fIarg arg ...\fR?
-.BE
-
-.SH DESCRIPTION
-.PP
-The \fBimage\fR command is used to create, delete, and query images.
-It can take several different forms, depending on the
-\fIoption\fR argument. The legal forms are:
-.TP
-\fBimage create \fItype \fR?\fIname\fR? ?\fIoption value ...\fR?
-Creates a new image and returns its name.
-\fItype\fR specifies the type of the image, which must be one of
-the types currently defined (e.g., \fBbitmap\fR).
-\fIname\fR specifies the name for the image; if it is omitted then
-Tk picks a name of the form \fBimage\fIx\fR, where \fIx\fR is
-an integer.
-There may be any number of \fIoption\fR\-\fIvalue\fR pairs,
-which provide configuration options for the new image.
-The legal set of options is defined separately for each image
-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.
-.TP
-\fBimage delete \fR?\fIname name\fR ...?
-Deletes each of the named images and returns an empty string.
-If there are instances of the images displayed in widgets,
-the images won't actually be deleted until all of the instances
-are released.
-However, the association between the instances and the image
-manager will be dropped.
-Existing instances will retain their sizes but redisplay as
-empty areas.
-If a deleted image is recreated with another call to \fBimage create\fR,
-the existing instances will use the new image.
-.TP
-\fBimage height \fIname\fR
-Returns a decimal string giving the height of image \fIname\fR
-in pixels.
-.TP
-\fBimage names\fR
-Returns a list containing the names of all existing images.
-.TP
-\fBimage type \fIname\fR
-Returns the type of image \fIname\fR (the value of the \fItype\fR
-argument to \fBimage create\fR when the image was created).
-.TP
-\fBimage types\fR
-Returns a list whose elements are all of the valid image types
-(i.e., all of the values that may be supplied for the \fItype\fR
-argument to \fBimage create\fR).
-.TP
-\fBimage width \fIname\fR
-Returns a decimal string giving the width of image \fIname\fR
-in pixels.
-
-.SH "BUILT-IN IMAGE TYPES"
-.PP
-The following image types are defined by Tk so they will be available
-in any Tk application.
-Individual applications or extensions may define additional types.
-.TP
-\fBbitmap\fR
-Each pixel in the image displays a foreground color, a background
-color, or nothing.
-See the \fBbitmap\fR manual entry for more information.
-.TP
-\fBphoto\fR
-Displays a variety of full-color images, using dithering to
-approximate colors on displays with limited color capabilities.
-See the \fBphoto\fR manual entry for more information.
-
-.SH KEYWORDS
-height, image, types of images, width
diff --git a/doc/label.n b/doc/label.n
deleted file mode 100644
index 370f4f4..0000000
--- a/doc/label.n
+++ /dev/null
@@ -1,103 +0,0 @@
-'\"
-'\" 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: label.n,v 1.2 1998/09/14 18:22:57 stanton Exp $
-'\"
-.so man.macros
-.TH label n 4.0 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-label \- Create and manipulate label widgets
-.SH SYNOPSIS
-\fBlabel\fR \fIpathName \fR?\fIoptions\fR?
-.SO
-\-anchor \-font \-image \-takefocus
-\-background \-foreground \-justify \-text
-\-bitmap \-highlightbackground \-padx \-textvariable
-\-borderwidth \-highlightcolor \-pady \-underline
-\-cursor \-highlightthickness \-relief \-wraplength
-.SE
-.SH "WIDGET-SPECIFIC OPTIONS"
-.OP \-height height Height
-Specifies a desired height for the label.
-If an image or bitmap is being displayed in the label then the value is in
-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 label's desired height is computed
-from the size of the image or bitmap or text being displayed in it.
-.OP \-width width Width
-Specifies a desired width for the label.
-If an image or bitmap is being displayed in the label then the value is in
-screen units (i.e. any of the forms acceptable to \fBTk_GetPixels\fR);
-for text it is in characters.
-If this option isn't specified, the label's desired width is computed
-from the size of the image or bitmap or text being displayed in it.
-.BE
-
-.SH DESCRIPTION
-.PP
-The \fBlabel\fR command creates a new window (given by the
-\fIpathName\fR argument) and makes it into a label widget.
-Additional
-options, described above, may be specified on the command line
-or in the option database
-to configure aspects of the label such as its colors, font,
-text, and initial relief. The \fBlabel\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 label is a widget that displays a textual string, bitmap or image.
-If text is displayed, it must all be in a single font, but it
-can occupy multiple lines on the screen (if it contains newlines
-or if wrapping occurs because of the \fBwrapLength\fR option) and
-one of the characters may optionally be underlined using the
-\fBunderline\fR option.
-The label can be manipulated in a few simple ways, such as
-changing its relief or text, using the commands described below.
-
-.SH "WIDGET COMMAND"
-.PP
-The \fBlabel\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. The following
-commands are possible for label 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 \fBlabel\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 \fBlabel\fR
-command.
-
-.SH BINDINGS
-.PP
-When a new label is created, it has no default event bindings:
-labels are not intended to be interactive.
-
-.SH KEYWORDS
-label, widget
diff --git a/doc/listbox.n b/doc/listbox.n
deleted file mode 100644
index a22e86b..0000000
--- a/doc/listbox.n
+++ /dev/null
@@ -1,491 +0,0 @@
-'\"
-'\" Copyright (c) 1990 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: listbox.n,v 1.2 1998/09/14 18:22:57 stanton Exp $
-'\"
-.so man.macros
-.TH listbox n 8.0 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-listbox \- Create and manipulate listbox widgets
-.SH SYNOPSIS
-\fBlistbox\fR \fIpathName \fR?\fIoptions\fR?
-.SO
-\-background \-foreground \-relief \-takefocus
-\-borderwidth \-height \-selectbackground \-width
-\-cursor \-highlightbackground \-selectborderwidth \-xscrollcommand
-\-exportselection \-highlightcolor \-selectforeground \-yscrollcommand
-\-font \-highlightthickness \-setgrid
-.SE
-.SH "WIDGET-SPECIFIC OPTIONS"
-.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 \-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 \-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
-character ``0'' is used in translating from character units to
-screen units.
-If zero or less, then the desired width for the window is made just
-large enough to hold all the elements in the listbox.
-.BE
-
-.SH DESCRIPTION
-.PP
-The \fBlistbox\fR command creates a new window (given by the
-\fIpathName\fR argument) and makes it into a listbox widget.
-Additional
-options, described above, may be specified on the command line
-or in the option database
-to configure aspects of the listbox such as its colors, font,
-text, and relief. The \fBlistbox\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 listbox is a widget that displays a list of strings, one per line.
-When first created, a new listbox has no elements.
-Elements may be added or deleted using widget commands described
-below. In addition, one or more elements may be selected as described
-below.
-If a listbox is exporting its selection (see \fBexportSelection\fR
-option), then it will observe the standard X11 protocols
-for handling the selection.
-Listbox selections are available as type \fBSTRING\fR;
-the value of the selection will be the text of the selected elements, with
-newlines separating the elements.
-.PP
-It is not necessary for all the elements to be
-displayed in the listbox window at once; commands described below
-may be used to change the view in the window. Listboxes allow
-scrolling in both directions using the standard \fBxScrollCommand\fR
-and \fByScrollCommand\fR options.
-They also support scanning, as described below.
-
-.SH "INDICES"
-.PP
-Many of the widget commands for listboxes take one or more indices
-as arguments.
-An index specifies a particular element of the listbox, in any of
-the following ways:
-.TP 12
-\fInumber\fR
-Specifies the element as a numerical index, where 0 corresponds
-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
-widget command.
-.TP 12
-\fBanchor\fR
-Indicates the anchor point for the selection, which is set with the
-\fBselection anchor\fR widget command.
-.TP 12
-\fBend\fR
-Indicates the end of the listbox.
-.VS 8.0
-For most commands this refers to the last element in the listbox,
-but for a few commands such as \fBindex\fR and \fBinsert\fR
-it refers to the element just after the last one.
-.VE
-.TP 12
-\fB@\fIx\fB,\fIy\fR
-Indicates the element that covers the point in the listbox window
-specified by \fIx\fR and \fIy\fR (in pixel coordinates). If no
-element covers that point, then the closest element to that
-point is used.
-.LP
-In the widget command descriptions below, arguments named \fIindex\fR,
-\fIfirst\fR, and \fIlast\fR always contain text indices in one of
-the above forms.
-
-.SH "WIDGET COMMAND"
-.PP
-The \fBlistbox\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. The following
-commands are possible for listbox widgets:
-.TP
-\fIpathName \fBactivate\fR \fIindex\fR
-Sets the active element to the one indicated by \fIindex\fR.
-.VS 8.0
-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
-index \fBactive\fR.
-.TP
-\fIpathName \fBbbox\fR \fIindex\fR
-Returns a list of four numbers describing the bounding box of
-the text in the element 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 text
-(specified in pixels relative to the widget) and the last two
-elements give the width and height of the area, in pixels.
-If no part of the element given by \fIindex\fR is visible on the
-screen,
-.VS 8.0
-or if \fIindex\fR refers to a non-existent element,
-.VE
-then the result is an empty string; if the element is
-partially visible, the result gives the full area of the element,
-including any parts that are not visible.
-.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 \fBlistbox\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 \fBlistbox\fR
-command.
-.TP
-\fIpathName \fBcurselection\fR
-Returns a list containing the numerical indices of
-all of the elements in the listbox that are currently selected.
-If there are no elements selected in the listbox then an empty
-string is returned.
-.TP
-\fIpathName \fBdelete \fIfirst \fR?\fIlast\fR?
-Deletes one or more elements of the listbox. \fIFirst\fR and \fIlast\fR
-are indices specifying the first and last elements in the range
-to delete. If \fIlast\fR isn't specified it defaults to
-\fIfirst\fR, i.e. a single element is deleted.
-.TP
-\fIpathName \fBget \fIfirst\fR ?\fIlast\fR?
-If \fIlast\fR is omitted, returns the contents of the listbox
-element indicated by \fIfirst\fR,
-.VS 8.0
-or an empty string if \fIfirst\fR refers to a non-existent element.
-.VE
-If \fIlast\fR is specified, the command returns a list whose elements
-are all of the listbox elements between \fIfirst\fR and \fIlast\fR,
-inclusive.
-Both \fIfirst\fR and \fIlast\fR may have any of the standard
-forms for indices.
-.TP
-\fIpathName \fBindex \fIindex\fR
-Returns the integer index value that corresponds to \fIindex\fR.
-.VS 8.0
-If \fIindex\fR is \fBend\fR the return value is a count of the number
-of elements in the listbox (not the index of the last element).
-.VE
-.TP
-\fIpathName \fBinsert \fIindex \fR?\fIelement element ...\fR?
-Inserts zero or more new elements in the list just before the
-element given by \fIindex\fR. If \fIindex\fR is specified as
-\fBend\fR then the new elements are added to the end of the
-list. Returns an empty string.
-.TP
-\fIpathName \fBnearest \fIy\fR
-Given a y-coordinate within the listbox window, this command returns
-the index of the (visible) listbox element nearest to that y-coordinate.
-.TP
-\fIpathName \fBscan\fR \fIoption args\fR
-This command is used to implement scanning on listboxes. It has
-two forms, depending on \fIoption\fR:
-.RS
-.TP
-\fIpathName \fBscan mark \fIx y\fR
-Records \fIx\fR and \fIy\fR and the current view in the listbox
-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 y\fR.
-This command computes the difference between its \fIx\fR and \fIy\fR
-arguments and the \fIx\fR and \fIy\fR arguments to the last
-\fBscan mark\fR command for the widget.
-It then adjusts the view by 10 times the
-difference in coordinates. This command is typically associated
-with mouse motion events in the widget, to produce the effect of
-dragging the list at high speed through the window. The return
-value is an empty string.
-.RE
-.TP
-\fIpathName \fBsee \fIindex\fR
-Adjust the view in the listbox so that the element given by \fIindex\fR
-is visible.
-If the element is already visible then the command has no effect;
-if the element is near one edge of the window then the listbox
-scrolls to bring the element into view at the edge; otherwise
-the listbox scrolls to center the element.
-.TP
-\fIpathName \fBselection \fIoption arg\fR
-This command is used to adjust the selection within a listbox. It
-has several forms, depending on \fIoption\fR:
-.RS
-.TP
-\fIpathName \fBselection anchor \fIindex\fR
-Sets the selection anchor to the element given by \fIindex\fR.
-.VS 8.0
-If \fIindex\fR refers to a non-existent element, then the closest
-element is used.
-.VE
-The selection anchor is the end of the selection that is fixed
-while dragging out a selection with the mouse.
-The index \fBanchor\fR may be used to refer to the anchor
-element.
-.TP
-\fIpathName \fBselection clear \fIfirst \fR?\fIlast\fR?
-If any of the elements between \fIfirst\fR and \fIlast\fR
-(inclusive) are selected, they are deselected.
-The selection state is not changed for elements outside
-this range.
-.TP
-\fIpathName \fBselection includes \fIindex\fR
-Returns 1 if the element indicated by \fIindex\fR is currently
-selected, 0 if it isn't.
-.TP
-\fIpathName \fBselection set \fIfirst \fR?\fIlast\fR?
-Selects all of the elements in the range between
-\fIfirst\fR and \fIlast\fR, inclusive, without affecting
-the selection state of elements outside that range.
-.RE
-.TP
-\fIpathName \fBsize\fR
-Returns a decimal string indicating the total number of elements
-in the listbox.
-.TP
-\fIpathName \fBxview \fIargs\fR
-This command is used to query and change the horizontal position of the
-information 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 listbox'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 position given by
-\fIindex\fR is displayed at the left edge of the window.
-Character positions are defined by the width of the character \fB0\fR.
-.TP
-\fIpathName \fBxview moveto\fI fraction\fR
-Adjusts the view in the window so that \fIfraction\fR of the
-total width of the listbox text is off-screen to the left.
-\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 character units (the width of the \fB0\fR character)
-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
-.TP
-\fIpathName \fByview \fI?args\fR?
-This command is used to query and change the vertical position of the
-text in the widget's window.
-It can take any of the following forms:
-.RS
-.TP
-\fIpathName \fByview\fR
-Returns a list containing two elements, both of which are real fractions
-between 0 and 1.
-The first element gives the position of the listbox element at the
-top of the window, relative to the listbox as a whole (0.5 means
-it is halfway through the listbox, for example).
-The second element gives the position of the listbox element just after
-the last one in the window, relative to the listbox as a whole.
-These are the same values passed to scrollbars via the \fB\-yscrollcommand\fR
-option.
-.TP
-\fIpathName \fByview\fR \fIindex\fR
-Adjusts the view in the window so that the element given by
-\fIindex\fR is displayed at the top of the window.
-.TP
-\fIpathName \fByview moveto\fI fraction\fR
-Adjusts the view in the window so that the element given by \fIfraction\fR
-appears at the top of the window.
-\fIFraction\fR is a fraction between 0 and 1; 0 indicates the first
-element in the listbox, 0.33 indicates the element one-third the
-way through the listbox, and so on.
-.TP
-\fIpathName \fByview scroll \fInumber what\fR
-This command adjusts the view in the window up or down according to
-\fInumber\fR and \fIwhat\fR.
-\fINumber\fR must be an integer.
-\fIWhat\fR must be either \fBunits\fR or \fBpages\fR.
-If \fIwhat\fR is \fBunits\fR, the view adjusts up or down by
-\fInumber\fR lines; if it is \fBpages\fR then
-the view adjusts by \fInumber\fR screenfuls.
-If \fInumber\fR is negative then earlier elements
-become visible; if it is positive then later elements
-become visible.
-.RE
-
-.SH "DEFAULT BINDINGS"
-.PP
-Tk automatically creates class bindings for listboxes that give them
-Motif-like behavior. Much of the behavior of a listbox is determined
-by its \fBselectMode\fR option, which selects one of four ways
-of dealing with the selection.
-.PP
-If the selection mode is \fBsingle\fR or \fBbrowse\fR, at most one
-element can be selected in the listbox at once.
-In both modes, clicking button 1 on an element selects
-it and deselects any other selected item.
-In \fBbrowse\fR mode it is also possible to drag the selection
-with button 1.
-.PP
-If the selection mode is \fBmultiple\fR or \fBextended\fR,
-any number of elements may be selected at once, including discontiguous
-ranges. In \fBmultiple\fR mode, clicking button 1 on an element
-toggles its selection state without affecting any other elements.
-In \fBextended\fR mode, pressing button 1 on an element selects
-it, deselects everything else, and sets the anchor to the element
-under the mouse; dragging the mouse with button 1
-down extends the selection to include all the elements between
-the anchor and the element under the mouse, inclusive.
-.PP
-Most people will probably want to use \fBbrowse\fR mode for
-single selections and \fBextended\fR mode for multiple selections;
-the other modes appear to be useful only in special situations.
-.PP
-In addition to the above behavior, the following additional behavior
-is defined by the default bindings:
-.IP [1]
-In \fBextended\fR mode, the selected range can be adjusted by pressing
-button 1 with the Shift key down: this modifies the selection to
-consist of the elements between the anchor and the element under
-the mouse, inclusive.
-The un-anchored end of this new selection can also be dragged with
-the button down.
-.IP [2]
-In \fBextended\fR mode, pressing button 1 with the Control key down
-starts a toggle operation: the anchor is set to the element under
-the mouse, and its selection state is reversed. The selection state
-of other elements isn't changed.
-If the mouse is dragged with button 1 down, then the selection state
-of all elements between the anchor and the element under the mouse
-is set to match that of the anchor element; the selection state of
-all other elements remains what it was before the toggle operation
-began.
-.IP [3]
-If the mouse leaves the listbox window with button 1 down, the window
-scrolls away from the mouse, making information visible that used
-to be off-screen on the side of the mouse.
-The scrolling continues until the mouse re-enters the window, the
-button is released, or the end of the listbox is reached.
-.IP [4]
-Mouse button 2 may be used for scanning.
-If it is pressed and dragged over the listbox, the contents of
-the listbox drag at high speed in the direction the mouse moves.
-.IP [5]
-If the Up or Down key is pressed, the location cursor (active
-element) moves up or down one element.
-If the selection mode is \fBbrowse\fR or \fBextended\fR then the
-new active element is also selected and all other elements are
-deselected.
-In \fBextended\fR mode the new active element becomes the
-selection anchor.
-.IP [6]
-In \fBextended\fR mode, Shift-Up and Shift-Down move the location
-cursor (active element) up or down one element and also extend
-the selection to that element in a fashion similar to dragging
-with mouse button 1.
-.IP [7]
-The Left and Right keys scroll the listbox view left and right
-by the width of the character \fB0\fR.
-Control-Left and Control-Right scroll the listbox view left and
-right by the width of the window.
-Control-Prior and Control-Next also scroll left and right by
-the width of the window.
-.IP [8]
-The Prior and Next keys scroll the listbox view up and down
-by one page (the height of the window).
-.IP [9]
-The Home and End keys scroll the listbox horizontally to
-the left and right edges, respectively.
-.IP [10]
-Control-Home sets the location cursor to the the first element in
-the listbox, selects that element, and deselects everything else
-in the listbox.
-.IP [11]
-Control-End sets the location cursor to the the last element in
-the listbox, selects that element, and deselects everything else
-in the listbox.
-.IP [12]
-In \fBextended\fR mode, Control-Shift-Home extends the selection
-to the first element in the listbox and Control-Shift-End extends
-the selection to the last element.
-.IP [13]
-In \fBmultiple\fR mode, Control-Shift-Home moves the location cursor
-to the first element in the listbox and Control-Shift-End moves
-the location cursor to the last element.
-.IP [14]
-The space and Select keys make a selection at the location cursor
-(active element) just as if mouse button 1 had been pressed over
-this element.
-.IP [15]
-In \fBextended\fR mode, Control-Shift-space and Shift-Select
-extend the selection to the active element just as if button 1
-had been pressed with the Shift key down.
-.IP [16]
-In \fBextended\fR mode, the Escape key cancels the most recent
-selection and restores all the elements in the selected range
-to their previous selection state.
-.IP [17]
-Control-slash selects everything in the widget, except in
-\fBsingle\fR and \fBbrowse\fR modes, in which case it selects
-the active element and deselects everything else.
-.IP [18]
-Control-backslash deselects everything in the widget, except in
-\fBbrowse\fR mode where it has no effect.
-.IP [19]
-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.
-
-.PP
-The behavior of listboxes can be changed by defining new bindings for
-individual widgets or by redefining the class bindings.
-
-.SH KEYWORDS
-listbox, widget
diff --git a/doc/loadTk.n b/doc/loadTk.n
deleted file mode 100644
index 8e1836c..0000000
--- a/doc/loadTk.n
+++ /dev/null
@@ -1,76 +0,0 @@
-'\"
-'\" Copyright (c) 1995-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: loadTk.n,v 1.3 1998/09/14 18:22:57 stanton Exp $
-'\"
-.so man.macros
-.TH "Safe Tk" n 8.0 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-loadTk \- Load Tk into a safe interpreter.
-.SH SYNOPSIS
-\fB::safe::loadTk \fIslave\fR ?\fB\-use\fR \fIwindowId\fR? ?\fB\-display\fR \fIdisplayName\fR?
-.BE
-
-Safe Tk is based on Safe Tcl, which provides a mechanism
-that allows restricted and mediated
-access to auto-loading and packages for safe interpreters.
-Safe Tk adds the ability to configure the interpreter
-for safe Tk operations and load Tk into safe
-interpreters.
-
-.SH DESCRIPTION
-.PP
-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
-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
-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
-.PP
-Please read the \fBsafe\fR manual page for Tcl to learn about the basic
-security considerations for Safe Tcl.
-.PP
-\fB::safe::loadTk\fR adds the value of \fBtk_library\fR taken from the master
-interpreter to the virtual access path of the safe interpreter so that
-auto-loading will work in the safe interpreter.
-.PP
-.PP
-Tk initialization is now safe with respect to not trusting
-the slave's state for startup. \fB::safe::loadTk\fR
-registers the slave's name so
-when the Tk initialization (\fBTk_SafeInit\fR) is called
-and in turn calls the master's \fB::safe::InitTk\fR it will
-return the desired \fBargv\fR equivalent (\fB\-use\fR
-\fIwindowId\fR, correct \fB\-display\fR, etc...).
-.PP
-When \fB\-use\fR is not used, the new toplevel created is specially
-decorated so the user is always aware that the user interface presented comes
-from a potentially unsafe code and can easily delete the corresponding
-interpreter.
-.PP
-On X11, conflicting \fB\-use\fR and \fB\-display\fR are likely
-to generate a fatal X error.
-
-.SH "SEE ALSO"
-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/doc/lower.n b/doc/lower.n
deleted file mode 100644
index ca08b92..0000000
--- a/doc/lower.n
+++ /dev/null
@@ -1,38 +0,0 @@
-'\"
-'\" Copyright (c) 1990 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: lower.n,v 1.2 1998/09/14 18:22:57 stanton Exp $
-'\"
-.so man.macros
-.TH lower n 3.3 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-lower \- Change a window's position in the stacking order
-.SH SYNOPSIS
-\fBlower \fIwindow \fR?\fIbelowThis\fR?
-.BE
-
-.SH DESCRIPTION
-.PP
-If the \fIbelowThis\fR argument is omitted then the command lowers
-\fIwindow\fR so that it is below all of its siblings in the stacking
-order (it will be obscured by any siblings that overlap it and
-will not obscure any siblings).
-If \fIbelowThis\fR is specified then it must be the path name of
-a window that is either a sibling of \fIwindow\fR or the descendant
-of a sibling of \fIwindow\fR.
-In this case the \fBlower\fR command will insert
-\fIwindow\fR into the stacking order just below \fIbelowThis\fR
-(or the ancestor of \fIbelowThis\fR that is a sibling of \fIwindow\fR);
-this could end up either raising or lowering \fIwindow\fR.
-
-.SH "SEE ALSO"
-raise
-
-.SH KEYWORDS
-lower, obscure, stacking order
diff --git a/doc/menu.n b/doc/menu.n
deleted file mode 100644
index cd3ad0a..0000000
--- a/doc/menu.n
+++ /dev/null
@@ -1,757 +0,0 @@
-'\"
-'\" Copyright (c) 1990-1994 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: menu.n,v 1.2 1998/09/14 18:22:57 stanton Exp $
-'\"
-.so man.macros
-.TH menu n 4.1 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-menu \- Create and manipulate menu widgets
-.SH SYNOPSIS
-\fBmenu\fR \fIpathName \fR?\fIoptions\fR?
-.SO
-\-activebackground \-background \-disabledforeground \-relief
-\-activeborderwidth \-borderwidth \-font \-takefocus
-\-activeforeground \-cursor \-foreground
-.SE
-.SH "WIDGET-SPECIFIC OPTIONS"
-.VS
-.OP \-postcommand postCommand Command
-If this option is specified then it provides a Tcl command to execute
-each time the menu is posted. The command is invoked by the \fBpost\fR
-widget command before posting the menu. Note that in 8.0 on Macintosh
-and Windows, all commands in a menu systems are executed before any
-are posted. This is due to the limitations in the individual platforms'
-menu managers.
-.VE
-.OP \-selectcolor selectColor Background
-For menu entries that are check buttons or radio buttons, this option
-specifies the color to display in the indicator when the check button
-or radio button is selected.
-.OP \-tearoff tearOff TearOff
-This option must have a proper boolean value, which specifies
-whether or not the menu should include a tear-off entry at the
-top. If so, it will exist as entry 0 of the menu and the other
-entries will number starting at 1. The default
-menu bindings arrange for the menu to be torn off when the tear-off
-entry is invoked.
-.OP \-tearoffcommand tearOffCommand TearOffCommand
-If this option has a non-empty value, then it specifies a Tcl command
-to invoke whenever the menu is torn off. The actual command will
-consist of the value of this option, followed by a space, followed
-by the name of the menu window, followed by a space, followed by
-the name of the name of the torn off menu window. For example, if
-the option's is ``\fBa b\fR'' and menu \fB.x.y\fR is torn off to
-create a new menu \fB.x.tearoff1\fR, then the command
-``\fBa b .x.y .x.tearoff1\fR'' will be invoked.
-.VS
-.OP \-title title Title
-The string will be used to title the window created when this menu is
-torn off. If the title is NULL, then the window will have the title
-of the menubutton or the text of the cascade item from which this menu
-was invoked.
-.OP \-type type Type
-This option can be one of \fBmenubar\fR, \fBtearoff\fR, or
-\fBnormal\fR, and is set when the menu is created. While the string
-returned by the configuration database will change if this option is
-changed, this does not affect the menu widget's behavior. This is used
-by the cloning mechanism and is not normally set outside of the Tk
-library.
-.VE
-.BE
-
-.SH INTRODUCTION
-.PP
-The \fBmenu\fR command creates a new top-level window (given
-by the \fIpathName\fR argument) and makes it into a menu widget.
-Additional
-options, described above, may be specified on the command line
-or in the option database
-to configure aspects of the menu such as its colors and font.
-The \fBmenu\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
-.VS
-A menu is a widget that displays a collection of one-line entries arranged
-in one or more columns. There exist several different types of entries,
-each with different properties. Entries of different types may be
-combined in a single menu. Menu entries are not the same as
-entry widgets. In fact, menu entries are not even distinct widgets;
-the entire menu is one widget.
-.VE
-.PP
-Menu entries are displayed with up to three separate fields.
-The main field is a label in the form of a text string,
-a bitmap, or an image, controlled by the \fB\-label\fR,
-\fB\-bitmap\fR, and \fB\-image\fR options for the entry.
-If the \fB\-accelerator\fR option is specified for an entry then a second
-textual field is displayed to the right of the label. The accelerator
-typically describes a keystroke sequence that may be typed in the
-application to cause the same result as invoking the menu entry.
-The third field is an \fIindicator\fR. The indicator is present only for
-checkbutton or radiobutton entries. It indicates whether the entry
-is selected or not, and is displayed to the left of the entry's
-string.
-.PP
-In normal use, an entry becomes active (displays itself differently)
-whenever the mouse pointer is over the entry. If a mouse
-button is released over the entry then the entry is \fIinvoked\fR.
-The effect of invocation is different for each type of entry;
-these effects are described below in the sections on individual
-entries.
-.PP
-Entries may be \fIdisabled\fR, which causes their labels
-and accelerators to be displayed
-with dimmer colors.
-The default menu bindings will not allow
-a disabled entry to be activated or invoked.
-Disabled entries may be re-enabled, at which point it becomes
-possible to activate and invoke them again.
-.VS
-.PP
-Whenever a menu's active entry is changed, a <<MenuSelect>> virtual
-event is send to the menu. The active item can then be queried from
-the menu, and an action can be taken, such as setting
-context-sensitive help text for the entry.
-.VE
-
-.SH "COMMAND ENTRIES"
-.PP
-The most common kind of menu entry is a command entry, which
-behaves much like a button widget. When a command entry is
-invoked, a Tcl command is executed. The Tcl
-command is specified with the \fB\-command\fR option.
-
-.SH "SEPARATOR ENTRIES"
-.PP
-A separator is an entry that is displayed as a horizontal dividing
-line. A separator may not be activated or invoked, and it has
-no behavior other than its display appearance.
-
-.SH "CHECKBUTTON ENTRIES"
-.PP
-A checkbutton menu entry behaves much like a checkbutton widget.
-When it is invoked it toggles back and forth between the selected
-and deselected states. When the entry is selected, a particular
-value is stored in a particular global variable (as determined by
-the \fB\-onvalue\fR and \fB\-variable\fR options for the entry); when
-the entry is deselected another value (determined by the
-\fB\-offvalue\fR option) is stored in the global variable.
-An indicator box is displayed to the left of the label in a checkbutton
-entry. If the entry is selected then the indicator's center is displayed
-in the color given by the \fB-selectcolor\fR option for the entry;
-otherwise the indicator's center is displayed in the background color for
-the menu. If a \fB\-command\fR option is specified for a checkbutton
-entry, then its value is evaluated as a Tcl command each time the entry
-is invoked; this happens after toggling the entry's
-selected state.
-
-.SH "RADIOBUTTON ENTRIES"
-.PP
-A radiobutton menu entry behaves much like a radiobutton widget.
-Radiobutton entries are organized in groups of which only one
-entry may be selected at a time. Whenever a particular entry
-becomes selected it stores a particular value into a particular
-global variable (as determined by the \fB\-value\fR and
-\fB\-variable\fR options for the entry). This action
-causes any previously-selected entry in the same group
-to deselect itself.
-Once an entry has become selected, any change to the entry's
-associated variable will cause the entry to deselect itself.
-Grouping of radiobutton entries is determined by their
-associated variables: if two entries have the same associated
-variable then they are in the same group.
-An indicator diamond is displayed to the left of the label in each
-radiobutton entry. If the entry is selected then the indicator's
-center is displayed in the color given by the \fB\-selectcolor\fR option
-for the entry;
-otherwise the indicator's center is displayed in the background color for
-the menu. If a \fB\-command\fR option is specified for a radiobutton
-entry, then its value is evaluated as a Tcl command each time the entry
-is invoked; this happens after selecting the entry.
-
-.SH "CASCADE ENTRIES"
-.PP
-A cascade entry is one with an associated menu (determined
-by the \fB\-menu\fR option). Cascade entries allow the construction
-of cascading menus.
-The \fBpostcascade\fR widget command can be used to post and unpost
-the associated menu just next to of the cascade entry.
-The associated menu must be a child of the menu containing
-the cascade entry (this is needed in order for menu traversal to
-work correctly).
-.PP
-A cascade entry posts its associated menu by invoking a
-Tcl command of the form
-.CS
-\fImenu\fB post \fIx y\fR
-.CE
-where \fImenu\fR is the path name of the associated menu, and \fIx\fR
-and \fIy\fR are the root-window coordinates of the upper-right
-corner of the cascade entry.
-.VS
-On Unix, the lower-level menu is unposted by executing a Tcl command with
-the form
-.CS
-\fImenu\fB unpost\fR
-.CE
-where \fImenu\fR is the name of the associated menu.
-On other platforms, the platform's native code takes care of unposting the
-menu.
-.VE
-.PP
-.VS
-If a \fB\-command\fR option is specified for a cascade entry then it is
-evaluated as a Tcl command whenever the entry is invoked. This is not
-supported on Windows.
-.VE
-
-.SH "TEAR-OFF ENTRIES"
-.PP
-A tear-off entry appears at the top of the menu if enabled with the
-\fBtearOff\fR option. It is not like other menu entries in that
-it cannot be created with the \fBadd\fR widget command and
-cannot be deleted with the \fBdelete\fR widget command.
-When a tear-off entry is created it appears as a dashed line at
-the top of the menu. Under the default bindings, invoking the
-tear-off entry causes a torn-off copy to be made of the menu and
-all of its submenus.
-
-.VS
-.SH "MENUBARS"
-.PP
-Any menu can be set as a menubar for a toplevel window (see
-\fBtoplevel\fR command for syntax). On the Macintosh, whenever the
-toplevel is in front, this menu's cascade items will appear in the
-menubar across the top of the main monitor. On Windows and Unix, this
-menu's items will be displayed in a menubar accross the top of the
-window. These menus will behave according to the interface guidelines
-of their platforms. For every menu set as a menubar, a clone menu is
-made. See the \fBCLONES\fR section for more information.
-.VE
-
-.VS
-.SH "SPECIAL MENUS IN MENUBARS"
-.PP
-Certain menus in a menubar will be treated specially. On the Macintosh,
-access to the special Apple and Help menus is provided. On Windows,
-access to the Windows System menu in each window is provided. On X Windows,
-a special right-justified help menu is provided. In all cases, these
-menus must be created with the command name of the menubar menu concatenated
-with the special name. So for a menubar named .menubar, on the Macintosh,
-the special menus would be .menubar.apple and .menubar.help; on Windows,
-the special menu would be .menubar.system; on X Windows, the help
-menu would be .menubar.help.
-.PP
-When Tk sees an Apple menu on the Macintosh, that menu's contents make
-up the first items of the Apple menu on the screen whenever the window
-containing the menubar is in front. The menu is the
-first one that the user sees and has a title which is an Apple logo.
-After all of the Tk-defined items, the menu will have a separator,
-followed by all of the items in the user's Apple Menu Items folder.
-Since the System uses a different menu definition procedure for
-the Apple menu than Tk uses for its menus, and the system APIs do
-not fully support everything Tk tries to do, the menu item will only
-have its text displayed. No font attributes, images, bitmaps, or colors
-will be displayed. In addition, a menu with a tearoff item will have
-the tearoff item displayed as "(TearOff)".
-.PP
-When Tk see a Help menu on the Macintosh, the menu's contents are
-appended to the standard help menu on the right of the user's menubar
-whenever the user's menubar is in front. The first items in the menu
-are provided by Apple. Similar to the Apple Menu, cusomization in this
-menu is limited to what the system provides.
-.PP
-When Tk sees a System menu on Windows, its items are appended to the
-system menu that the menubar is attached to. This menu has an icon
-representing a spacebar, and can be invoked with the mouse or by typing
-Alt+Spacebar. Due to limitations in the Windows API, any font changes,
-colors, images, bitmaps, or tearoff images will not appear in the
-system menu.
-.PP
-When Tk see a Help menu on X Windows, the menu is moved to be last in
-the menubar and is right justified.
-.VE
-
-.VS
-.SH "CLONES"
-.PP
-When a menu is set as a menubar for a toplevel window, or when a menu
-is torn off, a clone of the menu is made. This clone is a menu widget
-in its own right, but it is a child of the original. Changes in the
-configuration of the original are reflected in the
-clone. Additionally, any cascades that are pointed to are also cloned
-so that menu traversal will work right. Clones are destroyed when
-either the tearoff or menubar goes away, or when the original menu is
-destroyed.
-.VE
-
-.SH "WIDGET COMMAND"
-.PP
-The \fBmenu\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 a menu take as one argument an
-indicator of which entry of the menu to operate on. These
-indicators are called \fIindex\fRes and may be specified in
-any of the following forms:
-.TP 12
-\fInumber\fR
-Specifies the entry numerically, where 0 corresponds
-to the top-most entry of the menu, 1 to the entry below it, and
-so on.
-.TP 12
-\fBactive\fR
-Indicates the entry that is currently active. If no entry is
-active then this form is equivalent to \fBnone\fR. This form may
-not be abbreviated.
-.TP 12
-\fBend\fR
-Indicates the bottommost entry in the menu. If there are no
-entries in the menu then this form is equivalent to \fBnone\fR.
-This form may not be abbreviated.
-.TP 12
-\fBlast\fR
-Same as \fBend\fR.
-.TP 12
-\fBnone\fR
-Indicates ``no entry at all''; this is used most commonly with
-the \fBactivate\fR option to deactivate all the entries in the
-menu. In most cases the specification of \fBnone\fR causes
-nothing to happen in the widget command.
-This form may not be abbreviated.
-.TP 12
-\fB@\fInumber\fR
-In this form, \fInumber\fR is treated as a y-coordinate in the
-menu's window; the entry closest to that y-coordinate is used.
-For example, ``\fB@0\fR'' indicates the top-most entry in the
-window.
-.TP 12
-\fIpattern\fR
-If the index doesn't satisfy one of the above forms then this
-form is used. \fIPattern\fR is pattern-matched against the label of
-each entry in the menu, in order from the top down, until a
-matching entry is found. The rules of \fBTcl_StringMatch\fR
-are used.
-.PP
-The following widget commands are possible for menu widgets:
-.TP
-\fIpathName \fBactivate \fIindex\fR
-Change the state of the entry indicated by \fIindex\fR to \fBactive\fR
-and redisplay it using its active colors.
-Any previously-active entry is deactivated. If \fIindex\fR
-is specified as \fBnone\fR, or if the specified entry is
-disabled, then the menu ends up with no active entry.
-Returns an empty string.
-.TP
-\fIpathName \fBadd \fItype \fR?\fIoption value option value ...\fR?
-Add a new entry to the bottom of the menu. The new entry's type
-is given by \fItype\fR and must be one of \fBcascade\fR,
-\fBcheckbutton\fR, \fBcommand\fR, \fBradiobutton\fR, or \fBseparator\fR,
-or a unique abbreviation of one of the above. If additional arguments
-are present, they specify any of the following options:
-.RS
-.TP
-\fB\-activebackground \fIvalue\fR
-Specifies a background color to use for displaying this entry when it
-is active.
-If this option is specified as an empty string (the default), then the
-\fBactiveBackground\fR option for the overall menu is used.
-If the \fBtk_strictMotif\fR variable has been set to request strict
-Motif compliance, then this option is ignored and the \fB\-background\fR
-option is used in its place.
-This option is not available for separator or tear-off entries.
-.TP
-\fB\-activeforeground \fIvalue\fR
-Specifies a foreground color to use for displaying this entry when it
-is active.
-If this option is specified as an empty string (the default), then the
-\fBactiveForeground\fR option for the overall menu is used.
-This option is not available for separator or tear-off entries.
-.TP
-\fB\-accelerator \fIvalue\fR
-Specifies a string to display at the right side of the menu entry.
-Normally describes an accelerator keystroke sequence that may be
-typed to invoke the same function as the menu entry. This option
-is not available for separator or tear-off entries.
-.TP
-\fB\-background \fIvalue\fR
-Specifies a background color to use for displaying this entry when it
-is in the normal state (neither active nor disabled).
-If this option is specified as an empty string (the default), then the
-\fBbackground\fR option for the overall menu is used.
-This option is not available for separator or tear-off entries.
-.TP
-\fB\-bitmap \fIvalue\fR
-Specifies a bitmap to display in the menu instead of a textual
-label, in any of the forms accepted by \fBTk_GetBitmap\fR.
-This option overrides the \fB\-label\fR option but may be reset
-to an empty string to enable a textual label to be displayed.
-If a \fB\-image\fR option has been specified, it overrides
-\fB\-bitmap\fR.
-This option is not available for separator or tear-off entries.
-.VS
-.TP
-\fB\-columnbreak \fIvalue\fR
-When this option is zero, the appears below the previous entry. When
-this option is one, the menu appears at the top of a new column in the
-menu.
-.VE
-.TP
-\fB\-command \fIvalue\fR
-Specifies a Tcl command to execute when the menu entry is invoked.
-Not available for separator or tear-off entries.
-.TP
-\fB\-font \fIvalue\fR
-Specifies the font to use when drawing the label or accelerator
-string in this entry.
-If this option is specified as an empty string (the default) then
-the \fBfont\fR option for the overall menu is used.
-This option is not available for separator or tear-off entries.
-.TP
-\fB\-foreground \fIvalue\fR
-Specifies a foreground color to use for displaying this entry when it
-is in the normal state (neither active nor disabled).
-If this option is specified as an empty string (the default), then the
-\fBforeground\fR option for the overall menu is used.
-This option is not available for separator or tear-off entries.
-.VS
-.TP
-\fB\-hidemargin \fIvalue\fR
-Specifies whether the standard margins should be drawn for this menu
-entry. This is useful when creating palette with images in them, i.e.,
-color palettes, pattern palettes, etc. 1 indicates that the margin for
-the entry is hidden; 0 means that the margin is used.
-.VE
-.TP
-\fB\-image \fIvalue\fR
-Specifies an image to display in the menu instead of a text string
-or bitmap
-The image must have been created by some previous invocation of
-\fBimage create\fR.
-This option overrides the \fB\-label\fR and \fB\-bitmap\fR options
-but may be reset to an empty string to enable a textual or
-bitmap label to be displayed.
-This option is not available for separator or tear-off entries.
-.TP
-\fB\-indicatoron \fIvalue\fR
-Available only for checkbutton and radiobutton entries.
-\fIValue\fR is a boolean that determines whether or not the
-indicator should be displayed.
-.TP
-\fB\-label \fIvalue\fR
-Specifies a string to display as an identifying label in the menu
-entry. Not available for separator or tear-off entries.
-.TP
-\fB\-menu \fIvalue\fR
-Available only for cascade entries. Specifies the path name of
-the submenu associated with this entry.
-The submenu must be a child of the menu.
-.TP
-\fB\-offvalue \fIvalue\fR
-Available only for checkbutton entries. Specifies the value to
-store in the entry's associated variable when the entry is
-deselected.
-.TP
-\fB\-onvalue \fIvalue\fR
-Available only for checkbutton entries. Specifies the value to
-store in the entry's associated variable when the entry is selected.
-.TP
-\fB\-selectcolor \fIvalue\fR
-Available only for checkbutton and radiobutton entries.
-Specifies the color to display in the indicator when the entry is
-selected.
-If the value is an empty string (the default) then the \fBselectColor\fR
-option for the menu determines the indicator color.
-.TP
-\fB\-selectimage \fIvalue\fR
-Available only for checkbutton and radiobutton entries.
-Specifies an image to display in the entry (in place of
-the \fB\-image\fR option) when it is selected.
-\fIValue\fR is the name of an image, which must have been created
-by some previous invocation of \fBimage create\fR.
-This option is ignored unless the \fB\-image\fR option has
-been specified.
-.TP
-\fB\-state \fIvalue\fR
-Specifies one of three states for the entry: \fBnormal\fR, \fBactive\fR,
-or \fBdisabled\fR. In normal state the entry is displayed using the
-\fBforeground\fR option for the menu and the \fBbackground\fR
-option from the entry or the menu.
-The active state is typically used when the pointer is over the entry.
-In active state the entry is displayed using the \fBactiveForeground\fR
-option for the menu along with the \fBactivebackground\fR option from
-the entry. Disabled state means that the entry
-should be insensitive: the default bindings will refuse to activate
-or invoke the entry.
-In this state the entry is displayed according to the
-\fBdisabledForeground\fR option for the menu and the
-\fBbackground\fR option from the entry.
-This option is not available for separator entries.
-.TP
-\fB\-underline \fIvalue\fR
-Specifies the integer index of a character to underline in the entry.
-This option is also queried by the default bindings and used to
-implement keyboard traversal.
-0 corresponds to the first character of the text displayed in the entry,
-1 to the next character, and so on.
-If a bitmap or image is displayed in the entry then this option is ignored.
-This option is not available for separator or tear-off entries.
-.TP
-\fB\-value \fIvalue\fR
-Available only for radiobutton entries. Specifies the value to
-store in the entry's associated variable when the entry is selected.
-If an empty string is specified, then the \fB\-label\fR option
-for the entry as the value to store in the variable.
-.TP
-\fB\-variable \fIvalue\fR
-Available only for checkbutton and radiobutton entries. Specifies
-the name of a global value to set when the entry is selected.
-For checkbutton entries the variable is also set when the entry
-is deselected. For radiobutton entries, changing the variable
-causes the currently-selected entry to deselect itself.
-.LP
-The \fBadd\fR widget command returns an empty string.
-.RE
-.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 \fBmenu\fR
-command.
-.VS
-.TP
-\fIpathName\fR \fBclone\fR \fInewPathname ?cloneType?\fR
-Makes a clone of the current menu named \fInewPathName\fR. This clone
-is a menu in its own right, but any changes to the clone are
-propogated to the original menu and vice versa. \fIcloneType\fR can be
-\fBnormal\fR, \fBmenubar\fR, or \fBtearoff\fR. Should not normally be
-called outside of the Tk library. See the \fBCLONES\fR section for
-more information.
-.VE
-.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 \fBmenu\fR
-command.
-.TP
-\fIpathName \fBdelete \fIindex1\fR ?\fIindex2\fR?
-Delete all of the menu entries between \fIindex1\fR and
-\fIindex2\fR inclusive.
-If \fIindex2\fR is omitted then it defaults to \fIindex1\fR.
-Attempts to delete a tear-off menu entry are ignored (instead, you
-should change the \fBtearOff\fR option to remove the tear-off entry).
-.TP
-\fIpathName \fBentrycget\fR \fIindex option\fR
-Returns the current value of a configuration option for
-the entry given by \fIindex\fR.
-\fIOption\fR may have any of the values accepted by the \fBadd\fR
-widget command.
-.TP
-\fIpathName \fBentryconfigure \fIindex \fR?\fIoptions\fR?
-This command is similar to the \fBconfigure\fR command, except that
-it applies to the options for an individual entry, whereas \fBconfigure\fR
-applies to the options for the menu as a whole.
-\fIOptions\fR may have any of the values accepted by the \fBadd\fR
-widget command. If \fIoptions\fR are specified, options are modified
-as indicated
-in the command and the command returns an empty string.
-If no \fIoptions\fR are specified, returns a list describing
-the current options for entry \fIindex\fR (see \fBTk_ConfigureInfo\fR for
-information on the format of this list).
-.TP
-\fIpathName \fBindex \fIindex\fR
-Returns the numerical index corresponding to \fIindex\fR, or
-\fBnone\fR if \fIindex\fR was specified as \fBnone\fR.
-.TP
-\fIpathName \fBinsert \fIindex\fR \fItype \fR?\fIoption value option value ...\fR?
-Same as the \fBadd\fR widget command except that it inserts the new
-entry just before the entry given by \fIindex\fR, instead of appending
-to the end of the menu. The \fItype\fR, \fIoption\fR, and \fIvalue\fR
-arguments have the same interpretation as for the \fBadd\fR widget
-command. It is not possible to insert new menu entries before the
-tear-off entry, if the menu has one.
-.TP
-\fIpathName \fBinvoke \fIindex\fR
-Invoke the action of the menu entry. See the sections on the
-individual entries above for details on what happens. If the
-menu entry is disabled then nothing happens. If the
-entry has a command associated with it then the result of that
-command is returned as the result of the \fBinvoke\fR widget
-command. Otherwise the result is an empty string. Note: invoking
-a menu entry does not automatically unpost the menu; the default
-bindings normally take care of this before invoking the \fBinvoke\fR
-widget command.
-.TP
-\fIpathName \fBpost \fIx y\fR
-Arrange for the menu to be displayed on the screen at the root-window
-coordinates given by \fIx\fR and \fIy\fR. These coordinates are
-adjusted if necessary to guarantee that the entire menu is visible on
-the screen. This command normally returns an empty string.
-If the \fBpostCommand\fR option has been specified, then its value is
-executed as a Tcl script before posting the menu and the result of
-that script is returned as the result of the \fBpost\fR widget
-command.
-If an error returns while executing the command, then the error is
-returned without posting the menu.
-.TP
-\fIpathName \fBpostcascade \fIindex\fR
-Posts the submenu associated with the cascade entry given by
-\fIindex\fR, and unposts any previously posted submenu.
-If \fIindex\fR doesn't correspond to a cascade entry,
-or if \fIpathName\fR isn't posted,
-the command has no effect except to unpost any currently posted
-submenu.
-.TP
-\fIpathName \fBtype \fIindex\fR
-Returns the type of the menu entry given by \fIindex\fR.
-This is the \fItype\fR argument passed to the \fBadd\fR widget
-command when the entry was created, such as \fBcommand\fR
-or \fBseparator\fR, or \fBtearoff\fR for a tear-off entry.
-.TP
-.VS
-\fIpathName \fBunpost\fR
-Unmap the window so that it is no longer displayed. If a
-lower-level cascaded menu is posted, unpost that menu. Returns an
-empty string. This subcommand does not work on Windows and the
-Macintosh, as those platforms have their own way of unposting menus.
-.VE
-.TP
-\fIpathName \fByposition \fIindex\fR
-Returns a decimal string giving the y-coordinate within the menu
-window of the topmost pixel in the entry specified by \fIindex\fR.
-
-.SH "MENU CONFIGURATIONS"
-.PP
-The default bindings support four different ways of using menus:
-.VS
-.TP
-\fBPulldown Menus in Menubar\fR
-This is the most command case. You create a menu widget that will become the
-menu bar. You then add cascade entries to this menu, specifying the
-pull down menus you wish to use in your menu bar. You then create all
-of the pulldowns. Once you have done this, specify the menu using the
-\fB-menu\fR option of the toplevel's widget command. See the
-\fBtoplevel\fR manual entry for details.
-.VE
-.TP
-\fBPulldown Menus in Menu Buttons\fR
-This is the compatable way to do menu bars. You create one menubutton
-widget for each top-level menu, and typically you arrange a series of
-menubuttons in a row in a menubar window. You also create the top-level menus
-and any cascaded submenus, and tie them together with \fB\-menu\fR
-options in menubuttons and cascade menu entries. The top-level menu must
-be a child of the menubutton, and each submenu must be a child of the
-menu that refers to it. Once you have done this, the default bindings
-will allow users to traverse and invoke the tree of menus via its
-menubutton; see the \fBmenubutton\fR manual entry for details.
-.TP
-\fBPopup Menus\fR
-Popup menus typically post in response to a mouse button press or
-keystroke. You create the popup menus and any cascaded submenus,
-then you call the \fBtk_popup\fR procedure at the appropriate time
-to post the top-level menu.
-.TP
-\fBOption Menus\fR
-An option menu consists of a menubutton with an associated menu
-that allows you to select one of several values. The current value
-is displayed in the menubutton and is also stored in a global
-variable. Use the \fBtk_optionMenu\fR procedure to create option
-menubuttons and their menus.
-.TP
-\fBTorn-off Menus\fR
-You create a torn-off menu by invoking the tear-off entry at
-the top of an existing menu. The default bindings will create a new menu
-that is a copy of the original menu and leave it permanently
-posted as a top-level window. The torn-off menu behaves just
-the same as the original menu.
-
-.SH "DEFAULT BINDINGS"
-.PP
-Tk automatically creates class bindings for menus that give them
-the following default behavior:
-.IP [1]
-When the mouse enters a menu, the entry underneath the mouse
-cursor activates; as the mouse moves around the menu, the active
-entry changes to track the mouse.
-.IP [2]
-When the mouse leaves a menu all of the entries in the menu
-deactivate, except in the special case where the mouse moves from
-a menu to a cascaded submenu.
-.IP [3]
-When a button is released over a menu, the active entry (if any) is invoked.
-The menu also unposts unless it is a torn-off menu.
-.IP [4]
-The Space and Return keys invoke the active entry and
-unpost the menu.
-.IP [5]
-If any of the entries in a menu have letters underlined with
-with \fB\-underline\fR option, then pressing one of the underlined
-letters (or its upper-case or lower-case equivalent) invokes that
-entry and unposts the menu.
-.IP [6]
-The Escape key aborts a menu selection in progress without invoking any
-entry. It also unposts the menu unless it is a torn-off menu.
-.IP [7]
-The Up and Down keys activate the next higher or lower entry
-in the menu. When one end of the menu is reached, the active
-entry wraps around to the other end.
-.IP [8]
-The Left key moves to the next menu to the left.
-If the current menu is a cascaded submenu, then the submenu is
-unposted and the current menu entry becomes the cascade entry
-in the parent.
-If the current menu is a top-level menu posted from a
-menubutton, then the current menubutton is unposted and the
-next menubutton to the left is posted.
-Otherwise the key has no effect.
-The left-right order of menubuttons is determined by their stacking
-order: Tk assumes that the lowest menubutton (which by default
-is the first one created) is on the left.
-.IP [9]
-The Right key moves to the next menu to the right.
-If the current entry is a cascade entry, then the submenu is
-posted and the current menu entry becomes the first entry
-in the submenu.
-Otherwise, if the current menu was posted from a
-menubutton, then the current menubutton is unposted and the
-next menubutton to the right is posted.
-.PP
-Disabled menu entries are non-responsive: they don't activate and
-they ignore mouse button presses and releases.
-.PP
-The behavior of menus can be changed by defining new bindings for
-individual widgets or by redefining the class bindings.
-
-.SH BUGS
-.PP
-At present it isn't possible to use the
-option database to specify values for the options to individual
-entries.
-
-.SH KEYWORDS
-menu, widget
diff --git a/doc/menubar.n b/doc/menubar.n
deleted file mode 100644
index bedd287..0000000
--- a/doc/menubar.n
+++ /dev/null
@@ -1,33 +0,0 @@
-'\"
-'\" 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: menubar.n,v 1.2 1998/09/14 18:22:57 stanton Exp $
-'\"
-.so man.macros
-.TH tk_menuBar n "" Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-tk_menuBar, tk_bindForTraversal \- Obsolete support for menu bars
-.SH SYNOPSIS
-\fBtk_menuBar \fIframe \fR?\fImenu menu ...\fR?
-.sp
-\fBtk_bindForTraversal \fIarg arg ... \fR
-.BE
-
-.SH DESCRIPTION
-.PP
-These procedures were used in Tk 3.6 and earlier releases to help
-manage pulldown menus and to implement keyboard traversal of menus.
-In Tk 4.0 and later releases they are no
-longer needed. Stubs for these procedures have been retained for
-backward compatibility, but they have no effect. You should remove
-calls to these procedures from your code, since eventually the
-procedures will go away.
-
-.SH KEYWORDS
-keyboard traversal, menu, menu bar, post
diff --git a/doc/menubutton.n b/doc/menubutton.n
deleted file mode 100644
index b9183a5..0000000
--- a/doc/menubutton.n
+++ /dev/null
@@ -1,193 +0,0 @@
-'\"
-'\" Copyright (c) 1990-1994 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: menubutton.n,v 1.2 1998/09/14 18:22:57 stanton Exp $
-'\"
-.so man.macros
-.TH menubutton n 4.0 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-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
-.SE
-.SH "WIDGET-SPECIFIC OPTIONS"
-.VS
-.OP \-direction direction Height
-Specifies where the menu is going to be popup up. \fBabove\fR tries to
-pop the menu above the menubutton. \fBbelow\fR tries to pop the menu
-below the menubutton. \fBleft\fR tries to pop the menu to the left of
-the menubutton. \fBright\fR tries to pop the menu to the right of the
-menu button. \fBflush\fR pops the menu directly over the menubutton.
-.VE
-.OP \-height height Height
-Specifies a desired height for the menubutton.
-If an image or bitmap is being displayed in the menubutton then the value is in
-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 menubutton's desired height is computed
-from the size of the image or bitmap or text being displayed in it.
-.OP \-indicatoron indicatorOn IndicatorOn
-The value must be a proper boolean value. If it is true then
-a small indicator rectangle will be displayed on the right side
-of the menubutton and the default menu bindings will treat this
-as an option menubutton. If false then no indicator will be
-displayed.
-.OP \-menu menu MenuName
-Specifies the path name of the menu associated with this menubutton.
-The menu must be a child of the menubutton.
-.OP \-state state State
-Specifies one of three states for the menubutton: \fBnormal\fR, \fBactive\fR,
-or \fBdisabled\fR. In normal state the menubutton is displayed using the
-\fBforeground\fR and \fBbackground\fR options. The active state is
-typically used when the pointer is over the menubutton. In active state
-the menubutton is displayed using the \fBactiveForeground\fR and
-\fBactiveBackground\fR options. Disabled state means that the menubutton
-should be insensitive: the default bindings will refuse to activate
-the widget and will ignore mouse button presses.
-In this state the \fBdisabledForeground\fR and
-\fBbackground\fR options determine how the button is displayed.
-.OP \-width width Width
-Specifies a desired width for the menubutton.
-If an image or bitmap is being displayed in the menubutton then the value is in
-screen units (i.e. any of the forms acceptable to \fBTk_GetPixels\fR);
-for text it is in characters.
-If this option isn't specified, the menubutton's desired width is computed
-from the size of the image or bitmap or text being displayed in it.
-.BE
-
-.SH INTRODUCTION
-.PP
-The \fBmenubutton\fR command creates a new window (given by the
-\fIpathName\fR argument) and makes it into a menubutton widget.
-Additional
-options, described above, may be specified on the command line
-or in the option database
-to configure aspects of the menubutton such as its colors, font,
-text, and initial relief. The \fBmenubutton\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 menubutton is a widget that displays a textual string, bitmap, or image
-and is associated with a menu widget.
-If text is displayed, it must all be in a single font, but it
-can occupy multiple lines on the screen (if it contains newlines
-or if wrapping occurs because of the \fBwrapLength\fR option) and
-one of the characters may optionally be underlined using the
-\fBunderline\fR option. In normal usage, pressing
-mouse button 1 over the menubutton causes the associated menu to
-be posted just underneath the menubutton. If the mouse is moved over
-the menu before releasing the mouse button, the button release
-causes the underlying menu entry to be invoked. When the button
-is released, the menu is unposted.
-.PP
-Menubuttons are typically organized into groups called menu bars
-that allow scanning:
-if the mouse button is pressed over one menubutton (causing it
-to post its menu) and the mouse is moved over another menubutton
-in the same menu bar without releasing the mouse button, then the
-menu of the first menubutton is unposted and the menu of the
-new menubutton is posted instead.
-.PP
-There are several interactions between menubuttons and menus; see
-the \fBmenu\fR manual entry for information on various menu configurations,
-such as pulldown menus and option menus.
-
-.SH "WIDGET COMMAND"
-.PP
-The \fBmenubutton\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. The following
-commands are possible for menubutton 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 \fBmenubutton\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 \fBmenubutton\fR
-command.
-
-.SH "DEFAULT BINDINGS"
-.PP
-Tk automatically creates class bindings for menubuttons that give them
-the following default behavior:
-.IP [1]
-A menubutton activates whenever the mouse passes over it and deactivates
-whenever the mouse leaves it.
-.IP [2]
-Pressing mouse button 1 over a menubutton posts the menubutton:
-its relief changes to raised and its associated menu is posted
-under the menubutton. If the mouse is dragged down into the menu
-with the button still down, and if the mouse button is then
-released over an entry in the menu, the menubutton is unposted
-and the menu entry is invoked.
-.IP [3]
-If button 1 is pressed over a menubutton and then released over that
-menubutton, the menubutton stays posted: you can still move the mouse
-over the menu and click button 1 on an entry to invoke it.
-Once a menu entry has been invoked, the menubutton unposts itself.
-.IP [4]
-If button 1 is pressed over a menubutton and then dragged over some
-other menubutton, the original menubutton unposts itself and the
-new menubutton posts.
-.IP [5]
-If button 1 is pressed over a menubutton and released outside
-any menubutton or menu, the menubutton unposts without invoking
-any menu entry.
-.IP [6]
-When a menubutton is posted, its associated menu claims the input
-focus to allow keyboard traversal of the menu and its submenus.
-See the \fBmenu\fR manual entry for details on these bindings.
-.IP [7]
-If the \fBunderline\fR option has been specified for a menubutton
-then keyboard traversal may be used to post the menubutton:
-Alt+\fIx\fR, where \fIx\fR is the underlined character (or its
-lower-case or upper-case equivalent), may be typed in any window
-under the menubutton's toplevel to post the menubutton.
-.IP [8]
-The F10 key may be typed in any window to post the first menubutton
-under its toplevel window that isn't disabled.
-.IP [9]
-If a menubutton has the input focus, the space and return keys
-post the menubutton.
-.PP
-If the menubutton's state is \fBdisabled\fR then none of the above
-actions occur: the menubutton is completely non-responsive.
-.PP
-The behavior of menubuttons can be changed by defining new bindings for
-individual widgets or by redefining the class bindings.
-
-.SH KEYWORDS
-menubutton, widget
diff --git a/doc/message.n b/doc/message.n
deleted file mode 100644
index 986fe5e..0000000
--- a/doc/message.n
+++ /dev/null
@@ -1,147 +0,0 @@
-'\"
-'\" 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: message.n,v 1.2 1998/09/14 18:22:58 stanton Exp $
-'\"
-.so man.macros
-.TH message n 4.0 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-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
-.SE
-.SH "WIDGET-SPECIFIC OPTIONS"
-.OP \-aspect aspect Aspect
-Specifies a non-negative integer value indicating desired
-aspect ratio for the text. The aspect ratio is specified as
-100*width/height. 100 means the text should
-be as wide as it is tall, 200 means the text should
-be twice as wide as it is tall, 50 means the text should
-be twice as tall as it is wide, and so on.
-Used to choose line length for text if \fBwidth\fR option
-isn't specified.
-Defaults to 150.
-.OP \-justify justify Justify
-Specifies how to justify lines of text.
-Must be one of \fBleft\fR, \fBcenter\fR, or \fBright\fR. Defaults
-to \fBleft\fR.
-This option works together with the \fBanchor\fR, \fBaspect\fR,
-\fBpadX\fR, \fBpadY\fR, and \fBwidth\fR options to provide a variety
-of arrangements of the text within the window.
-The \fBaspect\fR and \fBwidth\fR options determine the amount of
-screen space needed to display the text.
-The \fBanchor\fR, \fBpadX\fR, and \fBpadY\fR options determine where this
-rectangular area is displayed within the widget's window, and the
-\fBjustify\fR option determines how each line is displayed within that
-rectangular region.
-For example, suppose \fBanchor\fR is \fBe\fR and \fBjustify\fR is
-\fBleft\fR, and that the message window is much larger than needed
-for the text.
-The the text will displayed so that the left edges of all the lines
-line up and the right edge of the longest line is \fBpadX\fR from
-the right side of the window; the entire text block will be centered
-in the vertical span of the window.
-.OP \-width width Width
-Specifies the length of lines in the window.
-The value may have any of the forms acceptable to \fBTk_GetPixels\fR.
-If this option has a value greater than zero then the \fBaspect\fR
-option is ignored and the \fBwidth\fR option determines the line
-length.
-If this option has a value less than or equal to zero, then
-the \fBaspect\fR option determines the line length.
-.BE
-
-.SH DESCRIPTION
-.PP
-The \fBmessage\fR command creates a new window (given by the
-\fIpathName\fR argument) and makes it into a message widget.
-Additional
-options, described above, may be specified on the command line
-or in the option database
-to configure aspects of the message such as its colors, font,
-text, and initial relief. The \fBmessage\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 message is a widget that displays a textual string. A message
-widget has three special features. First, it breaks up
-its string into lines in order to produce a given aspect ratio
-for the window. The line breaks are chosen at word boundaries
-wherever possible (if not even a single word would fit on a
-line, then the word will be split across lines). Newline characters
-in the string will force line breaks; they can be used, for example,
-to leave blank lines in the display.
-.PP
-The second feature of a message widget is justification. The text
-may be displayed left-justified (each line starts at the left side of
-the window), centered on a line-by-line basis, or right-justified
-(each line ends at the right side of the window).
-.PP
-The third feature of a message widget is that it handles control
-characters and non-printing characters specially. Tab characters
-are replaced with enough blank space to line up on the next
-8-character boundary. Newlines cause line breaks. Other control
-characters (ASCII code less than 0x20) and characters not defined
-in the font are displayed as a four-character sequence \fB\ex\fIhh\fR where
-\fIhh\fR is the two-digit hexadecimal number corresponding to
-the character. In the unusual case where the font doesn't contain
-all of the characters in ``0123456789abcdef\ex'' then control
-characters and undefined characters are not displayed at all.
-
-.SH "WIDGET COMMAND"
-.PP
-The \fBmessage\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. The following
-commands are possible for message 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 \fBmessage\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 \fBmessage\fR
-command.
-
-.SH "DEFAULT BINDINGS"
-.PP
-When a new message is created, it has no default event bindings:
-messages are intended for output purposes only.
-
-.SH BUGS
-.PP
-Tabs don't work very well with text that is centered or right-justified.
-The most common result is that the line is justified wrong.
-
-.SH KEYWORDS
-message, widget
diff --git a/doc/messageBox.n b/doc/messageBox.n
deleted file mode 100644
index 927c120..0000000
--- a/doc/messageBox.n
+++ /dev/null
@@ -1,90 +0,0 @@
-'\"
-'\" Copyright (c) 1996 Sun Microsystems, Inc.
-'\"
-'\" See the file "license.terms" for information on usage and redistribution
-'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-'\"
-'\" RCS: @(#) $Id: messageBox.n,v 1.2 1998/09/14 18:22:58 stanton Exp $
-'\"
-.so man.macros
-.TH tk_messageBox n 4.2 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-tk_messageBox \- pops up a message window and waits for user response.
-.SH SYNOPSIS
-\fBtk_messageBox \fR?\fIoption value ...\fR?
-.BE
-
-.SH DESCRIPTION
-.PP
-This procedure creates and displays a message window with an
-application-specified message, an icon and a set of buttons. Each of
-the buttons in the message window is identified by a unique symbolic
-name (see the \fB\-type\fR options). After the message window is
-popped up, \fBtk_messageBox\fR waits for the user to select one of the
-buttons. Then it returns the symbolic name of the selected button.
-
-The following option-value pairs are supported:
-.TP
-\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.
-.TP
-\fB\-icon\fR \fIiconImage\fR
-Specifies an icon to display. \fIIconImage\fR must be one of the
-following: \fBerror\fR, \fBinfo\fR, \fBquestion\fR or
-\fBwarning\fR. If this option is not specified, then no icon will be
-displayed.
-.TP
-\fB\-message\fR \fIstring\fR
-Specifies the message to display in this message box.
-.TP
-\fB\-parent\fR \fIwindow\fR
-Makes \fIwindow\fR the logical parent of the message box. The message
-box is displayed on top of its parent window.
-.TP
-\fB\-title\fR \fItitleString\fR
-Specifies a string to display as the title of the message box. The
-default value is an empty string.
-.TP
-\fB\-type\fR \fIpredefinedType\fR
-Arranges for a predefined set of buttons to be displayed. The
-following values are possible for \fIpredefinedType\fR:
-.RS
-.TP 18
-\fBabortretryignore\fR
-Displays three buttons whose symbolic names are \fBabort\fR,
-\fBretry\fR and \fBignore\fR.
-.TP 18
-\fBok\fR
-Displays one button whose symbolic name is \fBok\fR.
-.TP 18
-\fBokcancel\fR
-Displays two buttons whose symbolic names are \fBok\fR and \fBcancel\fR.
-.TP 18
-\fBretrycancel\fR
-Displays two buttons whose symbolic names are \fBretry\fR and \fBcancel\fR.
-.TP 18
-\fByesno\fR
-Displays two buttons whose symbolic names are \fByes\fR and \fBno\fR.
-.TP 18
-\fByesnocancel\fR
-Displays three buttons whose symbolic names are \fByes\fR, \fBno\fR
-and \fBcancel\fR.
-.RE
-.PP
-.SH EXAMPLE
-.CS
-set answer [tk_messageBox \-message "Really quit?" \-type yesno \-icon question]
-case $answer {
- yes exit
- no {tk_messageBox \-message "I know you like this application!" \-type ok}
-}
-.CE
-
-.SH KEYWORDS
-message box
diff --git a/doc/option.n b/doc/option.n
deleted file mode 100644
index 4545eb2..0000000
--- a/doc/option.n
+++ /dev/null
@@ -1,91 +0,0 @@
-'\"
-'\" Copyright (c) 1990 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: option.n,v 1.2 1998/09/14 18:22:58 stanton Exp $
-'\"
-.so man.macros
-.TH option n "" Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-option \- Add/retrieve window options to/from the option database
-.SH SYNOPSIS
-\fBoption add \fIpattern value \fR?\fIpriority\fR?
-.sp
-\fBoption clear\fR
-.sp
-\fBoption get \fIwindow name class\fR
-.sp
-\fBoption readfile \fIfileName \fR?\fIpriority\fR?
-.BE
-
-.SH DESCRIPTION
-.PP
-The \fBoption\fR command allows you to add entries to the Tk option
-database or to retrieve options from the database. The \fBadd\fR
-form of the command adds a new option to the database.
-\fIPattern\fR contains
-the option being specified, and consists of names and/or classes
-separated by asterisks or dots, in the usual X format. \fIValue\fR
-contains a text string to associate with \fIpattern\fR; this is the
-value that will be returned in calls to \fBTk_GetOption\fR or by
-invocations of the \fBoption get\fR command. If \fIpriority\fR
-is specified, it indicates the priority level for this option (see
-below for legal values); it defaults to \fBinteractive\fR.
-This command always returns an empty string.
-.PP
-The \fBoption clear\fR command clears the option database. Default
-options (from the
-\fBRESOURCE_MANAGER\fR property or the \fB.Xdefaults\fR
-file) will be reloaded automatically the next time an
-option is added to the database or removed from it. This command
-always returns an empty string.
-.PP
-The \fBoption get\fR command returns the value of the option
-specified for \fIwindow\fR
-under \fIname\fR and \fIclass\fR. If several entries in the option
-database match \fIwindow\fR, \fIname\fR, and \fIclass\fR, then
-the command returns whichever was created with highest
-\fIpriority\fR level. If there are several matching
-entries at the same priority level, then it returns whichever entry
-was most recently entered into the option database. If there are
-no matching entries, then the empty string is returned.
-.PP
-The \fBreadfile\fR form of the command reads \fIfileName\fR,
-which should have the standard format for an
-X resource database such as \fB.Xdefaults\fR, and adds all the
-options specified in that file to the option database. If \fIpriority\fR
-is specified, it indicates the priority level at which to enter the
-options; \fIpriority\fR defaults to \fBinteractive\fR.
-.PP
-The \fIpriority\fR arguments to the \fBoption\fR command are
-normally specified symbolically using one of the following values:
-.TP
-\fBwidgetDefault\fR
-Level 20. Used for default values hard-coded into widgets.
-.TP
-\fBstartupFile\fR
-Level 40. Used for options specified in application-specific
-startup files.
-.TP
-\fBuserDefault\fR
-Level 60. Used for options specified in user-specific defaults
-files, such as \fB.Xdefaults\fR, resource databases loaded into
-the X server, or user-specific startup files.
-.TP
-\fBinteractive\fR
-Level 80. Used for options specified interactively after the application
-starts running. If \fIpriority\fR isn't specified, it defaults to
-this level.
-.LP
-Any of the above keywords may be abbreviated. In addition, priorities
-may be specified numerically using integers between 0 and 100,
-inclusive. The numeric form is probably a bad idea except for new priority
-levels other than the ones given above.
-
-.SH KEYWORDS
-database, option, priority, retrieve
diff --git a/doc/optionMenu.n b/doc/optionMenu.n
deleted file mode 100644
index 17a2727..0000000
--- a/doc/optionMenu.n
+++ /dev/null
@@ -1,40 +0,0 @@
-'\"
-'\" 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: optionMenu.n,v 1.2 1998/09/14 18:22:58 stanton Exp $
-'\"
-.so man.macros
-.TH tk_optionMenu n 4.0 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-tk_optionMenu \- Create an option menubutton and its menu
-.SH SYNOPSIS
-\fBtk_optionMenu \fIw varName value \fR?\fIvalue value ...\fR?
-.BE
-
-.SH DESCRIPTION
-.PP
-This procedure creates an option menubutton whose name is \fIw\fR,
-plus an associated menu.
-Together they allow the user to select one of the values
-given by the \fIvalue\fR arguments.
-The current value will be stored in the global variable whose
-name is given by \fIvarName\fR and it will also be displayed as the label
-in the option menubutton.
-The user can click on the menubutton to display a menu containing
-all of the \fIvalue\fRs and thereby select a new value.
-Once a new value is selected, it will be stored in the variable
-and appear in the option menubutton.
-The current value can also be changed by setting the variable.
-.PP
-The return value from \fBtk_optionMenu\fR is the name of the menu
-associated with \fIw\fR, so that the caller can change its configuration
-options or manipulate it in other ways.
-
-.SH KEYWORDS
-option menu
diff --git a/doc/options.n b/doc/options.n
deleted file mode 100644
index 4715cf4..0000000
--- a/doc/options.n
+++ /dev/null
@@ -1,328 +0,0 @@
-'\"
-'\" 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: options.n,v 1.2 1998/09/14 18:22:58 stanton Exp $
-'\"
-.so man.macros
-.TH options n 4.4 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-options \- Standard options supported by widgets
-.BE
-
-.SH DESCRIPTION
-This manual entry describes the common configuration options supported
-by widgets in the Tk toolkit. Every widget does not necessarily support
-every option (see the manual entries for individual widgets for a list
-of the standard options supported by that widget), but if a widget does
-support an option with one of the names listed below, then the option
-has exactly the effect described below.
-.PP
-In the descriptions below, ``Command-Line Name'' refers to the
-switch used in class commands and \fBconfigure\fR widget commands to
-set this value. For example, if an option's command-line switch is
-\fB\-foreground\fR and there exists a widget \fB.a.b.c\fR, then the
-command
-.CS
-\&\fB.a.b.c\0\0configure\0\0\-foreground black\fR
-.CE
-may be used to specify the value \fBblack\fR for the option in the
-the widget \fB.a.b.c\fR. Command-line switches may be abbreviated,
-as long as the abbreviation is unambiguous.
-``Database Name'' refers to the option's name in the option database (e.g.
-in .Xdefaults files). ``Database Class'' refers to the option's class value
-in the option database.
-.OP \-activebackground activeBackground Foreground
-Specifies background color to use when drawing active elements.
-An element (a widget or portion of a widget) is active if the
-mouse cursor is positioned over the element and pressing a mouse button
-will cause some action to occur.
-If strict Motif compliance has been requested by setting the
-\fBtk_strictMotif\fR variable, this option will normally be
-ignored; the normal background color will be used instead.
-.VS
-For some elements on Windows and Macintosh systems, the active color
-will only be used while mouse button 1 is pressed over the element.
-.VE
-.OP \-activeborderwidth activeBorderWidth BorderWidth
-Specifies a non-negative value indicating
-the width of the 3-D border drawn around active elements. See above for
-definition of active elements.
-The value may have any of the forms acceptable to \fBTk_GetPixels\fR.
-This option is typically only available in widgets displaying more
-than one element at a time (e.g. menus but not buttons).
-.OP \-activeforeground activeForeground Background
-Specifies foreground color to use when drawing active elements.
-See above for definition of active elements.
-.OP \-anchor anchor Anchor
-Specifies how the information in a widget (e.g. text or a bitmap)
-is to be displayed in the widget.
-Must be one of the values \fBn\fR, \fBne\fR, \fBe\fR, \fBse\fR,
-\fBs\fR, \fBsw\fR, \fBw\fR, \fBnw\fR, or \fBcenter\fR.
-For example, \fBnw\fR means display the information such that its
-top-left corner is at the top-left corner of the widget.
-.OP "\-background or \-bg" background Background
-Specifies the normal background color to use when displaying the
-widget.
-.OP \-bitmap bitmap Bitmap
-Specifies a bitmap to display in the widget, in any of the forms
-acceptable to \fBTk_GetBitmap\fR.
-The exact way in which the bitmap is displayed may be affected by
-other options such as \fBanchor\fR or \fBjustify\fR.
-Typically, if this option is specified then it overrides other
-options that specify a textual value to display in the widget;
-the \fBbitmap\fR option may be reset to an empty string to re-enable
-a text display.
-In widgets that support both \fBbitmap\fR and \fBimage\fR options,
-\fBimage\fR will usually override \fBbitmap\fR.
-.OP "\-borderwidth or \-bd" borderWidth BorderWidth
-Specifies a non-negative value indicating the width
-of the 3-D border to draw around the outside of the widget (if such a
-border is being drawn; the \fBrelief\fR option typically determines
-this). The value may also be used when drawing 3-D effects in the
-interior of the widget.
-The value may have any of the forms acceptable to \fBTk_GetPixels\fR.
-.OP \-cursor cursor Cursor
-Specifies the mouse cursor to be used for the widget.
-The value may have any of the forms acceptable to \fBTk_GetCursor\fR.
-.OP \-disabledforeground disabledForeground DisabledForeground
-Specifies foreground color to use when drawing a disabled element.
-If the option is specified as an empty string (which is typically the
-case on monochrome displays), disabled elements are drawn with the
-normal foreground color but they are dimmed by drawing them
-with a stippled fill pattern.
-.OP \-exportselection exportSelection ExportSelection
-Specifies whether or not a selection in the widget should also be
-the X selection.
-The value may have any of the forms accepted by \fBTcl_GetBoolean\fR,
-such as \fBtrue\fR, \fBfalse\fR, \fB0\fR, \fB1\fR, \fByes\fR, or \fBno\fR.
-If the selection is exported, then selecting in the widget deselects
-the current X selection, selecting outside the widget deselects any
-widget selection, and the widget will respond to selection retrieval
-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.
-.OP "\-foreground or \-fg" foreground Foreground
-Specifies the normal foreground color to use when displaying the widget.
-.OP \-highlightbackground highlightBackground HighlightBackground
-Specifies the color to display in the traversal highlight region when
-the widget does not have the input focus.
-.OP \-highlightcolor highlightColor HighlightColor
-Specifies the color to use for the traversal highlight rectangle that is
-drawn around the widget when it has the input focus.
-.OP \-highlightthickness highlightThickness HighlightThickness
-Specifies a non-negative value indicating the width of the highlight
-rectangle to draw around the outside of the widget when it has the
-input focus.
-The value may have any of the forms acceptable to \fBTk_GetPixels\fR.
-If the value is zero, no focus highlight is drawn around the widget.
-.OP \-image image Image
-Specifies an image to display in the widget, which must have been
-created with the \fBimage create\fR command.
-Typically, if the \fBimage\fR option is specified then it overrides other
-options that specify a bitmap or textual value to display in the widget;
-the \fBimage\fR option may be reset to an empty string to re-enable
-a bitmap or text display.
-.OP \-insertbackground insertBackground Foreground
-Specifies the color to use as background in the area covered by the
-insertion cursor. This color will normally override either the normal
-background for the widget (or the selection background if the insertion
-cursor happens to fall in the selection).
-.OP \-insertborderwidth insertBorderWidth BorderWidth
-Specifies a non-negative value indicating the width
-of the 3-D border to draw around the insertion cursor.
-The value may have any of the forms acceptable to \fBTk_GetPixels\fR.
-.OP \-insertofftime insertOffTime OffTime
-Specifies a non-negative integer value indicating the number of
-milliseconds the insertion cursor should remain ``off'' in each blink cycle.
-If this option is zero then the cursor doesn't blink: it is on
-all the time.
-.OP \-insertontime insertOnTime OnTime
-Specifies a non-negative integer value indicating the number of
-milliseconds the insertion cursor should remain ``on'' in each blink cycle.
-.OP \-insertwidth insertWidth InsertWidth
-Specifies a value indicating the total width of the insertion cursor.
-The value may have any of the forms acceptable to \fBTk_GetPixels\fR.
-If a border has been specified for the insertion
-cursor (using the \fBinsertBorderWidth\fR option), the border
-will be drawn inside the width specified by the \fBinsertWidth\fR
-option.
-.OP \-jump jump Jump
-For widgets with a slider that can be dragged to adjust a value,
-such as scrollbars, this option determines when
-notifications are made about changes in the value.
-The option's value must be a boolean of the form accepted by
-\fBTcl_GetBoolean\fR.
-If the value is false, updates are made continuously as the
-slider is dragged.
-If the value is true, updates are delayed until the mouse button
-is released to end the drag; at that point a single notification
-is made (the value ``jumps'' rather than changing smoothly).
-.OP \-justify justify Justify
-When there are multiple lines of text displayed in a widget, this
-option determines how the lines line up with each other.
-Must be one of \fBleft\fR, \fBcenter\fR, or \fBright\fR.
-\fBLeft\fR means that the lines' left edges all line up, \fBcenter\fR
-means that the lines' centers are aligned, and \fBright\fR means
-that the lines' right edges line up.
-.OP \-orient orient Orient
-For widgets that can lay themselves out with either a horizontal
-or vertical orientation, such as scrollbars, this option specifies
-which orientation should be used. Must be either \fBhorizontal\fR
-or \fBvertical\fR or an abbreviation of one of these.
-.OP \-padx padX Pad
-Specifies a non-negative value indicating how much extra space
-to request for the widget in the X-direction.
-The value may have any of the forms acceptable to \fBTk_GetPixels\fR.
-When computing how large a window it needs, the widget will
-add this amount to the width it would normally need (as determined
-by the width of the things displayed in the widget); if the geometry
-manager can satisfy this request, the widget will end up with extra
-internal space to the left and/or right of what it displays inside.
-Most widgets only use this option for padding text: if they are
-displaying a bitmap or image, then they usually ignore padding
-options.
-.OP \-pady padY Pad
-Specifies a non-negative value indicating how much extra space
-to request for the widget in the Y-direction.
-The value may have any of the forms acceptable to \fBTk_GetPixels\fR.
-When computing how large a window it needs, the widget will add
-this amount to the height it would normally need (as determined by
-the height of the things displayed in the widget); if the geometry
-manager can satisfy this request, the widget will end up with extra
-internal space above and/or below what it displays inside.
-Most widgets only use this option for padding text: if they are
-displaying a bitmap or image, then they usually ignore padding
-options.
-.OP \-relief relief Relief
-Specifies the 3-D effect desired for the widget. Acceptable
-values are \fBraised\fR, \fBsunken\fR, \fBflat\fR, \fBridge\fR,
-\fBsolid\fR, and \fBgroove\fR.
-The value
-indicates how the interior of the widget should appear relative
-to its exterior; for example, \fBraised\fR means the interior of
-the widget should appear to protrude from the screen, relative to
-the exterior of the widget.
-.OP \-repeatdelay repeatDelay RepeatDelay
-Specifies the number of milliseconds a button or key must be held
-down before it begins to auto-repeat. Used, for example, on the
-up- and down-arrows in scrollbars.
-.OP \-repeatinterval repeatInterval RepeatInterval
-Used in conjunction with \fBrepeatDelay\fR: once auto-repeat
-begins, this option determines the number of milliseconds between
-auto-repeats.
-.OP \-selectbackground selectBackground Foreground
-Specifies the background color to use when displaying selected
-items.
-.OP \-selectborderwidth selectBorderWidth BorderWidth
-Specifies a non-negative value indicating the width
-of the 3-D border to draw around selected items.
-The value may have any of the forms acceptable to \fBTk_GetPixels\fR.
-.OP \-selectforeground selectForeground Background
-Specifies the foreground color to use when displaying selected
-items.
-.OP \-setgrid setGrid SetGrid
-Specifies a boolean value that determines whether this widget controls the
-resizing grid for its top-level window.
-This option is typically used in text widgets, where the information
-in the widget has a natural size (the size of a character) and it makes
-sense for the window's dimensions to be integral numbers of these units.
-These natural window sizes form a grid.
-If the \fBsetGrid\fR option is set to true then the widget will
-communicate with the window manager so that when the user interactively
-resizes the top-level window that contains the widget, the dimensions of
-the window will be displayed to the user in grid units and the window
-size will be constrained to integral numbers of grid units.
-See the section GRIDDED GEOMETRY MANAGEMENT in the \fBwm\fR manual
-entry for more details.
-.OP \-takefocus takeFocus TakeFocus
-Determines whether the window accepts the focus during keyboard
-traversal (e.g., Tab and Shift-Tab).
-Before setting the focus to a window, the traversal scripts
-consult the value of the \fBtakeFocus\fR option.
-A value of \fB0\fR means that the window should be skipped entirely
-during keyboard traversal.
-\fB1\fR means that the window should receive the input
-focus as long as it is viewable (it and all of its ancestors are mapped).
-An empty value for the option means that the traversal scripts make
-the decision about whether or not to focus on the window: the current
-algorithm is to skip the window if it is
-disabled, if it has no key bindings, or if it is not viewable.
-If the value has any other form, then the traversal scripts take
-the value, append the name of the window to it (with a separator space),
-and evaluate the resulting string as a Tcl script.
-The script must return \fB0\fR, \fB1\fR, or an empty string: a
-\fB0\fR or \fB1\fR value specifies whether the window will receive
-the input focus, and an empty string results in the default decision
-described above.
-Note: this interpretation of the option is defined entirely by
-the Tcl scripts that implement traversal: the widget implementations
-ignore the option entirely, so you can change its meaning if you
-redefine the keyboard traversal scripts.
-.OP \-text text Text
-Specifies a string to be displayed inside the widget. The way in which
-the string is displayed depends on the particular widget and may be
-determined by other options, such as \fBanchor\fR or \fBjustify\fR.
-.OP \-textvariable textVariable Variable
-Specifies the name of a variable. The value of the variable is a text
-string to be displayed inside the widget; if the variable value changes
-then the widget will automatically update itself to reflect the new value.
-The way in which the string is displayed in the widget depends on the
-particular widget and may be determined by other options, such as
-\fBanchor\fR or \fBjustify\fR.
-.OP \-troughcolor troughColor Background
-Specifies the color to use for the rectangular trough areas
-in widgets such as scrollbars and scales.
-.OP \-underline underline Underline
-Specifies the integer index of a character to underline in the widget.
-This option is used by the default bindings to implement keyboard
-traversal for menu buttons and menu entries.
-0 corresponds to the first character of the text displayed in the
-widget, 1 to the next character, and so on.
-.OP \-wraplength wrapLength WrapLength
-For widgets that can perform word-wrapping, this option specifies
-the maximum line length.
-Lines that would exceed this length are wrapped onto the next line,
-so that no line is longer than the specified length.
-The value may be specified in any of the standard forms for
-screen distances.
-If this value is less than or equal to 0 then no wrapping is done: lines
-will break only at newline characters in the text.
-.OP \-xscrollcommand xScrollCommand ScrollCommand
-Specifies the prefix for a command used to communicate with horizontal
-scrollbars.
-When the view in the widget's window changes (or
-whenever anything else occurs that could change the display in a
-scrollbar, such as a change in the total size of the widget's
-contents), the widget will
-generate a Tcl command by concatenating the scroll command and
-two numbers.
-Each of the numbers is a fraction between 0 and 1, which indicates
-a position in the document. 0 indicates the beginning of the document,
-1 indicates the end, .333 indicates a position one third the way through
-the document, and so on.
-The first fraction indicates the first information in the document
-that is visible in the window, and the second fraction indicates
-the information just after the last portion that is visible.
-The command is
-then passed to the Tcl interpreter for execution. Typically the
-\fBxScrollCommand\fR option consists of the path name of a scrollbar
-widget followed by ``set'', e.g. ``.x.scrollbar set'': this will cause
-the scrollbar to be updated whenever the view in the window changes.
-If this option is not specified, then no command will be executed.
-.OP \-yscrollcommand yScrollCommand ScrollCommand
-Specifies the prefix for a command used to communicate with vertical
-scrollbars. This option is treated in the same way as the
-\fBxScrollCommand\fR option, except that it is used for vertical
-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 KEYWORDS
-class, name, standard option, switch
diff --git a/doc/pack-old.n b/doc/pack-old.n
deleted file mode 100644
index 4b0a1d6..0000000
--- a/doc/pack-old.n
+++ /dev/null
@@ -1,196 +0,0 @@
-'\"
-'\" 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: pack-old.n,v 1.2 1998/09/14 18:22:58 stanton Exp $
-'\"
-.so man.macros
-.TH pack-old n 4.0 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-pack \- Obsolete syntax for packer geometry manager
-.SH SYNOPSIS
-\fBpack after \fIsibling \fIwindow options\fR ?\fIwindow options \fR...?
-.sp
-\fBpack append \fIparent \fIwindow options\fR ?\fIwindow options \fR...?
-.sp
-\fBpack before \fIsibling \fIwindow options\fR ?\fIwindow options \fR...?
-.sp
-\fBpack unpack \fIwindow\fR
-.BE
-
-.SH DESCRIPTION
-.PP
-\fINote: this manual entry describes the syntax for the \fBpack\fI
-command as it existed before Tk version 3.3.
-Although this syntax continues to be supported for backward
-compatibility, it is obsolete and should not be used anymore.
-At some point in the future it may cease to be supported.\fR
-.PP
-The packer is a geometry manager that arranges the
-children of a parent by packing them in order around the edges of
-the parent. The first child is placed against one side of
-the window, occupying the entire span of the window along that
-side. This reduces the space remaining for other children as
-if the side had been moved in by the size of the first child.
-Then the next child is placed against one side of the remaining
-cavity, and so on until all children have been placed or there
-is no space left in the cavity.
-.PP
-The \fBbefore\fR, \fBafter\fR, and \fBappend\fR forms of the \fBpack\fR
-command are used to insert one or more children into the packing order
-for their parent. The \fBbefore\fR form inserts the children before
-window \fIsibling\fR in the order; all of the other windows must be
-siblings of \fIsibling\fR. The \fBafter\fR form inserts the windows
-after \fIsibling\fR, and the \fBappend\fR form appends one or more
-windows to the end of the packing order for \fIparent\fR. If a
-\fIwindow\fR named in any of these commands is already packed in
-its parent, it is removed from its current position in the packing
-order and repositioned as indicated by the command. All of these
-commands return an empty string as result.
-.PP
-The \fBunpack\fR form of the \fBpack\fR command removes \fIwindow\fR
-from the packing order of its parent and unmaps it. After the
-execution of this command the packer will no longer manage
-\fIwindow\fR's geometry.
-.PP
-The placement of each child is actually a four-step process;
-the \fIoptions\fR argument following each \fIwindow\fR consists of
-a list of one or more fields that govern the placement of that
-window. In the discussion below, the term \fIcavity\fR refers
-to the space left in a parent when a particular child is placed
-(i.e. all the space that wasn't claimed by earlier children in
-the packing order). The term \fIparcel\fR refers to the space
-allocated to a particular child; this is not necessarily the
-same as the child window's final geometry.
-.PP
-The first step in placing a child is to determine which side of
-the cavity it will lie against. Any one of the following options
-may be used to specify a side:
-.TP
-\fBtop\fR
-Position the child's parcel against the top of the cavity,
-occupying the full width of the cavity.
-.TP
-\fBbottom\fR
-Position the child's parcel against the bottom of the cavity,
-occupying the full width of the cavity.
-.TP
-\fBleft\fR
-Position the child's parcel against the left side of the cavity,
-occupying the full height of the cavity.
-.TP
-\fBright\fR
-Position the child's parcel against the right side of the cavity,
-occupying the full height of the cavity.
-.LP
-At most one of these options should be specified for any given window.
-If no side is specified, then the default is \fBtop\fR.
-.PP
-The second step is to decide on a parcel for the child. For \fBtop\fR
-and \fBbottom\fR windows, the desired parcel width is normally the cavity
-width and the desired parcel height is the window's requested height,
-as passed to \fBTk_GeometryRequest\fR. For \fBleft\fR and \fBright\fR
-windows, the desired parcel height is normally the cavity height and the
-desired width is the window's requested width. However, extra
-space may be requested for the window using any of the following
-options:
-.TP 12
-\fBpadx \fInum\fR
-Add \fInum\fR pixels to the window's requested width before computing
-the parcel size as described above.
-.TP 12
-\fBpady \fInum\fR
-Add \fInum\fR pixels to the window's requested height before computing
-the parcel size as described above.
-.TP 12
-\fBexpand\fR
-This option requests that the window's parcel absorb any extra space left over
-in the parent's cavity after packing all the children.
-The amount of space left over depends on the sizes requested by the
-other children, and may be zero. If several windows have all specified
-\fBexpand\fR then the extra width will be divided equally among all the
-\fBleft\fR and \fBright\fR windows that specified \fBexpand\fR and
-the extra height will be divided equally among all the \fBtop\fR and
-\fBbottom\fR windows that specified \fBexpand\fR.
-.LP
-If the desired width or height for a parcel is larger than the corresponding
-dimension of the cavity, then the cavity's dimension is used instead.
-.PP
-The third step in placing the window is to decide on the window's
-width and height. The default is for the window to receive either
-its requested width and height or the those of the parcel, whichever
-is smaller. If the parcel is larger than the window's requested
-size, then the following options may be used to expand the
-window to partially or completely fill the parcel:
-.TP
-\fBfill\fR
-Set the window's size to equal the parcel size.
-.TP
-\fBfillx\fR
-Increase the window's width to equal the parcel's width, but retain
-the window's requested height.
-.TP
-\fBfilly\fR
-Increase the window's height to equal the parcel's height, but retain
-the window's requested width.
-.PP
-The last step is to decide the window's location within its parcel.
-If the window's size equals the parcel's size, then the window simply
-fills the entire parcel. If the parcel is larger than the window,
-then one of
-the following options may be used to specify where the window should
-be positioned within its parcel:
-.TP 15
-\fBframe center\fR
-Center the window in its parcel. This is the default if no framing
-option is specified.
-.TP 15
-\fBframe n\fR
-Position the window with its top edge centered on the top edge of
-the parcel.
-.TP 15
-\fBframe ne\fR
-Position the window with its upper-right corner at the upper-right corner
-of the parcel.
-.TP 15
-\fBframe e\fR
-Position the window with its right edge centered on the right edge of
-the parcel.
-.TP 15
-\fBframe se\fR
-Position the window with its lower-right corner at the lower-right corner
-of the parcel.
-.TP 15
-\fBframe s\fR
-Position the window with its bottom edge centered on the bottom edge of
-the parcel.
-.TP 15
-\fBframe sw\fR
-Position the window with its lower-left corner at the lower-left corner
-of the parcel.
-.TP 15
-\fBframe w\fR
-Position the window with its left edge centered on the left edge of
-the parcel.
-.TP 15
-\fBframe nw\fR
-Position the window with its upper-left corner at the upper-left corner
-of the parcel.
-.PP
-The packer manages the mapped/unmapped state of all the packed
-children windows. It automatically maps the windows when it packs
-them, and it unmaps any windows for which there was no space left
-in the cavity.
-.PP
-The packer makes geometry requests on behalf of the parent windows
-it manages. For each parent window it requests a size large enough
-to accommodate all the options specified by all the packed children,
-such that zero space would be leftover for \fBexpand\fR options.
-
-.SH KEYWORDS
-geometry manager, location, packer, parcel, size
diff --git a/doc/pack.n b/doc/pack.n
deleted file mode 100644
index 411e8f7..0000000
--- a/doc/pack.n
+++ /dev/null
@@ -1,266 +0,0 @@
-'\"
-'\" 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: pack.n,v 1.2 1998/09/14 18:22:58 stanton Exp $
-'\"
-.so man.macros
-.TH pack n 4.0 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-pack \- Geometry manager that packs around edges of cavity
-.SH SYNOPSIS
-\fBpack \fIoption arg \fR?\fIarg ...\fR?
-.BE
-
-.SH DESCRIPTION
-.PP
-The \fBpack\fR command is used to communicate with the packer,
-a geometry manager that arranges the children of a parent by
-packing them in order around the edges of the parent.
-The \fBpack\fR command can have any of several forms, depending
-on the \fIoption\fR argument:
-.TP
-\fBpack \fIslave \fR?\fIslave ...\fR? ?\fIoptions\fR?
-If the first argument to \fBpack\fR is a window name (any value
-starting with ``.''), then the command is processed in the same
-way as \fBpack configure\fR.
-.TP
-\fBpack configure \fIslave \fR?\fIslave ...\fR? ?\fIoptions\fR?
-The arguments consist of the names of one or more slave windows
-followed by pairs of arguments that specify how
-to manage the slaves.
-See ``THE PACKER ALGORITHM'' below for details on how the options
-are used by the packer.
-The following options are supported:
-.RS
-.TP
-\fB\-after \fIother\fR
-\fIOther\fR must the name of another window.
-Use its master as the master for the slaves, and insert
-the slaves just after \fIother\fR in the packing order.
-.TP
-\fB\-anchor \fIanchor\fR
-\fIAnchor\fR must be a valid anchor position such as \fBn\fR
-or \fBsw\fR; it specifies where to position each slave in its
-parcel.
-Defaults to \fBcenter\fR.
-.TP
-\fB\-before \fIother\fR
-\fIOther\fR must the name of another window.
-Use its master as the master for the slaves, and insert
-the slaves just before \fIother\fR in the packing order.
-.TP
-\fB\-expand \fIboolean\fR
-Specifies whether the slaves should be expanded to consume
-extra space in their master.
-\fIBoolean\fR may have any proper boolean value, such as \fB1\fR
-or \fBno\fR.
-Defaults to 0.
-.TP
-\fB\-fill \fIstyle\fR
-If a slave's parcel is larger than its requested dimensions, this
-option may be used to stretch the slave.
-\fIStyle\fR must have one of the following values:
-.RS
-.TP
-\fBnone\fR
-Give the slave its requested dimensions plus any internal padding
-requested with \fB\-ipadx\fR or \fB\-ipady\fR. This is the default.
-.TP
-\fBx\fR
-Stretch the slave horizontally to fill the entire width of its
-parcel (except leave external padding as specified by \fB\-padx\fR).
-.TP
-\fBy\fR
-Stretch the slave vertically to fill the entire height of its
-parcel (except leave external padding as specified by \fB\-pady\fR).
-.TP
-\fBboth\fR
-Stretch the slave both horizontally and vertically.
-.RE
-.TP
-\fB\-in \fIother\fR
-Insert the slave(s) at the end of the packing order for the master
-window given by \fIother\fR.
-.TP
-\fB\-ipadx \fIamount\fR
-\fIAmount\fR specifies how much horizontal internal padding to
-leave on each side of the slave(s).
-\fIAmount\fR must be a valid screen distance, such as \fB2\fR or \fB.5c\fR.
-It defaults to 0.
-.TP
-\fB\-ipady \fIamount\fR
-\fIAmount\fR specifies how much vertical internal padding to
-leave on each side of the slave(s).
-\fIAmount\fR defaults to 0.
-.TP
-\fB\-padx \fIamount\fR
-\fIAmount\fR specifies how much horizontal external padding to
-leave on each side of the slave(s).
-\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).
-\fIAmount\fR defaults to 0.
-.TP
-\fB\-side \fIside\fR
-Specifies which side of the master the slave(s) will be packed against.
-Must be \fBleft\fR, \fBright\fR, \fBtop\fR, or \fBbottom\fR.
-Defaults to \fBtop\fR.
-.LP
-If no \fB\-in\fR, \fB\-after\fR or \fB\-before\fR option is specified
-then each of the slaves will be inserted at the end of the packing list
-for its parent unless it is already managed by the packer (in which
-case it will be left where it is).
-If one of these options is specified then all the slaves will be
-inserted at the specified point.
-If any of the slaves are already managed by the geometry manager
-then any unspecified options for them retain their previous values rather
-than receiving default values.
-.RE
-.TP
-\fBpack forget \fIslave \fR?\fIslave ...\fR?
-Removes each of the \fIslave\fRs from the packing order for its
-master and unmaps their windows.
-The slaves will no longer be managed by the packer.
-.TP
-\fBpack info \fIslave\fR
-Returns a list whose elements are the current configuration state of
-the slave given by \fIslave\fR in the same option-value form that
-might be specified to \fBpack configure\fR.
-The first two elements of the list are ``\fB\-in \fImaster\fR'' where
-\fImaster\fR is the slave's master.
-.TP
-\fBpack propagate \fImaster\fR ?\fIboolean\fR?
-If \fIboolean\fR has a true boolean value such as \fB1\fR or \fBon\fR
-then propagation is enabled for \fImaster\fR, which must be a window
-name (see ``GEOMETRY PROPAGATION'' below).
-If \fIboolean\fR has a false boolean value then propagation is
-disabled for \fImaster\fR.
-In either of these cases an empty string is returned.
-If \fIboolean\fR is omitted then the command returns \fB0\fR or
-\fB1\fR to indicate whether propagation is currently enabled
-for \fImaster\fR.
-Propagation is enabled by default.
-.TP
-\fBpack slaves \fImaster\fR
-Returns a list of all of the slaves in the packing order for \fImaster\fR.
-The order of the slaves in the list is the same as their order in
-the packing order.
-If \fImaster\fR has no slaves then an empty string is returned.
-
-.SH "THE PACKER ALGORITHM"
-.PP
-For each master the packer maintains an ordered list of slaves
-called the \fIpacking list\fR.
-The \fB\-in\fR, \fB\-after\fR, and \fB\-before\fR configuration
-options are used to specify the master for each slave and the slave's
-position in the packing list.
-If none of these options is given for a slave then the slave
-is added to the end of the packing list for its parent.
-.PP
-The packer arranges the slaves for a master by scanning the
-packing list in order.
-At the time it processes each slave, a rectangular area within
-the master is still unallocated.
-This area is called the \fIcavity\fR; for the first slave it
-is the entire area of the master.
-.PP
-For each slave the packer carries out the following steps:
-.IP [1]
-The packer allocates a rectangular \fIparcel\fR for the slave
-along the side of the cavity given by the slave's \fB\-side\fR option.
-If the side is top or bottom then the width of the parcel is
-the width of the cavity and its height is the requested height
-of the slave plus the \fB\-ipady\fR and \fB\-pady\fR options.
-For the left or right side the height of the parcel is
-the height of the cavity and the width is the requested width
-of the slave plus the \fB\-ipadx\fR and \fB\-padx\fR options.
-The parcel may be enlarged further because of the \fB\-expand\fR
-option (see ``EXPANSION'' below)
-.IP [2]
-The packer chooses the dimensions of the slave.
-The width will normally be the slave's requested width plus
-twice its \fB\-ipadx\fR option and the height will normally be
-the slave's requested height plus twice its \fB\-ipady\fR
-option.
-However, if the \fB\-fill\fR option is \fBx\fR or \fBboth\fR
-then the width of the slave is expanded to fill the width of the parcel,
-minus twice the \fB\-padx\fR option.
-If the \fB\-fill\fR option is \fBy\fR or \fBboth\fR
-then the height of the slave is expanded to fill the width of the parcel,
-minus twice the \fB\-pady\fR option.
-.IP [3]
-The packer positions the slave over its parcel.
-If the slave is smaller than the parcel then the \fB\-anchor\fR
-option determines where in the parcel the slave will be placed.
-If \fB\-padx\fR or \fB\-pady\fR is non-zero, then the given
-amount of external padding will always be left between the
-slave and the edges of the parcel.
-.PP
-Once a given slave has been packed, the area of its parcel
-is subtracted from the cavity, leaving a smaller rectangular
-cavity for the next slave.
-If a slave doesn't use all of its parcel, the unused space
-in the parcel will not be used by subsequent slaves.
-If the cavity should become too small to meet the needs of
-a slave then the slave will be given whatever space is
-left in the cavity.
-If the cavity shrinks to zero size, then all remaining slaves
-on the packing list will be unmapped from the screen until
-the master window becomes large enough to hold them again.
-
-.SH "EXPANSION"
-.PP
-If a master window is so large that there will be extra space
-left over after all of its slaves have been packed, then the
-extra space is distributed uniformly among all of the slaves
-for which the \fB\-expand\fR option is set.
-Extra horizontal space is distributed among the expandable
-slaves whose \fB\-side\fR is \fBleft\fR or \fBright\fR,
-and extra vertical space is distributed among the expandable
-slaves whose \fB\-side\fR is \fBtop\fR or \fBbottom\fR.
-
-.SH "GEOMETRY PROPAGATION"
-.PP
-The packer normally computes how large a master must be to
-just exactly meet the needs of its slaves, and it sets the
-requested width and height of the master to these dimensions.
-This causes geometry information to propagate up through a
-window hierarchy to a top-level window so that the entire
-sub-tree sizes itself to fit the needs of the leaf windows.
-However, the \fBpack propagate\fR command may be used to
-turn off propagation for one or more masters.
-If propagation is disabled then the packer will not set
-the requested width and height of the packer.
-This may be useful if, for example, you wish for a master
-window to have a fixed size that you specify.
-
-.SH "RESTRICTIONS ON MASTER WINDOWS"
-.PP
-The master for each slave must either be the slave's parent
-(the default) or a descendant of the slave's parent.
-This restriction is necessary to guarantee that the
-slave can be placed over any part of its master that is
-visible without danger of the slave being clipped by its parent.
-
-.SH "PACKING ORDER"
-.PP
-If the master for a slave is not its parent then you must make sure
-that the slave is higher in the stacking order than the master.
-Otherwise the master will obscure the slave and it will appear as
-if the slave hasn't been packed correctly.
-The easiest way to make sure the slave is higher than the master is
-to create the master window first: the most recently created window
-will be highest in the stacking order.
-Or, you can use the \fBraise\fR and \fBlower\fR commands to change
-the stacking order of either the master or the slave.
-
-.SH KEYWORDS
-geometry manager, location, packer, parcel, propagation, size
diff --git a/doc/palette.n b/doc/palette.n
deleted file mode 100644
index 3d77282..0000000
--- a/doc/palette.n
+++ /dev/null
@@ -1,73 +0,0 @@
-'\"
-'\" Copyright (c) 1995-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: palette.n,v 1.2 1998/09/14 18:22:58 stanton Exp $
-'\"
-.so man.macros
-.TH tk_setPalette n 4.0 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-tk_setPalette, tk_bisque \- Modify the Tk color palette
-.SH SYNOPSIS
-\fBtk_setPalette \fIbackground\fR
-.sp
-\fBtk_setPalette \fIname value \fR?\fIname value ...\fR?
-.sp
-\fBtk_bisque\fR
-.BE
-
-.SH DESCRIPTION
-.PP
-The \fBtk_setPalette\fR procedure changes the color scheme for Tk.
-It does this by modifying the colors of existing widgets and by changing
-the option database so that future widgets will use the new color scheme.
-If \fBtk_setPalette\fR is invoked with a single argument, the
-argument is the name of a color to use as the normal background
-color; \fBtk_setPalette\fR will compute a complete color palette
-from this background color.
-Alternatively, the arguments to \fBtk_setPalette\fR may consist of any number
-of \fIname\fR\-\fIvalue\fR pairs, where the first argument of the pair
-is the name of an option in the Tk option database and the second
-argument is the new value to use for that option. The following
-database names are currently supported:
-.DS L
-.ta 4c 8c
-\fBactiveBackground foreground selectColor
-activeForeground highlightBackground selectBackground
-background highlightColor selectForeground
-disabledForeground insertBackground troughColor\fR
-.DE
-\fBtk_setPalette\fR tries to compute reasonable defaults for any
-options that you don't specify. You can specify options other
-than the above ones and Tk will change those options on widgets as
-well. This feature may be useful if you are using custom widgets with
-additional color options.
-.PP
-Once it has computed the new value to use for each of the color options,
-\fBtk_setPalette\fR scans the widget hierarchy to modify the options
-of all existing widgets. For each widget, it checks to see if any
-of the above options is defined for the widget. If so, and if the
-option's current value is the default, then the value is changed; if
-the option has a value other than the default, \fBtk_setPalette\fR
-will not change it. The default for an option is the one provided by
-the widget (\fB[lindex [$w configure $option] 3]\fR) unless
-\fBtk_setPalette\fR has been run previously, in which case it is the
-value specified in the previous invocation of \fBtk_setPalette\fR.
-.PP
-After modifying all the widgets in the application, \fBtk_setPalette\fR
-adds options to the option database to change the defaults for
-widgets created in the future. The new options are added at
-priority \fBwidgetDefault\fR, so they will be overridden by options
-from the .Xdefaults file or options specified on the command-line
-that creates a widget.
-.PP
-The procedure \fBtk_bisque\fR is provided for backward compatibility:
-it restores the application's colors to the light brown (``bisque'')
-color scheme used in Tk 3.6 and earlier versions.
-
-.SH KEYWORDS
-bisque, color, palette
diff --git a/doc/photo.n b/doc/photo.n
deleted file mode 100644
index b03ccf8..0000000
--- a/doc/photo.n
+++ /dev/null
@@ -1,344 +0,0 @@
-'\"
-'\" Copyright (c) 1994 The Australian National University
-'\" 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.
-'\"
-'\" Author: Paul Mackerras (paulus@cs.anu.edu.au),
-'\" Department of Computer Science,
-'\" Australian National University.
-'\"
-'\" RCS: @(#) $Id: photo.n,v 1.2 1998/09/14 18:22:59 stanton Exp $
-'\"
-.so man.macros
-.TH photo n 4.0 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-photo \- Full-color images
-.SH SYNOPSIS
-\fBimage create photo \fR?\fIname\fR? ?\fIoptions\fR?
-.BE
-
-.SH DESCRIPTION
-.PP
-A photo is an image whose pixels can display any color or be
-transparent. A photo image is stored internally in full color (24
-bits per pixel), and is displayed using dithering if necessary. Image
-data for a photo image can be obtained from a file or a string, or it
-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.
-
-.SH "CREATING PHOTOS"
-.PP
-Like all images, photos are created using the \fBimage create\fR
-command.
-Photos support the following \fIoptions\fR:
-.TP
-\fB\-data \fIstring\fR
-Specifies the contents of the image as a string. The format of the
-string must be one of those for which there is an image file format
-handler that will accept string data. If both the \fB\-data\fR
-and \fB\-file\fR options are specified, the \fB\-file\fR option takes
-precedence.
-.TP
-\fB\-format \fIformat-name\fR
-Specifies the name of the file format for the data specified with the
-\fB\-data\fR or \fB\-file\fR option.
-.TP
-\fB\-file \fIname\fR
-\fIname\fR gives the name of a file that is to be read to supply data
-for the photo image. The file format must be one of those for which
-there is an image file format handler that can read data.
-.TP
-\fB\-gamma \fIvalue\fR
-Specifies that the colors allocated for displaying this image in a
-window should be corrected for a non-linear display with the specified
-gamma exponent value. (The intensity produced by most
-CRT displays is a power function of the input value, to a good
-approximation; gamma is the exponent and is typically around 2).
-The value specified must be greater than zero. The default
-value is one (no correction). In general, values greater than one
-will make the image lighter, and values less than one will make it
-darker.
-.TP
-\fB\-height \fInumber\fR
-Specifies the height of the image, in pixels. This option is useful
-primarily in situations where the user wishes to build up the contents
-of the image piece by piece. A value of zero (the default) allows the
-image to expand or shrink vertically to fit the data stored in it.
-.TP
-\fB\-palette \fIpalette-spec\fR
-Specifies the resolution of the color cube to be allocated for
-displaying this image, and thus the number of colors used from the
-colormaps of the windows where it is displayed. The
-\fIpalette-spec\fR string may be either a single decimal number,
-specifying the number of shades of gray to use, or three decimal
-numbers separated by slashes (/), specifying the number of shades of
-red, green and blue to use, respectively. If the first form (a single
-number) is used, the image will be displayed in monochrome (i.e.,
-grayscale).
-.TP
-\fB\-width \fInumber\fR
-Specifies the width of the image, in pixels. This option is useful
-primarily in situations where the user wishes to build up the contents
-of the image piece by piece. A value of zero (the default) allows the
-image to expand or shrink horizontally to fit the data stored in it.
-
-.SH "IMAGE COMMAND"
-.PP
-When a photo image is created, Tk also creates a new command
-whose name is the same as the image.
-This command may be used to invoke various operations
-on the image.
-It has the following general form:
-.CS
-\fIimageName option \fR?\fIarg arg ...\fR?
-.CE
-\fIOption\fR and the \fIarg\fRs
-determine the exact behavior of the command.
-.PP
-Those options that write data to the image generally expand the size
-of the image, if necessary, to accommodate the data written to the
-image, unless the user has specified non-zero values for the
-\fB\-width\fR and/or \fB\-height\fR configuration options, in which
-case the width and/or height, respectively, of the image will not be
-changed.
-.PP
-The following commands are possible for photo images:
-.TP
-\fIimageName \fBblank\fR
-Blank the image; that is, set the entire image to have no data, so it
-will be displayed as transparent, and the background of whatever
-window it is displayed in will show through.
-.TP
-\fIimageName \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
-\fBimage create photo\fR command.
-.TP
-\fIimageName \fBconfigure\fR ?\fIoption\fR? ?\fIvalue option value ...\fR?
-Query or modify the configuration options for the image.
-If no \fIoption\fR is specified, returns a list describing all of
-the available options for \fIimageName\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 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
-\fBimage create photo\fR command.
-.TP
-\fIimageName \fBcopy\fR \fIsourceImage\fR ?\fIoption value(s) ...\fR?
-Copies a region from the image called \fIsourceImage\fR (which must
-be a photo image) to the image called \fIimageName\fR, possibly with
-pixel zooming and/or subsampling. If no options are specified, this
-command copies the whole of \fIsourceImage\fR into \fIimageName\fR,
-starting at coordinates (0,0) in \fIimageName\fR. The following
-options may be specified:
-.RS
-.TP
-\fB\-from \fIx1 y1 x2 y2\fR
-Specifies a rectangular sub-region of the source image to be copied.
-(\fIx1,y1\fR) and (\fIx2,y2\fR) specify diagonally opposite corners of
-the rectangle. If \fIx2\fR and \fIy2\fR are not specified, the
-default value is the bottom-right corner of the source image. The
-pixels copied will include the left and top edges of the specified
-rectangle but not the bottom or right edges. If the \fB\-from\fR
-option is not given, the default is the whole source image.
-.TP
-\fB\-to \fIx1 y1 x2 y2\fR
-Specifies a rectangular sub-region of the destination image to be
-affected. (\fIx1,y1\fR) and (\fIx2,y2\fR) specify diagonally opposite
-corners of the rectangle. If \fIx2\fR and \fIy2\fR are not specified,
-the default value is (\fIx1,y1\fR) plus the size of the source
-region (after subsampling and zooming, if specified). If \fIx2\fR and
-\fIy2\fR are specified, the source region will be replicated if
-necessary to fill the destination region in a tiled fashion.
-.TP
-\fB\-shrink\fR
-Specifies that the size of the destination image should be reduced, if
-necessary, so that the region being copied into is at the bottom-right
-corner of the image. This option will not affect the width or height
-of the image if the user has specified a non-zero value for the
-\fB\-width\fR or \fB\-height\fR configuration option, respectively.
-.TP
-\fB\-zoom \fIx y\fR
-Specifies that the source region should be magnified by a factor of
-\fIx\fR in the X direction and \fIy\fR in the Y direction. If \fIy\fR
-is not given, the default value is the same as \fIx\fR. With this
-option, each pixel in the source image will be expanded into a block
-of \fIx\fR x \fIy\fR pixels in the destination image, all the same
-color. \fIx\fR and \fIy\fR must be greater than 0.
-.TP
-\fB\-subsample \fIx y\fR
-Specifies that the source image should be reduced in size by using
-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.
-.RE
-.TP
-\fIimageName \fBget\fR \fIx y\fR
-Returns the color of the pixel at coordinates (\fIx\fR,\fIy\fR) in the
-image as a list of three integers between 0 and 255, representing the
-red, green and blue components respectively.
-.TP
-\fIimageName \fBput \fIdata\fR ?\fB\-to\fI x1 y1 x2 y2\fR?
-Sets pixels in \fIimageName\fR to the colors specified in \fIdata\fR.
-\fIdata\fR is used to form a two-dimensional array of pixels that are
-then copied into the \fIimageName\fR. \fIdata\fR is structured as a
-list of horizontal rows, from top to bottom, each of which is a list
-of colors, listed from left to right. Each color may be specified by name
-(e.g., blue) or in hexadecimal form (e.g., #2376af). The
-\fB\-to\fR option can be used to specify the area of \fIimageName\fR to be
-affected. If only \fIx1\fR and \fIy1\fR are given, the area affected
-has its top-left corner at (\fIx1,y1\fR) and is the same size as the
-array given in \fIdata\fR. If all four coordinates are given, they
-specify diagonally opposite corners of the affected rectangle, and the
-array given in \fIdata\fR will be replicated as necessary in the X and
-Y directions to fill the rectangle.
-.TP
-\fIimageName \fBread\fR \fIfilename\fR ?\fIoption value(s) ...\fR?
-Reads image data from the file named \fIfilename\fR into the image.
-This command first searches the list of
-image file format handlers for a handler that can interpret the data
-in \fIfilename\fR, and then reads the image in \fIfilename\fR into
-\fIimageName\fR (the destination image). The following options may be
-specified:
-.RS
-.TP
-\fB\-format \fIformat-name\fR
-Specifies the format of the image data in \fIfilename\fR.
-Specifically, only image file format handlers whose names begin with
-\fIformat-name\fR will be used while searching for an image data
-format handler to read the data.
-.TP
-\fB\-from \fIx1 y1 x2 y2\fR
-Specifies a rectangular sub-region of the image file data to be copied
-to the destination image. If only \fIx1\fR and \fIy1\fR are
-specified, the region extends from (\fIx1,y1\fR) to the bottom-right
-corner of the image in the image file. If all four coordinates are
-specified, they specify diagonally opposite corners or the region.
-The default, if this option is not specified, is the whole of the
-image in the image file.
-.TP
-\fB\-shrink\fR
-If this option, the size of \fIimageName\fR will be reduced, if
-necessary, so that the region into which the image file data are read
-is at the bottom-right corner of the \fIimageName\fR. This option
-will not affect the width or height of the image if the user has
-specified a non-zero value for the \fB\-width\fR or \fB\-height\fR
-configuration option, respectively.
-.TP
-\fB\-to \fIx y\fR
-Specifies the coordinates of the top-left corner of the region of
-\fIimageName\fR into which data from \fIfilename\fR are to be read.
-The default is (0,0).
-.RE
-.TP
-\fIimageName \fBredither\fR
-The dithering algorithm used in displaying photo images propagates
-quantization errors from one pixel to its neighbors.
-If the image data for \fIimageName\fR is supplied in pieces, the
-dithered image may not be exactly correct. Normally the difference is
-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 \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:
-.RS
-.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
-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.
-.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
-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.
-.RE
-.SH "IMAGE FORMATS"
-.PP
-The photo image code is structured to allow handlers for additional
-image file formats to be added easily. The photo image code maintains
-a list of these handlers. Handlers are added to the list by
-registering them with a call to \fBTk_CreatePhotoImageFormat\fR. The
-standard Tk distribution comes with handlers for PPM/PGM and GIF formats,
-which are automatically registered on initialization.
-.PP
-When reading an image file or processing
-string data specified with the \fB\-data\fR configuration option, the
-photo image code invokes each handler in turn until one is
-found that claims to be able to read the data in the file or string.
-Usually this will find the correct handler, but if it doesn't, the
-user may give a format name with the \fB\-format\fR option to specify
-which handler to use. In fact the photo image code will try those
-handlers whose names begin with the string specified for the
-\fB\-format\fR option (the comparison is case-insensitive). For
-example, if the user specifies \fB\-format gif\fR, then a handler
-named GIF87 or GIF89 may be invoked, but a handler
-named JPEG may not (assuming that such handlers had been
-registered).
-.PP
-When writing image data to a file, the processing of the
-\fB\-format\fR option is slightly different: the string value given
-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.
-
-.SH "COLOR ALLOCATION"
-.PP
-When a photo image is displayed in a window, the photo image code
-allocates colors to use to display the image and dithers the image, if
-necessary, to display a reasonable approximation to the image using
-the colors that are available. The colors are allocated as a color
-cube, that is, the number of colors allocated is the product of the
-number of shades of red, green and blue.
-.PP
-Normally, the number of
-colors allocated is chosen based on the depth of the window. For
-example, in an 8-bit PseudoColor window, the photo image code will
-attempt to allocate seven shades of red, seven shades of green and
-four shades of blue, for a total of 198 colors. In a 1-bit StaticGray
-(monochrome) window, it will allocate two colors, black and white. In
-a 24-bit DirectColor or TrueColor window, it will allocate 256 shades
-each of red, green and blue. Fortunately, because of the way that
-pixel values can be combined in DirectColor and TrueColor windows,
-this only requires 256 colors to be allocated. If not all of the
-colors can be allocated, the photo image code reduces the number of
-shades of each primary color and tries again.
-.PP
-The user can exercise some control over the number of colors that a
-photo image uses with the \fB\-palette\fR configuration option. If
-this option is used, it specifies the maximum number of shades of
-each primary color to try to allocate. It can also be used to force
-the image to be displayed in shades of gray, even on a color display,
-by giving a single number rather than three numbers separated by
-slashes.
-
-.SH CREDITS
-.PP
-The photo image type was designed and implemented by Paul Mackerras,
-based on his earlier photo widget and some suggestions from
-John Ousterhout.
-
-.SH KEYWORDS
-photo, image, color
diff --git a/doc/place.n b/doc/place.n
deleted file mode 100644
index b51e996..0000000
--- a/doc/place.n
+++ /dev/null
@@ -1,237 +0,0 @@
-'\"
-'\" 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: place.n,v 1.2 1998/09/14 18:22:59 stanton Exp $
-'\"
-.so man.macros
-.TH place n "" Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-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?
-.sp
-\fBplace forget \fIwindow\fR
-.sp
-\fBplace info \fIwindow\fR
-.sp
-\fBplace slaves \fIwindow\fR
-.BE
-
-.SH DESCRIPTION
-.PP
-The placer is a geometry manager for Tk.
-It provides simple fixed placement of windows, where you specify
-the exact size and location of one window, called the \fIslave\fR,
-within another window, called the \fImaster\fR.
-The placer also provides rubber-sheet placement, where you specify the
-size and location of the slave in terms of the dimensions of
-the master, so that the slave changes size and location
-in response to changes in the size of the master.
-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.
-The following \fIoption\-value\fR pairs are supported:
-.TP
-\fB\-in \fImaster\fR
-\fIMaster\fR specifes the path name of the window relative
-to which \fIwindow\fR is to be placed.
-\fIMaster\fR must either be \fIwindow\fR's parent or a descendant
-of \fIwindow\fR's parent.
-In addition, \fImaster\fR and \fIwindow\fR must both be descendants
-of the same top-level window.
-These restrictions are necessary to guarantee
-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.
-.TP
-\fB\-relx \fIlocation\fR
-\fILocation\fR specifies the x-coordinate within the master window
-of the anchor point for \fIwindow\fR.
-In this case the location is specified in a relative fashion
-as a floating-point number: 0.0 corresponds to the left edge
-of the master and 1.0 corresponds to the right edge of the master.
-\fILocation\fR need not be in the range 0.0\-1.0.
-If both \fB\-x\fR and \fB\-relx\fR are specified for a slave
-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.
-In this case the value is specified in a relative fashion
-as a floating-point number: 0.0 corresponds to the top edge
-of the master and 1.0 corresponds to the bottom edge of the master.
-\fILocation\fR need not be in the range 0.0\-1.0.
-If both \fB\-y\fR and \fB\-rely\fR are specified for a slave
-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).
-The width will be the outer width of \fIwindow\fR including its
-border, if any.
-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.
-.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.
-.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.
-The list consists of \fIoption\-value\fR pairs in exactly the
-same form as might be specified to the \fBplace configure\fR
-command.
-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
-for the window and then invoking \fBplace configure\fR with
-the saved information.
-
-.SH "FINE POINTS"
-.PP
-It is not necessary for the master window to be the parent
-of the slave window.
-This feature is useful in at least two situations.
-First, for complex window layouts it means you can create a
-hierarchy of subwindows whose only purpose
-is to assist in the layout of the parent.
-The ``real children'' of the parent (i.e. the windows that
-are significant for the application's user interface) can be
-children of the parent yet be placed inside the windows
-of the geometry-management hierarchy.
-This means that the path names of the ``real children''
-don't reflect the geometry-management hierarchy and users
-can specify options for the real children
-without being aware of the structure of the geometry-management
-hierarchy.
-.PP
-A second reason for having a master different than the slave's
-parent is to tie two siblings together.
-For example, the placer can be used to force a window always to
-be positioned centered just below one of its
-siblings by specifying the configuration
-.CS
-\fB\-in \fIsibling\fB \-relx 0.5 \-rely 1.0 \-anchor n \-bordermode outside\fR
-.CE
-Whenever the sibling is repositioned in the future, the slave
-will be repositioned as well.
-.PP
-Unlike many other geometry managers (such as the packer)
-the placer does not make any attempt to manipulate the geometry of
-the master windows or the parents of slave windows (i.e. it doesn't
-set their requested sizes).
-To control the sizes of these windows, make them windows like
-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/doc/popup.n b/doc/popup.n
deleted file mode 100644
index a1b49bd..0000000
--- a/doc/popup.n
+++ /dev/null
@@ -1,33 +0,0 @@
-'\"
-'\" 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: popup.n,v 1.2 1998/09/14 18:22:59 stanton Exp $
-'\"
-.so man.macros
-.TH tk_popup n 4.0 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-tk_popup \- Post a popup menu
-.SH SYNOPSIS
-\fBtk_popup \fImenu x y \fR?\fIentry\fR?
-.BE
-
-.SH DESCRIPTION
-.PP
-This procedure posts a menu at a given position on the screen and
-configures Tk so that the menu and its cascaded children can be
-traversed with the mouse or the keyboard.
-\fIMenu\fR is the name of a menu widget and \fIx\fR and \fIy\fR
-are the root coordinates at which to display the menu.
-If \fIentry\fR is omitted or an empty string, the
-menu's upper left corner is positioned at the given point.
-Otherwise \fIentry\fR gives the index of an entry in \fImenu\fR and
-the menu will be positioned so that the entry is positioned over
-the given point.
-
-.SH KEYWORDS
-menu, popup
diff --git a/doc/radiobutton.n b/doc/radiobutton.n
deleted file mode 100644
index 5b4e85c..0000000
--- a/doc/radiobutton.n
+++ /dev/null
@@ -1,233 +0,0 @@
-'\"
-'\" 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: radiobutton.n,v 1.2 1998/09/14 18:22:59 stanton Exp $
-'\"
-.so man.macros
-.TH radiobutton n 4.4 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-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
-.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. The button's global variable (\fB\-variable\fR option) will
-be updated before the command is invoked.
-.OP \-height height Height
-Specifies a desired height for the button.
-If an image or bitmap is being displayed in the button then the value is in
-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.
-.OP \-indicatoron indicatorOn IndicatorOn
-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.
-.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.
-Under Windows, this color is used as the background for the indicator
-regardless of the select state.
-If \fBindicatorOn\fR is false, this color is used as the background
-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.
-.OP \-selectimage selectImage SelectImage
-Specifies an image to display (in place of the \fBimage\fR option)
-when the radiobutton is selected.
-This option is ignored unless the \fBimage\fR option has been
-specified.
-.OP \-state state State
-Specifies one of three states for the radiobutton: \fBnormal\fR, \fBactive\fR,
-or \fBdisabled\fR. In normal state the radiobutton is displayed using the
-\fBforeground\fR and \fBbackground\fR options. The active state is
-typically used when the pointer is over the radiobutton. In active state
-the radiobutton is displayed using the \fBactiveForeground\fR and
-\fBactiveBackground\fR options. Disabled state means that the radiobutton
-should be insensitive: the default bindings will refuse to activate
-the widget and will ignore mouse button presses.
-In this state the \fBdisabledForeground\fR and
-\fBbackground\fR options determine how the radiobutton is displayed.
-.OP \-value value Value
-Specifies value to store in the button's associated variable whenever
-this button is selected.
-.OP \-variable variable Variable
-Specifies name of global variable to set whenever this button is
-selected. Changes in this variable also cause the button to select
-or deselect itself.
-Defaults to the value \fBselectedButton\fR.
-.OP \-width width Width
-Specifies a desired width for the button.
-If an image or bitmap is being displayed in the button, the value is in
-screen units (i.e. any of the forms acceptable to \fBTk_GetPixels\fR);
-for text it is in characters.
-If this option isn't specified, the button's desired width is computed
-from the size of the image or bitmap or text being displayed in it.
-.BE
-
-.SH DESCRIPTION
-.PP
-The \fBradiobutton\fR command creates a new window (given by the
-\fIpathName\fR argument) and makes it into a radiobutton widget.
-Additional
-options, described above, may be specified on the command line
-or in the option database
-to configure aspects of the radiobutton such as its colors, font,
-text, and initial relief. The \fBradiobutton\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
-.VS
-A radiobutton is a widget that displays a textual string, bitmap or image
-and a diamond or circle called an \fIindicator\fR.
-.VE
-If text is displayed, it must all be in a single font, but it
-can occupy multiple lines on the screen (if it contains newlines
-or if wrapping occurs because of the \fBwrapLength\fR option) and
-one of the characters may optionally be underlined using the
-\fBunderline\fR option. A radiobutton has
-all of the behavior of a simple button: it can display itself in either
-of three different ways, according to the \fBstate\fR option;
-it can be made to appear
-raised, sunken, or flat; it can be made to flash; and it invokes
-a Tcl command whenever mouse button 1 is clicked over the
-check button.
-.PP
-In addition, radiobuttons can be \fIselected\fR.
-If a radiobutton is selected, the indicator is normally
-.VS
-drawn with a selected appearance, and
-a Tcl variable associated with the radiobutton is set to a particular
-value (normally 1).
-Under Unix, the indicator is drawn with a sunken relief and a special
-color. Under Windows, the indicator is drawn with a round mark inside.
-If the radiobutton is not selected, then the indicator is drawn with a
-deselected appearance, and the associated variable is
-set to a different value (typically 0).
-Under Unix, the indicator is drawn with a raised relief and no special
-color. Under Windows, the indicator is drawn without a round mark inside.
-.VE
-Typically, several radiobuttons share a single variable and the
-value of the variable indicates which radiobutton is to be selected.
-When a radiobutton is selected it sets the value of the variable to
-indicate that fact; each radiobutton also monitors the value of
-the variable and automatically selects and deselects itself when the
-variable's value changes.
-By default the variable \fBselectedButton\fR
-is used; its contents give the name of the button that is
-selected, or the empty string if no button associated with that
-variable is selected.
-The name of the variable for a radiobutton,
-plus the variable to be stored into it, may be modified with options
-on the command line or in the option database.
-Configuration options may also be used to modify the way the
-indicator is displayed (or whether it is displayed at all).
-By default a radiobutton is configured to select itself on button clicks.
-
-.SH "WIDGET COMMAND"
-.PP
-The \fBradiobutton\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. The following
-commands are possible for radiobutton 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 \fBradiobutton\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, 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, 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 \fBradiobutton\fR
-command.
-.TP
-\fIpathName \fBdeselect\fR
-Deselects the radiobutton and sets the associated variable to an
-empty string.
-If this radiobutton was not currently selected, the command has
-no effect.
-.TP
-\fIpathName \fBflash\fR
-Flashes the radiobutton. This is accomplished by redisplaying the radiobutton
-several times, alternating between active and normal colors. At
-the end of the flash the radiobutton is left in the same normal/active
-state as when the command was invoked.
-This command is ignored if the radiobutton's state is \fBdisabled\fR.
-.TP
-\fIpathName \fBinvoke\fR
-Does just what would have happened if the user invoked the radiobutton
-with the mouse: selects the button and invokes
-its associated Tcl command, if there is one.
-The return value is the return value from the Tcl command, or an
-empty string if there is no command associated with the radiobutton.
-This command is ignored if the radiobutton's state is \fBdisabled\fR.
-.TP
-\fIpathName \fBselect\fR
-Selects the radiobutton and sets the associated variable to the
-value corresponding to this widget.
-
-.SH BINDINGS
-.PP
-Tk automatically creates class bindings for radiobuttons that give them
-the following default behavior:
-.VS
-.IP [1]
-On Unix systems, a radiobutton activates whenever the mouse passes
-over it and deactivates whenever the mouse leaves the radiobutton. On
-Mac and Windows systems, when mouse button 1 is pressed over a
-radiobutton, the button activates whenever the mouse pointer is inside
-the button, and deactivates whenever the mouse pointer leaves the
-button.
-.VE
-.IP [2]
-When mouse button 1 is pressed over a radiobutton it is invoked (it
-becomes selected and the command associated with the button is
-invoked, if there is one).
-.IP [3]
-When a radiobutton has the input focus, the space key causes the radiobutton
-to be invoked.
-.PP
-If the radiobutton's state is \fBdisabled\fR then none of the above
-actions occur: the radiobutton is completely non-responsive.
-.PP
-The behavior of radiobuttons can be changed by defining new bindings for
-individual widgets or by redefining the class bindings.
-
-.SH KEYWORDS
-radiobutton, widget
diff --git a/doc/raise.n b/doc/raise.n
deleted file mode 100644
index 534aa12..0000000
--- a/doc/raise.n
+++ /dev/null
@@ -1,38 +0,0 @@
-'\"
-'\" Copyright (c) 1990 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: raise.n,v 1.2 1998/09/14 18:22:59 stanton Exp $
-'\"
-.so man.macros
-.TH raise n 3.3 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-raise \- Change a window's position in the stacking order
-.SH SYNOPSIS
-\fBraise \fIwindow \fR?\fIaboveThis\fR?
-.BE
-
-.SH DESCRIPTION
-.PP
-If the \fIaboveThis\fR argument is omitted then the command raises
-\fIwindow\fR so that it is above all of its siblings in the stacking
-order (it will not be obscured by any siblings and will obscure
-any siblings that overlap it).
-If \fIaboveThis\fR is specified then it must be the path name of
-a window that is either a sibling of \fIwindow\fR or the descendant
-of a sibling of \fIwindow\fR.
-In this case the \fBraise\fR command will insert
-\fIwindow\fR into the stacking order just above \fIaboveThis\fR
-(or the ancestor of \fIaboveThis\fR that is a sibling of \fIwindow\fR);
-this could end up either raising or lowering \fIwindow\fR.
-
-.SH "SEE ALSO"
-lower
-
-.SH KEYWORDS
-obscure, raise, stacking order
diff --git a/doc/scale.n b/doc/scale.n
deleted file mode 100644
index aabc7a2..0000000
--- a/doc/scale.n
+++ /dev/null
@@ -1,246 +0,0 @@
-'\"
-'\" 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: scale.n,v 1.2 1998/09/14 18:22:59 stanton Exp $
-'\"
-.so man.macros
-.TH scale n 4.1 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-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
-.SE
-.SH "WIDGET-SPECIFIC OPTIONS"
-.OP \-bigincrement bigIncrement BigIncrement
-Some interactions with the scale cause its value to change by
-``large'' increments; this option specifies the size of the
-large increments. If specified as 0, the large increments default
-to 1/10 the range of the scale.
-.OP \-command command Command
-Specifies the prefix of a Tcl command to invoke whenever the scale's
-value is changed via a widget command.
-The actual command consists
-of this option followed by a space and a real number indicating the
-new value of the scale.
-.OP \-digits digits Digits
-An integer specifying how many significant digits should be retained
-when converting the value of the scale to a string.
-If the number is less than or equal to zero, then the scale picks
-the smallest value that guarantees that every possible slider
-position prints as a different string.
-.OP \-from from From
-A real value corresponding to the left or top end of the scale.
-.OP \-label label Label
-A string to display as a label for the scale. For
-vertical scales the label is displayed just to the right of the
-top end of the scale. For horizontal scales the label is displayed
-just above the left end of the scale. If the option is specified
-as an empty string, no label is displayed.
-.OP \-length length Length
-Specifies the desired long dimension of the scale in screen units
-(i.e. any of the forms acceptable to \fBTk_GetPixels\fR).
-For vertical scales this is the scale's height; for horizontal scales
-it is the scale's width.
-.OP \-resolution resolution Resolution
-A real value specifying the resolution for the scale.
-If this value is greater than zero then the scale's value will always be
-rounded to an even multiple of this value, as will tick marks and
-the endpoints of the scale. If the value is less than zero then no
-rounding occurs. Defaults to 1 (i.e., the value will be integral).
-.OP \-showvalue showValue ShowValue
-Specifies a boolean value indicating whether or not the current
-value of the scale is to be displayed.
-.OP \-sliderlength sliderLength SliderLength
-Specfies the size of the slider, measured in screen units along the slider's
-long dimension. The value may be specified in any of the forms acceptable
-to \fBTk_GetPixels\fR.
-.OP \-sliderrelief sliderRelief SliderRelief
-Specifies the relief to use when drawing the slider, such as \fBraised\fR
-or \fBsunken\fR.
-.OP \-state state State
-Specifies one of three states for the scale: \fBnormal\fR,
-\fBactive\fR, or \fBdisabled\fR.
-If the scale is disabled then the value may not be changed and the scale
-won't activate.
-If the scale is active, the slider is displayed using the color
-specified by the \fBactiveBackground\fR option.
-.OP \-tickinterval tickInterval TickInterval
-Must be a real value.
-Determines the spacing between numerical
-tick marks displayed below or to the left of the slider.
-If 0, no tick marks will be displayed.
-.OP \-to to To
-Specifies a real value corresponding
-to the right or bottom end of the scale.
-This value may be either less than or greater than the \fBfrom\fR option.
-.OP \-variable variable Variable
-Specifies the name of a global variable to link to the scale. Whenever the
-value of the variable changes, the scale will update to reflect this
-value.
-Whenever the scale is manipulated interactively, the variable
-will be modified to reflect the scale's new value.
-.OP \-width width Width
-Specifies the desired narrow dimension of the trough in screen units
-(i.e. any of the forms acceptable to \fBTk_GetPixels\fR).
-For vertical scales this is the trough's width; for horizontal scales
-this is the trough's height.
-.BE
-
-.SH DESCRIPTION
-.PP
-The \fBscale\fR command creates a new window (given by the
-\fIpathName\fR argument) and makes it into a scale widget.
-Additional
-options, described above, may be specified on the command line
-or in the option database
-to configure aspects of the scale such as its colors, orientation,
-and relief. The \fBscale\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 scale is a widget that displays a rectangular \fItrough\fR and a
-small \fIslider\fR. The trough corresponds to a range
-of real values (determined by the \fBfrom\fR, \fBto\fR, and
-\fBresolution\fR options),
-and the position of the slider selects a particular real value.
-The slider's position (and hence the scale's value) may be adjusted
-with the mouse or keyboard as described in the BINDINGS
-section below. Whenever the scale's value is changed, a Tcl
-command is invoked (using the \fBcommand\fR option) to notify
-other interested widgets of the change.
-In addition, the value
-of the scale can be linked to a Tcl variable (using the \fBvariable\fR
-option), so that changes in either are reflected in the other.
-.PP
-Three annotations may be displayed in a scale widget: a label
-appearing at the top right of the widget (top left for horizontal
-scales), a number displayed just to the left of the slider
-(just above the slider for horizontal scales), and a collection
-of numerical tick marks just to the left of the current value
-(just below the trough for horizontal scales). Each of these three
-annotations may be enabled or disabled using the
-configuration options.
-
-.SH "WIDGET COMMAND"
-.PP
-The \fBscale\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. The following
-commands are possible for scale 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 \fBscale\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 \fBscale\fR
-command.
-.TP
-\fIpathName \fBcoords \fR?\fIvalue\fR?
-Returns a list whose elements are the x and y coordinates of
-the point along the centerline of the trough that corresponds
-to \fIvalue\fR.
-If \fIvalue\fR is omitted then the scale's current value is used.
-.TP
-\fIpathName \fBget\fR ?\fIx y\fR?
-If \fIx\fR and \fIy\fR are omitted, returns the current value
-of the scale. If \fIx\fR and \fIy\fR are specified, they give
-pixel coordinates within the widget; the command returns
-the scale value corresponding to the given pixel.
-Only one of \fIx\fR or \fIy\fR is used: for horizontal scales
-\fIy\fR is ignored, and for vertical scales \fIx\fR is ignored.
-.TP
-\fIpathName \fBidentify\fR \fIx y\fR
-Returns a string indicating what part of the scale lies under
-the coordinates given by \fIx\fR and \fIy\fR.
-A return value of \fBslider\fR means that the point is over
-the slider; \fBtrough1\fR means that the point is over the
-portion of the slider above or to the left of the slider;
-and \fBtrough2\fR means that the point is over the portion
-of the slider below or to the right of the slider.
-If the point isn't over one of these elements, an empty string
-is returned.
-.TP
-\fIpathName \fBset\fR \fIvalue\fR
-This command is invoked to change the current value of the scale,
-and hence the position at which the slider is displayed. \fIValue\fR
-gives the new value for the scale.
-The command has no effect if the scale is disabled.
-
-.SH BINDINGS
-.PP
-Tk automatically creates class bindings for scales that give them
-the following default behavior.
-Where the behavior is different for vertical and horizontal scales,
-the horizontal behavior is described in parentheses.
-.IP [1]
-If button 1 is pressed in the trough, the scale's value will
-be incremented or decremented by the value of the \fBresolution\fR
-option so that the slider moves in the direction of the cursor.
-If the button is held down, the action auto-repeats.
-.IP [2]
-If button 1 is pressed over the slider, the slider can be dragged
-with the mouse.
-.IP [3]
-If button 1 is pressed in the trough with the Control key down,
-the slider moves all the way to the end of its range, in the
-direction towards the mouse cursor.
-.IP [4]
-If button 2 is pressed, the scale's value is set to the mouse
-position. If the mouse is dragged with button 2 down, the scale's
-value changes with the drag.
-.IP [5]
-The Up and Left keys move the slider up (left) by the value
-of the \fBresolution\fR option.
-.IP [6]
-The Down and Right keys move the slider down (right) by the value
-of the \fBresolution\fR option.
-.IP [7]
-Control-Up and Control-Left move the slider up (left) by the
-value of the \fBbigIncrement\fR option.
-.IP [8]
-Control-Down and Control-Right move the slider down (right) by the
-value of the \fBbigIncrement\fR option.
-.IP [9]
-Home moves the slider to the top (left) end of its range.
-.IP [10]
-End moves the slider to the bottom (right) end of its range.
-.PP
-If the scale is disabled using the \fBstate\fR option then
-none of the above bindings have any effect.
-.PP
-The behavior of scales can be changed by defining new bindings for
-individual widgets or by redefining the class bindings.
-
-.SH KEYWORDS
-scale, slider, trough, widget
diff --git a/doc/scrollbar.n b/doc/scrollbar.n
deleted file mode 100644
index 28ba598..0000000
--- a/doc/scrollbar.n
+++ /dev/null
@@ -1,340 +0,0 @@
-'\"
-'\" 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: scrollbar.n,v 1.2 1998/09/14 18:22:59 stanton Exp $
-'\"
-.so man.macros
-.TH scrollbar n 4.1 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-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
-.SE
-.SH "WIDGET-SPECIFIC OPTIONS"
-.OP \-activerelief activeRelief ActiveRelief
-Specifies the relief to use when displaying the element that is
-active, if any.
-Elements other than the active element are always displayed with
-a raised relief.
-.OP \-command command Command
-Specifies the prefix of a Tcl command to invoke to change the view
-in the widget associated with the scrollbar. When a user requests
-a view change by manipulating the scrollbar, a Tcl command is
-invoked. The actual command consists of this option followed by
-additional information as described later. This option almost always has
-a value such as \fB.t xview\fR or \fB.t yview\fR, consisting of the
-name of a widget and either \fBxview\fR (if the scrollbar is for
-horizontal scrolling) or \fByview\fR (for vertical scrolling).
-All scrollable widgets have \fBxview\fR and \fByview\fR commands
-that take exactly the additional arguments appended by the scrollbar
-as described in SCROLLING COMMANDS below.
-.OP \-elementborderwidth elementBorderWidth BorderWidth
-Specifies the width of borders drawn around the internal elements
-of the scrollbar (the two arrows and the slider). The value may
-have any of the forms acceptable to \fBTk_GetPixels\fR.
-If this value is less than zero, the value of the \fBborderWidth\fR
-option is used in its place.
-.OP \-width width Width
-Specifies the desired narrow dimension of the scrollbar window,
-not including 3-D border, if any. For vertical
-scrollbars this will be the width and for horizontal scrollbars
-this will be the height.
-The value may have any of the forms acceptable to \fBTk_GetPixels\fR.
-.BE
-
-.SH DESCRIPTION
-.PP
-The \fBscrollbar\fR command creates a new window (given by the
-\fIpathName\fR argument) and makes it into a scrollbar widget.
-Additional options, described above, may be specified on the command
-line or in the option database to configure aspects of the scrollbar
-such as its colors, orientation, and relief.
-The \fBscrollbar\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 scrollbar is a widget that displays two arrows, one at each end of
-the scrollbar, and a \fIslider\fR in the middle portion of the
-scrollbar.
-It provides information about what is visible in an \fIassociated window\fR
-that displays an document of some sort (such as a file being edited or
-a drawing).
-The position and size of the slider indicate which portion of the
-document is visible in the associated window. For example, if the
-slider in a vertical scrollbar covers the top third of the area
-between the two arrows, it means that the associated window displays
-the top third of its document.
-.PP
-Scrollbars can be used to adjust the view in the associated window
-by clicking or dragging with the mouse. See the BINDINGS section
-below for details.
-
-.SH "ELEMENTS"
-.PP
-A scrollbar displays five elements, which are referred to in the
-widget commands for the scrollbar:
-.TP 10
-\fBarrow1\fR
-The top or left arrow in the scrollbar.
-.TP 10
-\fBtrough1\fR
-The region between the slider and \fBarrow1\fR.
-.TP 10
-\fBslider\fR
-The rectangle that indicates what is visible in the associated widget.
-.TP 10
-\fBtrough2\fR
-The region between the slider and \fBarrow2\fR.
-.TP 10
-\fBarrow2\fR
-The bottom or right arrow in the scrollbar.
-
-.SH "WIDGET COMMAND"
-.PP
-The \fBscrollbar\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. The following
-commands are possible for scrollbar widgets:
-.TP
-\fIpathName \fBactivate \fR?\fIelement\fR?
-Marks the element indicated by \fIelement\fR as active, which
-causes it to be displayed as specified by the \fBactiveBackground\fR
-and \fBactiveRelief\fR options.
-The only element values understood by this command are \fBarrow1\fR,
-\fBslider\fR, or \fBarrow2\fR.
-If any other value is specified then no element of the scrollbar
-will be active.
-If \fIelement\fR is not specified, the command returns
-the name of the element that is currently active, or an empty string
-if no element is active.
-.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 \fBscrollbar\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 \fBscrollbar\fR
-command.
-.TP
-\fIpathName \fBdelta \fIdeltaX deltaY\fR
-Returns a real number indicating the fractional change in
-the scrollbar setting that corresponds to a given change
-in slider position. For example, if the scrollbar is horizontal,
-the result indicates how much the scrollbar setting must change
-to move the slider \fIdeltaX\fR pixels to the right (\fIdeltaY\fR is
-ignored in this case).
-If the scrollbar is vertical, the result indicates how much the
-scrollbar setting must change to move the slider \fIdeltaY\fR pixels
-down. The arguments and the result may be zero or negative.
-.TP
-\fIpathName \fBfraction \fIx y\fR
-Returns a real number between 0 and 1 indicating where the point
-given by \fIx\fR and \fIy\fR lies in the trough area of the scrollbar.
-The value 0 corresponds to the top or left of the trough, the
-value 1 corresponds to the bottom or right, 0.5 corresponds to
-the middle, and so on.
-\fIX\fR and \fIy\fR must be pixel coordinates relative to the scrollbar
-widget.
-If \fIx\fR and \fIy\fR refer to a point outside the trough, the closest
-point in the trough is used.
-.TP
-\fIpathName \fBget\fR
-Returns the scrollbar settings in the form of a list whose
-elements are the arguments to the most recent \fBset\fR widget command.
-.TP
-\fIpathName \fBidentify\fR \fIx y\fR
-Returns the name of the element under the point given by \fIx\fR and
-\fIy\fR (such as \fBarrow1\fR), or an empty string if the point does
-not lie in any element of the scrollbar.
-\fIX\fR and \fIy\fR must be pixel coordinates relative to the scrollbar
-widget.
-.TP
-\fIpathName \fBset\fR \fIfirst last\fR
-This command is invoked by the scrollbar's associated widget to
-tell the scrollbar about the current view in the widget.
-The command takes two arguments, each of which is a real fraction
-between 0 and 1.
-The fractions describe the range of the document that is visible in
-the associated widget.
-For example, if \fIfirst\fR is 0.2 and \fIlast\fR is 0.4, it means
-that the first part of the document visible in the window is 20%
-of the way through the document, and the last visible part is 40%
-of the way through.
-
-.SH "SCROLLING COMMANDS"
-.PP
-When the user interacts with the scrollbar, for example by dragging
-the slider, the scrollbar notifies the associated widget that it
-must change its view.
-The scrollbar makes the notification by evaluating a Tcl command
-generated from the scrollbar's \fB\-command\fR option.
-The command may take any of the following forms.
-In each case, \fIprefix\fR is the contents of the
-\fB\-command\fR option, which usually has a form like \fB.t yview\fR
-.TP
-\fIprefix \fBmoveto \fIfraction\fR
-\fIFraction\fR is a real number between 0 and 1.
-The widget should adjust its view so that the point given
-by \fIfraction\fR appears at the beginning of the widget.
-If \fIfraction\fR is 0 it refers to the beginning of the
-document. 1.0 refers to the end of the document, 0.333
-refers to a point one-third of the way through the document,
-and so on.
-.TP
-\fIprefix \fBscroll \fInumber \fBunits\fR
-The widget should adjust its view by \fInumber\fR units.
-The units are defined in whatever way makes sense for the widget,
-such as characters or lines in a text widget.
-\fINumber\fR is either 1, which means one unit should scroll off
-the top or left of the window, or \-1, which means that one unit
-should scroll off the bottom or right of the window.
-.TP
-\fIprefix \fBscroll \fInumber \fBpages\fR
-The widget should adjust its view by \fInumber\fR pages.
-It is up to the widget to define the meaning of a page; typically
-it is slightly less than what fits in the window, so that there
-is a slight overlap between the old and new views.
-\fINumber\fR is either 1, which means the next page should
-become visible, or \-1, which means that the previous page should
-become visible.
-
-.SH "OLD COMMAND SYNTAX"
-.PP
-In versions of Tk before 4.0, the \fBset\fR and \fBget\fR widget
-commands used a different form.
-This form is still supported for backward compatibility, but it
-is deprecated.
-In the old command syntax, the \fBset\fR widget command has the
-following form:
-.TP
-\fIpathName \fBset\fR \fItotalUnits windowUnits firstUnit lastUnit\fR
-In this form the arguments are all integers.
-\fITotalUnits\fR gives the total size of the object being displayed in the
-associated widget. The meaning of one unit depends on the associated
-widget; for example, in a text editor widget units might
-correspond to lines of
-text. \fIWindowUnits\fR indicates the total number of units that
-can fit in the associated window at one time. \fIFirstUnit\fR
-and \fIlastUnit\fR give the indices of the first and last units
-currently visible in the associated window (zero corresponds to the
-first unit of the object).
-.LP
-Under the old syntax the \fBget\fR widget command returns a list
-of four integers, consisting of the \fItotalUnits\fR, \fIwindowUnits\fR,
-\fIfirstUnit\fR, and \fIlastUnit\fR values from the last \fBset\fR
-widget command.
-.PP
-The commands generated by scrollbars also have a different form
-when the old syntax is being used:
-.TP
-\fIprefix\fR \fIunit\fR
-\fIUnit\fR is an integer that indicates what should appear at
-the top or left of the associated widget's window.
-It has the same meaning as the \fIfirstUnit\fR and \fIlastUnit\fR
-arguments to the \fBset\fR widget command.
-.LP
-The most recent \fBset\fR widget command determines whether or not
-to use the old syntax.
-If it is given two real arguments then the new syntax will be
-used in the future, and if it is given four integer arguments then
-the old syntax will be used.
-
-.SH BINDINGS
-Tk automatically creates class bindings for scrollbars that give them
-the following default behavior.
-If the behavior is different for vertical and horizontal scrollbars,
-the horizontal behavior is described in parentheses.
-
-.IP [1]
-Pressing button 1 over \fBarrow1\fR causes the view in the
-associated widget to shift up (left) by one unit so that the
-document appears to move down (right) one unit.
-If the button is held down, the action auto-repeats.
-.IP [2]
-Pressing button 1 over \fBtrough1\fR causes the view in the
-associated widget to shift up (left) by one screenful so that the
-document appears to move down (right) one screenful.
-If the button is held down, the action auto-repeats.
-.IP [3]
-Pressing button 1 over the slider and dragging causes the view
-to drag with the slider.
-If the \fBjump\fR option is true, then the view doesn't drag along
-with the slider; it changes only when the mouse button is released.
-.IP [4]
-Pressing button 1 over \fBtrough2\fR causes the view in the
-associated widget to shift down (right) by one screenful so that the
-document appears to move up (left) one screenful.
-If the button is held down, the action auto-repeats.
-.IP [5]
-Pressing button 1 over \fBarrow2\fR causes the view in the
-associated widget to shift down (right) by one unit so that the
-document appears to move up (left) one unit.
-If the button is held down, the action auto-repeats.
-.IP [6]
-If button 2 is pressed over the trough or the slider, it sets
-the view to correspond to the mouse position; dragging the
-mouse with button 2 down causes the view to drag with the mouse.
-If button 2 is pressed over one of the arrows, it causes the
-same behavior as pressing button 1.
-.IP [7]
-If button 1 is pressed with the Control key down, then if the
-mouse is over \fBarrow1\fR or \fBtrough1\fR the view changes
-to the very top (left) of the document; if the mouse is over
-\fBarrow2\fR or \fBtrough2\fR the view changes
-to the very bottom (right) of the document; if the mouse is
-anywhere else then the button press has no effect.
-.IP [8]
-In vertical scrollbars the Up and Down keys have the same behavior
-as mouse clicks over \fBarrow1\fR and \fBarrow2\fR, respectively.
-In horizontal scrollbars these keys have no effect.
-.IP [9]
-In vertical scrollbars Control-Up and Control-Down have the same
-behavior as mouse clicks over \fBtrough1\fR and \fBtrough2\fR, respectively.
-In horizontal scrollbars these keys have no effect.
-.IP [10]
-In horizontal scrollbars the Up and Down keys have the same behavior
-as mouse clicks over \fBarrow1\fR and \fBarrow2\fR, respectively.
-In vertical scrollbars these keys have no effect.
-.IP [11]
-In horizontal scrollbars Control-Up and Control-Down have the same
-behavior as mouse clicks over \fBtrough1\fR and \fBtrough2\fR, respectively.
-In vertical scrollbars these keys have no effect.
-.IP [12]
-The Prior and Next keys have the same behavior
-as mouse clicks over \fBtrough1\fR and \fBtrough2\fR, respectively.
-.IP [13]
-The Home key adjusts the view to the top (left edge) of the document.
-.IP [14]
-The End key adjusts the view to the bottom (right edge) of the document.
-
-.SH KEYWORDS
-scrollbar, widget
diff --git a/doc/selection.n b/doc/selection.n
deleted file mode 100644
index f6caddd..0000000
--- a/doc/selection.n
+++ /dev/null
@@ -1,128 +0,0 @@
-'\"
-'\" 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: selection.n,v 1.2 1998/09/14 18:22:59 stanton Exp $
-'\"
-.so man.macros
-.TH selection n 4.0 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-selection \- Manipulate the X selection
-.SH SYNOPSIS
-\fBselection \fIoption\fR ?\fIarg arg ...\fR?
-.BE
-
-.SH DESCRIPTION
-.PP
-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
-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:
-.PP
-.TP
-\fBselection clear\fR ?\fB\-displayof\fR \fIwindow\fR? ?\fB\-selection\fR \fIselection\fR?
-If \fIselection\fR exists anywhere on \fIwindow\fR's display, clear it
-so that no window owns the selection anymore. \fISelection\fR
-specifies the X selection that should be cleared, and should be an
-atom name such as PRIMARY or CLIPBOARD; see the Inter-Client
-Communication Conventions Manual for complete details.
-\fISelection\fR defaults to PRIMARY and \fIwindow\fR defaults to ``.''.
-Returns an empty string.
-.TP
-\fBselection get\fR ?\fB\-displayof\fR \fIwindow\fR? ?\fB\-selection\fR \fIselection\fR? ?\fB\-type\fR \fItype\fR?
-Retrieves the value of \fIselection\fR from \fIwindow\fR's display and
-returns it as a result. \fISelection\fR defaults to PRIMARY and
-\fIwindow\fR defaults to ``.''.
-\fIType\fR specifies the form in which the selection is to be returned
-(the desired ``target'' for conversion, in ICCCM terminology), and
-should be an atom name such as STRING or FILE_NAME; see the
-Inter-Client Communication Conventions Manual for complete details.
-\fIType\fR defaults to STRING. The selection owner may choose to
-return the selection in any of several different representation
-formats, such as STRING, ATOM, INTEGER, etc. (this format is different
-than the selection type; see the ICCCM for all the confusing details).
-If the selection is returned in a non-string format, such as INTEGER
-or ATOM, the \fBselection\fR command converts it to string format as a
-collection of fields separated by spaces: atoms are converted to their
-textual names, and anything else is converted to hexadecimal integers.
-.TP
-\fBselection handle\fR ?\fB\-selection\fR \fIselection\fR? ?\fB\-type\fR \fItype\fR? ?\fB\-format\fR \fIformat\fR? \fIwindow command\fR
-Creates a handler for selection requests, such that \fIcommand\fR will
-be executed whenever \fIselection\fR is owned by \fIwindow\fR and
-someone attempts to retrieve it in the form given by \fItype\fR
-(e.g. \fItype\fR is specified in the \fBselection get\fR command).
-\fISelection\fR defaults to PRIMARY, \fItype\fR defaults to STRING, and
-\fIformat\fR defaults to STRING. If \fIcommand\fR is an empty string
-then any existing handler for \fIwindow\fR, \fItype\fR, and
-\fIselection\fR is removed.
-.RS
-.PP
-When \fIselection\fR is requested, \fIwindow\fR is the selection owner,
-and \fItype\fR is the requested type, \fIcommand\fR will be executed
-as a Tcl command with two additional numbers appended to it
-(with space separators).
-The two additional numbers
-are \fIoffset\fR and \fImaxBytes\fR: \fIoffset\fR specifies a starting
-character position in the selection and \fImaxBytes\fR gives the maximum
-number of bytes to retrieve. The command should return a value consisting
-of at most \fImaxBytes\fR of the selection, starting at position
-\fIoffset\fR. For very large selections (larger than \fImaxBytes\fR)
-the selection will be retrieved using several invocations of \fIcommand\fR
-with increasing \fIoffset\fR values. If \fIcommand\fR returns a string
-whose length is less than \fImaxBytes\fR, the return value is assumed to
-include all of the remainder of the selection; if the length of
-\fIcommand\fR's result is equal to \fImaxBytes\fR then
-\fIcommand\fR will be invoked again, until it eventually
-returns a result shorter than \fImaxBytes\fR. The value of \fImaxBytes\fR
-will always be relatively large (thousands of bytes).
-.PP
-If \fIcommand\fR returns an error then the selection retrieval is rejected
-just as if the selection didn't exist at all.
-.PP
-The \fIformat\fR argument specifies the representation that should be
-used to transmit the selection to the requester (the second column of
-Table 2 of the ICCCM), and defaults to STRING. If \fIformat\fR is
-STRING, the selection is transmitted as 8-bit ASCII characters (i.e.
-just in the form returned by \fIcommand\fR). If \fIformat\fR is
-ATOM, then the return value from \fIcommand\fR is divided into fields
-separated by white space; each field is converted to its atom value,
-and the 32-bit atom value is transmitted instead of the atom name.
-For any other \fIformat\fR, the return value from \fIcommand\fR is
-divided into fields separated by white space and each field is
-converted to a 32-bit integer; an array of integers is transmitted
-to the selection requester.
-.PP
-The \fIformat\fR argument is needed only for compatibility with
-selection requesters that don't use Tk. If Tk is being
-used to retrieve the selection then the value is converted back to
-a string at the requesting end, so \fIformat\fR is
-irrelevant.
-.RE
-.TP
-\fBselection own\fR ?\fB\-displayof\fR \fIwindow\fR? ?\fB\-selection\fR \fIselection\fR?
-.TP
-\fBselection own\fR ?\fB\-command\fR \fIcommand\fR? ?\fB\-selection\fR \fIselection\fR? \fIwindow\fR
-The first form of \fBselection own\fR returns the path name of the
-window in this application that owns \fIselection\fR on the display
-containing \fIwindow\fR, or an empty string if no window in this
-application owns the selection. \fISelection\fR defaults to PRIMARY and
-\fIwindow\fR defaults to ``.''.
-.PP
-The second form of \fBselection own\fR causes \fIwindow\fR to become
-the new owner of \fIselection\fR on \fIwindow\fR's display, returning
-an empty string as result. The existing owner, if any, is notified
-that it has lost the selection.
-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 KEYWORDS
-clear, format, handler, ICCCM, own, selection, target, type
diff --git a/doc/send.n b/doc/send.n
deleted file mode 100644
index 51ad739..0000000
--- a/doc/send.n
+++ /dev/null
@@ -1,92 +0,0 @@
-'\"
-'\" 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: send.n,v 1.2 1998/09/14 18:23:00 stanton Exp $
-'\"
-.so man.macros
-.TH send n 4.0 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-send \- Execute a command in a different application
-.SH SYNOPSIS
-\fBsend ?\fIoptions\fR? \fIapp cmd \fR?\fIarg arg ...\fR?
-.BE
-
-.SH DESCRIPTION
-.PP
-This command arranges for \fIcmd\fR (and \fIarg\fRs) to be executed in the
-application named by \fIapp\fR. It returns the result or
-error from that command execution.
-\fIApp\fR may be the name of any application whose main window is
-on the display containing the sender's main window; it need not
-be within the same process.
-If no \fIarg\fR arguments are present, then the command to be executed is
-contained entirely within the \fIcmd\fR argument. If one or
-more \fIarg\fRs are present, they are concatenated to form the
-command to be executed, just as for the \fBeval\fR command.
-.PP
-If the initial arguments of the command begin with ``\-''
-they are treated as options. The following options are
-currently defined:
-.TP
-\fB\-async\fR
-Requests asynchronous invocation. In this case the \fBsend\fR
-command will complete immediately without waiting for \fIcmd\fR
-to complete in the target application; no result will be available
-and errors in the sent command will be ignored.
-If the target application is in the same process as the sending
-application then the \fB\-async\fR option is ignored.
-.TP
-\fB\-displayof\fR \fIpathName\fR
-Specifies that the target application's main window is on the display
-of the window given by \fIpathName\fR, instead of the display containing
-the application's main window.
-.TP
-\fB\-\|\-\fR
-Serves no purpose except to terminate the list of options. This
-option is needed only if \fIapp\fR could contain a leading ``\-''
-character.
-
-.SH "APPLICATION NAMES"
-.PP
-The name of an application is set initially from the name of the
-program or script that created the application.
-You can query and change the name of an application with the
-\fBtk appname\fR command.
-
-.SH "DISABLING SENDS"
-.PP
-If the \fBsend\fR command is removed from an application (e.g.
-with the command \fBrename send {}\fR) then the application
-will not respond to incoming send requests anymore, nor will it
-be able to issue outgoing requests.
-Communication can be reenabled by invoking the \fBtk appname\fR
-command.
-
-.SH SECURITY
-.PP
-The \fBsend\fR command is potentially a serious security loophole,
-since any application that can connect to your X server can send
-scripts to your applications.
-These incoming scripts can use Tcl to read and
-write your files and invoke subprocesses under your name.
-Host-based access control such as that provided by \fBxhost\fR
-is particularly insecure, since it allows anyone with an account
-on particular hosts to connect to your server, and if disabled it
-allows anyone anywhere to connect to your server.
-In order to provide at least a small amount of
-security, Tk checks the access control being used by the server
-and rejects incoming sends unless (a) \fBxhost\fR-style access control
-is enabled (i.e. only certain hosts can establish connections) and (b) the
-list of enabled hosts is empty.
-This means that applications cannot connect to your server unless
-they use some other form of authorization
-such as that provide by \fBxauth\fR.
-
-.SH KEYWORDS
-application, name, remote execution, security, send
diff --git a/doc/text.n b/doc/text.n
deleted file mode 100644
index b577d5a..0000000
--- a/doc/text.n
+++ /dev/null
@@ -1,1621 +0,0 @@
-'\"
-'\" 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: text.n,v 1.2 1998/09/14 18:23:00 stanton Exp $
-'\"
-.so man.macros
-.TH text n 4.0 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-text \- Create and manipulate text widgets
-.SH SYNOPSIS
-\fBtext\fR \fIpathName \fR?\fIoptions\fR?
-.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
-.SE
-.SH "WIDGET-SPECIFIC OPTIONS"
-.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 \-spacing1 spacing1 Spacing1
-Requests additional space above each text line in the widget,
-using any of the standard forms for screen distances.
-If a line wraps, this option only applies to the first line
-on the display.
-This option may be overriden with \fB\-spacing1\fR options in
-tags.
-.OP \-spacing2 spacing2 Spacing2
-For lines that wrap (so that they cover more than one line on the
-display) this option specifies additional space to provide between
-the display lines that represent a single line of text.
-The value may have any of the standard forms for screen distances.
-This option may be overriden with \fB\-spacing2\fR options in
-tags.
-.OP \-spacing3 spacing3 Spacing3
-Requests additional space below each text line in the widget,
-using any of the standard forms for screen distances.
-If a line wraps, this option only applies to the last line
-on the display.
-This option may be overriden with \fB\-spacing3\fR options in
-tags.
-.OP \-state state State
-Specifies one of two states for the text: \fBnormal\fR or \fBdisabled\fR.
-If the text is disabled then characters may not be inserted or deleted
-and no insertion cursor will be displayed, even if the input focus is
-in the widget.
-.OP \-tabs tabs Tabs
-Specifies a set of tab stops for the window. The option's value consists
-of a list of screen distances giving the positions of the tab stops. Each
-position may optionally be followed in the next list element
-by one of the keywords \fBleft\fR, \fBright\fR, \fBcenter\fR,
-or \fBnumeric\fR, which specifies how to justify
-text relative to the tab stop. \fBLeft\fR is the default; it causes
-the text following the tab character to be positioned with its left edge
-at the tab position. \fBRight\fR means that the right edge of the text
-following the tab character is positioned at the tab position, and
-\fBcenter\fR means that the text is centered at the tab position.
-\fBNumeric\fR means that the decimal point in the text is positioned
-at the tab position; if there is no decimal point then the least
-significant digit of the number is positioned just to the left of the
-tab position; if there is no number in the text then the text is
-right-justified at the tab position.
-For example, \fB\-tabs {2c left 4c 6c center}\fR creates three
-tab stops at two-centimeter intervals; the first two use left
-justification and the third uses center justification.
-If the list of tab stops does not have enough elements to cover all
-of the tabs in a text line, then Tk extrapolates new tab stops using
-the spacing and alignment from the last tab stop in the list.
-The value of the \fBtabs\fR option may be overridden by \fB\-tabs\fR
-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 \-width width Width
-Specifies the desired width for the window in units of characters
-in the font given by the \fB\-font\fR option.
-If the font doesn't have a uniform width then the width of the
-character ``0'' is used in translating from character units to
-screen units.
-.OP \-wrap wrap Wrap
-Specifies how to handle lines in the text that are too long to be
-displayed in a single line of the text's window.
-The value must be \fBnone\fR or \fBchar\fR or \fBword\fR.
-A wrap mode of \fBnone\fR means that each line of text appears as
-exactly one line on the screen; extra characters that don't fit
-on the screen are not displayed.
-In the other modes each line of text will be broken up into several
-screen lines if necessary to keep all the characters visible.
-In \fBchar\fR mode a screen line break may occur after any character;
-in \fBword\fR mode a line break will only be made at word boundaries.
-.BE
-
-.SH DESCRIPTION
-.PP
-The \fBtext\fR command creates a new window (given by the
-\fIpathName\fR argument) and makes it into a text widget.
-Additional
-options, described above, may be specified on the command line
-or in the option database
-to configure aspects of the text such as its default background color
-and relief. The \fBtext\fR command returns the
-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
-that scripts are invoked when particular actions such as keystrokes
-and mouse button presses occur in particular ranges of the text.
-See TAGS below for more details.
-.PP
-The second form of annotation consists of marks, which are floating
-markers in the text.
-Marks are used to keep track of various interesting positions in the
-text as it is edited.
-See MARKS below for more details.
-.PP
-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
-
-.SH INDICES
-.PP
-Many of the widget commands for texts take one or more indices
-as arguments.
-An index is a string used to indicate a particular place within
-a text, such as a place to insert characters or one endpoint of a
-range of characters to delete.
-Indices have the syntax
-.CS
-\fIbase modifier modifier modifier ...\fR
-.CE
-Where \fIbase\fR gives a starting point and the \fImodifier\fRs
-adjust the index from the starting point (e.g. move forward or
-backward one character). Every index must contain a \fIbase\fR,
-but the \fImodifier\fRs are optional.
-.PP
-The \fIbase\fR for an index must have one of the following forms:
-.TP 12
-\fIline\fB.\fIchar\fR
-Indicates \fIchar\fR'th character on line \fIline\fR.
-Lines are numbered from 1 for consistency with other UNIX programs
-that use this numbering scheme.
-Within a line, characters are numbered from 0.
-If \fIchar\fR is \fBend\fR then it refers to the newline character
-that ends the line.
-.TP 12
-\fB@\fIx\fB,\fIy\fR
-Indicates the character that covers the pixel whose x and y coordinates
-within the text's window are \fIx\fR and \fIy\fR.
-.TP 12
-\fBend\fR
-Indicates the end of the text (the character just after the last
-newline).
-.TP 12
-\fImark\fR
-Indicates the character just after the mark whose name is \fImark\fR.
-.TP 12
-\fItag\fB.first\fR
-Indicates the first character in the text that has been tagged with
-\fItag\fR.
-This form generates an error if no characters are currently tagged
-with \fItag\fR.
-.TP 12
-\fItag\fB.last\fR
-Indicates the character just after the last one in the text that has
-been tagged with \fItag\fR.
-This form generates an error if no characters are currently tagged
-with \fItag\fR.
-.TP 12
-\fIpathName\fR
-Indicates the position of the embedded window whose name is
-\fIpathName\fR.
-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
-the form earlier in the above list takes precedence.
-If modifiers follow the base index, each one of them must have one
-of the forms listed below. Keywords such as \fBchars\fR and \fBwordend\fR
-may be abbreviated as long as the abbreviation is unambiguous.
-.TP
-\fB+ \fIcount\fB chars\fR
-Adjust the index forward by \fIcount\fR characters, moving to later
-lines in the text if necessary. If there are fewer than \fIcount\fR
-characters in the text after the current index, then set the index
-to the last character in the text.
-Spaces on either side of \fIcount\fR are optional.
-.TP
-\fB\- \fIcount\fB chars\fR
-Adjust the index backward by \fIcount\fR characters, moving to earlier
-lines in the text if necessary. If there are fewer than \fIcount\fR
-characters in the text before the current index, then set the index
-to the first character in the text.
-Spaces on either side of \fIcount\fR are optional.
-.TP
-\fB+ \fIcount\fB lines\fR
-Adjust the index forward by \fIcount\fR lines, retaining the same
-character position within the line. If there are fewer than \fIcount\fR
-lines after the line containing the current index, then set the index
-to refer to the same character position on the last line of the text.
-Then, if the line is not long enough to contain a character at the indicated
-character position, adjust the character position to refer to the last
-character of the line (the newline).
-Spaces on either side of \fIcount\fR are optional.
-.TP
-\fB\- \fIcount\fB lines\fR
-Adjust the index backward by \fIcount\fR lines, retaining the same
-character position within the line. If there are fewer than \fIcount\fR
-lines before the line containing the current index, then set the index
-to refer to the same character position on the first line of the text.
-Then, if the line is not long enough to contain a character at the indicated
-character position, adjust the character position to refer to the last
-character of the line (the newline).
-Spaces on either side of \fIcount\fR are optional.
-.TP
-\fBlinestart\fR
-Adjust the index to refer to the first character on the line.
-.TP
-\fBlineend\fR
-Adjust the index to refer to the last character on the line (the newline).
-.TP
-\fBwordstart\fR
-Adjust the index to refer to the first character of the word containing
-the current index. A word consists of any number of adjacent characters
-that are letters, digits, or underscores, or a single character that
-is not one of these.
-.TP
-\fBwordend\fR
-Adjust the index to refer to the character just after the last one of the
-word containing the current index. If the current index refers to the last
-character of the text then it is not modified.
-.PP
-If more than one modifier is present then they are applied in
-left-to-right order. For example, the index ``\fBend \- 1 chars\fR''
-refers to the next-to-last character in the text and
-``\fBinsert wordstart \- 1 c\fR'' refers to the character just before
-the first one in the word containing the insertion cursor.
-
-.SH TAGS
-.PP
-The first form of annotation in text widgets is a tag.
-A tag is a textual string that is associated with some of the characters
-in a text.
-Tags may contain arbitrary characters, but it is probably best to
-avoid using the the characters `` '' (space), \fB+\fR, or \fB\-\fR:
-these characters have special meaning in indices, so tags containing
-them can't be used as indices.
-There may be any number of tags associated with characters in a
-text.
-Each tag may refer to a single character, a range of characters, or
-several ranges of characters.
-An individual character may have any number of tags associated with it.
-.PP
-A priority order is defined among tags, and this order is used in
-implementing some of the tag-related functions described below.
-When a tag is defined (by associating it with characters or setting
-its display options or binding commands to it), it is given
-a priority higher than any existing tag.
-The priority order of tags may be redefined using the
-``\fIpathName \fBtag raise\fR'' and ``\fIpathName \fBtag lower\fR''
-widget commands.
-.PP
-Tags serve three purposes in text widgets.
-First, they control the way information is displayed on the screen.
-By default, characters are displayed as determined by the
-\fBbackground\fR, \fBfont\fR, and \fBforeground\fR options for the
-text widget.
-However, display options may be associated with individual tags
-using the ``\fIpathName \fBtag configure\fR'' widget command.
-If a character has been tagged, then the display options associated
-with the tag override the default display style.
-The following options are currently supported for tags:
-.TP
-\fB\-background \fIcolor\fR
-\fIColor\fR specifies the background color to use for characters
-associated with the tag.
-It may have any of the forms accepted by \fBTk_GetColor\fR.
-.TP
-\fB\-bgstipple \fIbitmap\fR
-\fIBitmap\fR specifies a bitmap that is used as a stipple pattern
-for the background.
-It may have any of the forms accepted by \fBTk_GetBitmap\fR.
-If \fIbitmap\fR hasn't been specified, or if it is specified
-as an empty string, then a solid fill will be used for the
-background.
-.TP
-\fB\-borderwidth \fIpixels\fR
-\fIPixels\fR specifies the width of a 3-D border to draw around
-the background.
-It may have any of the forms accepted by \fBTk_GetPixels\fR.
-This option is used in conjunction with the \fB\-relief\fR
-option to give a 3-D appearance to the background for characters;
-it is ignored unless the \fB\-background\fR option
-has been set for the tag.
-.TP
-\fB\-fgstipple \fIbitmap\fR
-\fIBitmap\fR specifies a bitmap that is used as a stipple pattern
-when drawing text and other foreground information such as
-underlines.
-It may have any of the forms accepted by \fBTk_GetBitmap\fR.
-If \fIbitmap\fR hasn't been specified, or if it is specified
-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.
-.TP
-\fB\-foreground \fIcolor\fR
-\fIColor\fR specifies the color to use when drawing text and other
-foreground information such as underlines.
-It may have any of the forms accepted by \fBTk_GetColor\fR.
-.TP
-\fB\-justify \fIjustify\fR
-If the first character of a display line has a tag for which this
-option has been specified, then \fIjustify\fR determines how to
-justify the line.
-It must be one of \fBleft\fR, \fBright\fR, or \fBcenter\fR.
-If a line wraps, then the justification for each line on the
-display is determined by the first character of that display line.
-.TP
-\fB\-lmargin1 \fIpixels\fR
-If the first character of a text line has a tag for which this
-option has been specified, then \fIpixels\fR specifies how
-much the line should be indented from the left edge of the
-window.
-\fIPixels\fR may have any of the standard forms for screen
-distances.
-If a line of text wraps, this option only applies to the
-first line on the display; the \fB\-lmargin2\fR option controls
-the indentation for subsequent lines.
-.TP
-\fB\-lmargin2 \fIpixels\fR
-If the first character of a display line has a tag for which this
-option has been specified, and if the display line is not the
-first for its text line (i.e., the text line has wrapped), then
-\fIpixels\fR specifies how much the line should be indented from
-the left edge of the window.
-\fIPixels\fR may have any of the standard forms for screen
-distances.
-This option is only used when wrapping is enabled, and it only
-applies to the second and later display lines for a text line.
-.TP
-\fB\-offset \fIpixels\fR
-\fIPixels\fR specifies an amount by which the text's baseline
-should be offset vertically from the baseline of the overall
-line, in pixels.
-For example, a positive offset can be used for superscripts
-and a negative offset can be used for subscripts.
-\fIPixels\fR may have any of the standard forms for screen
-distances.
-.TP
-\fB\-overstrike \fIboolean\fR
-Specifies whether or not to draw a horizontal rule through
-the middle of characters.
-\fIBoolean\fR may have any of the forms accepted by \fBTk_GetBoolean\fR.
-.TP
-\fB\-relief \fIrelief\fR
-\fIRelief\fR specifies the 3-D relief to use for drawing backgrounds,
-in any of the forms accepted by \fBTk_GetRelief\fR.
-This option is used in conjunction with the \fB\-borderwidth\fR
-option to give a 3-D appearance to the background for characters;
-it is ignored unless the \fB\-background\fR option
-has been set for the tag.
-.TP
-\fB\-rmargin \fIpixels\fR
-If the first character of a display line has a tag for which this
-option has been specified, then \fIpixels\fR specifies how wide
-a margin to leave between the end of the line and the right
-edge of the window.
-\fIPixels\fR may have any of the standard forms for screen
-distances.
-This option is only used when wrapping is enabled.
-If a text line wraps, the right margin for each line on the
-display is determined by the first character of that display
-line.
-.TP
-\fB\-spacing1 \fIpixels\fR
-\fIPixels\fR specifies how much additional space should be
-left above each text line, using any of the standard forms for
-screen distances.
-If a line wraps, this option only applies to the first
-line on the display.
-.TP
-\fB\-spacing2 \fIpixels\fR
-For lines that wrap, this option specifies how much additional
-space to leave between the display lines for a single text line.
-\fIPixels\fR may have any of the standard forms for screen
-distances.
-.TP
-\fB\-spacing3 \fIpixels\fR
-\fIPixels\fR specifies how much additional space should be
-left below each text line, using any of the standard forms for
-screen distances.
-If a line wraps, this option only applies to the last
-line on the display.
-.TP
-\fB\-tabs \fItabList\fR
-\fITabList\fR specifies a set of tab stops in the same form
-as for the \fB\-tabs\fR option for the text widget. This
-option only applies to a display line if it applies to the
-first character on that display line.
-If this option is specified as an empty string, it cancels
-the option, leaving it unspecified for the tag (the default).
-If the option is specified as a non-empty string that is
-an empty list, such as \fB\-tags\0{\0}\fR, then it requests
-default 8-character tabs as described for the \fBtags\fR
-widget option.
-.TP
-\fB\-underline \fIboolean\fR
-\fIBoolean\fR specifies whether or not to draw an underline underneath
-characters.
-It may have any of the forms accepted by \fBTk_GetBoolean\fR.
-.TP
-\fB\-wrap \fImode\fR
-\fIMode\fR specifies how to handle lines that are wider than the
-text's window.
-It has the same legal values as the \fB\-wrap\fR option
-for the text widget: \fBnone\fR, \fBchar\fR, or \fBword\fR.
-If this tag option is specified, it overrides the \fB\-wrap\fR option
-for the text widget.
-.PP
-If a character has several tags associated with it, and if their
-display options conflict, then the options of the highest priority
-tag are used.
-If a particular display option hasn't been specified for a
-particular tag, or if it is specified as an empty string, then
-that option will never be used; the next-highest-priority
-tag's option will used instead.
-If no tag specifies a particular display option, then the default
-style for the widget will be used.
-.PP
-The second purpose for tags is event bindings.
-You can associate bindings with a tag in much the same way you can
-associate bindings with a widget class: whenever particular X
-events occur on characters with the given tag, a given
-Tcl command will be executed.
-Tag bindings can be used to give behaviors to ranges of characters;
-among other things, this allows hypertext-like
-features to be implemented.
-For details, see the description of the \fBtag bind\fR widget
-command below.
-.PP
-The third use for tags is in managing the selection.
-See THE SELECTION below.
-
-.SH MARKS
-.PP
-The second form of annotation in text widgets is a mark.
-Marks are used for remembering particular places in a text.
-They are something like tags, in that they have names and
-they refer to places in the file, but a mark isn't associated
-with particular characters.
-Instead, a mark is associated with the gap between two characters.
-Only a single position may be associated with a mark at any given
-time.
-If the characters around a mark are deleted the mark will still
-remain; it will just have new neighbor characters.
-In contrast, if the characters containing a tag are deleted then
-the tag will no longer have an association with characters in
-the file.
-Marks may be manipulated with the ``\fIpathName \fBmark\fR'' widget
-command, and their current locations may be determined by using the
-mark name as an index in widget commands.
-.PP
-Each mark also has a \fIgravity\fR, which is either \fBleft\fR or
-\fBright\fR.
-The gravity for a mark specifies what happens to the mark when
-text is inserted at the point of the mark.
-If a mark has left gravity, then the mark is treated as if it
-were attached to the character on its left, so the mark will
-remain to the left of any text inserted at the mark position.
-If the mark has right gravity, new text inserted at the mark
-position will appear to the right of the mark. The gravity
-for a mark defaults to \fBright\fR.
-.PP
-The name space for marks is different from that for tags: the
-same name may be used for both a mark and a tag, but they will refer
-to different things.
-.PP
-Two marks have special significance.
-First, the mark \fBinsert\fR is associated with the insertion cursor,
-as described under THE INSERTION CURSOR below.
-Second, the mark \fBcurrent\fR is associated with the character
-closest to the mouse and is adjusted automatically to track the
-mouse position and any changes to the text in the widget (one
-exception: \fBcurrent\fR is not updated in response to mouse
-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
-.PP
-The third form of annotation in text widgets is an embedded window.
-Each embedded window annotation causes a window to be displayed
-at a particular point in the text.
-There may be any number of embedded windows in a text widget,
-and any widget may be used as an embedded window (subject to the
-usual rules for geometry management, which require the text window
-to be the parent of the embedded window or a descendant of its
-parent).
-The embedded window's position on the screen will be updated as the
-text is modified or scrolled, and it will be mapped and unmapped as
-it moves into and out of the visible area of the text widget.
-Each embedded window occupies one character's worth of index space
-in the text widget, and it may be referred to either by the name
-of its embedded window or by its position in the widget's
-index space.
-If the range of text containing the embedded window is deleted then
-the window is destroyed.
-.PP
-When an embedded window is added to a text widget with the
-\fBwindow create\fR widget command, several configuration
-options may be associated with it.
-These options may be modified later with the \fBwindow configure\fR
-widget command.
-The following options are currently supported:
-.TP
-\fB\-align \fIwhere\fR
-If the window is not as tall as the line in which it is displayed,
-this option determines where the window is displayed in the line.
-\fIWhere\fR must have one of the values \fBtop\fR (align the top of the window
-with the top of the line), \fBcenter\fR (center the window
-within the range of the line), \fBbottom\fR (align the bottom of the
-window with the bottom of the line's area),
-or \fBbaseline\fR (align the bottom of the window with the baseline
-of the line).
-.TP
-\fB\-create \fIscript\fR
-Specifies a Tcl script that may be evaluated to create the window
-for the annotation.
-If no \fB\-window\fR option has been specified for the annotation
-this script will be evaluated when the annotation is about to
-be displayed on the screen.
-\fIScript\fR must create a window for the annotation and return
-the name of that window as its result.
-If the annotation's window should ever be deleted, \fIscript\fR
-will be evaluated again the next time the annotation is displayed.
-.TP
-\fB\-padx \fIpixels\fR
-\fIPixels\fR specifies the amount of extra space to leave on
-each side of the embedded window.
-It may have any of the usual forms defined for a screen distance.
-.TP
-\fB\-pady \fIpixels\fR
-\fIPixels\fR specifies the amount of extra space to leave on
-the top and on the bottom of the embedded window.
-It may have any of the usual forms defined for a screen distance.
-.TP
-\fB\-stretch \fIboolean\fR
-If the requested height of the embedded window is less than the
-height of the line in which it is displayed, this option can be
-used to specify whether the window should be stretched vertically
-to fill its line.
-If the \fB\-pady\fR option has been specified as well, then the
-requested padding will be retained even if the window is
-stretched.
-.TP
-\fB\-window \fIpathName\fR
-Specifies the name of a window to display in the annotation.
-
-.VS
-.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
-at a particular point in the text.
-There may be any number of embedded images in a text widget,
-and a particular image may be embedded in multiple places in the same
-text widget.
-The embedded image's position on the screen will be updated as the
-text is modified or scrolled.
-Each embedded image occupies one character's worth of index space
-in the text widget, and it may be referred to either by
-its position in the widget's index space, or the name it is assigned
-when the image is inserted into the text widget widh \fBimage create\fP.
-If the range of text containing the embedded image is deleted then
-that copy of the image is removed from the screen.
-.PP
-When an embedded image is added to a text widget with the \fBimage
-create\fR widget command, a name unique to this instance of the image
-is returned. This name may then be used to refer to this image
-instance. The name is taken to be the value of the \fB-name\fP option
-(described below). If the \fB-name\fP option is not provided, the
-\fB-image\fP name is used instead. If the \fIimageName\fP is already
-in use in the text widget, then \fB#\fInn\fR is added to the end of the
-\fIimageName\fP, where \fInn\fP is an arbitrary integer. This insures
-the \fIimageName\fP is unique.
-Once this name is assigned to this instance of the image, it does not
-change, even though the \fB-image\fP or \fB-name\fP values can be changed
-with \fBimage configure\fP.
-.PP
-When an embedded image is added to a text widget with the
-\fBimage create\fR widget command, several configuration
-options may be associated with it.
-These options may be modified later with the \fBimage configure\fR
-widget command.
-The following options are currently supported:
-.TP
-\fB\-align \fIwhere\fR
-If the image is not as tall as the line in which it is displayed,
-this option determines where the image is displayed in the line.
-\fIWhere\fR must have one of the values \fBtop\fR (align the top of the image
-with the top of the line), \fBcenter\fR (center the image
-within the range of the line), \fBbottom\fR (align the bottom of the
-image with the bottom of the line's area),
-or \fBbaseline\fR (align the bottom of the image with the baseline
-of the line).
-.TP
-\fB\-image \fIimage\fR
-Specifies the name of the Tk image to display in the annotation.
-If \fIimage\fP is not a valid Tk image, then an error is returned.
-.TP
-\fB\-name \fIImageName\fR
-Specifies the name by which this image instance may be referenced in
-the text widget. If \fIImageName\fP is not supplied, then the
-name of the Tk image is used instead.
-If the \fIimageName\fP is already in use, \fI#nn\fP is appended to
-the end of the name as described above.
-.TP
-\fB\-padx \fIpixels\fR
-\fIPixels\fR specifies the amount of extra space to leave on
-each side of the embedded image.
-It may have any of the usual forms defined for a screen distance.
-.TP
-\fB\-pady \fIpixels\fR
-\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
-.PP
-Selection support is implemented via tags.
-If the \fBexportSelection\fR option for the text widget is true
-then the \fBsel\fR tag will be associated with the selection:
-.IP [1]
-Whenever characters are tagged with \fBsel\fR the text widget
-will claim ownership of the selection.
-.IP [2]
-Attempts to retrieve the
-selection will be serviced by the text widget, returning all the
-characters with the \fBsel\fR tag.
-.IP [3]
-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.
-.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''
-widget command. Furthermore, the \fBselectBackground\fR,
-\fBselectBorderWidth\fR, and \fBselectForeground\fR options for
-the text widget are tied to the \fB\-background\fR,
-\fB\-borderwidth\fR, and \fB\-foreground\fR options for the \fBsel\fR
-tag: changes in either will automatically be reflected in the
-other.
-
-.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
-may not be unset with the ``\fIpathName \fBmark unset\fR'' widget
-command.
-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 "WIDGET COMMAND"
-.PP
-The \fBtext\fR command creates a new Tcl command whose
-name is the same as the path name of the text'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 text widget's path name. \fIOption\fR and the \fIarg\fRs
-determine the exact behavior of the command. The following
-commands are possible for text widgets:
-.TP
-\fIpathName \fBbbox \fIindex\fR
-Returns a list of four elements describing the screen area
-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 area occupied by the
-character, and the last two elements give the width and height
-of the area.
-If the character is only partially visible on the screen, then
-the return value reflects just the visible part.
-If the character is not visible on the screen then the return
-value is an empty list.
-.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 \fBtext\fR
-command.
-.TP
-\fIpathName \fBcompare\fR \fIindex1 op index2\fR
-Compares the indices given by \fIindex1\fR and \fIindex2\fR according
-to the relational operator given by \fIop\fR, and returns 1 if
-the relationship is satisfied and 0 if it isn't.
-\fIOp\fR must be one of the operators <, <=, ==, >=, >, or !=.
-If \fIop\fR is == then 1 is returned if the two indices refer to
-the same character, if \fIop\fR is < then 1 is returned if \fIindex1\fR
-refers to an earlier character in the text than \fIindex2\fR, and
-so on.
-.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 \fBtext\fR
-command.
-.TP
-\fIpathName \fBdebug \fR?\fIboolean\fR?
-If \fIboolean\fR is specified, then it must have one of the true or
-false values accepted by Tcl_GetBoolean.
-If the value is a true one then internal consistency checks will be
-turned on in the B-tree code associated with text widgets.
-If \fIboolean\fR has a false value then the debugging checks will
-be turned off.
-In either case the command returns an empty string.
-If \fIboolean\fR is not specified then the command returns \fBon\fR
-or \fBoff\fR to indicate whether or not debugging is turned on.
-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?
-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
-and stopping just before \fIindex2\fR (i.e. the character at
-\fIindex2\fR is not deleted).
-If \fIindex2\fR doesn't specify a position later in the text
-than \fIindex1\fR then no characters are deleted.
-If \fIindex2\fR isn't specified then the single character at
-\fIindex1\fR is deleted.
-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.
-.TP
-\fIpathName \fBdlineinfo \fIindex\fR
-Returns a list with five elements describing the area occupied
-by the display line containing \fIindex\fR.
-The first two elements of the list give the x and y coordinates
-of the upper-left corner of the area occupied by the
-line, the third and fourth elements give the width and height
-of the area, and the fifth element gives the position of the baseline
-for the line, measured down from the top of the area.
-All of this information is measured in pixels.
-If the current wrap mode is \fBnone\fR and the line extends beyond
-the boundaries of the window,
-the area returned reflects the entire area of the line, including the
-portions that are out of the window.
-If the line is shorter than the full width of the window then the
-area returned reflects just the portion of the line that is occupied
-by characters and embedded windows.
-If the display line containing \fIindex\fR is not visible on
-the screen then the return value is an empty list.
-.TP
-\fIpathName \fBdump \fR?\fIswitches\fR? \fIindex1 \fR?\fIindex2\fR?
-Return the contents of the text widget from \fIindex1\fR up to,
-but not including \fIindex2\fR,
-including the text and
-information about marks, tags, and embedded windows.
-If \fIindex2\fR is not specified, then it defaults to
-one character past \fIindex1\fR. The information is returned
-in the following format:
-.LP
-.RS
-\fIkey1 value1 index1 key2 value2 index2\fR ...
-.LP
-The possible \fIkey\fP values are \fBtext\fP, \fBmark\fP,
-\fBtagon\fP, \fBtagoff\fP, and \fBwindow\fP. The corresponding
-\fIvalue\fP is the text, mark name, tag name, or window name.
-The \fIindex\fP information is the index of the
-start of the text, the mark, the tag transition, or the window.
-One or more of the following switches (or abbreviations thereof)
-may be specified to control the dump:
-.TP
-\fB\-all\fR
-Return information about all elements: text, marks, tags, and windows.
-This is the default.
-.TP
-\fB\-command \fIcommand\fR
-Instead of returning the information as the result of the dump operation,
-invoke the \fIcommand\fR on each element of the text widget within the range.
-The command has three arguments appended to it before it is evaluated:
-the \fIkey\fP, \fIvalue\fP, and \fIindex\fP.
-.TP
-\fB\-mark\fR
-Include information about marks in the dump results.
-.TP
-\fB\-tag\fR
-Include information about tag transitions in the dump results. Tag information is
-returned as \fBtagon\fP and \fBtagoff\fP elements that indicate the
-begin and end of each range of each tag, respectively.
-.TP
-\fB\-text\fR
-Include information about text in the dump results. The value is the
-text up to the next element or the end of range indicated by \fIindex2\fR.
-A text element does not span newlines. A multi-line block of text that
-contains no marks or tag transitions will still be dumped as a set
-of text seqments that each end with a newline. The newline is part
-of the value.
-.TP
-\fB\-window\fR
-Include information about embedded windows in the dump results.
-The value of a window is its Tk pathname, unless the window
-has not been created yet. (It must have a create script.)
-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?
-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
-the one whose index is \fIindex2\fR (the character at \fIindex2\fR
-will not be returned).
-If \fIindex2\fR is omitted then the single character at \fIindex1\fR
-is returned.
-If there are no characters in the specified range (e.g. \fIindex1\fR
-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.
-.TP
-\fIpathName \fBimage \fIoption \fR?\fIarg arg ...\fR?
-This command is used to manipulate embedded images.
-The behavior of the command depends on the \fIoption\fR argument
-that follows the \fBtag\fR argument.
-The following forms of the command are currently supported:
-.RS
-.TP
-\fIpathName \fBimage cget\fR \fIindex option\fR
-Returns the value of a configuration option for an embedded image.
-\fIIndex\fR identifies the embedded image, and \fIoption\fR
-specifies a particular configuration option, which must be one of
-the ones listed in the section EMBEDDED IMAGES.
-.TP
-\fIpathName \fBimage configure \fIindex\fR ?\fIoption value ...\fR?
-Query or modify the configuration options for an embedded image.
-If no \fIoption\fR is specified, returns a list describing all of
-the available options for the embedded image at \fIindex\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 option(s) to have the given value(s); in
-this case the command returns an empty string.
-See EMBEDDED IMAGES for information on the options that
-are supported.
-.TP
-\fIpathName \fBimage create \fIindex\fR ?\fIoption value ...\fR?
-This command creates a new image annotation, which will appear
-in the text at the position given by \fIindex\fR.
-Any number of \fIoption\-value\fR pairs may be specified to
-configure the annotation.
-Returns a unique identifier that may be used as an index to refer to
-this image.
-See EMBEDDED IMAGES for information on the options that
-are supported, and a description of the identifier returned.
-.TP
-\fIpathName \fBimage names\fR
-Returns a list whose elements are the names of all image instances currently
-embedded in \fIwindow\fR.
-.RE
-.TP
-\fIpathName \fBindex \fIindex\fR
-Returns the position corresponding to \fIindex\fR in the form
-\fIline.char\fR where \fIline\fR is the line number and \fIchar\fR
-is the character number.
-\fIIndex\fR may have any of the forms described under INDICES above.
-.TP
-\fIpathName \fBinsert \fIindex chars \fR?\fItagList chars tagList ...\fR?
-Inserts all of the \fIchars\fR arguments just before the character at
-\fIindex\fR.
-If \fIindex\fR refers to the end of the text (the character after
-the last newline) then the new text is inserted just before the
-last newline instead.
-If there is a single \fIchars\fR argument and no \fItagList\fR, then
-the new text will receive any tags that are present on both the
-character before and the character after the insertion point; if a tag
-is present on only one of these characters then it will not be
-applied to the new text.
-If \fItagList\fR is specified then it consists of a list of
-tag names; the new characters will receive all of the tags in
-this list and no others, regardless of the tags present around
-the insertion point.
-If multiple \fIchars\fR\-\fItagList\fR argument pairs are present,
-they produce the same effect as if a separate \fBinsert\fR widget
-command had been issued for each pair, in order.
-The last \fItagList\fR argument may be omitted.
-.TP
-\fIpathName \fBmark \fIoption \fR?\fIarg arg ...\fR?
-This command is used to manipulate marks. The exact behavior of
-the command depends on the \fIoption\fR argument that follows
-the \fBmark\fR argument. The following forms of the command
-are currently supported:
-.RS
-.TP
-\fIpathName \fBmark gravity \fImarkName\fR ?\fIdirection\fR?
-If \fIdirection\fR is not specified, returns \fBleft\fR or \fBright\fR
-to indicate which of its adjacent characters \fImarkName\fR is attached
-to.
-If \fIdirection\fR is specified, it must be \fBleft\fR or \fBright\fR;
-the gravity of \fImarkName\fR is set to the given value.
-.TP
-\fIpathName \fBmark names\fR
-Returns a list whose elements are the names of all the marks that
-are currently set.
-.TP
-\fIpathName \fBmark next \fIindex\fR
-Returns the name of the next mark at or after \fIindex\fR.
-If \fIindex\fR is specified in numerical form, then the search for
-the next mark begins at that index.
-If \fIindex\fR is the name of a mark, then the search for
-the next mark begins immediately after that mark.
-This can still return a mark at the same position if
-there are multiple marks at the same index.
-These semantics mean that the \fBmark next\fP operation can be used to
-step through all the marks in a text widget in the same order
-as the mark information returned by the \fBdump\fP operation.
-If a mark has been set to the special \fBend\fP index,
-then it appears to be \fIafter\fP \fBend\fP with respect to the \fBmark next\fP operation.
-An empty string is returned if there are no marks after \fIindex\fR.
-.TP
-\fIpathName \fBmark previous \fIindex\fR
-Returns the name of the mark at or before \fIindex\fR.
-If \fIindex\fR is specified in numerical form, then the search for
-the previous mark begins with the character just before that index.
-If \fIindex\fR is the name of a mark, then the search for
-the next mark begins immediately before that mark.
-This can still return a mark at the same position if
-there are multiple marks at the same index.
-These semantics mean that the \fBmark previous\fP operation can be used to
-step through all the marks in a text widget in the reverse order
-as the mark information returned by the \fBdump\fP operation.
-An empty string is returned if there are no marks before \fIindex\fR.
-.TP
-\fIpathName \fBmark set \fImarkName index\fR
-Sets the mark named \fImarkName\fR to a position just before the
-character at \fIindex\fR.
-If \fImarkName\fR already exists, it is moved from its old position;
-if it doesn't exist, a new mark is created.
-This command returns an empty string.
-.TP
-\fIpathName \fBmark unset \fImarkName \fR?\fImarkName markName ...\fR?
-Remove the mark corresponding to each of the \fImarkName\fR arguments.
-The removed marks will not be usable in indices and will not be
-returned by future calls to ``\fIpathName \fBmark names\fR''.
-This command returns an empty string.
-.RE
-.TP
-\fIpathName \fBscan\fR \fIoption args\fR
-This command is used to implement scanning on texts. It has
-two forms, depending on \fIoption\fR:
-.RS
-.TP
-\fIpathName \fBscan mark \fIx y\fR
-Records \fIx\fR and \fIy\fR and the current view in the text window,
-for use 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 y\fR
-This command computes the difference between its \fIx\fR and \fIy\fR
-arguments and the \fIx\fR and \fIy\fR arguments to the last
-\fBscan mark\fR command for the widget.
-It then adjusts the view by 10 times the difference in coordinates.
-This command is typically associated
-with mouse motion events in the widget, to produce the effect of
-dragging the text at high speed through the window. The return
-value is an empty string.
-.RE
-.TP
-\fIpathName \fBsearch \fR?\fIswitches\fR? \fIpattern index \fR?\fIstopIndex\fR?
-Searches the text in \fIpathName\fR starting at \fIindex\fR for a range
-of characters that matches \fIpattern\fR.
-If a match is found, the index of the first character in the match is
-returned as result; otherwise an empty string is returned.
-One or more of the following switches (or abbreviations thereof)
-may be specified to control the search:
-.RS
-.TP
-\fB\-forwards\fR
-The search will proceed forward through the text, finding the first
-matching range starting at or after the position given by \fIindex\fR.
-This is the default.
-.TP
-\fB\-backwards\fR
-The search will proceed backward through the text, finding the
-matching range closest to \fIindex\fR whose first character
-is before \fIindex\fR.
-.TP
-\fB\-exact\fR
-Use exact matching: the characters in the matching range must be
-identical to those in \fIpattern\fR.
-This is the default.
-.TP
-\fB\-regexp\fR
-Treat \fIpattern\fR as a regular expression and match it against
-the text using the rules for regular expressions (see the \fBregexp\fR
-command for details).
-.TP
-\fB\-nocase\fR
-Ignore case differences between the pattern and the text.
-.TP
-\fB\-count\fI varName\fR
-The argument following \fB\-count\fR gives the name of a variable;
-if a match is found, the number of characters in the matching
-range will be stored in the variable.
-.TP
-\fB\-\|\-\fR
-This switch has no effect except to terminate the list of switches:
-the next argument will be treated as \fIpattern\fR even if it starts
-with \fB\-\fR.
-.LP
-The matching range must be entirely within a single line of text.
-For regular expression matching the newlines are removed from the ends
-of the lines before matching: use the \fB$\fR feature in regular
-expressions to match the end of a line.
-For exact matching the newlines are retained.
-If \fIstopIndex\fR is specified, the search stops at that index:
-for forward searches, no match at or after \fIstopIndex\fR will
-be considered; for backward searches, no match earlier in the
-text than \fIstopIndex\fR will be considered.
-If \fIstopIndex\fR is omitted, the entire text will be searched:
-when the beginning or end of the text is reached, the search
-continues at the other end until the starting location is reached
-again; if \fIstopIndex\fR is specified, no wrap-around will occur.
-.RE
-.TP
-\fIpathName \fBsee \fIindex\fR
-Adjusts the view in the window so that the character given by \fIindex\fR
-is completely visible.
-If \fIindex\fR is already visible then the command does nothing.
-If \fIindex\fR is a short distance out of view, the command
-adjusts the view just enough to make \fIindex\fR visible at the
-edge of the window.
-If \fIindex\fR is far out of view, then the command centers
-\fIindex\fR in the window.
-.TP
-\fIpathName \fBtag \fIoption \fR?\fIarg arg ...\fR?
-This command is used to manipulate tags. The exact behavior of the
-command depends on the \fIoption\fR argument that follows the
-\fBtag\fR argument. The following forms of the command are currently
-supported:
-.RS
-.TP
-\fIpathName \fBtag add \fItagName index1 \fR?\fIindex2 index1 index2 ...\fR?
-Associate the tag \fItagName\fR with all of the characters starting
-with \fIindex1\fR and ending just before
-\fIindex2\fR (the character at \fIindex2\fR isn't tagged).
-A single command may contain any number of \fIindex1\fR\-\fIindex2\fR
-pairs.
-If the last \fIindex2\fR is omitted then the single character at
-\fIindex1\fR is tagged.
-If there are no characters in the specified range (e.g. \fIindex1\fR
-is past the end of the file or \fIindex2\fR is less than or equal
-to \fIindex1\fR) then the command has no effect.
-.TP
-\fIpathName \fBtag bind \fItagName\fR ?\fIsequence\fR? ?\fIscript\fR?
-This command associates \fIscript\fR with the tag given by
-\fItagName\fR.
-Whenever the event sequence given by \fIsequence\fR occurs for a
-character that has been tagged with \fItagName\fR,
-the script will be invoked.
-This widget command is similar to the \fBbind\fR command except that
-it operates on characters in a text rather than entire widgets.
-See the \fBbind\fR manual entry for complete details
-on the syntax of \fIsequence\fR and the substitutions performed
-on \fIscript\fR before invoking it.
-If all arguments are specified then a new binding is created, replacing
-any existing binding for the same \fIsequence\fR and \fItagName\fR
-(if the first character of \fIscript\fR is ``+'' then \fIscript\fR
-augments an existing binding rather than replacing it).
-In this case the return value is an empty string.
-If \fIscript\fR is omitted then the command returns the \fIscript\fR
-associated with \fItagName\fR and \fIsequence\fR (an error occurs
-if there is no such binding).
-If both \fIscript\fR and \fIsequence\fR are omitted then the command
-returns a list of all the sequences for which bindings have been
-defined for \fItagName\fR.
-.RS
-.PP
-.VS
-The only events for which bindings may be specified are those related
-to the mouse and keyboard (such as \fBEnter\fR, \fBLeave\fR,
-\fBButtonPress\fR, \fBMotion\fR, and \fBKeyPress\fR) or virtual events.
-Event bindings for a text widget use the \fBcurrent\fR mark described
-under MARKS above. An \fBEnter\fR event triggers for a tag when the tag
-first becomes present on the current character, and a \fBLeave\fR event
-triggers for a tag when it ceases to be present on the current character.
-\fBEnter\fR and \fBLeave\fR events can happen either because the
-\fBcurrent\fR mark moved or because the character at that position
-changed. Note that these events are different than \fBEnter\fR and
-\fBLeave\fR events for windows. Mouse and keyboard events are directed
-to the current character. If a virtual event is used in a binding, that
-binding can trigger only if the virtual event is defined by an underlying
-mouse-related or keyboard-related event.
-.VE
-.PP
-It is possible for the current character to have multiple tags,
-and for each of them to have a binding for a particular event
-sequence.
-When this occurs, one binding is invoked for each tag, in order
-from lowest-priority to highest priority.
-If there are multiple matching bindings for a single tag, then
-the most specific binding is chosen (see the manual entry for
-the \fBbind\fR command for details).
-\fBcontinue\fR and \fBbreak\fR commands within binding scripts
-are processed in the same way as for bindings created with
-the \fBbind\fR command.
-.PP
-If bindings are created for the widget as a whole using the
-\fBbind\fR command, then those bindings will supplement the
-tag bindings.
-The tag bindings will be invoked first, followed by bindings
-for the window as a whole.
-.RE
-.TP
-\fIpathName \fBtag cget\fR \fItagName option\fR
-This command returns the current value of the option named \fIoption\fR
-associated with the tag given by \fItagName\fR.
-\fIOption\fR may have any of the values accepted by the \fBtag configure\fR
-widget command.
-.TP
-\fIpathName \fBtag configure \fItagName\fR ?\fIoption\fR? ?\fIvalue\fR? ?\fIoption value ...\fR?
-This command is similar to the \fBconfigure\fR widget command except
-that it modifies options associated with the tag given by \fItagName\fR
-instead of modifying options for the overall text widget.
-If no \fIoption\fR is specified, the command returns a list describing
-all of the available options for \fItagName\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 option(s) to have the given value(s) in \fItagName\fR;
-in this case the command returns an empty string.
-See TAGS above for details on the options available for tags.
-.TP
-\fIpathName \fBtag delete \fItagName \fR?\fItagName ...\fR?
-Deletes all tag information for each of the \fItagName\fR
-arguments.
-The command removes the tags from all characters in the file
-and also deletes any other information associated with the tags,
-such as bindings and display information.
-The command returns an empty string.
-.TP
-\fIpathName\fB tag lower \fItagName \fR?\fIbelowThis\fR?
-Changes the priority of tag \fItagName\fR so that it is just lower
-in priority than the tag whose name is \fIbelowThis\fR.
-If \fIbelowThis\fR is omitted, then \fItagName\fR's priority
-is changed to make it lowest priority of all tags.
-.TP
-\fIpathName \fBtag names \fR?\fIindex\fR?
-Returns a list whose elements are the names of all the tags that
-are active at the character position given by \fIindex\fR.
-If \fIindex\fR is omitted, then the return value will describe
-all of the tags that exist for the text (this includes all tags
-that have been named in a ``\fIpathName \fBtag\fR'' widget
-command but haven't been deleted by a ``\fIpathName \fBtag delete\fR''
-widget command, even if no characters are currently marked with
-the tag).
-The list will be sorted in order from lowest priority to highest
-priority.
-.TP
-\fIpathName \fBtag nextrange \fItagName index1 \fR?\fIindex2\fR?
-This command searches the text for a range of characters tagged
-with \fItagName\fR where the first character of the range is
-no earlier than the character at \fIindex1\fR and no later than
-the character just before \fIindex2\fR (a range starting at
-\fIindex2\fR will not be considered).
-If several matching ranges exist, the first one is chosen.
-The command's return value is a list containing
-two elements, which are the index of the first character of the
-range and the index of the character just after the last one in
-the range.
-If no matching range is found then the return value is an
-empty string.
-If \fIindex2\fR is not given then it defaults to the end of the text.
-.TP
-\fIpathName \fBtag prevrange \fItagName index1 \fR?\fIindex2\fR?
-This command searches the text for a range of characters tagged
-with \fItagName\fR where the first character of the range is
-before the character at \fIindex1\fR and no earlier than
-the character at \fIindex2\fR (a range starting at
-\fIindex2\fR will be considered).
-If several matching ranges exist, the one closest to \fIindex1\fR is chosen.
-The command's return value is a list containing
-two elements, which are the index of the first character of the
-range and the index of the character just after the last one in
-the range.
-If no matching range is found then the return value is an
-empty string.
-If \fIindex2\fR is not given then it defaults to the beginning of the text.
-.TP
-\fIpathName\fB tag raise \fItagName \fR?\fIaboveThis\fR?
-Changes the priority of tag \fItagName\fR so that it is just higher
-in priority than the tag whose name is \fIaboveThis\fR.
-If \fIaboveThis\fR is omitted, then \fItagName\fR's priority
-is changed to make it highest priority of all tags.
-.TP
-\fIpathName \fBtag ranges \fItagName\fR
-Returns a list describing all of the ranges of text that have been
-tagged with \fItagName\fR.
-The first two elements of the list describe the first tagged range
-in the text, the next two elements describe the second range, and
-so on.
-The first element of each pair contains the index of the first
-character of the range, and the second element of the pair contains
-the index of the character just after the last one in the
-range.
-If there are no characters tagged with \fItag\fR then an
-empty string is returned.
-.TP
-\fIpathName \fBtag remove \fItagName index1 \fR?\fIindex2 index1 index2 ...\fR?
-Remove the tag \fItagName\fR from all of the characters starting
-at \fIindex1\fR and ending just before
-\fIindex2\fR (the character at \fIindex2\fR isn't affected).
-A single command may contain any number of \fIindex1\fR\-\fIindex2\fR
-pairs.
-If the last \fIindex2\fR is omitted then the single character at
-\fIindex1\fR is tagged.
-If there are no characters in the specified range (e.g. \fIindex1\fR
-is past the end of the file or \fIindex2\fR is less than or equal
-to \fIindex1\fR) then the command has no effect.
-This command returns an empty string.
-.RE
-.TP
-\fIpathName \fBwindow \fIoption \fR?\fIarg arg ...\fR?
-This command is used to manipulate embedded windows.
-The behavior of the command depends on the \fIoption\fR argument
-that follows the \fBtag\fR argument.
-The following forms of the command are currently supported:
-.RS
-.TP
-\fIpathName \fBwindow cget\fR \fIindex option\fR
-Returns the value of a configuration option for an embedded window.
-\fIIndex\fR identifies the embedded window, and \fIoption\fR
-specifies a particular configuration option, which must be one of
-the ones listed in the section EMBEDDED WINDOWS.
-.TP
-\fIpathName \fBwindow configure \fIindex\fR ?\fIoption value ...\fR?
-Query or modify the configuration options for an embedded window.
-If no \fIoption\fR is specified, returns a list describing all of
-the available options for the embedded window at \fIindex\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 option(s) to have the given value(s); in
-this case the command returns an empty string.
-See EMBEDDED WINDOWS for information on the options that
-are supported.
-.TP
-\fIpathName \fBwindow create \fIindex\fR ?\fIoption value ...\fR?
-This command creates a new window annotation, which will appear
-in the text at the position given by \fIindex\fR.
-Any number of \fIoption\-value\fR pairs may be specified to
-configure the annotation.
-See EMBEDDED WINDOWS for information on the options that
-are supported.
-Returns an empty string.
-.TP
-\fIpathName \fBwindow names\fR
-Returns a list whose elements are the names of all windows currently
-embedded in \fIwindow\fR.
-.RE
-.TP
-\fIpathName \fBxview \fIoption args\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 portion of the document's 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 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.
-The fractions refer only to the lines that are actually visible in the
-window: if the lines in the window are all very short, so that they
-are entirely visible, the returned fractions will be 0 and 1,
-even if there are other lines in the text that are
-much wider than the window.
-These are the same values passed to scrollbars via the \fB\-xscrollcommand\fR
-option.
-.TP
-\fIpathName \fBxview moveto\fI fraction\fR
-Adjusts the view in the window so that \fIfraction\fR of the horizontal
-span of the text is off-screen to the left.
-\fIFraction\fR is 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
-.TP
-\fIpathName \fByview \fI?args\fR?
-This command is used to query and change the vertical position of the
-text in the widget's window.
-It can take any of the following forms:
-.RS
-.TP
-\fIpathName \fByview\fR
-Returns a list containing two elements, both of which are real fractions
-between 0 and 1.
-The first element gives the position of the first character in the
-top line in the window, relative to the text as a whole (0.5 means
-it is halfway through the text, for example).
-The second element gives the position of the character just after
-the last one in the bottom line of the window,
-relative to the text as a whole.
-These are the same values passed to scrollbars via the \fB\-yscrollcommand\fR
-option.
-.TP
-\fIpathName \fByview moveto\fI fraction\fR
-Adjusts the view in the window so that the character given by \fIfraction\fR
-appears on the top line of the window.
-\fIFraction\fR is a fraction between 0 and 1; 0 indicates the first
-character in the text, 0.33 indicates the character one-third the
-way through the text, and so on.
-.TP
-\fIpathName \fByview scroll \fInumber what\fR
-This command adjust the view in the window up or down according to
-\fInumber\fR and \fIwhat\fR.
-\fINumber\fR must be an integer.
-\fIWhat\fR must be either \fBunits\fR or \fBpages\fR.
-If \fIwhat\fR is \fBunits\fR, the view adjusts up or down by
-\fInumber\fR lines on the display; if it is \fBpages\fR then
-the view adjusts by \fInumber\fR screenfuls.
-If \fInumber\fR is negative then earlier positions in the text
-become visible; if it is positive then later positions in the text
-become visible.
-.TP
-\fIpathName \fByview \fR?\fB\-pickplace\fR? \fIindex\fR
-Changes the view in the widget's window to make \fIindex\fR visible.
-If the \fB\-pickplace\fR option isn't specified then \fIindex\fR will
-appear at the top of the window.
-If \fB\-pickplace\fR is specified then the widget chooses where
-\fIindex\fR appears in the window:
-.RS
-.IP [1]
-If \fIindex\fR is already visible somewhere in the window then the
-command does nothing.
-.IP [2]
-If \fIindex\fR is only a few lines off-screen above the window then
-it will be positioned at the top of the window.
-.IP [3]
-If \fIindex\fR is only a few lines off-screen below the window then
-it will be positioned at the bottom of the window.
-.IP [4]
-Otherwise, \fIindex\fR will be centered in the window.
-.LP
-The \fB\-pickplace\fR option has been obsoleted by the \fBsee\fR widget
-command (\fBsee\fR handles both x- and y-motion to make a location
-visible, whereas \fB\-pickplace\fR only handles motion in y).
-.RE
-.TP
-\fIpathName \fByview \fInumber\fR
-This command makes the first character on the line after
-the one given by \fInumber\fR visible at the top of the window.
-\fINumber\fR must be an integer.
-This command used to be used for scrolling, but now it is obsolete.
-.RE
-
-.SH BINDINGS
-.PP
-Tk automatically creates class bindings for texts 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 the line under the mouse
-and positions the insertion cursor at the beginning of the line.
-Dragging after a triple click will stroke out a selection consisting
-of whole lines.
-.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; if it is triple-clicked
-then the selection will be adjusted in units of whole lines.
-.IP [5]
-Clicking mouse button 1 with the Control key down will reposition the
-insertion cursor without affecting the selection.
-.IP [6]
-If any normal printing characters are typed, they are
-inserted at the point of the insertion cursor.
-.IP [7]
-The view in the widget can be adjusted by dragging with mouse button 2.
-If mouse button 2 is clicked without moving the mouse, the selection
-is copied into the text at the position of the mouse cursor.
-The Insert key also inserts the selection, but at the position of
-the insertion cursor.
-.IP [8]
-If the mouse is dragged out of the widget
-while button 1 is pressed, the entry will automatically scroll to
-make more text visible (if there is more text 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 text.
-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 Up and Down keys move the insertion cursor one line up or
-down and clear any selection in the text.
-If Up 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-Up and Control-Down move the insertion cursor by paragraphs (groups
-of lines separated by blank lines), and
-Control-Shift-Up and Control-Shift-Down move the insertion cursor
-by paragraphs and also extend the selection.
-Control-p and Control-n behave the same as Up and Down, respectively.
-.IP [11]
-The Next and Prior keys move the insertion cursor forward or backwards
-by one screenful and clear any selection in the text.
-If the Shift key is held down while Next or Prior is typed, then
-the selection is extended to include the new character.
-Control-v moves the view down one screenful without moving the
-insertion cursor or adjusting the selection.
-.IP [12]
-Control-Next and Control-Prior scroll the view right or left by one page
-without moving the insertion cursor or affecting the selection.
-.IP [13]
-Home and Control-a move the insertion cursor to the
-beginning of its line and clear any selection in the widget.
-Shift-Home moves the insertion cursor to the beginning of the line
-and also extends the selection to that point.
-.IP [14]
-End and Control-e move the insertion cursor to the
-end of the line and clear any selection in the widget.
-Shift-End moves the cursor to the end of the line and extends the selection
-to that point.
-.IP [15]
-Control-Home and Meta-< move the insertion cursor to the beginning of
-the text and clear any selection in the widget.
-Control-Shift-Home moves the insertion cursor to the beginning of the text
-and also extends the selection to that point.
-.IP [16]
-Control-End and Meta-> move the insertion cursor to the end of the
-text and clear any selection in the widget.
-Control-Shift-End moves the cursor to the end of the text and extends
-the selection to that point.
-.IP [17]
-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 [18]
-Control-/ selects the entire contents of the widget.
-.IP [19]
-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.
-.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.
-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.
-.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
-the insertion cursor.
-.IP [24]
-Backspace and Control-h delete the selection, if there is one
-in the widget.
-If there is no selection, they delete the character to the left of
-the insertion cursor.
-.IP [25]
-Control-d deletes the character to the right of the insertion cursor.
-.IP [26]
-Meta-d deletes the word to the right of the insertion cursor.
-.IP [27]
-Control-k deletes from the insertion cursor to the end of its line;
-if the insertion cursor is already at the end of a line, then
-Control-k deletes the newline character.
-.IP [28]
-Control-o opens a new line by inserting a newline character in
-front of the insertion cursor without moving the insertion cursor.
-.IP [29]
-Meta-backspace and Meta-Delete delete the word to the left of the
-insertion cursor.
-.IP [30]
-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.
-.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,
-but no insertion cursor will be displayed and no text modifications will
-take place.
-.PP
-The behavior of texts can be changed by defining new bindings for
-individual widgets or by redefining the class bindings.
-
-.SH "PERFORMANCE ISSUES"
-.PP
-Text widgets should run efficiently under a variety
-of conditions. The text widget uses about 2-3 bytes of
-main memory for each byte of text, so texts containing a megabyte
-or more should be practical on most workstations.
-Text is represented internally with a modified B-tree structure
-that makes operations relatively efficient even with large texts.
-Tags are included in the B-tree structure in a way that allows
-tags to span large ranges or have many disjoint smaller ranges
-without loss of efficiency.
-Marks are also implemented in a way that allows large numbers of
-marks.
-In most cases it is fine to have large numbers of unique tags,
-or a tag that has many distinct ranges.
-.PP
-One performance problem can arise if you have hundreds or thousands
-of different tags that all have the following characteristics:
-the first and last ranges of each tag are near the beginning and
-end of the text, respectively,
-or a single tag range covers most of the text widget.
-The cost of adding and deleting tags like this is proportional
-to the number of other tags with the same properties.
-In contrast, there is no problem with having thousands of distinct
-tags if their overall ranges are localized and spread uniformly throughout
-the text.
-.PP
-Very long text lines can be expensive,
-especially if they have many marks and tags within them.
-.PP
-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
diff --git a/doc/tk.n b/doc/tk.n
deleted file mode 100644
index 9c1b110..0000000
--- a/doc/tk.n
+++ /dev/null
@@ -1,72 +0,0 @@
-'\"
-'\" 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: tk.n,v 1.2 1998/09/14 18:23:00 stanton Exp $
-'\"
-.so man.macros
-.TH tk n 4.0 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-tk \- Manipulate Tk internal state
-.SH SYNOPSIS
-\fBtk\fR \fIoption \fR?\fIarg arg ...\fR?
-.BE
-
-.SH DESCRIPTION
-.PP
-The \fBtk\fR command provides access to miscellaneous
-elements of Tk's internal state.
-Most of the information manipulated by this command pertains to the
-application as a whole, or to a screen or display, rather than to a
-particular window.
-The command can take any of a number of different forms
-depending on the \fIoption\fR argument. The legal forms are:
-.TP
-\fBtk appname \fR?\fInewName\fR?
-If \fInewName\fR isn't specified, this command returns the name
-of the application (the name that may be used in \fBsend\fR
-commands to communicate with the application).
-If \fInewName\fR is specified, then the name of the application
-is changed to \fInewName\fR.
-If the given name is already in use, then a suffix of the form
-``\fB #2\fR'' or ``\fB #3\fR'' is appended in order to make the name unique.
-The command's result is the name actually chosen.
-\fInewName\fR should not start with a capital letter.
-This will interfere with option processing, since names starting with
-capitals are assumed to be classes; as a result, Tk may not
-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
-.TP
-\fBtk scaling \fR?\fB\-displayof \fIwindow\fR? ?\fInumber\fR?
-.
-Sets and queries the current scaling factor used by Tk to convert between
-physical units (for example, points, inches, or millimeters) and pixels. The
-\fInumber\fR argument is a floating point number that specifies the number of
-pixels per point on \fIwindow\fR's display. If the \fIwindow\fR argument is
-omitted, it defaults to the main window. If the \fInumber\fR argument is
-omitted, the current value of the scaling factor is returned.
-.RS
-.PP
-A ``point'' is a unit of measurement equal to 1/72 inch. A scaling factor
-of 1.0 corresponds to 1 pixel per point, which is equivalent to a standard
-72 dpi monitor. A scaling factor of 1.25 would mean 1.25 pixels per point,
-which is the setting for a 90 dpi monitor; setting the scaling factor to
-1.25 on a 72 dpi monitor would cause everything in the application to be
-displayed 1.25 times as large as normal. The initial value for the scaling
-factor is set when the application starts, based on properties of the
-installed monitor, but it can be changed at any time. Measurements made
-after the scaling factor is changed will use the new scaling factor, but it
-is undefined whether existing widgets will resize themselves dynamically to
-accomodate the new scaling factor.
-.RE
-.VE
-.SH KEYWORDS
-application name, send
diff --git a/doc/tk4.0.ps b/doc/tk4.0.ps
deleted file mode 100644
index d79642d..0000000
--- a/doc/tk4.0.ps
+++ /dev/null
@@ -1,4602 +0,0 @@
-%!
-%%BoundingBox: (atend)
-%%Pages: (atend)
-%%DocumentFonts: (atend)
-%%EndComments
-%%BeginProlog
-%
-% FrameMaker postscript_prolog 3.0, for use with FrameMaker 3.0
-% This postscript_prolog file is Copyright (c) 1986-1991 Frame Technology
-% Corporation. All rights reserved. This postscript_prolog file may be
-% freely copied and distributed in conjunction with documents created using
-% FrameMaker.
-% NOTE
-% This file fixes the problem with NeWS printers dithering color output.
-% Any questions should be sent to mickey@magickingdom.eng.sun.com
-%
-% Known Problems:
-% Due to bugs in Transcript, the 'PS-Adobe-' is omitted from line 1
-/FMversion (3.0) def
-% Set up Color vs. Black-and-White
-
-/FMPrintInColor { % once-thru loop gimmick
- % See if we're a NeWSprint printer
- /currentcanvas where {
- pop systemdict /separationdict known
- exit
- } if
-% originally had the following, which should always be false:
-% /currentcanvas where {
-% pop currentcanvas /Color known {
-% currentcanvas /Color get
-% exit
-% } if
-% } if
- systemdict /colorimage known
- systemdict /currentcolortransfer known and
-exit } loop def
-
-% Uncomment the following line to force b&w on color printer
-% /FMPrintInColor false def
-/FrameDict 195 dict def
-systemdict /errordict known not {/errordict 10 dict def
- errordict /rangecheck {stop} put} if
-% The readline in 23.0 doesn't recognize cr's as nl's on AppleTalk
-FrameDict /tmprangecheck errordict /rangecheck get put
-errordict /rangecheck {FrameDict /bug true put} put
-FrameDict /bug false put
-mark
-% Some PS machines read past the CR, so keep the following 3 lines together!
-currentfile 5 string readline
-00
-0000000000
-cleartomark
-errordict /rangecheck FrameDict /tmprangecheck get put
-FrameDict /bug get {
- /readline {
- /gstring exch def
- /gfile exch def
- /gindex 0 def
- {
- gfile read pop
- dup 10 eq {exit} if
- dup 13 eq {exit} if
- gstring exch gindex exch put
- /gindex gindex 1 add def
- } loop
- pop
- gstring 0 gindex getinterval true
- } def
- } if
-/FMVERSION {
- FMversion ne {
- /Times-Roman findfont 18 scalefont setfont
- 100 100 moveto
- (FrameMaker version does not match postscript_prolog!)
- dup =
- show showpage
- } if
- } def
-/FMLOCAL {
- FrameDict begin
- 0 def
- end
- } def
- /gstring FMLOCAL
- /gfile FMLOCAL
- /gindex FMLOCAL
- /orgxfer FMLOCAL
- /orgproc FMLOCAL
- /organgle FMLOCAL
- /orgfreq FMLOCAL
- /yscale FMLOCAL
- /xscale FMLOCAL
- /manualfeed FMLOCAL
- /paperheight FMLOCAL
- /paperwidth FMLOCAL
-/FMDOCUMENT {
- array /FMfonts exch def
- /#copies exch def
- FrameDict begin
- 0 ne dup {setmanualfeed} if
- /manualfeed exch def
- /paperheight exch def
- /paperwidth exch def
- /yscale exch def
- /xscale exch def
- currenttransfer cvlit /orgxfer exch def
- currentscreen cvlit /orgproc exch def
- /organgle exch def /orgfreq exch def
- setpapername
- manualfeed {true} {papersize} ifelse
- {manualpapersize} {false} ifelse
- {desperatepapersize} if
- end
- } def
- /pagesave FMLOCAL
- /orgmatrix FMLOCAL
- /landscape FMLOCAL
-/FMBEGINPAGE {
- FrameDict begin
- /pagesave save def
- 3.86 setmiterlimit
- /landscape exch 0 ne def
- landscape {
- 90 rotate 0 exch neg translate pop
- }
- {pop pop}
- ifelse
- xscale yscale scale
- /orgmatrix matrix def
- gsave
- } def
-/FMENDPAGE {
- grestore
- pagesave restore
- end
- showpage
- } def
-/FMFONTDEFINE {
- FrameDict begin
- findfont
- ReEncode
- 1 index exch
- definefont
- FMfonts 3 1 roll
- put
- end
- } def
-/FMFILLS {
- FrameDict begin
- array /fillvals exch def
- end
- } def
-/FMFILL {
- FrameDict begin
- fillvals 3 1 roll put
- end
- } def
-/FMNORMALIZEGRAPHICS {
- newpath
- 0.0 0.0 moveto
- 1 setlinewidth
- 0 setlinecap
- 0 0 0 sethsbcolor
- 0 setgray
- } bind def
- /fx FMLOCAL
- /fy FMLOCAL
- /fh FMLOCAL
- /fw FMLOCAL
- /llx FMLOCAL
- /lly FMLOCAL
- /urx FMLOCAL
- /ury FMLOCAL
-/FMBEGINEPSF {
- end
- /FMEPSF save def
- /showpage {} def
- FMNORMALIZEGRAPHICS
- [/fy /fx /fh /fw /ury /urx /lly /llx] {exch def} forall
- fx fy translate
- rotate
- fw urx llx sub div fh ury lly sub div scale
- llx neg lly neg translate
- } bind def
-/FMENDEPSF {
- FMEPSF restore
- FrameDict begin
- } bind def
-FrameDict begin
-/setmanualfeed {
-%%BeginFeature *ManualFeed True
- statusdict /manualfeed true put
-%%EndFeature
- } def
-/max {2 copy lt {exch} if pop} bind def
-/min {2 copy gt {exch} if pop} bind def
-/inch {72 mul} def
-/pagedimen {
- paperheight sub abs 16 lt exch
- paperwidth sub abs 16 lt and
- {/papername exch def} {pop} ifelse
- } def
- /papersizedict FMLOCAL
-/setpapername {
- /papersizedict 14 dict def
- papersizedict begin
- /papername /unknown def
- /Letter 8.5 inch 11.0 inch pagedimen
- /LetterSmall 7.68 inch 10.16 inch pagedimen
- /Tabloid 11.0 inch 17.0 inch pagedimen
- /Ledger 17.0 inch 11.0 inch pagedimen
- /Legal 8.5 inch 14.0 inch pagedimen
- /Statement 5.5 inch 8.5 inch pagedimen
- /Executive 7.5 inch 10.0 inch pagedimen
- /A3 11.69 inch 16.5 inch pagedimen
- /A4 8.26 inch 11.69 inch pagedimen
- /A4Small 7.47 inch 10.85 inch pagedimen
- /B4 10.125 inch 14.33 inch pagedimen
- /B5 7.16 inch 10.125 inch pagedimen
- end
- } def
-/papersize {
- papersizedict begin
- /Letter {lettertray letter} def
- /LetterSmall {lettertray lettersmall} def
- /Tabloid {11x17tray 11x17} def
- /Ledger {ledgertray ledger} def
- /Legal {legaltray legal} def
- /Statement {statementtray statement} def
- /Executive {executivetray executive} def
- /A3 {a3tray a3} def
- /A4 {a4tray a4} def
- /A4Small {a4tray a4small} def
- /B4 {b4tray b4} def
- /B5 {b5tray b5} def
- /unknown {unknown} def
- papersizedict dup papername known {papername} {/unknown} ifelse get
- end
- /FMdicttop countdictstack 1 add def
- statusdict begin stopped end
- countdictstack -1 FMdicttop {pop end} for
- } def
-/manualpapersize {
- papersizedict begin
- /Letter {letter} def
- /LetterSmall {lettersmall} def
- /Tabloid {11x17} def
- /Ledger {ledger} def
- /Legal {legal} def
- /Statement {statement} def
- /Executive {executive} def
- /A3 {a3} def
- /A4 {a4} def
- /A4Small {a4small} def
- /B4 {b4} def
- /B5 {b5} def
- /unknown {unknown} def
- papersizedict dup papername known {papername} {/unknown} ifelse get
- end
- stopped
- } def
-/desperatepapersize {
- statusdict /setpageparams known
- {
- paperwidth paperheight 0 1
- statusdict begin
- {setpageparams} stopped pop
- end
- } if
- } def
-/savematrix {
- orgmatrix currentmatrix pop
- } bind def
-/restorematrix {
- orgmatrix setmatrix
- } bind def
-/dmatrix matrix def
-/dpi 72 0 dmatrix defaultmatrix dtransform
- dup mul exch dup mul add sqrt def
-/freq dpi 18.75 div 8 div round dup 0 eq {pop 1} if 8 mul dpi exch div def
-/sangle 1 0 dmatrix defaultmatrix dtransform exch atan def
-/DiacriticEncoding [
-/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
-/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
-/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
-/.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
-/.notdef /.notdef /.notdef /.notdef /space /exclam /quotedbl
-/numbersign /dollar /percent /ampersand /quotesingle /parenleft
-/parenright /asterisk /plus /comma /hyphen /period /slash /zero /one
-/two /three /four /five /six /seven /eight /nine /colon /semicolon
-/less /equal /greater /question /at /A /B /C /D /E /F /G /H /I /J /K
-/L /M /N /O /P /Q /R /S /T /U /V /W /X /Y /Z /bracketleft /backslash
-/bracketright /asciicircum /underscore /grave /a /b /c /d /e /f /g /h
-/i /j /k /l /m /n /o /p /q /r /s /t /u /v /w /x /y /z /braceleft /bar
-/braceright /asciitilde /.notdef /Adieresis /Aring /Ccedilla /Eacute
-/Ntilde /Odieresis /Udieresis /aacute /agrave /acircumflex /adieresis
-/atilde /aring /ccedilla /eacute /egrave /ecircumflex /edieresis
-/iacute /igrave /icircumflex /idieresis /ntilde /oacute /ograve
-/ocircumflex /odieresis /otilde /uacute /ugrave /ucircumflex
-/udieresis /dagger /.notdef /cent /sterling /section /bullet
-/paragraph /germandbls /registered /copyright /trademark /acute
-/dieresis /.notdef /AE /Oslash /.notdef /.notdef /.notdef /.notdef
-/yen /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
-/ordfeminine /ordmasculine /.notdef /ae /oslash /questiondown
-/exclamdown /logicalnot /.notdef /florin /.notdef /.notdef
-/guillemotleft /guillemotright /ellipsis /.notdef /Agrave /Atilde
-/Otilde /OE /oe /endash /emdash /quotedblleft /quotedblright
-/quoteleft /quoteright /.notdef /.notdef /ydieresis /Ydieresis
-/fraction /currency /guilsinglleft /guilsinglright /fi /fl /daggerdbl
-/periodcentered /quotesinglbase /quotedblbase /perthousand
-/Acircumflex /Ecircumflex /Aacute /Edieresis /Egrave /Iacute
-/Icircumflex /Idieresis /Igrave /Oacute /Ocircumflex /.notdef /Ograve
-/Uacute /Ucircumflex /Ugrave /dotlessi /circumflex /tilde /macron
-/breve /dotaccent /ring /cedilla /hungarumlaut /ogonek /caron
-] def
-/ReEncode {
- dup
- length
- dict begin
- {
- 1 index /FID ne
- {def}
- {pop pop} ifelse
- } forall
- 0 eq {/Encoding DiacriticEncoding def} if
- currentdict
- end
- } bind def
-/graymode true def
- /bwidth FMLOCAL
- /bpside FMLOCAL
- /bstring FMLOCAL
- /onbits FMLOCAL
- /offbits FMLOCAL
- /xindex FMLOCAL
- /yindex FMLOCAL
- /x FMLOCAL
- /y FMLOCAL
-/setpattern {
- /bwidth exch def
- /bpside exch def
- /bstring exch def
- /onbits 0 def /offbits 0 def
- freq sangle landscape {90 add} if
- {/y exch def
- /x exch def
- /xindex x 1 add 2 div bpside mul cvi def
- /yindex y 1 add 2 div bpside mul cvi def
- bstring yindex bwidth mul xindex 8 idiv add get
- 1 7 xindex 8 mod sub bitshift and 0 ne
- {/onbits onbits 1 add def 1}
- {/offbits offbits 1 add def 0}
- ifelse
- }
- setscreen
- {} settransfer
- offbits offbits onbits add div FMsetgray
- /graymode false def
- } bind def
-/grayness {
- FMsetgray
- graymode not {
- /graymode true def
- orgxfer cvx settransfer
- orgfreq organgle orgproc cvx setscreen
- } if
- } bind def
- /HUE FMLOCAL
- /SAT FMLOCAL
- /BRIGHT FMLOCAL
- /Colors FMLOCAL
-FMPrintInColor
-
- {
- /HUE 0 def
- /SAT 0 def
- /BRIGHT 0 def
- % array of arrays Hue and Sat values for the separations [HUE BRIGHT]
- /Colors
- [[0 0 ] % black
- [0 0 ] % white
- [0.00 1.0] % red
- [0.37 1.0] % green
- [0.60 1.0] % blue
- [0.50 1.0] % cyan
- [0.83 1.0] % magenta
- [0.16 1.0] % comment / yellow
- ] def
-
- /BEGINBITMAPCOLOR {
- BITMAPCOLOR} def
- /BEGINBITMAPCOLORc {
- BITMAPCOLORc} def
- /BEGINBITMAPTRUECOLOR {
- BITMAPTRUECOLOR } def
- /BEGINBITMAPTRUECOLORc {
- BITMAPTRUECOLORc } def
- /K {
- Colors exch get dup
- 0 get /HUE exch store
- 1 get /BRIGHT exch store
- HUE 0 eq BRIGHT 0 eq and
- {1.0 SAT sub setgray}
- {HUE SAT BRIGHT sethsbcolor}
- ifelse
- } def
- /FMsetgray {
- /SAT exch 1.0 exch sub store
- HUE 0 eq BRIGHT 0 eq and
- {1.0 SAT sub setgray}
- {HUE SAT BRIGHT sethsbcolor}
- ifelse
- } bind def
- }
-
- {
- /BEGINBITMAPCOLOR {
- BITMAPGRAY} def
- /BEGINBITMAPCOLORc {
- BITMAPGRAYc} def
- /BEGINBITMAPTRUECOLOR {
- BITMAPTRUEGRAY } def
- /BEGINBITMAPTRUECOLORc {
- BITMAPTRUEGRAYc } def
- /FMsetgray {setgray} bind def
- /K {
- pop
- } def
- }
-ifelse
-/normalize {
- transform round exch round exch itransform
- } bind def
-/dnormalize {
- dtransform round exch round exch idtransform
- } bind def
-/lnormalize {
- 0 dtransform exch cvi 2 idiv 2 mul 1 add exch idtransform pop
- } bind def
-/H {
- lnormalize setlinewidth
- } bind def
-/Z {
- setlinecap
- } bind def
- /fillvals FMLOCAL
-/X {
- fillvals exch get
- dup type /stringtype eq
- {8 1 setpattern}
- {grayness}
- ifelse
- } bind def
-/V {
- gsave eofill grestore
- } bind def
-/N {
- stroke
- } bind def
-/M {newpath moveto} bind def
-/E {lineto} bind def
-/D {curveto} bind def
-/O {closepath} bind def
- /n FMLOCAL
-/L {
- /n exch def
- newpath
- normalize
- moveto
- 2 1 n {pop normalize lineto} for
- } bind def
-/Y {
- L
- closepath
- } bind def
- /x1 FMLOCAL
- /x2 FMLOCAL
- /y1 FMLOCAL
- /y2 FMLOCAL
- /rad FMLOCAL
-/R {
- /y2 exch def
- /x2 exch def
- /y1 exch def
- /x1 exch def
- x1 y1
- x2 y1
- x2 y2
- x1 y2
- 4 Y
- } bind def
-/RR {
- /rad exch def
- normalize
- /y2 exch def
- /x2 exch def
- normalize
- /y1 exch def
- /x1 exch def
- newpath
- x1 y1 rad add moveto
- x1 y2 x2 y2 rad arcto
- x2 y2 x2 y1 rad arcto
- x2 y1 x1 y1 rad arcto
- x1 y1 x1 y2 rad arcto
- closepath
- 16 {pop} repeat
- } bind def
-/C {
- grestore
- gsave
- R
- clip
- } bind def
- /FMpointsize FMLOCAL
-/F {
- FMfonts exch get
- FMpointsize scalefont
- setfont
- } bind def
-/Q {
- /FMpointsize exch def
- F
- } bind def
-/T {
- moveto show
- } bind def
-/RF {
- rotate
- 0 ne {-1 1 scale} if
- } bind def
-/TF {
- gsave
- moveto
- RF
- show
- grestore
- } bind def
-/P {
- moveto
- 0 32 3 2 roll widthshow
- } bind def
-/PF {
- gsave
- moveto
- RF
- 0 32 3 2 roll widthshow
- grestore
- } bind def
-/S {
- moveto
- 0 exch ashow
- } bind def
-/SF {
- gsave
- moveto
- RF
- 0 exch ashow
- grestore
- } bind def
-/B {
- moveto
- 0 32 4 2 roll 0 exch awidthshow
- } bind def
-/BF {
- gsave
- moveto
- RF
- 0 32 4 2 roll 0 exch awidthshow
- grestore
- } bind def
-/G {
- gsave
- newpath
- normalize translate 0.0 0.0 moveto
- dnormalize scale
- 0.0 0.0 1.0 5 3 roll arc
- closepath fill
- grestore
- } bind def
-/A {
- gsave
- savematrix
- newpath
- 2 index 2 div add exch 3 index 2 div sub exch
- normalize 2 index 2 div sub exch 3 index 2 div add exch
- translate
- scale
- 0.0 0.0 1.0 5 3 roll arc
- restorematrix
- stroke
- grestore
- } bind def
- /x FMLOCAL
- /y FMLOCAL
- /w FMLOCAL
- /h FMLOCAL
- /xx FMLOCAL
- /yy FMLOCAL
- /ww FMLOCAL
- /hh FMLOCAL
- /FMsaveobject FMLOCAL
- /FMoptop FMLOCAL
- /FMdicttop FMLOCAL
-/BEGINPRINTCODE {
- /FMdicttop countdictstack 1 add def
- /FMoptop count 4 sub def
- /FMsaveobject save def
- userdict begin
- /showpage {} def
- FMNORMALIZEGRAPHICS
- 3 index neg 3 index neg translate
- } bind def
-/ENDPRINTCODE {
- count -1 FMoptop {pop pop} for
- countdictstack -1 FMdicttop {pop end} for
- FMsaveobject restore
- } bind def
-/gn {
- 0
- { 46 mul
- cf read pop
- 32 sub
- dup 46 lt {exit} if
- 46 sub add
- } loop
- add
- } bind def
- /str FMLOCAL
-/cfs {
- /str sl string def
- 0 1 sl 1 sub {str exch val put} for
- str def
- } bind def
-/ic [
- 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0223
- 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0223
- 0
- {0 hx} {1 hx} {2 hx} {3 hx} {4 hx} {5 hx} {6 hx} {7 hx} {8 hx} {9 hx}
- {10 hx} {11 hx} {12 hx} {13 hx} {14 hx} {15 hx} {16 hx} {17 hx} {18 hx}
- {19 hx} {gn hx} {0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10} {11} {12}
- {13} {14} {15} {16} {17} {18} {19} {gn} {0 wh} {1 wh} {2 wh} {3 wh}
- {4 wh} {5 wh} {6 wh} {7 wh} {8 wh} {9 wh} {10 wh} {11 wh} {12 wh}
- {13 wh} {14 wh} {gn wh} {0 bl} {1 bl} {2 bl} {3 bl} {4 bl} {5 bl} {6 bl}
- {7 bl} {8 bl} {9 bl} {10 bl} {11 bl} {12 bl} {13 bl} {14 bl} {gn bl}
- {0 fl} {1 fl} {2 fl} {3 fl} {4 fl} {5 fl} {6 fl} {7 fl} {8 fl} {9 fl}
- {10 fl} {11 fl} {12 fl} {13 fl} {14 fl} {gn fl}
- ] def
- /sl FMLOCAL
- /val FMLOCAL
- /ws FMLOCAL
- /im FMLOCAL
- /bs FMLOCAL
- /cs FMLOCAL
- /len FMLOCAL
- /pos FMLOCAL
-/ms {
- /sl exch def
- /val 255 def
- /ws cfs
- /im cfs
- /val 0 def
- /bs cfs
- /cs cfs
- } bind def
-400 ms
-/ip {
- is
- 0
- cf cs readline pop
- { ic exch get exec
- add
- } forall
- pop
-
- } bind def
-/wh {
- /len exch def
- /pos exch def
- ws 0 len getinterval im pos len getinterval copy pop
- pos len
- } bind def
-/bl {
- /len exch def
- /pos exch def
- bs 0 len getinterval im pos len getinterval copy pop
- pos len
- } bind def
-/s1 1 string def
-/fl {
- /len exch def
- /pos exch def
- /val cf s1 readhexstring pop 0 get def
- pos 1 pos len add 1 sub {im exch val put} for
- pos len
- } bind def
-/hx {
- 3 copy getinterval
- cf exch readhexstring pop pop
- } bind def
- /h FMLOCAL
- /w FMLOCAL
- /d FMLOCAL
- /lb FMLOCAL
- /bitmapsave FMLOCAL
- /is FMLOCAL
- /cf FMLOCAL
-/wbytes {
- dup
- 8 eq {pop} {1 eq {7 add 8 idiv} {3 add 4 idiv} ifelse} ifelse
- } bind def
-/BEGINBITMAPBWc {
- 1 {} COMMONBITMAPc
- } bind def
-/BEGINBITMAPGRAYc {
- 8 {} COMMONBITMAPc
- } bind def
-/BEGINBITMAP2BITc {
- 2 {} COMMONBITMAPc
- } bind def
-/COMMONBITMAPc {
- /r exch def
- /d exch def
- gsave
- translate rotate scale /h exch def /w exch def
- /lb w d wbytes def
- sl lb lt {lb ms} if
- /bitmapsave save def
- r
- /is im 0 lb getinterval def
- ws 0 lb getinterval is copy pop
- /cf currentfile def
- w h d [w 0 0 h neg 0 h]
- {ip} image
- bitmapsave restore
- grestore
- } bind def
-/BEGINBITMAPBW {
- 1 {} COMMONBITMAP
- } bind def
-/BEGINBITMAPGRAY {
- 8 {} COMMONBITMAP
- } bind def
-/BEGINBITMAP2BIT {
- 2 {} COMMONBITMAP
- } bind def
-/COMMONBITMAP {
- /r exch def
- /d exch def
- gsave
- translate rotate scale /h exch def /w exch def
- /bitmapsave save def
- r
- /is w d wbytes string def
- /cf currentfile def
- w h d [w 0 0 h neg 0 h]
- {cf is readhexstring pop} image
- bitmapsave restore
- grestore
- } bind def
- /proc1 FMLOCAL
- /proc2 FMLOCAL
- /newproc FMLOCAL
-/Fmcc {
- /proc2 exch cvlit def
- /proc1 exch cvlit def
- /newproc proc1 length proc2 length add array def
- newproc 0 proc1 putinterval
- newproc proc1 length proc2 putinterval
- newproc cvx
-} bind def
-/ngrayt 256 array def
-/nredt 256 array def
-/nbluet 256 array def
-/ngreent 256 array def
- /gryt FMLOCAL
- /blut FMLOCAL
- /grnt FMLOCAL
- /redt FMLOCAL
- /indx FMLOCAL
- /cynu FMLOCAL
- /magu FMLOCAL
- /yelu FMLOCAL
- /k FMLOCAL
- /u FMLOCAL
-/colorsetup {
- currentcolortransfer
- /gryt exch def
- /blut exch def
- /grnt exch def
- /redt exch def
- 0 1 255 {
- /indx exch def
- /cynu 1 red indx get 255 div sub def
- /magu 1 green indx get 255 div sub def
- /yelu 1 blue indx get 255 div sub def
- /k cynu magu min yelu min def
- /u k currentundercolorremoval exec def
- nredt indx 1 0 cynu u sub max sub redt exec put
- ngreent indx 1 0 magu u sub max sub grnt exec put
- nbluet indx 1 0 yelu u sub max sub blut exec put
- ngrayt indx 1 k currentblackgeneration exec sub gryt exec put
- } for
- {255 mul cvi nredt exch get}
- {255 mul cvi ngreent exch get}
- {255 mul cvi nbluet exch get}
- {255 mul cvi ngrayt exch get}
- setcolortransfer
- {pop 0} setundercolorremoval
- {} setblackgeneration
- } bind def
- /tran FMLOCAL
-/fakecolorsetup {
- /tran 256 string def
- 0 1 255 {/indx exch def
- tran indx
- red indx get 77 mul
- green indx get 151 mul
- blue indx get 28 mul
- add add 256 idiv put} for
- currenttransfer
- {255 mul cvi tran exch get 255.0 div}
- exch Fmcc settransfer
-} bind def
-/BITMAPCOLOR {
- /d 8 def
- gsave
- translate rotate scale /h exch def /w exch def
- /bitmapsave save def
- colorsetup
- /is w d wbytes string def
- /cf currentfile def
- w h d [w 0 0 h neg 0 h]
- {cf is readhexstring pop} {is} {is} true 3 colorimage
- bitmapsave restore
- grestore
- } bind def
-/BITMAPCOLORc {
- /d 8 def
- gsave
- translate rotate scale /h exch def /w exch def
- /lb w d wbytes def
- sl lb lt {lb ms} if
- /bitmapsave save def
- colorsetup
- /is im 0 lb getinterval def
- ws 0 lb getinterval is copy pop
- /cf currentfile def
- w h d [w 0 0 h neg 0 h]
- {ip} {is} {is} true 3 colorimage
- bitmapsave restore
- grestore
- } bind def
-/BITMAPTRUECOLORc {
- gsave
- translate rotate scale /h exch def /w exch def
- /bitmapsave save def
-
- /is w string def
-
- ws 0 w getinterval is copy pop
- /cf currentfile def
- w h 8 [w 0 0 h neg 0 h]
- {ip} {gip} {bip} true 3 colorimage
- bitmapsave restore
- grestore
- } bind def
-/BITMAPTRUECOLOR {
- gsave
- translate rotate scale /h exch def /w exch def
- /bitmapsave save def
- /is w string def
- /gis w string def
- /bis w string def
- /cf currentfile def
- w h 8 [w 0 0 h neg 0 h]
- { cf is readhexstring pop }
- { cf gis readhexstring pop }
- { cf bis readhexstring pop }
- true 3 colorimage
- bitmapsave restore
- grestore
- } bind def
-/BITMAPTRUEGRAYc {
- gsave
- translate rotate scale /h exch def /w exch def
- /bitmapsave save def
-
- /is w string def
-
- ws 0 w getinterval is copy pop
- /cf currentfile def
- w h 8 [w 0 0 h neg 0 h]
- {ip gip bip w gray} image
- bitmapsave restore
- grestore
- } bind def
-/ww FMLOCAL
-/r FMLOCAL
-/g FMLOCAL
-/b FMLOCAL
-/i FMLOCAL
-/gray {
- /ww exch def
- /b exch def
- /g exch def
- /r exch def
- 0 1 ww 1 sub { /i exch def r i get .299 mul g i get .587 mul
- b i get .114 mul add add r i 3 -1 roll floor cvi put } for
- r
- } bind def
-/BITMAPTRUEGRAY {
- gsave
- translate rotate scale /h exch def /w exch def
- /bitmapsave save def
- /is w string def
- /gis w string def
- /bis w string def
- /cf currentfile def
- w h 8 [w 0 0 h neg 0 h]
- { cf is readhexstring pop
- cf gis readhexstring pop
- cf bis readhexstring pop w gray} image
- bitmapsave restore
- grestore
- } bind def
-/BITMAPGRAY {
- 8 {fakecolorsetup} COMMONBITMAP
- } bind def
-/BITMAPGRAYc {
- 8 {fakecolorsetup} COMMONBITMAPc
- } bind def
-/ENDBITMAP {
- } bind def
-end
- /ALDsave FMLOCAL
- /ALDmatrix matrix def ALDmatrix currentmatrix pop
-/StartALD {
- /ALDsave save def
- savematrix
- ALDmatrix setmatrix
- } bind def
-/InALD {
- restorematrix
- } bind def
-/DoneALD {
- ALDsave restore
- } bind def
-%%EndProlog
-%%BeginSetup
-(3.0) FMVERSION
-1 1 612 792 0 1 13 FMDOCUMENT
-0 0 /Helvetica-Bold FMFONTDEFINE
-1 0 /Times-Bold FMFONTDEFINE
-2 0 /Times-Italic FMFONTDEFINE
-3 0 /Times-Roman FMFONTDEFINE
-4 0 /Helvetica FMFONTDEFINE
-5 0 /Courier FMFONTDEFINE
-6 0 /Courier-Oblique FMFONTDEFINE
-32 FMFILLS
-0 0 FMFILL
-1 0.1 FMFILL
-2 0.3 FMFILL
-3 0.5 FMFILL
-4 0.7 FMFILL
-5 0.9 FMFILL
-6 0.97 FMFILL
-7 1 FMFILL
-8 <0f1e3c78f0e1c387> FMFILL
-9 <0f87c3e1f0783c1e> FMFILL
-10 <cccccccccccccccc> FMFILL
-11 <ffff0000ffff0000> FMFILL
-12 <8142241818244281> FMFILL
-13 <03060c183060c081> FMFILL
-14 <8040201008040201> FMFILL
-16 1 FMFILL
-17 0.9 FMFILL
-18 0.7 FMFILL
-19 0.5 FMFILL
-20 0.3 FMFILL
-21 0.1 FMFILL
-22 0.03 FMFILL
-23 0 FMFILL
-24 <f0e1c3870f1e3c78> FMFILL
-25 <f0783c1e0f87c3e1> FMFILL
-26 <3333333333333333> FMFILL
-27 <0000ffff0000ffff> FMFILL
-28 <7ebddbe7e7dbbd7e> FMFILL
-29 <fcf9f3e7cf9f3f7e> FMFILL
-30 <7fbfdfeff7fbfdfe> FMFILL
-%%EndSetup
-%%Page: "1" 1
-%%BeginPaperSize: Letter
-%%EndPaperSize
-612 792 0 FMBEGINPAGE
-98.1 675 512.1 675 2 L
-7 X
-0 K
-V
-2 H
-0 Z
-0 X
-N
-98.1 450 512.1 450 2 L
-7 X
-V
-2 Z
-0 X
-N
-98.1 108 512.1 126 R
-7 X
-V
-0 10 Q
-0 X
-(1) 506.54 119.33 T
-1 24 Q
--0.48 (Tk4.0 Overview and Porting Guide) 152.1 605 S
-2 12 Q
-(John Ouster) 152.1 563 T
-(hout) 210.84 563 T
-98.1 135 512.1 423 R
-7 X
-V
-3 10 Q
-0 X
-(Tk version 4.0 is a major new release with many improvements, new features, and bug) 152.1 416.33 T
-(\336xes. This document provides an introduction to the new features and describes the most) 152.1 404.33 T
--0.18 (common problems you are likely to encounter when porting scripts from Tk 3.6, the previ-) 152.1 392.33 P
-(ous release. This is) 152.1 380.33 T
-2 F
-(not) 230.66 380.33 T
-3 F
-( an introduction to Tk: I assume that you are already familiar with) 243.43 380.33 T
-(Tk 3.6 as described in the book) 152.1 368.33 T
-2 F
-(T) 279.79 368.33 T
-(cl and the Tk T) 284.43 368.33 T
-(oolkit) 343.48 368.33 T
-3 F
-(.) 366.24 368.33 T
--0.26 (The good news about Tk 4.0 is that it has many improvements over Tk 3.6. Here are a) 170.1 356.33 P
-(few of the most important new features:) 152.1 344.33 T
-3 12 Q
-(\245) 152.1 329.33 T
-3 10 Q
-(Tk 4.0 includes a general-purpose mechanism for manipulating color images \050Tk 3.6) 162.9 329.33 T
-(supports only monochrome images\051.) 162.9 317.33 T
-3 12 Q
-(\245) 152.1 302.33 T
-3 10 Q
--0.17 (The text widget in Tk 4.0 includes many new features such as tab stops, embedded win-) 162.9 302.33 P
-(dows, horizontal scrolling, and many new formatting options.) 162.9 290.33 T
-3 12 Q
-(\245) 152.1 275.33 T
-3 10 Q
-(The binding mechanism in Tk 4.0 is much more powerful in Tk 3.6.) 162.9 275.33 T
-3 12 Q
-(\245) 152.1 260.33 T
-3 10 Q
-(Motif compliance is much better) 162.9 260.33 T
-(. For example, there is now support for keyboard tra-) 292.82 260.33 T
-(versal and focus highlights.) 162.9 248.33 T
-3 12 Q
-(\245) 152.1 233.33 T
-3 10 Q
-(Many widgets have been improved. For example, buttons and labels can display multi-) 162.9 233.33 T
-(line justi\336ed text, and scales can handle real values.) 162.9 221.33 T
-(The bad news about Tk 4.0 is that it contains several incompatibilities with Tk 3.6.) 170.1 206.33 T
-(Ever since the \336rst release of Tk I have assumed that there would eventually be a major) 152.1 194.33 T
-(new release of Tk with substantial incompatibilities. I knew that I wouldn\325) 152.1 182.33 T
-(t be able to get) 450.06 182.33 T
-(all of the features of Tk right the \336rst time; rather than live forever with all of my early) 152.1 170.33 T
-(mistakes, I wanted to have a chance to correct them. Tk 4.0 is that correction. I apologize) 152.1 158.33 T
--0.05 (for the incompatibilities, but I hope they improve Tk enough to justify the dif) 152.1 146.33 P
--0.05 (\336culties you) 460.55 146.33 P
-44.1 351 98.1 423 C
-35.1 360 197.1 414 R
-7 X
-0 K
-V
-1 9 Q
-0 X
-(FIGURE 1) 35.1 408 T
-(T) 35.1 387 T
-(ABLE 1) 40.43 387 T
-26.1 351 125.1 423 R
-7 X
-V
-40.5 63 571.5 729 C
-FMENDPAGE
-%%EndPage: "1" 2
-%%Page: "2" 2
-612 792 0 FMBEGINPAGE
-0 10 Q
-0 X
-0 K
-(2) 98.1 668.33 T
-4 F
-(Tk4.0 Overview and Porting Guide) 359.34 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-3 F
-0 X
-(encounter during porting. Tk 4.0 is a one-time correction: we will try very hard to avoid) 152.1 632.33 T
-(substantial incompatibilities \050especially in Tk\325) 152.1 620.3 T
-(s T) 337 620.3 T
-(cl-level interfaces\051 in future releases.) 348.79 620.3 T
--0.4 (Sections 1-1) 170.1 608.3 P
--0.4 (1 cover the major areas of change in Tk 4.0: bindings, focus, text widgets,) 219.02 608.3 P
--0 (Motif compliance, other widget changes, images, color management, event handling, sup-) 152.1 596.26 P
-(port for multiple displays, the) 152.1 584.23 T
-5 F
-(send) 273.14 584.23 T
-3 F
-( command, and the selection. Section 12 summarizes) 297.13 584.23 T
-(several smaller changes. Section 13 lists all of the incompatibilities that af) 152.1 572.19 T
-(fect T) 448.4 572.19 T
-(cl scripts,) 471.29 572.19 T
--0.02 (along with suggestions for how to deal with them. The explanations here are not intended) 152.1 560.16 P
-(to be comprehensive, but rather to introduce you to the issues; for complete information) 152.1 548.12 T
-(on new or modi\336ed commands, refer to the reference documentation that comes with the) 152.1 536.09 T
-(distribution.) 152.1 524.05 T
-98.1 480.7 512.1 483.72 C
-152.1 481.92 512.1 481.92 2 L
-0.5 H
-2 Z
-0 X
-0 K
-N
-98.1 482.21 143.1 482.21 2 L
-0 Z
-N
-40.5 63 571.5 729 C
-0 12 Q
-0 X
-0 K
-(1) 134.63 487.72 T
-(Bindings) 152.1 487.72 T
-3 10 Q
--0.35 (The changes for Tk 4.0 that are most likely to af) 152.1 464.03 P
--0.35 (fect existing T) 341.31 464.03 P
--0.35 (cl scripts are those related to) 397.64 464.03 P
-(bindings. The new binding mechanism in Tk 4.0 is much more powerful than that of Tk) 152.1 452 T
-(3.6, particularly in the way it allows behaviors to be combined, but several incompatible) 152.1 439.96 T
-(changes were required to implement the new features. These changes are likely to break) 152.1 427.93 T
-(most Tk 3.6 scripts. Fortunately) 152.1 415.89 T
-(, it is relatively easy to upgrade your bindings to work) 279.16 415.89 T
-(under Tk 4.0.) 152.1 403.86 T
--0.27 (The basic mechanism for bindings is the same as in Tk 3.6. A binding associates a T) 170.1 391.86 P
--0.27 (cl) 502.65 391.86 P
-(script with a particular event \050or sequence of events\051 occurring in one or more windows;) 152.1 379.82 T
--0.11 (the script will be invoked automatically whenever the event sequence occurs in any of the) 152.1 367.79 P
--0.13 (speci\336ed windows. The Tk 4.0 binding mechanism has three major feature changes. First,) 152.1 355.75 P
-(there is a more general mechanism for specifying the relationship between windows and) 152.1 343.72 T
-(bindings, called) 152.1 331.68 T
-2 F
-(binding tags) 217.89 331.68 T
-3 F
-(. Second, the con\337ict resolution mechanism \050which is) 267.6 331.68 T
-(invoked when more than one binding matches an event\051 has been changed to allow more) 152.1 319.65 T
-(than one binding script to execute for a single event. Third, the) 152.1 307.61 T
-5 F
-(Any) 405.81 307.61 T
-3 F
-( modi\336er is now) 423.8 307.61 T
-(implicit in all binding patterns. These changes are discussed separately in the subsections) 152.1 295.58 T
-(that follow) 152.1 283.54 T
-(.) 195.04 283.54 T
--0.16 (Overall, the main ef) 170.1 271.54 P
--0.16 (fect of Tk 4.0\325) 249.37 271.54 P
--0.16 (s binding changes is that it allows more bindings to) 306.06 271.54 P
-(trigger than Tk 3.6 does. Feedback from the T) 152.1 259.51 T
-(cl/Tk community about the Tk 3.6 binding) 335.71 259.51 T
-(mechanism indicated that it was too conservative about triggering bindings. This caused) 152.1 247.47 T
-(the system to lose behaviors relatively easily and made the binding structure fragile. It) 152.1 235.44 T
--0.35 (appears to be easier to deal with too many binding invocations than too few) 152.1 223.4 P
--0.35 (, so Tk 4.0 tries) 449.17 223.4 P
-(to err in this direction.) 152.1 211.37 T
-0 F
-(1.1) 127.41 181.37 T
-(Binding tags) 152.1 181.37 T
-3 F
-(In Tk 3.6 you specify the window\050s\051 for a binding in one of three ways:) 152.1 165.37 T
-3 12 Q
-(\245) 152.1 150.37 T
-3 10 Q
-(Y) 162.9 150.37 T
-(ou give the name of a window) 169.12 150.37 T
-(, such as) 289.49 150.37 T
-5 F
-(.a.b.c) 326.13 150.37 T
-3 F
-(, in which case the binding applies) 362.11 150.37 T
-(only to that window) 162.9 138.33 T
-(.) 242.49 138.33 T
-FMENDPAGE
-%%EndPage: "2" 3
-%%Page: "3" 3
-612 792 0 FMBEGINPAGE
-4 10 Q
-0 X
-0 K
-(1 Bindings) 98.1 668.33 T
-0 F
-(3) 506.54 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-3 12 Q
-0 X
-(\245) 152.1 632.33 T
-3 10 Q
--0.06 (Y) 162.9 632.33 P
--0.06 (ou give the name of a class, such as) 169.12 632.33 P
-5 F
--0.15 (Button) 313.45 632.33 P
-3 F
--0.06 (, in which case the binding applies to all) 349.43 632.33 P
-(the windows of that class.) 162.9 620.33 T
-3 12 Q
-(\245) 152.1 605.33 T
-3 10 Q
-(Y) 162.9 605.33 T
-(ou specify) 169.12 605.33 T
-5 F
-(all) 212.97 605.33 T
-3 F
-(, in which case the binding applies to all windows.) 230.96 605.33 T
--0.3 (In Tk4.0 you specify the window\050s\051 using a more general mechanism called a) 170.1 590.33 P
-2 F
--0.3 (binding) 479.35 590.33 P
-(tag) 152.1 578.33 T
-3 F
-(. A binding tag may be an arbitrary string, but if it starts with a \322.\323 then it must be the) 164.87 578.33 T
-(name of a window) 152.1 566.33 T
-(. If you specify a class name or) 225.56 566.33 T
-5 F
-(all) 352.4 566.33 T
-3 F
-( as a binding tag, it will usually) 370.39 566.33 T
--0.1 (have the same ef) 152.1 554.33 P
--0.1 (fect as in Tk 3.6, but you may also specify other strings that were not per-) 218.51 554.33 P
-(mitted in Tk 3.6.) 152.1 542.33 T
--0.07 (Each window in Tk 4.0 has a list of binding tags. When an event occurs in a window) 170.1 530.33 P
--0.07 (,) 507.17 530.33 P
--0.19 (Tk fetches the window\325) 152.1 518.33 P
--0.19 (s binding tags and matches the event against all of the bindings for) 245.62 518.33 P
--0.09 (any of the tags. By default, the binding tags for a window consist of the window name, its) 152.1 506.33 P
--0.14 (class name, the name of its nearest toplevel ancestor) 152.1 494.33 P
--0.14 (, and) 359.61 494.33 P
-5 F
--0.33 (all) 381.26 494.33 P
-3 F
--0.14 (. For example, a button win-) 399.25 494.33 P
-(dow named) 152.1 482.33 T
-5 F
-(.b) 200.95 482.33 T
-3 F
-( will have the tags) 212.95 482.33 T
-5 9 Q
-(.b Button . all) 179.1 468 T
-3 10 Q
-(by default and all of the following bindings will apply to the window:) 152.1 454.33 T
-5 9 Q
-(bind .b <Enter> {identify "press here to exit"}) 179.1 440 T
-(bind Button <Button-Release-1> {%W invoke}) 179.1 430 T
-(bind all <Help> {help %W}) 179.1 420 T
-3 10 Q
-(So far) 152.1 406.33 T
-(, this mechanism produces the same behavior as in Tk 3.6 except that bindings cre-) 175.85 406.33 T
-(ated for a toplevel also apply to its descendants \050see Section 1.5 for more on this issue\051.) 152.1 394.33 T
-(Y) 170.1 382.33 T
-(ou can use the) 176.32 382.33 T
-5 F
-(bindtags) 235.71 382.33 T
-3 F
-( command to change the binding tags for a window or) 283.69 382.33 T
-(their order) 152.1 370.33 T
-(. For example, the command) 193.46 370.33 T
-5 9 Q
-(bindtags .b {.b MyButton all}) 179.1 356 T
-3 10 Q
-(will change the binding tags for) 152.1 342.33 T
-5 F
-(.b) 281.46 342.33 T
-3 F
-( to the three values in the list. This provides a simple) 293.45 342.33 T
-(way to make radical changes the behavior of a window) 152.1 330.33 T
-(. After the above command is) 371.55 330.33 T
-(invoked none of the) 152.1 318.33 T
-5 F
-(Button) 234.26 318.33 T
-3 F
-( class bindings will apply to) 270.24 318.33 T
-5 F
-(.b) 384.63 318.33 T
-3 F
-(. Instead, bindings for) 396.63 318.33 T
-5 F
--0.81 (MyButton) 152.1 306.33 P
-3 F
--0.34 ( will apply; this might give the button a totally dif) 200.07 306.33 P
--0.34 (ferent set of behaviors than a) 395.88 306.33 P
-(normal button. In addition, the) 152.1 294.33 T
-5 F
-(bindtags) 276.75 294.33 T
-3 F
-( command removes the \322.\323 tag, so bindings on) 324.72 294.33 T
-(\322.\323 will not apply to) 152.1 282.33 T
-5 F
-(.b) 234.27 282.33 T
-3 F
-(.) 246.27 282.33 T
-(Y) 170.1 270.33 T
-(ou can also place additional tags on a window with the) 176.32 270.33 T
-5 F
-(bindtags) 397.55 270.33 T
-3 F
-( command to) 445.53 270.33 T
-(combine a number of behaviors. For example,) 152.1 258.33 T
-5 9 Q
-(bindtags .b {.b MyButton Button . all}) 179.1 244 T
-3 10 Q
-(gives) 152.1 230.33 T
-5 F
-(.b) 175.7 230.33 T
-3 F
-( the behaviors of) 187.69 230.33 T
-5 F
-(MyButton) 257.08 230.33 T
-3 F
-( bindings as well as those speci\336ed by) 305.06 230.33 T
-5 F
-(Button) 459.96 230.33 T
-3 F
-(bindings.) 152.1 218.33 T
-(Overall, binding tags are similar to the tag mechanisms already used internally by) 170.1 206.33 T
-(canvas and text widgets in Tk 3.6, except that binding tags apply to windows instead of) 152.1 194.33 T
-(graphical objects or textual characters.) 152.1 182.33 T
-FMENDPAGE
-%%EndPage: "3" 4
-%%Page: "4" 4
-612 792 0 FMBEGINPAGE
-0 10 Q
-0 X
-0 K
-(4) 98.1 668.33 T
-4 F
-(Tk4.0 Overview and Porting Guide) 359.34 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-0 F
-0 X
-(1.2) 127.41 632.33 T
-(Con\337ict resolution) 152.1 632.33 T
-3 F
-(It is possible for several bindings to match a particular event. In Tk 3.6 at most one event) 152.1 616.33 T
-(is actually allowed to trigger: a set of con\337ict resolution rules determines the winner) 152.1 604.22 T
-(. In) 488.27 604.22 T
-(general, a more speci\336c binding takes precedence over a less speci\336c binding. For exam-) 152.1 592.11 T
--0.27 (ple, any binding for a speci\336c widget takes precedence over any class or) 152.1 580 P
-5 F
--0.66 (all) 439.96 580 P
-3 F
--0.27 ( binding, and) 457.95 580 P
-(a binding on) 152.1 567.89 T
-5 F
-(<Control-a>) 204.57 567.89 T
-3 F
-( takes precedence over a binding on) 270.54 567.89 T
-5 F
-(<KeyPress>.) 416.24 567.89 T
-3 F
--0.26 (The mechanism for con\337ict resolution is similar in Tk 4.0 except that one binding can) 170.1 555.89 P
--0.35 (trigger for) 152.1 543.78 P
-2 F
--0.35 (each) 194.7 543.78 P
-3 F
--0.35 ( binding tag on the window where the event occurs. The bindings trigger in) 213.57 543.78 P
-(the order of the tags. Thus if button) 152.1 531.67 T
-5 F
-(.b) 296.17 531.67 T
-3 F
-( has the default binding tags, one binding for) 308.16 531.67 T
-5 F
-(.b) 489.71 531.67 T
-3 F
-(can trigger) 152.1 519.56 T
-(, followed by one for) 194.72 519.56 T
-5 F
-(Button) 281.32 519.56 T
-3 F
-(, followed by one for \322) 317.3 519.56 T
-5 F
-(.) 408.34 519.56 T
-3 F
-(\323, followed by one for) 414.34 519.56 T
-5 F
-(all) 152.1 507.44 T
-3 F
-(. If there are no matching bindings for a given tag then none will trigger) 170.09 507.44 T
-(, and if there) 456.98 507.44 T
-(are several matching bindings for a given tag then a single one is chosen using the same) 152.1 495.33 T
-(rules as in Tk 3.6.) 152.1 483.22 T
-(The philosophy behind binding tags in Tk 4.0 is that each binding tag corresponds to) 170.1 471.22 T
-(an independent behavior) 152.1 459.11 T
-(, so bindings with dif) 249.96 459.11 T
-(ferent tags should usually be additive. Sup-) 334.46 459.11 T
-(pose you de\336ned the following binding:) 152.1 447 T
-5 9 Q
-(bind .b <Enter> {puts "press here to exit"}) 179.1 432.67 T
-3 10 Q
-(This binding will add to the behavior de\336ned by the Button class binding for) 152.1 419 T
-5 F
-(<Enter>) 460.81 419 T
-3 F
-(.) 502.79 419 T
-(In Tk 3.6, the widget-speci\336c binding will replace the class binding, which will break the) 152.1 406.89 T
-(behavior of the button so that it no longer has normal button behavior) 152.1 394.78 T
-(.) 429.71 394.78 T
-(Sometimes there need to be interactions between binding tags. For example, you) 170.1 382.78 T
-(might wish to keep most of the default button behavior for) 152.1 370.67 T
-5 F
-(.b) 388.34 370.67 T
-3 F
-( but replace the default) 400.33 370.67 T
-(behavior for) 152.1 358.56 T
-5 F
-(<ButtonRelease>) 203.72 358.56 T
-3 F
-( with some other behavior) 293.67 358.56 T
-(. T) 397.49 358.56 T
-(o allow bindings to be) 407.9 358.56 T
--0.17 (overridden, Tk 4.0 allows the) 152.1 346.44 P
-5 F
--0.41 (break) 271.44 346.44 P
-3 F
--0.17 ( command to be invoked from inside a binding. This) 301.43 346.44 P
-(causes all remaining binding tags for that binding to be skipped. Consider the following) 152.1 334.33 T
-(binding:) 152.1 322.22 T
-5 9 Q
-(bind .b <ButtonRelease-1> {myRelease .b; break}) 179.1 307.89 T
-3 10 Q
--0.21 (This will cause the) 152.1 294.22 P
-5 F
--0.5 (myRelease) 228.99 294.22 P
-3 F
--0.21 ( procedure to be invoked, then the) 282.96 294.22 P
-5 F
--0.5 (break) 420.28 294.22 P
-3 F
--0.21 ( command will) 450.26 294.22 P
--0.37 (cause the class binding for the event to be skipped \050assuming that the widget name appears) 152.1 282.11 P
-(before its class in the binding tags for) 152.1 270 T
-5 F
-(.b) 304.78 270 T
-3 F
-(\051, along with any bindings for other tags.) 316.77 270 T
-2 F
-(Note:) 119.09 254 T
--0.07 (Y) 152.1 254 P
--0.07 (ou cannot invoke) 156.74 254 P
-6 F
--0.17 (break) 227.31 254 P
-2 F
--0.07 ( fr) 257.29 254 P
--0.07 (om within the) 266.02 254 P
-6 F
--0.17 (myRelease) 322.73 254 P
-2 F
--0.07 ( pr) 376.7 254 P
--0.07 (ocedur) 387.64 254 P
--0.07 (e in the above example:) 415.03 254 P
--0.02 (this will generate a T) 152.1 242.89 P
--0.02 (cl err) 236.05 242.89 P
--0.02 (or) 257.59 242.89 P
--0.02 (. However) 265.37 242.89 P
--0.02 (, you can invoke the command \322) 305.31 242.89 P
-6 F
--0.05 (return -code) 434.25 242.89 P
-(break) 152.1 231.78 T
-2 F
-(\323 in the pr) 182.08 231.78 T
-(ocedur) 223.64 231.78 T
-(e to achieve the same effect as the) 251.03 231.78 T
-6 F
-(break) 389.25 231.78 T
-2 F
-( in the binding script.) 419.23 231.78 T
-0 F
-(1.3) 127.41 202.78 T
-(Implicit Any) 152.1 202.78 T
-3 F
--0.13 (In Tk 3.6 extraneous modi\336ers prevent a binding from matching an event. For example, if) 152.1 186.78 P
-(a binding is de\336ned for) 152.1 174.67 T
-5 F
-(<Button-1>) 247.32 174.67 T
-3 F
-( and the mouse button is pressed with the) 307.29 174.67 T
-5 F
-(Num-) 474.68 174.67 T
-(Lock) 152.1 162.56 T
-3 F
-( key down, then the binding will not match. If you want a binding to trigger even) 176.09 162.56 T
-(when extraneous modi\336ers are present, you must specify the) 152.1 150.45 T
-5 F
-(Any) 396.37 150.45 T
-3 F
-( modi\336er) 414.36 150.45 T
-(, as in) 450.33 150.45 T
-5 F
-(<Any-) 476.42 150.45 T
-(Button-1>) 152.1 138.33 T
-3 F
-(.) 206.07 138.33 T
-FMENDPAGE
-%%EndPage: "4" 5
-%%Page: "5" 5
-612 792 0 FMBEGINPAGE
-4 10 Q
-0 X
-0 K
-(1 Bindings) 98.1 668.33 T
-0 F
-(5) 506.54 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-3 F
-0 X
--0.06 (In Tk 4.0, all bindings have the) 170.1 632.33 P
-5 F
--0.15 (Any) 297.08 632.33 P
-3 F
--0.06 ( modi\336er present implicitly) 315.08 632.33 P
--0.06 (. The) 423.35 632.33 P
-5 F
--0.15 (Any) 446.26 632.33 P
-3 F
--0.06 ( modi\336er is) 464.25 632.33 P
-(still allowed for compatibility) 152.1 620.33 T
-(, but it has no meaning. Thus a binding for) 270.55 620.33 T
-5 F
-(<Button-1>) 443.23 620.33 T
-3 F
-(will match a button press event even if) 152.1 608.33 T
-5 F
-(NumLock) 309.21 608.33 T
-3 F
-(,) 351.19 608.33 T
-5 F
-(Shift) 356.19 608.33 T
-3 F
-(,) 386.17 608.33 T
-5 F
-(Control) 391.17 608.33 T
-3 F
-(, or any combina-) 433.15 608.33 T
-(tion of them. If you wish for a binding not to trigger when a modi\336er is present, you can) 152.1 596.33 T
-(just de\336ne an empty binding for that modi\336er combination. For example,) 152.1 584.33 T
-5 9 Q
-(bind .b <Control-ButtonPress-1> {# this script is a no-op}) 179.1 570 T
-3 10 Q
-(creates a binding that will trigger on mouse button presses when the) 152.1 556.33 T
-5 F
-(Control) 426.36 556.33 T
-3 F
-( key is) 468.34 556.33 T
--0.22 (down. If there is also a) 152.1 544.33 P
-5 F
--0.52 (<ButtonPress-1>) 244.35 544.33 P
-3 F
--0.22 ( binding for) 334.3 544.33 P
-5 F
--0.52 (.b) 383.35 544.33 P
-3 F
--0.22 (, it will no longer be invoked) 395.34 544.33 P
--0.02 (if the) 152.1 532.33 P
-5 F
--0.05 (Control) 175.37 532.33 P
-3 F
--0.02 ( key is down, due to the con\337ict resolution rules. The script for the above) 217.35 532.33 P
-(binding is just a T) 152.1 520.33 T
-(cl comment, so it has no ef) 223.59 520.33 T
-(fect when it is invoked. Alternatively) 330.84 520.33 T
-(, you) 478.98 520.33 T
-(could use) 152.1 508.33 T
-5 F
-(%s) 192.63 508.33 T
-3 F
-( in the binding script to extract the modi\336er state, then test to see that only) 204.62 508.33 T
-(desired modi\336ers are present.) 152.1 496.33 T
-0 F
-(1.4) 127.41 466.33 T
-(Porting problems: widget bindings vs. class bindings) 152.1 466.33 T
-3 F
--0.38 (Y) 152.1 450.33 P
--0.38 (ou are likely to encounter two problems with bindings when you port Tk 3.6 scripts to Tk) 158.32 450.33 P
--0.18 (4.0: widget bindings vs. class bindings, and events on top-level windows. This section dis-) 152.1 438.33 P
-(cusses the \336rst problem and the following section discusses the second problem.) 152.1 426.33 T
-(In Tk 3.6, if a widget-speci\336c binding matches an event then no class binding will) 170.1 414.33 T
--0.15 (trigger for the event; in Tk 4.0 both bindings will trigger) 152.1 402.33 P
--0.15 (. Because of this change, you will) 375.75 402.33 P
--0.09 (need to modify most of your widget-speci\336c bindings in one of two ways. If a widget-spe-) 152.1 390.33 P
-(ci\336c binding in Tk 3.6 was intended to supplement the class binding, this could only be) 152.1 378.33 T
-(done by duplicating the code of the class binding in the widget binding script. This dupli-) 152.1 366.33 T
--0.02 (cated code is no longer necessary in Tk 4.0 and will probably interfere with the new class) 152.1 354.33 P
-(bindings in Tk 4.0; you should remove the duplicated class code, leaving only the widget-) 152.1 342.33 T
-(speci\336c code in the binding script. If a widget-speci\336c binding in Tk 3.6 was intended to) 152.1 330.33 T
--0.17 (override the class binding, this will no longer occur by default in Tk 4.0; you should add a) 152.1 318.33 P
-5 F
--0.54 (break) 152.1 306.33 P
-3 F
--0.22 ( command at the end of the binding script to prevent the class binding from trigger-) 182.08 306.33 P
-(ing. If a widget binding in Tk 3.6 didn\325) 152.1 294.33 T
-(t con\337ict with a class binding, then you will not) 308.49 294.33 T
-(need to modify it for Tk 4.0. For example, a widget binding for) 152.1 282.33 T
-5 F
-(<Help>) 407.49 282.33 T
-3 F
-( in a text widget) 443.47 282.33 T
-(would not need to be modi\336ed, since it doesn\325) 152.1 270.33 T
-(t con\337ict with a class binding.) 336.53 270.33 T
-0 F
-(1.5) 127.41 240.33 T
-(Porting problems: events on top-levels) 152.1 240.33 T
-3 F
--0.26 (The second binding problem you are likely to encounter in porting Tk 3.6 scripts to Tk 4.0) 152.1 224.33 P
-(is that in Tk 4.0 a binding on a toplevel will match events on any of the internal windows) 152.1 212.33 T
-(within that top-level. For example, suppose you have a binding created as follows:) 152.1 200.33 T
-5 9 Q
-(toplevel .t) 179.1 186 T
-(button .t.b1 ...) 179.1 176 T
-(button .t.b2 ...) 179.1 166 T
-(bind .t <Enter> action) 179.1 156 T
-FMENDPAGE
-%%EndPage: "5" 6
-%%Page: "6" 6
-612 792 0 FMBEGINPAGE
-0 10 Q
-0 X
-0 K
-(6) 98.1 668.33 T
-4 F
-(Tk4.0 Overview and Porting Guide) 359.34 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-3 F
-0 X
--0.27 (This binding will trigger not only when the mouse enters) 152.1 632.33 P
-5 F
--0.64 (.t) 379.29 632.33 P
-3 F
--0.27 (, but also when it enters either) 391.28 632.33 P
-5 F
-(.t.b1) 152.1 620.33 T
-3 F
-( or) 182.08 620.33 T
-5 F
-(.t.b2) 195.41 620.33 T
-3 F
-(. This is because the binding tags for a window include its nearest) 225.39 620.33 T
-(ancestor toplevel by default. The toplevel is present in the binding tags to make it easy to) 152.1 608.33 T
-(set up accelerator keys that apply in all the windows of a panel. For example,) 152.1 596.33 T
-5 9 Q
-(bind .t <Control-a> {controlAProc %W}) 179.1 582 T
-3 10 Q
-(will cause) 152.1 568.33 T
-5 F
-(controlAProc) 194.85 568.33 T
-3 F
-( to be invoked whenever) 266.81 568.33 T
-5 F
-(Control-a) 367.56 568.33 T
-3 F
-( is typed in any of the) 421.53 568.33 T
--0.12 (windows in) 152.1 556.33 P
-5 F
--0.29 (.t) 200.72 556.33 P
-3 F
--0.12 (. The procedure will receive the name of the focus window as its ar) 212.71 556.33 P
--0.12 (gument.) 479.62 556.33 P
-(Unfortunately) 170.1 544.33 T
-(, if you have created bindings on toplevel windows in your Tk 3.6) 225.52 544.33 T
--0.16 (scripts, they probably expect to trigger only for events in the toplevel, so the bindings will) 152.1 532.33 P
-(misbehave under Tk 4.0. Fortunately you can reproduce the behavior of Tk 3.6 by using) 152.1 520.33 T
-(the) 152.1 508.33 T
-5 F
-(%W) 166.81 508.33 T
-3 F
-( substitution in the binding script. For example, to ensure that) 178.8 508.33 T
-5 F
-(action) 427.28 508.33 T
-3 F
-( is invoked) 463.26 508.33 T
-(only for) 152.1 496.33 T
-5 F
-(Enter) 186.52 496.33 T
-3 F
-( events in a toplevel window itself, create the following binding in place) 216.51 496.33 T
-(of the one above:) 152.1 484.33 T
-5 9 Q
-(bind .t <Enter> {) 179.1 470 T
-(if {"%W" == ".t"} {) 200.63 460 T
-(action) 222.23 450 T
-(}) 200.63 440 T
-(}) 179.1 430 T
-3 10 Q
--0.01 (When an) 152.1 416.33 P
-5 F
--0.03 (Enter) 190.38 416.33 P
-3 F
--0.01 ( event occurs in a descendant of) 220.36 416.33 P
-5 F
--0.03 (.t) 350.45 416.33 P
-3 F
--0.01 ( such as) 362.45 416.33 P
-5 F
--0.03 (.t.x) 396.56 416.33 P
-3 F
--0.01 (, a binding for) 420.54 416.33 P
-5 F
--0.03 (Enter) 479.63 416.33 P
-3 F
-(in) 152.1 404.33 T
-5 F
-(.t.x) 162.37 404.33 T
-3 F
-( will trigger \336rst, if there is one. Then the above binding will trigger) 186.36 404.33 T
-(. Since) 457.58 404.33 T
-5 F
-(%W) 487.29 404.33 T
-3 F
-(will be substituted with) 152.1 392.33 T
-5 F
-(.t.x) 248.17 392.33 T
-3 F
-(, the) 272.15 392.33 T
-5 F
-(if) 291.86 392.33 T
-3 F
-( condition will not be satis\336ed and the binding will) 303.86 392.33 T
-(not do anything.) 152.1 380.33 T
--0.14 ( An alternative solution is to remove the toplevel window from the binding tags of all) 170.1 368.33 P
--0.12 (its internal windows. However) 152.1 356.33 P
--0.12 (, this means that you won\325) 274.03 356.33 P
--0.12 (t be able to take advantage of the) 378.73 356.33 P
-(tag to create key bindings that apply everywhere within the toplevel.) 152.1 344.33 T
-0 F
-(1.6) 127.41 314.33 T
-(Internal bindings in canvases and texts) 152.1 314.33 T
-3 F
-(The same changes in con\337ict resolution described in Section 1.2 also apply to bindings) 152.1 298.33 T
--0.05 (created internally for the items of a canvas or the tags of a text widget. If a canvas item or) 152.1 286.33 P
--0.29 (character of text has multiple tags, then one binding can trigger for each tag on each event.) 152.1 274.33 P
--0.32 (The bindings trigger in the priority order of the tags. Similar porting problems are likely to) 152.1 262.33 P
--0.19 (occur as described in Section 1.4; if a binding for one tag needs to override that of another) 152.1 250.33 P
-(tag, you\325ll need to add a) 152.1 238.33 T
-5 F
-(break) 251.2 238.33 T
-3 F
-( command under Tk 4.0; if a binding for one tag dupli-) 281.18 238.33 T
--0.28 (cated the code from another tag\325) 152.1 226.33 P
--0.28 (s binding, so that they will compose in Tk 3.6, you\325ll have) 279.76 226.33 P
-(to remove the duplicated code in Tk 4.0.) 152.1 214.33 T
-FMENDPAGE
-%%EndPage: "6" 7
-%%Page: "7" 7
-612 792 0 FMBEGINPAGE
-4 10 Q
-0 X
-0 K
-(2 Focus management) 98.1 668.33 T
-0 F
-(7) 506.54 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-98.1 623.98 512.1 627 C
-152.1 625.2 512.1 625.2 2 L
-0.5 H
-2 Z
-0 X
-0 K
-N
-98.1 625.49 143.1 625.49 2 L
-0 Z
-N
-40.5 63 571.5 729 C
-0 12 Q
-0 X
-0 K
-(2) 134.63 631 T
-(Focus management) 152.1 631 T
-3 10 Q
-(The input focus is another area where Tk 4.0 contains major changes. Fortunately) 152.1 607.31 T
-(, the) 477.87 607.31 T
--0.09 (focus changes should not require as many modi\336cations to your Tk 3.6 scripts as the bind-) 152.1 595.31 P
-(ing changes.) 152.1 583.31 T
-0 F
-(2.1) 127.41 553.31 T
-(One focus window per toplevel) 152.1 553.31 T
-3 F
-(Tk 3.6 only keeps track of a single focus window for each application, and this results in) 152.1 537.31 T
-(two problems. First, it doesn\325) 152.1 525.31 T
-(t allow an application to use multiple displays since this) 269.64 525.31 T
--0.16 (could result in multiple simultaneous focus windows, one on each display) 152.1 513.31 P
--0.16 (. Second, the Tk) 444.99 513.31 P
-(3.6 model doesn\325) 152.1 501.31 T
-(t work very well for applications that have multiple toplevels: when the) 221.04 501.31 T
-(mouse moves from one toplevel to another) 152.1 489.31 T
-(, the focus window should switch to whatever) 322.7 489.31 T
--0.24 (window had the focus the last time the mouse was in the new toplevel, but Tk 3.6 does not) 152.1 477.31 P
-(remember this information.) 152.1 465.31 T
-(Tk 4.0 corrects both of these problems. It remembers one focus window for each) 170.1 453.31 T
-(toplevel, which can be queried with the) 152.1 441.31 T
-5 F
-(focus -lastfor) 311.98 441.31 T
-3 F
-( command. When the win-) 395.94 441.31 T
-(dow manager gives the focus to a toplevel window \050because the mouse entered the win-) 152.1 429.31 T
-(dow or because you clicked on the window) 152.1 417.31 T
-(, depending on the focus model being used by) 324.38 417.31 T
-(the window manager\051, Tk passes the focus on to the remembered window) 152.1 405.31 T
-(. Several win-) 446.23 405.31 T
-(dows in an application can have the focus at the same time, one on each display the appli-) 152.1 393.31 T
-(cation is using. When asking for the current focus window in the) 152.1 381.31 T
-5 F
-(focus) 413.31 381.31 T
-3 F
-( command, you) 443.29 381.31 T
-(can use the) 152.1 369.31 T
-5 F
-(-displayof) 199 369.31 T
-3 F
-( switch to specify a particular display) 258.97 369.31 T
-(.) 407.66 369.31 T
-(When you set the focus to a window with the) 170.1 357.31 T
-5 F
-(focus) 353.31 357.31 T
-3 F
-( command, Tk remembers that) 383.29 357.31 T
-(window as the most recent focus window for its toplevel. In addition, if the application) 152.1 345.31 T
-(currently has the focus for the window\325) 152.1 333.31 T
-(s display) 309.2 333.31 T
-(, Tk moves the focus to the speci\336ed win-) 343.82 333.31 T
--0.35 (dow; this can be used, for example to move the focus to a dialog when the dialog is posted,) 152.1 321.31 P
-(or to perform keyboard traversal among the toplevels of an application. If the application) 152.1 309.31 T
-(doesn\325) 152.1 297.31 T
-(t currently have the focus for the display) 178.57 297.31 T
-(, then Tk will not normally take the focus) 339.74 297.31 T
-(from its current owner) 152.1 285.31 T
-(. However) 241.2 285.31 T
-(, you can specify the) 282.43 285.31 T
-5 F
-(-force) 367.36 285.31 T
-3 F
-( ar) 403.34 285.31 T
-(gument to) 413.43 285.31 T
-5 F
-(focus) 456.18 285.31 T
-3 F
-( to) 486.17 285.31 T
-(insist that Tk grab the focus for this application \050in general this is probably not a good) 152.1 273.31 T
-(idea, since it may clash with the window manager) 152.1 261.31 T
-(\325) 352.05 261.31 T
-(s focus policy\051.) 354.83 261.31 T
-0 F
-(2.2) 127.41 231.31 T
-(Keyboard traversal) 152.1 231.31 T
-3 F
--0.38 (Tk 4.0 has a much more complete implementation of keyboard traversal than Tk 3.6. In Tk) 152.1 215.31 P
-(3.6 there is built-in support only for keyboard traversal of menus. In Tk 4.0 keyboard tra-) 152.1 203.31 T
-(versal is implemented for all widgets. Y) 152.1 191.31 T
-(ou can type) 311.27 191.31 T
-5 F
-(Tab) 359.85 191.31 T
-3 F
-( to move the focus among the) 377.84 191.31 T
--0.4 (windows within a toplevel and) 152.1 179.31 P
-5 F
--0.95 (Shift+Tab) 275.31 179.31 P
-3 F
--0.4 ( to move in the reverse direction. The order of) 329.28 179.31 P
--0.11 (traversal is de\336ned by the stacking order of widgets, with the lowest widget \336rst in the tra-) 152.1 167.31 P
-(versal order) 152.1 155.31 T
-(. All Tk widgets now provide a) 199 155.31 T
-5 F
-(-takefocus) 326.14 155.31 T
-3 F
-( option, which determines) 386.11 155.31 T
-FMENDPAGE
-%%EndPage: "7" 8
-%%Page: "8" 8
-612 792 0 FMBEGINPAGE
-0 10 Q
-0 X
-0 K
-(8) 98.1 668.33 T
-4 F
-(Tk4.0 Overview and Porting Guide) 359.34 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-3 F
-0 X
-(whether the window should accept the focus during traversal or be skipped. This option) 152.1 632.33 T
-(has several features; see the) 152.1 620.33 T
-5 F
-(options.n) 265.61 620.33 T
-3 F
-( manual entry for details.) 319.58 620.33 T
-(All of the Tk widgets provide a traversal highlight ring as required by Motif. The) 170.1 608.33 T
-(highlight ring turns dark when the widget has the input focus. Its size and colors are con-) 152.1 596.33 T
-(trolled by the) 152.1 584.33 T
-5 F
-(-highlightthickness) 207.9 584.33 T
-3 F
-(,) 321.84 584.33 T
-5 F
-(-highlightbackground) 326.83 584.33 T
-3 F
-(, and) 446.77 584.33 T
-5 F
-(-) 152.1 572.33 T
-(highlightcolor) 158.1 572.33 T
-3 F
-( options. Y) 242.05 572.33 T
-(ou may notice that widgets appear to have extra space) 285.2 572.33 T
-(around them in Tk 4.0; this is due to the traversal highlight ring, which is normally the) 152.1 560.33 T
-(same color as the background for widgets.) 152.1 548.33 T
-0 F
-(2.3) 127.41 518.33 T
-(Support for focus-follows-mouse) 152.1 518.33 T
-3 F
-(Both Tk 3.6 and Tk 4.0 use an) 152.1 502.33 T
-2 F
-(explicit focus model) 275.91 502.33 T
-3 F
-( within a toplevel. This means that) 355.86 502.33 T
-(moving the mouse among the windows of a toplevel does not normally move the focus;) 152.1 490.33 T
--0.06 (you have to click or perform some other action \050such as pressing) 152.1 478.33 P
-5 F
--0.15 (Tab) 412.26 478.33 P
-3 F
--0.06 (\051 to move the focus.) 430.25 478.33 P
-(Tk 3.6 has no support for an) 152.1 466.33 T
-2 F
-(implicit focus model) 267.58 466.33 T
-3 F
-( where the window under the mouse) 348.64 466.33 T
-(always has the focus. In Tk 4.0 you can invoke the library procedure) 152.1 454.33 T
-5 F
-(tk_focusFol-) 428.83 454.33 T
-(lowsMouse) 152.1 442.33 T
-3 F
-( to switch to an implicit focus model; in this mode whenever the mouse) 206.07 442.33 T
-(enters a new window the focus will switch to that window) 152.1 430.33 T
-(.) 384.07 430.33 T
-0 F
-(2.4) 127.41 400.33 T
-(No default focus window) 152.1 400.33 T
-(, no \322none\323 focus.) 269.45 400.33 T
-3 F
--0.16 (Tk 3.6 has the notion of a default focus window) 152.1 384.33 P
--0.16 (, which receives the focus if the focus win-) 341.56 384.33 P
-(dow is deleted. It is also possible for an application to abandon the input focus by setting) 152.1 372.33 T
-(the focus to) 152.1 360.33 T
-5 F
-(none) 201.23 360.33 T
-3 F
-(. In Tk 4.0 both of these features have been eliminated. There is no) 225.22 360.33 T
-(default focus window) 152.1 348.33 T
-(, and the focus can never be explicitly abandoned. If the focus win-) 238.05 348.33 T
-(dow is destroyed, Tk resets the input focus to the toplevel containing the old focus win-) 152.1 336.33 T
-(dow) 152.1 324.33 T
-(. If the toplevel is destroyed, the window manager will reclaim the focus and move it) 168.66 324.33 T
-(elsewhere.) 152.1 312.33 T
--0.18 (If you really want to abandon the focus in Tk 4.0 so that keyboard events are ignored,) 170.1 300.33 P
-(you can create a dummy window with no key bindings \050set its binding tags to an empty) 152.1 288.33 T
-(string to be sure\051, make sure that is never mapped, and give it the input focus.) 152.1 276.33 T
-0 F
-(2.5) 127.41 246.33 T
-(Better focus events) 152.1 246.33 T
-3 F
--0.13 (Tk 3.6 has a quirky event model for) 152.1 230.33 P
-5 F
--0.32 (FocusIn) 296.77 230.33 P
-3 F
--0.13 ( and) 338.75 230.33 P
-5 F
--0.32 (FocusOut) 357.92 230.33 P
-3 F
--0.13 ( events: when the window) 405.89 230.33 P
--0.23 (manager gives the focus to a toplevel, Tk generates a) 152.1 218.33 P
-5 F
--0.55 (FocusIn) 364.36 218.33 P
-3 F
--0.23 ( event for the toplevel and) 406.33 218.33 P
-(another) 152.1 206.33 T
-5 F
-(FocusIn) 184.57 206.33 T
-3 F
-( event for the focus window) 226.55 206.33 T
-(, but no events for any other windows.) 337.76 206.33 T
-(When the window manager moves the focus somewhere else,) 152.1 194.33 T
-5 F
-(FocusOut) 400.79 194.33 T
-3 F
-( events are gen-) 448.77 194.33 T
--0 (erated for these same two windows. In Tk 4.0,) 152.1 182.33 P
-5 F
--0 (FocusIn) 339.73 182.33 P
-3 F
--0 ( and) 381.71 182.33 P
-5 F
--0 (FocusOut) 401.13 182.33 P
-3 F
--0 ( events are gen-) 449.11 182.33 P
--0.26 (erated in the same way as) 152.1 170.33 P
-5 F
--0.63 (Enter) 255.43 170.33 P
-3 F
--0.26 ( and) 285.41 170.33 P
-5 F
--0.63 (Leave) 304.31 170.33 P
-3 F
--0.26 ( events: when the focus arrives, a) 334.29 170.33 P
-5 F
--0.63 (FocusIn) 467.89 170.33 P
-3 F
--0.05 (event is generated for each window from the toplevel down to the focus window) 152.1 158.33 P
--0.05 (, with dif-) 472.5 158.33 P
-FMENDPAGE
-%%EndPage: "8" 9
-%%Page: "9" 9
-612 792 0 FMBEGINPAGE
-4 10 Q
-0 X
-0 K
-(3 T) 98.1 668.33 T
-(ext widgets) 111.43 668.33 T
-0 F
-(9) 506.54 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-3 F
-0 X
--0.33 (ferent detail \336elds for dif) 152.1 632.33 P
--0.33 (ferent windows \050see Xlib documentation for information on these) 250.53 632.33 P
-(values\051. The reverse happens when the focus leaves a window) 152.1 620.33 T
-(.) 399.57 620.33 T
-0 F
-(2.6) 127.41 590.33 T
-(Porting issues) 152.1 590.33 T
-3 F
-(If you didn\325) 152.1 574.33 T
-(t have any special focus-related code in Tk 3.6, then you shouldn\325) 199.66 574.33 T
-(t need to) 462.9 574.33 T
-(make any changes for 4.0; things will just work better) 152.1 562.33 T
-(. If you wrote code in Tk 3.6 to get) 366.96 562.33 T
-(around the weaknesses with its focus mechanism, then you should remove most or all of) 152.1 550.33 T
-(that code. For example, if you implemented keyboard traversal yourself, or if you built) 152.1 538.33 T
-(your own mechanism to remember a separate focus window for each toplevel and give it) 152.1 526.33 T
-(the input focus whenever the toplevel gets the focus, you can simply remove this code,) 152.1 514.33 T
--0.33 (since Tk 4.0 performs these functions for you. If you wrote code that depends on the weird) 152.1 502.33 P
--0.03 (event model in Tk 3.6, that code will need to be rewritten for Tk 4.0. The Tk 4.0 model is) 152.1 490.33 P
-(general enough to duplicate any ef) 152.1 478.33 T
-(fects that were possible in Tk 3.6.) 289.86 478.33 T
-98.1 434.98 512.1 438 C
-152.1 436.2 512.1 436.2 2 L
-0.5 H
-2 Z
-0 X
-0 K
-N
-98.1 436.49 143.1 436.49 2 L
-0 Z
-N
-40.5 63 571.5 729 C
-0 12 Q
-0 X
-0 K
-(3) 134.63 442 T
-(T) 152.1 442 T
-(ext widgets) 158.54 442 T
-3 10 Q
-(T) 152.1 418.31 T
-(ext widgets have under) 157.51 418.31 T
-(gone a major overhaul for Tk 4.0 and they have improved in) 249.76 418.31 T
-(many ways. The changes to text widgets are almost entirely upward-compatible from Tk) 152.1 406.31 T
-(3.6.) 152.1 394.31 T
-0 F
-(3.1) 127.41 364.31 T
-(Embedded windows.) 152.1 364.31 T
-3 F
-(Tk 3.6 supported two kinds of annotations in texts: marks and tags. In Tk 4.0 a third kind) 152.1 348.31 T
--0.04 (of annotation is available: an embedded window) 152.1 336.31 P
--0.04 (. This allows you to embed other widgets) 344.99 336.31 P
-(inside a text widget, mixed in with the text. The text widget acts as a geometry manager) 152.1 324.31 T
-(for these windows, laying them out and wrapping them just as if each embedded window) 152.1 312.31 T
-(were a single character in the text. Y) 152.1 300.31 T
-(ou can even have texts with nothing in them but) 297.64 300.31 T
-(embedded windows. The) 152.1 288.31 T
-5 F
-(window) 254.8 288.31 T
-3 F
-( widget command for text widgets provides several) 290.78 288.31 T
-(options to manage embedded windows.) 152.1 276.31 T
-0 F
-(3.2) 127.41 246.31 T
-(More options for tags.) 152.1 246.31 T
-3 F
-(In Tk 4.0 tags support many new options providing additional control over how informa-) 152.1 230.31 T
-(tion is displayed. Here is a summary of the new options:) 152.1 218.31 T
-3 12 Q
-(\245) 152.1 203.31 T
-3 10 Q
-(Y) 162.9 203.31 T
-(ou can now specify tab stops with the) 169.12 203.31 T
-5 F
-(-tabs) 321.79 203.31 T
-3 F
-( option. Each tab stop can use left, cen-) 351.78 203.31 T
-(ter) 162.9 191.31 T
-(, right, or numeric justi\336cation. T) 173.04 191.31 T
-(ab stops can also be speci\336ed for the widget as a) 305.6 191.31 T
-(whole.) 162.9 179.31 T
-3 12 Q
-(\245) 152.1 164.31 T
-3 10 Q
-(Y) 162.9 164.31 T
-(ou can specify justi\336cation \050left, center or right\051 with the) 169.12 164.31 T
-5 F
-(-justify) 398.12 164.31 T
-3 F
-( option.) 446.09 164.31 T
-FMENDPAGE
-%%EndPage: "9" 10
-%%Page: "10" 10
-612 792 0 FMBEGINPAGE
-0 10 Q
-0 X
-0 K
-(10) 98.1 668.33 T
-4 F
-(Tk4.0 Overview and Porting Guide) 359.34 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-3 12 Q
-0 X
-(\245) 152.1 632.33 T
-3 10 Q
-(Y) 162.9 632.33 T
-(ou can now specify line spacing with three options,) 169.12 632.33 T
-5 F
-(-spacing1) 376.75 632.33 T
-3 F
-(,) 430.72 632.33 T
-5 F
-(-spacing2) 435.72 632.33 T
-3 F
-(, and) 489.69 632.33 T
-5 F
-(-) 162.9 620.2 T
-(spacing3) 168.9 620.2 T
-3 F
-(, which control the spacing above a line, between wrapped lines, and) 216.87 620.2 T
-(below a line.) 162.9 608.06 T
-3 12 Q
-(\245) 152.1 593.06 T
-3 10 Q
-(Y) 162.9 593.06 T
-(ou can now specify mar) 169.12 593.06 T
-(gins with the) 264.41 593.06 T
-5 F
-(-lmargin1) 318.55 593.06 T
-3 F
-(,) 372.52 593.06 T
-5 F
-(-lmargin2) 377.52 593.06 T
-3 F
-(, and) 431.49 593.06 T
-5 F
-(-rmargin) 453.42 593.06 T
-3 F
-(options.) 162.9 580.92 T
-3 12 Q
-(\245) 152.1 565.92 T
-3 10 Q
--0.25 (Y) 162.9 565.92 P
--0.25 (ou can now adjust the vertical position of text \050e.g. for superscripts or subscripts\051 with) 169.12 565.92 P
-(the) 162.9 553.79 T
-5 F
-(-offset) 177.61 553.79 T
-3 F
-( option.) 219.59 553.79 T
-3 12 Q
-(\245) 152.1 538.79 T
-3 10 Q
--0.03 (Y) 162.9 538.79 P
--0.03 (ou can now specify the wrapping style \050word wrapping, character wrapping, or none\051) 169.12 538.79 P
-(with the) 162.9 526.65 T
-5 F
-(-wrap) 197.88 526.65 T
-3 F
-( option.) 227.86 526.65 T
-3 12 Q
-(\245) 152.1 511.65 T
-3 10 Q
-(Y) 162.9 511.65 T
-(ou can now request overstriking with the) 169.12 511.65 T
-5 F
-(-overstrike) 334.83 511.65 T
-3 F
-( option.) 400.8 511.65 T
-0 F
-(3.3) 127.41 481.65 T
-(Bindings) 152.1 481.65 T
-3 F
--0.19 (The default bindings for text widgets have been completely rewritten in Tk 4.0. They now) 152.1 465.65 P
-(support almost all of the Motif behavior \050everything except add mode and secondary) 152.1 453.52 T
--0.36 (selections\051. They also include a substantial subset of the Emacs bindings for cursor motion) 152.1 441.38 P
-(and basic editing. The) 152.1 429.24 T
-5 F
-(tk_strictMotif) 242.87 429.24 T
-3 F
-( variable disables the Emacs bindings.) 326.82 429.24 T
-0 F
-(3.4) 127.41 399.24 T
-(Miscellaneous new features) 152.1 399.24 T
-3 F
-(In addition to the major changes described above, text widgets also include the following) 152.1 383.24 T
-(new features:) 152.1 371.11 T
-1 F
-(Horizontal scr) 162.9 356.11 T
-(olling) 224.07 356.11 T
-3 F
-(. T) 247.95 356.11 T
-(ext widgets can now be scrolled horizontally as well as verti-) 258.36 356.11 T
-(cally) 162.9 343.97 T
-(, using the) 181.68 343.97 T
-5 F
-(-) 225.55 343.97 T
-(xscrollcommand) 231.54 343.97 T
-3 F
-( option and the) 315.5 343.97 T
-5 F
-(xview) 377.68 343.97 T
-3 F
-( widget command.) 407.67 343.97 T
-1 F
-(Sear) 162.9 328.97 T
-(ching) 182.15 328.97 T
-3 F
-(. T) 205.48 328.97 T
-(ext widgets have a new) 215.88 328.97 T
-5 F
-(search) 311.64 328.97 T
-3 F
-( widget command, which provides ef) 347.62 328.97 T
-(\336-) 495.67 328.97 T
--0.19 (cient searching of text widgets using either exact matching, glob-style matching, or reg-) 162.9 316.83 P
-(ular expressions. Y) 162.9 304.7 T
-(ou can search forwards or backwards.) 238.79 304.7 T
-1 F
-(Mark gravity) 162.9 289.7 T
-3 F
-(. In Tk 3.6 marks always had \322right gravity\323, which means they stick to) 219.71 289.7 T
-(the character on the right side of the mark; if you insert at the position of a mark, the) 162.9 277.56 T
--0.1 (new character goes before the mark. In Tk 4.0 you can specify whether marks have left) 162.9 265.42 P
-(or right gravity) 162.9 253.29 T
-(.) 222.77 253.29 T
-1 F
-(Scr) 162.9 238.29 T
-(een information) 177.15 238.29 T
-3 F
-(. In Tk 4.0 there are two new widget commands for text widgets) 245.16 238.29 T
-(that return information about the screen layout. The) 162.9 226.15 T
-5 F
-(dlineinfo) 371.92 226.15 T
-3 F
-( widget command) 425.89 226.15 T
-(returns the bounding box of a display line \050all the information displayed on one line of) 162.9 214.02 T
-(the window) 162.9 201.88 T
-(, which may be either a whole line of text or a partial line if wrapping has) 209.16 201.88 T
-(occurred\051. The) 162.9 189.74 T
-5 F
-(bbox) 224.23 189.74 T
-3 F
-( widget command returns the screen area occupied by a single) 248.21 189.74 T
-(character) 162.9 177.61 T
-(.) 198.97 177.61 T
-1 F
-(Extended insert command) 162.9 162.61 T
-3 F
-(. The) 275.06 162.61 T
-5 F
-(insert) 298.1 162.61 T
-3 F
-( widget command now supports an addi-) 334.08 162.61 T
--0.32 (tional ar) 162.9 150.47 P
--0.32 (gument giving a list of tags to apply to the new characters. Y) 195.43 150.47 P
--0.32 (ou can also include) 434 150.47 P
-(several text and tag ar) 162.9 138.33 T
-(guments in a single) 250.42 138.33 T
-5 F
-(insert) 330.38 138.33 T
-3 F
-( command.) 366.36 138.33 T
-FMENDPAGE
-%%EndPage: "10" 11
-%%Page: "11" 11
-612 792 0 FMBEGINPAGE
-4 10 Q
-0 X
-0 K
-(4 Better Motif compliance) 98.1 668.33 T
-0 F
-(1) 501.54 668.33 T
-(1) 506.54 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-1 F
-0 X
-(See command) 162.9 632.33 T
-3 F
-(. There is a new) 222.03 632.33 T
-5 F
-(see) 288.08 632.33 T
-3 F
-( widget command, which adjusts the view in the) 306.07 632.33 T
-(widget if needed to ensure that a particular character is visible in the window) 162.9 620.29 T
-(.) 470.07 620.29 T
-0 F
-(3.5) 127.41 590.29 T
-(Porting issues: tag stickiness, change in end) 152.1 590.29 T
-3 F
-(There are two changes in text widgets that may require modi\336cations to Tk 3.6 scripts.) 152.1 574.29 T
--0.06 (The \336rst change has to do with tag stickiness. In Tk 3.6, tags are sticky to the right: if you) 152.1 562.24 P
-(insert new text just after a tagged range, the new text acquires the tags of the preceding) 152.1 550.19 T
-(character) 152.1 538.14 T
-(. If you insert text before a tagged range in Tk 3.6, the new characters do not) 188.17 538.14 T
--0.34 (acquire the tags of the range. In Tk 4.0, tags are not sticky on either side: new text acquires) 152.1 526.09 P
-(a tag from surrounding characters only if the tag is present on both sides of the insertion) 152.1 514.05 T
-(position. The sticky behavior in Tk 3.6 was rarely useful and special code was often) 152.1 502 T
-(needed to work around it. Y) 152.1 489.95 T
-(ou should be able to eliminate this code in Tk 4.0.) 263.24 489.95 T
-(The second incompatible change in text widgets is that the index) 170.1 477.95 T
-5 F
-(end) 431.32 477.95 T
-3 F
-( now refers to) 449.31 477.95 T
--0.14 (the position just after the \336nal newline in the text, whereas in Tk 3.6 it referred to the posi-) 152.1 465.9 P
--0.1 (tion just before the \336nal newline. This makes it possible to apply tags to the \336nal newline,) 152.1 453.86 P
-(which was not possible in Tk 3.6, but you may need to modify your scripts if you depend) 152.1 441.81 T
-(on the old position of) 152.1 429.76 T
-5 F
-(end) 240.11 429.76 T
-3 F
-(.) 258.1 429.76 T
-98.1 386.4 512.1 389.43 C
-152.1 387.63 512.1 387.63 2 L
-0.5 H
-2 Z
-0 X
-0 K
-N
-98.1 387.92 143.1 387.92 2 L
-0 Z
-N
-40.5 63 571.5 729 C
-0 12 Q
-0 X
-0 K
-(4) 134.63 393.43 T
-(Better Motif compliance) 152.1 393.43 T
-3 10 Q
-(All of the widgets have been modi\336ed in Tk 4.0 to improve their Motif compliance. This) 152.1 369.74 T
--0.3 (was done by adding features that were missing and reworking the bindings to comply with) 152.1 357.69 P
-(Motif conventions. I believe that the widgets are now completely Motif compliant except) 152.1 345.64 T
-(for the following missing features:) 152.1 333.6 T
-3 12 Q
-(\245) 152.1 318.6 T
-3 10 Q
-(There is no support for secondary selections.) 162.9 318.6 T
-3 12 Q
-(\245) 152.1 303.6 T
-3 10 Q
-(There is no support for \322add mode\323 in widgets such as texts and listboxes.) 162.9 303.6 T
-3 12 Q
-(\245) 152.1 288.6 T
-3 10 Q
-(There is no support for drag and drop.) 162.9 288.6 T
--0.02 (Please let me know if you \336nd any other discrepancies between the Tk widgets and Motif) 152.1 273.59 P
-(widgets. W) 152.1 261.55 T
-(e plan to eliminate the remaining incompatibilities over the next year or two.) 196.82 261.55 T
-98.1 218.19 512.1 221.21 C
-152.1 219.41 512.1 219.41 2 L
-0.5 H
-2 Z
-0 X
-0 K
-N
-98.1 219.7 143.1 219.7 2 L
-0 Z
-N
-40.5 63 571.5 729 C
-0 12 Q
-0 X
-0 K
-(5) 134.63 225.21 T
-(W) 152.1 225.21 T
-(idget changes) 163.31 225.21 T
-3 10 Q
--0.07 (All of the Tk 4.0 widgets have been improved over their 3.6 counterparts, mostly in small) 152.1 201.52 P
--0.23 (and backwards compatible ways. Here is a summary of the widget improvements; see Sec-) 152.1 189.48 P
-(tion 13 for information about incompatible changes.) 152.1 177.43 T
-3 12 Q
-(\245) 152.1 162.43 T
-3 10 Q
-(All widgets now have a) 162.9 162.43 T
-5 F
-(cget) 259.78 162.43 T
-3 F
-( command, which provides an easier way to retrieve the) 283.76 162.43 T
-(value of a con\336guration option. In other situations where con\336guration options are) 162.9 150.38 T
-(used, such as for menu entries or text tags, a) 162.9 138.33 T
-5 F
-(cget) 342.21 138.33 T
-3 F
-( command is also available.) 366.2 138.33 T
-FMENDPAGE
-%%EndPage: "11" 12
-%%Page: "12" 12
-612 792 0 FMBEGINPAGE
-0 10 Q
-0 X
-0 K
-(12) 98.1 668.33 T
-4 F
-(Tk4.0 Overview and Porting Guide) 359.34 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-3 12 Q
-0 X
-(\245) 152.1 632.33 T
-3 10 Q
--0.22 (All widgets now have) 162.9 632.33 P
-5 F
--0.53 (-highlightthickness) 251.96 632.33 P
-3 F
--0.22 (,) 365.9 632.33 P
-5 F
--0.53 (-highlightbackground) 370.68 632.33 P
-3 F
--0.22 (, and) 490.61 632.33 P
-5 F
-(-) 162.9 620.33 T
-(highlightcolor) 168.9 620.33 T
-3 F
-( options for displaying a highlight ring when the widget \050or one) 252.85 620.33 T
-(of its descendants\051 has the input focus.) 162.9 608.33 T
-3 12 Q
-(\245) 152.1 593.33 T
-3 10 Q
-(Entry widgets now support justi\336cation and provide a) 162.9 593.33 T
-5 F
-(-show) 379.99 593.33 T
-3 F
-( option for \050not\051 display-) 409.97 593.33 T
-(ing passwords. They will autosize to \336t their text if) 162.9 581.33 T
-5 F
-(-width 0) 369.17 581.33 T
-3 F
-( is speci\336ed.) 417.14 581.33 T
-3 12 Q
-(\245) 152.1 566.33 T
-3 10 Q
--0.16 (The label/button family of widgets now supports multiline text and justi\336cation, includ-) 162.9 566.33 P
-(ing new options) 162.9 554.33 T
-5 F
-(-wraplength) 229.25 554.33 T
-3 F
-( and) 295.22 554.33 T
-5 F
-(-justify) 314.65 554.33 T
-3 F
-(. These features make the message) 361.97 554.33 T
--0.04 (widget obsolete. There is also a new) 162.9 542.33 P
-5 F
--0.1 (-underline) 310.27 542.33 P
-3 F
--0.04 ( option for highlighting a character) 370.23 542.33 P
-(for keyboard traversal.) 162.9 530.33 T
-3 12 Q
-(\245) 152.1 515.33 T
-3 10 Q
--0.23 (Listboxes now support all of the Motif selection modes, including single selection, mul-) 162.9 515.33 P
-(tiple selection, and multiple disjoint selections, via the) 162.9 503.33 T
-5 F
-(-selectmode) 382.78 503.33 T
-3 F
-( option. They) 448.74 503.33 T
-(will autosize to \336t their contents if) 162.9 491.33 T
-5 F
-(-width 0) 302.54 491.33 T
-3 F
-( or) 350.52 491.33 T
-5 F
-(-height 0) 363.84 491.33 T
-3 F
-( is speci\336ed. There are) 417.81 491.33 T
-(new) 162.9 479.33 T
-5 F
-(see) 182.05 479.33 T
-3 F
-(,) 200.04 479.33 T
-5 F
-(bbox) 205.04 479.33 T
-3 F
-(, and) 229.02 479.33 T
-5 F
-(activate) 250.95 479.33 T
-3 F
-( widget commands.) 298.92 479.33 T
-3 12 Q
-(\245) 152.1 464.33 T
-3 10 Q
-(Canvas polygons now support) 162.9 464.33 T
-5 F
-(-outline) 286.16 464.33 T
-3 F
-( and) 334.14 464.33 T
-5 F
-(-width) 353.57 464.33 T
-3 F
-( options for drawing outlines.) 389.55 464.33 T
-3 12 Q
-(\245) 152.1 449.33 T
-3 10 Q
--0.03 (Scale widgets now support real values as well as integers \050see the) 162.9 449.33 P
-5 F
--0.08 (-resolution) 426.77 449.33 P
-3 F
--0.03 ( and) 492.73 449.33 P
-5 F
--0.54 (-digits) 162.9 437.33 P
-3 F
--0.22 ( options\051, and they have a) 204.88 437.33 P
-5 F
--0.54 (-variable) 308.73 437.33 P
-3 F
--0.22 ( option to link to a T) 362.7 437.33 P
--0.22 (cl variable. They) 442.83 437.33 P
--0.28 (have two new widget commands,) 162.9 425.33 P
-5 F
--0.67 (coords) 297.52 425.33 P
-3 F
--0.28 ( and) 333.5 425.33 P
-5 F
--0.67 (identify) 352.37 425.33 P
-3 F
--0.28 (, and their bindings are now) 399.69 425.33 P
-(de\336ned in T) 162.9 413.33 T
-(cl rather than being hardwired in C code as in Tk 3.6.) 210.5 413.33 T
-3 12 Q
-(\245) 152.1 398.33 T
-3 10 Q
-(Scrollbar widgets now have a new interface to the controlling widget, which provides) 162.9 398.33 T
--0.04 (more \337exibility than the old style \050but the old style is still supported for compatibility\051.) 162.9 386.33 P
-(There is a new option) 162.9 374.33 T
-5 F
-(-jump) 252 374.33 T
-3 F
-( to prevent continuous updates while dragging the slider) 281.98 374.33 T
-(,) 505.88 374.33 T
--0.24 (and a new option) 162.9 362.33 P
-5 F
--0.59 (-elementborderwidth) 232.98 362.33 P
-3 F
--0.24 ( to control the border width of the arrows) 346.92 362.33 P
-(and slider separately from the widget\325) 162.9 350.33 T
-(s outer border) 314.18 350.33 T
-(. There are four new widget com-) 369.14 350.33 T
-(mands,) 162.9 338.33 T
-5 F
-(activate) 193.99 338.33 T
-3 F
-(,) 241.97 338.33 T
-5 F
-(delta) 246.96 338.33 T
-3 F
-(,) 276.95 338.33 T
-5 F
-(fraction) 281.95 338.33 T
-3 F
-(, and) 329.92 338.33 T
-5 F
-(identify) 351.85 338.33 T
-3 F
-(, and the default bindings) 399.17 338.33 T
-(are now de\336ned in T) 162.9 326.33 T
-(cl rather than being hardwired in C code as in Tk 3.6.) 244.91 326.33 T
-3 12 Q
-(\245) 152.1 311.33 T
-3 10 Q
--0.13 (Menu entries now have several new con\336guration options such as) 162.9 311.33 P
-5 F
--0.31 (-foreground) 426.97 311.33 P
-3 F
--0.13 ( and) 492.93 311.33 P
-5 F
--0.41 (-) 162.9 299.33 P
--0.41 (indicatoron) 168.9 299.33 P
-3 F
--0.17 (, and tear) 234.86 299.33 P
--0.17 (-of) 271.23 299.33 P
--0.17 (f menus have been reimplemented to be more Motif-like.) 282.7 299.33 P
-(New menu entries can be created in the middle of a menu using the) 162.9 287.33 T
-5 F
-(insert) 434.36 287.33 T
-3 F
-( widget) 470.34 287.33 T
-(command, and there is a) 162.9 275.33 T
-5 F
-(type) 262.83 275.33 T
-3 F
-( widget command that returns the type of a menu entry) 286.81 275.33 T
-(.) 505.45 275.33 T
-3 12 Q
-(\245) 152.1 260.33 T
-3 10 Q
-(Menubuttons now have a) 162.9 260.33 T
-5 F
-(-indicatoron) 266.16 260.33 T
-3 F
-( option for displaying an option menu indi-) 338.12 260.33 T
--0.38 (cator) 162.9 248.33 P
--0.38 (. There is now support for option menus via the) 182.33 248.33 P
-5 F
--0.91 (tk_optionMenu) 370.9 248.33 P
-3 F
--0.38 ( procedure, and) 448.86 248.33 P
-(popups are simpli\336ed with the) 162.9 236.33 T
-5 F
-(tk_popup) 286.44 236.33 T
-3 F
-( procedure.) 334.42 236.33 T
-3 12 Q
-(\245) 152.1 221.33 T
-3 10 Q
--0.03 (The variable) 162.9 221.33 P
-5 F
--0.07 (tk_strictMotif) 215.57 221.33 P
-3 F
--0.03 ( is used in more places to enforce even stricter Motif) 299.53 221.33 P
-(compliance.) 162.9 209.33 T
-FMENDPAGE
-%%EndPage: "12" 13
-%%Page: "13" 13
-612 792 0 FMBEGINPAGE
-4 10 Q
-0 X
-0 K
-(6 Images) 98.1 668.33 T
-0 F
-(13) 500.99 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-98.1 623.98 512.1 627 C
-152.1 625.2 512.1 625.2 2 L
-0.5 H
-2 Z
-0 X
-0 K
-N
-98.1 625.49 143.1 625.49 2 L
-0 Z
-N
-40.5 63 571.5 729 C
-0 12 Q
-0 X
-0 K
-(6) 134.63 631 T
-(Images) 152.1 631 T
-3 10 Q
-(Tk 4.0 contains a general-purpose image mechanism for displaying color pictures and) 152.1 607.31 T
-(other complex objects. There is a new command,) 152.1 595.26 T
-5 F
-(image) 350.84 595.26 T
-3 F
-(, which may be used to create) 380.82 595.26 T
-(image objects. For example, the command) 152.1 583.21 T
-5 9 Q
-(image create photo myFace -f) 179.1 568.88 T
-(ile picture.ppm) 330.09 568.88 T
-3 10 Q
-(creates a new image named) 152.1 555.21 T
-5 F
-(myFace) 264.5 555.21 T
-3 F
-(. The image is of type) 300.48 555.21 T
-5 F
-(photo) 390.14 555.21 T
-3 F
-( \050a full-color represen-) 420.12 555.21 T
-(tation that dithers on monochrome or color) 152.1 543.17 T
-(-mapped displays\051 and the source data for the) 323.46 543.17 T
-(image is in the \336le named) 152.1 531.12 T
-5 F
-(picture.ppm) 257.59 531.12 T
-3 F
-(. Once an image has been created, it can be) 323.56 531.12 T
--0.15 (used in many dif) 152.1 519.07 P
--0.15 (ferent places by specifying a) 218.37 519.07 P
-5 F
--0.36 (-image) 334.46 519.07 P
-3 F
--0.15 ( option. For example, the command) 370.44 519.07 P
-5 9 Q
-(label .l -image myFace) 179.1 504.74 T
-3 10 Q
-(will create a label widget that displays the image, and if) 152.1 491.07 T
-5 F
-(.c) 377.5 491.07 T
-3 F
-( is a canvas widget the com-) 389.49 491.07 T
-(mand) 152.1 479.02 T
-5 9 Q
-(.c create image 400 200 -image myFace) 179.1 464.69 T
-3 10 Q
-(will create an image item in the canvas that displays) 152.1 451.02 T
-5 F
-(myFace) 363.06 451.02 T
-3 F
-(.) 399.04 451.02 T
-(The image mechanism provides a great deal of \337exibility:) 170.1 439.02 T
-3 12 Q
-(\245) 152.1 424.02 T
-3 10 Q
--0.18 (Once an image has been de\336ned, it can be used in many dif) 162.9 424.02 P
--0.18 (ferent places, even on dif) 397.84 424.02 P
--0.18 (fer-) 497.68 424.02 P
-(ent displays.) 162.9 411.98 T
-3 12 Q
-(\245) 152.1 396.98 T
-3 10 Q
-(Images provide image commands, analogous to widget commands, that can be used to) 162.9 396.98 T
-(manipulate the image; any changes in an image are automatically re\337ected in all of its) 162.9 384.93 T
-(instances.) 162.9 372.88 T
-3 12 Q
-(\245) 152.1 357.88 T
-3 10 Q
--0.21 (There can be many dif) 162.9 357.88 P
--0.21 (ferent types of images. Tk 4.0 has two built-in types,) 251.78 357.88 P
-5 F
--0.51 (photo) 463.11 357.88 P
-3 F
--0.21 ( and) 493.1 357.88 P
-5 F
-(bitmap) 162.9 345.83 T
-3 F
-(. Other image types can be de\336ned in C as extensions \050see the documentation) 198.88 345.83 T
--0.16 (for the) 162.9 333.79 P
-5 F
--0.39 (Tk_CreateImageType) 191.44 333.79 P
-3 F
--0.16 ( library procedure\051. The photo image type was imple-) 299.38 333.79 P
-(mented by Paul Mackerras, based on his earlier photo widget.) 162.9 321.74 T
-3 12 Q
-(\245) 152.1 306.74 T
-3 10 Q
-(W) 162.9 306.74 T
-(ithin the photo image type, there can be many dif) 171.93 306.74 T
-(ferent \336le formats. In Tk 4.0, only) 368.29 306.74 T
--0.11 (PPM, PGM, and GIF formats are built-in, but other formats can be added as extensions) 162.9 294.69 P
-(\050see the documentation for the) 162.9 282.64 T
-5 F
-(Tk_CreatePhotoImageFormat) 286.97 282.64 T
-3 F
-( library proce-) 436.89 282.64 T
-(dure\051. Readers for XPM, TIFF) 162.9 270.59 T
-(, and others are available from the T) 284.23 270.59 T
-(cl community) 428.41 270.59 T
-(.) 483.01 270.59 T
-98.1 227.24 512.1 230.26 C
-152.1 228.46 512.1 228.46 2 L
-0.5 H
-2 Z
-0 X
-0 K
-N
-98.1 228.75 143.1 228.75 2 L
-0 Z
-N
-40.5 63 571.5 729 C
-0 12 Q
-0 X
-0 K
-(7) 134.63 234.26 T
-(Color management) 152.1 234.26 T
-3 10 Q
-(Tk 3.6 suf) 152.1 210.57 T
-(fers from a relatively weak mechanism for managing colors. It uses only the) 192.73 210.57 T
-(default colormap for a screen, and if all the entries in that colormap \336ll up then Tk) 152.1 198.52 T
-(switches to monochrome mode and \322rounds\323 all future colors to black or white. This) 152.1 186.48 T
-(approach is becoming increasingly unpleasant because of applications such as Frame and) 152.1 174.43 T
-(W) 152.1 162.38 T
-(eb browsers that use up all the entries in the default colormap.) 160.74 162.38 T
-(Tk 4.0 has a much more powerful color management mechanism. If a colormap \336lls) 170.1 150.38 T
-(up, Tk allocates future colors by picking the closest match from the available colors, so) 152.1 138.33 T
-FMENDPAGE
-%%EndPage: "13" 14
-%%Page: "14" 14
-612 792 0 FMBEGINPAGE
-0 10 Q
-0 X
-0 K
-(14) 98.1 668.33 T
-4 F
-(Tk4.0 Overview and Porting Guide) 359.34 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-3 F
-0 X
-(that it need not revert to monochrome mode. Tk also manages colors better by delaying) 152.1 632.33 T
--0.3 (color allocation until colors are actually needed; in many cases, such as 3D borders, colors) 152.1 620.33 P
-(are never needed. When colors are scarce Tk changes the way it displays beveled borders) 152.1 608.33 T
--0.38 (so that it uses stippling instead of additional colors for the light and dark shadows. Y) 152.1 596.33 P
--0.38 (ou can) 484.01 596.33 P
-(\336nd out whether a colormap has \336lled up using the new command) 152.1 584.33 T
-5 F
-(winfo colormap-) 418.59 584.33 T
-(full) 152.1 572.33 T
-3 F
-(.) 176.09 572.33 T
--0.26 (Tk 4.0 also allows you to allocate new colormaps for toplevel and frame widgets with) 170.1 560.33 P
-(the) 152.1 548.33 T
-5 F
-(-colormap) 166.81 548.33 T
-3 F
-( option, and you change the visual type in these widgets \050with the) 220.78 548.33 T
-5 F
-(-) 152.1 536.33 T
-(visual) 158.1 536.33 T
-3 F
-( option\051 to take advantage of visuals other than the default visual for a screen.) 194.08 536.33 T
-(New commands) 152.1 524.33 T
-5 F
-(winfo visualsavailable) 219.27 524.33 T
-3 F
-( and) 351.2 524.33 T
-5 F
-(wm colormapwindows) 370.63 524.33 T
-3 F
-( have) 478.57 524.33 T
-(been added to help manage colormaps and visuals.) 152.1 512.33 T
-(The default color scheme in Tk 4.0 has changed from a tan palette \050\322bisque\323\051 to a) 170.1 500.33 T
-(gray palette, which seems to becoming standard for Motif. There is a new T) 152.1 488.33 T
-(cl procedure) 454.78 488.33 T
-5 F
--0.36 (tk_setPalette) 152.1 476.33 P
-3 F
--0.15 ( that changes the palette of an application on the \337y) 230.06 476.33 P
--0.15 (, and there is also a) 433.89 476.33 P
-(procedure) 152.1 464.33 T
-5 F
-(tk_bisque) 194.56 464.33 T
-3 F
-( to restore the palette to the old bisque colors.) 248.53 464.33 T
-(The Tk 3.6 color model mechanism is no longer necessary so it has been removed in) 170.1 452.33 T
-(Tk 4.0. If you want to \336nd out whether a screen is monochrome or color) 152.1 440.33 T
-(, you cannot use) 440.38 440.33 T
-(the) 152.1 428.33 T
-5 F
-(tk colormodel) 166.81 428.33 T
-3 F
-( command anymore; use) 244.77 428.33 T
-5 F
-(winfo depth) 345.25 428.33 T
-3 F
-( instead.) 411.22 428.33 T
-98.1 384.98 512.1 388 C
-152.1 386.2 512.1 386.2 2 L
-0.5 H
-2 Z
-0 X
-0 K
-N
-98.1 386.49 143.1 386.49 2 L
-0 Z
-N
-40.5 63 571.5 729 C
-0 12 Q
-0 X
-0 K
-(8) 134.63 392 T
-(Event handling: \336leevent and after) 152.1 392 T
-3 10 Q
-(Tk 4.0 contains several improvements in the area of event handling besides those already) 152.1 368.31 T
-(mentioned for bindings:) 152.1 356.31 T
-3 12 Q
-(\245) 152.1 341.31 T
-3 10 Q
-(There is a new command) 162.9 341.31 T
-5 F
-(f) 265.87 341.31 T
-(ileevent) 271.87 341.31 T
-3 F
-( for performing event-driven I/O to and from) 319.84 341.31 T
--0.12 (\336les. The) 162.9 329.31 P
-5 F
--0.29 (f) 202.35 329.31 P
--0.29 (ileevent) 208.35 329.31 P
-3 F
--0.12 ( command is modelled very closely after Mark Diekhans\325) 256.33 329.31 P
-5 F
--0.29 (add-) 488.11 329.31 P
-(input) 162.9 317.31 T
-3 F
-( extension, which has been used widely with Tk 3.6.) 192.88 317.31 T
-3 12 Q
-(\245) 152.1 302.31 T
-3 10 Q
--0.34 (The) 162.9 302.31 P
-5 F
--0.82 (after) 180.6 302.31 P
-3 F
--0.34 ( command has two new options,) 210.58 302.31 P
-5 F
--0.82 (idle) 339.82 302.31 P
-3 F
--0.34 ( and) 363.81 302.31 P
-5 F
--0.82 (cancel) 382.55 302.31 P
-3 F
--0.34 (.) 418.53 302.31 P
-5 F
--0.82 (After idle) 423.19 302.31 P
-3 F
--0.34 ( can be) 482.33 302.31 P
--0.2 (used to schedule a script as an \322idle handler\323, which means it runs the next time that Tk) 162.9 290.31 P
-(enters the event loop and \336nds no work to do.) 162.9 278.31 T
-5 F
-(After cancel) 348.06 278.31 T
-3 F
-( may be used to delete) 420.02 278.31 T
-(a previously-scheduled) 162.9 266.31 T
-5 F
-(after) 257.83 266.31 T
-3 F
-( script, so that it will no longer be invoked.) 287.81 266.31 T
-98.1 222.95 512.1 225.98 C
-152.1 224.18 512.1 224.18 2 L
-0.5 H
-2 Z
-0 X
-0 K
-N
-98.1 224.46 143.1 224.46 2 L
-0 Z
-N
-40.5 63 571.5 729 C
-0 12 Q
-0 X
-0 K
-(9) 134.63 229.98 T
-(Multiple displays) 152.1 229.98 T
-3 10 Q
-(Although Tk has always allowed a single application to open windows on several dis-) 152.1 206.29 T
-(plays, the support for multiple displays is weak in Tk 3.6. For example, many of the bind-) 152.1 194.29 T
-(ings break if users work simultaneously in windows on dif) 152.1 182.29 T
-(ferent displays, and) 385.94 182.29 T
-(mechanisms like the selection and the input focus have insuf) 152.1 170.29 T
-(\336cient support for multiple) 394.26 170.29 T
-(displays.) 152.1 158.29 T
-FMENDPAGE
-%%EndPage: "14" 15
-%%Page: "15" 15
-612 792 0 FMBEGINPAGE
-4 10 Q
-0 X
-0 K
-(10 The send command) 98.1 668.33 T
-0 F
-(15) 500.99 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-3 F
-0 X
--0.33 (Tk 4.0 contains numerous modi\336cations to improve the handling of multiple displays.) 170.1 632.33 P
--0.18 (Several commands, such as) 152.1 620.24 P
-5 F
--0.44 (selection) 263.78 620.24 P
-3 F
--0.18 (,) 317.76 620.24 P
-5 F
--0.44 (send) 322.57 620.24 P
-3 F
--0.18 (, and) 346.55 620.24 P
-5 F
--0.44 (focus) 368.12 620.24 P
-3 F
--0.18 (, have a new) 398.1 620.24 P
-5 F
--0.44 (-displayof) 449.82 620.24 P
-3 F
-(ar) 152.1 608.15 T
-(gument so that you can select a particular display) 159.69 608.15 T
-(. In addition, the bindings have been) 356.12 608.15 T
-(reworked to handle interactions occurring simultaneously on dif) 152.1 596.05 T
-(ferent displays. W) 408.13 596.05 T
-(ith Tk) 480.73 596.05 T
-(4.0 it should be possible to create applications that really use multiple displays gracefully) 152.1 583.96 T
-(.) 508.44 583.96 T
-98.1 540.6 512.1 543.63 C
-152.1 541.83 512.1 541.83 2 L
-0.5 H
-2 Z
-0 X
-0 K
-N
-98.1 542.12 143.1 542.12 2 L
-0 Z
-N
-40.5 63 571.5 729 C
-0 12 Q
-0 X
-0 K
-(10) 127.96 547.63 T
-(The send command) 152.1 547.63 T
-3 10 Q
--0.2 (The) 152.1 523.94 P
-5 F
--0.48 (send) 169.94 523.94 P
-3 F
--0.2 ( command has been completely overhauled for Tk 4.0 to eliminate several prob-) 193.93 523.94 P
-(lems in Tk 3.6 and add a number of new features:) 152.1 511.85 T
-3 12 Q
-(\245) 152.1 496.85 T
-3 10 Q
-(Tk 3.6 aborts a) 162.9 496.85 T
-5 F
-(send) 225.36 496.85 T
-3 F
-( command if no response is received within 5 seconds; this made) 249.34 496.85 T
-(it very dif) 162.9 484.75 T
-(\336cult to invoke long-running commands. Tk 4.0 eliminates the timeout and) 202.14 484.75 T
-(uses a dif) 162.9 472.66 T
-(ferent mechanism to tell if the tar) 200.47 472.66 T
-(get application has crashed.) 333.53 472.66 T
-3 12 Q
-(\245) 152.1 457.66 T
-3 10 Q
--0.36 (The) 162.9 457.66 P
-5 F
--0.87 (winfo interps) 180.58 457.66 P
-3 F
--0.36 ( command no longer returns the names of applications that have) 257.66 457.66 P
-(exited or crashed.) 162.9 445.57 T
-3 12 Q
-(\245) 152.1 430.57 T
-3 10 Q
-(Asynchronous sends are possible using the) 162.9 430.57 T
-5 F
-(-async) 336.67 430.57 T
-3 F
-( switch.) 372.65 430.57 T
-3 12 Q
-(\245) 152.1 415.57 T
-3 10 Q
-(Commands can be sent to displays other than that of the root window) 162.9 415.57 T
-(, using the) 439.3 415.57 T
-5 F
-(-) 162.9 403.47 T
-(displayof) 168.9 403.47 T
-3 F
-( switch.) 222.87 403.47 T
-3 12 Q
-(\245) 152.1 388.47 T
-3 10 Q
-(W) 162.9 388.47 T
-(indow server security is now checked on each) 171.93 388.47 T
-5 F
-(send) 357.89 388.47 T
-3 F
-(, so Tk 4.0 deals better with) 381.88 388.47 T
-(changes in the security of the server) 162.9 376.38 T
-(.) 306.12 376.38 T
-3 12 Q
-(\245) 152.1 361.38 T
-3 10 Q
-(More complete error information \050including the) 162.9 361.38 T
-5 F
-(errorCode) 356.09 361.38 T
-3 F
-( and) 410.06 361.38 T
-5 F
-(errorInfo) 429.49 361.38 T
-3 F
-( vari-) 483.46 361.38 T
-(ables\051 is propagated back to the sender after errors.) 162.9 349.29 T
-3 12 Q
-(\245) 152.1 334.29 T
-3 10 Q
-(Y) 162.9 334.29 T
-(ou can query and change the name of an application with the) 169.12 334.29 T
-5 F
-(tk appname) 414.48 334.29 T
-3 F
-( com-) 474.45 334.29 T
-(mand.) 162.9 322.19 T
-(Unfortunately the improvements to the Tk 4.0) 152.1 307.19 T
-5 F
-(send) 338.65 307.19 T
-3 F
-( mechanism required substantial) 362.63 307.19 T
-(changes to the transport protocol for sends; this makes it impossible for Tk 4.0 applica-) 152.1 295.1 T
-(tions to communicate with Tk 3.6 applications via) 152.1 283.01 T
-5 F
-(send) 355.04 283.01 T
-3 F
-(. The new transport protocol is) 379.02 283.01 T
-(more \337exible than the old protocol, so it should be possible to make protocol improve-) 152.1 270.91 T
-(ments in an upward-compatible way) 152.1 258.82 T
-(.) 296.9 258.82 T
-98.1 215.47 512.1 218.49 C
-152.1 216.69 512.1 216.69 2 L
-0.5 H
-2 Z
-0 X
-0 K
-N
-98.1 216.98 143.1 216.98 2 L
-0 Z
-N
-40.5 63 571.5 729 C
-0 12 Q
-0 X
-0 K
-(1) 128.62 222.49 T
-(1) 134.63 222.49 T
-(The selection and clipboard) 152.1 222.49 T
-3 10 Q
-(In Tk 3.6 the selection mechanism can deal only with the display of the root window and) 152.1 198.8 T
--0.13 (with the primary selection; there is no support for multiple displays, secondary selections,) 152.1 186.71 P
-(or the clipboard. Tk 4.0 eliminates all of these shortcomings. The) 152.1 174.61 T
-5 F
-(-displayof) 415.82 174.61 T
-3 F
-( option) 475.78 174.61 T
--0.12 (can be used to specify a particular display in the selection command, and there is now full) 152.1 162.52 P
-(access to all of the X selection types. Tk 4.0 also includes a new) 152.1 150.43 T
-5 F
-(clipboard) 411.36 150.43 T
-3 F
-( command) 465.33 150.43 T
-(for manipulating the clipboard.) 152.1 138.33 T
-FMENDPAGE
-%%EndPage: "15" 16
-%%Page: "16" 16
-612 792 0 FMBEGINPAGE
-0 10 Q
-0 X
-0 K
-(16) 98.1 668.33 T
-4 F
-(Tk4.0 Overview and Porting Guide) 359.34 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-98.1 623.98 512.1 627 C
-152.1 625.2 512.1 625.2 2 L
-0.5 H
-2 Z
-0 X
-0 K
-N
-98.1 625.49 143.1 625.49 2 L
-0 Z
-N
-40.5 63 571.5 729 C
-0 12 Q
-0 X
-0 K
-(12) 127.96 631 T
-(Miscellaneous changes) 152.1 631 T
-3 10 Q
-(Here is a quick summary of the remaining changes in Tk 4.0:) 152.1 607.31 T
-3 12 Q
-(\245) 152.1 592.31 T
-3 10 Q
--0.17 (The) 162.9 592.31 P
-5 F
--0.42 (wish) 180.76 592.31 P
-3 F
--0.17 ( application has been modi\336ed so that the) 204.75 592.31 P
-5 F
--0.42 (-f) 371.58 592.31 P
--0.42 (ile) 383.57 592.31 P
-3 F
--0.17 ( switch is no longer needed) 401.56 592.31 P
-(or recommended. This makes) 162.9 580.31 T
-5 F
-(wish) 283.64 580.31 T
-3 F
-( just like) 307.63 580.31 T
-5 F
-(tclsh) 344.56 580.31 T
-3 F
-(, where you specify the script \336le) 374.54 580.31 T
-(as the \336rst ar) 162.9 568.31 T
-(gument to the program, e.g.) 214.07 568.31 T
-5 F
-(wish foo.tcl) 327.33 568.31 T
-3 F
-(. The) 399.29 568.31 T
-5 F
-(-f) 422.33 568.31 T
-(ile) 434.32 568.31 T
-3 F
-( switch is still) 452.31 568.31 T
-(permitted for backward compatibility) 162.9 556.31 T
-(, but its use is deprecated.) 311.87 556.31 T
-3 12 Q
-(\245) 152.1 541.31 T
-5 10 Q
-(Wish) 162.9 541.31 T
-3 F
-( now sets the application\325) 186.89 541.31 T
-(s class from the application name \050what appears in the) 288.49 541.31 T
--0.37 (title bar of the window by default\051, rather than always using) 162.9 529.31 P
-5 F
--0.88 (Tk) 400.9 529.31 P
-3 F
--0.37 ( as the class as in Tk 3.6.) 412.89 529.31 P
-(This makes application-speci\336c options easier to use.) 162.9 517.31 T
-3 12 Q
-(\245) 152.1 502.31 T
-3 10 Q
-(T) 162.9 502.31 T
-(oplevel windows are now resizable by default, whereas in Tk 3.6 they were not. Y) 168.31 502.31 T
-(ou) 496.22 502.31 T
-(can use the) 162.9 490.31 T
-5 F
-(wm resizable) 209.8 490.31 T
-3 F
-( command to make windows non-reiszable.) 281.77 490.31 T
-3 12 Q
-(\245) 152.1 475.31 T
-3 10 Q
-(Tk 4.0 patches around an Xlib bug whereby long-running applications tended to reach) 162.9 475.31 T
-(the end of the space of X resource ids, wrap around to 0 again, and then crash. Tk now) 162.9 463.31 T
-(reuses resource identi\336ers so that wrap-around should never occur) 162.9 451.31 T
-(.) 427.14 451.31 T
-3 12 Q
-(\245) 152.1 436.31 T
-3 10 Q
--0.13 (There is a new) 162.9 436.31 P
-5 F
--0.31 (winfo manager) 223.43 436.31 P
-3 F
--0.13 ( command that tells which geometry manager is con-) 301.08 436.31 P
-(trolling a particular widget.) 162.9 424.31 T
-3 12 Q
-(\245) 152.1 409.31 T
-3 10 Q
-(There is a new) 162.9 409.31 T
-5 F
-(bell) 223.96 409.31 T
-3 F
-( command that does what its name suggests.) 247.94 409.31 T
-3 12 Q
-(\245) 152.1 394.31 T
-3 10 Q
-(There are new) 162.9 394.31 T
-5 F
-(winfo pointerx) 222.56 394.31 T
-3 F
-(,) 306.51 394.31 T
-5 F
-(winfo pointery) 311.51 394.31 T
-3 F
-(, and) 394.81 394.31 T
-5 F
-(winfo pointerxy) 416.74 394.31 T
-3 F
-(commands that can be used to query the position of the mouse pointer) 162.9 382.31 T
-(.) 442.17 382.31 T
-98.1 338.95 512.1 341.98 C
-152.1 340.18 512.1 340.18 2 L
-0.5 H
-2 Z
-0 X
-0 K
-N
-98.1 340.46 143.1 340.46 2 L
-0 Z
-N
-40.5 63 571.5 729 C
-0 12 Q
-0 X
-0 K
-(13) 127.96 345.98 T
-(Summary of Incompatibilites) 152.1 345.98 T
-3 10 Q
--0.24 (This section lists all of the incompatible changes in Tk 4.0 that may require changes in T) 152.1 322.29 P
--0.24 (cl) 502.62 322.29 P
--0.22 (scripts written for T) 152.1 310.29 P
--0.22 (cl 3.6. Each incompatibility is described in terms of the problem it pro-) 230.42 310.29 P
-(duces when you run your Tk 3.6 script under Tk 4.0 and a possible work-around. Only) 152.1 298.29 T
-(T) 152.1 286.29 T
-(cl-level incompatibilities are covered here. For incompatible changes at the C level, see) 157.51 286.29 T
-(the) 152.1 274.29 T
-5 F
-(README) 166.81 274.29 T
-3 F
-( and) 202.79 274.29 T
-5 F
-(changes) 222.22 274.29 T
-3 F
-( \336les in the distribution. The problems and solutions are) 264.2 274.29 T
-(roughly in order of importance, with the most important problems \336rst.) 152.1 262.29 T
-1 F
-(Pr) 152.1 247.29 T
-(oblem #1:) 162.46 247.29 T
-3 F
-(When you change the background color of a widget, a small ring in the) 206.88 247.29 T
-(default background color remains around the edge of the widget.) 152.1 235.29 T
-2 F
-(Solution:) 170.1 223.29 T
-3 F
-(This is the focus traversal highlight, whose color is speci\336ed separately) 209.25 223.29 T
-(from) 170.1 211.29 T
-5 F
-(-background) 192.03 211.29 T
-3 F
-(; use the) 257.99 211.29 T
-5 F
-(-highlightbackground) 293.8 211.29 T
-3 F
-( option to change the) 413.74 211.29 T
-(color of the highlight. Or) 170.1 199.29 T
-(, you can set) 269.92 199.29 T
-5 F
-(-highlightthickness) 322.38 199.29 T
-3 F
-( to 0 to eliminate) 436.31 199.29 T
-(the traversal highlight altogether) 170.1 187.29 T
-(.) 299.74 187.29 T
-1 F
-(Pr) 152.1 172.29 T
-(oblem #2:) 162.46 172.29 T
-3 F
-(Bindings de\336ned for a widget no longer replace the corresponding class) 206.88 172.29 T
-(bindings, so unwanted class bindings get invoked in addition to the widget bindings.) 152.1 160.29 T
-FMENDPAGE
-%%EndPage: "16" 17
-%%Page: "17" 17
-612 792 0 FMBEGINPAGE
-4 10 Q
-0 X
-0 K
-(13 Summary of Incompatibilites) 98.1 668.33 T
-0 F
-(17) 500.99 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-2 F
-0 X
-(Solution:) 170.1 632.33 T
-3 F
-(Add a) 209.25 632.33 T
-5 F
-(break) 235.89 632.33 T
-3 F
-( command at the end of the widget binding, or rework the) 265.88 632.33 T
-(widget binding so that it\325) 170.1 620.33 T
-(s OK for the class binding to execute.) 270.05 620.33 T
-1 F
-(Pr) 152.1 605.33 T
-(oblem #3:) 162.46 605.33 T
-3 F
-(Bindings on toplevel windows are invoked when events occur for internal) 206.88 605.33 T
-(windows inside the toplevels.) 152.1 593.33 T
-2 F
-(Solution:) 170.1 581.33 T
-3 F
-(Use the) 209.25 581.33 T
-5 F
-(%W) 242 581.33 T
-3 F
-( substitution to extract the name of the window where the event) 253.99 581.33 T
-(actually occurred, and only execute the rest of the binding script if this matches the) 170.1 569.33 T
-(name of the toplevel.) 170.1 557.33 T
-1 F
--0.15 (Pr) 152.1 542.33 P
--0.15 (oblem #4:) 162.46 542.33 P
-3 F
--0.15 (The) 206.58 542.33 P
-5 F
--0.37 (-command) 224.46 542.33 P
-3 F
--0.15 ( option for a cascade menu entry is no longer invoked when) 272.44 542.33 P
-(the submenu is posted.) 152.1 530.33 T
-2 F
-(Solution:) 170.1 518.33 T
-3 F
-(Use the) 209.25 518.33 T
-5 F
-(-postcommand) 242 518.33 T
-3 F
-( option for the submenu instead.) 313.96 518.33 T
-1 F
-(Pr) 152.1 503.33 T
-(oblem #5:) 162.46 503.33 T
-3 F
-(The) 206.88 503.33 T
-5 F
-(-geometry) 224.92 503.33 T
-3 F
-( option is no longer supported by listboxes, frames, and) 278.89 503.33 T
-(toplevels.) 152.1 491.33 T
-2 F
-(Solution:) 170.1 479.33 T
-3 F
-(Use the) 209.25 479.33 T
-5 F
-(-width) 242 479.33 T
-3 F
-( and) 277.98 479.33 T
-5 F
-(-height) 297.41 479.33 T
-3 F
-( options instead.) 339.39 479.33 T
-1 F
-(Pr) 152.1 464.33 T
-(oblem #6:) 162.46 464.33 T
-3 F
-(The procedure) 206.88 464.33 T
-5 F
-(tk_listboxSingleSelect) 267.38 464.33 T
-3 F
-( no longer exists.) 399.3 464.33 T
-2 F
-(Solution:) 170.1 452.33 T
-3 F
-(Use the) 209.25 452.33 T
-5 F
-(-selectmode) 242 452.33 T
-3 F
-( option on the listbox instead.) 307.96 452.33 T
-1 F
-(Pr) 152.1 437.33 T
-(oblem #7:) 162.46 437.33 T
-3 F
-(Canvases no longer have a) 206.88 437.33 T
-5 F
-(-scrollincrement) 315.96 437.33 T
-3 F
-( option.) 411.91 437.33 T
-2 F
-(Solution:) 170.1 425.33 T
-3 F
-(Use the new) 209.25 425.33 T
-5 F
-(-xscrollincrement) 261.15 425.33 T
-3 F
-( and) 363.09 425.33 T
-5 F
-(-yscrollincrement) 382.52 425.33 T
-3 F
-(options instead.) 170.1 413.33 T
-1 F
-(Pr) 152.1 398.33 T
-(oblem #8:) 162.46 398.33 T
-3 F
-(The) 206.88 398.33 T
-5 F
-(tk colormodel) 224.92 398.33 T
-3 F
-( command no longer exists.) 302.88 398.33 T
-2 F
--0.28 (Solution:) 170.1 386.33 P
-3 F
--0.28 (T) 208.97 386.33 P
--0.28 (o \336nd out whether a window is monochrome or color) 214.37 386.33 P
--0.28 (, use) 424.34 386.33 P
-5 F
--0.68 (winfo depth) 444.6 386.33 P
-3 F
-(to extract the window\325) 170.1 374.33 T
-(s depth; a depth of 1 means monochrome.) 259.76 374.33 T
-1 F
--0.08 (Pr) 152.1 359.33 P
--0.08 (oblem #9:) 162.46 359.33 P
-3 F
--0.08 (The class of Tk applications is no longer) 206.72 359.33 P
-5 F
--0.19 (Tk) 370.97 359.33 P
-3 F
--0.08 (, so options speci\336ed for the) 382.96 359.33 P
-5 F
--0.19 (Tk) 497.69 359.33 P
-3 F
-(class in your) 152.1 347.33 T
-5 F
-(.Xdefaults) 205.12 347.33 T
-3 F
-( \336le are no longer used.) 265.09 347.33 T
-2 F
-(Solution:) 170.1 335.33 T
-3 F
-(Modify your) 209.25 335.33 T
-5 F
-(.Xdefaults) 262.55 335.33 T
-3 F
-( \336le \050and any T) 322.52 335.33 T
-(cl code that sets options\051 to) 382.88 335.33 T
-(specify the name of the application \050with the \336rst letter capitalized\051 as the class) 170.1 323.33 T
-(instead of) 170.1 311.33 T
-5 F
-(Tk) 211.74 311.33 T
-3 F
-(.) 223.73 311.33 T
-1 F
--0.15 (Pr) 152.1 296.33 P
--0.15 (oblem #10:) 162.46 296.33 P
-3 F
--0.15 (When text is added to a text widget just after a tagged area, the new text no) 211.57 296.33 P
-(longer receives the tag.) 152.1 284.33 T
-2 F
--0.1 (Solution:) 170.1 272.33 P
-3 F
--0.1 (Explicitly tag the new text with the desired tags. If you want the tags on the) 209.15 272.33 P
--0.08 (new text to be the same as those at some other point in the text, you can use the) 170.1 260.33 P
-5 F
--0.2 (tag) 488.31 260.33 P
-(names) 170.1 248.33 T
-3 F
-( widget command to query existing tags.) 200.08 248.33 T
-1 F
-(Pr) 152.1 233.33 T
-(oblem #1) 162.46 233.33 T
-(1:) 200.5 233.33 T
-3 F
-(W) 211.33 233.33 T
-(idgets appear lar) 220.36 233.33 T
-(ger than they did in Tk 3.6.) 286.24 233.33 T
-2 F
-(Solution:) 170.1 221.33 T
-3 F
-(There are two issues here. The \336rst is that all widgets now have a focus tra-) 209.25 221.33 T
--0.24 (versal highlight ring that turns dark when the widget has the focus; this is required for) 170.1 209.33 P
-(Motif compliance but you can eliminate it by specifying a 0 value for the) 170.1 197.33 T
-5 F
-( -high-) 462.4 197.33 T
-(lightthickness) 170.1 185.33 T
-3 F
-( option. The second issue is that the default padding for buttons) 254.05 185.33 T
--0.17 (and menubuttons has been increased to match the sizes of Motif widgets. If you don\325) 170.1 173.33 P
--0.17 (t) 506.99 173.33 P
-(mind being dif) 170.1 161.33 T
-(ferent from Motif, you can set the) 228.78 161.33 T
-5 F
-(-padx) 366.45 161.33 T
-3 F
-( and) 396.44 161.33 T
-5 F
-(-) 415.86 161.33 T
-(pady) 421.86 161.33 T
-3 F
-( options back to) 445.85 161.33 T
-FMENDPAGE
-%%EndPage: "17" 18
-%%Page: "18" 18
-612 792 0 FMBEGINPAGE
-0 10 Q
-0 X
-0 K
-(18) 98.1 668.33 T
-4 F
-(Tk4.0 Overview and Porting Guide) 359.34 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-3 F
-0 X
-(their Tk 3.6 values \050use the) 170.1 632.33 T
-5 F
-(conf) 281.41 632.33 T
-(igure) 305.4 632.33 T
-3 F
-( widget command in Tk 3.6 to see what the) 335.38 632.33 T
-(old values were\051.) 170.1 620.33 T
-1 F
-(Pr) 152.1 605.33 T
-(oblem #12:) 162.46 605.33 T
-3 F
-(Listboxes now return the selection as a string with newlines separating the) 211.88 605.33 T
-(values, rather than a T) 152.1 593.33 T
-(cl, list.) 240.49 593.33 T
-2 F
-(Solution:) 170.1 581.33 T
-3 F
-(Modify your code to handle the new format. Y) 209.25 581.33 T
-(ou can convert the selection) 395.06 581.33 T
-(back into the old list format with a script like the following:) 170.1 569.33 T
-5 9 Q
-(split [selection get] \134n) 179.1 555 T
-1 10 Q
-(Pr) 152.1 541.33 T
-(oblem #13:) 162.46 541.33 T
-3 F
-(Tk 4.0 applications cannot) 211.88 541.33 T
-5 F
-(send) 320.42 541.33 T
-3 F
-( to or be sent from Tk 3.6 applications.) 344.4 541.33 T
-2 F
-(Solution:) 170.1 529.33 T
-3 F
-(The only solution is to upgrade all your applications to Tk 4.0.) 209.25 529.33 T
-1 F
--0.17 (Pr) 152.1 514.33 P
--0.17 (oblem #14:) 162.46 514.33 P
-3 F
--0.17 (In texts,) 211.54 514.33 P
-5 F
--0.4 (end) 245.91 514.33 P
-3 F
--0.17 ( now refers to a position just after the \336nal newline, instead of) 263.9 514.33 P
-(the \336nal newline.) 152.1 502.33 T
-2 F
--0.08 (Solution:) 170.1 490.33 P
-3 F
--0.08 (If you wish to refer to the \336nal newline, use the index) 209.17 490.33 P
-5 F
--0.19 (end-1char) 424.98 490.33 P
-3 F
--0.08 ( instead) 478.95 490.33 P
-(of) 170.1 478.33 T
-5 F
-(end) 180.92 478.33 T
-3 F
-(.) 198.91 478.33 T
-1 F
-(Pr) 152.1 463.33 T
-(oblem #15:) 162.46 463.33 T
-3 F
-(In entry widgets,) 211.88 463.33 T
-5 F
-(sel.last) 281.83 463.33 T
-3 F
-( now refers to the character just after the last) 329.8 463.33 T
-(selected one, rather than the last selected one. The second index for the) 152.1 451.33 T
-5 F
-(delete) 438.81 451.33 T
-3 F
-( widget) 474.79 451.33 T
-(command has changed in the same way) 152.1 439.33 T
-(.) 309.66 439.33 T
-2 F
-(Solution:) 170.1 427.33 T
-3 F
-(Add one to the values used in your scripts.) 209.25 427.33 T
-1 F
-(Pr) 152.1 412.33 T
-(oblem #16:) 162.46 412.33 T
-3 F
-(Because) 211.88 412.33 T
-5 F
-(Any) 247.68 412.33 T
-3 F
-( is implicit in all bindings, bindings trigger when extra modi-) 265.67 412.33 T
-(\336ers are present, whereas they didn\325) 152.1 400.33 T
-(t trigger in Tk 3.6.) 296.24 400.33 T
-2 F
-(Solution:) 170.1 388.33 T
-3 F
-(In most cases it\325) 209.25 388.33 T
-(s probably \336ne to ignore the extra modi\336ers. If you really) 273.93 388.33 T
--0.12 (don\325) 170.1 376.33 P
--0.12 (t want any actions to be taken when extra modi\336ers are present, create additional) 188.24 376.33 P
-(bindings for the cases with extra modi\336ers, and specify a single blank character \050or) 170.1 364.33 T
-(any script that does nothing\051 as the script for those bindings. Alternatively) 170.1 352.33 T
-(, you can) 465.93 352.33 T
-(use the) 170.1 340.33 T
-5 F
-(%s) 200.63 340.33 T
-3 F
-( substitution to extract the mouse and modi\336er state in the event binding,) 212.63 340.33 T
-(then you can test this value for modi\336ers you do or don\325) 170.1 328.33 T
-(t want.) 394.5 328.33 T
-1 F
-(Pr) 152.1 313.33 T
-(oblem #17:) 162.46 313.33 T
-3 F
-(In scrollbars there is no longer a) 211.88 313.33 T
-5 F
-(-foreground) 343.17 313.33 T
-3 F
-( or) 409.13 313.33 T
-5 F
-(-activefore-) 422.45 313.33 T
-(ground) 152.1 301.33 T
-3 F
-( option, and) 188.08 301.33 T
-5 F
-(-background) 238.05 301.33 T
-3 F
-( has a dif) 304.02 301.33 T
-(ferent meaning.) 340.2 301.33 T
-2 F
--0.4 (Solution:) 170.1 289.33 P
-3 F
--0.4 (Use) 208.85 289.33 P
-5 F
--0.96 (-troughcolor) 226.49 289.33 P
-3 F
--0.4 ( everywhere that you used) 298.45 289.33 P
-5 F
--0.96 (-background) 403.87 289.33 P
-3 F
--0.4 ( in Tk 3.6,) 469.83 289.33 P
-5 F
-(-background) 170.1 277.33 T
-3 F
-( everywhere you used to use) 236.06 277.33 T
-5 F
-(-foreground) 352.08 277.33 T
-3 F
-(, and) 418.04 277.33 T
-5 F
-(-activeback-) 439.97 277.33 T
-(ground) 170.1 265.33 T
-3 F
-( everywhere you used to use) 206.08 265.33 T
-5 F
-(-activeforeground) 322.1 265.33 T
-3 F
-(.) 424.04 265.33 T
-1 F
-(Pr) 152.1 250.33 T
-(oblem #18:) 162.46 250.33 T
-3 F
-(Options for colors seem to have changed in scale widgets.) 211.88 250.33 T
-2 F
-(Solution:) 170.1 238.33 T
-3 F
-(Use) 209.25 238.33 T
-5 F
-(-background) 227.29 238.33 T
-3 F
-( where you used to use) 293.25 238.33 T
-5 F
-(-sliderforeground) 387.07 238.33 T
-3 F
-(,) 489.02 238.33 T
-5 F
-(-) 170.1 226.33 T
-(troughcolor) 176.1 226.33 T
-3 F
-( where you used to use) 242.06 226.33 T
-5 F
-(-background) 335.88 226.33 T
-3 F
-(, and) 401.84 226.33 T
-5 F
-( -activeback-) 421.27 226.33 T
-(ground) 170.1 214.33 T
-3 F
-( everywhere you used to use) 206.08 214.33 T
-5 F
-(-activeforeground) 322.1 214.33 T
-3 F
-(.) 424.04 214.33 T
-1 F
-(Pr) 152.1 199.33 T
-(oblem #19:) 162.46 199.33 T
-3 F
-(Scale widgets no longer accept hexadecimal or octal numbers in the) 211.88 199.33 T
-5 F
-(set) 485.84 199.33 T
-3 F
-(command or the) 152.1 187.33 T
-5 F
-(-from) 219.55 187.33 T
-3 F
-( and) 249.54 187.33 T
-5 F
-(-to) 268.97 187.33 T
-3 F
-( options.) 286.96 187.33 T
-2 F
-(Solution:) 170.1 175.33 T
-3 F
-(Use) 209.25 175.33 T
-5 F
-(format) 227.29 175.33 T
-3 F
-( or) 263.27 175.33 T
-5 F
-(expr) 276.59 175.33 T
-3 F
-( to convert the values to decimal.) 300.58 175.33 T
-1 F
-(Pr) 152.1 160.33 T
-(oblem #20:) 162.46 160.33 T
-3 F
-(In checkbuttons, radiobuttons, and menu entries, the) 211.88 160.33 T
-5 F
-(-selector) 423.4 160.33 T
-3 F
-( option) 477.37 160.33 T
-(no longer exists.) 152.1 148.33 T
-FMENDPAGE
-%%EndPage: "18" 19
-%%Page: "19" 19
-612 792 0 FMBEGINPAGE
-4 10 Q
-0 X
-0 K
-(13 Summary of Incompatibilites) 98.1 668.33 T
-0 F
-(19) 500.99 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-2 F
-0 X
-(Solution:) 170.1 632.33 T
-3 F
-(Use) 209.25 632.33 T
-5 F
-(-selectcolor) 227.29 632.33 T
-3 F
-( instead of) 299.25 632.33 T
-5 F
-(-select) 343.39 632.33 T
-3 F
-(. T) 385.36 632.33 T
-(o specify that no indicator) 395.77 632.33 T
-(should be drawn at all, use the) 170.1 620.33 T
-5 F
-(-indicatoron) 293.9 620.33 T
-3 F
-( option instead of setting) 365.86 620.33 T
-5 F
-(-select) 467.2 620.33 T
-3 F
-(to an empty string.) 170.1 608.33 T
-1 F
--0.12 (Pr) 152.1 593.33 P
--0.12 (oblem #21:) 162.46 593.33 P
-3 F
--0.12 (The indices of menu entries have changed, and operations on menu entry 0) 211.64 593.33 P
-(no longer work.) 152.1 581.33 T
-2 F
-(Solution:) 170.1 569.33 T
-3 F
-(This is because menus now have a tearof) 209.25 569.33 T
-(f entry at the top by default, and) 372.55 569.33 T
-(this occupies entry 0, so your \336rst entry is now entry 1. Y) 170.1 557.33 T
-(ou can either set the) 398.95 557.33 T
-5 F
-(-) 170.1 545.33 T
-(tearoff) 176.1 545.33 T
-3 F
-( option to 0 to eliminate the tearof) 218.07 545.33 T
-(f entry or add 1 to all the indices you) 354.2 545.33 T
-(use in your scripts.) 170.1 533.33 T
-1 F
--0.22 (Pr) 152.1 518.33 P
--0.22 (oblem #22:) 162.46 518.33 P
-3 F
--0.22 (The) 211.44 518.33 P
-5 F
--0.53 (enable) 229.26 518.33 P
-3 F
--0.22 ( and) 265.24 518.33 P
-5 F
--0.53 (disable) 284.23 518.33 P
-3 F
--0.22 ( widget commands are no longer supported by) 326.21 518.33 P
-(menus.) 152.1 506.33 T
-2 F
-(Solution:) 170.1 494.33 T
-3 F
-(Use the) 209.25 494.33 T
-5 F
-(-state) 242 494.33 T
-3 F
-( con\336guration option instead.) 277.98 494.33 T
-1 F
-(Pr) 152.1 479.33 T
-(oblem #23:) 162.46 479.33 T
-3 F
-(The) 211.88 479.33 T
-5 F
-(activate) 229.92 479.33 T
-3 F
-( and) 277.89 479.33 T
-5 F
-(deactivate) 297.32 479.33 T
-3 F
-( widget commands are no longer sup-) 357.29 479.33 T
-(ported by buttons, checkbuttons, radiobuttons, and menus.) 152.1 467.33 T
-2 F
-(Solution:) 170.1 455.33 T
-3 F
-(Use the) 209.25 455.33 T
-5 F
-(-state) 242 455.33 T
-3 F
-( con\336guration option instead.) 277.98 455.33 T
-1 F
-(Pr) 152.1 440.33 T
-(oblem #24:) 162.46 440.33 T
-3 F
-(Canvas arc items no longer use the) 211.88 440.33 T
-5 F
-(-f) 353.72 440.33 T
-(ill) 365.71 440.33 T
-3 F
-( and) 383.7 440.33 T
-5 F
-(-stipple) 403.13 440.33 T
-3 F
-( options for) 451.11 440.33 T
-(drawing when the) 152.1 428.33 T
-5 F
-(-style) 226.21 428.33 T
-3 F
-( option is) 262.19 428.33 T
-5 F
-(arc) 301.9 428.33 T
-3 F
-(.) 319.89 428.33 T
-2 F
-(Solution:) 170.1 416.33 T
-3 F
-(Use the) 209.25 416.33 T
-5 F
-(-outline) 242 416.33 T
-3 F
-( and) 289.97 416.33 T
-5 F
-(-outlinestipple) 309.4 416.33 T
-3 F
-( options instead.) 399.35 416.33 T
-1 F
--0.29 (Pr) 152.1 401.33 P
--0.29 (oblem #25:) 162.46 401.33 P
-3 F
--0.29 (The variable) 211.29 401.33 P
-5 F
--0.7 (tkVersion) 263.43 401.33 P
-3 F
--0.29 ( no longer exists \050it has been obsolete for several) 317.4 401.33 P
-(releases\051.) 152.1 389.33 T
-2 F
-(Solution:) 170.1 377.33 T
-3 F
-(Use) 209.25 377.33 T
-5 F
-(tk_version) 227.29 377.33 T
-3 F
-( instead.) 287.26 377.33 T
-1 F
-(Pr) 152.1 362.33 T
-(oblem #26:) 162.46 362.33 T
-3 F
-(The syntax of the) 211.88 362.33 T
-5 F
-(scan) 284.05 362.33 T
-3 F
-( widget commands for texts has changed.) 308.03 362.33 T
-2 F
-(Solution:) 170.1 350.33 T
-3 F
-(Modify your code to use the new syntax.) 209.25 350.33 T
-1 F
-(Pr) 152.1 335.33 T
-(oblem #27:) 162.46 335.33 T
-5 F
-(wish) 211.88 335.33 T
-3 F
-( no longer recognizes the) 235.86 335.33 T
-5 F
-(-help) 338.84 335.33 T
-3 F
-( option.) 368.82 335.33 T
-2 F
-(Solution:) 170.1 323.33 T
-3 F
-(Implement this option yourself in your) 209.25 323.33 T
-5 F
-(wish) 366.38 323.33 T
-3 F
-( scripts.) 390.37 323.33 T
-1 F
-(Pr) 152.1 308.33 T
-(oblem #28:) 162.46 308.33 T
-3 F
-(Tk 4.0 always prints real numbers such as canvas coordinates with a deci-) 211.88 308.33 T
-(mal point. This can cause syntax errors if you later use them in situations where integers) 152.1 296.33 T
-(are expected.) 152.1 284.33 T
-2 F
-(Solution:) 170.1 272.33 T
-3 F
-(Change your code so that real numbers work OK, or use the) 209.25 272.33 T
-5 F
-(expr) 451.57 272.33 T
-3 F
-( com-) 475.55 272.33 T
-(mand \050with the) 170.1 260.33 T
-5 F
-(round) 233.12 260.33 T
-3 F
-( function\051 to convert the numbers to integers.) 263.1 260.33 T
-1 F
-(Pr) 152.1 245.33 T
-(oblem #29:) 162.46 245.33 T
-3 F
-(The) 211.88 245.33 T
-5 F
-(pack info) 229.92 245.33 T
-3 F
-( command returns dif) 283.89 245.33 T
-(ferent information, and) 369.48 245.33 T
-5 F
-(pack) 464.41 245.33 T
-(newinfo) 152.1 233.33 T
-3 F
-( no longer exists.) 194.08 233.33 T
-2 F
-(Solution:) 170.1 221.33 T
-3 F
-(Use) 209.25 221.33 T
-5 F
-(pack info) 227.29 221.33 T
-3 F
-( where you used to use) 281.26 221.33 T
-5 F
-(pack newinfo) 375.08 221.33 T
-3 F
-(.) 447.04 221.33 T
-5 F
-(Pack info) 452.04 221.33 T
-3 F
-(was obsolete, so it has been eliminated.) 170.1 209.33 T
-1 F
-(Pr) 152.1 194.33 T
-(oblem #30:) 162.46 194.33 T
-3 F
-(The) 211.88 194.33 T
-5 F
-(view) 229.92 194.33 T
-3 F
-( widget command for entries no longer exists, nor does the) 253.9 194.33 T
-5 F
-(-) 152.1 182.33 T
-(scrollcommand) 158.1 182.33 T
-3 F
-( option.) 236.05 182.33 T
-2 F
--0.29 (Solution:) 170.1 170.33 P
-3 F
--0.29 (Use) 208.96 170.33 P
-5 F
--0.69 (xview) 226.71 170.33 P
-3 F
--0.29 ( where you used to use) 256.7 170.33 P
-5 F
--0.69 (view) 348.8 170.33 P
-3 F
--0.29 (; use) 372.78 170.33 P
-5 F
--0.69 (-xscrollcommand) 393.31 170.33 P
-3 F
--0.29 ( where) 483.26 170.33 P
-(you used to use) 170.1 158.33 T
-5 F
-(-scrollcommand) 234.51 158.33 T
-3 F
-(.) 318.46 158.33 T
-FMENDPAGE
-%%EndPage: "19" 20
-%%Page: "20" 20
-612 792 0 FMBEGINPAGE
-0 10 Q
-0 X
-0 K
-(20) 98.1 668.33 T
-4 F
-(Tk4.0 Overview and Porting Guide) 359.34 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-1 F
-0 X
-(Pr) 152.1 632.33 T
-(oblem #31:) 162.46 632.33 T
-3 F
-(The) 211.88 632.33 T
-5 F
-(-padx) 229.92 632.33 T
-3 F
-( and) 259.9 632.33 T
-5 F
-(-pady) 279.33 632.33 T
-3 F
-( options are ignored for the button family of wid-) 309.31 632.33 T
-(gets if a bitmap or image is being displayed: the padding is always 0.) 152.1 620.02 T
-2 F
--0.27 (Solution:) 170.1 608.02 P
-3 F
--0.27 (Pack the button inside a frame, with extra padding in the frame. Or) 208.98 608.02 P
--0.27 (, redo the) 472.94 608.02 P
-(image or bitmap to incorporate padding into it.) 170.1 595.71 T
-1 F
-(Pr) 152.1 580.71 T
-(oblem #32:) 162.46 580.71 T
-3 F
-(In radiobuttons, the) 211.88 580.71 T
-5 F
-(-value) 292.38 580.71 T
-3 F
-( option no longer defaults to the name of the) 328.36 580.71 T
-(widget; it defaults to an empty string.) 152.1 568.4 T
-2 F
-(Solution:) 170.1 556.4 T
-3 F
-(Specify the widget\325) 209.25 556.4 T
-(s name explicitly as the value of the option.) 286.98 556.4 T
-1 F
-(Pr) 152.1 541.4 T
-(oblem #33:) 162.46 541.4 T
-3 F
-(The) 211.88 541.4 T
-5 F
-(-menu) 229.92 541.4 T
-3 F
-( option for menubuttons and cascade menu entries may refer) 259.9 541.4 T
-(only to a child of the menubutton or menu.) 152.1 529.08 T
-2 F
-(Solution:) 170.1 517.08 T
-3 F
-(Rename menus to meet this requirement.) 209.25 517.08 T
-1 F
-(Pr) 152.1 502.08 T
-(oblem #34:) 162.46 502.08 T
-3 F
-(The interpretation of) 211.88 502.08 T
-5 F
-(@y) 297.09 502.08 T
-3 F
-( in menus has changed: it never returns) 309.08 502.08 T
-5 F
-(none) 467.86 502.08 T
-3 F
-(,) 491.84 502.08 T
-(even if the y-coordinate is outside the menu \050it returns the index of the closest entry\051.) 152.1 489.77 T
-2 F
-(Solution:) 170.1 477.77 T
-3 F
-(If you care about this distinction, check the y-coordinate explicitly to see if) 209.25 477.77 T
--0.17 (it is less than 0 or greater than or equal to the window\325) 170.1 465.46 P
--0.17 (s height \050use) 385.7 465.46 P
-5 F
--0.41 (winfo height) 438.21 465.46 P
-3 F
-(to get the height\051.) 170.1 453.15 T
-1 F
--0.13 (Pr) 152.1 438.15 P
--0.13 (oblem #35:) 162.46 438.15 P
-3 F
--0.13 (The) 211.62 438.15 P
-5 F
--0.3 (invoke) 229.54 438.15 P
-3 F
--0.13 ( and) 265.52 438.15 P
-5 F
--0.3 (activate) 284.7 438.15 P
-3 F
--0.13 ( widget commands for menus no longer post) 332.67 438.15 P
-(cascaded submenus.) 152.1 425.83 T
-2 F
-(Solution:) 170.1 413.83 T
-3 F
-(Use the) 209.25 413.83 T
-5 F
-(postcascade) 242 413.83 T
-3 F
-( widget command to post submenus.) 307.96 413.83 T
-1 F
-(Pr) 152.1 398.83 T
-(oblem #36:) 162.46 398.83 T
-3 F
-(The selection tar) 211.88 398.83 T
-(gets) 278.31 398.83 T
-5 F
-(APPLICATION) 296.91 398.83 T
-3 F
-( and) 362.87 398.83 T
-5 F
-(WINDOW_NAME) 382.3 398.83 T
-3 F
-( are no longer) 448.27 398.83 T
-(supported.) 152.1 386.52 T
-2 F
-(Solution:) 170.1 374.52 T
-3 F
-(Use tar) 209.25 374.52 T
-(gets) 237.65 374.52 T
-5 F
-(TK_APPLICATION) 256.25 374.52 T
-3 F
-( and) 340.21 374.52 T
-5 F
-(TK_WINDOW) 359.64 374.52 T
-3 F
-( instead.) 413.61 374.52 T
-1 F
-(Pr) 152.1 359.52 T
-(oblem #37:) 162.46 359.52 T
-3 F
-(There is no longer a default focus.) 211.88 359.52 T
-2 F
-(Solution:) 170.1 347.52 T
-3 F
-(None: modify your code not to depend on this feature.) 209.25 347.52 T
-1 F
-(Pr) 152.1 332.52 T
-(oblem #38:) 162.46 332.52 T
-3 F
-(The) 211.88 332.52 T
-5 F
-(focus) 229.92 332.52 T
-3 F
-( command now returns an empty string to indicate that the) 259.9 332.52 T
-(application doesn\325) 152.1 320.21 T
-(t have the input focus, instead of) 225.48 320.21 T
-5 F
-(none) 358.17 320.21 T
-3 F
-(.) 382.15 320.21 T
-2 F
-(Solution:) 170.1 308.21 T
-3 F
-(Modify your code to check for an empty string instead of) 209.25 308.21 T
-5 F
-(none) 440.47 308.21 T
-3 F
-(.) 464.46 308.21 T
-1 F
-(Pr) 152.1 293.21 T
-(oblem #39:) 162.46 293.21 T
-5 F
-(FocusIn) 211.88 293.21 T
-3 F
-( and) 253.85 293.21 T
-5 F
-(FocusOut) 273.28 293.21 T
-3 F
-( events are delivered to more windows than) 321.26 293.21 T
-(they used to be.) 152.1 280.9 T
-2 F
--0.02 (Solution:) 170.1 268.9 P
-3 F
--0.02 (Modify your code to use the new set of events. The old event set was some-) 209.23 268.9 P
-(what bizarre, and the new set matches more closely what happens elsewhere, such as) 170.1 256.58 T
-(with) 170.1 244.27 T
-5 F
-(Enter) 190.37 244.27 T
-3 F
-( and) 220.35 244.27 T
-5 F
-(Leave) 239.78 244.27 T
-3 F
-( events.) 269.77 244.27 T
-1 F
--0.28 (Pr) 152.1 229.27 P
--0.28 (oblem #40:) 162.46 229.27 P
-5 F
--0.67 (wm maxsize) 211.32 229.27 P
-3 F
--0.28 ( and) 270.62 229.27 P
-5 F
--0.67 (wm minsize) 289.49 229.27 P
-3 F
--0.28 ( no longer accept empty ar) 348.79 229.27 P
--0.28 (guments. This) 453.52 229.27 P
-(means that you cannot use these commands to make windows non-resizable.) 152.1 216.96 T
-2 F
-(Solution:) 170.1 204.96 T
-3 F
-(Use the) 209.25 204.96 T
-5 F
-(wm resizable) 242 204.96 T
-3 F
-( command to make windows resizable.) 313.96 204.96 T
-1 F
-(Pr) 152.1 189.96 T
-(oblem #41:) 162.46 189.96 T
-3 F
-(In the placer) 211.88 189.96 T
-(, if you specify both) 261.43 189.96 T
-5 F
-(-x) 344.15 189.96 T
-3 F
-( and) 356.15 189.96 T
-5 F
-(-relx) 375.58 189.96 T
-3 F
-( then they add, instead of) 405.56 189.96 T
-(the most recent speci\336cation replacing the earlier one. Ditto for) 152.1 177.65 T
-5 F
-(-y) 407.74 177.65 T
-3 F
-( and) 419.73 177.65 T
-5 F
-(-rely) 439.16 177.65 T
-3 F
-(,) 468.5 177.65 T
-5 F
-(-width) 473.49 177.65 T
-3 F
-(and) 152.1 165.33 T
-5 F
-(-relwidth) 169.03 165.33 T
-3 F
-(, and) 223 165.33 T
-5 F
-(-height) 244.93 165.33 T
-3 F
-( and) 286.91 165.33 T
-5 F
-(-relheight) 306.33 165.33 T
-3 F
-(.) 366.3 165.33 T
-2 F
-(Solution:) 170.1 153.33 T
-3 F
-(If you no longer want one of these options to be used, set it to 0 explicitly) 209.25 153.33 T
-(.) 503.14 153.33 T
-1 F
-(Pr) 152.1 138.33 T
-(oblem #42:) 162.46 138.33 T
-3 F
-(The command \322) 211.88 138.33 T
-5 F
-(focus none) 276.27 138.33 T
-3 F
-(\323 doesn\325) 336.24 138.33 T
-(t work in Tk 4.0.) 369.64 138.33 T
-FMENDPAGE
-%%EndPage: "20" 21
-%%Page: "21" 21
-612 792 0 FMBEGINPAGE
-4 10 Q
-0 X
-0 K
-(13 Summary of Incompatibilites) 98.1 668.33 T
-0 F
-(21) 500.99 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-2 F
-0 X
-(Solution:) 170.1 632.33 T
-3 F
-(Create a dummy widget that is never mapped and set the focus to that wid-) 209.25 632.33 T
-(get.) 170.1 620.33 T
-1 F
-(Pr) 152.1 605.33 T
-(oblem #43:) 162.46 605.33 T
-5 F
-(%D) 211.88 605.33 T
-3 F
-( substitutions are no longer supported in bindings, nor are the event) 223.87 605.33 T
-(types) 152.1 593.33 T
-5 F
-(CirculateRequest) 175.7 593.33 T
-3 F
-(,) 271.64 593.33 T
-5 F
-(Conf) 276.64 593.33 T
-(igureRequest) 300.63 593.33 T
-3 F
-(,) 372.59 593.33 T
-5 F
-(MapRequest) 377.59 593.33 T
-3 F
-(, and) 437.55 593.33 T
-5 F
-(Resiz-) 459.48 593.33 T
-(eRequest) 152.1 581.33 T
-3 F
-(.) 200.07 581.33 T
-2 F
--0.25 (Solution:) 170.1 569.33 P
-3 F
--0.25 (Use the name of the display instead of %D to identify a display; you can get) 209 569.33 P
-(the display name with the) 170.1 557.33 T
-5 F
-(winfo screen) 275.31 557.33 T
-3 F
-( command. The desupported event types) 347.27 557.33 T
-(never really worked anyway) 170.1 545.33 T
-(, so there should be no code that depends on them.) 282.96 545.33 T
-1 F
-(Pr) 152.1 530.33 T
-(oblem #44:) 162.46 530.33 T
-5 F
-(%) 211.88 530.33 T
-3 F
-( binding substitutions that return window identi\336ers, such as) 217.87 530.33 T
-5 F
-(%a) 461.63 530.33 T
-3 F
-( and) 473.62 530.33 T
-5 F
-(%S) 493.05 530.33 T
-3 F
-(,) 505.05 530.33 T
-(now produce hexadecimal results instead of decimal.) 152.1 518.33 T
-2 F
-(Solution:) 170.1 506.33 T
-3 F
-(Use the) 209.25 506.33 T
-5 F
-(format) 242 506.33 T
-3 F
-( command to turn them back to decimal.) 277.98 506.33 T
-1 F
-(Pr) 152.1 491.33 T
-(oblem #45:) 162.46 491.33 T
-5 F
-(Enter) 211.88 491.33 T
-3 F
-(,) 241.46 491.33 T
-5 F
-(Leave) 246.46 491.33 T
-3 F
-(,) 276.44 491.33 T
-5 F
-(FocusIn) 281.44 491.33 T
-3 F
-(, and) 323.42 491.33 T
-5 F
-(FocusOut) 345.34 491.33 T
-3 F
-( events with detail) 393.32 491.33 T
-5 F
-(Notify-) 468.83 491.33 T
-(Inferior) 152.1 479.33 T
-3 F
-( are now ignored by the binding mechanism, so they\325re not visible to T) 200.07 479.33 T
-(cl) 483.08 479.33 T
-(scripts.) 152.1 467.33 T
-2 F
--0.13 (Solution:) 170.1 455.33 P
-3 F
--0.13 (In most cases, T) 209.12 455.33 P
--0.13 (cl scripts work better if these bindings are ignored. Y) 273 455.33 P
--0.13 (ou can) 483.49 455.33 P
-(still use C code to access these events if you really need them. Or) 170.1 443.33 T
-(, create bindings on) 431.18 443.33 T
--0.33 (the inferior windows and use) 170.1 431.33 P
-5 F
--0.8 (NotifyAncestor) 286.96 431.33 P
-3 F
--0.33 ( bindings on the children instead of) 370.91 431.33 P
-5 F
-(NotifyInferior) 170.1 419.33 T
-3 F
-( bindings on the parent.) 254.05 419.33 T
-FMENDPAGE
-%%EndPage: "21" 22
-%%Page: "22" 22
-612 792 0 FMBEGINPAGE
-0 10 Q
-0 X
-0 K
-(22) 98.1 668.33 T
-4 F
-(Tk4.0 Overview and Porting Guide) 359.34 668.33 T
-98.1 660.6 512.1 660.6 2 L
-0.25 H
-0 Z
-N
-98.1 135 512.1 639 R
-7 X
-V
-FMENDPAGE
-%%EndPage: "22" 23
-%%Trailer
-%%BoundingBox: 0 0 612 792
-%%Pages: 22 1
-%%DocumentFonts: Helvetica-Bold
-%%+ Times-Bold
-%%+ Times-Italic
-%%+ Times-Roman
-%%+ Helvetica
-%%+ Courier
-%%+ Courier-Oblique
diff --git a/doc/tkerror.n b/doc/tkerror.n
deleted file mode 100644
index 61b8350..0000000
--- a/doc/tkerror.n
+++ /dev/null
@@ -1,38 +0,0 @@
-'\"
-'\" 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: tkerror.n,v 1.2 1998/09/14 18:23:00 stanton Exp $
-'\"
-.so man.macros
-.TH tkerror n 4.1 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-tkerror \- Command invoked to process background errors
-.SH SYNOPSIS
-\fBtkerror \fImessage\fR
-.BE
-
-.SH DESCRIPTION
-.PP
-Note: as of Tk 4.1 the \fBtkerror\fR command has been renamed to
-\fBbgerror\fR because the event loop (which is what usually invokes
-it) is now part of Tcl. For backward compatibility
-the \fBbgerror\fR provided by the current Tk version still
-tries to call \fBtkerror\fR if there is one (or an auto loadable one),
-so old script defining that error handler should still work, but you
-should anyhow modify your scripts to use \fBbgerror\fR instead
-of \fBtkerror\fR because that support for the old name might vanish
-in the near future. If that call fails, \fBbgerror\fR
-posts a dialog showing the error and offering to see the stack trace
-to the user. If you want your own error management you should
-directly override \fBbgerror\fR instead of \fBtkerror\fR.
-Documentation for \fBbgerror\fR is available as part of Tcl's
-documentation.
-
-.SH KEYWORDS
-background error, reporting
diff --git a/doc/tkvars.n b/doc/tkvars.n
deleted file mode 100644
index f2e9a73..0000000
--- a/doc/tkvars.n
+++ /dev/null
@@ -1,72 +0,0 @@
-'\"
-'\" 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: tkvars.n,v 1.2 1998/09/14 18:23:00 stanton Exp $
-'\"
-.so man.macros
-.TH tkvars n 4.1 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-tkvars \- Variables used or set by Tk
-.BE
-
-.SH DESCRIPTION
-.PP
-The following Tcl variables are either set or used by Tk at various times
-in its execution:
-.TP 15
-\fBtk_library\fR
-This variable holds the file name for a directory containing a library
-of Tcl scripts related to Tk. These scripts include an initialization
-file that is normally processed whenever a Tk application starts up,
-plus other files containing procedures that implement default behaviors
-for widgets.
-The initial value of \fBtcl_library\fR is set when Tk is added to
-an interpreter; this is done by searching several different directories
-until one is found that contains an appropriate Tk startup script.
-If the \fBTK_LIBRARY\fR environment variable exists, then
-the directory it names is checked first.
-If \fBTK_LIBRARY\fR isn't set or doesn't refer to an appropriate
-directory, then Tk checks several other directories based on a
-compiled-in default location, the location of the Tcl library directory,
-the location of the binary containing the application, and the current
-working directory.
-The variable can be modified by an application to switch to a different
-library.
-.TP
-\fBtk_patchLevel\fR
-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
-This variable is an array containing several pieces of information
-that are private to Tk. The elements of \fBtkPriv\fR are used by
-Tk library procedures and default bindings.
-They should not be accessed by any code outside Tk.
-.TP
-\fBtk_strictMotif\fR
-This variable is set to zero by default.
-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 15
-\fBtk_version\fR
-Tk sets this variable in the interpreter for each application.
-The variable holds the current version number of the Tk
-library in the form \fImajor\fR.\fIminor\fR. \fIMajor\fR and
-\fIminor\fR are integers. The major version number increases in
-any Tk release that includes changes that are not backward compatible
-(i.e. whenever existing Tk applications and scripts may have to change to
-work with the new release). The minor version number increases with
-each new release of Tk, except that it resets to zero whenever the
-major version number changes.
-
-.SH KEYWORDS
-variables, version
diff --git a/doc/tkwait.n b/doc/tkwait.n
deleted file mode 100644
index b3282c2..0000000
--- a/doc/tkwait.n
+++ /dev/null
@@ -1,51 +0,0 @@
-'\"
-'\" 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: tkwait.n,v 1.2 1998/09/14 18:23:00 stanton Exp $
-'\"
-.so man.macros
-.TH tkwait n "" Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-tkwait \- Wait for variable to change or window to be destroyed
-.SH SYNOPSIS
-\fBtkwait variable \fIname\fR
-.sp
-\fBtkwait visibility \fIname\fR
-.sp
-\fBtkwait window \fIname\fR
-.BE
-
-.SH DESCRIPTION
-.PP
-The \fBtkwait\fR command waits for one of several things to happen,
-then it returns without taking any other actions.
-The return value is always an empty string.
-If the first argument is \fBvariable\fR (or any abbreviation of
-it) then the second argument is the name of a global variable and the
-command waits for that variable to be modified.
-If the first argument is \fBvisibility\fR (or any abbreviation
-of it) then the second argument is the name of a window and the
-\fBtkwait\fR command waits for a change in its
-visibility state (as indicated by the arrival of a VisibilityNotify
-event). This form is typically used to wait for a newly-created
-window to appear on the screen before taking some action.
-If the first argument is \fBwindow\fR (or any abbreviation
-of it) then the second argument is the name of a window and the
-\fBtkwait\fR command waits for that window to be destroyed.
-This form is typically used to wait for a user to finish interacting
-with a dialog box before using the result of that interaction.
-.PP
-While the \fBtkwait\fR command is waiting it processes events in
-the normal fashion, so the application will continue to respond
-to user interactions.
-If an event handler invokes \fBtkwait\fR again, the nested call
-to \fBtkwait\fR must complete before the outer call can complete.
-
-.SH KEYWORDS
-variable, visibility, wait, window
diff --git a/doc/toplevel.n b/doc/toplevel.n
deleted file mode 100644
index 160ac88..0000000
--- a/doc/toplevel.n
+++ /dev/null
@@ -1,163 +0,0 @@
-'\"
-'\" 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: toplevel.n,v 1.2 1998/09/14 18:23:00 stanton Exp $
-'\"
-.so man.macros
-.TH toplevel n 8.0 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-toplevel \- Create and manipulate toplevel widgets
-.SH SYNOPSIS
-\fBtoplevel\fR \fIpathName \fR?\fIoptions\fR?
-.SO
-\-borderwidth \-highlightbackground \-highlightthickness \-takefocus
-\-cursor \-highlightcolor \-relief
-.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 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
-(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.
-.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
-different display.
-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
-a hexadecimal string like the ones returned by the \fBwinfo id\fR
-command. The toplevel widget will be created as a child of the given
-container instead of the root window for the screen. If the container
-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.
-If this option is not specified, the new window will use the default
-visual for its screen.
-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 \fBtoplevel\fR command creates a new toplevel widget (given
-by the \fIpathName\fR argument). Additional
-options, described above, may be specified on the command line
-or in the option database
-to configure aspects of the toplevel such as its background color
-and relief. The \fBtoplevel\fR command returns the
-path name of the new window.
-.PP
-A toplevel is similar to a frame except that it is created as a
-top-level window: its X parent is the root window of a screen
-rather than the logical parent from its path name. The primary
-purpose of a toplevel is to serve as a container for dialog boxes
-and other collections of widgets. The only visible features
-of a toplevel are its background color and an optional 3-D border
-to make the toplevel appear raised or sunken.
-
-.SH "WIDGET COMMAND"
-.PP
-The \fBtoplevel\fR command creates a new Tcl command whose
-name is the same as the path name of the toplevel's window. This
-command may be used to invoke various
-operations on the widget. It has the following general form:
-.CS
-\fIpathName option \fR?\fIarg arg ...\fR?
-.CE
-\fIPathName\fR is the name of the command, which is the same as
-the toplevel widget's path name. \fIOption\fR and the \fIarg\fRs
-determine the exact behavior of the command. The following
-commands are possible for toplevel widgets:
-.TP
-\fIpathName \fBcget\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 \fBtoplevel\fR
-command.
-.TP
-\fIpathName \fBconfigure\fR ?\fIoption\fR? ?\fIvalue option value ...\fR?
-Query or modify the configuration options of the widget.
-If no \fIoption\fR is specified, returns a list describing all of
-the available options for \fIpathName\fR (see \fBTk_ConfigureInfo\fR for
-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 \fBtoplevel\fR
-command.
-
-.SH BINDINGS
-.PP
-When a new toplevel is created, it has no default event bindings:
-toplevels are not intended to be interactive.
-
-.SH KEYWORDS
-toplevel, widget
diff --git a/doc/winfo.n b/doc/winfo.n
deleted file mode 100644
index f9e4de1..0000000
--- a/doc/winfo.n
+++ /dev/null
@@ -1,330 +0,0 @@
-'\"
-'\" Copyright (c) 1990-1994 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: winfo.n,v 1.2 1998/09/14 18:23:00 stanton Exp $
-'\"
-.so man.macros
-.TH winfo n 4.3 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-winfo \- Return window-related information
-.SH SYNOPSIS
-\fBwinfo\fR \fIoption \fR?\fIarg arg ...\fR?
-.BE
-
-.SH DESCRIPTION
-.PP
-The \fBwinfo\fR command is used to retrieve information about windows
-managed by Tk. It can take any of a number of different forms,
-depending on the \fIoption\fR argument. The legal forms are:
-.TP
-\fBwinfo atom \fR?\fB\-displayof \fIwindow\fR? \fIname\fR
-Returns a decimal string giving the integer identifier for the
-atom whose name is \fIname\fR. If no atom exists with the name
-\fIname\fR then a new one is created.
-If the \fB\-displayof\fR option is given then the atom is looked
-up on the display of \fIwindow\fR; otherwise it is looked up on
-the display of the application's main window.
-.TP
-\fBwinfo atomname \fR?\fB\-displayof \fIwindow\fR? \fIid\fR
-Returns the textual name for the atom whose integer identifier is
-\fIid\fR.
-If the \fB\-displayof\fR option is given then the identifier is looked
-up on the display of \fIwindow\fR; otherwise it is looked up on
-the display of the application's main window.
-This command is the inverse of the \fBwinfo atom\fR command.
-It generates an error if no such atom exists.
-.TP
-\fBwinfo cells \fIwindow\fR
-Returns a decimal string giving the number of cells in the
-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.
-.TP
-\fBwinfo class \fIwindow\fR
-Returns the class name for \fIwindow\fR.
-.TP
-\fBwinfo colormapfull \fIwindow\fR
-Returns 1 if the colormap for \fIwindow\fR is known to be full, 0
-otherwise. The colormap for a window is ``known'' to be full if the last
-attempt to allocate a new color on that window failed and this
-application hasn't freed any colors in the colormap since the
-failed allocation.
-.TP
-\fBwinfo containing \fR?\fB\-displayof \fIwindow\fR? \fIrootX rootY\fR
-Returns the path name for the window containing the point given
-by \fIrootX\fR and \fIrootY\fR.
-\fIRootX\fR and \fIrootY\fR are specified in screen units (i.e.
-any form acceptable to \fBTk_GetPixels\fR) in the coordinate
-system of the root window (if a virtual-root window manager is in
-use then the coordinate system of the virtual root window is used).
-If the \fB\-displayof\fR option is given then the coordinates refer
-to the screen containing \fIwindow\fR; otherwise they refer to the
-screen of the application's main window.
-If no window in this application contains the point then an empty
-string is returned.
-In selecting the containing window, children are given higher priority
-than parents and among siblings the highest one in the stacking order is
-chosen.
-.TP
-\fBwinfo depth \fIwindow\fR
-Returns a decimal string giving the depth of \fIwindow\fR (number
-of bits per pixel).
-.TP
-\fBwinfo exists \fIwindow\fR
-Returns 1 if there exists a window named \fIwindow\fR, 0 if no such
-window exists.
-.TP
-\fBwinfo fpixels \fIwindow\fR \fInumber\fR
-Returns a floating-point value giving the number of pixels
-in \fIwindow\fR corresponding to the distance given by \fInumber\fR.
-\fINumber\fR may be specified in any of the forms acceptable
-to \fBTk_GetScreenMM\fR, such as ``2.0c'' or ``1i''.
-The return value may be fractional; for an integer value, use
-\fBwinfo pixels\fR.
-.TP
-\fBwinfo geometry \fIwindow\fR
-Returns the geometry for \fIwindow\fR, in the form
-\fIwidth\fBx\fIheight\fB+\fIx\fB+\fIy\fR. All dimensions are
-in pixels.
-.TP
-\fBwinfo height \fIwindow\fR
-Returns a decimal string giving \fIwindow\fR's height in pixels.
-When a window is first created its height will be 1 pixel; the
-height will eventually be changed by a geometry manager to fulfill
-the window's needs.
-If you need the true height immediately after creating a widget,
-invoke \fBupdate\fR to force the geometry manager to arrange it,
-or use \fBwinfo reqheight\fR to get the window's requested height
-instead of its actual height.
-.TP
-\fBwinfo id \fIwindow\fR
-.VS
-Returns a hexadecimal string giving a low-level platform-specific
-identifier for \fIwindow\fR. On Unix platforms, this is the X
-window identifier. Under Windows, this is the Windows
-HWND. On the Macintosh the value has no meaning outside Tk.
-.VE
-.TP
-\fBwinfo interps \fR?\fB\-displayof \fIwindow\fR?
-Returns a list whose members are the names of all Tcl interpreters
-(e.g. all Tk-based applications) currently registered for a particular display.
-If the \fB\-displayof\fR option is given then the return value refers
-to the display of \fIwindow\fR; otherwise it refers to
-the display of the application's main window.
-.TP
-\fBwinfo ismapped \fIwindow\fR
-Returns \fB1\fR if \fIwindow\fR is currently mapped, \fB0\fR otherwise.
-.TP
-\fBwinfo manager \fIwindow\fR
-Returns the name of the geometry manager currently
-responsible for \fIwindow\fR, or an empty string if \fIwindow\fR
-isn't managed by any geometry manager.
-The name is usually the name of the Tcl command for the geometry
-manager, such as \fBpack\fR or \fBplace\fR.
-If the geometry manager is a widget, such as canvases or text, the
-name is the widget's class command, such as \fBcanvas\fR.
-.TP
-\fBwinfo name \fIwindow\fR
-Returns \fIwindow\fR's name (i.e. its name within its parent, as opposed
-to its full path name).
-The command \fBwinfo name .\fR will return the name of the application.
-.TP
-\fBwinfo parent \fIwindow\fR
-Returns the path name of \fIwindow\fR's parent, or an empty string
-if \fIwindow\fR is the main window of the application.
-.TP
-\fBwinfo pathname \fR?\fB\-displayof \fIwindow\fR? \fIid\fR
-Returns the path name of the window whose X identifier is \fIid\fR.
-\fIId\fR must be a decimal, hexadecimal, or octal integer and must
-correspond to a window in the invoking application.
-If the \fB\-displayof\fR option is given then the identifier is looked
-up on the display of \fIwindow\fR; otherwise it is looked up on
-the display of the application's main window.
-.TP
-\fBwinfo pixels \fIwindow\fR \fInumber\fR
-Returns the number of pixels in \fIwindow\fR corresponding
-to the distance given by \fInumber\fR.
-\fINumber\fR may be specified in any of the forms acceptable
-to \fBTk_GetPixels\fR, such as ``2.0c'' or ``1i''.
-The result is rounded to the nearest integer value; for a
-fractional result, use \fBwinfo fpixels\fR.
-.TP
-\fBwinfo pointerx \fIwindow\fR
-If the mouse pointer is on the same screen as \fIwindow\fR, returns the
-pointer's x coordinate, measured in pixels in the screen's root window.
-If a virtual root window is in use on the screen, the position is
-measured in the virtual root.
-If the mouse pointer isn't on the same screen as \fIwindow\fR then
--1 is returned.
-.TP
-\fBwinfo pointerxy \fIwindow\fR
-If the mouse pointer is on the same screen as \fIwindow\fR, returns a list
-with two elements, which are the pointer's x and y coordinates measured
-in pixels in the screen's root window.
-If a virtual root window is in use on the screen, the position
-is computed in the virtual root.
-If the mouse pointer isn't on the same screen as \fIwindow\fR then
-both of the returned coordinates are -1.
-.TP
-\fBwinfo pointery \fIwindow\fR
-If the mouse pointer is on the same screen as \fIwindow\fR, returns the
-pointer's y coordinate, measured in pixels in the screen's root window.
-If a virtual root window is in use on the screen, the position
-is computed in the virtual root.
-If the mouse pointer isn't on the same screen as \fIwindow\fR then
--1 is returned.
-.TP
-\fBwinfo reqheight \fIwindow\fR
-Returns a decimal string giving \fIwindow\fR's requested height,
-in pixels. This is the value used by \fIwindow\fR's geometry
-manager to compute its geometry.
-.TP
-\fBwinfo reqwidth \fIwindow\fR
-Returns a decimal string giving \fIwindow\fR's requested width,
-in pixels. This is the value used by \fIwindow\fR's geometry
-manager to compute its geometry.
-.TP
-\fBwinfo rgb \fIwindow color\fR
-Returns a list containing three decimal values, which are the
-red, green, and blue intensities that correspond to \fIcolor\fR in
-the window given by \fIwindow\fR. \fIColor\fR
-may be specified in any of the forms acceptable for a color
-option.
-.TP
-\fBwinfo rootx \fIwindow\fR
-Returns a decimal string giving the x-coordinate, in the root
-window of the screen, of the
-upper-left corner of \fIwindow\fR's border (or \fIwindow\fR if it
-has no border).
-.TP
-\fBwinfo rooty \fIwindow\fR
-Returns a decimal string giving the y-coordinate, in the root
-window of the screen, of the
-upper-left corner of \fIwindow\fR's border (or \fIwindow\fR if it
-has no border).
-.TP
-\fBwinfo screen \fIwindow\fR
-Returns the name of the screen associated with \fIwindow\fR, in
-the form \fIdisplayName\fR.\fIscreenIndex\fR.
-.TP
-\fBwinfo screencells \fIwindow\fR
-Returns a decimal string giving the number of cells in the default
-color map for \fIwindow\fR's screen.
-.TP
-\fBwinfo screendepth \fIwindow\fR
-Returns a decimal string giving the depth of the root window
-of \fIwindow\fR's screen (number of bits per pixel).
-.TP
-\fBwinfo screenheight \fIwindow\fR
-Returns a decimal string giving the height of \fIwindow\fR's screen,
-in pixels.
-.TP
-\fBwinfo screenmmheight \fIwindow\fR
-Returns a decimal string giving the height of \fIwindow\fR's screen,
-in millimeters.
-.TP
-\fBwinfo screenmmwidth \fIwindow\fR
-Returns a decimal string giving the width of \fIwindow\fR's screen,
-in millimeters.
-.TP
-\fBwinfo screenvisual \fIwindow\fR
-Returns one of the following strings to indicate the default visual
-class for \fIwindow\fR's screen: \fBdirectcolor\fR, \fBgrayscale\fR,
-\fBpseudocolor\fR, \fBstaticcolor\fR, \fBstaticgray\fR, or
-\fBtruecolor\fR.
-.TP
-\fBwinfo screenwidth \fIwindow\fR
-Returns a decimal string giving the width of \fIwindow\fR's screen,
-in pixels.
-.TP
-\fBwinfo server \fIwindow\fR
-Returns a string containing information about the server for
-\fIwindow\fR's display. The exact format of this string may vary
-from platform to platform. For X servers the string
-has the form ``\fBX\fImajor\fBR\fIminor vendor vendorVersion\fR''
-where \fImajor\fR and \fIminor\fR are the version and revision
-numbers provided by the server (e.g., \fBX11R5\fR), \fIvendor\fR
-is the name of the vendor for the server, and \fIvendorRelease\fR
-is an integer release number provided by the server.
-.TP
-\fBwinfo toplevel \fIwindow\fR
-Returns the path name of the top-level window containing \fIwindow\fR.
-.TP
-\fBwinfo viewable \fIwindow\fR
-Returns 1 if \fIwindow\fR and all of its ancestors up through the
-nearest toplevel window are mapped. Returns 0 if any of these
-windows are not mapped.
-.TP
-\fBwinfo visual \fIwindow\fR
-Returns one of the following strings to indicate the visual
-class for \fIwindow\fR: \fBdirectcolor\fR, \fBgrayscale\fR,
-\fBpseudocolor\fR, \fBstaticcolor\fR, \fBstaticgray\fR, or
-\fBtruecolor\fR.
-.TP
-\fBwinfo visualid \fIwindow\fR
-Returns the X identifier for the visual for \fIwindow\fR.
-.TP
-\fBwinfo visualsavailable \fIwindow\fR ?\fBincludeids\fR?
-Returns a list whose elements describe the visuals available for
-\fIwindow\fR's screen.
-Each element consists of a visual class followed by an integer depth.
-The class has the same form as returned by \fBwinfo visual\fR.
-The depth gives the number of bits per pixel in the visual.
-In addition, if the \fBincludeids\fR argument is provided, then the
-depth is followed by the X identifier for the visual.
-.TP
-\fBwinfo vrootheight \fIwindow\fR
-Returns the height of the virtual root window associated with \fIwindow\fR
-if there is one; otherwise returns the height of \fIwindow\fR's screen.
-.TP
-\fBwinfo vrootwidth \fIwindow\fR
-Returns the width of the virtual root window associated with \fIwindow\fR
-if there is one; otherwise returns the width of \fIwindow\fR's screen.
-.TP
-\fBwinfo vrootx \fIwindow\fR
-Returns the x-offset of the virtual root window associated with \fIwindow\fR,
-relative to the root window of its screen.
-This is normally either zero or negative.
-Returns 0 if there is no virtual root window for \fIwindow\fR.
-.TP
-\fBwinfo vrooty \fIwindow\fR
-Returns the y-offset of the virtual root window associated with \fIwindow\fR,
-relative to the root window of its screen.
-This is normally either zero or negative.
-Returns 0 if there is no virtual root window for \fIwindow\fR.
-.TP
-\fBwinfo width \fIwindow\fR
-Returns a decimal string giving \fIwindow\fR's width in pixels.
-When a window is first created its width will be 1 pixel; the
-width will eventually be changed by a geometry manager to fulfill
-the window's needs.
-If you need the true width immediately after creating a widget,
-invoke \fBupdate\fR to force the geometry manager to arrange it,
-or use \fBwinfo reqwidth\fR to get the window's requested width
-instead of its actual width.
-.TP
-\fBwinfo x \fIwindow\fR
-Returns a decimal string giving the x-coordinate, in \fIwindow\fR's
-parent, of the
-upper-left corner of \fIwindow\fR's border (or \fIwindow\fR if it
-has no border).
-.TP
-\fBwinfo y \fIwindow\fR
-Returns a decimal string giving the y-coordinate, in \fIwindow\fR's
-parent, of the
-upper-left corner of \fIwindow\fR's border (or \fIwindow\fR if it
-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/doc/wish.1 b/doc/wish.1
deleted file mode 100644
index d83caae..0000000
--- a/doc/wish.1
+++ /dev/null
@@ -1,186 +0,0 @@
-'\"
-'\" Copyright (c) 1991-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: wish.1,v 1.2 1998/09/14 18:23:01 stanton Exp $
-'\"
-.so man.macros
-.TH wish 1 8.0 Tk "Tk Applications"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-wish \- Simple windowing shell
-.SH SYNOPSIS
-\fBwish\fR ?\fIfileName arg arg ...\fR?
-.SH OPTIONS
-.IP "\fB\-colormap \fInew\fR" 20
-Specifies that the window should have a new private colormap instead of
-using the default colormap for the screen.
-.IP "\fB\-display \fIdisplay\fR" 20
-Display (and screen) on which to display window.
-.IP "\fB\-geometry \fIgeometry\fR" 20
-Initial geometry to use for window. If this option is specified, its
-value is stored in the \fBgeometry\fR global variable of the application's
-Tcl interpreter.
-.IP "\fB\-name \fIname\fR" 20
-Use \fIname\fR as the title to be displayed in the window, and
-as the name of the interpreter for \fBsend\fR commands.
-.IP "\fB\-sync\fR" 20
-Execute all X server commands synchronously, so that errors
-are reported immediately. This will result in much slower
-execution, but it is useful for debugging.
-.VS 8.0 br
-.IP "\fB\-use\fR \fIid\fR" 20
-Specifies that the main window for the application is to be embedded in
-the window whose identifier is \fIid\fR, instead of being created as an
-independent toplevel window. \fIId\fR must be specified in the same
-way as the value for the \fB\-use\fR option for toplevel widgets (i.e.
-it has a form like that returned by the \fBwinfo id\fR command).
-.VE
-.IP "\fB\-visual \fIvisual\fR" 20
-Specifies the visual to use for the window.
-\fIVisual\fR may have any of the forms supported by the \fBTk_GetVisual\fR
-procedure.
-.IP "\fB\-\|\-\fR" 20
-Pass all remaining arguments through to the script's \fBargv\fR
-variable without interpreting them.
-This provides a mechanism for passing arguments such as \fB\-name\fR
-to a script instead of having \fBwish\fR interpret them.
-.BE
-
-.SH DESCRIPTION
-.PP
-\fBWish\fR is a simple program consisting of the Tcl command
-language, the Tk toolkit, and a main program that reads commands
-from standard input or from a file.
-It creates a main window and then processes Tcl commands.
-If \fBwish\fR is invoked with no arguments, or with a first argument
-that starts with ``\-'', then it reads Tcl commands interactively from
-standard input.
-It will continue processing commands until all windows have been
-deleted or until end-of-file is reached on standard input.
-If there exists a file \fB.wishrc\fR in the home directory of
-the user, \fBwish\fR evaluates the file as a Tcl script
-just before reading the first command from standard input.
-.PP
-If \fBwish\fR is invoked with an initial \fIfileName\fR argument, then
-\fIfileName\fR is treated as the name of a script file.
-\fBWish\fR will evaluate the script in \fIfileName\fR (which
-presumably creates a user interface), then it will respond to events
-until all windows have been deleted.
-Commands will not be read from standard input.
-There is no automatic evaluation of \fB.wishrc\fR in this
-case, but the script file can always \fBsource\fR it if desired.
-
-.SH "OPTIONS"
-.PP
-\fBWish\fR automatically processes all of the command-line options
-described in the \fBOPTIONS\fR summary above.
-Any other command-line arguments besides these are passed through
-to the application using the \fBargc\fR and \fBargv\fR variables
-described later.
-
-.SH "APPLICATION NAME AND CLASS"
-.PP
-The name of the application, which is used for purposes such as
-\fBsend\fR commands, is taken from the \fB\-name\fR option,
-if it is specified; otherwise it is taken from \fIfileName\fR,
-if it is specified, or from the command name by which
-\fBwish\fR was invoked. In the last two cases, if the name contains a ``/''
-character, then only the characters after the last slash are used
-as the application name.
-.PP
-The class of the application, which is used for purposes such as
-specifying options with a \fBRESOURCE_MANAGER\fR property or .Xdefaults
-file, is the same as its name except that the first letter is
-capitalized.
-
-.SH "VARIABLES"
-.PP
-\fBWish\fR sets the following Tcl variables:
-.TP 15
-\fBargc\fR
-Contains a count of the number of \fIarg\fR arguments (0 if none),
-not including the options described above.
-.TP 15
-\fBargv\fR
-Contains a Tcl list whose elements are the \fIarg\fR arguments
-that follow a \fB\-\|\-\fR option or don't match any of the
-options described in OPTIONS above, in order, or an empty string
-if there are no such arguments.
-.TP 15
-\fBargv0\fR
-Contains \fIfileName\fR if it was specified.
-Otherwise, contains the name by which \fBwish\fR was invoked.
-.TP 15
-\fBgeometry\fR
-If the \fB\-geometry\fR option is specified, \fBwish\fR copies its
-value into this variable. If the variable still exists after
-\fIfileName\fR has been evaluated, \fBwish\fR uses the value of
-the variable in a \fBwm geometry\fR command to set the main
-window's geometry.
-.TP 15
-\fBtcl_interactive\fR
-Contains 1 if \fBwish\fR is reading commands interactively (\fIfileName\fR
-was not specified and standard input is a terminal-like
-device), 0 otherwise.
-
-.SH "SCRIPT FILES"
-.PP
-If you create a Tcl script in a file whose first line is
-.CS
-\fB#!/usr/local/bin/wish\fR
-.CE
-then you can invoke the script file directly from your shell if
-you mark it as executable.
-This assumes that \fBwish\fR has been installed in the default
-location in /usr/local/bin; if it's installed somewhere else
-then you'll have to modify the above line to match.
-Many UNIX systems do not allow the \fB#!\fR line to exceed about
-30 characters in length, so be sure that the \fBwish\fR executable
-can be accessed with a short file name.
-.PP
-An even better approach is to start your script files with the
-following three lines:
-.CS
-\fB#!/bin/sh
-# the next line restarts using wish \e
-exec wish "$0" "$@"\fR
-.CE
-This approach has three advantages over the approach in the previous
-paragraph. First, the location of the \fBwish\fR binary doesn't have
-to be hard-wired into the script: it can be anywhere in your shell
-search path. Second, it gets around the 30-character file name limit
-in the previous approach.
-Third, this approach will work even if \fBwish\fR is
-itself a shell script (this is done on some systems in order to
-handle multiple architectures or operating systems: the \fBwish\fR
-script selects one of several binaries to run). The three lines
-cause both \fBsh\fR and \fBwish\fR to process the script, but the
-\fBexec\fR is only executed by \fBsh\fR.
-\fBsh\fR processes the script first; it treats the second
-line as a comment and executes the third line.
-The \fBexec\fR statement cause the shell to stop processing and
-instead to start up \fBwish\fR to reprocess the entire script.
-When \fBwish\fR starts up, it treats all three lines as comments,
-since the backslash at the end of the second line causes the third
-line to be treated as part of the comment on the second line.
-
-.SH PROMPTS
-.PP
-When \fBwish\fR is invoked interactively it normally prompts for each
-command with ``\fB% \fR''. You can change the prompt by setting the
-variables \fBtcl_prompt1\fR and \fBtcl_prompt2\fR. If variable
-\fBtcl_prompt1\fR exists then it must consist of a Tcl script
-to output a prompt; instead of outputting a prompt \fBwish\fR
-will evaluate the script in \fBtcl_prompt1\fR.
-The variable \fBtcl_prompt2\fR is used in a similar way when
-a newline is typed but the current command isn't yet complete;
-if \fBtcl_prompt2\fR isn't set then no prompt is output for
-incomplete commands.
-
-.SH KEYWORDS
-shell, toolkit
diff --git a/doc/wm.n b/doc/wm.n
deleted file mode 100644
index 31f1b9e..0000000
--- a/doc/wm.n
+++ /dev/null
@@ -1,503 +0,0 @@
-'\"
-'\" Copyright (c) 1991-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: wm.n,v 1.2 1998/09/14 18:23:01 stanton Exp $
-'\"
-.so man.macros
-.TH wm n 4.3 Tk "Tk Built-In Commands"
-.BS
-'\" Note: do not modify the .SH NAME line immediately below!
-.SH NAME
-wm \- Communicate with window manager
-.SH SYNOPSIS
-\fBwm\fR \fIoption window \fR?\fIargs\fR?
-.BE
-
-.SH DESCRIPTION
-.PP
-The \fBwm\fR command is used to interact with window managers in
-order to control such things as the title for a window, its geometry,
-or the increments in terms of which it may be resized. The \fBwm\fR
-command can take any of a number of different forms, depending on
-the \fIoption\fR argument. All of the forms expect at least one
-additional argument, \fIwindow\fR, which must be the path name of a
-top-level window.
-.PP
-The legal forms for the \fBwm\fR command are:
-.TP
-\fBwm aspect \fIwindow\fR ?\fIminNumer minDenom maxNumer maxDenom\fR?
-If \fIminNumer\fR, \fIminDenom\fR, \fImaxNumer\fR, and \fImaxDenom\fR
-are all specified, then they will be passed to the window manager
-and the window manager should use them to enforce a range of
-acceptable aspect ratios for \fIwindow\fR. The aspect ratio of
-\fIwindow\fR (width/length) will be constrained to lie
-between \fIminNumer\fR/\fIminDenom\fR and \fImaxNumer\fR/\fImaxDenom\fR.
-If \fIminNumer\fR etc. are all specified as empty strings, then
-any existing aspect ratio restrictions are removed.
-If \fIminNumer\fR etc. are specified, then the command returns an
-empty string. Otherwise, it returns
-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).
-.TP
-\fBwm client \fIwindow\fR ?\fIname\fR?
-If \fIname\fR is specified, this command stores \fIname\fR (which
-should be the name of
-the host on which the application is executing) in \fIwindow\fR's
-\fBWM_CLIENT_MACHINE\fR property for use by the window manager or
-session manager.
-The command returns an empty string in this case.
-If \fIname\fR isn't specified, the command returns the last name
-set in a \fBwm client\fR command for \fIwindow\fR.
-If \fIname\fR is specified as an empty string, the command deletes the
-\fBWM_CLIENT_MACHINE\fR property from \fIwindow\fR.
-.TP
-\fBwm colormapwindows \fIwindow\fR ?\fIwindowList\fR?
-This command is used to manipulate the \fBWM_COLORMAP_WINDOWS\fR
-property, which provides information to the window managers about
-windows that have private colormaps.
-If \fIwindowList\fR isn't specified, the command returns a list
-whose elements are the names of the windows in the \fBWM_COLORMAP_WINDOWS\fR
-property.
-If \fIwindowList\fR is specified, it consists of a list of window
-path names; the command overwrites the \fBWM_COLORMAP_WINDOWS\fR
-property with the given windows and returns an empty string.
-The \fBWM_COLORMAP_WINDOWS\fR property should normally contain a
-list of the internal windows within \fIwindow\fR whose colormaps differ
-from their parents.
-The order of the windows in the property indicates a priority order:
-the window manager will attempt to install as many colormaps as possible
-from the head of this list when \fIwindow\fR gets the colormap focus.
-If \fIwindow\fR is not included among the windows in \fIwindowList\fR,
-Tk implicitly adds it at the end of the \fBWM_COLORMAP_WINDOWS\fR
-property, so that its colormap is lowest in priority.
-If \fBwm colormapwindows\fR is not invoked, Tk will automatically set
-the property for each top-level window to all the internal windows
-whose colormaps differ from their parents, followed by the top-level
-itself; the order of the internal windows is undefined.
-See the ICCCM documentation for more information on the
-\fBWM_COLORMAP_WINDOWS\fR property.
-.TP
-\fBwm command \fIwindow\fR ?\fIvalue\fR?
-If \fIvalue\fR is specified, this command stores \fIvalue\fR in \fIwindow\fR's
-\fBWM_COMMAND\fR property for use by the window manager or
-session manager and returns an empty string.
-\fIValue\fR must have proper list structure; the elements should
-contain the words of the command used to invoke the application.
-If \fIvalue\fR isn't specified then the command returns the last value
-set in a \fBwm command\fR command for \fIwindow\fR.
-If \fIvalue\fR is specified as an empty string, the command
-deletes the \fBWM_COMMAND\fR property from \fIwindow\fR.
-.TP
-\fBwm deiconify \fIwindow\fR
-Arrange for \fIwindow\fR to be displayed in normal (non-iconified) form.
-This is done by mapping the window. If the window has never been
-mapped then this command will not map the window, but it will ensure
-that when the window is first mapped it will be displayed
-in de-iconified form. Returns an empty string.
-.TP
-\fBwm focusmodel \fIwindow\fR ?\fBactive\fR|\fBpassive\fR?
-If \fBactive\fR or \fBpassive\fR is supplied as an optional argument
-to the command, then it specifies the focus model for \fIwindow\fR.
-In this case the command returns an empty string. If no additional
-argument is supplied, then the command returns the current focus
-model for \fIwindow\fR.
-An \fBactive\fR focus model means that \fIwindow\fR will claim the
-input focus for itself or its descendants, even at times when
-the focus is currently in some other application. \fBPassive\fR means that
-\fIwindow\fR will never claim the focus for itself: the window manager
-should give the focus to \fIwindow\fR at appropriate times. However,
-once the focus has been given to \fIwindow\fR or one of its descendants,
-the application may re-assign the focus among \fIwindow\fR's descendants.
-The focus model defaults to \fBpassive\fR, and Tk's \fBfocus\fR command
-assumes a passive model of focusing.
-.TP
-\fBwm frame \fIwindow\fR
-.VS
-If \fIwindow\fR has been reparented by the window manager into a
-decorative frame, the command returns the platform specific window
-identifier for the outermost frame that contains \fIwindow\fR (the
-window whose parent is the root or virtual root). If \fIwindow\fR
-hasn't been reparented by the window manager then the command returns
-the platform specific window identifier for \fIwindow\fR.
-.VE
-.TP
-\fBwm geometry \fIwindow\fR ?\fInewGeometry\fR?
-If \fInewGeometry\fR is specified, then the geometry of \fIwindow\fR
-is changed and an empty string is returned. Otherwise the current
-geometry for \fIwindow\fR is returned (this is the most recent
-geometry specified either by manual resizing or
-in a \fBwm geometry\fR command). \fINewGeometry\fR has
-the form \fB=\fIwidth\fBx\fIheight\fB\(+-\fIx\fB\(+-\fIy\fR, where
-any of \fB=\fR, \fIwidth\fBx\fIheight\fR, or \fB\(+-\fIx\fB\(+-\fIy\fR
-may be omitted. \fIWidth\fR and \fIheight\fR are positive integers
-specifying the desired dimensions of \fIwindow\fR. If \fIwindow\fR
-is gridded (see GRIDDED GEOMETRY MANAGEMENT below) then the dimensions
-are specified in grid units; otherwise they are specified in pixel
-units. \fIX\fR and \fIy\fR specify the desired location of
-\fIwindow\fR on the screen, in pixels.
-If \fIx\fR is preceded by \fB+\fR, it specifies
-the number of pixels between the left edge of the screen and the left
-edge of \fIwindow\fR's border; if preceded by \fB\-\fR then
-\fIx\fR specifies the number of pixels
-between the right edge of the screen and the right edge of \fIwindow\fR's
-border. If \fIy\fR is preceded by \fB+\fR then it specifies the
-number of pixels between the top of the screen and the top
-of \fIwindow\fR's border; if \fIy\fR is preceded by \fB\-\fR then
-it specifies the number of pixels between the bottom of \fIwindow\fR's
-border and the bottom of the screen.
-If \fInewGeometry\fR is specified as an empty string then any
-existing user-specified geometry for \fIwindow\fR is cancelled, and
-the window will revert to the size requested internally by its
-widgets.
-.TP
-\fBwm grid \fIwindow\fR ?\fIbaseWidth baseHeight widthInc heightInc\fR?
-This command indicates that \fIwindow\fR is to be managed as a
-gridded window.
-It also specifies the relationship between grid units and pixel units.
-\fIBaseWidth\fR and \fIbaseHeight\fR specify the number of grid
-units corresponding to the pixel dimensions requested internally
-by \fIwindow\fR using \fBTk_GeometryRequest\fR. \fIWidthInc\fR
-and \fIheightInc\fR specify the number of pixels in each horizontal
-and vertical grid unit.
-These four values determine a range of acceptable sizes for
-\fIwindow\fR, corresponding to grid-based widths and heights
-that are non-negative integers.
-Tk will pass this information to the window manager; during
-manual resizing, the window manager will restrict the window's size
-to one of these acceptable sizes.
-Furthermore, during manual resizing the window manager will display
-the window's current size in terms of grid units rather than pixels.
-If \fIbaseWidth\fR etc. are all specified as empty strings, then
-\fIwindow\fR will no longer be managed as a gridded window. If
-\fIbaseWidth\fR etc. are specified then the return value is an
-empty string.
-Otherwise the return value is a Tcl list containing
-four elements corresponding to the current \fIbaseWidth\fR,
-\fIbaseHeight\fR, \fIwidthInc\fR, and \fIheightInc\fR; if
-\fIwindow\fR is not currently gridded, then an empty string
-is returned.
-Note: this command should not be needed very often, since the
-\fBTk_SetGrid\fR library procedure and the \fBsetGrid\fR option
-provide easier access to the same functionality.
-.TP
-\fBwm group \fIwindow\fR ?\fIpathName\fR?
-If \fIpathName\fR is specified, it gives the path name for the leader of
-a group of related windows. The window manager may use this information,
-for example, to unmap all of the windows in a group when the group's
-leader is iconified. \fIPathName\fR may be specified as an empty string to
-remove \fIwindow\fR from any group association. If \fIpathName\fR is
-specified then the command returns an empty string; otherwise it
-returns the path name of \fIwindow\fR's current group leader, or an empty
-string if \fIwindow\fR isn't part of any group.
-.TP
-\fBwm iconbitmap \fIwindow\fR ?\fIbitmap\fR?
-If \fIbitmap\fR is specified, then it names a bitmap in the standard
-forms accepted by Tk (see the \fBTk_GetBitmap\fR manual entry for details).
-This bitmap is passed to the window manager to be displayed in
-\fIwindow\fR's icon, and the command returns an empty string. If
-an empty string is specified for \fIbitmap\fR, then any current icon
-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.
-.TP
-\fBwm iconify \fIwindow\fR
-Arrange for \fIwindow\fR to be iconified. It \fIwindow\fR hasn't
-yet been mapped for the first time, this command will arrange for
-it to appear in the iconified state when it is eventually mapped.
-.TP
-\fBwm iconmask \fIwindow\fR ?\fIbitmap\fR?
-If \fIbitmap\fR is specified, then it names a bitmap in the standard
-forms accepted by Tk (see the \fBTk_GetBitmap\fR manual entry for details).
-This bitmap is passed to the window manager to be used as a mask
-in conjunction with the \fBiconbitmap\fR option: where the mask
-has zeroes no icon will be displayed; where it has ones, the bits
-from the icon bitmap will be displayed. If
-an empty string is specified for \fIbitmap\fR then any current icon
-mask is cancelled for \fIwindow\fR (this is equivalent to specifying
-a bitmap of all ones). If \fIbitmap\fR is specified
-then the command returns an empty string. Otherwise it
-returns the name of the current icon mask associated with
-\fIwindow\fR, or an empty string if no mask is in effect.
-.TP
-\fBwm iconname \fIwindow\fR ?\fInewName\fR?
-If \fInewName\fR is specified, then it is passed to the window
-manager; the window manager should display \fInewName\fR inside
-the icon associated with \fIwindow\fR. In this case an empty
-string is returned as result. If \fInewName\fR isn't specified
-then the command returns the current icon name for \fIwindow\fR,
-or an empty string if no icon name has been specified (in this
-case the window manager will normally display the window's title,
-as specified with the \fBwm title\fR command).
-.TP
-\fBwm iconposition \fIwindow\fR ?\fIx y\fR?
-If \fIx\fR and \fIy\fR are specified, they are passed to the window
-manager as a hint about where to position the icon for \fIwindow\fR.
-In this case an empty string is returned. If \fIx\fR and \fIy\fR are
-specified as empty strings then any existing icon position hint is cancelled.
-If neither \fIx\fR nor \fIy\fR is specified, then the command returns
-a Tcl list containing two values, which are the current icon position
-hints (if no hints are in effect then an empty string is returned).
-.TP
-\fBwm iconwindow \fIwindow\fR ?\fIpathName\fR?
-If \fIpathName\fR is specified, it is the path name for a window to
-use as icon for \fIwindow\fR: when \fIwindow\fR is iconified then
-\fIpathName\fR will be mapped to serve as icon, and when \fIwindow\fR
-is de-iconified then \fIpathName\fR will be unmapped again. If
-\fIpathName\fR is specified as an empty string then any existing
-icon window association for \fIwindow\fR will be cancelled. If
-the \fIpathName\fR argument is specified then an empty string is
-returned. Otherwise the command returns the path name of the
-current icon window for \fIwindow\fR, or an empty string if there
-is no icon window currently specified for \fIwindow\fR.
-Button press events are disabled for \fIwindow\fR as long as it is
-an icon window; this is needed in order to allow window managers
-to ``own'' those events.
-Note: not all window managers support the notion of an icon window.
-.TP
-\fBwm maxsize \fIwindow\fR ?\fIwidth height\fR?
-If \fIwidth\fR and \fIheight\fR are specified, they give
-the maximum permissible dimensions for \fIwindow\fR.
-For gridded windows the dimensions are specified in
-grid units; otherwise they are specified in pixel units.
-The window manager will restrict the window's dimensions to be
-less than or equal to \fIwidth\fR and \fIheight\fR.
-If \fIwidth\fR and \fIheight\fR are
-specified, then the command returns an empty string. Otherwise
-it returns a Tcl list with two elements, which are the
-maximum width and height currently in effect.
-The maximum size defaults to the size of the screen.
-If resizing has been disabled with the \fBwm resizable\fR command,
-then this command has no effect.
-See the sections on geometry management below for more information.
-.TP
-\fBwm minsize \fIwindow\fR ?\fIwidth height\fR?
-If \fIwidth\fR and \fIheight\fR are specified, they give the
-minimum permissible dimensions for \fIwindow\fR.
-For gridded windows the dimensions are specified in
-grid units; otherwise they are specified in pixel units.
-The window manager will restrict the window's dimensions to be
-greater than or equal to \fIwidth\fR and \fIheight\fR.
-If \fIwidth\fR and \fIheight\fR are
-specified, then the command returns an empty string. Otherwise
-it returns a Tcl list with two elements, which are the
-minimum width and height currently in effect.
-The minimum size defaults to one pixel in each dimension.
-If resizing has been disabled with the \fBwm resizable\fR command,
-then this command has no effect.
-See the sections on geometry management below for more information.
-.TP
-\fBwm overrideredirect \fIwindow\fR ?\fIboolean\fR?
-If \fIboolean\fR is specified, it must have a proper boolean form and
-the override-redirect flag for \fIwindow\fR is set to that value.
-If \fIboolean\fR is not specified then \fB1\fR or \fB0\fR is
-returned to indicate whether or not the override-redirect flag
-is currently set for \fIwindow\fR.
-Setting the override-redirect flag for a window causes
-it to be ignored by the window manager; among other things, this means
-that the window will not be reparented from the root window into a
-decorative frame and the user will not be able to manipulate the
-window using the normal window manager mechanisms.
-.TP
-\fBwm positionfrom \fIwindow\fR ?\fIwho\fR?
-If \fIwho\fR is specified, it must be either \fBprogram\fR or
-\fBuser\fR, or an abbreviation of one of these two. It indicates
-whether \fIwindow\fR's current position was requested by the
-program or by the user. Many window managers ignore program-requested
-initial positions and ask the user to manually position the window; if
-\fBuser\fR is specified then the window manager should position the
-window at the given place without asking the user for assistance.
-If \fIwho\fR is specified as an empty string, then the current position
-source is cancelled.
-If \fIwho\fR is specified, then the command returns an empty string.
-Otherwise it returns \fBuser\fR or \fBwindow\fR to indicate the
-source of the window's current position, or an empty string if
-no source has been specified yet. Most window managers interpret
-``no source'' as equivalent to \fBprogram\fR.
-Tk will automatically set the position source to \fBuser\fR
-when a \fBwm geometry\fR command is invoked, unless the source has
-been set explicitly to \fBprogram\fR.
-.TP
-\fBwm protocol \fIwindow\fR ?\fIname\fR? ?\fIcommand\fR?
-This command is used to manage window manager protocols such as
-\fBWM_DELETE_WINDOW\fR.
-\fIName\fR is the name of an atom corresponding to a window manager
-protocol, such as \fBWM_DELETE_WINDOW\fR or \fBWM_SAVE_YOURSELF\fR
-or \fBWM_TAKE_FOCUS\fR.
-If both \fIname\fR and \fIcommand\fR are specified, then \fIcommand\fR
-is associated with the protocol specified by \fIname\fR.
-\fIName\fR will be added to \fIwindow\fR's \fBWM_PROTOCOLS\fR
-property to tell the window manager that the application has a
-protocol handler for \fIname\fR, and \fIcommand\fR will
-be invoked in the future whenever the window manager sends a
-message to the client for that protocol.
-In this case the command returns an empty string.
-If \fIname\fR is specified but \fIcommand\fR isn't, then the current
-command for \fIname\fR is returned, or an empty string if there
-is no handler defined for \fIname\fR.
-If \fIcommand\fR is specified as an empty string then the current
-handler for \fIname\fR is deleted and it is removed from the
-\fBWM_PROTOCOLS\fR property on \fIwindow\fR; an empty string is
-returned.
-Lastly, if neither \fIname\fR nor \fIcommand\fR is specified, the
-command returns a list of all the protocols for which handlers
-are currently defined for \fIwindow\fR.
-.RS
-.PP
-Tk always defines a protocol handler for \fBWM_DELETE_WINDOW\fR, even if
-you haven't asked for one with \fBwm protocol\fR.
-If a \fBWM_DELETE_WINDOW\fR message arrives when you haven't defined
-a handler, then Tk handles the message by destroying the window for
-which it was received.
-.RE
-.TP
-\fBwm resizable \fIwindow\fR ?\fIwidth height\fR?
-This command controls whether or not the user may interactively
-resize a top-level window. If \fIwidth\fR and \fIheight\fR are
-specified, they are boolean values that determine whether the
-width and height of \fIwindow\fR may be modified by the user.
-In this case the command returns an empty string.
-If \fIwidth\fR and \fIheight\fR are omitted then the command
-returns a list with two 0/1 elements that indicate whether the
-width and height of \fIwindow\fR are currently resizable.
-By default, windows are resizable in both dimensions.
-If resizing is disabled, then the window's size will be the size
-from the most recent interactive resize or \fBwm geometry\fR
-command. If there has been no such operation then
-the window's natural size will be used.
-.TP
-\fBwm sizefrom \fIwindow\fR ?\fIwho\fR?
-If \fIwho\fR is specified, it must be either \fBprogram\fR or
-\fBuser\fR, or an abbreviation of one of these two. It indicates
-whether \fIwindow\fR's current size was requested by the
-program or by the user. Some window managers ignore program-requested
-sizes and ask the user to manually size the window; if
-\fBuser\fR is specified then the window manager should give the
-window its specified size without asking the user for assistance.
-If \fIwho\fR is specified as an empty string, then the current size
-source is cancelled.
-If \fIwho\fR is specified, then the command returns an empty string.
-Otherwise it returns \fBuser\fR or \fBwindow\fR to indicate the
-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 state \fIwindow\fR
-Returns the current state of \fIwindow\fR: either \fBnormal\fR,
-\fBiconic\fR, \fBwithdrawn\fR, or \fBicon\fR. The difference
-between \fBiconic\fR and \fBicon\fR is that \fBiconic\fR refers
-to a window that has been iconified (e.g., with the \fBwm iconify\fR
-command) while \fBicon\fR refers to a window whose only purpose is
-to serve as the icon for some other window (via the \fBwm iconwindow\fR
-command).
-.TP
-\fBwm title \fIwindow\fR ?\fIstring\fR?
-If \fIstring\fR is specified, then it will be passed to the window
-manager for use as the title for \fIwindow\fR (the window manager
-should display this string in \fIwindow\fR's title bar). In this
-case the command returns an empty string. If \fIstring\fR isn't
-specified then the command returns the current title for the
-\fIwindow\fR. The title for a window defaults to its name.
-.TP
-\fBwm transient \fIwindow\fR ?\fImaster\fR?
-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
-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
-returns the path name of \fIwindow\fR's current master, or an
-empty string if \fIwindow\fR isn't currently a transient window.
-.TP
-\fBwm withdraw \fIwindow\fR
-Arranges for \fIwindow\fR to be withdrawn from the screen. This
-causes the window to be unmapped and forgotten about by the window
-manager. If the window
-has never been mapped, then this command
-causes the window to be mapped in the withdrawn state. Not all
-window managers appear to know how to handle windows that are
-mapped in the withdrawn state.
-Note: it sometimes seems to be necessary to withdraw a
-window and then re-map it (e.g. with \fBwm deiconify\fR) to get some
-window managers to pay attention to changes in window attributes
-such as group.
-
-.SH "GEOMETRY MANAGEMENT"
-.PP
-By default a top-level window appears on the screen in its
-\fInatural size\fR, which is the one determined internally by its
-widgets and geometry managers.
-If the natural size of a top-level window changes, then the window's size
-changes to match.
-A top-level window can be given a size other than its natural size in two ways.
-First, the user can resize the window manually using the facilities
-of the window manager, such as resize handles.
-Second, the application can request a particular size for a
-top-level window using the \fBwm geometry\fR command.
-These two cases are handled identically by Tk; in either case,
-the requested size overrides the natural size.
-You can return the window to its natural by invoking \fBwm geometry\fR
-with an empty \fIgeometry\fR string.
-.PP
-Normally a top-level window can have any size from one pixel in each
-dimension up to the size of its screen.
-However, you can use the \fBwm minsize\fR and \fBwm maxsize\fR commands
-to limit the range of allowable sizes.
-The range set by \fBwm minsize\fR and \fBwm maxsize\fR applies to
-all forms of resizing, including the window's natural size as
-well as manual resizes and the \fBwm geometry\fR command.
-You can also use the command \fBwm resizable\fR to completely
-disable interactive resizing in one or both dimensions.
-
-.SH "GRIDDED GEOMETRY MANAGEMENT"
-.PP
-Gridded geometry management occurs when one of the widgets of an
-application supports a range of useful sizes.
-This occurs, for example, in a text editor where the scrollbars,
-menus, and other adornments are fixed in size but the edit widget
-can support any number of lines of text or characters per line.
-In this case, it is usually desirable to let the user specify the
-number of lines or characters-per-line, either with the
-\fBwm geometry\fR command or by interactively resizing the window.
-In the case of text, and in other interesting cases also, only
-discrete sizes of the window make sense, such as integral numbers
-of lines and characters-per-line; arbitrary pixel sizes are not useful.
-.PP
-Gridded geometry management provides support for this kind of
-application.
-Tk (and the window manager) assume that there is a grid of some
-sort within the application and that the application should be
-resized in terms of \fIgrid units\fR rather than pixels.
-Gridded geometry management is typically invoked by turning on
-the \fBsetGrid\fR option for a widget; it can also be invoked
-with the \fBwm grid\fR command or by calling \fBTk_SetGrid\fR.
-In each of these approaches the particular widget (or sometimes
-code in the application as a whole) specifies the relationship between
-integral grid sizes for the window and pixel sizes.
-To return to non-gridded geometry management, invoke
-\fBwm grid\fR with empty argument strings.
-.PP
-When gridded geometry management is enabled then all the dimensions specified
-in \fBwm minsize\fR, \fBwm maxsize\fR, and \fBwm geometry\fR commands
-are treated as grid units rather than pixel units.
-Interactive resizing is also carried out in even numbers of grid units
-rather than pixels.
-
-.SH BUGS
-.PP
-Most existing window managers appear to have bugs that affect the
-operation of the \fBwm\fR command. For example, some changes won't
-take effect if the window is already active: the window will have
-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/generic/README b/generic/README
deleted file mode 100644
index 4cbf41e..0000000
--- a/generic/README
+++ /dev/null
@@ -1,5 +0,0 @@
-This directory contains Tk source files that work on all the platforms
-where Tk runs (e.g. UNIX, PCs, and Macintoshes). Platform-specific
-sources are in the directories ../unix, ../win, and ../mac.
-
-RCS ID: @(#) $Id: README,v 1.2 1998/09/14 18:23:02 stanton Exp $
diff --git a/generic/default.h b/generic/default.h
deleted file mode 100644
index c83567b..0000000
--- a/generic/default.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * default.h --
- *
- * This file defines the defaults for all options for all of
- * the Tk widgets.
- *
- * Copyright (c) 1991-1994 The Regents of the University of California.
- * Copyright (c) 1994 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: default.h,v 1.2 1998/09/14 18:23:02 stanton Exp $
- */
-
-#ifndef _DEFAULT
-#define _DEFAULT
-
-#if defined(__WIN32__) || defined(_WIN32)
-# include "tkWinDefault.h"
-#else
-# if defined(MAC_TCL)
-# include "tkMacDefault.h"
-# else
-# include "tkUnixDefault.h"
-# endif
-#endif
-
-#endif /* _DEFAULT */
diff --git a/generic/ks_names.h b/generic/ks_names.h
deleted file mode 100644
index 0bc0e13..0000000
--- a/generic/ks_names.h
+++ /dev/null
@@ -1,921 +0,0 @@
-/*
- * This file is generated from $(INCLUDESRC)/keysymdef.h. Do not edit.
- * RCS: $Id: ks_names.h,v 1.3 1998/09/14 18:23:02 stanton Exp $
- */
-{ "BackSpace", 0xFF08 },
-{ "Tab", 0xFF09 },
-{ "Linefeed", 0xFF0A },
-{ "Clear", 0xFF0B },
-{ "Return", 0xFF0D },
-{ "Pause", 0xFF13 },
-{ "Escape", 0xFF1B },
-{ "Delete", 0xFFFF },
-{ "Multi_key", 0xFF20 },
-{ "Kanji", 0xFF21 },
-{ "Home", 0xFF50 },
-{ "Left", 0xFF51 },
-{ "Up", 0xFF52 },
-{ "Right", 0xFF53 },
-{ "Down", 0xFF54 },
-{ "Prior", 0xFF55 },
-{ "Next", 0xFF56 },
-{ "End", 0xFF57 },
-{ "Begin", 0xFF58 },
-{ "Win_L", 0xFF5B },
-{ "Win_R", 0xFF5C },
-{ "App", 0xFF5D },
-{ "Select", 0xFF60 },
-{ "Print", 0xFF61 },
-{ "Execute", 0xFF62 },
-{ "Insert", 0xFF63 },
-{ "Undo", 0xFF65 },
-{ "Redo", 0xFF66 },
-{ "Menu", 0xFF67 },
-{ "Find", 0xFF68 },
-{ "Cancel", 0xFF69 },
-{ "Help", 0xFF6A },
-{ "Break", 0xFF6B },
-{ "Mode_switch", 0xFF7E },
-{ "script_switch", 0xFF7E },
-{ "Num_Lock", 0xFF7F },
-{ "KP_Space", 0xFF80 },
-{ "KP_Tab", 0xFF89 },
-{ "KP_Enter", 0xFF8D },
-{ "KP_F1", 0xFF91 },
-{ "KP_F2", 0xFF92 },
-{ "KP_F3", 0xFF93 },
-{ "KP_F4", 0xFF94 },
-{ "KP_Equal", 0xFFBD },
-{ "KP_Multiply", 0xFFAA },
-{ "KP_Add", 0xFFAB },
-{ "KP_Separator", 0xFFAC },
-{ "KP_Subtract", 0xFFAD },
-{ "KP_Decimal", 0xFFAE },
-{ "KP_Divide", 0xFFAF },
-{ "KP_0", 0xFFB0 },
-{ "KP_1", 0xFFB1 },
-{ "KP_2", 0xFFB2 },
-{ "KP_3", 0xFFB3 },
-{ "KP_4", 0xFFB4 },
-{ "KP_5", 0xFFB5 },
-{ "KP_6", 0xFFB6 },
-{ "KP_7", 0xFFB7 },
-{ "KP_8", 0xFFB8 },
-{ "KP_9", 0xFFB9 },
-{ "F1", 0xFFBE },
-{ "F2", 0xFFBF },
-{ "F3", 0xFFC0 },
-{ "F4", 0xFFC1 },
-{ "F5", 0xFFC2 },
-{ "F6", 0xFFC3 },
-{ "F7", 0xFFC4 },
-{ "F8", 0xFFC5 },
-{ "F9", 0xFFC6 },
-{ "F10", 0xFFC7 },
-{ "F11", 0xFFC8 },
-{ "L1", 0xFFC8 },
-{ "F12", 0xFFC9 },
-{ "L2", 0xFFC9 },
-{ "F13", 0xFFCA },
-{ "L3", 0xFFCA },
-{ "F14", 0xFFCB },
-{ "L4", 0xFFCB },
-{ "F15", 0xFFCC },
-{ "L5", 0xFFCC },
-{ "F16", 0xFFCD },
-{ "L6", 0xFFCD },
-{ "F17", 0xFFCE },
-{ "L7", 0xFFCE },
-{ "F18", 0xFFCF },
-{ "L8", 0xFFCF },
-{ "F19", 0xFFD0 },
-{ "L9", 0xFFD0 },
-{ "F20", 0xFFD1 },
-{ "L10", 0xFFD1 },
-{ "F21", 0xFFD2 },
-{ "R1", 0xFFD2 },
-{ "F22", 0xFFD3 },
-{ "R2", 0xFFD3 },
-{ "F23", 0xFFD4 },
-{ "R3", 0xFFD4 },
-{ "F24", 0xFFD5 },
-{ "R4", 0xFFD5 },
-{ "F25", 0xFFD6 },
-{ "R5", 0xFFD6 },
-{ "F26", 0xFFD7 },
-{ "R6", 0xFFD7 },
-{ "F27", 0xFFD8 },
-{ "R7", 0xFFD8 },
-{ "F28", 0xFFD9 },
-{ "R8", 0xFFD9 },
-{ "F29", 0xFFDA },
-{ "R9", 0xFFDA },
-{ "F30", 0xFFDB },
-{ "R10", 0xFFDB },
-{ "F31", 0xFFDC },
-{ "R11", 0xFFDC },
-{ "F32", 0xFFDD },
-{ "R12", 0xFFDD },
-{ "R13", 0xFFDE },
-{ "F33", 0xFFDE },
-{ "F34", 0xFFDF },
-{ "R14", 0xFFDF },
-{ "F35", 0xFFE0 },
-{ "R15", 0xFFE0 },
-{ "Shift_L", 0xFFE1 },
-{ "Shift_R", 0xFFE2 },
-{ "Control_L", 0xFFE3 },
-{ "Control_R", 0xFFE4 },
-{ "Caps_Lock", 0xFFE5 },
-{ "Shift_Lock", 0xFFE6 },
-{ "Meta_L", 0xFFE7 },
-{ "Meta_R", 0xFFE8 },
-{ "Alt_L", 0xFFE9 },
-{ "Alt_R", 0xFFEA },
-{ "Super_L", 0xFFEB },
-{ "Super_R", 0xFFEC },
-{ "Hyper_L", 0xFFED },
-{ "Hyper_R", 0xFFEE },
-{ "space", 0x020 },
-{ "exclam", 0x021 },
-{ "quotedbl", 0x022 },
-{ "numbersign", 0x023 },
-{ "dollar", 0x024 },
-{ "percent", 0x025 },
-{ "ampersand", 0x026 },
-{ "quoteright", 0x027 },
-{ "parenleft", 0x028 },
-{ "parenright", 0x029 },
-{ "asterisk", 0x02a },
-{ "plus", 0x02b },
-{ "comma", 0x02c },
-{ "minus", 0x02d },
-{ "period", 0x02e },
-{ "slash", 0x02f },
-{ "0", 0x030 },
-{ "1", 0x031 },
-{ "2", 0x032 },
-{ "3", 0x033 },
-{ "4", 0x034 },
-{ "5", 0x035 },
-{ "6", 0x036 },
-{ "7", 0x037 },
-{ "8", 0x038 },
-{ "9", 0x039 },
-{ "colon", 0x03a },
-{ "semicolon", 0x03b },
-{ "less", 0x03c },
-{ "equal", 0x03d },
-{ "greater", 0x03e },
-{ "question", 0x03f },
-{ "at", 0x040 },
-{ "A", 0x041 },
-{ "B", 0x042 },
-{ "C", 0x043 },
-{ "D", 0x044 },
-{ "E", 0x045 },
-{ "F", 0x046 },
-{ "G", 0x047 },
-{ "H", 0x048 },
-{ "I", 0x049 },
-{ "J", 0x04a },
-{ "K", 0x04b },
-{ "L", 0x04c },
-{ "M", 0x04d },
-{ "N", 0x04e },
-{ "O", 0x04f },
-{ "P", 0x050 },
-{ "Q", 0x051 },
-{ "R", 0x052 },
-{ "S", 0x053 },
-{ "T", 0x054 },
-{ "U", 0x055 },
-{ "V", 0x056 },
-{ "W", 0x057 },
-{ "X", 0x058 },
-{ "Y", 0x059 },
-{ "Z", 0x05a },
-{ "bracketleft", 0x05b },
-{ "backslash", 0x05c },
-{ "bracketright", 0x05d },
-{ "asciicircum", 0x05e },
-{ "underscore", 0x05f },
-{ "quoteleft", 0x060 },
-{ "a", 0x061 },
-{ "b", 0x062 },
-{ "c", 0x063 },
-{ "d", 0x064 },
-{ "e", 0x065 },
-{ "f", 0x066 },
-{ "g", 0x067 },
-{ "h", 0x068 },
-{ "i", 0x069 },
-{ "j", 0x06a },
-{ "k", 0x06b },
-{ "l", 0x06c },
-{ "m", 0x06d },
-{ "n", 0x06e },
-{ "o", 0x06f },
-{ "p", 0x070 },
-{ "q", 0x071 },
-{ "r", 0x072 },
-{ "s", 0x073 },
-{ "t", 0x074 },
-{ "u", 0x075 },
-{ "v", 0x076 },
-{ "w", 0x077 },
-{ "x", 0x078 },
-{ "y", 0x079 },
-{ "z", 0x07a },
-{ "braceleft", 0x07b },
-{ "bar", 0x07c },
-{ "braceright", 0x07d },
-{ "asciitilde", 0x07e },
-{ "nobreakspace", 0x0a0 },
-{ "exclamdown", 0x0a1 },
-{ "cent", 0x0a2 },
-{ "sterling", 0x0a3 },
-{ "currency", 0x0a4 },
-{ "yen", 0x0a5 },
-{ "brokenbar", 0x0a6 },
-{ "section", 0x0a7 },
-{ "diaeresis", 0x0a8 },
-{ "copyright", 0x0a9 },
-{ "ordfeminine", 0x0aa },
-{ "guillemotleft", 0x0ab },
-{ "notsign", 0x0ac },
-{ "hyphen", 0x0ad },
-{ "registered", 0x0ae },
-{ "macron", 0x0af },
-{ "degree", 0x0b0 },
-{ "plusminus", 0x0b1 },
-{ "twosuperior", 0x0b2 },
-{ "threesuperior", 0x0b3 },
-{ "acute", 0x0b4 },
-{ "mu", 0x0b5 },
-{ "paragraph", 0x0b6 },
-{ "periodcentered", 0x0b7 },
-{ "cedilla", 0x0b8 },
-{ "onesuperior", 0x0b9 },
-{ "masculine", 0x0ba },
-{ "guillemotright", 0x0bb },
-{ "onequarter", 0x0bc },
-{ "onehalf", 0x0bd },
-{ "threequarters", 0x0be },
-{ "questiondown", 0x0bf },
-{ "Agrave", 0x0c0 },
-{ "Aacute", 0x0c1 },
-{ "Acircumflex", 0x0c2 },
-{ "Atilde", 0x0c3 },
-{ "Adiaeresis", 0x0c4 },
-{ "Aring", 0x0c5 },
-{ "AE", 0x0c6 },
-{ "Ccedilla", 0x0c7 },
-{ "Egrave", 0x0c8 },
-{ "Eacute", 0x0c9 },
-{ "Ecircumflex", 0x0ca },
-{ "Ediaeresis", 0x0cb },
-{ "Igrave", 0x0cc },
-{ "Iacute", 0x0cd },
-{ "Icircumflex", 0x0ce },
-{ "Idiaeresis", 0x0cf },
-{ "Eth", 0x0d0 },
-{ "Ntilde", 0x0d1 },
-{ "Ograve", 0x0d2 },
-{ "Oacute", 0x0d3 },
-{ "Ocircumflex", 0x0d4 },
-{ "Otilde", 0x0d5 },
-{ "Odiaeresis", 0x0d6 },
-{ "multiply", 0x0d7 },
-{ "Ooblique", 0x0d8 },
-{ "Ugrave", 0x0d9 },
-{ "Uacute", 0x0da },
-{ "Ucircumflex", 0x0db },
-{ "Udiaeresis", 0x0dc },
-{ "Yacute", 0x0dd },
-{ "Thorn", 0x0de },
-{ "ssharp", 0x0df },
-{ "agrave", 0x0e0 },
-{ "aacute", 0x0e1 },
-{ "acircumflex", 0x0e2 },
-{ "atilde", 0x0e3 },
-{ "adiaeresis", 0x0e4 },
-{ "aring", 0x0e5 },
-{ "ae", 0x0e6 },
-{ "ccedilla", 0x0e7 },
-{ "egrave", 0x0e8 },
-{ "eacute", 0x0e9 },
-{ "ecircumflex", 0x0ea },
-{ "ediaeresis", 0x0eb },
-{ "igrave", 0x0ec },
-{ "iacute", 0x0ed },
-{ "icircumflex", 0x0ee },
-{ "idiaeresis", 0x0ef },
-{ "eth", 0x0f0 },
-{ "ntilde", 0x0f1 },
-{ "ograve", 0x0f2 },
-{ "oacute", 0x0f3 },
-{ "ocircumflex", 0x0f4 },
-{ "otilde", 0x0f5 },
-{ "odiaeresis", 0x0f6 },
-{ "division", 0x0f7 },
-{ "oslash", 0x0f8 },
-{ "ugrave", 0x0f9 },
-{ "uacute", 0x0fa },
-{ "ucircumflex", 0x0fb },
-{ "udiaeresis", 0x0fc },
-{ "yacute", 0x0fd },
-{ "thorn", 0x0fe },
-{ "ydiaeresis", 0x0ff },
-{ "Aogonek", 0x1a1 },
-{ "breve", 0x1a2 },
-{ "Lstroke", 0x1a3 },
-{ "Lcaron", 0x1a5 },
-{ "Sacute", 0x1a6 },
-{ "Scaron", 0x1a9 },
-{ "Scedilla", 0x1aa },
-{ "Tcaron", 0x1ab },
-{ "Zacute", 0x1ac },
-{ "Zcaron", 0x1ae },
-{ "Zabovedot", 0x1af },
-{ "aogonek", 0x1b1 },
-{ "ogonek", 0x1b2 },
-{ "lstroke", 0x1b3 },
-{ "lcaron", 0x1b5 },
-{ "sacute", 0x1b6 },
-{ "caron", 0x1b7 },
-{ "scaron", 0x1b9 },
-{ "scedilla", 0x1ba },
-{ "tcaron", 0x1bb },
-{ "zacute", 0x1bc },
-{ "doubleacute", 0x1bd },
-{ "zcaron", 0x1be },
-{ "zabovedot", 0x1bf },
-{ "Racute", 0x1c0 },
-{ "Abreve", 0x1c3 },
-{ "Cacute", 0x1c6 },
-{ "Ccaron", 0x1c8 },
-{ "Eogonek", 0x1ca },
-{ "Ecaron", 0x1cc },
-{ "Dcaron", 0x1cf },
-{ "Nacute", 0x1d1 },
-{ "Ncaron", 0x1d2 },
-{ "Odoubleacute", 0x1d5 },
-{ "Rcaron", 0x1d8 },
-{ "Uring", 0x1d9 },
-{ "Udoubleacute", 0x1db },
-{ "Tcedilla", 0x1de },
-{ "racute", 0x1e0 },
-{ "abreve", 0x1e3 },
-{ "cacute", 0x1e6 },
-{ "ccaron", 0x1e8 },
-{ "eogonek", 0x1ea },
-{ "ecaron", 0x1ec },
-{ "dcaron", 0x1ef },
-{ "nacute", 0x1f1 },
-{ "ncaron", 0x1f2 },
-{ "odoubleacute", 0x1f5 },
-{ "udoubleacute", 0x1fb },
-{ "rcaron", 0x1f8 },
-{ "uring", 0x1f9 },
-{ "tcedilla", 0x1fe },
-{ "abovedot", 0x1ff },
-{ "Hstroke", 0x2a1 },
-{ "Hcircumflex", 0x2a6 },
-{ "Iabovedot", 0x2a9 },
-{ "Gbreve", 0x2ab },
-{ "Jcircumflex", 0x2ac },
-{ "hstroke", 0x2b1 },
-{ "hcircumflex", 0x2b6 },
-{ "idotless", 0x2b9 },
-{ "gbreve", 0x2bb },
-{ "jcircumflex", 0x2bc },
-{ "Cabovedot", 0x2c5 },
-{ "Ccircumflex", 0x2c6 },
-{ "Gabovedot", 0x2d5 },
-{ "Gcircumflex", 0x2d8 },
-{ "Ubreve", 0x2dd },
-{ "Scircumflex", 0x2de },
-{ "cabovedot", 0x2e5 },
-{ "ccircumflex", 0x2e6 },
-{ "gabovedot", 0x2f5 },
-{ "gcircumflex", 0x2f8 },
-{ "ubreve", 0x2fd },
-{ "scircumflex", 0x2fe },
-{ "kappa", 0x3a2 },
-{ "Rcedilla", 0x3a3 },
-{ "Itilde", 0x3a5 },
-{ "Lcedilla", 0x3a6 },
-{ "Emacron", 0x3aa },
-{ "Gcedilla", 0x3ab },
-{ "Tslash", 0x3ac },
-{ "rcedilla", 0x3b3 },
-{ "itilde", 0x3b5 },
-{ "lcedilla", 0x3b6 },
-{ "emacron", 0x3ba },
-{ "gacute", 0x3bb },
-{ "tslash", 0x3bc },
-{ "ENG", 0x3bd },
-{ "eng", 0x3bf },
-{ "Amacron", 0x3c0 },
-{ "Iogonek", 0x3c7 },
-{ "Eabovedot", 0x3cc },
-{ "Imacron", 0x3cf },
-{ "Ncedilla", 0x3d1 },
-{ "Omacron", 0x3d2 },
-{ "Kcedilla", 0x3d3 },
-{ "Uogonek", 0x3d9 },
-{ "Utilde", 0x3dd },
-{ "Umacron", 0x3de },
-{ "amacron", 0x3e0 },
-{ "iogonek", 0x3e7 },
-{ "eabovedot", 0x3ec },
-{ "imacron", 0x3ef },
-{ "ncedilla", 0x3f1 },
-{ "omacron", 0x3f2 },
-{ "kcedilla", 0x3f3 },
-{ "uogonek", 0x3f9 },
-{ "utilde", 0x3fd },
-{ "umacron", 0x3fe },
-{ "overline", 0x47e },
-{ "kana_fullstop", 0x4a1 },
-{ "kana_openingbracket", 0x4a2 },
-{ "kana_closingbracket", 0x4a3 },
-{ "kana_comma", 0x4a4 },
-{ "kana_middledot", 0x4a5 },
-{ "kana_WO", 0x4a6 },
-{ "kana_a", 0x4a7 },
-{ "kana_i", 0x4a8 },
-{ "kana_u", 0x4a9 },
-{ "kana_e", 0x4aa },
-{ "kana_o", 0x4ab },
-{ "kana_ya", 0x4ac },
-{ "kana_yu", 0x4ad },
-{ "kana_yo", 0x4ae },
-{ "kana_tu", 0x4af },
-{ "prolongedsound", 0x4b0 },
-{ "kana_A", 0x4b1 },
-{ "kana_I", 0x4b2 },
-{ "kana_U", 0x4b3 },
-{ "kana_E", 0x4b4 },
-{ "kana_O", 0x4b5 },
-{ "kana_KA", 0x4b6 },
-{ "kana_KI", 0x4b7 },
-{ "kana_KU", 0x4b8 },
-{ "kana_KE", 0x4b9 },
-{ "kana_KO", 0x4ba },
-{ "kana_SA", 0x4bb },
-{ "kana_SHI", 0x4bc },
-{ "kana_SU", 0x4bd },
-{ "kana_SE", 0x4be },
-{ "kana_SO", 0x4bf },
-{ "kana_TA", 0x4c0 },
-{ "kana_TI", 0x4c1 },
-{ "kana_TU", 0x4c2 },
-{ "kana_TE", 0x4c3 },
-{ "kana_TO", 0x4c4 },
-{ "kana_NA", 0x4c5 },
-{ "kana_NI", 0x4c6 },
-{ "kana_NU", 0x4c7 },
-{ "kana_NE", 0x4c8 },
-{ "kana_NO", 0x4c9 },
-{ "kana_HA", 0x4ca },
-{ "kana_HI", 0x4cb },
-{ "kana_HU", 0x4cc },
-{ "kana_HE", 0x4cd },
-{ "kana_HO", 0x4ce },
-{ "kana_MA", 0x4cf },
-{ "kana_MI", 0x4d0 },
-{ "kana_MU", 0x4d1 },
-{ "kana_ME", 0x4d2 },
-{ "kana_MO", 0x4d3 },
-{ "kana_YA", 0x4d4 },
-{ "kana_YU", 0x4d5 },
-{ "kana_YO", 0x4d6 },
-{ "kana_RA", 0x4d7 },
-{ "kana_RI", 0x4d8 },
-{ "kana_RU", 0x4d9 },
-{ "kana_RE", 0x4da },
-{ "kana_RO", 0x4db },
-{ "kana_WA", 0x4dc },
-{ "kana_N", 0x4dd },
-{ "voicedsound", 0x4de },
-{ "semivoicedsound", 0x4df },
-{ "kana_switch", 0xFF7E },
-{ "Arabic_comma", 0x5ac },
-{ "Arabic_semicolon", 0x5bb },
-{ "Arabic_question_mark", 0x5bf },
-{ "Arabic_hamza", 0x5c1 },
-{ "Arabic_maddaonalef", 0x5c2 },
-{ "Arabic_hamzaonalef", 0x5c3 },
-{ "Arabic_hamzaonwaw", 0x5c4 },
-{ "Arabic_hamzaunderalef", 0x5c5 },
-{ "Arabic_hamzaonyeh", 0x5c6 },
-{ "Arabic_alef", 0x5c7 },
-{ "Arabic_beh", 0x5c8 },
-{ "Arabic_tehmarbuta", 0x5c9 },
-{ "Arabic_teh", 0x5ca },
-{ "Arabic_theh", 0x5cb },
-{ "Arabic_jeem", 0x5cc },
-{ "Arabic_hah", 0x5cd },
-{ "Arabic_khah", 0x5ce },
-{ "Arabic_dal", 0x5cf },
-{ "Arabic_thal", 0x5d0 },
-{ "Arabic_ra", 0x5d1 },
-{ "Arabic_zain", 0x5d2 },
-{ "Arabic_seen", 0x5d3 },
-{ "Arabic_sheen", 0x5d4 },
-{ "Arabic_sad", 0x5d5 },
-{ "Arabic_dad", 0x5d6 },
-{ "Arabic_tah", 0x5d7 },
-{ "Arabic_zah", 0x5d8 },
-{ "Arabic_ain", 0x5d9 },
-{ "Arabic_ghain", 0x5da },
-{ "Arabic_tatweel", 0x5e0 },
-{ "Arabic_feh", 0x5e1 },
-{ "Arabic_qaf", 0x5e2 },
-{ "Arabic_kaf", 0x5e3 },
-{ "Arabic_lam", 0x5e4 },
-{ "Arabic_meem", 0x5e5 },
-{ "Arabic_noon", 0x5e6 },
-{ "Arabic_heh", 0x5e7 },
-{ "Arabic_waw", 0x5e8 },
-{ "Arabic_alefmaksura", 0x5e9 },
-{ "Arabic_yeh", 0x5ea },
-{ "Arabic_fathatan", 0x5eb },
-{ "Arabic_dammatan", 0x5ec },
-{ "Arabic_kasratan", 0x5ed },
-{ "Arabic_fatha", 0x5ee },
-{ "Arabic_damma", 0x5ef },
-{ "Arabic_kasra", 0x5f0 },
-{ "Arabic_shadda", 0x5f1 },
-{ "Arabic_sukun", 0x5f2 },
-{ "Arabic_switch", 0xFF7E },
-{ "Serbian_dje", 0x6a1 },
-{ "Macedonia_gje", 0x6a2 },
-{ "Cyrillic_io", 0x6a3 },
-{ "Ukranian_je", 0x6a4 },
-{ "Macedonia_dse", 0x6a5 },
-{ "Ukranian_i", 0x6a6 },
-{ "Ukranian_yi", 0x6a7 },
-{ "Serbian_je", 0x6a8 },
-{ "Serbian_lje", 0x6a9 },
-{ "Serbian_nje", 0x6aa },
-{ "Serbian_tshe", 0x6ab },
-{ "Macedonia_kje", 0x6ac },
-{ "Byelorussian_shortu", 0x6ae },
-{ "Serbian_dze", 0x6af },
-{ "numerosign", 0x6b0 },
-{ "Serbian_DJE", 0x6b1 },
-{ "Macedonia_GJE", 0x6b2 },
-{ "Cyrillic_IO", 0x6b3 },
-{ "Ukranian_JE", 0x6b4 },
-{ "Macedonia_DSE", 0x6b5 },
-{ "Ukranian_I", 0x6b6 },
-{ "Ukranian_YI", 0x6b7 },
-{ "Serbian_JE", 0x6b8 },
-{ "Serbian_LJE", 0x6b9 },
-{ "Serbian_NJE", 0x6ba },
-{ "Serbian_TSHE", 0x6bb },
-{ "Macedonia_KJE", 0x6bc },
-{ "Byelorussian_SHORTU", 0x6be },
-{ "Serbian_DZE", 0x6bf },
-{ "Cyrillic_yu", 0x6c0 },
-{ "Cyrillic_a", 0x6c1 },
-{ "Cyrillic_be", 0x6c2 },
-{ "Cyrillic_tse", 0x6c3 },
-{ "Cyrillic_de", 0x6c4 },
-{ "Cyrillic_ie", 0x6c5 },
-{ "Cyrillic_ef", 0x6c6 },
-{ "Cyrillic_ghe", 0x6c7 },
-{ "Cyrillic_ha", 0x6c8 },
-{ "Cyrillic_i", 0x6c9 },
-{ "Cyrillic_shorti", 0x6ca },
-{ "Cyrillic_ka", 0x6cb },
-{ "Cyrillic_el", 0x6cc },
-{ "Cyrillic_em", 0x6cd },
-{ "Cyrillic_en", 0x6ce },
-{ "Cyrillic_o", 0x6cf },
-{ "Cyrillic_pe", 0x6d0 },
-{ "Cyrillic_ya", 0x6d1 },
-{ "Cyrillic_er", 0x6d2 },
-{ "Cyrillic_es", 0x6d3 },
-{ "Cyrillic_te", 0x6d4 },
-{ "Cyrillic_u", 0x6d5 },
-{ "Cyrillic_zhe", 0x6d6 },
-{ "Cyrillic_ve", 0x6d7 },
-{ "Cyrillic_softsign", 0x6d8 },
-{ "Cyrillic_yeru", 0x6d9 },
-{ "Cyrillic_ze", 0x6da },
-{ "Cyrillic_sha", 0x6db },
-{ "Cyrillic_e", 0x6dc },
-{ "Cyrillic_shcha", 0x6dd },
-{ "Cyrillic_che", 0x6de },
-{ "Cyrillic_hardsign", 0x6df },
-{ "Cyrillic_YU", 0x6e0 },
-{ "Cyrillic_A", 0x6e1 },
-{ "Cyrillic_BE", 0x6e2 },
-{ "Cyrillic_TSE", 0x6e3 },
-{ "Cyrillic_DE", 0x6e4 },
-{ "Cyrillic_IE", 0x6e5 },
-{ "Cyrillic_EF", 0x6e6 },
-{ "Cyrillic_GHE", 0x6e7 },
-{ "Cyrillic_HA", 0x6e8 },
-{ "Cyrillic_I", 0x6e9 },
-{ "Cyrillic_SHORTI", 0x6ea },
-{ "Cyrillic_KA", 0x6eb },
-{ "Cyrillic_EL", 0x6ec },
-{ "Cyrillic_EM", 0x6ed },
-{ "Cyrillic_EN", 0x6ee },
-{ "Cyrillic_O", 0x6ef },
-{ "Cyrillic_PE", 0x6f0 },
-{ "Cyrillic_YA", 0x6f1 },
-{ "Cyrillic_ER", 0x6f2 },
-{ "Cyrillic_ES", 0x6f3 },
-{ "Cyrillic_TE", 0x6f4 },
-{ "Cyrillic_U", 0x6f5 },
-{ "Cyrillic_ZHE", 0x6f6 },
-{ "Cyrillic_VE", 0x6f7 },
-{ "Cyrillic_SOFTSIGN", 0x6f8 },
-{ "Cyrillic_YERU", 0x6f9 },
-{ "Cyrillic_ZE", 0x6fa },
-{ "Cyrillic_SHA", 0x6fb },
-{ "Cyrillic_E", 0x6fc },
-{ "Cyrillic_SHCHA", 0x6fd },
-{ "Cyrillic_CHE", 0x6fe },
-{ "Cyrillic_HARDSIGN", 0x6ff },
-{ "Greek_ALPHAaccent", 0x7a1 },
-{ "Greek_EPSILONaccent", 0x7a2 },
-{ "Greek_ETAaccent", 0x7a3 },
-{ "Greek_IOTAaccent", 0x7a4 },
-{ "Greek_IOTAdiaeresis", 0x7a5 },
-{ "Greek_IOTAaccentdiaeresis", 0x7a6 },
-{ "Greek_OMICRONaccent", 0x7a7 },
-{ "Greek_UPSILONaccent", 0x7a8 },
-{ "Greek_UPSILONdieresis", 0x7a9 },
-{ "Greek_UPSILONaccentdieresis", 0x7aa },
-{ "Greek_OMEGAaccent", 0x7ab },
-{ "Greek_alphaaccent", 0x7b1 },
-{ "Greek_epsilonaccent", 0x7b2 },
-{ "Greek_etaaccent", 0x7b3 },
-{ "Greek_iotaaccent", 0x7b4 },
-{ "Greek_iotadieresis", 0x7b5 },
-{ "Greek_iotaaccentdieresis", 0x7b6 },
-{ "Greek_omicronaccent", 0x7b7 },
-{ "Greek_upsilonaccent", 0x7b8 },
-{ "Greek_upsilondieresis", 0x7b9 },
-{ "Greek_upsilonaccentdieresis", 0x7ba },
-{ "Greek_omegaaccent", 0x7bb },
-{ "Greek_ALPHA", 0x7c1 },
-{ "Greek_BETA", 0x7c2 },
-{ "Greek_GAMMA", 0x7c3 },
-{ "Greek_DELTA", 0x7c4 },
-{ "Greek_EPSILON", 0x7c5 },
-{ "Greek_ZETA", 0x7c6 },
-{ "Greek_ETA", 0x7c7 },
-{ "Greek_THETA", 0x7c8 },
-{ "Greek_IOTA", 0x7c9 },
-{ "Greek_KAPPA", 0x7ca },
-{ "Greek_LAMBDA", 0x7cb },
-{ "Greek_MU", 0x7cc },
-{ "Greek_NU", 0x7cd },
-{ "Greek_XI", 0x7ce },
-{ "Greek_OMICRON", 0x7cf },
-{ "Greek_PI", 0x7d0 },
-{ "Greek_RHO", 0x7d1 },
-{ "Greek_SIGMA", 0x7d2 },
-{ "Greek_TAU", 0x7d4 },
-{ "Greek_UPSILON", 0x7d5 },
-{ "Greek_PHI", 0x7d6 },
-{ "Greek_CHI", 0x7d7 },
-{ "Greek_PSI", 0x7d8 },
-{ "Greek_OMEGA", 0x7d9 },
-{ "Greek_alpha", 0x7e1 },
-{ "Greek_beta", 0x7e2 },
-{ "Greek_gamma", 0x7e3 },
-{ "Greek_delta", 0x7e4 },
-{ "Greek_epsilon", 0x7e5 },
-{ "Greek_zeta", 0x7e6 },
-{ "Greek_eta", 0x7e7 },
-{ "Greek_theta", 0x7e8 },
-{ "Greek_iota", 0x7e9 },
-{ "Greek_kappa", 0x7ea },
-{ "Greek_lambda", 0x7eb },
-{ "Greek_mu", 0x7ec },
-{ "Greek_nu", 0x7ed },
-{ "Greek_xi", 0x7ee },
-{ "Greek_omicron", 0x7ef },
-{ "Greek_pi", 0x7f0 },
-{ "Greek_rho", 0x7f1 },
-{ "Greek_sigma", 0x7f2 },
-{ "Greek_finalsmallsigma", 0x7f3 },
-{ "Greek_tau", 0x7f4 },
-{ "Greek_upsilon", 0x7f5 },
-{ "Greek_phi", 0x7f6 },
-{ "Greek_chi", 0x7f7 },
-{ "Greek_psi", 0x7f8 },
-{ "Greek_omega", 0x7f9 },
-{ "Greek_switch", 0xFF7E },
-{ "leftradical", 0x8a1 },
-{ "topleftradical", 0x8a2 },
-{ "horizconnector", 0x8a3 },
-{ "topintegral", 0x8a4 },
-{ "botintegral", 0x8a5 },
-{ "vertconnector", 0x8a6 },
-{ "topleftsqbracket", 0x8a7 },
-{ "botleftsqbracket", 0x8a8 },
-{ "toprightsqbracket", 0x8a9 },
-{ "botrightsqbracket", 0x8aa },
-{ "topleftparens", 0x8ab },
-{ "botleftparens", 0x8ac },
-{ "toprightparens", 0x8ad },
-{ "botrightparens", 0x8ae },
-{ "leftmiddlecurlybrace", 0x8af },
-{ "rightmiddlecurlybrace", 0x8b0 },
-{ "topleftsummation", 0x8b1 },
-{ "botleftsummation", 0x8b2 },
-{ "topvertsummationconnector", 0x8b3 },
-{ "botvertsummationconnector", 0x8b4 },
-{ "toprightsummation", 0x8b5 },
-{ "botrightsummation", 0x8b6 },
-{ "rightmiddlesummation", 0x8b7 },
-{ "lessthanequal", 0x8bc },
-{ "notequal", 0x8bd },
-{ "greaterthanequal", 0x8be },
-{ "integral", 0x8bf },
-{ "therefore", 0x8c0 },
-{ "variation", 0x8c1 },
-{ "infinity", 0x8c2 },
-{ "nabla", 0x8c5 },
-{ "approximate", 0x8c8 },
-{ "similarequal", 0x8c9 },
-{ "ifonlyif", 0x8cd },
-{ "implies", 0x8ce },
-{ "identical", 0x8cf },
-{ "radical", 0x8d6 },
-{ "includedin", 0x8da },
-{ "includes", 0x8db },
-{ "intersection", 0x8dc },
-{ "union", 0x8dd },
-{ "logicaland", 0x8de },
-{ "logicalor", 0x8df },
-{ "partialderivative", 0x8ef },
-{ "function", 0x8f6 },
-{ "leftarrow", 0x8fb },
-{ "uparrow", 0x8fc },
-{ "rightarrow", 0x8fd },
-{ "downarrow", 0x8fe },
-{ "blank", 0x9df },
-{ "soliddiamond", 0x9e0 },
-{ "checkerboard", 0x9e1 },
-{ "ht", 0x9e2 },
-{ "ff", 0x9e3 },
-{ "cr", 0x9e4 },
-{ "lf", 0x9e5 },
-{ "nl", 0x9e8 },
-{ "vt", 0x9e9 },
-{ "lowrightcorner", 0x9ea },
-{ "uprightcorner", 0x9eb },
-{ "upleftcorner", 0x9ec },
-{ "lowleftcorner", 0x9ed },
-{ "crossinglines", 0x9ee },
-{ "horizlinescan1", 0x9ef },
-{ "horizlinescan3", 0x9f0 },
-{ "horizlinescan5", 0x9f1 },
-{ "horizlinescan7", 0x9f2 },
-{ "horizlinescan9", 0x9f3 },
-{ "leftt", 0x9f4 },
-{ "rightt", 0x9f5 },
-{ "bott", 0x9f6 },
-{ "topt", 0x9f7 },
-{ "vertbar", 0x9f8 },
-{ "emspace", 0xaa1 },
-{ "enspace", 0xaa2 },
-{ "em3space", 0xaa3 },
-{ "em4space", 0xaa4 },
-{ "digitspace", 0xaa5 },
-{ "punctspace", 0xaa6 },
-{ "thinspace", 0xaa7 },
-{ "hairspace", 0xaa8 },
-{ "emdash", 0xaa9 },
-{ "endash", 0xaaa },
-{ "signifblank", 0xaac },
-{ "ellipsis", 0xaae },
-{ "doubbaselinedot", 0xaaf },
-{ "onethird", 0xab0 },
-{ "twothirds", 0xab1 },
-{ "onefifth", 0xab2 },
-{ "twofifths", 0xab3 },
-{ "threefifths", 0xab4 },
-{ "fourfifths", 0xab5 },
-{ "onesixth", 0xab6 },
-{ "fivesixths", 0xab7 },
-{ "careof", 0xab8 },
-{ "figdash", 0xabb },
-{ "leftanglebracket", 0xabc },
-{ "decimalpoint", 0xabd },
-{ "rightanglebracket", 0xabe },
-{ "marker", 0xabf },
-{ "oneeighth", 0xac3 },
-{ "threeeighths", 0xac4 },
-{ "fiveeighths", 0xac5 },
-{ "seveneighths", 0xac6 },
-{ "trademark", 0xac9 },
-{ "signaturemark", 0xaca },
-{ "trademarkincircle", 0xacb },
-{ "leftopentriangle", 0xacc },
-{ "rightopentriangle", 0xacd },
-{ "emopencircle", 0xace },
-{ "emopenrectangle", 0xacf },
-{ "leftsinglequotemark", 0xad0 },
-{ "rightsinglequotemark", 0xad1 },
-{ "leftdoublequotemark", 0xad2 },
-{ "rightdoublequotemark", 0xad3 },
-{ "prescription", 0xad4 },
-{ "minutes", 0xad6 },
-{ "seconds", 0xad7 },
-{ "latincross", 0xad9 },
-{ "hexagram", 0xada },
-{ "filledrectbullet", 0xadb },
-{ "filledlefttribullet", 0xadc },
-{ "filledrighttribullet", 0xadd },
-{ "emfilledcircle", 0xade },
-{ "emfilledrect", 0xadf },
-{ "enopencircbullet", 0xae0 },
-{ "enopensquarebullet", 0xae1 },
-{ "openrectbullet", 0xae2 },
-{ "opentribulletup", 0xae3 },
-{ "opentribulletdown", 0xae4 },
-{ "openstar", 0xae5 },
-{ "enfilledcircbullet", 0xae6 },
-{ "enfilledsqbullet", 0xae7 },
-{ "filledtribulletup", 0xae8 },
-{ "filledtribulletdown", 0xae9 },
-{ "leftpointer", 0xaea },
-{ "rightpointer", 0xaeb },
-{ "club", 0xaec },
-{ "diamond", 0xaed },
-{ "heart", 0xaee },
-{ "maltesecross", 0xaf0 },
-{ "dagger", 0xaf1 },
-{ "doubledagger", 0xaf2 },
-{ "checkmark", 0xaf3 },
-{ "ballotcross", 0xaf4 },
-{ "musicalsharp", 0xaf5 },
-{ "musicalflat", 0xaf6 },
-{ "malesymbol", 0xaf7 },
-{ "femalesymbol", 0xaf8 },
-{ "telephone", 0xaf9 },
-{ "telephonerecorder", 0xafa },
-{ "phonographcopyright", 0xafb },
-{ "caret", 0xafc },
-{ "singlelowquotemark", 0xafd },
-{ "doublelowquotemark", 0xafe },
-{ "cursor", 0xaff },
-{ "leftcaret", 0xba3 },
-{ "rightcaret", 0xba6 },
-{ "downcaret", 0xba8 },
-{ "upcaret", 0xba9 },
-{ "overbar", 0xbc0 },
-{ "downtack", 0xbc2 },
-{ "upshoe", 0xbc3 },
-{ "downstile", 0xbc4 },
-{ "underbar", 0xbc6 },
-{ "jot", 0xbca },
-{ "quad", 0xbcc },
-{ "uptack", 0xbce },
-{ "circle", 0xbcf },
-{ "upstile", 0xbd3 },
-{ "downshoe", 0xbd6 },
-{ "rightshoe", 0xbd8 },
-{ "leftshoe", 0xbda },
-{ "lefttack", 0xbdc },
-{ "righttack", 0xbfc },
-{ "hebrew_aleph", 0xce0 },
-{ "hebrew_beth", 0xce1 },
-{ "hebrew_gimmel", 0xce2 },
-{ "hebrew_daleth", 0xce3 },
-{ "hebrew_he", 0xce4 },
-{ "hebrew_waw", 0xce5 },
-{ "hebrew_zayin", 0xce6 },
-{ "hebrew_het", 0xce7 },
-{ "hebrew_teth", 0xce8 },
-{ "hebrew_yod", 0xce9 },
-{ "hebrew_finalkaph", 0xcea },
-{ "hebrew_kaph", 0xceb },
-{ "hebrew_lamed", 0xcec },
-{ "hebrew_finalmem", 0xced },
-{ "hebrew_mem", 0xcee },
-{ "hebrew_finalnun", 0xcef },
-{ "hebrew_nun", 0xcf0 },
-{ "hebrew_samekh", 0xcf1 },
-{ "hebrew_ayin", 0xcf2 },
-{ "hebrew_finalpe", 0xcf3 },
-{ "hebrew_pe", 0xcf4 },
-{ "hebrew_finalzadi", 0xcf5 },
-{ "hebrew_zadi", 0xcf6 },
-{ "hebrew_kuf", 0xcf7 },
-{ "hebrew_resh", 0xcf8 },
-{ "hebrew_shin", 0xcf9 },
-{ "hebrew_taf", 0xcfa },
-{ "Hebrew_switch", 0xFF7E },
diff --git a/generic/tk.h b/generic/tk.h
deleted file mode 100644
index 6fcff0b..0000000
--- a/generic/tk.h
+++ /dev/null
@@ -1,1558 +0,0 @@
-/*
- * tk.h --
- *
- * Declarations for Tk-related things that are visible
- * outside of the Tk module itself.
- *
- * Copyright (c) 1989-1994 The Regents of the University of California.
- * Copyright (c) 1994 The Australian National University.
- * 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: tk.h,v 1.12 1998/09/14 18:23:02 stanton Exp $
- */
-
-#ifndef _TK
-#define _TK
-
-/*
- * When version numbers change here, you must also go into the following files
- * and update the version numbers:
- *
- * README
- * unix/configure.in
- * win/makefile.bc (Not for patch release updates)
- * win/makefile.vc (Not for patch release updates)
- * library/tk.tcl
- *
- * The release level should be 0 for alpha, 1 for beta, and 2 for
- * final/patch. The release serial value is the number that follows the
- * "a", "b", or "p" in the patch level; for example, if the patch level
- * is 4.3b2, TK_RELEASE_SERIAL is 2. It restarts at 1 whenever the
- * release level is changed, except for the final release, which should
- * be 0.
- *
- * 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 0
-#define TK_RELEASE_LEVEL 2
-#define TK_RELEASE_SERIAL 3
-
-#define TK_VERSION "8.0"
-#define TK_PATCH_LEVEL "8.0.3"
-
-/*
- * A special definition used to allow this header file to be included
- * in resource files.
- */
-
-#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
-# ifndef REDO_KEYSYM_LOOKUP
-# define REDO_KEYSYM_LOOKUP
-# endif
-#endif
-
-#ifndef _TCL
-# include <tcl.h>
-#endif
-#ifndef _XLIB_H
-# ifdef MAC_TCL
-# include <Xlib.h>
-# include <X.h>
-# else
-# include <X11/Xlib.h>
-# endif
-#endif
-#ifdef __STDC__
-# include <stddef.h>
-#endif
-
-#ifdef BUILD_tk
-# undef TCL_STORAGE_CLASS
-# define TCL_STORAGE_CLASS DLLEXPORT
-#endif
-
-/*
- * Decide whether or not to use input methods.
- */
-
-#ifdef XNQueryInputStyle
-#define TK_USE_INPUT_METHODS
-#endif
-
-/*
- * Dummy types that are used by clients:
- */
-
-typedef struct Tk_BindingTable_ *Tk_BindingTable;
-typedef struct Tk_Canvas_ *Tk_Canvas;
-typedef struct Tk_Cursor_ *Tk_Cursor;
-typedef struct Tk_ErrorHandler_ *Tk_ErrorHandler;
-typedef struct Tk_Font_ *Tk_Font;
-typedef struct Tk_Image__ *Tk_Image;
-typedef struct Tk_ImageMaster_ *Tk_ImageMaster;
-typedef struct Tk_TextLayout_ *Tk_TextLayout;
-typedef struct Tk_Window_ *Tk_Window;
-typedef struct Tk_3DBorder_ *Tk_3DBorder;
-
-/*
- * Additional types exported to clients.
- */
-
-typedef char *Tk_Uid;
-
-/*
- * Structure used to specify how to handle argv options.
- */
-
-typedef struct {
- char *key; /* The key string that flags the option in the
- * argv array. */
- int type; /* Indicates option type; see below. */
- char *src; /* Value to be used in setting dst; usage
- * depends on type. */
- char *dst; /* Address of value to be modified; usage
- * depends on type. */
- char *help; /* Documentation message describing this option. */
-} Tk_ArgvInfo;
-
-/*
- * Legal values for the type field of a Tk_ArgvInfo: see the user
- * documentation for details.
- */
-
-#define TK_ARGV_CONSTANT 15
-#define TK_ARGV_INT 16
-#define TK_ARGV_STRING 17
-#define TK_ARGV_UID 18
-#define TK_ARGV_REST 19
-#define TK_ARGV_FLOAT 20
-#define TK_ARGV_FUNC 21
-#define TK_ARGV_GENFUNC 22
-#define TK_ARGV_HELP 23
-#define TK_ARGV_CONST_OPTION 24
-#define TK_ARGV_OPTION_VALUE 25
-#define TK_ARGV_OPTION_NAME_VALUE 26
-#define TK_ARGV_END 27
-
-/*
- * Flag bits for passing to Tk_ParseArgv:
- */
-
-#define TK_ARGV_NO_DEFAULTS 0x1
-#define TK_ARGV_NO_LEFTOVERS 0x2
-#define TK_ARGV_NO_ABBREV 0x4
-#define TK_ARGV_DONT_SKIP_FIRST_ARG 0x8
-
-/*
- * Structure used to describe application-specific configuration
- * options: indicates procedures to call to parse an option and
- * to return a text string describing an option.
- */
-
-typedef int (Tk_OptionParseProc) _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, Tk_Window tkwin, char *value, char *widgRec,
- int offset));
-typedef char *(Tk_OptionPrintProc) _ANSI_ARGS_((ClientData clientData,
- Tk_Window tkwin, char *widgRec, int offset,
- Tcl_FreeProc **freeProcPtr));
-
-typedef struct Tk_CustomOption {
- Tk_OptionParseProc *parseProc; /* Procedure to call to parse an
- * option and store it in converted
- * form. */
- Tk_OptionPrintProc *printProc; /* Procedure to return a printable
- * string describing an existing
- * option. */
- ClientData clientData; /* Arbitrary one-word value used by
- * option parser: passed to
- * parseProc and printProc. */
-} Tk_CustomOption;
-
-/*
- * Structure used to specify information for Tk_ConfigureWidget. Each
- * structure gives complete information for one option, including
- * how the option is specified on the command line, where it appears
- * in the option database, etc.
- */
-
-typedef struct Tk_ConfigSpec {
- int type; /* Type of option, such as TK_CONFIG_COLOR;
- * see definitions below. Last option in
- * 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
- * specified in command line or database. */
- int offset; /* Where in widget record to store value;
- * use Tk_Offset macro to generate values
- * for this. */
- int specFlags; /* Any combination of the values defined
- * below; other bits are used internally
- * by tkConfig.c. */
- Tk_CustomOption *customPtr; /* If type is TK_CONFIG_CUSTOM then this is
- * a pointer to info about how to parse and
- * print the option. Otherwise it is
- * irrelevant. */
-} Tk_ConfigSpec;
-
-/*
- * Type values for Tk_ConfigSpec structures. See the user
- * documentation for details.
- */
-
-#define TK_CONFIG_BOOLEAN 1
-#define TK_CONFIG_INT 2
-#define TK_CONFIG_DOUBLE 3
-#define TK_CONFIG_STRING 4
-#define TK_CONFIG_UID 5
-#define TK_CONFIG_COLOR 6
-#define TK_CONFIG_FONT 7
-#define TK_CONFIG_BITMAP 8
-#define TK_CONFIG_BORDER 9
-#define TK_CONFIG_RELIEF 10
-#define TK_CONFIG_CURSOR 11
-#define TK_CONFIG_ACTIVE_CURSOR 12
-#define TK_CONFIG_JUSTIFY 13
-#define TK_CONFIG_ANCHOR 14
-#define TK_CONFIG_SYNONYM 15
-#define TK_CONFIG_CAP_STYLE 16
-#define TK_CONFIG_JOIN_STYLE 17
-#define TK_CONFIG_PIXELS 18
-#define TK_CONFIG_MM 19
-#define TK_CONFIG_WINDOW 20
-#define TK_CONFIG_CUSTOM 21
-#define TK_CONFIG_END 22
-
-/*
- * Macro to use to fill in "offset" fields of Tk_ConfigInfos.
- * Computes number of bytes from beginning of structure to a
- * given field.
- */
-
-#ifdef offsetof
-#define Tk_Offset(type, field) ((int) offsetof(type, field))
-#else
-#define Tk_Offset(type, field) ((int) ((char *) &((type *) 0)->field))
-#endif
-
-/*
- * Possible values for flags argument to Tk_ConfigureWidget:
- */
-
-#define TK_CONFIG_ARGV_ONLY 1
-
-/*
- * Possible flag values for Tk_ConfigInfo structures. Any bits at
- * or above TK_CONFIG_USER_BIT may be used by clients for selecting
- * certain entries. Before changing any values here, coordinate with
- * tkConfig.c (internal-use-only flags are defined there).
- */
-
-#define TK_CONFIG_COLOR_ONLY 1
-#define TK_CONFIG_MONO_ONLY 2
-#define TK_CONFIG_NULL_OK 4
-#define TK_CONFIG_DONT_SET_DEFAULT 8
-#define TK_CONFIG_OPTION_SPECIFIED 0x10
-#define TK_CONFIG_USER_BIT 0x100
-
-/*
- * Enumerated type for describing actions to be taken in response
- * to a restrictProc established by Tk_RestrictEvents.
- */
-
-typedef enum {
- TK_DEFER_EVENT, TK_PROCESS_EVENT, TK_DISCARD_EVENT
-} Tk_RestrictAction;
-
-/*
- * Priority levels to pass to Tk_AddOption:
- */
-
-#define TK_WIDGET_DEFAULT_PRIO 20
-#define TK_STARTUP_FILE_PRIO 40
-#define TK_USER_DEFAULT_PRIO 60
-#define TK_INTERACTIVE_PRIO 80
-#define TK_MAX_PRIO 100
-
-/*
- * Relief values returned by Tk_GetRelief:
- */
-
-#define TK_RELIEF_RAISED 1
-#define TK_RELIEF_FLAT 2
-#define TK_RELIEF_SUNKEN 4
-#define TK_RELIEF_GROOVE 8
-#define TK_RELIEF_RIDGE 16
-#define TK_RELIEF_SOLID 32
-
-/*
- * "Which" argument values for Tk_3DBorderGC:
- */
-
-#define TK_3D_FLAT_GC 1
-#define TK_3D_LIGHT_GC 2
-#define TK_3D_DARK_GC 3
-
-/*
- * Special EnterNotify/LeaveNotify "mode" for use in events
- * generated by tkShare.c. Pick a high enough value that it's
- * unlikely to conflict with existing values (like NotifyNormal)
- * or any new values defined in the future.
- */
-
-#define TK_NOTIFY_SHARE 20
-
-/*
- * Enumerated type for describing a point by which to anchor something:
- */
-
-typedef enum {
- TK_ANCHOR_N, TK_ANCHOR_NE, TK_ANCHOR_E, TK_ANCHOR_SE,
- TK_ANCHOR_S, TK_ANCHOR_SW, TK_ANCHOR_W, TK_ANCHOR_NW,
- TK_ANCHOR_CENTER
-} Tk_Anchor;
-
-/*
- * Enumerated type for describing a style of justification:
- */
-
-typedef enum {
- TK_JUSTIFY_LEFT, TK_JUSTIFY_RIGHT, TK_JUSTIFY_CENTER
-} Tk_Justify;
-
-/*
- * The following structure is used by Tk_GetFontMetrics() to return
- * information about the properties of a Tk_Font.
- */
-
-typedef struct Tk_FontMetrics {
- int ascent; /* The amount in pixels that the tallest
- * letter sticks up above the baseline, plus
- * any extra blank space added by the designer
- * of the font. */
- int descent; /* The largest amount in pixels that any
- * letter sticks below the baseline, plus any
- * extra blank space added by the designer of
- * the font. */
- int linespace; /* The sum of the ascent and descent. How
- * far apart two lines of text in the same
- * font should be placed so that none of the
- * characters in one line overlap any of the
- * characters in the other line. */
-} Tk_FontMetrics;
-
-/*
- * Flags passed to Tk_MeasureChars:
- */
-
-#define TK_WHOLE_WORDS 1
-#define TK_AT_LEAST_ONE 2
-#define TK_PARTIAL_OK 4
-
-/*
- * Flags passed to Tk_ComputeTextLayout:
- */
-
-#define TK_IGNORE_TABS 8
-#define TK_IGNORE_NEWLINES 16
-
-/*
- * Each geometry manager (the packer, the placer, etc.) is represented
- * by a structure of the following form, which indicates procedures
- * to invoke in the geometry manager to carry out certain functions.
- */
-
-typedef void (Tk_GeomRequestProc) _ANSI_ARGS_((ClientData clientData,
- Tk_Window tkwin));
-typedef void (Tk_GeomLostSlaveProc) _ANSI_ARGS_((ClientData clientData,
- Tk_Window tkwin));
-
-typedef struct Tk_GeomMgr {
- char *name; /* Name of the geometry manager (command
- * used to invoke it, or name of widget
- * class that allows embedded widgets). */
- Tk_GeomRequestProc *requestProc;
- /* Procedure to invoke when a slave's
- * requested geometry changes. */
- Tk_GeomLostSlaveProc *lostSlaveProc;
- /* Procedure to invoke when a slave is
- * taken away from one geometry manager
- * by another. NULL means geometry manager
- * doesn't care when slaves are lost. */
-} Tk_GeomMgr;
-
-/*
- * Result values returned by Tk_GetScrollInfo:
- */
-
-#define TK_SCROLL_MOVETO 1
-#define TK_SCROLL_PAGES 2
-#define TK_SCROLL_UNITS 3
-#define TK_SCROLL_ERROR 4
-
-/*
- *---------------------------------------------------------------------------
- *
- * Extensions to the X event set
- *
- *---------------------------------------------------------------------------
- */
-#define VirtualEvent (LASTEvent)
-#define ActivateNotify (LASTEvent + 1)
-#define DeactivateNotify (LASTEvent + 2)
-#define TK_LASTEVENT (LASTEvent + 3)
-
-#define VirtualEventMask (1L << 30)
-#define ActivateMask (1L << 29)
-#define TK_LASTEVENT (LASTEvent + 3)
-
-
-/*
- * A virtual event shares most of its fields with the XKeyEvent and
- * XButtonEvent structures. 99% of the time a virtual event will be
- * an abstraction of a key or button event, so this structure provides
- * the most information to the user. The only difference is the changing
- * of the detail field for a virtual event so that it holds the name of the
- * virtual event being triggered.
- */
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* True if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window event; /* Window on which event was requested. */
- Window root; /* root window that the event occured on */
- Window subwindow; /* child window */
- Time time; /* milliseconds */
- int x, y; /* pointer x, y coordinates in event window */
- int x_root, y_root; /* coordinates relative to root */
- unsigned int state; /* key or button mask */
- Tk_Uid name; /* Name of virtual event. */
- Bool same_screen; /* same screen flag */
-} XVirtualEvent;
-
-typedef struct {
- int type;
- unsigned long serial; /* # of last request processed by server */
- Bool send_event; /* True if this came from a SendEvent request */
- Display *display; /* Display the event was read from */
- Window window; /* Window in which event occurred. */
-} XActivateDeactivateEvent;
-typedef XActivateDeactivateEvent XActivateEvent;
-typedef XActivateDeactivateEvent XDeactivateEvent;
-
-/*
- *--------------------------------------------------------------
- *
- * Macros for querying Tk_Window structures. See the
- * manual entries for documentation.
- *
- *--------------------------------------------------------------
- */
-
-#define Tk_Display(tkwin) (((Tk_FakeWin *) (tkwin))->display)
-#define Tk_ScreenNumber(tkwin) (((Tk_FakeWin *) (tkwin))->screenNum)
-#define Tk_Screen(tkwin) (ScreenOfDisplay(Tk_Display(tkwin), \
- Tk_ScreenNumber(tkwin)))
-#define Tk_Depth(tkwin) (((Tk_FakeWin *) (tkwin))->depth)
-#define Tk_Visual(tkwin) (((Tk_FakeWin *) (tkwin))->visual)
-#define Tk_WindowId(tkwin) (((Tk_FakeWin *) (tkwin))->window)
-#define Tk_PathName(tkwin) (((Tk_FakeWin *) (tkwin))->pathName)
-#define Tk_Name(tkwin) (((Tk_FakeWin *) (tkwin))->nameUid)
-#define Tk_Class(tkwin) (((Tk_FakeWin *) (tkwin))->classUid)
-#define Tk_X(tkwin) (((Tk_FakeWin *) (tkwin))->changes.x)
-#define Tk_Y(tkwin) (((Tk_FakeWin *) (tkwin))->changes.y)
-#define Tk_Width(tkwin) (((Tk_FakeWin *) (tkwin))->changes.width)
-#define Tk_Height(tkwin) \
- (((Tk_FakeWin *) (tkwin))->changes.height)
-#define Tk_Changes(tkwin) (&((Tk_FakeWin *) (tkwin))->changes)
-#define Tk_Attributes(tkwin) (&((Tk_FakeWin *) (tkwin))->atts)
-#define Tk_IsEmbedded(tkwin) \
- (((Tk_FakeWin *) (tkwin))->flags & TK_EMBEDDED)
-#define Tk_IsContainer(tkwin) \
- (((Tk_FakeWin *) (tkwin))->flags & TK_CONTAINER)
-#define Tk_IsMapped(tkwin) \
- (((Tk_FakeWin *) (tkwin))->flags & TK_MAPPED)
-#define Tk_IsTopLevel(tkwin) \
- (((Tk_FakeWin *) (tkwin))->flags & TK_TOP_LEVEL)
-#define Tk_ReqWidth(tkwin) (((Tk_FakeWin *) (tkwin))->reqWidth)
-#define Tk_ReqHeight(tkwin) (((Tk_FakeWin *) (tkwin))->reqHeight)
-#define Tk_InternalBorderWidth(tkwin) \
- (((Tk_FakeWin *) (tkwin))->internalBorderWidth)
-#define Tk_Parent(tkwin) (((Tk_FakeWin *) (tkwin))->parentPtr)
-#define Tk_Colormap(tkwin) (((Tk_FakeWin *) (tkwin))->atts.colormap)
-
-/*
- * The structure below is needed by the macros above so that they can
- * access the fields of a Tk_Window. The fields not needed by the macros
- * are declared as "dummyX". The structure has its own type in order to
- * prevent applications from accessing Tk_Window fields except using
- * official macros. WARNING!! The structure definition must be kept
- * consistent with the TkWindow structure in tkInt.h. If you change one,
- * then change the other. See the declaration in tkInt.h for
- * documentation on what the fields are used for internally.
- */
-
-typedef struct Tk_FakeWin {
- Display *display;
- char *dummy1;
- int screenNum;
- Visual *visual;
- int depth;
- Window window;
- char *dummy2;
- char *dummy3;
- Tk_Window parentPtr;
- char *dummy4;
- char *dummy5;
- char *pathName;
- Tk_Uid nameUid;
- Tk_Uid classUid;
- XWindowChanges changes;
- unsigned int dummy6;
- XSetWindowAttributes atts;
- unsigned long dummy7;
- unsigned int flags;
- char *dummy8;
-#ifdef TK_USE_INPUT_METHODS
- XIC dummy9;
-#endif /* TK_USE_INPUT_METHODS */
- ClientData *dummy10;
- int dummy11;
- int dummy12;
- char *dummy13;
- char *dummy14;
- ClientData dummy15;
- int reqWidth, reqHeight;
- int internalBorderWidth;
- char *dummy16;
- char *dummy17;
- ClientData dummy18;
- char *dummy19;
-} Tk_FakeWin;
-
-/*
- * Flag values for TkWindow (and Tk_FakeWin) structures are:
- *
- * 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_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
- * before it was made to exist. At the time of
- * making it exist a ConfigureNotify event needs
- * to be generated.
- * TK_GRAB_FLAG: Used to manage grabs. See tkGrab.c for
- * details.
- * TK_CHECKED_IC: 1 means we've already tried to get an input
- * context for this window; if the ic field
- * is NULL it means that there isn't a context
- * for the field.
- * TK_DONT_DESTROY_WINDOW: 1 means that Tk_DestroyWindow should not
- * invoke XDestroyWindow to destroy this widget's
- * X window. The flag is set when the window
- * has already been destroyed elsewhere (e.g.
- * by another application) or when it will be
- * destroyed later (e.g. by destroying its
- * parent).
- * TK_WM_COLORMAP_WINDOW: 1 means that this window has at some time
- * appeared in the WM_COLORMAP_WINDOWS property
- * for its toplevel, so we have to remove it
- * from that property if the window is
- * deleted and the toplevel isn't.
- * TK_EMBEDDED: 1 means that this window (which must be a
- * toplevel) is not a free-standing window but
- * rather is embedded in some other application.
- * TK_CONTAINER: 1 means that this window is a container, and
- * that some other application (either in
- * this process or elsewhere) may be
- * embedding itself inside the window.
- * TK_BOTH_HALVES: 1 means that this window is used for
- * application embedding (either as
- * container or embedded application), and
- * both the containing and embedded halves
- * are associated with windows in this
- * particular process.
- * TK_DEFER_MODAL: 1 means that this window has deferred a modal
- * loop until all of the bindings for the current
- * event have been invoked.
- * TK_WRAPPER: 1 means that this window is the extra
- * wrapper window created around a toplevel
- * to hold the menubar under Unix. See
- * tkUnixWm.c for more information.
- * TK_REPARENTED: 1 means that this window has been reparented
- * so that as far as the window system is
- * concerned it isn't a child of its Tk
- * parent. Initially this is used only for
- * special Unix menubar windows.
- */
-
-
-#define TK_MAPPED 1
-#define TK_TOP_LEVEL 2
-#define TK_ALREADY_DEAD 4
-#define TK_NEED_CONFIG_NOTIFY 8
-#define TK_GRAB_FLAG 0x10
-#define TK_CHECKED_IC 0x20
-#define TK_DONT_DESTROY_WINDOW 0x40
-#define TK_WM_COLORMAP_WINDOW 0x80
-#define TK_EMBEDDED 0x100
-#define TK_CONTAINER 0x200
-#define TK_BOTH_HALVES 0x400
-#define TK_DEFER_MODAL 0x800
-#define TK_WRAPPER 0x1000
-#define TK_REPARENTED 0x2000
-
-/*
- *--------------------------------------------------------------
- *
- * Procedure prototypes and structures used for defining new canvas
- * items:
- *
- *--------------------------------------------------------------
- */
-
-/*
- * For each item in a canvas widget there exists one record with
- * the following structure. Each actual item is represented by
- * a record with the following stuff at its beginning, plus additional
- * type-specific stuff after that.
- */
-
-#define TK_TAG_SPACE 3
-
-typedef struct Tk_Item {
- int id; /* Unique identifier for this item
- * (also serves as first tag for
- * item). */
- struct Tk_Item *nextPtr; /* Next in display list of all
- * items in this canvas. Later items
- * in list are drawn on top of earlier
- * ones. */
- Tk_Uid staticTagSpace[TK_TAG_SPACE];/* Built-in space for limited # of
- * tags. */
- Tk_Uid *tagPtr; /* Pointer to array of tags. Usually
- * points to staticTagSpace, but
- * may point to malloc-ed space if
- * there are lots of tags. */
- int tagSpace; /* Total amount of tag space available
- * at tagPtr. */
- int numTags; /* Number of tag slots actually used
- * at *tagPtr. */
- struct Tk_ItemType *typePtr; /* Table of procedures that implement
- * this type of item. */
- int x1, y1, x2, y2; /* Bounding box for item, in integer
- * canvas units. Set by item-specific
- * code and guaranteed to contain every
- * pixel drawn in item. Item area
- * includes x1 and y1 but not x2
- * and y2. */
- int reserved1; /* This padding is for compatibility */
- char *reserved2; /* with Jan Nijtmans dash patch */
- int reserved3;
- char *reserved4;
-
- /*
- *------------------------------------------------------------------
- * Starting here is additional type-specific stuff; see the
- * declarations for individual types to see what is part of
- * each type. The actual space below is determined by the
- * "itemInfoSize" of the type's Tk_ItemType record.
- *------------------------------------------------------------------
- */
-} Tk_Item;
-
-/*
- * Records of the following type are used to describe a type of
- * item (e.g. lines, circles, etc.) that can form part of a
- * canvas widget.
- */
-
-typedef int Tk_ItemCreateProc _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Canvas canvas, Tk_Item *itemPtr, int argc,
- char **argv));
-typedef int Tk_ItemConfigureProc _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Canvas canvas, Tk_Item *itemPtr, int argc,
- char **argv, int flags));
-typedef int Tk_ItemCoordProc _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Canvas canvas, Tk_Item *itemPtr, int argc,
- char **argv));
-typedef void Tk_ItemDeleteProc _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, Display *display));
-typedef void Tk_ItemDisplayProc _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, Display *display, Drawable dst,
- int x, int y, int width, int height));
-typedef double Tk_ItemPointProc _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double *pointPtr));
-typedef int Tk_ItemAreaProc _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double *rectPtr));
-typedef int Tk_ItemPostscriptProc _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Canvas canvas, Tk_Item *itemPtr, int prepass));
-typedef void Tk_ItemScaleProc _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double originX, double originY,
- double scaleX, double scaleY));
-typedef void Tk_ItemTranslateProc _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double deltaX, double deltaY));
-typedef int Tk_ItemIndexProc _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Canvas canvas, Tk_Item *itemPtr, char *indexString,
- int *indexPtr));
-typedef void Tk_ItemCursorProc _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, int index));
-typedef int Tk_ItemSelectionProc _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, int offset, char *buffer,
- int maxBytes));
-typedef void Tk_ItemInsertProc _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, int beforeThis, char *string));
-typedef void Tk_ItemDCharsProc _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, int first, int last));
-
-typedef struct Tk_ItemType {
- char *name; /* The name of this type of item, such
- * as "line". */
- int itemSize; /* Total amount of space needed for
- * item's record. */
- Tk_ItemCreateProc *createProc; /* Procedure to create a new item of
- * this type. */
- Tk_ConfigSpec *configSpecs; /* Pointer to array of configuration
- * specs for this type. Used for
- * returning configuration info. */
- Tk_ItemConfigureProc *configProc; /* Procedure to call to change
- * configuration options. */
- Tk_ItemCoordProc *coordProc; /* Procedure to call to get and set
- * the item's coordinates. */
- Tk_ItemDeleteProc *deleteProc; /* Procedure to delete existing item of
- * this type. */
- Tk_ItemDisplayProc *displayProc; /* Procedure to display items of
- * this type. */
- int alwaysRedraw; /* Non-zero means displayProc should
- * be called even when the item has
- * been moved off-screen. */
- Tk_ItemPointProc *pointProc; /* Computes distance from item to
- * a given point. */
- Tk_ItemAreaProc *areaProc; /* Computes whether item is inside,
- * outside, or overlapping an area. */
- Tk_ItemPostscriptProc *postscriptProc;
- /* Procedure to write a Postscript
- * description for items of this
- * type. */
- Tk_ItemScaleProc *scaleProc; /* Procedure to rescale items of
- * this type. */
- Tk_ItemTranslateProc *translateProc;/* Procedure to translate items of
- * this type. */
- Tk_ItemIndexProc *indexProc; /* Procedure to determine index of
- * indicated character. NULL if
- * item doesn't support indexing. */
- Tk_ItemCursorProc *icursorProc; /* Procedure to set insert cursor pos.
- * to just before a given position. */
- Tk_ItemSelectionProc *selectionProc;/* Procedure to return selection (in
- * STRING format) when it is in this
- * item. */
- Tk_ItemInsertProc *insertProc; /* Procedure to insert something into
- * an item. */
- Tk_ItemDCharsProc *dCharsProc; /* Procedure to delete characters
- * from an item. */
- struct Tk_ItemType *nextPtr; /* Used to link types together into
- * a list. */
- char *reserved1; /* Reserved for future extension. */
- int reserved2; /* Carefully compatible with */
- char *reserved3; /* Jan Nijtmans dash patch */
- char *reserved4;
-} Tk_ItemType;
-
-/*
- * The following structure provides information about the selection and
- * the insertion cursor. It is needed by only a few items, such as
- * those that display text. It is shared by the generic canvas code
- * and the item-specific code, but most of the fields should be written
- * only by the canvas generic code.
- */
-
-typedef struct Tk_CanvasTextInfo {
- Tk_3DBorder selBorder; /* Border and background for selected
- * characters. Read-only to items.*/
- int selBorderWidth; /* Width of border around selection.
- * Read-only to items. */
- XColor *selFgColorPtr; /* Foreground color for selected text.
- * Read-only to items. */
- Tk_Item *selItemPtr; /* Pointer to selected item. NULL means
- * selection isn't in this canvas.
- * Writable by items. */
- int selectFirst; /* Index of first selected character.
- * Writable by items. */
- int selectLast; /* Index of last selected character.
- * Writable by items. */
- Tk_Item *anchorItemPtr; /* Item corresponding to "selectAnchor":
- * not necessarily selItemPtr. Read-only
- * to items. */
- int selectAnchor; /* Fixed end of selection (i.e. "select to"
- * operation will use this as one end of the
- * selection). Writable by items. */
- Tk_3DBorder insertBorder; /* Used to draw vertical bar for insertion
- * cursor. Read-only to items. */
- int insertWidth; /* Total width of insertion cursor. Read-only
- * to items. */
- int insertBorderWidth; /* Width of 3-D border around insert cursor.
- * Read-only to items. */
- Tk_Item *focusItemPtr; /* Item that currently has the input focus,
- * or NULL if no such item. Read-only to
- * items. */
- int gotFocus; /* Non-zero means that the canvas widget has
- * the input focus. Read-only to items.*/
- int cursorOn; /* Non-zero means that an insertion cursor
- * should be displayed in focusItemPtr.
- * Read-only to items.*/
-} Tk_CanvasTextInfo;
-
-/*
- *--------------------------------------------------------------
- *
- * Procedure prototypes and structures used for managing images:
- *
- *--------------------------------------------------------------
- */
-
-typedef struct Tk_ImageType Tk_ImageType;
-typedef int (Tk_ImageCreateProc) _ANSI_ARGS_((Tcl_Interp *interp,
- char *name, int argc, char **argv, Tk_ImageType *typePtr,
- Tk_ImageMaster master, ClientData *masterDataPtr));
-typedef ClientData (Tk_ImageGetProc) _ANSI_ARGS_((Tk_Window tkwin,
- ClientData masterData));
-typedef void (Tk_ImageDisplayProc) _ANSI_ARGS_((ClientData instanceData,
- Display *display, Drawable drawable, int imageX, int imageY,
- int width, int height, int drawableX, int drawableY));
-typedef void (Tk_ImageFreeProc) _ANSI_ARGS_((ClientData instanceData,
- Display *display));
-typedef void (Tk_ImageDeleteProc) _ANSI_ARGS_((ClientData masterData));
-typedef void (Tk_ImageChangedProc) _ANSI_ARGS_((ClientData clientData,
- int x, int y, int width, int height, int imageWidth,
- int imageHeight));
-
-/*
- * The following structure represents a particular type of image
- * (bitmap, xpm image, etc.). It provides information common to
- * all images of that type, such as the type name and a collection
- * of procedures in the image manager that respond to various
- * events. Each image manager is represented by one of these
- * structures.
- */
-
-struct Tk_ImageType {
- char *name; /* Name of image type. */
- Tk_ImageCreateProc *createProc;
- /* Procedure to call to create a new image
- * of this type. */
- Tk_ImageGetProc *getProc; /* Procedure to call the first time
- * Tk_GetImage is called in a new way
- * (new visual or screen). */
- Tk_ImageDisplayProc *displayProc;
- /* Call to draw image, in response to
- * Tk_RedrawImage calls. */
- Tk_ImageFreeProc *freeProc; /* Procedure to call whenever Tk_FreeImage
- * is called to release an instance of an
- * image. */
- Tk_ImageDeleteProc *deleteProc;
- /* Procedure to call to delete image. It
- * will not be called until after freeProc
- * has been called for each instance of the
- * image. */
- struct Tk_ImageType *nextPtr;
- /* Next in list of all image types currently
- * known. Filled in by Tk, not by image
- * manager. */
- char *reserved; /* reserved for future expansion */
-};
-
-/*
- *--------------------------------------------------------------
- *
- * Additional definitions used to manage images of type "photo".
- *
- *--------------------------------------------------------------
- */
-
-/*
- * The following type is used to identify a particular photo image
- * to be manipulated:
- */
-
-typedef void *Tk_PhotoHandle;
-
-/*
- * The following structure describes a block of pixels in memory:
- */
-
-typedef struct Tk_PhotoImageBlock {
- unsigned char *pixelPtr; /* Pointer to the first pixel. */
- int width; /* Width of block, in pixels. */
- int height; /* Height of block, in pixels. */
- int pitch; /* Address difference between corresponding
- * pixels in successive lines. */
- int pixelSize; /* Address difference between successive
- * pixels in the same line. */
- int offset[3]; /* Address differences between the red, green
- * and blue components of the pixel and the
- * pixel as a whole. */
- int reserved; /* Reserved for extensions (dash patch) */
-} Tk_PhotoImageBlock;
-
-/*
- * Procedure prototypes and structures used in reading and
- * writing photo images:
- */
-
-typedef struct Tk_PhotoImageFormat Tk_PhotoImageFormat;
-typedef int (Tk_ImageFileMatchProc) _ANSI_ARGS_((Tcl_Channel chan,
- char *fileName, char *formatString, int *widthPtr, int *heightPtr));
-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,
- 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));
-typedef int (Tk_ImageStringWriteProc) _ANSI_ARGS_((Tcl_Interp *interp,
- Tcl_DString *dataPtr, char *formatString,
- Tk_PhotoImageBlock *blockPtr));
-
-/*
- * The following structure represents a particular file format for
- * storing images (e.g., PPM, GIF, JPEG, etc.). It provides information
- * to allow image files of that format to be recognized and read into
- * a photo image.
- */
-
-struct Tk_PhotoImageFormat {
- char *name; /* Name of image file format */
- Tk_ImageFileMatchProc *fileMatchProc;
- /* Procedure to call to determine whether
- * an image file matches this format. */
- Tk_ImageStringMatchProc *stringMatchProc;
- /* Procedure to call to determine whether
- * the data in a string matches this format. */
- Tk_ImageFileReadProc *fileReadProc;
- /* Procedure to call to read data from
- * an image file into a photo image. */
- Tk_ImageStringReadProc *stringReadProc;
- /* Procedure to call to read data from
- * a string into a photo image. */
- Tk_ImageFileWriteProc *fileWriteProc;
- /* Procedure to call to write data from
- * a photo image to a file. */
- Tk_ImageStringWriteProc *stringWriteProc;
- /* Procedure to call to obtain a string
- * representation of the data in a photo
- * image.*/
- struct Tk_PhotoImageFormat *nextPtr;
- /* Next in list of all photo image formats
- * currently known. Filled in by Tk, not
- * by image format handler. */
-};
-
-/*
- *--------------------------------------------------------------
- *
- * The definitions below provide backward compatibility for
- * functions and types related to event handling that used to
- * be in Tk but have moved to Tcl.
- *
- *--------------------------------------------------------------
- */
-
-#define TK_READABLE TCL_READABLE
-#define TK_WRITABLE TCL_WRITABLE
-#define TK_EXCEPTION TCL_EXCEPTION
-
-#define TK_DONT_WAIT TCL_DONT_WAIT
-#define TK_X_EVENTS TCL_WINDOW_EVENTS
-#define TK_WINDOW_EVENTS TCL_WINDOW_EVENTS
-#define TK_FILE_EVENTS TCL_FILE_EVENTS
-#define TK_TIMER_EVENTS TCL_TIMER_EVENTS
-#define TK_IDLE_EVENTS TCL_IDLE_EVENTS
-#define TK_ALL_EVENTS TCL_ALL_EVENTS
-
-#define Tk_IdleProc Tcl_IdleProc
-#define Tk_FileProc Tcl_FileProc
-#define Tk_TimerProc Tcl_TimerProc
-#define Tk_TimerToken Tcl_TimerToken
-
-#define Tk_BackgroundError Tcl_BackgroundError
-#define Tk_CancelIdleCall Tcl_CancelIdleCall
-#define Tk_CreateFileHandler Tcl_CreateFileHandler
-#define Tk_CreateTimerHandler Tcl_CreateTimerHandler
-#define Tk_DeleteFileHandler Tcl_DeleteFileHandler
-#define Tk_DeleteTimerHandler Tcl_DeleteTimerHandler
-#define Tk_DoOneEvent Tcl_DoOneEvent
-#define Tk_DoWhenIdle Tcl_DoWhenIdle
-#define Tk_Sleep Tcl_Sleep
-
-/* 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
-#define Tk_Release Tcl_Release
-
-/*
- *--------------------------------------------------------------
- *
- * Additional procedure types defined by Tk.
- *
- *--------------------------------------------------------------
- */
-
-typedef int (Tk_ErrorProc) _ANSI_ARGS_((ClientData clientData,
- XErrorEvent *errEventPtr));
-typedef void (Tk_EventProc) _ANSI_ARGS_((ClientData clientData,
- XEvent *eventPtr));
-typedef int (Tk_GenericProc) _ANSI_ARGS_((ClientData clientData,
- XEvent *eventPtr));
-typedef int (Tk_GetSelProc) _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, char *portion));
-typedef void (Tk_LostSelProc) _ANSI_ARGS_((ClientData clientData));
-typedef Tk_RestrictAction (Tk_RestrictProc) _ANSI_ARGS_((
- ClientData clientData, XEvent *eventPtr));
-typedef int (Tk_SelectionProc) _ANSI_ARGS_((ClientData clientData,
- int offset, char *buffer, int maxBytes));
-
-/*
- *--------------------------------------------------------------
- *
- * Exported procedures and variables.
- *
- *--------------------------------------------------------------
- */
-
-EXTERN XColor * Tk_3DBorderColor _ANSI_ARGS_((Tk_3DBorder border));
-EXTERN GC Tk_3DBorderGC _ANSI_ARGS_((Tk_Window tkwin,
- Tk_3DBorder border, int which));
-EXTERN 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));
-EXTERN 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));
-EXTERN void Tk_AddOption _ANSI_ARGS_((Tk_Window tkwin, char *name,
- char *value, int priority));
-EXTERN void Tk_BindEvent _ANSI_ARGS_((Tk_BindingTable bindingTable,
- XEvent *eventPtr, Tk_Window tkwin, int numObjects,
- ClientData *objectPtr));
-EXTERN void Tk_CanvasDrawableCoords _ANSI_ARGS_((Tk_Canvas canvas,
- double x, double y, short *drawableXPtr,
- short *drawableYPtr));
-EXTERN void Tk_CanvasEventuallyRedraw _ANSI_ARGS_((
- Tk_Canvas canvas, int x1, int y1, int x2,
- int y2));
-EXTERN int Tk_CanvasGetCoord _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Canvas canvas, char *string,
- double *doublePtr));
-EXTERN Tk_CanvasTextInfo *Tk_CanvasGetTextInfo _ANSI_ARGS_((Tk_Canvas canvas));
-EXTERN int Tk_CanvasPsBitmap _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Canvas canvas, Pixmap bitmap, int x, int y,
- int width, int height));
-EXTERN int Tk_CanvasPsColor _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Canvas canvas, XColor *colorPtr));
-EXTERN int Tk_CanvasPsFont _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Canvas canvas, Tk_Font font));
-EXTERN void Tk_CanvasPsPath _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Canvas canvas, double *coordPtr, int numPoints));
-EXTERN int Tk_CanvasPsStipple _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Canvas canvas, Pixmap bitmap));
-EXTERN double Tk_CanvasPsY _ANSI_ARGS_((Tk_Canvas canvas, double y));
-EXTERN void Tk_CanvasSetStippleOrigin _ANSI_ARGS_((
- Tk_Canvas canvas, GC gc));
-EXTERN int Tk_CanvasTagsParseProc _ANSI_ARGS_((
- ClientData clientData, Tcl_Interp *interp,
- Tk_Window tkwin, char *value, char *widgRec,
- int offset));
-EXTERN char * Tk_CanvasTagsPrintProc _ANSI_ARGS_((
- ClientData clientData, Tk_Window tkwin,
- char *widgRec, int offset,
- Tcl_FreeProc **freeProcPtr));
-EXTERN Tk_Window Tk_CanvasTkwin _ANSI_ARGS_((Tk_Canvas canvas));
-EXTERN void Tk_CanvasWindowCoords _ANSI_ARGS_((Tk_Canvas canvas,
- double x, double y, short *screenXPtr,
- short *screenYPtr));
-EXTERN void Tk_ChangeWindowAttributes _ANSI_ARGS_((Tk_Window tkwin,
- unsigned long valueMask,
- XSetWindowAttributes *attsPtr));
-EXTERN int Tk_CharBbox _ANSI_ARGS_((Tk_TextLayout layout,
- int index, int *xPtr, int *yPtr, int *widthPtr,
- int *heightPtr));
-EXTERN void Tk_ClearSelection _ANSI_ARGS_((Tk_Window tkwin,
- Atom selection));
-EXTERN int Tk_ClipboardAppend _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Window tkwin, Atom target, Atom format,
- char* buffer));
-EXTERN int Tk_ClipboardClear _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Window tkwin));
-EXTERN int Tk_ConfigureInfo _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Window tkwin, Tk_ConfigSpec *specs,
- char *widgRec, char *argvName, int flags));
-EXTERN int Tk_ConfigureValue _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Window tkwin, Tk_ConfigSpec *specs,
- char *widgRec, char *argvName, int flags));
-EXTERN int Tk_ConfigureWidget _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Window tkwin, Tk_ConfigSpec *specs,
- int argc, char **argv, char *widgRec,
- int flags));
-EXTERN void Tk_ConfigureWindow _ANSI_ARGS_((Tk_Window tkwin,
- unsigned int valueMask, XWindowChanges *valuePtr));
-EXTERN Tk_TextLayout Tk_ComputeTextLayout _ANSI_ARGS_((Tk_Font font,
- CONST char *string, int numChars, int wrapLength,
- Tk_Justify justify, int flags, int *widthPtr,
- int *heightPtr));
-EXTERN Tk_Window Tk_CoordsToWindow _ANSI_ARGS_((int rootX, int rootY,
- Tk_Window tkwin));
-EXTERN unsigned long Tk_CreateBinding _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_BindingTable bindingTable, ClientData object,
- char *eventString, char *command, int append));
-EXTERN Tk_BindingTable Tk_CreateBindingTable _ANSI_ARGS_((Tcl_Interp *interp));
-EXTERN Tk_ErrorHandler Tk_CreateErrorHandler _ANSI_ARGS_((Display *display,
- int errNum, int request, int minorCode,
- Tk_ErrorProc *errorProc, ClientData clientData));
-EXTERN void Tk_CreateEventHandler _ANSI_ARGS_((Tk_Window token,
- unsigned long mask, Tk_EventProc *proc,
- ClientData clientData));
-EXTERN void Tk_CreateGenericHandler _ANSI_ARGS_((
- Tk_GenericProc *proc, ClientData clientData));
-EXTERN void Tk_CreateImageType _ANSI_ARGS_((
- Tk_ImageType *typePtr));
-EXTERN void Tk_CreateItemType _ANSI_ARGS_((Tk_ItemType *typePtr));
-EXTERN void Tk_CreatePhotoImageFormat _ANSI_ARGS_((
- Tk_PhotoImageFormat *formatPtr));
-EXTERN void Tk_CreateSelHandler _ANSI_ARGS_((Tk_Window tkwin,
- Atom selection, Atom target,
- Tk_SelectionProc *proc, ClientData clientData,
- Atom format));
-EXTERN Tk_Window Tk_CreateWindow _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Window parent, char *name, char *screenName));
-EXTERN Tk_Window Tk_CreateWindowFromPath _ANSI_ARGS_((
- Tcl_Interp *interp, Tk_Window tkwin,
- char *pathName, char *screenName));
-EXTERN int Tk_DefineBitmap _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Uid name, char *source, int width,
- int height));
-EXTERN void Tk_DefineCursor _ANSI_ARGS_((Tk_Window window,
- Tk_Cursor cursor));
-EXTERN void Tk_DeleteAllBindings _ANSI_ARGS_((
- Tk_BindingTable bindingTable, ClientData object));
-EXTERN int Tk_DeleteBinding _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_BindingTable bindingTable, ClientData object,
- char *eventString));
-EXTERN void Tk_DeleteBindingTable _ANSI_ARGS_((
- Tk_BindingTable bindingTable));
-EXTERN void Tk_DeleteErrorHandler _ANSI_ARGS_((
- Tk_ErrorHandler handler));
-EXTERN void Tk_DeleteEventHandler _ANSI_ARGS_((Tk_Window token,
- unsigned long mask, Tk_EventProc *proc,
- ClientData clientData));
-EXTERN void Tk_DeleteGenericHandler _ANSI_ARGS_((
- Tk_GenericProc *proc, ClientData clientData));
-EXTERN void Tk_DeleteImage _ANSI_ARGS_((Tcl_Interp *interp,
- char *name));
-EXTERN void Tk_DeleteSelHandler _ANSI_ARGS_((Tk_Window tkwin,
- Atom selection, Atom target));
-EXTERN void Tk_DestroyWindow _ANSI_ARGS_((Tk_Window tkwin));
-EXTERN char * Tk_DisplayName _ANSI_ARGS_((Tk_Window tkwin));
-EXTERN int Tk_DistanceToTextLayout _ANSI_ARGS_((
- Tk_TextLayout layout, int x, int y));
-EXTERN void Tk_Draw3DPolygon _ANSI_ARGS_((Tk_Window tkwin,
- Drawable drawable, Tk_3DBorder border,
- XPoint *pointPtr, int numPoints, int borderWidth,
- int leftRelief));
-EXTERN 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));
-EXTERN void Tk_DrawChars _ANSI_ARGS_((Display *display,
- Drawable drawable, GC gc, Tk_Font tkfont,
- CONST char *source, int numChars, int x,
- int y));
-EXTERN void Tk_DrawFocusHighlight _ANSI_ARGS_((Tk_Window tkwin,
- GC gc, int width, Drawable drawable));
-EXTERN void Tk_DrawTextLayout _ANSI_ARGS_((Display *display,
- Drawable drawable, GC gc, Tk_TextLayout layout,
- int x, int y, int firstChar, int lastChar));
-EXTERN void Tk_Fill3DPolygon _ANSI_ARGS_((Tk_Window tkwin,
- Drawable drawable, Tk_3DBorder border,
- XPoint *pointPtr, int numPoints, int borderWidth,
- int leftRelief));
-EXTERN 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));
-EXTERN Tk_PhotoHandle Tk_FindPhoto _ANSI_ARGS_((Tcl_Interp *interp,
- char *imageName));
-EXTERN Font Tk_FontId _ANSI_ARGS_((Tk_Font font));
-EXTERN void Tk_Free3DBorder _ANSI_ARGS_((Tk_3DBorder border));
-EXTERN void Tk_FreeBitmap _ANSI_ARGS_((Display *display,
- Pixmap bitmap));
-EXTERN void Tk_FreeColor _ANSI_ARGS_((XColor *colorPtr));
-EXTERN void Tk_FreeColormap _ANSI_ARGS_((Display *display,
- Colormap colormap));
-EXTERN void Tk_FreeCursor _ANSI_ARGS_((Display *display,
- Tk_Cursor cursor));
-EXTERN void Tk_FreeFont _ANSI_ARGS_((Tk_Font));
-EXTERN void Tk_FreeGC _ANSI_ARGS_((Display *display, GC gc));
-EXTERN void Tk_FreeImage _ANSI_ARGS_((Tk_Image image));
-EXTERN void Tk_FreeOptions _ANSI_ARGS_((Tk_ConfigSpec *specs,
- char *widgRec, Display *display, int needFlags));
-EXTERN void Tk_FreePixmap _ANSI_ARGS_((Display *display,
- Pixmap pixmap));
-EXTERN void Tk_FreeTextLayout _ANSI_ARGS_((
- Tk_TextLayout textLayout));
-EXTERN void Tk_FreeXId _ANSI_ARGS_((Display *display, XID xid));
-EXTERN GC Tk_GCForColor _ANSI_ARGS_((XColor *colorPtr,
- Drawable drawable));
-EXTERN void Tk_GeometryRequest _ANSI_ARGS_((Tk_Window tkwin,
- int reqWidth, int reqHeight));
-EXTERN Tk_3DBorder Tk_Get3DBorder _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Window tkwin, Tk_Uid colorName));
-EXTERN void Tk_GetAllBindings _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_BindingTable bindingTable, ClientData object));
-EXTERN int Tk_GetAnchor _ANSI_ARGS_((Tcl_Interp *interp,
- char *string, Tk_Anchor *anchorPtr));
-EXTERN char * Tk_GetAtomName _ANSI_ARGS_((Tk_Window tkwin,
- Atom atom));
-EXTERN char * Tk_GetBinding _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_BindingTable bindingTable, ClientData object,
- char *eventString));
-EXTERN Pixmap Tk_GetBitmap _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Window tkwin, Tk_Uid string));
-EXTERN Pixmap Tk_GetBitmapFromData _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Window tkwin, char *source,
- int width, int height));
-EXTERN int Tk_GetCapStyle _ANSI_ARGS_((Tcl_Interp *interp,
- char *string, int *capPtr));
-EXTERN XColor * Tk_GetColor _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Window tkwin, Tk_Uid name));
-EXTERN XColor * Tk_GetColorByValue _ANSI_ARGS_((Tk_Window tkwin,
- XColor *colorPtr));
-EXTERN Colormap Tk_GetColormap _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Window tkwin, char *string));
-EXTERN Tk_Cursor Tk_GetCursor _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Window tkwin, Tk_Uid string));
-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));
-EXTERN Tk_Font Tk_GetFont _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Window tkwin, CONST char *string));
-EXTERN Tk_Font Tk_GetFontFromObj _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Window tkwin, Tcl_Obj *objPtr));
-EXTERN void Tk_GetFontMetrics _ANSI_ARGS_((Tk_Font font,
- Tk_FontMetrics *fmPtr));
-EXTERN GC Tk_GetGC _ANSI_ARGS_((Tk_Window tkwin,
- unsigned long valueMask, XGCValues *valuePtr));
-EXTERN Tk_Image Tk_GetImage _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Window tkwin, char *name,
- Tk_ImageChangedProc *changeProc,
- ClientData clientData));
-EXTERN ClientData Tk_GetImageMasterData _ANSI_ARGS_ ((Tcl_Interp *interp,
- char *name, Tk_ImageType **typePtrPtr));
-EXTERN Tk_ItemType * Tk_GetItemTypes _ANSI_ARGS_((void));
-EXTERN int Tk_GetJoinStyle _ANSI_ARGS_((Tcl_Interp *interp,
- char *string, int *joinPtr));
-EXTERN int Tk_GetJustify _ANSI_ARGS_((Tcl_Interp *interp,
- char *string, Tk_Justify *justifyPtr));
-EXTERN int Tk_GetNumMainWindows _ANSI_ARGS_((void));
-EXTERN Tk_Uid Tk_GetOption _ANSI_ARGS_((Tk_Window tkwin, char *name,
- char *className));
-EXTERN int Tk_GetPixels _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Window tkwin, char *string, int *intPtr));
-EXTERN Pixmap Tk_GetPixmap _ANSI_ARGS_((Display *display, Drawable d,
- int width, int height, int depth));
-EXTERN int Tk_GetRelief _ANSI_ARGS_((Tcl_Interp *interp,
- char *name, int *reliefPtr));
-EXTERN void Tk_GetRootCoords _ANSI_ARGS_ ((Tk_Window tkwin,
- int *xPtr, int *yPtr));
-EXTERN int Tk_GetScrollInfo _ANSI_ARGS_((Tcl_Interp *interp,
- int argc, char **argv, double *dblPtr,
- int *intPtr));
-EXTERN int Tk_GetScreenMM _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Window tkwin, char *string, double *doublePtr));
-EXTERN int Tk_GetSelection _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Window tkwin, Atom selection, Atom target,
- Tk_GetSelProc *proc, ClientData clientData));
-EXTERN Tk_Uid Tk_GetUid _ANSI_ARGS_((CONST char *string));
-EXTERN Visual * Tk_GetVisual _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Window tkwin, char *string, int *depthPtr,
- Colormap *colormapPtr));
-EXTERN void Tk_GetVRootGeometry _ANSI_ARGS_((Tk_Window tkwin,
- int *xPtr, int *yPtr, int *widthPtr,
- int *heightPtr));
-EXTERN int Tk_Grab _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Window tkwin, int grabGlobal));
-EXTERN void Tk_HandleEvent _ANSI_ARGS_((XEvent *eventPtr));
-EXTERN Tk_Window Tk_IdToWindow _ANSI_ARGS_((Display *display,
- Window window));
-EXTERN void Tk_ImageChanged _ANSI_ARGS_((
- Tk_ImageMaster master, int x, int y,
- int width, int height, int imageWidth,
- int imageHeight));
-EXTERN int Tk_Init _ANSI_ARGS_((Tcl_Interp *interp));
-EXTERN Atom Tk_InternAtom _ANSI_ARGS_((Tk_Window tkwin,
- char *name));
-EXTERN int Tk_IntersectTextLayout _ANSI_ARGS_((
- Tk_TextLayout layout, int x, int y, int width,
- int height));
-EXTERN void Tk_Main _ANSI_ARGS_((int argc, char **argv,
- Tcl_AppInitProc *appInitProc));
-EXTERN void Tk_MainLoop _ANSI_ARGS_((void));
-EXTERN void Tk_MaintainGeometry _ANSI_ARGS_((Tk_Window slave,
- Tk_Window master, int x, int y, int width,
- int height));
-EXTERN Tk_Window Tk_MainWindow _ANSI_ARGS_((Tcl_Interp *interp));
-EXTERN void Tk_MakeWindowExist _ANSI_ARGS_((Tk_Window tkwin));
-EXTERN void Tk_ManageGeometry _ANSI_ARGS_((Tk_Window tkwin,
- Tk_GeomMgr *mgrPtr, ClientData clientData));
-EXTERN void Tk_MapWindow _ANSI_ARGS_((Tk_Window tkwin));
-EXTERN int Tk_MeasureChars _ANSI_ARGS_((Tk_Font tkfont,
- CONST char *source, int maxChars, int maxPixels,
- int flags, int *lengthPtr));
-EXTERN void Tk_MoveResizeWindow _ANSI_ARGS_((Tk_Window tkwin,
- int x, int y, int width, int height));
-EXTERN void Tk_MoveWindow _ANSI_ARGS_((Tk_Window tkwin, int x,
- int y));
-EXTERN void Tk_MoveToplevelWindow _ANSI_ARGS_((Tk_Window tkwin,
- int x, int y));
-EXTERN char * Tk_NameOf3DBorder _ANSI_ARGS_((Tk_3DBorder border));
-EXTERN char * Tk_NameOfAnchor _ANSI_ARGS_((Tk_Anchor anchor));
-EXTERN char * Tk_NameOfBitmap _ANSI_ARGS_((Display *display,
- Pixmap bitmap));
-EXTERN char * Tk_NameOfCapStyle _ANSI_ARGS_((int cap));
-EXTERN char * Tk_NameOfColor _ANSI_ARGS_((XColor *colorPtr));
-EXTERN char * Tk_NameOfCursor _ANSI_ARGS_((Display *display,
- Tk_Cursor cursor));
-EXTERN char * Tk_NameOfFont _ANSI_ARGS_((Tk_Font font));
-EXTERN char * Tk_NameOfImage _ANSI_ARGS_((
- Tk_ImageMaster imageMaster));
-EXTERN char * Tk_NameOfJoinStyle _ANSI_ARGS_((int join));
-EXTERN char * Tk_NameOfJustify _ANSI_ARGS_((Tk_Justify justify));
-EXTERN char * Tk_NameOfRelief _ANSI_ARGS_((int relief));
-EXTERN Tk_Window Tk_NameToWindow _ANSI_ARGS_((Tcl_Interp *interp,
- char *pathName, Tk_Window tkwin));
-EXTERN void Tk_OwnSelection _ANSI_ARGS_((Tk_Window tkwin,
- Atom selection, Tk_LostSelProc *proc,
- ClientData clientData));
-EXTERN int Tk_ParseArgv _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Window tkwin, int *argcPtr, char **argv,
- Tk_ArgvInfo *argTable, int flags));
-EXTERN void Tk_PhotoPutBlock _ANSI_ARGS_((Tk_PhotoHandle handle,
- Tk_PhotoImageBlock *blockPtr, int x, int y,
- int width, int height));
-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));
-EXTERN int Tk_PhotoGetImage _ANSI_ARGS_((Tk_PhotoHandle handle,
- Tk_PhotoImageBlock *blockPtr));
-EXTERN void Tk_PhotoBlank _ANSI_ARGS_((Tk_PhotoHandle handle));
-EXTERN void Tk_PhotoExpand _ANSI_ARGS_((Tk_PhotoHandle handle,
- int width, int height ));
-EXTERN void Tk_PhotoGetSize _ANSI_ARGS_((Tk_PhotoHandle handle,
- int *widthPtr, int *heightPtr));
-EXTERN void Tk_PhotoSetSize _ANSI_ARGS_((Tk_PhotoHandle handle,
- int width, int height));
-EXTERN int Tk_PointToChar _ANSI_ARGS_((Tk_TextLayout layout,
- int x, int y));
-EXTERN int Tk_PostscriptFontName _ANSI_ARGS_((Tk_Font tkfont,
- Tcl_DString *dsPtr));
-EXTERN void Tk_PreserveColormap _ANSI_ARGS_((Display *display,
- Colormap colormap));
-EXTERN void Tk_QueueWindowEvent _ANSI_ARGS_((XEvent *eventPtr,
- Tcl_QueuePosition position));
-EXTERN void Tk_RedrawImage _ANSI_ARGS_((Tk_Image image, int imageX,
- int imageY, int width, int height,
- Drawable drawable, int drawableX, int drawableY));
-EXTERN void Tk_ResizeWindow _ANSI_ARGS_((Tk_Window tkwin,
- int width, int height));
-EXTERN int Tk_RestackWindow _ANSI_ARGS_((Tk_Window tkwin,
- int aboveBelow, Tk_Window other));
-EXTERN Tk_RestrictProc *Tk_RestrictEvents _ANSI_ARGS_((Tk_RestrictProc *proc,
- ClientData arg, ClientData *prevArgPtr));
-EXTERN int Tk_SafeInit _ANSI_ARGS_((Tcl_Interp *interp));
-EXTERN char * Tk_SetAppName _ANSI_ARGS_((Tk_Window tkwin,
- char *name));
-EXTERN void Tk_SetBackgroundFromBorder _ANSI_ARGS_((
- Tk_Window tkwin, Tk_3DBorder border));
-EXTERN void Tk_SetClass _ANSI_ARGS_((Tk_Window tkwin,
- char *className));
-EXTERN void Tk_SetGrid _ANSI_ARGS_((Tk_Window tkwin,
- int reqWidth, int reqHeight, int gridWidth,
- int gridHeight));
-EXTERN void Tk_SetInternalBorder _ANSI_ARGS_((Tk_Window tkwin,
- int width));
-EXTERN void Tk_SetWindowBackground _ANSI_ARGS_((Tk_Window tkwin,
- unsigned long pixel));
-EXTERN void Tk_SetWindowBackgroundPixmap _ANSI_ARGS_((
- Tk_Window tkwin, Pixmap pixmap));
-EXTERN void Tk_SetWindowBorder _ANSI_ARGS_((Tk_Window tkwin,
- unsigned long pixel));
-EXTERN void Tk_SetWindowBorderWidth _ANSI_ARGS_((Tk_Window tkwin,
- int width));
-EXTERN void Tk_SetWindowBorderPixmap _ANSI_ARGS_((Tk_Window tkwin,
- Pixmap pixmap));
-EXTERN void Tk_SetWindowColormap _ANSI_ARGS_((Tk_Window tkwin,
- Colormap colormap));
-EXTERN int Tk_SetWindowVisual _ANSI_ARGS_((Tk_Window tkwin,
- Visual *visual, int depth,
- Colormap colormap));
-EXTERN void Tk_SizeOfBitmap _ANSI_ARGS_((Display *display,
- Pixmap bitmap, int *widthPtr,
- int *heightPtr));
-EXTERN void Tk_SizeOfImage _ANSI_ARGS_((Tk_Image image,
- int *widthPtr, int *heightPtr));
-EXTERN int Tk_StrictMotif _ANSI_ARGS_((Tk_Window tkwin));
-EXTERN void Tk_TextLayoutToPostscript _ANSI_ARGS_((
- Tcl_Interp *interp, Tk_TextLayout layout));
-EXTERN int Tk_TextWidth _ANSI_ARGS_((Tk_Font font,
- CONST char *string, int numChars));
-EXTERN void Tk_UndefineCursor _ANSI_ARGS_((Tk_Window window));
-EXTERN void Tk_UnderlineChars _ANSI_ARGS_((Display *display,
- Drawable drawable, GC gc, Tk_Font tkfont,
- CONST char *source, int x, int y, int firstChar,
- int lastChar));
-EXTERN void Tk_UnderlineTextLayout _ANSI_ARGS_((
- Display *display, Drawable drawable, GC gc,
- Tk_TextLayout layout, int x, int y,
- int underline));
-EXTERN void Tk_Ungrab _ANSI_ARGS_((Tk_Window tkwin));
-EXTERN void Tk_UnmaintainGeometry _ANSI_ARGS_((Tk_Window slave,
- Tk_Window master));
-EXTERN void Tk_UnmapWindow _ANSI_ARGS_((Tk_Window tkwin));
-EXTERN void Tk_UnsetGrid _ANSI_ARGS_((Tk_Window tkwin));
-EXTERN void Tk_UpdatePointer _ANSI_ARGS_((Tk_Window tkwin,
- int x, int y, int state));
-
-/*
- * Tcl commands exported by Tk:
- */
-
-EXTERN int Tk_AfterCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-EXTERN int Tk_BellCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-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_ButtonCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-EXTERN int Tk_CanvasCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-EXTERN int Tk_CheckbuttonCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-EXTERN int Tk_ClipboardCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-EXTERN int Tk_ChooseColorCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-EXTERN int Tk_ChooseFontCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-EXTERN int Tk_DestroyCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-EXTERN int Tk_EntryCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-EXTERN int Tk_EventCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-EXTERN int Tk_FileeventCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-EXTERN int Tk_FrameCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-EXTERN int Tk_FocusCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-EXTERN int Tk_FontObjCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *CONST objv[]));
-EXTERN int Tk_GetOpenFileCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-EXTERN int Tk_GetSaveFileCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-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_ImageCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-EXTERN int Tk_LabelCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-EXTERN int Tk_ListboxCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-EXTERN int Tk_LowerCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-EXTERN int Tk_MenuCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-EXTERN int Tk_MenubuttonCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-EXTERN int Tk_MessageBoxCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-EXTERN int Tk_MessageCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-EXTERN int Tk_OptionCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-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_RadiobuttonCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-EXTERN int Tk_RaiseCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-EXTERN int Tk_ScaleCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-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));
-EXTERN int Tk_SendCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-EXTERN int Tk_TextCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, 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_ToplevelCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-EXTERN int Tk_UpdateCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-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));
-
-#endif /* RESOURCE_INCLUDED */
-
-#undef TCL_STORAGE_CLASS
-#define TCL_STORAGE_CLASS DLLIMPORT
-
-#endif /* _TK */
diff --git a/generic/tk3d.c b/generic/tk3d.c
deleted file mode 100644
index ae049c9..0000000
--- a/generic/tk3d.c
+++ /dev/null
@@ -1,949 +0,0 @@
-/*
- * tk3d.c --
- *
- * This module provides procedures to draw borders in
- * the three-dimensional Motif style.
- *
- * Copyright (c) 1990-1994 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: tk3d.c,v 1.2 1998/09/14 18:23:02 stanton Exp $
- */
-
-#include <tk3d.h>
-
-/*
- * Hash table to map from a border's values (color, etc.) to a
- * Border structure for those values.
- */
-
-static Tcl_HashTable borderTable;
-typedef struct {
- Tk_Uid colorName; /* Color for border. */
- Colormap colormap; /* Colormap used for allocating border
- * colors. */
- Screen *screen; /* Screen on which border will be drawn. */
-} BorderKey;
-
-static int initialized = 0; /* 0 means static structures haven't
- * been initialized yet. */
-
-/*
- * Forward declarations for procedures defined in this file:
- */
-
-static void BorderInit _ANSI_ARGS_((void));
-static int Intersect _ANSI_ARGS_((XPoint *a1Ptr, XPoint *a2Ptr,
- XPoint *b1Ptr, XPoint *b2Ptr, XPoint *iPtr));
-static void ShiftLine _ANSI_ARGS_((XPoint *p1Ptr, XPoint *p2Ptr,
- int distance, XPoint *p3Ptr));
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_Get3DBorder --
- *
- * Create a data structure for displaying a 3-D border.
- *
- * Results:
- * The return value is a token for a data structure
- * describing a 3-D border. This token may be passed
- * to Tk_Draw3DRectangle and Tk_Free3DBorder. If an
- * error prevented the border from being created then
- * NULL is returned and an error message will be left
- * in interp->result.
- *
- * Side effects:
- * Data structures, graphics contexts, etc. are allocated.
- * It is the caller's responsibility to eventually call
- * Tk_Free3DBorder to release the resources.
- *
- *--------------------------------------------------------------
- */
-
-Tk_3DBorder
-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. */
- Tk_Uid colorName; /* String giving name of color
- * for window background. */
-{
- BorderKey key;
- Tcl_HashEntry *hashPtr;
- register TkBorder *borderPtr;
- int new;
- XGCValues gcValues;
-
- if (!initialized) {
- BorderInit();
- }
-
- /*
- * First, check to see if there's already a border that will work
- * for this request.
- */
-
- key.colorName = colorName;
- key.colormap = Tk_Colormap(tkwin);
- key.screen = Tk_Screen(tkwin);
-
- hashPtr = Tcl_CreateHashEntry(&borderTable, (char *) &key, &new);
- if (!new) {
- borderPtr = (TkBorder *) Tcl_GetHashValue(hashPtr);
- borderPtr->refCount++;
- } else {
- XColor *bgColorPtr;
-
- /*
- * No satisfactory border exists yet. Initialize a new one.
- */
-
- bgColorPtr = Tk_GetColor(interp, tkwin, colorName);
- if (bgColorPtr == NULL) {
- Tcl_DeleteHashEntry(hashPtr);
- return NULL;
- }
-
- borderPtr = TkpGetBorder();
- borderPtr->screen = Tk_Screen(tkwin);
- borderPtr->visual = Tk_Visual(tkwin);
- borderPtr->depth = Tk_Depth(tkwin);
- borderPtr->colormap = key.colormap;
- borderPtr->refCount = 1;
- borderPtr->bgColorPtr = bgColorPtr;
- borderPtr->darkColorPtr = NULL;
- borderPtr->lightColorPtr = NULL;
- borderPtr->shadow = None;
- borderPtr->bgGC = None;
- borderPtr->darkGC = None;
- borderPtr->lightGC = None;
- borderPtr->hashPtr = hashPtr;
- Tcl_SetHashValue(hashPtr, borderPtr);
-
- /*
- * Create the information for displaying the background color,
- * but delay the allocation of shadows until they are actually
- * needed for drawing.
- */
-
- gcValues.foreground = borderPtr->bgColorPtr->pixel;
- borderPtr->bgGC = Tk_GetGC(tkwin, GCForeground, &gcValues);
- }
- return (Tk_3DBorder) borderPtr;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_Draw3DRectangle --
- *
- * Draw a 3-D border at a given place in a given window.
- *
- * Results:
- * None.
- *
- * Side effects:
- * A 3-D border will be drawn in the indicated drawable.
- * The outside edges of the border will be determined by x,
- * y, width, and height. The inside edges of the border
- * will be determined by the borderWidth argument.
- *
- *--------------------------------------------------------------
- */
-
-void
-Tk_Draw3DRectangle(tkwin, drawable, border, x, y, width, height,
- borderWidth, relief)
- Tk_Window tkwin; /* Window for which border was allocated. */
- Drawable drawable; /* X window or pixmap in which to draw. */
- Tk_3DBorder border; /* Token for border to draw. */
- int x, y, width, height; /* Outside area of region in
- * which border will be drawn. */
- int borderWidth; /* Desired width for border, in
- * pixels. */
- int relief; /* Type of relief: TK_RELIEF_RAISED,
- * TK_RELIEF_SUNKEN, TK_RELIEF_GROOVE, etc. */
-{
- if (width < 2*borderWidth) {
- borderWidth = width/2;
- }
- if (height < 2*borderWidth) {
- borderWidth = height/2;
- }
- Tk_3DVerticalBevel(tkwin, drawable, border, x, y, borderWidth, height,
- 1, relief);
- Tk_3DVerticalBevel(tkwin, drawable, border, x+width-borderWidth, y,
- borderWidth, height, 0, relief);
- Tk_3DHorizontalBevel(tkwin, drawable, border, x, y, width, borderWidth,
- 1, 1, 1, relief);
- Tk_3DHorizontalBevel(tkwin, drawable, border, x, y+height-borderWidth,
- width, borderWidth, 0, 0, 0, relief);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_NameOf3DBorder --
- *
- * Given a border, return a textual string identifying the
- * border's color.
- *
- * Results:
- * The return value is the string that was used to create
- * the border.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-char *
-Tk_NameOf3DBorder(border)
- Tk_3DBorder border; /* Token for border. */
-{
- TkBorder *borderPtr = (TkBorder *) border;
-
- return ((BorderKey *) borderPtr->hashPtr->key.words)->colorName;
-}
-
-/*
- *--------------------------------------------------------------------
- *
- * Tk_3DBorderColor --
- *
- * Given a 3D border, return the X color used for the "flat"
- * surfaces.
- *
- * Results:
- * Returns the color used drawing flat surfaces with the border.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------------
- */
-XColor *
-Tk_3DBorderColor(border)
- Tk_3DBorder border; /* Border whose color is wanted. */
-{
- return(((TkBorder *) border)->bgColorPtr);
-}
-
-/*
- *--------------------------------------------------------------------
- *
- * Tk_3DBorderGC --
- *
- * Given a 3D border, returns one of the graphics contexts used to
- * draw the border.
- *
- * Results:
- * Returns the graphics context given by the "which" argument.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------------
- */
-GC
-Tk_3DBorderGC(tkwin, border, which)
- Tk_Window tkwin; /* Window for which border was allocated. */
- Tk_3DBorder border; /* Border whose GC is wanted. */
- int which; /* Selects one of the border's 3 GC's:
- * TK_3D_FLAT_GC, TK_3D_LIGHT_GC, or
- * TK_3D_DARK_GC. */
-{
- TkBorder * borderPtr = (TkBorder *) border;
-
- if ((borderPtr->lightGC == None) && (which != TK_3D_FLAT_GC)) {
- TkpGetShadows(borderPtr, tkwin);
- }
- if (which == TK_3D_FLAT_GC) {
- return borderPtr->bgGC;
- } else if (which == TK_3D_LIGHT_GC) {
- return borderPtr->lightGC;
- } else if (which == TK_3D_DARK_GC){
- return borderPtr->darkGC;
- }
- panic("bogus \"which\" value in Tk_3DBorderGC");
-
- /*
- * The code below will never be executed, but it's needed to
- * keep compilers happy.
- */
-
- return (GC) None;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_Free3DBorder --
- *
- * This procedure is called when a 3D border is no longer
- * needed. It frees the resources associated with the
- * border. After this call, the caller should never again
- * use the "border" token.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Resources are freed.
- *
- *--------------------------------------------------------------
- */
-
-void
-Tk_Free3DBorder(border)
- Tk_3DBorder border; /* Token for border to be released. */
-{
- register TkBorder *borderPtr = (TkBorder *) border;
- Display *display = DisplayOfScreen(borderPtr->screen);
-
- borderPtr->refCount--;
- if (borderPtr->refCount == 0) {
- TkpFreeBorder(borderPtr);
- if (borderPtr->bgColorPtr != NULL) {
- Tk_FreeColor(borderPtr->bgColorPtr);
- }
- if (borderPtr->darkColorPtr != NULL) {
- Tk_FreeColor(borderPtr->darkColorPtr);
- }
- if (borderPtr->lightColorPtr != NULL) {
- Tk_FreeColor(borderPtr->lightColorPtr);
- }
- if (borderPtr->shadow != None) {
- Tk_FreeBitmap(display, borderPtr->shadow);
- }
- if (borderPtr->bgGC != None) {
- Tk_FreeGC(display, borderPtr->bgGC);
- }
- if (borderPtr->darkGC != None) {
- Tk_FreeGC(display, borderPtr->darkGC);
- }
- if (borderPtr->lightGC != None) {
- Tk_FreeGC(display, borderPtr->lightGC);
- }
- Tcl_DeleteHashEntry(borderPtr->hashPtr);
- ckfree((char *) borderPtr);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_SetBackgroundFromBorder --
- *
- * Change the background of a window to one appropriate for a given
- * 3-D border.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Tkwin's background gets modified.
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tk_SetBackgroundFromBorder(tkwin, border)
- Tk_Window tkwin; /* Window whose background is to be set. */
- Tk_3DBorder border; /* Token for border. */
-{
- register TkBorder *borderPtr = (TkBorder *) border;
-
- Tk_SetWindowBackground(tkwin, borderPtr->bgColorPtr->pixel);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_GetRelief --
- *
- * Parse a relief description and return the corresponding
- * relief value, or an error.
- *
- * Results:
- * A standard Tcl return value. If all goes well then
- * *reliefPtr is filled in with one of the values
- * TK_RELIEF_RAISED, TK_RELIEF_FLAT, or TK_RELIEF_SUNKEN.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-int
-Tk_GetRelief(interp, name, reliefPtr)
- Tcl_Interp *interp; /* For error messages. */
- char *name; /* Name of a relief type. */
- int *reliefPtr; /* Where to store converted relief. */
-{
- char c;
- size_t length;
-
- c = name[0];
- length = strlen(name);
- if ((c == 'f') && (strncmp(name, "flat", length) == 0)) {
- *reliefPtr = TK_RELIEF_FLAT;
- } else if ((c == 'g') && (strncmp(name, "groove", length) == 0)
- && (length >= 2)) {
- *reliefPtr = TK_RELIEF_GROOVE;
- } else if ((c == 'r') && (strncmp(name, "raised", length) == 0)
- && (length >= 2)) {
- *reliefPtr = TK_RELIEF_RAISED;
- } else if ((c == 'r') && (strncmp(name, "ridge", length) == 0)) {
- *reliefPtr = TK_RELIEF_RIDGE;
- } else if ((c == 's') && (strncmp(name, "solid", length) == 0)) {
- *reliefPtr = TK_RELIEF_SOLID;
- } else if ((c == 's') && (strncmp(name, "sunken", length) == 0)) {
- *reliefPtr = TK_RELIEF_SUNKEN;
- } else {
- sprintf(interp->result, "bad relief type \"%.50s\": must be %s",
- name, "flat, groove, raised, ridge, solid, or sunken");
- return TCL_ERROR;
- }
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_NameOfRelief --
- *
- * Given a relief value, produce a string describing that
- * relief value.
- *
- * Results:
- * The return value is a static string that is equivalent
- * to relief.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-char *
-Tk_NameOfRelief(relief)
- int relief; /* One of TK_RELIEF_FLAT, TK_RELIEF_RAISED,
- * or TK_RELIEF_SUNKEN. */
-{
- if (relief == TK_RELIEF_FLAT) {
- return "flat";
- } else if (relief == TK_RELIEF_SUNKEN) {
- return "sunken";
- } else if (relief == TK_RELIEF_RAISED) {
- return "raised";
- } else if (relief == TK_RELIEF_GROOVE) {
- return "groove";
- } else if (relief == TK_RELIEF_RIDGE) {
- return "ridge";
- } else if (relief == TK_RELIEF_SOLID) {
- return "solid";
- } else {
- return "unknown relief";
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_Draw3DPolygon --
- *
- * Draw a border with 3-D appearance around the edge of a
- * given polygon.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Information is drawn in "drawable" in the form of a
- * 3-D border borderWidth units width wide on the left
- * of the trajectory given by pointPtr and numPoints (or
- * -borderWidth units wide on the right side, if borderWidth
- * is negative).
- *
- *--------------------------------------------------------------
- */
-
-void
-Tk_Draw3DPolygon(tkwin, drawable, border, pointPtr, numPoints,
- borderWidth, leftRelief)
- Tk_Window tkwin; /* Window for which border was allocated. */
- Drawable drawable; /* X window or pixmap in which to draw. */
- Tk_3DBorder border; /* Token for border to draw. */
- XPoint *pointPtr; /* Array of points describing
- * polygon. All points must be
- * absolute (CoordModeOrigin). */
- int numPoints; /* Number of points at *pointPtr. */
- int borderWidth; /* Width of border, measured in
- * pixels to the left of the polygon's
- * trajectory. May be negative. */
- int leftRelief; /* TK_RELIEF_RAISED or
- * TK_RELIEF_SUNKEN: indicates how
- * stuff to left of trajectory looks
- * relative to stuff on right. */
-{
- XPoint poly[4], b1, b2, newB1, newB2;
- XPoint perp, c, shift1, shift2; /* Used for handling parallel lines. */
- register XPoint *p1Ptr, *p2Ptr;
- TkBorder *borderPtr = (TkBorder *) border;
- GC gc;
- int i, lightOnLeft, dx, dy, parallel, pointsSeen;
- Display *display = Tk_Display(tkwin);
-
- if (borderPtr->lightGC == None) {
- TkpGetShadows(borderPtr, tkwin);
- }
-
- /*
- * Handle grooves and ridges with recursive calls.
- */
-
- if ((leftRelief == TK_RELIEF_GROOVE) || (leftRelief == TK_RELIEF_RIDGE)) {
- int halfWidth;
-
- halfWidth = borderWidth/2;
- Tk_Draw3DPolygon(tkwin, drawable, border, pointPtr, numPoints,
- halfWidth, (leftRelief == TK_RELIEF_GROOVE) ? TK_RELIEF_RAISED
- : TK_RELIEF_SUNKEN);
- Tk_Draw3DPolygon(tkwin, drawable, border, pointPtr, numPoints,
- -halfWidth, (leftRelief == TK_RELIEF_GROOVE) ? TK_RELIEF_SUNKEN
- : TK_RELIEF_RAISED);
- return;
- }
-
- /*
- * If the polygon is already closed, drop the last point from it
- * (we'll close it automatically).
- */
-
- p1Ptr = &pointPtr[numPoints-1];
- p2Ptr = &pointPtr[0];
- if ((p1Ptr->x == p2Ptr->x) && (p1Ptr->y == p2Ptr->y)) {
- numPoints--;
- }
-
- /*
- * The loop below is executed once for each vertex in the polgon.
- * At the beginning of each iteration things look like this:
- *
- * poly[1] /
- * * /
- * | /
- * b1 * poly[0] (pointPtr[i-1])
- * | |
- * | |
- * | |
- * | |
- * | |
- * | | *p1Ptr *p2Ptr
- * b2 *--------------------*
- * |
- * |
- * x-------------------------
- *
- * The job of this iteration is to do the following:
- * (a) Compute x (the border corner corresponding to
- * pointPtr[i]) and put it in poly[2]. As part of
- * this, compute a new b1 and b2 value for the next
- * side of the polygon.
- * (b) Put pointPtr[i] into poly[3].
- * (c) Draw the polygon given by poly[0..3].
- * (d) Advance poly[0], poly[1], b1, and b2 for the
- * next side of the polygon.
- */
-
- /*
- * The above situation doesn't first come into existence until
- * two points have been processed; the first two points are
- * used to "prime the pump", so some parts of the processing
- * are ommitted for these points. The variable "pointsSeen"
- * keeps track of the priming process; it has to be separate
- * from i in order to be able to ignore duplicate points in the
- * polygon.
- */
-
- pointsSeen = 0;
- for (i = -2, p1Ptr = &pointPtr[numPoints-2], p2Ptr = p1Ptr+1;
- i < numPoints; i++, p1Ptr = p2Ptr, p2Ptr++) {
- if ((i == -1) || (i == numPoints-1)) {
- p2Ptr = pointPtr;
- }
- if ((p2Ptr->x == p1Ptr->x) && (p2Ptr->y == p1Ptr->y)) {
- /*
- * Ignore duplicate points (they'd cause core dumps in
- * ShiftLine calls below).
- */
- continue;
- }
- ShiftLine(p1Ptr, p2Ptr, borderWidth, &newB1);
- newB2.x = newB1.x + (p2Ptr->x - p1Ptr->x);
- newB2.y = newB1.y + (p2Ptr->y - p1Ptr->y);
- poly[3] = *p1Ptr;
- parallel = 0;
- if (pointsSeen >= 1) {
- parallel = Intersect(&newB1, &newB2, &b1, &b2, &poly[2]);
-
- /*
- * If two consecutive segments of the polygon are parallel,
- * then things get more complex. Consider the following
- * diagram:
- *
- * poly[1]
- * *----b1-----------b2------a
- * \
- * \
- * *---------*----------* b
- * poly[0] *p2Ptr *p1Ptr /
- * /
- * --*--------*----c
- * newB1 newB2
- *
- * Instead of using x and *p1Ptr for poly[2] and poly[3], as
- * in the original diagram, use a and b as above. Then instead
- * of using x and *p1Ptr for the new poly[0] and poly[1], use
- * b and c as above.
- *
- * Do the computation in three stages:
- * 1. Compute a point "perp" such that the line p1Ptr-perp
- * is perpendicular to p1Ptr-p2Ptr.
- * 2. Compute the points a and c by intersecting the lines
- * b1-b2 and newB1-newB2 with p1Ptr-perp.
- * 3. Compute b by shifting p1Ptr-perp to the right and
- * intersecting it with p1Ptr-p2Ptr.
- */
-
- if (parallel) {
- perp.x = p1Ptr->x + (p2Ptr->y - p1Ptr->y);
- perp.y = p1Ptr->y - (p2Ptr->x - p1Ptr->x);
- (void) Intersect(p1Ptr, &perp, &b1, &b2, &poly[2]);
- (void) Intersect(p1Ptr, &perp, &newB1, &newB2, &c);
- ShiftLine(p1Ptr, &perp, borderWidth, &shift1);
- shift2.x = shift1.x + (perp.x - p1Ptr->x);
- shift2.y = shift1.y + (perp.y - p1Ptr->y);
- (void) Intersect(p1Ptr, p2Ptr, &shift1, &shift2, &poly[3]);
- }
- }
- if (pointsSeen >= 2) {
- dx = poly[3].x - poly[0].x;
- dy = poly[3].y - poly[0].y;
- if (dx > 0) {
- lightOnLeft = (dy <= dx);
- } else {
- lightOnLeft = (dy < dx);
- }
- if (lightOnLeft ^ (leftRelief == TK_RELIEF_RAISED)) {
- gc = borderPtr->lightGC;
- } else {
- gc = borderPtr->darkGC;
- }
- XFillPolygon(display, drawable, gc, poly, 4, Convex,
- CoordModeOrigin);
- }
- b1.x = newB1.x;
- b1.y = newB1.y;
- b2.x = newB2.x;
- b2.y = newB2.y;
- poly[0].x = poly[3].x;
- poly[0].y = poly[3].y;
- if (parallel) {
- poly[1].x = c.x;
- poly[1].y = c.y;
- } else if (pointsSeen >= 1) {
- poly[1].x = poly[2].x;
- poly[1].y = poly[2].y;
- }
- pointsSeen++;
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_Fill3DRectangle --
- *
- * Fill a rectangular area, supplying a 3D border if desired.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Information gets drawn on the screen.
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tk_Fill3DRectangle(tkwin, drawable, border, x, y, width,
- height, borderWidth, relief)
- Tk_Window tkwin; /* Window for which border was allocated. */
- Drawable drawable; /* X window or pixmap in which to draw. */
- Tk_3DBorder border; /* Token for border to draw. */
- int x, y, width, height; /* Outside area of rectangular region. */
- int borderWidth; /* Desired width for border, in
- * pixels. Border will be *inside* region. */
- int relief; /* Indicates 3D effect: TK_RELIEF_FLAT,
- * TK_RELIEF_RAISED, or TK_RELIEF_SUNKEN. */
-{
- register TkBorder *borderPtr = (TkBorder *) border;
- int doubleBorder;
-
- /*
- * This code is slightly tricky because it only draws the background
- * in areas not covered by the 3D border. This avoids flashing
- * effects on the screen for the border region.
- */
-
- if (relief == TK_RELIEF_FLAT) {
- borderWidth = 0;
- }
- doubleBorder = 2*borderWidth;
-
- if ((width > doubleBorder) && (height > doubleBorder)) {
- XFillRectangle(Tk_Display(tkwin), drawable, borderPtr->bgGC,
- x + borderWidth, y + borderWidth,
- (unsigned int) (width - doubleBorder),
- (unsigned int) (height - doubleBorder));
- }
- if (borderWidth) {
- Tk_Draw3DRectangle(tkwin, drawable, border, x, y, width,
- height, borderWidth, relief);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_Fill3DPolygon --
- *
- * Fill a polygonal area, supplying a 3D border if desired.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Information gets drawn on the screen.
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tk_Fill3DPolygon(tkwin, drawable, border, pointPtr, numPoints,
- borderWidth, leftRelief)
- Tk_Window tkwin; /* Window for which border was allocated. */
- Drawable drawable; /* X window or pixmap in which to draw. */
- Tk_3DBorder border; /* Token for border to draw. */
- XPoint *pointPtr; /* Array of points describing
- * polygon. All points must be
- * absolute (CoordModeOrigin). */
- int numPoints; /* Number of points at *pointPtr. */
- int borderWidth; /* Width of border, measured in
- * pixels to the left of the polygon's
- * trajectory. May be negative. */
- int leftRelief; /* Indicates 3D effect of left side of
- * trajectory relative to right:
- * TK_RELIEF_FLAT, TK_RELIEF_RAISED,
- * or TK_RELIEF_SUNKEN. */
-{
- register TkBorder *borderPtr = (TkBorder *) border;
-
- XFillPolygon(Tk_Display(tkwin), drawable, borderPtr->bgGC,
- pointPtr, numPoints, Complex, CoordModeOrigin);
- if (leftRelief != TK_RELIEF_FLAT) {
- Tk_Draw3DPolygon(tkwin, drawable, border, pointPtr, numPoints,
- borderWidth, leftRelief);
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * BorderInit --
- *
- * Initialize the structures used for border management.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Read the code.
- *
- *-------------------------------------------------------------
- */
-
-static void
-BorderInit()
-{
- initialized = 1;
- Tcl_InitHashTable(&borderTable, sizeof(BorderKey)/sizeof(int));
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ShiftLine --
- *
- * Given two points on a line, compute a point on a
- * new line that is parallel to the given line and
- * a given distance away from it.
- *
- * Results:
- * None.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-static void
-ShiftLine(p1Ptr, p2Ptr, distance, p3Ptr)
- XPoint *p1Ptr; /* First point on line. */
- XPoint *p2Ptr; /* Second point on line. */
- int distance; /* New line is to be this many
- * units to the left of original
- * line, when looking from p1 to
- * p2. May be negative. */
- XPoint *p3Ptr; /* Store coords of point on new
- * line here. */
-{
- int dx, dy, dxNeg, dyNeg;
-
- /*
- * The table below is used for a quick approximation in
- * computing the new point. An index into the table
- * is 128 times the slope of the original line (the slope
- * must always be between 0 and 1). The value of the table
- * entry is 128 times the amount to displace the new line
- * in y for each unit of perpendicular distance. In other
- * words, the table maps from the tangent of an angle to
- * the inverse of its cosine. If the slope of the original
- * line is greater than 1, then the displacement is done in
- * x rather than in y.
- */
-
- static int shiftTable[129];
-
- /*
- * Initialize the table if this is the first time it is
- * used.
- */
-
- if (shiftTable[0] == 0) {
- int i;
- double tangent, cosine;
-
- for (i = 0; i <= 128; i++) {
- tangent = i/128.0;
- cosine = 128/cos(atan(tangent)) + .5;
- shiftTable[i] = (int) cosine;
- }
- }
-
- *p3Ptr = *p1Ptr;
- dx = p2Ptr->x - p1Ptr->x;
- dy = p2Ptr->y - p1Ptr->y;
- if (dy < 0) {
- dyNeg = 1;
- dy = -dy;
- } else {
- dyNeg = 0;
- }
- if (dx < 0) {
- dxNeg = 1;
- dx = -dx;
- } else {
- dxNeg = 0;
- }
- if (dy <= dx) {
- dy = ((distance * shiftTable[(dy<<7)/dx]) + 64) >> 7;
- if (!dxNeg) {
- dy = -dy;
- }
- p3Ptr->y += dy;
- } else {
- dx = ((distance * shiftTable[(dx<<7)/dy]) + 64) >> 7;
- if (dyNeg) {
- dx = -dx;
- }
- p3Ptr->x += dx;
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Intersect --
- *
- * Find the intersection point between two lines.
- *
- * Results:
- * Under normal conditions 0 is returned and the point
- * at *iPtr is filled in with the intersection between
- * the two lines. If the two lines are parallel, then
- * -1 is returned and *iPtr isn't modified.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-static int
-Intersect(a1Ptr, a2Ptr, b1Ptr, b2Ptr, iPtr)
- XPoint *a1Ptr; /* First point of first line. */
- XPoint *a2Ptr; /* Second point of first line. */
- XPoint *b1Ptr; /* First point of second line. */
- XPoint *b2Ptr; /* Second point of second line. */
- XPoint *iPtr; /* Filled in with intersection point. */
-{
- int dxadyb, dxbdya, dxadxb, dyadyb, p, q;
-
- /*
- * The code below is just a straightforward manipulation of two
- * equations of the form y = (x-x1)*(y2-y1)/(x2-x1) + y1 to solve
- * for the x-coordinate of intersection, then the y-coordinate.
- */
-
- dxadyb = (a2Ptr->x - a1Ptr->x)*(b2Ptr->y - b1Ptr->y);
- dxbdya = (b2Ptr->x - b1Ptr->x)*(a2Ptr->y - a1Ptr->y);
- dxadxb = (a2Ptr->x - a1Ptr->x)*(b2Ptr->x - b1Ptr->x);
- dyadyb = (a2Ptr->y - a1Ptr->y)*(b2Ptr->y - b1Ptr->y);
-
- if (dxadyb == dxbdya) {
- return -1;
- }
- p = (a1Ptr->x*dxbdya - b1Ptr->x*dxadyb + (b1Ptr->y - a1Ptr->y)*dxadxb);
- q = dxbdya - dxadyb;
- if (q < 0) {
- p = -p;
- q = -q;
- }
- if (p < 0) {
- iPtr->x = - ((-p + q/2)/q);
- } else {
- iPtr->x = (p + q/2)/q;
- }
- p = (a1Ptr->y*dxadyb - b1Ptr->y*dxbdya + (b1Ptr->x - a1Ptr->x)*dyadyb);
- q = dxadyb - dxbdya;
- if (q < 0) {
- p = -p;
- q = -q;
- }
- if (p < 0) {
- iPtr->y = - ((-p + q/2)/q);
- } else {
- iPtr->y = (p + q/2)/q;
- }
- return 0;
-}
diff --git a/generic/tk3d.h b/generic/tk3d.h
deleted file mode 100644
index 1ec63d0..0000000
--- a/generic/tk3d.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * tk3d.h --
- *
- * Declarations of types and functions shared by the 3d border
- * module.
- *
- * Copyright (c) 1996 by 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: tk3d.h,v 1.4 1998/09/14 18:23:03 stanton Exp $
- */
-
-#ifndef _TK3D
-#define _TK3D
-
-#include <tkInt.h>
-
-#ifdef BUILD_tk
-# undef TCL_STORAGE_CLASS
-# define TCL_STORAGE_CLASS DLLEXPORT
-#endif
-
-/*
- * One of the following data structures is allocated for
- * each 3-D border currently in use. Structures of this
- * type are indexed by borderTable, so that a single
- * structure can be shared for several uses.
- */
-
-typedef struct {
- Screen *screen; /* Screen on which the border will be used. */
- Visual *visual; /* Visual for all windows and pixmaps using
- * the border. */
- int depth; /* Number of bits per pixel of drawables where
- * the border will be used. */
- Colormap colormap; /* Colormap out of which pixels are
- * allocated. */
- int refCount; /* Number of different users of
- * this border. */
- XColor *bgColorPtr; /* Background color (intensity
- * between lightColorPtr and
- * darkColorPtr). */
- XColor *darkColorPtr; /* Color for darker areas (must free when
- * deleting structure). NULL means shadows
- * haven't been allocated yet.*/
- XColor *lightColorPtr; /* Color used for lighter areas of border
- * (must free this when deleting structure).
- * NULL means shadows haven't been allocated
- * yet. */
- Pixmap shadow; /* Stipple pattern to use for drawing
- * shadows areas. Used for displays with
- * <= 64 colors or where colormap has filled
- * up. */
- GC bgGC; /* Used (if necessary) to draw areas in
- * the background color. */
- GC darkGC; /* Used to draw darker parts of the
- * border. None means the shadow colors
- * haven't been allocated yet.*/
- GC lightGC; /* Used to draw lighter parts of
- * the border. None means the shadow colors
- * haven't been allocated yet. */
- Tcl_HashEntry *hashPtr; /* Entry in borderTable (needed in
- * order to delete structure). */
-} TkBorder;
-
-
-/*
- * Maximum intensity for a color:
- */
-
-#define MAX_INTENSITY 65535
-
-/*
- * Declarations for platform specific interfaces used by this module.
- */
-
-EXTERN TkBorder * TkpGetBorder _ANSI_ARGS_((void));
-EXTERN void TkpGetShadows _ANSI_ARGS_((TkBorder *borderPtr,
- Tk_Window tkwin));
-EXTERN void TkpFreeBorder _ANSI_ARGS_((TkBorder *borderPtr));
-
-# undef TCL_STORAGE_CLASS
-# define TCL_STORAGE_CLASS DLLIMPORT
-
-#endif /* _TK3D */
diff --git a/generic/tkArgv.c b/generic/tkArgv.c
deleted file mode 100644
index 8d5d661..0000000
--- a/generic/tkArgv.c
+++ /dev/null
@@ -1,433 +0,0 @@
-/*
- * tkArgv.c --
- *
- * This file contains a procedure that handles table-based
- * argv-argc parsing.
- *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994 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: tkArgv.c,v 1.2 1998/09/14 18:23:03 stanton Exp $
- */
-
-#include "tkPort.h"
-#include "tk.h"
-
-/*
- * Default table of argument descriptors. These are normally available
- * in every application.
- */
-
-static Tk_ArgvInfo defaultTable[] = {
- {"-help", TK_ARGV_HELP, (char *) NULL, (char *) NULL,
- "Print summary of command-line options and abort"},
- {NULL, TK_ARGV_END, (char *) NULL, (char *) NULL,
- (char *) NULL}
-};
-
-/*
- * Forward declarations for procedures defined in this file:
- */
-
-static void PrintUsage _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_ArgvInfo *argTable, int flags));
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_ParseArgv --
- *
- * Process an argv array according to a table of expected
- * command-line options. See the manual page for more details.
- *
- * Results:
- * The return value is a standard Tcl return value. If an
- * error occurs then an error message is left in interp->result.
- * Under normal conditions, both *argcPtr and *argv are modified
- * to return the arguments that couldn't be processed here (they
- * didn't match the option table, or followed an TK_ARGV_REST
- * argument).
- *
- * Side effects:
- * Variables may be modified, resources may be entered for tkwin,
- * or procedures may be called. It all depends on the arguments
- * and their entries in argTable. See the user documentation
- * for details.
- *
- *----------------------------------------------------------------------
- */
-
-int
-Tk_ParseArgv(interp, tkwin, argcPtr, argv, argTable, flags)
- Tcl_Interp *interp; /* Place to store error message. */
- Tk_Window tkwin; /* Window to use for setting Tk options.
- * 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
- * those that couldn't be processed here. */
- Tk_ArgvInfo *argTable; /* Array of option descriptions */
- int flags; /* Or'ed combination of various flag bits,
- * such as TK_ARGV_NO_DEFAULTS. */
-{
- register Tk_ArgvInfo *infoPtr;
- /* Pointer to the current entry in the
- * table of argument descriptions. */
- Tk_ArgvInfo *matchPtr; /* Descriptor that matches current argument. */
- 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
- * be '-'). */
- int srcIndex; /* Location from which to read next argument
- * from argv. */
- int dstIndex; /* Index into argv to which next unused
- * argument should be copied (never greater
- * than srcIndex). */
- int argc; /* # arguments in argv still to process. */
- size_t length; /* Number of characters in current argument. */
- int i;
-
- if (flags & TK_ARGV_DONT_SKIP_FIRST_ARG) {
- srcIndex = dstIndex = 0;
- argc = *argcPtr;
- } else {
- srcIndex = dstIndex = 1;
- argc = *argcPtr-1;
- }
-
- while (argc > 0) {
- curArg = argv[srcIndex];
- srcIndex++;
- argc--;
- length = strlen(curArg);
- if (length > 0) {
- c = curArg[1];
- } else {
- c = 0;
- }
-
- /*
- * Loop throught the argument descriptors searching for one with
- * the matching key string. If found, leave a pointer to it in
- * matchPtr.
- */
-
- matchPtr = NULL;
- for (i = 0; i < 2; i++) {
- if (i == 0) {
- infoPtr = argTable;
- } else {
- infoPtr = defaultTable;
- }
- for (; (infoPtr != NULL) && (infoPtr->type != TK_ARGV_END);
- infoPtr++) {
- if (infoPtr->key == NULL) {
- continue;
- }
- if ((infoPtr->key[1] != c)
- || (strncmp(infoPtr->key, curArg, length) != 0)) {
- continue;
- }
- if ((tkwin == NULL)
- && ((infoPtr->type == TK_ARGV_CONST_OPTION)
- || (infoPtr->type == TK_ARGV_OPTION_VALUE)
- || (infoPtr->type == TK_ARGV_OPTION_NAME_VALUE))) {
- continue;
- }
- if (infoPtr->key[length] == 0) {
- matchPtr = infoPtr;
- goto gotMatch;
- }
- if (flags & TK_ARGV_NO_ABBREV) {
- continue;
- }
- if (matchPtr != NULL) {
- Tcl_AppendResult(interp, "ambiguous option \"", curArg,
- "\"", (char *) NULL);
- return TCL_ERROR;
- }
- matchPtr = infoPtr;
- }
- }
- if (matchPtr == NULL) {
-
- /*
- * Unrecognized argument. Just copy it down, unless the caller
- * prefers an error to be registered.
- */
-
- if (flags & TK_ARGV_NO_LEFTOVERS) {
- Tcl_AppendResult(interp, "unrecognized argument \"",
- curArg, "\"", (char *) NULL);
- return TCL_ERROR;
- }
- argv[dstIndex] = curArg;
- dstIndex++;
- continue;
- }
-
- /*
- * Take the appropriate action based on the option type
- */
-
- gotMatch:
- infoPtr = matchPtr;
- switch (infoPtr->type) {
- case TK_ARGV_CONSTANT:
- *((int *) infoPtr->dst) = (int) infoPtr->src;
- break;
- case TK_ARGV_INT:
- if (argc == 0) {
- goto missingArg;
- } else {
- char *endPtr;
-
- *((int *) infoPtr->dst) =
- strtol(argv[srcIndex], &endPtr, 0);
- if ((endPtr == argv[srcIndex]) || (*endPtr != 0)) {
- Tcl_AppendResult(interp, "expected integer argument ",
- "for \"", infoPtr->key, "\" but got \"",
- argv[srcIndex], "\"", (char *) NULL);
- return TCL_ERROR;
- }
- srcIndex++;
- argc--;
- }
- break;
- case TK_ARGV_STRING:
- if (argc == 0) {
- goto missingArg;
- } else {
- *((char **)infoPtr->dst) = argv[srcIndex];
- srcIndex++;
- argc--;
- }
- break;
- case TK_ARGV_UID:
- if (argc == 0) {
- goto missingArg;
- } else {
- *((Tk_Uid *)infoPtr->dst) = Tk_GetUid(argv[srcIndex]);
- srcIndex++;
- argc--;
- }
- break;
- case TK_ARGV_REST:
- *((int *) infoPtr->dst) = dstIndex;
- goto argsDone;
- case TK_ARGV_FLOAT:
- if (argc == 0) {
- goto missingArg;
- } else {
- char *endPtr;
-
- *((double *) infoPtr->dst) =
- strtod(argv[srcIndex], &endPtr);
- if ((endPtr == argv[srcIndex]) || (*endPtr != 0)) {
- Tcl_AppendResult(interp, "expected floating-point ",
- "argument for \"", infoPtr->key,
- "\" but got \"", argv[srcIndex], "\"",
- (char *) NULL);
- return TCL_ERROR;
- }
- srcIndex++;
- argc--;
- }
- break;
- case TK_ARGV_FUNC: {
- typedef int (ArgvFunc)_ANSI_ARGS_((char *, char *, char *));
- ArgvFunc *handlerProc;
-
- handlerProc = (ArgvFunc *) infoPtr->src;
- if ((*handlerProc)(infoPtr->dst, infoPtr->key,
- argv[srcIndex])) {
- srcIndex += 1;
- argc -= 1;
- }
- break;
- }
- case TK_ARGV_GENFUNC: {
- typedef int (ArgvGenFunc)_ANSI_ARGS_((char *, Tcl_Interp *,
- char *, int, char **));
- ArgvGenFunc *handlerProc;
-
- handlerProc = (ArgvGenFunc *) infoPtr->src;
- argc = (*handlerProc)(infoPtr->dst, interp, infoPtr->key,
- argc, argv+srcIndex);
- if (argc < 0) {
- return TCL_ERROR;
- }
- break;
- }
- case TK_ARGV_HELP:
- PrintUsage (interp, argTable, flags);
- return TCL_ERROR;
- case TK_ARGV_CONST_OPTION:
- Tk_AddOption(tkwin, infoPtr->dst, infoPtr->src,
- TK_INTERACTIVE_PRIO);
- break;
- case TK_ARGV_OPTION_VALUE:
- if (argc < 1) {
- goto missingArg;
- }
- Tk_AddOption(tkwin, infoPtr->dst, argv[srcIndex],
- TK_INTERACTIVE_PRIO);
- srcIndex++;
- argc--;
- break;
- case TK_ARGV_OPTION_NAME_VALUE:
- if (argc < 2) {
- Tcl_AppendResult(interp, "\"", curArg,
- "\" option requires two following arguments",
- (char *) NULL);
- return TCL_ERROR;
- }
- Tk_AddOption(tkwin, argv[srcIndex], argv[srcIndex+1],
- TK_INTERACTIVE_PRIO);
- srcIndex += 2;
- argc -= 2;
- break;
- default:
- sprintf(interp->result, "bad argument type %d in Tk_ArgvInfo",
- infoPtr->type);
- return TCL_ERROR;
- }
- }
-
- /*
- * If we broke out of the loop because of an OPT_REST argument,
- * copy the remaining arguments down.
- */
-
- argsDone:
- while (argc) {
- argv[dstIndex] = argv[srcIndex];
- srcIndex++;
- dstIndex++;
- argc--;
- }
- argv[dstIndex] = (char *) NULL;
- *argcPtr = dstIndex;
- return TCL_OK;
-
- missingArg:
- Tcl_AppendResult(interp, "\"", curArg,
- "\" option requires an additional argument", (char *) NULL);
- return TCL_ERROR;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * PrintUsage --
- *
- * Generate a help string describing command-line options.
- *
- * Results:
- * Interp->result will be modified to hold a help string
- * describing all the options in argTable, plus all those
- * in the default table unless TK_ARGV_NO_DEFAULTS is
- * specified in flags.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-PrintUsage(interp, argTable, flags)
- Tcl_Interp *interp; /* Place information in this interp's
- * result area. */
- Tk_ArgvInfo *argTable; /* Array of command-specific argument
- * descriptions. */
- int flags; /* If the TK_ARGV_NO_DEFAULTS bit is set
- * in this word, then don't generate
- * information for default options. */
-{
- register Tk_ArgvInfo *infoPtr;
- int width, i, numSpaces;
-#define NUM_SPACES 20
- static char spaces[] = " ";
- char tmp[30];
-
- /*
- * First, compute the width of the widest option key, so that we
- * can make everything line up.
- */
-
- width = 4;
- for (i = 0; i < 2; i++) {
- for (infoPtr = i ? defaultTable : argTable;
- infoPtr->type != TK_ARGV_END; infoPtr++) {
- int length;
- if (infoPtr->key == NULL) {
- continue;
- }
- length = strlen(infoPtr->key);
- if (length > width) {
- width = length;
- }
- }
- }
-
- Tcl_AppendResult(interp, "Command-specific options:", (char *) NULL);
- for (i = 0; ; i++) {
- for (infoPtr = i ? defaultTable : argTable;
- infoPtr->type != TK_ARGV_END; infoPtr++) {
- if ((infoPtr->type == TK_ARGV_HELP) && (infoPtr->key == NULL)) {
- Tcl_AppendResult(interp, "\n", infoPtr->help, (char *) NULL);
- continue;
- }
- Tcl_AppendResult(interp, "\n ", infoPtr->key, ":", (char *) NULL);
- numSpaces = width + 1 - strlen(infoPtr->key);
- while (numSpaces > 0) {
- if (numSpaces >= NUM_SPACES) {
- Tcl_AppendResult(interp, spaces, (char *) NULL);
- } else {
- Tcl_AppendResult(interp, spaces+NUM_SPACES-numSpaces,
- (char *) NULL);
- }
- numSpaces -= NUM_SPACES;
- }
- Tcl_AppendResult(interp, infoPtr->help, (char *) NULL);
- switch (infoPtr->type) {
- case TK_ARGV_INT: {
- sprintf(tmp, "%d", *((int *) infoPtr->dst));
- Tcl_AppendResult(interp, "\n\t\tDefault value: ",
- tmp, (char *) NULL);
- break;
- }
- case TK_ARGV_FLOAT: {
- sprintf(tmp, "%g", *((double *) infoPtr->dst));
- Tcl_AppendResult(interp, "\n\t\tDefault value: ",
- tmp, (char *) NULL);
- break;
- }
- case TK_ARGV_STRING: {
- char *string;
-
- string = *((char **) infoPtr->dst);
- if (string != NULL) {
- Tcl_AppendResult(interp, "\n\t\tDefault value: \"",
- string, "\"", (char *) NULL);
- }
- break;
- }
- default: {
- break;
- }
- }
- }
-
- if ((flags & TK_ARGV_NO_DEFAULTS) || (i > 0)) {
- break;
- }
- Tcl_AppendResult(interp, "\nGeneric options for all commands:",
- (char *) NULL);
- }
-}
diff --git a/generic/tkAtom.c b/generic/tkAtom.c
deleted file mode 100644
index fba9fb8..0000000
--- a/generic/tkAtom.c
+++ /dev/null
@@ -1,217 +0,0 @@
-/*
- * tkAtom.c --
- *
- * This file manages a cache of X Atoms in order to avoid
- * interactions with the X server. It's much like the Xmu
- * routines, except it has a cleaner interface (caller
- * doesn't have to provide permanent storage for atom names,
- * for example).
- *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994 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: tkAtom.c,v 1.2 1998/09/14 18:23:03 stanton Exp $
- */
-
-#include "tkPort.h"
-#include "tkInt.h"
-
-/*
- * The following are a list of the predefined atom strings.
- * They should match those found in xatom.h
- */
-
-static char * atomNameArray[] = {
- "PRIMARY", "SECONDARY", "ARC",
- "ATOM", "BITMAP", "CARDINAL",
- "COLORMAP", "CURSOR", "CUT_BUFFER0",
- "CUT_BUFFER1", "CUT_BUFFER2", "CUT_BUFFER3",
- "CUT_BUFFER4", "CUT_BUFFER5", "CUT_BUFFER6",
- "CUT_BUFFER7", "DRAWABLE", "FONT",
- "INTEGER", "PIXMAP", "POINT",
- "RECTANGLE", "RESOURCE_MANAGER", "RGB_COLOR_MAP",
- "RGB_BEST_MAP", "RGB_BLUE_MAP", "RGB_DEFAULT_MAP",
- "RGB_GRAY_MAP", "RGB_GREEN_MAP", "RGB_RED_MAP",
- "STRING", "VISUALID", "WINDOW",
- "WM_COMMAND", "WM_HINTS", "WM_CLIENT_MACHINE",
- "WM_ICON_NAME", "WM_ICON_SIZE", "WM_NAME",
- "WM_NORMAL_HINTS", "WM_SIZE_HINTS", "WM_ZOOM_HINTS",
- "MIN_SPACE", "NORM_SPACE", "MAX_SPACE",
- "END_SPACE", "SUPERSCRIPT_X", "SUPERSCRIPT_Y",
- "SUBSCRIPT_X", "SUBSCRIPT_Y", "UNDERLINE_POSITION",
- "UNDERLINE_THICKNESS", "STRIKEOUT_ASCENT", "STRIKEOUT_DESCENT",
- "ITALIC_ANGLE", "X_HEIGHT", "QUAD_WIDTH",
- "WEIGHT", "POINT_SIZE", "RESOLUTION",
- "COPYRIGHT", "NOTICE", "FONT_NAME",
- "FAMILY_NAME", "FULL_NAME", "CAP_HEIGHT",
- "WM_CLASS", "WM_TRANSIENT_FOR",
- (char *) NULL
-};
-
-/*
- * Forward references to procedures defined in this file:
- */
-
-static void AtomInit _ANSI_ARGS_((TkDisplay *dispPtr));
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_InternAtom --
- *
- * Given a string, produce the equivalent X atom. This
- * procedure is equivalent to XInternAtom, except that it
- * keeps a local cache of atoms. Once a name is known,
- * the server need not be contacted again for that name.
- *
- * Results:
- * The return value is the Atom corresponding to name.
- *
- * Side effects:
- * A new entry may be added to the local atom cache.
- *
- *--------------------------------------------------------------
- */
-
-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. */
-{
- register TkDisplay *dispPtr;
- register Tcl_HashEntry *hPtr;
- int new;
-
- dispPtr = ((TkWindow *) tkwin)->dispPtr;
- if (!dispPtr->atomInit) {
- AtomInit(dispPtr);
- }
-
- hPtr = Tcl_CreateHashEntry(&dispPtr->nameTable, name, &new);
- if (new) {
- Tcl_HashEntry *hPtr2;
- Atom atom;
-
- atom = XInternAtom(dispPtr->display, name, False);
- Tcl_SetHashValue(hPtr, atom);
- hPtr2 = Tcl_CreateHashEntry(&dispPtr->atomTable, (char *) atom,
- &new);
- Tcl_SetHashValue(hPtr2, Tcl_GetHashKey(&dispPtr->nameTable, hPtr));
- }
- return (Atom) Tcl_GetHashValue(hPtr);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_GetAtomName --
- *
- * This procedure is equivalent to XGetAtomName except that
- * it uses the local atom cache to avoid contacting the
- * server.
- *
- * Results:
- * The return value is a character string corresponding to
- * the atom given by "atom". This string's storage space
- * is static: it need not be freed by the caller, and should
- * not be modified by the caller. If "atom" doesn't exist
- * on tkwin's display, then the string "?bad atom?" is returned.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-char *
-Tk_GetAtomName(tkwin, atom)
- Tk_Window tkwin; /* Window token; map atom to name
- * relative to this window's
- * display. */
- Atom atom; /* Atom whose name is wanted. */
-{
- register TkDisplay *dispPtr;
- register Tcl_HashEntry *hPtr;
-
- dispPtr = ((TkWindow *) tkwin)->dispPtr;
- if (!dispPtr->atomInit) {
- AtomInit(dispPtr);
- }
-
- hPtr = Tcl_FindHashEntry(&dispPtr->atomTable, (char *) atom);
- if (hPtr == NULL) {
- char *name;
- Tk_ErrorHandler handler;
- int new, mustFree;
-
- handler= Tk_CreateErrorHandler(dispPtr->display, BadAtom,
- -1, -1, (Tk_ErrorProc *) NULL, (ClientData) NULL);
- name = XGetAtomName(dispPtr->display, atom);
- mustFree = 1;
- if (name == NULL) {
- name = "?bad atom?";
- mustFree = 0;
- }
- Tk_DeleteErrorHandler(handler);
- hPtr = Tcl_CreateHashEntry(&dispPtr->nameTable, (char *) name,
- &new);
- Tcl_SetHashValue(hPtr, atom);
- if (mustFree) {
- XFree(name);
- }
- name = Tcl_GetHashKey(&dispPtr->nameTable, hPtr);
- hPtr = Tcl_CreateHashEntry(&dispPtr->atomTable, (char *) atom,
- &new);
- Tcl_SetHashValue(hPtr, name);
- }
- return (char *) Tcl_GetHashValue(hPtr);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * AtomInit --
- *
- * Initialize atom-related information for a display.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Tables get initialized, etc. etc..
- *
- *--------------------------------------------------------------
- */
-
-static void
-AtomInit(dispPtr)
- register TkDisplay *dispPtr; /* Display to initialize. */
-{
- Tcl_HashEntry *hPtr;
- Atom atom;
-
- dispPtr->atomInit = 1;
- Tcl_InitHashTable(&dispPtr->nameTable, TCL_STRING_KEYS);
- Tcl_InitHashTable(&dispPtr->atomTable, TCL_ONE_WORD_KEYS);
-
- for (atom = 1; atom <= XA_LAST_PREDEFINED; atom++) {
- hPtr = Tcl_FindHashEntry(&dispPtr->atomTable, (char *) atom);
- if (hPtr == NULL) {
- char *name;
- int new;
-
- name = atomNameArray[atom - 1];
- hPtr = Tcl_CreateHashEntry(&dispPtr->nameTable, (char *) name,
- &new);
- Tcl_SetHashValue(hPtr, atom);
- name = Tcl_GetHashKey(&dispPtr->nameTable, hPtr);
- hPtr = Tcl_CreateHashEntry(&dispPtr->atomTable, (char *) atom,
- &new);
- Tcl_SetHashValue(hPtr, name);
- }
- }
-}
diff --git a/generic/tkBind.c b/generic/tkBind.c
deleted file mode 100644
index 6fcafd2..0000000
--- a/generic/tkBind.c
+++ /dev/null
@@ -1,4533 +0,0 @@
-/*
- * tkBind.c --
- *
- * This file provides procedures that associate Tcl commands
- * with X events or sequences of X events.
- *
- * Copyright (c) 1989-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: tkBind.c,v 1.3 1998/09/14 18:23:03 stanton Exp $
- */
-
-#include "tkPort.h"
-#include "tkInt.h"
-
-/*
- * File structure:
- *
- * Structure definitions and static variables.
- *
- * Init/Free this package.
- *
- * Tcl "bind" command (actually located in tkCmds.c).
- * "bind" command implementation.
- * "bind" implementation helpers.
- *
- * Tcl "event" command.
- * "event" command implementation.
- * "event" implementation helpers.
- *
- * Package-specific common helpers.
- *
- * Non-package-specific helpers.
- */
-
-
-/*
- * The following union is used to hold the detail information from an
- * XEvent (including Tk's XVirtualEvent extension).
- */
-typedef union {
- KeySym keySym; /* KeySym that corresponds to xkey.keycode. */
- int button; /* Button that was pressed (xbutton.button). */
- Tk_Uid name; /* Tk_Uid of virtual event. */
- ClientData clientData; /* Used when type of Detail is unknown, and to
- * ensure that all bytes of Detail are initialized
- * when this structure is used in a hash key. */
-} Detail;
-
-/*
- * The structure below represents a binding table. A binding table
- * represents a domain in which event bindings may occur. It includes
- * a space of objects relative to which events occur (usually windows,
- * but not always), a history of recent events in the domain, and
- * a set of mappings that associate particular Tcl commands with sequences
- * of events in the domain. Multiple binding tables may exist at once,
- * either because there are multiple applications open, or because there
- * are multiple domains within an application with separate event
- * bindings for each (for example, each canvas widget has a separate
- * binding table for associating events with the items in the canvas).
- *
- * Note: it is probably a bad idea to reduce EVENT_BUFFER_SIZE much
- * below 30. To see this, consider a triple mouse button click while
- * the Shift key is down (and auto-repeating). There may be as many
- * as 3 auto-repeat events after each mouse button press or release
- * (see the first large comment block within Tk_BindEvent for more on
- * this), for a total of 20 events to cover the three button presses
- * and two intervening releases. If you reduce EVENT_BUFFER_SIZE too
- * much, shift multi-clicks will be lost.
- *
- */
-
-#define EVENT_BUFFER_SIZE 30
-typedef struct BindingTable {
- XEvent eventRing[EVENT_BUFFER_SIZE];/* Circular queue of recent events
- * (higher indices are for more recent
- * events). */
- Detail detailRing[EVENT_BUFFER_SIZE];/* "Detail" information (keySym,
- * button, Tk_Uid, or 0) for each
- * entry in eventRing. */
- int curEvent; /* Index in eventRing of most recent
- * event. Newer events have higher
- * indices. */
- Tcl_HashTable patternTable; /* Used to map from an event to a
- * list of patterns that may match that
- * event. Keys are PatternTableKey
- * structs, values are (PatSeq *). */
- Tcl_HashTable objectTable; /* Used to map from an object to a
- * list of patterns associated with
- * that object. Keys are ClientData,
- * values are (PatSeq *). */
- Tcl_Interp *interp; /* Interpreter in which commands are
- * executed. */
-} BindingTable;
-
-/*
- * The following structure represents virtual event table. A virtual event
- * table provides a way to map from platform-specific physical events such
- * as button clicks or key presses to virtual events such as <<Paste>>,
- * <<Close>>, or <<ScrollWindow>>.
- *
- * A virtual event is usually never part of the event stream, but instead is
- * synthesized inline by matching low-level events. However, a virtual
- * event may be generated by platform-specific code or by Tcl scripts. In
- * that case, no lookup of the virtual event will need to be done using
- * this table, because the virtual event is actually in the event stream.
- */
-
-typedef struct VirtualEventTable {
- Tcl_HashTable patternTable; /* Used to map from a physical event to
- * a list of patterns that may match that
- * event. Keys are PatternTableKey
- * structs, values are (PatSeq *). */
- Tcl_HashTable nameTable; /* Used to map a virtual event name to
- * the array of physical events that can
- * trigger it. Keys are the Tk_Uid names
- * of the virtual events, values are
- * PhysicalsOwned structs. */
-} VirtualEventTable;
-
-/*
- * The following structure is used as a key in a patternTable for both
- * binding tables and a virtual event tables.
- *
- * In a binding table, the object field corresponds to the binding tag
- * for the widget whose bindings are being accessed.
- *
- * In a virtual event table, the object field is always NULL. Virtual
- * events are a global definiton and are not tied to a particular
- * binding tag.
- *
- * The same key is used for both types of pattern tables so that the
- * helper functions that traverse and match patterns will work for both
- * binding tables and virtual event tables.
- */
-typedef struct PatternTableKey {
- ClientData object; /* For binding table, identifies the binding
- * tag of the object (or class of objects)
- * relative to which the event occurred.
- * For virtual event table, always NULL. */
- int type; /* Type of event (from X). */
- Detail detail; /* Additional information, such as keysym,
- * button, Tk_Uid, or 0 if nothing
- * additional. */
-} PatternTableKey;
-
-/*
- * The following structure defines a pattern, which is matched against X
- * events as part of the process of converting X events into Tcl commands.
- */
-
-typedef struct Pattern {
- int eventType; /* Type of X event, e.g. ButtonPress. */
- int needMods; /* Mask of modifiers that must be
- * present (0 means no modifiers are
- * required). */
- Detail detail; /* Additional information that must
- * match event. Normally this is 0,
- * meaning no additional information
- * must match. For KeyPress and
- * KeyRelease events, a keySym may
- * be specified to select a
- * particular keystroke (0 means any
- * keystrokes). For button events,
- * specifies a particular button (0
- * means any buttons are OK). For virtual
- * events, specifies the Tk_Uid of the
- * virtual event name (never 0). */
-} Pattern;
-
-/*
- * The following structure defines a pattern sequence, which consists of one
- * or more patterns. In order to trigger, a pattern sequence must match
- * the most recent X events (first pattern to most recent event, next
- * pattern to next event, and so on). It is used as the hash value in a
- * patternTable for both binding tables and virtual event tables.
- *
- * In a binding table, it is the sequence of physical events that make up
- * a binding for an object.
- *
- * In a virtual event table, it is the sequence of physical events that
- * define a virtual event.
- *
- * The same structure is used for both types of pattern tables so that the
- * helper functions that traverse and match patterns will work for both
- * binding tables and virtual event tables.
- */
-
-typedef struct PatSeq {
- int numPats; /* Number of patterns in sequence (usually
- * 1). */
- TkBindEvalProc *eventProc; /* The procedure that will be invoked on
- * the clientData when this pattern sequence
- * matches. */
- TkBindFreeProc *freeProc; /* The procedure that will be invoked to
- * release the clientData when this pattern
- * sequence is freed. */
- ClientData clientData; /* Arbitray data passed to eventProc and
- * freeProc when sequence matches. */
- int flags; /* Miscellaneous flag values; see below for
- * definitions. */
- int refCount; /* Number of times that this binding is in
- * the midst of executing. If greater than 1,
- * then a recursive invocation is happening.
- * Only when this is zero can the binding
- * actually be freed. */
- struct PatSeq *nextSeqPtr; /* Next in list of all pattern sequences
- * that have the same initial pattern. NULL
- * means end of list. */
- Tcl_HashEntry *hPtr; /* Pointer to hash table entry for the
- * initial pattern. This is the head of the
- * list of which nextSeqPtr forms a part. */
- struct VirtualOwners *voPtr;/* In a binding table, always NULL. In a
- * virtual event table, identifies the array
- * of virtual events that can be triggered by
- * this event. */
- struct PatSeq *nextObjPtr; /* In a binding table, next in list of all
- * pattern sequences for the same object (NULL
- * for end of list). Needed to implement
- * Tk_DeleteAllBindings. In a virtual event
- * table, always NULL. */
- Pattern pats[1]; /* Array of "numPats" patterns. Only one
- * element is declared here but in actuality
- * enough space will be allocated for "numPats"
- * patterns. To match, pats[0] must match
- * event n, pats[1] must match event n-1, etc.
- */
-} PatSeq;
-
-/*
- * Flag values for PatSeq structures:
- *
- * PAT_NEARBY 1 means that all of the events matching
- * this sequence must occur with nearby X
- * and Y mouse coordinates and close in time.
- * This is typically used to restrict multiple
- * button presses.
- * MARKED_DELETED 1 means that this binding has been marked as deleted
- * and removed from the binding table, but its memory
- * could not be released because it was already queued for
- * execution. When the binding is actually about to be
- * executed, this flag will be checked and the binding
- * skipped if set.
- */
-
-#define PAT_NEARBY 0x1
-#define MARKED_DELETED 0x2
-
-/*
- * Constants that define how close together two events must be
- * in milliseconds or pixels to meet the PAT_NEARBY constraint:
- */
-
-#define NEARBY_PIXELS 5
-#define NEARBY_MS 500
-
-
-/*
- * The following structure keeps track of all the virtual events that are
- * associated with a particular physical event. It is pointed to by the
- * voPtr field in a PatSeq in the patternTable of a virtual event table.
- */
-
-typedef struct VirtualOwners {
- int numOwners; /* Number of virtual events to trigger. */
- Tcl_HashEntry *owners[1]; /* Array of pointers to entries in
- * nameTable. Enough space will
- * actually be allocated for numOwners
- * hash entries. */
-} VirtualOwners;
-
-/*
- * The following structure is used in the nameTable of a virtual event
- * table to associate a virtual event with all the physical events that can
- * trigger it.
- */
-typedef struct PhysicalsOwned {
- int numOwned; /* Number of physical events owned. */
- PatSeq *patSeqs[1]; /* Array of pointers to physical event
- * patterns. Enough space will actually
- * be allocated to hold numOwned. */
-} PhysicalsOwned;
-
-/*
- * 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
- * structure).
- */
-
-typedef struct {
- TkDisplay *curDispPtr; /* Display for last binding command invoked
- * in this application. */
- int curScreenIndex; /* Index of screen for last binding command. */
- int bindingDepth; /* Number of active instances of Tk_BindEvent
- * in this application. */
-} ScreenInfo;
-
-/*
- * The following structure is used to keep track of all the C bindings that
- * are awaiting invocation and whether the window they refer to has been
- * destroyed. If the window is destroyed, then all pending callbacks for
- * that window will be cancelled. The Tcl bindings will still all be
- * invoked, however.
- */
-
-typedef struct PendingBinding {
- struct PendingBinding *nextPtr;
- /* Next in chain of pending bindings, in
- * case a recursive binding evaluation is in
- * progress. */
- Tk_Window tkwin; /* The window that the following bindings
- * depend upon. */
- int deleted; /* Set to non-zero by window cleanup code
- * if tkwin is deleted. */
- PatSeq *matchArray[5]; /* Array of pending C bindings. The actual
- * size of this depends on how many C bindings
- * matched the event passed to Tk_BindEvent.
- * THIS FIELD MUST BE THE LAST IN THE
- * STRUCTURE. */
-} PendingBinding;
-
-/*
- * The following structure keeps track of all the information local to
- * the binding package on a per interpreter basis.
- */
-
-typedef struct BindInfo {
- VirtualEventTable virtualEventTable;
- /* The virtual events that exist in this
- * interpreter. */
- ScreenInfo screenInfo; /* Keeps track of the current display and
- * screen, so it can be restored after
- * a binding has executed. */
- PendingBinding *pendingList;/* The list of pending C bindings, kept in
- * case a C or Tcl binding causes the target
- * window to be deleted. */
-} BindInfo;
-
-/*
- * In X11R4 and earlier versions, XStringToKeysym is ridiculously
- * slow. The data structure and hash table below, along with the
- * code that uses them, implement a fast mapping from strings to
- * keysyms. In X11R5 and later releases XStringToKeysym is plenty
- * fast so this stuff isn't needed. The #define REDO_KEYSYM_LOOKUP
- * is normally undefined, so that XStringToKeysym gets used. It
- * can be set in the Makefile to enable the use of the hash table
- * below.
- */
-
-#ifdef REDO_KEYSYM_LOOKUP
-typedef struct {
- char *name; /* Name of keysym. */
- KeySym value; /* Numeric identifier for keysym. */
-} KeySymInfo;
-static KeySymInfo keyArray[] = {
-#ifndef lint
-#include "ks_names.h"
-#endif
- {(char *) NULL, 0}
-};
-static Tcl_HashTable keySymTable; /* keyArray hashed by keysym value. */
-static Tcl_HashTable nameTable; /* keyArray hashed by keysym name. */
-#endif /* REDO_KEYSYM_LOOKUP */
-
-/*
- * Set to non-zero when the package-wide static variables have been
- * initialized.
- */
-
-static int initialized = 0;
-
-/*
- * A hash table is kept to map from the string names of event
- * modifiers to information about those modifiers. The structure
- * for storing this information, and the hash table built at
- * initialization time, are defined below.
- */
-
-typedef struct {
- char *name; /* Name of modifier. */
- int mask; /* Button/modifier mask value, * such as Button1Mask. */
- int flags; /* Various flags; see below for
- * definitions. */
-} ModInfo;
-
-/*
- * Flags for ModInfo structures:
- *
- * DOUBLE - Non-zero means duplicate this event,
- * e.g. for double-clicks.
- * TRIPLE - Non-zero means triplicate this event,
- * e.g. for triple-clicks.
- */
-
-#define DOUBLE 1
-#define TRIPLE 2
-
-/*
- * The following special modifier mask bits are defined, to indicate
- * logical modifiers such as Meta and Alt that may float among the
- * actual modifier bits.
- */
-
-#define META_MASK (AnyModifier<<1)
-#define ALT_MASK (AnyModifier<<2)
-
-static ModInfo modArray[] = {
- {"Control", ControlMask, 0},
- {"Shift", ShiftMask, 0},
- {"Lock", LockMask, 0},
- {"Meta", META_MASK, 0},
- {"M", META_MASK, 0},
- {"Alt", ALT_MASK, 0},
- {"B1", Button1Mask, 0},
- {"Button1", Button1Mask, 0},
- {"B2", Button2Mask, 0},
- {"Button2", Button2Mask, 0},
- {"B3", Button3Mask, 0},
- {"Button3", Button3Mask, 0},
- {"B4", Button4Mask, 0},
- {"Button4", Button4Mask, 0},
- {"B5", Button5Mask, 0},
- {"Button5", Button5Mask, 0},
- {"Mod1", Mod1Mask, 0},
- {"M1", Mod1Mask, 0},
- {"Command", Mod1Mask, 0},
- {"Mod2", Mod2Mask, 0},
- {"M2", Mod2Mask, 0},
- {"Option", Mod2Mask, 0},
- {"Mod3", Mod3Mask, 0},
- {"M3", Mod3Mask, 0},
- {"Mod4", Mod4Mask, 0},
- {"M4", Mod4Mask, 0},
- {"Mod5", Mod5Mask, 0},
- {"M5", Mod5Mask, 0},
- {"Double", 0, DOUBLE},
- {"Triple", 0, TRIPLE},
- {"Any", 0, 0}, /* Ignored: historical relic. */
- {NULL, 0, 0}
-};
-static Tcl_HashTable modTable;
-
-/*
- * This module also keeps a hash table mapping from event names
- * to information about those events. The structure, an array
- * to use to initialize the hash table, and the hash table are
- * all defined below.
- */
-
-typedef struct {
- char *name; /* Name of event. */
- int type; /* Event type for X, such as
- * ButtonPress. */
- int eventMask; /* Mask bits (for XSelectInput)
- * for this event type. */
-} EventInfo;
-
-/*
- * Note: some of the masks below are an OR-ed combination of
- * several masks. This is necessary because X doesn't report
- * up events unless you also ask for down events. Also, X
- * doesn't report button state in motion events unless you've
- * asked about button events.
- */
-
-static EventInfo eventArray[] = {
- {"Key", KeyPress, KeyPressMask},
- {"KeyPress", KeyPress, KeyPressMask},
- {"KeyRelease", KeyRelease, KeyPressMask|KeyReleaseMask},
- {"Button", ButtonPress, ButtonPressMask},
- {"ButtonPress", ButtonPress, ButtonPressMask},
- {"ButtonRelease", ButtonRelease,
- ButtonPressMask|ButtonReleaseMask},
- {"Motion", MotionNotify,
- ButtonPressMask|PointerMotionMask},
- {"Enter", EnterNotify, EnterWindowMask},
- {"Leave", LeaveNotify, LeaveWindowMask},
- {"FocusIn", FocusIn, FocusChangeMask},
- {"FocusOut", FocusOut, FocusChangeMask},
- {"Expose", Expose, ExposureMask},
- {"Visibility", VisibilityNotify, VisibilityChangeMask},
- {"Destroy", DestroyNotify, StructureNotifyMask},
- {"Unmap", UnmapNotify, StructureNotifyMask},
- {"Map", MapNotify, StructureNotifyMask},
- {"Reparent", ReparentNotify, StructureNotifyMask},
- {"Configure", ConfigureNotify, StructureNotifyMask},
- {"Gravity", GravityNotify, StructureNotifyMask},
- {"Circulate", CirculateNotify, StructureNotifyMask},
- {"Property", PropertyNotify, PropertyChangeMask},
- {"Colormap", ColormapNotify, ColormapChangeMask},
- {"Activate", ActivateNotify, ActivateMask},
- {"Deactivate", DeactivateNotify, ActivateMask},
- {(char *) NULL, 0, 0}
-};
-static Tcl_HashTable eventTable;
-
-/*
- * The defines and table below are used to classify events into
- * various groups. The reason for this is that logically identical
- * fields (e.g. "state") appear at different places in different
- * types of events. The classification masks can be used to figure
- * out quickly where to extract information from events.
- */
-
-#define KEY 0x1
-#define BUTTON 0x2
-#define MOTION 0x4
-#define CROSSING 0x8
-#define FOCUS 0x10
-#define EXPOSE 0x20
-#define VISIBILITY 0x40
-#define CREATE 0x80
-#define DESTROY 0x100
-#define UNMAP 0x200
-#define MAP 0x400
-#define REPARENT 0x800
-#define CONFIG 0x1000
-#define GRAVITY 0x2000
-#define CIRC 0x4000
-#define PROP 0x8000
-#define COLORMAP 0x10000
-#define VIRTUAL 0x20000
-#define ACTIVATE 0x40000
-
-#define KEY_BUTTON_MOTION_VIRTUAL (KEY|BUTTON|MOTION|VIRTUAL)
-
-static int flagArray[TK_LASTEVENT] = {
- /* Not used */ 0,
- /* Not used */ 0,
- /* KeyPress */ KEY,
- /* KeyRelease */ KEY,
- /* ButtonPress */ BUTTON,
- /* ButtonRelease */ BUTTON,
- /* MotionNotify */ MOTION,
- /* EnterNotify */ CROSSING,
- /* LeaveNotify */ CROSSING,
- /* FocusIn */ FOCUS,
- /* FocusOut */ FOCUS,
- /* KeymapNotify */ 0,
- /* Expose */ EXPOSE,
- /* GraphicsExpose */ EXPOSE,
- /* NoExpose */ 0,
- /* VisibilityNotify */ VISIBILITY,
- /* CreateNotify */ CREATE,
- /* DestroyNotify */ DESTROY,
- /* UnmapNotify */ UNMAP,
- /* MapNotify */ MAP,
- /* MapRequest */ 0,
- /* ReparentNotify */ REPARENT,
- /* ConfigureNotify */ CONFIG,
- /* ConfigureRequest */ 0,
- /* GravityNotify */ GRAVITY,
- /* ResizeRequest */ 0,
- /* CirculateNotify */ CIRC,
- /* CirculateRequest */ 0,
- /* PropertyNotify */ PROP,
- /* SelectionClear */ 0,
- /* SelectionRequest */ 0,
- /* SelectionNotify */ 0,
- /* ColormapNotify */ COLORMAP,
- /* ClientMessage */ 0,
- /* MappingNotify */ 0,
- /* VirtualEvent */ VIRTUAL,
- /* Activate */ ACTIVATE,
- /* Deactivate */ ACTIVATE
-};
-
-/*
- * The following tables are used as a two-way map between X's internal
- * numeric values for fields in an XEvent and the strings used in Tcl. The
- * tables are used both when constructing an XEvent from user input and
- * when providing data from an XEvent to the user.
- */
-
-static TkStateMap notifyMode[] = {
- {NotifyNormal, "NotifyNormal"},
- {NotifyGrab, "NotifyGrab"},
- {NotifyUngrab, "NotifyUngrab"},
- {NotifyWhileGrabbed, "NotifyWhileGrabbed"},
- {-1, NULL}
-};
-
-static TkStateMap notifyDetail[] = {
- {NotifyAncestor, "NotifyAncestor"},
- {NotifyVirtual, "NotifyVirtual"},
- {NotifyInferior, "NotifyInferior"},
- {NotifyNonlinear, "NotifyNonlinear"},
- {NotifyNonlinearVirtual, "NotifyNonlinearVirtual"},
- {NotifyPointer, "NotifyPointer"},
- {NotifyPointerRoot, "NotifyPointerRoot"},
- {NotifyDetailNone, "NotifyDetailNone"},
- {-1, NULL}
-};
-
-static TkStateMap circPlace[] = {
- {PlaceOnTop, "PlaceOnTop"},
- {PlaceOnBottom, "PlaceOnBottom"},
- {-1, NULL}
-};
-
-static TkStateMap visNotify[] = {
- {VisibilityUnobscured, "VisibilityUnobscured"},
- {VisibilityPartiallyObscured, "VisibilityPartiallyObscured"},
- {VisibilityFullyObscured, "VisibilityFullyObscured"},
- {-1, NULL}
-};
-
-/*
- * Prototypes for local procedures defined in this file:
- */
-
-static void ChangeScreen _ANSI_ARGS_((Tcl_Interp *interp,
- char *dispName, int screenIndex));
-static int CreateVirtualEvent _ANSI_ARGS_((Tcl_Interp *interp,
- VirtualEventTable *vetPtr, char *virtString,
- char *eventString));
-static int DeleteVirtualEvent _ANSI_ARGS_((Tcl_Interp *interp,
- VirtualEventTable *vetPtr, char *virtString,
- char *eventString));
-static void DeleteVirtualEventTable _ANSI_ARGS_((
- VirtualEventTable *vetPtr));
-static void ExpandPercents _ANSI_ARGS_((TkWindow *winPtr,
- 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));
-static void GetAllVirtualEvents _ANSI_ARGS_((Tcl_Interp *interp,
- VirtualEventTable *vetPtr));
-static char * GetField _ANSI_ARGS_((char *p, char *copy, int size));
-static KeySym GetKeySym _ANSI_ARGS_((TkDisplay *dispPtr,
- XEvent *eventPtr));
-static void GetPatternString _ANSI_ARGS_((PatSeq *psPtr,
- Tcl_DString *dsPtr));
-static int GetVirtualEvent _ANSI_ARGS_((Tcl_Interp *interp,
- VirtualEventTable *vetPtr, char *virtString));
-static Tk_Uid GetVirtualEventUid _ANSI_ARGS_((Tcl_Interp *interp,
- char *virtString));
-static int HandleEventGenerate _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Window main, int argc, char **argv));
-static void InitKeymapInfo _ANSI_ARGS_((TkDisplay *dispPtr));
-static void InitVirtualEventTable _ANSI_ARGS_((
- VirtualEventTable *vetPtr));
-static PatSeq * MatchPatterns _ANSI_ARGS_((TkDisplay *dispPtr,
- BindingTable *bindPtr, PatSeq *psPtr,
- PatSeq *bestPtr, ClientData *objectPtr,
- PatSeq **sourcePtrPtr));
-static int ParseEventDescription _ANSI_ARGS_((Tcl_Interp *interp,
- char **eventStringPtr, Pattern *patPtr,
- unsigned long *eventMaskPtr));
-
-/*
- * The following define is used as a short circuit for the callback
- * procedure to evaluate a TclBinding. The actual evaluation of the
- * binding is handled inline, because special things have to be done
- * with a Tcl binding before evaluation time.
- */
-
-#define EvalTclBinding ((TkBindEvalProc *) 1)
-
-
-/*
- *---------------------------------------------------------------------------
- *
- * TkBindInit --
- *
- * This procedure is called when an application is created. It
- * initializes all the structures used by bindings and virtual
- * events. It must be called before any other functions in this
- * file are called.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Memory allocated.
- *
- *---------------------------------------------------------------------------
- */
-
-void
-TkBindInit(mainPtr)
- TkMainInfo *mainPtr; /* The newly created application. */
-{
- BindInfo *bindInfoPtr;
-
- if (sizeof(XEvent) < sizeof(XVirtualEvent)) {
- panic("TkBindInit: virtual events can't be supported");
- }
-
- /*
- * Initialize the static data structures used by the binding package.
- * They are only initialized once, no matter how many interps are
- * created.
- */
-
- if (!initialized) {
- Tcl_HashEntry *hPtr;
- ModInfo *modPtr;
- EventInfo *eiPtr;
- int dummy;
-
-#ifdef REDO_KEYSYM_LOOKUP
- KeySymInfo *kPtr;
-
- Tcl_InitHashTable(&keySymTable, TCL_STRING_KEYS);
- Tcl_InitHashTable(&nameTable, TCL_ONE_WORD_KEYS);
- for (kPtr = keyArray; kPtr->name != NULL; kPtr++) {
- hPtr = Tcl_CreateHashEntry(&keySymTable, kPtr->name, &dummy);
- Tcl_SetHashValue(hPtr, kPtr->value);
- hPtr = Tcl_CreateHashEntry(&nameTable, (char *) kPtr->value,
- &dummy);
- Tcl_SetHashValue(hPtr, kPtr->name);
- }
-#endif /* REDO_KEYSYM_LOOKUP */
-
- Tcl_InitHashTable(&modTable, TCL_STRING_KEYS);
- for (modPtr = modArray; modPtr->name != NULL; modPtr++) {
- hPtr = Tcl_CreateHashEntry(&modTable, modPtr->name, &dummy);
- Tcl_SetHashValue(hPtr, modPtr);
- }
-
- Tcl_InitHashTable(&eventTable, TCL_STRING_KEYS);
- for (eiPtr = eventArray; eiPtr->name != NULL; eiPtr++) {
- hPtr = Tcl_CreateHashEntry(&eventTable, eiPtr->name, &dummy);
- Tcl_SetHashValue(hPtr, eiPtr);
- }
- initialized = 1;
- }
-
- mainPtr->bindingTable = Tk_CreateBindingTable(mainPtr->interp);
-
- bindInfoPtr = (BindInfo *) ckalloc(sizeof(BindInfo));
- InitVirtualEventTable(&bindInfoPtr->virtualEventTable);
- bindInfoPtr->screenInfo.curDispPtr = NULL;
- bindInfoPtr->screenInfo.curScreenIndex = -1;
- bindInfoPtr->screenInfo.bindingDepth = 0;
- bindInfoPtr->pendingList = NULL;
- mainPtr->bindInfo = (TkBindInfo) bindInfoPtr;
-
- TkpInitializeMenuBindings(mainPtr->interp, mainPtr->bindingTable);
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * TkBindFree --
- *
- * This procedure is called when an application is deleted. It
- * deletes all the structures used by bindings and virtual events.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Memory freed.
- *
- *---------------------------------------------------------------------------
- */
-
-void
-TkBindFree(mainPtr)
- TkMainInfo *mainPtr; /* The newly created application. */
-{
- BindInfo *bindInfoPtr;
-
- Tk_DeleteBindingTable(mainPtr->bindingTable);
- mainPtr->bindingTable = NULL;
-
- bindInfoPtr = (BindInfo *) mainPtr->bindInfo;
- DeleteVirtualEventTable(&bindInfoPtr->virtualEventTable);
- mainPtr->bindInfo = NULL;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_CreateBindingTable --
- *
- * Set up a new domain in which event bindings may be created.
- *
- * Results:
- * The return value is a token for the new table, which must
- * be passed to procedures like Tk_CreatBinding.
- *
- * Side effects:
- * Memory is allocated for the new table.
- *
- *--------------------------------------------------------------
- */
-
-Tk_BindingTable
-Tk_CreateBindingTable(interp)
- Tcl_Interp *interp; /* Interpreter to associate with the binding
- * table: commands are executed in this
- * interpreter. */
-{
- BindingTable *bindPtr;
- int i;
-
- /*
- * Create and initialize a new binding table.
- */
-
- bindPtr = (BindingTable *) ckalloc(sizeof(BindingTable));
- for (i = 0; i < EVENT_BUFFER_SIZE; i++) {
- bindPtr->eventRing[i].type = -1;
- }
- bindPtr->curEvent = 0;
- Tcl_InitHashTable(&bindPtr->patternTable,
- sizeof(PatternTableKey)/sizeof(int));
- Tcl_InitHashTable(&bindPtr->objectTable, TCL_ONE_WORD_KEYS);
- bindPtr->interp = interp;
- return (Tk_BindingTable) bindPtr;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_DeleteBindingTable --
- *
- * Destroy a binding table and free up all its memory.
- * The caller should not use bindingTable again after
- * this procedure returns.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Memory is freed.
- *
- *--------------------------------------------------------------
- */
-
-void
-Tk_DeleteBindingTable(bindingTable)
- Tk_BindingTable bindingTable; /* Token for the binding table to
- * destroy. */
-{
- BindingTable *bindPtr = (BindingTable *) bindingTable;
- PatSeq *psPtr, *nextPtr;
- Tcl_HashEntry *hPtr;
- Tcl_HashSearch search;
-
- /*
- * Find and delete all of the patterns associated with the binding
- * table.
- */
-
- for (hPtr = Tcl_FirstHashEntry(&bindPtr->patternTable, &search);
- hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
- for (psPtr = (PatSeq *) Tcl_GetHashValue(hPtr);
- psPtr != NULL; psPtr = nextPtr) {
- nextPtr = psPtr->nextSeqPtr;
- psPtr->flags |= MARKED_DELETED;
- if (psPtr->refCount == 0) {
- if (psPtr->freeProc != NULL) {
- (*psPtr->freeProc)(psPtr->clientData);
- }
- ckfree((char *) psPtr);
- }
- }
- }
-
- /*
- * Clean up the rest of the information associated with the
- * binding table.
- */
-
- Tcl_DeleteHashTable(&bindPtr->patternTable);
- Tcl_DeleteHashTable(&bindPtr->objectTable);
- ckfree((char *) bindPtr);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_CreateBinding --
- *
- * Add a binding to a binding table, so that future calls to
- * Tk_BindEvent may execute the command in the binding.
- *
- * Results:
- * The return value is 0 if an error occurred while setting
- * up the binding. In this case, an error message will be
- * left in interp->result. If all went well then the return
- * value is a mask of the event types that must be made
- * available to Tk_BindEvent in order to properly detect when
- * this binding triggers. This value can be used to determine
- * what events to select for in a window, for example.
- *
- * Side effects:
- * An existing binding on the same event sequence may be
- * replaced.
- * The new binding may cause future calls to Tk_BindEvent to
- * behave differently than they did previously.
- *
- *--------------------------------------------------------------
- */
-
-unsigned long
-Tk_CreateBinding(interp, bindingTable, object, eventString, command, append)
- Tcl_Interp *interp; /* Used for error reporting. */
- Tk_BindingTable bindingTable;
- /* Table in which to create binding. */
- ClientData object; /* Token for object with which binding is
- * associated. */
- char *eventString; /* String describing event sequence that
- * triggers binding. */
- 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
- * binding. If the existing binding is for a
- * callback function and not a Tcl command
- * string, the existing binding will always be
- * replaced. */
-{
- BindingTable *bindPtr = (BindingTable *) bindingTable;
- PatSeq *psPtr;
- unsigned long eventMask;
- char *new, *old;
-
- psPtr = FindSequence(interp, &bindPtr->patternTable, object, eventString,
- 1, 1, &eventMask);
- if (psPtr == NULL) {
- return 0;
- }
- if (psPtr->eventProc == NULL) {
- int new;
- Tcl_HashEntry *hPtr;
-
- /*
- * This pattern sequence was just created.
- * Link the pattern into the list associated with the object, so
- * that if the object goes away, these bindings will all
- * automatically be deleted.
- */
-
- hPtr = Tcl_CreateHashEntry(&bindPtr->objectTable, (char *) object,
- &new);
- if (new) {
- psPtr->nextObjPtr = NULL;
- } else {
- psPtr->nextObjPtr = (PatSeq *) Tcl_GetHashValue(hPtr);
- }
- Tcl_SetHashValue(hPtr, psPtr);
- } else if (psPtr->eventProc != EvalTclBinding) {
- /*
- * Free existing procedural binding.
- */
-
- if (psPtr->freeProc != NULL) {
- (*psPtr->freeProc)(psPtr->clientData);
- }
- psPtr->clientData = NULL;
- append = 0;
- }
-
- old = (char *) psPtr->clientData;
- if ((append != 0) && (old != NULL)) {
- int length;
-
- length = strlen(old) + strlen(command) + 2;
- new = (char *) ckalloc((unsigned) length);
- sprintf(new, "%s\n%s", old, command);
- } else {
- new = (char *) ckalloc((unsigned) strlen(command) + 1);
- strcpy(new, command);
- }
- if (old != NULL) {
- ckfree(old);
- }
- psPtr->eventProc = EvalTclBinding;
- psPtr->freeProc = FreeTclBinding;
- psPtr->clientData = (ClientData) new;
- return eventMask;
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * TkCreateBindingProcedure --
- *
- * Add a C binding to a binding table, so that future calls to
- * Tk_BindEvent may callback the procedure in the binding.
- *
- * Results:
- * The return value is 0 if an error occurred while setting
- * up the binding. In this case, an error message will be
- * left in interp->result. If all went well then the return
- * value is a mask of the event types that must be made
- * available to Tk_BindEvent in order to properly detect when
- * this binding triggers. This value can be used to determine
- * what events to select for in a window, for example.
- *
- * Side effects:
- * Any existing binding on the same event sequence will be
- * replaced.
- *
- *---------------------------------------------------------------------------
- */
-
-unsigned long
-TkCreateBindingProcedure(interp, bindingTable, object, eventString,
- eventProc, freeProc, clientData)
- Tcl_Interp *interp; /* Used for error reporting. */
- Tk_BindingTable bindingTable;
- /* Table in which to create binding. */
- ClientData object; /* Token for object with which binding is
- * associated. */
- char *eventString; /* String describing event sequence that
- * triggers binding. */
- TkBindEvalProc *eventProc; /* Procedure to invoke when binding
- * triggers. Must not be NULL. */
- TkBindFreeProc *freeProc; /* Procedure to invoke when binding is
- * freed. May be NULL for no procedure. */
- ClientData clientData; /* Arbitrary ClientData to pass to eventProc
- * and freeProc. */
-{
- BindingTable *bindPtr = (BindingTable *) bindingTable;
- PatSeq *psPtr;
- unsigned long eventMask;
-
- psPtr = FindSequence(interp, &bindPtr->patternTable, object, eventString,
- 1, 1, &eventMask);
- if (psPtr == NULL) {
- return 0;
- }
- if (psPtr->eventProc == NULL) {
- int new;
- Tcl_HashEntry *hPtr;
-
- /*
- * This pattern sequence was just created.
- * Link the pattern into the list associated with the object, so
- * that if the object goes away, these bindings will all
- * automatically be deleted.
- */
-
- hPtr = Tcl_CreateHashEntry(&bindPtr->objectTable, (char *) object,
- &new);
- if (new) {
- psPtr->nextObjPtr = NULL;
- } else {
- psPtr->nextObjPtr = (PatSeq *) Tcl_GetHashValue(hPtr);
- }
- Tcl_SetHashValue(hPtr, psPtr);
- } else {
-
- /*
- * Free existing callback.
- */
-
- if (psPtr->freeProc != NULL) {
- (*psPtr->freeProc)(psPtr->clientData);
- }
- }
-
- psPtr->eventProc = eventProc;
- psPtr->freeProc = freeProc;
- psPtr->clientData = clientData;
- return eventMask;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_DeleteBinding --
- *
- * Remove an event binding from a binding table.
- *
- * Results:
- * The result is a standard Tcl return value. If an error
- * occurs then interp->result will contain an error message.
- *
- * Side effects:
- * The binding given by object and eventString is removed
- * from bindingTable.
- *
- *--------------------------------------------------------------
- */
-
-int
-Tk_DeleteBinding(interp, bindingTable, object, eventString)
- Tcl_Interp *interp; /* Used for error reporting. */
- 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
- * that triggers binding. */
-{
- BindingTable *bindPtr = (BindingTable *) bindingTable;
- PatSeq *psPtr, *prevPtr;
- unsigned long eventMask;
- Tcl_HashEntry *hPtr;
-
- psPtr = FindSequence(interp, &bindPtr->patternTable, object, eventString,
- 0, 1, &eventMask);
- if (psPtr == NULL) {
- Tcl_ResetResult(interp);
- return TCL_OK;
- }
-
- /*
- * Unlink the binding from the list for its object, then from the
- * list for its pattern.
- */
-
- hPtr = Tcl_FindHashEntry(&bindPtr->objectTable, (char *) object);
- if (hPtr == NULL) {
- panic("Tk_DeleteBinding couldn't find object table entry");
- }
- prevPtr = (PatSeq *) Tcl_GetHashValue(hPtr);
- if (prevPtr == psPtr) {
- Tcl_SetHashValue(hPtr, psPtr->nextObjPtr);
- } else {
- for ( ; ; prevPtr = prevPtr->nextObjPtr) {
- if (prevPtr == NULL) {
- panic("Tk_DeleteBinding couldn't find on object list");
- }
- if (prevPtr->nextObjPtr == psPtr) {
- prevPtr->nextObjPtr = psPtr->nextObjPtr;
- break;
- }
- }
- }
- prevPtr = (PatSeq *) Tcl_GetHashValue(psPtr->hPtr);
- if (prevPtr == psPtr) {
- if (psPtr->nextSeqPtr == NULL) {
- Tcl_DeleteHashEntry(psPtr->hPtr);
- } else {
- Tcl_SetHashValue(psPtr->hPtr, psPtr->nextSeqPtr);
- }
- } else {
- for ( ; ; prevPtr = prevPtr->nextSeqPtr) {
- if (prevPtr == NULL) {
- panic("Tk_DeleteBinding couldn't find on hash chain");
- }
- if (prevPtr->nextSeqPtr == psPtr) {
- prevPtr->nextSeqPtr = psPtr->nextSeqPtr;
- break;
- }
- }
- }
-
- psPtr->flags |= MARKED_DELETED;
- if (psPtr->refCount == 0) {
- if (psPtr->freeProc != NULL) {
- (*psPtr->freeProc)(psPtr->clientData);
- }
- ckfree((char *) psPtr);
- }
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_GetBinding --
- *
- * Return the command associated with a given event string.
- *
- * Results:
- * The return value is a pointer to the command string
- * associated with eventString for object in the domain
- * given by bindingTable. If there is no binding for
- * eventString, or if eventString is improperly formed,
- * then NULL is returned and an error message is left in
- * interp->result. The return value is semi-static: it
- * will persist until the binding is changed or deleted.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-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
- * that triggers binding. */
-{
- BindingTable *bindPtr = (BindingTable *) bindingTable;
- PatSeq *psPtr;
- unsigned long eventMask;
-
- psPtr = FindSequence(interp, &bindPtr->patternTable, object, eventString,
- 0, 1, &eventMask);
- if (psPtr == NULL) {
- return NULL;
- }
- if (psPtr->eventProc == EvalTclBinding) {
- return (char *) psPtr->clientData;
- }
- return "";
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_GetAllBindings --
- *
- * Return a list of event strings for all the bindings
- * associated with a given object.
- *
- * Results:
- * There is no return value. Interp->result is modified to
- * hold a Tcl list with one entry for each binding associated
- * with object in bindingTable. Each entry in the list
- * contains the event string associated with one binding.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-void
-Tk_GetAllBindings(interp, bindingTable, object)
- Tcl_Interp *interp; /* Interpreter returning result or
- * error. */
- Tk_BindingTable bindingTable; /* Table in which to look for
- * bindings. */
- ClientData object; /* Token for object. */
-
-{
- BindingTable *bindPtr = (BindingTable *) bindingTable;
- PatSeq *psPtr;
- Tcl_HashEntry *hPtr;
- Tcl_DString ds;
-
- hPtr = Tcl_FindHashEntry(&bindPtr->objectTable, (char *) object);
- if (hPtr == NULL) {
- return;
- }
- Tcl_DStringInit(&ds);
- for (psPtr = (PatSeq *) Tcl_GetHashValue(hPtr); psPtr != NULL;
- psPtr = psPtr->nextObjPtr) {
- /*
- * For each binding, output information about each of the
- * patterns in its sequence.
- */
-
- Tcl_DStringSetLength(&ds, 0);
- GetPatternString(psPtr, &ds);
- Tcl_AppendElement(interp, Tcl_DStringValue(&ds));
- }
- Tcl_DStringFree(&ds);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_DeleteAllBindings --
- *
- * Remove all bindings associated with a given object in a
- * given binding table.
- *
- * Results:
- * All bindings associated with object are removed from
- * bindingTable.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-void
-Tk_DeleteAllBindings(bindingTable, object)
- Tk_BindingTable bindingTable; /* Table in which to delete
- * bindings. */
- ClientData object; /* Token for object. */
-{
- BindingTable *bindPtr = (BindingTable *) bindingTable;
- PatSeq *psPtr, *prevPtr;
- PatSeq *nextPtr;
- Tcl_HashEntry *hPtr;
-
- hPtr = Tcl_FindHashEntry(&bindPtr->objectTable, (char *) object);
- if (hPtr == NULL) {
- return;
- }
- for (psPtr = (PatSeq *) Tcl_GetHashValue(hPtr); psPtr != NULL;
- psPtr = nextPtr) {
- nextPtr = psPtr->nextObjPtr;
-
- /*
- * Be sure to remove each binding from its hash chain in the
- * pattern table. If this is the last pattern in the chain,
- * then delete the hash entry too.
- */
-
- prevPtr = (PatSeq *) Tcl_GetHashValue(psPtr->hPtr);
- if (prevPtr == psPtr) {
- if (psPtr->nextSeqPtr == NULL) {
- Tcl_DeleteHashEntry(psPtr->hPtr);
- } else {
- Tcl_SetHashValue(psPtr->hPtr, psPtr->nextSeqPtr);
- }
- } else {
- for ( ; ; prevPtr = prevPtr->nextSeqPtr) {
- if (prevPtr == NULL) {
- panic("Tk_DeleteAllBindings couldn't find on hash chain");
- }
- if (prevPtr->nextSeqPtr == psPtr) {
- prevPtr->nextSeqPtr = psPtr->nextSeqPtr;
- break;
- }
- }
- }
- psPtr->flags |= MARKED_DELETED;
-
- if (psPtr->refCount == 0) {
- if (psPtr->freeProc != NULL) {
- (*psPtr->freeProc)(psPtr->clientData);
- }
- ckfree((char *) psPtr);
- }
- }
- Tcl_DeleteHashEntry(hPtr);
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * Tk_BindEvent --
- *
- * This procedure is invoked to process an X event. The
- * event is added to those recorded for the binding table.
- * Then each of the objects at *objectPtr is checked in
- * order to see if it has a binding that matches the recent
- * events. If so, the most specific binding is invoked for
- * each object.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Depends on the command associated with the matching binding.
- *
- * All Tcl bindings scripts for each object are accumulated before
- * the first binding is evaluated. If the action of a Tcl binding
- * is to change or delete a binding, or delete the window associated
- * with the binding, all the original Tcl binding scripts will still
- * fire. Contrast this with C binding procedures. If a pending C
- * binding (one that hasn't fired yet, but is queued to be fired for
- * this window) is deleted, it will not be called, and if it is
- * changed, then the new binding procedure will be called. If the
- * window itself is deleted, no further C binding procedures will be
- * called for this window. When both Tcl binding scripts and C binding
- * procedures are interleaved, the above rules still apply.
- *
- *---------------------------------------------------------------------------
- */
-
-void
-Tk_BindEvent(bindingTable, eventPtr, tkwin, numObjects, objectPtr)
- Tk_BindingTable bindingTable; /* Table in which to look for
- * bindings. */
- XEvent *eventPtr; /* What actually happened. */
- Tk_Window tkwin; /* Window on display where event
- * occurred (needed in order to
- * locate display information). */
- int numObjects; /* Number of objects at *objectPtr. */
- ClientData *objectPtr; /* Array of one or more objects
- * to check for a matching binding. */
-{
- BindingTable *bindPtr;
- TkDisplay *dispPtr;
- BindInfo *bindInfoPtr;
- TkDisplay *oldDispPtr;
- ScreenInfo *screenPtr;
- XEvent *ringPtr;
- PatSeq *vMatchDetailList, *vMatchNoDetailList;
- int flags, oldScreen, i, deferModal;
- unsigned int matchCount, matchSpace;
- Tcl_Interp *interp;
- Tcl_DString scripts, savedResult;
- Detail detail;
- char *p, *end;
- PendingBinding *pendingPtr;
- PendingBinding staticPending;
- TkWindow *winPtr = (TkWindow *)tkwin;
- PatternTableKey key;
-
- /*
- * Ignore events on windows that don't have names: these are windows
- * like wrapper windows that shouldn't be visible to the
- * application.
- */
-
- if (winPtr->pathName == NULL) {
- return;
- }
-
- /*
- * Ignore the event completely if it is an Enter, Leave, FocusIn,
- * or FocusOut event with detail NotifyInferior. The reason for
- * ignoring these events is that we don't want transitions between
- * a window and its children to visible to bindings on the parent:
- * this would cause problems for mega-widgets, since the internal
- * structure of a mega-widget isn't supposed to be visible to
- * people watching the parent.
- */
-
- if ((eventPtr->type == EnterNotify) || (eventPtr->type == LeaveNotify)) {
- if (eventPtr->xcrossing.detail == NotifyInferior) {
- return;
- }
- }
- if ((eventPtr->type == FocusIn) || (eventPtr->type == FocusOut)) {
- if (eventPtr->xfocus.detail == NotifyInferior) {
- return;
- }
- }
-
- bindPtr = (BindingTable *) bindingTable;
- dispPtr = ((TkWindow *) tkwin)->dispPtr;
- bindInfoPtr = (BindInfo *) winPtr->mainPtr->bindInfo;
-
- /*
- * Add the new event to the ring of saved events for the
- * binding table. Two tricky points:
- *
- * 1. Combine consecutive MotionNotify events. Do this by putting
- * the new event *on top* of the previous event.
- * 2. If a modifier key is held down, it auto-repeats to generate
- * continuous KeyPress and KeyRelease events. These can flush
- * the event ring so that valuable information is lost (such
- * as repeated button clicks). To handle this, check for the
- * special case of a modifier KeyPress arriving when the previous
- * two events are a KeyRelease and KeyPress of the same key.
- * If this happens, mark the most recent event (the KeyRelease)
- * invalid and put the new event on top of the event before that
- * (the KeyPress).
- */
-
- if ((eventPtr->type == MotionNotify)
- && (bindPtr->eventRing[bindPtr->curEvent].type == MotionNotify)) {
- /*
- * Don't advance the ring pointer.
- */
- } else if (eventPtr->type == KeyPress) {
- int i;
- for (i = 0; ; i++) {
- if (i >= dispPtr->numModKeyCodes) {
- goto advanceRingPointer;
- }
- if (dispPtr->modKeyCodes[i] == eventPtr->xkey.keycode) {
- break;
- }
- }
- ringPtr = &bindPtr->eventRing[bindPtr->curEvent];
- if ((ringPtr->type != KeyRelease)
- || (ringPtr->xkey.keycode != eventPtr->xkey.keycode)) {
- goto advanceRingPointer;
- }
- if (bindPtr->curEvent <= 0) {
- i = EVENT_BUFFER_SIZE - 1;
- } else {
- i = bindPtr->curEvent - 1;
- }
- ringPtr = &bindPtr->eventRing[i];
- if ((ringPtr->type != KeyPress)
- || (ringPtr->xkey.keycode != eventPtr->xkey.keycode)) {
- goto advanceRingPointer;
- }
- bindPtr->eventRing[bindPtr->curEvent].type = -1;
- bindPtr->curEvent = i;
- } else {
- advanceRingPointer:
- bindPtr->curEvent++;
- if (bindPtr->curEvent >= EVENT_BUFFER_SIZE) {
- bindPtr->curEvent = 0;
- }
- }
- ringPtr = &bindPtr->eventRing[bindPtr->curEvent];
- memcpy((VOID *) ringPtr, (VOID *) eventPtr, sizeof(XEvent));
- detail.clientData = 0;
- flags = flagArray[ringPtr->type];
- if (flags & KEY) {
- detail.keySym = GetKeySym(dispPtr, ringPtr);
- if (detail.keySym == NoSymbol) {
- detail.keySym = 0;
- }
- } else if (flags & BUTTON) {
- detail.button = ringPtr->xbutton.button;
- } else if (flags & VIRTUAL) {
- detail.name = ((XVirtualEvent *) ringPtr)->name;
- }
- bindPtr->detailRing[bindPtr->curEvent] = detail;
-
- /*
- * Find out if there are any virtual events that correspond to this
- * physical event (or sequence of physical events).
- */
-
- vMatchDetailList = NULL;
- vMatchNoDetailList = NULL;
- memset(&key, 0, sizeof(key));
-
- if (ringPtr->type != VirtualEvent) {
- Tcl_HashTable *veptPtr;
- Tcl_HashEntry *hPtr;
-
- veptPtr = &bindInfoPtr->virtualEventTable.patternTable;
-
- key.object = NULL;
- key.type = ringPtr->type;
- key.detail = detail;
-
- hPtr = Tcl_FindHashEntry(veptPtr, (char *) &key);
- if (hPtr != NULL) {
- vMatchDetailList = (PatSeq *) Tcl_GetHashValue(hPtr);
- }
-
- if (key.detail.clientData != 0) {
- key.detail.clientData = 0;
- hPtr = Tcl_FindHashEntry(veptPtr, (char *) &key);
- if (hPtr != NULL) {
- vMatchNoDetailList = (PatSeq *) Tcl_GetHashValue(hPtr);
- }
- }
- }
-
- /*
- * Loop over all the binding tags, finding the binding script or
- * callback for each one. Append all of the binding scripts, with
- * %-sequences expanded, to "scripts", with null characters separating
- * the scripts for each object. Append all the callbacks to the array
- * of pending callbacks.
- */
-
- pendingPtr = &staticPending;
- matchCount = 0;
- matchSpace = sizeof(staticPending.matchArray) / sizeof(PatSeq *);
- Tcl_DStringInit(&scripts);
-
- for ( ; numObjects > 0; numObjects--, objectPtr++) {
- PatSeq *matchPtr, *sourcePtr;
- Tcl_HashEntry *hPtr;
-
- matchPtr = NULL;
- sourcePtr = NULL;
-
- /*
- * Match the new event against those recorded in the pattern table,
- * saving the longest matching pattern. For events with details
- * (button and key events), look for a binding for the specific
- * key or button. First see if the event matches a physical event
- * that the object is interested in, then look for a virtual event.
- */
-
- key.object = *objectPtr;
- key.type = ringPtr->type;
- key.detail = detail;
- hPtr = Tcl_FindHashEntry(&bindPtr->patternTable, (char *) &key);
- if (hPtr != NULL) {
- matchPtr = MatchPatterns(dispPtr, bindPtr,
- (PatSeq *) Tcl_GetHashValue(hPtr), matchPtr, NULL,
- &sourcePtr);
- }
-
- if (vMatchDetailList != NULL) {
- matchPtr = MatchPatterns(dispPtr, bindPtr, vMatchDetailList,
- matchPtr, objectPtr, &sourcePtr);
- }
-
- /*
- * If no match was found, look for a binding for all keys or buttons
- * (detail of 0). Again, first match on a virtual event.
- */
-
- if ((detail.clientData != 0) && (matchPtr == NULL)) {
- key.detail.clientData = 0;
- hPtr = Tcl_FindHashEntry(&bindPtr->patternTable, (char *) &key);
- if (hPtr != NULL) {
- matchPtr = MatchPatterns(dispPtr, bindPtr,
- (PatSeq *) Tcl_GetHashValue(hPtr), matchPtr, NULL,
- &sourcePtr);
- }
-
- if (vMatchNoDetailList != NULL) {
- matchPtr = MatchPatterns(dispPtr, bindPtr, vMatchNoDetailList,
- matchPtr, objectPtr, &sourcePtr);
- }
-
- }
-
- if (matchPtr != NULL) {
- if (sourcePtr->eventProc == NULL) {
- panic("Tk_BindEvent: missing command");
- }
- if (sourcePtr->eventProc == EvalTclBinding) {
- ExpandPercents(winPtr, (char *) sourcePtr->clientData,
- eventPtr, detail.keySym, &scripts);
- } else {
- if (matchCount >= matchSpace) {
- PendingBinding *new;
- unsigned int oldSize, newSize;
-
- oldSize = sizeof(staticPending)
- - sizeof(staticPending.matchArray)
- + matchSpace * sizeof(PatSeq*);
- matchSpace *= 2;
- newSize = sizeof(staticPending)
- - sizeof(staticPending.matchArray)
- + matchSpace * sizeof(PatSeq*);
- new = (PendingBinding *) ckalloc(newSize);
- memcpy((VOID *) new, (VOID *) pendingPtr, oldSize);
- if (pendingPtr != &staticPending) {
- ckfree((char *) pendingPtr);
- }
- pendingPtr = new;
- }
- sourcePtr->refCount++;
- pendingPtr->matchArray[matchCount] = sourcePtr;
- matchCount++;
- }
- /*
- * A "" is added to the scripts string to separate the
- * various scripts that should be invoked.
- */
-
- Tcl_DStringAppend(&scripts, "", 1);
- }
- }
- if (Tcl_DStringLength(&scripts) == 0) {
- return;
- }
-
- /*
- * Now go back through and evaluate the binding for each object,
- * in order, dealing with "break" and "continue" exceptions
- * appropriately.
- *
- * There are two tricks here:
- * 1. Bindings can be invoked from in the middle of Tcl commands,
- * where interp->result is significant (for example, a widget
- * might be deleted because of an error in creating it, so the
- * result contains an error message that is eventually going to
- * be returned by the creating command). To preserve the result,
- * we save it in a dynamic string.
- * 2. The binding's action can potentially delete the binding,
- * so bindPtr may not point to anything valid once the action
- * completes. Thus we have to save bindPtr->interp in a
- * local variable in order to restore the result.
- */
-
- interp = bindPtr->interp;
- Tcl_DStringInit(&savedResult);
-
- /*
- * Save information about the current screen, then invoke a script
- * if the screen has changed.
- */
-
- Tcl_DStringGetResult(interp, &savedResult);
- screenPtr = &bindInfoPtr->screenInfo;
- oldDispPtr = screenPtr->curDispPtr;
- oldScreen = screenPtr->curScreenIndex;
- if ((dispPtr != screenPtr->curDispPtr)
- || (Tk_ScreenNumber(tkwin) != screenPtr->curScreenIndex)) {
- screenPtr->curDispPtr = dispPtr;
- screenPtr->curScreenIndex = Tk_ScreenNumber(tkwin);
- ChangeScreen(interp, dispPtr->name, screenPtr->curScreenIndex);
- }
-
- if (matchCount > 0) {
- pendingPtr->nextPtr = bindInfoPtr->pendingList;
- pendingPtr->tkwin = tkwin;
- pendingPtr->deleted = 0;
- bindInfoPtr->pendingList = pendingPtr;
- }
-
- /*
- * Save the current value of the TK_DEFER_MODAL flag so we can
- * restore it at the end of the loop. Clear the flag so we can
- * detect any recursive requests for a modal loop.
- */
-
- flags = winPtr->flags;
- winPtr->flags &= ~TK_DEFER_MODAL;
-
- p = Tcl_DStringValue(&scripts);
- end = p + Tcl_DStringLength(&scripts);
- i = 0;
-
- while (p < end) {
- int code;
-
- screenPtr->bindingDepth++;
- Tcl_AllowExceptions(interp);
-
- if (*p == '\0') {
- PatSeq *psPtr;
-
- psPtr = pendingPtr->matchArray[i];
- i++;
- code = TCL_OK;
- if ((pendingPtr->deleted == 0)
- && ((psPtr->flags & MARKED_DELETED) == 0)) {
- code = (*psPtr->eventProc)(psPtr->clientData, interp, eventPtr,
- tkwin, detail.keySym);
- }
- psPtr->refCount--;
- if ((psPtr->refCount == 0) && (psPtr->flags & MARKED_DELETED)) {
- if (psPtr->freeProc != NULL) {
- (*psPtr->freeProc)(psPtr->clientData);
- }
- ckfree((char *) psPtr);
- }
- } else {
- code = Tcl_GlobalEval(interp, p);
- p += strlen(p);
- }
- p++;
- screenPtr->bindingDepth--;
- if (code != TCL_OK) {
- if (code == TCL_CONTINUE) {
- /*
- * Do nothing: just go on to the next command.
- */
- } else if (code == TCL_BREAK) {
- break;
- } else {
- Tcl_AddErrorInfo(interp, "\n (command bound to event)");
- Tcl_BackgroundError(interp);
- break;
- }
- }
- }
-
- if (matchCount > 0 && !pendingPtr->deleted) {
- /*
- * Restore the original modal flag value and invoke the modal loop
- * if needed.
- */
-
- deferModal = winPtr->flags & TK_DEFER_MODAL;
- winPtr->flags = (winPtr->flags & (unsigned int) ~TK_DEFER_MODAL)
- | (flags & TK_DEFER_MODAL);
- if (deferModal) {
- (*winPtr->classProcsPtr->modalProc)(tkwin, eventPtr);
- }
- }
-
- if ((screenPtr->bindingDepth != 0) &&
- ((oldDispPtr != screenPtr->curDispPtr)
- || (oldScreen != screenPtr->curScreenIndex))) {
-
- /*
- * Some other binding script is currently executing, but its
- * screen is no longer current. Change the current display
- * back again.
- */
-
- screenPtr->curDispPtr = oldDispPtr;
- screenPtr->curScreenIndex = oldScreen;
- ChangeScreen(interp, oldDispPtr->name, oldScreen);
- }
- Tcl_DStringResult(interp, &savedResult);
- Tcl_DStringFree(&scripts);
-
- if (matchCount > 0) {
- PendingBinding **curPtrPtr;
-
- for (curPtrPtr = &bindInfoPtr->pendingList; ; ) {
- if (*curPtrPtr == pendingPtr) {
- *curPtrPtr = pendingPtr->nextPtr;
- break;
- }
- curPtrPtr = &(*curPtrPtr)->nextPtr;
- }
- if (pendingPtr != &staticPending) {
- ckfree((char *) pendingPtr);
- }
- }
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * TkBindDeadWindow --
- *
- * This procedure is invoked when it is determined that a window is
- * dead. It cleans up bind-related information about the window
- *
- * Results:
- * None.
- *
- * Side effects:
- * Any pending C bindings for this window are cancelled.
- *
- *---------------------------------------------------------------------------
- */
-
-void
-TkBindDeadWindow(winPtr)
- TkWindow *winPtr; /* The window that is being deleted. */
-{
- BindInfo *bindInfoPtr;
- PendingBinding *curPtr;
-
- bindInfoPtr = (BindInfo *) winPtr->mainPtr->bindInfo;
- curPtr = bindInfoPtr->pendingList;
- while (curPtr != NULL) {
- if (curPtr->tkwin == (Tk_Window) winPtr) {
- curPtr->deleted = 1;
- }
- curPtr = curPtr->nextPtr;
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * MatchPatterns --
- *
- * Given a list of pattern sequences and a list of recent events,
- * return the pattern sequence that best matches the event list,
- * if there is one.
- *
- * This procedure is used in two different ways. In the simplest
- * use, "object" is NULL and psPtr is a list of pattern sequences,
- * each of which corresponds to a binding. In this case, the
- * procedure finds the pattern sequences that match the event list
- * and returns the most specific of those, if there is more than one.
- *
- * In the second case, psPtr is a list of pattern sequences, each
- * of which corresponds to a definition for a virtual binding.
- * In order for one of these sequences to "match", it must match
- * the events (as above) but in addition there must be a binding
- * for its associated virtual event on the current object. The
- * "object" argument indicates which object the binding must be for.
- *
- * Results:
- * The return value is NULL if bestPtr is NULL and no pattern matches
- * the recent events from bindPtr. Otherwise the return value is
- * the most specific pattern sequence among bestPtr and all those
- * at psPtr that match the event list and object. If a pattern
- * sequence other than bestPtr is returned, then *bestCommandPtr
- * is filled in with a pointer to the command from the best sequence.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-static PatSeq *
-MatchPatterns(dispPtr, bindPtr, psPtr, bestPtr, objectPtr, sourcePtrPtr)
- TkDisplay *dispPtr; /* Display from which the event came. */
- BindingTable *bindPtr; /* Information about binding table, such as
- * ring of recent events. */
- PatSeq *psPtr; /* List of pattern sequences. */
- PatSeq *bestPtr; /* The best match seen so far, from a
- * previous call to this procedure. NULL
- * means no prior best match. */
- ClientData *objectPtr; /* If NULL, the sequences at psPtr
- * correspond to "normal" bindings. If
- * non-NULL, the sequences at psPtr correspond
- * to virtual bindings; in order to match each
- * sequence must correspond to a virtual
- * binding for which a binding exists for
- * object in bindPtr. */
- PatSeq **sourcePtrPtr; /* Filled with the pattern sequence that
- * contains the eventProc and clientData
- * associated with the best match. If this
- * differs from the return value, it is the
- * virtual event that most closely matched the
- * return value (a physical event). Not
- * modified unless a result other than bestPtr
- * is returned. */
-{
- PatSeq *matchPtr, *bestSourcePtr, *sourcePtr;
-
- bestSourcePtr = *sourcePtrPtr;
-
- /*
- * Iterate over all the pattern sequences.
- */
-
- for ( ; psPtr != NULL; psPtr = psPtr->nextSeqPtr) {
- XEvent *eventPtr;
- Pattern *patPtr;
- Window window;
- Detail *detailPtr;
- int patCount, ringCount, flags, state;
- int modMask;
-
- /*
- * Iterate over all the patterns in a sequence to be
- * sure that they all match.
- */
-
- eventPtr = &bindPtr->eventRing[bindPtr->curEvent];
- detailPtr = &bindPtr->detailRing[bindPtr->curEvent];
- window = eventPtr->xany.window;
- patPtr = psPtr->pats;
- patCount = psPtr->numPats;
- ringCount = EVENT_BUFFER_SIZE;
- while (patCount > 0) {
- if (ringCount <= 0) {
- goto nextSequence;
- }
- if (eventPtr->xany.type != patPtr->eventType) {
- /*
- * Most of the event types are considered superfluous
- * in that they are ignored if they occur in the middle
- * of a pattern sequence and have mismatching types. The
- * only ones that cannot be ignored are ButtonPress and
- * ButtonRelease events (if the next event in the pattern
- * is a KeyPress or KeyRelease) and KeyPress and KeyRelease
- * events (if the next pattern event is a ButtonPress or
- * ButtonRelease). Here are some tricky cases to consider:
- * 1. Double-Button or Double-Key events.
- * 2. Double-ButtonRelease or Double-KeyRelease events.
- * 3. The arrival of various events like Enter and Leave
- * and FocusIn and GraphicsExpose between two button
- * presses or key presses.
- * 4. Modifier keys like Shift and Control shouldn't
- * generate conflicts with button events.
- */
-
- if ((patPtr->eventType == KeyPress)
- || (patPtr->eventType == KeyRelease)) {
- if ((eventPtr->xany.type == ButtonPress)
- || (eventPtr->xany.type == ButtonRelease)) {
- goto nextSequence;
- }
- } else if ((patPtr->eventType == ButtonPress)
- || (patPtr->eventType == ButtonRelease)) {
- if ((eventPtr->xany.type == KeyPress)
- || (eventPtr->xany.type == KeyRelease)) {
- int i;
-
- /*
- * Ignore key events if they are modifier keys.
- */
-
- for (i = 0; i < dispPtr->numModKeyCodes; i++) {
- if (dispPtr->modKeyCodes[i]
- == eventPtr->xkey.keycode) {
- /*
- * This key is a modifier key, so ignore it.
- */
- goto nextEvent;
- }
- }
- goto nextSequence;
- }
- }
- goto nextEvent;
- }
- if (eventPtr->xany.window != window) {
- goto nextSequence;
- }
-
- /*
- * Note: it's important for the keysym check to go before
- * the modifier check, so we can ignore unwanted modifier
- * keys before choking on the modifier check.
- */
-
- if ((patPtr->detail.clientData != 0)
- && (patPtr->detail.clientData != detailPtr->clientData)) {
- /*
- * The detail appears not to match. However, if the event
- * is a KeyPress for a modifier key then just ignore the
- * event. Otherwise event sequences like "aD" never match
- * because the shift key goes down between the "a" and the
- * "D".
- */
-
- if (eventPtr->xany.type == KeyPress) {
- int i;
-
- for (i = 0; i < dispPtr->numModKeyCodes; i++) {
- if (dispPtr->modKeyCodes[i] == eventPtr->xkey.keycode) {
- goto nextEvent;
- }
- }
- }
- goto nextSequence;
- }
- flags = flagArray[eventPtr->type];
- if (flags & (KEY_BUTTON_MOTION_VIRTUAL)) {
- state = eventPtr->xkey.state;
- } else if (flags & CROSSING) {
- state = eventPtr->xcrossing.state;
- } else {
- state = 0;
- }
- if (patPtr->needMods != 0) {
- modMask = patPtr->needMods;
- if ((modMask & META_MASK) && (dispPtr->metaModMask != 0)) {
- modMask = (modMask & ~META_MASK) | dispPtr->metaModMask;
- }
- if ((modMask & ALT_MASK) && (dispPtr->altModMask != 0)) {
- modMask = (modMask & ~ALT_MASK) | dispPtr->altModMask;
- }
- if ((state & modMask) != modMask) {
- goto nextSequence;
- }
- }
- if (psPtr->flags & PAT_NEARBY) {
- XEvent *firstPtr;
- int timeDiff;
-
- firstPtr = &bindPtr->eventRing[bindPtr->curEvent];
- timeDiff = (Time) firstPtr->xkey.time - eventPtr->xkey.time;
- if ((firstPtr->xkey.x_root
- < (eventPtr->xkey.x_root - NEARBY_PIXELS))
- || (firstPtr->xkey.x_root
- > (eventPtr->xkey.x_root + NEARBY_PIXELS))
- || (firstPtr->xkey.y_root
- < (eventPtr->xkey.y_root - NEARBY_PIXELS))
- || (firstPtr->xkey.y_root
- > (eventPtr->xkey.y_root + NEARBY_PIXELS))
- || (timeDiff > NEARBY_MS)) {
- goto nextSequence;
- }
- }
- patPtr++;
- patCount--;
- nextEvent:
- if (eventPtr == bindPtr->eventRing) {
- eventPtr = &bindPtr->eventRing[EVENT_BUFFER_SIZE-1];
- detailPtr = &bindPtr->detailRing[EVENT_BUFFER_SIZE-1];
- } else {
- eventPtr--;
- detailPtr--;
- }
- ringCount--;
- }
-
- matchPtr = psPtr;
- sourcePtr = psPtr;
-
- if (objectPtr != NULL) {
- int iVirt;
- VirtualOwners *voPtr;
- PatternTableKey key;
-
- /*
- * The sequence matches the physical constraints.
- * Is this object interested in any of the virtual events
- * that correspond to this sequence?
- */
-
- voPtr = psPtr->voPtr;
-
- memset(&key, 0, sizeof(key));
- key.object = *objectPtr;
- key.type = VirtualEvent;
- key.detail.clientData = 0;
-
- for (iVirt = 0; iVirt < voPtr->numOwners; iVirt++) {
- Tcl_HashEntry *hPtr = voPtr->owners[iVirt];
-
- key.detail.name = (Tk_Uid) Tcl_GetHashKey(hPtr->tablePtr,
- hPtr);
- hPtr = Tcl_FindHashEntry(&bindPtr->patternTable,
- (char *) &key);
- if (hPtr != NULL) {
-
- /*
- * This tag is interested in this virtual event and its
- * corresponding physical event is a good match with the
- * virtual event's definition.
- */
-
- PatSeq *virtMatchPtr;
-
- virtMatchPtr = (PatSeq *) Tcl_GetHashValue(hPtr);
- if ((virtMatchPtr->numPats != 1)
- || (virtMatchPtr->nextSeqPtr != NULL)) {
- panic("MatchPattern: badly constructed virtual event");
- }
- sourcePtr = virtMatchPtr;
- goto match;
- }
- }
-
- /*
- * The physical event matches a virtual event's definition, but
- * the tag isn't interested in it.
- */
- goto nextSequence;
- }
- match:
-
- /*
- * This sequence matches. If we've already got another match,
- * pick whichever is most specific. Detail is most important,
- * then needMods.
- */
-
- if (bestPtr != NULL) {
- Pattern *patPtr2;
- int i;
-
- if (matchPtr->numPats != bestPtr->numPats) {
- if (bestPtr->numPats > matchPtr->numPats) {
- goto nextSequence;
- } else {
- goto newBest;
- }
- }
- for (i = 0, patPtr = matchPtr->pats, patPtr2 = bestPtr->pats;
- i < matchPtr->numPats; i++, patPtr++, patPtr2++) {
- if (patPtr->detail.clientData != patPtr2->detail.clientData) {
- if (patPtr->detail.clientData == 0) {
- goto nextSequence;
- } else {
- goto newBest;
- }
- }
- if (patPtr->needMods != patPtr2->needMods) {
- if ((patPtr->needMods & patPtr2->needMods)
- == patPtr->needMods) {
- goto nextSequence;
- } else if ((patPtr->needMods & patPtr2->needMods)
- == patPtr2->needMods) {
- goto newBest;
- }
- }
- }
- /*
- * Tie goes to current best pattern.
- *
- * (1) For virtual vs. virtual, the least recently defined
- * virtual wins, because virtuals are examined in order of
- * definition. This order is _not_ guaranteed in the
- * documentation.
- *
- * (2) For virtual vs. physical, the physical wins because all
- * the physicals are examined before the virtuals. This order
- * is guaranteed in the documentation.
- *
- * (3) For physical vs. physical pattern, the most recently
- * defined physical wins, because physicals are examined in
- * reverse order of definition. This order is guaranteed in
- * the documentation.
- */
-
- goto nextSequence;
- }
- newBest:
- bestPtr = matchPtr;
- bestSourcePtr = sourcePtr;
-
- nextSequence: continue;
- }
-
- *sourcePtrPtr = bestSourcePtr;
- return bestPtr;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ExpandPercents --
- *
- * Given a command and an event, produce a new command
- * by replacing % constructs in the original command
- * with information from the X event.
- *
- * Results:
- * The new expanded command is appended to the dynamic string
- * given by dsPtr.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-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
- * to be replaced. */
- XEvent *eventPtr; /* X event containing information to be
- * used in % replacements. */
- KeySym keySym; /* KeySym: only relevant for KeyPress and
- * KeyRelease events). */
- Tcl_DString *dsPtr; /* Dynamic string in which to append new
- * command. */
-{
- int spaceNeeded, cvtFlags; /* Used to substitute string as proper Tcl
- * list element. */
- int number, flags, length;
-#define NUM_SIZE 40
- char *string;
- char numStorage[NUM_SIZE+1];
-
- if (eventPtr->type < TK_LASTEVENT) {
- flags = flagArray[eventPtr->type];
- } else {
- flags = 0;
- }
- while (1) {
- /*
- * Find everything up to the next % character and append it
- * to the result string.
- */
-
- for (string = before; (*string != 0) && (*string != '%'); string++) {
- /* Empty loop body. */
- }
- if (string != before) {
- Tcl_DStringAppend(dsPtr, before, string-before);
- before = string;
- }
- if (*before == 0) {
- break;
- }
-
- /*
- * There's a percent sequence here. Process it.
- */
-
- number = 0;
- string = "??";
- switch (before[1]) {
- case '#':
- number = eventPtr->xany.serial;
- goto doNumber;
- case 'a':
- TkpPrintWindowId(numStorage, eventPtr->xconfigure.above);
- string = numStorage;
- goto doString;
- case 'b':
- number = eventPtr->xbutton.button;
- goto doNumber;
- case 'c':
- if (flags & EXPOSE) {
- number = eventPtr->xexpose.count;
- }
- goto doNumber;
- case 'd':
- if (flags & (CROSSING|FOCUS)) {
- if (flags & FOCUS) {
- number = eventPtr->xfocus.detail;
- } else {
- number = eventPtr->xcrossing.detail;
- }
- string = TkFindStateString(notifyDetail, number);
- }
- goto doString;
- case 'f':
- number = eventPtr->xcrossing.focus;
- goto doNumber;
- case 'h':
- if (flags & EXPOSE) {
- number = eventPtr->xexpose.height;
- } else if (flags & (CONFIG)) {
- number = eventPtr->xconfigure.height;
- }
- goto doNumber;
- case 'k':
- number = eventPtr->xkey.keycode;
- goto doNumber;
- case 'm':
- if (flags & CROSSING) {
- number = eventPtr->xcrossing.mode;
- } else if (flags & FOCUS) {
- number = eventPtr->xfocus.mode;
- }
- string = TkFindStateString(notifyMode, number);
- goto doString;
- case 'o':
- if (flags & CREATE) {
- number = eventPtr->xcreatewindow.override_redirect;
- } else if (flags & MAP) {
- number = eventPtr->xmap.override_redirect;
- } else if (flags & REPARENT) {
- number = eventPtr->xreparent.override_redirect;
- } else if (flags & CONFIG) {
- number = eventPtr->xconfigure.override_redirect;
- }
- goto doNumber;
- case 'p':
- string = TkFindStateString(circPlace, eventPtr->xcirculate.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 & VISIBILITY) {
- string = TkFindStateString(visNotify,
- eventPtr->xvisibility.state);
- goto doString;
- }
- goto doNumber;
- case 't':
- if (flags & (KEY_BUTTON_MOTION_VIRTUAL)) {
- number = (int) eventPtr->xkey.time;
- } else if (flags & CROSSING) {
- number = (int) eventPtr->xcrossing.time;
- } else if (flags & PROP) {
- number = (int) eventPtr->xproperty.time;
- }
- goto doNumber;
- case 'v':
- number = eventPtr->xconfigurerequest.value_mask;
- goto doNumber;
- case 'w':
- if (flags & EXPOSE) {
- number = eventPtr->xexpose.width;
- } else if (flags & CONFIG) {
- number = eventPtr->xconfigure.width;
- }
- goto doNumber;
- case 'x':
- if (flags & (KEY_BUTTON_MOTION_VIRTUAL)) {
- number = eventPtr->xkey.x;
- } else if (flags & CROSSING) {
- number = eventPtr->xcrossing.x;
- } else if (flags & EXPOSE) {
- number = eventPtr->xexpose.x;
- } else if (flags & (CREATE|CONFIG|GRAVITY)) {
- number = eventPtr->xcreatewindow.x;
- } else if (flags & REPARENT) {
- number = eventPtr->xreparent.x;
- }
- goto doNumber;
- case 'y':
- if (flags & (KEY_BUTTON_MOTION_VIRTUAL)) {
- number = eventPtr->xkey.y;
- } else if (flags & EXPOSE) {
- number = eventPtr->xexpose.y;
- } else if (flags & (CREATE|CONFIG|GRAVITY)) {
- number = eventPtr->xcreatewindow.y;
- } else if (flags & REPARENT) {
- number = eventPtr->xreparent.y;
- } else if (flags & CROSSING) {
- number = eventPtr->xcrossing.y;
-
- }
- goto doNumber;
- case 'A':
- if (flags & KEY) {
- int numChars;
-
- /*
- * If we're using input methods and this is a keypress
- * event, invoke XmbTkFindStateString. Otherwise just use
- * the older XTkFindStateString.
- */
-
-#ifdef TK_USE_INPUT_METHODS
- Status status;
- if ((winPtr->inputContext != NULL)
- && (eventPtr->type == KeyPress)) {
- numChars = XmbLookupString(winPtr->inputContext,
- &eventPtr->xkey, numStorage, NUM_SIZE,
- (KeySym *) NULL, &status);
- if ((status != XLookupChars)
- && (status != XLookupBoth)) {
- numChars = 0;
- }
- } else {
- numChars = XLookupString(&eventPtr->xkey, numStorage,
- NUM_SIZE, (KeySym *) NULL,
- (XComposeStatus *) NULL);
- }
-#else /* TK_USE_INPUT_METHODS */
- numChars = XLookupString(&eventPtr->xkey, numStorage,
- NUM_SIZE, (KeySym *) NULL,
- (XComposeStatus *) NULL);
-#endif /* TK_USE_INPUT_METHODS */
- numStorage[numChars] = '\0';
- string = numStorage;
- }
- goto doString;
- case 'B':
- number = eventPtr->xcreatewindow.border_width;
- goto doNumber;
- case 'E':
- number = (int) eventPtr->xany.send_event;
- goto doNumber;
- case 'K':
- if (flags & KEY) {
- char *name;
-
- name = TkKeysymToString(keySym);
- if (name != NULL) {
- string = name;
- }
- }
- goto doString;
- case 'N':
- number = (int) keySym;
- goto doNumber;
- case 'R':
- TkpPrintWindowId(numStorage, eventPtr->xkey.root);
- string = numStorage;
- goto doString;
- case 'S':
- TkpPrintWindowId(numStorage, eventPtr->xkey.subwindow);
- string = numStorage;
- goto doString;
- case 'T':
- number = eventPtr->type;
- goto doNumber;
- case 'W': {
- Tk_Window tkwin;
-
- tkwin = Tk_IdToWindow(eventPtr->xany.display,
- eventPtr->xany.window);
- if (tkwin != NULL) {
- string = Tk_PathName(tkwin);
- } else {
- string = "??";
- }
- goto doString;
- }
- case 'X': {
- Tk_Window tkwin;
- int x, y;
- int width, height;
-
- number = eventPtr->xkey.x_root;
- tkwin = Tk_IdToWindow(eventPtr->xany.display,
- eventPtr->xany.window);
- if (tkwin != NULL) {
- Tk_GetVRootGeometry(tkwin, &x, &y, &width, &height);
- number -= x;
- }
- goto doNumber;
- }
- case 'Y': {
- Tk_Window tkwin;
- int x, y;
- int width, height;
-
- number = eventPtr->xkey.y_root;
- tkwin = Tk_IdToWindow(eventPtr->xany.display,
- eventPtr->xany.window);
- if (tkwin != NULL) {
- Tk_GetVRootGeometry(tkwin, &x, &y, &width, &height);
- number -= y;
- }
- goto doNumber;
- }
- default:
- numStorage[0] = before[1];
- numStorage[1] = '\0';
- string = numStorage;
- goto doString;
- }
-
- doNumber:
- sprintf(numStorage, "%d", number);
- string = numStorage;
-
- doString:
- spaceNeeded = Tcl_ScanElement(string, &cvtFlags);
- length = Tcl_DStringLength(dsPtr);
- Tcl_DStringSetLength(dsPtr, length + spaceNeeded);
- spaceNeeded = Tcl_ConvertElement(string,
- Tcl_DStringValue(dsPtr) + length,
- cvtFlags | TCL_DONT_USE_BRACES);
- Tcl_DStringSetLength(dsPtr, length + spaceNeeded);
- before += 2;
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ChangeScreen --
- *
- * 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
- * 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.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-ChangeScreen(interp, dispName, screenIndex)
- Tcl_Interp *interp; /* Interpreter in which to invoke
- * command. */
- char *dispName; /* Name of new display. */
- int screenIndex; /* Index of new screen. */
-{
- Tcl_DString cmd;
- int code;
- char screen[30];
-
- Tcl_DStringInit(&cmd);
- Tcl_DStringAppend(&cmd, "tkScreenChanged ", 16);
- Tcl_DStringAppend(&cmd, dispName, -1);
- sprintf(screen, ".%d", screenIndex);
- Tcl_DStringAppend(&cmd, screen, -1);
- code = Tcl_GlobalEval(interp, Tcl_DStringValue(&cmd));
- if (code != TCL_OK) {
- Tcl_AddErrorInfo(interp,
- "\n (changing screen in event binding)");
- Tcl_BackgroundError(interp);
- }
-}
-
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_EventCmd --
- *
- * This procedure is invoked to process the "event" Tcl command.
- * It is used to define and generate events.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
-
-int
-Tk_EventCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Main window associated with
- * interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- int i;
- size_t length;
- char *option;
- Tk_Window tkwin;
- VirtualEventTable *vetPtr;
- TkBindInfo bindInfo;
-
- if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " option ?arg1?\"", (char *) NULL);
- return TCL_ERROR;
- }
-
- option = argv[1];
- length = strlen(option);
- if (length == 0) {
- goto badopt;
- }
-
- tkwin = (Tk_Window) clientData;
- bindInfo = ((TkWindow *) tkwin)->mainPtr->bindInfo;
- vetPtr = &((BindInfo *) bindInfo)->virtualEventTable;
-
- if (strncmp(option, "add", length) == 0) {
- if (argc < 4) {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
- " add virtual sequence ?sequence ...?\"", (char *) NULL);
- return TCL_ERROR;
- }
- for (i = 3; i < argc; i++) {
- if (CreateVirtualEvent(interp, vetPtr, argv[2], argv[i])
- != TCL_OK) {
- return TCL_ERROR;
- }
- }
- } else if (strncmp(option, "delete", length) == 0) {
- if (argc < 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
- " delete virtual ?sequence sequence ...?\"",
- (char *) NULL);
- return TCL_ERROR;
- }
- if (argc == 3) {
- return DeleteVirtualEvent(interp, vetPtr, argv[2], NULL);
- }
- for (i = 3; i < argc; i++) {
- if (DeleteVirtualEvent(interp, vetPtr, argv[2], argv[i])
- != TCL_OK) {
- return TCL_ERROR;
- }
- }
- } else if (strncmp(option, "generate", length) == 0) {
- if (argc < 4) {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
- " generate window event ?options?\"", (char *) NULL);
- return TCL_ERROR;
- }
- return HandleEventGenerate(interp, tkwin, argc - 2, argv + 2);
- } else if (strncmp(option, "info", length) == 0) {
- if (argc == 2) {
- GetAllVirtualEvents(interp, vetPtr);
- return TCL_OK;
- } else if (argc == 3) {
- return GetVirtualEvent(interp, vetPtr, argv[2]);
- } else {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
- " info ?virtual?\"", (char *) NULL);
- return TCL_ERROR;
- }
- } else {
- badopt:
- Tcl_AppendResult(interp, "bad option \"", argv[1],
- "\": should be add, delete, generate, info", (char *) NULL);
- return TCL_ERROR;
- }
- return TCL_OK;
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * InitVirtualEventTable --
- *
- * Given storage for a virtual event table, set up the fields to
- * prepare a new domain in which virtual events may be defined.
- *
- * Results:
- * None.
- *
- * Side effects:
- * *vetPtr is now initialized.
- *
- *---------------------------------------------------------------------------
- */
-
-static void
-InitVirtualEventTable(vetPtr)
- VirtualEventTable *vetPtr; /* Pointer to virtual event table. Memory
- * is supplied by the caller. */
-{
- Tcl_InitHashTable(&vetPtr->patternTable,
- sizeof(PatternTableKey) / sizeof(int));
- Tcl_InitHashTable(&vetPtr->nameTable, TCL_ONE_WORD_KEYS);
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * DeleteVirtualEventTable --
- *
- * Delete the contents of a virtual event table. The caller is
- * responsible for freeing any memory used by the table itself.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Memory is freed.
- *
- *---------------------------------------------------------------------------
- */
-
-static void
-DeleteVirtualEventTable(vetPtr)
- VirtualEventTable *vetPtr; /* The virtual event table to delete. */
-{
- Tcl_HashEntry *hPtr;
- Tcl_HashSearch search;
- PatSeq *psPtr, *nextPtr;
-
- hPtr = Tcl_FirstHashEntry(&vetPtr->patternTable, &search);
- for ( ; hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
- psPtr = (PatSeq *) Tcl_GetHashValue(hPtr);
- for ( ; psPtr != NULL; psPtr = nextPtr) {
- nextPtr = psPtr->nextSeqPtr;
- ckfree((char *) psPtr->voPtr);
- ckfree((char *) psPtr);
- }
- }
- Tcl_DeleteHashTable(&vetPtr->patternTable);
-
- hPtr = Tcl_FirstHashEntry(&vetPtr->nameTable, &search);
- for ( ; hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
- ckfree((char *) Tcl_GetHashValue(hPtr));
- }
- Tcl_DeleteHashTable(&vetPtr->nameTable);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * CreateVirtualEvent --
- *
- * Add a new definition for a virtual event. If the virtual event
- * is already defined, the new definition augments those that
- * already exist.
- *
- * Results:
- * The return value is TCL_ERROR if an error occured while
- * creating the virtual binding. In this case, an error message
- * will be left in interp->result. If all went well then the return
- * value is TCL_OK.
- *
- * Side effects:
- * The virtual event may cause future calls to Tk_BindEvent to
- * behave differently than they did previously.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-CreateVirtualEvent(interp, vetPtr, virtString, eventString)
- Tcl_Interp *interp; /* Used for error reporting. */
- VirtualEventTable *vetPtr;/* Table in which to augment virtual event. */
- char *virtString; /* Name of new virtual event. */
- char *eventString; /* String describing physical event that
- * triggers virtual event. */
-{
- PatSeq *psPtr;
- int dummy;
- Tcl_HashEntry *vhPtr;
- unsigned long eventMask;
- PhysicalsOwned *poPtr;
- VirtualOwners *voPtr;
- Tk_Uid virtUid;
-
- virtUid = GetVirtualEventUid(interp, virtString);
- if (virtUid == NULL) {
- return TCL_ERROR;
- }
-
- /*
- * Find/create physical event
- */
-
- psPtr = FindSequence(interp, &vetPtr->patternTable, NULL, eventString,
- 1, 0, &eventMask);
- if (psPtr == NULL) {
- return TCL_ERROR;
- }
-
- /*
- * Find/create virtual event.
- */
-
- vhPtr = Tcl_CreateHashEntry(&vetPtr->nameTable, virtUid, &dummy);
-
- /*
- * Make virtual event own the physical event.
- */
-
- poPtr = (PhysicalsOwned *) Tcl_GetHashValue(vhPtr);
- if (poPtr == NULL) {
- poPtr = (PhysicalsOwned *) ckalloc(sizeof(PhysicalsOwned));
- poPtr->numOwned = 0;
- } else {
- /*
- * See if this virtual event is already defined for this physical
- * event and just return if it is.
- */
-
- int i;
- for (i = 0; i < poPtr->numOwned; i++) {
- if (poPtr->patSeqs[i] == psPtr) {
- return TCL_OK;
- }
- }
- poPtr = (PhysicalsOwned *) ckrealloc((char *) poPtr,
- sizeof(PhysicalsOwned) + poPtr->numOwned * sizeof(PatSeq *));
- }
- Tcl_SetHashValue(vhPtr, (ClientData) poPtr);
- poPtr->patSeqs[poPtr->numOwned] = psPtr;
- poPtr->numOwned++;
-
- /*
- * Make physical event so it can trigger the virtual event.
- */
-
- voPtr = psPtr->voPtr;
- if (voPtr == NULL) {
- voPtr = (VirtualOwners *) ckalloc(sizeof(VirtualOwners));
- voPtr->numOwners = 0;
- } else {
- voPtr = (VirtualOwners *) ckrealloc((char *) voPtr,
- sizeof(VirtualOwners)
- + voPtr->numOwners * sizeof(Tcl_HashEntry *));
- }
- psPtr->voPtr = voPtr;
- voPtr->owners[voPtr->numOwners] = vhPtr;
- voPtr->numOwners++;
-
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * DeleteVirtualEvent --
- *
- * Remove the definition of a given virtual event. If the
- * event string is NULL, all definitions of the virtual event
- * will be removed. Otherwise, just the specified definition
- * of the virtual event will be removed.
- *
- * Results:
- * The result is a standard Tcl return value. If an error
- * occurs then interp->result will contain an error message.
- * It is not an error to attempt to delete a virtual event that
- * does not exist or a definition that does not exist.
- *
- * Side effects:
- * The virtual event given by virtString may be removed from the
- * virtual event table.
- *
- *--------------------------------------------------------------
- */
-
-static int
-DeleteVirtualEvent(interp, vetPtr, virtString, eventString)
- Tcl_Interp *interp; /* Used for error reporting. */
- VirtualEventTable *vetPtr;/* Table in which to delete event. */
- char *virtString; /* String describing event sequence that
- * triggers binding. */
- char *eventString; /* The event sequence that should be deleted,
- * or NULL to delete all event sequences for
- * the entire virtual event. */
-{
- int iPhys;
- Tk_Uid virtUid;
- Tcl_HashEntry *vhPtr;
- PhysicalsOwned *poPtr;
- PatSeq *eventPSPtr;
-
- virtUid = GetVirtualEventUid(interp, virtString);
- if (virtUid == NULL) {
- return TCL_ERROR;
- }
-
- vhPtr = Tcl_FindHashEntry(&vetPtr->nameTable, virtUid);
- if (vhPtr == NULL) {
- return TCL_OK;
- }
- poPtr = (PhysicalsOwned *) Tcl_GetHashValue(vhPtr);
-
- eventPSPtr = NULL;
- if (eventString != NULL) {
- unsigned long eventMask;
-
- /*
- * Delete only the specific physical event associated with the
- * virtual event. If the physical event doesn't already exist, or
- * the virtual event doesn't own that physical event, return w/o
- * doing anything.
- */
-
- eventPSPtr = FindSequence(interp, &vetPtr->patternTable, NULL,
- eventString, 0, 0, &eventMask);
- if (eventPSPtr == NULL) {
- return (interp->result[0] != '\0') ? TCL_ERROR : TCL_OK;
- }
- }
-
- for (iPhys = poPtr->numOwned; --iPhys >= 0; ) {
- PatSeq *psPtr = poPtr->patSeqs[iPhys];
- if ((eventPSPtr == NULL) || (psPtr == eventPSPtr)) {
- int iVirt;
- VirtualOwners *voPtr;
-
- /*
- * Remove association between this physical event and the given
- * virtual event that it triggers.
- */
-
- voPtr = psPtr->voPtr;
- for (iVirt = 0; iVirt < voPtr->numOwners; iVirt++) {
- if (voPtr->owners[iVirt] == vhPtr) {
- break;
- }
- }
- if (iVirt == voPtr->numOwners) {
- panic("DeleteVirtualEvent: couldn't find owner");
- }
- voPtr->numOwners--;
- if (voPtr->numOwners == 0) {
- /*
- * Removed last reference to this physical event, so
- * remove it from physical->virtual map.
- */
- PatSeq *prevPtr = (PatSeq *) Tcl_GetHashValue(psPtr->hPtr);
- if (prevPtr == psPtr) {
- if (psPtr->nextSeqPtr == NULL) {
- Tcl_DeleteHashEntry(psPtr->hPtr);
- } else {
- Tcl_SetHashValue(psPtr->hPtr,
- psPtr->nextSeqPtr);
- }
- } else {
- for ( ; ; prevPtr = prevPtr->nextSeqPtr) {
- if (prevPtr == NULL) {
- panic("Tk_DeleteVirtualEvent couldn't find on hash chain");
- }
- if (prevPtr->nextSeqPtr == psPtr) {
- prevPtr->nextSeqPtr = psPtr->nextSeqPtr;
- break;
- }
- }
- }
- ckfree((char *) psPtr->voPtr);
- ckfree((char *) psPtr);
- } else {
- /*
- * This physical event still triggers some other virtual
- * event(s). Consolidate the list of virtual owners for
- * this physical event so it no longer triggers the
- * given virtual event.
- */
- voPtr->owners[iVirt] = voPtr->owners[voPtr->numOwners];
- }
-
- /*
- * Now delete the virtual event's reference to the physical
- * event.
- */
-
- poPtr->numOwned--;
- if (eventPSPtr != NULL && poPtr->numOwned != 0) {
- /*
- * Just deleting this one physical event. Consolidate list
- * of owned physical events and return.
- */
-
- poPtr->patSeqs[iPhys] = poPtr->patSeqs[poPtr->numOwned];
- return TCL_OK;
- }
- }
- }
-
- if (poPtr->numOwned == 0) {
- /*
- * All the physical events for this virtual event were deleted,
- * either because there was only one associated physical event or
- * because the caller was deleting the entire virtual event. Now
- * the virtual event itself should be deleted.
- */
-
- ckfree((char *) poPtr);
- Tcl_DeleteHashEntry(vhPtr);
- }
- return TCL_OK;
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * GetVirtualEvent --
- *
- * Return the list of physical events that can invoke the
- * given virtual event.
- *
- * Results:
- * The return value is TCL_OK and interp->result is filled with the
- * string representation of the physical events associated with the
- * virtual event; if there are no physical events for the given virtual
- * event, interp->result is filled with and empty string. If the
- * virtual event string is improperly formed, then TCL_ERROR is
- * returned and an error message is left in interp->result.
- *
- * Side effects:
- * None.
- *
- *---------------------------------------------------------------------------
- */
-
-static int
-GetVirtualEvent(interp, vetPtr, virtString)
- Tcl_Interp *interp; /* Interpreter for reporting. */
- VirtualEventTable *vetPtr;/* Table in which to look for event. */
- char *virtString; /* String describing virtual event. */
-{
- Tcl_HashEntry *vhPtr;
- Tcl_DString ds;
- int iPhys;
- PhysicalsOwned *poPtr;
- Tk_Uid virtUid;
-
- virtUid = GetVirtualEventUid(interp, virtString);
- if (virtUid == NULL) {
- return TCL_ERROR;
- }
-
- vhPtr = Tcl_FindHashEntry(&vetPtr->nameTable, virtUid);
- if (vhPtr == NULL) {
- return TCL_OK;
- }
-
- Tcl_DStringInit(&ds);
-
- poPtr = (PhysicalsOwned *) Tcl_GetHashValue(vhPtr);
- for (iPhys = 0; iPhys < poPtr->numOwned; iPhys++) {
- Tcl_DStringSetLength(&ds, 0);
- GetPatternString(poPtr->patSeqs[iPhys], &ds);
- Tcl_AppendElement(interp, Tcl_DStringValue(&ds));
- }
- Tcl_DStringFree(&ds);
-
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * GetAllVirtualEvents --
- *
- * Return a list that contains the names of all the virtual
- * event defined.
- *
- * Results:
- * There is no return value. Interp->result is modified to
- * hold a Tcl list with one entry for each virtual event in
- * nameTable.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-static void
-GetAllVirtualEvents(interp, vetPtr)
- Tcl_Interp *interp; /* Interpreter returning result. */
- VirtualEventTable *vetPtr;/* Table containing events. */
-{
- Tcl_HashEntry *hPtr;
- Tcl_HashSearch search;
- Tcl_DString ds;
-
- Tcl_DStringInit(&ds);
-
- hPtr = Tcl_FirstHashEntry(&vetPtr->nameTable, &search);
- for ( ; hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
- Tcl_DStringSetLength(&ds, 0);
- Tcl_DStringAppend(&ds, "<<", 2);
- Tcl_DStringAppend(&ds, Tcl_GetHashKey(hPtr->tablePtr, hPtr), -1);
- Tcl_DStringAppend(&ds, ">>", 2);
- Tcl_AppendElement(interp, Tcl_DStringValue(&ds));
- }
-
- Tcl_DStringFree(&ds);
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * HandleEventGenerate --
- *
- * Helper function for the "event generate" command. Generate and
- * process an XEvent, constructed from information parsed from the
- * event description string and its optional arguments.
- *
- * argv[0] contains name of the target window.
- * argv[1] contains pattern string for one event (e.g, <Control-v>).
- * argv[2..argc-1] contains -field/option pairs for specifying
- * additional detail in the generated event.
- *
- * Either virtual or physical events can be generated this way.
- * The event description string must contain the specification
- * for only one event.
- *
- * Results:
- * None.
- *
- * Side effects:
- * When constructing the event,
- * event.xany.serial is filled with the current X serial number.
- * event.xany.window is filled with the target window.
- * event.xany.display is filled with the target window's display.
- * Any other fields in eventPtr which are not specified by the pattern
- * string or the optional arguments, are set to 0.
- *
- * The event may be handled sychronously or asynchronously, depending
- * on the value specified by the optional "-when" option. The
- * default setting is synchronous.
- *
- *---------------------------------------------------------------------------
- */
-static int
-HandleEventGenerate(interp, mainwin, argc, argv)
- Tcl_Interp *interp; /* Interp for error messages and name lookup. */
- Tk_Window mainwin; /* Main window associated with interp. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- Pattern pat;
- Tk_Window tkwin;
- char *p;
- unsigned long eventMask;
- int count, i, state, flags, synch;
- Tcl_QueuePosition pos;
- XEvent event;
-
- if (argv[0][0] == '.') {
- tkwin = Tk_NameToWindow(interp, argv[0], mainwin);
- if (tkwin == NULL) {
- return TCL_ERROR;
- }
- } else {
- if (TkpScanWindowId(NULL, argv[0], &i) != TCL_OK) {
- Tcl_AppendResult(interp, "bad window name/identifier \"",
- argv[0], "\"", (char *) NULL);
- return TCL_ERROR;
- }
- tkwin = Tk_IdToWindow(Tk_Display(mainwin), (Window) i);
- if ((tkwin == NULL) || (((TkWindow *) mainwin)->mainPtr
- != ((TkWindow *) tkwin)->mainPtr)) {
- Tcl_AppendResult(interp, "window id \"", argv[0],
- "\" doesn't exist in this application", (char *) NULL);
- return TCL_ERROR;
- }
- }
-
- p = argv[1];
- count = ParseEventDescription(interp, &p, &pat, &eventMask);
- if (count == 0) {
- return TCL_ERROR;
- }
- if (count != 1) {
- interp->result = "Double or Triple modifier not allowed";
- return TCL_ERROR;
- }
- if (*p != '\0') {
- interp->result = "only one event specification allowed";
- return TCL_ERROR;
- }
- if (argc & 1) {
- Tcl_AppendResult(interp, "value for \"", argv[argc - 1],
- "\" missing", (char *) NULL);
- return TCL_ERROR;
- }
-
- memset((VOID *) &event, 0, sizeof(event));
- event.xany.type = pat.eventType;
- event.xany.serial = NextRequest(Tk_Display(tkwin));
- event.xany.send_event = False;
- event.xany.window = Tk_WindowId(tkwin);
- event.xany.display = Tk_Display(tkwin);
-
- flags = flagArray[event.xany.type];
- if (flags & (KEY_BUTTON_MOTION_VIRTUAL)) {
- event.xkey.state = pat.needMods;
- if (flags & KEY) {
- /*
- * When mapping from a keysym to a keycode, need information about
- * the modifier state that should be used so that when they call
- * XKeycodeToKeysym taking into account the xkey.state, they will
- * get back the original keysym.
- */
-
- if (pat.detail.keySym == NoSymbol) {
- event.xkey.keycode = 0;
- } else {
- event.xkey.keycode = XKeysymToKeycode(event.xany.display,
- pat.detail.keySym);
- }
- if (event.xkey.keycode != 0) {
- for (state = 0; state < 4; state++) {
- if (XKeycodeToKeysym(event.xany.display,
- event.xkey.keycode, state) == pat.detail.keySym) {
- if (state & 1) {
- event.xkey.state |= ShiftMask;
- }
- if (state & 2) {
- TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
- event.xkey.state |= dispPtr->modeModMask;
- }
- break;
- }
- }
- }
- } else if (flags & BUTTON) {
- event.xbutton.button = pat.detail.button;
- } else if (flags & VIRTUAL) {
- ((XVirtualEvent *) &event)->name = pat.detail.name;
- }
- }
- if (flags & (CREATE|DESTROY|UNMAP|MAP|REPARENT|CONFIG|GRAVITY|CIRC)) {
- event.xcreatewindow.window = event.xany.window;
- }
-
- /*
- * Process the remaining arguments to fill in additional fields
- * of the event.
- */
-
- synch = 1;
- pos = TCL_QUEUE_TAIL;
- for (i = 2; i < argc; i += 2) {
- char *field, *value;
- Tk_Window tkwin2;
- int number;
- KeySym keysym;
-
- field = argv[i];
- value = argv[i+1];
-
- if (strcmp(field, "-when") == 0) {
- if (strcmp(value, "now") == 0) {
- synch = 1;
- } else if (strcmp(value, "head") == 0) {
- pos = TCL_QUEUE_HEAD;
- synch = 0;
- } else if (strcmp(value, "mark") == 0) {
- pos = TCL_QUEUE_MARK;
- synch = 0;
- } else if (strcmp(value, "tail") == 0) {
- pos = TCL_QUEUE_TAIL;
- synch = 0;
- } else {
- Tcl_AppendResult(interp, "bad position \"", value,
- "\": should be now, head, mark, tail", (char *) NULL);
- return TCL_ERROR;
- }
- } else if (strcmp(field, "-above") == 0) {
- if (value[0] == '.') {
- tkwin2 = Tk_NameToWindow(interp, value, mainwin);
- if (tkwin2 == NULL) {
- return TCL_ERROR;
- }
- number = Tk_WindowId(tkwin2);
- } else if (TkpScanWindowId(interp, value, &number)
- != TCL_OK) {
- return TCL_ERROR;
- }
- if (flags & CONFIG) {
- event.xconfigure.above = number;
- } else {
- goto badopt;
- }
- } else if (strcmp(field, "-borderwidth") == 0) {
- if (Tk_GetPixels(interp, tkwin, value, &number) != TCL_OK) {
- return TCL_ERROR;
- }
- if (flags & (CREATE|CONFIG)) {
- event.xcreatewindow.border_width = number;
- } else {
- goto badopt;
- }
- } else if (strcmp(field, "-button") == 0) {
- if (Tcl_GetInt(interp, value, &number) != TCL_OK) {
- return TCL_ERROR;
- }
- if (flags & BUTTON) {
- event.xbutton.button = number;
- } else {
- goto badopt;
- }
- } else if (strcmp(field, "-count") == 0) {
- if (Tcl_GetInt(interp, value, &number) != TCL_OK) {
- return TCL_ERROR;
- }
- if (flags & EXPOSE) {
- event.xexpose.count = number;
- } else {
- goto badopt;
- }
- } else if (strcmp(field, "-detail") == 0) {
- number = TkFindStateNum(interp, field, notifyDetail, value);
- if (number < 0) {
- return TCL_ERROR;
- }
- if (flags & FOCUS) {
- event.xfocus.detail = number;
- } else if (flags & CROSSING) {
- event.xcrossing.detail = number;
- } else {
- goto badopt;
- }
- } else if (strcmp(field, "-focus") == 0) {
- if (Tcl_GetBoolean(interp, value, &number) != TCL_OK) {
- return TCL_ERROR;
- }
- if (flags & CROSSING) {
- event.xcrossing.focus = number;
- } else {
- goto badopt;
- }
- } else if (strcmp(field, "-height") == 0) {
- if (Tk_GetPixels(interp, tkwin, value, &number) != TCL_OK) {
- return TCL_ERROR;
- }
- if (flags & EXPOSE) {
- event.xexpose.height = number;
- } else if (flags & CONFIG) {
- event.xconfigure.height = number;
- } else {
- goto badopt;
- }
- } else if (strcmp(field, "-keycode") == 0) {
- if (Tcl_GetInt(interp, value, &number) != TCL_OK) {
- return TCL_ERROR;
- }
- if (flags & KEY) {
- event.xkey.keycode = number;
- } else {
- goto badopt;
- }
- } else if (strcmp(field, "-keysym") == 0) {
- keysym = TkStringToKeysym(value);
- if (keysym == NoSymbol) {
- Tcl_AppendResult(interp, "unknown keysym \"", value,
- "\"", (char *) NULL);
- return TCL_ERROR;
- }
- /*
- * When mapping from a keysym to a keycode, need information about
- * the modifier state that should be used so that when they call
- * XKeycodeToKeysym taking into account the xkey.state, they will
- * get back the original keysym.
- */
-
- number = XKeysymToKeycode(event.xany.display, keysym);
- if (number == 0) {
- Tcl_AppendResult(interp, "no keycode for keysym \"", value,
- "\"", (char *) NULL);
- return TCL_ERROR;
- }
- for (state = 0; state < 4; state++) {
- if (XKeycodeToKeysym(event.xany.display, (unsigned) number,
- state) == keysym) {
- if (state & 1) {
- event.xkey.state |= ShiftMask;
- }
- if (state & 2) {
- TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
- event.xkey.state |= dispPtr->modeModMask;
- }
- break;
- }
- }
- if (flags & KEY) {
- event.xkey.keycode = number;
- } else {
- goto badopt;
- }
- } else if (strcmp(field, "-mode") == 0) {
- number = TkFindStateNum(interp, field, notifyMode, value);
- if (number < 0) {
- return TCL_ERROR;
- }
- if (flags & CROSSING) {
- event.xcrossing.mode = number;
- } else if (flags & FOCUS) {
- event.xfocus.mode = number;
- } else {
- goto badopt;
- }
- } else if (strcmp(field, "-override") == 0) {
- if (Tcl_GetBoolean(interp, value, &number) != TCL_OK) {
- return TCL_ERROR;
- }
- if (flags & CREATE) {
- event.xcreatewindow.override_redirect = number;
- } else if (flags & MAP) {
- event.xmap.override_redirect = number;
- } else if (flags & REPARENT) {
- event.xreparent.override_redirect = number;
- } else if (flags & CONFIG) {
- event.xconfigure.override_redirect = number;
- } else {
- goto badopt;
- }
- } else if (strcmp(field, "-place") == 0) {
- number = TkFindStateNum(interp, field, circPlace, value);
- if (number < 0) {
- return TCL_ERROR;
- }
- if (flags & CIRC) {
- event.xcirculate.place = number;
- } else {
- goto badopt;
- }
- } else if (strcmp(field, "-root") == 0) {
- if (value[0] == '.') {
- tkwin2 = Tk_NameToWindow(interp, value, mainwin);
- if (tkwin2 == NULL) {
- return TCL_ERROR;
- }
- number = Tk_WindowId(tkwin2);
- } else if (TkpScanWindowId(interp, value, &number)
- != TCL_OK) {
- return TCL_ERROR;
- }
- if (flags & (KEY_BUTTON_MOTION_VIRTUAL|CROSSING)) {
- event.xkey.root = number;
- } else {
- goto badopt;
- }
- } else if (strcmp(field, "-rootx") == 0) {
- if (Tk_GetPixels(interp, tkwin, value, &number) != TCL_OK) {
- return TCL_ERROR;
- }
- if (flags & (KEY_BUTTON_MOTION_VIRTUAL|CROSSING)) {
- event.xkey.x_root = number;
- } else {
- goto badopt;
- }
- } else if (strcmp(field, "-rooty") == 0) {
- if (Tk_GetPixels(interp, tkwin, value, &number) != TCL_OK) {
- return TCL_ERROR;
- }
- if (flags & (KEY_BUTTON_MOTION_VIRTUAL|CROSSING)) {
- event.xkey.y_root = number;
- } else {
- goto badopt;
- }
- } else if (strcmp(field, "-sendevent") == 0) {
- if (isdigit(UCHAR(value[0]))) {
- /*
- * Allow arbitrary integer values for the field; they
- * are needed by a few of the tests in the Tk test suite.
- */
-
- if (Tcl_GetInt(interp, value, &number) != TCL_OK) {
- return TCL_ERROR;
- }
- } else {
- if (Tcl_GetBoolean(interp, value, &number) != TCL_OK) {
- return TCL_ERROR;
- }
- }
- event.xany.send_event = number;
- } else if (strcmp(field, "-serial") == 0) {
- if (Tcl_GetInt(interp, value, &number) != TCL_OK) {
- return TCL_ERROR;
- }
- event.xany.serial = number;
- } else if (strcmp(field, "-state") == 0) {
- if (flags & (KEY_BUTTON_MOTION_VIRTUAL|CROSSING)) {
- if (Tcl_GetInt(interp, value, &number) != TCL_OK) {
- return TCL_ERROR;
- }
- if (flags & (KEY_BUTTON_MOTION_VIRTUAL)) {
- event.xkey.state = number;
- } else {
- event.xcrossing.state = number;
- }
- } else if (flags & VISIBILITY) {
- number = TkFindStateNum(interp, field, visNotify, value);
- if (number < 0) {
- return TCL_ERROR;
- }
- event.xvisibility.state = number;
- } else {
- goto badopt;
- }
- } else if (strcmp(field, "-subwindow") == 0) {
- if (value[0] == '.') {
- tkwin2 = Tk_NameToWindow(interp, value, mainwin);
- if (tkwin2 == NULL) {
- return TCL_ERROR;
- }
- number = Tk_WindowId(tkwin2);
- } else if (TkpScanWindowId(interp, value, &number)
- != TCL_OK) {
- return TCL_ERROR;
- }
- if (flags & (KEY_BUTTON_MOTION_VIRTUAL|CROSSING)) {
- event.xkey.subwindow = number;
- } else {
- goto badopt;
- }
- } else if (strcmp(field, "-time") == 0) {
- if (Tcl_GetInt(interp, value, &number) != TCL_OK) {
- return TCL_ERROR;
- }
- if (flags & (KEY_BUTTON_MOTION_VIRTUAL|CROSSING)) {
- event.xkey.time = (Time) number;
- } else if (flags & PROP) {
- event.xproperty.time = (Time) number;
- } else {
- goto badopt;
- }
- } else if (strcmp(field, "-width") == 0) {
- if (Tk_GetPixels(interp, tkwin, value, &number) != TCL_OK) {
- return TCL_ERROR;
- }
- if (flags & EXPOSE) {
- event.xexpose.width = number;
- } else if (flags & (CREATE|CONFIG)) {
- event.xcreatewindow.width = number;
- } else {
- goto badopt;
- }
- } else if (strcmp(field, "-window") == 0) {
- if (value[0] == '.') {
- tkwin2 = Tk_NameToWindow(interp, value, mainwin);
- if (tkwin2 == NULL) {
- return TCL_ERROR;
- }
- number = Tk_WindowId(tkwin2);
- } else if (TkpScanWindowId(interp, value, &number)
- != TCL_OK) {
- return TCL_ERROR;
- }
- if (flags & (CREATE|DESTROY|UNMAP|MAP|REPARENT|CONFIG
- |GRAVITY|CIRC)) {
- event.xcreatewindow.window = number;
- } else {
- goto badopt;
- }
- } else if (strcmp(field, "-x") == 0) {
- int rootX, rootY;
- if (Tk_GetPixels(interp, tkwin, value, &number) != TCL_OK) {
- return TCL_ERROR;
- }
- Tk_GetRootCoords(tkwin, &rootX, &rootY);
- rootX += number;
- if (flags & (KEY_BUTTON_MOTION_VIRTUAL|CROSSING)) {
- event.xkey.x = number;
- event.xkey.x_root = rootX;
- } else if (flags & EXPOSE) {
- event.xexpose.x = number;
- } else if (flags & (CREATE|CONFIG|GRAVITY)) {
- event.xcreatewindow.x = number;
- } else if (flags & REPARENT) {
- event.xreparent.x = number;
- } else {
- goto badopt;
- }
- } else if (strcmp(field, "-y") == 0) {
- int rootX, rootY;
- if (Tk_GetPixels(interp, tkwin, value, &number) != TCL_OK) {
- return TCL_ERROR;
- }
- Tk_GetRootCoords(tkwin, &rootX, &rootY);
- rootY += number;
- if (flags & (KEY_BUTTON_MOTION_VIRTUAL|CROSSING)) {
- event.xkey.y = number;
- event.xkey.y_root = rootY;
- } else if (flags & EXPOSE) {
- event.xexpose.y = number;
- } else if (flags & (CREATE|CONFIG|GRAVITY)) {
- event.xcreatewindow.y = number;
- } else if (flags & REPARENT) {
- event.xreparent.y = number;
- } else {
- goto badopt;
- }
- } else {
- badopt:
- Tcl_AppendResult(interp, "bad option to ", argv[1],
- " event: \"", field, "\"", (char *) NULL);
- return TCL_ERROR;
- }
- }
-
- if (synch != 0) {
- Tk_HandleEvent(&event);
- } else {
- Tk_QueueWindowEvent(&event, pos);
- }
- Tcl_ResetResult(interp);
- return TCL_OK;
-}
-
-/*
- *-------------------------------------------------------------------------
- *
- * GetVirtualEventUid --
- *
- * Determine if the given string is in the proper format for a
- * virtual event.
- *
- * Results:
- * The return value is NULL if the virtual event string was
- * not in the proper format. In this case, an error message
- * will be left in interp->result. Otherwise the return
- * value is a Tk_Uid that represents the virtual event.
- *
- * Side effects:
- * None.
- *
- *-------------------------------------------------------------------------
- */
-static Tk_Uid
-GetVirtualEventUid(interp, virtString)
- Tcl_Interp *interp;
- char *virtString;
-{
- Tk_Uid uid;
- int length;
-
- length = strlen(virtString);
-
- if (length < 5 || virtString[0] != '<' || virtString[1] != '<' ||
- virtString[length - 2] != '>' || virtString[length - 1] != '>') {
- Tcl_AppendResult(interp, "virtual event \"", virtString,
- "\" is badly formed", (char *) NULL);
- return NULL;
- }
- virtString[length - 2] = '\0';
- uid = Tk_GetUid(virtString + 2);
- virtString[length - 2] = '>';
-
- return uid;
-}
-
-
-/*
- *----------------------------------------------------------------------
- *
- * FindSequence --
- *
- * Find the entry in the pattern table that corresponds to a
- * particular pattern string, and return a pointer to that
- * entry.
- *
- * Results:
- * The return value is normally a pointer to the PatSeq
- * in patternTable that corresponds to eventString. If an error
- * was found while parsing eventString, or if "create" is 0 and
- * no pattern sequence previously existed, then NULL is returned
- * and interp->result contains a message describing the problem.
- * If no pattern sequence previously existed for eventString, then
- * a new one is created with a NULL command field. In a successful
- * return, *maskPtr is filled in with a mask of the event types
- * on which the pattern sequence depends.
- *
- * Side effects:
- * A new pattern sequence may be allocated.
- *
- *----------------------------------------------------------------------
- */
-
-static PatSeq *
-FindSequence(interp, patternTablePtr, object, eventString, create,
- allowVirtual, maskPtr)
- Tcl_Interp *interp; /* Interpreter to use for error
- * reporting. */
- Tcl_HashTable *patternTablePtr; /* Table to use for lookup. */
- ClientData object; /* For binding table, token for object with
- * which binding is associated.
- * For virtual event table, NULL. */
- char *eventString; /* String description of pattern to
- * match on. See user documentation
- * for details. */
- int create; /* 0 means don't create the entry if
- * it doesn't already exist. Non-zero
- * means create. */
- int allowVirtual; /* 0 means that virtual events are not
- * allowed in the sequence. Non-zero
- * otherwise. */
- unsigned long *maskPtr; /* *maskPtr is filled in with the event
- * types on which this pattern sequence
- * depends. */
-{
-
- Pattern pats[EVENT_BUFFER_SIZE];
- int numPats, virtualFound;
- char *p;
- Pattern *patPtr;
- PatSeq *psPtr;
- Tcl_HashEntry *hPtr;
- int flags, count, new;
- size_t sequenceSize;
- unsigned long eventMask;
- PatternTableKey key;
-
- /*
- *-------------------------------------------------------------
- * Step 1: parse the pattern string to produce an array
- * of Patterns. The array is generated backwards, so
- * that the lowest-indexed pattern corresponds to the last
- * event that must occur.
- *-------------------------------------------------------------
- */
-
- p = eventString;
- flags = 0;
- eventMask = 0;
- virtualFound = 0;
-
- patPtr = &pats[EVENT_BUFFER_SIZE-1];
- for (numPats = 0; numPats < EVENT_BUFFER_SIZE; numPats++, patPtr--) {
- while (isspace(UCHAR(*p))) {
- p++;
- }
- if (*p == '\0') {
- break;
- }
-
- count = ParseEventDescription(interp, &p, patPtr, &eventMask);
- if (count == 0) {
- return NULL;
- }
-
- if (eventMask & VirtualEventMask) {
- if (allowVirtual == 0) {
- interp->result =
- "virtual event not allowed in definition of another virtual event";
- return NULL;
- }
- virtualFound = 1;
- }
-
- /*
- * Replicate events for DOUBLE and TRIPLE.
- */
-
- if ((count > 1) && (numPats < EVENT_BUFFER_SIZE-1)) {
- flags |= PAT_NEARBY;
- patPtr[-1] = patPtr[0];
- patPtr--;
- numPats++;
- if ((count == 3) && (numPats < EVENT_BUFFER_SIZE-1)) {
- patPtr[-1] = patPtr[0];
- patPtr--;
- numPats++;
- }
- }
- }
-
- /*
- *-------------------------------------------------------------
- * Step 2: find the sequence in the binding table if it exists,
- * and add a new sequence to the table if it doesn't.
- *-------------------------------------------------------------
- */
-
- if (numPats == 0) {
- interp->result = "no events specified in binding";
- return NULL;
- }
- if ((numPats > 1) && (virtualFound != 0)) {
- interp->result = "virtual events may not be composed";
- return NULL;
- }
-
- patPtr = &pats[EVENT_BUFFER_SIZE-numPats];
- memset(&key, 0, sizeof(key));
- key.object = object;
- key.type = patPtr->eventType;
- key.detail = patPtr->detail;
- hPtr = Tcl_CreateHashEntry(patternTablePtr, (char *) &key, &new);
- sequenceSize = numPats*sizeof(Pattern);
- if (!new) {
- for (psPtr = (PatSeq *) Tcl_GetHashValue(hPtr); psPtr != NULL;
- psPtr = psPtr->nextSeqPtr) {
- if ((numPats == psPtr->numPats)
- && ((flags & PAT_NEARBY) == (psPtr->flags & PAT_NEARBY))
- && (memcmp((char *) patPtr, (char *) psPtr->pats,
- sequenceSize) == 0)) {
- goto done;
- }
- }
- }
- if (!create) {
- if (new) {
- Tcl_DeleteHashEntry(hPtr);
- }
- return NULL;
- }
- psPtr = (PatSeq *) ckalloc((unsigned) (sizeof(PatSeq)
- + (numPats-1)*sizeof(Pattern)));
- psPtr->numPats = numPats;
- psPtr->eventProc = NULL;
- psPtr->freeProc = NULL;
- psPtr->clientData = NULL;
- psPtr->flags = flags;
- psPtr->refCount = 0;
- psPtr->nextSeqPtr = (PatSeq *) Tcl_GetHashValue(hPtr);
- psPtr->hPtr = hPtr;
- psPtr->voPtr = NULL;
- psPtr->nextObjPtr = NULL;
- Tcl_SetHashValue(hPtr, psPtr);
-
- memcpy((VOID *) psPtr->pats, (VOID *) patPtr, sequenceSize);
-
- done:
- *maskPtr = eventMask;
- return psPtr;
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * ParseEventDescription --
- *
- * Fill Pattern buffer with information about event from
- * event string.
- *
- * Results:
- * Leaves error message in interp and returns 0 if there was an
- * error due to a badly formed event string. Returns 1 if proper
- * event was specified, 2 if Double modifier was used in event
- * string, or 3 if Triple was used.
- *
- * Side effects:
- * On exit, eventStringPtr points to rest of event string (after the
- * closing '>', so that this procedure can be called repeatedly to
- * parse all the events in the entire sequence.
- *
- *---------------------------------------------------------------------------
- */
-
-static int
-ParseEventDescription(interp, eventStringPtr, patPtr,
- eventMaskPtr)
- Tcl_Interp *interp; /* For error messages. */
- 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
- * event string. */
- unsigned long *eventMaskPtr;/* Filled with event mask of matched event. */
-
-{
- char *p;
- unsigned long eventMask;
- int count, eventFlags;
-#define FIELD_SIZE 48
- char field[FIELD_SIZE];
- Tcl_HashEntry *hPtr;
-
- p = *eventStringPtr;
-
- patPtr->eventType = -1;
- patPtr->needMods = 0;
- patPtr->detail.clientData = 0;
-
- eventMask = 0;
- count = 1;
-
- /*
- * Handle simple ASCII characters.
- */
-
- if (*p != '<') {
- char string[2];
-
- patPtr->eventType = KeyPress;
- eventMask = KeyPressMask;
- string[0] = *p;
- string[1] = 0;
- patPtr->detail.keySym = TkStringToKeysym(string);
- if (patPtr->detail.keySym == NoSymbol) {
- if (isprint(UCHAR(*p))) {
- patPtr->detail.keySym = *p;
- } else {
- sprintf(interp->result,
- "bad ASCII character 0x%x", (unsigned char) *p);
- return 0;
- }
- }
- p++;
- goto end;
- }
-
- /*
- * A fancier event description. This can be either a virtual event
- * or a physical event.
- *
- * A virtual event description consists of:
- *
- * 1. double open angle brackets.
- * 2. virtual event name.
- * 3. double close angle brackets.
- *
- * A physical event description consists of:
- *
- * 1. open angle bracket.
- * 2. any number of modifiers, each followed by spaces
- * or dashes.
- * 3. an optional event name.
- * 4. an option button or keysym name. Either this or
- * item 3 *must* be present; if both are present
- * then they are separated by spaces or dashes.
- * 5. a close angle bracket.
- */
-
- p++;
- if (*p == '<') {
- /*
- * This is a virtual event: soak up all the characters up to
- * the next '>'.
- */
-
- char *field = p + 1;
- p = strchr(field, '>');
- if (p == field) {
- interp->result = "virtual event \"<<>>\" is badly formed";
- return 0;
- }
- if ((p == NULL) || (p[1] != '>')) {
- interp->result = "missing \">\" in virtual binding";
- return 0;
- }
- *p = '\0';
- patPtr->eventType = VirtualEvent;
- eventMask = VirtualEventMask;
- patPtr->detail.name = Tk_GetUid(field);
- *p = '>';
-
- p += 2;
- goto end;
- }
-
- while (1) {
- ModInfo *modPtr;
- p = GetField(p, field, FIELD_SIZE);
- if (*p == '>') {
- /*
- * This solves the problem of, e.g., <Control-M> being
- * misinterpreted as Control + Meta + missing keysym
- * instead of Control + KeyPress + M.
- */
- break;
- }
- hPtr = Tcl_FindHashEntry(&modTable, field);
- if (hPtr == NULL) {
- break;
- }
- modPtr = (ModInfo *) Tcl_GetHashValue(hPtr);
- patPtr->needMods |= modPtr->mask;
- if (modPtr->flags & (DOUBLE|TRIPLE)) {
- if (modPtr->flags & DOUBLE) {
- count = 2;
- } else {
- count = 3;
- }
- }
- while ((*p == '-') || isspace(UCHAR(*p))) {
- p++;
- }
- }
-
- eventFlags = 0;
- hPtr = Tcl_FindHashEntry(&eventTable, field);
- if (hPtr != NULL) {
- EventInfo *eiPtr;
- eiPtr = (EventInfo *) Tcl_GetHashValue(hPtr);
-
- patPtr->eventType = eiPtr->type;
- eventFlags = flagArray[eiPtr->type];
- eventMask = eiPtr->eventMask;
- while ((*p == '-') || isspace(UCHAR(*p))) {
- p++;
- }
- p = GetField(p, field, FIELD_SIZE);
- }
- if (*field != '\0') {
- if ((*field >= '1') && (*field <= '5') && (field[1] == '\0')) {
- if (eventFlags == 0) {
- patPtr->eventType = ButtonPress;
- eventMask = ButtonPressMask;
- } else if (eventFlags & KEY) {
- goto getKeysym;
- } else if ((eventFlags & BUTTON) == 0) {
- Tcl_AppendResult(interp, "specified button \"", field,
- "\" for non-button event", (char *) NULL);
- return 0;
- }
- patPtr->detail.button = (*field - '0');
- } else {
- getKeysym:
- patPtr->detail.keySym = TkStringToKeysym(field);
- if (patPtr->detail.keySym == NoSymbol) {
- Tcl_AppendResult(interp, "bad event type or keysym \"",
- field, "\"", (char *) NULL);
- return 0;
- }
- if (eventFlags == 0) {
- patPtr->eventType = KeyPress;
- eventMask = KeyPressMask;
- } else if ((eventFlags & KEY) == 0) {
- Tcl_AppendResult(interp, "specified keysym \"", field,
- "\" for non-key event", (char *) NULL);
- return 0;
- }
- }
- } else if (eventFlags == 0) {
- interp->result = "no event type or button # or keysym";
- return 0;
- }
-
- while ((*p == '-') || isspace(UCHAR(*p))) {
- p++;
- }
- if (*p != '>') {
- while (*p != '\0') {
- p++;
- if (*p == '>') {
- interp->result = "extra characters after detail in binding";
- return 0;
- }
- }
- interp->result = "missing \">\" in binding";
- return 0;
- }
- p++;
-
-end:
- *eventStringPtr = p;
- *eventMaskPtr |= eventMask;
- return count;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * GetField --
- *
- * Used to parse pattern descriptions. Copies up to
- * size characters from p to copy, stopping at end of
- * string, space, "-", ">", or whenever size is
- * exceeded.
- *
- * Results:
- * The return value is a pointer to the character just
- * after the last one copied (usually "-" or space or
- * ">", but could be anything if size was exceeded).
- * Also places NULL-terminated string (up to size
- * character, including NULL), at copy.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static char *
-GetField(p, copy, size)
- char *p; /* Pointer to part of pattern. */
- char *copy; /* Place to copy field. */
- int size; /* Maximum number of characters to
- * copy. */
-{
- while ((*p != '\0') && !isspace(UCHAR(*p)) && (*p != '>')
- && (*p != '-') && (size > 1)) {
- *copy = *p;
- p++;
- copy++;
- size--;
- }
- *copy = '\0';
- return p;
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * GetPatternString --
- *
- * Produce a string version of the given event, for displaying to
- * the user.
- *
- * Results:
- * The string is left in dsPtr.
- *
- * Side effects:
- * It is the caller's responsibility to initialize the DString before
- * and to free it after calling this procedure.
- *
- *---------------------------------------------------------------------------
- */
-static void
-GetPatternString(psPtr, dsPtr)
- PatSeq *psPtr;
- Tcl_DString *dsPtr;
-{
- Pattern *patPtr;
- char c, buffer[10];
- int patsLeft, needMods;
- ModInfo *modPtr;
- EventInfo *eiPtr;
-
- /*
- * The order of the patterns in the sequence is backwards from the order
- * in which they must be output.
- */
-
- for (patsLeft = psPtr->numPats, patPtr = &psPtr->pats[psPtr->numPats - 1];
- patsLeft > 0; patsLeft--, patPtr--) {
-
- /*
- * Check for simple case of an ASCII character.
- */
-
- if ((patPtr->eventType == KeyPress)
- && ((psPtr->flags & PAT_NEARBY) == 0)
- && (patPtr->needMods == 0)
- && (patPtr->detail.keySym < 128)
- && isprint(UCHAR(patPtr->detail.keySym))
- && (patPtr->detail.keySym != '<')
- && (patPtr->detail.keySym != ' ')) {
-
- c = (char) patPtr->detail.keySym;
- Tcl_DStringAppend(dsPtr, &c, 1);
- continue;
- }
-
- /*
- * Check for virtual event.
- */
-
- if (patPtr->eventType == VirtualEvent) {
- Tcl_DStringAppend(dsPtr, "<<", 2);
- Tcl_DStringAppend(dsPtr, patPtr->detail.name, -1);
- Tcl_DStringAppend(dsPtr, ">>", 2);
- continue;
- }
-
- /*
- * It's a more general event specification. First check
- * for "Double" or "Triple", then modifiers, then event type,
- * then keysym or button detail.
- */
-
- Tcl_DStringAppend(dsPtr, "<", 1);
- if ((psPtr->flags & PAT_NEARBY) && (patsLeft > 1)
- && (memcmp((char *) patPtr, (char *) (patPtr-1),
- sizeof(Pattern)) == 0)) {
- patsLeft--;
- patPtr--;
- if ((patsLeft > 1) && (memcmp((char *) patPtr,
- (char *) (patPtr-1), sizeof(Pattern)) == 0)) {
- patsLeft--;
- patPtr--;
- Tcl_DStringAppend(dsPtr, "Triple-", 7);
- } else {
- Tcl_DStringAppend(dsPtr, "Double-", 7);
- }
- }
- for (needMods = patPtr->needMods, modPtr = modArray;
- needMods != 0; modPtr++) {
- if (modPtr->mask & needMods) {
- needMods &= ~modPtr->mask;
- Tcl_DStringAppend(dsPtr, modPtr->name, -1);
- Tcl_DStringAppend(dsPtr, "-", 1);
- }
- }
- for (eiPtr = eventArray; eiPtr->name != NULL; eiPtr++) {
- if (eiPtr->type == patPtr->eventType) {
- Tcl_DStringAppend(dsPtr, eiPtr->name, -1);
- if (patPtr->detail.clientData != 0) {
- Tcl_DStringAppend(dsPtr, "-", 1);
- }
- break;
- }
- }
-
- if (patPtr->detail.clientData != 0) {
- if ((patPtr->eventType == KeyPress)
- || (patPtr->eventType == KeyRelease)) {
- char *string;
-
- string = TkKeysymToString(patPtr->detail.keySym);
- if (string != NULL) {
- Tcl_DStringAppend(dsPtr, string, -1);
- }
- } else {
- sprintf(buffer, "%d", patPtr->detail.button);
- Tcl_DStringAppend(dsPtr, buffer, -1);
- }
- }
- Tcl_DStringAppend(dsPtr, ">", 1);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * GetKeySym --
- *
- * Given an X KeyPress or KeyRelease event, map the
- * keycode in the event into a KeySym.
- *
- * Results:
- * The return value is the KeySym corresponding to
- * eventPtr, or NoSymbol if no matching Keysym could be
- * found.
- *
- * Side effects:
- * In the first call for a given display, keycode-to-
- * KeySym maps get loaded.
- *
- *----------------------------------------------------------------------
- */
-
-static KeySym
-GetKeySym(dispPtr, eventPtr)
- TkDisplay *dispPtr; /* Display in which to
- * map keycode. */
- XEvent *eventPtr; /* Description of X event. */
-{
- KeySym sym;
- int index;
-
- /*
- * Refresh the mapping information if it's stale
- */
-
- if (dispPtr->bindInfoStale) {
- InitKeymapInfo(dispPtr);
- }
-
- /*
- * Figure out which of the four slots in the keymap vector to
- * use for this key. Refer to Xlib documentation for more info
- * on how this computation works.
- */
-
- index = 0;
- if (eventPtr->xkey.state & dispPtr->modeModMask) {
- index = 2;
- }
- if ((eventPtr->xkey.state & ShiftMask)
- || ((dispPtr->lockUsage != LU_IGNORE)
- && (eventPtr->xkey.state & LockMask))) {
- index += 1;
- }
- sym = XKeycodeToKeysym(dispPtr->display, eventPtr->xkey.keycode, index);
-
- /*
- * Special handling: if the key was shifted because of Lock, but
- * lock is only caps lock, not shift lock, and the shifted keysym
- * isn't upper-case alphabetic, then switch back to the unshifted
- * keysym.
- */
-
- if ((index & 1) && !(eventPtr->xkey.state & ShiftMask)
- && (dispPtr->lockUsage == LU_CAPS)) {
- if (!(((sym >= XK_A) && (sym <= XK_Z))
- || ((sym >= XK_Agrave) && (sym <= XK_Odiaeresis))
- || ((sym >= XK_Ooblique) && (sym <= XK_Thorn)))) {
- index &= ~1;
- sym = XKeycodeToKeysym(dispPtr->display, eventPtr->xkey.keycode,
- index);
- }
- }
-
- /*
- * Another bit of special handling: if this is a shifted key and there
- * is no keysym defined, then use the keysym for the unshifted key.
- */
-
- if ((index & 1) && (sym == NoSymbol)) {
- sym = XKeycodeToKeysym(dispPtr->display, eventPtr->xkey.keycode,
- index & ~1);
- }
- return sym;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * InitKeymapInfo --
- *
- * This procedure is invoked to scan keymap information
- * to recompute stuff that's important for binding, such
- * as the modifier key (if any) that corresponds to "mode
- * switch".
- *
- * Results:
- * None.
- *
- * Side effects:
- * Keymap-related information in dispPtr is updated.
- *
- *--------------------------------------------------------------
- */
-
-static void
-InitKeymapInfo(dispPtr)
- TkDisplay *dispPtr; /* Display for which to recompute keymap
- * information. */
-{
- XModifierKeymap *modMapPtr;
- KeyCode *codePtr;
- KeySym keysym;
- int count, i, j, max, arraySize;
-#define KEYCODE_ARRAY_SIZE 20
-
- dispPtr->bindInfoStale = 0;
- modMapPtr = XGetModifierMapping(dispPtr->display);
-
- /*
- * Check the keycodes associated with the Lock modifier. If
- * any of them is associated with the XK_Shift_Lock modifier,
- * then Lock has to be interpreted as Shift Lock, not Caps Lock.
- */
-
- dispPtr->lockUsage = LU_IGNORE;
- codePtr = modMapPtr->modifiermap + modMapPtr->max_keypermod*LockMapIndex;
- for (count = modMapPtr->max_keypermod; count > 0; count--, codePtr++) {
- if (*codePtr == 0) {
- continue;
- }
- keysym = XKeycodeToKeysym(dispPtr->display, *codePtr, 0);
- if (keysym == XK_Shift_Lock) {
- dispPtr->lockUsage = LU_SHIFT;
- break;
- }
- if (keysym == XK_Caps_Lock) {
- dispPtr->lockUsage = LU_CAPS;
- break;
- }
- }
-
- /*
- * Look through the keycodes associated with modifiers to see if
- * the the "mode switch", "meta", or "alt" keysyms are associated
- * with any modifiers. If so, remember their modifier mask bits.
- */
-
- dispPtr->modeModMask = 0;
- dispPtr->metaModMask = 0;
- dispPtr->altModMask = 0;
- codePtr = modMapPtr->modifiermap;
- max = 8*modMapPtr->max_keypermod;
- for (i = 0; i < max; i++, codePtr++) {
- if (*codePtr == 0) {
- continue;
- }
- keysym = XKeycodeToKeysym(dispPtr->display, *codePtr, 0);
- if (keysym == XK_Mode_switch) {
- dispPtr->modeModMask |= ShiftMask << (i/modMapPtr->max_keypermod);
- }
- if ((keysym == XK_Meta_L) || (keysym == XK_Meta_R)) {
- dispPtr->metaModMask |= ShiftMask << (i/modMapPtr->max_keypermod);
- }
- if ((keysym == XK_Alt_L) || (keysym == XK_Alt_R)) {
- dispPtr->altModMask |= ShiftMask << (i/modMapPtr->max_keypermod);
- }
- }
-
- /*
- * Create an array of the keycodes for all modifier keys.
- */
-
- if (dispPtr->modKeyCodes != NULL) {
- ckfree((char *) dispPtr->modKeyCodes);
- }
- dispPtr->numModKeyCodes = 0;
- arraySize = KEYCODE_ARRAY_SIZE;
- dispPtr->modKeyCodes = (KeyCode *) ckalloc((unsigned)
- (KEYCODE_ARRAY_SIZE * sizeof(KeyCode)));
- for (i = 0, codePtr = modMapPtr->modifiermap; i < max; i++, codePtr++) {
- if (*codePtr == 0) {
- continue;
- }
-
- /*
- * Make sure that the keycode isn't already in the array.
- */
-
- for (j = 0; j < dispPtr->numModKeyCodes; j++) {
- if (dispPtr->modKeyCodes[j] == *codePtr) {
- goto nextModCode;
- }
- }
- if (dispPtr->numModKeyCodes >= arraySize) {
- KeyCode *new;
-
- /*
- * Ran out of space in the array; grow it.
- */
-
- arraySize *= 2;
- new = (KeyCode *) ckalloc((unsigned)
- (arraySize * sizeof(KeyCode)));
- memcpy((VOID *) new, (VOID *) dispPtr->modKeyCodes,
- (dispPtr->numModKeyCodes * sizeof(KeyCode)));
- ckfree((char *) dispPtr->modKeyCodes);
- dispPtr->modKeyCodes = new;
- }
- dispPtr->modKeyCodes[dispPtr->numModKeyCodes] = *codePtr;
- dispPtr->numModKeyCodes++;
- nextModCode: continue;
- }
- XFreeModifiermap(modMapPtr);
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * EvalTclBinding --
- *
- * The procedure that is invoked by Tk_BindEvent when a Tcl binding
- * is fired.
- *
- * Results:
- * A standard Tcl result code, the result of globally evaluating the
- * percent-substitued binding string.
- *
- * Side effects:
- * Normal side effects due to eval.
- *
- *---------------------------------------------------------------------------
- */
-
-static void
-FreeTclBinding(clientData)
- ClientData clientData;
-{
- ckfree((char *) clientData);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkStringToKeysym --
- *
- * This procedure finds the keysym associated with a given keysym
- * name.
- *
- * Results:
- * The return value is the keysym that corresponds to name, or
- * NoSymbol if there is no such keysym.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-KeySym
-TkStringToKeysym(name)
- char *name; /* Name of a keysym. */
-{
-#ifdef REDO_KEYSYM_LOOKUP
- Tcl_HashEntry *hPtr;
- KeySym keysym;
-
- hPtr = Tcl_FindHashEntry(&keySymTable, name);
- if (hPtr != NULL) {
- return (KeySym) Tcl_GetHashValue(hPtr);
- }
- if (strlen(name) == 1) {
- keysym = (KeySym) (unsigned char) name[0];
- if (TkKeysymToString(keysym) != NULL) {
- return keysym;
- }
- }
-#endif /* REDO_KEYSYM_LOOKUP */
- return XStringToKeysym(name);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkKeysymToString --
- *
- * This procedure finds the keysym name associated with a given
- * keysym.
- *
- * Results:
- * The return value is a pointer to a static string containing
- * the name of the given keysym, or NULL if there is no known name.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-char *
-TkKeysymToString(keysym)
- KeySym keysym;
-{
-#ifdef REDO_KEYSYM_LOOKUP
- Tcl_HashEntry *hPtr;
-
- hPtr = Tcl_FindHashEntry(&nameTable, (char *)keysym);
- if (hPtr != NULL) {
- return (char *) Tcl_GetHashValue(hPtr);
- }
-#endif /* REDO_KEYSYM_LOOKUP */
- return XKeysymToString(keysym);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkCopyAndGlobalEval --
- *
- * This procedure makes a copy of a script then calls Tcl_GlobalEval
- * to evaluate it. It's used in situations where the execution of
- * a command may cause the original command string to be reallocated.
- *
- * Results:
- * Returns the result of evaluating script, including both a standard
- * Tcl completion code and a string in interp->result.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-int
-TkCopyAndGlobalEval(interp, script)
- Tcl_Interp *interp; /* Interpreter in which to evaluate
- * script. */
- char *script; /* Script to evaluate. */
-{
- Tcl_DString buffer;
- int code;
-
- Tcl_DStringInit(&buffer);
- Tcl_DStringAppend(&buffer, script, -1);
- code = Tcl_GlobalEval(interp, Tcl_DStringValue(&buffer));
- Tcl_DStringFree(&buffer);
- return code;
-}
-
-
diff --git a/generic/tkBitmap.c b/generic/tkBitmap.c
deleted file mode 100644
index e7a14b9..0000000
--- a/generic/tkBitmap.c
+++ /dev/null
@@ -1,630 +0,0 @@
-/*
- * tkBitmap.c --
- *
- * This file maintains a database of read-only bitmaps for the Tk
- * toolkit. This allows bitmaps to be shared between widgets and
- * also avoids interactions with the X server.
- *
- * 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: tkBitmap.c,v 1.6 1998/09/14 18:23:03 stanton Exp $
- */
-
-#include "tkPort.h"
-#include "tkInt.h"
-
-/*
- * The includes below are for pre-defined bitmaps.
- *
- * Platform-specific issue: Windows complains when the bitmaps are
- * included, because an array of characters is being initialized with
- * integers as elements. For lint purposes, the following pragmas
- * temporarily turn off that warning message.
- */
-
-#if defined(__WIN32__) || defined(_WIN32)
-#pragma warning (disable : 4305)
-#endif
-
-#include "error.bmp"
-#include "gray12.bmp"
-#include "gray25.bmp"
-#include "gray50.bmp"
-#include "gray75.bmp"
-#include "hourglass.bmp"
-#include "info.bmp"
-#include "questhead.bmp"
-#include "question.bmp"
-#include "warning.bmp"
-
-#if defined(__WIN32__) || defined(_WIN32)
-#pragma warning (default : 4305)
-#endif
-
-/*
- * One of the following data structures exists for each bitmap that is
- * currently in use. Each structure is indexed with both "idTable" and
- * "nameTable".
- */
-
-typedef struct {
- Pixmap bitmap; /* X identifier for bitmap. None means this
- * bitmap was created by Tk_DefineBitmap
- * and it isn't currently in use. */
- int width, height; /* Dimensions of bitmap. */
- Display *display; /* Display for which bitmap is valid. */
- int refCount; /* Number of active uses of bitmap. */
- Tcl_HashEntry *hashPtr; /* Entry in nameTable for this structure
- * (needed when deleting). */
-} TkBitmap;
-
-/*
- * Hash table to map from a textual description of a bitmap to the
- * TkBitmap record for the bitmap, and key structure used in that
- * hash table:
- */
-
-static Tcl_HashTable nameTable;
-typedef struct {
- Tk_Uid name; /* Textual name for desired bitmap. */
- Screen *screen; /* Screen on which bitmap will be used. */
-} NameKey;
-
-/*
- * Hash table that maps from <display + bitmap id> to the TkBitmap structure
- * for the bitmap. This table is used by Tk_FreeBitmap.
- */
-
-static Tcl_HashTable idTable;
-typedef struct {
- Display *display; /* Display for which bitmap was allocated. */
- Pixmap pixmap; /* X identifier for pixmap. */
-} IdKey;
-
-/*
- * Hash table create by Tk_DefineBitmap to map from a name to a
- * collection of in-core data about a bitmap. The table is
- * indexed by the address of the data for the bitmap, and the entries
- * contain pointers to TkPredefBitmap structures.
- */
-
-Tcl_HashTable tkPredefBitmapTable;
-
-/*
- * Hash table used by Tk_GetBitmapFromData to map from a collection
- * of in-core data about a bitmap to a Tk_Uid giving an automatically-
- * generated name for the bitmap:
- */
-
-static Tcl_HashTable dataTable;
-typedef struct {
- char *source; /* Bitmap bits. */
- int width, height; /* Dimensions of bitmap. */
-} DataKey;
-
-static int initialized = 0; /* 0 means static structures haven't been
- * initialized yet. */
-
-/*
- * Forward declarations for procedures defined in this file:
- */
-
-static void BitmapInit _ANSI_ARGS_((void));
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_GetBitmap --
- *
- * Given a string describing a bitmap, locate (or create if necessary)
- * a bitmap that fits the description.
- *
- * Results:
- * The return value is the X identifer for the desired bitmap
- * (i.e. a Pixmap with a single plane), unless string couldn't be
- * parsed correctly. In this case, None is returned and an error
- * message is left in interp->result. The caller should never
- * modify the bitmap that is returned, and should eventually call
- * Tk_FreeBitmap when the bitmap is no longer needed.
- *
- * Side effects:
- * The bitmap is added to an internal database with a reference count.
- * For each call to this procedure, there should eventually be a call
- * to Tk_FreeBitmap, so that the database can be cleaned up when bitmaps
- * aren't needed anymore.
- *
- *----------------------------------------------------------------------
- */
-
-Pixmap
-Tk_GetBitmap(interp, tkwin, string)
- Tcl_Interp *interp; /* Interpreter to use for error reporting,
- * this may be NULL. */
- Tk_Window tkwin; /* Window in which bitmap will be used. */
- Tk_Uid string; /* Description of bitmap. See manual entry
- * for details on legal syntax. */
-{
- NameKey nameKey;
- IdKey idKey;
- Tcl_HashEntry *nameHashPtr, *idHashPtr, *predefHashPtr;
- register TkBitmap *bitmapPtr;
- TkPredefBitmap *predefPtr;
- int new;
- Pixmap bitmap;
- int width, height;
- int dummy2;
-
- if (!initialized) {
- BitmapInit();
- }
-
- nameKey.name = string;
- nameKey.screen = Tk_Screen(tkwin);
- nameHashPtr = Tcl_CreateHashEntry(&nameTable, (char *) &nameKey, &new);
- if (!new) {
- bitmapPtr = (TkBitmap *) Tcl_GetHashValue(nameHashPtr);
- bitmapPtr->refCount++;
- return bitmapPtr->bitmap;
- }
-
- /*
- * No suitable bitmap exists. Create a new bitmap from the
- * information contained in the string. If the string starts
- * with "@" then the rest of the string is a file name containing
- * the bitmap. Otherwise the string must refer to a bitmap
- * defined by a call to Tk_DefineBitmap.
- */
-
- if (*string == '@') {
- Tcl_DString buffer;
- int result;
-
- if (Tcl_IsSafe(interp)) {
- Tcl_AppendResult(interp, "can't specify bitmap with '@' in a",
- " safe interpreter", (char *) NULL);
- goto error;
- }
-
- string = Tcl_TranslateFileName(interp, string + 1, &buffer);
- if (string == NULL) {
- goto error;
- }
- result = TkReadBitmapFile(Tk_Display(tkwin),
- RootWindowOfScreen(nameKey.screen), string,
- (unsigned int *) &width, (unsigned int *) &height,
- &bitmap, &dummy2, &dummy2);
- if (result != BitmapSuccess) {
- if (interp != NULL) {
- Tcl_AppendResult(interp, "error reading bitmap file \"", string,
- "\"", (char *) NULL);
- }
- Tcl_DStringFree(&buffer);
- goto error;
- }
- Tcl_DStringFree(&buffer);
- } else {
- predefHashPtr = Tcl_FindHashEntry(&tkPredefBitmapTable, string);
- if (predefHashPtr == NULL) {
- /*
- * The following platform specific call allows the user to
- * define bitmaps that may only exist during run time. If
- * it returns None nothing was found and we return the error.
- */
- bitmap = TkpGetNativeAppBitmap(Tk_Display(tkwin), string,
- &width, &height);
-
- if (bitmap == None) {
- if (interp != NULL) {
- Tcl_AppendResult(interp, "bitmap \"", string,
- "\" not defined", (char *) NULL);
- }
- goto error;
- }
- } else {
- predefPtr = (TkPredefBitmap *) Tcl_GetHashValue(predefHashPtr);
- width = predefPtr->width;
- height = predefPtr->height;
- if (predefPtr->native) {
- bitmap = TkpCreateNativeBitmap(Tk_Display(tkwin),
- predefPtr->source);
- if (bitmap == None) {
- panic("native bitmap creation failed");
- }
- } else {
- bitmap = XCreateBitmapFromData(Tk_Display(tkwin),
- RootWindowOfScreen(nameKey.screen), predefPtr->source,
- (unsigned) width, (unsigned) height);
- }
- }
- }
-
- /*
- * Add information about this bitmap to our database.
- */
-
- bitmapPtr = (TkBitmap *) ckalloc(sizeof(TkBitmap));
- bitmapPtr->bitmap = bitmap;
- bitmapPtr->width = width;
- bitmapPtr->height = height;
- bitmapPtr->display = Tk_Display(tkwin);
- bitmapPtr->refCount = 1;
- bitmapPtr->hashPtr = nameHashPtr;
- idKey.display = bitmapPtr->display;
- idKey.pixmap = bitmap;
- idHashPtr = Tcl_CreateHashEntry(&idTable, (char *) &idKey,
- &new);
- if (!new) {
- panic("bitmap already registered in Tk_GetBitmap");
- }
- Tcl_SetHashValue(nameHashPtr, bitmapPtr);
- Tcl_SetHashValue(idHashPtr, bitmapPtr);
- return bitmapPtr->bitmap;
-
- error:
- Tcl_DeleteHashEntry(nameHashPtr);
- return None;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_DefineBitmap --
- *
- * This procedure associates a textual name with a binary bitmap
- * description, so that the name may be used to refer to the
- * bitmap in future calls to Tk_GetBitmap.
- *
- * Results:
- * A standard Tcl result. If an error occurs then TCL_ERROR is
- * returned and a message is left in interp->result.
- *
- * Side effects:
- * "Name" is entered into the bitmap table and may be used from
- * here on to refer to the given bitmap.
- *
- *----------------------------------------------------------------------
- */
-
-int
-Tk_DefineBitmap(interp, name, source, width, height)
- Tcl_Interp *interp; /* Interpreter to use for error reporting. */
- Tk_Uid name; /* Name to use for bitmap. Must not already
- * be defined as a bitmap. */
- char *source; /* Address of bits for bitmap. */
- int width; /* Width of bitmap. */
- int height; /* Height of bitmap. */
-{
- int new;
- Tcl_HashEntry *predefHashPtr;
- TkPredefBitmap *predefPtr;
-
- if (!initialized) {
- BitmapInit();
- }
-
- predefHashPtr = Tcl_CreateHashEntry(&tkPredefBitmapTable, name, &new);
- if (!new) {
- Tcl_AppendResult(interp, "bitmap \"", name,
- "\" is already defined", (char *) NULL);
- return TCL_ERROR;
- }
- predefPtr = (TkPredefBitmap *) ckalloc(sizeof(TkPredefBitmap));
- predefPtr->source = source;
- predefPtr->width = width;
- predefPtr->height = height;
- predefPtr->native = 0;
- Tcl_SetHashValue(predefHashPtr, predefPtr);
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_NameOfBitmap --
- *
- * Given a bitmap, return a textual string identifying the
- * bitmap.
- *
- * Results:
- * The return value is the string name associated with bitmap.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-Tk_Uid
-Tk_NameOfBitmap(display, bitmap)
- Display *display; /* Display for which bitmap was
- * allocated. */
- Pixmap bitmap; /* Bitmap whose name is wanted. */
-{
- IdKey idKey;
- Tcl_HashEntry *idHashPtr;
- TkBitmap *bitmapPtr;
-
- if (!initialized) {
- unknown:
- panic("Tk_NameOfBitmap received unknown bitmap argument");
- }
-
- idKey.display = display;
- idKey.pixmap = bitmap;
- idHashPtr = Tcl_FindHashEntry(&idTable, (char *) &idKey);
- if (idHashPtr == NULL) {
- goto unknown;
- }
- bitmapPtr = (TkBitmap *) Tcl_GetHashValue(idHashPtr);
- return ((NameKey *) bitmapPtr->hashPtr->key.words)->name;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_SizeOfBitmap --
- *
- * Given a bitmap managed by this module, returns the width
- * and height of the bitmap.
- *
- * Results:
- * The words at *widthPtr and *heightPtr are filled in with
- * the dimenstions of bitmap.
- *
- * Side effects:
- * If bitmap isn't managed by this module then the procedure
- * panics..
- *
- *--------------------------------------------------------------
- */
-
-void
-Tk_SizeOfBitmap(display, bitmap, widthPtr, heightPtr)
- Display *display; /* Display for which bitmap was
- * allocated. */
- Pixmap bitmap; /* Bitmap whose size is wanted. */
- int *widthPtr; /* Store bitmap width here. */
- int *heightPtr; /* Store bitmap height here. */
-{
- IdKey idKey;
- Tcl_HashEntry *idHashPtr;
- TkBitmap *bitmapPtr;
-
- if (!initialized) {
- unknownBitmap:
- panic("Tk_SizeOfBitmap received unknown bitmap argument");
- }
-
- idKey.display = display;
- idKey.pixmap = bitmap;
- idHashPtr = Tcl_FindHashEntry(&idTable, (char *) &idKey);
- if (idHashPtr == NULL) {
- goto unknownBitmap;
- }
- bitmapPtr = (TkBitmap *) Tcl_GetHashValue(idHashPtr);
- *widthPtr = bitmapPtr->width;
- *heightPtr = bitmapPtr->height;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_FreeBitmap --
- *
- * This procedure is called to release a bitmap allocated by
- * Tk_GetBitmap or TkGetBitmapFromData.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The reference count associated with bitmap is decremented, and
- * it is officially deallocated if no-one is using it anymore.
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tk_FreeBitmap(display, bitmap)
- Display *display; /* Display for which bitmap was
- * allocated. */
- Pixmap bitmap; /* Bitmap to be released. */
-{
- Tcl_HashEntry *idHashPtr;
- register TkBitmap *bitmapPtr;
- IdKey idKey;
-
- if (!initialized) {
- panic("Tk_FreeBitmap called before Tk_GetBitmap");
- }
-
- idKey.display = display;
- idKey.pixmap = bitmap;
- idHashPtr = Tcl_FindHashEntry(&idTable, (char *) &idKey);
- if (idHashPtr == NULL) {
- panic("Tk_FreeBitmap received unknown bitmap argument");
- }
- bitmapPtr = (TkBitmap *) Tcl_GetHashValue(idHashPtr);
- bitmapPtr->refCount--;
- if (bitmapPtr->refCount == 0) {
- Tk_FreePixmap(bitmapPtr->display, bitmapPtr->bitmap);
- Tcl_DeleteHashEntry(idHashPtr);
- Tcl_DeleteHashEntry(bitmapPtr->hashPtr);
- ckfree((char *) bitmapPtr);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_GetBitmapFromData --
- *
- * Given a description of the bits for a bitmap, make a bitmap that
- * has the given properties. *** NOTE: this procedure is obsolete
- * and really shouldn't be used anymore. ***
- *
- * Results:
- * The return value is the X identifer for the desired bitmap
- * (a one-plane Pixmap), unless it couldn't be created properly.
- * In this case, None is returned and an error message is left in
- * interp->result. The caller should never modify the bitmap that
- * is returned, and should eventually call Tk_FreeBitmap when the
- * bitmap is no longer needed.
- *
- * Side effects:
- * The bitmap is added to an internal database with a reference count.
- * For each call to this procedure, there should eventually be a call
- * to Tk_FreeBitmap, so that the database can be cleaned up when bitmaps
- * aren't needed anymore.
- *
- *----------------------------------------------------------------------
- */
-
- /* ARGSUSED */
-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. */
- int width, height; /* Dimensions of bitmap. */
-{
- DataKey nameKey;
- Tcl_HashEntry *dataHashPtr;
- Tk_Uid name;
- int new;
- char string[20];
- static int autoNumber = 0;
-
- if (!initialized) {
- BitmapInit();
- }
-
- nameKey.source = source;
- nameKey.width = width;
- nameKey.height = height;
- dataHashPtr = Tcl_CreateHashEntry(&dataTable, (char *) &nameKey, &new);
- if (!new) {
- name = (Tk_Uid) Tcl_GetHashValue(dataHashPtr);
- } else {
- autoNumber++;
- sprintf(string, "_tk%d", autoNumber);
- name = Tk_GetUid(string);
- Tcl_SetHashValue(dataHashPtr, name);
- if (Tk_DefineBitmap(interp, name, source, width, height) != TCL_OK) {
- Tcl_DeleteHashEntry(dataHashPtr);
- return TCL_ERROR;
- }
- }
- return Tk_GetBitmap(interp, tkwin, name);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * BitmapInit --
- *
- * Initialize the structures used for bitmap management.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Read the code.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-BitmapInit()
-{
- Tcl_Interp *dummy;
-
- dummy = Tcl_CreateInterp();
- initialized = 1;
- Tcl_InitHashTable(&nameTable, sizeof(NameKey)/sizeof(int));
- Tcl_InitHashTable(&dataTable, sizeof(DataKey)/sizeof(int));
- Tcl_InitHashTable(&tkPredefBitmapTable, TCL_ONE_WORD_KEYS);
-
- /*
- * The call below is tricky: can't use sizeof(IdKey) because it
- * gets padded with extra unpredictable bytes on some 64-bit
- * machines.
- */
-
- Tcl_InitHashTable(&idTable, (sizeof(Display *) + sizeof(Pixmap))
- /sizeof(int));
-
- Tk_DefineBitmap(dummy, Tk_GetUid("error"), (char *) error_bits,
- error_width, error_height);
- Tk_DefineBitmap(dummy, Tk_GetUid("gray75"), (char *) gray75_bits,
- gray75_width, gray75_height);
- Tk_DefineBitmap(dummy, Tk_GetUid("gray50"), (char *) gray50_bits,
- gray50_width, gray50_height);
- Tk_DefineBitmap(dummy, Tk_GetUid("gray25"), (char *) gray25_bits,
- gray25_width, gray25_height);
- Tk_DefineBitmap(dummy, Tk_GetUid("gray12"), (char *) gray12_bits,
- gray12_width, gray12_height);
- Tk_DefineBitmap(dummy, Tk_GetUid("hourglass"), (char *) hourglass_bits,
- hourglass_width, hourglass_height);
- Tk_DefineBitmap(dummy, Tk_GetUid("info"), (char *) info_bits,
- info_width, info_height);
- Tk_DefineBitmap(dummy, Tk_GetUid("questhead"), (char *) questhead_bits,
- questhead_width, questhead_height);
- Tk_DefineBitmap(dummy, Tk_GetUid("question"), (char *) question_bits,
- question_width, question_height);
- Tk_DefineBitmap(dummy, Tk_GetUid("warning"), (char *) warning_bits,
- warning_width, warning_height);
-
- TkpDefineNativeBitmaps();
-
- Tcl_DeleteInterp(dummy);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkReadBitmapFile --
- *
- * Loads a bitmap image in X bitmap format into the specified
- * drawable. This is equivelent to the XReadBitmapFile in X.
- *
- * Results:
- * Sets the size, hotspot, and bitmap on success.
- *
- * Side effects:
- * Creates a new bitmap from the file data.
- *
- *----------------------------------------------------------------------
- */
-
-int
-TkReadBitmapFile(display, d, filename, width_return, height_return,
- bitmap_return, x_hot_return, y_hot_return)
- 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;
-{
- char *data;
-
- data = TkGetBitmapData(NULL, NULL, (char *) filename,
- (int *) width_return, (int *) height_return, x_hot_return,
- y_hot_return);
- if (data == NULL) {
- return BitmapFileInvalid;
- }
-
- *bitmap_return = XCreateBitmapFromData(display, d, data, *width_return,
- *height_return);
-
- ckfree(data);
- return BitmapSuccess;
-}
diff --git a/generic/tkButton.c b/generic/tkButton.c
deleted file mode 100644
index aea1e58..0000000
--- a/generic/tkButton.c
+++ /dev/null
@@ -1,1347 +0,0 @@
-/*
- * tkButton.c --
- *
- * This module implements a collection of button-like
- * widgets for the Tk toolkit. The widgets implemented
- * include labels, buttons, check buttons, and radio
- * buttons.
- *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1995 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: tkButton.c,v 1.2 1998/09/14 18:23:04 stanton Exp $
- */
-
-#include "tkButton.h"
-#include "default.h"
-
-/*
- * Class names for buttons, indexed by one of the type values above.
- */
-
-static char *classNames[] = {"Label", "Button", "Checkbutton", "Radiobutton"};
-
-/*
- * The class procedure table for the button widget.
- */
-
-static int configFlags[] = {LABEL_MASK, BUTTON_MASK,
- CHECK_BUTTON_MASK, RADIO_BUTTON_MASK};
-
-/*
- * Information used for parsing configuration specs:
- */
-
-Tk_ConfigSpec tkpButtonConfigSpecs[] = {
- {TK_CONFIG_BORDER, "-activebackground", "activeBackground", "Foreground",
- DEF_BUTTON_ACTIVE_BG_COLOR, Tk_Offset(TkButton, activeBorder),
- BUTTON_MASK|CHECK_BUTTON_MASK|RADIO_BUTTON_MASK
- |TK_CONFIG_COLOR_ONLY},
- {TK_CONFIG_BORDER, "-activebackground", "activeBackground", "Foreground",
- DEF_BUTTON_ACTIVE_BG_MONO, Tk_Offset(TkButton, activeBorder),
- BUTTON_MASK|CHECK_BUTTON_MASK|RADIO_BUTTON_MASK
- |TK_CONFIG_MONO_ONLY},
- {TK_CONFIG_COLOR, "-activeforeground", "activeForeground", "Background",
- DEF_BUTTON_ACTIVE_FG_COLOR, Tk_Offset(TkButton, activeFg),
- BUTTON_MASK|TK_CONFIG_COLOR_ONLY},
- {TK_CONFIG_COLOR, "-activeforeground", "activeForeground", "Background",
- DEF_CHKRAD_ACTIVE_FG_COLOR, Tk_Offset(TkButton, activeFg),
- CHECK_BUTTON_MASK|RADIO_BUTTON_MASK|TK_CONFIG_COLOR_ONLY},
- {TK_CONFIG_COLOR, "-activeforeground", "activeForeground", "Background",
- DEF_BUTTON_ACTIVE_FG_MONO, Tk_Offset(TkButton, activeFg),
- BUTTON_MASK|CHECK_BUTTON_MASK|RADIO_BUTTON_MASK
- |TK_CONFIG_MONO_ONLY},
- {TK_CONFIG_ANCHOR, "-anchor", "anchor", "Anchor",
- DEF_BUTTON_ANCHOR, Tk_Offset(TkButton, anchor), ALL_MASK},
- {TK_CONFIG_BORDER, "-background", "background", "Background",
- DEF_BUTTON_BG_COLOR, Tk_Offset(TkButton, normalBorder),
- ALL_MASK | TK_CONFIG_COLOR_ONLY},
- {TK_CONFIG_BORDER, "-background", "background", "Background",
- DEF_BUTTON_BG_MONO, Tk_Offset(TkButton, normalBorder),
- ALL_MASK | TK_CONFIG_MONO_ONLY},
- {TK_CONFIG_SYNONYM, "-bd", "borderWidth", (char *) NULL,
- (char *) NULL, 0, ALL_MASK},
- {TK_CONFIG_SYNONYM, "-bg", "background", (char *) NULL,
- (char *) NULL, 0, ALL_MASK},
- {TK_CONFIG_BITMAP, "-bitmap", "bitmap", "Bitmap",
- DEF_BUTTON_BITMAP, Tk_Offset(TkButton, bitmap),
- ALL_MASK|TK_CONFIG_NULL_OK},
- {TK_CONFIG_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_BUTTON_BORDER_WIDTH, Tk_Offset(TkButton, borderWidth), ALL_MASK},
- {TK_CONFIG_STRING, "-command", "command", "Command",
- DEF_BUTTON_COMMAND, Tk_Offset(TkButton, command),
- BUTTON_MASK|CHECK_BUTTON_MASK|RADIO_BUTTON_MASK|TK_CONFIG_NULL_OK},
- {TK_CONFIG_ACTIVE_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_BUTTON_CURSOR, Tk_Offset(TkButton, cursor),
- ALL_MASK|TK_CONFIG_NULL_OK},
- {TK_CONFIG_UID, "-default", "default", "Default",
- DEF_BUTTON_DEFAULT, Tk_Offset(TkButton, defaultState), BUTTON_MASK},
- {TK_CONFIG_COLOR, "-disabledforeground", "disabledForeground",
- "DisabledForeground", DEF_BUTTON_DISABLED_FG_COLOR,
- Tk_Offset(TkButton, disabledFg), BUTTON_MASK|CHECK_BUTTON_MASK
- |RADIO_BUTTON_MASK|TK_CONFIG_COLOR_ONLY|TK_CONFIG_NULL_OK},
- {TK_CONFIG_COLOR, "-disabledforeground", "disabledForeground",
- "DisabledForeground", DEF_BUTTON_DISABLED_FG_MONO,
- Tk_Offset(TkButton, disabledFg), BUTTON_MASK|CHECK_BUTTON_MASK
- |RADIO_BUTTON_MASK|TK_CONFIG_MONO_ONLY|TK_CONFIG_NULL_OK},
- {TK_CONFIG_SYNONYM, "-fg", "foreground", (char *) NULL,
- (char *) NULL, 0, ALL_MASK},
- {TK_CONFIG_FONT, "-font", "font", "Font",
- DEF_BUTTON_FONT, Tk_Offset(TkButton, tkfont),
- ALL_MASK},
- {TK_CONFIG_COLOR, "-foreground", "foreground", "Foreground",
- DEF_BUTTON_FG, Tk_Offset(TkButton, normalFg), LABEL_MASK|BUTTON_MASK},
- {TK_CONFIG_COLOR, "-foreground", "foreground", "Foreground",
- DEF_CHKRAD_FG, Tk_Offset(TkButton, normalFg), CHECK_BUTTON_MASK
- |RADIO_BUTTON_MASK},
- {TK_CONFIG_STRING, "-height", "height", "Height",
- DEF_BUTTON_HEIGHT, Tk_Offset(TkButton, heightString), ALL_MASK},
- {TK_CONFIG_BORDER, "-highlightbackground", "highlightBackground",
- "HighlightBackground", DEF_BUTTON_HIGHLIGHT_BG,
- Tk_Offset(TkButton, highlightBorder), ALL_MASK},
- {TK_CONFIG_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_BUTTON_HIGHLIGHT, Tk_Offset(TkButton, highlightColorPtr),
- ALL_MASK},
- {TK_CONFIG_PIXELS, "-highlightthickness", "highlightThickness",
- "HighlightThickness",
- DEF_LABEL_HIGHLIGHT_WIDTH, Tk_Offset(TkButton, highlightWidth),
- LABEL_MASK},
- {TK_CONFIG_PIXELS, "-highlightthickness", "highlightThickness",
- "HighlightThickness",
- DEF_BUTTON_HIGHLIGHT_WIDTH, Tk_Offset(TkButton, highlightWidth),
- BUTTON_MASK|CHECK_BUTTON_MASK|RADIO_BUTTON_MASK},
- {TK_CONFIG_STRING, "-image", "image", "Image",
- DEF_BUTTON_IMAGE, Tk_Offset(TkButton, imageString),
- ALL_MASK|TK_CONFIG_NULL_OK},
- {TK_CONFIG_BOOLEAN, "-indicatoron", "indicatorOn", "IndicatorOn",
- DEF_BUTTON_INDICATOR, Tk_Offset(TkButton, indicatorOn),
- CHECK_BUTTON_MASK|RADIO_BUTTON_MASK},
- {TK_CONFIG_JUSTIFY, "-justify", "justify", "Justify",
- DEF_BUTTON_JUSTIFY, Tk_Offset(TkButton, justify), ALL_MASK},
- {TK_CONFIG_STRING, "-offvalue", "offValue", "Value",
- DEF_BUTTON_OFF_VALUE, Tk_Offset(TkButton, offValue),
- CHECK_BUTTON_MASK},
- {TK_CONFIG_STRING, "-onvalue", "onValue", "Value",
- DEF_BUTTON_ON_VALUE, Tk_Offset(TkButton, onValue),
- CHECK_BUTTON_MASK},
- {TK_CONFIG_PIXELS, "-padx", "padX", "Pad",
- DEF_BUTTON_PADX, Tk_Offset(TkButton, padX), BUTTON_MASK},
- {TK_CONFIG_PIXELS, "-padx", "padX", "Pad",
- DEF_LABCHKRAD_PADX, Tk_Offset(TkButton, padX),
- LABEL_MASK|CHECK_BUTTON_MASK|RADIO_BUTTON_MASK},
- {TK_CONFIG_PIXELS, "-pady", "padY", "Pad",
- DEF_BUTTON_PADY, Tk_Offset(TkButton, padY), BUTTON_MASK},
- {TK_CONFIG_PIXELS, "-pady", "padY", "Pad",
- DEF_LABCHKRAD_PADY, Tk_Offset(TkButton, padY),
- LABEL_MASK|CHECK_BUTTON_MASK|RADIO_BUTTON_MASK},
- {TK_CONFIG_RELIEF, "-relief", "relief", "Relief",
- DEF_BUTTON_RELIEF, Tk_Offset(TkButton, relief), BUTTON_MASK},
- {TK_CONFIG_RELIEF, "-relief", "relief", "Relief",
- DEF_LABCHKRAD_RELIEF, Tk_Offset(TkButton, relief),
- LABEL_MASK|CHECK_BUTTON_MASK|RADIO_BUTTON_MASK},
- {TK_CONFIG_BORDER, "-selectcolor", "selectColor", "Background",
- DEF_BUTTON_SELECT_COLOR, Tk_Offset(TkButton, selectBorder),
- CHECK_BUTTON_MASK|RADIO_BUTTON_MASK|TK_CONFIG_COLOR_ONLY
- |TK_CONFIG_NULL_OK},
- {TK_CONFIG_BORDER, "-selectcolor", "selectColor", "Background",
- DEF_BUTTON_SELECT_MONO, Tk_Offset(TkButton, selectBorder),
- CHECK_BUTTON_MASK|RADIO_BUTTON_MASK|TK_CONFIG_MONO_ONLY
- |TK_CONFIG_NULL_OK},
- {TK_CONFIG_STRING, "-selectimage", "selectImage", "SelectImage",
- DEF_BUTTON_SELECT_IMAGE, Tk_Offset(TkButton, selectImageString),
- CHECK_BUTTON_MASK|RADIO_BUTTON_MASK|TK_CONFIG_NULL_OK},
- {TK_CONFIG_UID, "-state", "state", "State",
- DEF_BUTTON_STATE, Tk_Offset(TkButton, state),
- BUTTON_MASK|CHECK_BUTTON_MASK|RADIO_BUTTON_MASK},
- {TK_CONFIG_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_LABEL_TAKE_FOCUS, Tk_Offset(TkButton, takeFocus),
- LABEL_MASK|TK_CONFIG_NULL_OK},
- {TK_CONFIG_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_BUTTON_TAKE_FOCUS, Tk_Offset(TkButton, takeFocus),
- BUTTON_MASK|CHECK_BUTTON_MASK|RADIO_BUTTON_MASK|TK_CONFIG_NULL_OK},
- {TK_CONFIG_STRING, "-text", "text", "Text",
- DEF_BUTTON_TEXT, Tk_Offset(TkButton, text), ALL_MASK},
- {TK_CONFIG_STRING, "-textvariable", "textVariable", "Variable",
- DEF_BUTTON_TEXT_VARIABLE, Tk_Offset(TkButton, textVarName),
- ALL_MASK|TK_CONFIG_NULL_OK},
- {TK_CONFIG_INT, "-underline", "underline", "Underline",
- DEF_BUTTON_UNDERLINE, Tk_Offset(TkButton, underline), ALL_MASK},
- {TK_CONFIG_STRING, "-value", "value", "Value",
- DEF_BUTTON_VALUE, Tk_Offset(TkButton, onValue),
- RADIO_BUTTON_MASK},
- {TK_CONFIG_STRING, "-variable", "variable", "Variable",
- DEF_RADIOBUTTON_VARIABLE, Tk_Offset(TkButton, selVarName),
- RADIO_BUTTON_MASK},
- {TK_CONFIG_STRING, "-variable", "variable", "Variable",
- DEF_CHECKBUTTON_VARIABLE, Tk_Offset(TkButton, selVarName),
- CHECK_BUTTON_MASK|TK_CONFIG_NULL_OK},
- {TK_CONFIG_STRING, "-width", "width", "Width",
- DEF_BUTTON_WIDTH, Tk_Offset(TkButton, widthString), ALL_MASK},
- {TK_CONFIG_PIXELS, "-wraplength", "wrapLength", "WrapLength",
- DEF_BUTTON_WRAP_LENGTH, Tk_Offset(TkButton, wrapLength), ALL_MASK},
- {TK_CONFIG_END, (char *) NULL, (char *) NULL, (char *) NULL,
- (char *) NULL, 0, 0}
-};
-
-/*
- * String to print out in error messages, identifying options for
- * widget commands for different types of labels or buttons:
- */
-
-static char *optionStrings[] = {
- "cget or configure",
- "cget, configure, flash, or invoke",
- "cget, configure, deselect, flash, invoke, select, or toggle",
- "cget, configure, deselect, flash, invoke, or select"
-};
-
-/*
- * Forward declarations for procedures defined later in this file:
- */
-
-static void ButtonCmdDeletedProc _ANSI_ARGS_((
- ClientData clientData));
-static int ButtonCreate _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv,
- int type));
-static void ButtonEventProc _ANSI_ARGS_((ClientData clientData,
- XEvent *eventPtr));
-static void ButtonImageProc _ANSI_ARGS_((ClientData clientData,
- int x, int y, int width, int height,
- int imgWidth, int imgHeight));
-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));
-static char * ButtonVarProc _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, char *name1, char *name2,
- int flags));
-static int ButtonWidgetCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-static int ConfigureButton _ANSI_ARGS_((Tcl_Interp *interp,
- TkButton *butPtr, int argc, char **argv,
- int flags));
-static void DestroyButton _ANSI_ARGS_((TkButton *butPtr));
-
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_ButtonCmd, Tk_CheckbuttonCmd, Tk_LabelCmd, Tk_RadiobuttonCmd --
- *
- * These procedures are invoked to process the "button", "label",
- * "radiobutton", and "checkbutton" 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.
- *
- *--------------------------------------------------------------
- */
-
-int
-Tk_ButtonCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Main window associated with
- * interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- return ButtonCreate(clientData, interp, argc, argv, TYPE_BUTTON);
-}
-
-int
-Tk_CheckbuttonCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Main window associated with
- * interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- return ButtonCreate(clientData, interp, argc, argv, TYPE_CHECK_BUTTON);
-}
-
-int
-Tk_LabelCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Main window associated with
- * interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- return ButtonCreate(clientData, interp, argc, argv, TYPE_LABEL);
-}
-
-int
-Tk_RadiobuttonCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Main window associated with
- * interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- return ButtonCreate(clientData, interp, argc, argv, TYPE_RADIO_BUTTON);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ButtonCreate --
- *
- * This procedure does all the real work of implementing the
- * "button", "label", "radiobutton", and "checkbutton" Tcl
- * commands. See the user documentation for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *--------------------------------------------------------------
- */
-
-static int
-ButtonCreate(clientData, interp, argc, argv, type)
- ClientData clientData; /* Main window associated with
- * interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
- int type; /* Type of button to create: TYPE_LABEL,
- * TYPE_BUTTON, TYPE_CHECK_BUTTON, or
- * TYPE_RADIO_BUTTON. */
-{
- register TkButton *butPtr;
- Tk_Window tkwin = (Tk_Window) clientData;
- Tk_Window new;
-
- if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " pathName ?options?\"", (char *) NULL);
- return TCL_ERROR;
- }
-
- /*
- * Create the new window.
- */
-
- new = Tk_CreateWindowFromPath(interp, tkwin, argv[1], (char *) NULL);
- if (new == NULL) {
- return TCL_ERROR;
- }
-
- Tk_SetClass(new, classNames[type]);
- butPtr = TkpCreateButton(new);
-
- TkSetClassProcs(new, &tkpButtonProcs, (ClientData) butPtr);
-
- /*
- * Initialize the data structure for the button.
- */
-
- butPtr->tkwin = new;
- butPtr->display = Tk_Display(new);
- butPtr->widgetCmd = Tcl_CreateCommand(interp, Tk_PathName(butPtr->tkwin),
- ButtonWidgetCmd, (ClientData) butPtr, ButtonCmdDeletedProc);
- butPtr->interp = interp;
- butPtr->type = type;
- butPtr->text = NULL;
- butPtr->underline = -1;
- butPtr->textVarName = NULL;
- butPtr->bitmap = None;
- butPtr->imageString = NULL;
- butPtr->image = NULL;
- butPtr->selectImageString = NULL;
- butPtr->selectImage = NULL;
- butPtr->state = tkNormalUid;
- butPtr->normalBorder = NULL;
- butPtr->activeBorder = NULL;
- butPtr->borderWidth = 0;
- butPtr->relief = TK_RELIEF_FLAT;
- butPtr->highlightWidth = 0;
- butPtr->highlightBorder = NULL;
- butPtr->highlightColorPtr = NULL;
- butPtr->inset = 0;
- butPtr->tkfont = NULL;
- butPtr->normalFg = NULL;
- butPtr->activeFg = NULL;
- butPtr->disabledFg = NULL;
- butPtr->normalTextGC = None;
- butPtr->activeTextGC = None;
- butPtr->gray = None;
- butPtr->disabledGC = None;
- butPtr->copyGC = None;
- butPtr->widthString = NULL;
- butPtr->heightString = NULL;
- butPtr->width = 0;
- butPtr->height = 0;
- butPtr->wrapLength = 0;
- butPtr->padX = 0;
- butPtr->padY = 0;
- butPtr->anchor = TK_ANCHOR_CENTER;
- butPtr->justify = TK_JUSTIFY_CENTER;
- butPtr->textLayout = NULL;
- butPtr->indicatorOn = 0;
- butPtr->selectBorder = NULL;
- butPtr->indicatorSpace = 0;
- butPtr->indicatorDiameter = 0;
- butPtr->defaultState = tkDisabledUid;
- butPtr->selVarName = NULL;
- butPtr->onValue = NULL;
- butPtr->offValue = NULL;
- butPtr->cursor = None;
- butPtr->command = NULL;
- butPtr->takeFocus = NULL;
- butPtr->flags = 0;
-
- Tk_CreateEventHandler(butPtr->tkwin,
- ExposureMask|StructureNotifyMask|FocusChangeMask,
- ButtonEventProc, (ClientData) butPtr);
-
- if (ConfigureButton(interp, butPtr, argc - 2, argv + 2,
- configFlags[type]) != TCL_OK) {
- Tk_DestroyWindow(butPtr->tkwin);
- return TCL_ERROR;
- }
-
- interp->result = Tk_PathName(butPtr->tkwin);
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ButtonWidgetCmd --
- *
- * 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
-ButtonWidgetCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Information about button widget. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- register TkButton *butPtr = (TkButton *) clientData;
- int result = TCL_OK;
- size_t length;
- int c;
-
- if (argc < 2) {
- sprintf(interp->result,
- "wrong # args: should be \"%.50s option ?arg arg ...?\"",
- argv[0]);
- return TCL_ERROR;
- }
- Tcl_Preserve((ClientData) butPtr);
- 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);
- goto error;
- }
- result = Tk_ConfigureValue(interp, butPtr->tkwin, tkpButtonConfigSpecs,
- (char *) butPtr, argv[2], configFlags[butPtr->type]);
- } else if ((c == 'c') && (strncmp(argv[1], "configure", length) == 0)
- && (length >= 2)) {
- if (argc == 2) {
- result = Tk_ConfigureInfo(interp, butPtr->tkwin,
- tkpButtonConfigSpecs, (char *) butPtr, (char *) NULL,
- configFlags[butPtr->type]);
- } else if (argc == 3) {
- result = Tk_ConfigureInfo(interp, butPtr->tkwin,
- tkpButtonConfigSpecs, (char *) butPtr, argv[2],
- configFlags[butPtr->type]);
- } else {
- result = ConfigureButton(interp, butPtr, argc-2, argv+2,
- configFlags[butPtr->type] | TK_CONFIG_ARGV_ONLY);
- }
- } else if ((c == 'd') && (strncmp(argv[1], "deselect", length) == 0)
- && (butPtr->type >= TYPE_CHECK_BUTTON)) {
- if (argc > 2) {
- sprintf(interp->result,
- "wrong # args: should be \"%.50s deselect\"",
- argv[0]);
- goto error;
- }
- if (butPtr->type == TYPE_CHECK_BUTTON) {
- if (Tcl_SetVar(interp, butPtr->selVarName, butPtr->offValue,
- TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG) == NULL) {
- result = TCL_ERROR;
- }
- } else if (butPtr->flags & SELECTED) {
- if (Tcl_SetVar(interp, butPtr->selVarName, "",
- TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG) == NULL) {
- result = TCL_ERROR;
- };
- }
- } else if ((c == 'f') && (strncmp(argv[1], "flash", length) == 0)
- && (butPtr->type != TYPE_LABEL)) {
- int i;
-
- if (argc > 2) {
- sprintf(interp->result,
- "wrong # args: should be \"%.50s flash\"",
- argv[0]);
- goto error;
- }
- if (butPtr->state != tkDisabledUid) {
- for (i = 0; i < 4; i++) {
- butPtr->state = (butPtr->state == tkNormalUid)
- ? tkActiveUid : tkNormalUid;
- Tk_SetBackgroundFromBorder(butPtr->tkwin,
- (butPtr->state == tkActiveUid) ? butPtr->activeBorder
- : butPtr->normalBorder);
- TkpDisplayButton((ClientData) butPtr);
-
- /*
- * Special note: must cancel any existing idle handler
- * for TkpDisplayButton; it's no longer needed, and TkpDisplayButton
- * cleared the REDRAW_PENDING flag.
- */
-
- Tcl_CancelIdleCall(TkpDisplayButton, (ClientData) butPtr);
- XFlush(butPtr->display);
- Tcl_Sleep(50);
- }
- }
- } else if ((c == 'i') && (strncmp(argv[1], "invoke", length) == 0)
- && (butPtr->type > TYPE_LABEL)) {
- if (argc > 2) {
- sprintf(interp->result,
- "wrong # args: should be \"%.50s invoke\"",
- argv[0]);
- goto error;
- }
- if (butPtr->state != tkDisabledUid) {
- result = TkInvokeButton(butPtr);
- }
- } else if ((c == 's') && (strncmp(argv[1], "select", length) == 0)
- && (butPtr->type >= TYPE_CHECK_BUTTON)) {
- if (argc > 2) {
- sprintf(interp->result,
- "wrong # args: should be \"%.50s select\"",
- argv[0]);
- goto error;
- }
- if (Tcl_SetVar(interp, butPtr->selVarName, butPtr->onValue,
- TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG) == NULL) {
- result = TCL_ERROR;
- }
- } else if ((c == 't') && (strncmp(argv[1], "toggle", length) == 0)
- && (length >= 2) && (butPtr->type == TYPE_CHECK_BUTTON)) {
- if (argc > 2) {
- sprintf(interp->result,
- "wrong # args: should be \"%.50s toggle\"",
- argv[0]);
- goto error;
- }
- if (butPtr->flags & SELECTED) {
- if (Tcl_SetVar(interp, butPtr->selVarName, butPtr->offValue,
- TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG) == NULL) {
- result = TCL_ERROR;
- }
- } else {
- if (Tcl_SetVar(interp, butPtr->selVarName, butPtr->onValue,
- TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG) == NULL) {
- result = TCL_ERROR;
- }
- }
- } else {
- sprintf(interp->result,
- "bad option \"%.50s\": must be %s", argv[1],
- optionStrings[butPtr->type]);
- goto error;
- }
- Tcl_Release((ClientData) butPtr);
- return result;
-
- error:
- Tcl_Release((ClientData) butPtr);
- return TCL_ERROR;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * DestroyButton --
- *
- * This procedure is invoked by Tcl_EventuallyFree or Tcl_Release
- * to clean up the internal structure of a button at a safe time
- * (when no-one is using it anymore).
- *
- * Results:
- * None.
- *
- * Side effects:
- * Everything associated with the widget is freed up.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-DestroyButton(butPtr)
- TkButton *butPtr; /* Info about button widget. */
-{
- /*
- * Free up all the stuff that requires special handling, then
- * let Tk_FreeOptions handle all the standard option-related
- * stuff.
- */
-
- if (butPtr->textVarName != NULL) {
- Tcl_UntraceVar(butPtr->interp, butPtr->textVarName,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- ButtonTextVarProc, (ClientData) butPtr);
- }
- if (butPtr->image != NULL) {
- Tk_FreeImage(butPtr->image);
- }
- if (butPtr->selectImage != NULL) {
- Tk_FreeImage(butPtr->selectImage);
- }
- if (butPtr->normalTextGC != None) {
- Tk_FreeGC(butPtr->display, butPtr->normalTextGC);
- }
- if (butPtr->activeTextGC != None) {
- Tk_FreeGC(butPtr->display, butPtr->activeTextGC);
- }
- if (butPtr->gray != None) {
- Tk_FreeBitmap(butPtr->display, butPtr->gray);
- }
- if (butPtr->disabledGC != None) {
- Tk_FreeGC(butPtr->display, butPtr->disabledGC);
- }
- if (butPtr->copyGC != None) {
- Tk_FreeGC(butPtr->display, butPtr->copyGC);
- }
- if (butPtr->selVarName != NULL) {
- Tcl_UntraceVar(butPtr->interp, butPtr->selVarName,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- ButtonVarProc, (ClientData) butPtr);
- }
- Tk_FreeTextLayout(butPtr->textLayout);
- Tk_FreeOptions(tkpButtonConfigSpecs, (char *) butPtr, butPtr->display,
- configFlags[butPtr->type]);
- Tcl_EventuallyFree((ClientData)butPtr, TCL_DYNAMIC);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ConfigureButton --
- *
- * This procedure is called to process an argv/argc list, plus
- * the Tk option database, in order to configure (or
- * reconfigure) a button widget.
- *
- * Results:
- * The return value is a standard Tcl result. If TCL_ERROR is
- * returned, then interp->result contains an error message.
- *
- * Side effects:
- * Configuration information, such as text string, colors, font,
- * etc. get set for butPtr; old resources get freed, if there
- * were any. The button is redisplayed.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-ConfigureButton(interp, butPtr, argc, argv, flags)
- Tcl_Interp *interp; /* Used for error reporting. */
- register TkButton *butPtr; /* 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 flags; /* Flags to pass to Tk_ConfigureWidget. */
-{
- Tk_Image image;
-
- /*
- * Eliminate any existing trace on variables monitored by the button.
- */
-
- if (butPtr->textVarName != NULL) {
- Tcl_UntraceVar(interp, butPtr->textVarName,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- ButtonTextVarProc, (ClientData) butPtr);
- }
- if (butPtr->selVarName != NULL) {
- Tcl_UntraceVar(interp, butPtr->selVarName,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- ButtonVarProc, (ClientData) butPtr);
- }
-
-
-
- if (Tk_ConfigureWidget(interp, butPtr->tkwin, tkpButtonConfigSpecs,
- argc, argv, (char *) butPtr, flags) != TCL_OK) {
- return TCL_ERROR;
- }
-
- /*
- * A few options need special processing, such as setting the
- * background from a 3-D border, or filling in complicated
- * defaults that couldn't be specified to Tk_ConfigureWidget.
- */
-
- if ((butPtr->state == tkActiveUid) && !Tk_StrictMotif(butPtr->tkwin)) {
- Tk_SetBackgroundFromBorder(butPtr->tkwin, butPtr->activeBorder);
- } else {
- Tk_SetBackgroundFromBorder(butPtr->tkwin, butPtr->normalBorder);
- if ((butPtr->state != tkNormalUid) && (butPtr->state != tkActiveUid)
- && (butPtr->state != tkDisabledUid)) {
- Tcl_AppendResult(interp, "bad state value \"", butPtr->state,
- "\": must be normal, active, or disabled", (char *) NULL);
- butPtr->state = tkNormalUid;
- return TCL_ERROR;
- }
- }
-
- if ((butPtr->defaultState != tkActiveUid)
- && (butPtr->defaultState != tkDisabledUid)
- && (butPtr->defaultState != tkNormalUid)) {
- Tcl_AppendResult(interp, "bad -default value \"", butPtr->defaultState,
- "\": must be normal, active, or disabled", (char *) NULL);
- butPtr->defaultState = tkDisabledUid;
- return TCL_ERROR;
- }
-
- if (butPtr->highlightWidth < 0) {
- butPtr->highlightWidth = 0;
- }
-
- if (butPtr->padX < 0) {
- butPtr->padX = 0;
- }
- if (butPtr->padY < 0) {
- butPtr->padY = 0;
- }
-
- if (butPtr->type >= TYPE_CHECK_BUTTON) {
- char *value;
-
- if (butPtr->selVarName == NULL) {
- butPtr->selVarName = (char *) ckalloc((unsigned)
- (strlen(Tk_Name(butPtr->tkwin)) + 1));
- strcpy(butPtr->selVarName, Tk_Name(butPtr->tkwin));
- }
-
- /*
- * Select the button if the associated variable has the
- * appropriate value, initialize the variable if it doesn't
- * exist, then set a trace on the variable to monitor future
- * changes to its value.
- */
-
- value = Tcl_GetVar(interp, butPtr->selVarName, TCL_GLOBAL_ONLY);
- butPtr->flags &= ~SELECTED;
- if (value != NULL) {
- if (strcmp(value, butPtr->onValue) == 0) {
- butPtr->flags |= SELECTED;
- }
- } else {
- if (Tcl_SetVar(interp, butPtr->selVarName,
- (butPtr->type == TYPE_CHECK_BUTTON) ? butPtr->offValue : "",
- TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG) == NULL) {
- return TCL_ERROR;
- }
- }
- Tcl_TraceVar(interp, butPtr->selVarName,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- ButtonVarProc, (ClientData) butPtr);
- }
-
- /*
- * Get the images for the widget, if there are any. Allocate the
- * new images before freeing the old ones, so that the reference
- * counts don't go to zero and cause image data to be discarded.
- */
-
- if (butPtr->imageString != NULL) {
- image = Tk_GetImage(butPtr->interp, butPtr->tkwin,
- butPtr->imageString, ButtonImageProc, (ClientData) butPtr);
- if (image == NULL) {
- return TCL_ERROR;
- }
- } else {
- image = NULL;
- }
- if (butPtr->image != NULL) {
- Tk_FreeImage(butPtr->image);
- }
- butPtr->image = image;
- if (butPtr->selectImageString != NULL) {
- image = Tk_GetImage(butPtr->interp, butPtr->tkwin,
- butPtr->selectImageString, ButtonSelectImageProc,
- (ClientData) butPtr);
- if (image == NULL) {
- return TCL_ERROR;
- }
- } else {
- image = NULL;
- }
- if (butPtr->selectImage != NULL) {
- Tk_FreeImage(butPtr->selectImage);
- }
- butPtr->selectImage = image;
-
- if ((butPtr->image == NULL) && (butPtr->bitmap == None)
- && (butPtr->textVarName != NULL)) {
- /*
- * The button must display the value of a variable: set up a trace
- * on the variable's value, create the variable if it doesn't
- * exist, and fetch its current value.
- */
-
- char *value;
-
- value = Tcl_GetVar(interp, butPtr->textVarName, TCL_GLOBAL_ONLY);
- if (value == NULL) {
- if (Tcl_SetVar(interp, butPtr->textVarName, butPtr->text,
- TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG) == NULL) {
- return TCL_ERROR;
- }
- } else {
- if (butPtr->text != NULL) {
- ckfree(butPtr->text);
- }
- butPtr->text = (char *) ckalloc((unsigned) (strlen(value) + 1));
- strcpy(butPtr->text, value);
- }
- Tcl_TraceVar(interp, butPtr->textVarName,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- ButtonTextVarProc, (ClientData) butPtr);
- }
-
- if ((butPtr->bitmap != None) || (butPtr->image != NULL)) {
- if (Tk_GetPixels(interp, butPtr->tkwin, butPtr->widthString,
- &butPtr->width) != TCL_OK) {
- widthError:
- Tcl_AddErrorInfo(interp, "\n (processing -width option)");
- return TCL_ERROR;
- }
- if (Tk_GetPixels(interp, butPtr->tkwin, butPtr->heightString,
- &butPtr->height) != TCL_OK) {
- heightError:
- Tcl_AddErrorInfo(interp, "\n (processing -height option)");
- return TCL_ERROR;
- }
- } else {
- if (Tcl_GetInt(interp, butPtr->widthString, &butPtr->width)
- != TCL_OK) {
- goto widthError;
- }
- if (Tcl_GetInt(interp, butPtr->heightString, &butPtr->height)
- != TCL_OK) {
- goto heightError;
- }
- }
-
- TkButtonWorldChanged((ClientData) butPtr);
- return TCL_OK;
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * TkButtonWorldChanged --
- *
- * 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:
- * Button will be relayed out and redisplayed.
- *
- *---------------------------------------------------------------------------
- */
-
-void
-TkButtonWorldChanged(instanceData)
- ClientData instanceData; /* Information about widget. */
-{
- XGCValues gcValues;
- GC newGC;
- unsigned long mask;
- TkButton *butPtr;
-
- butPtr = (TkButton *) instanceData;
-
- /*
- * Recompute GCs.
- */
-
- gcValues.font = Tk_FontId(butPtr->tkfont);
- gcValues.foreground = butPtr->normalFg->pixel;
- gcValues.background = Tk_3DBorderColor(butPtr->normalBorder)->pixel;
-
- /*
- * Note: GraphicsExpose events are disabled in normalTextGC because it's
- * used to copy stuff from an off-screen pixmap onto the screen (we know
- * that there's no problem with obscured areas).
- */
-
- gcValues.graphics_exposures = False;
- mask = GCForeground | GCBackground | GCFont | GCGraphicsExposures;
- newGC = Tk_GetGC(butPtr->tkwin, mask, &gcValues);
- if (butPtr->normalTextGC != None) {
- Tk_FreeGC(butPtr->display, butPtr->normalTextGC);
- }
- butPtr->normalTextGC = newGC;
-
- if (butPtr->activeFg != NULL) {
- gcValues.font = Tk_FontId(butPtr->tkfont);
- gcValues.foreground = butPtr->activeFg->pixel;
- gcValues.background = Tk_3DBorderColor(butPtr->activeBorder)->pixel;
- mask = GCForeground | GCBackground | GCFont;
- newGC = Tk_GetGC(butPtr->tkwin, mask, &gcValues);
- if (butPtr->activeTextGC != None) {
- Tk_FreeGC(butPtr->display, butPtr->activeTextGC);
- }
- butPtr->activeTextGC = newGC;
- }
-
- if (butPtr->type != TYPE_LABEL) {
- gcValues.font = Tk_FontId(butPtr->tkfont);
- gcValues.background = Tk_3DBorderColor(butPtr->normalBorder)->pixel;
- if ((butPtr->disabledFg != NULL) && (butPtr->imageString == NULL)) {
- gcValues.foreground = butPtr->disabledFg->pixel;
- mask = GCForeground | GCBackground | GCFont;
- } else {
- gcValues.foreground = gcValues.background;
- mask = GCForeground;
- if (butPtr->gray == None) {
- butPtr->gray = Tk_GetBitmap(NULL, butPtr->tkwin,
- Tk_GetUid("gray50"));
- }
- if (butPtr->gray != None) {
- gcValues.fill_style = FillStippled;
- gcValues.stipple = butPtr->gray;
- mask |= GCFillStyle | GCStipple;
- }
- }
- newGC = Tk_GetGC(butPtr->tkwin, mask, &gcValues);
- if (butPtr->disabledGC != None) {
- Tk_FreeGC(butPtr->display, butPtr->disabledGC);
- }
- butPtr->disabledGC = newGC;
- }
-
- if (butPtr->copyGC == None) {
- butPtr->copyGC = Tk_GetGC(butPtr->tkwin, 0, &gcValues);
- }
-
- TkpComputeButtonGeometry(butPtr);
-
- /*
- * Lastly, arrange for the button to be redisplayed.
- */
-
- if (Tk_IsMapped(butPtr->tkwin) && !(butPtr->flags & REDRAW_PENDING)) {
- Tcl_DoWhenIdle(TkpDisplayButton, (ClientData) butPtr);
- butPtr->flags |= REDRAW_PENDING;
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ButtonEventProc --
- *
- * This procedure is invoked by the Tk dispatcher for various
- * events on buttons.
- *
- * Results:
- * None.
- *
- * Side effects:
- * When the window gets deleted, internal structures get
- * cleaned up. When it gets exposed, it is redisplayed.
- *
- *--------------------------------------------------------------
- */
-
-static void
-ButtonEventProc(clientData, eventPtr)
- ClientData clientData; /* Information about window. */
- XEvent *eventPtr; /* Information about event. */
-{
- TkButton *butPtr = (TkButton *) clientData;
- if ((eventPtr->type == Expose) && (eventPtr->xexpose.count == 0)) {
- goto redraw;
- } else if (eventPtr->type == ConfigureNotify) {
- /*
- * Must redraw after size changes, since layout could have changed
- * and borders will need to be redrawn.
- */
-
- goto redraw;
- } else if (eventPtr->type == DestroyNotify) {
- TkpDestroyButton(butPtr);
- if (butPtr->tkwin != NULL) {
- butPtr->tkwin = NULL;
- Tcl_DeleteCommandFromToken(butPtr->interp, butPtr->widgetCmd);
- }
- if (butPtr->flags & REDRAW_PENDING) {
- Tcl_CancelIdleCall(TkpDisplayButton, (ClientData) butPtr);
- }
- DestroyButton(butPtr);
- } else if (eventPtr->type == FocusIn) {
- if (eventPtr->xfocus.detail != NotifyInferior) {
- butPtr->flags |= GOT_FOCUS;
- if (butPtr->highlightWidth > 0) {
- goto redraw;
- }
- }
- } else if (eventPtr->type == FocusOut) {
- if (eventPtr->xfocus.detail != NotifyInferior) {
- butPtr->flags &= ~GOT_FOCUS;
- if (butPtr->highlightWidth > 0) {
- goto redraw;
- }
- }
- }
- return;
-
- redraw:
- if ((butPtr->tkwin != NULL) && !(butPtr->flags & REDRAW_PENDING)) {
- Tcl_DoWhenIdle(TkpDisplayButton, (ClientData) butPtr);
- butPtr->flags |= REDRAW_PENDING;
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ButtonCmdDeletedProc --
- *
- * 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
-ButtonCmdDeletedProc(clientData)
- ClientData clientData; /* Pointer to widget record for widget. */
-{
- TkButton *butPtr = (TkButton *) clientData;
- Tk_Window tkwin = butPtr->tkwin;
-
- /*
- * This procedure could be invoked either because the window was
- * destroyed and the command was then deleted (in which case tkwin
- * is NULL) or because the command was deleted, and then this procedure
- * destroys the widget.
- */
-
- if (tkwin != NULL) {
- butPtr->tkwin = NULL;
- Tk_DestroyWindow(tkwin);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkInvokeButton --
- *
- * This procedure is called to carry out the actions associated
- * with a button, such as invoking a Tcl command or setting a
- * variable. This procedure is invoked, for example, when the
- * button is invoked via the mouse.
- *
- * Results:
- * A standard Tcl return value. Information is also left in
- * interp->result.
- *
- * Side effects:
- * Depends on the button and its associated command.
- *
- *----------------------------------------------------------------------
- */
-
-int
-TkInvokeButton(butPtr)
- register TkButton *butPtr; /* Information about button. */
-{
- if (butPtr->type == TYPE_CHECK_BUTTON) {
- if (butPtr->flags & SELECTED) {
- if (Tcl_SetVar(butPtr->interp, butPtr->selVarName, butPtr->offValue,
- TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG) == NULL) {
- return TCL_ERROR;
- }
- } else {
- if (Tcl_SetVar(butPtr->interp, butPtr->selVarName, butPtr->onValue,
- TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG) == NULL) {
- return TCL_ERROR;
- }
- }
- } else if (butPtr->type == TYPE_RADIO_BUTTON) {
- if (Tcl_SetVar(butPtr->interp, butPtr->selVarName, butPtr->onValue,
- TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG) == NULL) {
- return TCL_ERROR;
- }
- }
- if ((butPtr->type != TYPE_LABEL) && (butPtr->command != NULL)) {
- return TkCopyAndGlobalEval(butPtr->interp, butPtr->command);
- }
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ButtonVarProc --
- *
- * This procedure is invoked when someone changes the
- * state variable associated with a radio button. Depending
- * on the new value of the button's variable, the button
- * may be selected or deselected.
- *
- * Results:
- * NULL is always returned.
- *
- * Side effects:
- * The button may become selected or deselected.
- *
- *--------------------------------------------------------------
- */
-
- /* ARGSUSED */
-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. */
- int flags; /* Information about what happened. */
-{
- register TkButton *butPtr = (TkButton *) clientData;
- char *value;
-
- /*
- * If the variable is being unset, then just re-establish the
- * trace unless the whole interpreter is going away.
- */
-
- if (flags & TCL_TRACE_UNSETS) {
- butPtr->flags &= ~SELECTED;
- if ((flags & TCL_TRACE_DESTROYED) && !(flags & TCL_INTERP_DESTROYED)) {
- Tcl_TraceVar(interp, butPtr->selVarName,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- ButtonVarProc, clientData);
- }
- goto redisplay;
- }
-
- /*
- * Use the value of the variable to update the selected status of
- * the button.
- */
-
- value = Tcl_GetVar(interp, butPtr->selVarName, TCL_GLOBAL_ONLY);
- if (value == NULL) {
- value = "";
- }
- if (strcmp(value, butPtr->onValue) == 0) {
- if (butPtr->flags & SELECTED) {
- return (char *) NULL;
- }
- butPtr->flags |= SELECTED;
- } else if (butPtr->flags & SELECTED) {
- butPtr->flags &= ~SELECTED;
- } else {
- return (char *) NULL;
- }
-
- redisplay:
- if ((butPtr->tkwin != NULL) && Tk_IsMapped(butPtr->tkwin)
- && !(butPtr->flags & REDRAW_PENDING)) {
- Tcl_DoWhenIdle(TkpDisplayButton, (ClientData) butPtr);
- butPtr->flags |= REDRAW_PENDING;
- }
- return (char *) NULL;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ButtonTextVarProc --
- *
- * This procedure is invoked when someone changes the variable
- * whose contents are to be displayed in a button.
- *
- * Results:
- * NULL is always returned.
- *
- * Side effects:
- * The text displayed in the button will change to match the
- * variable.
- *
- *--------------------------------------------------------------
- */
-
- /* ARGSUSED */
-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. */
- int flags; /* Information about what happened. */
-{
- register TkButton *butPtr = (TkButton *) clientData;
- char *value;
-
- /*
- * If the variable is unset, then immediately recreate it unless
- * the whole interpreter is going away.
- */
-
- if (flags & TCL_TRACE_UNSETS) {
- if ((flags & TCL_TRACE_DESTROYED) && !(flags & TCL_INTERP_DESTROYED)) {
- Tcl_SetVar(interp, butPtr->textVarName, butPtr->text,
- TCL_GLOBAL_ONLY);
- Tcl_TraceVar(interp, butPtr->textVarName,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- ButtonTextVarProc, clientData);
- }
- return (char *) NULL;
- }
-
- value = Tcl_GetVar(interp, butPtr->textVarName, TCL_GLOBAL_ONLY);
- if (value == NULL) {
- value = "";
- }
- if (butPtr->text != NULL) {
- ckfree(butPtr->text);
- }
- butPtr->text = (char *) ckalloc((unsigned) (strlen(value) + 1));
- strcpy(butPtr->text, value);
- TkpComputeButtonGeometry(butPtr);
-
- if ((butPtr->tkwin != NULL) && Tk_IsMapped(butPtr->tkwin)
- && !(butPtr->flags & REDRAW_PENDING)) {
- Tcl_DoWhenIdle(TkpDisplayButton, (ClientData) butPtr);
- butPtr->flags |= REDRAW_PENDING;
- }
- return (char *) NULL;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ButtonImageProc --
- *
- * This procedure is invoked by the image code whenever the manager
- * for an image does something that affects the size of contents
- * of an image displayed in a button.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Arranges for the button to get redisplayed.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-ButtonImageProc(clientData, x, y, width, height, imgWidth, imgHeight)
- ClientData clientData; /* Pointer to widget record. */
- int x, y; /* Upper left pixel (within image)
- * that must be redisplayed. */
- int width, height; /* Dimensions of area to redisplay
- * (may be <= 0). */
- int imgWidth, imgHeight; /* New dimensions of image. */
-{
- register TkButton *butPtr = (TkButton *) clientData;
-
- if (butPtr->tkwin != NULL) {
- TkpComputeButtonGeometry(butPtr);
- if (Tk_IsMapped(butPtr->tkwin) && !(butPtr->flags & REDRAW_PENDING)) {
- Tcl_DoWhenIdle(TkpDisplayButton, (ClientData) butPtr);
- butPtr->flags |= REDRAW_PENDING;
- }
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ButtonSelectImageProc --
- *
- * This procedure is invoked by the image code whenever the manager
- * for an image does something that affects the size of contents
- * of the image displayed in a button when it is selected.
- *
- * Results:
- * None.
- *
- * Side effects:
- * May arrange for the button to get redisplayed.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-ButtonSelectImageProc(clientData, x, y, width, height, imgWidth, imgHeight)
- ClientData clientData; /* Pointer to widget record. */
- int x, y; /* Upper left pixel (within image)
- * that must be redisplayed. */
- int width, height; /* Dimensions of area to redisplay
- * (may be <= 0). */
- int imgWidth, imgHeight; /* New dimensions of image. */
-{
- register TkButton *butPtr = (TkButton *) clientData;
-
- /*
- * Don't recompute geometry: it's controlled by the primary image.
- */
-
- if ((butPtr->flags & SELECTED) && (butPtr->tkwin != NULL)
- && Tk_IsMapped(butPtr->tkwin)
- && !(butPtr->flags & REDRAW_PENDING)) {
- Tcl_DoWhenIdle(TkpDisplayButton, (ClientData) butPtr);
- butPtr->flags |= REDRAW_PENDING;
- }
-}
diff --git a/generic/tkButton.h b/generic/tkButton.h
deleted file mode 100644
index a873dbe..0000000
--- a/generic/tkButton.h
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- * tkButton.h --
- *
- * Declarations of types and functions used to implement
- * button-like widgets.
- *
- * Copyright (c) 1996 by 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: tkButton.h,v 1.4 1998/09/14 18:23:04 stanton Exp $
- */
-
-#ifndef _TKBUTTON
-#define _TKBUTTON
-
-#ifndef _TKINT
-#include "tkInt.h"
-#endif
-
-#ifdef BUILD_tk
-# undef TCL_STORAGE_CLASS
-# define TCL_STORAGE_CLASS DLLEXPORT
-#endif
-
-/*
- * A data structure of the following type is kept for each
- * widget managed by this file:
- */
-
-typedef struct {
- Tk_Window tkwin; /* Window that embodies the button. NULL
- * means that the window has been destroyed. */
- Display *display; /* Display containing widget. Needed to
- * free up resources after tkwin is gone. */
- Tcl_Interp *interp; /* Interpreter associated with button. */
- Tcl_Command widgetCmd; /* Token for button's widget command. */
- int type; /* Type of widget: restricts operations
- * that may be performed on widget. See
- * below for possible values. */
-
- /*
- * Information about what's in the button.
- */
-
- char *text; /* Text to display in button (malloc'ed)
- * or NULL. */
- int underline; /* Index of character to underline. < 0 means
- * don't underline anything. */
- char *textVarName; /* Name of variable (malloc'ed) or NULL.
- * If non-NULL, button displays the contents
- * of this variable. */
- Pixmap bitmap; /* Bitmap to display or None. If not None
- * then text and textVar are ignored. */
- char *imageString; /* Name of image to display (malloc'ed), or
- * NULL. If non-NULL, bitmap, text, and
- * textVarName are ignored. */
- Tk_Image image; /* Image to display in window, or NULL if
- * none. */
- char *selectImageString; /* Name of image to display when selected
- * (malloc'ed), or NULL. */
- Tk_Image selectImage; /* Image to display in window when selected,
- * or NULL if none. Ignored if image is
- * NULL. */
-
- /*
- * Information used when displaying widget:
- */
-
- Tk_Uid state; /* State of button for display purposes:
- * normal, active, or disabled. */
- Tk_3DBorder normalBorder; /* Structure used to draw 3-D
- * border and background when window
- * isn't active. NULL means no such
- * border exists. */
- Tk_3DBorder activeBorder; /* Structure used to draw 3-D
- * border and background when window
- * is active. NULL means no such
- * border exists. */
- int borderWidth; /* Width of border. */
- int relief; /* 3-d effect: TK_RELIEF_RAISED, etc. */
- int highlightWidth; /* Width in pixels of highlight to draw
- * around widget when it has the focus.
- * <= 0 means don't draw a highlight. */
- Tk_3DBorder highlightBorder;
- /* Structure used to draw 3-D default ring
- * and focus highlight area when highlight
- * is off. */
- XColor *highlightColorPtr; /* Color for drawing traversal highlight. */
-
- int inset; /* Total width of all borders, including
- * traversal highlight and 3-D border.
- * Indicates how much interior stuff must
- * be offset from outside edges to leave
- * room for borders. */
- Tk_Font tkfont; /* Information about text font, or NULL. */
- XColor *normalFg; /* Foreground color in normal mode. */
- XColor *activeFg; /* Foreground color in active mode. NULL
- * means use normalFg instead. */
- XColor *disabledFg; /* Foreground color when disabled. NULL
- * means use normalFg with a 50% stipple
- * instead. */
- GC normalTextGC; /* GC for drawing text in normal mode. Also
- * used to copy from off-screen pixmap onto
- * screen. */
- GC activeTextGC; /* GC for drawing text in active mode (NULL
- * means use normalTextGC). */
- Pixmap gray; /* Pixmap for displaying disabled text if
- * disabledFg is NULL. */
- GC disabledGC; /* Used to produce disabled effect. If
- * disabledFg isn't NULL, this GC is used to
- * draw button text or icon. Otherwise
- * text or icon is drawn with normalGC and
- * this GC is used to stipple background
- * across it. For labels this is None. */
- GC copyGC; /* Used for copying information from an
- * off-screen pixmap to the screen. */
- char *widthString; /* Value of -width option. Malloc'ed. */
- char *heightString; /* Value of -height option. Malloc'ed. */
- int width, height; /* If > 0, these specify dimensions to request
- * for window, in characters for text and in
- * pixels for bitmaps. In this case the actual
- * size of the text string or bitmap is
- * ignored in computing desired window size. */
- int wrapLength; /* Line length (in pixels) at which to wrap
- * onto next line. <= 0 means don't wrap
- * except at newlines. */
- int padX, padY; /* Extra space around text (pixels to leave
- * on each side). Ignored for bitmaps and
- * images. */
- Tk_Anchor anchor; /* Where text/bitmap should be displayed
- * inside button region. */
- Tk_Justify justify; /* Justification to use for multi-line text. */
- int indicatorOn; /* True means draw indicator, false means
- * don't draw it. */
- Tk_3DBorder selectBorder; /* For drawing indicator background, or perhaps
- * widget background, when selected. */
- int textWidth; /* Width needed to display text as requested,
- * in pixels. */
- int textHeight; /* Height needed to display text as requested,
- * in pixels. */
- Tk_TextLayout textLayout; /* Saved text layout information. */
- int indicatorSpace; /* Horizontal space (in pixels) allocated for
- * display of indicator. */
- int indicatorDiameter; /* Diameter of indicator, in pixels. */
- Tk_Uid defaultState; /* State of default ring: normal, active, or
- * disabled. */
-
- /*
- * For check and radio buttons, the fields below are used
- * to manage the variable indicating the button's state.
- */
-
- char *selVarName; /* Name of variable used to control selected
- * state of button. Malloc'ed (if
- * not NULL). */
- char *onValue; /* Value to store in variable when
- * this button is selected. Malloc'ed (if
- * not NULL). */
- char *offValue; /* Value to store in variable when this
- * button isn't selected. Malloc'ed
- * (if not NULL). Valid only for check
- * buttons. */
-
- /*
- * Miscellaneous information:
- */
-
- Tk_Cursor cursor; /* Current cursor for window, or None. */
- 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 *command; /* Command to execute when button is
- * invoked; valid for buttons only.
- * If not NULL, it's malloc-ed. */
- int flags; /* Various flags; see below for
- * definitions. */
-} TkButton;
-
-/*
- * Possible "type" values for buttons. These are the kinds of
- * widgets supported by this file. The ordering of the type
- * numbers is significant: greater means more features and is
- * used in the code.
- */
-
-#define TYPE_LABEL 0
-#define TYPE_BUTTON 1
-#define TYPE_CHECK_BUTTON 2
-#define TYPE_RADIO_BUTTON 3
-
-/*
- * Flag bits for buttons:
- *
- * REDRAW_PENDING: Non-zero means a DoWhenIdle handler
- * has already been queued to redraw
- * this window.
- * SELECTED: Non-zero means this button is selected,
- * so special highlight should be drawn.
- * GOT_FOCUS: Non-zero means this button currently
- * has the input focus.
- */
-
-#define REDRAW_PENDING 1
-#define SELECTED 2
-#define GOT_FOCUS 4
-
-/*
- * Mask values used to selectively enable entries in the
- * configuration specs:
- */
-
-#define LABEL_MASK TK_CONFIG_USER_BIT
-#define BUTTON_MASK TK_CONFIG_USER_BIT << 1
-#define CHECK_BUTTON_MASK TK_CONFIG_USER_BIT << 2
-#define RADIO_BUTTON_MASK TK_CONFIG_USER_BIT << 3
-#define ALL_MASK (LABEL_MASK | BUTTON_MASK \
- | CHECK_BUTTON_MASK | RADIO_BUTTON_MASK)
-
-/*
- * Declaration of variables shared between the files in the button module.
- */
-
-extern TkClassProcs tkpButtonProcs;
-extern Tk_ConfigSpec tkpButtonConfigSpecs[];
-
-/*
- * Declaration of procedures used in the implementation of the button
- * widget.
- */
-
-EXTERN void TkButtonWorldChanged _ANSI_ARGS_((
- ClientData instanceData));
-EXTERN void TkpComputeButtonGeometry _ANSI_ARGS_((
- TkButton *butPtr));
-EXTERN TkButton * TkpCreateButton _ANSI_ARGS_((Tk_Window tkwin));
-#ifndef TkpDestroyButton
-EXTERN void TkpDestroyButton _ANSI_ARGS_((TkButton *butPtr));
-#endif
-#ifndef TkpDisplayButton
-EXTERN void TkpDisplayButton _ANSI_ARGS_((ClientData clientData));
-#endif
-EXTERN int TkInvokeButton _ANSI_ARGS_((TkButton *butPtr));
-
-# undef TCL_STORAGE_CLASS
-# define TCL_STORAGE_CLASS DLLIMPORT
-
-#endif /* _TKBUTTON */
diff --git a/generic/tkCanvArc.c b/generic/tkCanvArc.c
deleted file mode 100644
index ab48720..0000000
--- a/generic/tkCanvArc.c
+++ /dev/null
@@ -1,1716 +0,0 @@
-/*
- * tkCanvArc.c --
- *
- * This file implements arc items for canvas widgets.
- *
- * Copyright (c) 1992-1994 The Regents of the University of California.
- * Copyright (c) 1994-1995 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: tkCanvArc.c,v 1.3 1998/09/14 18:23:04 stanton Exp $
- */
-
-#include <stdio.h>
-#include "tkPort.h"
-#include "tkInt.h"
-
-/*
- * The structure below defines the record for each arc item.
- */
-
-typedef struct ArcItem {
- Tk_Item header; /* Generic stuff that's the same for all
- * types. MUST BE FIRST IN STRUCTURE. */
- double bbox[4]; /* Coordinates (x1, y1, x2, y2) of bounding
- * box for oval of which arc is a piece. */
- double start; /* Angle at which arc begins, in degrees
- * between 0 and 360. */
- double extent; /* Extent of arc (angular distance from
- * start to end of arc) in degrees between
- * -360 and 360. */
- double *outlinePtr; /* Points to (x,y) coordinates for points
- * that define one or two closed polygons
- * representing the portion of the outline
- * that isn't part of the arc (the V-shape
- * for a pie slice or a line-like segment
- * for a chord). Malloc'ed. */
- int numOutlinePoints; /* Number of points at outlinePtr. Zero
- * means no space allocated. */
- int width; /* Width of outline (in pixels). */
- XColor *outlineColor; /* Color for outline. NULL means don't
- * draw outline. */
- XColor *fillColor; /* Color for filling arc (used for drawing
- * outline too when style is "arc"). NULL
- * means don't fill arc. */
- Pixmap fillStipple; /* Stipple bitmap for filling item. */
- Pixmap outlineStipple; /* Stipple bitmap for outline. */
- Tk_Uid style; /* How to draw arc: arc, chord, or pieslice. */
- GC outlineGC; /* Graphics context for outline. */
- GC fillGC; /* Graphics context for filling item. */
- double center1[2]; /* Coordinates of center of arc outline at
- * start (see ComputeArcOutline). */
- double center2[2]; /* Coordinates of center of arc outline at
- * start+extent (see ComputeArcOutline). */
-} ArcItem;
-
-/*
- * The definitions below define the sizes of the polygons used to
- * display outline information for various styles of arcs:
- */
-
-#define CHORD_OUTLINE_PTS 7
-#define PIE_OUTLINE1_PTS 6
-#define PIE_OUTLINE2_PTS 7
-
-/*
- * Information used for parsing configuration specs:
- */
-
-static Tk_CustomOption tagsOption = {Tk_CanvasTagsParseProc,
- Tk_CanvasTagsPrintProc, (ClientData) NULL
-};
-
-static Tk_ConfigSpec configSpecs[] = {
- {TK_CONFIG_DOUBLE, "-extent", (char *) NULL, (char *) NULL,
- "90", Tk_Offset(ArcItem, extent), TK_CONFIG_DONT_SET_DEFAULT},
- {TK_CONFIG_COLOR, "-fill", (char *) NULL, (char *) NULL,
- (char *) NULL, Tk_Offset(ArcItem, fillColor), TK_CONFIG_NULL_OK},
- {TK_CONFIG_COLOR, "-outline", (char *) NULL, (char *) NULL,
- "black", Tk_Offset(ArcItem, outlineColor), TK_CONFIG_NULL_OK},
- {TK_CONFIG_BITMAP, "-outlinestipple", (char *) NULL, (char *) NULL,
- (char *) NULL, Tk_Offset(ArcItem, outlineStipple), TK_CONFIG_NULL_OK},
- {TK_CONFIG_DOUBLE, "-start", (char *) NULL, (char *) NULL,
- "0", Tk_Offset(ArcItem, start), TK_CONFIG_DONT_SET_DEFAULT},
- {TK_CONFIG_BITMAP, "-stipple", (char *) NULL, (char *) NULL,
- (char *) NULL, Tk_Offset(ArcItem, fillStipple), TK_CONFIG_NULL_OK},
- {TK_CONFIG_UID, "-style", (char *) NULL, (char *) NULL,
- "pieslice", Tk_Offset(ArcItem, style), TK_CONFIG_DONT_SET_DEFAULT},
- {TK_CONFIG_CUSTOM, "-tags", (char *) NULL, (char *) NULL,
- (char *) NULL, 0, TK_CONFIG_NULL_OK, &tagsOption},
- {TK_CONFIG_PIXELS, "-width", (char *) NULL, (char *) NULL,
- "1", Tk_Offset(ArcItem, width), TK_CONFIG_DONT_SET_DEFAULT},
- {TK_CONFIG_END, (char *) NULL, (char *) NULL, (char *) NULL,
- (char *) NULL, 0, 0}
-};
-
-/*
- * Prototypes for procedures defined in this file:
- */
-
-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,
- char **argv, int flags));
-static int CreateArc _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Canvas canvas, struct Tk_Item *itemPtr,
- int argc, char **argv));
-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,
- char **argv));
-static int ArcToArea _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double *rectPtr));
-static double ArcToPoint _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double *coordPtr));
-static int ArcToPostscript _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Canvas canvas, Tk_Item *itemPtr, int prepass));
-static void ScaleArc _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double originX, double originY,
- double scaleX, double scaleY));
-static void TranslateArc _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double deltaX, double deltaY));
-static int AngleInRange _ANSI_ARGS_((double x, double y,
- double start, double extent));
-static void ComputeArcOutline _ANSI_ARGS_((ArcItem *arcPtr));
-static int HorizLineToArc _ANSI_ARGS_((double x1, double x2,
- double y, double rx, double ry,
- double start, double extent));
-static int VertLineToArc _ANSI_ARGS_((double x, double y1,
- double y2, double rx, double ry,
- double start, double extent));
-
-/*
- * The structures below defines the arc item types by means of procedures
- * that can be invoked by generic item code.
- */
-
-Tk_ItemType tkArcType = {
- "arc", /* name */
- sizeof(ArcItem), /* itemSize */
- CreateArc, /* createProc */
- configSpecs, /* configSpecs */
- ConfigureArc, /* configureProc */
- ArcCoords, /* coordProc */
- DeleteArc, /* deleteProc */
- DisplayArc, /* displayProc */
- 0, /* alwaysRedraw */
- ArcToPoint, /* pointProc */
- ArcToArea, /* areaProc */
- ArcToPostscript, /* postscriptProc */
- ScaleArc, /* scaleProc */
- TranslateArc, /* translateProc */
- (Tk_ItemIndexProc *) NULL, /* indexProc */
- (Tk_ItemCursorProc *) NULL, /* icursorProc */
- (Tk_ItemSelectionProc *) NULL, /* selectionProc */
- (Tk_ItemInsertProc *) NULL, /* insertProc */
- (Tk_ItemDCharsProc *) NULL, /* dTextProc */
- (Tk_ItemType *) NULL /* nextPtr */
-};
-
-#ifndef PI
-# define PI 3.14159265358979323846
-#endif
-
-/*
- * The uid's below comprise the legal values for the "-style"
- * option for arcs.
- */
-
-static Tk_Uid arcUid = NULL;
-static Tk_Uid chordUid = NULL;
-static Tk_Uid pieSliceUid = NULL;
-
-/*
- *--------------------------------------------------------------
- *
- * CreateArc --
- *
- * This procedure is invoked to create a new arc item in
- * a canvas.
- *
- * Results:
- * A standard Tcl return value. If an error occurred in
- * creating the item, then an error message is left in
- * interp->result; in this case itemPtr is
- * left uninitialized, so it can be safely freed by the
- * caller.
- *
- * Side effects:
- * A new arc item is created.
- *
- *--------------------------------------------------------------
- */
-
-static int
-CreateArc(interp, canvas, itemPtr, argc, argv)
- 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. */
- char **argv; /* Arguments describing arc. */
-{
- ArcItem *arcPtr = (ArcItem *) itemPtr;
-
- if (argc < 4) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- Tk_PathName(Tk_CanvasTkwin(canvas)), " create ",
- itemPtr->typePtr->name, " x1 y1 x2 y2 ?options?\"",
- (char *) NULL);
- return TCL_ERROR;
- }
-
- /*
- * Carry out once-only initialization.
- */
-
- if (arcUid == NULL) {
- arcUid = Tk_GetUid("arc");
- chordUid = Tk_GetUid("chord");
- pieSliceUid = Tk_GetUid("pieslice");
- }
-
- /*
- * Carry out initialization that is needed in order to clean
- * up after errors during the the remainder of this procedure.
- */
-
- arcPtr->start = 0;
- arcPtr->extent = 90;
- arcPtr->outlinePtr = NULL;
- arcPtr->numOutlinePoints = 0;
- arcPtr->width = 1;
- arcPtr->outlineColor = NULL;
- arcPtr->fillColor = NULL;
- arcPtr->fillStipple = None;
- arcPtr->outlineStipple = None;
- arcPtr->style = pieSliceUid;
- arcPtr->outlineGC = None;
- arcPtr->fillGC = None;
-
- /*
- * Process the arguments to fill in the item record.
- */
-
- if ((Tk_CanvasGetCoord(interp, canvas, argv[0], &arcPtr->bbox[0]) != TCL_OK)
- || (Tk_CanvasGetCoord(interp, canvas, argv[1],
- &arcPtr->bbox[1]) != TCL_OK)
- || (Tk_CanvasGetCoord(interp, canvas, argv[2],
- &arcPtr->bbox[2]) != TCL_OK)
- || (Tk_CanvasGetCoord(interp, canvas, argv[3],
- &arcPtr->bbox[3]) != TCL_OK)) {
- return TCL_ERROR;
- }
-
- if (ConfigureArc(interp, canvas, itemPtr, argc-4, argv+4, 0) != TCL_OK) {
- DeleteArc(canvas, itemPtr, Tk_Display(Tk_CanvasTkwin(canvas)));
- return TCL_ERROR;
- }
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ArcCoords --
- *
- * This procedure is invoked to process the "coords" widget
- * command on arcs. See the user documentation for details
- * on what it does.
- *
- * Results:
- * Returns TCL_OK or TCL_ERROR, and sets interp->result.
- *
- * Side effects:
- * The coordinates for the given item may be changed.
- *
- *--------------------------------------------------------------
- */
-
-static int
-ArcCoords(interp, canvas, itemPtr, argc, argv)
- 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. */
- char **argv; /* Array of coordinates: x1, y1,
- * x2, y2, ... */
-{
- ArcItem *arcPtr = (ArcItem *) itemPtr;
- char c0[TCL_DOUBLE_SPACE], c1[TCL_DOUBLE_SPACE];
- char c2[TCL_DOUBLE_SPACE], c3[TCL_DOUBLE_SPACE];
-
- if (argc == 0) {
- Tcl_PrintDouble(interp, arcPtr->bbox[0], c0);
- Tcl_PrintDouble(interp, arcPtr->bbox[1], c1);
- Tcl_PrintDouble(interp, arcPtr->bbox[2], c2);
- Tcl_PrintDouble(interp, arcPtr->bbox[3], c3);
- Tcl_AppendResult(interp, c0, " ", c1, " ", c2, " ", c3,
- (char *) NULL);
- } else if (argc == 4) {
- if ((Tk_CanvasGetCoord(interp, canvas, argv[0],
- &arcPtr->bbox[0]) != TCL_OK)
- || (Tk_CanvasGetCoord(interp, canvas, argv[1],
- &arcPtr->bbox[1]) != TCL_OK)
- || (Tk_CanvasGetCoord(interp, canvas, argv[2],
- &arcPtr->bbox[2]) != TCL_OK)
- || (Tk_CanvasGetCoord(interp, canvas, argv[3],
- &arcPtr->bbox[3]) != TCL_OK)) {
- return TCL_ERROR;
- }
- ComputeArcBbox(canvas, arcPtr);
- } else {
- sprintf(interp->result,
- "wrong # coordinates: expected 0 or 4, got %d",
- argc);
- return TCL_ERROR;
- }
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ConfigureArc --
- *
- * This procedure is invoked to configure various aspects
- * of a arc item, such as its outline and fill colors.
- *
- * Results:
- * A standard Tcl result code. If an error occurs, then
- * an error message is left in interp->result.
- *
- * Side effects:
- * Configuration information, such as colors and stipple
- * patterns, may be set for itemPtr.
- *
- *--------------------------------------------------------------
- */
-
-static int
-ConfigureArc(interp, canvas, itemPtr, argc, argv, 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. */
- char **argv; /* Arguments describing things to configure. */
- int flags; /* Flags to pass to Tk_ConfigureWidget. */
-{
- ArcItem *arcPtr = (ArcItem *) itemPtr;
- XGCValues gcValues;
- GC newGC;
- unsigned long mask;
- int i;
- Tk_Window tkwin;
-
- tkwin = Tk_CanvasTkwin(canvas);
- if (Tk_ConfigureWidget(interp, tkwin, configSpecs, argc, argv,
- (char *) arcPtr, flags) != TCL_OK) {
- return TCL_ERROR;
- }
-
- /*
- * A few of the options require additional processing, such as
- * style and graphics contexts.
- */
-
- i = (int) (arcPtr->start/360.0);
- arcPtr->start -= i*360.0;
- if (arcPtr->start < 0) {
- arcPtr->start += 360.0;
- }
- i = (int) (arcPtr->extent/360.0);
- arcPtr->extent -= i*360.0;
-
- if ((arcPtr->style != arcUid) && (arcPtr->style != chordUid)
- && (arcPtr->style != pieSliceUid)) {
- Tcl_AppendResult(interp, "bad -style option \"",
- arcPtr->style, "\": must be arc, chord, or pieslice",
- (char *) NULL);
- arcPtr->style = pieSliceUid;
- return TCL_ERROR;
- }
-
- if (arcPtr->width < 0) {
- arcPtr->width = 1;
- }
- if (arcPtr->outlineColor == NULL) {
- newGC = None;
- } else {
- gcValues.foreground = arcPtr->outlineColor->pixel;
- gcValues.cap_style = CapButt;
- gcValues.line_width = arcPtr->width;
- mask = GCForeground|GCCapStyle|GCLineWidth;
- if (arcPtr->outlineStipple != None) {
- gcValues.stipple = arcPtr->outlineStipple;
- gcValues.fill_style = FillStippled;
- mask |= GCStipple|GCFillStyle;
- }
- newGC = Tk_GetGC(tkwin, mask, &gcValues);
- }
- if (arcPtr->outlineGC != None) {
- Tk_FreeGC(Tk_Display(tkwin), arcPtr->outlineGC);
- }
- arcPtr->outlineGC = newGC;
-
- if ((arcPtr->fillColor == NULL) || (arcPtr->style == arcUid)) {
- newGC = None;
- } else {
- gcValues.foreground = arcPtr->fillColor->pixel;
- if (arcPtr->style == chordUid) {
- gcValues.arc_mode = ArcChord;
- } else {
- gcValues.arc_mode = ArcPieSlice;
- }
- mask = GCForeground|GCArcMode;
- if (arcPtr->fillStipple != None) {
- gcValues.stipple = arcPtr->fillStipple;
- gcValues.fill_style = FillStippled;
- mask |= GCStipple|GCFillStyle;
- }
- newGC = Tk_GetGC(tkwin, mask, &gcValues);
- }
- if (arcPtr->fillGC != None) {
- Tk_FreeGC(Tk_Display(tkwin), arcPtr->fillGC);
- }
- arcPtr->fillGC = newGC;
-
- ComputeArcBbox(canvas, arcPtr);
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * DeleteArc --
- *
- * This procedure is called to clean up the data structure
- * associated with a arc item.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Resources associated with itemPtr are released.
- *
- *--------------------------------------------------------------
- */
-
-static void
-DeleteArc(canvas, itemPtr, display)
- Tk_Canvas canvas; /* Info about overall canvas. */
- Tk_Item *itemPtr; /* Item that is being deleted. */
- Display *display; /* Display containing window for
- * canvas. */
-{
- ArcItem *arcPtr = (ArcItem *) itemPtr;
-
- if (arcPtr->numOutlinePoints != 0) {
- ckfree((char *) arcPtr->outlinePtr);
- }
- if (arcPtr->outlineColor != NULL) {
- Tk_FreeColor(arcPtr->outlineColor);
- }
- if (arcPtr->fillColor != NULL) {
- Tk_FreeColor(arcPtr->fillColor);
- }
- if (arcPtr->fillStipple != None) {
- Tk_FreeBitmap(display, arcPtr->fillStipple);
- }
- if (arcPtr->outlineStipple != None) {
- Tk_FreeBitmap(display, arcPtr->outlineStipple);
- }
- if (arcPtr->outlineGC != None) {
- Tk_FreeGC(display, arcPtr->outlineGC);
- }
- if (arcPtr->fillGC != None) {
- Tk_FreeGC(display, arcPtr->fillGC);
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ComputeArcBbox --
- *
- * This procedure is invoked to compute the bounding box of
- * all the pixels that may be drawn as part of an arc.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The fields x1, y1, x2, and y2 are updated in the header
- * for itemPtr.
- *
- *--------------------------------------------------------------
- */
-
- /* ARGSUSED */
-static void
-ComputeArcBbox(canvas, arcPtr)
- Tk_Canvas canvas; /* Canvas that contains item. */
- ArcItem *arcPtr; /* Item whose bbox is to be
- * recomputed. */
-{
- double tmp, center[2], point[2];
-
- /*
- * Make sure that the first coordinates are the lowest ones.
- */
-
- if (arcPtr->bbox[1] > arcPtr->bbox[3]) {
- double tmp;
- tmp = arcPtr->bbox[3];
- arcPtr->bbox[3] = arcPtr->bbox[1];
- arcPtr->bbox[1] = tmp;
- }
- if (arcPtr->bbox[0] > arcPtr->bbox[2]) {
- double tmp;
- tmp = arcPtr->bbox[2];
- arcPtr->bbox[2] = arcPtr->bbox[0];
- arcPtr->bbox[0] = tmp;
- }
-
- ComputeArcOutline(arcPtr);
-
- /*
- * To compute the bounding box, start with the the bbox formed
- * by the two endpoints of the arc. Then add in the center of
- * the arc's oval (if relevant) and the 3-o'clock, 6-o'clock,
- * 9-o'clock, and 12-o'clock positions, if they are relevant.
- */
-
- arcPtr->header.x1 = arcPtr->header.x2 = (int) arcPtr->center1[0];
- arcPtr->header.y1 = arcPtr->header.y2 = (int) arcPtr->center1[1];
- TkIncludePoint((Tk_Item *) arcPtr, arcPtr->center2);
- center[0] = (arcPtr->bbox[0] + arcPtr->bbox[2])/2;
- center[1] = (arcPtr->bbox[1] + arcPtr->bbox[3])/2;
- if (arcPtr->style == pieSliceUid) {
- TkIncludePoint((Tk_Item *) arcPtr, center);
- }
-
- tmp = -arcPtr->start;
- if (tmp < 0) {
- tmp += 360.0;
- }
- if ((tmp < arcPtr->extent) || ((tmp-360) > arcPtr->extent)) {
- point[0] = arcPtr->bbox[2];
- point[1] = center[1];
- TkIncludePoint((Tk_Item *) arcPtr, point);
- }
- tmp = 90.0 - arcPtr->start;
- if (tmp < 0) {
- tmp += 360.0;
- }
- if ((tmp < arcPtr->extent) || ((tmp-360) > arcPtr->extent)) {
- point[0] = center[0];
- point[1] = arcPtr->bbox[1];
- TkIncludePoint((Tk_Item *) arcPtr, point);
- }
- tmp = 180.0 - arcPtr->start;
- if (tmp < 0) {
- tmp += 360.0;
- }
- if ((tmp < arcPtr->extent) || ((tmp-360) > arcPtr->extent)) {
- point[0] = arcPtr->bbox[0];
- point[1] = center[1];
- TkIncludePoint((Tk_Item *) arcPtr, point);
- }
- tmp = 270.0 - arcPtr->start;
- if (tmp < 0) {
- tmp += 360.0;
- }
- if ((tmp < arcPtr->extent) || ((tmp-360) > arcPtr->extent)) {
- point[0] = center[0];
- point[1] = arcPtr->bbox[3];
- TkIncludePoint((Tk_Item *) arcPtr, point);
- }
-
- /*
- * Lastly, expand by the width of the arc (if the arc's outline is
- * being drawn) and add one extra pixel just for safety.
- */
-
- if (arcPtr->outlineColor == NULL) {
- tmp = 1;
- } else {
- tmp = (arcPtr->width + 1)/2 + 1;
- }
- arcPtr->header.x1 -= (int) tmp;
- arcPtr->header.y1 -= (int) tmp;
- arcPtr->header.x2 += (int) tmp;
- arcPtr->header.y2 += (int) tmp;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * DisplayArc --
- *
- * This procedure is invoked to draw an arc item in a given
- * drawable.
- *
- * Results:
- * None.
- *
- * Side effects:
- * ItemPtr is drawn in drawable using the transformation
- * information in canvas.
- *
- *--------------------------------------------------------------
- */
-
-static void
-DisplayArc(canvas, itemPtr, display, drawable, x, y, width, height)
- Tk_Canvas canvas; /* Canvas that contains item. */
- Tk_Item *itemPtr; /* Item to be displayed. */
- Display *display; /* Display on which to draw item. */
- Drawable drawable; /* Pixmap or window in which to draw
- * item. */
- int x, y, width, height; /* Describes region of canvas that
- * must be redisplayed (not used). */
-{
- ArcItem *arcPtr = (ArcItem *) itemPtr;
- short x1, y1, x2, y2;
- int start, extent;
-
- /*
- * Compute the screen coordinates of the bounding box for the item,
- * plus integer values for the angles.
- */
-
- Tk_CanvasDrawableCoords(canvas, arcPtr->bbox[0], arcPtr->bbox[1],
- &x1, &y1);
- Tk_CanvasDrawableCoords(canvas, arcPtr->bbox[2], arcPtr->bbox[3],
- &x2, &y2);
- if (x2 <= x1) {
- x2 = x1+1;
- }
- if (y2 <= y1) {
- y2 = y1+1;
- }
- start = (int) ((64*arcPtr->start) + 0.5);
- extent = (int) ((64*arcPtr->extent) + 0.5);
-
- /*
- * Display filled arc first (if wanted), then outline. If the extent
- * is zero then don't invoke XFillArc or XDrawArc, since this causes
- * some window servers to crash and should be a no-op anyway.
- */
-
- if ((arcPtr->fillGC != None) && (extent != 0)) {
- if (arcPtr->fillStipple != None) {
- Tk_CanvasSetStippleOrigin(canvas, arcPtr->fillGC);
- }
- XFillArc(display, drawable, arcPtr->fillGC, x1, y1, (unsigned) (x2-x1),
- (unsigned) (y2-y1), start, extent);
- if (arcPtr->fillStipple != None) {
- XSetTSOrigin(display, arcPtr->fillGC, 0, 0);
- }
- }
- if (arcPtr->outlineGC != None) {
- if (arcPtr->outlineStipple != None) {
- Tk_CanvasSetStippleOrigin(canvas, arcPtr->outlineGC);
- }
- if (extent != 0) {
- XDrawArc(display, drawable, arcPtr->outlineGC, x1, y1,
- (unsigned) (x2-x1), (unsigned) (y2-y1), start, extent);
- }
-
- /*
- * If the outline width is very thin, don't use polygons to draw
- * the linear parts of the outline (this often results in nothing
- * being displayed); just draw lines instead.
- */
-
- if (arcPtr->width <= 2) {
- Tk_CanvasDrawableCoords(canvas, arcPtr->center1[0],
- arcPtr->center1[1], &x1, &y1);
- Tk_CanvasDrawableCoords(canvas, arcPtr->center2[0],
- arcPtr->center2[1], &x2, &y2);
-
- if (arcPtr->style == chordUid) {
- XDrawLine(display, drawable, arcPtr->outlineGC,
- x1, y1, x2, y2);
- } else if (arcPtr->style == pieSliceUid) {
- short cx, cy;
-
- Tk_CanvasDrawableCoords(canvas,
- (arcPtr->bbox[0] + arcPtr->bbox[2])/2.0,
- (arcPtr->bbox[1] + arcPtr->bbox[3])/2.0, &cx, &cy);
- XDrawLine(display, drawable, arcPtr->outlineGC,
- cx, cy, x1, y1);
- XDrawLine(display, drawable, arcPtr->outlineGC,
- cx, cy, x2, y2);
- }
- } else {
- if (arcPtr->style == chordUid) {
- TkFillPolygon(canvas, arcPtr->outlinePtr, CHORD_OUTLINE_PTS,
- display, drawable, arcPtr->outlineGC, None);
- } else if (arcPtr->style == pieSliceUid) {
- TkFillPolygon(canvas, arcPtr->outlinePtr, PIE_OUTLINE1_PTS,
- display, drawable, arcPtr->outlineGC, None);
- TkFillPolygon(canvas, arcPtr->outlinePtr + 2*PIE_OUTLINE1_PTS,
- PIE_OUTLINE2_PTS, display, drawable, arcPtr->outlineGC,
- None);
- }
- }
- if (arcPtr->outlineStipple != None) {
- XSetTSOrigin(display, arcPtr->outlineGC, 0, 0);
- }
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ArcToPoint --
- *
- * Computes the distance from a given point to a given
- * arc, in canvas units.
- *
- * Results:
- * The return value is 0 if the point whose x and y coordinates
- * are coordPtr[0] and coordPtr[1] is inside the arc. If the
- * point isn't inside the arc then the return value is the
- * distance from the point to the arc. If itemPtr is filled,
- * then anywhere in the interior is considered "inside"; if
- * itemPtr isn't filled, then "inside" means only the area
- * occupied by the outline.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
- /* ARGSUSED */
-static double
-ArcToPoint(canvas, itemPtr, pointPtr)
- Tk_Canvas canvas; /* Canvas containing item. */
- Tk_Item *itemPtr; /* Item to check against point. */
- double *pointPtr; /* Pointer to x and y coordinates. */
-{
- ArcItem *arcPtr = (ArcItem *) itemPtr;
- double vertex[2], pointAngle, diff, dist, newDist;
- double poly[8], polyDist, width, t1, t2;
- int filled, angleInRange;
-
- /*
- * See if the point is within the angular range of the arc.
- * Remember, X angles are backwards from the way we'd normally
- * think of them. Also, compensate for any eccentricity of
- * the oval.
- */
-
- vertex[0] = (arcPtr->bbox[0] + arcPtr->bbox[2])/2.0;
- vertex[1] = (arcPtr->bbox[1] + arcPtr->bbox[3])/2.0;
- t1 = (pointPtr[1] - vertex[1])/(arcPtr->bbox[3] - arcPtr->bbox[1]);
- t2 = (pointPtr[0] - vertex[0])/(arcPtr->bbox[2] - arcPtr->bbox[0]);
- if ((t1 == 0.0) && (t2 == 0.0)) {
- pointAngle = 0;
- } else {
- pointAngle = -atan2(t1, t2)*180/PI;
- }
- diff = pointAngle - arcPtr->start;
- diff -= ((int) (diff/360.0) * 360.0);
- if (diff < 0) {
- diff += 360.0;
- }
- angleInRange = (diff <= arcPtr->extent) ||
- ((arcPtr->extent < 0) && ((diff - 360.0) >= arcPtr->extent));
-
- /*
- * Now perform different tests depending on what kind of arc
- * we're dealing with.
- */
-
- if (arcPtr->style == arcUid) {
- if (angleInRange) {
- return TkOvalToPoint(arcPtr->bbox, (double) arcPtr->width,
- 0, pointPtr);
- }
- dist = hypot(pointPtr[0] - arcPtr->center1[0],
- pointPtr[1] - arcPtr->center1[1]);
- newDist = hypot(pointPtr[0] - arcPtr->center2[0],
- pointPtr[1] - arcPtr->center2[1]);
- if (newDist < dist) {
- return newDist;
- }
- return dist;
- }
-
- if ((arcPtr->fillGC != None) || (arcPtr->outlineGC == None)) {
- filled = 1;
- } else {
- filled = 0;
- }
- if (arcPtr->outlineGC == None) {
- width = 0.0;
- } else {
- width = arcPtr->width;
- }
-
- if (arcPtr->style == pieSliceUid) {
- if (width > 1.0) {
- dist = TkPolygonToPoint(arcPtr->outlinePtr, PIE_OUTLINE1_PTS,
- pointPtr);
- newDist = TkPolygonToPoint(arcPtr->outlinePtr + 2*PIE_OUTLINE1_PTS,
- PIE_OUTLINE2_PTS, pointPtr);
- } else {
- dist = TkLineToPoint(vertex, arcPtr->center1, pointPtr);
- newDist = TkLineToPoint(vertex, arcPtr->center2, pointPtr);
- }
- if (newDist < dist) {
- dist = newDist;
- }
- if (angleInRange) {
- newDist = TkOvalToPoint(arcPtr->bbox, width, filled, pointPtr);
- if (newDist < dist) {
- dist = newDist;
- }
- }
- return dist;
- }
-
- /*
- * This is a chord-style arc. We have to deal specially with the
- * triangular piece that represents the difference between a
- * chord-style arc and a pie-slice arc (for small angles this piece
- * is excluded here where it would be included for pie slices;
- * for large angles the piece is included here but would be
- * excluded for pie slices).
- */
-
- if (width > 1.0) {
- dist = TkPolygonToPoint(arcPtr->outlinePtr, CHORD_OUTLINE_PTS,
- pointPtr);
- } else {
- dist = TkLineToPoint(arcPtr->center1, arcPtr->center2, pointPtr);
- }
- poly[0] = poly[6] = vertex[0];
- poly[1] = poly[7] = vertex[1];
- poly[2] = arcPtr->center1[0];
- poly[3] = arcPtr->center1[1];
- poly[4] = arcPtr->center2[0];
- poly[5] = arcPtr->center2[1];
- polyDist = TkPolygonToPoint(poly, 4, pointPtr);
- if (angleInRange) {
- if ((arcPtr->extent < -180.0) || (arcPtr->extent > 180.0)
- || (polyDist > 0.0)) {
- newDist = TkOvalToPoint(arcPtr->bbox, width, filled, pointPtr);
- if (newDist < dist) {
- dist = newDist;
- }
- }
- } else {
- if ((arcPtr->extent < -180.0) || (arcPtr->extent > 180.0)) {
- if (filled && (polyDist < dist)) {
- dist = polyDist;
- }
- }
- }
- return dist;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ArcToArea --
- *
- * This procedure is called to determine whether an item
- * lies entirely inside, entirely outside, or overlapping
- * a given area.
- *
- * Results:
- * -1 is returned if the item is entirely outside the area
- * given by rectPtr, 0 if it overlaps, and 1 if it is entirely
- * inside the given area.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
- /* ARGSUSED */
-static int
-ArcToArea(canvas, itemPtr, rectPtr)
- Tk_Canvas canvas; /* Canvas containing item. */
- Tk_Item *itemPtr; /* Item to check against arc. */
- double *rectPtr; /* Pointer to array of four coordinates
- * (x1, y1, x2, y2) describing rectangular
- * area. */
-{
- ArcItem *arcPtr = (ArcItem *) itemPtr;
- double rx, ry; /* Radii for transformed oval: these define
- * an oval centered at the origin. */
- double tRect[4]; /* Transformed version of x1, y1, x2, y2,
- * for coord. system where arc is centered
- * on the origin. */
- double center[2], width, angle, tmp;
- double points[20], *pointPtr;
- int numPoints, filled;
- int inside; /* Non-zero means every test so far suggests
- * that arc is inside rectangle. 0 means
- * every test so far shows arc to be outside
- * of rectangle. */
- int newInside;
-
- if ((arcPtr->fillGC != None) || (arcPtr->outlineGC == None)) {
- filled = 1;
- } else {
- filled = 0;
- }
- if (arcPtr->outlineGC == None) {
- width = 0.0;
- } else {
- width = arcPtr->width;
- }
-
- /*
- * Transform both the arc and the rectangle so that the arc's oval
- * is centered on the origin.
- */
-
- center[0] = (arcPtr->bbox[0] + arcPtr->bbox[2])/2.0;
- center[1] = (arcPtr->bbox[1] + arcPtr->bbox[3])/2.0;
- tRect[0] = rectPtr[0] - center[0];
- tRect[1] = rectPtr[1] - center[1];
- tRect[2] = rectPtr[2] - center[0];
- tRect[3] = rectPtr[3] - center[1];
- rx = arcPtr->bbox[2] - center[0] + width/2.0;
- ry = arcPtr->bbox[3] - center[1] + width/2.0;
-
- /*
- * Find the extreme points of the arc and see whether these are all
- * inside the rectangle (in which case we're done), partly in and
- * partly out (in which case we're done), or all outside (in which
- * case we have more work to do). The extreme points include the
- * following, which are checked in order:
- *
- * 1. The outside points of the arc, corresponding to start and
- * extent.
- * 2. The center of the arc (but only in pie-slice mode).
- * 3. The 12, 3, 6, and 9-o'clock positions (but only if the arc
- * includes those angles).
- */
-
- pointPtr = points;
- angle = -arcPtr->start*(PI/180.0);
- pointPtr[0] = rx*cos(angle);
- pointPtr[1] = ry*sin(angle);
- angle += -arcPtr->extent*(PI/180.0);
- pointPtr[2] = rx*cos(angle);
- pointPtr[3] = ry*sin(angle);
- numPoints = 2;
- pointPtr += 4;
-
- if ((arcPtr->style == pieSliceUid) && (arcPtr->extent < 180.0)) {
- pointPtr[0] = 0.0;
- pointPtr[1] = 0.0;
- numPoints++;
- pointPtr += 2;
- }
-
- tmp = -arcPtr->start;
- if (tmp < 0) {
- tmp += 360.0;
- }
- if ((tmp < arcPtr->extent) || ((tmp-360) > arcPtr->extent)) {
- pointPtr[0] = rx;
- pointPtr[1] = 0.0;
- numPoints++;
- pointPtr += 2;
- }
- tmp = 90.0 - arcPtr->start;
- if (tmp < 0) {
- tmp += 360.0;
- }
- if ((tmp < arcPtr->extent) || ((tmp-360) > arcPtr->extent)) {
- pointPtr[0] = 0.0;
- pointPtr[1] = -ry;
- numPoints++;
- pointPtr += 2;
- }
- tmp = 180.0 - arcPtr->start;
- if (tmp < 0) {
- tmp += 360.0;
- }
- if ((tmp < arcPtr->extent) || ((tmp-360) > arcPtr->extent)) {
- pointPtr[0] = -rx;
- pointPtr[1] = 0.0;
- numPoints++;
- pointPtr += 2;
- }
- tmp = 270.0 - arcPtr->start;
- if (tmp < 0) {
- tmp += 360.0;
- }
- if ((tmp < arcPtr->extent) || ((tmp-360) > arcPtr->extent)) {
- pointPtr[0] = 0.0;
- pointPtr[1] = ry;
- numPoints++;
- }
-
- /*
- * Now that we've located the extreme points, loop through them all
- * to see which are inside the rectangle.
- */
-
- inside = (points[0] > tRect[0]) && (points[0] < tRect[2])
- && (points[1] > tRect[1]) && (points[1] < tRect[3]);
- for (pointPtr = points+2; numPoints > 1; pointPtr += 2, numPoints--) {
- newInside = (pointPtr[0] > tRect[0]) && (pointPtr[0] < tRect[2])
- && (pointPtr[1] > tRect[1]) && (pointPtr[1] < tRect[3]);
- if (newInside != inside) {
- return 0;
- }
- }
-
- if (inside) {
- return 1;
- }
-
- /*
- * So far, oval appears to be outside rectangle, but can't yet tell
- * for sure. Next, test each of the four sides of the rectangle
- * against the bounding region for the arc. If any intersections
- * are found, then return "overlapping". First, test against the
- * polygon(s) forming the sides of a chord or pie-slice.
- */
-
- if (arcPtr->style == pieSliceUid) {
- if (width >= 1.0) {
- if (TkPolygonToArea(arcPtr->outlinePtr, PIE_OUTLINE1_PTS,
- rectPtr) != -1) {
- return 0;
- }
- if (TkPolygonToArea(arcPtr->outlinePtr + 2*PIE_OUTLINE1_PTS,
- PIE_OUTLINE2_PTS, rectPtr) != -1) {
- return 0;
- }
- } else {
- if ((TkLineToArea(center, arcPtr->center1, rectPtr) != -1) ||
- (TkLineToArea(center, arcPtr->center2, rectPtr) != -1)) {
- return 0;
- }
- }
- } else if (arcPtr->style == chordUid) {
- if (width >= 1.0) {
- if (TkPolygonToArea(arcPtr->outlinePtr, CHORD_OUTLINE_PTS,
- rectPtr) != -1) {
- return 0;
- }
- } else {
- if (TkLineToArea(arcPtr->center1, arcPtr->center2,
- rectPtr) != -1) {
- return 0;
- }
- }
- }
-
- /*
- * Next check for overlap between each of the four sides and the
- * outer perimiter of the arc. If the arc isn't filled, then also
- * check the inner perimeter of the arc.
- */
-
- if (HorizLineToArc(tRect[0], tRect[2], tRect[1], rx, ry, arcPtr->start,
- arcPtr->extent)
- || HorizLineToArc(tRect[0], tRect[2], tRect[3], rx, ry,
- arcPtr->start, arcPtr->extent)
- || VertLineToArc(tRect[0], tRect[1], tRect[3], rx, ry,
- arcPtr->start, arcPtr->extent)
- || VertLineToArc(tRect[2], tRect[1], tRect[3], rx, ry,
- arcPtr->start, arcPtr->extent)) {
- return 0;
- }
- if ((width > 1.0) && !filled) {
- rx -= width;
- ry -= width;
- if (HorizLineToArc(tRect[0], tRect[2], tRect[1], rx, ry, arcPtr->start,
- arcPtr->extent)
- || HorizLineToArc(tRect[0], tRect[2], tRect[3], rx, ry,
- arcPtr->start, arcPtr->extent)
- || VertLineToArc(tRect[0], tRect[1], tRect[3], rx, ry,
- arcPtr->start, arcPtr->extent)
- || VertLineToArc(tRect[2], tRect[1], tRect[3], rx, ry,
- arcPtr->start, arcPtr->extent)) {
- return 0;
- }
- }
-
- /*
- * The arc still appears to be totally disjoint from the rectangle,
- * but it's also possible that the rectangle is totally inside the arc.
- * Do one last check, which is to check one point of the rectangle
- * to see if it's inside the arc. If it is, we've got overlap. If
- * it isn't, the arc's really outside the rectangle.
- */
-
- if (ArcToPoint(canvas, itemPtr, rectPtr) == 0.0) {
- return 0;
- }
- return -1;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ScaleArc --
- *
- * This procedure is invoked to rescale an arc item.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The arc referred to by itemPtr is rescaled so that the
- * following transformation is applied to all point
- * coordinates:
- * x' = originX + scaleX*(x-originX)
- * y' = originY + scaleY*(y-originY)
- *
- *--------------------------------------------------------------
- */
-
-static void
-ScaleArc(canvas, itemPtr, originX, originY, scaleX, scaleY)
- Tk_Canvas canvas; /* Canvas containing arc. */
- Tk_Item *itemPtr; /* Arc to be scaled. */
- double originX, originY; /* Origin about which to scale rect. */
- double scaleX; /* Amount to scale in X direction. */
- double scaleY; /* Amount to scale in Y direction. */
-{
- ArcItem *arcPtr = (ArcItem *) itemPtr;
-
- arcPtr->bbox[0] = originX + scaleX*(arcPtr->bbox[0] - originX);
- arcPtr->bbox[1] = originY + scaleY*(arcPtr->bbox[1] - originY);
- arcPtr->bbox[2] = originX + scaleX*(arcPtr->bbox[2] - originX);
- arcPtr->bbox[3] = originY + scaleY*(arcPtr->bbox[3] - originY);
- ComputeArcBbox(canvas, arcPtr);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * TranslateArc --
- *
- * This procedure is called to move an arc by a given amount.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The position of the arc is offset by (xDelta, yDelta), and
- * the bounding box is updated in the generic part of the item
- * structure.
- *
- *--------------------------------------------------------------
- */
-
-static void
-TranslateArc(canvas, itemPtr, deltaX, deltaY)
- Tk_Canvas canvas; /* Canvas containing item. */
- Tk_Item *itemPtr; /* Item that is being moved. */
- double deltaX, deltaY; /* Amount by which item is to be
- * moved. */
-{
- ArcItem *arcPtr = (ArcItem *) itemPtr;
-
- arcPtr->bbox[0] += deltaX;
- arcPtr->bbox[1] += deltaY;
- arcPtr->bbox[2] += deltaX;
- arcPtr->bbox[3] += deltaY;
- ComputeArcBbox(canvas, arcPtr);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ComputeArcOutline --
- *
- * This procedure creates a polygon describing everything in
- * the outline for an arc except what's in the curved part.
- * For a "pie slice" arc this is a V-shaped chunk, and for
- * a "chord" arc this is a linear chunk (with cutaway corners).
- * For "arc" arcs, this stuff isn't relevant.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The information at arcPtr->outlinePtr gets modified, and
- * storage for arcPtr->outlinePtr may be allocated or freed.
- *
- *--------------------------------------------------------------
- */
-
-static void
-ComputeArcOutline(arcPtr)
- ArcItem *arcPtr; /* Information about arc. */
-{
- double sin1, cos1, sin2, cos2, angle, halfWidth;
- double boxWidth, boxHeight;
- double vertex[2], corner1[2], corner2[2];
- double *outlinePtr;
-
- /*
- * Make sure that the outlinePtr array is large enough to hold
- * either a chord or pie-slice outline.
- */
-
- if (arcPtr->numOutlinePoints == 0) {
- arcPtr->outlinePtr = (double *) ckalloc((unsigned)
- (26 * sizeof(double)));
- arcPtr->numOutlinePoints = 22;
- }
- outlinePtr = arcPtr->outlinePtr;
-
- /*
- * First compute the two points that lie at the centers of
- * the ends of the curved arc segment, which are marked with
- * X's in the figure below:
- *
- *
- * * * *
- * * *
- * * * * *
- * * * * *
- * * * * *
- * X * * X
- *
- * The code is tricky because the arc can be ovular in shape.
- * It computes the position for a unit circle, and then
- * scales to fit the shape of the arc's bounding box.
- *
- * Also, watch out because angles go counter-clockwise like you
- * might expect, but the y-coordinate system is inverted. To
- * handle this, just negate the angles in all the computations.
- */
-
- boxWidth = arcPtr->bbox[2] - arcPtr->bbox[0];
- boxHeight = arcPtr->bbox[3] - arcPtr->bbox[1];
- angle = -arcPtr->start*PI/180.0;
- sin1 = sin(angle);
- cos1 = cos(angle);
- angle -= arcPtr->extent*PI/180.0;
- sin2 = sin(angle);
- cos2 = cos(angle);
- vertex[0] = (arcPtr->bbox[0] + arcPtr->bbox[2])/2.0;
- vertex[1] = (arcPtr->bbox[1] + arcPtr->bbox[3])/2.0;
- arcPtr->center1[0] = vertex[0] + cos1*boxWidth/2.0;
- arcPtr->center1[1] = vertex[1] + sin1*boxHeight/2.0;
- arcPtr->center2[0] = vertex[0] + cos2*boxWidth/2.0;
- arcPtr->center2[1] = vertex[1] + sin2*boxHeight/2.0;
-
- /*
- * Next compute the "outermost corners" of the arc, which are
- * marked with X's in the figure below:
- *
- * * * *
- * * *
- * * * * *
- * * * * *
- * X * * X
- * * *
- *
- * The code below is tricky because it has to handle eccentricity
- * in the shape of the oval. The key in the code below is to
- * realize that the slope of the line from arcPtr->center1 to corner1
- * is (boxWidth*sin1)/(boxHeight*cos1), and similarly for arcPtr->center2
- * and corner2. These formulas can be computed from the formula for
- * the oval.
- */
-
- halfWidth = arcPtr->width/2.0;
- if (((boxWidth*sin1) == 0.0) && ((boxHeight*cos1) == 0.0)) {
- angle = 0.0;
- } else {
- angle = atan2(boxWidth*sin1, boxHeight*cos1);
- }
- corner1[0] = arcPtr->center1[0] + cos(angle)*halfWidth;
- corner1[1] = arcPtr->center1[1] + sin(angle)*halfWidth;
- if (((boxWidth*sin2) == 0.0) && ((boxHeight*cos2) == 0.0)) {
- angle = 0.0;
- } else {
- angle = atan2(boxWidth*sin2, boxHeight*cos2);
- }
- corner2[0] = arcPtr->center2[0] + cos(angle)*halfWidth;
- corner2[1] = arcPtr->center2[1] + sin(angle)*halfWidth;
-
- /*
- * For a chord outline, generate a six-sided polygon with three
- * points for each end of the chord. The first and third points
- * for each end are butt points generated on either side of the
- * center point. The second point is the corner point.
- */
-
- if (arcPtr->style == chordUid) {
- outlinePtr[0] = outlinePtr[12] = corner1[0];
- outlinePtr[1] = outlinePtr[13] = corner1[1];
- TkGetButtPoints(arcPtr->center2, arcPtr->center1,
- (double) arcPtr->width, 0, outlinePtr+10, outlinePtr+2);
- outlinePtr[4] = arcPtr->center2[0] + outlinePtr[2]
- - arcPtr->center1[0];
- outlinePtr[5] = arcPtr->center2[1] + outlinePtr[3]
- - arcPtr->center1[1];
- outlinePtr[6] = corner2[0];
- outlinePtr[7] = corner2[1];
- outlinePtr[8] = arcPtr->center2[0] + outlinePtr[10]
- - arcPtr->center1[0];
- outlinePtr[9] = arcPtr->center2[1] + outlinePtr[11]
- - arcPtr->center1[1];
- } else if (arcPtr->style == pieSliceUid) {
- /*
- * For pie slices, generate two polygons, one for each side
- * of the pie slice. The first arm has a shape like this,
- * where the center of the oval is X, arcPtr->center1 is at Y, and
- * corner1 is at Z:
- *
- * _____________________
- * | \
- * | \
- * X Y Z
- * | /
- * |_____________________/
- *
- */
-
- TkGetButtPoints(arcPtr->center1, vertex, (double) arcPtr->width, 0,
- outlinePtr, outlinePtr+2);
- outlinePtr[4] = arcPtr->center1[0] + outlinePtr[2] - vertex[0];
- outlinePtr[5] = arcPtr->center1[1] + outlinePtr[3] - vertex[1];
- outlinePtr[6] = corner1[0];
- outlinePtr[7] = corner1[1];
- outlinePtr[8] = arcPtr->center1[0] + outlinePtr[0] - vertex[0];
- outlinePtr[9] = arcPtr->center1[1] + outlinePtr[1] - vertex[1];
- outlinePtr[10] = outlinePtr[0];
- outlinePtr[11] = outlinePtr[1];
-
- /*
- * The second arm has a shape like this:
- *
- *
- * ______________________
- * / \
- * / \
- * Z Y X /
- * \ /
- * \______________________/
- *
- * Similar to above X is the center of the oval/circle, Y is
- * arcPtr->center2, and Z is corner2. The extra jog out to the left
- * of X is needed in or to produce a butted joint with the
- * first arm; the corner to the right of X is one of the
- * first two points of the first arm, depending on extent.
- */
-
- TkGetButtPoints(arcPtr->center2, vertex, (double) arcPtr->width, 0,
- outlinePtr+12, outlinePtr+16);
- if ((arcPtr->extent > 180) ||
- ((arcPtr->extent < 0) && (arcPtr->extent > -180))) {
- outlinePtr[14] = outlinePtr[0];
- outlinePtr[15] = outlinePtr[1];
- } else {
- outlinePtr[14] = outlinePtr[2];
- outlinePtr[15] = outlinePtr[3];
- }
- outlinePtr[18] = arcPtr->center2[0] + outlinePtr[16] - vertex[0];
- outlinePtr[19] = arcPtr->center2[1] + outlinePtr[17] - vertex[1];
- outlinePtr[20] = corner2[0];
- outlinePtr[21] = corner2[1];
- outlinePtr[22] = arcPtr->center2[0] + outlinePtr[12] - vertex[0];
- outlinePtr[23] = arcPtr->center2[1] + outlinePtr[13] - vertex[1];
- outlinePtr[24] = outlinePtr[12];
- outlinePtr[25] = outlinePtr[13];
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * HorizLineToArc --
- *
- * Determines whether a horizontal line segment intersects
- * a given arc.
- *
- * Results:
- * The return value is 1 if the given line intersects the
- * infinitely-thin arc section defined by rx, ry, start,
- * and extent, and 0 otherwise. Only the perimeter of the
- * arc is checked: interior areas (e.g. pie-slice or chord)
- * are not checked.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-static int
-HorizLineToArc(x1, x2, y, rx, ry, start, extent)
- double x1, x2; /* X-coords of endpoints of line segment.
- * X1 must be <= x2. */
- double y; /* Y-coordinate of line segment. */
- double rx, ry; /* These x- and y-radii define an oval
- * centered at the origin. */
- double start, extent; /* Angles that define extent of arc, in
- * the standard fashion for this module. */
-{
- double tmp;
- double tx, ty; /* Coordinates of intersection point in
- * transformed coordinate system. */
- double x;
-
- /*
- * Compute the x-coordinate of one possible intersection point
- * between the arc and the line. Use a transformed coordinate
- * system where the oval is a unit circle centered at the origin.
- * Then scale back to get actual x-coordinate.
- */
-
- ty = y/ry;
- tmp = 1 - ty*ty;
- if (tmp < 0) {
- return 0;
- }
- tx = sqrt(tmp);
- x = tx*rx;
-
- /*
- * Test both intersection points.
- */
-
- if ((x >= x1) && (x <= x2) && AngleInRange(tx, ty, start, extent)) {
- return 1;
- }
- if ((-x >= x1) && (-x <= x2) && AngleInRange(-tx, ty, start, extent)) {
- return 1;
- }
- return 0;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * VertLineToArc --
- *
- * Determines whether a vertical line segment intersects
- * a given arc.
- *
- * Results:
- * The return value is 1 if the given line intersects the
- * infinitely-thin arc section defined by rx, ry, start,
- * and extent, and 0 otherwise. Only the perimeter of the
- * arc is checked: interior areas (e.g. pie-slice or chord)
- * are not checked.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-static int
-VertLineToArc(x, y1, y2, rx, ry, start, extent)
- double x; /* X-coordinate of line segment. */
- double y1, y2; /* Y-coords of endpoints of line segment.
- * Y1 must be <= y2. */
- double rx, ry; /* These x- and y-radii define an oval
- * centered at the origin. */
- double start, extent; /* Angles that define extent of arc, in
- * the standard fashion for this module. */
-{
- double tmp;
- double tx, ty; /* Coordinates of intersection point in
- * transformed coordinate system. */
- double y;
-
- /*
- * Compute the y-coordinate of one possible intersection point
- * between the arc and the line. Use a transformed coordinate
- * system where the oval is a unit circle centered at the origin.
- * Then scale back to get actual y-coordinate.
- */
-
- tx = x/rx;
- tmp = 1 - tx*tx;
- if (tmp < 0) {
- return 0;
- }
- ty = sqrt(tmp);
- y = ty*ry;
-
- /*
- * Test both intersection points.
- */
-
- if ((y > y1) && (y < y2) && AngleInRange(tx, ty, start, extent)) {
- return 1;
- }
- if ((-y > y1) && (-y < y2) && AngleInRange(tx, -ty, start, extent)) {
- return 1;
- }
- return 0;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * AngleInRange --
- *
- * Determine whether the angle from the origin to a given
- * point is within a given range.
- *
- * Results:
- * The return value is 1 if the angle from (0,0) to (x,y)
- * is in the range given by start and extent, where angles
- * are interpreted in the standard way for ovals (meaning
- * backwards from normal interpretation). Otherwise the
- * return value is 0.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-static int
-AngleInRange(x, y, start, extent)
- double x, y; /* Coordinate of point; angle measured
- * from origin to here, relative to x-axis. */
- double start; /* First angle, degrees, >=0, <=360. */
- double extent; /* Size of arc in degrees >=-360, <=360. */
-{
- double diff;
-
- if ((x == 0.0) && (y == 0.0)) {
- return 1;
- }
- diff = -atan2(y, x);
- diff = diff*(180.0/PI) - start;
- while (diff > 360.0) {
- diff -= 360.0;
- }
- while (diff < 0.0) {
- diff += 360.0;
- }
- if (extent >= 0) {
- return diff <= extent;
- }
- return (diff-360.0) >= extent;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ArcToPostscript --
- *
- * This procedure is called to generate Postscript for
- * arc items.
- *
- * Results:
- * The return value is a standard Tcl result. If an error
- * occurs in generating Postscript then an error message is
- * left in interp->result, replacing whatever used
- * to be there. If no error occurs, then Postscript for the
- * item is appended to the result.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-static int
-ArcToPostscript(interp, canvas, itemPtr, prepass)
- Tcl_Interp *interp; /* Leave Postscript or error message
- * here. */
- Tk_Canvas canvas; /* Information about overall canvas. */
- Tk_Item *itemPtr; /* Item for which Postscript is
- * wanted. */
- int prepass; /* 1 means this is a prepass to
- * collect font information; 0 means
- * final Postscript is being created. */
-{
- ArcItem *arcPtr = (ArcItem *) itemPtr;
- char buffer[400];
- double y1, y2, ang1, ang2;
-
- y1 = Tk_CanvasPsY(canvas, arcPtr->bbox[1]);
- y2 = Tk_CanvasPsY(canvas, arcPtr->bbox[3]);
- ang1 = arcPtr->start;
- ang2 = ang1 + arcPtr->extent;
- if (ang2 < ang1) {
- ang1 = ang2;
- ang2 = arcPtr->start;
- }
-
- /*
- * If the arc is filled, output Postscript for the interior region
- * of the arc.
- */
-
- if (arcPtr->fillGC != None) {
- sprintf(buffer, "matrix currentmatrix\n%.15g %.15g translate %.15g %.15g scale\n",
- (arcPtr->bbox[0] + arcPtr->bbox[2])/2, (y1 + y2)/2,
- (arcPtr->bbox[2] - arcPtr->bbox[0])/2, (y1 - y2)/2);
- Tcl_AppendResult(interp, buffer, (char *) NULL);
- if (arcPtr->style == chordUid) {
- sprintf(buffer, "0 0 1 %.15g %.15g arc closepath\nsetmatrix\n",
- ang1, ang2);
- } else {
- sprintf(buffer,
- "0 0 moveto 0 0 1 %.15g %.15g arc closepath\nsetmatrix\n",
- ang1, ang2);
- }
- Tcl_AppendResult(interp, buffer, (char *) NULL);
- if (Tk_CanvasPsColor(interp, canvas, arcPtr->fillColor) != TCL_OK) {
- return TCL_ERROR;
- };
- if (arcPtr->fillStipple != None) {
- Tcl_AppendResult(interp, "clip ", (char *) NULL);
- if (Tk_CanvasPsStipple(interp, canvas, arcPtr->fillStipple)
- != TCL_OK) {
- return TCL_ERROR;
- }
- if (arcPtr->outlineGC != None) {
- Tcl_AppendResult(interp, "grestore gsave\n", (char *) NULL);
- }
- } else {
- Tcl_AppendResult(interp, "fill\n", (char *) NULL);
- }
- }
-
- /*
- * If there's an outline for the arc, draw it.
- */
-
- if (arcPtr->outlineGC != None) {
- sprintf(buffer, "matrix currentmatrix\n%.15g %.15g translate %.15g %.15g scale\n",
- (arcPtr->bbox[0] + arcPtr->bbox[2])/2, (y1 + y2)/2,
- (arcPtr->bbox[2] - arcPtr->bbox[0])/2, (y1 - y2)/2);
- Tcl_AppendResult(interp, buffer, (char *) NULL);
- sprintf(buffer, "0 0 1 %.15g %.15g arc\nsetmatrix\n", ang1, ang2);
- Tcl_AppendResult(interp, buffer, (char *) NULL);
- sprintf(buffer, "%d setlinewidth\n0 setlinecap\n", arcPtr->width);
- Tcl_AppendResult(interp, buffer, (char *) NULL);
- if (Tk_CanvasPsColor(interp, canvas, arcPtr->outlineColor)
- != TCL_OK) {
- return TCL_ERROR;
- }
- if (arcPtr->outlineStipple != None) {
- Tcl_AppendResult(interp, "StrokeClip ", (char *) NULL);
- if (Tk_CanvasPsStipple(interp, canvas,
- arcPtr->outlineStipple) != TCL_OK) {
- return TCL_ERROR;
- }
- } else {
- Tcl_AppendResult(interp, "stroke\n", (char *) NULL);
- }
- if (arcPtr->style != arcUid) {
- Tcl_AppendResult(interp, "grestore gsave\n", (char *) NULL);
- if (arcPtr->style == chordUid) {
- Tk_CanvasPsPath(interp, canvas, arcPtr->outlinePtr,
- CHORD_OUTLINE_PTS);
- } else {
- Tk_CanvasPsPath(interp, canvas, arcPtr->outlinePtr,
- PIE_OUTLINE1_PTS);
- if (Tk_CanvasPsColor(interp, canvas, arcPtr->outlineColor)
- != TCL_OK) {
- return TCL_ERROR;
- }
- if (arcPtr->outlineStipple != None) {
- Tcl_AppendResult(interp, "clip ", (char *) NULL);
- if (Tk_CanvasPsStipple(interp, canvas,
- arcPtr->outlineStipple) != TCL_OK) {
- return TCL_ERROR;
- }
- } else {
- Tcl_AppendResult(interp, "fill\n", (char *) NULL);
- }
- Tcl_AppendResult(interp, "grestore gsave\n", (char *) NULL);
- Tk_CanvasPsPath(interp, canvas,
- arcPtr->outlinePtr + 2*PIE_OUTLINE1_PTS,
- PIE_OUTLINE2_PTS);
- }
- if (Tk_CanvasPsColor(interp, canvas, arcPtr->outlineColor)
- != TCL_OK) {
- return TCL_ERROR;
- }
- if (arcPtr->outlineStipple != None) {
- Tcl_AppendResult(interp, "clip ", (char *) NULL);
- if (Tk_CanvasPsStipple(interp, canvas,
- arcPtr->outlineStipple) != TCL_OK) {
- return TCL_ERROR;
- }
- } else {
- Tcl_AppendResult(interp, "fill\n", (char *) NULL);
- }
- }
- }
-
- return TCL_OK;
-}
diff --git a/generic/tkCanvBmap.c b/generic/tkCanvBmap.c
deleted file mode 100644
index a09bf8d..0000000
--- a/generic/tkCanvBmap.c
+++ /dev/null
@@ -1,800 +0,0 @@
-/*
- * tkCanvBmap.c --
- *
- * This file implements bitmap items for canvas widgets.
- *
- * Copyright (c) 1992-1994 The Regents of the University of California.
- * Copyright (c) 1994-1995 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: tkCanvBmap.c,v 1.2 1998/09/14 18:23:04 stanton Exp $
- */
-
-#include <stdio.h>
-#include "tkInt.h"
-#include "tkPort.h"
-#include "tkCanvas.h"
-
-/*
- * The structure below defines the record for each bitmap item.
- */
-
-typedef struct BitmapItem {
- Tk_Item header; /* Generic stuff that's the same for all
- * types. MUST BE FIRST IN STRUCTURE. */
- double x, y; /* Coordinates of positioning point for
- * bitmap. */
- Tk_Anchor anchor; /* Where to anchor bitmap relative to
- * (x,y). */
- Pixmap bitmap; /* Bitmap to display in window. */
- XColor *fgColor; /* Foreground color to use for bitmap. */
- XColor *bgColor; /* Background color to use for bitmap. */
- GC gc; /* Graphics context to use for drawing
- * bitmap on screen. */
-} BitmapItem;
-
-/*
- * Information used for parsing configuration specs:
- */
-
-static Tk_CustomOption tagsOption = {Tk_CanvasTagsParseProc,
- Tk_CanvasTagsPrintProc, (ClientData) NULL
-};
-
-static Tk_ConfigSpec configSpecs[] = {
- {TK_CONFIG_ANCHOR, "-anchor", (char *) NULL, (char *) NULL,
- "center", Tk_Offset(BitmapItem, anchor), TK_CONFIG_DONT_SET_DEFAULT},
- {TK_CONFIG_COLOR, "-background", (char *) NULL, (char *) NULL,
- (char *) NULL, Tk_Offset(BitmapItem, bgColor), TK_CONFIG_NULL_OK},
- {TK_CONFIG_BITMAP, "-bitmap", (char *) NULL, (char *) NULL,
- (char *) NULL, Tk_Offset(BitmapItem, bitmap), TK_CONFIG_NULL_OK},
- {TK_CONFIG_COLOR, "-foreground", (char *) NULL, (char *) NULL,
- "black", Tk_Offset(BitmapItem, fgColor), 0},
- {TK_CONFIG_CUSTOM, "-tags", (char *) NULL, (char *) NULL,
- (char *) NULL, 0, TK_CONFIG_NULL_OK, &tagsOption},
- {TK_CONFIG_END, (char *) NULL, (char *) NULL, (char *) NULL,
- (char *) NULL, 0, 0}
-};
-
-/*
- * Prototypes for procedures defined in this file:
- */
-
-static int BitmapCoords _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Canvas canvas, Tk_Item *itemPtr, int argc,
- char **argv));
-static int BitmapToArea _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double *rectPtr));
-static double BitmapToPoint _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double *coordPtr));
-static int BitmapToPostscript _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Canvas canvas, Tk_Item *itemPtr, int prepass));
-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,
- char **argv, int flags));
-static int CreateBitmap _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Canvas canvas, struct Tk_Item *itemPtr,
- int argc, char **argv));
-static void DeleteBitmap _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, Display *display));
-static void DisplayBitmap _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, Display *display, Drawable dst,
- int x, int y, int width, int height));
-static void ScaleBitmap _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double originX, double originY,
- double scaleX, double scaleY));
-static void TranslateBitmap _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double deltaX, double deltaY));
-
-/*
- * The structures below defines the bitmap item type in terms of
- * procedures that can be invoked by generic item code.
- */
-
-Tk_ItemType tkBitmapType = {
- "bitmap", /* name */
- sizeof(BitmapItem), /* itemSize */
- CreateBitmap, /* createProc */
- configSpecs, /* configSpecs */
- ConfigureBitmap, /* configureProc */
- BitmapCoords, /* coordProc */
- DeleteBitmap, /* deleteProc */
- DisplayBitmap, /* displayProc */
- 0, /* alwaysRedraw */
- BitmapToPoint, /* pointProc */
- BitmapToArea, /* areaProc */
- BitmapToPostscript, /* postscriptProc */
- ScaleBitmap, /* scaleProc */
- TranslateBitmap, /* translateProc */
- (Tk_ItemIndexProc *) NULL, /* indexProc */
- (Tk_ItemCursorProc *) NULL, /* icursorProc */
- (Tk_ItemSelectionProc *) NULL, /* selectionProc */
- (Tk_ItemInsertProc *) NULL, /* insertProc */
- (Tk_ItemDCharsProc *) NULL, /* dTextProc */
- (Tk_ItemType *) NULL /* nextPtr */
-};
-
-/*
- *--------------------------------------------------------------
- *
- * CreateBitmap --
- *
- * This procedure is invoked to create a new bitmap
- * item in a canvas.
- *
- * Results:
- * A standard Tcl return value. If an error occurred in
- * creating the item, then an error message is left in
- * interp->result; in this case itemPtr is left uninitialized,
- * so it can be safely freed by the caller.
- *
- * Side effects:
- * A new bitmap item is created.
- *
- *--------------------------------------------------------------
- */
-
-static int
-CreateBitmap(interp, canvas, itemPtr, argc, argv)
- 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. */
- char **argv; /* Arguments describing rectangle. */
-{
- BitmapItem *bmapPtr = (BitmapItem *) itemPtr;
-
- if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- Tk_PathName(Tk_CanvasTkwin(canvas)), " create ",
- itemPtr->typePtr->name, " x y ?options?\"",
- (char *) NULL);
- return TCL_ERROR;
- }
-
- /*
- * Initialize item's record.
- */
-
- bmapPtr->anchor = TK_ANCHOR_CENTER;
- bmapPtr->bitmap = None;
- bmapPtr->fgColor = NULL;
- bmapPtr->bgColor = NULL;
- bmapPtr->gc = None;
-
- /*
- * Process the arguments to fill in the item record.
- */
-
- if ((Tk_CanvasGetCoord(interp, canvas, argv[0], &bmapPtr->x) != TCL_OK)
- || (Tk_CanvasGetCoord(interp, canvas, argv[1], &bmapPtr->y)
- != TCL_OK)) {
- return TCL_ERROR;
- }
-
- if (ConfigureBitmap(interp, canvas, itemPtr, argc-2, argv+2, 0) != TCL_OK) {
- DeleteBitmap(canvas, itemPtr, Tk_Display(Tk_CanvasTkwin(canvas)));
- return TCL_ERROR;
- }
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * BitmapCoords --
- *
- * This procedure is invoked to process the "coords" widget
- * command on bitmap items. See the user documentation for
- * details on what it does.
- *
- * Results:
- * Returns TCL_OK or TCL_ERROR, and sets interp->result.
- *
- * Side effects:
- * The coordinates for the given item may be changed.
- *
- *--------------------------------------------------------------
- */
-
-static int
-BitmapCoords(interp, canvas, itemPtr, argc, argv)
- 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. */
- char **argv; /* Array of coordinates: x1, y1,
- * x2, y2, ... */
-{
- BitmapItem *bmapPtr = (BitmapItem *) itemPtr;
- char x[TCL_DOUBLE_SPACE], y[TCL_DOUBLE_SPACE];
-
- if (argc == 0) {
- Tcl_PrintDouble(interp, bmapPtr->x, x);
- Tcl_PrintDouble(interp, bmapPtr->y, y);
- Tcl_AppendResult(interp, x, " ", y, (char *) NULL);
- } else if (argc == 2) {
- if ((Tk_CanvasGetCoord(interp, canvas, argv[0], &bmapPtr->x) != TCL_OK)
- || (Tk_CanvasGetCoord(interp, canvas, argv[1], &bmapPtr->y)
- != TCL_OK)) {
- return TCL_ERROR;
- }
- ComputeBitmapBbox(canvas, bmapPtr);
- } else {
- sprintf(interp->result,
- "wrong # coordinates: expected 0 or 2, got %d", argc);
- return TCL_ERROR;
- }
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ConfigureBitmap --
- *
- * This procedure is invoked to configure various aspects
- * of a bitmap item, such as its anchor position.
- *
- * Results:
- * A standard Tcl result code. If an error occurs, then
- * an error message is left in interp->result.
- *
- * Side effects:
- * Configuration information may be set for itemPtr.
- *
- *--------------------------------------------------------------
- */
-
-static int
-ConfigureBitmap(interp, canvas, itemPtr, argc, argv, 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. */
- char **argv; /* Arguments describing things to configure. */
- int flags; /* Flags to pass to Tk_ConfigureWidget. */
-{
- BitmapItem *bmapPtr = (BitmapItem *) itemPtr;
- XGCValues gcValues;
- GC newGC;
- Tk_Window tkwin;
- unsigned long mask;
-
- tkwin = Tk_CanvasTkwin(canvas);
- if (Tk_ConfigureWidget(interp, tkwin, configSpecs, argc, argv,
- (char *) bmapPtr, flags) != TCL_OK) {
- return TCL_ERROR;
- }
-
- /*
- * A few of the options require additional processing, such as those
- * that determine the graphics context.
- */
-
- gcValues.foreground = bmapPtr->fgColor->pixel;
- mask = GCForeground;
- if (bmapPtr->bgColor != NULL) {
- gcValues.background = bmapPtr->bgColor->pixel;
- mask |= GCBackground;
- } else {
- gcValues.clip_mask = bmapPtr->bitmap;
- mask |= GCClipMask;
- }
- newGC = Tk_GetGC(tkwin, mask, &gcValues);
- if (bmapPtr->gc != None) {
- Tk_FreeGC(Tk_Display(tkwin), bmapPtr->gc);
- }
- bmapPtr->gc = newGC;
-
- ComputeBitmapBbox(canvas, bmapPtr);
-
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * DeleteBitmap --
- *
- * This procedure is called to clean up the data structure
- * associated with a bitmap item.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Resources associated with itemPtr are released.
- *
- *--------------------------------------------------------------
- */
-
-static void
-DeleteBitmap(canvas, itemPtr, display)
- Tk_Canvas canvas; /* Info about overall canvas widget. */
- Tk_Item *itemPtr; /* Item that is being deleted. */
- Display *display; /* Display containing window for
- * canvas. */
-{
- BitmapItem *bmapPtr = (BitmapItem *) itemPtr;
-
- if (bmapPtr->bitmap != None) {
- Tk_FreeBitmap(display, bmapPtr->bitmap);
- }
- if (bmapPtr->fgColor != NULL) {
- Tk_FreeColor(bmapPtr->fgColor);
- }
- if (bmapPtr->bgColor != NULL) {
- Tk_FreeColor(bmapPtr->bgColor);
- }
- if (bmapPtr->gc != NULL) {
- Tk_FreeGC(display, bmapPtr->gc);
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ComputeBitmapBbox --
- *
- * This procedure is invoked to compute the bounding box of
- * all the pixels that may be drawn as part of a bitmap item.
- * This procedure is where the child bitmap's placement is
- * computed.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The fields x1, y1, x2, and y2 are updated in the header
- * for itemPtr.
- *
- *--------------------------------------------------------------
- */
-
- /* ARGSUSED */
-static void
-ComputeBitmapBbox(canvas, bmapPtr)
- Tk_Canvas canvas; /* Canvas that contains item. */
- BitmapItem *bmapPtr; /* Item whose bbox is to be
- * recomputed. */
-{
- int width, height;
- int x, y;
-
- x = (int) (bmapPtr->x + ((bmapPtr->x >= 0) ? 0.5 : - 0.5));
- y = (int) (bmapPtr->y + ((bmapPtr->y >= 0) ? 0.5 : - 0.5));
-
- if (bmapPtr->bitmap == None) {
- bmapPtr->header.x1 = bmapPtr->header.x2 = x;
- bmapPtr->header.y1 = bmapPtr->header.y2 = y;
- return;
- }
-
- /*
- * Compute location and size of bitmap, using anchor information.
- */
-
- Tk_SizeOfBitmap(Tk_Display(Tk_CanvasTkwin(canvas)), bmapPtr->bitmap,
- &width, &height);
- switch (bmapPtr->anchor) {
- case TK_ANCHOR_N:
- x -= width/2;
- break;
- case TK_ANCHOR_NE:
- x -= width;
- break;
- case TK_ANCHOR_E:
- x -= width;
- y -= height/2;
- break;
- case TK_ANCHOR_SE:
- x -= width;
- y -= height;
- break;
- case TK_ANCHOR_S:
- x -= width/2;
- y -= height;
- break;
- case TK_ANCHOR_SW:
- y -= height;
- break;
- case TK_ANCHOR_W:
- y -= height/2;
- break;
- case TK_ANCHOR_NW:
- break;
- case TK_ANCHOR_CENTER:
- x -= width/2;
- y -= height/2;
- break;
- }
-
- /*
- * Store the information in the item header.
- */
-
- bmapPtr->header.x1 = x;
- bmapPtr->header.y1 = y;
- bmapPtr->header.x2 = x + width;
- bmapPtr->header.y2 = y + height;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * DisplayBitmap --
- *
- * This procedure is invoked to draw a bitmap item in a given
- * drawable.
- *
- * Results:
- * None.
- *
- * Side effects:
- * ItemPtr is drawn in drawable using the transformation
- * information in canvas.
- *
- *--------------------------------------------------------------
- */
-
-static void
-DisplayBitmap(canvas, itemPtr, display, drawable, x, y, width, height)
- Tk_Canvas canvas; /* Canvas that contains item. */
- Tk_Item *itemPtr; /* Item to be displayed. */
- Display *display; /* Display on which to draw item. */
- Drawable drawable; /* Pixmap or window in which to draw
- * item. */
- int x, y, width, height; /* Describes region of canvas that
- * must be redisplayed (not used). */
-{
- BitmapItem *bmapPtr = (BitmapItem *) itemPtr;
- int bmapX, bmapY, bmapWidth, bmapHeight;
- short drawableX, drawableY;
-
- /*
- * If the area being displayed doesn't cover the whole bitmap,
- * then only redisplay the part of the bitmap that needs
- * redisplay.
- */
-
- if (bmapPtr->bitmap != None) {
- if (x > bmapPtr->header.x1) {
- bmapX = x - bmapPtr->header.x1;
- bmapWidth = bmapPtr->header.x2 - x;
- } else {
- bmapX = 0;
- if ((x+width) < bmapPtr->header.x2) {
- bmapWidth = x + width - bmapPtr->header.x1;
- } else {
- bmapWidth = bmapPtr->header.x2 - bmapPtr->header.x1;
- }
- }
- if (y > bmapPtr->header.y1) {
- bmapY = y - bmapPtr->header.y1;
- bmapHeight = bmapPtr->header.y2 - y;
- } else {
- bmapY = 0;
- if ((y+height) < bmapPtr->header.y2) {
- bmapHeight = y + height - bmapPtr->header.y1;
- } else {
- bmapHeight = bmapPtr->header.y2 - bmapPtr->header.y1;
- }
- }
- Tk_CanvasDrawableCoords(canvas,
- (double) (bmapPtr->header.x1 + bmapX),
- (double) (bmapPtr->header.y1 + bmapY),
- &drawableX, &drawableY);
-
- /*
- * Must modify the mask origin within the graphics context
- * to line up with the bitmap's origin (in order to make
- * bitmaps with "-background {}" work right).
- */
-
- XSetClipOrigin(display, bmapPtr->gc, drawableX - bmapX,
- drawableY - bmapY);
- XCopyPlane(display, bmapPtr->bitmap, drawable,
- bmapPtr->gc, bmapX, bmapY, (unsigned int) bmapWidth,
- (unsigned int) bmapHeight, drawableX, drawableY, 1);
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * BitmapToPoint --
- *
- * Computes the distance from a given point to a given
- * rectangle, in canvas units.
- *
- * Results:
- * The return value is 0 if the point whose x and y coordinates
- * are coordPtr[0] and coordPtr[1] is inside the bitmap. If the
- * point isn't inside the bitmap then the return value is the
- * distance from the point to the bitmap.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
- /* ARGSUSED */
-static double
-BitmapToPoint(canvas, itemPtr, coordPtr)
- Tk_Canvas canvas; /* Canvas containing item. */
- Tk_Item *itemPtr; /* Item to check against point. */
- double *coordPtr; /* Pointer to x and y coordinates. */
-{
- BitmapItem *bmapPtr = (BitmapItem *) itemPtr;
- double x1, x2, y1, y2, xDiff, yDiff;
-
- x1 = bmapPtr->header.x1;
- y1 = bmapPtr->header.y1;
- x2 = bmapPtr->header.x2;
- y2 = bmapPtr->header.y2;
-
- /*
- * Point is outside rectangle.
- */
-
- if (coordPtr[0] < x1) {
- xDiff = x1 - coordPtr[0];
- } else if (coordPtr[0] > x2) {
- xDiff = coordPtr[0] - x2;
- } else {
- xDiff = 0;
- }
-
- if (coordPtr[1] < y1) {
- yDiff = y1 - coordPtr[1];
- } else if (coordPtr[1] > y2) {
- yDiff = coordPtr[1] - y2;
- } else {
- yDiff = 0;
- }
-
- return hypot(xDiff, yDiff);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * BitmapToArea --
- *
- * This procedure is called to determine whether an item
- * lies entirely inside, entirely outside, or overlapping
- * a given rectangle.
- *
- * Results:
- * -1 is returned if the item is entirely outside the area
- * given by rectPtr, 0 if it overlaps, and 1 if it is entirely
- * inside the given area.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
- /* ARGSUSED */
-static int
-BitmapToArea(canvas, itemPtr, rectPtr)
- Tk_Canvas canvas; /* Canvas containing item. */
- Tk_Item *itemPtr; /* Item to check against rectangle. */
- double *rectPtr; /* Pointer to array of four coordinates
- * (x1, y1, x2, y2) describing rectangular
- * area. */
-{
- BitmapItem *bmapPtr = (BitmapItem *) itemPtr;
-
- if ((rectPtr[2] <= bmapPtr->header.x1)
- || (rectPtr[0] >= bmapPtr->header.x2)
- || (rectPtr[3] <= bmapPtr->header.y1)
- || (rectPtr[1] >= bmapPtr->header.y2)) {
- return -1;
- }
- if ((rectPtr[0] <= bmapPtr->header.x1)
- && (rectPtr[1] <= bmapPtr->header.y1)
- && (rectPtr[2] >= bmapPtr->header.x2)
- && (rectPtr[3] >= bmapPtr->header.y2)) {
- return 1;
- }
- return 0;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ScaleBitmap --
- *
- * This procedure is invoked to rescale a bitmap item in a
- * canvas. It is one of the standard item procedures for
- * bitmap items, and is invoked by the generic canvas code.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The item referred to by itemPtr is rescaled so that the
- * following transformation is applied to all point coordinates:
- * x' = originX + scaleX*(x-originX)
- * y' = originY + scaleY*(y-originY)
- *
- *--------------------------------------------------------------
- */
-
-static void
-ScaleBitmap(canvas, itemPtr, originX, originY, scaleX, scaleY)
- Tk_Canvas canvas; /* Canvas containing rectangle. */
- Tk_Item *itemPtr; /* Rectangle to be scaled. */
- double originX, originY; /* Origin about which to scale item. */
- double scaleX; /* Amount to scale in X direction. */
- double scaleY; /* Amount to scale in Y direction. */
-{
- BitmapItem *bmapPtr = (BitmapItem *) itemPtr;
-
- bmapPtr->x = originX + scaleX*(bmapPtr->x - originX);
- bmapPtr->y = originY + scaleY*(bmapPtr->y - originY);
- ComputeBitmapBbox(canvas, bmapPtr);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * TranslateBitmap --
- *
- * This procedure is called to move an item by a given amount.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The position of the item is offset by (xDelta, yDelta), and
- * the bounding box is updated in the generic part of the item
- * structure.
- *
- *--------------------------------------------------------------
- */
-
-static void
-TranslateBitmap(canvas, itemPtr, deltaX, deltaY)
- Tk_Canvas canvas; /* Canvas containing item. */
- Tk_Item *itemPtr; /* Item that is being moved. */
- double deltaX, deltaY; /* Amount by which item is to be
- * moved. */
-{
- BitmapItem *bmapPtr = (BitmapItem *) itemPtr;
-
- bmapPtr->x += deltaX;
- bmapPtr->y += deltaY;
- ComputeBitmapBbox(canvas, bmapPtr);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * BitmapToPostscript --
- *
- * This procedure is called to generate Postscript for
- * bitmap items.
- *
- * Results:
- * The return value is a standard Tcl result. If an error
- * occurs in generating Postscript then an error message is
- * left in interp->result, replacing whatever used to be there.
- * If no error occurs, then Postscript for the item is appended
- * to the result.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-static int
-BitmapToPostscript(interp, canvas, itemPtr, prepass)
- Tcl_Interp *interp; /* Leave Postscript or error message
- * here. */
- Tk_Canvas canvas; /* Information about overall canvas. */
- Tk_Item *itemPtr; /* Item for which Postscript is
- * wanted. */
- int prepass; /* 1 means this is a prepass to
- * collect font information; 0 means
- * final Postscript is being created. */
-{
- BitmapItem *bmapPtr = (BitmapItem *) itemPtr;
- double x, y;
- int width, height, rowsAtOnce, rowsThisTime;
- int curRow;
- char buffer[200];
-
- if (bmapPtr->bitmap == None) {
- return TCL_OK;
- }
-
- /*
- * Compute the coordinates of the lower-left corner of the bitmap,
- * taking into account the anchor position for the bitmp.
- */
-
- x = bmapPtr->x;
- y = Tk_CanvasPsY(canvas, bmapPtr->y);
- Tk_SizeOfBitmap(Tk_Display(Tk_CanvasTkwin(canvas)), bmapPtr->bitmap,
- &width, &height);
- switch (bmapPtr->anchor) {
- case TK_ANCHOR_NW: y -= height; break;
- case TK_ANCHOR_N: x -= width/2.0; y -= height; break;
- case TK_ANCHOR_NE: x -= width; y -= height; break;
- case TK_ANCHOR_E: x -= width; y -= height/2.0; break;
- case TK_ANCHOR_SE: x -= width; break;
- case TK_ANCHOR_S: x -= width/2.0; break;
- case TK_ANCHOR_SW: break;
- case TK_ANCHOR_W: y -= height/2.0; break;
- case TK_ANCHOR_CENTER: x -= width/2.0; y -= height/2.0; break;
- }
-
- /*
- * Color the background, if there is one.
- */
-
- if (bmapPtr->bgColor != NULL) {
- sprintf(buffer,
- "%.15g %.15g 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_CanvasPsColor(interp, canvas, bmapPtr->bgColor) != TCL_OK) {
- return TCL_ERROR;
- }
- Tcl_AppendResult(interp, "fill\n", (char *) NULL);
- }
-
- /*
- * 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.
- */
-
- if (bmapPtr->fgColor != NULL) {
- if (Tk_CanvasPsColor(interp, canvas, bmapPtr->fgColor) != 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);
- return TCL_ERROR;
- }
- rowsAtOnce = 60000/width;
- if (rowsAtOnce < 1) {
- rowsAtOnce = 1;
- }
- sprintf(buffer, "%.15g %.15g translate\n", x, y+height);
- Tcl_AppendResult(interp, buffer, (char *) NULL);
- for (curRow = 0; curRow < height; curRow += rowsAtOnce) {
- rowsThisTime = rowsAtOnce;
- if (rowsThisTime > (height - curRow)) {
- rowsThisTime = height - curRow;
- }
- sprintf(buffer, "0 -%.15g translate\n%d %d true matrix {\n",
- (double) rowsThisTime, width, rowsThisTime);
- Tcl_AppendResult(interp, buffer, (char *) NULL);
- if (Tk_CanvasPsBitmap(interp, canvas, bmapPtr->bitmap,
- 0, curRow, width, rowsThisTime) != TCL_OK) {
- return TCL_ERROR;
- }
- Tcl_AppendResult(interp, "\n} imagemask\n", (char *) NULL);
- }
- }
- return TCL_OK;
-}
diff --git a/generic/tkCanvImg.c b/generic/tkCanvImg.c
deleted file mode 100644
index 0432bd7..0000000
--- a/generic/tkCanvImg.c
+++ /dev/null
@@ -1,677 +0,0 @@
-/*
- * tkCanvImg.c --
- *
- * This file implements image items for canvas widgets.
- *
- * Copyright (c) 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: tkCanvImg.c,v 1.2 1998/09/14 18:23:05 stanton Exp $
- */
-
-#include <stdio.h>
-#include "tkInt.h"
-#include "tkPort.h"
-#include "tkCanvas.h"
-
-/*
- * The structure below defines the record for each image item.
- */
-
-typedef struct ImageItem {
- Tk_Item header; /* Generic stuff that's the same for all
- * types. MUST BE FIRST IN STRUCTURE. */
- Tk_Canvas canvas; /* Canvas containing the image. */
- double x, y; /* Coordinates of positioning point for
- * image. */
- Tk_Anchor anchor; /* Where to anchor image relative to
- * (x,y). */
- char *imageString; /* String describing -image option (malloc-ed).
- * NULL means no image right now. */
- Tk_Image image; /* Image to display in window, or NULL if
- * no image at present. */
-} ImageItem;
-
-/*
- * Information used for parsing configuration specs:
- */
-
-static Tk_CustomOption tagsOption = {Tk_CanvasTagsParseProc,
- Tk_CanvasTagsPrintProc, (ClientData) NULL
-};
-
-static Tk_ConfigSpec configSpecs[] = {
- {TK_CONFIG_ANCHOR, "-anchor", (char *) NULL, (char *) NULL,
- "center", Tk_Offset(ImageItem, anchor), TK_CONFIG_DONT_SET_DEFAULT},
- {TK_CONFIG_STRING, "-image", (char *) NULL, (char *) NULL,
- (char *) NULL, Tk_Offset(ImageItem, imageString), TK_CONFIG_NULL_OK},
- {TK_CONFIG_CUSTOM, "-tags", (char *) NULL, (char *) NULL,
- (char *) NULL, 0, TK_CONFIG_NULL_OK, &tagsOption},
- {TK_CONFIG_END, (char *) NULL, (char *) NULL, (char *) NULL,
- (char *) NULL, 0, 0}
-};
-
-/*
- * Prototypes for procedures defined in this file:
- */
-
-static void ImageChangedProc _ANSI_ARGS_((ClientData clientData,
- int x, int y, int width, int height, int imgWidth,
- int imgHeight));
-static int ImageCoords _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Canvas canvas, Tk_Item *itemPtr, int argc,
- char **argv));
-static int ImageToArea _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double *rectPtr));
-static double ImageToPoint _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double *coordPtr));
-static void ComputeImageBbox _ANSI_ARGS_((Tk_Canvas canvas,
- ImageItem *imgPtr));
-static int ConfigureImage _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Canvas canvas, Tk_Item *itemPtr, int argc,
- char **argv, int flags));
-static int CreateImage _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Canvas canvas, struct Tk_Item *itemPtr,
- int argc, char **argv));
-static void DeleteImage _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, Display *display));
-static void DisplayImage _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, Display *display, Drawable dst,
- int x, int y, int width, int height));
-static void ScaleImage _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double originX, double originY,
- double scaleX, double scaleY));
-static void TranslateImage _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double deltaX, double deltaY));
-
-/*
- * The structures below defines the image item type in terms of
- * procedures that can be invoked by generic item code.
- */
-
-Tk_ItemType tkImageType = {
- "image", /* name */
- sizeof(ImageItem), /* itemSize */
- CreateImage, /* createProc */
- configSpecs, /* configSpecs */
- ConfigureImage, /* configureProc */
- ImageCoords, /* coordProc */
- DeleteImage, /* deleteProc */
- DisplayImage, /* displayProc */
- 0, /* alwaysRedraw */
- ImageToPoint, /* pointProc */
- ImageToArea, /* areaProc */
- (Tk_ItemPostscriptProc *) NULL, /* postscriptProc */
- ScaleImage, /* scaleProc */
- TranslateImage, /* translateProc */
- (Tk_ItemIndexProc *) NULL, /* indexProc */
- (Tk_ItemCursorProc *) NULL, /* icursorProc */
- (Tk_ItemSelectionProc *) NULL, /* selectionProc */
- (Tk_ItemInsertProc *) NULL, /* insertProc */
- (Tk_ItemDCharsProc *) NULL, /* dTextProc */
- (Tk_ItemType *) NULL /* nextPtr */
-};
-
-/*
- *--------------------------------------------------------------
- *
- * CreateImage --
- *
- * This procedure is invoked to create a new image
- * item in a canvas.
- *
- * Results:
- * A standard Tcl return value. If an error occurred in
- * creating the item, then an error message is left in
- * interp->result; in this case itemPtr is left uninitialized,
- * so it can be safely freed by the caller.
- *
- * Side effects:
- * A new image item is created.
- *
- *--------------------------------------------------------------
- */
-
-static int
-CreateImage(interp, canvas, itemPtr, argc, argv)
- 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. */
- char **argv; /* Arguments describing rectangle. */
-{
- ImageItem *imgPtr = (ImageItem *) itemPtr;
-
- if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- Tk_PathName(Tk_CanvasTkwin(canvas)), " create ",
- itemPtr->typePtr->name, " x y ?options?\"",
- (char *) NULL);
- return TCL_ERROR;
- }
-
- /*
- * Initialize item's record.
- */
-
- imgPtr->canvas = canvas;
- imgPtr->anchor = TK_ANCHOR_CENTER;
- imgPtr->imageString = NULL;
- imgPtr->image = NULL;
-
- /*
- * Process the arguments to fill in the item record.
- */
-
- if ((Tk_CanvasGetCoord(interp, canvas, argv[0], &imgPtr->x) != TCL_OK)
- || (Tk_CanvasGetCoord(interp, canvas, argv[1], &imgPtr->y)
- != TCL_OK)) {
- return TCL_ERROR;
- }
-
- if (ConfigureImage(interp, canvas, itemPtr, argc-2, argv+2, 0) != TCL_OK) {
- DeleteImage(canvas, itemPtr, Tk_Display(Tk_CanvasTkwin(canvas)));
- return TCL_ERROR;
- }
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ImageCoords --
- *
- * This procedure is invoked to process the "coords" widget
- * command on image items. See the user documentation for
- * details on what it does.
- *
- * Results:
- * Returns TCL_OK or TCL_ERROR, and sets interp->result.
- *
- * Side effects:
- * The coordinates for the given item may be changed.
- *
- *--------------------------------------------------------------
- */
-
-static int
-ImageCoords(interp, canvas, itemPtr, argc, argv)
- 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. */
- char **argv; /* Array of coordinates: x1, y1,
- * x2, y2, ... */
-{
- ImageItem *imgPtr = (ImageItem *) itemPtr;
- char x[TCL_DOUBLE_SPACE], y[TCL_DOUBLE_SPACE];
-
- if (argc == 0) {
- Tcl_PrintDouble(interp, imgPtr->x, x);
- Tcl_PrintDouble(interp, imgPtr->y, y);
- Tcl_AppendResult(interp, x, " ", y, (char *) NULL);
- } else if (argc == 2) {
- if ((Tk_CanvasGetCoord(interp, canvas, argv[0], &imgPtr->x) != TCL_OK)
- || (Tk_CanvasGetCoord(interp, canvas, argv[1],
- &imgPtr->y) != TCL_OK)) {
- return TCL_ERROR;
- }
- ComputeImageBbox(canvas, imgPtr);
- } else {
- sprintf(interp->result,
- "wrong # coordinates: expected 0 or 2, got %d", argc);
- return TCL_ERROR;
- }
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ConfigureImage --
- *
- * This procedure is invoked to configure various aspects
- * of an image item, such as its anchor position.
- *
- * Results:
- * A standard Tcl result code. If an error occurs, then
- * an error message is left in interp->result.
- *
- * Side effects:
- * Configuration information may be set for itemPtr.
- *
- *--------------------------------------------------------------
- */
-
-static int
-ConfigureImage(interp, canvas, itemPtr, argc, argv, flags)
- Tcl_Interp *interp; /* Used for error reporting. */
- Tk_Canvas canvas; /* Canvas containing itemPtr. */
- Tk_Item *itemPtr; /* Image item to reconfigure. */
- int argc; /* Number of elements in argv. */
- char **argv; /* Arguments describing things to configure. */
- int flags; /* Flags to pass to Tk_ConfigureWidget. */
-{
- ImageItem *imgPtr = (ImageItem *) itemPtr;
- Tk_Window tkwin;
- Tk_Image image;
-
- tkwin = Tk_CanvasTkwin(canvas);
- if (Tk_ConfigureWidget(interp, tkwin, configSpecs, argc,
- argv, (char *) imgPtr, flags) != TCL_OK) {
- return TCL_ERROR;
- }
-
- /*
- * Create the image. Save the old image around and don't free it
- * until after the new one is allocated. This keeps the reference
- * count from going to zero so the image doesn't have to be recreated
- * if it hasn't changed.
- */
-
- if (imgPtr->imageString != NULL) {
- image = Tk_GetImage(interp, tkwin, imgPtr->imageString,
- ImageChangedProc, (ClientData) imgPtr);
- if (image == NULL) {
- return TCL_ERROR;
- }
- } else {
- image = NULL;
- }
- if (imgPtr->image != NULL) {
- Tk_FreeImage(imgPtr->image);
- }
- imgPtr->image = image;
- ComputeImageBbox(canvas, imgPtr);
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * DeleteImage --
- *
- * This procedure is called to clean up the data structure
- * associated with a image item.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Resources associated with itemPtr are released.
- *
- *--------------------------------------------------------------
- */
-
-static void
-DeleteImage(canvas, itemPtr, display)
- Tk_Canvas canvas; /* Info about overall canvas widget. */
- Tk_Item *itemPtr; /* Item that is being deleted. */
- Display *display; /* Display containing window for
- * canvas. */
-{
- ImageItem *imgPtr = (ImageItem *) itemPtr;
-
- if (imgPtr->imageString != NULL) {
- ckfree(imgPtr->imageString);
- }
- if (imgPtr->image != NULL) {
- Tk_FreeImage(imgPtr->image);
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ComputeImageBbox --
- *
- * This procedure is invoked to compute the bounding box of
- * all the pixels that may be drawn as part of a image item.
- * This procedure is where the child image's placement is
- * computed.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The fields x1, y1, x2, and y2 are updated in the header
- * for itemPtr.
- *
- *--------------------------------------------------------------
- */
-
- /* ARGSUSED */
-static void
-ComputeImageBbox(canvas, imgPtr)
- Tk_Canvas canvas; /* Canvas that contains item. */
- ImageItem *imgPtr; /* Item whose bbox is to be
- * recomputed. */
-{
- int width, height;
- int x, y;
-
- x = (int) (imgPtr->x + ((imgPtr->x >= 0) ? 0.5 : - 0.5));
- y = (int) (imgPtr->y + ((imgPtr->y >= 0) ? 0.5 : - 0.5));
-
- if (imgPtr->image == None) {
- imgPtr->header.x1 = imgPtr->header.x2 = x;
- imgPtr->header.y1 = imgPtr->header.y2 = y;
- return;
- }
-
- /*
- * Compute location and size of image, using anchor information.
- */
-
- Tk_SizeOfImage(imgPtr->image, &width, &height);
- switch (imgPtr->anchor) {
- case TK_ANCHOR_N:
- x -= width/2;
- break;
- case TK_ANCHOR_NE:
- x -= width;
- break;
- case TK_ANCHOR_E:
- x -= width;
- y -= height/2;
- break;
- case TK_ANCHOR_SE:
- x -= width;
- y -= height;
- break;
- case TK_ANCHOR_S:
- x -= width/2;
- y -= height;
- break;
- case TK_ANCHOR_SW:
- y -= height;
- break;
- case TK_ANCHOR_W:
- y -= height/2;
- break;
- case TK_ANCHOR_NW:
- break;
- case TK_ANCHOR_CENTER:
- x -= width/2;
- y -= height/2;
- break;
- }
-
- /*
- * Store the information in the item header.
- */
-
- imgPtr->header.x1 = x;
- imgPtr->header.y1 = y;
- imgPtr->header.x2 = x + width;
- imgPtr->header.y2 = y + height;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * DisplayImage --
- *
- * This procedure is invoked to draw a image item in a given
- * drawable.
- *
- * Results:
- * None.
- *
- * Side effects:
- * ItemPtr is drawn in drawable using the transformation
- * information in canvas.
- *
- *--------------------------------------------------------------
- */
-
-static void
-DisplayImage(canvas, itemPtr, display, drawable, x, y, width, height)
- Tk_Canvas canvas; /* Canvas that contains item. */
- Tk_Item *itemPtr; /* Item to be displayed. */
- Display *display; /* Display on which to draw item. */
- Drawable drawable; /* Pixmap or window in which to draw
- * item. */
- int x, y, width, height; /* Describes region of canvas that
- * must be redisplayed (not used). */
-{
- ImageItem *imgPtr = (ImageItem *) itemPtr;
- short drawableX, drawableY;
-
- if (imgPtr->image == NULL) {
- return;
- }
-
- /*
- * Translate the coordinates to those of the image, then redisplay it.
- */
-
- Tk_CanvasDrawableCoords(canvas, (double) x, (double) y,
- &drawableX, &drawableY);
- Tk_RedrawImage(imgPtr->image, x - imgPtr->header.x1, y - imgPtr->header.y1,
- width, height, drawable, drawableX, drawableY);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ImageToPoint --
- *
- * Computes the distance from a given point to a given
- * rectangle, in canvas units.
- *
- * Results:
- * The return value is 0 if the point whose x and y coordinates
- * are coordPtr[0] and coordPtr[1] is inside the image. If the
- * point isn't inside the image then the return value is the
- * distance from the point to the image.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-static double
-ImageToPoint(canvas, itemPtr, coordPtr)
- Tk_Canvas canvas; /* Canvas containing item. */
- Tk_Item *itemPtr; /* Item to check against point. */
- double *coordPtr; /* Pointer to x and y coordinates. */
-{
- ImageItem *imgPtr = (ImageItem *) itemPtr;
- double x1, x2, y1, y2, xDiff, yDiff;
-
- x1 = imgPtr->header.x1;
- y1 = imgPtr->header.y1;
- x2 = imgPtr->header.x2;
- y2 = imgPtr->header.y2;
-
- /*
- * Point is outside rectangle.
- */
-
- if (coordPtr[0] < x1) {
- xDiff = x1 - coordPtr[0];
- } else if (coordPtr[0] > x2) {
- xDiff = coordPtr[0] - x2;
- } else {
- xDiff = 0;
- }
-
- if (coordPtr[1] < y1) {
- yDiff = y1 - coordPtr[1];
- } else if (coordPtr[1] > y2) {
- yDiff = coordPtr[1] - y2;
- } else {
- yDiff = 0;
- }
-
- return hypot(xDiff, yDiff);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ImageToArea --
- *
- * This procedure is called to determine whether an item
- * lies entirely inside, entirely outside, or overlapping
- * a given rectangle.
- *
- * Results:
- * -1 is returned if the item is entirely outside the area
- * given by rectPtr, 0 if it overlaps, and 1 if it is entirely
- * inside the given area.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-static int
-ImageToArea(canvas, itemPtr, rectPtr)
- Tk_Canvas canvas; /* Canvas containing item. */
- Tk_Item *itemPtr; /* Item to check against rectangle. */
- double *rectPtr; /* Pointer to array of four coordinates
- * (x1, y1, x2, y2) describing rectangular
- * area. */
-{
- ImageItem *imgPtr = (ImageItem *) itemPtr;
-
- if ((rectPtr[2] <= imgPtr->header.x1)
- || (rectPtr[0] >= imgPtr->header.x2)
- || (rectPtr[3] <= imgPtr->header.y1)
- || (rectPtr[1] >= imgPtr->header.y2)) {
- return -1;
- }
- if ((rectPtr[0] <= imgPtr->header.x1)
- && (rectPtr[1] <= imgPtr->header.y1)
- && (rectPtr[2] >= imgPtr->header.x2)
- && (rectPtr[3] >= imgPtr->header.y2)) {
- return 1;
- }
- return 0;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ScaleImage --
- *
- * This procedure is invoked to rescale an item.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The item referred to by itemPtr is rescaled so that the
- * following transformation is applied to all point coordinates:
- * x' = originX + scaleX*(x-originX)
- * y' = originY + scaleY*(y-originY)
- *
- *--------------------------------------------------------------
- */
-
-static void
-ScaleImage(canvas, itemPtr, originX, originY, scaleX, scaleY)
- Tk_Canvas canvas; /* Canvas containing rectangle. */
- Tk_Item *itemPtr; /* Rectangle to be scaled. */
- double originX, originY; /* Origin about which to scale rect. */
- double scaleX; /* Amount to scale in X direction. */
- double scaleY; /* Amount to scale in Y direction. */
-{
- ImageItem *imgPtr = (ImageItem *) itemPtr;
-
- imgPtr->x = originX + scaleX*(imgPtr->x - originX);
- imgPtr->y = originY + scaleY*(imgPtr->y - originY);
- ComputeImageBbox(canvas, imgPtr);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * TranslateImage --
- *
- * This procedure is called to move an item by a given amount.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The position of the item is offset by (xDelta, yDelta), and
- * the bounding box is updated in the generic part of the item
- * structure.
- *
- *--------------------------------------------------------------
- */
-
-static void
-TranslateImage(canvas, itemPtr, deltaX, deltaY)
- Tk_Canvas canvas; /* Canvas containing item. */
- Tk_Item *itemPtr; /* Item that is being moved. */
- double deltaX, deltaY; /* Amount by which item is to be
- * moved. */
-{
- ImageItem *imgPtr = (ImageItem *) itemPtr;
-
- imgPtr->x += deltaX;
- imgPtr->y += deltaY;
- ComputeImageBbox(canvas, imgPtr);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ImageChangedProc --
- *
- * This procedure is invoked by the image code whenever the manager
- * for an image does something that affects the image's size or
- * how it is displayed.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Arranges for the canvas to get redisplayed.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-ImageChangedProc(clientData, x, y, width, height, imgWidth, imgHeight)
- ClientData clientData; /* Pointer to canvas item for image. */
- int x, y; /* Upper left pixel (within image)
- * that must be redisplayed. */
- int width, height; /* Dimensions of area to redisplay
- * (may be <= 0). */
- int imgWidth, imgHeight; /* New dimensions of image. */
-{
- ImageItem *imgPtr = (ImageItem *) clientData;
-
- /*
- * If the image's size changed and it's not anchored at its
- * northwest corner then just redisplay the entire area of the
- * image. This is a bit over-conservative, but we need to do
- * something because a size change also means a position change.
- */
-
- if (((imgPtr->header.x2 - imgPtr->header.x1) != imgWidth)
- || ((imgPtr->header.y2 - imgPtr->header.y1) != imgHeight)) {
- x = y = 0;
- width = imgWidth;
- height = imgHeight;
- Tk_CanvasEventuallyRedraw(imgPtr->canvas, imgPtr->header.x1,
- imgPtr->header.y1, imgPtr->header.x2, imgPtr->header.y2);
- }
- ComputeImageBbox(imgPtr->canvas, imgPtr);
- Tk_CanvasEventuallyRedraw(imgPtr->canvas, imgPtr->header.x1 + x,
- imgPtr->header.y1 + y, (int) (imgPtr->header.x1 + x + width),
- (int) (imgPtr->header.y1 + y + height));
-}
diff --git a/generic/tkCanvLine.c b/generic/tkCanvLine.c
deleted file mode 100644
index 20a9fb6..0000000
--- a/generic/tkCanvLine.c
+++ /dev/null
@@ -1,1623 +0,0 @@
-/*
- * tkCanvLine.c --
- *
- * This file implements line items for canvas widgets.
- *
- * Copyright (c) 1991-1994 The Regents of the University of California.
- * Copyright (c) 1994-1995 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: tkCanvLine.c,v 1.2 1998/09/14 18:23:05 stanton Exp $
- */
-
-#include <stdio.h>
-#include "tkInt.h"
-#include "tkPort.h"
-
-/*
- * The structure below defines the record for each line item.
- */
-
-typedef struct LineItem {
- Tk_Item header; /* Generic stuff that's the same for all
- * types. MUST BE FIRST IN STRUCTURE. */
- Tk_Canvas canvas; /* Canvas containing item. Needed for
- * parsing arrow shapes. */
- int numPoints; /* Number of points in line (always >= 2). */
- double *coordPtr; /* Pointer to malloc-ed array containing
- * x- and y-coords of all points in line.
- * X-coords are even-valued indices, y-coords
- * are corresponding odd-valued indices. If
- * the line has arrowheads then the first
- * and last points have been adjusted to refer
- * to the necks of the arrowheads rather than
- * their tips. The actual endpoints are
- * stored in the *firstArrowPtr and
- * *lastArrowPtr, if they exist. */
- int width; /* Width of line. */
- XColor *fg; /* Foreground color for line. */
- Pixmap fillStipple; /* Stipple bitmap for filling line. */
- int capStyle; /* Cap style for line. */
- int joinStyle; /* Join style for line. */
- GC gc; /* Graphics context for filling line. */
- GC arrowGC; /* Graphics context for drawing arrowheads. */
- Tk_Uid arrow; /* Indicates whether or not to draw arrowheads:
- * "none", "first", "last", or "both". */
- float arrowShapeA; /* Distance from tip of arrowhead to center. */
- float arrowShapeB; /* Distance from tip of arrowhead to trailing
- * point, measured along shaft. */
- float arrowShapeC; /* Distance of trailing points from outside
- * edge of shaft. */
- double *firstArrowPtr; /* Points to array of PTS_IN_ARROW points
- * describing polygon for arrowhead at first
- * point in line. First point of arrowhead
- * is tip. Malloc'ed. NULL means no arrowhead
- * at first point. */
- double *lastArrowPtr; /* Points to polygon for arrowhead at last
- * point in line (PTS_IN_ARROW points, first
- * of which is tip). Malloc'ed. NULL means
- * no arrowhead at last point. */
- int smooth; /* Non-zero means draw line smoothed (i.e.
- * with Bezier splines). */
- int splineSteps; /* Number of steps in each spline segment. */
-} LineItem;
-
-/*
- * Number of points in an arrowHead:
- */
-
-#define PTS_IN_ARROW 6
-
-/*
- * Prototypes for procedures defined in this file:
- */
-
-static int ArrowheadPostscript _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Canvas canvas, LineItem *linePtr,
- double *arrowPtr));
-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,
- char **argv, 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, char **argv));
-static void DeleteLine _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, Display *display));
-static void DisplayLine _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, Display *display, Drawable dst,
- int x, int y, int width, int height));
-static int LineCoords _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Canvas canvas, Tk_Item *itemPtr,
- int argc, char **argv));
-static int LineToArea _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double *rectPtr));
-static double LineToPoint _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double *coordPtr));
-static int LineToPostscript _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Canvas canvas, Tk_Item *itemPtr, int prepass));
-static int ParseArrowShape _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, Tk_Window tkwin, char *value,
- char *recordPtr, int offset));
-static char * PrintArrowShape _ANSI_ARGS_((ClientData clientData,
- Tk_Window tkwin, char *recordPtr, int offset,
- Tcl_FreeProc **freeProcPtr));
-static void ScaleLine _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double originX, double originY,
- double scaleX, double scaleY));
-static void TranslateLine _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double deltaX, double deltaY));
-
-/*
- * Information used for parsing configuration specs. If you change any
- * of the default strings, be sure to change the corresponding default
- * values in CreateLine.
- */
-
-static Tk_CustomOption arrowShapeOption = {ParseArrowShape,
- PrintArrowShape, (ClientData) NULL};
-static Tk_CustomOption tagsOption = {Tk_CanvasTagsParseProc,
- Tk_CanvasTagsPrintProc, (ClientData) NULL
-};
-
-static Tk_ConfigSpec configSpecs[] = {
- {TK_CONFIG_UID, "-arrow", (char *) NULL, (char *) NULL,
- "none", Tk_Offset(LineItem, arrow), TK_CONFIG_DONT_SET_DEFAULT},
- {TK_CONFIG_CUSTOM, "-arrowshape", (char *) NULL, (char *) NULL,
- "8 10 3", Tk_Offset(LineItem, arrowShapeA),
- TK_CONFIG_DONT_SET_DEFAULT, &arrowShapeOption},
- {TK_CONFIG_CAP_STYLE, "-capstyle", (char *) NULL, (char *) NULL,
- "butt", Tk_Offset(LineItem, capStyle), TK_CONFIG_DONT_SET_DEFAULT},
- {TK_CONFIG_COLOR, "-fill", (char *) NULL, (char *) NULL,
- "black", Tk_Offset(LineItem, fg), TK_CONFIG_NULL_OK},
- {TK_CONFIG_JOIN_STYLE, "-joinstyle", (char *) NULL, (char *) NULL,
- "round", Tk_Offset(LineItem, joinStyle), TK_CONFIG_DONT_SET_DEFAULT},
- {TK_CONFIG_BOOLEAN, "-smooth", (char *) NULL, (char *) NULL,
- "0", Tk_Offset(LineItem, smooth), TK_CONFIG_DONT_SET_DEFAULT},
- {TK_CONFIG_INT, "-splinesteps", (char *) NULL, (char *) NULL,
- "12", Tk_Offset(LineItem, splineSteps), TK_CONFIG_DONT_SET_DEFAULT},
- {TK_CONFIG_BITMAP, "-stipple", (char *) NULL, (char *) NULL,
- (char *) NULL, Tk_Offset(LineItem, fillStipple), TK_CONFIG_NULL_OK},
- {TK_CONFIG_CUSTOM, "-tags", (char *) NULL, (char *) NULL,
- (char *) NULL, 0, TK_CONFIG_NULL_OK, &tagsOption},
- {TK_CONFIG_PIXELS, "-width", (char *) NULL, (char *) NULL,
- "1", Tk_Offset(LineItem, width), TK_CONFIG_DONT_SET_DEFAULT},
- {TK_CONFIG_END, (char *) NULL, (char *) NULL, (char *) NULL,
- (char *) NULL, 0, 0}
-};
-
-/*
- * The structures below defines the line item type by means
- * of procedures that can be invoked by generic item code.
- */
-
-Tk_ItemType tkLineType = {
- "line", /* name */
- sizeof(LineItem), /* itemSize */
- CreateLine, /* createProc */
- configSpecs, /* configSpecs */
- ConfigureLine, /* configureProc */
- LineCoords, /* coordProc */
- DeleteLine, /* deleteProc */
- DisplayLine, /* displayProc */
- 0, /* alwaysRedraw */
- LineToPoint, /* pointProc */
- LineToArea, /* areaProc */
- LineToPostscript, /* postscriptProc */
- ScaleLine, /* scaleProc */
- TranslateLine, /* translateProc */
- (Tk_ItemIndexProc *) NULL, /* indexProc */
- (Tk_ItemCursorProc *) NULL, /* icursorProc */
- (Tk_ItemSelectionProc *) NULL, /* selectionProc */
- (Tk_ItemInsertProc *) NULL, /* insertProc */
- (Tk_ItemDCharsProc *) NULL, /* dTextProc */
- (Tk_ItemType *) NULL /* nextPtr */
-};
-
-/*
- * The Tk_Uid's below refer to uids for the various arrow types:
- */
-
-static Tk_Uid noneUid = NULL;
-static Tk_Uid firstUid = NULL;
-static Tk_Uid lastUid = NULL;
-static Tk_Uid bothUid = NULL;
-
-/*
- * The definition below determines how large are static arrays
- * used to hold spline points (splines larger than this have to
- * have their arrays malloc-ed).
- */
-
-#define MAX_STATIC_POINTS 200
-
-/*
- *--------------------------------------------------------------
- *
- * CreateLine --
- *
- * This procedure is invoked to create a new line item in
- * a canvas.
- *
- * Results:
- * A standard Tcl return value. If an error occurred in
- * creating the item, then an error message is left in
- * interp->result; in this case itemPtr is left uninitialized,
- * so it can be safely freed by the caller.
- *
- * Side effects:
- * A new line item is created.
- *
- *--------------------------------------------------------------
- */
-
-static int
-CreateLine(interp, canvas, itemPtr, argc, argv)
- 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. */
- char **argv; /* Arguments describing line. */
-{
- LineItem *linePtr = (LineItem *) itemPtr;
- int i;
-
- if (argc < 4) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- Tk_PathName(Tk_CanvasTkwin(canvas)), " create ",
- itemPtr->typePtr->name, " x1 y1 x2 y2 ?x3 y3 ...? ?options?\"",
- (char *) NULL);
- return TCL_ERROR;
- }
-
- /*
- * Carry out initialization that is needed to set defaults and to
- * allow proper cleanup after errors during the the remainder of
- * this procedure.
- */
-
- linePtr->canvas = canvas;
- linePtr->numPoints = 0;
- linePtr->coordPtr = NULL;
- linePtr->width = 1;
- linePtr->fg = None;
- linePtr->fillStipple = None;
- linePtr->capStyle = CapButt;
- linePtr->joinStyle = JoinRound;
- linePtr->gc = None;
- linePtr->arrowGC = None;
- if (noneUid == NULL) {
- noneUid = Tk_GetUid("none");
- firstUid = Tk_GetUid("first");
- lastUid = Tk_GetUid("last");
- bothUid = Tk_GetUid("both");
- }
- linePtr->arrow = noneUid;
- linePtr->arrowShapeA = (float)8.0;
- linePtr->arrowShapeB = (float)10.0;
- linePtr->arrowShapeC = (float)3.0;
- linePtr->firstArrowPtr = NULL;
- linePtr->lastArrowPtr = NULL;
- linePtr->smooth = 0;
- linePtr->splineSteps = 12;
-
- /*
- * Count the number of points and then parse them into a point
- * array. Leading arguments are assumed to be points if they
- * start with a digit or a minus sign followed by a digit.
- */
-
- for (i = 4; i < (argc-1); i+=2) {
- if ((!isdigit(UCHAR(argv[i][0]))) &&
- ((argv[i][0] != '-')
- || ((argv[i][1] != '.') && !isdigit(UCHAR(argv[i][1]))))) {
- break;
- }
- }
- if (LineCoords(interp, canvas, itemPtr, i, argv) != TCL_OK) {
- goto error;
- }
- if (ConfigureLine(interp, canvas, itemPtr, argc-i, argv+i, 0) == TCL_OK) {
- return TCL_OK;
- }
-
- error:
- DeleteLine(canvas, itemPtr, Tk_Display(Tk_CanvasTkwin(canvas)));
- return TCL_ERROR;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * LineCoords --
- *
- * This procedure is invoked to process the "coords" widget
- * command on lines. See the user documentation for details
- * on what it does.
- *
- * Results:
- * Returns TCL_OK or TCL_ERROR, and sets interp->result.
- *
- * Side effects:
- * The coordinates for the given item may be changed.
- *
- *--------------------------------------------------------------
- */
-
-static int
-LineCoords(interp, canvas, itemPtr, argc, argv)
- 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. */
- char **argv; /* Array of coordinates: x1, y1,
- * x2, y2, ... */
-{
- LineItem *linePtr = (LineItem *) itemPtr;
- char buffer[TCL_DOUBLE_SPACE];
- int i, numPoints;
-
- if (argc == 0) {
- double *coordPtr;
- int numCoords;
-
- numCoords = 2*linePtr->numPoints;
- if (linePtr->firstArrowPtr != NULL) {
- coordPtr = linePtr->firstArrowPtr;
- } else {
- coordPtr = linePtr->coordPtr;
- }
- for (i = 0; i < numCoords; i++, coordPtr++) {
- if (i == 2) {
- coordPtr = linePtr->coordPtr+2;
- }
- if ((linePtr->lastArrowPtr != NULL) && (i == (numCoords-2))) {
- coordPtr = linePtr->lastArrowPtr;
- }
- Tcl_PrintDouble(interp, *coordPtr, buffer);
- Tcl_AppendElement(interp, buffer);
- }
- } else if (argc < 4) {
- Tcl_AppendResult(interp,
- "too few coordinates for line: must have at least 4",
- (char *) NULL);
- return TCL_ERROR;
- } else if (argc & 1) {
- Tcl_AppendResult(interp,
- "odd number of coordinates specified for line",
- (char *) NULL);
- return TCL_ERROR;
- } else {
- numPoints = argc/2;
- if (linePtr->numPoints != numPoints) {
- if (linePtr->coordPtr != NULL) {
- ckfree((char *) linePtr->coordPtr);
- }
- linePtr->coordPtr = (double *) ckalloc((unsigned)
- (sizeof(double) * argc));
- linePtr->numPoints = numPoints;
- }
- for (i = argc-1; i >= 0; i--) {
- if (Tk_CanvasGetCoord(interp, canvas, argv[i],
- &linePtr->coordPtr[i]) != TCL_OK) {
- return TCL_ERROR;
- }
- }
-
- /*
- * Update arrowheads by throwing away any existing arrow-head
- * information and calling ConfigureArrows to recompute it.
- */
-
- if (linePtr->firstArrowPtr != NULL) {
- ckfree((char *) linePtr->firstArrowPtr);
- linePtr->firstArrowPtr = NULL;
- }
- if (linePtr->lastArrowPtr != NULL) {
- ckfree((char *) linePtr->lastArrowPtr);
- linePtr->lastArrowPtr = NULL;
- }
- if (linePtr->arrow != noneUid) {
- ConfigureArrows(canvas, linePtr);
- }
- ComputeLineBbox(canvas, linePtr);
- }
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ConfigureLine --
- *
- * This procedure is invoked to configure various aspects
- * of a line item such as its background color.
- *
- * Results:
- * A standard Tcl result code. If an error occurs, then
- * an error message is left in interp->result.
- *
- * Side effects:
- * Configuration information, such as colors and stipple
- * patterns, may be set for itemPtr.
- *
- *--------------------------------------------------------------
- */
-
-static int
-ConfigureLine(interp, canvas, itemPtr, argc, argv, flags)
- Tcl_Interp *interp; /* Used for error reporting. */
- Tk_Canvas canvas; /* Canvas containing itemPtr. */
- Tk_Item *itemPtr; /* Line item to reconfigure. */
- int argc; /* Number of elements in argv. */
- char **argv; /* Arguments describing things to configure. */
- int flags; /* Flags to pass to Tk_ConfigureWidget. */
-{
- LineItem *linePtr = (LineItem *) itemPtr;
- XGCValues gcValues;
- GC newGC, arrowGC;
- unsigned long mask;
- Tk_Window tkwin;
-
- tkwin = Tk_CanvasTkwin(canvas);
- if (Tk_ConfigureWidget(interp, tkwin, configSpecs, argc, argv,
- (char *) linePtr, flags) != TCL_OK) {
- return TCL_ERROR;
- }
-
- /*
- * A few of the options require additional processing, such as
- * graphics contexts.
- */
-
- if (linePtr->fg == NULL) {
- newGC = arrowGC = None;
- } else {
- gcValues.foreground = linePtr->fg->pixel;
- gcValues.join_style = linePtr->joinStyle;
- if (linePtr->width < 0) {
- linePtr->width = 1;
- }
- gcValues.line_width = linePtr->width;
- mask = GCForeground|GCJoinStyle|GCLineWidth;
- if (linePtr->fillStipple != None) {
- gcValues.stipple = linePtr->fillStipple;
- gcValues.fill_style = FillStippled;
- mask |= GCStipple|GCFillStyle;
- }
- if (linePtr->arrow == noneUid) {
- gcValues.cap_style = linePtr->capStyle;
- mask |= GCCapStyle;
- }
- newGC = Tk_GetGC(tkwin, mask, &gcValues);
- gcValues.line_width = 0;
- arrowGC = Tk_GetGC(tkwin, mask, &gcValues);
- }
- if (linePtr->gc != None) {
- Tk_FreeGC(Tk_Display(tkwin), linePtr->gc);
- }
- if (linePtr->arrowGC != None) {
- Tk_FreeGC(Tk_Display(tkwin), linePtr->arrowGC);
- }
- linePtr->gc = newGC;
- linePtr->arrowGC = arrowGC;
-
- /*
- * Keep spline parameters within reasonable limits.
- */
-
- if (linePtr->splineSteps < 1) {
- linePtr->splineSteps = 1;
- } else if (linePtr->splineSteps > 100) {
- linePtr->splineSteps = 100;
- }
-
- /*
- * Setup arrowheads, if needed. If arrowheads are turned off,
- * restore the line's endpoints (they were shortened when the
- * arrowheads were added).
- */
-
- if ((linePtr->firstArrowPtr != NULL) && (linePtr->arrow != firstUid)
- && (linePtr->arrow != bothUid)) {
- linePtr->coordPtr[0] = linePtr->firstArrowPtr[0];
- linePtr->coordPtr[1] = linePtr->firstArrowPtr[1];
- ckfree((char *) linePtr->firstArrowPtr);
- linePtr->firstArrowPtr = NULL;
- }
- if ((linePtr->lastArrowPtr != NULL) && (linePtr->arrow != lastUid)
- && (linePtr->arrow != bothUid)) {
- int i;
-
- i = 2*(linePtr->numPoints-1);
- linePtr->coordPtr[i] = linePtr->lastArrowPtr[0];
- linePtr->coordPtr[i+1] = linePtr->lastArrowPtr[1];
- ckfree((char *) linePtr->lastArrowPtr);
- linePtr->lastArrowPtr = NULL;
- }
- if (linePtr->arrow != noneUid) {
- if ((linePtr->arrow != firstUid) && (linePtr->arrow != lastUid)
- && (linePtr->arrow != bothUid)) {
- Tcl_AppendResult(interp, "bad arrow spec \"",
- linePtr->arrow, "\": must be none, first, last, or both",
- (char *) NULL);
- linePtr->arrow = noneUid;
- return TCL_ERROR;
- }
- ConfigureArrows(canvas, linePtr);
- }
-
- /*
- * Recompute bounding box for line.
- */
-
- ComputeLineBbox(canvas, linePtr);
-
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * DeleteLine --
- *
- * This procedure is called to clean up the data structure
- * associated with a line item.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Resources associated with itemPtr are released.
- *
- *--------------------------------------------------------------
- */
-
-static void
-DeleteLine(canvas, itemPtr, display)
- Tk_Canvas canvas; /* Info about overall canvas widget. */
- Tk_Item *itemPtr; /* Item that is being deleted. */
- Display *display; /* Display containing window for
- * canvas. */
-{
- LineItem *linePtr = (LineItem *) itemPtr;
-
- if (linePtr->coordPtr != NULL) {
- ckfree((char *) linePtr->coordPtr);
- }
- if (linePtr->fg != NULL) {
- Tk_FreeColor(linePtr->fg);
- }
- if (linePtr->fillStipple != None) {
- Tk_FreeBitmap(display, linePtr->fillStipple);
- }
- if (linePtr->gc != None) {
- Tk_FreeGC(display, linePtr->gc);
- }
- if (linePtr->arrowGC != None) {
- Tk_FreeGC(display, linePtr->arrowGC);
- }
- if (linePtr->firstArrowPtr != NULL) {
- ckfree((char *) linePtr->firstArrowPtr);
- }
- if (linePtr->lastArrowPtr != NULL) {
- ckfree((char *) linePtr->lastArrowPtr);
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ComputeLineBbox --
- *
- * This procedure is invoked to compute the bounding box of
- * all the pixels that may be drawn as part of a line.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The fields x1, y1, x2, and y2 are updated in the header
- * for itemPtr.
- *
- *--------------------------------------------------------------
- */
-
-static void
-ComputeLineBbox(canvas, linePtr)
- Tk_Canvas canvas; /* Canvas that contains item. */
- LineItem *linePtr; /* Item whose bbos is to be
- * recomputed. */
-{
- double *coordPtr;
- int i, width;
-
- coordPtr = linePtr->coordPtr;
- linePtr->header.x1 = linePtr->header.x2 = (int) *coordPtr;
- linePtr->header.y1 = linePtr->header.y2 = (int) coordPtr[1];
-
- /*
- * Compute the bounding box of all the points in the line,
- * then expand in all directions by the line's width to take
- * care of butting or rounded corners and projecting or
- * rounded caps. This expansion is an overestimate (worst-case
- * is square root of two over two) but it's simple. Don't do
- * anything special for curves. This causes an additional
- * overestimate in the bounding box, but is faster.
- */
-
- for (i = 1, coordPtr = linePtr->coordPtr+2; i < linePtr->numPoints;
- i++, coordPtr += 2) {
- TkIncludePoint((Tk_Item *) linePtr, coordPtr);
- }
- width = linePtr->width;
- if (width < 1) {
- width = 1;
- }
- linePtr->header.x1 -= width;
- linePtr->header.x2 += width;
- linePtr->header.y1 -= width;
- linePtr->header.y2 += width;
-
- /*
- * For mitered lines, make a second pass through all the points.
- * Compute the locations of the two miter vertex points and add
- * those into the bounding box.
- */
-
- if (linePtr->joinStyle == JoinMiter) {
- for (i = linePtr->numPoints, coordPtr = linePtr->coordPtr; i >= 3;
- i--, coordPtr += 2) {
- double miter[4];
- int j;
-
- if (TkGetMiterPoints(coordPtr, coordPtr+2, coordPtr+4,
- (double) width, miter, miter+2)) {
- for (j = 0; j < 4; j += 2) {
- TkIncludePoint((Tk_Item *) linePtr, miter+j);
- }
- }
- }
- }
-
- /*
- * Add in the sizes of arrowheads, if any.
- */
-
- if (linePtr->arrow != noneUid) {
- if (linePtr->arrow != lastUid) {
- for (i = 0, coordPtr = linePtr->firstArrowPtr; i < PTS_IN_ARROW;
- i++, coordPtr += 2) {
- TkIncludePoint((Tk_Item *) linePtr, coordPtr);
- }
- }
- if (linePtr->arrow != firstUid) {
- for (i = 0, coordPtr = linePtr->lastArrowPtr; i < PTS_IN_ARROW;
- i++, coordPtr += 2) {
- TkIncludePoint((Tk_Item *) linePtr, coordPtr);
- }
- }
- }
-
- /*
- * Add one more pixel of fudge factor just to be safe (e.g.
- * X may round differently than we do).
- */
-
- linePtr->header.x1 -= 1;
- linePtr->header.x2 += 1;
- linePtr->header.y1 -= 1;
- linePtr->header.y2 += 1;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * DisplayLine --
- *
- * This procedure is invoked to draw a line item in a given
- * drawable.
- *
- * Results:
- * None.
- *
- * Side effects:
- * ItemPtr is drawn in drawable using the transformation
- * information in canvas.
- *
- *--------------------------------------------------------------
- */
-
-static void
-DisplayLine(canvas, itemPtr, display, drawable, x, y, width, height)
- Tk_Canvas canvas; /* Canvas that contains item. */
- Tk_Item *itemPtr; /* Item to be displayed. */
- Display *display; /* Display on which to draw item. */
- Drawable drawable; /* Pixmap or window in which to draw
- * item. */
- int x, y, width, height; /* Describes region of canvas that
- * must be redisplayed (not used). */
-{
- LineItem *linePtr = (LineItem *) itemPtr;
- XPoint staticPoints[MAX_STATIC_POINTS];
- XPoint *pointPtr;
- XPoint *pPtr;
- double *coordPtr;
- int i, numPoints;
-
- if (linePtr->gc == None) {
- return;
- }
-
- /*
- * Build up an array of points in screen coordinates. Use a
- * static array unless the line has an enormous number of points;
- * in this case, dynamically allocate an array. For smoothed lines,
- * generate the curve points on each redisplay.
- */
-
- if ((linePtr->smooth) && (linePtr->numPoints > 2)) {
- numPoints = 1 + linePtr->numPoints*linePtr->splineSteps;
- } else {
- numPoints = linePtr->numPoints;
- }
-
- if (numPoints <= MAX_STATIC_POINTS) {
- pointPtr = staticPoints;
- } else {
- pointPtr = (XPoint *) ckalloc((unsigned) (numPoints * sizeof(XPoint)));
- }
-
- if ((linePtr->smooth) && (linePtr->numPoints > 2)) {
- numPoints = TkMakeBezierCurve(canvas, linePtr->coordPtr,
- linePtr->numPoints, linePtr->splineSteps, pointPtr,
- (double *) NULL);
- } else {
- for (i = 0, coordPtr = linePtr->coordPtr, pPtr = pointPtr;
- i < linePtr->numPoints; i += 1, coordPtr += 2, pPtr++) {
- Tk_CanvasDrawableCoords(canvas, coordPtr[0], coordPtr[1],
- &pPtr->x, &pPtr->y);
- }
- }
-
- /*
- * Display line, the free up line storage if it was dynamically
- * allocated. If we're stippling, then modify the stipple offset
- * in the GC. Be sure to reset the offset when done, since the
- * GC is supposed to be read-only.
- */
-
- if (linePtr->fillStipple != None) {
- Tk_CanvasSetStippleOrigin(canvas, linePtr->gc);
- Tk_CanvasSetStippleOrigin(canvas, linePtr->arrowGC);
- }
- XDrawLines(display, drawable, linePtr->gc, pointPtr, numPoints,
- CoordModeOrigin);
- if (pointPtr != staticPoints) {
- ckfree((char *) pointPtr);
- }
-
- /*
- * Display arrowheads, if they are wanted.
- */
-
- if (linePtr->firstArrowPtr != NULL) {
- TkFillPolygon(canvas, linePtr->firstArrowPtr, PTS_IN_ARROW,
- display, drawable, linePtr->gc, NULL);
- }
- if (linePtr->lastArrowPtr != NULL) {
- TkFillPolygon(canvas, linePtr->lastArrowPtr, PTS_IN_ARROW,
- display, drawable, linePtr->gc, NULL);
- }
- if (linePtr->fillStipple != None) {
- XSetTSOrigin(display, linePtr->gc, 0, 0);
- XSetTSOrigin(display, linePtr->arrowGC, 0, 0);
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * LineToPoint --
- *
- * Computes the distance from a given point to a given
- * line, in canvas units.
- *
- * Results:
- * The return value is 0 if the point whose x and y coordinates
- * are pointPtr[0] and pointPtr[1] is inside the line. If the
- * point isn't inside the line then the return value is the
- * distance from the point to the line.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
- /* ARGSUSED */
-static double
-LineToPoint(canvas, itemPtr, pointPtr)
- Tk_Canvas canvas; /* Canvas containing item. */
- Tk_Item *itemPtr; /* Item to check against point. */
- double *pointPtr; /* Pointer to x and y coordinates. */
-{
- LineItem *linePtr = (LineItem *) itemPtr;
- double *coordPtr, *linePoints;
- double staticSpace[2*MAX_STATIC_POINTS];
- double poly[10];
- double bestDist, dist;
- int numPoints, count;
- int changedMiterToBevel; /* Non-zero means that a mitered corner
- * had to be treated as beveled after all
- * because the angle was < 11 degrees. */
-
- bestDist = 1.0e36;
-
- /*
- * Handle smoothed lines by generating an expanded set of points
- * against which to do the check.
- */
-
- if ((linePtr->smooth) && (linePtr->numPoints > 2)) {
- numPoints = 1 + linePtr->numPoints*linePtr->splineSteps;
- if (numPoints <= MAX_STATIC_POINTS) {
- linePoints = staticSpace;
- } else {
- linePoints = (double *) ckalloc((unsigned)
- (2*numPoints*sizeof(double)));
- }
- numPoints = TkMakeBezierCurve(canvas, linePtr->coordPtr,
- linePtr->numPoints, linePtr->splineSteps, (XPoint *) NULL,
- linePoints);
- } else {
- numPoints = linePtr->numPoints;
- linePoints = linePtr->coordPtr;
- }
-
- /*
- * The overall idea is to iterate through all of the edges of
- * the line, computing a polygon for each edge and testing the
- * point against that polygon. In addition, there are additional
- * tests to deal with rounded joints and caps.
- */
-
- changedMiterToBevel = 0;
- for (count = numPoints, coordPtr = linePoints; count >= 2;
- count--, coordPtr += 2) {
-
- /*
- * If rounding is done around the first point then compute
- * the distance between the point and the point.
- */
-
- if (((linePtr->capStyle == CapRound) && (count == numPoints))
- || ((linePtr->joinStyle == JoinRound)
- && (count != numPoints))) {
- dist = hypot(coordPtr[0] - pointPtr[0], coordPtr[1] - pointPtr[1])
- - linePtr->width/2.0;
- if (dist <= 0.0) {
- bestDist = 0.0;
- goto done;
- } else if (dist < bestDist) {
- bestDist = dist;
- }
- }
-
- /*
- * Compute the polygonal shape corresponding to this edge,
- * consisting of two points for the first point of the edge
- * and two points for the last point of the edge.
- */
-
- if (count == numPoints) {
- TkGetButtPoints(coordPtr+2, coordPtr, (double) linePtr->width,
- linePtr->capStyle == CapProjecting, poly, poly+2);
- } else if ((linePtr->joinStyle == JoinMiter) && !changedMiterToBevel) {
- poly[0] = poly[6];
- poly[1] = poly[7];
- poly[2] = poly[4];
- poly[3] = poly[5];
- } else {
- TkGetButtPoints(coordPtr+2, coordPtr, (double) linePtr->width, 0,
- poly, poly+2);
-
- /*
- * If this line uses beveled joints, then check the distance
- * to a polygon comprising the last two points of the previous
- * polygon and the first two from this polygon; this checks
- * the wedges that fill the mitered joint.
- */
-
- if ((linePtr->joinStyle == JoinBevel) || changedMiterToBevel) {
- poly[8] = poly[0];
- poly[9] = poly[1];
- dist = TkPolygonToPoint(poly, 5, pointPtr);
- if (dist <= 0.0) {
- bestDist = 0.0;
- goto done;
- } else if (dist < bestDist) {
- bestDist = dist;
- }
- changedMiterToBevel = 0;
- }
- }
- if (count == 2) {
- TkGetButtPoints(coordPtr, coordPtr+2, (double) linePtr->width,
- linePtr->capStyle == CapProjecting, poly+4, poly+6);
- } else if (linePtr->joinStyle == JoinMiter) {
- if (TkGetMiterPoints(coordPtr, coordPtr+2, coordPtr+4,
- (double) linePtr->width, poly+4, poly+6) == 0) {
- changedMiterToBevel = 1;
- TkGetButtPoints(coordPtr, coordPtr+2, (double) linePtr->width,
- 0, poly+4, poly+6);
- }
- } else {
- TkGetButtPoints(coordPtr, coordPtr+2, (double) linePtr->width, 0,
- poly+4, poly+6);
- }
- poly[8] = poly[0];
- poly[9] = poly[1];
- dist = TkPolygonToPoint(poly, 5, pointPtr);
- if (dist <= 0.0) {
- bestDist = 0.0;
- goto done;
- } else if (dist < bestDist) {
- bestDist = dist;
- }
- }
-
- /*
- * If caps are rounded, check the distance to the cap around the
- * final end point of the line.
- */
-
- if (linePtr->capStyle == CapRound) {
- dist = hypot(coordPtr[0] - pointPtr[0], coordPtr[1] - pointPtr[1])
- - linePtr->width/2.0;
- if (dist <= 0.0) {
- bestDist = 0.0;
- goto done;
- } else if (dist < bestDist) {
- bestDist = dist;
- }
- }
-
- /*
- * If there are arrowheads, check the distance to the arrowheads.
- */
-
- if (linePtr->arrow != noneUid) {
- if (linePtr->arrow != lastUid) {
- dist = TkPolygonToPoint(linePtr->firstArrowPtr, PTS_IN_ARROW,
- pointPtr);
- if (dist <= 0.0) {
- bestDist = 0.0;
- goto done;
- } else if (dist < bestDist) {
- bestDist = dist;
- }
- }
- if (linePtr->arrow != firstUid) {
- dist = TkPolygonToPoint(linePtr->lastArrowPtr, PTS_IN_ARROW,
- pointPtr);
- if (dist <= 0.0) {
- bestDist = 0.0;
- goto done;
- } else if (dist < bestDist) {
- bestDist = dist;
- }
- }
- }
-
- done:
- if ((linePoints != staticSpace) && (linePoints != linePtr->coordPtr)) {
- ckfree((char *) linePoints);
- }
- return bestDist;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * LineToArea --
- *
- * This procedure is called to determine whether an item
- * lies entirely inside, entirely outside, or overlapping
- * a given rectangular area.
- *
- * Results:
- * -1 is returned if the item is entirely outside the
- * area, 0 if it overlaps, and 1 if it is entirely
- * inside the given area.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
- /* ARGSUSED */
-static int
-LineToArea(canvas, itemPtr, rectPtr)
- Tk_Canvas canvas; /* Canvas containing item. */
- Tk_Item *itemPtr; /* Item to check against line. */
- double *rectPtr;
-{
- LineItem *linePtr = (LineItem *) itemPtr;
- double staticSpace[2*MAX_STATIC_POINTS];
- double *linePoints;
- int numPoints, result;
-
- /*
- * Handle smoothed lines by generating an expanded set of points
- * against which to do the check.
- */
-
- if ((linePtr->smooth) && (linePtr->numPoints > 2)) {
- numPoints = 1 + linePtr->numPoints*linePtr->splineSteps;
- if (numPoints <= MAX_STATIC_POINTS) {
- linePoints = staticSpace;
- } else {
- linePoints = (double *) ckalloc((unsigned)
- (2*numPoints*sizeof(double)));
- }
- numPoints = TkMakeBezierCurve(canvas, linePtr->coordPtr,
- linePtr->numPoints, linePtr->splineSteps, (XPoint *) NULL,
- linePoints);
- } else {
- numPoints = linePtr->numPoints;
- linePoints = linePtr->coordPtr;
- }
-
- /*
- * Check the segments of the line.
- */
-
- result = TkThickPolyLineToArea(linePoints, numPoints,
- (double) linePtr->width, linePtr->capStyle, linePtr->joinStyle,
- rectPtr);
- if (result == 0) {
- goto done;
- }
-
- /*
- * Check arrowheads, if any.
- */
-
- if (linePtr->arrow != noneUid) {
- if (linePtr->arrow != lastUid) {
- if (TkPolygonToArea(linePtr->firstArrowPtr, PTS_IN_ARROW,
- rectPtr) != result) {
- result = 0;
- goto done;
- }
- }
- if (linePtr->arrow != firstUid) {
- if (TkPolygonToArea(linePtr->lastArrowPtr, PTS_IN_ARROW,
- rectPtr) != result) {
- result = 0;
- goto done;
- }
- }
- }
-
- done:
- if ((linePoints != staticSpace) && (linePoints != linePtr->coordPtr)) {
- ckfree((char *) linePoints);
- }
- return result;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ScaleLine --
- *
- * This procedure is invoked to rescale a line item.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The line referred to by itemPtr is rescaled so that the
- * following transformation is applied to all point
- * coordinates:
- * x' = originX + scaleX*(x-originX)
- * y' = originY + scaleY*(y-originY)
- *
- *--------------------------------------------------------------
- */
-
-static void
-ScaleLine(canvas, itemPtr, originX, originY, scaleX, scaleY)
- Tk_Canvas canvas; /* Canvas containing line. */
- Tk_Item *itemPtr; /* Line to be scaled. */
- double originX, originY; /* Origin about which to scale rect. */
- double scaleX; /* Amount to scale in X direction. */
- double scaleY; /* Amount to scale in Y direction. */
-{
- LineItem *linePtr = (LineItem *) itemPtr;
- double *coordPtr;
- int i;
-
- /*
- * Delete any arrowheads before scaling all the points (so that
- * the end-points of the line get restored).
- */
-
- if (linePtr->firstArrowPtr != NULL) {
- linePtr->coordPtr[0] = linePtr->firstArrowPtr[0];
- linePtr->coordPtr[1] = linePtr->firstArrowPtr[1];
- ckfree((char *) linePtr->firstArrowPtr);
- linePtr->firstArrowPtr = NULL;
- }
- if (linePtr->lastArrowPtr != NULL) {
- int i;
-
- i = 2*(linePtr->numPoints-1);
- linePtr->coordPtr[i] = linePtr->lastArrowPtr[0];
- linePtr->coordPtr[i+1] = linePtr->lastArrowPtr[1];
- ckfree((char *) linePtr->lastArrowPtr);
- linePtr->lastArrowPtr = NULL;
- }
- for (i = 0, coordPtr = linePtr->coordPtr; i < linePtr->numPoints;
- i++, coordPtr += 2) {
- coordPtr[0] = originX + scaleX*(*coordPtr - originX);
- coordPtr[1] = originY + scaleY*(coordPtr[1] - originY);
- }
- if (linePtr->arrow != noneUid) {
- ConfigureArrows(canvas, linePtr);
- }
- ComputeLineBbox(canvas, linePtr);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * TranslateLine --
- *
- * This procedure is called to move a line by a given amount.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The position of the line is offset by (xDelta, yDelta), and
- * the bounding box is updated in the generic part of the item
- * structure.
- *
- *--------------------------------------------------------------
- */
-
-static void
-TranslateLine(canvas, itemPtr, deltaX, deltaY)
- Tk_Canvas canvas; /* Canvas containing item. */
- Tk_Item *itemPtr; /* Item that is being moved. */
- double deltaX, deltaY; /* Amount by which item is to be
- * moved. */
-{
- LineItem *linePtr = (LineItem *) itemPtr;
- double *coordPtr;
- int i;
-
- for (i = 0, coordPtr = linePtr->coordPtr; i < linePtr->numPoints;
- i++, coordPtr += 2) {
- coordPtr[0] += deltaX;
- coordPtr[1] += deltaY;
- }
- if (linePtr->firstArrowPtr != NULL) {
- for (i = 0, coordPtr = linePtr->firstArrowPtr; i < PTS_IN_ARROW;
- i++, coordPtr += 2) {
- coordPtr[0] += deltaX;
- coordPtr[1] += deltaY;
- }
- }
- if (linePtr->lastArrowPtr != NULL) {
- for (i = 0, coordPtr = linePtr->lastArrowPtr; i < PTS_IN_ARROW;
- i++, coordPtr += 2) {
- coordPtr[0] += deltaX;
- coordPtr[1] += deltaY;
- }
- }
- ComputeLineBbox(canvas, linePtr);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ParseArrowShape --
- *
- * This procedure is called back during option parsing to
- * parse arrow shape information.
- *
- * Results:
- * The return value is a standard Tcl result: TCL_OK means
- * that the arrow shape information was parsed ok, and
- * TCL_ERROR means it couldn't be parsed.
- *
- * Side effects:
- * Arrow information in recordPtr is updated.
- *
- *--------------------------------------------------------------
- */
-
- /* ARGSUSED */
-static int
-ParseArrowShape(clientData, interp, tkwin, value, recordPtr, offset)
- ClientData clientData; /* Not used. */
- Tcl_Interp *interp; /* Used for error reporting. */
- Tk_Window tkwin; /* Not used. */
- char *value; /* Textual specification of arrow shape. */
- char *recordPtr; /* Pointer to item record in which to
- * store arrow information. */
- int offset; /* Offset of shape information in widget
- * record. */
-{
- LineItem *linePtr = (LineItem *) recordPtr;
- double a, b, c;
- int argc;
- char **argv = NULL;
-
- if (offset != Tk_Offset(LineItem, arrowShapeA)) {
- panic("ParseArrowShape received bogus offset");
- }
-
- if (Tcl_SplitList(interp, value, &argc, &argv) != TCL_OK) {
- syntaxError:
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "bad arrow shape \"", value,
- "\": must be list with three numbers", (char *) NULL);
- if (argv != NULL) {
- ckfree((char *) argv);
- }
- return TCL_ERROR;
- }
- if (argc != 3) {
- goto syntaxError;
- }
- if ((Tk_CanvasGetCoord(interp, linePtr->canvas, argv[0], &a) != TCL_OK)
- || (Tk_CanvasGetCoord(interp, linePtr->canvas, argv[1], &b)
- != TCL_OK)
- || (Tk_CanvasGetCoord(interp, linePtr->canvas, argv[2], &c)
- != TCL_OK)) {
- goto syntaxError;
- }
- linePtr->arrowShapeA = (float)a;
- linePtr->arrowShapeB = (float)b;
- linePtr->arrowShapeC = (float)c;
- ckfree((char *) argv);
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * PrintArrowShape --
- *
- * This procedure is a callback invoked by the configuration
- * code to return a printable value describing an arrow shape.
- *
- * Results:
- * None.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
- /* ARGSUSED */
-static char *
-PrintArrowShape(clientData, tkwin, recordPtr, offset, freeProcPtr)
- ClientData clientData; /* Not used. */
- Tk_Window tkwin; /* Window associated with linePtr's widget. */
- char *recordPtr; /* Pointer to item record containing current
- * shape information. */
- int offset; /* Offset of arrow information in record. */
- Tcl_FreeProc **freeProcPtr; /* Store address of procedure to call to
- * free string here. */
-{
- LineItem *linePtr = (LineItem *) recordPtr;
- char *buffer;
-
- buffer = (char *) ckalloc(120);
- sprintf(buffer, "%.5g %.5g %.5g", linePtr->arrowShapeA,
- linePtr->arrowShapeB, linePtr->arrowShapeC);
- *freeProcPtr = TCL_DYNAMIC;
- return buffer;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ConfigureArrows --
- *
- * If arrowheads have been requested for a line, this
- * procedure makes arrangements for the arrowheads.
- *
- * Results:
- * Always returns TCL_OK.
- *
- * Side effects:
- * Information in linePtr is set up for one or two arrowheads.
- * the firstArrowPtr and lastArrowPtr polygons are allocated
- * and initialized, if need be, and the end points of the line
- * are adjusted so that a thick line doesn't stick out past
- * the arrowheads.
- *
- *--------------------------------------------------------------
- */
-
- /* ARGSUSED */
-static int
-ConfigureArrows(canvas, linePtr)
- Tk_Canvas canvas; /* Canvas in which arrows will be
- * displayed (interp and tkwin
- * fields are needed). */
- LineItem *linePtr; /* Item to configure for arrows. */
-{
- double *poly, *coordPtr;
- double dx, dy, length, sinTheta, cosTheta, temp;
- double fracHeight; /* Line width as fraction of
- * arrowhead width. */
- double backup; /* Distance to backup end points
- * so the line ends in the middle
- * of the arrowhead. */
- double vertX, vertY; /* Position of arrowhead vertex. */
- double shapeA, shapeB, shapeC; /* Adjusted coordinates (see
- * explanation below). */
-
- /*
- * The code below makes a tiny increase in the shape parameters
- * for the line. This is a bit of a hack, but it seems to result
- * in displays that more closely approximate the specified parameters.
- * Without the adjustment, the arrows come out smaller than expected.
- */
-
- shapeA = linePtr->arrowShapeA + 0.001;
- shapeB = linePtr->arrowShapeB + 0.001;
- shapeC = linePtr->arrowShapeC + linePtr->width/2.0 + 0.001;
-
- /*
- * If there's an arrowhead on the first point of the line, compute
- * its polygon and adjust the first point of the line so that the
- * line doesn't stick out past the leading edge of the arrowhead.
- */
-
- fracHeight = (linePtr->width/2.0)/shapeC;
- backup = fracHeight*shapeB + shapeA*(1.0 - fracHeight)/2.0;
- if (linePtr->arrow != lastUid) {
- poly = linePtr->firstArrowPtr;
- if (poly == NULL) {
- poly = (double *) ckalloc((unsigned)
- (2*PTS_IN_ARROW*sizeof(double)));
- poly[0] = poly[10] = linePtr->coordPtr[0];
- poly[1] = poly[11] = linePtr->coordPtr[1];
- linePtr->firstArrowPtr = poly;
- }
- dx = poly[0] - linePtr->coordPtr[2];
- dy = poly[1] - linePtr->coordPtr[3];
- length = hypot(dx, dy);
- if (length == 0) {
- sinTheta = cosTheta = 0.0;
- } else {
- sinTheta = dy/length;
- cosTheta = dx/length;
- }
- vertX = poly[0] - shapeA*cosTheta;
- vertY = poly[1] - shapeA*sinTheta;
- temp = shapeC*sinTheta;
- poly[2] = poly[0] - shapeB*cosTheta + temp;
- poly[8] = poly[2] - 2*temp;
- temp = shapeC*cosTheta;
- poly[3] = poly[1] - shapeB*sinTheta - temp;
- poly[9] = poly[3] + 2*temp;
- poly[4] = poly[2]*fracHeight + vertX*(1.0-fracHeight);
- poly[5] = poly[3]*fracHeight + vertY*(1.0-fracHeight);
- poly[6] = poly[8]*fracHeight + vertX*(1.0-fracHeight);
- poly[7] = poly[9]*fracHeight + vertY*(1.0-fracHeight);
-
- /*
- * Polygon done. Now move the first point towards the second so
- * that the corners at the end of the line are inside the
- * arrowhead.
- */
-
- linePtr->coordPtr[0] = poly[0] - backup*cosTheta;
- linePtr->coordPtr[1] = poly[1] - backup*sinTheta;
- }
-
- /*
- * Similar arrowhead calculation for the last point of the line.
- */
-
- if (linePtr->arrow != firstUid) {
- coordPtr = linePtr->coordPtr + 2*(linePtr->numPoints-2);
- poly = linePtr->lastArrowPtr;
- if (poly == NULL) {
- poly = (double *) ckalloc((unsigned)
- (2*PTS_IN_ARROW*sizeof(double)));
- poly[0] = poly[10] = coordPtr[2];
- poly[1] = poly[11] = coordPtr[3];
- linePtr->lastArrowPtr = poly;
- }
- dx = poly[0] - coordPtr[0];
- dy = poly[1] - coordPtr[1];
- length = hypot(dx, dy);
- if (length == 0) {
- sinTheta = cosTheta = 0.0;
- } else {
- sinTheta = dy/length;
- cosTheta = dx/length;
- }
- vertX = poly[0] - shapeA*cosTheta;
- vertY = poly[1] - shapeA*sinTheta;
- temp = shapeC*sinTheta;
- poly[2] = poly[0] - shapeB*cosTheta + temp;
- poly[8] = poly[2] - 2*temp;
- temp = shapeC*cosTheta;
- poly[3] = poly[1] - shapeB*sinTheta - temp;
- poly[9] = poly[3] + 2*temp;
- poly[4] = poly[2]*fracHeight + vertX*(1.0-fracHeight);
- poly[5] = poly[3]*fracHeight + vertY*(1.0-fracHeight);
- poly[6] = poly[8]*fracHeight + vertX*(1.0-fracHeight);
- poly[7] = poly[9]*fracHeight + vertY*(1.0-fracHeight);
- coordPtr[2] = poly[0] - backup*cosTheta;
- coordPtr[3] = poly[1] - backup*sinTheta;
- }
-
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * LineToPostscript --
- *
- * This procedure is called to generate Postscript for
- * line items.
- *
- * Results:
- * The return value is a standard Tcl result. If an error
- * occurs in generating Postscript then an error message is
- * left in interp->result, replacing whatever used
- * to be there. If no error occurs, then Postscript for the
- * item is appended to the result.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-static int
-LineToPostscript(interp, canvas, itemPtr, prepass)
- Tcl_Interp *interp; /* Leave Postscript or error message
- * here. */
- Tk_Canvas canvas; /* Information about overall canvas. */
- Tk_Item *itemPtr; /* Item for which Postscript is
- * wanted. */
- int prepass; /* 1 means this is a prepass to
- * collect font information; 0 means
- * final Postscript is being created. */
-{
- LineItem *linePtr = (LineItem *) itemPtr;
- char buffer[200];
- char *style;
-
- if (linePtr->fg == NULL) {
- return TCL_OK;
- }
-
- /*
- * Generate a path for the line's center-line (do this differently
- * for straight lines and smoothed lines).
- */
-
- if ((!linePtr->smooth) || (linePtr->numPoints <= 2)) {
- Tk_CanvasPsPath(interp, canvas, linePtr->coordPtr, linePtr->numPoints);
- } else {
- if (linePtr->fillStipple == None) {
- TkMakeBezierPostscript(interp, canvas, linePtr->coordPtr,
- linePtr->numPoints);
- } else {
- /*
- * Special hack: Postscript printers don't appear to be able
- * to turn a path drawn with "curveto"s into a clipping path
- * without exceeding resource limits, so TkMakeBezierPostscript
- * won't work for stippled curves. Instead, generate all of
- * the intermediate points here and output them into the
- * Postscript file with "lineto"s instead.
- */
-
- double staticPoints[2*MAX_STATIC_POINTS];
- double *pointPtr;
- int numPoints;
-
- numPoints = 1 + linePtr->numPoints*linePtr->splineSteps;
- pointPtr = staticPoints;
- if (numPoints > MAX_STATIC_POINTS) {
- pointPtr = (double *) ckalloc((unsigned)
- (numPoints * 2 * sizeof(double)));
- }
- numPoints = TkMakeBezierCurve(canvas, linePtr->coordPtr,
- linePtr->numPoints, linePtr->splineSteps, (XPoint *) NULL,
- pointPtr);
- Tk_CanvasPsPath(interp, canvas, pointPtr, numPoints);
- if (pointPtr != staticPoints) {
- ckfree((char *) pointPtr);
- }
- }
- }
-
- /*
- * Set other line-drawing parameters and stroke out the line.
- */
-
- sprintf(buffer, "%d setlinewidth\n", linePtr->width);
- Tcl_AppendResult(interp, buffer, (char *) NULL);
- style = "0 setlinecap\n";
- if (linePtr->capStyle == CapRound) {
- style = "1 setlinecap\n";
- } else if (linePtr->capStyle == CapProjecting) {
- style = "2 setlinecap\n";
- }
- Tcl_AppendResult(interp, style, (char *) NULL);
- style = "0 setlinejoin\n";
- if (linePtr->joinStyle == JoinRound) {
- style = "1 setlinejoin\n";
- } else if (linePtr->joinStyle == JoinBevel) {
- style = "2 setlinejoin\n";
- }
- Tcl_AppendResult(interp, style, (char *) NULL);
- if (Tk_CanvasPsColor(interp, canvas, linePtr->fg) != TCL_OK) {
- return TCL_ERROR;
- };
- if (linePtr->fillStipple != None) {
- Tcl_AppendResult(interp, "StrokeClip ", (char *) NULL);
- if (Tk_CanvasPsStipple(interp, canvas, linePtr->fillStipple)
- != TCL_OK) {
- return TCL_ERROR;
- }
- } else {
- Tcl_AppendResult(interp, "stroke\n", (char *) NULL);
- }
-
- /*
- * Output polygons for the arrowheads, if there are any.
- */
-
- if (linePtr->firstArrowPtr != NULL) {
- if (linePtr->fillStipple != None) {
- Tcl_AppendResult(interp, "grestore gsave\n",
- (char *) NULL);
- }
- if (ArrowheadPostscript(interp, canvas, linePtr,
- linePtr->firstArrowPtr) != TCL_OK) {
- return TCL_ERROR;
- }
- }
- if (linePtr->lastArrowPtr != NULL) {
- if (linePtr->fillStipple != None) {
- Tcl_AppendResult(interp, "grestore gsave\n", (char *) NULL);
- }
- if (ArrowheadPostscript(interp, canvas, linePtr,
- linePtr->lastArrowPtr) != TCL_OK) {
- return TCL_ERROR;
- }
- }
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ArrowheadPostscript --
- *
- * This procedure is called to generate Postscript for
- * an arrowhead for a line item.
- *
- * Results:
- * The return value is a standard Tcl result. If an error
- * occurs in generating Postscript then an error message is
- * left in interp->result, replacing whatever used
- * to be there. If no error occurs, then Postscript for the
- * arrowhead is appended to the result.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-static int
-ArrowheadPostscript(interp, canvas, linePtr, arrowPtr)
- Tcl_Interp *interp; /* Leave Postscript or error message
- * here. */
- Tk_Canvas canvas; /* Information about overall canvas. */
- LineItem *linePtr; /* Line item for which Postscript is
- * being generated. */
- double *arrowPtr; /* Pointer to first of five points
- * describing arrowhead polygon. */
-{
- Tk_CanvasPsPath(interp, canvas, arrowPtr, PTS_IN_ARROW);
- if (linePtr->fillStipple != None) {
- Tcl_AppendResult(interp, "clip ", (char *) NULL);
- if (Tk_CanvasPsStipple(interp, canvas, linePtr->fillStipple)
- != TCL_OK) {
- return TCL_ERROR;
- }
- } else {
- Tcl_AppendResult(interp, "fill\n", (char *) NULL);
- }
- return TCL_OK;
-}
diff --git a/generic/tkCanvPoly.c b/generic/tkCanvPoly.c
deleted file mode 100644
index 5f18bc7..0000000
--- a/generic/tkCanvPoly.c
+++ /dev/null
@@ -1,998 +0,0 @@
-/*
- * tkCanvPoly.c --
- *
- * This file implements polygon items for canvas widgets.
- *
- * Copyright (c) 1991-1994 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: tkCanvPoly.c,v 1.2 1998/09/14 18:23:05 stanton Exp $
- */
-
-#include <stdio.h>
-#include "tkInt.h"
-#include "tkPort.h"
-
-/*
- * The structure below defines the record for each polygon item.
- */
-
-typedef struct PolygonItem {
- Tk_Item header; /* Generic stuff that's the same for all
- * types. MUST BE FIRST IN STRUCTURE. */
- int numPoints; /* Number of points in polygon (always >= 3).
- * Polygon is always closed. */
- int pointsAllocated; /* Number of points for which space is
- * allocated at *coordPtr. */
- double *coordPtr; /* Pointer to malloc-ed array containing
- * x- and y-coords of all points in polygon.
- * X-coords are even-valued indices, y-coords
- * are corresponding odd-valued indices. */
- int width; /* Width of outline. */
- XColor *outlineColor; /* Color for outline. */
- GC outlineGC; /* Graphics context for drawing outline. */
- XColor *fillColor; /* Foreground color for polygon. */
- Pixmap fillStipple; /* Stipple bitmap for filling polygon. */
- GC fillGC; /* Graphics context for filling polygon. */
- int smooth; /* Non-zero means draw shape smoothed (i.e.
- * with Bezier splines). */
- int splineSteps; /* Number of steps in each spline segment. */
- int autoClosed; /* Zero means the given polygon was closed,
- one means that we auto closed it. */
-} PolygonItem;
-
-/*
- * Information used for parsing configuration specs:
- */
-
-static Tk_CustomOption tagsOption = {Tk_CanvasTagsParseProc,
- Tk_CanvasTagsPrintProc, (ClientData) NULL
-};
-
-static Tk_ConfigSpec configSpecs[] = {
- {TK_CONFIG_COLOR, "-fill", (char *) NULL, (char *) NULL,
- "black", Tk_Offset(PolygonItem, fillColor), TK_CONFIG_NULL_OK},
- {TK_CONFIG_COLOR, "-outline", (char *) NULL, (char *) NULL,
- (char *) NULL, Tk_Offset(PolygonItem, outlineColor), TK_CONFIG_NULL_OK},
- {TK_CONFIG_BOOLEAN, "-smooth", (char *) NULL, (char *) NULL,
- "0", Tk_Offset(PolygonItem, smooth), TK_CONFIG_DONT_SET_DEFAULT},
- {TK_CONFIG_INT, "-splinesteps", (char *) NULL, (char *) NULL,
- "12", Tk_Offset(PolygonItem, splineSteps), TK_CONFIG_DONT_SET_DEFAULT},
- {TK_CONFIG_BITMAP, "-stipple", (char *) NULL, (char *) NULL,
- (char *) NULL, Tk_Offset(PolygonItem, fillStipple), TK_CONFIG_NULL_OK},
- {TK_CONFIG_CUSTOM, "-tags", (char *) NULL, (char *) NULL,
- (char *) NULL, 0, TK_CONFIG_NULL_OK, &tagsOption},
- {TK_CONFIG_PIXELS, "-width", (char *) NULL, (char *) NULL,
- "1", Tk_Offset(PolygonItem, width), TK_CONFIG_DONT_SET_DEFAULT},
- {TK_CONFIG_END, (char *) NULL, (char *) NULL, (char *) NULL,
- (char *) NULL, 0, 0}
-};
-
-/*
- * Prototypes for procedures defined in this file:
- */
-
-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,
- char **argv, int flags));
-static int CreatePolygon _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Canvas canvas, struct Tk_Item *itemPtr,
- int argc, char **argv));
-static void DeletePolygon _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, Display *display));
-static void DisplayPolygon _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, Display *display, Drawable dst,
- int x, int y, int width, int height));
-static int PolygonCoords _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Canvas canvas, Tk_Item *itemPtr,
- int argc, char **argv));
-static int PolygonToArea _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double *rectPtr));
-static double PolygonToPoint _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double *pointPtr));
-static int PolygonToPostscript _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Canvas canvas, Tk_Item *itemPtr, int prepass));
-static void ScalePolygon _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double originX, double originY,
- double scaleX, double scaleY));
-static void TranslatePolygon _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double deltaX, double deltaY));
-
-/*
- * The structures below defines the polygon item type by means
- * of procedures that can be invoked by generic item code.
- */
-
-Tk_ItemType tkPolygonType = {
- "polygon", /* name */
- sizeof(PolygonItem), /* itemSize */
- CreatePolygon, /* createProc */
- configSpecs, /* configSpecs */
- ConfigurePolygon, /* configureProc */
- PolygonCoords, /* coordProc */
- DeletePolygon, /* deleteProc */
- DisplayPolygon, /* displayProc */
- 0, /* alwaysRedraw */
- PolygonToPoint, /* pointProc */
- PolygonToArea, /* areaProc */
- PolygonToPostscript, /* postscriptProc */
- ScalePolygon, /* scaleProc */
- TranslatePolygon, /* translateProc */
- (Tk_ItemIndexProc *) NULL, /* indexProc */
- (Tk_ItemCursorProc *) NULL, /* icursorProc */
- (Tk_ItemSelectionProc *) NULL, /* selectionProc */
- (Tk_ItemInsertProc *) NULL, /* insertProc */
- (Tk_ItemDCharsProc *) NULL, /* dTextProc */
- (Tk_ItemType *) NULL /* nextPtr */
-};
-
-/*
- * The definition below determines how large are static arrays
- * used to hold spline points (splines larger than this have to
- * have their arrays malloc-ed).
- */
-
-#define MAX_STATIC_POINTS 200
-
-/*
- *--------------------------------------------------------------
- *
- * CreatePolygon --
- *
- * This procedure is invoked to create a new polygon item in
- * a canvas.
- *
- * Results:
- * A standard Tcl return value. If an error occurred in
- * creating the item, then an error message is left in
- * interp->result; in this case itemPtr is
- * left uninitialized, so it can be safely freed by the
- * caller.
- *
- * Side effects:
- * A new polygon item is created.
- *
- *--------------------------------------------------------------
- */
-
-static int
-CreatePolygon(interp, canvas, itemPtr, argc, argv)
- 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. */
- char **argv; /* Arguments describing polygon. */
-{
- PolygonItem *polyPtr = (PolygonItem *) itemPtr;
- int i;
-
- if (argc < 6) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- Tk_PathName(Tk_CanvasTkwin(canvas)), " create ",
- itemPtr->typePtr->name,
- " x1 y1 x2 y2 x3 y3 ?x4 y4 ...? ?options?\"", (char *) NULL);
- return TCL_ERROR;
- }
-
- /*
- * Carry out initialization that is needed in order to clean
- * up after errors during the the remainder of this procedure.
- */
-
- polyPtr->numPoints = 0;
- polyPtr->pointsAllocated = 0;
- polyPtr->coordPtr = NULL;
- polyPtr->width = 1;
- polyPtr->outlineColor = NULL;
- polyPtr->outlineGC = None;
- polyPtr->fillColor = NULL;
- polyPtr->fillStipple = None;
- polyPtr->fillGC = None;
- polyPtr->smooth = 0;
- polyPtr->splineSteps = 12;
- polyPtr->autoClosed = 0;
-
- /*
- * Count the number of points and then parse them into a point
- * array. Leading arguments are assumed to be points if they
- * start with a digit or a minus sign followed by a digit.
- */
-
- for (i = 4; i < (argc-1); i+=2) {
- if ((!isdigit(UCHAR(argv[i][0]))) &&
- ((argv[i][0] != '-') || (!isdigit(UCHAR(argv[i][1]))))) {
- break;
- }
- }
- if (PolygonCoords(interp, canvas, itemPtr, i, argv) != TCL_OK) {
- goto error;
- }
-
- if (ConfigurePolygon(interp, canvas, itemPtr, argc-i, argv+i, 0)
- == TCL_OK) {
- return TCL_OK;
- }
-
- error:
- DeletePolygon(canvas, itemPtr, Tk_Display(Tk_CanvasTkwin(canvas)));
- return TCL_ERROR;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * PolygonCoords --
- *
- * This procedure is invoked to process the "coords" widget
- * command on polygons. See the user documentation for details
- * on what it does.
- *
- * Results:
- * Returns TCL_OK or TCL_ERROR, and sets interp->result.
- *
- * Side effects:
- * The coordinates for the given item may be changed.
- *
- *--------------------------------------------------------------
- */
-
-static int
-PolygonCoords(interp, canvas, itemPtr, argc, argv)
- 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. */
- char **argv; /* Array of coordinates: x1, y1,
- * x2, y2, ... */
-{
- PolygonItem *polyPtr = (PolygonItem *) itemPtr;
- char buffer[TCL_DOUBLE_SPACE];
- int i, numPoints;
-
- if (argc == 0) {
- /*
- * Print the coords used to create the polygon. If we auto
- * closed the polygon then we don't report the last point.
- */
- for (i = 0; i < 2*(polyPtr->numPoints - polyPtr->autoClosed); i++) {
- Tcl_PrintDouble(interp, polyPtr->coordPtr[i], buffer);
- Tcl_AppendElement(interp, buffer);
- }
- } else if (argc < 6) {
- Tcl_AppendResult(interp,
- "too few coordinates for polygon: must have at least 6",
- (char *) NULL);
- return TCL_ERROR;
- } else if (argc & 1) {
- Tcl_AppendResult(interp,
- "odd number of coordinates specified for polygon",
- (char *) NULL);
- return TCL_ERROR;
- } else {
- numPoints = argc/2;
- if (polyPtr->pointsAllocated <= numPoints) {
- if (polyPtr->coordPtr != NULL) {
- ckfree((char *) polyPtr->coordPtr);
- }
-
- /*
- * One extra point gets allocated here, just in case we have
- * to add another point to close the polygon.
- */
-
- polyPtr->coordPtr = (double *) ckalloc((unsigned)
- (sizeof(double) * (argc+2)));
- polyPtr->pointsAllocated = numPoints+1;
- }
- for (i = argc-1; i >= 0; i--) {
- if (Tk_CanvasGetCoord(interp, canvas, argv[i],
- &polyPtr->coordPtr[i]) != TCL_OK) {
- return TCL_ERROR;
- }
- }
- polyPtr->numPoints = numPoints;
- polyPtr->autoClosed = 0;
-
- /*
- * Close the polygon if it isn't already closed.
- */
-
- if ((polyPtr->coordPtr[argc-2] != polyPtr->coordPtr[0])
- || (polyPtr->coordPtr[argc-1] != polyPtr->coordPtr[1])) {
- polyPtr->autoClosed = 1;
- polyPtr->numPoints++;
- polyPtr->coordPtr[argc] = polyPtr->coordPtr[0];
- polyPtr->coordPtr[argc+1] = polyPtr->coordPtr[1];
- }
- ComputePolygonBbox(canvas, polyPtr);
- }
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ConfigurePolygon --
- *
- * This procedure is invoked to configure various aspects
- * of a polygon item such as its background color.
- *
- * Results:
- * A standard Tcl result code. If an error occurs, then
- * an error message is left in interp->result.
- *
- * Side effects:
- * Configuration information, such as colors and stipple
- * patterns, may be set for itemPtr.
- *
- *--------------------------------------------------------------
- */
-
-static int
-ConfigurePolygon(interp, canvas, itemPtr, argc, argv, 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. */
- char **argv; /* Arguments describing things to configure. */
- int flags; /* Flags to pass to Tk_ConfigureWidget. */
-{
- PolygonItem *polyPtr = (PolygonItem *) itemPtr;
- XGCValues gcValues;
- GC newGC;
- unsigned long mask;
- Tk_Window tkwin;
-
- tkwin = Tk_CanvasTkwin(canvas);
- if (Tk_ConfigureWidget(interp, tkwin, configSpecs, argc, argv,
- (char *) polyPtr, flags) != TCL_OK) {
- return TCL_ERROR;
- }
-
- /*
- * A few of the options require additional processing, such as
- * graphics contexts.
- */
-
- if (polyPtr->width < 1) {
- polyPtr->width = 1;
- }
- if (polyPtr->outlineColor == NULL) {
- newGC = None;
- } else {
- gcValues.foreground = polyPtr->outlineColor->pixel;
- gcValues.line_width = polyPtr->width;
- gcValues.cap_style = CapRound;
- gcValues.join_style = JoinRound;
- mask = GCForeground|GCLineWidth|GCCapStyle|GCJoinStyle;
- newGC = Tk_GetGC(tkwin, mask, &gcValues);
- }
- if (polyPtr->outlineGC != None) {
- Tk_FreeGC(Tk_Display(tkwin), polyPtr->outlineGC);
- }
- polyPtr->outlineGC = newGC;
-
- if (polyPtr->fillColor == NULL) {
- newGC = None;
- } else {
- gcValues.foreground = polyPtr->fillColor->pixel;
- mask = GCForeground;
- if (polyPtr->fillStipple != None) {
- gcValues.stipple = polyPtr->fillStipple;
- gcValues.fill_style = FillStippled;
- mask |= GCStipple|GCFillStyle;
- }
- newGC = Tk_GetGC(tkwin, mask, &gcValues);
- }
- if (polyPtr->fillGC != None) {
- Tk_FreeGC(Tk_Display(tkwin), polyPtr->fillGC);
- }
- polyPtr->fillGC = newGC;
-
- /*
- * Keep spline parameters within reasonable limits.
- */
-
- if (polyPtr->splineSteps < 1) {
- polyPtr->splineSteps = 1;
- } else if (polyPtr->splineSteps > 100) {
- polyPtr->splineSteps = 100;
- }
-
- ComputePolygonBbox(canvas, polyPtr);
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * DeletePolygon --
- *
- * This procedure is called to clean up the data structure
- * associated with a polygon item.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Resources associated with itemPtr are released.
- *
- *--------------------------------------------------------------
- */
-
-static void
-DeletePolygon(canvas, itemPtr, display)
- Tk_Canvas canvas; /* Info about overall canvas widget. */
- Tk_Item *itemPtr; /* Item that is being deleted. */
- Display *display; /* Display containing window for
- * canvas. */
-{
- PolygonItem *polyPtr = (PolygonItem *) itemPtr;
-
- if (polyPtr->coordPtr != NULL) {
- ckfree((char *) polyPtr->coordPtr);
- }
- if (polyPtr->fillColor != NULL) {
- Tk_FreeColor(polyPtr->fillColor);
- }
- if (polyPtr->fillStipple != None) {
- Tk_FreeBitmap(display, polyPtr->fillStipple);
- }
- if (polyPtr->outlineColor != NULL) {
- Tk_FreeColor(polyPtr->outlineColor);
- }
- if (polyPtr->outlineGC != None) {
- Tk_FreeGC(display, polyPtr->outlineGC);
- }
- if (polyPtr->fillGC != None) {
- Tk_FreeGC(display, polyPtr->fillGC);
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ComputePolygonBbox --
- *
- * This procedure is invoked to compute the bounding box of
- * all the pixels that may be drawn as part of a polygon.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The fields x1, y1, x2, and y2 are updated in the header
- * for itemPtr.
- *
- *--------------------------------------------------------------
- */
-
-static void
-ComputePolygonBbox(canvas, polyPtr)
- Tk_Canvas canvas; /* Canvas that contains item. */
- PolygonItem *polyPtr; /* Item whose bbox is to be
- * recomputed. */
-{
- double *coordPtr;
- int i;
-
- coordPtr = polyPtr->coordPtr;
- polyPtr->header.x1 = polyPtr->header.x2 = (int) *coordPtr;
- polyPtr->header.y1 = polyPtr->header.y2 = (int) coordPtr[1];
-
- for (i = 1, coordPtr = polyPtr->coordPtr+2; i < polyPtr->numPoints;
- i++, coordPtr += 2) {
- TkIncludePoint((Tk_Item *) polyPtr, coordPtr);
- }
-
- /*
- * Expand bounding box in all directions to account for the outline,
- * which can stick out beyond the polygon. Add one extra pixel of
- * fudge, just in case X rounds differently than we do.
- */
-
- i = (polyPtr->width+1)/2 + 1;
- polyPtr->header.x1 -= i;
- polyPtr->header.x2 += i;
- polyPtr->header.y1 -= i;
- polyPtr->header.y2 += i;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * TkFillPolygon --
- *
- * This procedure is invoked to convert a polygon to screen
- * coordinates and display it using a particular GC.
- *
- * Results:
- * None.
- *
- * Side effects:
- * ItemPtr is drawn in drawable using the transformation
- * information in canvas.
- *
- *--------------------------------------------------------------
- */
-
-void
-TkFillPolygon(canvas, coordPtr, numPoints, display, drawable, gc, outlineGC)
- Tk_Canvas canvas; /* Canvas whose coordinate system
- * is to be used for drawing. */
- double *coordPtr; /* Array of coordinates for polygon:
- * x1, y1, x2, y2, .... */
- int numPoints; /* Twice this many coordinates are
- * present at *coordPtr. */
- Display *display; /* Display on which to draw polygon. */
- Drawable drawable; /* Pixmap or window in which to draw
- * polygon. */
- GC gc; /* Graphics context for drawing. */
- GC outlineGC; /* If not None, use this to draw an
- * outline around the polygon after
- * filling it. */
-{
- XPoint staticPoints[MAX_STATIC_POINTS];
- XPoint *pointPtr;
- XPoint *pPtr;
- int i;
-
- /*
- * Build up an array of points in screen coordinates. Use a
- * static array unless the polygon has an enormous number of points;
- * in this case, dynamically allocate an array.
- */
-
- if (numPoints <= MAX_STATIC_POINTS) {
- pointPtr = staticPoints;
- } else {
- pointPtr = (XPoint *) ckalloc((unsigned) (numPoints * sizeof(XPoint)));
- }
-
- for (i = 0, pPtr = pointPtr; i < numPoints; i += 1, coordPtr += 2, pPtr++) {
- Tk_CanvasDrawableCoords(canvas, coordPtr[0], coordPtr[1], &pPtr->x,
- &pPtr->y);
- }
-
- /*
- * Display polygon, then free up polygon storage if it was dynamically
- * allocated.
- */
-
- if (gc != None) {
- XFillPolygon(display, drawable, gc, pointPtr, numPoints, Complex,
- CoordModeOrigin);
- }
- if (outlineGC != None) {
- XDrawLines(display, drawable, outlineGC, pointPtr,
- numPoints, CoordModeOrigin);
- }
- if (pointPtr != staticPoints) {
- ckfree((char *) pointPtr);
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * DisplayPolygon --
- *
- * This procedure is invoked to draw a polygon item in a given
- * drawable.
- *
- * Results:
- * None.
- *
- * Side effects:
- * ItemPtr is drawn in drawable using the transformation
- * information in canvas.
- *
- *--------------------------------------------------------------
- */
-
-static void
-DisplayPolygon(canvas, itemPtr, display, drawable, x, y, width, height)
- Tk_Canvas canvas; /* Canvas that contains item. */
- Tk_Item *itemPtr; /* Item to be displayed. */
- Display *display; /* Display on which to draw item. */
- Drawable drawable; /* Pixmap or window in which to draw
- * item. */
- int x, y, width, height; /* Describes region of canvas that
- * must be redisplayed (not used). */
-{
- PolygonItem *polyPtr = (PolygonItem *) itemPtr;
-
- if ((polyPtr->fillGC == None) && (polyPtr->outlineGC == None)) {
- return;
- }
-
- /*
- * If we're stippling then modify the stipple offset in the GC. Be
- * sure to reset the offset when done, since the GC is supposed to be
- * read-only.
- */
-
- if ((polyPtr->fillStipple != None) && (polyPtr->fillGC != None)) {
- Tk_CanvasSetStippleOrigin(canvas, polyPtr->fillGC);
- }
-
- if (!polyPtr->smooth) {
- TkFillPolygon(canvas, polyPtr->coordPtr, polyPtr->numPoints,
- display, drawable, polyPtr->fillGC, polyPtr->outlineGC);
- } else {
- int numPoints;
- XPoint staticPoints[MAX_STATIC_POINTS];
- XPoint *pointPtr;
-
- /*
- * This is a smoothed polygon. Display using a set of generated
- * spline points rather than the original points.
- */
-
- numPoints = 1 + polyPtr->numPoints*polyPtr->splineSteps;
- if (numPoints <= MAX_STATIC_POINTS) {
- pointPtr = staticPoints;
- } else {
- pointPtr = (XPoint *) ckalloc((unsigned)
- (numPoints * sizeof(XPoint)));
- }
- numPoints = TkMakeBezierCurve(canvas, polyPtr->coordPtr,
- polyPtr->numPoints, polyPtr->splineSteps, pointPtr,
- (double *) NULL);
- if (polyPtr->fillGC != None) {
- XFillPolygon(display, drawable, polyPtr->fillGC, pointPtr,
- numPoints, Complex, CoordModeOrigin);
- }
- if (polyPtr->outlineGC != None) {
- XDrawLines(display, drawable, polyPtr->outlineGC, pointPtr,
- numPoints, CoordModeOrigin);
- }
- if (pointPtr != staticPoints) {
- ckfree((char *) pointPtr);
- }
- }
- if ((polyPtr->fillStipple != None) && (polyPtr->fillGC != None)) {
- XSetTSOrigin(display, polyPtr->fillGC, 0, 0);
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * PolygonToPoint --
- *
- * Computes the distance from a given point to a given
- * polygon, in canvas units.
- *
- * Results:
- * The return value is 0 if the point whose x and y coordinates
- * are pointPtr[0] and pointPtr[1] is inside the polygon. If the
- * point isn't inside the polygon then the return value is the
- * distance from the point to the polygon.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
- /* ARGSUSED */
-static double
-PolygonToPoint(canvas, itemPtr, pointPtr)
- Tk_Canvas canvas; /* Canvas containing item. */
- Tk_Item *itemPtr; /* Item to check against point. */
- double *pointPtr; /* Pointer to x and y coordinates. */
-{
- PolygonItem *polyPtr = (PolygonItem *) itemPtr;
- double *coordPtr, distance;
- double staticSpace[2*MAX_STATIC_POINTS];
- int numPoints;
-
- if (!polyPtr->smooth) {
- distance = TkPolygonToPoint(polyPtr->coordPtr, polyPtr->numPoints,
- pointPtr);
- } else {
- /*
- * Smoothed polygon. Generate a new set of points and use them
- * for comparison.
- */
-
- numPoints = 1 + polyPtr->numPoints*polyPtr->splineSteps;
- if (numPoints <= MAX_STATIC_POINTS) {
- coordPtr = staticSpace;
- } else {
- coordPtr = (double *) ckalloc((unsigned)
- (2*numPoints*sizeof(double)));
- }
- numPoints = TkMakeBezierCurve(canvas, polyPtr->coordPtr,
- polyPtr->numPoints, polyPtr->splineSteps, (XPoint *) NULL,
- coordPtr);
- distance = TkPolygonToPoint(coordPtr, numPoints, pointPtr);
- if (coordPtr != staticSpace) {
- ckfree((char *) coordPtr);
- }
- }
- if (polyPtr->outlineColor != NULL) {
- distance -= polyPtr->width/2.0;
- if (distance < 0) {
- distance = 0;
- }
- }
- return distance;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * PolygonToArea --
- *
- * This procedure is called to determine whether an item
- * lies entirely inside, entirely outside, or overlapping
- * a given rectangular area.
- *
- * Results:
- * -1 is returned if the item is entirely outside the area
- * given by rectPtr, 0 if it overlaps, and 1 if it is entirely
- * inside the given area.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
- /* ARGSUSED */
-static int
-PolygonToArea(canvas, itemPtr, rectPtr)
- Tk_Canvas canvas; /* Canvas containing item. */
- Tk_Item *itemPtr; /* Item to check against polygon. */
- double *rectPtr; /* Pointer to array of four coordinates
- * (x1, y1, x2, y2) describing rectangular
- * area. */
-{
- PolygonItem *polyPtr = (PolygonItem *) itemPtr;
- double *coordPtr, rect2[4], halfWidth;
- double staticSpace[2*MAX_STATIC_POINTS];
- int numPoints, result;
-
- /*
- * Handle smoothed polygons by generating an expanded set of points
- * against which to do the check.
- */
-
- if (polyPtr->smooth) {
- numPoints = 1 + polyPtr->numPoints*polyPtr->splineSteps;
- if (numPoints <= MAX_STATIC_POINTS) {
- coordPtr = staticSpace;
- } else {
- coordPtr = (double *) ckalloc((unsigned)
- (2*numPoints*sizeof(double)));
- }
- numPoints = TkMakeBezierCurve(canvas, polyPtr->coordPtr,
- polyPtr->numPoints, polyPtr->splineSteps, (XPoint *) NULL,
- coordPtr);
- } else {
- numPoints = polyPtr->numPoints;
- coordPtr = polyPtr->coordPtr;
- }
-
- if (polyPtr->width <= 1) {
- /*
- * The outline of the polygon doesn't stick out, so we can
- * do a simple check.
- */
-
- result = TkPolygonToArea(coordPtr, numPoints, rectPtr);
- } else {
- /*
- * The polygon has a wide outline, so the check is more complicated.
- * First, check the line segments to see if they overlap the area.
- */
-
- result = TkThickPolyLineToArea(coordPtr, numPoints,
- (double) polyPtr->width, CapRound, JoinRound, rectPtr);
- if (result >= 0) {
- goto done;
- }
-
- /*
- * There is no overlap between the polygon's outline and the
- * rectangle. This means either the rectangle is entirely outside
- * the polygon or entirely inside. To tell the difference,
- * see whether the polygon (with 0 outline width) overlaps the
- * rectangle bloated by half the outline width.
- */
-
- halfWidth = polyPtr->width/2.0;
- rect2[0] = rectPtr[0] - halfWidth;
- rect2[1] = rectPtr[1] - halfWidth;
- rect2[2] = rectPtr[2] + halfWidth;
- rect2[3] = rectPtr[3] + halfWidth;
- if (TkPolygonToArea(coordPtr, numPoints, rect2) == -1) {
- result = -1;
- } else {
- result = 0;
- }
- }
-
- done:
- if ((coordPtr != staticSpace) && (coordPtr != polyPtr->coordPtr)) {
- ckfree((char *) coordPtr);
- }
- return result;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ScalePolygon --
- *
- * This procedure is invoked to rescale a polygon item.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The polygon referred to by itemPtr is rescaled so that the
- * following transformation is applied to all point
- * coordinates:
- * x' = originX + scaleX*(x-originX)
- * y' = originY + scaleY*(y-originY)
- *
- *--------------------------------------------------------------
- */
-
-static void
-ScalePolygon(canvas, itemPtr, originX, originY, scaleX, scaleY)
- Tk_Canvas canvas; /* Canvas containing polygon. */
- Tk_Item *itemPtr; /* Polygon to be scaled. */
- double originX, originY; /* Origin about which to scale rect. */
- double scaleX; /* Amount to scale in X direction. */
- double scaleY; /* Amount to scale in Y direction. */
-{
- PolygonItem *polyPtr = (PolygonItem *) itemPtr;
- double *coordPtr;
- int i;
-
- for (i = 0, coordPtr = polyPtr->coordPtr; i < polyPtr->numPoints;
- i++, coordPtr += 2) {
- *coordPtr = originX + scaleX*(*coordPtr - originX);
- coordPtr[1] = originY + scaleY*(coordPtr[1] - originY);
- }
- ComputePolygonBbox(canvas, polyPtr);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * TranslatePolygon --
- *
- * This procedure is called to move a polygon by a given
- * amount.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The position of the polygon is offset by (xDelta, yDelta),
- * and the bounding box is updated in the generic part of the
- * item structure.
- *
- *--------------------------------------------------------------
- */
-
-static void
-TranslatePolygon(canvas, itemPtr, deltaX, deltaY)
- Tk_Canvas canvas; /* Canvas containing item. */
- Tk_Item *itemPtr; /* Item that is being moved. */
- double deltaX, deltaY; /* Amount by which item is to be
- * moved. */
-{
- PolygonItem *polyPtr = (PolygonItem *) itemPtr;
- double *coordPtr;
- int i;
-
- for (i = 0, coordPtr = polyPtr->coordPtr; i < polyPtr->numPoints;
- i++, coordPtr += 2) {
- *coordPtr += deltaX;
- coordPtr[1] += deltaY;
- }
- ComputePolygonBbox(canvas, polyPtr);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * PolygonToPostscript --
- *
- * This procedure is called to generate Postscript for
- * polygon items.
- *
- * Results:
- * The return value is a standard Tcl result. If an error
- * occurs in generating Postscript then an error message is
- * left in interp->result, replacing whatever used
- * to be there. If no error occurs, then Postscript for the
- * item is appended to the result.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-static int
-PolygonToPostscript(interp, canvas, itemPtr, prepass)
- Tcl_Interp *interp; /* Leave Postscript or error message
- * here. */
- Tk_Canvas canvas; /* Information about overall canvas. */
- Tk_Item *itemPtr; /* Item for which Postscript is
- * wanted. */
- int prepass; /* 1 means this is a prepass to
- * collect font information; 0 means
- * final Postscript is being created. */
-{
- char string[100];
- PolygonItem *polyPtr = (PolygonItem *) itemPtr;
-
- /*
- * Fill the area of the polygon.
- */
-
- if (polyPtr->fillColor != NULL) {
- if (!polyPtr->smooth) {
- Tk_CanvasPsPath(interp, canvas, polyPtr->coordPtr,
- polyPtr->numPoints);
- } else {
- TkMakeBezierPostscript(interp, canvas, polyPtr->coordPtr,
- polyPtr->numPoints);
- }
- if (Tk_CanvasPsColor(interp, canvas, polyPtr->fillColor) != TCL_OK) {
- return TCL_ERROR;
- }
- if (polyPtr->fillStipple != None) {
- Tcl_AppendResult(interp, "eoclip ", (char *) NULL);
- if (Tk_CanvasPsStipple(interp, canvas, polyPtr->fillStipple)
- != TCL_OK) {
- return TCL_ERROR;
- }
- if (polyPtr->outlineColor != NULL) {
- Tcl_AppendResult(interp, "grestore gsave\n", (char *) NULL);
- }
- } else {
- Tcl_AppendResult(interp, "eofill\n", (char *) NULL);
- }
- }
-
- /*
- * Now draw the outline, if there is one.
- */
-
- if (polyPtr->outlineColor != NULL) {
- if (!polyPtr->smooth) {
- Tk_CanvasPsPath(interp, canvas, polyPtr->coordPtr,
- polyPtr->numPoints);
- } else {
- TkMakeBezierPostscript(interp, canvas, polyPtr->coordPtr,
- polyPtr->numPoints);
- }
-
- sprintf(string, "%d setlinewidth\n", polyPtr->width);
- Tcl_AppendResult(interp, string,
- "1 setlinecap\n1 setlinejoin\n", (char *) NULL);
- if (Tk_CanvasPsColor(interp, canvas, polyPtr->outlineColor)
- != TCL_OK) {
- return TCL_ERROR;
- }
- Tcl_AppendResult(interp, "stroke\n", (char *) NULL);
- }
- return TCL_OK;
-}
diff --git a/generic/tkCanvPs.c b/generic/tkCanvPs.c
deleted file mode 100644
index 3b83d35..0000000
--- a/generic/tkCanvPs.c
+++ /dev/null
@@ -1,1386 +0,0 @@
-/*
- * tkCanvPs.c --
- *
- * This module provides Postscript output support for canvases,
- * including the "postscript" widget command plus a few utility
- * procedures used for generating Postscript.
- *
- * Copyright (c) 1991-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: tkCanvPs.c,v 1.3 1998/09/14 18:23:05 stanton Exp $
- */
-
-#include "tkInt.h"
-#include "tkCanvas.h"
-#include "tkPort.h"
-
-/*
- * See tkCanvas.h for key data structures used to implement canvases.
- */
-
-/*
- * One of the following structures is created to keep track of Postscript
- * output being generated. It consists mostly of information provided on
- * the widget command line.
- */
-
-typedef struct TkPostscriptInfo {
- int x, y, width, height; /* Area to print, in canvas pixel
- * coordinates. */
- int x2, y2; /* x+width and y+height. */
- char *pageXString; /* String value of "-pagex" option or NULL. */
- char *pageYString; /* String value of "-pagey" option or NULL. */
- double pageX, pageY; /* Postscript coordinates (in points)
- * corresponding to pageXString and
- * pageYString. Don't forget that y-values
- * grow upwards for Postscript! */
- char *pageWidthString; /* Printed width of output. */
- char *pageHeightString; /* Printed height of output. */
- double scale; /* Scale factor for conversion: each pixel
- * maps into this many points. */
- Tk_Anchor pageAnchor; /* How to anchor bbox on Postscript page. */
- int rotate; /* Non-zero means output should be rotated
- * on page (landscape mode). */
- char *fontVar; /* If non-NULL, gives name of global variable
- * containing font mapping information.
- * Malloc'ed. */
- char *colorVar; /* If non-NULL, give name of global variable
- * containing color mapping information.
- * Malloc'ed. */
- char *colorMode; /* Mode for handling colors: "monochrome",
- * "gray", or "color". Malloc'ed. */
- int colorLevel; /* Numeric value corresponding to colorMode:
- * 0 for mono, 1 for gray, 2 for color. */
- char *fileName; /* Name of file in which to write Postscript;
- * NULL means return Postscript info as
- * result. Malloc'ed. */
- char *channelName; /* If -channel is specified, the name of
- * the channel to use. */
- Tcl_Channel chan; /* Open channel corresponding to fileName. */
- Tcl_HashTable fontTable; /* Hash table containing names of all font
- * families used in output. The hash table
- * values are not used. */
- int prepass; /* Non-zero means that we're currently in
- * the pre-pass that collects font information,
- * so the Postscript generated isn't
- * relevant. */
-} TkPostscriptInfo;
-
-/*
- * The table below provides a template that's used to process arguments
- * to the canvas "postscript" command and fill in TkPostscriptInfo
- * structures.
- */
-
-static Tk_ConfigSpec configSpecs[] = {
- {TK_CONFIG_STRING, "-colormap", (char *) NULL, (char *) NULL,
- "", Tk_Offset(TkPostscriptInfo, colorVar), 0},
- {TK_CONFIG_STRING, "-colormode", (char *) NULL, (char *) NULL,
- "", Tk_Offset(TkPostscriptInfo, colorMode), 0},
- {TK_CONFIG_STRING, "-file", (char *) NULL, (char *) NULL,
- "", Tk_Offset(TkPostscriptInfo, fileName), 0},
- {TK_CONFIG_STRING, "-channel", (char *) NULL, (char *) NULL,
- "", Tk_Offset(TkPostscriptInfo, channelName), 0},
- {TK_CONFIG_STRING, "-fontmap", (char *) NULL, (char *) NULL,
- "", Tk_Offset(TkPostscriptInfo, fontVar), 0},
- {TK_CONFIG_PIXELS, "-height", (char *) NULL, (char *) NULL,
- "", Tk_Offset(TkPostscriptInfo, height), 0},
- {TK_CONFIG_ANCHOR, "-pageanchor", (char *) NULL, (char *) NULL,
- "", Tk_Offset(TkPostscriptInfo, pageAnchor), 0},
- {TK_CONFIG_STRING, "-pageheight", (char *) NULL, (char *) NULL,
- "", Tk_Offset(TkPostscriptInfo, pageHeightString), 0},
- {TK_CONFIG_STRING, "-pagewidth", (char *) NULL, (char *) NULL,
- "", Tk_Offset(TkPostscriptInfo, pageWidthString), 0},
- {TK_CONFIG_STRING, "-pagex", (char *) NULL, (char *) NULL,
- "", Tk_Offset(TkPostscriptInfo, pageXString), 0},
- {TK_CONFIG_STRING, "-pagey", (char *) NULL, (char *) NULL,
- "", Tk_Offset(TkPostscriptInfo, pageYString), 0},
- {TK_CONFIG_BOOLEAN, "-rotate", (char *) NULL, (char *) NULL,
- "", Tk_Offset(TkPostscriptInfo, rotate), 0},
- {TK_CONFIG_PIXELS, "-width", (char *) NULL, (char *) NULL,
- "", Tk_Offset(TkPostscriptInfo, width), 0},
- {TK_CONFIG_PIXELS, "-x", (char *) NULL, (char *) NULL,
- "", Tk_Offset(TkPostscriptInfo, x), 0},
- {TK_CONFIG_PIXELS, "-y", (char *) NULL, (char *) NULL,
- "", Tk_Offset(TkPostscriptInfo, y), 0},
- {TK_CONFIG_END, (char *) NULL, (char *) NULL, (char *) NULL,
- (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.
- */
-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: tkCanvPs.c,v 1.3 1998/09/14 18:23:05 stanton Exp $
-\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:
- */
-
-static int GetPostscriptPoints _ANSI_ARGS_((Tcl_Interp *interp,
- char *string, double *doublePtr));
-
-/*
- *--------------------------------------------------------------
- *
- * TkCanvPostscriptCmd --
- *
- * This procedure is invoked to process the "postscript" options
- * of the widget command for canvas widgets. See the user
- * documentation for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *--------------------------------------------------------------
- */
-
- /* ARGSUSED */
-int
-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
- * already parsed this command enough
- * to know that argv[1] is
- * "postscript". */
-{
- TkPostscriptInfo psInfo, *oldInfoPtr;
- int result;
- Tk_Item *itemPtr;
-#define STRING_LENGTH 400
- char string[STRING_LENGTH+1], *p;
- time_t now;
- size_t length;
- int deltaX = 0, deltaY = 0; /* Offset of lower-left corner of
- * area to be marked up, measured
- * in canvas units from the positioning
- * point on the page (reflects
- * anchor position). Initial values
- * needed only to stop compiler
- * warnings. */
- Tcl_HashSearch search;
- Tcl_HashEntry *hPtr;
- Tcl_DString buffer;
- CONST char * CONST *chunk;
-
- /*
- *----------------------------------------------------------------
- * Initialize the data structure describing Postscript generation,
- * then process all the arguments to fill the data structure in.
- *----------------------------------------------------------------
- */
-
- oldInfoPtr = canvasPtr->psInfoPtr;
- canvasPtr->psInfoPtr = &psInfo;
- psInfo.x = canvasPtr->xOrigin;
- psInfo.y = canvasPtr->yOrigin;
- psInfo.width = -1;
- psInfo.height = -1;
- psInfo.pageXString = NULL;
- psInfo.pageYString = NULL;
- psInfo.pageX = 72*4.25;
- psInfo.pageY = 72*5.5;
- psInfo.pageWidthString = NULL;
- psInfo.pageHeightString = NULL;
- psInfo.scale = 1.0;
- psInfo.pageAnchor = TK_ANCHOR_CENTER;
- psInfo.rotate = 0;
- psInfo.fontVar = NULL;
- psInfo.colorVar = NULL;
- psInfo.colorMode = NULL;
- psInfo.colorLevel = 0;
- psInfo.fileName = NULL;
- psInfo.channelName = NULL;
- psInfo.chan = NULL;
- psInfo.prepass = 0;
- Tcl_InitHashTable(&psInfo.fontTable, TCL_STRING_KEYS);
- result = Tk_ConfigureWidget(canvasPtr->interp, canvasPtr->tkwin,
- configSpecs, argc-2, argv+2, (char *) &psInfo,
- TK_CONFIG_ARGV_ONLY);
- if (result != TCL_OK) {
- goto cleanup;
- }
-
- if (psInfo.width == -1) {
- psInfo.width = Tk_Width(canvasPtr->tkwin);
- }
- if (psInfo.height == -1) {
- psInfo.height = Tk_Height(canvasPtr->tkwin);
- }
- psInfo.x2 = psInfo.x + psInfo.width;
- psInfo.y2 = psInfo.y + psInfo.height;
-
- if (psInfo.pageXString != NULL) {
- if (GetPostscriptPoints(canvasPtr->interp, psInfo.pageXString,
- &psInfo.pageX) != TCL_OK) {
- goto cleanup;
- }
- }
- if (psInfo.pageYString != NULL) {
- if (GetPostscriptPoints(canvasPtr->interp, psInfo.pageYString,
- &psInfo.pageY) != TCL_OK) {
- goto cleanup;
- }
- }
- if (psInfo.pageWidthString != NULL) {
- if (GetPostscriptPoints(canvasPtr->interp, psInfo.pageWidthString,
- &psInfo.scale) != TCL_OK) {
- goto cleanup;
- }
- psInfo.scale /= psInfo.width;
- } else if (psInfo.pageHeightString != NULL) {
- if (GetPostscriptPoints(canvasPtr->interp, psInfo.pageHeightString,
- &psInfo.scale) != TCL_OK) {
- goto cleanup;
- }
- psInfo.scale /= psInfo.height;
- } else {
- psInfo.scale = (72.0/25.4)*WidthMMOfScreen(Tk_Screen(canvasPtr->tkwin));
- psInfo.scale /= WidthOfScreen(Tk_Screen(canvasPtr->tkwin));
- }
- switch (psInfo.pageAnchor) {
- case TK_ANCHOR_NW:
- case TK_ANCHOR_W:
- case TK_ANCHOR_SW:
- deltaX = 0;
- break;
- case TK_ANCHOR_N:
- case TK_ANCHOR_CENTER:
- case TK_ANCHOR_S:
- deltaX = -psInfo.width/2;
- break;
- case TK_ANCHOR_NE:
- case TK_ANCHOR_E:
- case TK_ANCHOR_SE:
- deltaX = -psInfo.width;
- break;
- }
- switch (psInfo.pageAnchor) {
- case TK_ANCHOR_NW:
- case TK_ANCHOR_N:
- case TK_ANCHOR_NE:
- deltaY = - psInfo.height;
- break;
- case TK_ANCHOR_W:
- case TK_ANCHOR_CENTER:
- case TK_ANCHOR_E:
- deltaY = -psInfo.height/2;
- break;
- case TK_ANCHOR_SW:
- case TK_ANCHOR_S:
- case TK_ANCHOR_SE:
- deltaY = 0;
- break;
- }
-
- if (psInfo.colorMode == NULL) {
- psInfo.colorLevel = 2;
- } else {
- length = strlen(psInfo.colorMode);
- if (strncmp(psInfo.colorMode, "monochrome", length) == 0) {
- psInfo.colorLevel = 0;
- } else if (strncmp(psInfo.colorMode, "gray", length) == 0) {
- psInfo.colorLevel = 1;
- } else if (strncmp(psInfo.colorMode, "color", length) == 0) {
- psInfo.colorLevel = 2;
- } else {
- Tcl_AppendResult(canvasPtr->interp, "bad color mode \"",
- psInfo.colorMode, "\": must be monochrome, ",
- "gray, or color", (char *) NULL);
- goto cleanup;
- }
- }
-
- if (psInfo.fileName != NULL) {
-
- /*
- * Check that -file and -channel are not both specified.
- */
-
- if (psInfo.channelName != NULL) {
- Tcl_AppendResult(canvasPtr->interp, "can't specify both -file",
- " and -channel", (char *) NULL);
- result = TCL_ERROR;
- goto cleanup;
- }
-
- /*
- * Check that we are not in a safe interpreter. If we are, disallow
- * the -file specification.
- */
-
- if (Tcl_IsSafe(canvasPtr->interp)) {
- Tcl_AppendResult(canvasPtr->interp, "can't specify -file in a",
- " safe interpreter", (char *) NULL);
- result = TCL_ERROR;
- goto cleanup;
- }
-
- p = Tcl_TranslateFileName(canvasPtr->interp, psInfo.fileName, &buffer);
- if (p == NULL) {
- goto cleanup;
- }
- psInfo.chan = Tcl_OpenFileChannel(canvasPtr->interp, p, "w", 0666);
- Tcl_DStringFree(&buffer);
- if (psInfo.chan == NULL) {
- goto cleanup;
- }
- }
-
- if (psInfo.channelName != NULL) {
- int mode;
-
- /*
- * Check that the channel is found in this interpreter and that it
- * is open for writing.
- */
-
- psInfo.chan = Tcl_GetChannel(canvasPtr->interp, psInfo.channelName,
- &mode);
- if (psInfo.chan == (Tcl_Channel) NULL) {
- result = TCL_ERROR;
- goto cleanup;
- }
- if ((mode & TCL_WRITABLE) == 0) {
- Tcl_AppendResult(canvasPtr->interp, "channel \"",
- psInfo.channelName, "\" wasn't opened for writing",
- (char *) NULL);
- result = TCL_ERROR;
- goto cleanup;
- }
- }
-
- /*
- *--------------------------------------------------------
- * Make a pre-pass over all of the items, generating Postscript
- * and then throwing it away. The purpose of this pass is just
- * to collect information about all the fonts in use, so that
- * we can output font information in the proper form required
- * by the Document Structuring Conventions.
- *--------------------------------------------------------
- */
-
- psInfo.prepass = 1;
- for (itemPtr = canvasPtr->firstItemPtr; itemPtr != NULL;
- itemPtr = itemPtr->nextPtr) {
- if ((itemPtr->x1 >= psInfo.x2) || (itemPtr->x2 < psInfo.x)
- || (itemPtr->y1 >= psInfo.y2) || (itemPtr->y2 < psInfo.y)) {
- continue;
- }
- if (itemPtr->typePtr->postscriptProc == NULL) {
- continue;
- }
- result = (*itemPtr->typePtr->postscriptProc)(canvasPtr->interp,
- (Tk_Canvas) canvasPtr, itemPtr, 1);
- Tcl_ResetResult(canvasPtr->interp);
- if (result != TCL_OK) {
- /*
- * An error just occurred. Just skip out of this loop.
- * There's no need to report the error now; it can be
- * reported later (errors can happen later that don't
- * happen now, so we still have to check for errors later
- * anyway).
- */
- break;
- }
- }
- psInfo.prepass = 0;
-
- /*
- *--------------------------------------------------------
- * Generate the header and prolog for the Postscript.
- *--------------------------------------------------------
- */
-
- Tcl_AppendResult(canvasPtr->interp, "%!PS-Adobe-3.0 EPSF-3.0\n",
- "%%Creator: Tk Canvas Widget\n", (char *) NULL);
-#if !(defined(__WIN32__) || defined(MAC_TCL))
- if (!Tcl_IsSafe(interp)) {
- struct passwd *pwPtr = getpwuid(getuid());
- Tcl_AppendResult(canvasPtr->interp, "%%For: ",
- (pwPtr != NULL) ? pwPtr->pw_gecos : "Unknown", "\n",
- (char *) NULL);
- endpwent();
- }
-#endif /* __WIN32__ || MAC_TCL */
- Tcl_AppendResult(canvasPtr->interp, "%%Title: Window ",
- Tk_PathName(canvasPtr->tkwin), "\n", (char *) NULL);
- time(&now);
- Tcl_AppendResult(canvasPtr->interp, "%%CreationDate: ",
- ctime(&now), (char *) NULL);
- if (!psInfo.rotate) {
- sprintf(string, "%d %d %d %d",
- (int) (psInfo.pageX + psInfo.scale*deltaX),
- (int) (psInfo.pageY + psInfo.scale*deltaY),
- (int) (psInfo.pageX + psInfo.scale*(deltaX + psInfo.width)
- + 1.0),
- (int) (psInfo.pageY + psInfo.scale*(deltaY + psInfo.height)
- + 1.0));
- } else {
- sprintf(string, "%d %d %d %d",
- (int) (psInfo.pageX - psInfo.scale*(deltaY + psInfo.height)),
- (int) (psInfo.pageY + psInfo.scale*deltaX),
- (int) (psInfo.pageX - psInfo.scale*deltaY + 1.0),
- (int) (psInfo.pageY + psInfo.scale*(deltaX + psInfo.width)
- + 1.0));
- }
- Tcl_AppendResult(canvasPtr->interp, "%%BoundingBox: ", string,
- "\n", (char *) NULL);
- Tcl_AppendResult(canvasPtr->interp, "%%Pages: 1\n",
- "%%DocumentData: Clean7Bit\n", (char *) NULL);
- Tcl_AppendResult(canvasPtr->interp, "%%Orientation: ",
- psInfo.rotate ? "Landscape\n" : "Portrait\n", (char *) NULL);
- p = "%%DocumentNeededResources: font ";
- for (hPtr = Tcl_FirstHashEntry(&psInfo.fontTable, &search);
- hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
- Tcl_AppendResult(canvasPtr->interp, p,
- Tcl_GetHashKey(&psInfo.fontTable, hPtr),
- "\n", (char *) NULL);
- p = "%%+ font ";
- }
- Tcl_AppendResult(canvasPtr->interp, "%%EndComments\n\n", (char *) NULL);
-
- /*
- * Insert the prolog
- */
- for (chunk=prolog; *chunk; chunk++) {
- Tcl_AppendResult(interp, *chunk, (char *) NULL);
- }
-
- if (psInfo.chan != NULL) {
- Tcl_Write(psInfo.chan, canvasPtr->interp->result, -1);
- Tcl_ResetResult(canvasPtr->interp);
- }
-
- /*
- *-----------------------------------------------------------
- * Document setup: set the color level and include fonts.
- *-----------------------------------------------------------
- */
-
- sprintf(string, "/CL %d def\n", psInfo.colorLevel);
- Tcl_AppendResult(canvasPtr->interp, "%%BeginSetup\n", string,
- (char *) NULL);
- for (hPtr = Tcl_FirstHashEntry(&psInfo.fontTable, &search);
- hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
- Tcl_AppendResult(canvasPtr->interp, "%%IncludeResource: font ",
- Tcl_GetHashKey(&psInfo.fontTable, hPtr), "\n", (char *) NULL);
- }
- Tcl_AppendResult(canvasPtr->interp, "%%EndSetup\n\n", (char *) NULL);
-
- /*
- *-----------------------------------------------------------
- * Page setup: move to page positioning point, rotate if
- * needed, set scale factor, offset for proper anchor position,
- * and set clip region.
- *-----------------------------------------------------------
- */
-
- Tcl_AppendResult(canvasPtr->interp, "%%Page: 1 1\n", "save\n",
- (char *) NULL);
- sprintf(string, "%.1f %.1f translate\n", psInfo.pageX, psInfo.pageY);
- Tcl_AppendResult(canvasPtr->interp, string, (char *) NULL);
- if (psInfo.rotate) {
- Tcl_AppendResult(canvasPtr->interp, "90 rotate\n", (char *) NULL);
- }
- sprintf(string, "%.4g %.4g scale\n", psInfo.scale, psInfo.scale);
- Tcl_AppendResult(canvasPtr->interp, string, (char *) NULL);
- sprintf(string, "%d %d translate\n", deltaX - psInfo.x, deltaY);
- Tcl_AppendResult(canvasPtr->interp, string, (char *) NULL);
- sprintf(string, "%d %.15g moveto %d %.15g lineto %d %.15g lineto %d %.15g",
- psInfo.x, Tk_CanvasPsY((Tk_Canvas) canvasPtr, (double) psInfo.y),
- psInfo.x2, Tk_CanvasPsY((Tk_Canvas) canvasPtr, (double) psInfo.y),
- psInfo.x2, Tk_CanvasPsY((Tk_Canvas) canvasPtr, (double) psInfo.y2),
- psInfo.x, Tk_CanvasPsY((Tk_Canvas) canvasPtr, (double) psInfo.y2));
- Tcl_AppendResult(canvasPtr->interp, string,
- " lineto closepath clip newpath\n", (char *) NULL);
- if (psInfo.chan != NULL) {
- Tcl_Write(psInfo.chan, canvasPtr->interp->result, -1);
- Tcl_ResetResult(canvasPtr->interp);
- }
-
- /*
- *---------------------------------------------------------------------
- * Iterate through all the items, having each relevant one draw itself.
- * Quit if any of the items returns an error.
- *---------------------------------------------------------------------
- */
-
- result = TCL_OK;
- for (itemPtr = canvasPtr->firstItemPtr; itemPtr != NULL;
- itemPtr = itemPtr->nextPtr) {
- if ((itemPtr->x1 >= psInfo.x2) || (itemPtr->x2 < psInfo.x)
- || (itemPtr->y1 >= psInfo.y2) || (itemPtr->y2 < psInfo.y)) {
- continue;
- }
- if (itemPtr->typePtr->postscriptProc == NULL) {
- continue;
- }
- Tcl_AppendResult(canvasPtr->interp, "gsave\n", (char *) NULL);
- result = (*itemPtr->typePtr->postscriptProc)(canvasPtr->interp,
- (Tk_Canvas) canvasPtr, itemPtr, 0);
- if (result != TCL_OK) {
- char msg[100];
-
- sprintf(msg, "\n (generating Postscript for item %d)",
- itemPtr->id);
- Tcl_AddErrorInfo(canvasPtr->interp, msg);
- goto cleanup;
- }
- Tcl_AppendResult(canvasPtr->interp, "grestore\n", (char *) NULL);
- if (psInfo.chan != NULL) {
- Tcl_Write(psInfo.chan, canvasPtr->interp->result, -1);
- Tcl_ResetResult(canvasPtr->interp);
- }
- }
-
- /*
- *---------------------------------------------------------------------
- * Output page-end information, such as commands to print the page
- * and document trailer stuff.
- *---------------------------------------------------------------------
- */
-
- Tcl_AppendResult(canvasPtr->interp, "restore showpage\n\n",
- "%%Trailer\nend\n%%EOF\n", (char *) NULL);
- if (psInfo.chan != NULL) {
- Tcl_Write(psInfo.chan, canvasPtr->interp->result, -1);
- Tcl_ResetResult(canvasPtr->interp);
- }
-
- /*
- * Clean up psInfo to release malloc'ed stuff.
- */
-
- cleanup:
- if (psInfo.pageXString != NULL) {
- ckfree(psInfo.pageXString);
- }
- if (psInfo.pageYString != NULL) {
- ckfree(psInfo.pageYString);
- }
- if (psInfo.pageWidthString != NULL) {
- ckfree(psInfo.pageWidthString);
- }
- if (psInfo.pageHeightString != NULL) {
- ckfree(psInfo.pageHeightString);
- }
- if (psInfo.fontVar != NULL) {
- ckfree(psInfo.fontVar);
- }
- if (psInfo.colorVar != NULL) {
- ckfree(psInfo.colorVar);
- }
- if (psInfo.colorMode != NULL) {
- ckfree(psInfo.colorMode);
- }
- if (psInfo.fileName != NULL) {
- ckfree(psInfo.fileName);
- }
- if ((psInfo.chan != NULL) && (psInfo.channelName == NULL)) {
- Tcl_Close(canvasPtr->interp, psInfo.chan);
- }
- if (psInfo.channelName != NULL) {
- ckfree(psInfo.channelName);
- }
- Tcl_DeleteHashTable(&psInfo.fontTable);
- canvasPtr->psInfoPtr = oldInfoPtr;
- return result;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_CanvasPsColor --
- *
- * This procedure is called by individual canvas items when
- * they want to set a color value for output. Given information
- * about an X color, this procedure will generate Postscript
- * commands to set up an appropriate color in Postscript.
- *
- * Results:
- * Returns a standard Tcl return value. If an error occurs
- * then an error message will be left in interp->result.
- * If no error occurs, then additional Postscript will be
- * appended to interp->result.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-int
-Tk_CanvasPsColor(interp, canvas, colorPtr)
- Tcl_Interp *interp; /* Interpreter for returning Postscript
- * or error message. */
- Tk_Canvas canvas; /* Information about canvas. */
- XColor *colorPtr; /* Information about color. */
-{
- TkCanvas *canvasPtr = (TkCanvas *) canvas;
- TkPostscriptInfo *psInfoPtr = canvasPtr->psInfoPtr;
- int tmp;
- double red, green, blue;
- char string[200];
-
- if (psInfoPtr->prepass) {
- return TCL_OK;
- }
-
- /*
- * If there is a color map defined, then look up the color's name
- * in the map and use the Postscript commands found there, if there
- * are any.
- */
-
- if (psInfoPtr->colorVar != NULL) {
- char *cmdString;
-
- cmdString = Tcl_GetVar2(interp, psInfoPtr->colorVar,
- Tk_NameOfColor(colorPtr), 0);
- if (cmdString != NULL) {
- Tcl_AppendResult(interp, cmdString, "\n", (char *) NULL);
- return TCL_OK;
- }
- }
-
- /*
- * No color map entry for this color. Grab the color's intensities
- * and output Postscript commands for them. Special note: X uses
- * a range of 0-65535 for intensities, but most displays only use
- * a range of 0-255, which maps to (0, 256, 512, ... 65280) in the
- * X scale. This means that there's no way to get perfect white,
- * since the highest intensity is only 65280 out of 65535. To
- * work around this problem, rescale the X intensity to a 0-255
- * scale and use that as the basis for the Postscript colors. This
- * scheme still won't work if the display only uses 4 bits per color,
- * but most diplays use at least 8 bits.
- */
-
- tmp = colorPtr->red;
- red = ((double) (tmp >> 8))/255.0;
- tmp = colorPtr->green;
- green = ((double) (tmp >> 8))/255.0;
- tmp = colorPtr->blue;
- blue = ((double) (tmp >> 8))/255.0;
- sprintf(string, "%.3f %.3f %.3f setrgbcolor AdjustColor\n",
- red, green, blue);
- Tcl_AppendResult(interp, string, (char *) NULL);
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_CanvasPsFont --
- *
- * This procedure is called by individual canvas items when
- * they want to output text. Given information about an X
- * font, this procedure will generate Postscript commands
- * to set up an appropriate font in Postscript.
- *
- * Results:
- * Returns a standard Tcl return value. If an error occurs
- * then an error message will be left in interp->result.
- * If no error occurs, then additional Postscript will be
- * appended to the interp->result.
- *
- * Side effects:
- * The Postscript font name is entered into psInfoPtr->fontTable
- * if it wasn't already there.
- *
- *--------------------------------------------------------------
- */
-
-int
-Tk_CanvasPsFont(interp, canvas, tkfont)
- Tcl_Interp *interp; /* Interpreter for returning Postscript
- * or error message. */
- Tk_Canvas canvas; /* Information about canvas. */
- Tk_Font tkfont; /* Information about font in which text
- * is to be printed. */
-{
- TkCanvas *canvasPtr = (TkCanvas *) canvas;
- TkPostscriptInfo *psInfoPtr = canvasPtr->psInfoPtr;
- char *end;
- char pointString[20];
- Tcl_DString ds;
- int i, points;
-
- /*
- * First, look up the font's name in the font map, if there is one.
- * If there is an entry for this font, it consists of a list
- * containing font name and size. Use this information.
- */
-
- Tcl_DStringInit(&ds);
-
- if (psInfoPtr->fontVar != NULL) {
- char *list, **argv;
- int argc;
- double size;
- char *name;
-
- name = Tk_NameOfFont(tkfont);
- list = Tcl_GetVar2(interp, psInfoPtr->fontVar, name, 0);
- if (list != NULL) {
- if (Tcl_SplitList(interp, list, &argc, &argv) != TCL_OK) {
- badMapEntry:
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "bad font map entry for \"", name,
- "\": \"", list, "\"", (char *) NULL);
- return TCL_ERROR;
- }
- if (argc != 2) {
- goto badMapEntry;
- }
- size = strtod(argv[1], &end);
- if ((size <= 0) || (*end != 0)) {
- goto badMapEntry;
- }
-
- Tcl_DStringAppend(&ds, argv[0], -1);
- points = (int) size;
-
- ckfree((char *) argv);
- goto findfont;
- }
- }
-
- points = Tk_PostscriptFontName(tkfont, &ds);
-
- findfont:
- sprintf(pointString, "%d", points);
- Tcl_AppendResult(interp, "/", Tcl_DStringValue(&ds), " findfont ",
- pointString, " scalefont ", (char *) NULL);
- if (strncasecmp(Tcl_DStringValue(&ds), "Symbol", 7) != 0) {
- Tcl_AppendResult(interp, "ISOEncode ", (char *) NULL);
- }
- Tcl_AppendResult(interp, "setfont\n", (char *) NULL);
- Tcl_CreateHashEntry(&psInfoPtr->fontTable, Tcl_DStringValue(&ds), &i);
- Tcl_DStringFree(&ds);
-
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_CanvasPsBitmap --
- *
- * This procedure is called to output the contents of a
- * sub-region of a bitmap in proper image data format for
- * Postscript (i.e. data between angle brackets, one bit
- * per pixel).
- *
- * Results:
- * Returns a standard Tcl return value. If an error occurs
- * then an error message will be left in interp->result.
- * If no error occurs, then additional Postscript will be
- * appended to interp->result.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-int
-Tk_CanvasPsBitmap(interp, canvas, bitmap, startX, startY, width, height)
- Tcl_Interp *interp; /* Interpreter for returning Postscript
- * or error message. */
- Tk_Canvas canvas; /* Information about canvas. */
- Pixmap bitmap; /* Bitmap for which to generate
- * Postscript. */
- int startX, startY; /* Coordinates of upper-left corner
- * of rectangular region to output. */
- int width, height; /* Height of rectangular region. */
-{
- TkCanvas *canvasPtr = (TkCanvas *) canvas;
- TkPostscriptInfo *psInfoPtr = canvasPtr->psInfoPtr;
- XImage *imagePtr;
- int charsInLine, x, y, lastX, lastY, value, mask;
- unsigned int totalWidth, totalHeight;
- char string[100];
- Window dummyRoot;
- int dummyX, dummyY;
- unsigned dummyBorderwidth, dummyDepth;
-
- if (psInfoPtr->prepass) {
- return TCL_OK;
- }
-
- /*
- * The following call should probably be a call to Tk_SizeOfBitmap
- * instead, but it seems that we are occasionally invoked by custom
- * item types that create their own bitmaps without registering them
- * with Tk. XGetGeometry is a bit slower than Tk_SizeOfBitmap, but
- * it shouldn't matter here.
- */
-
- XGetGeometry(Tk_Display(Tk_CanvasTkwin(canvas)), bitmap, &dummyRoot,
- (int *) &dummyX, (int *) &dummyY, (unsigned int *) &totalWidth,
- (unsigned int *) &totalHeight, &dummyBorderwidth, &dummyDepth);
- imagePtr = XGetImage(Tk_Display(canvasPtr->tkwin), bitmap, 0, 0,
- totalWidth, totalHeight, 1, XYPixmap);
- Tcl_AppendResult(interp, "<", (char *) NULL);
- mask = 0x80;
- value = 0;
- charsInLine = 0;
- lastX = startX + width - 1;
- lastY = startY + height - 1;
- for (y = lastY; y >= startY; y--) {
- for (x = startX; x <= lastX; x++) {
- if (XGetPixel(imagePtr, x, y)) {
- value |= mask;
- }
- mask >>= 1;
- if (mask == 0) {
- sprintf(string, "%02x", value);
- Tcl_AppendResult(interp, string, (char *) NULL);
- mask = 0x80;
- value = 0;
- charsInLine += 2;
- if (charsInLine >= 60) {
- Tcl_AppendResult(interp, "\n", (char *) NULL);
- charsInLine = 0;
- }
- }
- }
- if (mask != 0x80) {
- sprintf(string, "%02x", value);
- Tcl_AppendResult(interp, string, (char *) NULL);
- mask = 0x80;
- value = 0;
- charsInLine += 2;
- }
- }
- Tcl_AppendResult(interp, ">", (char *) NULL);
- XDestroyImage(imagePtr);
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_CanvasPsStipple --
- *
- * This procedure is called by individual canvas items when
- * they have created a path that they'd like to be filled with
- * a stipple pattern. Given information about an X bitmap,
- * this procedure will generate Postscript commands to fill
- * the current clip region using a stipple pattern defined by the
- * bitmap.
- *
- * Results:
- * Returns a standard Tcl return value. If an error occurs
- * then an error message will be left in interp->result.
- * If no error occurs, then additional Postscript will be
- * appended to interp->result.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-int
-Tk_CanvasPsStipple(interp, canvas, bitmap)
- Tcl_Interp *interp; /* Interpreter for returning Postscript
- * or error message. */
- Tk_Canvas canvas; /* Information about canvas. */
- Pixmap bitmap; /* Bitmap to use for stippling. */
-{
- TkCanvas *canvasPtr = (TkCanvas *) canvas;
- TkPostscriptInfo *psInfoPtr = canvasPtr->psInfoPtr;
- int width, height;
- char string[100];
- Window dummyRoot;
- int dummyX, dummyY;
- unsigned dummyBorderwidth, dummyDepth;
-
- if (psInfoPtr->prepass) {
- return TCL_OK;
- }
-
- /*
- * The following call should probably be a call to Tk_SizeOfBitmap
- * instead, but it seems that we are occasionally invoked by custom
- * item types that create their own bitmaps without registering them
- * with Tk. XGetGeometry is a bit slower than Tk_SizeOfBitmap, but
- * it shouldn't matter here.
- */
-
- XGetGeometry(Tk_Display(Tk_CanvasTkwin(canvas)), bitmap, &dummyRoot,
- (int *) &dummyX, (int *) &dummyY, (unsigned *) &width,
- (unsigned *) &height, &dummyBorderwidth, &dummyDepth);
- sprintf(string, "%d %d ", width, height);
- Tcl_AppendResult(interp, string, (char *) NULL);
- if (Tk_CanvasPsBitmap(interp, (Tk_Canvas) canvasPtr, bitmap, 0, 0,
- width, height) != TCL_OK) {
- return TCL_ERROR;
- }
- Tcl_AppendResult(interp, " StippleFill\n", (char *) NULL);
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_CanvasPsY --
- *
- * Given a y-coordinate in canvas coordinates, this procedure
- * returns a y-coordinate to use for Postscript output.
- *
- * Results:
- * Returns the Postscript coordinate that corresponds to
- * "y".
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-double
-Tk_CanvasPsY(canvas, y)
- Tk_Canvas canvas; /* Token for canvas on whose behalf
- * Postscript is being generated. */
- double y; /* Y-coordinate in canvas coords. */
-{
- TkPostscriptInfo *psInfoPtr = ((TkCanvas *) canvas)->psInfoPtr;
-
- return psInfoPtr->y2 - y;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_CanvasPsPath --
- *
- * Given an array of points for a path, generate Postscript
- * commands to create the path.
- *
- * Results:
- * Postscript commands get appended to what's in interp->result.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-void
-Tk_CanvasPsPath(interp, canvas, coordPtr, numPoints)
- Tcl_Interp *interp; /* Put generated Postscript in this
- * interpreter's result field. */
- Tk_Canvas canvas; /* Canvas on whose behalf Postscript
- * is being generated. */
- double *coordPtr; /* Pointer to first in array of
- * 2*numPoints coordinates giving
- * points for path. */
- int numPoints; /* Number of points at *coordPtr. */
-{
- TkPostscriptInfo *psInfoPtr = ((TkCanvas *) canvas)->psInfoPtr;
- char buffer[200];
-
- if (psInfoPtr->prepass) {
- return;
- }
- sprintf(buffer, "%.15g %.15g moveto\n", coordPtr[0],
- Tk_CanvasPsY(canvas, coordPtr[1]));
- Tcl_AppendResult(interp, buffer, (char *) NULL);
- for (numPoints--, coordPtr += 2; numPoints > 0;
- numPoints--, coordPtr += 2) {
- sprintf(buffer, "%.15g %.15g lineto\n", coordPtr[0],
- Tk_CanvasPsY(canvas, coordPtr[1]));
- Tcl_AppendResult(interp, buffer, (char *) NULL);
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * GetPostscriptPoints --
- *
- * Given a string, returns the number of Postscript points
- * corresponding to that string.
- *
- * Results:
- * The return value is a standard Tcl return result. If
- * TCL_OK is returned, then everything went well and the
- * screen distance is stored at *doublePtr; otherwise
- * TCL_ERROR is returned and an error message is left in
- * interp->result.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-static int
-GetPostscriptPoints(interp, string, doublePtr)
- Tcl_Interp *interp; /* Use this for error reporting. */
- char *string; /* String describing a screen distance. */
- double *doublePtr; /* Place to store converted result. */
-{
- char *end;
- double d;
-
- d = strtod(string, &end);
- if (end == string) {
- error:
- Tcl_AppendResult(interp, "bad distance \"", string,
- "\"", (char *) NULL);
- return TCL_ERROR;
- }
- while ((*end != '\0') && isspace(UCHAR(*end))) {
- end++;
- }
- switch (*end) {
- case 'c':
- d *= 72.0/2.54;
- end++;
- break;
- case 'i':
- d *= 72.0;
- end++;
- break;
- case 'm':
- d *= 72.0/25.4;
- end++;
- break;
- case 0:
- break;
- case 'p':
- end++;
- break;
- default:
- goto error;
- }
- while ((*end != '\0') && isspace(UCHAR(*end))) {
- end++;
- }
- if (*end != 0) {
- goto error;
- }
- *doublePtr = d;
- return TCL_OK;
-}
diff --git a/generic/tkCanvText.c b/generic/tkCanvText.c
deleted file mode 100644
index 298553a..0000000
--- a/generic/tkCanvText.c
+++ /dev/null
@@ -1,1313 +0,0 @@
-/*
- * tkCanvText.c --
- *
- * This file implements text items for canvas widgets.
- *
- * Copyright (c) 1991-1994 The Regents of the University of California.
- * Copyright (c) 1994-1995 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: tkCanvText.c,v 1.2 1998/09/14 18:23:05 stanton Exp $
- */
-
-#include <stdio.h>
-#include "tkInt.h"
-#include "tkCanvas.h"
-#include "tkPort.h"
-#include "default.h"
-
-/*
- * The structure below defines the record for each text item.
- */
-
-typedef struct TextItem {
- Tk_Item header; /* Generic stuff that's the same for all
- * types. MUST BE FIRST IN STRUCTURE. */
- Tk_CanvasTextInfo *textInfoPtr;
- /* Pointer to a structure containing
- * information about the selection and
- * insertion cursor. The structure is owned
- * by (and shared with) the generic canvas
- * code. */
- /*
- * Fields that are set by widget commands other than "configure".
- */
-
- double x, y; /* Positioning point for text. */
- int insertPos; /* Insertion cursor is displayed just to left
- * of character with this index. */
-
- /*
- * Configuration settings that are updated by Tk_ConfigureWidget.
- */
-
- Tk_Anchor anchor; /* Where to anchor text relative to (x,y). */
- XColor *color; /* Color for text. */
- Tk_Font tkfont; /* Font for drawing text. */
- Tk_Justify justify; /* Justification mode for text. */
- Pixmap stipple; /* Stipple bitmap for text, or None. */
- char *text; /* Text for item (malloc-ed). */
- int width; /* Width of lines for word-wrap, pixels.
- * Zero means no word-wrap. */
-
- /*
- * Fields whose values are derived from the current values of the
- * configuration settings above.
- */
-
- int numChars; /* Number of non-NULL characters in text. */
- Tk_TextLayout textLayout; /* Cached text layout information. */
- int leftEdge; /* Pixel location of the left edge of the
- * text item; where the left border of the
- * text layout is drawn. */
- int rightEdge; /* Pixel just to right of right edge of
- * area of text item. Used for selecting up
- * to end of line. */
- GC gc; /* Graphics context for drawing text. */
- GC selTextGC; /* Graphics context for selected text. */
- GC cursorOffGC; /* If not None, this gives a graphics context
- * to use to draw the insertion cursor when
- * it's off. Used if the selection and
- * insertion cursor colors are the same. */
-} TextItem;
-
-/*
- * Information used for parsing configuration specs:
- */
-
-static Tk_CustomOption tagsOption = {Tk_CanvasTagsParseProc,
- Tk_CanvasTagsPrintProc, (ClientData) NULL
-};
-
-static Tk_ConfigSpec configSpecs[] = {
- {TK_CONFIG_ANCHOR, "-anchor", (char *) NULL, (char *) NULL,
- "center", Tk_Offset(TextItem, anchor),
- TK_CONFIG_DONT_SET_DEFAULT},
- {TK_CONFIG_COLOR, "-fill", (char *) NULL, (char *) NULL,
- "black", Tk_Offset(TextItem, color), 0},
- {TK_CONFIG_FONT, "-font", (char *) NULL, (char *) NULL,
- DEF_CANVTEXT_FONT, Tk_Offset(TextItem, tkfont), 0},
- {TK_CONFIG_JUSTIFY, "-justify", (char *) NULL, (char *) NULL,
- "left", Tk_Offset(TextItem, justify),
- TK_CONFIG_DONT_SET_DEFAULT},
- {TK_CONFIG_BITMAP, "-stipple", (char *) NULL, (char *) NULL,
- (char *) NULL, Tk_Offset(TextItem, stipple), TK_CONFIG_NULL_OK},
- {TK_CONFIG_CUSTOM, "-tags", (char *) NULL, (char *) NULL,
- (char *) NULL, 0, TK_CONFIG_NULL_OK, &tagsOption},
- {TK_CONFIG_STRING, "-text", (char *) NULL, (char *) NULL,
- "", Tk_Offset(TextItem, text), 0},
- {TK_CONFIG_PIXELS, "-width", (char *) NULL, (char *) NULL,
- "0", Tk_Offset(TextItem, width), TK_CONFIG_DONT_SET_DEFAULT},
- {TK_CONFIG_END, (char *) NULL, (char *) NULL, (char *) NULL,
- (char *) NULL, 0, 0}
-};
-
-/*
- * Prototypes for procedures defined in this file:
- */
-
-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,
- char **argv, int flags));
-static int CreateText _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Canvas canvas, struct Tk_Item *itemPtr,
- int argc, char **argv));
-static void DeleteText _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, Display *display));
-static void DisplayCanvText _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, Display *display, Drawable dst,
- int x, int y, int width, int height));
-static int GetSelText _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, int offset, char *buffer,
- int maxBytes));
-static int GetTextIndex _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Canvas canvas, Tk_Item *itemPtr,
- char *indexString, int *indexPtr));
-static void ScaleText _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double originX, double originY,
- double scaleX, double scaleY));
-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, char **argv));
-static void TextDeleteChars _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, int first, int last));
-static void TextInsert _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, int beforeThis, char *string));
-static int TextToArea _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double *rectPtr));
-static double TextToPoint _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double *pointPtr));
-static int TextToPostscript _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Canvas canvas, Tk_Item *itemPtr, int prepass));
-static void TranslateText _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double deltaX, double deltaY));
-
-/*
- * The structures below defines the rectangle and oval item types
- * by means of procedures that can be invoked by generic item code.
- */
-
-Tk_ItemType tkTextType = {
- "text", /* name */
- sizeof(TextItem), /* itemSize */
- CreateText, /* createProc */
- configSpecs, /* configSpecs */
- ConfigureText, /* configureProc */
- TextCoords, /* coordProc */
- DeleteText, /* deleteProc */
- DisplayCanvText, /* displayProc */
- 0, /* alwaysRedraw */
- TextToPoint, /* pointProc */
- TextToArea, /* areaProc */
- TextToPostscript, /* postscriptProc */
- ScaleText, /* scaleProc */
- TranslateText, /* translateProc */
- GetTextIndex, /* indexProc */
- SetTextCursor, /* icursorProc */
- GetSelText, /* selectionProc */
- TextInsert, /* insertProc */
- TextDeleteChars, /* dTextProc */
- (Tk_ItemType *) NULL /* nextPtr */
-};
-
-/*
- *--------------------------------------------------------------
- *
- * CreateText --
- *
- * This procedure is invoked to create a new text item
- * in a canvas.
- *
- * Results:
- * A standard Tcl return value. If an error occurred in
- * creating the item then an error message is left in
- * interp->result; in this case itemPtr is left uninitialized
- * so it can be safely freed by the caller.
- *
- * Side effects:
- * A new text item is created.
- *
- *--------------------------------------------------------------
- */
-
-static int
-CreateText(interp, canvas, itemPtr, argc, argv)
- 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. */
- char **argv; /* Arguments describing rectangle. */
-{
- TextItem *textPtr = (TextItem *) itemPtr;
-
- if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- Tk_PathName(Tk_CanvasTkwin(canvas)), " create ",
- itemPtr->typePtr->name, " x y ?options?\"", (char *) NULL);
- return TCL_ERROR;
- }
-
- /*
- * Carry out initialization that is needed in order to clean
- * up after errors during the the remainder of this procedure.
- */
-
- textPtr->textInfoPtr = Tk_CanvasGetTextInfo(canvas);
-
- textPtr->insertPos = 0;
-
- textPtr->anchor = TK_ANCHOR_CENTER;
- textPtr->color = NULL;
- textPtr->tkfont = NULL;
- textPtr->justify = TK_JUSTIFY_LEFT;
- textPtr->stipple = None;
- textPtr->text = NULL;
- textPtr->width = 0;
-
- textPtr->numChars = 0;
- textPtr->textLayout = NULL;
- textPtr->leftEdge = 0;
- textPtr->rightEdge = 0;
- textPtr->gc = None;
- textPtr->selTextGC = None;
- textPtr->cursorOffGC = None;
-
- /*
- * Process the arguments to fill in the item record.
- */
-
- if ((Tk_CanvasGetCoord(interp, canvas, argv[0], &textPtr->x) != TCL_OK)
- || (Tk_CanvasGetCoord(interp, canvas, argv[1], &textPtr->y)
- != TCL_OK)) {
- return TCL_ERROR;
- }
-
- if (ConfigureText(interp, canvas, itemPtr, argc-2, argv+2, 0) != TCL_OK) {
- DeleteText(canvas, itemPtr, Tk_Display(Tk_CanvasTkwin(canvas)));
- return TCL_ERROR;
- }
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * TextCoords --
- *
- * This procedure is invoked to process the "coords" widget
- * command on text items. See the user documentation for
- * details on what it does.
- *
- * Results:
- * Returns TCL_OK or TCL_ERROR, and sets interp->result.
- *
- * Side effects:
- * The coordinates for the given item may be changed.
- *
- *--------------------------------------------------------------
- */
-
-static int
-TextCoords(interp, canvas, itemPtr, argc, argv)
- 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. */
- char **argv; /* Array of coordinates: x1, y1,
- * x2, y2, ... */
-{
- TextItem *textPtr = (TextItem *) itemPtr;
- char x[TCL_DOUBLE_SPACE], y[TCL_DOUBLE_SPACE];
-
- if (argc == 0) {
- Tcl_PrintDouble(interp, textPtr->x, x);
- Tcl_PrintDouble(interp, textPtr->y, y);
- Tcl_AppendResult(interp, x, " ", y, (char *) NULL);
- } else if (argc == 2) {
- if ((Tk_CanvasGetCoord(interp, canvas, argv[0], &textPtr->x) != TCL_OK)
- || (Tk_CanvasGetCoord(interp, canvas, argv[1],
- &textPtr->y) != TCL_OK)) {
- return TCL_ERROR;
- }
- ComputeTextBbox(canvas, textPtr);
- } else {
- sprintf(interp->result,
- "wrong # coordinates: expected 0 or 2, got %d", argc);
- return TCL_ERROR;
- }
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ConfigureText --
- *
- * This procedure is invoked to configure various aspects
- * of a text item, such as its border and background colors.
- *
- * Results:
- * A standard Tcl result code. If an error occurs, then
- * an error message is left in interp->result.
- *
- * Side effects:
- * Configuration information, such as colors and stipple
- * patterns, may be set for itemPtr.
- *
- *--------------------------------------------------------------
- */
-
-static int
-ConfigureText(interp, canvas, itemPtr, argc, argv, 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. */
- char **argv; /* Arguments describing things to configure. */
- int flags; /* Flags to pass to Tk_ConfigureWidget. */
-{
- TextItem *textPtr = (TextItem *) itemPtr;
- XGCValues gcValues;
- GC newGC, newSelGC;
- unsigned long mask;
- Tk_Window tkwin;
- Tk_CanvasTextInfo *textInfoPtr = textPtr->textInfoPtr;
- XColor *selBgColorPtr;
-
- tkwin = Tk_CanvasTkwin(canvas);
- if (Tk_ConfigureWidget(interp, tkwin, configSpecs, argc, argv,
- (char *) textPtr, flags) != TCL_OK) {
- return TCL_ERROR;
- }
-
- /*
- * A few of the options require additional processing, such as
- * graphics contexts.
- */
-
- newGC = newSelGC = None;
- if ((textPtr->color != NULL) && (textPtr->tkfont != NULL)) {
- gcValues.foreground = textPtr->color->pixel;
- gcValues.font = Tk_FontId(textPtr->tkfont);
- mask = GCForeground|GCFont;
- if (textPtr->stipple != None) {
- gcValues.stipple = textPtr->stipple;
- gcValues.fill_style = FillStippled;
- mask |= GCForeground|GCStipple|GCFillStyle;
- }
- newGC = Tk_GetGC(tkwin, mask, &gcValues);
- gcValues.foreground = textInfoPtr->selFgColorPtr->pixel;
- newSelGC = Tk_GetGC(tkwin, mask, &gcValues);
- }
- if (textPtr->gc != None) {
- Tk_FreeGC(Tk_Display(tkwin), textPtr->gc);
- }
- textPtr->gc = newGC;
- if (textPtr->selTextGC != None) {
- Tk_FreeGC(Tk_Display(tkwin), textPtr->selTextGC);
- }
- textPtr->selTextGC = newSelGC;
-
- selBgColorPtr = Tk_3DBorderColor(textInfoPtr->selBorder);
- if (Tk_3DBorderColor(textInfoPtr->insertBorder)->pixel
- == selBgColorPtr->pixel) {
- if (selBgColorPtr->pixel == BlackPixelOfScreen(Tk_Screen(tkwin))) {
- gcValues.foreground = WhitePixelOfScreen(Tk_Screen(tkwin));
- } else {
- gcValues.foreground = BlackPixelOfScreen(Tk_Screen(tkwin));
- }
- newGC = Tk_GetGC(tkwin, GCForeground, &gcValues);
- } else {
- newGC = None;
- }
- if (textPtr->cursorOffGC != None) {
- Tk_FreeGC(Tk_Display(tkwin), textPtr->cursorOffGC);
- }
- textPtr->cursorOffGC = newGC;
-
-
- /*
- * If the text was changed, move the selection and insertion indices
- * to keep them inside the item.
- */
-
- textPtr->numChars = strlen(textPtr->text);
- if (textInfoPtr->selItemPtr == itemPtr) {
- if (textInfoPtr->selectFirst >= textPtr->numChars) {
- textInfoPtr->selItemPtr = NULL;
- } else {
- if (textInfoPtr->selectLast >= textPtr->numChars) {
- textInfoPtr->selectLast = textPtr->numChars-1;
- }
- if ((textInfoPtr->anchorItemPtr == itemPtr)
- && (textInfoPtr->selectAnchor >= textPtr->numChars)) {
- textInfoPtr->selectAnchor = textPtr->numChars-1;
- }
- }
- }
- if (textPtr->insertPos >= textPtr->numChars) {
- textPtr->insertPos = textPtr->numChars;
- }
-
- ComputeTextBbox(canvas, textPtr);
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * DeleteText --
- *
- * This procedure is called to clean up the data structure
- * associated with a text item.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Resources associated with itemPtr are released.
- *
- *--------------------------------------------------------------
- */
-
-static void
-DeleteText(canvas, itemPtr, display)
- Tk_Canvas canvas; /* Info about overall canvas widget. */
- Tk_Item *itemPtr; /* Item that is being deleted. */
- Display *display; /* Display containing window for
- * canvas. */
-{
- TextItem *textPtr = (TextItem *) itemPtr;
-
- if (textPtr->color != NULL) {
- Tk_FreeColor(textPtr->color);
- }
- Tk_FreeFont(textPtr->tkfont);
- if (textPtr->stipple != None) {
- Tk_FreeBitmap(display, textPtr->stipple);
- }
- if (textPtr->text != NULL) {
- ckfree(textPtr->text);
- }
-
- Tk_FreeTextLayout(textPtr->textLayout);
- if (textPtr->gc != None) {
- Tk_FreeGC(display, textPtr->gc);
- }
- if (textPtr->selTextGC != None) {
- Tk_FreeGC(display, textPtr->selTextGC);
- }
- if (textPtr->cursorOffGC != None) {
- Tk_FreeGC(display, textPtr->cursorOffGC);
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ComputeTextBbox --
- *
- * This procedure is invoked to compute the bounding box of
- * all the pixels that may be drawn as part of a text item.
- * In addition, it recomputes all of the geometry information
- * used to display a text item or check for mouse hits.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The fields x1, y1, x2, and y2 are updated in the header
- * for itemPtr, and the linePtr structure is regenerated
- * for itemPtr.
- *
- *--------------------------------------------------------------
- */
-
-static void
-ComputeTextBbox(canvas, textPtr)
- Tk_Canvas canvas; /* Canvas that contains item. */
- TextItem *textPtr; /* Item whose bbos is to be
- * recomputed. */
-{
- Tk_CanvasTextInfo *textInfoPtr;
- int leftX, topY, width, height, fudge;
-
- Tk_FreeTextLayout(textPtr->textLayout);
- textPtr->textLayout = Tk_ComputeTextLayout(textPtr->tkfont,
- textPtr->text, textPtr->numChars, textPtr->width,
- textPtr->justify, 0, &width, &height);
-
- /*
- * Use overall geometry information to compute the top-left corner
- * of the bounding box for the text item.
- */
-
- leftX = (int) (textPtr->x + 0.5);
- topY = (int) (textPtr->y + 0.5);
- switch (textPtr->anchor) {
- case TK_ANCHOR_NW:
- case TK_ANCHOR_N:
- case TK_ANCHOR_NE:
- break;
-
- case TK_ANCHOR_W:
- case TK_ANCHOR_CENTER:
- case TK_ANCHOR_E:
- topY -= height / 2;
- break;
-
- case TK_ANCHOR_SW:
- case TK_ANCHOR_S:
- case TK_ANCHOR_SE:
- topY -= height;
- break;
- }
- switch (textPtr->anchor) {
- case TK_ANCHOR_NW:
- case TK_ANCHOR_W:
- case TK_ANCHOR_SW:
- break;
-
- case TK_ANCHOR_N:
- case TK_ANCHOR_CENTER:
- case TK_ANCHOR_S:
- leftX -= width / 2;
- break;
-
- case TK_ANCHOR_NE:
- case TK_ANCHOR_E:
- case TK_ANCHOR_SE:
- leftX -= width;
- break;
- }
-
- textPtr->leftEdge = leftX;
- textPtr->rightEdge = leftX + width;
-
- /*
- * Last of all, update the bounding box for the item. The item's
- * bounding box includes the bounding box of all its lines, plus
- * an extra fudge factor for the cursor border (which could
- * potentially be quite large).
- */
-
- textInfoPtr = textPtr->textInfoPtr;
- fudge = (textInfoPtr->insertWidth + 1) / 2;
- if (textInfoPtr->selBorderWidth > fudge) {
- fudge = textInfoPtr->selBorderWidth;
- }
- textPtr->header.x1 = leftX - fudge;
- textPtr->header.y1 = topY;
- textPtr->header.x2 = leftX + width + fudge;
- textPtr->header.y2 = topY + height;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * DisplayCanvText --
- *
- * This procedure is invoked to draw a text item in a given
- * drawable.
- *
- * Results:
- * None.
- *
- * Side effects:
- * ItemPtr is drawn in drawable using the transformation
- * information in canvas.
- *
- *--------------------------------------------------------------
- */
-
-static void
-DisplayCanvText(canvas, itemPtr, display, drawable, x, y, width, height)
- Tk_Canvas canvas; /* Canvas that contains item. */
- Tk_Item *itemPtr; /* Item to be displayed. */
- Display *display; /* Display on which to draw item. */
- Drawable drawable; /* Pixmap or window in which to draw
- * item. */
- int x, y, width, height; /* Describes region of canvas that
- * must be redisplayed (not used). */
-{
- TextItem *textPtr;
- Tk_CanvasTextInfo *textInfoPtr;
- int selFirst, selLast;
- short drawableX, drawableY;
-
- textPtr = (TextItem *) itemPtr;
- textInfoPtr = textPtr->textInfoPtr;
-
- if (textPtr->gc == None) {
- return;
- }
-
- /*
- * If we're stippling, then modify the stipple offset in the GC. Be
- * sure to reset the offset when done, since the GC is supposed to be
- * read-only.
- */
-
- if (textPtr->stipple != None) {
- Tk_CanvasSetStippleOrigin(canvas, textPtr->gc);
- }
-
- selFirst = -1;
- selLast = 0; /* lint. */
- if (textInfoPtr->selItemPtr == itemPtr) {
- selFirst = textInfoPtr->selectFirst;
- selLast = textInfoPtr->selectLast;
- if (selLast >= textPtr->numChars) {
- selLast = textPtr->numChars - 1;
- }
- if ((selFirst >= 0) && (selFirst <= selLast)) {
- /*
- * Draw a special background under the selection.
- */
-
- int xFirst, yFirst, hFirst;
- int xLast, yLast, wLast;
-
- Tk_CharBbox(textPtr->textLayout, selFirst,
- &xFirst, &yFirst, NULL, &hFirst);
- Tk_CharBbox(textPtr->textLayout, selLast,
- &xLast, &yLast, &wLast, NULL);
-
- /*
- * If the selection spans the end of this line, then display
- * selection background all the way to the end of the line.
- * However, for the last line we only want to display up to the
- * last character, not the end of the line.
- */
-
- x = xFirst;
- height = hFirst;
- for (y = yFirst ; y <= yLast; y += height) {
- if (y == yLast) {
- width = (xLast + wLast) - x;
- } else {
- width = textPtr->rightEdge - textPtr->leftEdge - x;
- }
- Tk_CanvasDrawableCoords(canvas,
- (double) (textPtr->leftEdge + x
- - textInfoPtr->selBorderWidth),
- (double) (textPtr->header.y1 + y),
- &drawableX, &drawableY);
- Tk_Fill3DRectangle(Tk_CanvasTkwin(canvas), drawable,
- textInfoPtr->selBorder, drawableX, drawableY,
- width + 2 * textInfoPtr->selBorderWidth,
- height, textInfoPtr->selBorderWidth, TK_RELIEF_RAISED);
- x = 0;
- }
- }
- }
-
- /*
- * If the insertion point should be displayed, then draw a special
- * background for the cursor before drawing the text. Note: if
- * we're the cursor item but the cursor is turned off, then redraw
- * background over the area of the cursor. This guarantees that
- * the selection won't make the cursor invisible on mono displays,
- * where both are drawn in the same color.
- */
-
- if ((textInfoPtr->focusItemPtr == itemPtr) && (textInfoPtr->gotFocus)) {
- if (Tk_CharBbox(textPtr->textLayout, textPtr->insertPos,
- &x, &y, NULL, &height)) {
- Tk_CanvasDrawableCoords(canvas,
- (double) (textPtr->leftEdge + x
- - (textInfoPtr->insertWidth / 2)),
- (double) (textPtr->header.y1 + y),
- &drawableX, &drawableY);
- if (textInfoPtr->cursorOn) {
- Tk_Fill3DRectangle(Tk_CanvasTkwin(canvas), drawable,
- textInfoPtr->insertBorder,
- drawableX, drawableY,
- textInfoPtr->insertWidth, height,
- textInfoPtr->insertBorderWidth, TK_RELIEF_RAISED);
- } else if (textPtr->cursorOffGC != None) {
- /*
- * Redraw the background over the area of the cursor,
- * even though the cursor is turned off. This
- * guarantees that the selection won't make the cursor
- * invisible on mono displays, where both may be drawn
- * in the same color.
- */
-
- XFillRectangle(display, drawable, textPtr->cursorOffGC,
- drawableX, drawableY,
- (unsigned) textInfoPtr->insertWidth,
- (unsigned) height);
- }
- }
- }
-
-
- /*
- * Display the text in two pieces: draw the entire text item, then
- * draw the selected text on top of it. The selected text then
- * will only need to be drawn if it has different attributes (such
- * as foreground color) than regular text.
- */
-
- Tk_CanvasDrawableCoords(canvas, (double) textPtr->leftEdge,
- (double) textPtr->header.y1, &drawableX, &drawableY);
- Tk_DrawTextLayout(display, drawable, textPtr->gc, textPtr->textLayout,
- drawableX, drawableY, 0, -1);
-
- if ((selFirst >= 0) && (textPtr->selTextGC != textPtr->gc)) {
- Tk_DrawTextLayout(display, drawable, textPtr->selTextGC,
- textPtr->textLayout, drawableX, drawableY, selFirst,
- selLast + 1);
- }
-
- if (textPtr->stipple != None) {
- XSetTSOrigin(display, textPtr->gc, 0, 0);
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * TextInsert --
- *
- * Insert characters into a text item at a given position.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The text in the given item is modified. The cursor and
- * selection positions are also modified to reflect the
- * insertion.
- *
- *--------------------------------------------------------------
- */
-
-static void
-TextInsert(canvas, itemPtr, beforeThis, string)
- Tk_Canvas canvas; /* Canvas containing text item. */
- Tk_Item *itemPtr; /* Text item to be modified. */
- int beforeThis; /* Index of character before which text is
- * to be inserted. */
- char *string; /* New characters to be inserted. */
-{
- TextItem *textPtr = (TextItem *) itemPtr;
- int length;
- char *new;
- Tk_CanvasTextInfo *textInfoPtr = textPtr->textInfoPtr;
-
- length = strlen(string);
- if (length == 0) {
- return;
- }
- if (beforeThis < 0) {
- beforeThis = 0;
- }
- if (beforeThis > textPtr->numChars) {
- beforeThis = textPtr->numChars;
- }
-
- new = (char *) ckalloc((unsigned) (textPtr->numChars + length + 1));
- strncpy(new, textPtr->text, (size_t) beforeThis);
- strcpy(new+beforeThis, string);
- strcpy(new+beforeThis+length, textPtr->text+beforeThis);
- ckfree(textPtr->text);
- textPtr->text = new;
- textPtr->numChars += length;
-
- /*
- * Inserting characters invalidates indices such as those for the
- * selection and cursor. Update the indices appropriately.
- */
-
- if (textInfoPtr->selItemPtr == itemPtr) {
- if (textInfoPtr->selectFirst >= beforeThis) {
- textInfoPtr->selectFirst += length;
- }
- if (textInfoPtr->selectLast >= beforeThis) {
- textInfoPtr->selectLast += length;
- }
- if ((textInfoPtr->anchorItemPtr == itemPtr)
- && (textInfoPtr->selectAnchor >= beforeThis)) {
- textInfoPtr->selectAnchor += length;
- }
- }
- if (textPtr->insertPos >= beforeThis) {
- textPtr->insertPos += length;
- }
- ComputeTextBbox(canvas, textPtr);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * TextDeleteChars --
- *
- * Delete one or more characters from a text item.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Characters between "first" and "last", inclusive, get
- * deleted from itemPtr, and things like the selection
- * position get updated.
- *
- *--------------------------------------------------------------
- */
-
-static void
-TextDeleteChars(canvas, itemPtr, first, last)
- Tk_Canvas canvas; /* Canvas containing itemPtr. */
- Tk_Item *itemPtr; /* Item in which to delete characters. */
- int first; /* Index of first character to delete. */
- int last; /* Index of last character to delete. */
-{
- TextItem *textPtr = (TextItem *) itemPtr;
- int count;
- char *new;
- Tk_CanvasTextInfo *textInfoPtr = textPtr->textInfoPtr;
-
- if (first < 0) {
- first = 0;
- }
- if (last >= textPtr->numChars) {
- last = textPtr->numChars-1;
- }
- if (first > last) {
- return;
- }
- count = last + 1 - first;
-
- new = (char *) ckalloc((unsigned) (textPtr->numChars + 1 - count));
- strncpy(new, textPtr->text, (size_t) first);
- strcpy(new+first, textPtr->text+last+1);
- ckfree(textPtr->text);
- textPtr->text = new;
- textPtr->numChars -= count;
-
- /*
- * Update indexes for the selection and cursor to reflect the
- * renumbering of the remaining characters.
- */
-
- if (textInfoPtr->selItemPtr == itemPtr) {
- if (textInfoPtr->selectFirst > first) {
- textInfoPtr->selectFirst -= count;
- if (textInfoPtr->selectFirst < first) {
- textInfoPtr->selectFirst = first;
- }
- }
- if (textInfoPtr->selectLast >= first) {
- textInfoPtr->selectLast -= count;
- if (textInfoPtr->selectLast < (first-1)) {
- textInfoPtr->selectLast = (first-1);
- }
- }
- if (textInfoPtr->selectFirst > textInfoPtr->selectLast) {
- textInfoPtr->selItemPtr = NULL;
- }
- if ((textInfoPtr->anchorItemPtr == itemPtr)
- && (textInfoPtr->selectAnchor > first)) {
- textInfoPtr->selectAnchor -= count;
- if (textInfoPtr->selectAnchor < first) {
- textInfoPtr->selectAnchor = first;
- }
- }
- }
- if (textPtr->insertPos > first) {
- textPtr->insertPos -= count;
- if (textPtr->insertPos < first) {
- textPtr->insertPos = first;
- }
- }
- ComputeTextBbox(canvas, textPtr);
- return;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * TextToPoint --
- *
- * Computes the distance from a given point to a given
- * text item, in canvas units.
- *
- * Results:
- * The return value is 0 if the point whose x and y coordinates
- * are pointPtr[0] and pointPtr[1] is inside the text item. If
- * the point isn't inside the text item then the return value
- * is the distance from the point to the text item.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-static double
-TextToPoint(canvas, itemPtr, pointPtr)
- Tk_Canvas canvas; /* Canvas containing itemPtr. */
- Tk_Item *itemPtr; /* Item to check against point. */
- double *pointPtr; /* Pointer to x and y coordinates. */
-{
- TextItem *textPtr;
-
- textPtr = (TextItem *) itemPtr;
- return (double) Tk_DistanceToTextLayout(textPtr->textLayout,
- (int) pointPtr[0] - textPtr->leftEdge,
- (int) pointPtr[1] - textPtr->header.y1);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * TextToArea --
- *
- * This procedure is called to determine whether an item
- * lies entirely inside, entirely outside, or overlapping
- * a given rectangle.
- *
- * Results:
- * -1 is returned if the item is entirely outside the area
- * given by rectPtr, 0 if it overlaps, and 1 if it is entirely
- * inside the given area.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-static int
-TextToArea(canvas, itemPtr, rectPtr)
- Tk_Canvas canvas; /* Canvas containing itemPtr. */
- Tk_Item *itemPtr; /* Item to check against rectangle. */
- double *rectPtr; /* Pointer to array of four coordinates
- * (x1, y1, x2, y2) describing rectangular
- * area. */
-{
- TextItem *textPtr;
-
- textPtr = (TextItem *) itemPtr;
- return Tk_IntersectTextLayout(textPtr->textLayout,
- (int) (rectPtr[0] + 0.5) - textPtr->leftEdge,
- (int) (rectPtr[1] + 0.5) - textPtr->header.y1,
- (int) (rectPtr[2] - rectPtr[0] + 0.5),
- (int) (rectPtr[3] - rectPtr[1] + 0.5));
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ScaleText --
- *
- * This procedure is invoked to rescale a text item.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Scales the position of the text, but not the size
- * of the font for the text.
- *
- *--------------------------------------------------------------
- */
-
- /* ARGSUSED */
-static void
-ScaleText(canvas, itemPtr, originX, originY, scaleX, scaleY)
- Tk_Canvas canvas; /* Canvas containing rectangle. */
- Tk_Item *itemPtr; /* Rectangle to be scaled. */
- double originX, originY; /* Origin about which to scale rect. */
- double scaleX; /* Amount to scale in X direction. */
- double scaleY; /* Amount to scale in Y direction. */
-{
- TextItem *textPtr = (TextItem *) itemPtr;
-
- textPtr->x = originX + scaleX*(textPtr->x - originX);
- textPtr->y = originY + scaleY*(textPtr->y - originY);
- ComputeTextBbox(canvas, textPtr);
- return;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * TranslateText --
- *
- * This procedure is called to move a text item by a
- * given amount.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The position of the text item is offset by (xDelta, yDelta),
- * and the bounding box is updated in the generic part of the
- * item structure.
- *
- *--------------------------------------------------------------
- */
-
-static void
-TranslateText(canvas, itemPtr, deltaX, deltaY)
- Tk_Canvas canvas; /* Canvas containing item. */
- Tk_Item *itemPtr; /* Item that is being moved. */
- double deltaX, deltaY; /* Amount by which item is to be
- * moved. */
-{
- TextItem *textPtr = (TextItem *) itemPtr;
-
- textPtr->x += deltaX;
- textPtr->y += deltaY;
- ComputeTextBbox(canvas, textPtr);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * GetTextIndex --
- *
- * Parse an index into a text item and return either its value
- * or an error.
- *
- * Results:
- * A standard Tcl result. If all went well, then *indexPtr is
- * filled in with the index (into itemPtr) corresponding to
- * string. Otherwise an error message is left in
- * interp->result.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-static int
-GetTextIndex(interp, canvas, itemPtr, string, indexPtr)
- Tcl_Interp *interp; /* Used for error reporting. */
- Tk_Canvas canvas; /* Canvas containing item. */
- Tk_Item *itemPtr; /* Item for which the index is being
- * specified. */
- char *string; /* Specification of a particular character
- * in itemPtr's text. */
- int *indexPtr; /* Where to store converted index. */
-{
- TextItem *textPtr = (TextItem *) itemPtr;
- size_t length;
- int c;
- TkCanvas *canvasPtr = (TkCanvas *) canvas;
- Tk_CanvasTextInfo *textInfoPtr = textPtr->textInfoPtr;
-
- c = string[0];
- length = strlen(string);
-
- if ((c == 'e') && (strncmp(string, "end", length) == 0)) {
- *indexPtr = textPtr->numChars;
- } else if ((c == 'i') && (strncmp(string, "insert", length) == 0)) {
- *indexPtr = textPtr->insertPos;
- } else if ((c == 's') && (strncmp(string, "sel.first", length) == 0)
- && (length >= 5)) {
- if (textInfoPtr->selItemPtr != itemPtr) {
- interp->result = "selection isn't in item";
- return TCL_ERROR;
- }
- *indexPtr = textInfoPtr->selectFirst;
- } else if ((c == 's') && (strncmp(string, "sel.last", length) == 0)
- && (length >= 5)) {
- if (textInfoPtr->selItemPtr != itemPtr) {
- interp->result = "selection isn't in item";
- return TCL_ERROR;
- }
- *indexPtr = textInfoPtr->selectLast;
- } else if (c == '@') {
- int x, y;
- double tmp;
- char *end, *p;
-
- p = string+1;
- tmp = strtod(p, &end);
- if ((end == p) || (*end != ',')) {
- goto badIndex;
- }
- x = (int) ((tmp < 0) ? tmp - 0.5 : tmp + 0.5);
- p = end+1;
- tmp = strtod(p, &end);
- if ((end == p) || (*end != 0)) {
- goto badIndex;
- }
- y = (int) ((tmp < 0) ? tmp - 0.5 : tmp + 0.5);
- *indexPtr = Tk_PointToChar(textPtr->textLayout,
- x + canvasPtr->scrollX1 - textPtr->leftEdge,
- y + canvasPtr->scrollY1 - textPtr->header.y1);
- } else if (Tcl_GetInt(interp, string, indexPtr) == TCL_OK) {
- if (*indexPtr < 0){
- *indexPtr = 0;
- } else if (*indexPtr > textPtr->numChars) {
- *indexPtr = textPtr->numChars;
- }
- } else {
- /*
- * Some of the paths here leave messages in interp->result,
- * so we have to clear it out before storing our own message.
- */
-
- badIndex:
- Tcl_SetResult(interp, (char *) NULL, TCL_STATIC);
- Tcl_AppendResult(interp, "bad index \"", string, "\"",
- (char *) NULL);
- return TCL_ERROR;
- }
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * SetTextCursor --
- *
- * Set the position of the insertion cursor in this item.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The cursor position will change.
- *
- *--------------------------------------------------------------
- */
-
- /* ARGSUSED */
-static void
-SetTextCursor(canvas, itemPtr, index)
- Tk_Canvas canvas; /* Record describing canvas widget. */
- Tk_Item *itemPtr; /* Text item in which cursor position
- * is to be set. */
- int index; /* Index of character just before which
- * cursor is to be positioned. */
-{
- TextItem *textPtr = (TextItem *) itemPtr;
-
- if (index < 0) {
- textPtr->insertPos = 0;
- } else if (index > textPtr->numChars) {
- textPtr->insertPos = textPtr->numChars;
- } else {
- textPtr->insertPos = index;
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * GetSelText --
- *
- * This procedure is invoked to return the selected portion
- * of a text item. It is only called when this item has
- * the selection.
- *
- * Results:
- * The return value is the number of non-NULL bytes stored
- * at buffer. Buffer is filled (or partially filled) with a
- * NULL-terminated string containing part or all of the selection,
- * as given by offset and maxBytes.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-static int
-GetSelText(canvas, itemPtr, offset, buffer, maxBytes)
- Tk_Canvas canvas; /* Canvas containing selection. */
- Tk_Item *itemPtr; /* Text item containing selection. */
- int offset; /* Offset within selection of first
- * character to be returned. */
- char *buffer; /* Location in which to place
- * selection. */
- int maxBytes; /* Maximum number of bytes to place
- * at buffer, not including terminating
- * NULL character. */
-{
- TextItem *textPtr = (TextItem *) itemPtr;
- int count;
- Tk_CanvasTextInfo *textInfoPtr = textPtr->textInfoPtr;
-
- count = textInfoPtr->selectLast + 1 - textInfoPtr->selectFirst - offset;
- if (textInfoPtr->selectLast == textPtr->numChars) {
- count -= 1;
- }
- if (count > maxBytes) {
- count = maxBytes;
- }
- if (count <= 0) {
- return 0;
- }
- strncpy(buffer, textPtr->text + textInfoPtr->selectFirst + offset,
- (size_t) count);
- buffer[count] = '\0';
- return count;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * TextToPostscript --
- *
- * This procedure is called to generate Postscript for
- * text items.
- *
- * Results:
- * The return value is a standard Tcl result. If an error
- * occurs in generating Postscript then an error message is
- * left in interp->result, replacing whatever used
- * to be there. If no error occurs, then Postscript for the
- * item is appended to the result.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-static int
-TextToPostscript(interp, canvas, itemPtr, prepass)
- Tcl_Interp *interp; /* Leave Postscript or error message
- * here. */
- Tk_Canvas canvas; /* Information about overall canvas. */
- Tk_Item *itemPtr; /* Item for which Postscript is
- * wanted. */
- int prepass; /* 1 means this is a prepass to
- * collect font information; 0 means
- * final Postscript is being created. */
-{
- TextItem *textPtr = (TextItem *) itemPtr;
- int x, y;
- Tk_FontMetrics fm;
- char *justify;
- char buffer[500];
-
- if (textPtr->color == NULL) {
- return TCL_OK;
- }
-
- if (Tk_CanvasPsFont(interp, canvas, textPtr->tkfont) != TCL_OK) {
- return TCL_ERROR;
- }
- if (prepass != 0) {
- return TCL_OK;
- }
- if (Tk_CanvasPsColor(interp, canvas, textPtr->color) != TCL_OK) {
- return TCL_ERROR;
- }
- if (textPtr->stipple != None) {
- Tcl_AppendResult(interp, "/StippleText {\n ",
- (char *) NULL);
- Tk_CanvasPsStipple(interp, canvas, textPtr->stipple);
- Tcl_AppendResult(interp, "} bind def\n", (char *) NULL);
- }
-
- sprintf(buffer, "%.15g %.15g [\n", textPtr->x,
- Tk_CanvasPsY(canvas, textPtr->y));
- Tcl_AppendResult(interp, buffer, (char *) NULL);
-
- Tk_TextLayoutToPostscript(interp, textPtr->textLayout);
-
- x = 0; y = 0; justify = NULL; /* lint. */
- switch (textPtr->anchor) {
- case TK_ANCHOR_NW: x = 0; y = 0; break;
- case TK_ANCHOR_N: x = 1; y = 0; break;
- case TK_ANCHOR_NE: x = 2; y = 0; break;
- case TK_ANCHOR_E: x = 2; y = 1; break;
- case TK_ANCHOR_SE: x = 2; y = 2; break;
- case TK_ANCHOR_S: x = 1; y = 2; break;
- case TK_ANCHOR_SW: x = 0; y = 2; break;
- case TK_ANCHOR_W: x = 0; y = 1; break;
- case TK_ANCHOR_CENTER: x = 1; y = 1; break;
- }
- switch (textPtr->justify) {
- case TK_JUSTIFY_LEFT: justify = "0"; break;
- case TK_JUSTIFY_CENTER: justify = "0.5";break;
- case TK_JUSTIFY_RIGHT: justify = "1"; break;
- }
-
- Tk_GetFontMetrics(textPtr->tkfont, &fm);
- sprintf(buffer, "] %d %g %g %s %s DrawText\n",
- fm.linespace, x / -2.0, y / 2.0, justify,
- ((textPtr->stipple == None) ? "false" : "true"));
- Tcl_AppendResult(interp, buffer, (char *) NULL);
-
- return TCL_OK;
-}
diff --git a/generic/tkCanvUtil.c b/generic/tkCanvUtil.c
deleted file mode 100644
index 16a5ffa..0000000
--- a/generic/tkCanvUtil.c
+++ /dev/null
@@ -1,376 +0,0 @@
-/*
- * tkCanvUtil.c --
- *
- * This procedure contains a collection of utility procedures
- * used by the implementations of various canvas item types.
- *
- * Copyright (c) 1994 Sun Microsystems, Inc.
- * Copyright (c) 1994 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: tkCanvUtil.c,v 1.2 1998/09/14 18:23:06 stanton Exp $
- */
-
-#include "tk.h"
-#include "tkCanvas.h"
-#include "tkPort.h"
-
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_CanvasTkwin --
- *
- * Given a token for a canvas, this procedure returns the
- * widget that represents the canvas.
- *
- * Results:
- * The return value is a handle for the widget.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-Tk_Window
-Tk_CanvasTkwin(canvas)
- Tk_Canvas canvas; /* Token for the canvas. */
-{
- TkCanvas *canvasPtr = (TkCanvas *) canvas;
- return canvasPtr->tkwin;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_CanvasDrawableCoords --
- *
- * Given an (x,y) coordinate pair within a canvas, this procedure
- * returns the corresponding coordinates at which the point should
- * be drawn in the drawable used for display.
- *
- * Results:
- * There is no return value. The values at *drawableXPtr and
- * *drawableYPtr are filled in with the coordinates at which
- * x and y should be drawn. These coordinates are clipped
- * to fit within a "short", since this is what X uses in
- * most cases for drawing.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tk_CanvasDrawableCoords(canvas, x, y, drawableXPtr, drawableYPtr)
- Tk_Canvas canvas; /* Token for the canvas. */
- double x, y; /* Coordinates in canvas space. */
- short *drawableXPtr, *drawableYPtr; /* Screen coordinates are stored
- * here. */
-{
- TkCanvas *canvasPtr = (TkCanvas *) canvas;
- double tmp;
-
- tmp = x - canvasPtr->drawableXOrigin;
- if (tmp > 0) {
- tmp += 0.5;
- } else {
- tmp -= 0.5;
- }
- if (tmp > 32767) {
- *drawableXPtr = 32767;
- } else if (tmp < -32768) {
- *drawableXPtr = -32768;
- } else {
- *drawableXPtr = (short) tmp;
- }
-
- tmp = y - canvasPtr->drawableYOrigin;
- if (tmp > 0) {
- tmp += 0.5;
- } else {
- tmp -= 0.5;
- }
- if (tmp > 32767) {
- *drawableYPtr = 32767;
- } else if (tmp < -32768) {
- *drawableYPtr = -32768;
- } else {
- *drawableYPtr = (short) tmp;
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_CanvasWindowCoords --
- *
- * Given an (x,y) coordinate pair within a canvas, this procedure
- * returns the corresponding coordinates in the canvas's window.
- *
- * Results:
- * There is no return value. The values at *screenXPtr and
- * *screenYPtr are filled in with the coordinates at which
- * (x,y) appears in the canvas's window. These coordinates
- * are clipped to fit within a "short", since this is what X
- * uses in most cases for drawing.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tk_CanvasWindowCoords(canvas, x, y, screenXPtr, screenYPtr)
- Tk_Canvas canvas; /* Token for the canvas. */
- double x, y; /* Coordinates in canvas space. */
- short *screenXPtr, *screenYPtr; /* Screen coordinates are stored
- * here. */
-{
- TkCanvas *canvasPtr = (TkCanvas *) canvas;
- double tmp;
-
- tmp = x - canvasPtr->xOrigin;
- if (tmp > 0) {
- tmp += 0.5;
- } else {
- tmp -= 0.5;
- }
- if (tmp > 32767) {
- *screenXPtr = 32767;
- } else if (tmp < -32768) {
- *screenXPtr = -32768;
- } else {
- *screenXPtr = (short) tmp;
- }
-
- tmp = y - canvasPtr->yOrigin;
- if (tmp > 0) {
- tmp += 0.5;
- } else {
- tmp -= 0.5;
- }
- if (tmp > 32767) {
- *screenYPtr = 32767;
- } else if (tmp < -32768) {
- *screenYPtr = -32768;
- } else {
- *screenYPtr = (short) tmp;
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_CanvasGetCoord --
- *
- * Given a string, returns a floating-point canvas coordinate
- * corresponding to that string.
- *
- * Results:
- * The return value is a standard Tcl return result. If
- * TCL_OK is returned, then everything went well and the
- * canvas coordinate is stored at *doublePtr; otherwise
- * TCL_ERROR is returned and an error message is left in
- * interp->result.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-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
- * coordinate form may be used here). */
- double *doublePtr; /* Place to store converted coordinate. */
-{
- TkCanvas *canvasPtr = (TkCanvas *) canvas;
- if (Tk_GetScreenMM(canvasPtr->interp, canvasPtr->tkwin, string,
- doublePtr) != TCL_OK) {
- return TCL_ERROR;
- }
- *doublePtr *= canvasPtr->pixelsPerMM;
- return TCL_OK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_CanvasSetStippleOrigin --
- *
- * This procedure sets the stipple origin in a graphics context
- * so that stipples drawn with the GC will line up with other
- * stipples previously drawn in the canvas.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The graphics context is modified.
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tk_CanvasSetStippleOrigin(canvas, gc)
- Tk_Canvas canvas; /* Token for a canvas. */
- GC gc; /* Graphics context that is about to be
- * used to draw a stippled pattern as
- * part of redisplaying the canvas. */
-
-{
- TkCanvas *canvasPtr = (TkCanvas *) canvas;
-
- XSetTSOrigin(canvasPtr->display, gc, -canvasPtr->drawableXOrigin,
- -canvasPtr->drawableYOrigin);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_CanvasGetTextInfo --
- *
- * This procedure returns a pointer to a structure containing
- * information about the selection and insertion cursor for
- * a canvas widget. Items such as text items save the pointer
- * and use it to share access to the information with the generic
- * canvas code.
- *
- * Results:
- * The return value is a pointer to the structure holding text
- * information for the canvas. Most of the fields should not
- * be modified outside the generic canvas code; see the user
- * documentation for details.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-Tk_CanvasTextInfo *
-Tk_CanvasGetTextInfo(canvas)
- Tk_Canvas canvas; /* Token for the canvas widget. */
-{
- return &((TkCanvas *) canvas)->textInfo;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_CanvasTagsParseProc --
- *
- * This procedure is invoked during option processing to handle
- * "-tags" options for canvas items.
- *
- * Results:
- * A standard Tcl return value.
- *
- * Side effects:
- * The tags for a given item get replaced by those indicated
- * in the value argument.
- *
- *--------------------------------------------------------------
- */
-
-int
-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
- * 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;
- Tk_Uid *newPtr;
-
- /*
- * Break the value up into the individual tag names.
- */
-
- if (Tcl_SplitList(interp, value, &argc, &argv) != TCL_OK) {
- return TCL_ERROR;
- }
-
- /*
- * Make sure that there's enough space in the item to hold the
- * tag names.
- */
-
- if (itemPtr->tagSpace < argc) {
- newPtr = (Tk_Uid *) ckalloc((unsigned) (argc * sizeof(Tk_Uid)));
- for (i = itemPtr->numTags-1; i >= 0; i--) {
- newPtr[i] = itemPtr->tagPtr[i];
- }
- if (itemPtr->tagPtr != itemPtr->staticTagSpace) {
- ckfree((char *) itemPtr->tagPtr);
- }
- itemPtr->tagPtr = newPtr;
- itemPtr->tagSpace = argc;
- }
- itemPtr->numTags = argc;
- for (i = 0; i < argc; i++) {
- itemPtr->tagPtr[i] = Tk_GetUid(argv[i]);
- }
- ckfree((char *) argv);
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_CanvasTagsPrintProc --
- *
- * This procedure is invoked by the Tk configuration code
- * to produce a printable string for the "-tags" configuration
- * option for canvas items.
- *
- * Results:
- * The return value is a string describing all the tags for
- * the item referred to by "widgRec". In addition, *freeProcPtr
- * is filled in with the address of a procedure to call to free
- * the result string when it's no longer needed (or NULL to
- * indicate that the string doesn't need to be freed).
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-char *
-Tk_CanvasTagsPrintProc(clientData, tkwin, widgRec, offset, freeProcPtr)
- ClientData clientData; /* Ignored. */
- Tk_Window tkwin; /* Window containing canvas widget. */
- char *widgRec; /* Pointer to record for item. */
- int offset; /* Ignored. */
- Tcl_FreeProc **freeProcPtr; /* Pointer to variable to fill in with
- * information about how to reclaim
- * storage for return string. */
-{
- register Tk_Item *itemPtr = (Tk_Item *) widgRec;
-
- if (itemPtr->numTags == 0) {
- *freeProcPtr = (Tcl_FreeProc *) NULL;
- return "";
- }
- if (itemPtr->numTags == 1) {
- *freeProcPtr = (Tcl_FreeProc *) NULL;
- return (char *) itemPtr->tagPtr[0];
- }
- *freeProcPtr = TCL_DYNAMIC;
- return Tcl_Merge(itemPtr->numTags, (char **) itemPtr->tagPtr);
-}
diff --git a/generic/tkCanvWind.c b/generic/tkCanvWind.c
deleted file mode 100644
index 5839cae..0000000
--- a/generic/tkCanvWind.c
+++ /dev/null
@@ -1,862 +0,0 @@
-/*
- * tkCanvWind.c --
- *
- * This file implements window items for canvas widgets.
- *
- * Copyright (c) 1992-1994 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: tkCanvWind.c,v 1.2 1998/09/14 18:23:06 stanton Exp $
- */
-
-#include <stdio.h>
-#include "tkInt.h"
-#include "tkPort.h"
-#include "tkCanvas.h"
-
-/*
- * The structure below defines the record for each window item.
- */
-
-typedef struct WindowItem {
- Tk_Item header; /* Generic stuff that's the same for all
- * types. MUST BE FIRST IN STRUCTURE. */
- double x, y; /* Coordinates of positioning point for
- * window. */
- Tk_Window tkwin; /* Window associated with item. NULL means
- * window has been destroyed. */
- int width; /* Width to use for window (<= 0 means use
- * window's requested width). */
- int height; /* Width to use for window (<= 0 means use
- * window's requested width). */
- Tk_Anchor anchor; /* Where to anchor window relative to
- * (x,y). */
- Tk_Canvas canvas; /* Canvas containing this item. */
-} WindowItem;
-
-/*
- * Information used for parsing configuration specs:
- */
-
-static Tk_CustomOption tagsOption = {Tk_CanvasTagsParseProc,
- Tk_CanvasTagsPrintProc, (ClientData) NULL
-};
-
-static Tk_ConfigSpec configSpecs[] = {
- {TK_CONFIG_ANCHOR, "-anchor", (char *) NULL, (char *) NULL,
- "center", Tk_Offset(WindowItem, anchor), TK_CONFIG_DONT_SET_DEFAULT},
- {TK_CONFIG_PIXELS, "-height", (char *) NULL, (char *) NULL,
- "0", Tk_Offset(WindowItem, height), TK_CONFIG_DONT_SET_DEFAULT},
- {TK_CONFIG_CUSTOM, "-tags", (char *) NULL, (char *) NULL,
- (char *) NULL, 0, TK_CONFIG_NULL_OK, &tagsOption},
- {TK_CONFIG_PIXELS, "-width", (char *) NULL, (char *) NULL,
- "0", Tk_Offset(WindowItem, width), TK_CONFIG_DONT_SET_DEFAULT},
- {TK_CONFIG_WINDOW, "-window", (char *) NULL, (char *) NULL,
- (char *) NULL, Tk_Offset(WindowItem, tkwin), TK_CONFIG_NULL_OK},
- {TK_CONFIG_END, (char *) NULL, (char *) NULL, (char *) NULL,
- (char *) NULL, 0, 0}
-};
-
-/*
- * Prototypes for procedures defined in this file:
- */
-
-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,
- char **argv, int flags));
-static int CreateWinItem _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Canvas canvas, struct Tk_Item *itemPtr,
- int argc, char **argv));
-static void DeleteWinItem _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, Display *display));
-static void DisplayWinItem _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, Display *display, Drawable dst,
- int x, int y, int width, int height));
-static void ScaleWinItem _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double originX, double originY,
- double scaleX, double scaleY));
-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,
- char **argv));
-static void WinItemLostSlaveProc _ANSI_ARGS_((
- ClientData clientData, Tk_Window tkwin));
-static void WinItemRequestProc _ANSI_ARGS_((ClientData clientData,
- Tk_Window tkwin));
-static void WinItemStructureProc _ANSI_ARGS_((
- ClientData clientData, XEvent *eventPtr));
-static int WinItemToArea _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double *rectPtr));
-static double WinItemToPoint _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double *pointPtr));
-
-/*
- * The structure below defines the window item type by means of procedures
- * that can be invoked by generic item code.
- */
-
-Tk_ItemType tkWindowType = {
- "window", /* name */
- sizeof(WindowItem), /* itemSize */
- CreateWinItem, /* createProc */
- configSpecs, /* configSpecs */
- ConfigureWinItem, /* configureProc */
- WinItemCoords, /* coordProc */
- DeleteWinItem, /* deleteProc */
- DisplayWinItem, /* displayProc */
- 1, /* alwaysRedraw */
- WinItemToPoint, /* pointProc */
- WinItemToArea, /* areaProc */
- (Tk_ItemPostscriptProc *) NULL, /* postscriptProc */
- ScaleWinItem, /* scaleProc */
- TranslateWinItem, /* translateProc */
- (Tk_ItemIndexProc *) NULL, /* indexProc */
- (Tk_ItemCursorProc *) NULL, /* cursorProc */
- (Tk_ItemSelectionProc *) NULL, /* selectionProc */
- (Tk_ItemInsertProc *) NULL, /* insertProc */
- (Tk_ItemDCharsProc *) NULL, /* dTextProc */
- (Tk_ItemType *) NULL /* nextPtr */
-};
-
-
-/*
- * The structure below defines the official type record for the
- * placer:
- */
-
-static Tk_GeomMgr canvasGeomType = {
- "canvas", /* name */
- WinItemRequestProc, /* requestProc */
- WinItemLostSlaveProc, /* lostSlaveProc */
-};
-
-/*
- *--------------------------------------------------------------
- *
- * CreateWinItem --
- *
- * This procedure is invoked to create a new window
- * item in a canvas.
- *
- * Results:
- * A standard Tcl return value. If an error occurred in
- * creating the item, then an error message is left in
- * interp->result; in this case itemPtr is
- * left uninitialized, so it can be safely freed by the
- * caller.
- *
- * Side effects:
- * A new window item is created.
- *
- *--------------------------------------------------------------
- */
-
-static int
-CreateWinItem(interp, canvas, itemPtr, argc, argv)
- 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. */
- char **argv; /* Arguments describing rectangle. */
-{
- WindowItem *winItemPtr = (WindowItem *) itemPtr;
-
- if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- Tk_PathName(Tk_CanvasTkwin(canvas)), " create ",
- itemPtr->typePtr->name, " x y ?options?\"",
- (char *) NULL);
- return TCL_ERROR;
- }
-
- /*
- * Initialize item's record.
- */
-
- winItemPtr->tkwin = NULL;
- winItemPtr->width = 0;
- winItemPtr->height = 0;
- winItemPtr->anchor = TK_ANCHOR_CENTER;
- winItemPtr->canvas = canvas;
-
- /*
- * Process the arguments to fill in the item record.
- */
-
- if ((Tk_CanvasGetCoord(interp, canvas, argv[0], &winItemPtr->x) != TCL_OK)
- || (Tk_CanvasGetCoord(interp, canvas, argv[1],
- &winItemPtr->y) != TCL_OK)) {
- return TCL_ERROR;
- }
-
- if (ConfigureWinItem(interp, canvas, itemPtr, argc-2, argv+2, 0)
- != TCL_OK) {
- DeleteWinItem(canvas, itemPtr, Tk_Display(Tk_CanvasTkwin(canvas)));
- return TCL_ERROR;
- }
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * WinItemCoords --
- *
- * This procedure is invoked to process the "coords" widget
- * command on window items. See the user documentation for
- * details on what it does.
- *
- * Results:
- * Returns TCL_OK or TCL_ERROR, and sets interp->result.
- *
- * Side effects:
- * The coordinates for the given item may be changed.
- *
- *--------------------------------------------------------------
- */
-
-static int
-WinItemCoords(interp, canvas, itemPtr, argc, argv)
- 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. */
- char **argv; /* Array of coordinates: x1, y1,
- * x2, y2, ... */
-{
- WindowItem *winItemPtr = (WindowItem *) itemPtr;
- char x[TCL_DOUBLE_SPACE], y[TCL_DOUBLE_SPACE];
-
- if (argc == 0) {
- Tcl_PrintDouble(interp, winItemPtr->x, x);
- Tcl_PrintDouble(interp, winItemPtr->y, y);
- Tcl_AppendResult(interp, x, " ", y, (char *) NULL);
- } else if (argc == 2) {
- if ((Tk_CanvasGetCoord(interp, canvas, argv[0], &winItemPtr->x)
- != TCL_OK) || (Tk_CanvasGetCoord(interp, canvas, argv[1],
- &winItemPtr->y) != TCL_OK)) {
- return TCL_ERROR;
- }
- ComputeWindowBbox(canvas, winItemPtr);
- } else {
- sprintf(interp->result,
- "wrong # coordinates: expected 0 or 2, got %d", argc);
- return TCL_ERROR;
- }
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ConfigureWinItem --
- *
- * This procedure is invoked to configure various aspects
- * of a window item, such as its anchor position.
- *
- * Results:
- * A standard Tcl result code. If an error occurs, then
- * an error message is left in interp->result.
- *
- * Side effects:
- * Configuration information may be set for itemPtr.
- *
- *--------------------------------------------------------------
- */
-
-static int
-ConfigureWinItem(interp, canvas, itemPtr, argc, argv, 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. */
- char **argv; /* Arguments describing things to configure. */
- int flags; /* Flags to pass to Tk_ConfigureWidget. */
-{
- WindowItem *winItemPtr = (WindowItem *) itemPtr;
- Tk_Window oldWindow;
- Tk_Window canvasTkwin;
-
- oldWindow = winItemPtr->tkwin;
- canvasTkwin = Tk_CanvasTkwin(canvas);
- if (Tk_ConfigureWidget(interp, canvasTkwin, configSpecs, argc, argv,
- (char *) winItemPtr, flags) != TCL_OK) {
- return TCL_ERROR;
- }
-
- /*
- * A few of the options require additional processing.
- */
-
- if (oldWindow != winItemPtr->tkwin) {
- if (oldWindow != NULL) {
- Tk_DeleteEventHandler(oldWindow, StructureNotifyMask,
- WinItemStructureProc, (ClientData) winItemPtr);
- Tk_ManageGeometry(oldWindow, (Tk_GeomMgr *) NULL,
- (ClientData) NULL);
- Tk_UnmaintainGeometry(oldWindow, canvasTkwin);
- Tk_UnmapWindow(oldWindow);
- }
- if (winItemPtr->tkwin != NULL) {
- Tk_Window ancestor, parent;
-
- /*
- * 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
- * managed inside a canvas.
- */
-
- parent = Tk_Parent(winItemPtr->tkwin);
- for (ancestor = canvasTkwin; ;
- ancestor = Tk_Parent(ancestor)) {
- if (ancestor == parent) {
- break;
- }
- if (((Tk_FakeWin *) (ancestor))->flags & TK_TOP_LEVEL) {
- badWindow:
- Tcl_AppendResult(interp, "can't use ",
- Tk_PathName(winItemPtr->tkwin),
- " in a window item of this canvas", (char *) NULL);
- winItemPtr->tkwin = NULL;
- return TCL_ERROR;
- }
- }
- if (((Tk_FakeWin *) (winItemPtr->tkwin))->flags & TK_TOP_LEVEL) {
- goto badWindow;
- }
- if (winItemPtr->tkwin == canvasTkwin) {
- goto badWindow;
- }
- Tk_CreateEventHandler(winItemPtr->tkwin, StructureNotifyMask,
- WinItemStructureProc, (ClientData) winItemPtr);
- Tk_ManageGeometry(winItemPtr->tkwin, &canvasGeomType,
- (ClientData) winItemPtr);
- }
- }
-
- ComputeWindowBbox(canvas, winItemPtr);
-
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * DeleteWinItem --
- *
- * This procedure is called to clean up the data structure
- * associated with a window item.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Resources associated with itemPtr are released.
- *
- *--------------------------------------------------------------
- */
-
-static void
-DeleteWinItem(canvas, itemPtr, display)
- Tk_Canvas canvas; /* Overall info about widget. */
- Tk_Item *itemPtr; /* Item that is being deleted. */
- Display *display; /* Display containing window for
- * canvas. */
-{
- WindowItem *winItemPtr = (WindowItem *) itemPtr;
- Tk_Window canvasTkwin = Tk_CanvasTkwin(canvas);
-
- if (winItemPtr->tkwin != NULL) {
- Tk_DeleteEventHandler(winItemPtr->tkwin, StructureNotifyMask,
- WinItemStructureProc, (ClientData) winItemPtr);
- Tk_ManageGeometry(winItemPtr->tkwin, (Tk_GeomMgr *) NULL,
- (ClientData) NULL);
- if (canvasTkwin != Tk_Parent(winItemPtr->tkwin)) {
- Tk_UnmaintainGeometry(winItemPtr->tkwin, canvasTkwin);
- }
- Tk_UnmapWindow(winItemPtr->tkwin);
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ComputeWindowBbox --
- *
- * This procedure is invoked to compute the bounding box of
- * all the pixels that may be drawn as part of a window item.
- * This procedure is where the child window's placement is
- * computed.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The fields x1, y1, x2, and y2 are updated in the header
- * for itemPtr.
- *
- *--------------------------------------------------------------
- */
-
-static void
-ComputeWindowBbox(canvas, winItemPtr)
- Tk_Canvas canvas; /* Canvas that contains item. */
- WindowItem *winItemPtr; /* Item whose bbox is to be
- * recomputed. */
-{
- int width, height, x, y;
-
- x = (int) (winItemPtr->x + ((winItemPtr->x >= 0) ? 0.5 : - 0.5));
- y = (int) (winItemPtr->y + ((winItemPtr->y >= 0) ? 0.5 : - 0.5));
-
- if (winItemPtr->tkwin == NULL) {
- /*
- * There is no window for this item yet. Just give it a 1x1
- * bounding box. Don't give it a 0x0 bounding box; there are
- * strange cases where this bounding box might be used as the
- * dimensions of the window, and 0x0 causes problems under X.
- */
-
- winItemPtr->header.x1 = x;
- winItemPtr->header.x2 = winItemPtr->header.x1 + 1;
- winItemPtr->header.y1 = y;
- winItemPtr->header.y2 = winItemPtr->header.y1 + 1;
- return;
- }
-
- /*
- * Compute dimensions of window.
- */
-
- width = winItemPtr->width;
- if (width <= 0) {
- width = Tk_ReqWidth(winItemPtr->tkwin);
- if (width <= 0) {
- width = 1;
- }
- }
- height = winItemPtr->height;
- if (height <= 0) {
- height = Tk_ReqHeight(winItemPtr->tkwin);
- if (height <= 0) {
- height = 1;
- }
- }
-
- /*
- * Compute location of window, using anchor information.
- */
-
- switch (winItemPtr->anchor) {
- case TK_ANCHOR_N:
- x -= width/2;
- break;
- case TK_ANCHOR_NE:
- x -= width;
- break;
- case TK_ANCHOR_E:
- x -= width;
- y -= height/2;
- break;
- case TK_ANCHOR_SE:
- x -= width;
- y -= height;
- break;
- case TK_ANCHOR_S:
- x -= width/2;
- y -= height;
- break;
- case TK_ANCHOR_SW:
- y -= height;
- break;
- case TK_ANCHOR_W:
- y -= height/2;
- break;
- case TK_ANCHOR_NW:
- break;
- case TK_ANCHOR_CENTER:
- x -= width/2;
- y -= height/2;
- break;
- }
-
- /*
- * Store the information in the item header.
- */
-
- winItemPtr->header.x1 = x;
- winItemPtr->header.y1 = y;
- winItemPtr->header.x2 = x + width;
- winItemPtr->header.y2 = y + height;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * DisplayWinItem --
- *
- * This procedure is invoked to "draw" a window item in a given
- * drawable. Since the window draws itself, we needn't do any
- * actual redisplay here. However, this procedure takes care
- * of actually repositioning the child window so that it occupies
- * the correct screen position.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The child window's position may get changed. Note: this
- * procedure gets called both when a window needs to be displayed
- * and when it ceases to be visible on the screen (e.g. it was
- * scrolled or moved off-screen or the enclosing canvas is
- * unmapped).
- *
- *--------------------------------------------------------------
- */
-
-static void
-DisplayWinItem(canvas, itemPtr, display, drawable, regionX, regionY,
- regionWidth, regionHeight)
- Tk_Canvas canvas; /* Canvas that contains item. */
- Tk_Item *itemPtr; /* Item to be displayed. */
- Display *display; /* Display on which to draw item. */
- Drawable drawable; /* Pixmap or window in which to draw
- * item. */
- int regionX, regionY, regionWidth, regionHeight;
- /* Describes region of canvas that
- * must be redisplayed (not used). */
-{
- WindowItem *winItemPtr = (WindowItem *) itemPtr;
- int width, height;
- short x, y;
- Tk_Window canvasTkwin = Tk_CanvasTkwin(canvas);
-
- if (winItemPtr->tkwin == NULL) {
- return;
- }
-
- Tk_CanvasWindowCoords(canvas, (double) winItemPtr->header.x1,
- (double) winItemPtr->header.y1, &x, &y);
- width = winItemPtr->header.x2 - winItemPtr->header.x1;
- height = winItemPtr->header.y2 - winItemPtr->header.y1;
-
- /*
- * If the window is completely out of the visible area of the canvas
- * then unmap it. This code used not to be present (why unmap the
- * window if it isn't visible anyway?) but this could cause the
- * window to suddenly reappear if the canvas window got resized.
- */
-
- if (((x + width) <= 0) || ((y + height) <= 0)
- || (x >= Tk_Width(canvasTkwin)) || (y >= Tk_Height(canvasTkwin))) {
- if (canvasTkwin == Tk_Parent(winItemPtr->tkwin)) {
- Tk_UnmapWindow(winItemPtr->tkwin);
- } else {
- Tk_UnmaintainGeometry(winItemPtr->tkwin, canvasTkwin);
- }
- return;
- }
-
- /*
- * Reposition and map the window (but in different ways depending
- * on whether the canvas is the window's parent).
- */
-
- if (canvasTkwin == Tk_Parent(winItemPtr->tkwin)) {
- if ((x != Tk_X(winItemPtr->tkwin)) || (y != Tk_Y(winItemPtr->tkwin))
- || (width != Tk_Width(winItemPtr->tkwin))
- || (height != Tk_Height(winItemPtr->tkwin))) {
- Tk_MoveResizeWindow(winItemPtr->tkwin, x, y, width, height);
- }
- Tk_MapWindow(winItemPtr->tkwin);
- } else {
- Tk_MaintainGeometry(winItemPtr->tkwin, canvasTkwin, x, y,
- width, height);
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * WinItemToPoint --
- *
- * Computes the distance from a given point to a given
- * rectangle, in canvas units.
- *
- * Results:
- * The return value is 0 if the point whose x and y coordinates
- * are coordPtr[0] and coordPtr[1] is inside the window. If the
- * point isn't inside the window then the return value is the
- * distance from the point to the window.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-static double
-WinItemToPoint(canvas, itemPtr, pointPtr)
- Tk_Canvas canvas; /* Canvas containing item. */
- Tk_Item *itemPtr; /* Item to check against point. */
- double *pointPtr; /* Pointer to x and y coordinates. */
-{
- WindowItem *winItemPtr = (WindowItem *) itemPtr;
- double x1, x2, y1, y2, xDiff, yDiff;
-
- x1 = winItemPtr->header.x1;
- y1 = winItemPtr->header.y1;
- x2 = winItemPtr->header.x2;
- y2 = winItemPtr->header.y2;
-
- /*
- * Point is outside rectangle.
- */
-
- if (pointPtr[0] < x1) {
- xDiff = x1 - pointPtr[0];
- } else if (pointPtr[0] >= x2) {
- xDiff = pointPtr[0] + 1 - x2;
- } else {
- xDiff = 0;
- }
-
- if (pointPtr[1] < y1) {
- yDiff = y1 - pointPtr[1];
- } else if (pointPtr[1] >= y2) {
- yDiff = pointPtr[1] + 1 - y2;
- } else {
- yDiff = 0;
- }
-
- return hypot(xDiff, yDiff);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * WinItemToArea --
- *
- * This procedure is called to determine whether an item
- * lies entirely inside, entirely outside, or overlapping
- * a given rectangle.
- *
- * Results:
- * -1 is returned if the item is entirely outside the area
- * given by rectPtr, 0 if it overlaps, and 1 if it is entirely
- * inside the given area.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-static int
-WinItemToArea(canvas, itemPtr, rectPtr)
- Tk_Canvas canvas; /* Canvas containing item. */
- Tk_Item *itemPtr; /* Item to check against rectangle. */
- double *rectPtr; /* Pointer to array of four coordinates
- * (x1, y1, x2, y2) describing rectangular
- * area. */
-{
- WindowItem *winItemPtr = (WindowItem *) itemPtr;
-
- if ((rectPtr[2] <= winItemPtr->header.x1)
- || (rectPtr[0] >= winItemPtr->header.x2)
- || (rectPtr[3] <= winItemPtr->header.y1)
- || (rectPtr[1] >= winItemPtr->header.y2)) {
- return -1;
- }
- if ((rectPtr[0] <= winItemPtr->header.x1)
- && (rectPtr[1] <= winItemPtr->header.y1)
- && (rectPtr[2] >= winItemPtr->header.x2)
- && (rectPtr[3] >= winItemPtr->header.y2)) {
- return 1;
- }
- return 0;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ScaleWinItem --
- *
- * This procedure is invoked to rescale a rectangle or oval
- * item.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The rectangle or oval referred to by itemPtr is rescaled
- * so that the following transformation is applied to all
- * point coordinates:
- * x' = originX + scaleX*(x-originX)
- * y' = originY + scaleY*(y-originY)
- *
- *--------------------------------------------------------------
- */
-
-static void
-ScaleWinItem(canvas, itemPtr, originX, originY, scaleX, scaleY)
- Tk_Canvas canvas; /* Canvas containing rectangle. */
- Tk_Item *itemPtr; /* Rectangle to be scaled. */
- double originX, originY; /* Origin about which to scale rect. */
- double scaleX; /* Amount to scale in X direction. */
- double scaleY; /* Amount to scale in Y direction. */
-{
- WindowItem *winItemPtr = (WindowItem *) itemPtr;
-
- winItemPtr->x = originX + scaleX*(winItemPtr->x - originX);
- winItemPtr->y = originY + scaleY*(winItemPtr->y - originY);
- if (winItemPtr->width > 0) {
- winItemPtr->width = (int) (scaleX*winItemPtr->width);
- }
- if (winItemPtr->height > 0) {
- winItemPtr->height = (int) (scaleY*winItemPtr->height);
- }
- ComputeWindowBbox(canvas, winItemPtr);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * TranslateWinItem --
- *
- * This procedure is called to move a rectangle or oval by a
- * given amount.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The position of the rectangle or oval is offset by
- * (xDelta, yDelta), and the bounding box is updated in the
- * generic part of the item structure.
- *
- *--------------------------------------------------------------
- */
-
-static void
-TranslateWinItem(canvas, itemPtr, deltaX, deltaY)
- Tk_Canvas canvas; /* Canvas containing item. */
- Tk_Item *itemPtr; /* Item that is being moved. */
- double deltaX, deltaY; /* Amount by which item is to be
- * moved. */
-{
- WindowItem *winItemPtr = (WindowItem *) itemPtr;
-
- winItemPtr->x += deltaX;
- winItemPtr->y += deltaY;
- ComputeWindowBbox(canvas, winItemPtr);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * WinItemStructureProc --
- *
- * This procedure is invoked whenever StructureNotify events
- * occur for a window that's managed as part of a canvas window
- * item. This procudure's only purpose is to clean up when
- * windows are deleted.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The window is disassociated from the window item when it is
- * deleted.
- *
- *--------------------------------------------------------------
- */
-
-static void
-WinItemStructureProc(clientData, eventPtr)
- ClientData clientData; /* Pointer to record describing window item. */
- XEvent *eventPtr; /* Describes what just happened. */
-{
- WindowItem *winItemPtr = (WindowItem *) clientData;
-
- if (eventPtr->type == DestroyNotify) {
- winItemPtr->tkwin = NULL;
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * WinItemRequestProc --
- *
- * This procedure is invoked whenever a window that's associated
- * with a window canvas item 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 window item.
- *
- *--------------------------------------------------------------
- */
-
-static void
-WinItemRequestProc(clientData, tkwin)
- ClientData clientData; /* Pointer to record for window item. */
- Tk_Window tkwin; /* Window that changed its desired
- * size. */
-{
- WindowItem *winItemPtr = (WindowItem *) clientData;
-
- ComputeWindowBbox(winItemPtr->canvas, winItemPtr);
- DisplayWinItem(winItemPtr->canvas, (Tk_Item *) winItemPtr,
- (Display *) NULL, (Drawable) None, 0, 0, 0, 0);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * WinItemLostSlaveProc --
- *
- * 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 canvas-related information about the slave.
- *
- *--------------------------------------------------------------
- */
-
- /* ARGSUSED */
-static void
-WinItemLostSlaveProc(clientData, tkwin)
- ClientData clientData; /* WindowItem structure for slave window that
- * was stolen away. */
- Tk_Window tkwin; /* Tk's handle for the slave window. */
-{
- WindowItem *winItemPtr = (WindowItem *) clientData;
- Tk_Window canvasTkwin = Tk_CanvasTkwin(winItemPtr->canvas);
-
- Tk_DeleteEventHandler(winItemPtr->tkwin, StructureNotifyMask,
- WinItemStructureProc, (ClientData) winItemPtr);
- if (canvasTkwin != Tk_Parent(winItemPtr->tkwin)) {
- Tk_UnmaintainGeometry(winItemPtr->tkwin, canvasTkwin);
- }
- Tk_UnmapWindow(winItemPtr->tkwin);
- winItemPtr->tkwin = NULL;
-}
diff --git a/generic/tkCanvas.c b/generic/tkCanvas.c
deleted file mode 100644
index 6574437..0000000
--- a/generic/tkCanvas.c
+++ /dev/null
@@ -1,3791 +0,0 @@
-/*
- * tkCanvas.c --
- *
- * This module implements canvas widgets for the Tk toolkit.
- * A canvas displays a background and a collection of graphical
- * objects such as rectangles, lines, and texts.
- *
- * Copyright (c) 1991-1994 The Regents of the University of California.
- * Copyright (c) 1994-1995 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: tkCanvas.c,v 1.2 1998/09/14 18:23:06 stanton Exp $
- */
-
-#include "default.h"
-#include "tkInt.h"
-#include "tkPort.h"
-#include "tkCanvas.h"
-
-/*
- * See tkCanvas.h for key data structures used to implement canvases.
- */
-
-/*
- * The structure defined below is used to keep track of a tag search
- * in progress. Only the "prevPtr" field should be accessed by anyone
- * other than StartTagSearch and NextItem.
- */
-
-typedef struct TagSearch {
- TkCanvas *canvasPtr; /* Canvas widget being searched. */
- Tk_Uid tag; /* Tag to search for. 0 means return
- * all items. */
- Tk_Item *prevPtr; /* Item just before last one found (or NULL
- * if last one found was first in the item
- * list of canvasPtr). */
- Tk_Item *currentPtr; /* Pointer to last item returned. */
- int searchOver; /* Non-zero means NextItem should always
- * return NULL. */
-} TagSearch;
-
-/*
- * Information used for argv parsing.
- */
-
-static Tk_ConfigSpec configSpecs[] = {
- {TK_CONFIG_BORDER, "-background", "background", "Background",
- DEF_CANVAS_BG_COLOR, Tk_Offset(TkCanvas, bgBorder),
- TK_CONFIG_COLOR_ONLY},
- {TK_CONFIG_BORDER, "-background", "background", "Background",
- DEF_CANVAS_BG_MONO, Tk_Offset(TkCanvas, bgBorder),
- 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_CANVAS_BORDER_WIDTH, Tk_Offset(TkCanvas, borderWidth), 0},
- {TK_CONFIG_DOUBLE, "-closeenough", "closeEnough", "CloseEnough",
- DEF_CANVAS_CLOSE_ENOUGH, Tk_Offset(TkCanvas, closeEnough), 0},
- {TK_CONFIG_BOOLEAN, "-confine", "confine", "Confine",
- DEF_CANVAS_CONFINE, Tk_Offset(TkCanvas, confine), 0},
- {TK_CONFIG_ACTIVE_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_CANVAS_CURSOR, Tk_Offset(TkCanvas, cursor), TK_CONFIG_NULL_OK},
- {TK_CONFIG_PIXELS, "-height", "height", "Height",
- DEF_CANVAS_HEIGHT, Tk_Offset(TkCanvas, height), 0},
- {TK_CONFIG_COLOR, "-highlightbackground", "highlightBackground",
- "HighlightBackground", DEF_CANVAS_HIGHLIGHT_BG,
- Tk_Offset(TkCanvas, highlightBgColorPtr), 0},
- {TK_CONFIG_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_CANVAS_HIGHLIGHT, Tk_Offset(TkCanvas, highlightColorPtr), 0},
- {TK_CONFIG_PIXELS, "-highlightthickness", "highlightThickness",
- "HighlightThickness",
- DEF_CANVAS_HIGHLIGHT_WIDTH, Tk_Offset(TkCanvas, highlightWidth), 0},
- {TK_CONFIG_BORDER, "-insertbackground", "insertBackground", "Foreground",
- DEF_CANVAS_INSERT_BG, Tk_Offset(TkCanvas, textInfo.insertBorder), 0},
- {TK_CONFIG_PIXELS, "-insertborderwidth", "insertBorderWidth", "BorderWidth",
- DEF_CANVAS_INSERT_BD_COLOR,
- Tk_Offset(TkCanvas, textInfo.insertBorderWidth), TK_CONFIG_COLOR_ONLY},
- {TK_CONFIG_PIXELS, "-insertborderwidth", "insertBorderWidth", "BorderWidth",
- DEF_CANVAS_INSERT_BD_MONO,
- Tk_Offset(TkCanvas, textInfo.insertBorderWidth), TK_CONFIG_MONO_ONLY},
- {TK_CONFIG_INT, "-insertofftime", "insertOffTime", "OffTime",
- DEF_CANVAS_INSERT_OFF_TIME, Tk_Offset(TkCanvas, insertOffTime), 0},
- {TK_CONFIG_INT, "-insertontime", "insertOnTime", "OnTime",
- DEF_CANVAS_INSERT_ON_TIME, Tk_Offset(TkCanvas, insertOnTime), 0},
- {TK_CONFIG_PIXELS, "-insertwidth", "insertWidth", "InsertWidth",
- DEF_CANVAS_INSERT_WIDTH, Tk_Offset(TkCanvas, textInfo.insertWidth), 0},
- {TK_CONFIG_RELIEF, "-relief", "relief", "Relief",
- DEF_CANVAS_RELIEF, Tk_Offset(TkCanvas, relief), 0},
- {TK_CONFIG_STRING, "-scrollregion", "scrollRegion", "ScrollRegion",
- DEF_CANVAS_SCROLL_REGION, Tk_Offset(TkCanvas, regionString),
- TK_CONFIG_NULL_OK},
- {TK_CONFIG_BORDER, "-selectbackground", "selectBackground", "Foreground",
- DEF_CANVAS_SELECT_COLOR, Tk_Offset(TkCanvas, textInfo.selBorder),
- TK_CONFIG_COLOR_ONLY},
- {TK_CONFIG_BORDER, "-selectbackground", "selectBackground", "Foreground",
- DEF_CANVAS_SELECT_MONO, Tk_Offset(TkCanvas, textInfo.selBorder),
- TK_CONFIG_MONO_ONLY},
- {TK_CONFIG_PIXELS, "-selectborderwidth", "selectBorderWidth", "BorderWidth",
- DEF_CANVAS_SELECT_BD_COLOR,
- Tk_Offset(TkCanvas, textInfo.selBorderWidth), TK_CONFIG_COLOR_ONLY},
- {TK_CONFIG_PIXELS, "-selectborderwidth", "selectBorderWidth", "BorderWidth",
- DEF_CANVAS_SELECT_BD_MONO, Tk_Offset(TkCanvas, textInfo.selBorderWidth),
- TK_CONFIG_MONO_ONLY},
- {TK_CONFIG_COLOR, "-selectforeground", "selectForeground", "Background",
- DEF_CANVAS_SELECT_FG_COLOR, Tk_Offset(TkCanvas, textInfo.selFgColorPtr),
- TK_CONFIG_COLOR_ONLY},
- {TK_CONFIG_COLOR, "-selectforeground", "selectForeground", "Background",
- DEF_CANVAS_SELECT_FG_MONO, Tk_Offset(TkCanvas, textInfo.selFgColorPtr),
- TK_CONFIG_MONO_ONLY},
- {TK_CONFIG_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_CANVAS_TAKE_FOCUS, Tk_Offset(TkCanvas, takeFocus),
- TK_CONFIG_NULL_OK},
- {TK_CONFIG_PIXELS, "-width", "width", "Width",
- DEF_CANVAS_WIDTH, Tk_Offset(TkCanvas, width), 0},
- {TK_CONFIG_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand",
- DEF_CANVAS_X_SCROLL_CMD, Tk_Offset(TkCanvas, xScrollCmd),
- TK_CONFIG_NULL_OK},
- {TK_CONFIG_PIXELS, "-xscrollincrement", "xScrollIncrement",
- "ScrollIncrement",
- DEF_CANVAS_X_SCROLL_INCREMENT, Tk_Offset(TkCanvas, xScrollIncrement),
- 0},
- {TK_CONFIG_STRING, "-yscrollcommand", "yScrollCommand", "ScrollCommand",
- DEF_CANVAS_Y_SCROLL_CMD, Tk_Offset(TkCanvas, yScrollCmd),
- TK_CONFIG_NULL_OK},
- {TK_CONFIG_PIXELS, "-yscrollincrement", "yScrollIncrement",
- "ScrollIncrement",
- DEF_CANVAS_Y_SCROLL_INCREMENT, Tk_Offset(TkCanvas, yScrollIncrement),
- 0},
- {TK_CONFIG_END, (char *) NULL, (char *) NULL, (char *) NULL,
- (char *) NULL, 0, 0}
-};
-
-/*
- * List of all the item types known at present:
- */
-
-static Tk_ItemType *typeList = NULL; /* NULL means initialization hasn't
- * been done yet. */
-
-/*
- * Standard item types provided by Tk:
- */
-
-extern Tk_ItemType tkArcType, tkBitmapType, tkImageType, tkLineType;
-extern Tk_ItemType tkOvalType, tkPolygonType;
-extern Tk_ItemType tkRectangleType, tkTextType, tkWindowType;
-
-/*
- * Various Tk_Uid's used by this module (set up during initialization):
- */
-
-static Tk_Uid allUid = NULL;
-static Tk_Uid currentUid = NULL;
-
-/*
- * Statistics counters:
- */
-
-static int numIdSearches;
-static int numSlowSearches;
-
-/*
- * Prototypes for procedures defined later in this file:
- */
-
-static void CanvasBindProc _ANSI_ARGS_((ClientData clientData,
- XEvent *eventPtr));
-static void CanvasBlinkProc _ANSI_ARGS_((ClientData clientData));
-static void CanvasCmdDeletedProc _ANSI_ARGS_((
- ClientData clientData));
-static void CanvasDoEvent _ANSI_ARGS_((TkCanvas *canvasPtr,
- XEvent *eventPtr));
-static void CanvasEventProc _ANSI_ARGS_((ClientData clientData,
- XEvent *eventPtr));
-static int CanvasFetchSelection _ANSI_ARGS_((
- ClientData clientData, int offset,
- char *buffer, int maxBytes));
-static Tk_Item * CanvasFindClosest _ANSI_ARGS_((TkCanvas *canvasPtr,
- double coords[2]));
-static void CanvasFocusProc _ANSI_ARGS_((TkCanvas *canvasPtr,
- int gotFocus));
-static void CanvasLostSelection _ANSI_ARGS_((
- ClientData clientData));
-static void CanvasSelectTo _ANSI_ARGS_((TkCanvas *canvasPtr,
- Tk_Item *itemPtr, int index));
-static void CanvasSetOrigin _ANSI_ARGS_((TkCanvas *canvasPtr,
- int xOrigin, int yOrigin));
-static void CanvasUpdateScrollbars _ANSI_ARGS_((
- TkCanvas *canvasPtr));
-static int CanvasWidgetCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-static void CanvasWorldChanged _ANSI_ARGS_((
- ClientData instanceData));
-static int ConfigureCanvas _ANSI_ARGS_((Tcl_Interp *interp,
- TkCanvas *canvasPtr, int argc, char **argv,
- int flags));
-static void DestroyCanvas _ANSI_ARGS_((char *memPtr));
-static void DisplayCanvas _ANSI_ARGS_((ClientData clientData));
-static void DoItem _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Item *itemPtr, Tk_Uid tag));
-static int FindItems _ANSI_ARGS_((Tcl_Interp *interp,
- TkCanvas *canvasPtr, int argc, char **argv,
- char *newTag, char *cmdName, char *option));
-static int FindArea _ANSI_ARGS_((Tcl_Interp *interp,
- TkCanvas *canvasPtr, char **argv, Tk_Uid uid,
- int enclosed));
-static double GridAlign _ANSI_ARGS_((double coord, double spacing));
-static void InitCanvas _ANSI_ARGS_((void));
-static Tk_Item * NextItem _ANSI_ARGS_((TagSearch *searchPtr));
-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 void RelinkItems _ANSI_ARGS_((TkCanvas *canvasPtr,
- char *tag, Tk_Item *prevPtr));
-static Tk_Item * StartTagSearch _ANSI_ARGS_((TkCanvas *canvasPtr,
- char *tag, TagSearch *searchPtr));
-
-/*
- * The structure below defines canvas class behavior by means of procedures
- * that can be invoked from generic window code.
- */
-
-static TkClassProcs canvasClass = {
- NULL, /* createProc. */
- CanvasWorldChanged, /* geometryProc. */
- NULL /* modalProc. */
-};
-
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_CanvasCmd --
- *
- * This procedure is invoked to process the "canvas" 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_CanvasCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Main window associated with
- * interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- Tk_Window tkwin = (Tk_Window) clientData;
- TkCanvas *canvasPtr;
- Tk_Window new;
-
- if (typeList == NULL) {
- InitCanvas();
- }
-
- if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " pathName ?options?\"", (char *) NULL);
- return TCL_ERROR;
- }
-
- new = Tk_CreateWindowFromPath(interp, tkwin, argv[1], (char *) NULL);
- if (new == NULL) {
- return TCL_ERROR;
- }
-
- /*
- * Initialize fields that won't be initialized by ConfigureCanvas,
- * or which ConfigureCanvas expects to have reasonable values
- * (e.g. resource pointers).
- */
-
- canvasPtr = (TkCanvas *) ckalloc(sizeof(TkCanvas));
- canvasPtr->tkwin = new;
- canvasPtr->display = Tk_Display(new);
- canvasPtr->interp = interp;
- canvasPtr->widgetCmd = Tcl_CreateCommand(interp,
- Tk_PathName(canvasPtr->tkwin), CanvasWidgetCmd,
- (ClientData) canvasPtr, CanvasCmdDeletedProc);
- canvasPtr->firstItemPtr = NULL;
- canvasPtr->lastItemPtr = NULL;
- canvasPtr->borderWidth = 0;
- canvasPtr->bgBorder = NULL;
- canvasPtr->relief = TK_RELIEF_FLAT;
- canvasPtr->highlightWidth = 0;
- canvasPtr->highlightBgColorPtr = NULL;
- canvasPtr->highlightColorPtr = NULL;
- canvasPtr->inset = 0;
- canvasPtr->pixmapGC = None;
- canvasPtr->width = None;
- canvasPtr->height = None;
- canvasPtr->confine = 0;
- canvasPtr->textInfo.selBorder = NULL;
- canvasPtr->textInfo.selBorderWidth = 0;
- canvasPtr->textInfo.selFgColorPtr = NULL;
- canvasPtr->textInfo.selItemPtr = NULL;
- canvasPtr->textInfo.selectFirst = -1;
- canvasPtr->textInfo.selectLast = -1;
- canvasPtr->textInfo.anchorItemPtr = NULL;
- canvasPtr->textInfo.selectAnchor = 0;
- canvasPtr->textInfo.insertBorder = NULL;
- canvasPtr->textInfo.insertWidth = 0;
- canvasPtr->textInfo.insertBorderWidth = 0;
- canvasPtr->textInfo.focusItemPtr = NULL;
- canvasPtr->textInfo.gotFocus = 0;
- canvasPtr->textInfo.cursorOn = 0;
- canvasPtr->insertOnTime = 0;
- canvasPtr->insertOffTime = 0;
- canvasPtr->insertBlinkHandler = (Tcl_TimerToken) NULL;
- canvasPtr->xOrigin = canvasPtr->yOrigin = 0;
- canvasPtr->drawableXOrigin = canvasPtr->drawableYOrigin = 0;
- canvasPtr->bindingTable = NULL;
- canvasPtr->currentItemPtr = NULL;
- canvasPtr->newCurrentPtr = NULL;
- canvasPtr->closeEnough = 0.0;
- canvasPtr->pickEvent.type = LeaveNotify;
- canvasPtr->pickEvent.xcrossing.x = 0;
- canvasPtr->pickEvent.xcrossing.y = 0;
- canvasPtr->state = 0;
- canvasPtr->xScrollCmd = NULL;
- canvasPtr->yScrollCmd = NULL;
- canvasPtr->scrollX1 = 0;
- canvasPtr->scrollY1 = 0;
- canvasPtr->scrollX2 = 0;
- canvasPtr->scrollY2 = 0;
- canvasPtr->regionString = NULL;
- canvasPtr->xScrollIncrement = 0;
- canvasPtr->yScrollIncrement = 0;
- canvasPtr->scanX = 0;
- canvasPtr->scanXOrigin = 0;
- canvasPtr->scanY = 0;
- canvasPtr->scanYOrigin = 0;
- canvasPtr->hotPtr = NULL;
- canvasPtr->hotPrevPtr = NULL;
- canvasPtr->cursor = None;
- canvasPtr->takeFocus = NULL;
- canvasPtr->pixelsPerMM = WidthOfScreen(Tk_Screen(new));
- canvasPtr->pixelsPerMM /= WidthMMOfScreen(Tk_Screen(new));
- canvasPtr->flags = 0;
- canvasPtr->nextId = 1;
- canvasPtr->psInfoPtr = NULL;
-
- Tk_SetClass(canvasPtr->tkwin, "Canvas");
- TkSetClassProcs(canvasPtr->tkwin, &canvasClass, (ClientData) canvasPtr);
- Tk_CreateEventHandler(canvasPtr->tkwin,
- ExposureMask|StructureNotifyMask|FocusChangeMask,
- CanvasEventProc, (ClientData) canvasPtr);
- Tk_CreateEventHandler(canvasPtr->tkwin, KeyPressMask|KeyReleaseMask
- |ButtonPressMask|ButtonReleaseMask|EnterWindowMask
- |LeaveWindowMask|PointerMotionMask|VirtualEventMask,
- CanvasBindProc, (ClientData) canvasPtr);
- Tk_CreateSelHandler(canvasPtr->tkwin, XA_PRIMARY, XA_STRING,
- CanvasFetchSelection, (ClientData) canvasPtr, XA_STRING);
- if (ConfigureCanvas(interp, canvasPtr, argc-2, argv+2, 0) != TCL_OK) {
- goto error;
- }
-
- interp->result = Tk_PathName(canvasPtr->tkwin);
- return TCL_OK;
-
- error:
- Tk_DestroyWindow(canvasPtr->tkwin);
- return TCL_ERROR;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * CanvasWidgetCmd --
- *
- * 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
-CanvasWidgetCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Information about canvas
- * widget. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- TkCanvas *canvasPtr = (TkCanvas *) clientData;
- size_t length;
- int c, result;
- Tk_Item *itemPtr = NULL; /* Initialization needed only to
- * prevent compiler warning. */
- TagSearch search;
-
- if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " option ?arg arg ...?\"", (char *) NULL);
- return TCL_ERROR;
- }
- Tcl_Preserve((ClientData) canvasPtr);
- result = TCL_OK;
- c = argv[1][0];
- length = strlen(argv[1]);
- if ((c == 'a') && (strncmp(argv[1], "addtag", length) == 0)) {
- if (argc < 4) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " addtags tag searchCommand ?arg arg ...?\"",
- (char *) NULL);
- goto error;
- }
- result = FindItems(interp, canvasPtr, argc-3, argv+3, argv[2], argv[0],
- " addtag tag");
- } else if ((c == 'b') && (strncmp(argv[1], "bbox", length) == 0)
- && (length >= 2)) {
- int i, gotAny;
- int x1 = 0, y1 = 0, x2 = 0, y2 = 0; /* Initializations needed
- * only to prevent compiler
- * warnings. */
-
- if (argc < 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " bbox tagOrId ?tagOrId ...?\"",
- (char *) NULL);
- goto error;
- }
- gotAny = 0;
- for (i = 2; i < argc; i++) {
- for (itemPtr = StartTagSearch(canvasPtr, argv[i], &search);
- itemPtr != NULL; itemPtr = NextItem(&search)) {
- if ((itemPtr->x1 >= itemPtr->x2)
- || (itemPtr->y1 >= itemPtr->y2)) {
- continue;
- }
- if (!gotAny) {
- x1 = itemPtr->x1;
- y1 = itemPtr->y1;
- x2 = itemPtr->x2;
- y2 = itemPtr->y2;
- gotAny = 1;
- } else {
- if (itemPtr->x1 < x1) {
- x1 = itemPtr->x1;
- }
- if (itemPtr->y1 < y1) {
- y1 = itemPtr->y1;
- }
- if (itemPtr->x2 > x2) {
- x2 = itemPtr->x2;
- }
- if (itemPtr->y2 > y2) {
- y2 = itemPtr->y2;
- }
- }
- }
- }
- if (gotAny) {
- sprintf(interp->result, "%d %d %d %d", x1, y1, x2, y2);
- }
- } else if ((c == 'b') && (strncmp(argv[1], "bind", length) == 0)
- && (length >= 2)) {
- ClientData object;
-
- if ((argc < 3) || (argc > 5)) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " bind tagOrId ?sequence? ?command?\"",
- (char *) NULL);
- goto error;
- }
-
- /*
- * Figure out what object to use for the binding (individual
- * item vs. tag).
- */
-
- object = 0;
- if (isdigit(UCHAR(argv[2][0]))) {
- int id;
- char *end;
-
- id = strtoul(argv[2], &end, 0);
- if (*end != 0) {
- goto bindByTag;
- }
- for (itemPtr = canvasPtr->firstItemPtr; itemPtr != NULL;
- itemPtr = itemPtr->nextPtr) {
- if (itemPtr->id == id) {
- object = (ClientData) itemPtr;
- break;
- }
- }
- if (object == 0) {
- Tcl_AppendResult(interp, "item \"", argv[2],
- "\" doesn't exist", (char *) NULL);
- goto error;
- }
- } else {
- bindByTag:
- object = (ClientData) Tk_GetUid(argv[2]);
- }
-
- /*
- * Make a binding table if the canvas doesn't already have
- * one.
- */
-
- if (canvasPtr->bindingTable == NULL) {
- canvasPtr->bindingTable = Tk_CreateBindingTable(interp);
- }
-
- if (argc == 5) {
- int append = 0;
- unsigned long mask;
-
- if (argv[4][0] == 0) {
- result = Tk_DeleteBinding(interp, canvasPtr->bindingTable,
- object, argv[3]);
- goto done;
- }
- if (argv[4][0] == '+') {
- argv[4]++;
- append = 1;
- }
- mask = Tk_CreateBinding(interp, canvasPtr->bindingTable,
- object, argv[3], argv[4], append);
- if (mask == 0) {
- goto error;
- }
- if (mask & (unsigned) ~(ButtonMotionMask|Button1MotionMask
- |Button2MotionMask|Button3MotionMask|Button4MotionMask
- |Button5MotionMask|ButtonPressMask|ButtonReleaseMask
- |EnterWindowMask|LeaveWindowMask|KeyPressMask
- |KeyReleaseMask|PointerMotionMask|VirtualEventMask)) {
- Tk_DeleteBinding(interp, canvasPtr->bindingTable,
- object, argv[3]);
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "requested illegal events; ",
- "only key, button, motion, enter, leave, and virtual ",
- "events may be used", (char *) NULL);
- goto error;
- }
- } else if (argc == 4) {
- char *command;
-
- command = Tk_GetBinding(interp, canvasPtr->bindingTable,
- object, argv[3]);
- if (command == NULL) {
- goto error;
- }
- interp->result = command;
- } else {
- Tk_GetAllBindings(interp, canvasPtr->bindingTable, object);
- }
- } else if ((c == 'c') && (strcmp(argv[1], "canvasx") == 0)) {
- int x;
- double grid;
-
- if ((argc < 3) || (argc > 4)) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " canvasx screenx ?gridspacing?\"",
- (char *) NULL);
- goto error;
- }
- if (Tk_GetPixels(interp, canvasPtr->tkwin, argv[2], &x) != TCL_OK) {
- goto error;
- }
- if (argc == 4) {
- if (Tk_CanvasGetCoord(interp, (Tk_Canvas) canvasPtr, argv[3],
- &grid) != TCL_OK) {
- goto error;
- }
- } else {
- grid = 0.0;
- }
- x += canvasPtr->xOrigin;
- Tcl_PrintDouble(interp, GridAlign((double) x, grid), interp->result);
- } else if ((c == 'c') && (strcmp(argv[1], "canvasy") == 0)) {
- int y;
- double grid;
-
- if ((argc < 3) || (argc > 4)) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " canvasy screeny ?gridspacing?\"",
- (char *) NULL);
- goto error;
- }
- if (Tk_GetPixels(interp, canvasPtr->tkwin, argv[2], &y) != TCL_OK) {
- goto error;
- }
- if (argc == 4) {
- if (Tk_CanvasGetCoord(interp, (Tk_Canvas) canvasPtr,
- argv[3], &grid) != TCL_OK) {
- goto error;
- }
- } else {
- grid = 0.0;
- }
- y += canvasPtr->yOrigin;
- Tcl_PrintDouble(interp, GridAlign((double) y, grid), interp->result);
- } else 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);
- goto error;
- }
- result = Tk_ConfigureValue(interp, canvasPtr->tkwin, configSpecs,
- (char *) canvasPtr, argv[2], 0);
- } else if ((c == 'c') && (strncmp(argv[1], "configure", length) == 0)
- && (length >= 3)) {
- if (argc == 2) {
- result = Tk_ConfigureInfo(interp, canvasPtr->tkwin, configSpecs,
- (char *) canvasPtr, (char *) NULL, 0);
- } else if (argc == 3) {
- result = Tk_ConfigureInfo(interp, canvasPtr->tkwin, configSpecs,
- (char *) canvasPtr, argv[2], 0);
- } else {
- result = ConfigureCanvas(interp, canvasPtr, argc-2, argv+2,
- TK_CONFIG_ARGV_ONLY);
- }
- } else if ((c == 'c') && (strncmp(argv[1], "coords", length) == 0)
- && (length >= 3)) {
- if (argc < 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " coords tagOrId ?x y x y ...?\"",
- (char *) NULL);
- goto error;
- }
- itemPtr = StartTagSearch(canvasPtr, argv[2], &search);
- if (itemPtr != NULL) {
- if (argc != 3) {
- Tk_CanvasEventuallyRedraw((Tk_Canvas) canvasPtr,
- itemPtr->x1, itemPtr->y1, itemPtr->x2, itemPtr->y2);
- }
- if (itemPtr->typePtr->coordProc != NULL) {
- result = (*itemPtr->typePtr->coordProc)(interp,
- (Tk_Canvas) canvasPtr, itemPtr, argc-3, argv+3);
- }
- if (argc != 3) {
- Tk_CanvasEventuallyRedraw((Tk_Canvas) canvasPtr,
- itemPtr->x1, itemPtr->y1, itemPtr->x2, itemPtr->y2);
- }
- }
- } else if ((c == 'c') && (strncmp(argv[1], "create", length) == 0)
- && (length >= 2)) {
- Tk_ItemType *typePtr;
- Tk_ItemType *matchPtr = NULL;
- Tk_Item *itemPtr;
-
- if (argc < 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " create type ?arg arg ...?\"", (char *) NULL);
- goto error;
- }
- c = argv[2][0];
- length = strlen(argv[2]);
- for (typePtr = typeList; typePtr != NULL; typePtr = typePtr->nextPtr) {
- if ((c == typePtr->name[0])
- && (strncmp(argv[2], typePtr->name, length) == 0)) {
- if (matchPtr != NULL) {
- badType:
- Tcl_AppendResult(interp,
- "unknown or ambiguous item type \"",
- argv[2], "\"", (char *) NULL);
- goto error;
- }
- matchPtr = typePtr;
- }
- }
- if (matchPtr == NULL) {
- goto badType;
- }
- typePtr = matchPtr;
- itemPtr = (Tk_Item *) ckalloc((unsigned) typePtr->itemSize);
- itemPtr->id = canvasPtr->nextId;
- canvasPtr->nextId++;
- itemPtr->tagPtr = itemPtr->staticTagSpace;
- itemPtr->tagSpace = TK_TAG_SPACE;
- itemPtr->numTags = 0;
- itemPtr->typePtr = typePtr;
- if ((*typePtr->createProc)(interp, (Tk_Canvas) canvasPtr,
- itemPtr, argc-3, argv+3) != TCL_OK) {
- ckfree((char *) itemPtr);
- goto error;
- }
- itemPtr->nextPtr = NULL;
- canvasPtr->hotPtr = itemPtr;
- canvasPtr->hotPrevPtr = canvasPtr->lastItemPtr;
- if (canvasPtr->lastItemPtr == NULL) {
- canvasPtr->firstItemPtr = itemPtr;
- } else {
- canvasPtr->lastItemPtr->nextPtr = itemPtr;
- }
- canvasPtr->lastItemPtr = itemPtr;
- Tk_CanvasEventuallyRedraw((Tk_Canvas) canvasPtr,
- itemPtr->x1, itemPtr->y1, itemPtr->x2, itemPtr->y2);
- canvasPtr->flags |= REPICK_NEEDED;
- sprintf(interp->result, "%d", itemPtr->id);
- } else if ((c == 'd') && (strncmp(argv[1], "dchars", length) == 0)
- && (length >= 2)) {
- int first, last;
-
- if ((argc != 4) && (argc != 5)) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " dchars tagOrId first ?last?\"",
- (char *) NULL);
- goto error;
- }
- for (itemPtr = StartTagSearch(canvasPtr, argv[2], &search);
- itemPtr != NULL; itemPtr = NextItem(&search)) {
- if ((itemPtr->typePtr->indexProc == NULL)
- || (itemPtr->typePtr->dCharsProc == NULL)) {
- continue;
- }
- if ((*itemPtr->typePtr->indexProc)(interp, (Tk_Canvas) canvasPtr,
- itemPtr, argv[3], &first) != TCL_OK) {
- goto error;
- }
- if (argc == 5) {
- if ((*itemPtr->typePtr->indexProc)(interp,
- (Tk_Canvas) canvasPtr, itemPtr, argv[4], &last)
- != TCL_OK) {
- goto error;
- }
- } else {
- last = first;
- }
-
- /*
- * Redraw both item's old and new areas: it's possible
- * that a delete could result in a new area larger than
- * the old area.
- */
-
- Tk_CanvasEventuallyRedraw((Tk_Canvas) canvasPtr,
- itemPtr->x1, itemPtr->y1, itemPtr->x2, itemPtr->y2);
- (*itemPtr->typePtr->dCharsProc)((Tk_Canvas) canvasPtr,
- itemPtr, first, last);
- Tk_CanvasEventuallyRedraw((Tk_Canvas) canvasPtr,
- itemPtr->x1, itemPtr->y1, itemPtr->x2, itemPtr->y2);
- }
- } else if ((c == 'd') && (strncmp(argv[1], "delete", length) == 0)
- && (length >= 2)) {
- int i;
-
- for (i = 2; i < argc; i++) {
- for (itemPtr = StartTagSearch(canvasPtr, argv[i], &search);
- itemPtr != NULL; itemPtr = NextItem(&search)) {
- Tk_CanvasEventuallyRedraw((Tk_Canvas) canvasPtr,
- itemPtr->x1, itemPtr->y1, itemPtr->x2, itemPtr->y2);
- if (canvasPtr->bindingTable != NULL) {
- Tk_DeleteAllBindings(canvasPtr->bindingTable,
- (ClientData) itemPtr);
- }
- (*itemPtr->typePtr->deleteProc)((Tk_Canvas) canvasPtr, itemPtr,
- canvasPtr->display);
- if (itemPtr->tagPtr != itemPtr->staticTagSpace) {
- ckfree((char *) itemPtr->tagPtr);
- }
- if (search.prevPtr == NULL) {
- canvasPtr->firstItemPtr = itemPtr->nextPtr;
- if (canvasPtr->firstItemPtr == NULL) {
- canvasPtr->lastItemPtr = NULL;
- }
- } else {
- search.prevPtr->nextPtr = itemPtr->nextPtr;
- }
- if (canvasPtr->lastItemPtr == itemPtr) {
- canvasPtr->lastItemPtr = search.prevPtr;
- }
- ckfree((char *) itemPtr);
- if (itemPtr == canvasPtr->currentItemPtr) {
- canvasPtr->currentItemPtr = NULL;
- canvasPtr->flags |= REPICK_NEEDED;
- }
- if (itemPtr == canvasPtr->newCurrentPtr) {
- canvasPtr->newCurrentPtr = NULL;
- canvasPtr->flags |= REPICK_NEEDED;
- }
- if (itemPtr == canvasPtr->textInfo.focusItemPtr) {
- canvasPtr->textInfo.focusItemPtr = NULL;
- }
- if (itemPtr == canvasPtr->textInfo.selItemPtr) {
- canvasPtr->textInfo.selItemPtr = NULL;
- }
- if ((itemPtr == canvasPtr->hotPtr)
- || (itemPtr == canvasPtr->hotPrevPtr)) {
- canvasPtr->hotPtr = NULL;
- }
- }
- }
- } else if ((c == 'd') && (strncmp(argv[1], "dtag", length) == 0)
- && (length >= 2)) {
- Tk_Uid tag;
- int i;
-
- if ((argc != 3) && (argc != 4)) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " dtag tagOrId ?tagToDelete?\"",
- (char *) NULL);
- goto error;
- }
- if (argc == 4) {
- tag = Tk_GetUid(argv[3]);
- } else {
- tag = Tk_GetUid(argv[2]);
- }
- for (itemPtr = StartTagSearch(canvasPtr, argv[2], &search);
- itemPtr != NULL; itemPtr = NextItem(&search)) {
- for (i = itemPtr->numTags-1; i >= 0; i--) {
- if (itemPtr->tagPtr[i] == tag) {
- itemPtr->tagPtr[i] = itemPtr->tagPtr[itemPtr->numTags-1];
- itemPtr->numTags--;
- }
- }
- }
- } else if ((c == 'f') && (strncmp(argv[1], "find", length) == 0)
- && (length >= 2)) {
- if (argc < 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " find searchCommand ?arg arg ...?\"",
- (char *) NULL);
- goto error;
- }
- result = FindItems(interp, canvasPtr, argc-2, argv+2, (char *) NULL,
- argv[0]," find");
- } else if ((c == 'f') && (strncmp(argv[1], "focus", length) == 0)
- && (length >= 2)) {
- if (argc > 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " focus ?tagOrId?\"",
- (char *) NULL);
- goto error;
- }
- itemPtr = canvasPtr->textInfo.focusItemPtr;
- if (argc == 2) {
- if (itemPtr != NULL) {
- sprintf(interp->result, "%d", itemPtr->id);
- }
- goto done;
- }
- if ((itemPtr != NULL) && (canvasPtr->textInfo.gotFocus)) {
- Tk_CanvasEventuallyRedraw((Tk_Canvas) canvasPtr,
- itemPtr->x1, itemPtr->y1, itemPtr->x2, itemPtr->y2);
- }
- if (argv[2][0] == 0) {
- canvasPtr->textInfo.focusItemPtr = NULL;
- goto done;
- }
- for (itemPtr = StartTagSearch(canvasPtr, argv[2], &search);
- itemPtr != NULL; itemPtr = NextItem(&search)) {
- if (itemPtr->typePtr->icursorProc != NULL) {
- break;
- }
- }
- if (itemPtr == NULL) {
- goto done;
- }
- canvasPtr->textInfo.focusItemPtr = itemPtr;
- if (canvasPtr->textInfo.gotFocus) {
- Tk_CanvasEventuallyRedraw((Tk_Canvas) canvasPtr,
- itemPtr->x1, itemPtr->y1, itemPtr->x2, itemPtr->y2);
- }
- } else if ((c == 'g') && (strncmp(argv[1], "gettags", length) == 0)) {
- if (argc != 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " gettags tagOrId\"", (char *) NULL);
- goto error;
- }
- itemPtr = StartTagSearch(canvasPtr, argv[2], &search);
- if (itemPtr != NULL) {
- int i;
- for (i = 0; i < itemPtr->numTags; i++) {
- Tcl_AppendElement(interp, (char *) itemPtr->tagPtr[i]);
- }
- }
- } else if ((c == 'i') && (strncmp(argv[1], "icursor", length) == 0)
- && (length >= 2)) {
- int index;
-
- if (argc != 4) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " icursor tagOrId index\"",
- (char *) NULL);
- goto error;
- }
- for (itemPtr = StartTagSearch(canvasPtr, argv[2], &search);
- itemPtr != NULL; itemPtr = NextItem(&search)) {
- if ((itemPtr->typePtr->indexProc == NULL)
- || (itemPtr->typePtr->icursorProc == NULL)) {
- goto done;
- }
- if ((*itemPtr->typePtr->indexProc)(interp, (Tk_Canvas) canvasPtr,
- itemPtr, argv[3], &index) != TCL_OK) {
- goto error;
- }
- (*itemPtr->typePtr->icursorProc)((Tk_Canvas) canvasPtr, itemPtr,
- index);
- if ((itemPtr == canvasPtr->textInfo.focusItemPtr)
- && (canvasPtr->textInfo.cursorOn)) {
- Tk_CanvasEventuallyRedraw((Tk_Canvas) canvasPtr,
- itemPtr->x1, itemPtr->y1, itemPtr->x2, itemPtr->y2);
- }
- }
- } else if ((c == 'i') && (strncmp(argv[1], "index", length) == 0)
- && (length >= 3)) {
- int index;
-
- if (argc != 4) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " index tagOrId string\"",
- (char *) NULL);
- goto error;
- }
- for (itemPtr = StartTagSearch(canvasPtr, argv[2], &search);
- itemPtr != NULL; itemPtr = NextItem(&search)) {
- if (itemPtr->typePtr->indexProc != NULL) {
- break;
- }
- }
- if (itemPtr == NULL) {
- Tcl_AppendResult(interp, "can't find an indexable item \"",
- argv[2], "\"", (char *) NULL);
- goto error;
- }
- if ((*itemPtr->typePtr->indexProc)(interp, (Tk_Canvas) canvasPtr,
- itemPtr, argv[3], &index) != TCL_OK) {
- goto error;
- }
- sprintf(interp->result, "%d", index);
- } else if ((c == 'i') && (strncmp(argv[1], "insert", length) == 0)
- && (length >= 3)) {
- int beforeThis;
-
- if (argc != 5) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " insert tagOrId beforeThis string\"",
- (char *) NULL);
- goto error;
- }
- for (itemPtr = StartTagSearch(canvasPtr, argv[2], &search);
- itemPtr != NULL; itemPtr = NextItem(&search)) {
- if ((itemPtr->typePtr->indexProc == NULL)
- || (itemPtr->typePtr->insertProc == NULL)) {
- continue;
- }
- if ((*itemPtr->typePtr->indexProc)(interp, (Tk_Canvas) canvasPtr,
- itemPtr, argv[3], &beforeThis) != TCL_OK) {
- goto error;
- }
-
- /*
- * Redraw both item's old and new areas: it's possible
- * that an insertion could result in a new area either
- * larger or smaller than the old area.
- */
-
- Tk_CanvasEventuallyRedraw((Tk_Canvas) canvasPtr,
- itemPtr->x1, itemPtr->y1, itemPtr->x2, itemPtr->y2);
- (*itemPtr->typePtr->insertProc)((Tk_Canvas) canvasPtr,
- itemPtr, beforeThis, argv[4]);
- Tk_CanvasEventuallyRedraw((Tk_Canvas) canvasPtr, itemPtr->x1,
- itemPtr->y1, itemPtr->x2, itemPtr->y2);
- }
- } else if ((c == 'i') && (strncmp(argv[1], "itemcget", length) == 0)
- && (length >= 6)) {
- if (argc != 4) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " itemcget tagOrId option\"",
- (char *) NULL);
- return TCL_ERROR;
- }
- itemPtr = StartTagSearch(canvasPtr, argv[2], &search);
- if (itemPtr != NULL) {
- result = Tk_ConfigureValue(canvasPtr->interp, canvasPtr->tkwin,
- itemPtr->typePtr->configSpecs, (char *) itemPtr,
- argv[3], 0);
- }
- } else if ((c == 'i') && (strncmp(argv[1], "itemconfigure", length) == 0)
- && (length >= 6)) {
- if (argc < 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " itemconfigure tagOrId ?option value ...?\"",
- (char *) NULL);
- goto error;
- }
- for (itemPtr = StartTagSearch(canvasPtr, argv[2], &search);
- itemPtr != NULL; itemPtr = NextItem(&search)) {
- if (argc == 3) {
- result = Tk_ConfigureInfo(canvasPtr->interp, canvasPtr->tkwin,
- itemPtr->typePtr->configSpecs, (char *) itemPtr,
- (char *) NULL, 0);
- } else if (argc == 4) {
- result = Tk_ConfigureInfo(canvasPtr->interp, canvasPtr->tkwin,
- itemPtr->typePtr->configSpecs, (char *) itemPtr,
- argv[3], 0);
- } else {
- Tk_CanvasEventuallyRedraw((Tk_Canvas) canvasPtr,
- itemPtr->x1, itemPtr->y1, itemPtr->x2, itemPtr->y2);
- result = (*itemPtr->typePtr->configProc)(interp,
- (Tk_Canvas) canvasPtr, itemPtr, argc-3, argv+3,
- TK_CONFIG_ARGV_ONLY);
- Tk_CanvasEventuallyRedraw((Tk_Canvas) canvasPtr,
- itemPtr->x1, itemPtr->y1, itemPtr->x2, itemPtr->y2);
- canvasPtr->flags |= REPICK_NEEDED;
- }
- if ((result != TCL_OK) || (argc < 5)) {
- break;
- }
- }
- } else if ((c == 'l') && (strncmp(argv[1], "lower", length) == 0)) {
- Tk_Item *prevPtr;
-
- if ((argc != 3) && (argc != 4)) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " lower tagOrId ?belowThis?\"",
- (char *) NULL);
- goto error;
- }
-
- /*
- * First find the item just after which we'll insert the
- * named items.
- */
-
- if (argc == 3) {
- prevPtr = NULL;
- } else {
- prevPtr = StartTagSearch(canvasPtr, argv[3], &search);
- if (prevPtr != NULL) {
- prevPtr = search.prevPtr;
- } else {
- Tcl_AppendResult(interp, "tag \"", argv[3],
- "\" doesn't match any items", (char *) NULL);
- goto error;
- }
- }
- RelinkItems(canvasPtr, argv[2], prevPtr);
- } else if ((c == 'm') && (strncmp(argv[1], "move", length) == 0)) {
- double xAmount, yAmount;
-
- if (argc != 5) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " move tagOrId xAmount yAmount\"",
- (char *) NULL);
- goto error;
- }
- if ((Tk_CanvasGetCoord(interp, (Tk_Canvas) canvasPtr, argv[3],
- &xAmount) != TCL_OK) || (Tk_CanvasGetCoord(interp,
- (Tk_Canvas) canvasPtr, argv[4], &yAmount) != TCL_OK)) {
- goto error;
- }
- for (itemPtr = StartTagSearch(canvasPtr, argv[2], &search);
- itemPtr != NULL; itemPtr = NextItem(&search)) {
- Tk_CanvasEventuallyRedraw((Tk_Canvas) canvasPtr,
- itemPtr->x1, itemPtr->y1, itemPtr->x2, itemPtr->y2);
- (void) (*itemPtr->typePtr->translateProc)((Tk_Canvas) canvasPtr,
- itemPtr, xAmount, yAmount);
- Tk_CanvasEventuallyRedraw((Tk_Canvas) canvasPtr,
- itemPtr->x1, itemPtr->y1, itemPtr->x2, itemPtr->y2);
- canvasPtr->flags |= REPICK_NEEDED;
- }
- } else if ((c == 'p') && (strncmp(argv[1], "postscript", length) == 0)) {
- result = TkCanvPostscriptCmd(canvasPtr, interp, argc, argv);
- } else if ((c == 'r') && (strncmp(argv[1], "raise", length) == 0)) {
- Tk_Item *prevPtr;
-
- if ((argc != 3) && (argc != 4)) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " raise tagOrId ?aboveThis?\"",
- (char *) NULL);
- goto error;
- }
-
- /*
- * First find the item just after which we'll insert the
- * named items.
- */
-
- if (argc == 3) {
- prevPtr = canvasPtr->lastItemPtr;
- } else {
- prevPtr = NULL;
- for (itemPtr = StartTagSearch(canvasPtr, argv[3], &search);
- itemPtr != NULL; itemPtr = NextItem(&search)) {
- prevPtr = itemPtr;
- }
- if (prevPtr == NULL) {
- Tcl_AppendResult(interp, "tagOrId \"", argv[3],
- "\" doesn't match any items", (char *) NULL);
- goto error;
- }
- }
- RelinkItems(canvasPtr, argv[2], prevPtr);
- } else if ((c == 's') && (strncmp(argv[1], "scale", length) == 0)
- && (length >= 3)) {
- double xOrigin, yOrigin, xScale, yScale;
-
- if (argc != 7) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " scale tagOrId xOrigin yOrigin xScale yScale\"",
- (char *) NULL);
- goto error;
- }
- if ((Tk_CanvasGetCoord(interp, (Tk_Canvas) canvasPtr,
- argv[3], &xOrigin) != TCL_OK)
- || (Tk_CanvasGetCoord(interp, (Tk_Canvas) canvasPtr,
- argv[4], &yOrigin) != TCL_OK)
- || (Tcl_GetDouble(interp, argv[5], &xScale) != TCL_OK)
- || (Tcl_GetDouble(interp, argv[6], &yScale) != TCL_OK)) {
- goto error;
- }
- if ((xScale == 0.0) || (yScale == 0.0)) {
- interp->result = "scale factor cannot be zero";
- goto error;
- }
- for (itemPtr = StartTagSearch(canvasPtr, argv[2], &search);
- itemPtr != NULL; itemPtr = NextItem(&search)) {
- Tk_CanvasEventuallyRedraw((Tk_Canvas) canvasPtr,
- itemPtr->x1, itemPtr->y1, itemPtr->x2, itemPtr->y2);
- (void) (*itemPtr->typePtr->scaleProc)((Tk_Canvas) canvasPtr,
- itemPtr, xOrigin, yOrigin, xScale, yScale);
- Tk_CanvasEventuallyRedraw((Tk_Canvas) canvasPtr,
- itemPtr->x1, itemPtr->y1, itemPtr->x2, itemPtr->y2);
- canvasPtr->flags |= REPICK_NEEDED;
- }
- } else if ((c == 's') && (strncmp(argv[1], "scan", length) == 0)
- && (length >= 3)) {
- int x, y;
-
- if (argc != 5) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " scan mark|dragto x y\"", (char *) NULL);
- goto error;
- }
- if ((Tcl_GetInt(interp, argv[3], &x) != TCL_OK)
- || (Tcl_GetInt(interp, argv[4], &y) != TCL_OK)){
- goto error;
- }
- if ((argv[2][0] == 'm')
- && (strncmp(argv[2], "mark", strlen(argv[2])) == 0)) {
- canvasPtr->scanX = x;
- canvasPtr->scanXOrigin = canvasPtr->xOrigin;
- canvasPtr->scanY = y;
- canvasPtr->scanYOrigin = canvasPtr->yOrigin;
- } else if ((argv[2][0] == 'd')
- && (strncmp(argv[2], "dragto", strlen(argv[2])) == 0)) {
- int newXOrigin, newYOrigin, tmp;
-
- /*
- * Compute a new view origin for the canvas, amplifying the
- * mouse motion.
- */
-
- tmp = canvasPtr->scanXOrigin - 10*(x - canvasPtr->scanX)
- - canvasPtr->scrollX1;
- newXOrigin = canvasPtr->scrollX1 + tmp;
- tmp = canvasPtr->scanYOrigin - 10*(y - canvasPtr->scanY)
- - canvasPtr->scrollY1;
- newYOrigin = canvasPtr->scrollY1 + tmp;
- CanvasSetOrigin(canvasPtr, newXOrigin, newYOrigin);
- } else {
- Tcl_AppendResult(interp, "bad scan option \"", argv[2],
- "\": must be mark or dragto", (char *) NULL);
- goto error;
- }
- } else if ((c == 's') && (strncmp(argv[1], "select", length) == 0)
- && (length >= 2)) {
- int index;
-
- if (argc < 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " select option ?tagOrId? ?arg?\"", (char *) NULL);
- goto error;
- }
- if (argc >= 4) {
- for (itemPtr = StartTagSearch(canvasPtr, argv[3], &search);
- itemPtr != NULL; itemPtr = NextItem(&search)) {
- if ((itemPtr->typePtr->indexProc != NULL)
- && (itemPtr->typePtr->selectionProc != NULL)){
- break;
- }
- }
- if (itemPtr == NULL) {
- Tcl_AppendResult(interp,
- "can't find an indexable and selectable item \"",
- argv[3], "\"", (char *) NULL);
- goto error;
- }
- }
- if (argc == 5) {
- if ((*itemPtr->typePtr->indexProc)(interp, (Tk_Canvas) canvasPtr,
- itemPtr, argv[4], &index) != TCL_OK) {
- goto error;
- }
- }
- length = strlen(argv[2]);
- c = argv[2][0];
- if ((c == 'a') && (strncmp(argv[2], "adjust", length) == 0)) {
- if (argc != 5) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " select adjust tagOrId index\"",
- (char *) NULL);
- goto error;
- }
- if (canvasPtr->textInfo.selItemPtr == itemPtr) {
- if (index < (canvasPtr->textInfo.selectFirst
- + canvasPtr->textInfo.selectLast)/2) {
- canvasPtr->textInfo.selectAnchor =
- canvasPtr->textInfo.selectLast + 1;
- } else {
- canvasPtr->textInfo.selectAnchor =
- canvasPtr->textInfo.selectFirst;
- }
- }
- CanvasSelectTo(canvasPtr, itemPtr, index);
- } else if ((c == 'c') && (argv[2] != NULL)
- && (strncmp(argv[2], "clear", length) == 0)) {
- if (argc != 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " select clear\"", (char *) NULL);
- goto error;
- }
- if (canvasPtr->textInfo.selItemPtr != NULL) {
- Tk_CanvasEventuallyRedraw((Tk_Canvas) canvasPtr,
- canvasPtr->textInfo.selItemPtr->x1,
- canvasPtr->textInfo.selItemPtr->y1,
- canvasPtr->textInfo.selItemPtr->x2,
- canvasPtr->textInfo.selItemPtr->y2);
- canvasPtr->textInfo.selItemPtr = NULL;
- }
- goto done;
- } else if ((c == 'f') && (strncmp(argv[2], "from", length) == 0)) {
- if (argc != 5) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " select from tagOrId index\"",
- (char *) NULL);
- goto error;
- }
- canvasPtr->textInfo.anchorItemPtr = itemPtr;
- canvasPtr->textInfo.selectAnchor = index;
- } else if ((c == 'i') && (strncmp(argv[2], "item", length) == 0)) {
- if (argc != 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " select item\"", (char *) NULL);
- goto error;
- }
- if (canvasPtr->textInfo.selItemPtr != NULL) {
- sprintf(interp->result, "%d",
- canvasPtr->textInfo.selItemPtr->id);
- }
- } else if ((c == 't') && (strncmp(argv[2], "to", length) == 0)) {
- if (argc != 5) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " select to tagOrId index\"",
- (char *) NULL);
- goto error;
- }
- CanvasSelectTo(canvasPtr, itemPtr, index);
- } else {
- Tcl_AppendResult(interp, "bad select option \"", argv[2],
- "\": must be adjust, clear, from, item, or to",
- (char *) NULL);
- goto error;
- }
- } else if ((c == 't') && (strncmp(argv[1], "type", length) == 0)) {
- if (argc != 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " type tag\"", (char *) NULL);
- goto error;
- }
- itemPtr = StartTagSearch(canvasPtr, argv[2], &search);
- if (itemPtr != NULL) {
- interp->result = itemPtr->typePtr->name;
- }
- } else if ((c == 'x') && (strncmp(argv[1], "xview", length) == 0)) {
- int count, type;
- int newX = 0; /* Initialization needed only to prevent
- * gcc warnings. */
- double fraction;
-
- if (argc == 2) {
- PrintScrollFractions(canvasPtr->xOrigin + canvasPtr->inset,
- canvasPtr->xOrigin + Tk_Width(canvasPtr->tkwin)
- - canvasPtr->inset, canvasPtr->scrollX1,
- canvasPtr->scrollX2, interp->result);
- } else {
- type = Tk_GetScrollInfo(interp, argc, argv, &fraction, &count);
- switch (type) {
- case TK_SCROLL_ERROR:
- goto error;
- case TK_SCROLL_MOVETO:
- newX = canvasPtr->scrollX1 - canvasPtr->inset
- + (int) (fraction * (canvasPtr->scrollX2
- - canvasPtr->scrollX1) + 0.5);
- break;
- case TK_SCROLL_PAGES:
- newX = (int) (canvasPtr->xOrigin + count * .9
- * (Tk_Width(canvasPtr->tkwin) - 2*canvasPtr->inset));
- break;
- case TK_SCROLL_UNITS:
- if (canvasPtr->xScrollIncrement > 0) {
- newX = canvasPtr->xOrigin
- + count*canvasPtr->xScrollIncrement;
- } else {
- newX = (int) (canvasPtr->xOrigin + count * .1
- * (Tk_Width(canvasPtr->tkwin)
- - 2*canvasPtr->inset));
- }
- break;
- }
- CanvasSetOrigin(canvasPtr, newX, canvasPtr->yOrigin);
- }
- } else if ((c == 'y') && (strncmp(argv[1], "yview", length) == 0)) {
- int count, type;
- int newY = 0; /* Initialization needed only to prevent
- * gcc warnings. */
- double fraction;
-
- if (argc == 2) {
- PrintScrollFractions(canvasPtr->yOrigin + canvasPtr->inset,
- canvasPtr->yOrigin + Tk_Height(canvasPtr->tkwin)
- - canvasPtr->inset, canvasPtr->scrollY1,
- canvasPtr->scrollY2, interp->result);
- } else {
- type = Tk_GetScrollInfo(interp, argc, argv, &fraction, &count);
- switch (type) {
- case TK_SCROLL_ERROR:
- goto error;
- case TK_SCROLL_MOVETO:
- newY = canvasPtr->scrollY1 - canvasPtr->inset
- + (int) (fraction*(canvasPtr->scrollY2
- - canvasPtr->scrollY1) + 0.5);
- break;
- case TK_SCROLL_PAGES:
- newY = (int) (canvasPtr->yOrigin + count * .9
- * (Tk_Height(canvasPtr->tkwin)
- - 2*canvasPtr->inset));
- break;
- case TK_SCROLL_UNITS:
- if (canvasPtr->yScrollIncrement > 0) {
- newY = canvasPtr->yOrigin
- + count*canvasPtr->yScrollIncrement;
- } else {
- newY = (int) (canvasPtr->yOrigin + count * .1
- * (Tk_Height(canvasPtr->tkwin)
- - 2*canvasPtr->inset));
- }
- break;
- }
- CanvasSetOrigin(canvasPtr, canvasPtr->xOrigin, newY);
- }
- } else {
- Tcl_AppendResult(interp, "bad option \"", argv[1],
- "\": must be addtag, bbox, bind, ",
- "canvasx, canvasy, cget, configure, coords, create, ",
- "dchars, delete, dtag, find, focus, ",
- "gettags, icursor, index, insert, itemcget, itemconfigure, ",
- "lower, move, postscript, raise, scale, scan, ",
- "select, type, xview, or yview",
- (char *) NULL);
- goto error;
- }
- done:
- Tcl_Release((ClientData) canvasPtr);
- return result;
-
- error:
- Tcl_Release((ClientData) canvasPtr);
- return TCL_ERROR;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * DestroyCanvas --
- *
- * This procedure is invoked by Tcl_EventuallyFree or Tcl_Release
- * to clean up the internal structure of a canvas at a safe time
- * (when no-one is using it anymore).
- *
- * Results:
- * None.
- *
- * Side effects:
- * Everything associated with the canvas is freed up.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-DestroyCanvas(memPtr)
- char *memPtr; /* Info about canvas widget. */
-{
- TkCanvas *canvasPtr = (TkCanvas *) memPtr;
- Tk_Item *itemPtr;
-
- /*
- * Free up all of the items in the canvas.
- */
-
- for (itemPtr = canvasPtr->firstItemPtr; itemPtr != NULL;
- itemPtr = canvasPtr->firstItemPtr) {
- canvasPtr->firstItemPtr = itemPtr->nextPtr;
- (*itemPtr->typePtr->deleteProc)((Tk_Canvas) canvasPtr, itemPtr,
- canvasPtr->display);
- if (itemPtr->tagPtr != itemPtr->staticTagSpace) {
- ckfree((char *) itemPtr->tagPtr);
- }
- ckfree((char *) itemPtr);
- }
-
- /*
- * Free up all the stuff that requires special handling,
- * then let Tk_FreeOptions handle all the standard option-related
- * stuff.
- */
-
- if (canvasPtr->pixmapGC != None) {
- Tk_FreeGC(canvasPtr->display, canvasPtr->pixmapGC);
- }
- Tcl_DeleteTimerHandler(canvasPtr->insertBlinkHandler);
- if (canvasPtr->bindingTable != NULL) {
- Tk_DeleteBindingTable(canvasPtr->bindingTable);
- }
- Tk_FreeOptions(configSpecs, (char *) canvasPtr, canvasPtr->display, 0);
- ckfree((char *) canvasPtr);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ConfigureCanvas --
- *
- * This procedure is called to process an argv/argc list, plus
- * the Tk option database, in order to configure (or
- * reconfigure) a canvas widget.
- *
- * Results:
- * The return value is a standard Tcl result. If TCL_ERROR is
- * returned, then interp->result contains an error message.
- *
- * Side effects:
- * Configuration information, such as colors, border width,
- * etc. get set for canvasPtr; old resources get freed,
- * if there were any.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-ConfigureCanvas(interp, canvasPtr, argc, argv, flags)
- Tcl_Interp *interp; /* Used for error reporting. */
- TkCanvas *canvasPtr; /* 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 flags; /* Flags to pass to Tk_ConfigureWidget. */
-{
- XGCValues gcValues;
- GC new;
-
- if (Tk_ConfigureWidget(interp, canvasPtr->tkwin, configSpecs,
- argc, argv, (char *) canvasPtr, flags) != TCL_OK) {
- return TCL_ERROR;
- }
-
- /*
- * A few options need special processing, such as setting the
- * background from a 3-D border and creating a GC for copying
- * bits to the screen.
- */
-
- Tk_SetBackgroundFromBorder(canvasPtr->tkwin, canvasPtr->bgBorder);
-
- if (canvasPtr->highlightWidth < 0) {
- canvasPtr->highlightWidth = 0;
- }
- canvasPtr->inset = canvasPtr->borderWidth + canvasPtr->highlightWidth;
-
- gcValues.function = GXcopy;
- gcValues.foreground = Tk_3DBorderColor(canvasPtr->bgBorder)->pixel;
- gcValues.graphics_exposures = False;
- new = Tk_GetGC(canvasPtr->tkwin,
- GCFunction|GCForeground|GCGraphicsExposures, &gcValues);
- if (canvasPtr->pixmapGC != None) {
- Tk_FreeGC(canvasPtr->display, canvasPtr->pixmapGC);
- }
- canvasPtr->pixmapGC = new;
-
- /*
- * Reset the desired dimensions for the window.
- */
-
- Tk_GeometryRequest(canvasPtr->tkwin, canvasPtr->width + 2*canvasPtr->inset,
- canvasPtr->height + 2*canvasPtr->inset);
-
- /*
- * Restart the cursor timing sequence in case the on-time or off-time
- * just changed.
- */
-
- if (canvasPtr->textInfo.gotFocus) {
- CanvasFocusProc(canvasPtr, 1);
- }
-
- /*
- * Recompute the scroll region.
- */
-
- canvasPtr->scrollX1 = 0;
- canvasPtr->scrollY1 = 0;
- canvasPtr->scrollX2 = 0;
- canvasPtr->scrollY2 = 0;
- if (canvasPtr->regionString != NULL) {
- int argc2;
- char **argv2;
-
- if (Tcl_SplitList(canvasPtr->interp, canvasPtr->regionString,
- &argc2, &argv2) != TCL_OK) {
- return TCL_ERROR;
- }
- if (argc2 != 4) {
- Tcl_AppendResult(interp, "bad scrollRegion \"",
- canvasPtr->regionString, "\"", (char *) NULL);
- badRegion:
- ckfree(canvasPtr->regionString);
- ckfree((char *) argv2);
- canvasPtr->regionString = NULL;
- return TCL_ERROR;
- }
- if ((Tk_GetPixels(canvasPtr->interp, canvasPtr->tkwin,
- argv2[0], &canvasPtr->scrollX1) != TCL_OK)
- || (Tk_GetPixels(canvasPtr->interp, canvasPtr->tkwin,
- argv2[1], &canvasPtr->scrollY1) != TCL_OK)
- || (Tk_GetPixels(canvasPtr->interp, canvasPtr->tkwin,
- argv2[2], &canvasPtr->scrollX2) != TCL_OK)
- || (Tk_GetPixels(canvasPtr->interp, canvasPtr->tkwin,
- argv2[3], &canvasPtr->scrollY2) != TCL_OK)) {
- goto badRegion;
- }
- ckfree((char *) argv2);
- }
-
- /*
- * Reset the canvas's origin (this is a no-op unless confine
- * mode has just been turned on or the scroll region has changed).
- */
-
- CanvasSetOrigin(canvasPtr, canvasPtr->xOrigin, canvasPtr->yOrigin);
- canvasPtr->flags |= UPDATE_SCROLLBARS|REDRAW_BORDERS;
- Tk_CanvasEventuallyRedraw((Tk_Canvas) canvasPtr,
- canvasPtr->xOrigin, canvasPtr->yOrigin,
- canvasPtr->xOrigin + Tk_Width(canvasPtr->tkwin),
- canvasPtr->yOrigin + Tk_Height(canvasPtr->tkwin));
- return TCL_OK;
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * CanvasWorldChanged --
- *
- * 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:
- * Configures all items in the canvas with a empty argc/argv, for
- * the side effect of causing all the items to recompute their
- * geometry and to be redisplayed.
- *
- *---------------------------------------------------------------------------
- */
-
-static void
-CanvasWorldChanged(instanceData)
- ClientData instanceData; /* Information about widget. */
-{
- TkCanvas *canvasPtr;
- Tk_Item *itemPtr;
- int result;
-
- canvasPtr = (TkCanvas *) instanceData;
- itemPtr = canvasPtr->firstItemPtr;
- for ( ; itemPtr != NULL; itemPtr = itemPtr->nextPtr) {
- result = (*itemPtr->typePtr->configProc)(canvasPtr->interp,
- (Tk_Canvas) canvasPtr, itemPtr, 0, NULL,
- TK_CONFIG_ARGV_ONLY);
- if (result != TCL_OK) {
- Tcl_ResetResult(canvasPtr->interp);
- }
- }
- canvasPtr->flags |= REPICK_NEEDED;
- Tk_CanvasEventuallyRedraw((Tk_Canvas) canvasPtr,
- canvasPtr->xOrigin, canvasPtr->yOrigin,
- canvasPtr->xOrigin + Tk_Width(canvasPtr->tkwin),
- canvasPtr->yOrigin + Tk_Height(canvasPtr->tkwin));
-}
-
-/*
- *--------------------------------------------------------------
- *
- * DisplayCanvas --
- *
- * This procedure redraws the contents of a canvas 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
-DisplayCanvas(clientData)
- ClientData clientData; /* Information about widget. */
-{
- TkCanvas *canvasPtr = (TkCanvas *) clientData;
- Tk_Window tkwin = canvasPtr->tkwin;
- Tk_Item *itemPtr;
- Pixmap pixmap;
- int screenX1, screenX2, screenY1, screenY2, width, height;
-
- if (canvasPtr->tkwin == NULL) {
- return;
- }
- if (!Tk_IsMapped(tkwin)) {
- goto done;
- }
-
- /*
- * Choose a new current item if that is needed (this could cause
- * event handlers to be invoked).
- */
-
- while (canvasPtr->flags & REPICK_NEEDED) {
- Tcl_Preserve((ClientData) canvasPtr);
- canvasPtr->flags &= ~REPICK_NEEDED;
- PickCurrentItem(canvasPtr, &canvasPtr->pickEvent);
- tkwin = canvasPtr->tkwin;
- Tcl_Release((ClientData) canvasPtr);
- if (tkwin == NULL) {
- return;
- }
- }
-
- /*
- * Compute the intersection between the area that needs redrawing
- * and the area that's visible on the screen.
- */
-
- if ((canvasPtr->redrawX1 < canvasPtr->redrawX2)
- && (canvasPtr->redrawY1 < canvasPtr->redrawY2)) {
- screenX1 = canvasPtr->xOrigin + canvasPtr->inset;
- screenY1 = canvasPtr->yOrigin + canvasPtr->inset;
- screenX2 = canvasPtr->xOrigin + Tk_Width(tkwin) - canvasPtr->inset;
- screenY2 = canvasPtr->yOrigin + Tk_Height(tkwin) - canvasPtr->inset;
- if (canvasPtr->redrawX1 > screenX1) {
- screenX1 = canvasPtr->redrawX1;
- }
- if (canvasPtr->redrawY1 > screenY1) {
- screenY1 = canvasPtr->redrawY1;
- }
- if (canvasPtr->redrawX2 < screenX2) {
- screenX2 = canvasPtr->redrawX2;
- }
- if (canvasPtr->redrawY2 < screenY2) {
- screenY2 = canvasPtr->redrawY2;
- }
- if ((screenX1 >= screenX2) || (screenY1 >= screenY2)) {
- goto borders;
- }
-
- /*
- * Redrawing is done in a temporary pixmap that is allocated
- * here and freed at the end of the procedure. All drawing
- * is done to the pixmap, and the pixmap is copied to the
- * screen at the end of the procedure. The temporary pixmap
- * serves two purposes:
- *
- * 1. It provides a smoother visual effect (no clearing and
- * gradual redraw will be visible to users).
- * 2. It allows us to redraw only the objects that overlap
- * the redraw area. Otherwise incorrect results could
- * occur from redrawing things that stick outside of
- * the redraw area (we'd have to redraw everything in
- * order to make the overlaps look right).
- *
- * Some tricky points about the pixmap:
- *
- * 1. We only allocate a large enough pixmap to hold the
- * area that has to be redisplayed. This saves time in
- * in the X server for large objects that cover much
- * more than the area being redisplayed: only the area
- * of the pixmap will actually have to be redrawn.
- * 2. Some X servers (e.g. the one for DECstations) have troubles
- * with characters that overlap an edge of the pixmap (on the
- * DEC servers, as of 8/18/92, such characters are drawn one
- * pixel too far to the right). To handle this problem,
- * make the pixmap a bit larger than is absolutely needed
- * so that for normal-sized fonts the characters that overlap
- * the edge of the pixmap will be outside the area we care
- * about.
- */
-
- canvasPtr->drawableXOrigin = screenX1 - 30;
- canvasPtr->drawableYOrigin = screenY1 - 30;
- pixmap = Tk_GetPixmap(Tk_Display(tkwin), Tk_WindowId(tkwin),
- (screenX2 + 30 - canvasPtr->drawableXOrigin),
- (screenY2 + 30 - canvasPtr->drawableYOrigin),
- Tk_Depth(tkwin));
-
- /*
- * Clear the area to be redrawn.
- */
-
- width = screenX2 - screenX1;
- height = screenY2 - screenY1;
-
- XFillRectangle(Tk_Display(tkwin), pixmap, canvasPtr->pixmapGC,
- screenX1 - canvasPtr->drawableXOrigin,
- screenY1 - canvasPtr->drawableYOrigin, (unsigned int) width,
- (unsigned int) height);
-
- /*
- * Scan through the item list, redrawing those items that need it.
- * An item must be redraw if either (a) it intersects the smaller
- * on-screen area or (b) it intersects the full canvas area and its
- * type requests that it be redrawn always (e.g. so subwindows can
- * be unmapped when they move off-screen).
- */
-
- for (itemPtr = canvasPtr->firstItemPtr; itemPtr != NULL;
- itemPtr = itemPtr->nextPtr) {
- if ((itemPtr->x1 >= screenX2)
- || (itemPtr->y1 >= screenY2)
- || (itemPtr->x2 < screenX1)
- || (itemPtr->y2 < screenY1)) {
- if (!itemPtr->typePtr->alwaysRedraw
- || (itemPtr->x1 >= canvasPtr->redrawX2)
- || (itemPtr->y1 >= canvasPtr->redrawY2)
- || (itemPtr->x2 < canvasPtr->redrawX1)
- || (itemPtr->y2 < canvasPtr->redrawY1)) {
- continue;
- }
- }
- (*itemPtr->typePtr->displayProc)((Tk_Canvas) canvasPtr, itemPtr,
- canvasPtr->display, pixmap, screenX1, screenY1, width,
- height);
- }
-
- /*
- * Copy from the temporary pixmap to the screen, then free up
- * the temporary pixmap.
- */
-
- XCopyArea(Tk_Display(tkwin), pixmap, Tk_WindowId(tkwin),
- canvasPtr->pixmapGC,
- screenX1 - canvasPtr->drawableXOrigin,
- screenY1 - canvasPtr->drawableYOrigin,
- (unsigned) (screenX2 - screenX1),
- (unsigned) (screenY2 - screenY1),
- screenX1 - canvasPtr->xOrigin, screenY1 - canvasPtr->yOrigin);
- Tk_FreePixmap(Tk_Display(tkwin), pixmap);
- }
-
- /*
- * Draw the window borders, if needed.
- */
-
- borders:
- if (canvasPtr->flags & REDRAW_BORDERS) {
- canvasPtr->flags &= ~REDRAW_BORDERS;
- if (canvasPtr->borderWidth > 0) {
- Tk_Draw3DRectangle(tkwin, Tk_WindowId(tkwin),
- canvasPtr->bgBorder, canvasPtr->highlightWidth,
- canvasPtr->highlightWidth,
- Tk_Width(tkwin) - 2*canvasPtr->highlightWidth,
- Tk_Height(tkwin) - 2*canvasPtr->highlightWidth,
- canvasPtr->borderWidth, canvasPtr->relief);
- }
- if (canvasPtr->highlightWidth != 0) {
- GC gc;
-
- if (canvasPtr->textInfo.gotFocus) {
- gc = Tk_GCForColor(canvasPtr->highlightColorPtr,
- Tk_WindowId(tkwin));
- } else {
- gc = Tk_GCForColor(canvasPtr->highlightBgColorPtr,
- Tk_WindowId(tkwin));
- }
- Tk_DrawFocusHighlight(tkwin, gc, canvasPtr->highlightWidth,
- Tk_WindowId(tkwin));
- }
- }
-
- done:
- canvasPtr->flags &= ~REDRAW_PENDING;
- canvasPtr->redrawX1 = canvasPtr->redrawX2 = 0;
- canvasPtr->redrawY1 = canvasPtr->redrawY2 = 0;
- if (canvasPtr->flags & UPDATE_SCROLLBARS) {
- CanvasUpdateScrollbars(canvasPtr);
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * CanvasEventProc --
- *
- * This procedure is invoked by the Tk dispatcher for various
- * events on canvases.
- *
- * Results:
- * None.
- *
- * Side effects:
- * When the window gets deleted, internal structures get
- * cleaned up. When it gets exposed, it is redisplayed.
- *
- *--------------------------------------------------------------
- */
-
-static void
-CanvasEventProc(clientData, eventPtr)
- ClientData clientData; /* Information about window. */
- XEvent *eventPtr; /* Information about event. */
-{
- TkCanvas *canvasPtr = (TkCanvas *) clientData;
-
- if (eventPtr->type == Expose) {
- int x, y;
-
- x = eventPtr->xexpose.x + canvasPtr->xOrigin;
- y = eventPtr->xexpose.y + canvasPtr->yOrigin;
- Tk_CanvasEventuallyRedraw((Tk_Canvas) canvasPtr, x, y,
- x + eventPtr->xexpose.width,
- y + eventPtr->xexpose.height);
- if ((eventPtr->xexpose.x < canvasPtr->inset)
- || (eventPtr->xexpose.y < canvasPtr->inset)
- || ((eventPtr->xexpose.x + eventPtr->xexpose.width)
- > (Tk_Width(canvasPtr->tkwin) - canvasPtr->inset))
- || ((eventPtr->xexpose.y + eventPtr->xexpose.height)
- > (Tk_Height(canvasPtr->tkwin) - canvasPtr->inset))) {
- canvasPtr->flags |= REDRAW_BORDERS;
- }
- } else if (eventPtr->type == DestroyNotify) {
- 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, DestroyCanvas);
- } else if (eventPtr->type == ConfigureNotify) {
- canvasPtr->flags |= UPDATE_SCROLLBARS;
-
- /*
- * The call below is needed in order to recenter the canvas if
- * it's confined and its scroll region is smaller than the window.
- */
-
- CanvasSetOrigin(canvasPtr, canvasPtr->xOrigin, canvasPtr->yOrigin);
- Tk_CanvasEventuallyRedraw((Tk_Canvas) canvasPtr, canvasPtr->xOrigin,
- canvasPtr->yOrigin,
- canvasPtr->xOrigin + Tk_Width(canvasPtr->tkwin),
- canvasPtr->yOrigin + Tk_Height(canvasPtr->tkwin));
- canvasPtr->flags |= REDRAW_BORDERS;
- } else if (eventPtr->type == FocusIn) {
- if (eventPtr->xfocus.detail != NotifyInferior) {
- CanvasFocusProc(canvasPtr, 1);
- }
- } else if (eventPtr->type == FocusOut) {
- if (eventPtr->xfocus.detail != NotifyInferior) {
- CanvasFocusProc(canvasPtr, 0);
- }
- } else if (eventPtr->type == UnmapNotify) {
- Tk_Item *itemPtr;
-
- /*
- * Special hack: if the canvas is unmapped, then must notify
- * all items with "alwaysRedraw" set, so that they know that
- * they are no longer displayed.
- */
-
- for (itemPtr = canvasPtr->firstItemPtr; itemPtr != NULL;
- itemPtr = itemPtr->nextPtr) {
- if (itemPtr->typePtr->alwaysRedraw) {
- (*itemPtr->typePtr->displayProc)((Tk_Canvas) canvasPtr,
- itemPtr, canvasPtr->display, None, 0, 0, 0, 0);
- }
- }
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * CanvasCmdDeletedProc --
- *
- * 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
-CanvasCmdDeletedProc(clientData)
- ClientData clientData; /* Pointer to widget record for widget. */
-{
- TkCanvas *canvasPtr = (TkCanvas *) clientData;
- Tk_Window tkwin = canvasPtr->tkwin;
-
- /*
- * This procedure could be invoked either because the window was
- * destroyed and the command was then deleted (in which case tkwin
- * is NULL) or because the command was deleted, and then this procedure
- * destroys the widget.
- */
-
- if (tkwin != NULL) {
- canvasPtr->tkwin = NULL;
- Tk_DestroyWindow(tkwin);
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_CanvasEventuallyRedraw --
- *
- * Arrange for part or all of a canvas widget to redrawn at
- * some convenient time in the future.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The screen will eventually be refreshed.
- *
- *--------------------------------------------------------------
- */
-
-void
-Tk_CanvasEventuallyRedraw(canvas, x1, y1, x2, y2)
- Tk_Canvas canvas; /* Information about widget. */
- int x1, y1; /* Upper left corner of area to redraw.
- * Pixels on edge are redrawn. */
- int x2, y2; /* Lower right corner of area to redraw.
- * Pixels on edge are not redrawn. */
-{
- TkCanvas *canvasPtr = (TkCanvas *) canvas;
- if ((x1 == x2) || (y1 == y2)) {
- return;
- }
- if (canvasPtr->flags & REDRAW_PENDING) {
- if (x1 <= canvasPtr->redrawX1) {
- canvasPtr->redrawX1 = x1;
- }
- if (y1 <= canvasPtr->redrawY1) {
- canvasPtr->redrawY1 = y1;
- }
- if (x2 >= canvasPtr->redrawX2) {
- canvasPtr->redrawX2 = x2;
- }
- if (y2 >= canvasPtr->redrawY2) {
- canvasPtr->redrawY2 = y2;
- }
- } else {
- canvasPtr->redrawX1 = x1;
- canvasPtr->redrawY1 = y1;
- canvasPtr->redrawX2 = x2;
- canvasPtr->redrawY2 = y2;
- Tcl_DoWhenIdle(DisplayCanvas, (ClientData) canvasPtr);
- canvasPtr->flags |= REDRAW_PENDING;
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_CreateItemType --
- *
- * This procedure may be invoked to add a new kind of canvas
- * element to the core item types supported by Tk.
- *
- * Results:
- * None.
- *
- * Side effects:
- * From now on, the new item type will be useable in canvas
- * widgets (e.g. typePtr->name can be used as the item type
- * in "create" widget commands). If there was already a
- * type with the same name as in typePtr, it is replaced with
- * the new type.
- *
- *--------------------------------------------------------------
- */
-
-void
-Tk_CreateItemType(typePtr)
- Tk_ItemType *typePtr; /* Information about item type;
- * storage must be statically
- * allocated (must live forever). */
-{
- Tk_ItemType *typePtr2, *prevPtr;
-
- if (typeList == NULL) {
- InitCanvas();
- }
-
- /*
- * If there's already an item type with the given name, remove it.
- */
-
- for (typePtr2 = typeList, prevPtr = NULL; typePtr2 != NULL;
- prevPtr = typePtr2, typePtr2 = typePtr2->nextPtr) {
- if (strcmp(typePtr2->name, typePtr->name) == 0) {
- if (prevPtr == NULL) {
- typeList = typePtr2->nextPtr;
- } else {
- prevPtr->nextPtr = typePtr2->nextPtr;
- }
- break;
- }
- }
- typePtr->nextPtr = typeList;
- typeList = typePtr;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_GetItemTypes --
- *
- * This procedure returns a pointer to the list of all item
- * types.
- *
- * Results:
- * The return value is a pointer to the first in the list
- * of item types currently supported by canvases.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-Tk_ItemType *
-Tk_GetItemTypes()
-{
- if (typeList == NULL) {
- InitCanvas();
- }
- return typeList;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * InitCanvas --
- *
- * This procedure is invoked to perform once-only-ever
- * initialization for the module, such as setting up
- * the type table.
- *
- * Results:
- * None.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-static void
-InitCanvas()
-{
- if (typeList != NULL) {
- return;
- }
- typeList = &tkRectangleType;
- tkRectangleType.nextPtr = &tkTextType;
- tkTextType.nextPtr = &tkLineType;
- tkLineType.nextPtr = &tkPolygonType;
- tkPolygonType.nextPtr = &tkImageType;
- tkImageType.nextPtr = &tkOvalType;
- tkOvalType.nextPtr = &tkBitmapType;
- tkBitmapType.nextPtr = &tkArcType;
- tkArcType.nextPtr = &tkWindowType;
- tkWindowType.nextPtr = NULL;
- allUid = Tk_GetUid("all");
- currentUid = Tk_GetUid("current");
-}
-
-/*
- *--------------------------------------------------------------
- *
- * StartTagSearch --
- *
- * This procedure is called to initiate an enumeration of
- * all items in a given canvas that contain a given tag.
- *
- * Results:
- * The return value is a pointer to the first item in
- * canvasPtr that matches tag, or NULL if there is no
- * such item. The information at *searchPtr is initialized
- * such that successive calls to NextItem will return
- * successive items that match tag.
- *
- * Side effects:
- * SearchPtr is linked into a list of searches in progress
- * on canvasPtr, so that elements can safely be deleted
- * while the search is in progress. EndTagSearch must be
- * called at the end of the search to unlink searchPtr from
- * this list.
- *
- *--------------------------------------------------------------
- */
-
-static Tk_Item *
-StartTagSearch(canvasPtr, tag, searchPtr)
- TkCanvas *canvasPtr; /* Canvas whose items are to be
- * searched. */
- char *tag; /* String giving tag value. */
- TagSearch *searchPtr; /* Record describing tag search;
- * will be initialized here. */
-{
- int id;
- Tk_Item *itemPtr, *prevPtr;
- Tk_Uid *tagPtr;
- Tk_Uid uid;
- int count;
-
- /*
- * Initialize the search.
- */
-
- searchPtr->canvasPtr = canvasPtr;
- searchPtr->searchOver = 0;
-
- /*
- * Find the first matching item in one of several ways. If the tag
- * is a number then it selects the single item with the matching
- * identifier. In this case see if the item being requested is the
- * hot item, in which case the search can be skipped.
- */
-
- if (isdigit(UCHAR(*tag))) {
- char *end;
-
- numIdSearches++;
- id = strtoul(tag, &end, 0);
- if (*end == 0) {
- itemPtr = canvasPtr->hotPtr;
- prevPtr = canvasPtr->hotPrevPtr;
- if ((itemPtr == NULL) || (itemPtr->id != id) || (prevPtr == NULL)
- || (prevPtr->nextPtr != itemPtr)) {
- numSlowSearches++;
- for (prevPtr = NULL, itemPtr = canvasPtr->firstItemPtr;
- itemPtr != NULL;
- prevPtr = itemPtr, itemPtr = itemPtr->nextPtr) {
- if (itemPtr->id == id) {
- break;
- }
- }
- }
- searchPtr->prevPtr = prevPtr;
- searchPtr->searchOver = 1;
- canvasPtr->hotPtr = itemPtr;
- canvasPtr->hotPrevPtr = prevPtr;
- return itemPtr;
- }
- }
-
- searchPtr->tag = uid = Tk_GetUid(tag);
- if (uid == allUid) {
-
- /*
- * All items match.
- */
-
- searchPtr->tag = NULL;
- searchPtr->prevPtr = NULL;
- searchPtr->currentPtr = canvasPtr->firstItemPtr;
- return canvasPtr->firstItemPtr;
- }
-
- /*
- * None of the above. Search for an item with a matching tag.
- */
-
- for (prevPtr = NULL, itemPtr = canvasPtr->firstItemPtr; itemPtr != NULL;
- prevPtr = itemPtr, itemPtr = itemPtr->nextPtr) {
- for (tagPtr = itemPtr->tagPtr, count = itemPtr->numTags;
- count > 0; tagPtr++, count--) {
- if (*tagPtr == uid) {
- searchPtr->prevPtr = prevPtr;
- searchPtr->currentPtr = itemPtr;
- return itemPtr;
- }
- }
- }
- searchPtr->prevPtr = prevPtr;
- searchPtr->searchOver = 1;
- return NULL;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * NextItem --
- *
- * This procedure returns successive items that match a given
- * tag; it should be called only after StartTagSearch has been
- * used to begin a search.
- *
- * Results:
- * The return value is a pointer to the next item that matches
- * the tag specified to StartTagSearch, or NULL if no such
- * item exists. *SearchPtr is updated so that the next call
- * to this procedure will return the next item.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-static Tk_Item *
-NextItem(searchPtr)
- TagSearch *searchPtr; /* Record describing search in
- * progress. */
-{
- Tk_Item *itemPtr, *prevPtr;
- int count;
- Tk_Uid uid;
- Tk_Uid *tagPtr;
-
- /*
- * Find next item in list (this may not actually be a suitable
- * one to return), and return if there are no items left.
- */
-
- prevPtr = searchPtr->prevPtr;
- if (prevPtr == NULL) {
- itemPtr = searchPtr->canvasPtr->firstItemPtr;
- } else {
- itemPtr = prevPtr->nextPtr;
- }
- if ((itemPtr == NULL) || (searchPtr->searchOver)) {
- searchPtr->searchOver = 1;
- return NULL;
- }
- if (itemPtr != searchPtr->currentPtr) {
- /*
- * The structure of the list has changed. Probably the
- * previously-returned item was removed from the list.
- * In this case, don't advance prevPtr; just return
- * its new successor (i.e. do nothing here).
- */
- } else {
- prevPtr = itemPtr;
- itemPtr = prevPtr->nextPtr;
- }
-
- /*
- * Handle special case of "all" search by returning next item.
- */
-
- uid = searchPtr->tag;
- if (uid == NULL) {
- searchPtr->prevPtr = prevPtr;
- searchPtr->currentPtr = itemPtr;
- return itemPtr;
- }
-
- /*
- * Look for an item with a particular tag.
- */
-
- for ( ; itemPtr != NULL; prevPtr = itemPtr, itemPtr = itemPtr->nextPtr) {
- for (tagPtr = itemPtr->tagPtr, count = itemPtr->numTags;
- count > 0; tagPtr++, count--) {
- if (*tagPtr == uid) {
- searchPtr->prevPtr = prevPtr;
- searchPtr->currentPtr = itemPtr;
- return itemPtr;
- }
- }
- }
- searchPtr->prevPtr = prevPtr;
- searchPtr->searchOver = 1;
- return NULL;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * DoItem --
- *
- * This is a utility procedure called by FindItems. It
- * either adds itemPtr's id to the result forming in interp,
- * or it adds a new tag to itemPtr, depending on the value
- * of tag.
- *
- * Results:
- * None.
- *
- * Side effects:
- * If tag is NULL then itemPtr's id is added as a list element
- * to interp->result; otherwise tag is added to itemPtr's
- * list of tags.
- *
- *--------------------------------------------------------------
- */
-
-static void
-DoItem(interp, itemPtr, tag)
- Tcl_Interp *interp; /* Interpreter in which to (possibly)
- * record item id. */
- Tk_Item *itemPtr; /* Item to (possibly) modify. */
- Tk_Uid tag; /* Tag to add to those already
- * present for item, or NULL. */
-{
- Tk_Uid *tagPtr;
- int count;
-
- /*
- * Handle the "add-to-result" case and return, if appropriate.
- */
-
- if (tag == NULL) {
- char msg[30];
- sprintf(msg, "%d", itemPtr->id);
- Tcl_AppendElement(interp, msg);
- return;
- }
-
- for (tagPtr = itemPtr->tagPtr, count = itemPtr->numTags;
- count > 0; tagPtr++, count--) {
- if (tag == *tagPtr) {
- return;
- }
- }
-
- /*
- * Grow the tag space if there's no more room left in the current
- * block.
- */
-
- if (itemPtr->tagSpace == itemPtr->numTags) {
- Tk_Uid *newTagPtr;
-
- itemPtr->tagSpace += 5;
- newTagPtr = (Tk_Uid *) ckalloc((unsigned)
- (itemPtr->tagSpace * sizeof(Tk_Uid)));
- memcpy((VOID *) newTagPtr, (VOID *) itemPtr->tagPtr,
- (itemPtr->numTags * sizeof(Tk_Uid)));
- if (itemPtr->tagPtr != itemPtr->staticTagSpace) {
- ckfree((char *) itemPtr->tagPtr);
- }
- itemPtr->tagPtr = newTagPtr;
- tagPtr = &itemPtr->tagPtr[itemPtr->numTags];
- }
-
- /*
- * Add in the new tag.
- */
-
- *tagPtr = tag;
- itemPtr->numTags++;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * FindItems --
- *
- * This procedure does all the work of implementing the
- * "find" and "addtag" options of the canvas widget command,
- * which locate items that have certain features (location,
- * tags, position in display list, etc.).
- *
- * Results:
- * A standard Tcl return value. If newTag is NULL, then a
- * list of ids from all the items that match argc/argv is
- * returned in interp->result. If newTag is NULL, then
- * the normal interp->result is an empty string. If an error
- * occurs, then interp->result will hold an error message.
- *
- * Side effects:
- * If newTag is non-NULL, then all the items that match the
- * information in argc/argv have that tag added to their
- * lists of tags.
- *
- *--------------------------------------------------------------
- */
-
-static int
-FindItems(interp, canvasPtr, argc, argv, newTag, cmdName, option)
- Tcl_Interp *interp; /* Interpreter for error reporting. */
- TkCanvas *canvasPtr; /* Canvas whose items are to be
- * searched. */
- int argc; /* Number of entries in argv. Must be
- * greater than zero. */
- char **argv; /* Arguments that describe what items
- * to search for (see user doc on
- * "find" and "addtag" options). */
- char *newTag; /* If non-NULL, gives new tag to set
- * on all found items; if NULL, then
- * ids of found items are returned
- * in interp->result. */
- char *cmdName; /* Name of original Tcl command, for
- * use in error messages. */
- char *option; /* For error messages: gives option
- * from Tcl command and other stuff
- * up to what's in argc/argv. */
-{
- int c;
- size_t length;
- TagSearch search;
- Tk_Item *itemPtr;
- Tk_Uid uid;
-
- if (newTag != NULL) {
- uid = Tk_GetUid(newTag);
- } else {
- uid = NULL;
- }
- c = argv[0][0];
- length = strlen(argv[0]);
- if ((c == 'a') && (strncmp(argv[0], "above", length) == 0)
- && (length >= 2)) {
- Tk_Item *lastPtr = NULL;
- if (argc != 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- cmdName, option, " above tagOrId", (char *) NULL);
- return TCL_ERROR;
- }
- for (itemPtr = StartTagSearch(canvasPtr, argv[1], &search);
- itemPtr != NULL; itemPtr = NextItem(&search)) {
- lastPtr = itemPtr;
- }
- if ((lastPtr != NULL) && (lastPtr->nextPtr != NULL)) {
- DoItem(interp, lastPtr->nextPtr, uid);
- }
- } else if ((c == 'a') && (strncmp(argv[0], "all", length) == 0)
- && (length >= 2)) {
- if (argc != 1) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- cmdName, option, " all", (char *) NULL);
- return TCL_ERROR;
- }
-
- for (itemPtr = canvasPtr->firstItemPtr; itemPtr != NULL;
- itemPtr = itemPtr->nextPtr) {
- DoItem(interp, itemPtr, uid);
- }
- } else if ((c == 'b') && (strncmp(argv[0], "below", length) == 0)) {
- if (argc != 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- cmdName, option, " below tagOrId", (char *) NULL);
- return TCL_ERROR;
- }
- (void) StartTagSearch(canvasPtr, argv[1], &search);
- if (search.prevPtr != NULL) {
- DoItem(interp, search.prevPtr, uid);
- }
- } else if ((c == 'c') && (strncmp(argv[0], "closest", length) == 0)) {
- double closestDist;
- Tk_Item *startPtr, *closestPtr;
- double coords[2], halo;
- int x1, y1, x2, y2;
-
- if ((argc < 3) || (argc > 5)) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- cmdName, option, " closest x y ?halo? ?start?",
- (char *) NULL);
- return TCL_ERROR;
- }
- if ((Tk_CanvasGetCoord(interp, (Tk_Canvas) canvasPtr, argv[1],
- &coords[0]) != TCL_OK) || (Tk_CanvasGetCoord(interp,
- (Tk_Canvas) canvasPtr, argv[2], &coords[1]) != TCL_OK)) {
- return TCL_ERROR;
- }
- if (argc > 3) {
- if (Tk_CanvasGetCoord(interp, (Tk_Canvas) canvasPtr, argv[3],
- &halo) != TCL_OK) {
- return TCL_ERROR;
- }
- if (halo < 0.0) {
- Tcl_AppendResult(interp, "can't have negative halo value \"",
- argv[3], "\"", (char *) NULL);
- return TCL_ERROR;
- }
- } else {
- halo = 0.0;
- }
-
- /*
- * Find the item at which to start the search.
- */
-
- startPtr = canvasPtr->firstItemPtr;
- if (argc == 5) {
- itemPtr = StartTagSearch(canvasPtr, argv[4], &search);
- if (itemPtr != NULL) {
- startPtr = itemPtr;
- }
- }
-
- /*
- * The code below is optimized so that it can eliminate most
- * items without having to call their item-specific procedures.
- * This is done by keeping a bounding box (x1, y1, x2, y2) that
- * an item's bbox must overlap if the item is to have any
- * chance of being closer than the closest so far.
- */
-
- itemPtr = startPtr;
- if (itemPtr == NULL) {
- return TCL_OK;
- }
- closestDist = (*itemPtr->typePtr->pointProc)((Tk_Canvas) canvasPtr,
- itemPtr, coords) - halo;
- if (closestDist < 0.0) {
- closestDist = 0.0;
- }
- while (1) {
- double newDist;
-
- /*
- * Update the bounding box using itemPtr, which is the
- * new closest item.
- */
-
- x1 = (int) (coords[0] - closestDist - halo - 1);
- y1 = (int) (coords[1] - closestDist - halo - 1);
- x2 = (int) (coords[0] + closestDist + halo + 1);
- y2 = (int) (coords[1] + closestDist + halo + 1);
- closestPtr = itemPtr;
-
- /*
- * Search for an item that beats the current closest one.
- * Work circularly through the canvas's item list until
- * getting back to the starting item.
- */
-
- while (1) {
- itemPtr = itemPtr->nextPtr;
- if (itemPtr == NULL) {
- itemPtr = canvasPtr->firstItemPtr;
- }
- if (itemPtr == startPtr) {
- DoItem(interp, closestPtr, uid);
- return TCL_OK;
- }
- if ((itemPtr->x1 >= x2) || (itemPtr->x2 <= x1)
- || (itemPtr->y1 >= y2) || (itemPtr->y2 <= y1)) {
- continue;
- }
- newDist = (*itemPtr->typePtr->pointProc)((Tk_Canvas) canvasPtr,
- itemPtr, coords) - halo;
- if (newDist < 0.0) {
- newDist = 0.0;
- }
- if (newDist <= closestDist) {
- closestDist = newDist;
- break;
- }
- }
- }
- } else if ((c == 'e') && (strncmp(argv[0], "enclosed", length) == 0)) {
- if (argc != 5) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- cmdName, option, " enclosed x1 y1 x2 y2", (char *) NULL);
- return TCL_ERROR;
- }
- return FindArea(interp, canvasPtr, argv+1, uid, 1);
- } else if ((c == 'o') && (strncmp(argv[0], "overlapping", length) == 0)) {
- if (argc != 5) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- cmdName, option, " overlapping x1 y1 x2 y2",
- (char *) NULL);
- return TCL_ERROR;
- }
- return FindArea(interp, canvasPtr, argv+1, uid, 0);
- } else if ((c == 'w') && (strncmp(argv[0], "withtag", length) == 0)) {
- if (argc != 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- cmdName, option, " withtag tagOrId", (char *) NULL);
- return TCL_ERROR;
- }
- for (itemPtr = StartTagSearch(canvasPtr, argv[1], &search);
- itemPtr != NULL; itemPtr = NextItem(&search)) {
- DoItem(interp, itemPtr, uid);
- }
- } else {
- Tcl_AppendResult(interp, "bad search command \"", argv[0],
- "\": must be above, all, below, closest, enclosed, ",
- "overlapping, or withtag", (char *) NULL);
- return TCL_ERROR;
- }
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * FindArea --
- *
- * This procedure implements area searches for the "find"
- * and "addtag" options.
- *
- * Results:
- * A standard Tcl return value. If newTag is NULL, then a
- * list of ids from all the items overlapping or enclosed
- * by the rectangle given by argc is returned in interp->result.
- * If newTag is NULL, then the normal interp->result is an
- * empty string. If an error occurs, then interp->result will
- * hold an error message.
- *
- * Side effects:
- * If uid is non-NULL, then all the items overlapping
- * or enclosed by the area in argv have that tag added to
- * their lists of tags.
- *
- *--------------------------------------------------------------
- */
-
-static int
-FindArea(interp, canvasPtr, argv, uid, enclosed)
- Tcl_Interp *interp; /* Interpreter for error reporting
- * and result storing. */
- TkCanvas *canvasPtr; /* Canvas whose items are to be
- * searched. */
- char **argv; /* Array of four arguments that
- * give the coordinates of the
- * rectangular area to search. */
- Tk_Uid uid; /* If non-NULL, gives new tag to set
- * on all found items; if NULL, then
- * ids of found items are returned
- * in interp->result. */
- int enclosed; /* 0 means overlapping or enclosed
- * items are OK, 1 means only enclosed
- * items are OK. */
-{
- double rect[4], tmp;
- int x1, y1, x2, y2;
- Tk_Item *itemPtr;
-
- if ((Tk_CanvasGetCoord(interp, (Tk_Canvas) canvasPtr, argv[0],
- &rect[0]) != TCL_OK)
- || (Tk_CanvasGetCoord(interp, (Tk_Canvas) canvasPtr, argv[1],
- &rect[1]) != TCL_OK)
- || (Tk_CanvasGetCoord(interp, (Tk_Canvas) canvasPtr, argv[2],
- &rect[2]) != TCL_OK)
- || (Tk_CanvasGetCoord(interp, (Tk_Canvas) canvasPtr, argv[3],
- &rect[3]) != TCL_OK)) {
- return TCL_ERROR;
- }
- if (rect[0] > rect[2]) {
- tmp = rect[0]; rect[0] = rect[2]; rect[2] = tmp;
- }
- if (rect[1] > rect[3]) {
- tmp = rect[1]; rect[1] = rect[3]; rect[3] = tmp;
- }
-
- /*
- * Use an integer bounding box for a quick test, to avoid
- * calling item-specific code except for items that are close.
- */
-
- x1 = (int) (rect[0]-1.0);
- y1 = (int) (rect[1]-1.0);
- x2 = (int) (rect[2]+1.0);
- y2 = (int) (rect[3]+1.0);
- for (itemPtr = canvasPtr->firstItemPtr; itemPtr != NULL;
- itemPtr = itemPtr->nextPtr) {
- if ((itemPtr->x1 >= x2) || (itemPtr->x2 <= x1)
- || (itemPtr->y1 >= y2) || (itemPtr->y2 <= y1)) {
- continue;
- }
- if ((*itemPtr->typePtr->areaProc)((Tk_Canvas) canvasPtr, itemPtr, rect)
- >= enclosed) {
- DoItem(interp, itemPtr, uid);
- }
- }
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * RelinkItems --
- *
- * Move one or more items to a different place in the
- * display order for a canvas.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The items identified by "tag" are moved so that they
- * are all together in the display list and immediately
- * after prevPtr. The order of the moved items relative
- * to each other is not changed.
- *
- *--------------------------------------------------------------
- */
-
-static void
-RelinkItems(canvasPtr, tag, prevPtr)
- TkCanvas *canvasPtr; /* Canvas to be modified. */
- char *tag; /* Tag identifying items to be moved
- * in the redisplay list. */
- Tk_Item *prevPtr; /* Reposition the items so that they
- * go just after this item (NULL means
- * put at beginning of list). */
-{
- Tk_Item *itemPtr;
- TagSearch search;
- Tk_Item *firstMovePtr, *lastMovePtr;
-
- /*
- * Find all of the items to be moved and remove them from
- * the list, making an auxiliary list running from firstMovePtr
- * to lastMovePtr. Record their areas for redisplay.
- */
-
- firstMovePtr = lastMovePtr = NULL;
- for (itemPtr = StartTagSearch(canvasPtr, tag, &search);
- itemPtr != NULL; itemPtr = NextItem(&search)) {
- if (itemPtr == prevPtr) {
- /*
- * Item after which insertion is to occur is being
- * moved! Switch to insert after its predecessor.
- */
-
- prevPtr = search.prevPtr;
- }
- if (search.prevPtr == NULL) {
- canvasPtr->firstItemPtr = itemPtr->nextPtr;
- } else {
- search.prevPtr->nextPtr = itemPtr->nextPtr;
- }
- if (canvasPtr->lastItemPtr == itemPtr) {
- canvasPtr->lastItemPtr = search.prevPtr;
- }
- if (firstMovePtr == NULL) {
- firstMovePtr = itemPtr;
- } else {
- lastMovePtr->nextPtr = itemPtr;
- }
- lastMovePtr = itemPtr;
- Tk_CanvasEventuallyRedraw((Tk_Canvas) canvasPtr, itemPtr->x1, itemPtr->y1,
- itemPtr->x2, itemPtr->y2);
- canvasPtr->flags |= REPICK_NEEDED;
- }
-
- /*
- * Insert the list of to-be-moved items back into the canvas's
- * at the desired position.
- */
-
- if (firstMovePtr == NULL) {
- return;
- }
- if (prevPtr == NULL) {
- lastMovePtr->nextPtr = canvasPtr->firstItemPtr;
- canvasPtr->firstItemPtr = firstMovePtr;
- } else {
- lastMovePtr->nextPtr = prevPtr->nextPtr;
- prevPtr->nextPtr = firstMovePtr;
- }
- if (canvasPtr->lastItemPtr == prevPtr) {
- canvasPtr->lastItemPtr = lastMovePtr;
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * CanvasBindProc --
- *
- * This procedure is invoked by the Tk dispatcher to handle
- * events associated with bindings on items.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Depends on the command invoked as part of the binding
- * (if there was any).
- *
- *--------------------------------------------------------------
- */
-
-static void
-CanvasBindProc(clientData, eventPtr)
- ClientData clientData; /* Pointer to canvas structure. */
- XEvent *eventPtr; /* Pointer to X event that just
- * happened. */
-{
- TkCanvas *canvasPtr = (TkCanvas *) clientData;
-
- Tcl_Preserve((ClientData) canvasPtr);
-
- /*
- * This code below keeps track of the current modifier state in
- * canvasPtr>state. This information is used to defer repicks of
- * the current item while buttons are down.
- */
-
- if ((eventPtr->type == ButtonPress) || (eventPtr->type == ButtonRelease)) {
- int mask;
-
- switch (eventPtr->xbutton.button) {
- case Button1:
- mask = Button1Mask;
- break;
- case Button2:
- mask = Button2Mask;
- break;
- case Button3:
- mask = Button3Mask;
- break;
- case Button4:
- mask = Button4Mask;
- break;
- case Button5:
- mask = Button5Mask;
- break;
- default:
- mask = 0;
- break;
- }
-
- /*
- * For button press events, repick the current item using the
- * button state before the event, then process the event. For
- * button release events, first process the event, then repick
- * the current item using the button state *after* the event
- * (the button has logically gone up before we change the
- * current item).
- */
-
- if (eventPtr->type == ButtonPress) {
- /*
- * On a button press, first repick the current item using
- * the button state before the event, the process the event.
- */
-
- canvasPtr->state = eventPtr->xbutton.state;
- PickCurrentItem(canvasPtr, eventPtr);
- canvasPtr->state ^= mask;
- CanvasDoEvent(canvasPtr, eventPtr);
- } else {
- /*
- * Button release: first process the event, with the button
- * still considered to be down. Then repick the current
- * item under the assumption that the button is no longer down.
- */
-
- canvasPtr->state = eventPtr->xbutton.state;
- CanvasDoEvent(canvasPtr, eventPtr);
- eventPtr->xbutton.state ^= mask;
- canvasPtr->state = eventPtr->xbutton.state;
- PickCurrentItem(canvasPtr, eventPtr);
- eventPtr->xbutton.state ^= mask;
- }
- goto done;
- } else if ((eventPtr->type == EnterNotify)
- || (eventPtr->type == LeaveNotify)) {
- canvasPtr->state = eventPtr->xcrossing.state;
- PickCurrentItem(canvasPtr, eventPtr);
- goto done;
- } else if (eventPtr->type == MotionNotify) {
- canvasPtr->state = eventPtr->xmotion.state;
- PickCurrentItem(canvasPtr, eventPtr);
- }
- CanvasDoEvent(canvasPtr, eventPtr);
-
- done:
- Tcl_Release((ClientData) canvasPtr);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * PickCurrentItem --
- *
- * Find the topmost item in a canvas that contains a given
- * location and mark the the current item. If the current
- * item has changed, generate a fake exit event on the old
- * current item and a fake enter event on the new current
- * item.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The current item for canvasPtr may change. If it does,
- * then the commands associated with item entry and exit
- * could do just about anything. A binding script could
- * delete the canvas, so callers should protect themselves
- * with Tcl_Preserve and Tcl_Release.
- *
- *--------------------------------------------------------------
- */
-
-static void
-PickCurrentItem(canvasPtr, eventPtr)
- TkCanvas *canvasPtr; /* Canvas widget in which to select
- * current item. */
- XEvent *eventPtr; /* Event describing location of
- * mouse cursor. Must be EnterWindow,
- * LeaveWindow, ButtonRelease, or
- * MotionNotify. */
-{
- double coords[2];
- int buttonDown;
-
- /*
- * Check whether or not a button is down. If so, we'll log entry
- * and exit into and out of the current item, but not entry into
- * any other item. This implements a form of grabbing equivalent
- * to what the X server does for windows.
- */
-
- buttonDown = canvasPtr->state
- & (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask);
- if (!buttonDown) {
- canvasPtr->flags &= ~LEFT_GRABBED_ITEM;
- }
-
- /*
- * Save information about this event in the canvas. The event in
- * the canvas is used for two purposes:
- *
- * 1. Event bindings: if the current item changes, fake events are
- * generated to allow item-enter and item-leave bindings to trigger.
- * 2. Reselection: if the current item gets deleted, can use the
- * saved event to find a new current item.
- * Translate MotionNotify events into EnterNotify events, since that's
- * what gets reported to item handlers.
- */
-
- if (eventPtr != &canvasPtr->pickEvent) {
- if ((eventPtr->type == MotionNotify)
- || (eventPtr->type == ButtonRelease)) {
- canvasPtr->pickEvent.xcrossing.type = EnterNotify;
- canvasPtr->pickEvent.xcrossing.serial = eventPtr->xmotion.serial;
- canvasPtr->pickEvent.xcrossing.send_event
- = eventPtr->xmotion.send_event;
- canvasPtr->pickEvent.xcrossing.display = eventPtr->xmotion.display;
- canvasPtr->pickEvent.xcrossing.window = eventPtr->xmotion.window;
- canvasPtr->pickEvent.xcrossing.root = eventPtr->xmotion.root;
- canvasPtr->pickEvent.xcrossing.subwindow = None;
- canvasPtr->pickEvent.xcrossing.time = eventPtr->xmotion.time;
- canvasPtr->pickEvent.xcrossing.x = eventPtr->xmotion.x;
- canvasPtr->pickEvent.xcrossing.y = eventPtr->xmotion.y;
- canvasPtr->pickEvent.xcrossing.x_root = eventPtr->xmotion.x_root;
- canvasPtr->pickEvent.xcrossing.y_root = eventPtr->xmotion.y_root;
- canvasPtr->pickEvent.xcrossing.mode = NotifyNormal;
- canvasPtr->pickEvent.xcrossing.detail = NotifyNonlinear;
- canvasPtr->pickEvent.xcrossing.same_screen
- = eventPtr->xmotion.same_screen;
- canvasPtr->pickEvent.xcrossing.focus = False;
- canvasPtr->pickEvent.xcrossing.state = eventPtr->xmotion.state;
- } else {
- canvasPtr->pickEvent = *eventPtr;
- }
- }
-
- /*
- * If this is a recursive call (there's already a partially completed
- * call pending on the stack; it's in the middle of processing a
- * Leave event handler for the old current item) then just return;
- * the pending call will do everything that's needed.
- */
-
- if (canvasPtr->flags & REPICK_IN_PROGRESS) {
- return;
- }
-
- /*
- * A LeaveNotify event automatically means that there's no current
- * object, so the check for closest item can be skipped.
- */
-
- coords[0] = canvasPtr->pickEvent.xcrossing.x + canvasPtr->xOrigin;
- coords[1] = canvasPtr->pickEvent.xcrossing.y + canvasPtr->yOrigin;
- if (canvasPtr->pickEvent.type != LeaveNotify) {
- canvasPtr->newCurrentPtr = CanvasFindClosest(canvasPtr, coords);
- } else {
- canvasPtr->newCurrentPtr = NULL;
- }
-
- if ((canvasPtr->newCurrentPtr == canvasPtr->currentItemPtr)
- && !(canvasPtr->flags & LEFT_GRABBED_ITEM)) {
- /*
- * Nothing to do: the current item hasn't changed.
- */
-
- return;
- }
-
- /*
- * Simulate a LeaveNotify event on the previous current item and
- * an EnterNotify event on the new current item. Remove the "current"
- * tag from the previous current item and place it on the new current
- * item.
- */
-
- if ((canvasPtr->newCurrentPtr != canvasPtr->currentItemPtr)
- && (canvasPtr->currentItemPtr != NULL)
- && !(canvasPtr->flags & LEFT_GRABBED_ITEM)) {
- XEvent event;
- Tk_Item *itemPtr = canvasPtr->currentItemPtr;
- int i;
-
- event = canvasPtr->pickEvent;
- event.type = LeaveNotify;
-
- /*
- * If the event's detail happens to be NotifyInferior the
- * binding mechanism will discard the event. To be consistent,
- * always use NotifyAncestor.
- */
-
- event.xcrossing.detail = NotifyAncestor;
- canvasPtr->flags |= REPICK_IN_PROGRESS;
- CanvasDoEvent(canvasPtr, &event);
- canvasPtr->flags &= ~REPICK_IN_PROGRESS;
-
- /*
- * The check below is needed because there could be an event
- * handler for <LeaveNotify> that deletes the current item.
- */
-
- if ((itemPtr == canvasPtr->currentItemPtr) && !buttonDown) {
- for (i = itemPtr->numTags-1; i >= 0; i--) {
- if (itemPtr->tagPtr[i] == currentUid) {
- itemPtr->tagPtr[i] = itemPtr->tagPtr[itemPtr->numTags-1];
- itemPtr->numTags--;
- break;
- }
- }
- }
-
- /*
- * Note: during CanvasDoEvent above, it's possible that
- * canvasPtr->newCurrentPtr got reset to NULL because the
- * item was deleted.
- */
- }
- if ((canvasPtr->newCurrentPtr != canvasPtr->currentItemPtr) && buttonDown) {
- canvasPtr->flags |= LEFT_GRABBED_ITEM;
- return;
- }
-
- /*
- * Special note: it's possible that canvasPtr->newCurrentPtr ==
- * canvasPtr->currentItemPtr here. This can happen, for example,
- * if LEFT_GRABBED_ITEM was set.
- */
-
- canvasPtr->flags &= ~LEFT_GRABBED_ITEM;
- canvasPtr->currentItemPtr = canvasPtr->newCurrentPtr;
- if (canvasPtr->currentItemPtr != NULL) {
- XEvent event;
-
- DoItem((Tcl_Interp *) NULL, canvasPtr->currentItemPtr, currentUid);
- event = canvasPtr->pickEvent;
- event.type = EnterNotify;
- event.xcrossing.detail = NotifyAncestor;
- CanvasDoEvent(canvasPtr, &event);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * CanvasFindClosest --
- *
- * Given x and y coordinates, find the topmost canvas item that
- * is "close" to the coordinates.
- *
- * Results:
- * The return value is a pointer to the topmost item that is
- * close to (x,y), or NULL if no item is close.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static Tk_Item *
-CanvasFindClosest(canvasPtr, coords)
- TkCanvas *canvasPtr; /* Canvas widget to search. */
- double coords[2]; /* Desired x,y position in canvas,
- * not screen, coordinates.) */
-{
- Tk_Item *itemPtr;
- Tk_Item *bestPtr;
- int x1, y1, x2, y2;
-
- x1 = (int) (coords[0] - canvasPtr->closeEnough);
- y1 = (int) (coords[1] - canvasPtr->closeEnough);
- x2 = (int) (coords[0] + canvasPtr->closeEnough);
- y2 = (int) (coords[1] + canvasPtr->closeEnough);
-
- bestPtr = NULL;
- for (itemPtr = canvasPtr->firstItemPtr; itemPtr != NULL;
- itemPtr = itemPtr->nextPtr) {
- if ((itemPtr->x1 > x2) || (itemPtr->x2 < x1)
- || (itemPtr->y1 > y2) || (itemPtr->y2 < y1)) {
- continue;
- }
- if ((*itemPtr->typePtr->pointProc)((Tk_Canvas) canvasPtr,
- itemPtr, coords) <= canvasPtr->closeEnough) {
- bestPtr = itemPtr;
- }
- }
- return bestPtr;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * CanvasDoEvent --
- *
- * This procedure is called to invoke binding processing
- * for a new event that is associated with the current item
- * for a canvas.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Depends on the bindings for the canvas. A binding script
- * could delete the canvas, so callers should protect themselves
- * with Tcl_Preserve and Tcl_Release.
- *
- *--------------------------------------------------------------
- */
-
-static void
-CanvasDoEvent(canvasPtr, eventPtr)
- TkCanvas *canvasPtr; /* Canvas widget in which event
- * occurred. */
- XEvent *eventPtr; /* Real or simulated X event that
- * is to be processed. */
-{
-#define NUM_STATIC 3
- ClientData staticObjects[NUM_STATIC];
- ClientData *objectPtr;
- int numObjects, i;
- Tk_Item *itemPtr;
-
- if (canvasPtr->bindingTable == NULL) {
- return;
- }
-
- itemPtr = canvasPtr->currentItemPtr;
- if ((eventPtr->type == KeyPress) || (eventPtr->type == KeyRelease)) {
- itemPtr = canvasPtr->textInfo.focusItemPtr;
- }
- if (itemPtr == NULL) {
- return;
- }
-
- /*
- * Set up an array with all the relevant objects for processing
- * this event. The relevant objects are (a) the event's item,
- * (b) the tags associated with the event's item, and (c) the
- * tag "all". If there are a lot of tags then malloc an array
- * to hold all of the objects.
- */
-
- numObjects = itemPtr->numTags + 2;
- if (numObjects <= NUM_STATIC) {
- objectPtr = staticObjects;
- } else {
- objectPtr = (ClientData *) ckalloc((unsigned)
- (numObjects * sizeof(ClientData)));
- }
- objectPtr[0] = (ClientData) allUid;
- for (i = itemPtr->numTags-1; i >= 0; i--) {
- objectPtr[i+1] = (ClientData) itemPtr->tagPtr[i];
- }
- objectPtr[itemPtr->numTags+1] = (ClientData) itemPtr;
-
- /*
- * Invoke the binding system, then free up the object array if
- * it was malloc-ed.
- */
-
- if (canvasPtr->tkwin != NULL) {
- Tk_BindEvent(canvasPtr->bindingTable, eventPtr, canvasPtr->tkwin,
- numObjects, objectPtr);
- }
- if (objectPtr != staticObjects) {
- ckfree((char *) objectPtr);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * CanvasBlinkProc --
- *
- * This procedure is called as a timer handler to blink the
- * insertion cursor off and on.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The cursor gets turned on or off, redisplay gets invoked,
- * and this procedure reschedules itself.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-CanvasBlinkProc(clientData)
- ClientData clientData; /* Pointer to record describing entry. */
-{
- TkCanvas *canvasPtr = (TkCanvas *) clientData;
-
- if (!canvasPtr->textInfo.gotFocus || (canvasPtr->insertOffTime == 0)) {
- return;
- }
- if (canvasPtr->textInfo.cursorOn) {
- canvasPtr->textInfo.cursorOn = 0;
- canvasPtr->insertBlinkHandler = Tcl_CreateTimerHandler(
- canvasPtr->insertOffTime, CanvasBlinkProc,
- (ClientData) canvasPtr);
- } else {
- canvasPtr->textInfo.cursorOn = 1;
- canvasPtr->insertBlinkHandler = Tcl_CreateTimerHandler(
- canvasPtr->insertOnTime, CanvasBlinkProc,
- (ClientData) canvasPtr);
- }
- if (canvasPtr->textInfo.focusItemPtr != NULL) {
- Tk_CanvasEventuallyRedraw((Tk_Canvas) canvasPtr,
- canvasPtr->textInfo.focusItemPtr->x1,
- canvasPtr->textInfo.focusItemPtr->y1,
- canvasPtr->textInfo.focusItemPtr->x2,
- canvasPtr->textInfo.focusItemPtr->y2);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * CanvasFocusProc --
- *
- * This procedure is called whenever a canvas gets or loses the
- * input focus. It's also called whenever the window is
- * reconfigured while it has the focus.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The cursor gets turned on or off.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-CanvasFocusProc(canvasPtr, gotFocus)
- TkCanvas *canvasPtr; /* Canvas that just got or lost focus. */
- int gotFocus; /* 1 means window is getting focus, 0 means
- * it's losing it. */
-{
- Tcl_DeleteTimerHandler(canvasPtr->insertBlinkHandler);
- if (gotFocus) {
- canvasPtr->textInfo.gotFocus = 1;
- canvasPtr->textInfo.cursorOn = 1;
- if (canvasPtr->insertOffTime != 0) {
- canvasPtr->insertBlinkHandler = Tcl_CreateTimerHandler(
- canvasPtr->insertOffTime, CanvasBlinkProc,
- (ClientData) canvasPtr);
- }
- } else {
- canvasPtr->textInfo.gotFocus = 0;
- canvasPtr->textInfo.cursorOn = 0;
- canvasPtr->insertBlinkHandler = (Tcl_TimerToken) NULL;
- }
- if (canvasPtr->textInfo.focusItemPtr != NULL) {
- Tk_CanvasEventuallyRedraw((Tk_Canvas) canvasPtr,
- canvasPtr->textInfo.focusItemPtr->x1,
- canvasPtr->textInfo.focusItemPtr->y1,
- canvasPtr->textInfo.focusItemPtr->x2,
- canvasPtr->textInfo.focusItemPtr->y2);
- }
- if (canvasPtr->highlightWidth > 0) {
- canvasPtr->flags |= REDRAW_BORDERS;
- if (!(canvasPtr->flags & REDRAW_PENDING)) {
- Tcl_DoWhenIdle(DisplayCanvas, (ClientData) canvasPtr);
- canvasPtr->flags |= REDRAW_PENDING;
- }
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * CanvasSelectTo --
- *
- * Modify the selection by moving its un-anchored end. This could
- * make the selection either larger or smaller.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The selection changes.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-CanvasSelectTo(canvasPtr, itemPtr, index)
- TkCanvas *canvasPtr; /* Information about widget. */
- Tk_Item *itemPtr; /* Item that is to hold selection. */
- int index; /* Index of element that is to become the
- * "other" end of the selection. */
-{
- int oldFirst, oldLast;
- Tk_Item *oldSelPtr;
-
- oldFirst = canvasPtr->textInfo.selectFirst;
- oldLast = canvasPtr->textInfo.selectLast;
- oldSelPtr = canvasPtr->textInfo.selItemPtr;
-
- /*
- * Grab the selection if we don't own it already.
- */
-
- if (canvasPtr->textInfo.selItemPtr == NULL) {
- Tk_OwnSelection(canvasPtr->tkwin, XA_PRIMARY, CanvasLostSelection,
- (ClientData) canvasPtr);
- } else if (canvasPtr->textInfo.selItemPtr != itemPtr) {
- Tk_CanvasEventuallyRedraw((Tk_Canvas) canvasPtr,
- canvasPtr->textInfo.selItemPtr->x1,
- canvasPtr->textInfo.selItemPtr->y1,
- canvasPtr->textInfo.selItemPtr->x2,
- canvasPtr->textInfo.selItemPtr->y2);
- }
- canvasPtr->textInfo.selItemPtr = itemPtr;
-
- if (canvasPtr->textInfo.anchorItemPtr != itemPtr) {
- canvasPtr->textInfo.anchorItemPtr = itemPtr;
- canvasPtr->textInfo.selectAnchor = index;
- }
- if (canvasPtr->textInfo.selectAnchor <= index) {
- canvasPtr->textInfo.selectFirst = canvasPtr->textInfo.selectAnchor;
- canvasPtr->textInfo.selectLast = index;
- } else {
- canvasPtr->textInfo.selectFirst = index;
- canvasPtr->textInfo.selectLast = canvasPtr->textInfo.selectAnchor - 1;
- }
- if ((canvasPtr->textInfo.selectFirst != oldFirst)
- || (canvasPtr->textInfo.selectLast != oldLast)
- || (itemPtr != oldSelPtr)) {
- Tk_CanvasEventuallyRedraw((Tk_Canvas) canvasPtr,
- itemPtr->x1, itemPtr->y1, itemPtr->x2, itemPtr->y2);
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * CanvasFetchSelection --
- *
- * This procedure is invoked by Tk to return part or all of
- * the selection, when the selection is in a canvas widget.
- * This procedure always returns the selection as a STRING.
- *
- * Results:
- * The return value is the number of non-NULL bytes stored
- * at buffer. Buffer is filled (or partially filled) with a
- * NULL-terminated string containing part or all of the selection,
- * as given by offset and maxBytes.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-static int
-CanvasFetchSelection(clientData, offset, buffer, maxBytes)
- ClientData clientData; /* Information about canvas widget. */
- int offset; /* Offset within selection of first
- * character to be returned. */
- char *buffer; /* Location in which to place
- * selection. */
- int maxBytes; /* Maximum number of bytes to place
- * at buffer, not including terminating
- * NULL character. */
-{
- TkCanvas *canvasPtr = (TkCanvas *) clientData;
-
- if (canvasPtr->textInfo.selItemPtr == NULL) {
- return -1;
- }
- if (canvasPtr->textInfo.selItemPtr->typePtr->selectionProc == NULL) {
- return -1;
- }
- return (*canvasPtr->textInfo.selItemPtr->typePtr->selectionProc)(
- (Tk_Canvas) canvasPtr, canvasPtr->textInfo.selItemPtr, offset,
- buffer, maxBytes);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * CanvasLostSelection --
- *
- * This procedure is called back by Tk when the selection is
- * grabbed away from a canvas widget.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The existing selection is unhighlighted, and the window is
- * marked as not containing a selection.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-CanvasLostSelection(clientData)
- ClientData clientData; /* Information about entry widget. */
-{
- TkCanvas *canvasPtr = (TkCanvas *) clientData;
-
- if (canvasPtr->textInfo.selItemPtr != NULL) {
- Tk_CanvasEventuallyRedraw((Tk_Canvas) canvasPtr,
- canvasPtr->textInfo.selItemPtr->x1,
- canvasPtr->textInfo.selItemPtr->y1,
- canvasPtr->textInfo.selItemPtr->x2,
- canvasPtr->textInfo.selItemPtr->y2);
- }
- canvasPtr->textInfo.selItemPtr = NULL;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * GridAlign --
- *
- * Given a coordinate and a grid spacing, this procedure
- * computes the location of the nearest grid line to the
- * coordinate.
- *
- * Results:
- * The return value is the location of the grid line nearest
- * to coord.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-static double
-GridAlign(coord, spacing)
- double coord; /* Coordinate to grid-align. */
- double spacing; /* Spacing between grid lines. If <= 0
- * then no alignment is done. */
-{
- if (spacing <= 0.0) {
- return coord;
- }
- if (coord < 0) {
- return -((int) ((-coord)/spacing + 0.5)) * spacing;
- }
- return ((int) (coord/spacing + 0.5)) * spacing;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * PrintScrollFractions --
- *
- * 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.
- *
- * Results:
- * The memory pointed to by string is modified to hold
- * two real numbers containing the scroll fractions (between
- * 0 and 1) corresponding to the other arguments.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-PrintScrollFractions(screen1, screen2, object1, object2, string)
- 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;
-
- range = object2 - object1;
- if (range <= 0) {
- f1 = 0;
- f2 = 1.0;
- } else {
- f1 = (screen1 - object1)/range;
- if (f1 < 0) {
- f1 = 0.0;
- }
- f2 = (screen2 - object1)/range;
- if (f2 > 1.0) {
- f2 = 1.0;
- }
- if (f2 < f1) {
- f2 = f1;
- }
- }
- sprintf(string, "%g %g", f1, f2);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * CanvasUpdateScrollbars --
- *
- * This procedure is invoked whenever a canvas has changed in
- * a way that requires scrollbars to be redisplayed (e.g. the
- * view in the canvas has changed).
- *
- * Results:
- * None.
- *
- * Side effects:
- * If there are scrollbars associated with the canvas, then
- * their scrolling commands are invoked to cause them to
- * redisplay. If errors occur, additional Tcl commands may
- * be invoked to process the errors.
- *
- *--------------------------------------------------------------
- */
-
-static void
-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;
- char *xScrollCmd, *yScrollCmd;
-
- /*
- * Save all the relevant values from the canvasPtr, because it might be
- * deleted as part of either of the two calls to Tcl_VarEval below.
- */
-
- interp = canvasPtr->interp;
- Tcl_Preserve((ClientData) interp);
- xScrollCmd = canvasPtr->xScrollCmd;
- if (xScrollCmd != (char *) NULL) {
- Tcl_Preserve((ClientData) xScrollCmd);
- }
- yScrollCmd = canvasPtr->yScrollCmd;
- if (yScrollCmd != (char *) NULL) {
- Tcl_Preserve((ClientData) yScrollCmd);
- }
- xOrigin = canvasPtr->xOrigin;
- yOrigin = canvasPtr->yOrigin;
- inset = canvasPtr->inset;
- width = Tk_Width(canvasPtr->tkwin);
- height = Tk_Height(canvasPtr->tkwin);
- scrollX1 = canvasPtr->scrollX1;
- scrollX2 = canvasPtr->scrollX2;
- scrollY1 = canvasPtr->scrollY1;
- 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);
- if (result != TCL_OK) {
- Tcl_BackgroundError(interp);
- }
- Tcl_ResetResult(interp);
- Tcl_Release((ClientData) xScrollCmd);
- }
-
- if (yScrollCmd != NULL) {
- PrintScrollFractions(yOrigin + inset, yOrigin + height - inset,
- scrollY1, scrollY2, buffer);
- result = Tcl_VarEval(interp, yScrollCmd, " ", buffer, (char *) NULL);
- if (result != TCL_OK) {
- Tcl_BackgroundError(interp);
- }
- Tcl_ResetResult(interp);
- Tcl_Release((ClientData) yScrollCmd);
- }
- Tcl_Release((ClientData) interp);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * CanvasSetOrigin --
- *
- * This procedure is invoked to change the mapping between
- * canvas coordinates and screen coordinates in the canvas
- * window.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The canvas will be redisplayed to reflect the change in
- * view. In addition, scrollbars will be updated if there
- * are any.
- *
- *--------------------------------------------------------------
- */
-
-static void
-CanvasSetOrigin(canvasPtr, xOrigin, yOrigin)
- TkCanvas *canvasPtr; /* Information about canvas. */
- int xOrigin; /* New X origin for canvas (canvas x-coord
- * corresponding to left edge of canvas
- * window). */
- int yOrigin; /* New Y origin for canvas (canvas y-coord
- * corresponding to top edge of canvas
- * window). */
-{
- int left, right, top, bottom, delta;
-
- /*
- * If scroll increments have been set, round the window origin
- * to the nearest multiple of the increments. Remember, the
- * origin is the place just inside the borders, not the upper
- * left corner.
- */
-
- if (canvasPtr->xScrollIncrement > 0) {
- if (xOrigin >= 0) {
- xOrigin += canvasPtr->xScrollIncrement/2;
- xOrigin -= (xOrigin + canvasPtr->inset)
- % canvasPtr->xScrollIncrement;
- } else {
- xOrigin = (-xOrigin) + canvasPtr->xScrollIncrement/2;
- xOrigin = -(xOrigin - (xOrigin - canvasPtr->inset)
- % canvasPtr->xScrollIncrement);
- }
- }
- if (canvasPtr->yScrollIncrement > 0) {
- if (yOrigin >= 0) {
- yOrigin += canvasPtr->yScrollIncrement/2;
- yOrigin -= (yOrigin + canvasPtr->inset)
- % canvasPtr->yScrollIncrement;
- } else {
- yOrigin = (-yOrigin) + canvasPtr->yScrollIncrement/2;
- yOrigin = -(yOrigin - (yOrigin - canvasPtr->inset)
- % canvasPtr->yScrollIncrement);
- }
- }
-
- /*
- * Adjust the origin if necessary to keep as much as possible of the
- * canvas in the view. The variables left, right, etc. keep track of
- * how much extra space there is on each side of the view before it
- * will stick out past the scroll region. If one side sticks out past
- * the edge of the scroll region, adjust the view to bring that side
- * back to the edge of the scrollregion (but don't move it so much that
- * the other side sticks out now). If scroll increments are in effect,
- * be sure to adjust only by full increments.
- */
-
- if ((canvasPtr->confine) && (canvasPtr->regionString != NULL)) {
- left = xOrigin + canvasPtr->inset - canvasPtr->scrollX1;
- right = canvasPtr->scrollX2
- - (xOrigin + Tk_Width(canvasPtr->tkwin) - canvasPtr->inset);
- top = yOrigin + canvasPtr->inset - canvasPtr->scrollY1;
- bottom = canvasPtr->scrollY2
- - (yOrigin + Tk_Height(canvasPtr->tkwin) - canvasPtr->inset);
- if ((left < 0) && (right > 0)) {
- delta = (right > -left) ? -left : right;
- if (canvasPtr->xScrollIncrement > 0) {
- delta -= delta % canvasPtr->xScrollIncrement;
- }
- xOrigin += delta;
- } else if ((right < 0) && (left > 0)) {
- delta = (left > -right) ? -right : left;
- if (canvasPtr->xScrollIncrement > 0) {
- delta -= delta % canvasPtr->xScrollIncrement;
- }
- xOrigin -= delta;
- }
- if ((top < 0) && (bottom > 0)) {
- delta = (bottom > -top) ? -top : bottom;
- if (canvasPtr->yScrollIncrement > 0) {
- delta -= delta % canvasPtr->yScrollIncrement;
- }
- yOrigin += delta;
- } else if ((bottom < 0) && (top > 0)) {
- delta = (top > -bottom) ? -bottom : top;
- if (canvasPtr->yScrollIncrement > 0) {
- delta -= delta % canvasPtr->yScrollIncrement;
- }
- yOrigin -= delta;
- }
- }
-
- if ((xOrigin == canvasPtr->xOrigin) && (yOrigin == canvasPtr->yOrigin)) {
- return;
- }
-
- /*
- * Tricky point: must redisplay not only everything that's visible
- * in the window's final configuration, but also everything that was
- * visible in the initial configuration. This is needed because some
- * item types, like windows, need to know when they move off-screen
- * so they can explicitly undisplay themselves.
- */
-
- Tk_CanvasEventuallyRedraw((Tk_Canvas) canvasPtr,
- canvasPtr->xOrigin, canvasPtr->yOrigin,
- canvasPtr->xOrigin + Tk_Width(canvasPtr->tkwin),
- canvasPtr->yOrigin + Tk_Height(canvasPtr->tkwin));
- canvasPtr->xOrigin = xOrigin;
- canvasPtr->yOrigin = yOrigin;
- canvasPtr->flags |= UPDATE_SCROLLBARS;
- Tk_CanvasEventuallyRedraw((Tk_Canvas) canvasPtr,
- canvasPtr->xOrigin, canvasPtr->yOrigin,
- canvasPtr->xOrigin + Tk_Width(canvasPtr->tkwin),
- canvasPtr->yOrigin + Tk_Height(canvasPtr->tkwin));
-}
diff --git a/generic/tkCanvas.h b/generic/tkCanvas.h
deleted file mode 100644
index a96fa6b..0000000
--- a/generic/tkCanvas.h
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- * tkCanvas.h --
- *
- * Declarations shared among all the files that implement
- * canvas widgets.
- *
- * Copyright (c) 1991-1994 The Regents of the University of California.
- * Copyright (c) 1994-1995 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: tkCanvas.h,v 1.2 1998/09/14 18:23:07 stanton Exp $
- */
-
-#ifndef _TKCANVAS
-#define _TKCANVAS
-
-#ifndef _TK
-#include "tk.h"
-#endif
-
-/*
- * The record below describes a canvas widget. It is made available
- * to the item procedures so they can access certain shared fields such
- * as the overall displacement and scale factor for the canvas.
- */
-
-typedef struct TkCanvas {
- Tk_Window tkwin; /* Window that embodies the canvas. NULL
- * means that the window has been destroyed
- * but the data structures haven't yet been
- * cleaned up.*/
- Display *display; /* Display containing widget; needed, among
- * other things, to release resources after
- * tkwin has already gone away. */
- Tcl_Interp *interp; /* Interpreter associated with canvas. */
- Tcl_Command widgetCmd; /* Token for canvas's widget command. */
- Tk_Item *firstItemPtr; /* First in list of all items in canvas,
- * or NULL if canvas empty. */
- Tk_Item *lastItemPtr; /* Last in list of all items in canvas,
- * or NULL if canvas empty. */
-
- /*
- * Information used when displaying widget:
- */
-
- int borderWidth; /* Width of 3-D border around window. */
- Tk_3DBorder bgBorder; /* Used for canvas background. */
- int relief; /* Indicates whether window as a whole is
- * raised, sunken, or flat. */
- int highlightWidth; /* Width in pixels of highlight to draw
- * around widget when it has the focus.
- * <= 0 means don't draw a highlight. */
- XColor *highlightBgColorPtr;
- /* Color for drawing traversal highlight
- * area when highlight is off. */
- XColor *highlightColorPtr; /* Color for drawing traversal highlight. */
- int inset; /* Total width of all borders, including
- * traversal highlight and 3-D border.
- * Indicates how much interior stuff must
- * be offset from outside edges to leave
- * room for borders. */
- GC pixmapGC; /* Used to copy bits from a pixmap to the
- * screen and also to clear the pixmap. */
- int width, height; /* Dimensions to request for canvas window,
- * specified in pixels. */
- int redrawX1, redrawY1; /* Upper left corner of area to redraw,
- * in pixel coordinates. Border pixels
- * are included. Only valid if
- * REDRAW_PENDING flag is set. */
- int redrawX2, redrawY2; /* Lower right corner of area to redraw,
- * in integer canvas coordinates. Border
- * pixels will *not* be redrawn. */
- int confine; /* Non-zero means constrain view to keep
- * as much of canvas visible as possible. */
-
- /*
- * Information used to manage the selection and insertion cursor:
- */
-
- Tk_CanvasTextInfo textInfo; /* Contains lots of fields; see tk.h for
- * details. This structure is shared with
- * the code that implements individual items. */
- int insertOnTime; /* Number of milliseconds cursor should spend
- * in "on" state for each blink. */
- int insertOffTime; /* Number of milliseconds cursor should spend
- * in "off" state for each blink. */
- Tcl_TimerToken insertBlinkHandler;
- /* Timer handler used to blink cursor on and
- * off. */
-
- /*
- * Transformation applied to canvas as a whole: to compute screen
- * coordinates (X,Y) from canvas coordinates (x,y), do the following:
- *
- * X = x - xOrigin;
- * Y = y - yOrigin;
- */
-
- int xOrigin, yOrigin; /* Canvas coordinates corresponding to
- * upper-left corner of window, given in
- * canvas pixel units. */
- int drawableXOrigin, drawableYOrigin;
- /* During redisplay, these fields give the
- * canvas coordinates corresponding to
- * the upper-left corner of the drawable
- * where items are actually being drawn
- * (typically a pixmap smaller than the
- * whole window). */
-
- /*
- * Information used for event bindings associated with items.
- */
-
- Tk_BindingTable bindingTable;
- /* Table of all bindings currently defined
- * for this canvas. NULL means that no
- * bindings exist, so the table hasn't been
- * created. Each "object" used for this
- * table is either a Tk_Uid for a tag or
- * the address of an item named by id. */
- Tk_Item *currentItemPtr; /* The item currently containing the mouse
- * pointer, or NULL if none. */
- Tk_Item *newCurrentPtr; /* The item that is about to become the
- * current one, or NULL. This field is
- * used to detect deletions of the new
- * current item pointer that occur during
- * Leave processing of the previous current
- * item. */
- double closeEnough; /* The mouse is assumed to be inside an
- * item if it is this close to it. */
- XEvent pickEvent; /* The event upon which the current choice
- * of currentItem is based. Must be saved
- * so that if the currentItem is deleted,
- * can pick another. */
- int state; /* Last known modifier state. Used to
- * defer picking a new current object
- * while buttons are down. */
-
- /*
- * Information used for managing scrollbars:
- */
-
- char *xScrollCmd; /* Command prefix for communicating with
- * horizontal scrollbar. NULL means no
- * horizontal scrollbar. Malloc'ed*/
- char *yScrollCmd; /* Command prefix for communicating with
- * vertical scrollbar. NULL means no
- * vertical scrollbar. Malloc'ed*/
- int scrollX1, scrollY1, scrollX2, scrollY2;
- /* These four coordinates define the region
- * that is the 100% area for scrolling (i.e.
- * these numbers determine the size and
- * location of the sliders on scrollbars).
- * Units are pixels in canvas coords. */
- char *regionString; /* The option string from which scrollX1
- * etc. are derived. Malloc'ed. */
- int xScrollIncrement; /* If >0, defines a grid for horizontal
- * scrolling. This is the size of the "unit",
- * and the left edge of the screen will always
- * lie on an even unit boundary. */
- int yScrollIncrement; /* If >0, defines a grid for horizontal
- * scrolling. This is the size of the "unit",
- * and the left edge of the screen will always
- * lie on an even unit boundary. */
-
- /*
- * Information used for scanning:
- */
-
- int scanX; /* X-position at which scan started (e.g.
- * button was pressed here). */
- int scanXOrigin; /* Value of xOrigin field when scan started. */
- int scanY; /* Y-position at which scan started (e.g.
- * button was pressed here). */
- int scanYOrigin; /* Value of yOrigin field when scan started. */
-
- /*
- * Information used to speed up searches by remembering the last item
- * created or found with an item id search.
- */
-
- Tk_Item *hotPtr; /* Pointer to "hot" item (one that's been
- * recently used. NULL means there's no
- * hot item. */
- Tk_Item *hotPrevPtr; /* Pointer to predecessor to hotPtr (NULL
- * means item is first in list). This is
- * only a hint and may not really be hotPtr's
- * predecessor. */
-
- /*
- * Miscellaneous information:
- */
-
- Tk_Cursor cursor; /* Current cursor for window, or None. */
- char *takeFocus; /* Value of -takefocus option; not used in
- * the C code, but used by keyboard traversal
- * scripts. Malloc'ed, but may be NULL. */
- double pixelsPerMM; /* Scale factor between MM and pixels;
- * used when converting coordinates. */
- int flags; /* Various flags; see below for
- * definitions. */
- int nextId; /* Number to use as id for next item
- * created in widget. */
- struct TkPostscriptInfo *psInfoPtr;
- /* Pointer to information used for generating
- * Postscript for the canvas. NULL means
- * no Postscript is currently being
- * generated. */
-} TkCanvas;
-
-/*
- * Flag bits for canvases:
- *
- * REDRAW_PENDING - 1 means a DoWhenIdle handler has already
- * been created to redraw some or all of the
- * canvas.
- * REDRAW_BORDERS - 1 means that the borders need to be redrawn
- * during the next redisplay operation.
- * REPICK_NEEDED - 1 means DisplayCanvas should pick a new
- * current item before redrawing the canvas.
- * GOT_FOCUS - 1 means the focus is currently in this
- * widget, so should draw the insertion cursor
- * and traversal highlight.
- * CURSOR_ON - 1 means the insertion cursor is in the "on"
- * phase of its blink cycle. 0 means either
- * we don't have the focus or the cursor is in
- * the "off" phase of its cycle.
- * UPDATE_SCROLLBARS - 1 means the scrollbars should get updated
- * as part of the next display operation.
- * LEFT_GRABBED_ITEM - 1 means that the mouse left the current
- * item while a grab was in effect, so we
- * didn't change canvasPtr->currentItemPtr.
- * REPICK_IN_PROGRESS - 1 means PickCurrentItem is currently
- * executing. If it should be called recursively,
- * it should simply return immediately.
- */
-
-#define REDRAW_PENDING 1
-#define REDRAW_BORDERS 2
-#define REPICK_NEEDED 4
-#define GOT_FOCUS 8
-#define CURSOR_ON 0x10
-#define UPDATE_SCROLLBARS 0x20
-#define LEFT_GRABBED_ITEM 0x40
-#define REPICK_IN_PROGRESS 0x100
-
-/*
- * Canvas-related procedures that are shared among Tk modules but not
- * exported to the outside world:
- */
-
-extern int TkCanvPostscriptCmd _ANSI_ARGS_((TkCanvas *canvasPtr,
- Tcl_Interp *interp, int argc, char **argv));
-
-#endif /* _TKCANVAS */
diff --git a/generic/tkClipboard.c b/generic/tkClipboard.c
deleted file mode 100644
index 7df518a..0000000
--- a/generic/tkClipboard.c
+++ /dev/null
@@ -1,606 +0,0 @@
-/*
- * tkClipboard.c --
- *
- * This file manages the clipboard for the Tk toolkit,
- * maintaining a collection of data buffers that will be
- * supplied on demand to requesting applications.
- *
- * Copyright (c) 1994 The Regents of the University of California.
- * Copyright (c) 1994-1995 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: tkClipboard.c,v 1.2 1998/09/14 18:23:07 stanton Exp $
- */
-
-#include "tkInt.h"
-#include "tkPort.h"
-#include "tkSelect.h"
-
-/*
- * Prototypes for procedures used only in this file:
- */
-
-static int ClipboardAppHandler _ANSI_ARGS_((ClientData clientData,
- int offset, char *buffer, int maxBytes));
-static int ClipboardHandler _ANSI_ARGS_((ClientData clientData,
- int offset, char *buffer, int maxBytes));
-static int ClipboardWindowHandler _ANSI_ARGS_((
- ClientData clientData, int offset, char *buffer,
- int maxBytes));
-static void ClipboardLostSel _ANSI_ARGS_((ClientData clientData));
-
-/*
- *----------------------------------------------------------------------
- *
- * ClipboardHandler --
- *
- * This procedure acts as selection handler for the
- * clipboard manager. It extracts the required chunk of
- * data from the buffer chain for a given selection target.
- *
- * Results:
- * The return value is a count of the number of bytes
- * actually stored at buffer.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-ClipboardHandler(clientData, offset, buffer, maxBytes)
- ClientData clientData; /* Information about data to fetch. */
- int offset; /* Return selection bytes starting at this
- * offset. */
- char *buffer; /* Place to store converted selection. */
- int maxBytes; /* Maximum # of bytes to store at buffer. */
-{
- TkClipboardTarget *targetPtr = (TkClipboardTarget*) clientData;
- TkClipboardBuffer *cbPtr;
- char *srcPtr, *destPtr;
- int count = 0;
- int scanned = 0;
- size_t length, freeCount;
-
- /*
- * Skip to buffer containing offset byte
- */
-
- for (cbPtr = targetPtr->firstBufferPtr; ; cbPtr = cbPtr->nextPtr) {
- if (cbPtr == NULL) {
- return 0;
- }
- if (scanned + cbPtr->length > offset) {
- break;
- }
- scanned += cbPtr->length;
- }
-
- /*
- * Copy up to maxBytes or end of list, switching buffers as needed.
- */
-
- freeCount = maxBytes;
- srcPtr = cbPtr->buffer + (offset - scanned);
- destPtr = buffer;
- length = cbPtr->length - (offset - scanned);
- while (1) {
- if (length > freeCount) {
- strncpy(destPtr, srcPtr, freeCount);
- return maxBytes;
- } else {
- strncpy(destPtr, srcPtr, length);
- destPtr += length;
- count += length;
- freeCount -= length;
- }
- cbPtr = cbPtr->nextPtr;
- if (cbPtr == NULL) {
- break;
- }
- srcPtr = cbPtr->buffer;
- length = cbPtr->length;
- }
- return count;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ClipboardAppHandler --
- *
- * This procedure acts as selection handler for retrievals of type
- * TK_APPLICATION. It returns the name of the application that
- * owns the clipboard. Note: we can't use the default Tk
- * selection handler for this selection type, because the clipboard
- * window isn't a "real" window and doesn't have the necessary
- * information.
- *
- * Results:
- * The return value is a count of the number of bytes
- * actually stored at buffer.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-ClipboardAppHandler(clientData, offset, buffer, maxBytes)
- ClientData clientData; /* Pointer to TkDisplay structure. */
- int offset; /* Return selection bytes starting at this
- * offset. */
- char *buffer; /* Place to store converted selection. */
- int maxBytes; /* Maximum # of bytes to store at buffer. */
-{
- TkDisplay *dispPtr = (TkDisplay *) clientData;
- size_t length;
- char *p;
-
- p = dispPtr->clipboardAppPtr->winPtr->nameUid;
- length = strlen(p);
- length -= offset;
- if (length <= 0) {
- return 0;
- }
- if (length > (size_t) maxBytes) {
- length = maxBytes;
- }
- strncpy(buffer, p, length);
- return length;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ClipboardWindowHandler --
- *
- * This procedure acts as selection handler for retrievals of
- * type TK_WINDOW. Since the clipboard doesn't correspond to
- * any particular window, we just return ".". We can't use Tk's
- * default handler for this selection type, because the clipboard
- * window isn't a valid window.
- *
- * Results:
- * The return value is 1, the number of non-null bytes stored
- * at buffer.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-ClipboardWindowHandler(clientData, offset, buffer, maxBytes)
- ClientData clientData; /* Not used. */
- int offset; /* Return selection bytes starting at this
- * offset. */
- char *buffer; /* Place to store converted selection. */
- int maxBytes; /* Maximum # of bytes to store at buffer. */
-{
- buffer[0] = '.';
- buffer[1] = 0;
- return 1;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ClipboardLostSel --
- *
- * This procedure is invoked whenever clipboard ownership is
- * claimed by another window. It just sets a flag so that we
- * know the clipboard was taken away.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The clipboard is marked as inactive.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-ClipboardLostSel(clientData)
- ClientData clientData; /* Pointer to TkDisplay structure. */
-{
- TkDisplay *dispPtr = (TkDisplay*) clientData;
-
- dispPtr->clipboardActive = 0;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_ClipboardClear --
- *
- * Take control of the clipboard and clear out the previous
- * contents. This procedure must be invoked before any
- * calls to Tk_AppendToClipboard.
- *
- * Results:
- * A standard Tcl result. If an error occurs, an error message is
- * left in interp->result.
- *
- * Side effects:
- * From now on, requests for the CLIPBOARD selection will be
- * directed to the clipboard manager routines associated with
- * clipWindow for the display of tkwin. In order to guarantee
- * atomicity, no event handling should occur between
- * Tk_ClipboardClear and the following Tk_AppendToClipboard
- * calls. This procedure may cause a user-defined LostSel command
- * to be invoked when the CLIPBOARD is claimed, so any calling
- * function should be reentrant at the point Tk_ClipboardClear is
- * invoked.
- *
- *----------------------------------------------------------------------
- */
-
-int
-Tk_ClipboardClear(interp, tkwin)
- Tcl_Interp *interp; /* Interpreter to use for error reporting. */
- Tk_Window tkwin; /* Window in application that is clearing
- * clipboard; identifies application and
- * display. */
-{
- TkWindow *winPtr = (TkWindow *) tkwin;
- TkDisplay *dispPtr = winPtr->dispPtr;
- TkClipboardTarget *targetPtr, *nextTargetPtr;
- TkClipboardBuffer *cbPtr, *nextCbPtr;
-
- if (dispPtr->clipWindow == NULL) {
- int result;
-
- result = TkClipInit(interp, dispPtr);
- if (result != TCL_OK) {
- return result;
- }
- }
-
- /*
- * Discard any existing clipboard data and delete the selection
- * handler(s) associated with that data.
- */
-
- for (targetPtr = dispPtr->clipTargetPtr; targetPtr != NULL;
- targetPtr = nextTargetPtr) {
- for (cbPtr = targetPtr->firstBufferPtr; cbPtr != NULL;
- cbPtr = nextCbPtr) {
- ckfree(cbPtr->buffer);
- nextCbPtr = cbPtr->nextPtr;
- ckfree((char *) cbPtr);
- }
- nextTargetPtr = targetPtr->nextPtr;
- Tk_DeleteSelHandler(dispPtr->clipWindow, dispPtr->clipboardAtom,
- targetPtr->type);
- ckfree((char *) targetPtr);
- }
- dispPtr->clipTargetPtr = NULL;
-
- /*
- * Reclaim the clipboard selection if we lost it.
- */
-
- if (!dispPtr->clipboardActive) {
- Tk_OwnSelection(dispPtr->clipWindow, dispPtr->clipboardAtom,
- ClipboardLostSel, (ClientData) dispPtr);
- dispPtr->clipboardActive = 1;
- }
- dispPtr->clipboardAppPtr = winPtr->mainPtr;
- return TCL_OK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_ClipboardAppend --
- *
- * Append a buffer of data to the clipboard. The first buffer of
- * a given type determines the format for that type. Any successive
- * appends to that type must have the same format or an error will
- * be returned. Tk_ClipboardClear must be called before a sequence
- * of Tk_ClipboardAppend calls can be issued. In order to guarantee
- * atomicity, no event handling should occur between Tk_ClipboardClear
- * and the following Tk_AppendToClipboard calls.
- *
- * Results:
- * A standard Tcl result. If an error is returned, an error message
- * is left in interp->result.
- *
- * Side effects:
- * The specified buffer will be copied onto the end of the clipboard.
- * The clipboard maintains a list of buffers which will be used to
- * supply the data for a selection get request. The first time a given
- * type is appended, Tk_ClipboardAppend will register a selection
- * handler of the appropriate type.
- *
- *----------------------------------------------------------------------
- */
-
-int
-Tk_ClipboardAppend(interp, tkwin, type, format, buffer)
- Tcl_Interp *interp; /* Used for error reporting. */
- Tk_Window tkwin; /* Window that selects a display. */
- Atom type; /* The desired conversion type for this
- * clipboard item, e.g. STRING or LENGTH. */
- Atom format; /* Format in which the selection
- * information should be returned to
- * the requestor. */
- char* buffer; /* NULL terminated string containing the data
- * to be added to the clipboard. */
-{
- TkWindow *winPtr = (TkWindow *) tkwin;
- TkDisplay *dispPtr = winPtr->dispPtr;
- TkClipboardTarget *targetPtr;
- TkClipboardBuffer *cbPtr;
-
- /*
- * If this application doesn't already own the clipboard, clear
- * the clipboard. If we don't own the clipboard selection, claim it.
- */
-
- if (dispPtr->clipboardAppPtr != winPtr->mainPtr) {
- Tk_ClipboardClear(interp, tkwin);
- } else if (!dispPtr->clipboardActive) {
- Tk_OwnSelection(dispPtr->clipWindow, dispPtr->clipboardAtom,
- ClipboardLostSel, (ClientData) dispPtr);
- dispPtr->clipboardActive = 1;
- }
-
- /*
- * Check to see if the specified target is already present on the
- * clipboard. If it isn't, we need to create a new target; otherwise,
- * we just append the new buffer to the clipboard list.
- */
-
- for (targetPtr = dispPtr->clipTargetPtr; targetPtr != NULL;
- targetPtr = targetPtr->nextPtr) {
- if (targetPtr->type == type)
- break;
- }
- if (targetPtr == NULL) {
- targetPtr = (TkClipboardTarget*) ckalloc(sizeof(TkClipboardTarget));
- targetPtr->type = type;
- targetPtr->format = format;
- targetPtr->firstBufferPtr = targetPtr->lastBufferPtr = NULL;
- targetPtr->nextPtr = dispPtr->clipTargetPtr;
- dispPtr->clipTargetPtr = targetPtr;
- Tk_CreateSelHandler(dispPtr->clipWindow, dispPtr->clipboardAtom,
- type, ClipboardHandler, (ClientData) targetPtr, format);
- } else if (targetPtr->format != format) {
- Tcl_AppendResult(interp, "format \"", Tk_GetAtomName(tkwin, format),
- "\" does not match current format \"",
- Tk_GetAtomName(tkwin, targetPtr->format),"\" for ",
- Tk_GetAtomName(tkwin, type), (char *) NULL);
- return TCL_ERROR;
- }
-
- /*
- * Append a new buffer to the buffer chain.
- */
-
- cbPtr = (TkClipboardBuffer*) ckalloc(sizeof(TkClipboardBuffer));
- cbPtr->nextPtr = NULL;
- if (targetPtr->lastBufferPtr != NULL) {
- targetPtr->lastBufferPtr->nextPtr = cbPtr;
- } else {
- targetPtr->firstBufferPtr = cbPtr;
- }
- targetPtr->lastBufferPtr = cbPtr;
-
- cbPtr->length = strlen(buffer);
- cbPtr->buffer = (char *) ckalloc((unsigned) (cbPtr->length + 1));
- strcpy(cbPtr->buffer, buffer);
-
- TkSelUpdateClipboard((TkWindow*)(dispPtr->clipWindow), targetPtr);
-
- return TCL_OK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_ClipboardCmd --
- *
- * This procedure is invoked to process the "clipboard" 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_ClipboardCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Main window associated with
- * interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- Tk_Window tkwin = (Tk_Window) clientData;
- char *path = NULL;
- size_t length;
- int count;
- char c;
- char **args;
-
- if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
- " option ?arg arg ...?\"", (char *) NULL);
- 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;
- }
- c = args[0][1];
- length = strlen(args[0]);
- if ((c == '-') && (length == 2)) {
- args++;
- count--;
- break;
- }
- 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);
- return TCL_ERROR;
- }
- }
- 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;
- }
- 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;
- }
- if (count < 2) {
- Tcl_AppendResult(interp, "value for \"", *args,
- "\" missing", (char *) 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);
- return TCL_ERROR;
- }
- }
- 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 {
- sprintf(interp->result,
- "bad option \"%.50s\": must be clear or append",
- argv[1]);
- return TCL_ERROR;
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkClipInit --
- *
- * This procedure is called to initialize the window for claiming
- * clipboard ownership and for receiving selection get results. This
- * function is called from tkSelect.c as well as tkClipboard.c.
- *
- * Results:
- * The result is a standard Tcl return value, which is normally TCL_OK.
- * If an error occurs then an error message is left in interp->result
- * and TCL_ERROR is returned.
- *
- * Side effects:
- * Sets up the clipWindow and related data structures.
- *
- *----------------------------------------------------------------------
- */
-
-int
-TkClipInit(interp, dispPtr)
- Tcl_Interp *interp; /* Interpreter to use for error
- * reporting. */
- register TkDisplay *dispPtr;/* Display to initialize. */
-{
- XSetWindowAttributes atts;
-
- dispPtr->clipTargetPtr = NULL;
- dispPtr->clipboardActive = 0;
- dispPtr->clipboardAppPtr = NULL;
-
- /*
- * Create the window used for clipboard ownership and selection retrieval,
- * and set up an event handler for it.
- */
-
- dispPtr->clipWindow = Tk_CreateWindow(interp, (Tk_Window) NULL,
- "_clip", DisplayString(dispPtr->display));
- if (dispPtr->clipWindow == NULL) {
- return TCL_ERROR;
- }
- atts.override_redirect = True;
- Tk_ChangeWindowAttributes(dispPtr->clipWindow, CWOverrideRedirect, &atts);
- Tk_MakeWindowExist(dispPtr->clipWindow);
-
- if (dispPtr->multipleAtom == None) {
- /*
- * Need to invoke selection initialization to make sure that
- * atoms we depend on below are defined.
- */
-
- TkSelInit(dispPtr->clipWindow);
- }
-
- /*
- * Create selection handlers for types TK_APPLICATION and TK_WINDOW
- * on this window. Can't use the default handlers for these types
- * because this isn't a full-fledged window.
- */
-
- Tk_CreateSelHandler(dispPtr->clipWindow, dispPtr->clipboardAtom,
- dispPtr->applicationAtom, ClipboardAppHandler,
- (ClientData) dispPtr, XA_STRING);
- Tk_CreateSelHandler(dispPtr->clipWindow, dispPtr->clipboardAtom,
- dispPtr->windowAtom, ClipboardWindowHandler,
- (ClientData) dispPtr, XA_STRING);
- return TCL_OK;
-}
diff --git a/generic/tkCmds.c b/generic/tkCmds.c
deleted file mode 100644
index 28f3202..0000000
--- a/generic/tkCmds.c
+++ /dev/null
@@ -1,1646 +0,0 @@
-/*
- * tkCmds.c --
- *
- * This file contains a collection of Tk-related Tcl commands
- * that didn't fit in any particular file of the toolkit.
- *
- * 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: tkCmds.c,v 1.3 1998/09/14 18:23:08 stanton Exp $
- */
-
-#include "tkPort.h"
-#include "tkInt.h"
-#include <errno.h>
-
-/*
- * Forward declarations for procedures defined later in this file:
- */
-
-static TkWindow * GetToplevel _ANSI_ARGS_((Tk_Window tkwin));
-static char * WaitVariableProc _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, char *name1, char *name2,
- int flags));
-static void WaitVisibilityProc _ANSI_ARGS_((ClientData clientData,
- XEvent *eventPtr));
-static void WaitWindowProc _ANSI_ARGS_((ClientData clientData,
- XEvent *eventPtr));
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_BellCmd --
- *
- * This procedure is invoked to process the "bell" 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_BellCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Main window associated with interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- Tk_Window tkwin = (Tk_Window) clientData;
- size_t length;
-
- if ((argc != 1) && (argc != 3)) {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
- " ?-displayof window?\"", (char *) NULL);
- return TCL_ERROR;
- }
-
- if (argc == 3) {
- length = strlen(argv[1]);
- if ((length < 2) || (strncmp(argv[1], "-displayof", length) != 0)) {
- Tcl_AppendResult(interp, "bad option \"", argv[1],
- "\": must be -displayof", (char *) NULL);
- return TCL_ERROR;
- }
- tkwin = Tk_NameToWindow(interp, argv[2], tkwin);
- if (tkwin == NULL) {
- return TCL_ERROR;
- }
- }
- XBell(Tk_Display(tkwin), 0);
- XForceScreenSaver(Tk_Display(tkwin), ScreenSaverReset);
- XFlush(Tk_Display(tkwin));
- return TCL_OK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_BindCmd --
- *
- * This procedure is invoked to process the "bind" 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_BindCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Main window associated with interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- 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);
- return TCL_ERROR;
- }
- if (argv[1][0] == '.') {
- winPtr = (TkWindow *) Tk_NameToWindow(interp, argv[1], tkwin);
- if (winPtr == NULL) {
- return TCL_ERROR;
- }
- object = (ClientData) winPtr->pathName;
- } else {
- winPtr = (TkWindow *) clientData;
- object = (ClientData) Tk_GetUid(argv[1]);
- }
-
- if (argc == 4) {
- int append = 0;
- unsigned long mask;
-
- if (argv[3][0] == 0) {
- return Tk_DeleteBinding(interp, winPtr->mainPtr->bindingTable,
- object, argv[2]);
- }
- if (argv[3][0] == '+') {
- argv[3]++;
- append = 1;
- }
- mask = Tk_CreateBinding(interp, winPtr->mainPtr->bindingTable,
- object, argv[2], argv[3], append);
- if (mask == 0) {
- return TCL_ERROR;
- }
- } else if (argc == 3) {
- char *command;
-
- command = Tk_GetBinding(interp, winPtr->mainPtr->bindingTable,
- object, argv[2]);
- if (command == NULL) {
- Tcl_ResetResult(interp);
- return TCL_OK;
- }
- interp->result = command;
- } else {
- Tk_GetAllBindings(interp, winPtr->mainPtr->bindingTable, object);
- }
- return TCL_OK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkBindEventProc --
- *
- * This procedure is invoked by Tk_HandleEvent for each event; it
- * causes any appropriate bindings for that event to be invoked.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Depends on what bindings have been established with the "bind"
- * command.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkBindEventProc(winPtr, eventPtr)
- TkWindow *winPtr; /* Pointer to info about window. */
- XEvent *eventPtr; /* Information about event. */
-{
-#define MAX_OBJS 20
- ClientData objects[MAX_OBJS], *objPtr;
- static Tk_Uid allUid = NULL;
- TkWindow *topLevPtr;
- int i, count;
- char *p;
- Tcl_HashEntry *hPtr;
-
- if ((winPtr->mainPtr == NULL) || (winPtr->mainPtr->bindingTable == NULL)) {
- return;
- }
-
- objPtr = objects;
- if (winPtr->numTags != 0) {
- /*
- * Make a copy of the tags for the window, replacing window names
- * with pointers to the pathName from the appropriate window.
- */
-
- if (winPtr->numTags > MAX_OBJS) {
- objPtr = (ClientData *) ckalloc((unsigned)
- (winPtr->numTags * sizeof(ClientData)));
- }
- for (i = 0; i < winPtr->numTags; i++) {
- p = (char *) winPtr->tagPtr[i];
- if (*p == '.') {
- hPtr = Tcl_FindHashEntry(&winPtr->mainPtr->nameTable, p);
- if (hPtr != NULL) {
- p = ((TkWindow *) Tcl_GetHashValue(hPtr))->pathName;
- } else {
- p = NULL;
- }
- }
- objPtr[i] = (ClientData) p;
- }
- count = winPtr->numTags;
- } else {
- objPtr[0] = (ClientData) winPtr->pathName;
- objPtr[1] = (ClientData) winPtr->classUid;
- for (topLevPtr = winPtr;
- (topLevPtr != NULL) && !(topLevPtr->flags & TK_TOP_LEVEL);
- topLevPtr = topLevPtr->parentPtr) {
- /* Empty loop body. */
- }
- if ((winPtr != topLevPtr) && (topLevPtr != NULL)) {
- count = 4;
- objPtr[2] = (ClientData) topLevPtr->pathName;
- } else {
- count = 3;
- }
- if (allUid == NULL) {
- allUid = Tk_GetUid("all");
- }
- objPtr[count-1] = (ClientData) allUid;
- }
- Tk_BindEvent(winPtr->mainPtr->bindingTable, eventPtr, (Tk_Window) winPtr,
- count, objPtr);
- if (objPtr != objects) {
- ckfree((char *) objPtr);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_BindtagsCmd --
- *
- * This procedure is invoked to process the "bindtags" 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_BindtagsCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Main window associated with interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- 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);
- return TCL_ERROR;
- }
- winPtr = (TkWindow *) Tk_NameToWindow(interp, argv[1], tkwin);
- if (winPtr == NULL) {
- return TCL_ERROR;
- }
- if (argc == 2) {
- 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. */
- }
- if ((winPtr != winPtr2) && (winPtr2 != NULL)) {
- Tcl_AppendElement(interp, winPtr2->pathName);
- }
- Tcl_AppendElement(interp, "all");
- } else {
- for (i = 0; i < winPtr->numTags; i++) {
- Tcl_AppendElement(interp, (char *) winPtr->tagPtr[i]);
- }
- }
- 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) {
- return TCL_ERROR;
- }
- winPtr->numTags = tagArgc;
- winPtr->tagPtr = (ClientData *) ckalloc((unsigned)
- (tagArgc * sizeof(ClientData)));
- for (i = 0; i < tagArgc; i++) {
- p = tagArgv[i];
- if (p[0] == '.') {
- char *copy;
-
- /*
- * Handle names starting with "." specially: store a malloc'ed
- * string, rather than a Uid; at event time we'll look up the
- * name in the window table and use the corresponding window,
- * if there is one.
- */
-
- copy = (char *) ckalloc((unsigned) (strlen(p) + 1));
- strcpy(copy, p);
- winPtr->tagPtr[i] = (ClientData) copy;
- } else {
- winPtr->tagPtr[i] = (ClientData) Tk_GetUid(p);
- }
- }
- ckfree((char *) tagArgv);
- return TCL_OK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkFreeBindingTags --
- *
- * This procedure is called to free all of the binding tags
- * associated with a window; typically it is only invoked where
- * there are window-specific tags.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Any binding tags for winPtr are freed.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkFreeBindingTags(winPtr)
- TkWindow *winPtr; /* Window whose tags are to be released. */
-{
- int i;
- char *p;
-
- for (i = 0; i < winPtr->numTags; i++) {
- p = (char *) (winPtr->tagPtr[i]);
- if (*p == '.') {
- /*
- * Names starting with "." are malloced rather than Uids, so
- * they have to be freed.
- */
-
- ckfree(p);
- }
- }
- ckfree((char *) winPtr->tagPtr);
- winPtr->numTags = 0;
- winPtr->tagPtr = NULL;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_DestroyCmd --
- *
- * This procedure is invoked to process the "destroy" 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_DestroyCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Main window associated with
- * interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- Tk_Window window;
- Tk_Window tkwin = (Tk_Window) clientData;
- int i;
-
- for (i = 1; i < argc; i++) {
- window = Tk_NameToWindow(interp, argv[i], tkwin);
- if (window == NULL) {
- Tcl_ResetResult(interp);
- continue;
- }
- Tk_DestroyWindow(window);
- if (window == tkwin) {
- /*
- * We just deleted the main window for the application! This
- * makes it impossible to do anything more (tkwin isn't
- * valid anymore).
- */
-
- break;
- }
- }
- return TCL_OK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_LowerCmd --
- *
- * This procedure is invoked to process the "lower" Tcl command.
- * See the user documentation for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
-
- /* ARGSUSED */
-int
-Tk_LowerCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Main window associated with
- * interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- Tk_Window mainwin = (Tk_Window) clientData;
- Tk_Window tkwin, other;
-
- if ((argc != 2) && (argc != 3)) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " window ?belowThis?\"", (char *) NULL);
- return TCL_ERROR;
- }
-
- tkwin = Tk_NameToWindow(interp, argv[1], mainwin);
- if (tkwin == NULL) {
- return TCL_ERROR;
- }
- if (argc == 2) {
- other = NULL;
- } else {
- other = Tk_NameToWindow(interp, argv[2], mainwin);
- if (other == NULL) {
- return TCL_ERROR;
- }
- }
- if (Tk_RestackWindow(tkwin, Below, other) != TCL_OK) {
- Tcl_AppendResult(interp, "can't lower \"", argv[1], "\" below \"",
- argv[2], "\"", (char *) NULL);
- return TCL_ERROR;
- }
- return TCL_OK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_RaiseCmd --
- *
- * This procedure is invoked to process the "raise" Tcl command.
- * See the user documentation for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
-
- /* ARGSUSED */
-int
-Tk_RaiseCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Main window associated with
- * interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- Tk_Window mainwin = (Tk_Window) clientData;
- Tk_Window tkwin, other;
-
- if ((argc != 2) && (argc != 3)) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " window ?aboveThis?\"", (char *) NULL);
- return TCL_ERROR;
- }
-
- tkwin = Tk_NameToWindow(interp, argv[1], mainwin);
- if (tkwin == NULL) {
- return TCL_ERROR;
- }
- if (argc == 2) {
- other = NULL;
- } else {
- other = Tk_NameToWindow(interp, argv[2], mainwin);
- if (other == NULL) {
- return TCL_ERROR;
- }
- }
- if (Tk_RestackWindow(tkwin, Above, other) != TCL_OK) {
- Tcl_AppendResult(interp, "can't raise \"", argv[1], "\" above \"",
- argv[2], "\"", (char *) NULL);
- return TCL_ERROR;
- }
- return TCL_OK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_TkObjCmd --
- *
- * This procedure is invoked to process the "tk" 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_TkObjCmd(clientData, interp, objc, objv)
- ClientData clientData; /* Main window associated with interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument objects. */
-{
- int index;
- Tk_Window tkwin;
- static char *optionStrings[] = {
- "appname", "scaling", NULL
- };
- enum options {
- TK_APPNAME, TK_SCALING
- };
-
- tkwin = (Tk_Window) clientData;
-
- if (objc < 2) {
- Tcl_WrongNumArgs(interp, 1, objv, "option ?arg?");
- return TCL_ERROR;
- }
- if (Tcl_GetIndexFromObj(interp, objv[1], optionStrings, "option", 0,
- &index) != TCL_OK) {
- return TCL_ERROR;
- }
-
- switch ((enum options) index) {
- case TK_APPNAME: {
- TkWindow *winPtr;
- char *string;
-
- winPtr = (TkWindow *) tkwin;
-
- if (objc > 3) {
- Tcl_WrongNumArgs(interp, 2, objv, "?newName?");
- return TCL_ERROR;
- }
- if (objc == 3) {
- string = Tcl_GetStringFromObj(objv[2], NULL);
- winPtr->nameUid = Tk_GetUid(Tk_SetAppName(tkwin, string));
- }
- Tcl_SetStringObj(Tcl_GetObjResult(interp), winPtr->nameUid, -1);
- break;
- }
- case TK_SCALING: {
- Screen *screenPtr;
- int skip, width, height;
- double d;
-
- screenPtr = Tk_Screen(tkwin);
-
- skip = TkGetDisplayOf(interp, objc - 2, objv + 2, &tkwin);
- if (skip < 0) {
- return TCL_ERROR;
- }
- if (objc - skip == 2) {
- d = 25.4 / 72;
- d *= WidthOfScreen(screenPtr);
- d /= WidthMMOfScreen(screenPtr);
- Tcl_SetDoubleObj(Tcl_GetObjResult(interp), d);
- } else if (objc - skip == 3) {
- if (Tcl_GetDoubleFromObj(interp, objv[2 + skip], &d) != TCL_OK) {
- return TCL_ERROR;
- }
- d = (25.4 / 72) / d;
- width = (int) (d * WidthOfScreen(screenPtr) + 0.5);
- if (width <= 0) {
- width = 1;
- }
- height = (int) (d * HeightOfScreen(screenPtr) + 0.5);
- if (height <= 0) {
- height = 1;
- }
- WidthMMOfScreen(screenPtr) = width;
- HeightMMOfScreen(screenPtr) = height;
- } else {
- Tcl_WrongNumArgs(interp, 2, objv,
- "?-displayof window? ?factor?");
- return TCL_ERROR;
- }
- break;
- }
- }
- return TCL_OK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_TkwaitCmd --
- *
- * This procedure is invoked to process the "tkwait" Tcl command.
- * See the user documentation for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
-
- /* ARGSUSED */
-int
-Tk_TkwaitCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Main window associated with
- * interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- Tk_Window tkwin = (Tk_Window) clientData;
- int c, done;
- size_t length;
-
- if (argc != 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " variable|visibility|window name\"", (char *) NULL);
- 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;
- }
- 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 \"", 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);
- }
- /*
- * 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;
- }
-
- /*
- * Clear out the interpreter's result, since it may have been set
- * by event handlers.
- */
-
- Tcl_ResetResult(interp);
- return TCL_OK;
-}
-
- /* ARGSUSED */
-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. */
- int flags; /* Information about what happened. */
-{
- int *donePtr = (int *) clientData;
-
- *donePtr = 1;
- return (char *) NULL;
-}
-
- /*ARGSUSED*/
-static void
-WaitVisibilityProc(clientData, eventPtr)
- ClientData clientData; /* Pointer to integer to set to 1. */
- XEvent *eventPtr; /* Information about event (not used). */
-{
- int *donePtr = (int *) clientData;
-
- if (eventPtr->type == VisibilityNotify) {
- *donePtr = 1;
- }
- if (eventPtr->type == DestroyNotify) {
- *donePtr = 2;
- }
-}
-
-static void
-WaitWindowProc(clientData, eventPtr)
- ClientData clientData; /* Pointer to integer to set to 1. */
- XEvent *eventPtr; /* Information about event. */
-{
- int *donePtr = (int *) clientData;
-
- if (eventPtr->type == DestroyNotify) {
- *donePtr = 1;
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_UpdateCmd --
- *
- * This procedure is invoked to process the "update" Tcl command.
- * See the user documentation for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
-
- /* ARGSUSED */
-int
-Tk_UpdateCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Main window associated with
- * interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- int flags;
- TkDisplay *dispPtr;
-
- if (argc == 1) {
- flags = TCL_DONT_WAIT;
- } else if (argc == 2) {
- if (strncmp(argv[1], "idletasks", strlen(argv[1])) != 0) {
- Tcl_AppendResult(interp, "bad option \"", argv[1],
- "\": must be idletasks", (char *) NULL);
- return TCL_ERROR;
- }
- flags = TCL_IDLE_EVENTS;
- } else {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " ?idletasks?\"", (char *) NULL);
- return TCL_ERROR;
- }
-
- /*
- * Handle all pending events, sync all displays, and repeat over
- * and over again until all pending events have been handled.
- * Special note: it's possible that the entire application could
- * be destroyed by an event handler that occurs during the update.
- * Thus, don't use any information from tkwin after calling
- * Tcl_DoOneEvent.
- */
-
- while (1) {
- while (Tcl_DoOneEvent(flags) != 0) {
- /* Empty loop body */
- }
- for (dispPtr = tkDisplayList; dispPtr != NULL;
- dispPtr = dispPtr->nextPtr) {
- XSync(dispPtr->display, False);
- }
- if (Tcl_DoOneEvent(flags) == 0) {
- break;
- }
- }
-
- /*
- * Must clear the interpreter's result because event handlers could
- * have executed commands.
- */
-
- Tcl_ResetResult(interp);
- return TCL_OK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_WinfoObjCmd --
- *
- * This procedure is invoked to process the "winfo" 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_WinfoObjCmd(clientData, interp, objc, objv)
- ClientData clientData; /* Main window associated with
- * interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument objects. */
-{
- int index, x, y, width, height, useX, useY, class, skip;
- char buf[128];
- char *string;
- TkWindow *winPtr;
- Tk_Window tkwin;
-
- static TkStateMap visualMap[] = {
- {PseudoColor, "pseudocolor"},
- {GrayScale, "grayscale"},
- {DirectColor, "directcolor"},
- {TrueColor, "truecolor"},
- {StaticColor, "staticcolor"},
- {StaticGray, "staticgray"},
- {-1, NULL}
- };
- static char *optionStrings[] = {
- "cells", "children", "class", "colormapfull",
- "depth", "geometry", "height", "id",
- "ismapped", "manager", "name", "parent",
- "pointerx", "pointery", "pointerxy", "reqheight",
- "reqwidth", "rootx", "rooty", "screen",
- "screencells", "screendepth", "screenheight", "screenwidth",
- "screenmmheight","screenmmwidth","screenvisual","server",
- "toplevel", "viewable", "visual", "visualid",
- "vrootheight", "vrootwidth", "vrootx", "vrooty",
- "width", "x", "y",
-
- "atom", "atomname", "containing", "interps",
- "pathname",
-
- "exists", "fpixels", "pixels", "rgb",
- "visualsavailable",
-
- NULL
- };
- enum options {
- WIN_CELLS, WIN_CHILDREN, WIN_CLASS, WIN_COLORMAPFULL,
- WIN_DEPTH, WIN_GEOMETRY, WIN_HEIGHT, WIN_ID,
- WIN_ISMAPPED, WIN_MANAGER, WIN_NAME, WIN_PARENT,
- WIN_POINTERX, WIN_POINTERY, WIN_POINTERXY, WIN_REQHEIGHT,
- WIN_REQWIDTH, WIN_ROOTX, WIN_ROOTY, WIN_SCREEN,
- WIN_SCREENCELLS,WIN_SCREENDEPTH,WIN_SCREENHEIGHT,WIN_SCREENWIDTH,
- WIN_SCREENMMHEIGHT,WIN_SCREENMMWIDTH,WIN_SCREENVISUAL,WIN_SERVER,
- WIN_TOPLEVEL, WIN_VIEWABLE, WIN_VISUAL, WIN_VISUALID,
- WIN_VROOTHEIGHT,WIN_VROOTWIDTH, WIN_VROOTX, WIN_VROOTY,
- WIN_WIDTH, WIN_X, WIN_Y,
-
- WIN_ATOM, WIN_ATOMNAME, WIN_CONTAINING, WIN_INTERPS,
- WIN_PATHNAME,
-
- WIN_EXISTS, WIN_FPIXELS, WIN_PIXELS, WIN_RGB,
- WIN_VISUALSAVAILABLE
- };
-
- tkwin = (Tk_Window) clientData;
-
- if (objc < 2) {
- Tcl_WrongNumArgs(interp, 1, objv, "option ?arg?");
- return TCL_ERROR;
- }
- if (Tcl_GetIndexFromObj(interp, objv[1], optionStrings, "option", 0,
- &index) != TCL_OK) {
- return TCL_ERROR;
- }
-
- if (index < WIN_ATOM) {
- if (objc != 3) {
- Tcl_WrongNumArgs(interp, 2, objv, "window");
- return TCL_ERROR;
- }
- string = Tcl_GetStringFromObj(objv[2], NULL);
- tkwin = Tk_NameToWindow(interp, string, tkwin);
- if (tkwin == NULL) {
- return TCL_ERROR;
- }
- }
- winPtr = (TkWindow *) tkwin;
-
- switch ((enum options) index) {
- case WIN_CELLS: {
- Tcl_ResetResult(interp);
- Tcl_SetIntObj(Tcl_GetObjResult(interp),
- Tk_Visual(tkwin)->map_entries);
- break;
- }
- case WIN_CHILDREN: {
- Tcl_Obj *strPtr;
-
- Tcl_ResetResult(interp);
- winPtr = winPtr->childList;
- for ( ; winPtr != NULL; winPtr = winPtr->nextPtr) {
- strPtr = Tcl_NewStringObj(winPtr->pathName, -1);
- Tcl_ListObjAppendElement(NULL,
- Tcl_GetObjResult(interp), strPtr);
- }
- break;
- }
- case WIN_CLASS: {
- Tcl_ResetResult(interp);
- Tcl_SetStringObj(Tcl_GetObjResult(interp), Tk_Class(tkwin), -1);
- break;
- }
- case WIN_COLORMAPFULL: {
- Tcl_ResetResult(interp);
- Tcl_SetBooleanObj(Tcl_GetObjResult(interp),
- TkpCmapStressed(tkwin, Tk_Colormap(tkwin)));
- break;
- }
- case WIN_DEPTH: {
- Tcl_ResetResult(interp);
- Tcl_SetIntObj(Tcl_GetObjResult(interp), Tk_Depth(tkwin));
- break;
- }
- case WIN_GEOMETRY: {
- Tcl_ResetResult(interp);
- sprintf(buf, "%dx%d+%d+%d", Tk_Width(tkwin), Tk_Height(tkwin),
- Tk_X(tkwin), Tk_Y(tkwin));
- Tcl_SetStringObj(Tcl_GetObjResult(interp), buf, -1);
- break;
- }
- case WIN_HEIGHT: {
- Tcl_ResetResult(interp);
- Tcl_SetIntObj(Tcl_GetObjResult(interp), Tk_Height(tkwin));
- break;
- }
- case WIN_ID: {
- Tk_MakeWindowExist(tkwin);
- TkpPrintWindowId(buf, Tk_WindowId(tkwin));
- Tcl_ResetResult(interp);
- Tcl_SetStringObj(Tcl_GetObjResult(interp), buf, -1);
- break;
- }
- case WIN_ISMAPPED: {
- Tcl_ResetResult(interp);
- Tcl_SetBooleanObj(Tcl_GetObjResult(interp),
- (int) Tk_IsMapped(tkwin));
- break;
- }
- case WIN_MANAGER: {
- Tcl_ResetResult(interp);
- if (winPtr->geomMgrPtr != NULL) {
- Tcl_SetStringObj(Tcl_GetObjResult(interp),
- winPtr->geomMgrPtr->name, -1);
- }
- break;
- }
- case WIN_NAME: {
- Tcl_ResetResult(interp);
- Tcl_SetStringObj(Tcl_GetObjResult(interp), Tk_Name(tkwin), -1);
- break;
- }
- case WIN_PARENT: {
- Tcl_ResetResult(interp);
- if (winPtr->parentPtr != NULL) {
- Tcl_SetStringObj(Tcl_GetObjResult(interp),
- winPtr->parentPtr->pathName, -1);
- }
- break;
- }
- case WIN_POINTERX: {
- useX = 1;
- useY = 0;
- goto pointerxy;
- }
- case WIN_POINTERY: {
- useX = 0;
- useY = 1;
- goto pointerxy;
- }
- case WIN_POINTERXY: {
- useX = 1;
- useY = 1;
-
- pointerxy:
- winPtr = GetToplevel(tkwin);
- if (winPtr == NULL) {
- x = -1;
- y = -1;
- } else {
- TkGetPointerCoords((Tk_Window) winPtr, &x, &y);
- }
- Tcl_ResetResult(interp);
- if (useX & useY) {
- sprintf(buf, "%d %d", x, y);
- Tcl_SetStringObj(Tcl_GetObjResult(interp), buf, -1);
- } else if (useX) {
- Tcl_SetIntObj(Tcl_GetObjResult(interp), x);
- } else {
- Tcl_SetIntObj(Tcl_GetObjResult(interp), y);
- }
- break;
- }
- case WIN_REQHEIGHT: {
- Tcl_ResetResult(interp);
- Tcl_SetIntObj(Tcl_GetObjResult(interp), Tk_ReqHeight(tkwin));
- break;
- }
- case WIN_REQWIDTH: {
- Tcl_ResetResult(interp);
- Tcl_SetIntObj(Tcl_GetObjResult(interp), Tk_ReqWidth(tkwin));
- break;
- }
- case WIN_ROOTX: {
- Tk_GetRootCoords(tkwin, &x, &y);
- Tcl_ResetResult(interp);
- Tcl_SetIntObj(Tcl_GetObjResult(interp), x);
- break;
- }
- case WIN_ROOTY: {
- Tk_GetRootCoords(tkwin, &x, &y);
- Tcl_ResetResult(interp);
- Tcl_SetIntObj(Tcl_GetObjResult(interp), y);
- break;
- }
- case WIN_SCREEN: {
- sprintf(buf, "%d", Tk_ScreenNumber(tkwin));
- Tcl_ResetResult(interp);
- Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
- Tk_DisplayName(tkwin), ".", buf, NULL);
- break;
- }
- case WIN_SCREENCELLS: {
- Tcl_ResetResult(interp);
- Tcl_SetIntObj(Tcl_GetObjResult(interp),
- CellsOfScreen(Tk_Screen(tkwin)));
- break;
- }
- case WIN_SCREENDEPTH: {
- Tcl_ResetResult(interp);
- Tcl_SetIntObj(Tcl_GetObjResult(interp),
- DefaultDepthOfScreen(Tk_Screen(tkwin)));
- break;
- }
- case WIN_SCREENHEIGHT: {
- Tcl_ResetResult(interp);
- Tcl_SetIntObj(Tcl_GetObjResult(interp),
- HeightOfScreen(Tk_Screen(tkwin)));
- break;
- }
- case WIN_SCREENWIDTH: {
- Tcl_ResetResult(interp);
- Tcl_SetIntObj(Tcl_GetObjResult(interp),
- WidthOfScreen(Tk_Screen(tkwin)));
- break;
- }
- case WIN_SCREENMMHEIGHT: {
- Tcl_ResetResult(interp);
- Tcl_SetIntObj(Tcl_GetObjResult(interp),
- HeightMMOfScreen(Tk_Screen(tkwin)));
- break;
- }
- case WIN_SCREENMMWIDTH: {
- Tcl_ResetResult(interp);
- Tcl_SetIntObj(Tcl_GetObjResult(interp),
- WidthMMOfScreen(Tk_Screen(tkwin)));
- break;
- }
- case WIN_SCREENVISUAL: {
- class = DefaultVisualOfScreen(Tk_Screen(tkwin))->class;
- goto visual;
- }
- case WIN_SERVER: {
- TkGetServerInfo(interp, tkwin);
- break;
- }
- case WIN_TOPLEVEL: {
- winPtr = GetToplevel(tkwin);
- if (winPtr != NULL) {
- Tcl_ResetResult(interp);
- Tcl_SetStringObj(Tcl_GetObjResult(interp),
- winPtr->pathName, -1);
- }
- break;
- }
- case WIN_VIEWABLE: {
- int viewable;
-
- viewable = 0;
- for ( ; ; winPtr = winPtr->parentPtr) {
- if ((winPtr == NULL) || !(winPtr->flags & TK_MAPPED)) {
- break;
- }
- if (winPtr->flags & TK_TOP_LEVEL) {
- viewable = 1;
- break;
- }
- }
- Tcl_ResetResult(interp);
- Tcl_SetBooleanObj(Tcl_GetObjResult(interp), viewable);
- break;
- }
- case WIN_VISUAL: {
- class = Tk_Visual(tkwin)->class;
-
- visual:
- string = TkFindStateString(visualMap, class);
- if (string == NULL) {
- string = "unknown";
- }
- Tcl_ResetResult(interp);
- Tcl_SetStringObj(Tcl_GetObjResult(interp), string, -1);
- break;
- }
- case WIN_VISUALID: {
- Tcl_ResetResult(interp);
- sprintf(buf, "0x%x",
- (unsigned int) XVisualIDFromVisual(Tk_Visual(tkwin)));
- Tcl_SetStringObj(Tcl_GetObjResult(interp), buf, -1);
- break;
- }
- case WIN_VROOTHEIGHT: {
- Tk_GetVRootGeometry(tkwin, &x, &y, &width, &height);
- Tcl_ResetResult(interp);
- Tcl_SetIntObj(Tcl_GetObjResult(interp), height);
- break;
- }
- case WIN_VROOTWIDTH: {
- Tk_GetVRootGeometry(tkwin, &x, &y, &width, &height);
- Tcl_ResetResult(interp);
- Tcl_SetIntObj(Tcl_GetObjResult(interp), width);
- break;
- }
- case WIN_VROOTX: {
- Tk_GetVRootGeometry(tkwin, &x, &y, &width, &height);
- Tcl_ResetResult(interp);
- Tcl_SetIntObj(Tcl_GetObjResult(interp), x);
- break;
- }
- case WIN_VROOTY: {
- Tk_GetVRootGeometry(tkwin, &x, &y, &width, &height);
- Tcl_ResetResult(interp);
- Tcl_SetIntObj(Tcl_GetObjResult(interp), y);
- break;
- }
- case WIN_WIDTH: {
- Tcl_ResetResult(interp);
- Tcl_SetIntObj(Tcl_GetObjResult(interp), Tk_Width(tkwin));
- break;
- }
- case WIN_X: {
- Tcl_ResetResult(interp);
- Tcl_SetIntObj(Tcl_GetObjResult(interp), Tk_X(tkwin));
- break;
- }
- case WIN_Y: {
- Tcl_ResetResult(interp);
- Tcl_SetIntObj(Tcl_GetObjResult(interp), Tk_Y(tkwin));
- break;
- }
-
- /*
- * Uses -displayof.
- */
-
- case WIN_ATOM: {
- skip = TkGetDisplayOf(interp, objc - 2, objv + 2, &tkwin);
- if (skip < 0) {
- return TCL_ERROR;
- }
- if (objc - skip != 3) {
- Tcl_WrongNumArgs(interp, 2, objv, "?-displayof window? name");
- return TCL_ERROR;
- }
- objv += skip;
- string = Tcl_GetStringFromObj(objv[2], NULL);
- Tcl_ResetResult(interp);
- Tcl_SetLongObj(Tcl_GetObjResult(interp),
- (long) Tk_InternAtom(tkwin, string));
- break;
- }
- case WIN_ATOMNAME: {
- char *name;
- long id;
-
- skip = TkGetDisplayOf(interp, objc - 2, objv + 2, &tkwin);
- if (skip < 0) {
- return TCL_ERROR;
- }
- if (objc - skip != 3) {
- Tcl_WrongNumArgs(interp, 2, objv, "?-displayof window? id");
- return TCL_ERROR;
- }
- objv += skip;
- if (Tcl_GetLongFromObj(interp, objv[2], &id) != TCL_OK) {
- return TCL_ERROR;
- }
- Tcl_ResetResult(interp);
- name = Tk_GetAtomName(tkwin, (Atom) id);
- if (strcmp(name, "?bad atom?") == 0) {
- string = Tcl_GetStringFromObj(objv[2], NULL);
- Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
- "no atom exists with id \"", string, "\"", NULL);
- return TCL_ERROR;
- }
- Tcl_SetStringObj(Tcl_GetObjResult(interp), name, -1);
- break;
- }
- case WIN_CONTAINING: {
- skip = TkGetDisplayOf(interp, objc - 2, objv + 2, &tkwin);
- if (skip < 0) {
- return TCL_ERROR;
- }
- if (objc - skip != 4) {
- Tcl_WrongNumArgs(interp, 2, objv,
- "?-displayof window? rootX rootY");
- return TCL_ERROR;
- }
- objv += skip;
- string = Tcl_GetStringFromObj(objv[2], NULL);
- if (Tk_GetPixels(interp, tkwin, string, &x) != TCL_OK) {
- return TCL_ERROR;
- }
- string = Tcl_GetStringFromObj(objv[3], NULL);
- if (Tk_GetPixels(interp, tkwin, string, &y) != TCL_OK) {
- return TCL_ERROR;
- }
- tkwin = Tk_CoordsToWindow(x, y, tkwin);
- if (tkwin != NULL) {
- Tcl_ResetResult(interp);
- Tcl_SetStringObj(Tcl_GetObjResult(interp),
- Tk_PathName(tkwin), -1);
- }
- break;
- }
- case WIN_INTERPS: {
- int result;
-
- skip = TkGetDisplayOf(interp, objc - 2, objv + 2, &tkwin);
- if (skip < 0) {
- return TCL_ERROR;
- }
- if (objc - skip != 2) {
- Tcl_WrongNumArgs(interp, 2, objv, "?-displayof window?");
- return TCL_ERROR;
- }
- result = TkGetInterpNames(interp, tkwin);
- return result;
- }
- case WIN_PATHNAME: {
- int id;
-
- skip = TkGetDisplayOf(interp, objc - 2, objv + 2, &tkwin);
- if (skip < 0) {
- return TCL_ERROR;
- }
- if (objc - skip != 3) {
- Tcl_WrongNumArgs(interp, 2, objv, "?-displayof window? id");
- return TCL_ERROR;
- }
- string = Tcl_GetStringFromObj(objv[2 + skip], NULL);
- if (TkpScanWindowId(interp, string, &id) != TCL_OK) {
- return TCL_ERROR;
- }
- winPtr = (TkWindow *)
- Tk_IdToWindow(Tk_Display(tkwin), (Window) id);
- if ((winPtr == NULL) ||
- (winPtr->mainPtr != ((TkWindow *) tkwin)->mainPtr)) {
- Tcl_ResetResult(interp);
- Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
- "window id \"", string,
- "\" doesn't exist in this application", (char *) NULL);
- return TCL_ERROR;
- }
-
- /*
- * If the window is a utility window with no associated path
- * (such as a wrapper window or send communication window), just
- * return an empty string.
- */
-
- tkwin = (Tk_Window) winPtr;
- if (Tk_PathName(tkwin) != NULL) {
- Tcl_ResetResult(interp);
- Tcl_SetStringObj(Tcl_GetObjResult(interp),
- Tk_PathName(tkwin), -1);
- }
- break;
- }
-
- /*
- * objv[3] is window.
- */
-
- case WIN_EXISTS: {
- int alive;
-
- if (objc != 3) {
- Tcl_WrongNumArgs(interp, 2, objv, "window");
- return TCL_ERROR;
- }
- string = Tcl_GetStringFromObj(objv[2], NULL);
- winPtr = (TkWindow *) Tk_NameToWindow(interp, string, tkwin);
- alive = 1;
- if ((winPtr == NULL) || (winPtr->flags & TK_ALREADY_DEAD)) {
- alive = 0;
- }
- Tcl_ResetResult(interp); /* clear any error msg */
- Tcl_SetBooleanObj(Tcl_GetObjResult(interp), alive);
- break;
- }
- case WIN_FPIXELS: {
- double mm, pixels;
-
- if (objc != 4) {
- Tcl_WrongNumArgs(interp, 2, objv, "window number");
- return TCL_ERROR;
- }
- string = Tcl_GetStringFromObj(objv[2], NULL);
- tkwin = Tk_NameToWindow(interp, string, tkwin);
- if (tkwin == NULL) {
- return TCL_ERROR;
- }
- string = Tcl_GetStringFromObj(objv[3], NULL);
- if (Tk_GetScreenMM(interp, tkwin, string, &mm) != TCL_OK) {
- return TCL_ERROR;
- }
- pixels = mm * WidthOfScreen(Tk_Screen(tkwin))
- / WidthMMOfScreen(Tk_Screen(tkwin));
- Tcl_ResetResult(interp);
- Tcl_SetDoubleObj(Tcl_GetObjResult(interp), pixels);
- break;
- }
- case WIN_PIXELS: {
- int pixels;
-
- if (objc != 4) {
- Tcl_WrongNumArgs(interp, 2, objv, "window number");
- return TCL_ERROR;
- }
- string = Tcl_GetStringFromObj(objv[2], NULL);
- tkwin = Tk_NameToWindow(interp, string, tkwin);
- if (tkwin == NULL) {
- return TCL_ERROR;
- }
- string = Tcl_GetStringFromObj(objv[3], NULL);
- if (Tk_GetPixels(interp, tkwin, string, &pixels) != TCL_OK) {
- return TCL_ERROR;
- }
- Tcl_ResetResult(interp);
- Tcl_SetIntObj(Tcl_GetObjResult(interp), pixels);
- break;
- }
- case WIN_RGB: {
- XColor *colorPtr;
-
- if (objc != 4) {
- Tcl_WrongNumArgs(interp, 2, objv, "window colorName");
- return TCL_ERROR;
- }
- string = Tcl_GetStringFromObj(objv[2], NULL);
- tkwin = Tk_NameToWindow(interp, string, tkwin);
- if (tkwin == NULL) {
- return TCL_ERROR;
- }
- string = Tcl_GetStringFromObj(objv[3], NULL);
- colorPtr = Tk_GetColor(interp, tkwin, string);
- if (colorPtr == NULL) {
- return TCL_ERROR;
- }
- sprintf(buf, "%d %d %d", colorPtr->red, colorPtr->green,
- colorPtr->blue);
- Tk_FreeColor(colorPtr);
- Tcl_ResetResult(interp);
- Tcl_SetStringObj(Tcl_GetObjResult(interp), buf, -1);
- break;
- }
- case WIN_VISUALSAVAILABLE: {
- XVisualInfo template, *visInfoPtr;
- int count, i;
- char visualIdString[16];
- int includeVisualId;
- Tcl_Obj *strPtr;
-
- if (objc == 3) {
- includeVisualId = 0;
- } else if ((objc == 4)
- && (strcmp(Tcl_GetStringFromObj(objv[3], NULL),
- "includeids") == 0)) {
- includeVisualId = 1;
- } else {
- Tcl_WrongNumArgs(interp, 2, objv, "window ?includeids?");
- return TCL_ERROR;
- }
-
- string = Tcl_GetStringFromObj(objv[2], NULL);
- tkwin = Tk_NameToWindow(interp, string, tkwin);
- if (tkwin == NULL) {
- return TCL_ERROR;
- }
-
- template.screen = Tk_ScreenNumber(tkwin);
- visInfoPtr = XGetVisualInfo(Tk_Display(tkwin), VisualScreenMask,
- &template, &count);
- Tcl_ResetResult(interp);
- if (visInfoPtr == NULL) {
- Tcl_SetStringObj(Tcl_GetObjResult(interp),
- "can't find any visuals for screen", -1);
- return TCL_ERROR;
- }
- for (i = 0; i < count; i++) {
- string = TkFindStateString(visualMap, visInfoPtr[i].class);
- if (string == NULL) {
- strcpy(buf, "unknown");
- } else {
- sprintf(buf, "%s %d", string, visInfoPtr[i].depth);
- }
- if (includeVisualId) {
- sprintf(visualIdString, " 0x%x",
- (unsigned int) visInfoPtr[i].visualid);
- strcat(buf, visualIdString);
- }
- strPtr = Tcl_NewStringObj(buf, -1);
- Tcl_ListObjAppendElement(NULL, Tcl_GetObjResult(interp),
- strPtr);
- }
- XFree((char *) visInfoPtr);
- break;
- }
- }
- return TCL_OK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkGetDisplayOf --
- *
- * Parses a "-displayof window" option for various commands. If
- * present, the literal "-displayof" should be in objv[0] and the
- * window name in objv[1].
- *
- * Results:
- * The return value is 0 if the argument strings did not contain
- * the "-displayof" option. The return value is 2 if the
- * argument strings contained both the "-displayof" option and
- * a valid window name. Otherwise, the return value is -1 if
- * the window name was missing or did not specify a valid window.
- *
- * If the return value was 2, *tkwinPtr is filled with the
- * token for the window specified on the command line. If the
- * return value was -1, an error message is left in interp's
- * result object.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-int
-TkGetDisplayOf(interp, objc, objv, tkwinPtr)
- Tcl_Interp *interp; /* Interpreter for error reporting. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument objects. If it is present,
- * "-displayof" should be in objv[0] and
- * objv[1] the name of a window. */
- Tk_Window *tkwinPtr; /* On input, contains main window of
- * application associated with interp. On
- * output, filled with window specified as
- * option to "-displayof" argument, or
- * unmodified if "-displayof" argument was not
- * present. */
-{
- char *string;
- int length;
-
- if (objc < 1) {
- return 0;
- }
- string = Tcl_GetStringFromObj(objv[0], &length);
- if ((length >= 2) && (strncmp(string, "-displayof", (unsigned) length) == 0)) {
- if (objc < 2) {
- Tcl_SetStringObj(Tcl_GetObjResult(interp),
- "value for \"-displayof\" missing", -1);
- return -1;
- }
- string = Tcl_GetStringFromObj(objv[1], NULL);
- *tkwinPtr = Tk_NameToWindow(interp, string, *tkwinPtr);
- if (*tkwinPtr == NULL) {
- return -1;
- }
- return 2;
- }
- return 0;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkDeadAppCmd --
- *
- * If an application has been deleted then all Tk commands will be
- * re-bound to this procedure.
- *
- * Results:
- * A standard Tcl error is reported to let the user know that
- * the application is dead.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
-
- /* ARGSUSED */
-int
-TkDeadAppCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Dummy. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- Tcl_AppendResult(interp, "can't invoke \"", argv[0],
- "\" command: application has been destroyed", (char *) NULL);
- return TCL_ERROR;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * GetToplevel --
- *
- * Retrieves the toplevel window which is the nearest ancestor of
- * of the specified window.
- *
- * Results:
- * Returns the toplevel window or NULL if the window has no
- * ancestor which is a toplevel.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static TkWindow *
-GetToplevel(tkwin)
- Tk_Window tkwin; /* Window for which the toplevel should be
- * deterined. */
-{
- TkWindow *winPtr = (TkWindow *) tkwin;
-
- while (!(winPtr->flags & TK_TOP_LEVEL)) {
- winPtr = winPtr->parentPtr;
- if (winPtr == NULL) {
- return NULL;
- }
- }
- return winPtr;
-}
diff --git a/generic/tkColor.c b/generic/tkColor.c
deleted file mode 100644
index 108bf70..0000000
--- a/generic/tkColor.c
+++ /dev/null
@@ -1,397 +0,0 @@
-/*
- * tkColor.c --
- *
- * This file maintains a database of color values for the Tk
- * toolkit, in order to avoid round-trips to the server to
- * map color names to pixel values.
- *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1995 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: tkColor.c,v 1.2 1998/09/14 18:23:08 stanton Exp $
- */
-
-#include <tkColor.h>
-
-/*
- * A two-level data structure is used to manage the color database.
- * The top level consists of one entry for each color name that is
- * currently active, and the bottom level contains one entry for each
- * pixel value that is still in use. The distinction between
- * levels is necessary because the same pixel may have several
- * different names. There are two hash tables, one used to index into
- * each of the data structures. The name hash table is used when
- * allocating colors, and the pixel hash table is used when freeing
- * colors.
- */
-
-
-/*
- * Hash table for name -> TkColor mapping, and key structure used to
- * index into that table:
- */
-
-static Tcl_HashTable nameTable;
-typedef struct {
- Tk_Uid name; /* Name of desired color. */
- Colormap colormap; /* Colormap from which color will be
- * allocated. */
- Display *display; /* Display for colormap. */
-} NameKey;
-
-/*
- * Hash table for value -> TkColor mapping, and key structure used to
- * index into that table:
- */
-
-static Tcl_HashTable valueTable;
-typedef struct {
- int red, green, blue; /* Values for desired color. */
- Colormap colormap; /* Colormap from which color will be
- * allocated. */
- Display *display; /* Display for colormap. */
-} ValueKey;
-
-static int initialized = 0; /* 0 means static structures haven't been
- * initialized yet. */
-
-/*
- * Forward declarations for procedures defined in this file:
- */
-
-static void ColorInit _ANSI_ARGS_((void));
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_GetColor --
- *
- * Given a string name for a color, map the name to a corresponding
- * XColor structure.
- *
- * Results:
- * The return value is a pointer to an XColor structure that
- * indicates the red, blue, and green intensities for the color
- * given by "name", and also specifies a pixel value to use to
- * draw in that color. If an error occurs, NULL is returned and
- * an error message will be left in interp->result.
- *
- * Side effects:
- * The color is added to an internal database with a reference count.
- * For each call to this procedure, there should eventually be a call
- * to Tk_FreeColor so that the database is cleaned up when colors
- * aren't in use anymore.
- *
- *----------------------------------------------------------------------
- */
-
-XColor *
-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. */
- Tk_Uid name; /* Name of color to allocated (in form
- * suitable for passing to XParseColor). */
-{
- NameKey nameKey;
- Tcl_HashEntry *nameHashPtr;
- int new;
- TkColor *tkColPtr;
- Display *display = Tk_Display(tkwin);
-
- if (!initialized) {
- ColorInit();
- }
-
- /*
- * First, check to see if there's already a mapping for this color
- * name.
- */
-
- nameKey.name = name;
- nameKey.colormap = Tk_Colormap(tkwin);
- nameKey.display = display;
- nameHashPtr = Tcl_CreateHashEntry(&nameTable, (char *) &nameKey, &new);
- if (!new) {
- tkColPtr = (TkColor *) Tcl_GetHashValue(nameHashPtr);
- tkColPtr->refCount++;
- return &tkColPtr->color;
- }
-
- /*
- * The name isn't currently known. Map from the name to a pixel
- * value.
- */
-
- tkColPtr = TkpGetColor(tkwin, name);
- if (tkColPtr == NULL) {
- if (interp != NULL) {
- if (*name == '#') {
- Tcl_AppendResult(interp, "invalid color name \"", name,
- "\"", (char *) NULL);
- } else {
- Tcl_AppendResult(interp, "unknown color name \"", name,
- "\"", (char *) NULL);
- }
- }
- Tcl_DeleteHashEntry(nameHashPtr);
- return (XColor *) NULL;
- }
-
- /*
- * Now create a new TkColor structure and add it to nameTable.
- */
-
- tkColPtr->magic = COLOR_MAGIC;
- tkColPtr->gc = None;
- tkColPtr->screen = Tk_Screen(tkwin);
- tkColPtr->colormap = nameKey.colormap;
- tkColPtr->visual = Tk_Visual(tkwin);
- tkColPtr->refCount = 1;
- tkColPtr->tablePtr = &nameTable;
- tkColPtr->hashPtr = nameHashPtr;
- Tcl_SetHashValue(nameHashPtr, tkColPtr);
-
- return &tkColPtr->color;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_GetColorByValue --
- *
- * Given a desired set of red-green-blue intensities for a color,
- * locate a pixel value to use to draw that color in a given
- * window.
- *
- * Results:
- * The return value is a pointer to an XColor structure that
- * indicates the closest red, blue, and green intensities available
- * to those specified in colorPtr, and also specifies a pixel
- * value to use to draw in that color.
- *
- * Side effects:
- * The color is added to an internal database with a reference count.
- * For each call to this procedure, there should eventually be a call
- * to Tk_FreeColor, so that the database is cleaned up when colors
- * aren't in use anymore.
- *
- *----------------------------------------------------------------------
- */
-
-XColor *
-Tk_GetColorByValue(tkwin, colorPtr)
- Tk_Window tkwin; /* Window where color will be used. */
- XColor *colorPtr; /* Red, green, and blue fields indicate
- * desired color. */
-{
- ValueKey valueKey;
- Tcl_HashEntry *valueHashPtr;
- int new;
- TkColor *tkColPtr;
- Display *display = Tk_Display(tkwin);
-
- if (!initialized) {
- ColorInit();
- }
-
- /*
- * First, check to see if there's already a mapping for this color
- * name.
- */
-
- valueKey.red = colorPtr->red;
- valueKey.green = colorPtr->green;
- valueKey.blue = colorPtr->blue;
- valueKey.colormap = Tk_Colormap(tkwin);
- valueKey.display = display;
- valueHashPtr = Tcl_CreateHashEntry(&valueTable, (char *) &valueKey, &new);
- if (!new) {
- tkColPtr = (TkColor *) Tcl_GetHashValue(valueHashPtr);
- tkColPtr->refCount++;
- return &tkColPtr->color;
- }
-
- /*
- * The name isn't currently known. Find a pixel value for this
- * color and add a new structure to valueTable.
- */
-
- tkColPtr = TkpGetColorByValue(tkwin, colorPtr);
- tkColPtr->magic = COLOR_MAGIC;
- tkColPtr->gc = None;
- tkColPtr->screen = Tk_Screen(tkwin);
- tkColPtr->colormap = valueKey.colormap;
- tkColPtr->visual = Tk_Visual(tkwin);
- tkColPtr->refCount = 1;
- tkColPtr->tablePtr = &valueTable;
- tkColPtr->hashPtr = valueHashPtr;
- Tcl_SetHashValue(valueHashPtr, tkColPtr);
- return &tkColPtr->color;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_NameOfColor --
- *
- * Given a color, return a textual string identifying
- * the color.
- *
- * Results:
- * If colorPtr was created by Tk_GetColor, then the return
- * value is the "string" that was used to create it.
- * Otherwise the return value is a string that could have
- * been passed to Tk_GetColor to allocate that color. The
- * storage for the returned string is only guaranteed to
- * persist up until the next call to this procedure.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-char *
-Tk_NameOfColor(colorPtr)
- XColor *colorPtr; /* Color whose name is desired. */
-{
- register TkColor *tkColPtr = (TkColor *) colorPtr;
- static char string[20];
-
- if ((tkColPtr->magic == COLOR_MAGIC)
- && (tkColPtr->tablePtr == &nameTable)) {
- return ((NameKey *) tkColPtr->hashPtr->key.words)->name;
- }
- sprintf(string, "#%04x%04x%04x", colorPtr->red, colorPtr->green,
- colorPtr->blue);
- return string;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_GCForColor --
- *
- * Given a color allocated from this module, this procedure
- * returns a GC that can be used for simple drawing with that
- * color.
- *
- * Results:
- * The return value is a GC with color set as its foreground
- * color and all other fields defaulted. This GC is only valid
- * as long as the color exists; it is freed automatically when
- * the last reference to the color is freed.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-GC
-Tk_GCForColor(colorPtr, drawable)
- XColor *colorPtr; /* Color for which a GC is desired. Must
- * have been allocated by Tk_GetColor or
- * Tk_GetColorByName. */
- Drawable drawable; /* Drawable in which the color will be
- * used (must have same screen and depth
- * as the one for which the color was
- * allocated). */
-{
- TkColor *tkColPtr = (TkColor *) colorPtr;
- XGCValues gcValues;
-
- /*
- * Do a quick sanity check to make sure this color was really
- * allocated by Tk_GetColor.
- */
-
- if (tkColPtr->magic != COLOR_MAGIC) {
- panic("Tk_GCForColor called with bogus color");
- }
-
- if (tkColPtr->gc == None) {
- gcValues.foreground = tkColPtr->color.pixel;
- tkColPtr->gc = XCreateGC(DisplayOfScreen(tkColPtr->screen),
- drawable, GCForeground, &gcValues);
- }
- return tkColPtr->gc;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_FreeColor --
- *
- * This procedure is called to release a color allocated by
- * Tk_GetColor.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The reference count associated with colorPtr is deleted, and
- * the color is released to X if there are no remaining uses
- * for it.
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tk_FreeColor(colorPtr)
- XColor *colorPtr; /* Color to be released. Must have been
- * allocated by Tk_GetColor or
- * Tk_GetColorByValue. */
-{
- register TkColor *tkColPtr = (TkColor *) colorPtr;
- Screen *screen = tkColPtr->screen;
-
- /*
- * Do a quick sanity check to make sure this color was really
- * allocated by Tk_GetColor.
- */
-
- if (tkColPtr->magic != COLOR_MAGIC) {
- panic("Tk_FreeColor called with bogus color");
- }
-
- tkColPtr->refCount--;
- if (tkColPtr->refCount == 0) {
- if (tkColPtr->gc != None) {
- XFreeGC(DisplayOfScreen(screen), tkColPtr->gc);
- tkColPtr->gc = None;
- }
- TkpFreeColor(tkColPtr);
- Tcl_DeleteHashEntry(tkColPtr->hashPtr);
- tkColPtr->magic = 0;
- ckfree((char *) tkColPtr);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ColorInit --
- *
- * Initialize the structure used for color management.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Read the code.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-ColorInit()
-{
- initialized = 1;
- Tcl_InitHashTable(&nameTable, sizeof(NameKey)/sizeof(int));
- Tcl_InitHashTable(&valueTable, sizeof(ValueKey)/sizeof(int));
-}
diff --git a/generic/tkColor.h b/generic/tkColor.h
deleted file mode 100644
index 8aa2e59..0000000
--- a/generic/tkColor.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * tkColor.h --
- *
- * Declarations of data types and functions used by the
- * Tk color module.
- *
- * Copyright (c) 1996 by 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: tkColor.h,v 1.4 1998/09/14 18:23:08 stanton Exp $
- */
-
-#ifndef _TKCOLOR
-#define _TKCOLOR
-
-#include <tkInt.h>
-
-#ifdef BUILD_tk
-# undef TCL_STORAGE_CLASS
-# define TCL_STORAGE_CLASS DLLEXPORT
-#endif
-
-/*
- * One of the following data structures is used to keep track of
- * each color that the color module has allocated from the X display
- * server.
- */
-
-#define COLOR_MAGIC ((unsigned int) 0x46140277)
-
-typedef struct TkColor {
- XColor color; /* Information about this color. */
- unsigned int magic; /* Used for quick integrity check on this
- * structure. Must always have the
- * value COLOR_MAGIC. */
- GC gc; /* Simple gc with this color as foreground
- * color and all other fields defaulted.
- * May be None. */
- Screen *screen; /* Screen where this color is valid. Used
- * to delete it, and to find its display. */
- Colormap colormap; /* Colormap from which this entry was
- * allocated. */
- Visual *visual; /* Visual associated with colormap. */
- int refCount; /* Number of uses of this structure. */
- Tcl_HashTable *tablePtr; /* Hash table that indexes this structure
- * (needed when deleting structure). */
- Tcl_HashEntry *hashPtr; /* Pointer to hash table entry for this
- * structure. (for use in deleting entry). */
-} TkColor;
-
-/*
- * Common APIs exported from all platform-specific implementations.
- */
-
-#ifndef TkpFreeColor
-EXTERN void TkpFreeColor _ANSI_ARGS_((TkColor *tkColPtr));
-#endif
-EXTERN TkColor * TkpGetColor _ANSI_ARGS_((Tk_Window tkwin,
- Tk_Uid name));
-EXTERN TkColor * TkpGetColorByValue _ANSI_ARGS_((Tk_Window tkwin,
- XColor *colorPtr));
-
-# undef TCL_STORAGE_CLASS
-# define TCL_STORAGE_CLASS DLLIMPORT
-
-#endif /* _TKCOLOR */
diff --git a/generic/tkConfig.c b/generic/tkConfig.c
deleted file mode 100644
index 9714feb..0000000
--- a/generic/tkConfig.c
+++ /dev/null
@@ -1,990 +0,0 @@
-/*
- * tkConfig.c --
- *
- * This file contains the Tk_ConfigureWidget procedure.
- *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1995 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: tkConfig.c,v 1.2 1998/09/14 18:23:08 stanton Exp $
- */
-
-#include "tkPort.h"
-#include "tk.h"
-
-/*
- * Values for "flags" field of Tk_ConfigSpec structures. Be sure
- * to coordinate these values with those defined in tk.h
- * (TK_CONFIG_COLOR_ONLY, etc.). There must not be overlap!
- *
- * INIT - Non-zero means (char *) things have been
- * converted to Tk_Uid's.
- */
-
-#define INIT 0x20
-
-/*
- * Forward declarations for procedures defined later in this file:
- */
-
-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,
- 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,
- Tk_Window tkwin, Tk_ConfigSpec *specPtr,
- char *widgRec, char *buffer,
- Tcl_FreeProc **freeProcPtr));
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_ConfigureWidget --
- *
- * Process command-line options and database options to
- * fill in fields of a widget record with resources and
- * other parameters.
- *
- * Results:
- * A standard Tcl return value. In case of an error,
- * interp->result will hold an error message.
- *
- * Side effects:
- * The fields of widgRec get filled in with information
- * from argc/argv and the option database. Old information
- * in widgRec's fields gets recycled.
- *
- *--------------------------------------------------------------
- */
-
-int
-Tk_ConfigureWidget(interp, tkwin, specs, argc, argv, widgRec, flags)
- Tcl_Interp *interp; /* Interpreter for error reporting. */
- Tk_Window tkwin; /* Window containing widget (needed to
- * set up X resources). */
- Tk_ConfigSpec *specs; /* Describes legal options. */
- int argc; /* Number of elements in argv. */
- char **argv; /* Command-line options. */
- char *widgRec; /* Record whose fields are to be
- * modified. Values must be properly
- * initialized. */
- int flags; /* Used to specify additional flags
- * that must be present in config specs
- * for them to be considered. Also,
- * may have TK_CONFIG_ARGV_ONLY set. */
-{
- register Tk_ConfigSpec *specPtr;
- Tk_Uid value; /* Value of option from database. */
- int needFlags; /* Specs must contain this set of flags
- * or else they are not considered. */
- int hateFlags; /* If a spec contains any bits here, it's
- * not considered. */
-
- needFlags = flags & ~(TK_CONFIG_USER_BIT - 1);
- if (Tk_Depth(tkwin) <= 1) {
- hateFlags = TK_CONFIG_COLOR_ONLY;
- } else {
- hateFlags = TK_CONFIG_MONO_ONLY;
- }
-
- /*
- * Pass one: scan through all the option specs, replacing strings
- * with Tk_Uids (if this hasn't been done already) and clearing
- * the TK_CONFIG_OPTION_SPECIFIED flags.
- */
-
- for (specPtr = specs; specPtr->type != TK_CONFIG_END; specPtr++) {
- if (!(specPtr->specFlags & INIT) && (specPtr->argvName != NULL)) {
- if (specPtr->dbName != NULL) {
- specPtr->dbName = Tk_GetUid(specPtr->dbName);
- }
- if (specPtr->dbClass != NULL) {
- specPtr->dbClass = Tk_GetUid(specPtr->dbClass);
- }
- if (specPtr->defValue != NULL) {
- specPtr->defValue = Tk_GetUid(specPtr->defValue);
- }
- }
- specPtr->specFlags = (specPtr->specFlags & ~TK_CONFIG_OPTION_SPECIFIED)
- | INIT;
- }
-
- /*
- * Pass two: scan through all of the arguments, processing those
- * that match entries in the specs.
- */
-
- for ( ; argc > 0; argc -= 2, argv += 2) {
- specPtr = FindConfigSpec(interp, specs, *argv, needFlags, hateFlags);
- if (specPtr == NULL) {
- return TCL_ERROR;
- }
-
- /*
- * Process the entry.
- */
-
- if (argc < 2) {
- Tcl_AppendResult(interp, "value for \"", *argv,
- "\" missing", (char *) NULL);
- return TCL_ERROR;
- }
- if (DoConfig(interp, tkwin, specPtr, argv[1], 0, widgRec) != TCL_OK) {
- char msg[100];
-
- sprintf(msg, "\n (processing \"%.40s\" option)",
- specPtr->argvName);
- Tcl_AddErrorInfo(interp, msg);
- return TCL_ERROR;
- }
- specPtr->specFlags |= TK_CONFIG_OPTION_SPECIFIED;
- }
-
- /*
- * Pass three: scan through all of the specs again; if no
- * command-line argument matched a spec, then check for info
- * in the option database. If there was nothing in the
- * database, then use the default.
- */
-
- if (!(flags & TK_CONFIG_ARGV_ONLY)) {
- for (specPtr = specs; specPtr->type != TK_CONFIG_END; specPtr++) {
- if ((specPtr->specFlags & TK_CONFIG_OPTION_SPECIFIED)
- || (specPtr->argvName == NULL)
- || (specPtr->type == TK_CONFIG_SYNONYM)) {
- continue;
- }
- if (((specPtr->specFlags & needFlags) != needFlags)
- || (specPtr->specFlags & hateFlags)) {
- continue;
- }
- value = NULL;
- if (specPtr->dbName != NULL) {
- value = Tk_GetOption(tkwin, specPtr->dbName, specPtr->dbClass);
- }
- if (value != NULL) {
- if (DoConfig(interp, tkwin, specPtr, value, 1, widgRec) !=
- TCL_OK) {
- char msg[200];
-
- sprintf(msg, "\n (%s \"%.50s\" in widget \"%.50s\")",
- "database entry for",
- specPtr->dbName, Tk_PathName(tkwin));
- Tcl_AddErrorInfo(interp, msg);
- return TCL_ERROR;
- }
- } else {
- value = specPtr->defValue;
- if ((value != NULL) && !(specPtr->specFlags
- & TK_CONFIG_DONT_SET_DEFAULT)) {
- if (DoConfig(interp, tkwin, specPtr, value, 1, widgRec) !=
- TCL_OK) {
- char msg[200];
-
- sprintf(msg,
- "\n (%s \"%.50s\" in widget \"%.50s\")",
- "default value for",
- specPtr->dbName, Tk_PathName(tkwin));
- Tcl_AddErrorInfo(interp, msg);
- return TCL_ERROR;
- }
- }
- }
- }
- }
-
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * FindConfigSpec --
- *
- * Search through a table of configuration specs, looking for
- * one that matches a given argvName.
- *
- * Results:
- * The return value is a pointer to the matching entry, or NULL
- * if nothing matched. In that case an error message is left
- * in interp->result.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-static Tk_ConfigSpec *
-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"
- * command) identifying particular option. */
- int needFlags; /* Flags that must be present in matching
- * entry. */
- int hateFlags; /* Flags that must NOT be present in
- * matching entry. */
-{
- register Tk_ConfigSpec *specPtr;
- register char c; /* First character of current argument. */
- Tk_ConfigSpec *matchPtr; /* Matching spec, or NULL. */
- size_t length;
-
- c = argvName[1];
- length = strlen(argvName);
- matchPtr = NULL;
- for (specPtr = specs; specPtr->type != TK_CONFIG_END; specPtr++) {
- if (specPtr->argvName == NULL) {
- continue;
- }
- if ((specPtr->argvName[1] != c)
- || (strncmp(specPtr->argvName, argvName, length) != 0)) {
- continue;
- }
- if (((specPtr->specFlags & needFlags) != needFlags)
- || (specPtr->specFlags & hateFlags)) {
- continue;
- }
- if (specPtr->argvName[length] == 0) {
- matchPtr = specPtr;
- goto gotMatch;
- }
- if (matchPtr != NULL) {
- Tcl_AppendResult(interp, "ambiguous option \"", argvName,
- "\"", (char *) NULL);
- return (Tk_ConfigSpec *) NULL;
- }
- matchPtr = specPtr;
- }
-
- if (matchPtr == NULL) {
- Tcl_AppendResult(interp, "unknown option \"", argvName,
- "\"", (char *) NULL);
- return (Tk_ConfigSpec *) NULL;
- }
-
- /*
- * Found a matching entry. If it's a synonym, then find the
- * entry that it's a synonym for.
- */
-
- gotMatch:
- specPtr = matchPtr;
- if (specPtr->type == TK_CONFIG_SYNONYM) {
- for (specPtr = specs; ; specPtr++) {
- if (specPtr->type == TK_CONFIG_END) {
- Tcl_AppendResult(interp,
- "couldn't find synonym for option \"",
- argvName, "\"", (char *) NULL);
- return (Tk_ConfigSpec *) NULL;
- }
- if ((specPtr->dbName == matchPtr->dbName)
- && (specPtr->type != TK_CONFIG_SYNONYM)
- && ((specPtr->specFlags & needFlags) == needFlags)
- && !(specPtr->specFlags & hateFlags)) {
- break;
- }
- }
- }
- return specPtr;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * DoConfig --
- *
- * This procedure applies a single configuration option
- * to a widget record.
- *
- * Results:
- * A standard Tcl return value.
- *
- * Side effects:
- * WidgRec is modified as indicated by specPtr and value.
- * The old value is recycled, if that is appropriate for
- * the value type.
- *
- *--------------------------------------------------------------
- */
-
-static int
-DoConfig(interp, tkwin, specPtr, value, valueIsUid, widgRec)
- Tcl_Interp *interp; /* Interpreter for error reporting. */
- 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. */
- 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
- * modified. Values must be properly
- * initialized. */
-{
- char *ptr;
- Tk_Uid uid;
- int nullValue;
-
- nullValue = 0;
- if ((*value == 0) && (specPtr->specFlags & TK_CONFIG_NULL_OK)) {
- nullValue = 1;
- }
-
- do {
- ptr = widgRec + specPtr->offset;
- switch (specPtr->type) {
- case TK_CONFIG_BOOLEAN:
- if (Tcl_GetBoolean(interp, value, (int *) ptr) != TCL_OK) {
- return TCL_ERROR;
- }
- break;
- case TK_CONFIG_INT:
- if (Tcl_GetInt(interp, value, (int *) ptr) != TCL_OK) {
- return TCL_ERROR;
- }
- break;
- case TK_CONFIG_DOUBLE:
- if (Tcl_GetDouble(interp, value, (double *) ptr) != TCL_OK) {
- return TCL_ERROR;
- }
- break;
- case TK_CONFIG_STRING: {
- char *old, *new;
-
- if (nullValue) {
- new = NULL;
- } else {
- new = (char *) ckalloc((unsigned) (strlen(value) + 1));
- strcpy(new, value);
- }
- old = *((char **) ptr);
- if (old != NULL) {
- ckfree(old);
- }
- *((char **) ptr) = new;
- break;
- }
- case TK_CONFIG_UID:
- if (nullValue) {
- *((Tk_Uid *) ptr) = NULL;
- } else {
- uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value);
- *((Tk_Uid *) ptr) = uid;
- }
- break;
- case TK_CONFIG_COLOR: {
- XColor *newPtr, *oldPtr;
-
- if (nullValue) {
- newPtr = NULL;
- } else {
- uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value);
- newPtr = Tk_GetColor(interp, tkwin, uid);
- if (newPtr == NULL) {
- return TCL_ERROR;
- }
- }
- oldPtr = *((XColor **) ptr);
- if (oldPtr != NULL) {
- Tk_FreeColor(oldPtr);
- }
- *((XColor **) ptr) = newPtr;
- break;
- }
- case TK_CONFIG_FONT: {
- Tk_Font new;
-
- if (nullValue) {
- new = NULL;
- } else {
- new = Tk_GetFont(interp, tkwin, value);
- if (new == NULL) {
- return TCL_ERROR;
- }
- }
- Tk_FreeFont(*((Tk_Font *) ptr));
- *((Tk_Font *) ptr) = new;
- break;
- }
- case TK_CONFIG_BITMAP: {
- Pixmap new, old;
-
- if (nullValue) {
- new = None;
- } else {
- uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value);
- new = Tk_GetBitmap(interp, tkwin, uid);
- if (new == None) {
- return TCL_ERROR;
- }
- }
- old = *((Pixmap *) ptr);
- if (old != None) {
- Tk_FreeBitmap(Tk_Display(tkwin), old);
- }
- *((Pixmap *) ptr) = new;
- break;
- }
- case TK_CONFIG_BORDER: {
- Tk_3DBorder new, old;
-
- if (nullValue) {
- new = NULL;
- } else {
- uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value);
- new = Tk_Get3DBorder(interp, tkwin, uid);
- if (new == NULL) {
- return TCL_ERROR;
- }
- }
- old = *((Tk_3DBorder *) ptr);
- if (old != NULL) {
- Tk_Free3DBorder(old);
- }
- *((Tk_3DBorder *) ptr) = new;
- break;
- }
- case TK_CONFIG_RELIEF:
- uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value);
- if (Tk_GetRelief(interp, uid, (int *) ptr) != TCL_OK) {
- return TCL_ERROR;
- }
- break;
- case TK_CONFIG_CURSOR:
- case TK_CONFIG_ACTIVE_CURSOR: {
- Tk_Cursor new, old;
-
- if (nullValue) {
- new = None;
- } else {
- uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value);
- new = Tk_GetCursor(interp, tkwin, uid);
- if (new == None) {
- return TCL_ERROR;
- }
- }
- old = *((Tk_Cursor *) ptr);
- if (old != None) {
- Tk_FreeCursor(Tk_Display(tkwin), old);
- }
- *((Tk_Cursor *) ptr) = new;
- if (specPtr->type == TK_CONFIG_ACTIVE_CURSOR) {
- Tk_DefineCursor(tkwin, new);
- }
- break;
- }
- case TK_CONFIG_JUSTIFY:
- uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value);
- if (Tk_GetJustify(interp, uid, (Tk_Justify *) ptr) != TCL_OK) {
- return TCL_ERROR;
- }
- break;
- case TK_CONFIG_ANCHOR:
- uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value);
- if (Tk_GetAnchor(interp, uid, (Tk_Anchor *) ptr) != TCL_OK) {
- return TCL_ERROR;
- }
- break;
- case TK_CONFIG_CAP_STYLE:
- uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value);
- if (Tk_GetCapStyle(interp, uid, (int *) ptr) != TCL_OK) {
- return TCL_ERROR;
- }
- break;
- case TK_CONFIG_JOIN_STYLE:
- uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value);
- if (Tk_GetJoinStyle(interp, uid, (int *) ptr) != TCL_OK) {
- return TCL_ERROR;
- }
- break;
- case TK_CONFIG_PIXELS:
- if (Tk_GetPixels(interp, tkwin, value, (int *) ptr)
- != TCL_OK) {
- return TCL_ERROR;
- }
- break;
- case TK_CONFIG_MM:
- if (Tk_GetScreenMM(interp, tkwin, value, (double *) ptr)
- != TCL_OK) {
- return TCL_ERROR;
- }
- break;
- case TK_CONFIG_WINDOW: {
- Tk_Window tkwin2;
-
- if (nullValue) {
- tkwin2 = NULL;
- } else {
- tkwin2 = Tk_NameToWindow(interp, value, tkwin);
- if (tkwin2 == NULL) {
- return TCL_ERROR;
- }
- }
- *((Tk_Window *) ptr) = tkwin2;
- break;
- }
- case TK_CONFIG_CUSTOM:
- if ((*specPtr->customPtr->parseProc)(
- specPtr->customPtr->clientData, interp, tkwin,
- value, widgRec, specPtr->offset) != TCL_OK) {
- return TCL_ERROR;
- }
- break;
- default: {
- sprintf(interp->result, "bad config table: unknown type %d",
- specPtr->type);
- return TCL_ERROR;
- }
- }
- specPtr++;
- } while ((specPtr->argvName == NULL) && (specPtr->type != TK_CONFIG_END));
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_ConfigureInfo --
- *
- * Return information about the configuration options
- * for a window, and their current values.
- *
- * Results:
- * Always returns TCL_OK. Interp->result will be modified
- * hold a description of either a single configuration option
- * available for "widgRec" via "specs", or all the configuration
- * options available. In the "all" case, the result will
- * available for "widgRec" via "specs". The result will
- * be a list, each of whose entries describes one option.
- * Each entry will itself be a list containing the option's
- * name for use on command lines, database name, database
- * class, default value, and current value (empty string
- * if none). For options that are synonyms, the list will
- * contain only two values: name and synonym name. If the
- * "name" argument is non-NULL, then the only information
- * returned is that for the named argument (i.e. the corresponding
- * entry in the overall list is returned).
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-int
-Tk_ConfigureInfo(interp, tkwin, specs, widgRec, argvName, flags)
- Tcl_Interp *interp; /* Interpreter for error reporting. */
- Tk_Window tkwin; /* Window corresponding to widgRec. */
- 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
- * whose info is to be returned. Otherwise
- * info is returned for all options. */
- int flags; /* Used to specify additional flags
- * that must be present in config specs
- * for them to be considered. */
-{
- register Tk_ConfigSpec *specPtr;
- int needFlags, hateFlags;
- char *list;
- char *leader = "{";
-
- needFlags = flags & ~(TK_CONFIG_USER_BIT - 1);
- if (Tk_Depth(tkwin) <= 1) {
- hateFlags = TK_CONFIG_COLOR_ONLY;
- } else {
- hateFlags = TK_CONFIG_MONO_ONLY;
- }
-
- /*
- * If information is only wanted for a single configuration
- * spec, then handle that one spec specially.
- */
-
- Tcl_SetResult(interp, (char *) NULL, TCL_STATIC);
- if (argvName != NULL) {
- specPtr = FindConfigSpec(interp, specs, argvName, needFlags,
- hateFlags);
- if (specPtr == NULL) {
- return TCL_ERROR;
- }
- interp->result = FormatConfigInfo(interp, tkwin, specPtr, widgRec);
- interp->freeProc = TCL_DYNAMIC;
- return TCL_OK;
- }
-
- /*
- * Loop through all the specs, creating a big list with all
- * their information.
- */
-
- for (specPtr = specs; specPtr->type != TK_CONFIG_END; specPtr++) {
- if ((argvName != NULL) && (specPtr->argvName != argvName)) {
- continue;
- }
- if (((specPtr->specFlags & needFlags) != needFlags)
- || (specPtr->specFlags & hateFlags)) {
- continue;
- }
- if (specPtr->argvName == NULL) {
- continue;
- }
- list = FormatConfigInfo(interp, tkwin, specPtr, widgRec);
- Tcl_AppendResult(interp, leader, list, "}", (char *) NULL);
- ckfree(list);
- leader = " {";
- }
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * FormatConfigInfo --
- *
- * Create a valid Tcl list holding the configuration information
- * for a single configuration option.
- *
- * Results:
- * A Tcl list, dynamically allocated. The caller is expected to
- * arrange for this list to be freed eventually.
- *
- * Side effects:
- * Memory is allocated.
- *
- *--------------------------------------------------------------
- */
-
-static char *
-FormatConfigInfo(interp, tkwin, specPtr, widgRec)
- Tcl_Interp *interp; /* Interpreter to use for things
- * like floating-point precision. */
- Tk_Window tkwin; /* Window corresponding to widget. */
- register Tk_ConfigSpec *specPtr; /* Pointer to information describing
- * option. */
- char *widgRec; /* Pointer to record holding current
- * values of info for widget. */
-{
- char *argv[6], *result;
- char buffer[200];
- Tcl_FreeProc *freeProc = (Tcl_FreeProc *) NULL;
-
- argv[0] = specPtr->argvName;
- argv[1] = specPtr->dbName;
- argv[2] = specPtr->dbClass;
- argv[3] = specPtr->defValue;
- if (specPtr->type == TK_CONFIG_SYNONYM) {
- return Tcl_Merge(2, argv);
- }
- argv[4] = FormatConfigValue(interp, tkwin, specPtr, widgRec, buffer,
- &freeProc);
- if (argv[1] == NULL) {
- argv[1] = "";
- }
- if (argv[2] == NULL) {
- argv[2] = "";
- }
- if (argv[3] == NULL) {
- argv[3] = "";
- }
- if (argv[4] == NULL) {
- argv[4] = "";
- }
- result = Tcl_Merge(5, argv);
- if (freeProc != NULL) {
- if ((freeProc == TCL_DYNAMIC) || (freeProc == (Tcl_FreeProc *) free)) {
- ckfree(argv[4]);
- } else {
- (*freeProc)(argv[4]);
- }
- }
- return result;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * FormatConfigValue --
- *
- * This procedure formats the current value of a configuration
- * option.
- *
- * Results:
- * The return value is the formatted value of the option given
- * by specPtr and widgRec. If the value is static, so that it
- * need not be freed, *freeProcPtr will be set to NULL; otherwise
- * *freeProcPtr will be set to the address of a procedure to
- * free the result, and the caller must invoke this procedure
- * when it is finished with the result.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static char *
-FormatConfigValue(interp, tkwin, specPtr, widgRec, buffer, freeProcPtr)
- Tcl_Interp *interp; /* Interpreter for use in real conversions. */
- Tk_Window tkwin; /* Window corresponding to widget. */
- Tk_ConfigSpec *specPtr; /* Pointer to information describing option.
- * Must not point to a synonym option. */
- char *widgRec; /* Pointer to record holding current
- * values of info for widget. */
- char *buffer; /* Static buffer to use for small values.
- * Must have at least 200 bytes of storage. */
- Tcl_FreeProc **freeProcPtr; /* Pointer to word to fill in with address
- * of procedure to free the result, or NULL
- * if result is static. */
-{
- char *ptr, *result;
-
- *freeProcPtr = NULL;
- ptr = widgRec + specPtr->offset;
- result = "";
- switch (specPtr->type) {
- case TK_CONFIG_BOOLEAN:
- if (*((int *) ptr) == 0) {
- result = "0";
- } else {
- result = "1";
- }
- break;
- case TK_CONFIG_INT:
- sprintf(buffer, "%d", *((int *) ptr));
- result = buffer;
- break;
- case TK_CONFIG_DOUBLE:
- Tcl_PrintDouble(interp, *((double *) ptr), buffer);
- result = buffer;
- break;
- case TK_CONFIG_STRING:
- result = (*(char **) ptr);
- if (result == NULL) {
- result = "";
- }
- break;
- case TK_CONFIG_UID: {
- Tk_Uid uid = *((Tk_Uid *) ptr);
- if (uid != NULL) {
- result = uid;
- }
- break;
- }
- case TK_CONFIG_COLOR: {
- XColor *colorPtr = *((XColor **) ptr);
- if (colorPtr != NULL) {
- result = Tk_NameOfColor(colorPtr);
- }
- break;
- }
- case TK_CONFIG_FONT: {
- Tk_Font tkfont = *((Tk_Font *) ptr);
- if (tkfont != NULL) {
- result = Tk_NameOfFont(tkfont);
- }
- break;
- }
- case TK_CONFIG_BITMAP: {
- Pixmap pixmap = *((Pixmap *) ptr);
- if (pixmap != None) {
- result = Tk_NameOfBitmap(Tk_Display(tkwin), pixmap);
- }
- break;
- }
- case TK_CONFIG_BORDER: {
- Tk_3DBorder border = *((Tk_3DBorder *) ptr);
- if (border != NULL) {
- result = Tk_NameOf3DBorder(border);
- }
- break;
- }
- case TK_CONFIG_RELIEF:
- result = Tk_NameOfRelief(*((int *) ptr));
- break;
- case TK_CONFIG_CURSOR:
- case TK_CONFIG_ACTIVE_CURSOR: {
- Tk_Cursor cursor = *((Tk_Cursor *) ptr);
- if (cursor != None) {
- result = Tk_NameOfCursor(Tk_Display(tkwin), cursor);
- }
- break;
- }
- case TK_CONFIG_JUSTIFY:
- result = Tk_NameOfJustify(*((Tk_Justify *) ptr));
- break;
- case TK_CONFIG_ANCHOR:
- result = Tk_NameOfAnchor(*((Tk_Anchor *) ptr));
- break;
- case TK_CONFIG_CAP_STYLE:
- result = Tk_NameOfCapStyle(*((int *) ptr));
- break;
- case TK_CONFIG_JOIN_STYLE:
- result = Tk_NameOfJoinStyle(*((int *) ptr));
- break;
- case TK_CONFIG_PIXELS:
- sprintf(buffer, "%d", *((int *) ptr));
- result = buffer;
- break;
- case TK_CONFIG_MM:
- Tcl_PrintDouble(interp, *((double *) ptr), buffer);
- result = buffer;
- break;
- case TK_CONFIG_WINDOW: {
- Tk_Window tkwin;
-
- tkwin = *((Tk_Window *) ptr);
- if (tkwin != NULL) {
- result = Tk_PathName(tkwin);
- }
- break;
- }
- case TK_CONFIG_CUSTOM:
- result = (*specPtr->customPtr->printProc)(
- specPtr->customPtr->clientData, tkwin, widgRec,
- specPtr->offset, freeProcPtr);
- break;
- default:
- result = "?? unknown type ??";
- }
- return result;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_ConfigureValue --
- *
- * This procedure returns the current value of a configuration
- * option for a widget.
- *
- * Results:
- * The return value is a standard Tcl completion code (TCL_OK or
- * TCL_ERROR). Interp->result will be set to hold either the value
- * of the option given by argvName (if TCL_OK is returned) or
- * an error message (if TCL_ERROR is returned).
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-int
-Tk_ConfigureValue(interp, tkwin, specs, widgRec, argvName, flags)
- Tcl_Interp *interp; /* Interpreter for error reporting. */
- Tk_Window tkwin; /* Window corresponding to widgRec. */
- 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
- * option whose value is to be returned. */
- int flags; /* Used to specify additional flags
- * that must be present in config specs
- * for them to be considered. */
-{
- Tk_ConfigSpec *specPtr;
- int needFlags, hateFlags;
-
- needFlags = flags & ~(TK_CONFIG_USER_BIT - 1);
- if (Tk_Depth(tkwin) <= 1) {
- hateFlags = TK_CONFIG_COLOR_ONLY;
- } else {
- hateFlags = TK_CONFIG_MONO_ONLY;
- }
- specPtr = FindConfigSpec(interp, specs, argvName, needFlags, hateFlags);
- if (specPtr == NULL) {
- return TCL_ERROR;
- }
- interp->result = FormatConfigValue(interp, tkwin, specPtr, widgRec,
- interp->result, &interp->freeProc);
- return TCL_OK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_FreeOptions --
- *
- * Free up all resources associated with configuration options.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Any resource in widgRec that is controlled by a configuration
- * option (e.g. a Tk_3DBorder or XColor) is freed in the appropriate
- * fashion.
- *
- *----------------------------------------------------------------------
- */
-
- /* ARGSUSED */
-void
-Tk_FreeOptions(specs, widgRec, display, needFlags)
- Tk_ConfigSpec *specs; /* Describes legal options. */
- char *widgRec; /* Record whose fields contain current
- * values for options. */
- Display *display; /* X display; needed for freeing some
- * resources. */
- int needFlags; /* Used to specify additional flags
- * that must be present in config specs
- * for them to be considered. */
-{
- register Tk_ConfigSpec *specPtr;
- char *ptr;
-
- for (specPtr = specs; specPtr->type != TK_CONFIG_END; specPtr++) {
- if ((specPtr->specFlags & needFlags) != needFlags) {
- continue;
- }
- ptr = widgRec + specPtr->offset;
- switch (specPtr->type) {
- case TK_CONFIG_STRING:
- if (*((char **) ptr) != NULL) {
- ckfree(*((char **) ptr));
- *((char **) ptr) = NULL;
- }
- break;
- case TK_CONFIG_COLOR:
- if (*((XColor **) ptr) != NULL) {
- Tk_FreeColor(*((XColor **) ptr));
- *((XColor **) ptr) = NULL;
- }
- break;
- case TK_CONFIG_FONT:
- Tk_FreeFont(*((Tk_Font *) ptr));
- *((Tk_Font *) ptr) = NULL;
- break;
- case TK_CONFIG_BITMAP:
- if (*((Pixmap *) ptr) != None) {
- Tk_FreeBitmap(display, *((Pixmap *) ptr));
- *((Pixmap *) ptr) = None;
- }
- break;
- case TK_CONFIG_BORDER:
- if (*((Tk_3DBorder *) ptr) != NULL) {
- Tk_Free3DBorder(*((Tk_3DBorder *) ptr));
- *((Tk_3DBorder *) ptr) = NULL;
- }
- break;
- case TK_CONFIG_CURSOR:
- case TK_CONFIG_ACTIVE_CURSOR:
- if (*((Tk_Cursor *) ptr) != None) {
- Tk_FreeCursor(display, *((Tk_Cursor *) ptr));
- *((Tk_Cursor *) ptr) = None;
- }
- }
- }
-}
diff --git a/generic/tkConsole.c b/generic/tkConsole.c
deleted file mode 100644
index 597b16e..0000000
--- a/generic/tkConsole.c
+++ /dev/null
@@ -1,616 +0,0 @@
-/*
- * tkConsole.c --
- *
- * This file implements a Tcl console for systems that may not
- * otherwise have access to a console. It uses the Text widget
- * and provides special access via a console command.
- *
- * Copyright (c) 1995-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: tkConsole.c,v 1.2 1998/09/14 18:23:08 stanton Exp $
- */
-
-#include "tk.h"
-#include <string.h>
-
-/*
- * A data structure of the following type holds information for each console
- * which a handler (i.e. a Tcl command) has been defined for a particular
- * top-level window.
- */
-
-typedef struct ConsoleInfo {
- Tcl_Interp *consoleInterp; /* Interpreter for the console. */
- Tcl_Interp *interp; /* Interpreter to send console commands. */
-} ConsoleInfo;
-
-static Tcl_Interp *gStdoutInterp = NULL;
-
-/*
- * Forward declarations for procedures defined later in this file:
- *
- * The first three will be used in the tk app shells...
- */
-
-void TkConsoleCreate _ANSI_ARGS_((void));
-int TkConsoleInit _ANSI_ARGS_((Tcl_Interp *interp));
-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));
-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));
-
-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));
-static int ConsoleClose _ANSI_ARGS_((ClientData instanceData,
- Tcl_Interp *interp));
-static void ConsoleWatch _ANSI_ARGS_((ClientData instanceData,
- int mask));
-static int ConsoleHandle _ANSI_ARGS_((ClientData instanceData,
- int direction, ClientData *handlePtr));
-
-/*
- * This structure describes the channel type structure for file based IO:
- */
-
-static Tcl_ChannelType consoleChannelType = {
- "console", /* Type name. */
- NULL, /* Always non-blocking.*/
- ConsoleClose, /* Close proc. */
- ConsoleInput, /* Input proc. */
- ConsoleOutput, /* Output proc. */
- NULL, /* Seek proc. */
- NULL, /* Set option proc. */
- NULL, /* Get option proc. */
- ConsoleWatch, /* Watch for events on console. */
- ConsoleHandle, /* Get a handle from the device. */
-};
-
-/*
- *----------------------------------------------------------------------
- *
- * TkConsoleCreate --
- *
- * Create the console channels and install them as the standard
- * channels. All I/O will be discarded until TkConsoleInit is
- * called to attach the console to a text widget.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Creates the console channel and installs it as the standard
- * channels.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkConsoleCreate()
-{
- Tcl_Channel consoleChannel;
-
- consoleChannel = Tcl_CreateChannel(&consoleChannelType, "console0",
- (ClientData) TCL_STDIN, TCL_READABLE);
- if (consoleChannel != NULL) {
- Tcl_SetChannelOption(NULL, consoleChannel, "-translation", "lf");
- Tcl_SetChannelOption(NULL, consoleChannel, "-buffering", "none");
- }
- Tcl_SetStdChannel(consoleChannel, TCL_STDIN);
- consoleChannel = Tcl_CreateChannel(&consoleChannelType, "console1",
- (ClientData) TCL_STDOUT, TCL_WRITABLE);
- if (consoleChannel != NULL) {
- Tcl_SetChannelOption(NULL, consoleChannel, "-translation", "lf");
- Tcl_SetChannelOption(NULL, consoleChannel, "-buffering", "none");
- }
- Tcl_SetStdChannel(consoleChannel, TCL_STDOUT);
- consoleChannel = Tcl_CreateChannel(&consoleChannelType, "console2",
- (ClientData) TCL_STDERR, TCL_WRITABLE);
- if (consoleChannel != NULL) {
- Tcl_SetChannelOption(NULL, consoleChannel, "-translation", "lf");
- Tcl_SetChannelOption(NULL, consoleChannel, "-buffering", "none");
- }
- Tcl_SetStdChannel(consoleChannel, TCL_STDERR);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkConsoleInit --
- *
- * Initialize the console. This code actually creates a new
- * application and associated interpreter. This effectivly hides
- * the implementation from the main application.
- *
- * Results:
- * None.
- *
- * Side effects:
- * A new console it created.
- *
- *----------------------------------------------------------------------
- */
-
-int
-TkConsoleInit(interp)
- Tcl_Interp *interp; /* Interpreter to use for prompting. */
-{
- Tcl_Interp *consoleInterp;
- ConsoleInfo *info;
- Tk_Window mainWindow = Tk_MainWindow(interp);
-#ifdef MAC_TCL
- static char initCmd[] = "source -rsrc {Console}";
-#else
- static char initCmd[] = "source $tk_library/console.tcl";
-#endif
-
- consoleInterp = Tcl_CreateInterp();
- if (consoleInterp == NULL) {
- goto error;
- }
-
- /*
- * Initialized Tcl and Tk.
- */
-
- if (Tcl_Init(consoleInterp) != TCL_OK) {
- goto error;
- }
- if (Tk_Init(consoleInterp) != TCL_OK) {
- goto error;
- }
- gStdoutInterp = interp;
-
- /*
- * Add console commands to the interp
- */
- info = (ConsoleInfo *) ckalloc(sizeof(ConsoleInfo));
- info->interp = interp;
- info->consoleInterp = consoleInterp;
- Tcl_CreateCommand(interp, "console", ConsoleCmd, (ClientData) info,
- (Tcl_CmdDeleteProc *) ConsoleDeleteProc);
- Tcl_CreateCommand(consoleInterp, "consoleinterp", InterpreterCmd,
- (ClientData) info, (Tcl_CmdDeleteProc *) NULL);
-
- Tk_CreateEventHandler(mainWindow, StructureNotifyMask, ConsoleEventProc,
- (ClientData) info);
-
- Tcl_Preserve((ClientData) consoleInterp);
- if (Tcl_Eval(consoleInterp, initCmd) == TCL_ERROR) {
- /* goto error; -- no problem for now... */
- printf("Eval error: %s", consoleInterp->result);
- }
- Tcl_Release((ClientData) consoleInterp);
- return TCL_OK;
-
- error:
- if (consoleInterp != NULL) {
- Tcl_DeleteInterp(consoleInterp);
- }
- return TCL_ERROR;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ConsoleOutput--
- *
- * Writes the given output on the IO channel. Returns count of how
- * many characters were actually written, and an error indication.
- *
- * Results:
- * A count of how many characters were written is returned and an
- * error indication is returned in an output argument.
- *
- * Side effects:
- * Writes output on the actual channel.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-ConsoleOutput(instanceData, buf, toWrite, errorCode)
- ClientData instanceData; /* Indicates which device to use. */
- char *buf; /* The data buffer. */
- int toWrite; /* How many bytes to write? */
- int *errorCode; /* Where to store error code. */
-{
- *errorCode = 0;
- Tcl_SetErrno(0);
-
- if (gStdoutInterp != NULL) {
- TkConsolePrint(gStdoutInterp, (int) instanceData, buf, toWrite);
- }
-
- return toWrite;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ConsoleInput --
- *
- * Read input from the console. Not currently implemented.
- *
- * Results:
- * Always returns EOF.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
- /* ARGSUSED */
-static int
-ConsoleInput(instanceData, buf, bufSize, errorCode)
- ClientData instanceData; /* Unused. */
- char *buf; /* Where to store data read. */
- int bufSize; /* How much space is available
- * in the buffer? */
- int *errorCode; /* Where to store error code. */
-{
- return 0; /* Always return EOF. */
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ConsoleClose --
- *
- * Closes the IO channel.
- *
- * Results:
- * Always returns 0 (success).
- *
- * Side effects:
- * Frees the dummy file associated with the channel.
- *
- *----------------------------------------------------------------------
- */
-
- /* ARGSUSED */
-static int
-ConsoleClose(instanceData, interp)
- ClientData instanceData; /* Unused. */
- Tcl_Interp *interp; /* Unused. */
-{
- return 0;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ConsoleWatch --
- *
- * Called by the notifier to set up the console device so that
- * events will be noticed. Since there are no events on the
- * console, this routine just returns without doing anything.
- *
- * Results:
- * None.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
- /* ARGSUSED */
-static void
-ConsoleWatch(instanceData, mask)
- ClientData instanceData; /* Device ID for the channel. */
- int mask; /* OR-ed combination of
- * TCL_READABLE, TCL_WRITABLE and
- * TCL_EXCEPTION, for the events
- * we are interested in. */
-{
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ConsoleHandle --
- *
- * Invoked by the generic IO layer to get a handle from a channel.
- * Because console channels are not devices, this function always
- * fails.
- *
- * Results:
- * Always returns TCL_ERROR.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
- /* ARGSUSED */
-static int
-ConsoleHandle(instanceData, direction, handlePtr)
- ClientData instanceData; /* Device ID for the channel. */
- int direction; /* TCL_READABLE or TCL_WRITABLE to indicate
- * which direction of the channel is being
- * requested. */
- ClientData *handlePtr; /* Where to store handle */
-{
- return TCL_ERROR;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ConsoleCmd --
- *
- * The console command implements a Tcl interface to the various console
- * options.
- *
- * Results:
- * None.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-ConsoleCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Not used. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- ConsoleInfo *info = (ConsoleInfo *) clientData;
- char c;
- int length;
- int result;
- Tcl_Interp *consoleInterp;
-
- if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
- " option ?arg arg ...?\"", (char *) NULL);
- return TCL_ERROR;
- }
-
- c = argv[1][0];
- length = strlen(argv[1]);
- result = TCL_OK;
- consoleInterp = info->consoleInterp;
- Tcl_Preserve((ClientData) consoleInterp);
- if ((c == 't') && (strncmp(argv[1], "title", length)) == 0) {
- Tcl_DString dString;
-
- Tcl_DStringInit(&dString);
- Tcl_DStringAppend(&dString, "wm title . ", -1);
- if (argc == 3) {
- Tcl_DStringAppendElement(&dString, argv[2]);
- }
- Tcl_Eval(consoleInterp, Tcl_DStringValue(&dString));
- Tcl_DStringFree(&dString);
- } else if ((c == 'h') && (strncmp(argv[1], "hide", length)) == 0) {
- Tcl_Eval(info->consoleInterp, "wm withdraw .");
- } else if ((c == 's') && (strncmp(argv[1], "show", length)) == 0) {
- Tcl_Eval(info->consoleInterp, "wm deiconify .");
- } else if ((c == 'e') && (strncmp(argv[1], "eval", length)) == 0) {
- if (argc == 3) {
- Tcl_Eval(info->consoleInterp, argv[2]);
- } else {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
- " eval command\"", (char *) NULL);
- return TCL_ERROR;
- }
- } else {
- Tcl_AppendResult(interp, "bad option \"", argv[1],
- "\": should be hide, show, or title",
- (char *) NULL);
- result = TCL_ERROR;
- }
- Tcl_Release((ClientData) consoleInterp);
- return result;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * InterpreterCmd --
- *
- * This command allows the console interp to communicate with the
- * main interpreter.
- *
- * Results:
- * None.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-InterpreterCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Not used. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- ConsoleInfo *info = (ConsoleInfo *) clientData;
- char c;
- int length;
- int result;
- Tcl_Interp *otherInterp;
-
- if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
- " option ?arg arg ...?\"", (char *) NULL);
- return TCL_ERROR;
- }
-
- c = argv[1][0];
- length = strlen(argv[1]);
- otherInterp = info->interp;
- Tcl_Preserve((ClientData) otherInterp);
- if ((c == 'e') && (strncmp(argv[1], "eval", length)) == 0) {
- result = Tcl_GlobalEval(otherInterp, argv[2]);
- Tcl_AppendResult(interp, otherInterp->result, (char *) NULL);
- } else if ((c == 'r') && (strncmp(argv[1], "record", length)) == 0) {
- Tcl_RecordAndEval(otherInterp, argv[2], TCL_EVAL_GLOBAL);
- result = TCL_OK;
- Tcl_AppendResult(interp, otherInterp->result, (char *) NULL);
- } else {
- Tcl_AppendResult(interp, "bad option \"", argv[1],
- "\": should be eval or record",
- (char *) NULL);
- result = TCL_ERROR;
- }
- Tcl_Release((ClientData) otherInterp);
- return result;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ConsoleDeleteProc --
- *
- * If the console command is deleted we destroy the console window
- * and all associated data structures.
- *
- * Results:
- * None.
- *
- * Side effects:
- * A new console it created.
- *
- *----------------------------------------------------------------------
- */
-
-void
-ConsoleDeleteProc(clientData)
- ClientData clientData;
-{
- ConsoleInfo *info = (ConsoleInfo *) clientData;
-
- Tcl_DeleteInterp(info->consoleInterp);
- info->consoleInterp = NULL;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ConsoleEventProc --
- *
- * 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".
- *
- * Results:
- * None.
- *
- * Side effects:
- * Invokes the "tkConsoleExit" procedure in the console interp.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-ConsoleEventProc(clientData, eventPtr)
- ClientData clientData;
- XEvent *eventPtr;
-{
- ConsoleInfo *info = (ConsoleInfo *) clientData;
- Tcl_Interp *consoleInterp;
-
- if (eventPtr->type == DestroyNotify) {
- consoleInterp = info->consoleInterp;
-
- /*
- * It is possible that the console interpreter itself has
- * already been deleted. In that case the consoleInterp
- * field will be set to NULL. If the interpreter is already
- * gone, we do not have to do any work here.
- */
-
- if (consoleInterp == (Tcl_Interp *) NULL) {
- return;
- }
- Tcl_Preserve((ClientData) consoleInterp);
- Tcl_Eval(consoleInterp, "tkConsoleExit");
- Tcl_Release((ClientData) consoleInterp);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkConsolePrint --
- *
- * Prints to the give text to the console. Given the main interp
- * this functions find the appropiate console interp and forwards
- * the text to be added to that console.
- *
- * Results:
- * None.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkConsolePrint(interp, devId, buffer, size)
- Tcl_Interp *interp; /* Main interpreter. */
- int devId; /* TCL_STDOUT for stdout, TCL_STDERR for
- * stderr. */
- char *buffer; /* Text buffer. */
- long size; /* Size of text buffer. */
-{
- Tcl_DString command, output;
- Tcl_CmdInfo cmdInfo;
- char *cmd;
- ConsoleInfo *info;
- Tcl_Interp *consoleInterp;
- int result;
-
- if (interp == NULL) {
- return;
- }
-
- if (devId == TCL_STDERR) {
- cmd = "tkConsoleOutput stderr ";
- } else {
- cmd = "tkConsoleOutput stdout ";
- }
-
- result = Tcl_GetCommandInfo(interp, "console", &cmdInfo);
- if (result == 0) {
- return;
- }
- info = (ConsoleInfo *) cmdInfo.clientData;
-
- Tcl_DStringInit(&output);
- Tcl_DStringAppend(&output, buffer, size);
-
- Tcl_DStringInit(&command);
- Tcl_DStringAppend(&command, cmd, strlen(cmd));
- Tcl_DStringAppendElement(&command, output.string);
-
- consoleInterp = info->consoleInterp;
- Tcl_Preserve((ClientData) consoleInterp);
- Tcl_Eval(consoleInterp, command.string);
- Tcl_Release((ClientData) consoleInterp);
-
- Tcl_DStringFree(&command);
- Tcl_DStringFree(&output);
-}
diff --git a/generic/tkCursor.c b/generic/tkCursor.c
deleted file mode 100644
index 297cd3e..0000000
--- a/generic/tkCursor.c
+++ /dev/null
@@ -1,384 +0,0 @@
-/*
- * tkCursor.c --
- *
- * This file maintains a database of read-only cursors for the Tk
- * toolkit. This allows cursors to be shared between widgets and
- * also avoids round-trips to the X server.
- *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1995 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: tkCursor.c,v 1.2 1998/09/14 18:23:09 stanton Exp $
- */
-
-#include "tkPort.h"
-#include "tkInt.h"
-
-/*
- * A TkCursor structure exists for each cursor that is currently
- * active. Each structure is indexed with two hash tables defined
- * below. One of the tables is idTable, and the other is either
- * nameTable or dataTable, also defined below.
- */
-
-/*
- * Hash table to map from a textual description of a cursor to the
- * TkCursor record for the cursor, and key structure used in that
- * hash table:
- */
-
-static Tcl_HashTable nameTable;
-typedef struct {
- Tk_Uid name; /* Textual name for desired cursor. */
- Display *display; /* Display for which cursor will be used. */
-} NameKey;
-
-/*
- * Hash table to map from a collection of in-core data about a
- * cursor (bitmap contents, etc.) to a TkCursor structure:
- */
-
-static Tcl_HashTable dataTable;
-typedef struct {
- char *source; /* Cursor bits. */
- char *mask; /* Mask bits. */
- int width, height; /* Dimensions of cursor (and data
- * and mask). */
- int xHot, yHot; /* Location of cursor hot-spot. */
- Tk_Uid fg, bg; /* Colors for cursor. */
- Display *display; /* Display on which cursor will be used. */
-} DataKey;
-
-/*
- * Hash table that maps from <display + cursor id> to the TkCursor structure
- * for the cursor. This table is used by Tk_FreeCursor.
- */
-
-static Tcl_HashTable idTable;
-typedef struct {
- Display *display; /* Display for which cursor was allocated. */
- Tk_Cursor cursor; /* Cursor identifier. */
-} IdKey;
-
-static int initialized = 0; /* 0 means static structures haven't been
- * initialized yet. */
-
-/*
- * Forward declarations for procedures defined in this file:
- */
-
-static void CursorInit _ANSI_ARGS_((void));
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_GetCursor --
- *
- * Given a string describing a cursor, locate (or create if necessary)
- * a cursor that fits the description.
- *
- * Results:
- * The return value is the X identifer for the desired cursor,
- * unless string couldn't be parsed correctly. In this case,
- * None is returned and an error message is left in interp->result.
- * The caller should never modify the cursor that is returned, and
- * should eventually call Tk_FreeCursor when the cursor is no longer
- * needed.
- *
- * Side effects:
- * The cursor is added to an internal database with a reference count.
- * For each call to this procedure, there should eventually be a call
- * to Tk_FreeCursor, so that the database can be cleaned up when cursors
- * aren't needed anymore.
- *
- *----------------------------------------------------------------------
- */
-
-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. */
- Tk_Uid string; /* Description of cursor. See manual entry
- * for details on legal syntax. */
-{
- NameKey nameKey;
- IdKey idKey;
- Tcl_HashEntry *nameHashPtr, *idHashPtr;
- register TkCursor *cursorPtr;
- int new;
-
- if (!initialized) {
- CursorInit();
- }
-
- nameKey.name = string;
- nameKey.display = Tk_Display(tkwin);
- nameHashPtr = Tcl_CreateHashEntry(&nameTable, (char *) &nameKey, &new);
- if (!new) {
- cursorPtr = (TkCursor *) Tcl_GetHashValue(nameHashPtr);
- cursorPtr->refCount++;
- return cursorPtr->cursor;
- }
-
- cursorPtr = TkGetCursorByName(interp, tkwin, string);
-
- if (cursorPtr == NULL) {
- Tcl_DeleteHashEntry(nameHashPtr);
- return None;
- }
-
- /*
- * Add information about this cursor to our database.
- */
-
- cursorPtr->refCount = 1;
- cursorPtr->otherTable = &nameTable;
- cursorPtr->hashPtr = nameHashPtr;
- idKey.display = nameKey.display;
- idKey.cursor = cursorPtr->cursor;
- idHashPtr = Tcl_CreateHashEntry(&idTable, (char *) &idKey, &new);
- if (!new) {
- panic("cursor already registered in Tk_GetCursor");
- }
- Tcl_SetHashValue(nameHashPtr, cursorPtr);
- Tcl_SetHashValue(idHashPtr, cursorPtr);
-
- return cursorPtr->cursor;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_GetCursorFromData --
- *
- * Given a description of the bits and colors for a cursor,
- * make a cursor that has the given properties.
- *
- * Results:
- * The return value is the X identifer for the desired cursor,
- * unless it couldn't be created properly. In this case, None is
- * returned and an error message is left in interp->result. The
- * caller should never modify the cursor that is returned, and
- * should eventually call Tk_FreeCursor when the cursor is no
- * longer needed.
- *
- * Side effects:
- * The cursor is added to an internal database with a reference count.
- * For each call to this procedure, there should eventually be a call
- * to Tk_FreeCursor, so that the database can be cleaned up when cursors
- * aren't needed anymore.
- *
- *----------------------------------------------------------------------
- */
-
-Tk_Cursor
-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. */
- int width, height; /* Dimensions of cursor. */
- int xHot, yHot; /* Location of hot-spot in cursor. */
- Tk_Uid fg; /* Foreground color for cursor. */
- Tk_Uid bg; /* Background color for cursor. */
-{
- DataKey dataKey;
- IdKey idKey;
- Tcl_HashEntry *dataHashPtr, *idHashPtr;
- register TkCursor *cursorPtr;
- int new;
- XColor fgColor, bgColor;
-
- if (!initialized) {
- CursorInit();
- }
-
- dataKey.source = source;
- dataKey.mask = mask;
- dataKey.width = width;
- dataKey.height = height;
- dataKey.xHot = xHot;
- dataKey.yHot = yHot;
- dataKey.fg = fg;
- dataKey.bg = bg;
- dataKey.display = Tk_Display(tkwin);
- dataHashPtr = Tcl_CreateHashEntry(&dataTable, (char *) &dataKey, &new);
- if (!new) {
- cursorPtr = (TkCursor *) Tcl_GetHashValue(dataHashPtr);
- cursorPtr->refCount++;
- return cursorPtr->cursor;
- }
-
- /*
- * No suitable cursor exists yet. Make one using the data
- * available and add it to the database.
- */
-
- if (XParseColor(dataKey.display, Tk_Colormap(tkwin), fg, &fgColor) == 0) {
- Tcl_AppendResult(interp, "invalid color name \"", fg, "\"",
- (char *) NULL);
- goto error;
- }
- if (XParseColor(dataKey.display, Tk_Colormap(tkwin), bg, &bgColor) == 0) {
- Tcl_AppendResult(interp, "invalid color name \"", bg, "\"",
- (char *) NULL);
- goto error;
- }
-
- cursorPtr = TkCreateCursorFromData(tkwin, source, mask, width, height,
- xHot, yHot, fgColor, bgColor);
-
- if (cursorPtr == NULL) {
- goto error;
- }
-
- cursorPtr->refCount = 1;
- cursorPtr->otherTable = &dataTable;
- cursorPtr->hashPtr = dataHashPtr;
- idKey.display = dataKey.display;
- idKey.cursor = cursorPtr->cursor;
- idHashPtr = Tcl_CreateHashEntry(&idTable, (char *) &idKey, &new);
- if (!new) {
- panic("cursor already registered in Tk_GetCursorFromData");
- }
- Tcl_SetHashValue(dataHashPtr, cursorPtr);
- Tcl_SetHashValue(idHashPtr, cursorPtr);
- return cursorPtr->cursor;
-
- error:
- Tcl_DeleteHashEntry(dataHashPtr);
- return None;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_NameOfCursor --
- *
- * Given a cursor, return a textual string identifying it.
- *
- * Results:
- * If cursor was created by Tk_GetCursor, then the return
- * value is the "string" that was used to create it.
- * Otherwise the return value is a string giving the X
- * identifier for the cursor. The storage for the returned
- * string is only guaranteed to persist up until the next
- * call to this procedure.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-char *
-Tk_NameOfCursor(display, cursor)
- Display *display; /* Display for which cursor was allocated. */
- Tk_Cursor cursor; /* Identifier for cursor whose name is
- * wanted. */
-{
- IdKey idKey;
- Tcl_HashEntry *idHashPtr;
- TkCursor *cursorPtr;
- static char string[20];
-
- if (!initialized) {
- printid:
- sprintf(string, "cursor id 0x%x", (unsigned int) cursor);
- return string;
- }
- idKey.display = display;
- idKey.cursor = cursor;
- idHashPtr = Tcl_FindHashEntry(&idTable, (char *) &idKey);
- if (idHashPtr == NULL) {
- goto printid;
- }
- cursorPtr = (TkCursor *) Tcl_GetHashValue(idHashPtr);
- if (cursorPtr->otherTable != &nameTable) {
- goto printid;
- }
- return ((NameKey *) cursorPtr->hashPtr->key.words)->name;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_FreeCursor --
- *
- * This procedure is called to release a cursor allocated by
- * Tk_GetCursor or TkGetCursorFromData.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The reference count associated with cursor is decremented, and
- * it is officially deallocated if no-one is using it anymore.
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tk_FreeCursor(display, cursor)
- Display *display; /* Display for which cursor was allocated. */
- Tk_Cursor cursor; /* Identifier for cursor to be released. */
-{
- IdKey idKey;
- Tcl_HashEntry *idHashPtr;
- register TkCursor *cursorPtr;
-
- if (!initialized) {
- panic("Tk_FreeCursor called before Tk_GetCursor");
- }
-
- idKey.display = display;
- idKey.cursor = cursor;
- idHashPtr = Tcl_FindHashEntry(&idTable, (char *) &idKey);
- if (idHashPtr == NULL) {
- panic("Tk_FreeCursor received unknown cursor argument");
- }
- cursorPtr = (TkCursor *) Tcl_GetHashValue(idHashPtr);
- cursorPtr->refCount--;
- if (cursorPtr->refCount == 0) {
- Tcl_DeleteHashEntry(cursorPtr->hashPtr);
- Tcl_DeleteHashEntry(idHashPtr);
- TkFreeCursor(cursorPtr);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * CursorInit --
- *
- * Initialize the structures used for cursor management.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Read the code.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-CursorInit()
-{
- initialized = 1;
- Tcl_InitHashTable(&nameTable, sizeof(NameKey)/sizeof(int));
- Tcl_InitHashTable(&dataTable, sizeof(DataKey)/sizeof(int));
-
- /*
- * The call below is tricky: can't use sizeof(IdKey) because it
- * gets padded with extra unpredictable bytes on some 64-bit
- * machines.
- */
-
- Tcl_InitHashTable(&idTable, (sizeof(Display *) + sizeof(Tk_Cursor))
- /sizeof(int));
-}
diff --git a/generic/tkEntry.c b/generic/tkEntry.c
deleted file mode 100644
index 9dc65ee..0000000
--- a/generic/tkEntry.c
+++ /dev/null
@@ -1,2313 +0,0 @@
-/*
- * tkEntry.c --
- *
- * This module implements entry widgets for the Tk
- * toolkit. An entry displays a string and allows
- * the string to be edited.
- *
- * 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: tkEntry.c,v 1.2 1998/09/14 18:23:09 stanton Exp $
- */
-
-#include "tkInt.h"
-#include "default.h"
-
-/*
- * A data structure of the following type is kept for each entry
- * widget managed by this file:
- */
-
-typedef struct {
- Tk_Window tkwin; /* Window that embodies the entry. NULL
- * means that the window has been destroyed
- * but the data structures haven't yet been
- * cleaned up.*/
- Display *display; /* Display containing widget. Used, among
- * other things, so that resources can be
- * freed even after tkwin has gone away. */
- Tcl_Interp *interp; /* Interpreter associated with entry. */
- Tcl_Command widgetCmd; /* Token for entry's widget command. */
-
- /*
- * Fields that are set by widget commands other than "configure".
- */
-
- char *string; /* Pointer to storage for string;
- * NULL-terminated; malloc-ed. */
- int insertPos; /* Index of character before which next
- * typed character will be inserted. */
-
- /*
- * Information about what's selected, if any.
- */
-
- int selectFirst; /* Index of first selected character (-1 means
- * nothing selected. */
- int selectLast; /* Index of last selected character (-1 means
- * nothing selected. */
- int selectAnchor; /* Fixed end of selection (i.e. "select to"
- * operation will use this as one end of the
- * selection). */
-
- /*
- * Information for scanning:
- */
-
- int scanMarkX; /* X-position at which scan started (e.g.
- * button was pressed here). */
- int scanMarkIndex; /* Index of character that was at left of
- * window when scan started. */
-
- /*
- * Configuration settings that are updated by Tk_ConfigureWidget.
- */
-
- Tk_3DBorder normalBorder; /* Used for drawing border around whole
- * window, 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 *highlightBgColorPtr;/* Color for drawing traversal highlight
- * area when highlight is off. */
- XColor *highlightColorPtr; /* Color for drawing traversal highlight. */
- int highlightWidth; /* Width in pixels of highlight to draw
- * around widget when it has the focus.
- * <= 0 means don't draw a highlight. */
- Tk_3DBorder insertBorder; /* Used to draw vertical bar for insertion
- * cursor. */
- int insertBorderWidth; /* Width of 3-D border around insert cursor. */
- int insertOffTime; /* Number of milliseconds cursor should spend
- * in "off" state for each blink. */
- int insertOnTime; /* Number of milliseconds cursor should spend
- * in "on" state for each blink. */
- int insertWidth; /* Total width of insert cursor. */
- Tk_Justify justify; /* Justification to use for text within
- * window. */
- int relief; /* 3-D effect: TK_RELIEF_RAISED, etc. */
- Tk_3DBorder selBorder; /* Border and background for selected
- * 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. */
- Tk_Uid state; /* Normal or disabled. Entry is read-only
- * when disabled. */
- char *textVarName; /* Name of variable (malloc'ed) or NULL.
- * If non-NULL, entry's string tracks the
- * contents of this variable and vice versa. */
- char *takeFocus; /* Value of -takefocus option; not used in
- * the C code, but used by keyboard traversal
- * scripts. Malloc'ed, but may be NULL. */
- int prefWidth; /* Desired width of window, measured in
- * average characters. */
- char *scrollCmd; /* Command prefix for communicating with
- * scrollbar(s). Malloc'ed. NULL means
- * no command to issue. */
-
- /*
- * Fields whose values are derived from the current values of the
- * configuration settings above.
- */
-
- int numChars; /* Number of non-NULL characters in
- * string (may be 0). */
- char *displayString; /* If non-NULL, points to string with same
- * length as string but whose characters
- * are all equal to showChar. Malloc'ed. */
- int inset; /* Number of pixels on the left and right
- * sides that are taken up by XPAD, borderWidth
- * (if any), and highlightWidth (if any). */
- Tk_TextLayout textLayout; /* Cached text layout information. */
- int layoutX, layoutY; /* Origin for layout. */
- int leftIndex; /* Index of left-most character visible in
- * window. */
- int leftX; /* X position at which character at leftIndex
- * is drawn (varies depending on justify). */
- Tcl_TimerToken insertBlinkHandler;
- /* Timer handler used to blink cursor on and
- * off. */
- GC textGC; /* For drawing normal text. */
- GC selTextGC; /* For drawing selected text. */
- GC highlightGC; /* For drawing traversal highlight. */
- int avgWidth; /* Width of average character. */
- int flags; /* Miscellaneous flags; see below for
- * definitions. */
-} Entry;
-
-/*
- * Assigned bits of "flags" fields of Entry structures, and what those
- * bits mean:
- *
- * REDRAW_PENDING: Non-zero means a DoWhenIdle handler has
- * already been queued to redisplay the entry.
- * BORDER_NEEDED: Non-zero means 3-D border must be redrawn
- * around window during redisplay. Normally
- * only text portion needs to be redrawn.
- * CURSOR_ON: Non-zero means insert cursor is displayed at
- * present. 0 means it isn't displayed.
- * GOT_FOCUS: Non-zero means this window has the input
- * focus.
- * UPDATE_SCROLLBAR: Non-zero means scrollbar should be updated
- * during next redisplay operation.
- * GOT_SELECTION: Non-zero means we've claimed the selection.
- */
-
-#define REDRAW_PENDING 1
-#define BORDER_NEEDED 2
-#define CURSOR_ON 4
-#define GOT_FOCUS 8
-#define UPDATE_SCROLLBAR 0x10
-#define GOT_SELECTION 0x20
-
-/*
- * The following macro defines how many extra pixels to leave on each
- * side of the text in the entry.
- */
-
-#define XPAD 1
-#define YPAD 1
-
-/*
- * Information used for argv parsing.
- */
-
-static Tk_ConfigSpec configSpecs[] = {
- {TK_CONFIG_BORDER, "-background", "background", "Background",
- DEF_ENTRY_BG_COLOR, Tk_Offset(Entry, normalBorder),
- TK_CONFIG_COLOR_ONLY},
- {TK_CONFIG_BORDER, "-background", "background", "Background",
- DEF_ENTRY_BG_MONO, Tk_Offset(Entry, normalBorder),
- 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_ENTRY_BORDER_WIDTH, Tk_Offset(Entry, borderWidth), 0},
- {TK_CONFIG_ACTIVE_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_ENTRY_CURSOR, Tk_Offset(Entry, cursor), TK_CONFIG_NULL_OK},
- {TK_CONFIG_BOOLEAN, "-exportselection", "exportSelection",
- "ExportSelection", DEF_ENTRY_EXPORT_SELECTION,
- Tk_Offset(Entry, exportSelection), 0},
- {TK_CONFIG_SYNONYM, "-fg", "foreground", (char *) NULL,
- (char *) NULL, 0, 0},
- {TK_CONFIG_FONT, "-font", "font", "Font",
- DEF_ENTRY_FONT, Tk_Offset(Entry, tkfont), 0},
- {TK_CONFIG_COLOR, "-foreground", "foreground", "Foreground",
- DEF_ENTRY_FG, Tk_Offset(Entry, fgColorPtr), 0},
- {TK_CONFIG_COLOR, "-highlightbackground", "highlightBackground",
- "HighlightBackground", DEF_ENTRY_HIGHLIGHT_BG,
- Tk_Offset(Entry, highlightBgColorPtr), 0},
- {TK_CONFIG_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_ENTRY_HIGHLIGHT, Tk_Offset(Entry, highlightColorPtr), 0},
- {TK_CONFIG_PIXELS, "-highlightthickness", "highlightThickness",
- "HighlightThickness",
- DEF_ENTRY_HIGHLIGHT_WIDTH, Tk_Offset(Entry, highlightWidth), 0},
- {TK_CONFIG_BORDER, "-insertbackground", "insertBackground", "Foreground",
- DEF_ENTRY_INSERT_BG, Tk_Offset(Entry, insertBorder), 0},
- {TK_CONFIG_PIXELS, "-insertborderwidth", "insertBorderWidth", "BorderWidth",
- DEF_ENTRY_INSERT_BD_COLOR, Tk_Offset(Entry, insertBorderWidth),
- TK_CONFIG_COLOR_ONLY},
- {TK_CONFIG_PIXELS, "-insertborderwidth", "insertBorderWidth", "BorderWidth",
- DEF_ENTRY_INSERT_BD_MONO, Tk_Offset(Entry, insertBorderWidth),
- TK_CONFIG_MONO_ONLY},
- {TK_CONFIG_INT, "-insertofftime", "insertOffTime", "OffTime",
- DEF_ENTRY_INSERT_OFF_TIME, Tk_Offset(Entry, insertOffTime), 0},
- {TK_CONFIG_INT, "-insertontime", "insertOnTime", "OnTime",
- DEF_ENTRY_INSERT_ON_TIME, Tk_Offset(Entry, insertOnTime), 0},
- {TK_CONFIG_PIXELS, "-insertwidth", "insertWidth", "InsertWidth",
- DEF_ENTRY_INSERT_WIDTH, Tk_Offset(Entry, insertWidth), 0},
- {TK_CONFIG_JUSTIFY, "-justify", "justify", "Justify",
- DEF_ENTRY_JUSTIFY, Tk_Offset(Entry, justify), 0},
- {TK_CONFIG_RELIEF, "-relief", "relief", "Relief",
- DEF_ENTRY_RELIEF, Tk_Offset(Entry, relief), 0},
- {TK_CONFIG_BORDER, "-selectbackground", "selectBackground", "Foreground",
- DEF_ENTRY_SELECT_COLOR, Tk_Offset(Entry, selBorder),
- TK_CONFIG_COLOR_ONLY},
- {TK_CONFIG_BORDER, "-selectbackground", "selectBackground", "Foreground",
- DEF_ENTRY_SELECT_MONO, Tk_Offset(Entry, selBorder),
- TK_CONFIG_MONO_ONLY},
- {TK_CONFIG_PIXELS, "-selectborderwidth", "selectBorderWidth", "BorderWidth",
- DEF_ENTRY_SELECT_BD_COLOR, Tk_Offset(Entry, selBorderWidth),
- TK_CONFIG_COLOR_ONLY},
- {TK_CONFIG_PIXELS, "-selectborderwidth", "selectBorderWidth", "BorderWidth",
- DEF_ENTRY_SELECT_BD_MONO, Tk_Offset(Entry, selBorderWidth),
- TK_CONFIG_MONO_ONLY},
- {TK_CONFIG_COLOR, "-selectforeground", "selectForeground", "Background",
- DEF_ENTRY_SELECT_FG_COLOR, Tk_Offset(Entry, selFgColorPtr),
- TK_CONFIG_COLOR_ONLY},
- {TK_CONFIG_COLOR, "-selectforeground", "selectForeground", "Background",
- DEF_ENTRY_SELECT_FG_MONO, Tk_Offset(Entry, selFgColorPtr),
- TK_CONFIG_MONO_ONLY},
- {TK_CONFIG_STRING, "-show", "show", "Show",
- DEF_ENTRY_SHOW, Tk_Offset(Entry, showChar), TK_CONFIG_NULL_OK},
- {TK_CONFIG_UID, "-state", "state", "State",
- DEF_ENTRY_STATE, Tk_Offset(Entry, state), 0},
- {TK_CONFIG_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_ENTRY_TAKE_FOCUS, Tk_Offset(Entry, takeFocus), TK_CONFIG_NULL_OK},
- {TK_CONFIG_STRING, "-textvariable", "textVariable", "Variable",
- DEF_ENTRY_TEXT_VARIABLE, Tk_Offset(Entry, textVarName),
- TK_CONFIG_NULL_OK},
- {TK_CONFIG_INT, "-width", "width", "Width",
- DEF_ENTRY_WIDTH, Tk_Offset(Entry, prefWidth), 0},
- {TK_CONFIG_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand",
- DEF_ENTRY_SCROLL_COMMAND, Tk_Offset(Entry, scrollCmd),
- TK_CONFIG_NULL_OK},
- {TK_CONFIG_END, (char *) NULL, (char *) NULL, (char *) NULL,
- (char *) NULL, 0, 0}
-};
-
-/*
- * Flags for GetEntryIndex procedure:
- */
-
-#define ZERO_OK 1
-#define LAST_PLUS_ONE_OK 2
-
-/*
- * Forward declarations for procedures defined later in this file:
- */
-
-static int ConfigureEntry _ANSI_ARGS_((Tcl_Interp *interp,
- Entry *entryPtr, int argc, char **argv,
- int flags));
-static void DeleteChars _ANSI_ARGS_((Entry *entryPtr, int index,
- int count));
-static void DestroyEntry _ANSI_ARGS_((char *memPtr));
-static void DisplayEntry _ANSI_ARGS_((ClientData clientData));
-static void EntryBlinkProc _ANSI_ARGS_((ClientData clientData));
-static void EntryCmdDeletedProc _ANSI_ARGS_((
- ClientData clientData));
-static void EntryComputeGeometry _ANSI_ARGS_((Entry *entryPtr));
-static void EntryEventProc _ANSI_ARGS_((ClientData clientData,
- XEvent *eventPtr));
-static void EntryFocusProc _ANSI_ARGS_ ((Entry *entryPtr,
- int gotFocus));
-static int EntryFetchSelection _ANSI_ARGS_((ClientData clientData,
- int offset, char *buffer, int maxBytes));
-static void EntryLostSelection _ANSI_ARGS_((
- ClientData clientData));
-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));
-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));
-static void EntryUpdateScrollbar _ANSI_ARGS_((Entry *entryPtr));
-static void EntryValueChanged _ANSI_ARGS_((Entry *entryPtr));
-static void EntryVisibleRange _ANSI_ARGS_((Entry *entryPtr,
- double *firstPtr, double *lastPtr));
-static int EntryWidgetCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-static void EntryWorldChanged _ANSI_ARGS_((
- ClientData instanceData));
-static int GetEntryIndex _ANSI_ARGS_((Tcl_Interp *interp,
- Entry *entryPtr, char *string, int *indexPtr));
-static void InsertChars _ANSI_ARGS_((Entry *entryPtr, int index,
- char *string));
-
-/*
- * The structure below defines entry class behavior by means of procedures
- * that can be invoked from generic window code.
- */
-
-static TkClassProcs entryClass = {
- NULL, /* createProc. */
- EntryWorldChanged, /* geometryProc. */
- NULL /* modalProc. */
-};
-
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_EntryCmd --
- *
- * This procedure is invoked to process the "entry" 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_EntryCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Main window associated with
- * interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- Tk_Window tkwin = (Tk_Window) clientData;
- register Entry *entryPtr;
- Tk_Window new;
-
- if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " pathName ?options?\"", (char *) NULL);
- return TCL_ERROR;
- }
-
- new = Tk_CreateWindowFromPath(interp, tkwin, argv[1], (char *) NULL);
- if (new == NULL) {
- return TCL_ERROR;
- }
-
- /*
- * 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).
- */
-
- entryPtr = (Entry *) ckalloc(sizeof(Entry));
- entryPtr->tkwin = new;
- entryPtr->display = Tk_Display(new);
- entryPtr->interp = interp;
- entryPtr->widgetCmd = Tcl_CreateCommand(interp,
- Tk_PathName(entryPtr->tkwin), EntryWidgetCmd,
- (ClientData) entryPtr, EntryCmdDeletedProc);
- entryPtr->string = (char *) ckalloc(1);
- entryPtr->string[0] = '\0';
- entryPtr->insertPos = 0;
- 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 = tkNormalUid;
- entryPtr->textVarName = NULL;
- entryPtr->takeFocus = NULL;
- entryPtr->prefWidth = 0;
- entryPtr->scrollCmd = NULL;
-
- entryPtr->numChars = 0;
- entryPtr->displayString = NULL;
- entryPtr->inset = XPAD;
- entryPtr->textLayout = NULL;
- entryPtr->layoutX = 0;
- entryPtr->layoutY = 0;
- entryPtr->leftIndex = 0;
- entryPtr->leftX = 0;
- entryPtr->insertBlinkHandler = (Tcl_TimerToken) NULL;
- entryPtr->textGC = None;
- entryPtr->selTextGC = None;
- entryPtr->highlightGC = None;
- entryPtr->avgWidth = 1;
- entryPtr->flags = 0;
-
- Tk_SetClass(entryPtr->tkwin, "Entry");
- TkSetClassProcs(entryPtr->tkwin, &entryClass, (ClientData) entryPtr);
- Tk_CreateEventHandler(entryPtr->tkwin,
- ExposureMask|StructureNotifyMask|FocusChangeMask,
- EntryEventProc, (ClientData) entryPtr);
- Tk_CreateSelHandler(entryPtr->tkwin, XA_PRIMARY, XA_STRING,
- EntryFetchSelection, (ClientData) entryPtr, XA_STRING);
- if (ConfigureEntry(interp, entryPtr, argc-2, argv+2, 0) != TCL_OK) {
- goto error;
- }
-
- interp->result = Tk_PathName(entryPtr->tkwin);
- return TCL_OK;
-
- error:
- Tk_DestroyWindow(entryPtr->tkwin);
- return TCL_ERROR;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * EntryWidgetCmd --
- *
- * 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
-EntryWidgetCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Information about entry widget. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- register Entry *entryPtr = (Entry *) clientData;
- int result = TCL_OK;
- size_t length;
- int c;
-
- if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " option ?arg arg ...?\"", (char *) NULL);
- return TCL_ERROR;
- }
- Tcl_Preserve((ClientData) entryPtr);
- c = argv[1][0];
- length = strlen(argv[1]);
- if ((c == 'b') && (strncmp(argv[1], "bbox", length) == 0)) {
- int index;
- int x, y, width, height;
-
- if (argc != 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " bbox index\"",
- (char *) NULL);
- goto error;
- }
- if (GetEntryIndex(interp, entryPtr, argv[2], &index) != TCL_OK) {
- goto error;
- }
- if ((index == entryPtr->numChars) && (index > 0)) {
- index--;
- }
- Tk_CharBbox(entryPtr->textLayout, index, &x, &y, &width, &height);
- sprintf(interp->result, "%d %d %d %d",
- x + entryPtr->layoutX, y + entryPtr->layoutY, width, height);
- } else 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);
- goto error;
- }
- result = Tk_ConfigureValue(interp, entryPtr->tkwin, configSpecs,
- (char *) entryPtr, argv[2], 0);
- } else if ((c == 'c') && (strncmp(argv[1], "configure", length) == 0)
- && (length >= 2)) {
- if (argc == 2) {
- result = Tk_ConfigureInfo(interp, entryPtr->tkwin, configSpecs,
- (char *) entryPtr, (char *) NULL, 0);
- } else if (argc == 3) {
- result = Tk_ConfigureInfo(interp, entryPtr->tkwin, configSpecs,
- (char *) entryPtr, argv[2], 0);
- } else {
- result = ConfigureEntry(interp, entryPtr, argc-2, argv+2,
- TK_CONFIG_ARGV_ONLY);
- }
- } else if ((c == 'd') && (strncmp(argv[1], "delete", length) == 0)) {
- int first, last;
-
- if ((argc < 3) || (argc > 4)) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " delete firstIndex ?lastIndex?\"",
- (char *) NULL);
- goto error;
- }
- if (GetEntryIndex(interp, entryPtr, argv[2], &first) != TCL_OK) {
- goto error;
- }
- if (argc == 3) {
- last = first+1;
- } else {
- if (GetEntryIndex(interp, entryPtr, argv[3], &last) != TCL_OK) {
- goto error;
- }
- }
- if ((last >= first) && (entryPtr->state == tkNormalUid)) {
- DeleteChars(entryPtr, first, last-first);
- }
- } else if ((c == 'g') && (strncmp(argv[1], "get", length) == 0)) {
- if (argc != 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " get\"", (char *) NULL);
- goto error;
- }
- interp->result = entryPtr->string;
- } else if ((c == 'i') && (strncmp(argv[1], "icursor", length) == 0)
- && (length >= 2)) {
- if (argc != 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " icursor pos\"",
- (char *) NULL);
- goto error;
- }
- if (GetEntryIndex(interp, entryPtr, argv[2], &entryPtr->insertPos)
- != TCL_OK) {
- goto error;
- }
- EventuallyRedraw(entryPtr);
- } else if ((c == 'i') && (strncmp(argv[1], "index", length) == 0)
- && (length >= 3)) {
- int index;
-
- if (argc != 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " index string\"", (char *) NULL);
- goto error;
- }
- if (GetEntryIndex(interp, entryPtr, argv[2], &index) != TCL_OK) {
- goto error;
- }
- sprintf(interp->result, "%d", index);
- } else if ((c == 'i') && (strncmp(argv[1], "insert", length) == 0)
- && (length >= 3)) {
- int index;
-
- if (argc != 4) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " insert index text\"",
- (char *) NULL);
- goto error;
- }
- if (GetEntryIndex(interp, entryPtr, argv[2], &index) != TCL_OK) {
- goto error;
- }
- if (entryPtr->state == tkNormalUid) {
- InsertChars(entryPtr, index, argv[3]);
- }
- } else if ((c == 's') && (length >= 2)
- && (strncmp(argv[1], "scan", length) == 0)) {
- int x;
-
- if (argc != 4) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " scan mark|dragto x\"", (char *) NULL);
- goto error;
- }
- if (Tcl_GetInt(interp, argv[3], &x) != TCL_OK) {
- goto error;
- }
- if ((argv[2][0] == 'm')
- && (strncmp(argv[2], "mark", strlen(argv[2])) == 0)) {
- entryPtr->scanMarkX = x;
- entryPtr->scanMarkIndex = entryPtr->leftIndex;
- } else if ((argv[2][0] == 'd')
- && (strncmp(argv[2], "dragto", strlen(argv[2])) == 0)) {
- EntryScanTo(entryPtr, x);
- } else {
- Tcl_AppendResult(interp, "bad scan option \"", argv[2],
- "\": must be mark or dragto", (char *) NULL);
- goto error;
- }
- } else if ((c == 's') && (length >= 2)
- && (strncmp(argv[1], "selection", length) == 0)) {
- int index, index2;
-
- if (argc < 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " select option ?index?\"", (char *) NULL);
- goto error;
- }
- length = strlen(argv[2]);
- c = argv[2][0];
- if ((c == 'c') && (strncmp(argv[2], "clear", length) == 0)) {
- if (argc != 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " selection clear\"", (char *) NULL);
- goto error;
- }
- if (entryPtr->selectFirst != -1) {
- entryPtr->selectFirst = entryPtr->selectLast = -1;
- EventuallyRedraw(entryPtr);
- }
- goto done;
- } else if ((c == 'p') && (strncmp(argv[2], "present", length) == 0)) {
- if (argc != 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " selection present\"", (char *) NULL);
- goto error;
- }
- if (entryPtr->selectFirst == -1) {
- interp->result = "0";
- } else {
- interp->result = "1";
- }
- goto done;
- }
- if (argc >= 4) {
- if (GetEntryIndex(interp, entryPtr, argv[3], &index) != TCL_OK) {
- goto error;
- }
- }
- if ((c == 'a') && (strncmp(argv[2], "adjust", length) == 0)) {
- if (argc != 4) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " selection adjust index\"",
- (char *) NULL);
- 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);
- } else if ((c == 'f') && (strncmp(argv[2], "from", length) == 0)) {
- if (argc != 4) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " selection from index\"",
- (char *) NULL);
- goto error;
- }
- entryPtr->selectAnchor = index;
- } else if ((c == 'r') && (strncmp(argv[2], "range", length) == 0)) {
- if (argc != 5) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " selection range start end\"",
- (char *) NULL);
- goto error;
- }
- if (GetEntryIndex(interp, entryPtr, argv[4], &index2) != TCL_OK) {
- goto error;
- }
- if (index >= index2) {
- entryPtr->selectFirst = 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);
- } else if ((c == 't') && (strncmp(argv[2], "to", length) == 0)) {
- if (argc != 4) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " selection to index\"",
- (char *) NULL);
- goto error;
- }
- EntrySelectTo(entryPtr, index);
- } else {
- Tcl_AppendResult(interp, "bad selection option \"", argv[2],
- "\": must be adjust, clear, from, present, range, or to",
- (char *) NULL);
- goto error;
- }
- } else if ((c == 'x') && (strncmp(argv[1], "xview", length) == 0)) {
- int index, type, count, charsPerPage;
- double fraction, first, last;
-
- if (argc == 2) {
- EntryVisibleRange(entryPtr, &first, &last);
- sprintf(interp->result, "%g %g", first, last);
- goto done;
- } else if (argc == 3) {
- if (GetEntryIndex(interp, entryPtr, argv[2], &index) != TCL_OK) {
- goto error;
- }
- } else {
- type = Tk_GetScrollInfo(interp, argc, argv, &fraction, &count);
- index = entryPtr->leftIndex;
- switch (type) {
- case TK_SCROLL_ERROR:
- goto error;
- case TK_SCROLL_MOVETO:
- index = (int) ((fraction * entryPtr->numChars) + 0.5);
- break;
- case TK_SCROLL_PAGES:
- charsPerPage = ((Tk_Width(entryPtr->tkwin)
- - 2*entryPtr->inset) / entryPtr->avgWidth) - 2;
- if (charsPerPage < 1) {
- charsPerPage = 1;
- }
- index += charsPerPage*count;
- 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);
- } else {
- Tcl_AppendResult(interp, "bad option \"", argv[1],
- "\": must be bbox, cget, configure, delete, get, ",
- "icursor, index, insert, scan, selection, or xview",
- (char *) NULL);
- goto error;
- }
- done:
- Tcl_Release((ClientData) entryPtr);
- return result;
-
- error:
- Tcl_Release((ClientData) entryPtr);
- return TCL_ERROR;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * DestroyEntry --
- *
- * This procedure is invoked by Tcl_EventuallyFree or Tcl_Release
- * to clean up the internal structure of an entry at a safe time
- * (when no-one is using it anymore).
- *
- * Results:
- * None.
- *
- * Side effects:
- * Everything associated with the entry is freed up.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-DestroyEntry(memPtr)
- char *memPtr; /* Info about entry widget. */
-{
- register Entry *entryPtr = (Entry *) memPtr;
-
- /*
- * Free up all the stuff that requires special handling, then
- * let Tk_FreeOptions handle all the standard option-related
- * stuff.
- */
-
- ckfree(entryPtr->string);
- if (entryPtr->textVarName != NULL) {
- Tcl_UntraceVar(entryPtr->interp, entryPtr->textVarName,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- EntryTextVarProc, (ClientData) entryPtr);
- }
- if (entryPtr->textGC != None) {
- Tk_FreeGC(entryPtr->display, entryPtr->textGC);
- }
- if (entryPtr->selTextGC != None) {
- Tk_FreeGC(entryPtr->display, entryPtr->selTextGC);
- }
- Tcl_DeleteTimerHandler(entryPtr->insertBlinkHandler);
- if (entryPtr->displayString != NULL) {
- ckfree(entryPtr->displayString);
- }
- Tk_FreeTextLayout(entryPtr->textLayout);
- Tk_FreeOptions(configSpecs, (char *) entryPtr, entryPtr->display, 0);
- ckfree((char *) entryPtr);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ConfigureEntry --
- *
- * This procedure is called to process an argv/argc list, plus
- * the Tk option database, in order to configure (or reconfigure)
- * an entry widget.
- *
- * Results:
- * The return value is a standard Tcl result. If TCL_ERROR is
- * returned, then interp->result contains an error message.
- *
- * Side effects:
- * Configuration information, such as colors, border width,
- * etc. get set for entryPtr; old resources get freed,
- * if there were any.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-ConfigureEntry(interp, entryPtr, argc, argv, flags)
- Tcl_Interp *interp; /* Used for error reporting. */
- register Entry *entryPtr; /* 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 flags; /* Flags to pass to Tk_ConfigureWidget. */
-{
- int oldExport;
-
- /*
- * Eliminate any existing trace on a variable monitored by the entry.
- */
-
- if (entryPtr->textVarName != NULL) {
- Tcl_UntraceVar(interp, entryPtr->textVarName,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- EntryTextVarProc, (ClientData) entryPtr);
- }
-
- oldExport = entryPtr->exportSelection;
- if (Tk_ConfigureWidget(interp, entryPtr->tkwin, configSpecs,
- argc, argv, (char *) entryPtr, flags) != TCL_OK) {
- return TCL_ERROR;
- }
-
- /*
- * 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 (entryPtr->textVarName != NULL) {
- char *value;
-
- value = Tcl_GetVar(interp, entryPtr->textVarName, TCL_GLOBAL_ONLY);
- if (value == NULL) {
- EntryValueChanged(entryPtr);
- } else {
- EntrySetValue(entryPtr, value);
- }
- Tcl_TraceVar(interp, entryPtr->textVarName,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- EntryTextVarProc, (ClientData) entryPtr);
- }
-
- /*
- * A few other options also need special processing, such as parsing
- * the geometry and setting the background from a 3-D border.
- */
-
- if ((entryPtr->state != tkNormalUid)
- && (entryPtr->state != tkDisabledUid)) {
- Tcl_AppendResult(interp, "bad state value \"", entryPtr->state,
- "\": must be normal or disabled", (char *) NULL);
- entryPtr->state = tkNormalUid;
- return TCL_ERROR;
- }
-
- Tk_SetBackgroundFromBorder(entryPtr->tkwin, entryPtr->normalBorder);
-
- if (entryPtr->insertWidth <= 0) {
- entryPtr->insertWidth = 2;
- }
- if (entryPtr->insertBorderWidth > entryPtr->insertWidth/2) {
- entryPtr->insertBorderWidth = entryPtr->insertWidth/2;
- }
-
- /*
- * Restart the cursor timing sequence in case the on-time or off-time
- * just changed.
- */
-
- if (entryPtr->flags & GOT_FOCUS) {
- EntryFocusProc(entryPtr, 1);
- }
-
- /*
- * Claim the selection if we've suddenly started exporting it.
- */
-
- if (entryPtr->exportSelection && (!oldExport)
- && (entryPtr->selectFirst != -1)
- && !(entryPtr->flags & GOT_SELECTION)) {
- Tk_OwnSelection(entryPtr->tkwin, XA_PRIMARY, EntryLostSelection,
- (ClientData) entryPtr);
- entryPtr->flags |= GOT_SELECTION;
- }
-
- /*
- * Recompute the window's geometry and arrange for it to be
- * redisplayed.
- */
-
- Tk_SetInternalBorder(entryPtr->tkwin,
- entryPtr->borderWidth + entryPtr->highlightWidth);
- if (entryPtr->highlightWidth <= 0) {
- entryPtr->highlightWidth = 0;
- }
- entryPtr->inset = entryPtr->highlightWidth + entryPtr->borderWidth + XPAD;
-
- EntryWorldChanged((ClientData) entryPtr);
- return TCL_OK;
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * EntryWorldChanged --
- *
- * 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:
- * Entry will be relayed out and redisplayed.
- *
- *---------------------------------------------------------------------------
- */
-
-static void
-EntryWorldChanged(instanceData)
- ClientData instanceData; /* Information about widget. */
-{
- XGCValues gcValues;
- GC gc;
- unsigned long mask;
- Entry *entryPtr;
-
- entryPtr = (Entry *) instanceData;
-
- entryPtr->avgWidth = Tk_TextWidth(entryPtr->tkfont, "0", 1);
- if (entryPtr->avgWidth == 0) {
- entryPtr->avgWidth = 1;
- }
-
- gcValues.foreground = entryPtr->fgColorPtr->pixel;
- gcValues.font = Tk_FontId(entryPtr->tkfont);
- gcValues.graphics_exposures = False;
- mask = GCForeground | GCFont | GCGraphicsExposures;
- gc = Tk_GetGC(entryPtr->tkwin, mask, &gcValues);
- if (entryPtr->textGC != None) {
- Tk_FreeGC(entryPtr->display, entryPtr->textGC);
- }
- entryPtr->textGC = gc;
-
- gcValues.foreground = entryPtr->selFgColorPtr->pixel;
- gcValues.font = Tk_FontId(entryPtr->tkfont);
- mask = GCForeground | GCFont;
- gc = Tk_GetGC(entryPtr->tkwin, mask, &gcValues);
- if (entryPtr->selTextGC != None) {
- Tk_FreeGC(entryPtr->display, entryPtr->selTextGC);
- }
- entryPtr->selTextGC = gc;
-
- /*
- * Recompute the window's geometry and arrange for it to be
- * redisplayed.
- */
-
- EntryComputeGeometry(entryPtr);
- entryPtr->flags |= UPDATE_SCROLLBAR;
- EventuallyRedraw(entryPtr);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * DisplayEntry --
- *
- * This procedure redraws the contents of an entry window.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Information appears on the screen.
- *
- *--------------------------------------------------------------
- */
-
-static void
-DisplayEntry(clientData)
- ClientData clientData; /* Information about window. */
-{
- register Entry *entryPtr = (Entry *) clientData;
- register Tk_Window tkwin = entryPtr->tkwin;
- int baseY, selStartX, selEndX, cursorX, x, w;
- int xBound;
- Tk_FontMetrics fm;
- Pixmap pixmap;
- int showSelection;
-
- entryPtr->flags &= ~REDRAW_PENDING;
- if ((entryPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) {
- return;
- }
-
- Tk_GetFontMetrics(entryPtr->tkfont, &fm);
-
- /*
- * Update the scrollbar if that's needed.
- */
-
- if (entryPtr->flags & UPDATE_SCROLLBAR) {
- entryPtr->flags &= ~UPDATE_SCROLLBAR;
- EntryUpdateScrollbar(entryPtr);
- }
-
- /*
- * In order to avoid screen flashes, this procedure redraws the
- * textual area of the entry 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(entryPtr->display, Tk_WindowId(tkwin),
- Tk_Width(tkwin), Tk_Height(tkwin), Tk_Depth(tkwin));
-
- /*
- * Compute x-coordinate of the pixel just after last visible
- * one, plus vertical position of baseline of text.
- */
-
- xBound = Tk_Width(tkwin) - entryPtr->inset;
- baseY = (Tk_Height(tkwin) + fm.ascent - fm.descent) / 2;
-
- /*
- * On Windows and Mac, we need to hide the selection whenever we
- * don't have the focus.
- */
-
-#ifdef ALWAYS_SHOW_SELECTION
- showSelection = 1;
-#else
- showSelection = (entryPtr->flags & GOT_FOCUS);
-#endif
-
- /*
- * Draw the background in three layers. From bottom to top the
- * layers are: normal background, selection background, and
- * insertion cursor background.
- */
-
- Tk_Fill3DRectangle(tkwin, pixmap, entryPtr->normalBorder,
- 0, 0, Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT);
- if (showSelection && (entryPtr->selectLast > entryPtr->leftIndex)) {
- if (entryPtr->selectFirst <= entryPtr->leftIndex) {
- selStartX = entryPtr->leftX;
- } else {
- Tk_CharBbox(entryPtr->textLayout, entryPtr->selectFirst,
- &x, NULL, NULL, NULL);
- selStartX = x + entryPtr->layoutX;
- }
- if ((selStartX - entryPtr->selBorderWidth) < xBound) {
- Tk_CharBbox(entryPtr->textLayout, entryPtr->selectLast - 1,
- &x, NULL, &w, NULL);
- selEndX = x + w + entryPtr->layoutX;
- Tk_Fill3DRectangle(tkwin, pixmap, entryPtr->selBorder,
- selStartX - entryPtr->selBorderWidth,
- baseY - fm.ascent - entryPtr->selBorderWidth,
- (selEndX - selStartX) + 2*entryPtr->selBorderWidth,
- (fm.ascent + fm.descent) + 2*entryPtr->selBorderWidth,
- entryPtr->selBorderWidth, TK_RELIEF_RAISED);
- }
- }
-
- /*
- * Draw a special background for the insertion cursor, overriding
- * even the selection background. As a special hack to keep the
- * cursor visible when the insertion cursor color is the same as
- * the color for selected text (e.g., on mono displays), write
- * background in the cursor area (instead of nothing) when the
- * cursor isn't on. Otherwise the selection would hide the cursor.
- */
-
- if ((entryPtr->insertPos >= entryPtr->leftIndex)
- && (entryPtr->state == tkNormalUid)
- && (entryPtr->flags & GOT_FOCUS)) {
- if (entryPtr->insertPos == 0) {
- cursorX = 0;
- } else if (entryPtr->insertPos >= entryPtr->numChars) {
- Tk_CharBbox(entryPtr->textLayout, entryPtr->numChars - 1,
- &x, NULL, &w, NULL);
- cursorX = x + w;
- } else {
- Tk_CharBbox(entryPtr->textLayout, entryPtr->insertPos,
- &x, NULL, NULL, NULL);
- cursorX = x;
- }
- 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);
- }
- }
- }
-
- /*
- * Draw the text in two pieces: first the unselected portion, then the
- * selected portion on top of it.
- */
-
- Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->textGC,
- entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY,
- entryPtr->leftIndex, entryPtr->numChars);
-
- if (showSelection && (entryPtr->selTextGC != entryPtr->textGC) &&
- (entryPtr->selectFirst < entryPtr->selectLast)) {
- int first;
-
- if (entryPtr->selectFirst - entryPtr->leftIndex < 0) {
- first = entryPtr->leftIndex;
- } else {
- first = entryPtr->selectFirst;
- }
- Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->selTextGC,
- entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY,
- first, entryPtr->selectLast);
- }
-
- /*
- * Draw the border and focus highlight last, so they will overwrite
- * any text that extends past the viewable part of the window.
- */
-
- 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,
- entryPtr->borderWidth, entryPtr->relief);
- }
- if (entryPtr->highlightWidth != 0) {
- GC gc;
-
- if (entryPtr->flags & GOT_FOCUS) {
- gc = Tk_GCForColor(entryPtr->highlightColorPtr, pixmap);
- } else {
- gc = Tk_GCForColor(entryPtr->highlightBgColorPtr, pixmap);
- }
- Tk_DrawFocusHighlight(tkwin, gc, entryPtr->highlightWidth, pixmap);
- }
-
- /*
- * Everything's been redisplayed; now copy the pixmap onto the screen
- * and free up the pixmap.
- */
-
- XCopyArea(entryPtr->display, pixmap, Tk_WindowId(tkwin), entryPtr->textGC,
- 0, 0, (unsigned) Tk_Width(tkwin), (unsigned) Tk_Height(tkwin),
- 0, 0);
- Tk_FreePixmap(entryPtr->display, pixmap);
- entryPtr->flags &= ~BORDER_NEEDED;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * EntryComputeGeometry --
- *
- * This procedure is invoked to recompute information about where
- * in its window an entry's string will be displayed. It also
- * computes the requested size for the window.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The leftX and tabOrigin fields are recomputed for entryPtr,
- * and leftIndex may be adjusted. Tk_GeometryRequest is called
- * to register the desired dimensions for the window.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-EntryComputeGeometry(entryPtr)
- Entry *entryPtr; /* Widget record for entry. */
-{
- int totalLength, overflow, maxOffScreen, rightX;
- int height, width, i;
- Tk_FontMetrics fm;
- char *p, *displayString;
-
- /*
- * If we're displaying a special character instead of the value of
- * the entry, recompute the displayString.
- */
-
- if (entryPtr->displayString != NULL) {
- ckfree(entryPtr->displayString);
- entryPtr->displayString = NULL;
- }
- if (entryPtr->showChar != NULL) {
- entryPtr->displayString = (char *) ckalloc((unsigned)
- (entryPtr->numChars + 1));
- for (p = entryPtr->displayString, i = entryPtr->numChars; i > 0;
- i--, p++) {
- *p = entryPtr->showChar[0];
- }
- *p = 0;
- displayString = entryPtr->displayString;
- } else {
- displayString = entryPtr->string;
- }
- Tk_FreeTextLayout(entryPtr->textLayout);
- entryPtr->textLayout = Tk_ComputeTextLayout(entryPtr->tkfont,
- displayString, entryPtr->numChars, 0, entryPtr->justify,
- TK_IGNORE_NEWLINES, &totalLength, &height);
-
- entryPtr->layoutY = (Tk_Height(entryPtr->tkwin) - height) / 2;
-
- /*
- * Recompute where the leftmost character on the display will
- * be drawn (entryPtr->leftX) and adjust leftIndex if necessary
- * so that we don't let characters hang off the edge of the
- * window unless the entire window is full.
- */
-
- overflow = totalLength - (Tk_Width(entryPtr->tkwin) - 2*entryPtr->inset);
- 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;
- } else {
- entryPtr->leftX = (Tk_Width(entryPtr->tkwin) - totalLength)/2;
- }
- entryPtr->layoutX = entryPtr->leftX;
- } else {
- /*
- * The whole string can't fit in the window. Compute the
- * maximum number of characters that may be off-screen to
- * the left without leaving empty space on the right of the
- * window, then don't let leftIndex be any greater than that.
- */
-
- maxOffScreen = Tk_PointToChar(entryPtr->textLayout, overflow, 0);
- Tk_CharBbox(entryPtr->textLayout, maxOffScreen,
- &rightX, NULL, NULL, NULL);
- if (rightX < overflow) {
- maxOffScreen += 1;
- }
- if (entryPtr->leftIndex > maxOffScreen) {
- entryPtr->leftIndex = maxOffScreen;
- }
- Tk_CharBbox(entryPtr->textLayout, entryPtr->leftIndex,
- &rightX, NULL, NULL, NULL);
- entryPtr->leftX = entryPtr->inset;
- entryPtr->layoutX = entryPtr->leftX - rightX;
- }
-
- Tk_GetFontMetrics(entryPtr->tkfont, &fm);
- height = fm.linespace + 2*entryPtr->inset + 2*(YPAD-XPAD);
- if (entryPtr->prefWidth > 0) {
- width = entryPtr->prefWidth*entryPtr->avgWidth + 2*entryPtr->inset;
- } else {
- if (totalLength == 0) {
- width = entryPtr->avgWidth + 2*entryPtr->inset;
- } else {
- width = totalLength + 2*entryPtr->inset;
- }
- }
- Tk_GeometryRequest(entryPtr->tkwin, width, height);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * InsertChars --
- *
- * Add new characters to an entry widget.
- *
- * Results:
- * None.
- *
- * Side effects:
- * New information gets added to entryPtr; it will be redisplayed
- * soon, but not necessarily immediately.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-InsertChars(entryPtr, index, string)
- register Entry *entryPtr; /* Entry that is to get the new
- * elements. */
- int index; /* Add the new elements before this
- * element. */
- char *string; /* New characters to add (NULL-terminated
- * string). */
-{
- int length;
- char *new;
-
- length = strlen(string);
- if (length == 0) {
- return;
- }
- new = (char *) ckalloc((unsigned) (entryPtr->numChars + length + 1));
- strncpy(new, entryPtr->string, (size_t) index);
- strcpy(new+index, string);
- strcpy(new+index+length, entryPtr->string+index);
- ckfree(entryPtr->string);
- entryPtr->string = new;
- entryPtr->numChars += length;
-
- /*
- * Inserting characters invalidates all indexes into the string.
- * Touch up the indexes so that they still refer to the same
- * characters (at new positions). When updating the selection
- * end-points, don't include the new text in the selection unless
- * it was completely surrounded by the selection.
- */
-
- if (entryPtr->selectFirst >= index) {
- entryPtr->selectFirst += length;
- }
- if (entryPtr->selectLast > index) {
- entryPtr->selectLast += length;
- }
- if ((entryPtr->selectAnchor > index) || (entryPtr->selectFirst >= index)) {
- entryPtr->selectAnchor += length;
- }
- if (entryPtr->leftIndex > index) {
- entryPtr->leftIndex += length;
- }
- if (entryPtr->insertPos >= index) {
- entryPtr->insertPos += length;
- }
- EntryValueChanged(entryPtr);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * DeleteChars --
- *
- * Remove one or more characters from an entry widget.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Memory gets freed, the entry gets modified and (eventually)
- * redisplayed.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-DeleteChars(entryPtr, index, count)
- register Entry *entryPtr; /* Entry widget to modify. */
- int index; /* Index of first character to delete. */
- int count; /* How many characters to delete. */
-{
- char *new;
-
- if ((index + count) > entryPtr->numChars) {
- count = entryPtr->numChars - index;
- }
- if (count <= 0) {
- return;
- }
-
- new = (char *) ckalloc((unsigned) (entryPtr->numChars + 1 - count));
- strncpy(new, entryPtr->string, (size_t) index);
- strcpy(new+index, entryPtr->string+index+count);
- ckfree(entryPtr->string);
- entryPtr->string = new;
- entryPtr->numChars -= count;
-
- /*
- * Deleting characters results in the remaining characters being
- * renumbered. Update the various indexes into the string to reflect
- * this change.
- */
-
- if (entryPtr->selectFirst >= index) {
- if (entryPtr->selectFirst >= (index+count)) {
- entryPtr->selectFirst -= count;
- } else {
- entryPtr->selectFirst = index;
- }
- }
- if (entryPtr->selectLast >= index) {
- if (entryPtr->selectLast >= (index+count)) {
- entryPtr->selectLast -= count;
- } else {
- entryPtr->selectLast = index;
- }
- }
- if (entryPtr->selectLast <= entryPtr->selectFirst) {
- entryPtr->selectFirst = entryPtr->selectLast = -1;
- }
- if (entryPtr->selectAnchor >= index) {
- if (entryPtr->selectAnchor >= (index+count)) {
- entryPtr->selectAnchor -= count;
- } else {
- entryPtr->selectAnchor = index;
- }
- }
- if (entryPtr->leftIndex > index) {
- if (entryPtr->leftIndex >= (index+count)) {
- entryPtr->leftIndex -= count;
- } else {
- entryPtr->leftIndex = index;
- }
- }
- if (entryPtr->insertPos >= index) {
- if (entryPtr->insertPos >= (index+count)) {
- entryPtr->insertPos -= count;
- } else {
- entryPtr->insertPos = index;
- }
- }
- EntryValueChanged(entryPtr);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * EntryValueChanged --
- *
- * This procedure is invoked when characters are inserted into
- * an entry or deleted from it. It updates the entry's associated
- * variable, if there is one, and does other bookkeeping such
- * as arranging for redisplay.
- *
- * Results:
- * None.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-EntryValueChanged(entryPtr)
- Entry *entryPtr; /* Entry whose value just changed. */
-{
- char *newValue;
-
- if (entryPtr->textVarName == NULL) {
- newValue = NULL;
- } else {
- newValue = Tcl_SetVar(entryPtr->interp, entryPtr->textVarName,
- entryPtr->string, TCL_GLOBAL_ONLY);
- }
-
- if ((newValue != NULL) && (strcmp(newValue, entryPtr->string) != 0)) {
- /*
- * The value of the variable is different than what we asked for.
- * This means that a trace on the variable modified it. In this
- * case our trace procedure wasn't invoked since the modification
- * came while a trace was already active on the variable. So,
- * update our value to reflect the variable's latest value.
- */
-
- EntrySetValue(entryPtr, newValue);
- } else {
- /*
- * Arrange for redisplay.
- */
-
- entryPtr->flags |= UPDATE_SCROLLBAR;
- EntryComputeGeometry(entryPtr);
- EventuallyRedraw(entryPtr);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * EntrySetValue --
- *
- * Replace the contents of a text entry with a given value. This
- * procedure is invoked when updating the entry from the entry's
- * associated variable.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The string displayed in the entry will change. The selection,
- * insertion point, and view may have to be adjusted to keep them
- * within the bounds of the new string. Note: this procedure does
- * *not* update the entry's associated variable, since that could
- * result in an infinite loop.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-EntrySetValue(entryPtr, value)
- register Entry *entryPtr; /* Entry whose value is to be
- * changed. */
- char *value; /* New text to display in entry. */
-{
- ckfree(entryPtr->string);
- entryPtr->numChars = strlen(value);
- entryPtr->string = (char *) ckalloc((unsigned) (entryPtr->numChars + 1));
- strcpy(entryPtr->string, value);
- if (entryPtr->selectFirst != -1) {
- if (entryPtr->selectFirst >= entryPtr->numChars) {
- entryPtr->selectFirst = entryPtr->selectLast = -1;
- } else if (entryPtr->selectLast > entryPtr->numChars) {
- entryPtr->selectLast = entryPtr->numChars;
- }
- }
- if (entryPtr->leftIndex >= entryPtr->numChars) {
- entryPtr->leftIndex = entryPtr->numChars-1;
- if (entryPtr->leftIndex < 0) {
- entryPtr->leftIndex = 0;
- }
- }
- if (entryPtr->insertPos > entryPtr->numChars) {
- entryPtr->insertPos = entryPtr->numChars;
- }
-
- entryPtr->flags |= UPDATE_SCROLLBAR;
- EntryComputeGeometry(entryPtr);
- EventuallyRedraw(entryPtr);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * EntryEventProc --
- *
- * This procedure is invoked by the Tk dispatcher for various
- * events on entryes.
- *
- * Results:
- * None.
- *
- * Side effects:
- * When the window gets deleted, internal structures get
- * cleaned up. When it gets exposed, it is redisplayed.
- *
- *--------------------------------------------------------------
- */
-
-static void
-EntryEventProc(clientData, eventPtr)
- ClientData clientData; /* Information about window. */
- XEvent *eventPtr; /* Information about event. */
-{
- Entry *entryPtr = (Entry *) clientData;
- if (eventPtr->type == Expose) {
- EventuallyRedraw(entryPtr);
- entryPtr->flags |= BORDER_NEEDED;
- } else if (eventPtr->type == DestroyNotify) {
- if (entryPtr->tkwin != NULL) {
- entryPtr->tkwin = NULL;
- Tcl_DeleteCommandFromToken(entryPtr->interp, entryPtr->widgetCmd);
- }
- if (entryPtr->flags & REDRAW_PENDING) {
- Tcl_CancelIdleCall(DisplayEntry, (ClientData) entryPtr);
- }
- Tcl_EventuallyFree((ClientData) entryPtr, DestroyEntry);
- } 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);
- }
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * EntryCmdDeletedProc --
- *
- * 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
-EntryCmdDeletedProc(clientData)
- ClientData clientData; /* Pointer to widget record for widget. */
-{
- Entry *entryPtr = (Entry *) clientData;
- Tk_Window tkwin = entryPtr->tkwin;
-
- /*
- * This procedure could be invoked either because the window was
- * destroyed and the command was then deleted (in which case tkwin
- * is NULL) or because the command was deleted, and then this procedure
- * destroys the widget.
- */
-
- if (tkwin != NULL) {
- entryPtr->tkwin = NULL;
- Tk_DestroyWindow(tkwin);
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * GetEntryIndex --
- *
- * Parse an index into an entry and return either its value
- * or an error.
- *
- * Results:
- * A standard Tcl result. If all went well, then *indexPtr is
- * filled in with the index (into entryPtr) corresponding to
- * string. The index value is guaranteed to lie between 0 and
- * the number of characters in the string, inclusive. If an
- * error occurs then an error message is left in interp->result.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-static int
-GetEntryIndex(interp, entryPtr, string, indexPtr)
- Tcl_Interp *interp; /* For error messages. */
- Entry *entryPtr; /* Entry for which the index is being
- * specified. */
- char *string; /* Specifies character in entryPtr. */
- int *indexPtr; /* Where to store converted index. */
-{
- size_t length;
-
- length = strlen(string);
-
- if (string[0] == 'a') {
- if (strncmp(string, "anchor", length) == 0) {
- *indexPtr = entryPtr->selectAnchor;
- } else {
- badIndex:
-
- /*
- * Some of the paths here leave messages in interp->result,
- * so we have to clear it out before storing our own message.
- */
-
- Tcl_SetResult(interp, (char *) NULL, TCL_STATIC);
- Tcl_AppendResult(interp, "bad entry index \"", string,
- "\"", (char *) NULL);
- return TCL_ERROR;
- }
- } else if (string[0] == 'e') {
- if (strncmp(string, "end", length) == 0) {
- *indexPtr = entryPtr->numChars;
- } else {
- goto badIndex;
- }
- } else if (string[0] == 'i') {
- if (strncmp(string, "insert", length) == 0) {
- *indexPtr = entryPtr->insertPos;
- } else {
- goto badIndex;
- }
- } else if (string[0] == 's') {
- if (entryPtr->selectFirst == -1) {
- interp->result = "selection isn't in entry";
- return TCL_ERROR;
- }
- if (length < 5) {
- goto badIndex;
- }
- if (strncmp(string, "sel.first", length) == 0) {
- *indexPtr = entryPtr->selectFirst;
- } else if (strncmp(string, "sel.last", length) == 0) {
- *indexPtr = entryPtr->selectLast;
- } else {
- goto badIndex;
- }
- } else if (string[0] == '@') {
- int x, roundUp;
-
- if (Tcl_GetInt(interp, string+1, &x) != TCL_OK) {
- goto badIndex;
- }
- if (x < entryPtr->inset) {
- x = entryPtr->inset;
- }
- roundUp = 0;
- if (x >= (Tk_Width(entryPtr->tkwin) - entryPtr->inset)) {
- x = Tk_Width(entryPtr->tkwin) - entryPtr->inset - 1;
- roundUp = 1;
- }
- *indexPtr = Tk_PointToChar(entryPtr->textLayout,
- x - entryPtr->layoutX, 0);
-
- /*
- * Special trick: if the x-position was off-screen to the right,
- * round the index up to refer to the character just after the
- * last visible one on the screen. This is needed to enable the
- * last character to be selected, for example.
- */
-
- if (roundUp && (*indexPtr < entryPtr->numChars)) {
- *indexPtr += 1;
- }
- } else {
- if (Tcl_GetInt(interp, string, indexPtr) != TCL_OK) {
- goto badIndex;
- }
- if (*indexPtr < 0){
- *indexPtr = 0;
- } else if (*indexPtr > entryPtr->numChars) {
- *indexPtr = entryPtr->numChars;
- }
- }
- return TCL_OK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * EntryScanTo --
- *
- * Given a y-coordinate (presumably of the curent mouse location)
- * drag the view in the window to implement the scan operation.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The view in the window may change.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-EntryScanTo(entryPtr, x)
- register Entry *entryPtr; /* Information about widget. */
- int x; /* X-coordinate to use for scan
- * operation. */
-{
- int newLeftIndex;
-
- /*
- * Compute new leftIndex for entry by amplifying the difference
- * between the current position and the place where the scan
- * started (the "mark" position). If we run off the left or right
- * side of the entry, then reset the mark point so that the current
- * position continues to correspond to the edge of the window.
- * This means that the picture will start dragging as soon as the
- * mouse reverses direction (without this reset, might have to slide
- * mouse a long ways back before the picture starts moving again).
- */
-
- newLeftIndex = entryPtr->scanMarkIndex
- - (10*(x - entryPtr->scanMarkX))/entryPtr->avgWidth;
- if (newLeftIndex >= entryPtr->numChars) {
- newLeftIndex = entryPtr->scanMarkIndex = entryPtr->numChars-1;
- entryPtr->scanMarkX = x;
- }
- if (newLeftIndex < 0) {
- newLeftIndex = entryPtr->scanMarkIndex = 0;
- entryPtr->scanMarkX = x;
- }
- if (newLeftIndex != entryPtr->leftIndex) {
- entryPtr->leftIndex = newLeftIndex;
- entryPtr->flags |= UPDATE_SCROLLBAR;
- EntryComputeGeometry(entryPtr);
- EventuallyRedraw(entryPtr);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * EntrySelectTo --
- *
- * Modify the selection by moving its un-anchored end. This could
- * make the selection either larger or smaller.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The selection changes.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-EntrySelectTo(entryPtr, index)
- register Entry *entryPtr; /* Information about widget. */
- int index; /* Index of element that is to
- * become the "other" end of the
- * selection. */
-{
- int newFirst, newLast;
-
- /*
- * Grab the selection if we don't own it already.
- */
-
- if (!(entryPtr->flags & GOT_SELECTION) && (entryPtr->exportSelection)) {
- Tk_OwnSelection(entryPtr->tkwin, XA_PRIMARY, EntryLostSelection,
- (ClientData) entryPtr);
- entryPtr->flags |= GOT_SELECTION;
- }
-
- /*
- * Pick new starting and ending points for the selection.
- */
-
- if (entryPtr->selectAnchor > entryPtr->numChars) {
- entryPtr->selectAnchor = entryPtr->numChars;
- }
- if (entryPtr->selectAnchor <= index) {
- newFirst = entryPtr->selectAnchor;
- newLast = index;
- } else {
- newFirst = index;
- newLast = entryPtr->selectAnchor;
- if (newLast < 0) {
- newFirst = newLast = -1;
- }
- }
- if ((entryPtr->selectFirst == newFirst)
- && (entryPtr->selectLast == newLast)) {
- return;
- }
- entryPtr->selectFirst = newFirst;
- entryPtr->selectLast = newLast;
- EventuallyRedraw(entryPtr);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * EntryFetchSelection --
- *
- * This procedure is called back by Tk when the selection is
- * requested by someone. It returns part or all of the selection
- * in a buffer provided by the caller.
- *
- * Results:
- * The return value is the number of non-NULL bytes stored
- * at buffer. Buffer is filled (or partially filled) with a
- * NULL-terminated string containing part or all of the selection,
- * as given by offset and maxBytes.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-EntryFetchSelection(clientData, offset, buffer, maxBytes)
- ClientData clientData; /* Information about entry widget. */
- int offset; /* Offset within selection of first
- * character to be returned. */
- char *buffer; /* Location in which to place
- * selection. */
- int maxBytes; /* Maximum number of bytes to place
- * at buffer, not including terminating
- * NULL character. */
-{
- Entry *entryPtr = (Entry *) clientData;
- int count;
- char *displayString;
-
- if ((entryPtr->selectFirst < 0) || !(entryPtr->exportSelection)) {
- return -1;
- }
- count = entryPtr->selectLast - entryPtr->selectFirst - offset;
- if (count > maxBytes) {
- count = maxBytes;
- }
- if (count <= 0) {
- return 0;
- }
- if (entryPtr->displayString == NULL) {
- displayString = entryPtr->string;
- } else {
- displayString = entryPtr->displayString;
- }
- strncpy(buffer, displayString + entryPtr->selectFirst + offset,
- (size_t) count);
- buffer[count] = '\0';
- return count;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * EntryLostSelection --
- *
- * This procedure is called back by Tk when the selection is
- * grabbed away from an entry widget.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The existing selection is unhighlighted, and the window is
- * marked as not containing a selection.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-EntryLostSelection(clientData)
- ClientData clientData; /* Information about entry widget. */
-{
- Entry *entryPtr = (Entry *) clientData;
-
- entryPtr->flags &= ~GOT_SELECTION;
-
- /*
- * On Windows and Mac systems, we want to remember the selection
- * for the next time the focus enters the window. On Unix, we need
- * to clear the selection since it is always visible.
- */
-
-#ifdef ALWAYS_SHOW_SELECTION
- if ((entryPtr->selectFirst != -1) && entryPtr->exportSelection) {
- entryPtr->selectFirst = -1;
- entryPtr->selectLast = -1;
- EventuallyRedraw(entryPtr);
- }
-#endif
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * EventuallyRedraw --
- *
- * Ensure that an entry is eventually redrawn on the display.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Information gets redisplayed. Right now we don't do selective
- * redisplays: the whole window will be redrawn. This doesn't
- * seem to hurt performance noticeably, but if it does then this
- * could be changed.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-EventuallyRedraw(entryPtr)
- register Entry *entryPtr; /* Information about widget. */
-{
- if ((entryPtr->tkwin == NULL) || !Tk_IsMapped(entryPtr->tkwin)) {
- return;
- }
-
- /*
- * Right now we don't do selective redisplays: the whole window
- * will be redrawn. This doesn't seem to hurt performance noticeably,
- * but if it does then this could be changed.
- */
-
- if (!(entryPtr->flags & REDRAW_PENDING)) {
- entryPtr->flags |= REDRAW_PENDING;
- Tcl_DoWhenIdle(DisplayEntry, (ClientData) entryPtr);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * EntryVisibleRange --
- *
- * Return information about the range of the entry that is
- * currently visible.
- *
- * Results:
- * *firstPtr and *lastPtr are modified to hold fractions between
- * 0 and 1 identifying the range of characters visible in the
- * entry.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-EntryVisibleRange(entryPtr, firstPtr, lastPtr)
- Entry *entryPtr; /* Information about widget. */
- double *firstPtr; /* Return position of first visible
- * character in widget. */
- double *lastPtr; /* Return position of char just after
- * last visible one. */
-{
- int charsInWindow;
-
- if (entryPtr->numChars == 0) {
- *firstPtr = 0.0;
- *lastPtr = 1.0;
- } else {
- charsInWindow = Tk_PointToChar(entryPtr->textLayout,
- Tk_Width(entryPtr->tkwin) - entryPtr->inset
- - entryPtr->layoutX - 1, 0) + 1;
- if (charsInWindow > entryPtr->numChars) {
- /*
- * If all chars were visible, then charsInWindow will be
- * the index just after the last char that was visible.
- */
-
- charsInWindow = entryPtr->numChars;
- }
- charsInWindow -= entryPtr->leftIndex;
- if (charsInWindow == 0) {
- charsInWindow = 1;
- }
- *firstPtr = ((double) entryPtr->leftIndex)/entryPtr->numChars;
- *lastPtr = ((double) (entryPtr->leftIndex + charsInWindow))
- /entryPtr->numChars;
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * EntryUpdateScrollbar --
- *
- * This procedure is invoked whenever information has changed in
- * an entry in a way that would invalidate a scrollbar display.
- * If there is an associated scrollbar, then this procedure updates
- * it by invoking a Tcl command.
- *
- * Results:
- * None.
- *
- * Side effects:
- * A Tcl command is invoked, and an additional command may be
- * invoked to process errors in the command.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-EntryUpdateScrollbar(entryPtr)
- Entry *entryPtr; /* Information about widget. */
-{
- char args[100];
- int code;
- double first, last;
- Tcl_Interp *interp;
-
- if (entryPtr->scrollCmd == NULL) {
- return;
- }
-
- interp = entryPtr->interp;
- Tcl_Preserve((ClientData) interp);
- EntryVisibleRange(entryPtr, &first, &last);
- sprintf(args, " %g %g", first, last);
- code = Tcl_VarEval(interp, entryPtr->scrollCmd, args, (char *) NULL);
- if (code != TCL_OK) {
- Tcl_AddErrorInfo(interp,
- "\n (horizontal scrolling command executed by entry)");
- Tcl_BackgroundError(interp);
- }
- Tcl_SetResult(interp, (char *) NULL, TCL_STATIC);
- Tcl_Release((ClientData) interp);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * EntryBlinkProc --
- *
- * This procedure is called as a timer handler to blink the
- * insertion cursor off and on.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The cursor gets turned on or off, redisplay gets invoked,
- * and this procedure reschedules itself.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-EntryBlinkProc(clientData)
- ClientData clientData; /* Pointer to record describing entry. */
-{
- register Entry *entryPtr = (Entry *) clientData;
-
- if (!(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);
- } else {
- entryPtr->flags |= CURSOR_ON;
- entryPtr->insertBlinkHandler = Tcl_CreateTimerHandler(
- entryPtr->insertOnTime, EntryBlinkProc, (ClientData) entryPtr);
- }
- EventuallyRedraw(entryPtr);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * EntryFocusProc --
- *
- * This procedure is called whenever the entry gets or loses the
- * input focus. It's also called whenever the window is reconfigured
- * while it has the focus.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The cursor gets turned on or off.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-EntryFocusProc(entryPtr, gotFocus)
- register Entry *entryPtr; /* Entry that got or lost focus. */
- int gotFocus; /* 1 means window is getting focus, 0 means
- * it's losing it. */
-{
- Tcl_DeleteTimerHandler(entryPtr->insertBlinkHandler);
- if (gotFocus) {
- entryPtr->flags |= GOT_FOCUS | CURSOR_ON;
- if (entryPtr->insertOffTime != 0) {
- entryPtr->insertBlinkHandler = Tcl_CreateTimerHandler(
- entryPtr->insertOnTime, EntryBlinkProc,
- (ClientData) entryPtr);
- }
- } else {
- entryPtr->flags &= ~(GOT_FOCUS | CURSOR_ON);
- entryPtr->insertBlinkHandler = (Tcl_TimerToken) NULL;
- }
- EventuallyRedraw(entryPtr);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * EntryTextVarProc --
- *
- * This procedure is invoked when someone changes the variable
- * whose contents are to be displayed in an entry.
- *
- * Results:
- * NULL is always returned.
- *
- * Side effects:
- * The text displayed in the entry will change to match the
- * variable.
- *
- *--------------------------------------------------------------
- */
-
- /* ARGSUSED */
-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. */
- int flags; /* Information about what happened. */
-{
- register Entry *entryPtr = (Entry *) clientData;
- char *value;
-
- /*
- * If the variable is unset, then immediately recreate it unless
- * the whole interpreter is going away.
- */
-
- if (flags & TCL_TRACE_UNSETS) {
- if ((flags & TCL_TRACE_DESTROYED) && !(flags & TCL_INTERP_DESTROYED)) {
- Tcl_SetVar(interp, entryPtr->textVarName, entryPtr->string,
- TCL_GLOBAL_ONLY);
- Tcl_TraceVar(interp, entryPtr->textVarName,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- EntryTextVarProc, clientData);
- }
- return (char *) NULL;
- }
-
- /*
- * Update the entry's text with the value of the variable, unless
- * the entry already has that value (this happens when the variable
- * changes value because we changed it because someone typed in
- * the entry).
- */
-
- value = Tcl_GetVar(interp, entryPtr->textVarName, TCL_GLOBAL_ONLY);
- if (value == NULL) {
- value = "";
- }
- if (strcmp(value, entryPtr->string) != 0) {
- EntrySetValue(entryPtr, value);
- }
- return (char *) NULL;
-}
diff --git a/generic/tkError.c b/generic/tkError.c
deleted file mode 100644
index a601720..0000000
--- a/generic/tkError.c
+++ /dev/null
@@ -1,307 +0,0 @@
-/*
- * tkError.c --
- *
- * This file provides a high-performance mechanism for
- * selectively dealing with errors that occur in talking
- * to the X server. This is useful, for example, when
- * communicating with a window that may not exist.
- *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1995 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: tkError.c,v 1.2 1998/09/14 18:23:09 stanton Exp $
- */
-
-#include "tkPort.h"
-#include "tkInt.h"
-
-/*
- * The default X error handler gets saved here, so that it can
- * be invoked if an error occurs that we can't handle.
- */
-
-static int (*defaultHandler) _ANSI_ARGS_((Display *display,
- XErrorEvent *eventPtr)) = NULL;
-
-
-/*
- * Forward references to procedures declared later in this file:
- */
-
-static int ErrorProc _ANSI_ARGS_((Display *display,
- XErrorEvent *errEventPtr));
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_CreateErrorHandler --
- *
- * Arrange for all a given procedure to be invoked whenever
- * certain errors occur.
- *
- * Results:
- * The return value is a token identifying the handler;
- * it must be passed to Tk_DeleteErrorHandler to delete the
- * handler.
- *
- * Side effects:
- * If an X error occurs that matches the error, request,
- * and minor arguments, then errorProc will be invoked.
- * ErrorProc should have the following structure:
- *
- * int
- * errorProc(clientData, errorEventPtr)
- * caddr_t clientData;
- * XErrorEvent *errorEventPtr;
- * {
- * }
- *
- * The clientData argument will be the same as the clientData
- * argument to this procedure, and errorEvent will describe
- * the error. If errorProc returns 0, it means that it
- * completely "handled" the error: no further processing
- * should be done. If errorProc returns 1, it means that it
- * didn't know how to deal with the error, so we should look
- * for other error handlers, or invoke the default error
- * handler if no other handler returns zero. Handlers are
- * invoked in order of age: youngest handler first.
- *
- * Note: errorProc will only be called for errors associated
- * with X requests made AFTER this call, but BEFORE the handler
- * is deleted by calling Tk_DeleteErrorHandler.
- *
- *--------------------------------------------------------------
- */
-
-Tk_ErrorHandler
-Tk_CreateErrorHandler(display, error, request, minorCode, errorProc, clientData)
- Display *display; /* Display for which to handle
- * errors. */
- int error; /* Consider only errors with this
- * error_code (-1 means consider
- * all errors). */
- int request; /* Consider only errors with this
- * major request code (-1 means
- * consider all major codes). */
- int minorCode; /* Consider only errors with this
- * minor request code (-1 means
- * consider all minor codes). */
- Tk_ErrorProc *errorProc; /* Procedure to invoke when a
- * matching error occurs. NULL means
- * just ignore matching errors. */
- ClientData clientData; /* Arbitrary value to pass to
- * errorProc. */
-{
- register TkErrorHandler *errorPtr;
- register TkDisplay *dispPtr;
-
- /*
- * Find the display. If Tk doesn't know about this display then
- * it's an error: panic.
- */
-
- dispPtr = TkGetDisplay(display);
- if (dispPtr == NULL) {
- panic("Unknown display passed to Tk_CreateErrorHandler");
- }
-
- /*
- * Make sure that X calls us whenever errors occur.
- */
-
- if (defaultHandler == NULL) {
- defaultHandler = XSetErrorHandler(ErrorProc);
- }
-
- /*
- * Create the handler record.
- */
-
- errorPtr = (TkErrorHandler *) ckalloc(sizeof(TkErrorHandler));
- errorPtr->dispPtr = dispPtr;
- errorPtr->firstRequest = NextRequest(display);
- errorPtr->lastRequest = (unsigned) -1;
- errorPtr->error = error;
- errorPtr->request = request;
- errorPtr->minorCode = minorCode;
- errorPtr->errorProc = errorProc;
- errorPtr->clientData = clientData;
- errorPtr->nextPtr = dispPtr->errorPtr;
- dispPtr->errorPtr = errorPtr;
-
- return (Tk_ErrorHandler) errorPtr;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_DeleteErrorHandler --
- *
- * Do not use an error handler anymore.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The handler denoted by the "handler" argument will not
- * be invoked for any X errors associated with requests
- * made after this call. However, if errors arrive later
- * for requests made BEFORE this call, then the handler
- * will still be invoked. Call XSync if you want to be
- * sure that all outstanding errors have been received
- * and processed.
- *
- *--------------------------------------------------------------
- */
-
-void
-Tk_DeleteErrorHandler(handler)
- Tk_ErrorHandler handler; /* Token for handler to delete;
- * was previous return value from
- * Tk_CreateErrorHandler. */
-{
- register TkErrorHandler *errorPtr = (TkErrorHandler *) handler;
- register TkDisplay *dispPtr = errorPtr->dispPtr;
-
- errorPtr->lastRequest = NextRequest(dispPtr->display) - 1;
-
- /*
- * Every once-in-a-while, cleanup handlers that are no longer
- * active. We probably won't be able to free the handler that
- * was just deleted (need to wait for any outstanding requests to
- * be processed by server), but there may be previously-deleted
- * handlers that are now ready for garbage collection. To reduce
- * the cost of the cleanup, let a few dead handlers pile up, then
- * clean them all at once. This adds a bit of overhead to errors
- * that might occur while the dead handlers are hanging around,
- * but reduces the overhead of scanning the list to clean up
- * (particularly if there are many handlers that stay around
- * forever).
- */
-
- dispPtr->deleteCount += 1;
- if (dispPtr->deleteCount >= 10) {
- register TkErrorHandler *prevPtr;
- TkErrorHandler *nextPtr;
- int lastSerial;
-
- dispPtr->deleteCount = 0;
- lastSerial = LastKnownRequestProcessed(dispPtr->display);
- errorPtr = dispPtr->errorPtr;
- for (prevPtr = NULL; errorPtr != NULL; errorPtr = nextPtr) {
- nextPtr = errorPtr->nextPtr;
- if ((errorPtr->lastRequest != (unsigned long) -1)
- && (errorPtr->lastRequest <= (unsigned long) lastSerial)) {
- if (prevPtr == NULL) {
- dispPtr->errorPtr = nextPtr;
- } else {
- prevPtr->nextPtr = nextPtr;
- }
- ckfree((char *) errorPtr);
- continue;
- }
- prevPtr = errorPtr;
- }
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ErrorProc --
- *
- * This procedure is invoked by the X system when error
- * events arrive.
- *
- * Results:
- * If it returns, the return value is zero. However,
- * it is possible that one of the error handlers may
- * just exit.
- *
- * Side effects:
- * This procedure does two things. First, it uses the
- * serial # in the error event to eliminate handlers whose
- * expiration serials are now in the past. Second, it
- * invokes any handlers that want to deal with the error.
- *
- *--------------------------------------------------------------
- */
-
-static int
-ErrorProc(display, errEventPtr)
- Display *display; /* Display for which error
- * occurred. */
- register XErrorEvent *errEventPtr; /* Information about error. */
-{
- register TkDisplay *dispPtr;
- register TkErrorHandler *errorPtr;
-
- /*
- * See if we know anything about the display. If not, then
- * invoke the default error handler.
- */
-
- dispPtr = TkGetDisplay(display);
- if (dispPtr == NULL) {
- goto couldntHandle;
- }
-
- /*
- * Otherwise invoke any relevant handlers for the error, in order.
- */
-
- for (errorPtr = dispPtr->errorPtr; errorPtr != NULL;
- errorPtr = errorPtr->nextPtr) {
- if ((errorPtr->firstRequest > errEventPtr->serial)
- || ((errorPtr->error != -1)
- && (errorPtr->error != errEventPtr->error_code))
- || ((errorPtr->request != -1)
- && (errorPtr->request != errEventPtr->request_code))
- || ((errorPtr->minorCode != -1)
- && (errorPtr->minorCode != errEventPtr->minor_code))
- || ((errorPtr->lastRequest != (unsigned long) -1)
- && (errorPtr->lastRequest < errEventPtr->serial))) {
- continue;
- }
- if (errorPtr->errorProc == NULL) {
- return 0;
- } else {
- if ((*errorPtr->errorProc)(errorPtr->clientData,
- errEventPtr) == 0) {
- return 0;
- }
- }
- }
-
- /*
- * See if the error is a BadWindow error. If so, and it refers
- * to a window that still exists in our window table, then ignore
- * the error. Errors like this can occur if a window owned by us
- * is deleted by someone externally, like a window manager. We'll
- * ignore the errors at least long enough to clean up internally and
- * remove the entry from the window table.
- *
- * NOTE: For embedding, we must also check whether the window was
- * recently deleted. If so, it may be that Tk generated operations on
- * windows that were deleted by the container. Now we are getting
- * the errors (BadWindow) after Tk already deleted the window itself.
- */
-
- if ((errEventPtr->error_code == BadWindow) &&
- ((Tk_IdToWindow(display, (Window) errEventPtr->resourceid) !=
- NULL) ||
- (TkpWindowWasRecentlyDeleted((Window) errEventPtr->resourceid,
- dispPtr)))) {
- return 0;
- }
-
- /*
- * We couldn't handle the error. Use the default handler.
- */
-
- couldntHandle:
- return (*defaultHandler)(display, errEventPtr);
-}
diff --git a/generic/tkEvent.c b/generic/tkEvent.c
deleted file mode 100644
index 2e32b8f..0000000
--- a/generic/tkEvent.c
+++ /dev/null
@@ -1,1038 +0,0 @@
-/*
- * tkEvent.c --
- *
- * This file provides basic low-level facilities for managing
- * X events in Tk.
- *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1995 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: tkEvent.c,v 1.2 1998/09/14 18:23:09 stanton Exp $
- */
-
-#include "tkPort.h"
-#include "tkInt.h"
-#include <signal.h>
-
-/*
- * There's a potential problem if a handler is deleted while it's
- * current (i.e. its procedure is executing), since Tk_HandleEvent
- * will need to read the handler's "nextPtr" field when the procedure
- * returns. To handle this problem, structures of the type below
- * indicate the next handler to be processed for any (recursively
- * nested) dispatches in progress. The nextHandler fields get
- * updated if the handlers pointed to are deleted. Tk_HandleEvent
- * also needs to know if the entire window gets deleted; the winPtr
- * field is set to zero if that particular window gets deleted.
- */
-
-typedef struct InProgress {
- XEvent *eventPtr; /* Event currently being handled. */
- TkWindow *winPtr; /* Window for event. Gets set to None if
- * window is deleted while event is being
- * handled. */
- TkEventHandler *nextHandler; /* Next handler in search. */
- struct InProgress *nextPtr; /* Next higher nested search. */
-} InProgress;
-
-static InProgress *pendingPtr = NULL;
- /* Topmost search in progress, or
- * NULL if none. */
-
-/*
- * For each call to Tk_CreateGenericHandler, an instance of the following
- * structure will be created. All of the active handlers are linked into a
- * list.
- */
-
-typedef struct GenericHandler {
- Tk_GenericProc *proc; /* Procedure to dispatch on all X events. */
- ClientData clientData; /* Client data to pass to procedure. */
- int deleteFlag; /* Flag to set when this handler is deleted. */
- struct GenericHandler *nextPtr;
- /* Next handler in list of all generic
- * handlers, or NULL for end of list. */
-} GenericHandler;
-
-static GenericHandler *genericList = NULL;
- /* First handler in the list, or NULL. */
-static GenericHandler *lastGenericPtr = NULL;
- /* Last handler in list. */
-
-/*
- * There's a potential problem if Tk_HandleEvent is entered recursively.
- * A handler cannot be deleted physically until we have returned from
- * calling it. Otherwise, we're looking at unallocated memory in advancing to
- * its `next' entry. We deal with the problem by using the `delete flag' and
- * deleting handlers only when it's known that there's no handler active.
- *
- * The following variable has a non-zero value when a handler is active.
- */
-
-static int genericHandlersActive = 0;
-
-/*
- * The following structure is used for queueing X-style events on the
- * Tcl event queue.
- */
-
-typedef struct TkWindowEvent {
- Tcl_Event header; /* Standard information for all events. */
- XEvent event; /* The X event. */
-} TkWindowEvent;
-
-/*
- * Array of event masks corresponding to each X event:
- */
-
-static unsigned long eventMasks[TK_LASTEVENT] = {
- 0,
- 0,
- KeyPressMask, /* KeyPress */
- KeyReleaseMask, /* KeyRelease */
- ButtonPressMask, /* ButtonPress */
- ButtonReleaseMask, /* ButtonRelease */
- PointerMotionMask|PointerMotionHintMask|ButtonMotionMask
- |Button1MotionMask|Button2MotionMask|Button3MotionMask
- |Button4MotionMask|Button5MotionMask,
- /* MotionNotify */
- EnterWindowMask, /* EnterNotify */
- LeaveWindowMask, /* LeaveNotify */
- FocusChangeMask, /* FocusIn */
- FocusChangeMask, /* FocusOut */
- KeymapStateMask, /* KeymapNotify */
- ExposureMask, /* Expose */
- ExposureMask, /* GraphicsExpose */
- ExposureMask, /* NoExpose */
- VisibilityChangeMask, /* VisibilityNotify */
- SubstructureNotifyMask, /* CreateNotify */
- StructureNotifyMask, /* DestroyNotify */
- StructureNotifyMask, /* UnmapNotify */
- StructureNotifyMask, /* MapNotify */
- SubstructureRedirectMask, /* MapRequest */
- StructureNotifyMask, /* ReparentNotify */
- StructureNotifyMask, /* ConfigureNotify */
- SubstructureRedirectMask, /* ConfigureRequest */
- StructureNotifyMask, /* GravityNotify */
- ResizeRedirectMask, /* ResizeRequest */
- StructureNotifyMask, /* CirculateNotify */
- SubstructureRedirectMask, /* CirculateRequest */
- PropertyChangeMask, /* PropertyNotify */
- 0, /* SelectionClear */
- 0, /* SelectionRequest */
- 0, /* SelectionNotify */
- ColormapChangeMask, /* ColormapNotify */
- 0, /* ClientMessage */
- 0, /* Mapping Notify */
- VirtualEventMask, /* VirtualEvents */
- ActivateMask, /* ActivateNotify */
- ActivateMask /* DeactivateNotify */
-};
-
-/*
- * If someone has called Tk_RestrictEvents, the information below
- * keeps track of it.
- */
-
-static Tk_RestrictProc *restrictProc;
- /* Procedure to call. NULL means no
- * restrictProc is currently in effect. */
-static ClientData restrictArg; /* Argument to pass to restrictProc. */
-
-/*
- * Prototypes for procedures that are only referenced locally within
- * this file.
- */
-
-static void DelayedMotionProc _ANSI_ARGS_((ClientData clientData));
-static int WindowEventProc _ANSI_ARGS_((Tcl_Event *evPtr,
- int flags));
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_CreateEventHandler --
- *
- * Arrange for a given procedure to be invoked whenever
- * events from a given class occur in a given window.
- *
- * Results:
- * None.
- *
- * Side effects:
- * From now on, whenever an event of the type given by
- * mask occurs for token and is processed by Tk_HandleEvent,
- * proc will be called. See the manual entry for details
- * of the calling sequence and return value for proc.
- *
- *--------------------------------------------------------------
- */
-
-void
-Tk_CreateEventHandler(token, mask, proc, clientData)
- Tk_Window token; /* Token for window in which to
- * create handler. */
- unsigned long mask; /* Events for which proc should
- * be called. */
- Tk_EventProc *proc; /* Procedure to call for each
- * selected event */
- ClientData clientData; /* Arbitrary data to pass to proc. */
-{
- register TkEventHandler *handlerPtr;
- register TkWindow *winPtr = (TkWindow *) token;
- int found;
-
- /*
- * Skim through the list of existing handlers to (a) compute the
- * overall event mask for the window (so we can pass this new
- * value to the X system) and (b) see if there's already a handler
- * declared with the same callback and clientData (if so, just
- * change the mask). If no existing handler matches, then create
- * a new handler.
- */
-
- found = 0;
- if (winPtr->handlerList == NULL) {
- handlerPtr = (TkEventHandler *) ckalloc(
- (unsigned) sizeof(TkEventHandler));
- winPtr->handlerList = handlerPtr;
- goto initHandler;
- } else {
- for (handlerPtr = winPtr->handlerList; ;
- handlerPtr = handlerPtr->nextPtr) {
- if ((handlerPtr->proc == proc)
- && (handlerPtr->clientData == clientData)) {
- handlerPtr->mask = mask;
- found = 1;
- }
- if (handlerPtr->nextPtr == NULL) {
- break;
- }
- }
- }
-
- /*
- * Create a new handler if no matching old handler was found.
- */
-
- if (!found) {
- handlerPtr->nextPtr = (TkEventHandler *)
- ckalloc(sizeof(TkEventHandler));
- handlerPtr = handlerPtr->nextPtr;
- initHandler:
- handlerPtr->mask = mask;
- handlerPtr->proc = proc;
- handlerPtr->clientData = clientData;
- handlerPtr->nextPtr = NULL;
- }
-
- /*
- * No need to call XSelectInput: Tk always selects on all events
- * for all windows (needed to support bindings on classes and "all").
- */
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_DeleteEventHandler --
- *
- * Delete a previously-created handler.
- *
- * Results:
- * None.
- *
- * Side effects:
- * If there existed a handler as described by the
- * parameters, the handler is deleted so that proc
- * will not be invoked again.
- *
- *--------------------------------------------------------------
- */
-
-void
-Tk_DeleteEventHandler(token, mask, proc, clientData)
- Tk_Window token; /* Same as corresponding arguments passed */
- unsigned long mask; /* previously to Tk_CreateEventHandler. */
- Tk_EventProc *proc;
- ClientData clientData;
-{
- register TkEventHandler *handlerPtr;
- register InProgress *ipPtr;
- TkEventHandler *prevPtr;
- register TkWindow *winPtr = (TkWindow *) token;
-
- /*
- * Find the event handler to be deleted, or return
- * immediately if it doesn't exist.
- */
-
- for (handlerPtr = winPtr->handlerList, prevPtr = NULL; ;
- prevPtr = handlerPtr, handlerPtr = handlerPtr->nextPtr) {
- if (handlerPtr == NULL) {
- return;
- }
- if ((handlerPtr->mask == mask) && (handlerPtr->proc == proc)
- && (handlerPtr->clientData == clientData)) {
- break;
- }
- }
-
- /*
- * If Tk_HandleEvent is about to process this handler, tell it to
- * process the next one instead.
- */
-
- for (ipPtr = pendingPtr; ipPtr != NULL; ipPtr = ipPtr->nextPtr) {
- if (ipPtr->nextHandler == handlerPtr) {
- ipPtr->nextHandler = handlerPtr->nextPtr;
- }
- }
-
- /*
- * Free resources associated with the handler.
- */
-
- if (prevPtr == NULL) {
- winPtr->handlerList = handlerPtr->nextPtr;
- } else {
- prevPtr->nextPtr = handlerPtr->nextPtr;
- }
- ckfree((char *) handlerPtr);
-
-
- /*
- * No need to call XSelectInput: Tk always selects on all events
- * for all windows (needed to support bindings on classes and "all").
- */
-}
-
-/*--------------------------------------------------------------
- *
- * Tk_CreateGenericHandler --
- *
- * Register a procedure to be called on each X event, regardless
- * of display or window. Generic handlers are useful for capturing
- * events that aren't associated with windows, or events for windows
- * not managed by Tk.
- *
- * Results:
- * None.
- *
- * Side Effects:
- * From now on, whenever an X event is given to Tk_HandleEvent,
- * invoke proc, giving it clientData and the event as arguments.
- *
- *--------------------------------------------------------------
- */
-
-void
-Tk_CreateGenericHandler(proc, clientData)
- Tk_GenericProc *proc; /* Procedure to call on every event. */
- ClientData clientData; /* One-word value to pass to proc. */
-{
- GenericHandler *handlerPtr;
-
- handlerPtr = (GenericHandler *) ckalloc (sizeof (GenericHandler));
-
- handlerPtr->proc = proc;
- handlerPtr->clientData = clientData;
- handlerPtr->deleteFlag = 0;
- handlerPtr->nextPtr = NULL;
- if (genericList == NULL) {
- genericList = handlerPtr;
- } else {
- lastGenericPtr->nextPtr = handlerPtr;
- }
- lastGenericPtr = handlerPtr;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_DeleteGenericHandler --
- *
- * Delete a previously-created generic 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 Tk_HandleEvent.
- *
- *--------------------------------------------------------------
- */
-
-void
-Tk_DeleteGenericHandler(proc, clientData)
- Tk_GenericProc *proc;
- ClientData clientData;
-{
- GenericHandler * handler;
-
- for (handler = genericList; handler; handler = handler->nextPtr) {
- if ((handler->proc == proc) && (handler->clientData == clientData)) {
- handler->deleteFlag = 1;
- }
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_HandleEvent --
- *
- * Given an event, invoke all the handlers that have
- * been registered for the event.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Depends on the handlers.
- *
- *--------------------------------------------------------------
- */
-
-void
-Tk_HandleEvent(eventPtr)
- XEvent *eventPtr; /* Event to dispatch. */
-{
- register TkEventHandler *handlerPtr;
- register GenericHandler *genericPtr;
- register GenericHandler *genPrevPtr;
- TkWindow *winPtr;
- unsigned long mask;
- InProgress ip;
- Window handlerWindow;
- TkDisplay *dispPtr;
- Tcl_Interp *interp = (Tcl_Interp *) NULL;
-
- /*
- * Next, invoke all the generic event handlers (those that are
- * invoked for all events). If a generic event handler reports that
- * an event is fully processed, go no further.
- */
-
- for (genPrevPtr = NULL, genericPtr = genericList; genericPtr != NULL; ) {
- if (genericPtr->deleteFlag) {
- if (!genericHandlersActive) {
- GenericHandler *tmpPtr;
-
- /*
- * This handler needs to be deleted and there are no
- * calls pending through the handler, so now is a safe
- * time to delete it.
- */
-
- tmpPtr = genericPtr->nextPtr;
- if (genPrevPtr == NULL) {
- genericList = tmpPtr;
- } else {
- genPrevPtr->nextPtr = tmpPtr;
- }
- if (tmpPtr == NULL) {
- lastGenericPtr = genPrevPtr;
- }
- (void) ckfree((char *) genericPtr);
- genericPtr = tmpPtr;
- continue;
- }
- } else {
- int done;
-
- genericHandlersActive++;
- done = (*genericPtr->proc)(genericPtr->clientData, eventPtr);
- genericHandlersActive--;
- if (done) {
- return;
- }
- }
- genPrevPtr = genericPtr;
- genericPtr = genPrevPtr->nextPtr;
- }
-
- /*
- * If the event is a MappingNotify event, find its display and
- * refresh the keyboard mapping information for the display.
- * After that there's nothing else to do with the event, so just
- * quit.
- */
-
- if (eventPtr->type == MappingNotify) {
- dispPtr = TkGetDisplay(eventPtr->xmapping.display);
- if (dispPtr != NULL) {
- XRefreshKeyboardMapping(&eventPtr->xmapping);
- dispPtr->bindInfoStale = 1;
- }
- return;
- }
-
- /*
- * Events selected by StructureNotify require special handling.
- * They look the same as those selected by SubstructureNotify.
- * The only difference is whether the "event" and "window" fields
- * are the same. Compare the two fields and convert StructureNotify
- * to SubstructureNotify if necessary.
- */
-
- handlerWindow = eventPtr->xany.window;
- mask = eventMasks[eventPtr->xany.type];
- if (mask == StructureNotifyMask) {
- if (eventPtr->xmap.event != eventPtr->xmap.window) {
- mask = SubstructureNotifyMask;
- handlerWindow = eventPtr->xmap.event;
- }
- }
- 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).
- */
-
- if (eventPtr->type == PropertyNotify) {
- TkSelPropProc(eventPtr);
- }
- return;
- }
-
- /*
- * Once a window has started getting deleted, don't process any more
- * events for it except for the DestroyNotify event. This check is
- * needed because a DestroyNotify handler could re-invoke the event
- * loop, causing other pending events to be handled for the window
- * (the window doesn't get totally expunged from our tables until
- * after the DestroyNotify event has been completely handled).
- */
-
- if ((winPtr->flags & TK_ALREADY_DEAD)
- && (eventPtr->type != DestroyNotify)) {
- return;
- }
-
- if (winPtr->mainPtr != NULL) {
-
- /*
- * Protect interpreter for this window from possible deletion
- * while we are dealing with the event for this window. Thus,
- * widget writers do not have to worry about protecting the
- * interpreter in their own code.
- */
-
- interp = winPtr->mainPtr->interp;
- Tcl_Preserve((ClientData) interp);
-
- /*
- * Call focus-related code to look at FocusIn, FocusOut, Enter,
- * and Leave events; depending on its return value, ignore the
- * event.
- */
-
- if ((mask & (FocusChangeMask|EnterWindowMask|LeaveWindowMask))
- && !TkFocusFilterEvent(winPtr, eventPtr)) {
- Tcl_Release((ClientData) interp);
- return;
- }
-
- /*
- * Redirect KeyPress and KeyRelease events to the focus window,
- * or ignore them entirely if there is no focus window.
- */
-
- if (mask & (KeyPressMask|KeyReleaseMask)) {
- winPtr->dispPtr->lastEventTime = eventPtr->xkey.time;
- winPtr = TkFocusKeyEvent(winPtr, eventPtr);
- if (winPtr == NULL) {
- Tcl_Release((ClientData) interp);
- return;
- }
- }
-
- /*
- * Call a grab-related procedure to do special processing on
- * pointer events.
- */
-
- if (mask & (ButtonPressMask|ButtonReleaseMask|PointerMotionMask
- |EnterWindowMask|LeaveWindowMask)) {
- if (mask & (ButtonPressMask|ButtonReleaseMask)) {
- winPtr->dispPtr->lastEventTime = eventPtr->xbutton.time;
- } else if (mask & PointerMotionMask) {
- winPtr->dispPtr->lastEventTime = eventPtr->xmotion.time;
- } else {
- winPtr->dispPtr->lastEventTime = eventPtr->xcrossing.time;
- }
- if (TkPointerEvent(eventPtr, winPtr) == 0) {
- goto done;
- }
- }
- }
-
-#ifdef TK_USE_INPUT_METHODS
- /*
- * 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).
- */
-
- 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);
- }
- winPtr->flags |= TK_CHECKED_IC;
- }
- if (XFilterEvent(eventPtr, None)) {
- goto done;
- }
-#endif /* TK_USE_INPUT_METHODS */
-
- /*
- * For events where it hasn't already been done, update the current
- * time in the display.
- */
-
- if (eventPtr->type == PropertyNotify) {
- winPtr->dispPtr->lastEventTime = eventPtr->xproperty.time;
- }
-
- /*
- * There's a potential interaction here with Tk_DeleteEventHandler.
- * Read the documentation for pendingPtr.
- */
-
- ip.eventPtr = eventPtr;
- ip.winPtr = winPtr;
- ip.nextHandler = NULL;
- ip.nextPtr = pendingPtr;
- pendingPtr = &ip;
- if (mask == 0) {
- if ((eventPtr->type == SelectionClear)
- || (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 {
- for (handlerPtr = winPtr->handlerList; handlerPtr != NULL; ) {
- if ((handlerPtr->mask & mask) != 0) {
- ip.nextHandler = handlerPtr->nextPtr;
- (*(handlerPtr->proc))(handlerPtr->clientData, eventPtr);
- handlerPtr = ip.nextHandler;
- } else {
- handlerPtr = handlerPtr->nextPtr;
- }
- }
-
- /*
- * Pass the event to the "bind" command mechanism. But, don't
- * do this for SubstructureNotify events. The "bind" command
- * doesn't support them anyway, and it's easier to filter out
- * these events here than in the lower-level procedures.
- */
-
- if ((ip.winPtr != None) && (mask != SubstructureNotifyMask)) {
- TkBindEventProc(winPtr, eventPtr);
- }
- }
- pendingPtr = ip.nextPtr;
-done:
-
- /*
- * Release the interpreter for this window so that it can be potentially
- * deleted if requested.
- */
-
- if (interp != (Tcl_Interp *) NULL) {
- Tcl_Release((ClientData) interp);
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * TkEventDeadWindow --
- *
- * This procedure is invoked when it is determined that
- * a window is dead. It cleans up event-related information
- * about the window.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Various things get cleaned up and recycled.
- *
- *--------------------------------------------------------------
- */
-
-void
-TkEventDeadWindow(winPtr)
- TkWindow *winPtr; /* Information about the window
- * that is being deleted. */
-{
- register TkEventHandler *handlerPtr;
- register InProgress *ipPtr;
-
- /*
- * While deleting all the handlers, be careful to check for
- * Tk_HandleEvent being about to process one of the deleted
- * handlers. If it is, tell it to quit (all of the handlers
- * are being deleted).
- */
-
- while (winPtr->handlerList != NULL) {
- handlerPtr = winPtr->handlerList;
- winPtr->handlerList = handlerPtr->nextPtr;
- for (ipPtr = pendingPtr; ipPtr != NULL; ipPtr = ipPtr->nextPtr) {
- if (ipPtr->nextHandler == handlerPtr) {
- ipPtr->nextHandler = NULL;
- }
- if (ipPtr->winPtr == winPtr) {
- ipPtr->winPtr = None;
- }
- }
- ckfree((char *) handlerPtr);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkCurrentTime --
- *
- * Try to deduce the current time. "Current time" means the time
- * of the event that led to the current code being executed, which
- * means the time in the most recently-nested invocation of
- * Tk_HandleEvent.
- *
- * Results:
- * The return value is the time from the current event, or
- * CurrentTime if there is no current event or if the current
- * event contains no time.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-Time
-TkCurrentTime(dispPtr)
- TkDisplay *dispPtr; /* Display for which the time is desired. */
-{
- register XEvent *eventPtr;
-
- if (pendingPtr == NULL) {
- return dispPtr->lastEventTime;
- }
- eventPtr = pendingPtr->eventPtr;
- switch (eventPtr->type) {
- case ButtonPress:
- case ButtonRelease:
- return eventPtr->xbutton.time;
- case KeyPress:
- case KeyRelease:
- return eventPtr->xkey.time;
- case MotionNotify:
- return eventPtr->xmotion.time;
- case EnterNotify:
- case LeaveNotify:
- return eventPtr->xcrossing.time;
- case PropertyNotify:
- return eventPtr->xproperty.time;
- }
- return dispPtr->lastEventTime;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_RestrictEvents --
- *
- * This procedure is used to globally restrict the set of events
- * that will be dispatched. The restriction is done by filtering
- * all incoming X events through a procedure that determines
- * whether they are to be processed immediately, deferred, or
- * discarded.
- *
- * Results:
- * The return value is the previous restriction procedure in effect,
- * if there was one, or NULL if there wasn't.
- *
- * Side effects:
- * From now on, proc will be called to determine whether to process,
- * defer or discard each incoming X event.
- *
- *----------------------------------------------------------------------
- */
-
-Tk_RestrictProc *
-Tk_RestrictEvents(proc, arg, prevArgPtr)
- Tk_RestrictProc *proc; /* Procedure to call for each incoming
- * event. */
- ClientData arg; /* Arbitrary argument to pass to proc. */
- ClientData *prevArgPtr; /* Place to store information about previous
- * argument. */
-{
- Tk_RestrictProc *prev;
-
- prev = restrictProc;
- *prevArgPtr = restrictArg;
- restrictProc = proc;
- restrictArg = arg;
- return prev;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_QueueWindowEvent --
- *
- * Given an X-style window event, this procedure adds it to the
- * Tcl event queue at the given position. This procedure also
- * performs mouse motion event collapsing if possible.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Adds stuff to the event queue, which will eventually be
- * processed.
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tk_QueueWindowEvent(eventPtr, position)
- XEvent *eventPtr; /* Event to add to queue. This
- * procedures copies it before adding
- * it to the queue. */
- Tcl_QueuePosition position; /* Where to put it on the queue:
- * TCL_QUEUE_TAIL, TCL_QUEUE_HEAD,
- * or TCL_QUEUE_MARK. */
-{
- TkWindowEvent *wevPtr;
- TkDisplay *dispPtr;
-
- /*
- * Find our display structure for the event's display.
- */
-
- for (dispPtr = tkDisplayList; ; dispPtr = dispPtr->nextPtr) {
- if (dispPtr == NULL) {
- return;
- }
- if (dispPtr->display == eventPtr->xany.display) {
- break;
- }
- }
-
- if ((dispPtr->delayedMotionPtr != NULL) && (position == TCL_QUEUE_TAIL)) {
- if ((eventPtr->type == MotionNotify) && (eventPtr->xmotion.window
- == dispPtr->delayedMotionPtr->event.xmotion.window)) {
- /*
- * The new event is a motion event in the same window as the
- * saved motion event. Just replace the saved event with the
- * new one.
- */
-
- dispPtr->delayedMotionPtr->event = *eventPtr;
- return;
- } else if ((eventPtr->type != GraphicsExpose)
- && (eventPtr->type != NoExpose)
- && (eventPtr->type != Expose)) {
- /*
- * The new event may conflict with the saved motion event. Queue
- * the saved motion event now so that it will be processed before
- * the new event.
- */
-
- Tcl_QueueEvent(&dispPtr->delayedMotionPtr->header, position);
- dispPtr->delayedMotionPtr = NULL;
- Tcl_CancelIdleCall(DelayedMotionProc, (ClientData) dispPtr);
- }
- }
-
- wevPtr = (TkWindowEvent *) ckalloc(sizeof(TkWindowEvent));
- wevPtr->header.proc = WindowEventProc;
- wevPtr->event = *eventPtr;
- if ((eventPtr->type == MotionNotify) && (position == TCL_QUEUE_TAIL)) {
- /*
- * The new event is a motion event so don't queue it immediately;
- * save it around in case another motion event arrives that it can
- * be collapsed with.
- */
-
- if (dispPtr->delayedMotionPtr != NULL) {
- panic("Tk_QueueWindowEvent found unexpected delayed motion event");
- }
- dispPtr->delayedMotionPtr = wevPtr;
- Tcl_DoWhenIdle(DelayedMotionProc, (ClientData) dispPtr);
- } else {
- Tcl_QueueEvent(&wevPtr->header, position);
- }
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * TkQueueEventForAllChildren --
- *
- * Given an XEvent, recursively queue the event for this window and
- * all non-toplevel children of the given window.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Events queued.
- *
- *---------------------------------------------------------------------------
- */
-
-void
-TkQueueEventForAllChildren(winPtr, eventPtr)
- TkWindow *winPtr; /* Window to which event is sent. */
- XEvent *eventPtr; /* The event to be sent. */
-{
- TkWindow *childPtr;
-
- eventPtr->xany.window = winPtr->window;
- Tk_QueueWindowEvent(eventPtr, TCL_QUEUE_TAIL);
-
- childPtr = winPtr->childList;
- while (childPtr != NULL) {
- if (!Tk_IsTopLevel(childPtr)) {
- TkQueueEventForAllChildren(childPtr, eventPtr);
- }
- childPtr = childPtr->nextPtr;
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * WindowEventProc --
- *
- * This procedure is called by Tcl_DoOneEvent when a window event
- * reaches the front of the event queue. This procedure is responsible
- * for actually handling the event.
- *
- * Results:
- * Returns 1 if the event was handled, meaning it should be removed
- * from the queue. Returns 0 if the event was not handled, meaning
- * it should stay on the queue. The event isn't handled if the
- * TCL_WINDOW_EVENTS bit isn't set in flags, if a restrict proc
- * prevents the event from being handled.
- *
- * Side effects:
- * Whatever the event handlers for the event do.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-WindowEventProc(evPtr, flags)
- Tcl_Event *evPtr; /* Event to service. */
- int flags; /* Flags that indicate what events to
- * handle, such as TCL_WINDOW_EVENTS. */
-{
- TkWindowEvent *wevPtr = (TkWindowEvent *) evPtr;
- Tk_RestrictAction result;
-
- if (!(flags & TCL_WINDOW_EVENTS)) {
- return 0;
- }
- if (restrictProc != NULL) {
- result = (*restrictProc)(restrictArg, &wevPtr->event);
- if (result != TK_PROCESS_EVENT) {
- if (result == TK_DEFER_EVENT) {
- return 0;
- } else {
- /*
- * TK_DELETE_EVENT: return and say we processed the event,
- * even though we didn't do anything at all.
- */
- return 1;
- }
- }
- }
- Tk_HandleEvent(&wevPtr->event);
- return 1;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * DelayedMotionProc --
- *
- * This procedure is invoked as an idle handler when a mouse motion
- * event has been delayed. It queues the delayed event so that it
- * will finally be serviced.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The delayed mouse motion event gets added to the Tcl event
- * queue for servicing.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-DelayedMotionProc(clientData)
- ClientData clientData; /* Pointer to display containing a delayed
- * motion event to be serviced. */
-{
- TkDisplay *dispPtr = (TkDisplay *) clientData;
-
- if (dispPtr->delayedMotionPtr == NULL) {
- panic("DelayedMotionProc found no delayed mouse motion event");
- }
- Tcl_QueueEvent(&dispPtr->delayedMotionPtr->header, TCL_QUEUE_TAIL);
- dispPtr->delayedMotionPtr = NULL;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_MainLoop --
- *
- * Call Tcl_DoOneEvent over and over again in an infinite
- * loop as long as there exist any main windows.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Arbitrary; depends on handlers for events.
- *
- *--------------------------------------------------------------
- */
-
-void
-Tk_MainLoop()
-{
- while (Tk_GetNumMainWindows() > 0) {
- Tcl_DoOneEvent(0);
- }
-}
diff --git a/generic/tkFileFilter.c b/generic/tkFileFilter.c
deleted file mode 100644
index 6a8c54a..0000000
--- a/generic/tkFileFilter.c
+++ /dev/null
@@ -1,486 +0,0 @@
-/*
- * tkFileFilter.c --
- *
- * Process the -filetypes option for the file dialogs on Windows and the
- * Mac.
- *
- * Copyright (c) 1996 Sun Microsystems, Inc.
- *
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- *
- * RCS: @(#) $Id: tkFileFilter.c,v 1.2 1998/09/14 18:23:10 stanton Exp $
- *
- */
-
-#include "tkInt.h"
-#include "tkFileFilter.h"
-
-static int AddClause _ANSI_ARGS_((
- Tcl_Interp * interp, FileFilter * filterPtr,
- char * patternsStr, char * ostypesStr,
- int isWindows));
-static void FreeClauses _ANSI_ARGS_((FileFilter * filterPtr));
-static void FreeGlobPatterns _ANSI_ARGS_((
- FileFilterClause * clausePtr));
-static void FreeMacFileTypes _ANSI_ARGS_((
- FileFilterClause * clausePtr));
-static FileFilter * GetFilter _ANSI_ARGS_((FileFilterList * flistPtr,
- char * name));
-
-/*
- *----------------------------------------------------------------------
- *
- * TkInitFileFilters --
- *
- * Initializes a FileFilterList data structure. A FileFilterList
- * must be initialized EXACTLY ONCE before any calls to
- * TkGetFileFilters() is made. The usual flow of control is:
- * TkInitFileFilters(&flist);
- * TkGetFileFilters(&flist, ...);
- * TkGetFileFilters(&flist, ...);
- * ...
- * TkFreeFileFilters(&flist);
- *
- * Results:
- * None.
- *
- * Side effects:
- * The fields in flistPtr are initialized.
- *----------------------------------------------------------------------
- */
-
-void
-TkInitFileFilters(flistPtr)
- FileFilterList * flistPtr; /* The structure to be initialized. */
-{
- flistPtr->filters = NULL;
- flistPtr->filtersTail = NULL;
- flistPtr->numFilters = 0;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkGetFileFilters --
- *
- * This function is called by the Mac and Windows implementation
- * of tk_getOpenFile and tk_getSaveFile to translate the string
- * value of the -filetypes option of into an easy-to-parse C
- * structure (flistPtr). The caller of this function will then use
- * flistPtr to perform filetype matching in a platform specific way.
- *
- * flistPtr must be initialized (See comments in TkInitFileFilters).
- *
- * Results:
- * A standard TCL return value.
- *
- * Side effects:
- * The fields in flistPtr are changed according to string.
- *----------------------------------------------------------------------
- */
-int
-TkGetFileFilters(interp, flistPtr, string, isWindows)
- Tcl_Interp *interp; /* Interpreter to use for error reporting. */
- FileFilterList * flistPtr; /* Stores the list of file filters. */
- char * string; /* Value of the -filetypes option. */
- int isWindows; /* True if we are running on Windows. */
-{
- int listArgc;
- char ** listArgv = NULL;
- char ** typeInfo = NULL;
- int code = TCL_OK;
- int i;
-
- if (Tcl_SplitList(interp, string, &listArgc, &listArgv) != TCL_OK) {
- return TCL_ERROR;
- }
- if (listArgc == 0) {
- goto done;
- }
-
- /*
- * Free the filter information that have been allocated the previous
- * time -- the -filefilters option may have been used more than once in
- * the command line.
- */
- TkFreeFileFilters(flistPtr);
-
- for (i = 0; i<listArgc; i++) {
- /*
- * Each file type should have two or three elements: the first one
- * is the name of the type and the second is the filter of the type.
- * The third is the Mac OSType ID, but we don't care about them here.
- */
- int count;
- FileFilter * filterPtr;
-
- if (Tcl_SplitList(interp, listArgv[i], &count, &typeInfo) != TCL_OK) {
- code = TCL_ERROR;
- goto done;
- }
-
- if (count != 2 && count != 3) {
- Tcl_AppendResult(interp, "bad file type \"", listArgv[i], "\", ",
- "should be \"typeName {extension ?extensions ...?} ",
- "?{macType ?macTypes ...?}?\"", NULL);
- code = TCL_ERROR;
- goto done;
- }
-
- filterPtr = GetFilter(flistPtr, typeInfo[0]);
-
- if (count == 2) {
- code = AddClause(interp, filterPtr, typeInfo[1], NULL,
- isWindows);
- } else {
- code = AddClause(interp, filterPtr, typeInfo[1], typeInfo[2],
- isWindows);
- }
- if (code != TCL_OK) {
- goto done;
- }
-
- if (typeInfo) {
- ckfree((char*)typeInfo);
- }
- typeInfo = NULL;
- }
-
- done:
- if (typeInfo) {
- ckfree((char*)typeInfo);
- }
- if (listArgv) {
- ckfree((char*)listArgv);
- }
- return code;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkFreeFileFilters --
- *
- * Frees the malloc'ed file filter information.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The fields allocated by TkGetFileFilters() are freed.
- *----------------------------------------------------------------------
- */
-
-void
-TkFreeFileFilters(flistPtr)
- FileFilterList * flistPtr; /* List of file filters to free */
-{
- FileFilter * filterPtr, *toFree;
-
- filterPtr=flistPtr->filters;
- while (filterPtr) {
- toFree = filterPtr;
- filterPtr=filterPtr->next;
- FreeClauses(toFree);
- ckfree((char*)toFree->name);
- ckfree((char*)toFree);
- }
- flistPtr->filters = NULL;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * AddClause --
- *
- * Add one FileFilterClause to filterPtr.
- *
- * Results:
- * A standard TCL result.
- *
- * Side effects:
- * The list of filter clauses are updated in filterPtr.
- *----------------------------------------------------------------------
- */
-
-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. */
- 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;
- int globCount;
- char ** ostypeList = NULL;
- int ostypeCount;
- FileFilterClause * clausePtr;
- int i;
- int code = TCL_OK;
-
- if (Tcl_SplitList(interp, patternsStr, &globCount, &globList)!= TCL_OK) {
- code = TCL_ERROR;
- goto done;
- }
- if (ostypesStr != NULL) {
- if (Tcl_SplitList(interp, ostypesStr, &ostypeCount, &ostypeList)
- != TCL_OK) {
- code = TCL_ERROR;
- goto done;
- }
- for (i=0; i<ostypeCount; i++) {
- if (strlen(ostypeList[i]) != 4) {
- Tcl_AppendResult(interp, "bad Macintosh file type \"",
- ostypeList[i], "\"", NULL);
- code = TCL_ERROR;
- goto done;
- }
- }
- }
-
- /*
- * Add the clause into the list of clauses
- */
-
- clausePtr = (FileFilterClause*)ckalloc(sizeof(FileFilterClause));
- clausePtr->patterns = NULL;
- clausePtr->patternsTail = NULL;
- clausePtr->macTypes = NULL;
- clausePtr->macTypesTail = NULL;
-
- if (filterPtr->clauses == NULL) {
- filterPtr->clauses = filterPtr->clausesTail = clausePtr;
- } else {
- filterPtr->clausesTail->next = clausePtr;
- filterPtr->clausesTail = clausePtr;
- }
- clausePtr->next = NULL;
-
- if (globCount > 0 && globList != NULL) {
- for (i=0; i<globCount; i++) {
- GlobPattern * globPtr = (GlobPattern*)ckalloc(sizeof(GlobPattern));
- int len;
-
- len = (strlen(globList[i]) + 1) * sizeof(char);
-
- if (globList[i][0] && globList[i][0] != '*') {
- /*
- * Prepend a "*" to patterns that do not have a leading "*"
- */
- globPtr->pattern = (char*)ckalloc(len+1);
- globPtr->pattern[0] = '*';
- strcpy(globPtr->pattern+1, globList[i]);
- }
- else if (isWindows) {
- if (strcmp(globList[i], "*") == 0) {
- globPtr->pattern = (char*)ckalloc(4*sizeof(char));
- strcpy(globPtr->pattern, "*.*");
- }
- else if (strcmp(globList[i], "") == 0) {
- /*
- * An empty string means "match all files with no
- * extensions"
- * BUG: "*." actually matches with all files on Win95
- */
- globPtr->pattern = (char*)ckalloc(3*sizeof(char));
- strcpy(globPtr->pattern, "*.");
- }
- else {
- globPtr->pattern = (char*)ckalloc(len);
- strcpy(globPtr->pattern, globList[i]);
- }
- } else {
- globPtr->pattern = (char*)ckalloc(len);
- strcpy(globPtr->pattern, globList[i]);
- }
-
- /*
- * Add the glob pattern into the list of patterns.
- */
-
- if (clausePtr->patterns == NULL) {
- clausePtr->patterns = clausePtr->patternsTail = globPtr;
- } else {
- clausePtr->patternsTail->next = globPtr;
- clausePtr->patternsTail = globPtr;
- }
- globPtr->next = NULL;
- }
- }
- if (ostypeCount > 0 && ostypeList != NULL) {
- for (i=0; i<ostypeCount; i++) {
- MacFileType * mfPtr = (MacFileType*)ckalloc(sizeof(MacFileType));
-
- memcpy(&mfPtr->type, ostypeList[i], sizeof(OSType));
-
- /*
- * Add the Mac type pattern into the list of Mac types
- */
- if (clausePtr->macTypes == NULL) {
- clausePtr->macTypes = clausePtr->macTypesTail = mfPtr;
- } else {
- clausePtr->macTypesTail->next = mfPtr;
- clausePtr->macTypesTail = mfPtr;
- }
- mfPtr->next = NULL;
- }
- }
-
- done:
- if (globList) {
- ckfree((char*)globList);
- }
- if (ostypeList) {
- ckfree((char*)ostypeList);
- }
-
- return code;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * GetFilter --
- *
- * Add one FileFilter to flistPtr.
- *
- * Results:
- * A standard TCL result.
- *
- * Side effects:
- * The list of filters are updated in flistPtr.
- *----------------------------------------------------------------------
- */
-
-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
- * in the "File Types" listbox in the file
- * dialogs. */
-{
- FileFilter * filterPtr;
-
- for (filterPtr=flistPtr->filters; filterPtr; filterPtr=filterPtr->next) {
- if (strcmp(filterPtr->name, name)==0) {
- return filterPtr;
- }
- }
-
- filterPtr = (FileFilter*)ckalloc(sizeof(FileFilter));
- filterPtr->clauses = NULL;
- filterPtr->clausesTail = NULL;
- filterPtr->name = (char*)ckalloc((strlen(name)+1) * sizeof(char));
- strcpy(filterPtr->name, name);
-
- if (flistPtr->filters == NULL) {
- flistPtr->filters = flistPtr->filtersTail = filterPtr;
- } else {
- flistPtr->filtersTail->next = filterPtr;
- flistPtr->filtersTail = filterPtr;
- }
- filterPtr->next = NULL;
-
- ++flistPtr->numFilters;
- return filterPtr;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * FreeClauses --
- *
- * Frees the malloc'ed file type clause
- *
- * Results:
- * None.
- *
- * Side effects:
- * The list of clauses in filterPtr->clauses are freed.
- *----------------------------------------------------------------------
- */
-
-static void
-FreeClauses(filterPtr)
- FileFilter * filterPtr; /* FileFilter whose clauses are to be freed */
-{
- FileFilterClause * clausePtr, * toFree;
-
- clausePtr = filterPtr->clauses;
- while (clausePtr) {
- toFree = clausePtr;
- clausePtr=clausePtr->next;
- FreeGlobPatterns(toFree);
- FreeMacFileTypes(toFree);
- ckfree((char*)toFree);
- }
- filterPtr->clauses = NULL;
- filterPtr->clausesTail = NULL;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * FreeGlobPatterns --
- *
- * Frees the malloc'ed glob patterns in a clause
- *
- * Results:
- * None.
- *
- * Side effects:
- * The list of glob patterns in clausePtr->patterns are freed.
- *----------------------------------------------------------------------
- */
-
-static void
-FreeGlobPatterns(clausePtr)
- FileFilterClause * clausePtr;/* The clause whose patterns are to be freed*/
-{
- GlobPattern * globPtr, * toFree;
-
- globPtr = clausePtr->patterns;
- while (globPtr) {
- toFree = globPtr;
- globPtr=globPtr->next;
-
- ckfree((char*)toFree->pattern);
- ckfree((char*)toFree);
- }
- clausePtr->patterns = NULL;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * FreeMacFileTypes --
- *
- * Frees the malloc'ed Mac file types in a clause
- *
- * Results:
- * None.
- *
- * Side effects:
- * The list of Mac file types in clausePtr->macTypes are freed.
- *----------------------------------------------------------------------
- */
-
-static void
-FreeMacFileTypes(clausePtr)
- FileFilterClause * clausePtr; /* The clause whose mac types are to be
- * freed */
-{
- MacFileType * mfPtr, * toFree;
-
- mfPtr = clausePtr->macTypes;
- while (mfPtr) {
- toFree = mfPtr;
- mfPtr=mfPtr->next;
- ckfree((char*)toFree);
- }
- clausePtr->macTypes = NULL;
-}
diff --git a/generic/tkFileFilter.h b/generic/tkFileFilter.h
deleted file mode 100644
index e1bc763..0000000
--- a/generic/tkFileFilter.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * tkFileFilter.h --
- *
- * Declarations for the file filter processing routines needed by
- * the file selection dialogs.
- *
- * Copyright (c) 1996 Sun Microsystems, Inc.
- *
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- *
- * RCS: @(#) $Id: tkFileFilter.h,v 1.4 1998/09/14 18:23:10 stanton Exp $
- *
- */
-
-#ifndef _TK_FILE_FILTER
-#define _TK_FILE_FILTER
-
-#ifdef MAC_TCL
-#include <StandardFile.h>
-#else
-#define OSType long
-#endif
-
-#ifdef BUILD_tk
-# undef TCL_STORAGE_CLASS
-# define TCL_STORAGE_CLASS DLLEXPORT
-#endif
-
-typedef struct GlobPattern {
- struct GlobPattern * next; /* Chains to the next glob pattern
- * in a glob pattern list */
- char * pattern; /* String value of the pattern, such
- * as "*.txt" or "*.*"
- */
-} GlobPattern;
-
-typedef struct MacFileType {
- struct MacFileType * next; /* Chains to the next mac file type
- * in a mac file type list */
- OSType type; /* Mac file type, such as 'TEXT' or
- * 'GIFF' */
-} MacFileType;
-
-typedef struct FileFilterClause {
- struct FileFilterClause * next; /* Chains to the next clause in
- * a clause list */
- GlobPattern * patterns; /* Head of glob pattern type list */
- GlobPattern * patternsTail; /* Tail of glob pattern type list */
- MacFileType * macTypes; /* Head of mac file type list */
- MacFileType * macTypesTail; /* Tail of mac file type list */
-} FileFilterClause;
-
-typedef struct FileFilter {
- struct FileFilter * next; /* Chains to the next filter
- * in a filter list */
- char * name; /* Name of the file filter,
- * such as "Text Documents" */
- FileFilterClause * clauses; /* Head of the clauses list */
- FileFilterClause * clausesTail; /* Tail of the clauses list */
-} FileFilter;
-
-/*----------------------------------------------------------------------
- * FileFilterList --
- *
- * The routine TkGetFileFilters() translates the string value of the
- * -filefilters option into a FileFilterList structure, which consists
- * of a list of file filters.
- *
- * Each file filter consists of one or more clauses. Each clause has
- * one or more glob patterns and/or one or more Mac file types
- *----------------------------------------------------------------------
- */
-
-typedef struct FileFilterList {
- FileFilter * filters; /* Head of the filter list */
- FileFilter * filtersTail; /* Tail of the filter list */
- int numFilters; /* number of filters in the list */
-} FileFilterList;
-
-EXTERN void TkFreeFileFilters _ANSI_ARGS_((
- FileFilterList * flistPtr));
-EXTERN void TkInitFileFilters _ANSI_ARGS_((
- FileFilterList * flistPtr));
-EXTERN int TkGetFileFilters _ANSI_ARGS_ ((Tcl_Interp *interp,
- FileFilterList * flistPtr, char * string,
- int isWindows));
-
-# undef TCL_STORAGE_CLASS
-# define TCL_STORAGE_CLASS DLLIMPORT
-
-#endif
diff --git a/generic/tkFocus.c b/generic/tkFocus.c
deleted file mode 100644
index 75c10bb..0000000
--- a/generic/tkFocus.c
+++ /dev/null
@@ -1,998 +0,0 @@
-/*
- * tkFocus.c --
- *
- * This file contains procedures that manage the input
- * focus for Tk.
- *
- * Copyright (c) 1990-1994 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: tkFocus.c,v 1.2 1998/09/14 18:23:10 stanton Exp $
- */
-
-#include "tkInt.h"
-#include "tkPort.h"
-
-
-/*
- * For each top-level window that has ever received the focus, there
- * is a record of the following type:
- */
-
-typedef struct TkToplevelFocusInfo {
- TkWindow *topLevelPtr; /* Information about top-level window. */
- TkWindow *focusWinPtr; /* The next time the focus comes to this
- * top-level, it will be given to this
- * window. */
- struct TkToplevelFocusInfo *nextPtr;
- /* Next in list of all toplevel focus records
- * for a given application. */
-} ToplevelFocusInfo;
-
-/*
- * One of the following structures exists for each display used by
- * each application. These are linked together from the TkMainInfo
- * structure. These structures are needed because it isn't
- * sufficient to store a single piece of focus information in each
- * display or in each application: we need the cross-product.
- * There needs to be separate information for each display, because
- * it's possible to have multiple focus windows active simultaneously
- * on different displays. There also needs to be separate information
- * for each application, because of embedding: if an embedded
- * application has the focus, its container application also has
- * the focus. Thus we keep a list of structures for each application:
- * the same display can appear in structures for several applications
- * at once.
- */
-
-typedef struct TkDisplayFocusInfo {
- TkDisplay *dispPtr; /* Display that this information pertains
- * to. */
- struct TkWindow *focusWinPtr;
- /* Window that currently has the focus for
- * this application on this display, or NULL
- * if none. */
- struct TkWindow *focusOnMapPtr;
- /* This points to a toplevel window that is
- * supposed to receive the X input focus as
- * soon as it is mapped (needed to handle the
- * fact that X won't allow the focus on an
- * unmapped window). NULL means no delayed
- * focus op in progress for this display. */
- int forceFocus; /* Associated with focusOnMapPtr: non-zero
- * means claim the focus even if some other
- * application currently has it. */
- unsigned long focusSerial; /* Serial number of last request this
- * application made to change the focus on
- * this display. Used to identify stale
- * focus notifications coming from the
- * X server. */
- struct TkDisplayFocusInfo *nextPtr;
- /* Next in list of all display focus
- * records for a given application. */
-} DisplayFocusInfo;
-
-/*
- * Global used for debugging.
- */
-
-int tclFocusDebug = 0;
-
-/*
- * The following magic value is stored in the "send_event" field of
- * FocusIn and FocusOut events that are generated in this file. This
- * allows us to separate "real" events coming from the server from
- * those that we generated.
- */
-
-#define GENERATED_EVENT_MAGIC ((Bool) 0x547321ac)
-
-/*
- * Forward declarations for procedures defined in this file:
- */
-
-
-static DisplayFocusInfo *FindDisplayFocusInfo _ANSI_ARGS_((TkMainInfo *mainPtr,
- TkDisplay *dispPtr));
-static void FocusMapProc _ANSI_ARGS_((ClientData clientData,
- XEvent *eventPtr));
-static void GenerateFocusEvents _ANSI_ARGS_((TkWindow *sourcePtr,
- TkWindow *destPtr));
-static void SetFocus _ANSI_ARGS_((TkWindow *winPtr, int force));
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_FocusCmd --
- *
- * This procedure is invoked to process the "focus" 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_FocusCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Main window associated with
- * interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- Tk_Window tkwin = (Tk_Window) clientData;
- TkWindow *winPtr = (TkWindow *) clientData;
- TkWindow *newPtr, *focusWinPtr, *topLevelPtr;
- ToplevelFocusInfo *tlFocusPtr;
- char c;
- size_t length;
-
- /*
- * If invoked with no arguments, just return the current focus window.
- */
-
- if (argc == 1) {
- focusWinPtr = TkGetFocusWin(winPtr);
- if (focusWinPtr != NULL) {
- interp->result = focusWinPtr->pathName;
- }
- return TCL_OK;
- }
-
- /*
- * If invoked with a single argument beginning with "." then focus
- * on that window.
- */
-
- if (argc == 2) {
- if (argv[1][0] == 0) {
- return TCL_OK;
- }
- if (argv[1][0] == '.') {
- newPtr = (TkWindow *) Tk_NameToWindow(interp, argv[1], tkwin);
- if (newPtr == NULL) {
- return TCL_ERROR;
- }
- if (!(newPtr->flags & TK_ALREADY_DEAD)) {
- SetFocus(newPtr, 0);
- }
- return TCL_OK;
- }
- }
-
- length = strlen(argv[1]);
- c = argv[1][1];
- if ((c == 'd') && (strncmp(argv[1], "-displayof", length) == 0)) {
- if (argc != 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " -displayof window\"", (char *) NULL);
- return TCL_ERROR;
- }
- newPtr = (TkWindow *) Tk_NameToWindow(interp, argv[2], tkwin);
- if (newPtr == NULL) {
- return TCL_ERROR;
- }
- newPtr = TkGetFocusWin(newPtr);
- if (newPtr != NULL) {
- interp->result = newPtr->pathName;
- }
- } else if ((c == 'f') && (strncmp(argv[1], "-force", length) == 0)) {
- if (argc != 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " -force window\"", (char *) NULL);
- return TCL_ERROR;
- }
- if (argv[2][0] == 0) {
- return TCL_OK;
- }
- newPtr = (TkWindow *) Tk_NameToWindow(interp, argv[2], tkwin);
- if (newPtr == NULL) {
- return TCL_ERROR;
- }
- SetFocus(newPtr, 1);
- } else if ((c == 'l') && (strncmp(argv[1], "-lastfor", length) == 0)) {
- if (argc != 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " -lastfor window\"", (char *) NULL);
- return TCL_ERROR;
- }
- newPtr = (TkWindow *) Tk_NameToWindow(interp, argv[2], tkwin);
- if (newPtr == NULL) {
- return TCL_ERROR;
- }
- for (topLevelPtr = newPtr; topLevelPtr != NULL;
- topLevelPtr = topLevelPtr->parentPtr) {
- if (topLevelPtr->flags & TK_TOP_LEVEL) {
- for (tlFocusPtr = newPtr->mainPtr->tlFocusPtr;
- tlFocusPtr != NULL;
- tlFocusPtr = tlFocusPtr->nextPtr) {
- if (tlFocusPtr->topLevelPtr == topLevelPtr) {
- interp->result = tlFocusPtr->focusWinPtr->pathName;
- return TCL_OK;
- }
- }
- interp->result = topLevelPtr->pathName;
- return TCL_OK;
- }
- }
- } else {
- Tcl_AppendResult(interp, "bad option \"", argv[1],
- "\": must be -displayof, -force, or -lastfor", (char *) NULL);
- return TCL_ERROR;
- }
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * TkFocusFilterEvent --
- *
- * This procedure is invoked by Tk_HandleEvent when it encounters
- * a FocusIn, FocusOut, Enter, or Leave event.
- *
- * Results:
- * A return value of 1 means that Tk_HandleEvent should process
- * the event normally (i.e. event handlers should be invoked).
- * A return value of 0 means that this event should be ignored.
- *
- * Side effects:
- * Additional events may be generated, and the focus may switch.
- *
- *--------------------------------------------------------------
- */
-
-int
-TkFocusFilterEvent(winPtr, eventPtr)
- TkWindow *winPtr; /* Window that focus event is directed to. */
- XEvent *eventPtr; /* FocusIn, FocusOut, Enter, or Leave
- * event. */
-{
- /*
- * Design notes: the window manager and X server work together to
- * transfer the focus among top-level windows. This procedure takes
- * care of transferring the focus from a top-level or wrapper window
- * to the actual window within that top-level that has the focus.
- * We do this by synthesizing X events to move the focus around.
- * None of the FocusIn and FocusOut events generated by X are ever
- * used outside of this procedure; only the synthesized events get
- * through to the rest of the application. At one point (e.g.
- * Tk4.0b1) Tk used to call X to move the focus from a top-level to
- * one of its descendants, then just pass through the events
- * generated by X. This approach didn't work very well, for a
- * variety of reasons. For example, if X generates the events they
- * go at the back of the event queue, which could cause problems if
- * other things have already happened, such as moving the focus to
- * yet another window.
- */
-
- ToplevelFocusInfo *tlFocusPtr;
- DisplayFocusInfo *displayFocusPtr;
- TkDisplay *dispPtr = winPtr->dispPtr;
- TkWindow *newFocusPtr;
- int retValue, delta;
-
- /*
- * If this was a generated event, just turn off the generated
- * flag and pass the event through to Tk bindings.
- */
-
- if (eventPtr->xfocus.send_event == GENERATED_EVENT_MAGIC) {
- eventPtr->xfocus.send_event = 0;
- return 1;
- }
-
- /*
- * Check for special events generated by embedded applications to
- * request the input focus. If this is one of those events, make
- * the change in focus and return without any additional processing
- * of the event (note: the "detail" field of the event indicates
- * whether to claim the focus even if we don't already have it).
- */
-
- if ((eventPtr->xfocus.mode == EMBEDDED_APP_WANTS_FOCUS)
- && (eventPtr->type == FocusIn)) {
- SetFocus(winPtr, eventPtr->xfocus.detail);
- return 0;
- }
-
- /*
- * This was not a generated event. We'll return 1 (so that the
- * event will be processed) if it's an Enter or Leave event, and
- * 0 (so that the event won't be processed) if it's a FocusIn or
- * FocusOut event.
- */
-
- retValue = 0;
- displayFocusPtr = FindDisplayFocusInfo(winPtr->mainPtr, winPtr->dispPtr);
- if (eventPtr->type == FocusIn) {
- /*
- * Skip FocusIn events that cause confusion
- * NotifyVirtual and NotifyNonlinearVirtual - Virtual events occur
- * on windows in between the origin and destination of the
- * focus change. For FocusIn we may see this when focus
- * goes into an embedded child. We don't care about this,
- * although we may end up getting a NotifyPointer later.
- * NotifyInferior - focus is coming to us from an embedded child.
- * When focus is on an embeded focus, we still think we have
- * the focus, too, so this message doesn't change our state.
- * NotifyPointerRoot - should never happen because this is sent
- * to the root window.
- *
- * Interesting FocusIn events are
- * NotifyAncestor - focus is coming from our parent, probably the root.
- * NotifyNonlinear - focus is coming from a different branch, probably
- * another toplevel.
- * NotifyPointer - implicit focus because of the mouse position.
- * This is only interesting on toplevels, when it means that the
- * focus has been set to the root window but the mouse is over
- * this toplevel. We take the focus implicitly (probably no
- * window manager)
- */
-
- if ((eventPtr->xfocus.detail == NotifyVirtual)
- || (eventPtr->xfocus.detail == NotifyNonlinearVirtual)
- || (eventPtr->xfocus.detail == NotifyPointerRoot)
- || (eventPtr->xfocus.detail == NotifyInferior)) {
- return retValue;
- }
- } else if (eventPtr->type == FocusOut) {
- /*
- * Skip FocusOut events that cause confusion.
- * NotifyPointer - the pointer is in us or a child, and we are losing
- * focus because of an XSetInputFocus. Other focus events
- * will set our state properly.
- * NotifyPointerRoot - should never happen because this is sent
- * to the root window.
- * NotifyInferior - focus leaving us for an embedded child. We
- * retain a notion of focus when an embedded child has focus.
- *
- * Interesting events are:
- * NotifyAncestor - focus is going to root.
- * NotifyNonlinear - focus is going to another branch, probably
- * another toplevel.
- * NotifyVirtual, NotifyNonlinearVirtual - focus is passing through,
- * and we need to make sure we track this.
- */
-
- if ((eventPtr->xfocus.detail == NotifyPointer)
- || (eventPtr->xfocus.detail == NotifyPointerRoot)
- || (eventPtr->xfocus.detail == NotifyInferior)) {
- return retValue;
- }
- } else {
- retValue = 1;
- if (eventPtr->xcrossing.detail == NotifyInferior) {
- return retValue;
- }
- }
-
- /*
- * If winPtr isn't a top-level window than just ignore the event.
- */
-
- winPtr = TkWmFocusToplevel(winPtr);
- if (winPtr == NULL) {
- return retValue;
- }
-
- /*
- * If there is a grab in effect and this window is outside the
- * grabbed tree, then ignore the event.
- */
-
- if (TkGrabState(winPtr) == TK_GRAB_EXCLUDED) {
- return retValue;
- }
-
- /*
- * It is possible that there were outstanding FocusIn and FocusOut
- * events on their way to us at the time the focus was changed
- * internally with the "focus" command. If so, these events could
- * potentially cause us to lose the focus (switch it to the window
- * of the last FocusIn event) even though the focus change occurred
- * after those events. The following code detects this and ignores
- * the stale events.
- *
- * Note: the focusSerial is only generated by TkpChangeFocus,
- * whereas in Tk 4.2 there was always a nop marker generated.
- */
-
- delta = eventPtr->xfocus.serial - displayFocusPtr->focusSerial;
- if (delta < 0) {
- return retValue;
- }
-
- /*
- * Find the ToplevelFocusInfo structure for the window, and make a new one
- * if there isn't one already.
- */
-
- for (tlFocusPtr = winPtr->mainPtr->tlFocusPtr; tlFocusPtr != NULL;
- tlFocusPtr = tlFocusPtr->nextPtr) {
- if (tlFocusPtr->topLevelPtr == winPtr) {
- break;
- }
- }
- if (tlFocusPtr == NULL) {
- tlFocusPtr = (ToplevelFocusInfo *) ckalloc(sizeof(ToplevelFocusInfo));
- tlFocusPtr->topLevelPtr = tlFocusPtr->focusWinPtr = winPtr;
- tlFocusPtr->nextPtr = winPtr->mainPtr->tlFocusPtr;
- winPtr->mainPtr->tlFocusPtr = tlFocusPtr;
- }
- newFocusPtr = tlFocusPtr->focusWinPtr;
-
- if (eventPtr->type == FocusIn) {
- GenerateFocusEvents(displayFocusPtr->focusWinPtr, newFocusPtr);
- displayFocusPtr->focusWinPtr = newFocusPtr;
- dispPtr->focusPtr = newFocusPtr;
-
- /*
- * NotifyPointer gets set when the focus has been set to the root window
- * but we have the pointer. We'll treat this like an implicit
- * focus in event so that upon Leave events we release focus.
- */
-
- if (!(winPtr->flags & TK_EMBEDDED)) {
- if (eventPtr->xfocus.detail == NotifyPointer) {
- dispPtr->implicitWinPtr = winPtr;
- } else {
- dispPtr->implicitWinPtr = NULL;
- }
- }
- } else if (eventPtr->type == FocusOut) {
- GenerateFocusEvents(displayFocusPtr->focusWinPtr, (TkWindow *) NULL);
-
- /*
- * Reset dispPtr->focusPtr, but only if it currently is the same
- * as this application's focusWinPtr: this check is needed to
- * handle embedded applications in the same process.
- */
-
- if (dispPtr->focusPtr == displayFocusPtr->focusWinPtr) {
- dispPtr->focusPtr = NULL;
- }
- displayFocusPtr->focusWinPtr = NULL;
- } else if (eventPtr->type == EnterNotify) {
- /*
- * If there is no window manager, or if the window manager isn't
- * moving the focus around (e.g. the disgusting "NoTitleFocus"
- * option has been selected in twm), then we won't get FocusIn
- * or FocusOut events. Instead, the "focus" field will be set
- * in an Enter event to indicate that we've already got the focus
- * when the mouse enters the window (even though we didn't get
- * a FocusIn event). Watch for this and grab the focus when it
- * happens. Note: if this is an embedded application then don't
- * accept the focus implicitly like this; the container
- * application will give us the focus explicitly if it wants us
- * to have it.
- */
-
- if (eventPtr->xcrossing.focus &&
- (displayFocusPtr->focusWinPtr == NULL)
- && !(winPtr->flags & TK_EMBEDDED)) {
- if (tclFocusDebug) {
- printf("Focussed implicitly on %s\n",
- newFocusPtr->pathName);
- }
-
- GenerateFocusEvents(displayFocusPtr->focusWinPtr, newFocusPtr);
- displayFocusPtr->focusWinPtr = newFocusPtr;
- dispPtr->implicitWinPtr = winPtr;
- dispPtr->focusPtr = newFocusPtr;
- }
- } else if (eventPtr->type == LeaveNotify) {
- /*
- * If the pointer just left a window for which we automatically
- * claimed the focus on enter, move the focus back to the root
- * window, where it was before we claimed it above. Note:
- * dispPtr->implicitWinPtr may not be the same as
- * displayFocusPtr->focusWinPtr (e.g. because the "focus"
- * command was used to redirect the focus after it arrived at
- * dispPtr->implicitWinPtr)!! In addition, we generate events
- * because the window manager won't give us a FocusOut event when
- * we focus on the root.
- */
-
- if ((dispPtr->implicitWinPtr != NULL)
- && !(winPtr->flags & TK_EMBEDDED)) {
- if (tclFocusDebug) {
- printf("Defocussed implicit Async\n");
- }
- GenerateFocusEvents(displayFocusPtr->focusWinPtr,
- (TkWindow *) NULL);
- XSetInputFocus(dispPtr->display, PointerRoot, RevertToPointerRoot,
- CurrentTime);
- displayFocusPtr->focusWinPtr = NULL;
- dispPtr->implicitWinPtr = NULL;
- }
- }
- return retValue;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * SetFocus --
- *
- * This procedure is invoked to change the focus window for a
- * given display in a given application.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Event handlers may be invoked to process the change of
- * focus.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-SetFocus(winPtr, force)
- TkWindow *winPtr; /* Window that is to be the new focus for
- * its display and application. */
- int force; /* If non-zero, set the X focus to this
- * window even if the application doesn't
- * currently have the X focus. */
-{
- ToplevelFocusInfo *tlFocusPtr;
- DisplayFocusInfo *displayFocusPtr;
- TkWindow *topLevelPtr;
- int allMapped, serial;
-
- displayFocusPtr = FindDisplayFocusInfo(winPtr->mainPtr, winPtr->dispPtr);
- if (winPtr == displayFocusPtr->focusWinPtr) {
- return;
- }
-
- /*
- * Find the top-level window for winPtr, then find (or create)
- * a record for the top-level. Also see whether winPtr and all its
- * ancestors are mapped.
- */
-
- allMapped = 1;
- for (topLevelPtr = winPtr; ; topLevelPtr = topLevelPtr->parentPtr) {
- if (topLevelPtr == NULL) {
- /*
- * The window is being deleted. No point in worrying about
- * giving it the focus.
- */
- return;
- }
- if (!(topLevelPtr->flags & TK_MAPPED)) {
- allMapped = 0;
- }
- if (topLevelPtr->flags & TK_TOP_LEVEL) {
- break;
- }
- }
-
- /*
- * If the new focus window isn't mapped, then we can't focus on it
- * (X will generate an error, for example). Instead, create an
- * event handler that will set the focus to this window once it gets
- * mapped. At the same time, delete any old handler that might be
- * around; it's no longer relevant.
- */
-
- if (displayFocusPtr->focusOnMapPtr != NULL) {
- Tk_DeleteEventHandler(
- (Tk_Window) displayFocusPtr->focusOnMapPtr,
- StructureNotifyMask, FocusMapProc,
- (ClientData) displayFocusPtr->focusOnMapPtr);
- displayFocusPtr->focusOnMapPtr = NULL;
- }
- if (!allMapped) {
- Tk_CreateEventHandler((Tk_Window) winPtr,
- VisibilityChangeMask, FocusMapProc,
- (ClientData) winPtr);
- displayFocusPtr->focusOnMapPtr = winPtr;
- displayFocusPtr->forceFocus = force;
- return;
- }
-
- for (tlFocusPtr = winPtr->mainPtr->tlFocusPtr; tlFocusPtr != NULL;
- tlFocusPtr = tlFocusPtr->nextPtr) {
- if (tlFocusPtr->topLevelPtr == topLevelPtr) {
- break;
- }
- }
- if (tlFocusPtr == NULL) {
- tlFocusPtr = (ToplevelFocusInfo *) ckalloc(sizeof(ToplevelFocusInfo));
- tlFocusPtr->topLevelPtr = topLevelPtr;
- tlFocusPtr->nextPtr = winPtr->mainPtr->tlFocusPtr;
- winPtr->mainPtr->tlFocusPtr = tlFocusPtr;
- }
- tlFocusPtr->focusWinPtr = winPtr;
-
- /*
- * Reset the window system's focus window and generate focus events,
- * with two special cases:
- *
- * 1. If the application is embedded and doesn't currently have the
- * focus, don't set the focus directly. Instead, see if the
- * embedding code can claim the focus from the enclosing
- * container.
- * 2. Otherwise, if the application doesn't currently have the
- * focus, don't change the window system's focus unless it was
- * already in this application or "force" was specified.
- */
-
- if ((topLevelPtr->flags & TK_EMBEDDED)
- && (displayFocusPtr->focusWinPtr == NULL)) {
- TkpClaimFocus(topLevelPtr, force);
- } else if ((displayFocusPtr->focusWinPtr != NULL) || force) {
- /*
- * Generate events to shift focus between Tk windows.
- * We do this regardless of what TkpChangeFocus does with
- * the real X focus so that Tk widgets track focus commands
- * when there is no window manager. GenerateFocusEvents will
- * set up a serial number marker so we discard focus events
- * that are triggered by the ChangeFocus.
- */
-
- serial = TkpChangeFocus(TkpGetWrapperWindow(topLevelPtr), force);
- if (serial != 0) {
- displayFocusPtr->focusSerial = serial;
- }
- GenerateFocusEvents(displayFocusPtr->focusWinPtr, winPtr);
- displayFocusPtr->focusWinPtr = winPtr;
- winPtr->dispPtr->focusPtr = winPtr;
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkGetFocusWin --
- *
- * Given a window, this procedure returns the current focus
- * window for its application and display.
- *
- * Results:
- * The return value is a pointer to the window that currently
- * has the input focus for the specified application and
- * display, or NULL if none.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-TkWindow *
-TkGetFocusWin(winPtr)
- TkWindow *winPtr; /* Window that selects an application
- * and a display. */
-{
- DisplayFocusInfo *displayFocusPtr;
-
- if (winPtr == NULL) {
- return (TkWindow *) NULL;
- }
-
- displayFocusPtr = FindDisplayFocusInfo(winPtr->mainPtr, winPtr->dispPtr);
- return displayFocusPtr->focusWinPtr;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkFocusKeyEvent --
- *
- * Given a window and a key press or release event that arrived for
- * the window, use information about the keyboard focus to compute
- * which window should really get the event. In addition, update
- * the event to refer to its new window.
- *
- * Results:
- * The return value is a pointer to the window that has the input
- * focus in winPtr's application, or NULL if winPtr's application
- * doesn't have the input focus. If a non-NULL value is returned,
- * eventPtr will be updated to refer properly to the focus window.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-TkWindow *
-TkFocusKeyEvent(winPtr, eventPtr)
- TkWindow *winPtr; /* Window that selects an application
- * and a display. */
- XEvent *eventPtr; /* X event to redirect (should be KeyPress
- * or KeyRelease). */
-{
- DisplayFocusInfo *displayFocusPtr;
- TkWindow *focusWinPtr;
- int focusX, focusY, vRootX, vRootY, vRootWidth, vRootHeight;
-
- displayFocusPtr = FindDisplayFocusInfo(winPtr->mainPtr, winPtr->dispPtr);
- focusWinPtr = displayFocusPtr->focusWinPtr;
-
- /*
- * The code below is a debugging aid to make sure that dispPtr->focusPtr
- * is kept properly in sync with the "truth", which is the value in
- * displayFocusPtr->focusWinPtr.
- */
-
-#ifdef TCL_MEM_DEBUG
- if (focusWinPtr != winPtr->dispPtr->focusPtr) {
- printf("TkFocusKeyEvent found dispPtr->focusPtr out of sync:\n");
- printf("expected %s, got %s\n",
- (focusWinPtr != NULL) ? focusWinPtr->pathName : "??",
- (winPtr->dispPtr->focusPtr != NULL) ?
- winPtr->dispPtr->focusPtr->pathName : "??");
- }
-#endif
-
- if ((focusWinPtr != NULL) && (focusWinPtr->mainPtr == winPtr->mainPtr)) {
- /*
- * Map the x and y coordinates to make sense in the context of
- * the focus window, if possible (make both -1 if the map-from
- * and map-to windows don't share the same screen).
- */
-
- if ((focusWinPtr->display != winPtr->display)
- || (focusWinPtr->screenNum != winPtr->screenNum)) {
- eventPtr->xkey.x = -1;
- eventPtr->xkey.y = -1;
- } else {
- Tk_GetVRootGeometry((Tk_Window) focusWinPtr, &vRootX, &vRootY,
- &vRootWidth, &vRootHeight);
- Tk_GetRootCoords((Tk_Window) focusWinPtr, &focusX, &focusY);
- eventPtr->xkey.x = eventPtr->xkey.x_root - vRootX - focusX;
- eventPtr->xkey.y = eventPtr->xkey.y_root - vRootY - focusY;
- }
- eventPtr->xkey.window = focusWinPtr->window;
- return focusWinPtr;
- }
-
- /*
- * The event doesn't belong to us. Perhaps, due to embedding, it
- * really belongs to someone else. Give the embedding code a chance
- * to redirect the event.
- */
-
- TkpRedirectKeyEvent(winPtr, eventPtr);
- return (TkWindow *) NULL;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkFocusDeadWindow --
- *
- * This procedure is invoked when it is determined that
- * a window is dead. It cleans up focus-related information
- * about the window.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Various things get cleaned up and recycled.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkFocusDeadWindow(winPtr)
- register TkWindow *winPtr; /* Information about the window
- * that is being deleted. */
-{
- ToplevelFocusInfo *tlFocusPtr, *prevPtr;
- DisplayFocusInfo *displayFocusPtr;
- TkDisplay *dispPtr = winPtr->dispPtr;
-
- /*
- * Search for focus records that refer to this window either as
- * the top-level window or the current focus window.
- */
-
- displayFocusPtr = FindDisplayFocusInfo(winPtr->mainPtr, winPtr->dispPtr);
- for (prevPtr = NULL, tlFocusPtr = winPtr->mainPtr->tlFocusPtr;
- tlFocusPtr != NULL;
- prevPtr = tlFocusPtr, tlFocusPtr = tlFocusPtr->nextPtr) {
- if (winPtr == tlFocusPtr->topLevelPtr) {
- /*
- * The top-level window is the one being deleted: free
- * the focus record and release the focus back to PointerRoot
- * if we acquired it implicitly.
- */
-
- if (dispPtr->implicitWinPtr == winPtr) {
- if (tclFocusDebug) {
- printf("releasing focus to root after %s died\n",
- tlFocusPtr->topLevelPtr->pathName);
- }
- dispPtr->implicitWinPtr = NULL;
- displayFocusPtr->focusWinPtr = NULL;
- dispPtr->focusPtr = NULL;
- }
- if (displayFocusPtr->focusWinPtr == tlFocusPtr->focusWinPtr) {
- displayFocusPtr->focusWinPtr = NULL;
- dispPtr->focusPtr = NULL;
- }
- if (prevPtr == NULL) {
- winPtr->mainPtr->tlFocusPtr = tlFocusPtr->nextPtr;
- } else {
- prevPtr->nextPtr = tlFocusPtr->nextPtr;
- }
- ckfree((char *) tlFocusPtr);
- break;
- } else if (winPtr == tlFocusPtr->focusWinPtr) {
- /*
- * The deleted window had the focus for its top-level:
- * move the focus to the top-level itself.
- */
-
- tlFocusPtr->focusWinPtr = tlFocusPtr->topLevelPtr;
- if ((displayFocusPtr->focusWinPtr == winPtr)
- && !(tlFocusPtr->topLevelPtr->flags & TK_ALREADY_DEAD)) {
- if (tclFocusDebug) {
- printf("forwarding focus to %s after %s died\n",
- tlFocusPtr->topLevelPtr->pathName,
- winPtr->pathName);
- }
- GenerateFocusEvents(displayFocusPtr->focusWinPtr,
- tlFocusPtr->topLevelPtr);
- displayFocusPtr->focusWinPtr = tlFocusPtr->topLevelPtr;
- dispPtr->focusPtr = tlFocusPtr->topLevelPtr;
- }
- break;
- }
- }
-
- if (displayFocusPtr->focusOnMapPtr == winPtr) {
- displayFocusPtr->focusOnMapPtr = NULL;
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * GenerateFocusEvents --
- *
- * This procedure is called to create FocusIn and FocusOut events to
- * move the input focus from one window to another.
- *
- * Results:
- * None.
- *
- * Side effects:
- * FocusIn and FocusOut events are generated.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-GenerateFocusEvents(sourcePtr, destPtr)
- TkWindow *sourcePtr; /* Window that used to have the focus (may
- * be NULL). */
- TkWindow *destPtr; /* New window to have the focus (may be
- * NULL). */
-
-{
- XEvent event;
- TkWindow *winPtr;
-
- winPtr = sourcePtr;
- if (winPtr == NULL) {
- winPtr = destPtr;
- if (winPtr == NULL) {
- return;
- }
- }
-
- event.xfocus.serial = LastKnownRequestProcessed(winPtr->display);
- event.xfocus.send_event = GENERATED_EVENT_MAGIC;
- event.xfocus.display = winPtr->display;
- event.xfocus.mode = NotifyNormal;
- TkInOutEvents(&event, sourcePtr, destPtr, FocusOut, FocusIn,
- TCL_QUEUE_MARK);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * FocusMapProc --
- *
- * This procedure is called as an event handler for VisibilityNotify
- * events, if a window receives the focus at a time when its
- * toplevel isn't mapped. The procedure is needed because X
- * won't allow the focus to be set to an unmapped window; we
- * detect when the toplevel is mapped and set the focus to it then.
- *
- * Results:
- * None.
- *
- * Side effects:
- * If this is a map event, the focus gets set to the toplevel
- * given by clientData.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-FocusMapProc(clientData, eventPtr)
- ClientData clientData; /* Toplevel window. */
- XEvent *eventPtr; /* Information about event. */
-{
- TkWindow *winPtr = (TkWindow *) clientData;
- DisplayFocusInfo *displayFocusPtr;
-
- if (eventPtr->type == VisibilityNotify) {
- displayFocusPtr = FindDisplayFocusInfo(winPtr->mainPtr,
- winPtr->dispPtr);
- if (tclFocusDebug) {
- printf("auto-focussing on %s, force %d\n", winPtr->pathName,
- displayFocusPtr->forceFocus);
- }
- Tk_DeleteEventHandler((Tk_Window) winPtr, VisibilityChangeMask,
- FocusMapProc, clientData);
- displayFocusPtr->focusOnMapPtr = NULL;
- SetFocus(winPtr, displayFocusPtr->forceFocus);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * FindDisplayFocusInfo --
- *
- * Given an application and a display, this procedure locate the
- * focus record for that combination. If no such record exists,
- * it creates a new record and initializes it.
- *
- * Results:
- * The return value is a pointer to the record.
- *
- * Side effects:
- * A new record will be allocated if there wasn't one already.
- *
- *----------------------------------------------------------------------
- */
-
-static DisplayFocusInfo *
-FindDisplayFocusInfo(mainPtr, dispPtr)
- TkMainInfo *mainPtr; /* Record that identifies a particular
- * application. */
- TkDisplay *dispPtr; /* Display whose focus information is
- * needed. */
-{
- DisplayFocusInfo *displayFocusPtr;
-
- for (displayFocusPtr = mainPtr->displayFocusPtr;
- displayFocusPtr != NULL;
- displayFocusPtr = displayFocusPtr->nextPtr) {
- if (displayFocusPtr->dispPtr == dispPtr) {
- return displayFocusPtr;
- }
- }
-
- /*
- * The record doesn't exist yet. Make a new one.
- */
-
- displayFocusPtr = (DisplayFocusInfo *) ckalloc(sizeof(DisplayFocusInfo));
- displayFocusPtr->dispPtr = dispPtr;
- displayFocusPtr->focusWinPtr = NULL;
- displayFocusPtr->focusOnMapPtr = NULL;
- displayFocusPtr->forceFocus = 0;
- displayFocusPtr->focusSerial = 0;
- displayFocusPtr->nextPtr = mainPtr->displayFocusPtr;
- mainPtr->displayFocusPtr = displayFocusPtr;
- return displayFocusPtr;
-}
diff --git a/generic/tkFont.c b/generic/tkFont.c
deleted file mode 100644
index 4c0ebb9..0000000
--- a/generic/tkFont.c
+++ /dev/null
@@ -1,3008 +0,0 @@
-/*
- * tkFont.c --
- *
- * This file maintains a database of fonts for the Tk toolkit.
- * It also provides several utility procedures for measuring and
- * displaying text.
- *
- * Copyright (c) 1990-1994 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: tkFont.c,v 1.2 1998/09/14 18:23:10 stanton Exp $
- */
-
-#include "tkInt.h"
-#include "tkFont.h"
-
-/*
- * The following structure is used to keep track of all the fonts that
- * exist in the current application. It must be stored in the
- * TkMainInfo for the application.
- */
-
-typedef struct TkFontInfo {
- Tcl_HashTable fontCache; /* Map a string to an existing Tk_Font.
- * Keys are CachedFontKey structs, values are
- * TkFont structs. */
- Tcl_HashTable namedTable; /* Map a name to a set of attributes for a
- * font, used when constructing a Tk_Font from
- * a named font description. Keys are
- * Tk_Uids, values are NamedFont structs. */
- TkMainInfo *mainPtr; /* Application that owns this structure. */
- int updatePending;
-} TkFontInfo;
-
-/*
- * The following structure is used as a key in the fontCache.
- */
-
-typedef struct CachedFontKey {
- Display *display; /* Display for which font was constructed. */
- Tk_Uid string; /* String that describes font. */
-} CachedFontKey;
-
-/*
- * The following data structure is used to keep track of the font attributes
- * for each named font that has been defined. The named font is only deleted
- * when the last reference to it goes away.
- */
-
-typedef struct NamedFont {
- int refCount; /* Number of users of named font. */
- int deletePending; /* Non-zero if font should be deleted when
- * last reference goes away. */
- TkFontAttributes fa; /* Desired attributes for named font. */
-} NamedFont;
-
-/*
- * The following two structures are used to keep track of string
- * measurement information when using the text layout facilities.
- *
- * A LayoutChunk represents a contiguous range of text that can be measured
- * and displayed by low-level text calls. In general, chunks will be
- * delimited by newlines and tabs. Low-level, platform-specific things
- * like kerning and non-integer character widths may occur between the
- * characters in a single chunk, but not between characters in different
- * chunks.
- *
- * A TextLayout is a collection of LayoutChunks. It can be displayed with
- * respect to any origin. It is the implementation of the Tk_TextLayout
- * opaque token.
- */
-
-typedef struct LayoutChunk {
- CONST char *start; /* Pointer to simple string to be displayed.
- * This is a pointer into the TkTextLayout's
- * string. */
- int numChars; /* The number of characters in this chunk. */
- int numDisplayChars; /* The number of characters to display when
- * this chunk is displayed. Can be less than
- * numChars if extra space characters were
- * absorbed by the end of the chunk. This
- * will be < 0 if this is a chunk that is
- * holding a tab or newline. */
- int x, y; /* The origin of the first character in this
- * chunk with respect to the upper-left hand
- * corner of the TextLayout. */
- int totalWidth; /* Width in pixels of this chunk. Used
- * when hit testing the invisible spaces at
- * the end of a chunk. */
- int displayWidth; /* Width in pixels of the displayable
- * characters in this chunk. Can be less than
- * width if extra space characters were
- * absorbed by the end of the chunk. */
-} LayoutChunk;
-
-typedef struct TextLayout {
- Tk_Font tkfont; /* The font used when laying out the text. */
- CONST char *string; /* The string that was layed out. */
- int width; /* The maximum width of all lines in the
- * text layout. */
- int numChunks; /* Number of chunks actually used in
- * following array. */
- LayoutChunk chunks[1]; /* Array of chunks. The actual size will
- * be maxChunks. THIS FIELD MUST BE THE LAST
- * IN THE STRUCTURE. */
-} TextLayout;
-
-/*
- * The following structures are used as two-way maps between the values for
- * the fields in the TkFontAttributes structure and the strings used in
- * Tcl, when parsing both option-value format and style-list format font
- * name strings.
- */
-
-static TkStateMap weightMap[] = {
- {TK_FW_NORMAL, "normal"},
- {TK_FW_BOLD, "bold"},
- {TK_FW_UNKNOWN, NULL}
-};
-
-static TkStateMap slantMap[] = {
- {TK_FS_ROMAN, "roman"},
- {TK_FS_ITALIC, "italic"},
- {TK_FS_UNKNOWN, NULL}
-};
-
-static TkStateMap underlineMap[] = {
- {1, "underline"},
- {0, NULL}
-};
-
-static TkStateMap overstrikeMap[] = {
- {1, "overstrike"},
- {0, NULL}
-};
-
-/*
- * The following structures are used when parsing XLFD's into a set of
- * TkFontAttributes.
- */
-
-static TkStateMap xlfdWeightMap[] = {
- {TK_FW_NORMAL, "normal"},
- {TK_FW_NORMAL, "medium"},
- {TK_FW_NORMAL, "book"},
- {TK_FW_NORMAL, "light"},
- {TK_FW_BOLD, "bold"},
- {TK_FW_BOLD, "demi"},
- {TK_FW_BOLD, "demibold"},
- {TK_FW_NORMAL, NULL} /* Assume anything else is "normal". */
-};
-
-static TkStateMap xlfdSlantMap[] = {
- {TK_FS_ROMAN, "r"},
- {TK_FS_ITALIC, "i"},
- {TK_FS_OBLIQUE, "o"},
- {TK_FS_ROMAN, NULL} /* Assume anything else is "roman". */
-};
-
-static TkStateMap xlfdSetwidthMap[] = {
- {TK_SW_NORMAL, "normal"},
- {TK_SW_CONDENSE, "narrow"},
- {TK_SW_CONDENSE, "semicondensed"},
- {TK_SW_CONDENSE, "condensed"},
- {TK_SW_UNKNOWN, NULL}
-};
-
-static TkStateMap xlfdCharsetMap[] = {
- {TK_CS_NORMAL, "iso8859"},
- {TK_CS_SYMBOL, "adobe"},
- {TK_CS_SYMBOL, "sun"},
- {TK_CS_OTHER, NULL}
-};
-
-/*
- * The following structure and defines specify the valid builtin options
- * when configuring a set of font attributes.
- */
-
-static char *fontOpt[] = {
- "-family",
- "-size",
- "-weight",
- "-slant",
- "-underline",
- "-overstrike",
- NULL
-};
-
-#define FONT_FAMILY 0
-#define FONT_SIZE 1
-#define FONT_WEIGHT 2
-#define FONT_SLANT 3
-#define FONT_UNDERLINE 4
-#define FONT_OVERSTRIKE 5
-#define FONT_NUMFIELDS 6 /* Length of fontOpt array. */
-
-#define GetFontAttributes(tkfont) \
- ((CONST TkFontAttributes *) &((TkFont *) (tkfont))->fa)
-
-#define GetFontMetrics(tkfont) \
- ((CONST TkFontMetrics *) &((TkFont *) (tkfont))->fm)
-
-
-static int ConfigAttributesObj _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Window tkwin, int objc, Tcl_Obj *CONST objv[],
- TkFontAttributes *faPtr));
-static int FieldSpecified _ANSI_ARGS_((CONST char *field));
-static int GetAttributeInfoObj _ANSI_ARGS_((Tcl_Interp *interp,
- CONST TkFontAttributes *faPtr, Tcl_Obj *objPtr));
-static LayoutChunk * NewChunk _ANSI_ARGS_((TextLayout **layoutPtrPtr,
- int *maxPtr, CONST char *start, int numChars,
- int curX, int newX, int y));
-static int ParseFontNameObj _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Window tkwin, Tcl_Obj *objPtr,
- TkFontAttributes *faPtr));
-static void RecomputeWidgets _ANSI_ARGS_((TkWindow *winPtr));
-static void TheWorldHasChanged _ANSI_ARGS_((
- ClientData clientData));
-static void UpdateDependantFonts _ANSI_ARGS_((TkFontInfo *fiPtr,
- Tk_Window tkwin, Tcl_HashEntry *namedHashPtr));
-
-
-
-
-/*
- *---------------------------------------------------------------------------
- *
- * TkFontPkgInit --
- *
- * This procedure is called when an application is created. It
- * initializes all the structures that are used by the font
- * package on a per application basis.
- *
- * Results:
- * Returns a token that must be stored in the TkMainInfo for this
- * application.
- *
- * Side effects:
- * Memory allocated.
- *
- *---------------------------------------------------------------------------
- */
-void
-TkFontPkgInit(mainPtr)
- TkMainInfo *mainPtr; /* The application being created. */
-{
- TkFontInfo *fiPtr;
-
- fiPtr = (TkFontInfo *) ckalloc(sizeof(TkFontInfo));
- Tcl_InitHashTable(&fiPtr->fontCache, sizeof(CachedFontKey) / sizeof(int));
- Tcl_InitHashTable(&fiPtr->namedTable, TCL_ONE_WORD_KEYS);
- fiPtr->mainPtr = mainPtr;
- fiPtr->updatePending = 0;
- mainPtr->fontInfoPtr = fiPtr;
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * TkFontPkgFree --
- *
- * This procedure is called when an application is deleted. It
- * deletes all the structures that were used by the font package
- * for this application.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Memory freed.
- *
- *---------------------------------------------------------------------------
- */
-
-void
-TkFontPkgFree(mainPtr)
- TkMainInfo *mainPtr; /* The application being deleted. */
-{
- TkFontInfo *fiPtr;
- Tcl_HashEntry *hPtr;
- Tcl_HashSearch search;
-
- fiPtr = mainPtr->fontInfoPtr;
-
- if (fiPtr->fontCache.numEntries != 0) {
- panic("TkFontPkgFree: all fonts should have been freed already");
- }
- Tcl_DeleteHashTable(&fiPtr->fontCache);
-
- hPtr = Tcl_FirstHashEntry(&fiPtr->namedTable, &search);
- while (hPtr != NULL) {
- ckfree((char *) Tcl_GetHashValue(hPtr));
- hPtr = Tcl_NextHashEntry(&search);
- }
- Tcl_DeleteHashTable(&fiPtr->namedTable);
- if (fiPtr->updatePending != 0) {
- Tcl_CancelIdleCall(TheWorldHasChanged, (ClientData) fiPtr);
- }
- ckfree((char *) fiPtr);
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * Tk_FontObjCmd --
- *
- * This procedure is implemented to process the "font" 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_FontObjCmd(clientData, interp, objc, objv)
- ClientData clientData; /* Main window associated with interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int objc; /* Number of arguments. */
- Tcl_Obj *CONST objv[]; /* Argument objects. */
-{
- int index;
- Tk_Window tkwin;
- TkFontInfo *fiPtr;
- static char *optionStrings[] = {
- "actual", "configure", "create", "delete",
- "families", "measure", "metrics", "names",
- NULL
- };
- enum options {
- FONT_ACTUAL, FONT_CONFIGURE, FONT_CREATE, FONT_DELETE,
- FONT_FAMILIES, FONT_MEASURE, FONT_METRICS, FONT_NAMES
- };
-
- tkwin = (Tk_Window) clientData;
- fiPtr = ((TkWindow *) tkwin)->mainPtr->fontInfoPtr;
-
- if (objc < 2) {
- Tcl_WrongNumArgs(interp, 1, objv, "option ?arg?");
- return TCL_ERROR;
- }
- if (Tcl_GetIndexFromObj(interp, objv[1], optionStrings, "option", 0,
- &index) != TCL_OK) {
- return TCL_ERROR;
- }
-
- switch ((enum options) index) {
- case FONT_ACTUAL: {
- int skip, result;
- Tk_Font tkfont;
- Tcl_Obj *objPtr;
- CONST TkFontAttributes *faPtr;
-
- skip = TkGetDisplayOf(interp, objc - 3, objv + 3, &tkwin);
- if (skip < 0) {
- return TCL_ERROR;
- }
- if ((objc < 3) || (objc - skip > 4)) {
- Tcl_WrongNumArgs(interp, 2, objv,
- "font ?-displayof window? ?option?");
- return TCL_ERROR;
- }
- tkfont = Tk_GetFontFromObj(interp, tkwin, objv[2]);
- if (tkfont == NULL) {
- return TCL_ERROR;
- }
- objc -= skip;
- objv += skip;
- faPtr = GetFontAttributes(tkfont);
- objPtr = NULL;
- if (objc > 3) {
- objPtr = objv[3];
- }
- result = GetAttributeInfoObj(interp, faPtr, objPtr);
- Tk_FreeFont(tkfont);
- return result;
- }
- case FONT_CONFIGURE: {
- int result;
- char *string;
- Tcl_Obj *objPtr;
- NamedFont *nfPtr;
- Tcl_HashEntry *namedHashPtr;
-
- if (objc < 3) {
- Tcl_WrongNumArgs(interp, 2, objv, "fontname ?options?");
- return TCL_ERROR;
- }
- string = Tk_GetUid(Tcl_GetStringFromObj(objv[2], NULL));
- namedHashPtr = Tcl_FindHashEntry(&fiPtr->namedTable, string);
- nfPtr = NULL; /* lint. */
- if (namedHashPtr != NULL) {
- nfPtr = (NamedFont *) Tcl_GetHashValue(namedHashPtr);
- }
- if ((namedHashPtr == NULL) || (nfPtr->deletePending != 0)) {
- Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "named font \"", string,
- "\" doesn't exist", NULL);
- return TCL_ERROR;
- }
- if (objc == 3) {
- objPtr = NULL;
- } else if (objc == 4) {
- objPtr = objv[3];
- } else {
- result = ConfigAttributesObj(interp, tkwin, objc - 3,
- objv + 3, &nfPtr->fa);
- UpdateDependantFonts(fiPtr, tkwin, namedHashPtr);
- return result;
- }
- return GetAttributeInfoObj(interp, &nfPtr->fa, objPtr);
- }
- case FONT_CREATE: {
- int skip, i;
- char *name;
- char buf[32];
- TkFontAttributes fa;
- Tcl_HashEntry *namedHashPtr;
-
- skip = 3;
- if (objc < 3) {
- name = NULL;
- } else {
- name = Tcl_GetStringFromObj(objv[2], NULL);
- if (name[0] == '-') {
- name = NULL;
- }
- }
- if (name == NULL) {
- /*
- * No font name specified. Generate one of the form "fontX".
- */
-
- for (i = 1; ; i++) {
- sprintf(buf, "font%d", i);
- namedHashPtr = Tcl_FindHashEntry(&fiPtr->namedTable,
- Tk_GetUid(buf));
- if (namedHashPtr == NULL) {
- break;
- }
- }
- name = buf;
- skip = 2;
- }
- TkInitFontAttributes(&fa);
- if (ConfigAttributesObj(interp, tkwin, objc - skip, objv + skip,
- &fa) != TCL_OK) {
- return TCL_ERROR;
- }
- if (TkCreateNamedFont(interp, tkwin, name, &fa) != TCL_OK) {
- return TCL_ERROR;
- }
- Tcl_SetStringObj(Tcl_GetObjResult(interp), name, -1);
- break;
- }
- case FONT_DELETE: {
- int i;
- char *string;
- NamedFont *nfPtr;
- Tcl_HashEntry *namedHashPtr;
-
- /*
- * Delete the named font. If there are still widgets using this
- * font, then it isn't deleted right away.
- */
-
- if (objc < 3) {
- Tcl_WrongNumArgs(interp, 2, objv, "fontname ?fontname ...?");
- return TCL_ERROR;
- }
- for (i = 2; i < objc; i++) {
- string = Tk_GetUid(Tcl_GetStringFromObj(objv[i], NULL));
- namedHashPtr = Tcl_FindHashEntry(&fiPtr->namedTable, string);
- if (namedHashPtr == NULL) {
- Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "named font \"", string,
- "\" doesn't exist", (char *) NULL);
- return TCL_ERROR;
- }
- nfPtr = (NamedFont *) Tcl_GetHashValue(namedHashPtr);
- if (nfPtr->refCount != 0) {
- nfPtr->deletePending = 1;
- } else {
- Tcl_DeleteHashEntry(namedHashPtr);
- ckfree((char *) nfPtr);
- }
- }
- break;
- }
- case FONT_FAMILIES: {
- int skip;
-
- skip = TkGetDisplayOf(interp, objc - 2, objv + 2, &tkwin);
- if (skip < 0) {
- return TCL_ERROR;
- }
- if (objc - skip != 2) {
- Tcl_WrongNumArgs(interp, 2, objv, "?-displayof window?");
- return TCL_ERROR;
- }
- TkpGetFontFamilies(interp, tkwin);
- break;
- }
- case FONT_MEASURE: {
- char *string;
- Tk_Font tkfont;
- int length, skip;
-
- skip = TkGetDisplayOf(interp, objc - 3, objv + 3, &tkwin);
- if (skip < 0) {
- return TCL_ERROR;
- }
- if (objc - skip != 4) {
- Tcl_WrongNumArgs(interp, 2, objv,
- "font ?-displayof window? text");
- return TCL_ERROR;
- }
- tkfont = Tk_GetFontFromObj(interp, tkwin, objv[2]);
- if (tkfont == NULL) {
- return TCL_ERROR;
- }
- string = Tcl_GetStringFromObj(objv[3 + skip], &length);
- Tcl_SetIntObj(Tcl_GetObjResult(interp), Tk_TextWidth(tkfont, string, length));
- Tk_FreeFont(tkfont);
- break;
- }
- case FONT_METRICS: {
- char buf[64];
- Tk_Font tkfont;
- int skip, index, i;
- CONST TkFontMetrics *fmPtr;
- static char *switches[] = {
- "-ascent", "-descent", "-linespace", "-fixed", NULL
- };
-
- skip = TkGetDisplayOf(interp, objc - 3, objv + 3, &tkwin);
- if (skip < 0) {
- return TCL_ERROR;
- }
- if ((objc < 3) || ((objc - skip) > 4)) {
- Tcl_WrongNumArgs(interp, 2, objv,
- "font ?-displayof window? ?option?");
- return TCL_ERROR;
- }
- tkfont = Tk_GetFontFromObj(interp, tkwin, objv[2]);
- if (tkfont == NULL) {
- return TCL_ERROR;
- }
- objc -= skip;
- objv += skip;
- fmPtr = GetFontMetrics(tkfont);
- if (objc == 3) {
- sprintf(buf, "-ascent %d -descent %d -linespace %d -fixed %d",
- fmPtr->ascent, fmPtr->descent,
- fmPtr->ascent + fmPtr->descent,
- fmPtr->fixed);
- Tcl_SetStringObj(Tcl_GetObjResult(interp), buf, -1);
- } else {
- if (Tcl_GetIndexFromObj(interp, objv[3], switches,
- "metric", 0, &index) != TCL_OK) {
- Tk_FreeFont(tkfont);
- return TCL_ERROR;
- }
- i = 0; /* Needed only to prevent compiler
- * warning. */
- switch (index) {
- case 0: i = fmPtr->ascent; break;
- case 1: i = fmPtr->descent; break;
- case 2: i = fmPtr->ascent + fmPtr->descent; break;
- case 3: i = fmPtr->fixed; break;
- }
- Tcl_SetIntObj(Tcl_GetObjResult(interp), i);
- }
- Tk_FreeFont(tkfont);
- break;
- }
- case FONT_NAMES: {
- char *string;
- Tcl_Obj *strPtr;
- NamedFont *nfPtr;
- Tcl_HashSearch search;
- Tcl_HashEntry *namedHashPtr;
-
- if (objc != 2) {
- Tcl_WrongNumArgs(interp, 1, objv, "names");
- return TCL_ERROR;
- }
- namedHashPtr = Tcl_FirstHashEntry(&fiPtr->namedTable, &search);
- while (namedHashPtr != NULL) {
- nfPtr = (NamedFont *) Tcl_GetHashValue(namedHashPtr);
- if (nfPtr->deletePending == 0) {
- string = Tcl_GetHashKey(&fiPtr->namedTable, namedHashPtr);
- strPtr = Tcl_NewStringObj(string, -1);
- Tcl_ListObjAppendElement(NULL, Tcl_GetObjResult(interp), strPtr);
- }
- namedHashPtr = Tcl_NextHashEntry(&search);
- }
- break;
- }
- }
- return TCL_OK;
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * UpdateDependantFonts, TheWorldHasChanged, RecomputeWidgets --
- *
- * Called when the attributes of a named font changes. Updates all
- * the instantiated fonts that depend on that named font and then
- * uses the brute force approach and prepares every widget to
- * recompute its geometry.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Things get queued for redisplay.
- *
- *---------------------------------------------------------------------------
- */
-
-static void
-UpdateDependantFonts(fiPtr, tkwin, namedHashPtr)
- TkFontInfo *fiPtr; /* Info about application's fonts. */
- Tk_Window tkwin; /* A window in the application. */
- Tcl_HashEntry *namedHashPtr;/* The named font that is changing. */
-{
- Tcl_HashEntry *cacheHashPtr;
- Tcl_HashSearch search;
- TkFont *fontPtr;
- NamedFont *nfPtr;
-
- nfPtr = (NamedFont *) Tcl_GetHashValue(namedHashPtr);
- if (nfPtr->refCount == 0) {
- /*
- * Well nobody's using this named font, so don't have to tell
- * any widgets to recompute themselves.
- */
-
- return;
- }
-
-
- cacheHashPtr = Tcl_FirstHashEntry(&fiPtr->fontCache, &search);
- while (cacheHashPtr != NULL) {
- fontPtr = (TkFont *) Tcl_GetHashValue(cacheHashPtr);
- if (fontPtr->namedHashPtr == namedHashPtr) {
- TkpGetFontFromAttributes(fontPtr, tkwin, &nfPtr->fa);
- if (fiPtr->updatePending == 0) {
- fiPtr->updatePending = 1;
- Tcl_DoWhenIdle(TheWorldHasChanged, (ClientData) fiPtr);
- }
- }
- cacheHashPtr = Tcl_NextHashEntry(&search);
- }
-}
-
-static void
-TheWorldHasChanged(clientData)
- ClientData clientData; /* Info about application's fonts. */
-{
- TkFontInfo *fiPtr;
-
- fiPtr = (TkFontInfo *) clientData;
- fiPtr->updatePending = 0;
-
- RecomputeWidgets(fiPtr->mainPtr->winPtr);
-}
-
-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);
- }
- for (winPtr = winPtr->childList; winPtr != NULL; winPtr = winPtr->nextPtr) {
- RecomputeWidgets(winPtr);
- }
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * TkCreateNamedFont --
- *
- * Create the specified named font with the given attributes in the
- * named font table associated with the interp.
- *
- * Results:
- * Returns TCL_OK if the font was successfully created, or TCL_ERROR
- * if the named font already existed. If TCL_ERROR is returned, an
- * error message is left in interp->result.
- *
- * Side effects:
- * Assume there used to exist a named font by the specified name, and
- * that the named font had been deleted, but there were still some
- * widgets using the named font at the time it was deleted. If a
- * new named font is created with the same name, all those widgets
- * that were using the old named font will be redisplayed using
- * the new named font's attributes.
- *
- *---------------------------------------------------------------------------
- */
-
-int
-TkCreateNamedFont(interp, tkwin, name, faPtr)
- Tcl_Interp *interp; /* Interp for error return. */
- Tk_Window tkwin; /* A window associated with interp. */
- CONST char *name; /* Name for the new named font. */
- TkFontAttributes *faPtr; /* Attributes for the new named font. */
-{
- TkFontInfo *fiPtr;
- Tcl_HashEntry *namedHashPtr;
- int new;
- NamedFont *nfPtr;
-
- fiPtr = ((TkWindow *) tkwin)->mainPtr->fontInfoPtr;
-
- name = Tk_GetUid(name);
- namedHashPtr = Tcl_CreateHashEntry(&fiPtr->namedTable, name, &new);
-
- if (new == 0) {
- nfPtr = (NamedFont *) Tcl_GetHashValue(namedHashPtr);
- if (nfPtr->deletePending == 0) {
- interp->result[0] = '\0';
- Tcl_AppendResult(interp, "font \"", name,
- "\" already exists", (char *) NULL);
- return TCL_ERROR;
- }
-
- /*
- * Recreating a named font with the same name as a previous
- * named font. Some widgets were still using that named
- * font, so they need to get redisplayed.
- */
-
- nfPtr->fa = *faPtr;
- nfPtr->deletePending = 0;
- UpdateDependantFonts(fiPtr, tkwin, namedHashPtr);
- return TCL_OK;
- }
-
- nfPtr = (NamedFont *) ckalloc(sizeof(NamedFont));
- nfPtr->deletePending = 0;
- Tcl_SetHashValue(namedHashPtr, nfPtr);
- nfPtr->fa = *faPtr;
- nfPtr->refCount = 0;
- nfPtr->deletePending = 0;
- return TCL_OK;
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * Tk_GetFont --
- *
- * Given a string description of a font, map the description to a
- * corresponding Tk_Font that represents the font.
- *
- * Results:
- * The return value is token for the font, or NULL if an error
- * prevented the font from being created. If NULL is returned, an
- * error message will be left in interp->result.
- *
- * Side effects:
- * Calls Tk_GetFontFromObj(), which modifies interp's result object,
- * then copies the string from the result object into interp->result.
- * This procedure will go away when Tk_ConfigureWidget() is
- * made into an object command.
- *
- *---------------------------------------------------------------------------
- */
-
-Tk_Font
-Tk_GetFont(interp, tkwin, string)
- Tcl_Interp *interp; /* Interp for database and error return. */
- Tk_Window tkwin; /* For display on which font will be used. */
- CONST char *string; /* String describing font, as: named font,
- * native format, or parseable string. */
-{
- Tcl_Obj *strPtr;
- Tk_Font tkfont;
-
- strPtr = Tcl_NewStringObj((char *) string, -1);
-
- tkfont = Tk_GetFontFromObj(interp, tkwin, strPtr);
- if (tkfont == NULL) {
- Tcl_SetResult(interp,
- Tcl_GetStringFromObj(Tcl_GetObjResult(interp), NULL),
- TCL_VOLATILE);
- }
-
- Tcl_DecrRefCount(strPtr); /* done with object */
- return tkfont;
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * Tk_GetFontFromObj --
- *
- * Given a string description of a font, map the description to a
- * corresponding Tk_Font that represents the font.
- *
- * Results:
- * The return value is token for the font, or NULL if an error
- * prevented the font from being created. If NULL is returned, an
- * error message will be left in interp's result object.
- *
- * Side effects:
- * The font is added to an internal database with a reference
- * count. For each call to this procedure, there should eventually
- * be a call to Tk_FreeFont() so that the database is cleaned up when
- * fonts aren't in use anymore.
- *
- *---------------------------------------------------------------------------
- */
-
-Tk_Font
-Tk_GetFontFromObj(interp, tkwin, objPtr)
- Tcl_Interp *interp; /* Interp for database and error return. */
- Tk_Window tkwin; /* For display on which font will be used. */
- Tcl_Obj *objPtr; /* Object describing font, as: named font,
- * native format, or parseable string. */
-{
- TkFontInfo *fiPtr;
- CachedFontKey key;
- Tcl_HashEntry *cacheHashPtr, *namedHashPtr;
- TkFont *fontPtr;
- int new, descent;
- NamedFont *nfPtr;
- char *string;
-
- fiPtr = ((TkWindow *) tkwin)->mainPtr->fontInfoPtr;
- string = Tcl_GetStringFromObj(objPtr, NULL);
-
- key.display = Tk_Display(tkwin);
- key.string = Tk_GetUid(string);
- cacheHashPtr = Tcl_CreateHashEntry(&fiPtr->fontCache, (char *) &key, &new);
-
- if (new == 0) {
- /*
- * We have already constructed a font with this description for
- * this display. Bump the reference count of the cached font.
- */
-
- fontPtr = (TkFont *) Tcl_GetHashValue(cacheHashPtr);
- fontPtr->refCount++;
- return (Tk_Font) fontPtr;
- }
-
- namedHashPtr = Tcl_FindHashEntry(&fiPtr->namedTable, key.string);
- if (namedHashPtr != NULL) {
- /*
- * Construct a font based on a named font.
- */
-
- nfPtr = (NamedFont *) Tcl_GetHashValue(namedHashPtr);
- nfPtr->refCount++;
-
- fontPtr = TkpGetFontFromAttributes(NULL, tkwin, &nfPtr->fa);
- } else {
- /*
- * Native font?
- */
-
- fontPtr = TkpGetNativeFont(tkwin, string);
- if (fontPtr == NULL) {
- TkFontAttributes fa;
-
- TkInitFontAttributes(&fa);
- if (ParseFontNameObj(interp, tkwin, objPtr, &fa) != TCL_OK) {
- Tcl_DeleteHashEntry(cacheHashPtr);
- return NULL;
- }
-
- /*
- * String contained the attributes inline.
- */
-
- fontPtr = TkpGetFontFromAttributes(NULL, tkwin, &fa);
- }
- }
- Tcl_SetHashValue(cacheHashPtr, fontPtr);
-
- fontPtr->refCount = 1;
- fontPtr->cacheHashPtr = cacheHashPtr;
- fontPtr->namedHashPtr = namedHashPtr;
-
- Tk_MeasureChars((Tk_Font) fontPtr, "0", 1, 0, 0, &fontPtr->tabWidth);
- if (fontPtr->tabWidth == 0) {
- fontPtr->tabWidth = fontPtr->fm.maxWidth;
- }
- fontPtr->tabWidth *= 8;
-
- /*
- * Make sure the tab width isn't zero (some fonts may not have enough
- * information to set a reasonable tab width).
- */
-
- if (fontPtr->tabWidth == 0) {
- fontPtr->tabWidth = 1;
- }
-
- /*
- * Get information used for drawing underlines in generic code on a
- * non-underlined font.
- */
-
- descent = fontPtr->fm.descent;
- fontPtr->underlinePos = descent / 2;
- fontPtr->underlineHeight = fontPtr->fa.pointsize / 10;
- if (fontPtr->underlineHeight == 0) {
- fontPtr->underlineHeight = 1;
- }
- if (fontPtr->underlinePos + fontPtr->underlineHeight > descent) {
- /*
- * If this set of values would cause the bottom of the underline
- * bar to stick below the descent of the font, jack the underline
- * up a bit higher.
- */
-
- fontPtr->underlineHeight = descent - fontPtr->underlinePos;
- if (fontPtr->underlineHeight == 0) {
- fontPtr->underlinePos--;
- fontPtr->underlineHeight = 1;
- }
- }
-
- return (Tk_Font) fontPtr;
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * Tk_NameOfFont --
- *
- * Given a font, return a textual string identifying it.
- *
- * Results:
- * The return value is the description that was passed to
- * Tk_GetFont() to create the font. The storage for the returned
- * string is only guaranteed to persist until the font is deleted.
- * The caller should not modify this string.
- *
- * Side effects:
- * None.
- *
- *---------------------------------------------------------------------------
- */
-
-char *
-Tk_NameOfFont(tkfont)
- Tk_Font tkfont; /* Font whose name is desired. */
-{
- TkFont *fontPtr;
- Tcl_HashEntry *hPtr;
- CachedFontKey *keyPtr;
-
- fontPtr = (TkFont *) tkfont;
- hPtr = fontPtr->cacheHashPtr;
-
- keyPtr = (CachedFontKey *) Tcl_GetHashKey(hPtr->tablePtr, hPtr);
- return (char *) keyPtr->string;
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * Tk_FreeFont --
- *
- * Called to release a font allocated by Tk_GetFont().
- *
- * Results:
- * None.
- *
- * Side effects:
- * The reference count associated with font is decremented, and
- * only deallocated when no one is using it.
- *
- *---------------------------------------------------------------------------
- */
-
-void
-Tk_FreeFont(tkfont)
- Tk_Font tkfont; /* Font to be released. */
-{
- TkFont *fontPtr;
- NamedFont *nfPtr;
-
- if (tkfont == NULL) {
- return;
- }
- fontPtr = (TkFont *) tkfont;
- fontPtr->refCount--;
- if (fontPtr->refCount == 0) {
- if (fontPtr->namedHashPtr != NULL) {
- /*
- * The font is being deleted. Determine if the associated named
- * font definition should and/or can be deleted too.
- */
-
- nfPtr = (NamedFont *) Tcl_GetHashValue(fontPtr->namedHashPtr);
- nfPtr->refCount--;
- if ((nfPtr->refCount == 0) && (nfPtr->deletePending != 0)) {
- Tcl_DeleteHashEntry(fontPtr->namedHashPtr);
- ckfree((char *) nfPtr);
- }
- }
- Tcl_DeleteHashEntry(fontPtr->cacheHashPtr);
- TkpDeleteFont(fontPtr);
- }
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * Tk_FontId --
- *
- * Given a font, return an opaque handle that should be selected
- * into the XGCValues structure in order to get the constructed
- * gc to use this font. This procedure would go away if the
- * XGCValues structure were replaced with a TkGCValues structure.
- *
- * Results:
- * As above.
- *
- * Side effects:
- * None.
- *
- *---------------------------------------------------------------------------
- */
-
-Font
-Tk_FontId(tkfont)
- Tk_Font tkfont; /* Font that is going to be selected into GC. */
-{
- TkFont *fontPtr;
-
- fontPtr = (TkFont *) tkfont;
- return fontPtr->fid;
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * Tk_GetFontMetrics --
- *
- * Returns overall ascent and descent metrics for the given font.
- * These values can be used to space multiple lines of text and
- * to align the baselines of text in different fonts.
- *
- * Results:
- * If *heightPtr is non-NULL, it is filled with the overall height
- * of the font, which is the sum of the ascent and descent.
- * If *ascentPtr or *descentPtr is non-NULL, they are filled with
- * the ascent and/or descent information for the font.
- *
- * Side effects:
- * None.
- *
- *---------------------------------------------------------------------------
- */
-void
-Tk_GetFontMetrics(tkfont, fmPtr)
- Tk_Font tkfont; /* Font in which metrics are calculated. */
- Tk_FontMetrics *fmPtr; /* Pointer to structure in which font
- * metrics for tkfont will be stored. */
-{
- TkFont *fontPtr;
-
- fontPtr = (TkFont *) tkfont;
- fmPtr->ascent = fontPtr->fm.ascent;
- fmPtr->descent = fontPtr->fm.descent;
- fmPtr->linespace = fontPtr->fm.ascent + fontPtr->fm.descent;
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * Tk_PostscriptFontName --
- *
- * Given a Tk_Font, return the name of the corresponding Postscript
- * font.
- *
- * Results:
- * The return value is the pointsize of the given Tk_Font.
- * The name of the Postscript font is appended to dsPtr.
- *
- * Side effects:
- * If the font does not exist on the printer, the print job will
- * fail at print time. Given a "reasonable" Postscript printer,
- * the following Tk_Font font families should print correctly:
- *
- * Avant Garde, Arial, Bookman, Courier, Courier New, Geneva,
- * Helvetica, Monaco, New Century Schoolbook, New York,
- * Palatino, Symbol, Times, Times New Roman, Zapf Chancery,
- * and Zapf Dingbats.
- *
- * Any other Tk_Font font families may not print correctly
- * because the computed Postscript font name may be incorrect.
- *
- *---------------------------------------------------------------------------
- */
-
-
-int
-Tk_PostscriptFontName(tkfont, dsPtr)
- Tk_Font tkfont; /* Font in which text will be printed. */
- Tcl_DString *dsPtr; /* Pointer to an initialized Tcl_DString to
- * which the name of the Postscript font that
- * corresponds to tkfont will be appended. */
-{
- TkFont *fontPtr;
- char *family, *weightString, *slantString;
- char *src, *dest;
- int upper, len;
-
- len = Tcl_DStringLength(dsPtr);
- fontPtr = (TkFont *) tkfont;
-
- /*
- * Convert the case-insensitive Tk_Font family name to the
- * case-sensitive Postscript family name. Take out any spaces and
- * capitalize the first letter of each word.
- */
-
- family = fontPtr->fa.family;
- if (strncasecmp(family, "itc ", 4) == 0) {
- family = family + 4;
- }
- if ((strcasecmp(family, "Arial") == 0)
- || (strcasecmp(family, "Geneva") == 0)) {
- family = "Helvetica";
- } else if ((strcasecmp(family, "Times New Roman") == 0)
- || (strcasecmp(family, "New York") == 0)) {
- family = "Times";
- } else if ((strcasecmp(family, "Courier New") == 0)
- || (strcasecmp(family, "Monaco") == 0)) {
- family = "Courier";
- } else if (strcasecmp(family, "AvantGarde") == 0) {
- family = "AvantGarde";
- } else if (strcasecmp(family, "ZapfChancery") == 0) {
- family = "ZapfChancery";
- } else if (strcasecmp(family, "ZapfDingbats") == 0) {
- family = "ZapfDingbats";
- } else {
- /*
- * Inline, capitalize the first letter of each word, lowercase the
- * rest of the letters in each word, and then take out the spaces
- * between the words. This may make the DString shorter, which is
- * safe to do.
- */
-
- Tcl_DStringAppend(dsPtr, family, -1);
-
- src = dest = Tcl_DStringValue(dsPtr) + len;
- upper = 1;
- for (; *src != '\0'; src++, dest++) {
- while (isspace(UCHAR(*src))) {
- src++;
- upper = 1;
- }
- *dest = *src;
- if ((upper != 0) && (islower(UCHAR(*src)))) {
- *dest = toupper(UCHAR(*src));
- }
- upper = 0;
- }
- *dest = '\0';
- Tcl_DStringSetLength(dsPtr, dest - Tcl_DStringValue(dsPtr));
- family = Tcl_DStringValue(dsPtr) + len;
- }
- if (family != Tcl_DStringValue(dsPtr) + len) {
- Tcl_DStringAppend(dsPtr, family, -1);
- family = Tcl_DStringValue(dsPtr) + len;
- }
-
- if (strcasecmp(family, "NewCenturySchoolbook") == 0) {
- Tcl_DStringSetLength(dsPtr, len);
- Tcl_DStringAppend(dsPtr, "NewCenturySchlbk", -1);
- family = Tcl_DStringValue(dsPtr) + len;
- }
-
- /*
- * Get the string to use for the weight.
- */
-
- weightString = NULL;
- if (fontPtr->fa.weight == TK_FW_NORMAL) {
- if (strcmp(family, "Bookman") == 0) {
- weightString = "Light";
- } else if (strcmp(family, "AvantGarde") == 0) {
- weightString = "Book";
- } else if (strcmp(family, "ZapfChancery") == 0) {
- weightString = "Medium";
- }
- } else {
- if ((strcmp(family, "Bookman") == 0)
- || (strcmp(family, "AvantGarde") == 0)) {
- weightString = "Demi";
- } else {
- weightString = "Bold";
- }
- }
-
- /*
- * Get the string to use for the slant.
- */
-
- slantString = NULL;
- if (fontPtr->fa.slant == TK_FS_ROMAN) {
- ;
- } else {
- if ((strcmp(family, "Helvetica") == 0)
- || (strcmp(family, "Courier") == 0)
- || (strcmp(family, "AvantGarde") == 0)) {
- slantString = "Oblique";
- } else {
- slantString = "Italic";
- }
- }
-
- /*
- * The string "Roman" needs to be added to some fonts that are not bold
- * and not italic.
- */
-
- if ((slantString == NULL) && (weightString == NULL)) {
- if ((strcmp(family, "Times") == 0)
- || (strcmp(family, "NewCenturySchlbk") == 0)
- || (strcmp(family, "Palatino") == 0)) {
- Tcl_DStringAppend(dsPtr, "-Roman", -1);
- }
- } else {
- Tcl_DStringAppend(dsPtr, "-", -1);
- if (weightString != NULL) {
- Tcl_DStringAppend(dsPtr, weightString, -1);
- }
- if (slantString != NULL) {
- Tcl_DStringAppend(dsPtr, slantString, -1);
- }
- }
-
- return fontPtr->fa.pointsize;
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * Tk_TextWidth --
- *
- * A wrapper function for the more complicated interface of
- * Tk_MeasureChars. Computes how much space the given
- * simple string needs.
- *
- * Results:
- * The return value is the width (in pixels) of the given string.
- *
- * Side effects:
- * None.
- *
- *---------------------------------------------------------------------------
- */
-
-int
-Tk_TextWidth(tkfont, string, numChars)
- Tk_Font tkfont; /* Font in which text will be measured. */
- CONST char *string; /* String whose width will be computed. */
- int numChars; /* Number of characters to consider from
- * string, or < 0 for strlen(). */
-{
- int width;
-
- if (numChars < 0) {
- numChars = strlen(string);
- }
- Tk_MeasureChars(tkfont, string, numChars, 0, 0, &width);
- return width;
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * Tk_UnderlineChars --
- *
- * This procedure draws an underline for a given range of characters
- * in a given string. It doesn't draw the characters (which are
- * assumed to have been displayed previously); it just draws the
- * underline. This procedure would mainly be used to quickly
- * underline a few characters without having to construct an
- * underlined font. To produce properly underlined text, the
- * appropriate underlined font should be constructed and used.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Information gets displayed in "drawable".
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tk_UnderlineChars(display, drawable, gc, tkfont, string, x, y, firstChar,
- lastChar)
- Display *display; /* Display on which to draw. */
- Drawable drawable; /* Window or pixmap in which to draw. */
- GC gc; /* Graphics context for actually drawing
- * line. */
- Tk_Font tkfont; /* Font used in GC; must have been allocated
- * by Tk_GetFont(). Used for character
- * dimensions, etc. */
- CONST char *string; /* String containing characters to be
- * underlined or overstruck. */
- int x, y; /* Coordinates at which first character of
- * string is drawn. */
- int firstChar; /* Index of first character. */
- int lastChar; /* Index of one after the last character. */
-{
- TkFont *fontPtr;
- int startX, endX;
-
- fontPtr = (TkFont *) tkfont;
-
- Tk_MeasureChars(tkfont, string, firstChar, 0, 0, &startX);
- Tk_MeasureChars(tkfont, string, lastChar, 0, 0, &endX);
-
- XFillRectangle(display, drawable, gc, x + startX,
- y + fontPtr->underlinePos, (unsigned int) (endX - startX),
- (unsigned int) fontPtr->underlineHeight);
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * Tk_ComputeTextLayout --
- *
- * Computes the amount of screen space needed to display a
- * multi-line, justified string of text. Records all the
- * measurements that were done to determine to size and
- * positioning of the individual lines of text; this information
- * can be used by the Tk_DrawTextLayout() procedure to
- * display the text quickly (without remeasuring it).
- *
- * This procedure is useful for simple widgets that want to
- * display single-font, multi-line text and want Tk to handle the
- * details.
- *
- * Results:
- * The return value is a Tk_TextLayout token that holds the
- * measurement information for the given string. The token is
- * only valid for the given string. If the string is freed,
- * the token is no longer valid and must also be freed. To free
- * the token, call Tk_FreeTextLayout().
- *
- * The dimensions of the screen area needed to display the text
- * are stored in *widthPtr and *heightPtr.
- *
- * Side effects:
- * Memory is allocated to hold the measurement information.
- *
- *---------------------------------------------------------------------------
- */
-
-Tk_TextLayout
-Tk_ComputeTextLayout(tkfont, string, numChars, wrapLength, justify, flags,
- widthPtr, heightPtr)
- Tk_Font tkfont; /* Font that will be used to display text. */
- CONST char *string; /* String whose dimensions are to be
- * computed. */
- int numChars; /* Number of characters to consider from
- * string, or < 0 for strlen(). */
- int wrapLength; /* Longest permissible line length, in
- * pixels. <= 0 means no automatic wrapping:
- * just let lines get as long as needed. */
- Tk_Justify justify; /* How to justify lines. */
- int flags; /* Flag bits OR-ed together.
- * TK_IGNORE_TABS means that tab characters
- * should not be expanded. TK_IGNORE_NEWLINES
- * means that newline characters should not
- * cause a line break. */
- int *widthPtr; /* Filled with width of string. */
- int *heightPtr; /* Filled with height of string. */
-{
- TkFont *fontPtr;
- CONST char *start, *end, *special;
- int n, y, charsThisChunk, maxChunks;
- int baseline, height, curX, newX, maxWidth;
- TextLayout *layoutPtr;
- LayoutChunk *chunkPtr;
- CONST TkFontMetrics *fmPtr;
-#define MAX_LINES 50
- int staticLineLengths[MAX_LINES];
- int *lineLengths;
- int maxLines, curLine, layoutHeight;
-
- lineLengths = staticLineLengths;
- maxLines = MAX_LINES;
-
- fontPtr = (TkFont *) tkfont;
- fmPtr = &fontPtr->fm;
-
- height = fmPtr->ascent + fmPtr->descent;
-
- if (numChars < 0) {
- numChars = strlen(string);
- }
-
- maxChunks = 1;
-
- layoutPtr = (TextLayout *) ckalloc(sizeof(TextLayout)
- + (maxChunks - 1) * sizeof(LayoutChunk));
- layoutPtr->tkfont = tkfont;
- layoutPtr->string = string;
- layoutPtr->numChunks = 0;
-
- baseline = fmPtr->ascent;
- maxWidth = 0;
-
- /*
- * Divide the string up into simple strings and measure each string.
- */
-
- curX = 0;
-
- end = string + numChars;
- special = string;
-
- flags &= TK_IGNORE_TABS | TK_IGNORE_NEWLINES;
- flags |= TK_WHOLE_WORDS | TK_AT_LEAST_ONE;
- curLine = 0;
- for (start = string; start < end; ) {
- if (start >= special) {
- /*
- * Find the next special character in the string.
- */
-
- for (special = start; special < end; special++) {
- if (!(flags & TK_IGNORE_NEWLINES)) {
- if ((*special == '\n') || (*special == '\r')) {
- break;
- }
- }
- if (!(flags & TK_IGNORE_TABS)) {
- if (*special == '\t') {
- break;
- }
- }
- }
- }
-
- /*
- * Special points at the next special character (or the end of the
- * string). Process characters between start and special.
- */
-
- chunkPtr = NULL;
- if (start < special) {
- charsThisChunk = Tk_MeasureChars(tkfont, start, special - start,
- wrapLength - curX, flags, &newX);
- newX += curX;
- flags &= ~TK_AT_LEAST_ONE;
- if (charsThisChunk > 0) {
- chunkPtr = NewChunk(&layoutPtr, &maxChunks, start,
- charsThisChunk, curX, newX, baseline);
-
- start += charsThisChunk;
- curX = newX;
- }
- }
-
- if ((start == special) && (special < end)) {
- /*
- * Handle the special character.
- */
-
- chunkPtr = NULL;
- if (*special == '\t') {
- newX = curX + fontPtr->tabWidth;
- newX -= newX % fontPtr->tabWidth;
- NewChunk(&layoutPtr, &maxChunks, start, 1, curX, newX,
- baseline)->numDisplayChars = -1;
- start++;
- if ((start < end) &&
- ((wrapLength <= 0) || (newX <= wrapLength))) {
- /*
- * More chars can still fit on this line.
- */
-
- curX = newX;
- flags &= ~TK_AT_LEAST_ONE;
- continue;
- }
- } else {
- NewChunk(&layoutPtr, &maxChunks, start, 1, curX, 1000000000,
- baseline)->numDisplayChars = -1;
- start++;
- goto wrapLine;
- }
- }
-
- /*
- * No more characters are going to go on this line, either because
- * no more characters can fit or there are no more characters left.
- * Consume all extra spaces at end of line.
- */
-
- while ((start < end) && isspace(UCHAR(*start))) {
- if (!(flags & TK_IGNORE_NEWLINES)) {
- if ((*start == '\n') || (*start == '\r')) {
- break;
- }
- }
- if (!(flags & TK_IGNORE_TABS)) {
- if (*start == '\t') {
- break;
- }
- }
- start++;
- }
- if (chunkPtr != NULL) {
- /*
- * Append all the extra spaces on this line to the end of the
- * last text chunk.
- */
- charsThisChunk = start - (chunkPtr->start + chunkPtr->numChars);
- if (charsThisChunk > 0) {
- chunkPtr->numChars += Tk_MeasureChars(tkfont,
- chunkPtr->start + chunkPtr->numChars, charsThisChunk,
- 0, 0, &chunkPtr->totalWidth);
- chunkPtr->totalWidth += curX;
- }
- }
-
- wrapLine:
- flags |= TK_AT_LEAST_ONE;
-
- /*
- * Save current line length, then move current position to start of
- * next line.
- */
-
- if (curX > maxWidth) {
- maxWidth = curX;
- }
-
- /*
- * Remember width of this line, so that all chunks on this line
- * can be centered or right justified, if necessary.
- */
-
- if (curLine >= maxLines) {
- int *newLengths;
-
- newLengths = (int *) ckalloc(2 * maxLines * sizeof(int));
- memcpy((void *) newLengths, lineLengths, maxLines * sizeof(int));
- if (lineLengths != staticLineLengths) {
- ckfree((char *) lineLengths);
- }
- lineLengths = newLengths;
- maxLines *= 2;
- }
- lineLengths[curLine] = curX;
- curLine++;
-
- curX = 0;
- baseline += height;
- }
-
- /*
- * If last line ends with a newline, then we need to make a 0 width
- * chunk on the next line. Otherwise "Hello" and "Hello\n" are the
- * same height.
- */
-
- if ((layoutPtr->numChunks > 0) && ((flags & TK_IGNORE_NEWLINES) == 0)) {
- if (layoutPtr->chunks[layoutPtr->numChunks - 1].start[0] == '\n') {
- chunkPtr = NewChunk(&layoutPtr, &maxChunks, start, 0, curX,
- 1000000000, baseline);
- chunkPtr->numDisplayChars = -1;
- baseline += height;
- }
- }
-
- /*
- * Using maximum line length, shift all the chunks so that the lines are
- * all justified correctly.
- */
-
- curLine = 0;
- chunkPtr = layoutPtr->chunks;
- y = chunkPtr->y;
- for (n = 0; n < layoutPtr->numChunks; n++) {
- int extra;
-
- if (chunkPtr->y != y) {
- curLine++;
- y = chunkPtr->y;
- }
- extra = maxWidth - lineLengths[curLine];
- if (justify == TK_JUSTIFY_CENTER) {
- chunkPtr->x += extra / 2;
- } else if (justify == TK_JUSTIFY_RIGHT) {
- chunkPtr->x += extra;
- }
- chunkPtr++;
- }
-
- layoutPtr->width = maxWidth;
- layoutHeight = baseline - fmPtr->ascent;
- if (layoutPtr->numChunks == 0) {
- layoutHeight = height;
-
- /*
- * This fake chunk is used by the other procedures so that they can
- * pretend that there is a chunk with no chars in it, which makes
- * the coding simpler.
- */
-
- layoutPtr->numChunks = 1;
- layoutPtr->chunks[0].start = string;
- layoutPtr->chunks[0].numChars = 0;
- layoutPtr->chunks[0].numDisplayChars = -1;
- layoutPtr->chunks[0].x = 0;
- layoutPtr->chunks[0].y = fmPtr->ascent;
- layoutPtr->chunks[0].totalWidth = 0;
- layoutPtr->chunks[0].displayWidth = 0;
- }
-
- if (widthPtr != NULL) {
- *widthPtr = layoutPtr->width;
- }
- if (heightPtr != NULL) {
- *heightPtr = layoutHeight;
- }
- if (lineLengths != staticLineLengths) {
- ckfree((char *) lineLengths);
- }
-
- return (Tk_TextLayout) layoutPtr;
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * Tk_FreeTextLayout --
- *
- * This procedure is called to release the storage associated with
- * a Tk_TextLayout when it is no longer needed.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Memory is freed.
- *
- *---------------------------------------------------------------------------
- */
-
-void
-Tk_FreeTextLayout(textLayout)
- Tk_TextLayout textLayout; /* The text layout to be released. */
-{
- TextLayout *layoutPtr;
-
- layoutPtr = (TextLayout *) textLayout;
- if (layoutPtr != NULL) {
- ckfree((char *) layoutPtr);
- }
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * Tk_DrawTextLayout --
- *
- * Use the information in the Tk_TextLayout token to display a
- * multi-line, justified string of text.
- *
- * This procedure is useful for simple widgets that need to
- * display single-font, multi-line text and want Tk to handle
- * the details.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Text drawn on the screen.
- *
- *---------------------------------------------------------------------------
- */
-
-void
-Tk_DrawTextLayout(display, drawable, gc, layout, x, y, firstChar, lastChar)
- Display *display; /* Display on which to draw. */
- Drawable drawable; /* Window or pixmap in which to draw. */
- GC gc; /* Graphics context to use for drawing text. */
- Tk_TextLayout layout; /* Layout information, from a previous call
- * to Tk_ComputeTextLayout(). */
- int x, y; /* Upper-left hand corner of rectangle in
- * which to draw (pixels). */
- int firstChar; /* The index of the first character to draw
- * from the given text item. 0 specfies the
- * beginning. */
- int lastChar; /* The index just after the last character
- * to draw from the given text item. A number
- * < 0 means to draw all characters. */
-{
- TextLayout *layoutPtr;
- int i, numDisplayChars, drawX;
- LayoutChunk *chunkPtr;
-
- layoutPtr = (TextLayout *) layout;
- if (layoutPtr == NULL) {
- return;
- }
-
- if (lastChar < 0) {
- lastChar = 100000000;
- }
- chunkPtr = layoutPtr->chunks;
- for (i = 0; i < layoutPtr->numChunks; i++) {
- numDisplayChars = chunkPtr->numDisplayChars;
- if ((numDisplayChars > 0) && (firstChar < numDisplayChars)) {
- if (firstChar <= 0) {
- drawX = 0;
- firstChar = 0;
- } else {
- Tk_MeasureChars(layoutPtr->tkfont, chunkPtr->start, firstChar,
- 0, 0, &drawX);
- }
- if (lastChar < numDisplayChars) {
- numDisplayChars = lastChar;
- }
- Tk_DrawChars(display, drawable, gc, layoutPtr->tkfont,
- chunkPtr->start + firstChar, numDisplayChars - firstChar,
- x + chunkPtr->x + drawX, y + chunkPtr->y);
- }
- firstChar -= chunkPtr->numChars;
- lastChar -= chunkPtr->numChars;
- if (lastChar <= 0) {
- break;
- }
- chunkPtr++;
- }
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * Tk_UnderlineTextLayout --
- *
- * Use the information in the Tk_TextLayout token to display an
- * underline below an individual character. This procedure does
- * not draw the text, just the underline.
- *
- * This procedure is useful for simple widgets that need to
- * display single-font, multi-line text with an individual
- * character underlined and want Tk to handle the details.
- * To display larger amounts of underlined text, construct
- * and use an underlined font.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Underline drawn on the screen.
- *
- *---------------------------------------------------------------------------
- */
-
-void
-Tk_UnderlineTextLayout(display, drawable, gc, layout, x, y, underline)
- Display *display; /* Display on which to draw. */
- Drawable drawable; /* Window or pixmap in which to draw. */
- GC gc; /* Graphics context to use for drawing text. */
- Tk_TextLayout layout; /* Layout information, from a previous call
- * to Tk_ComputeTextLayout(). */
- int x, y; /* Upper-left hand corner of rectangle in
- * which to draw (pixels). */
- int underline; /* Index of the single character to
- * underline, or -1 for no underline. */
-{
- TextLayout *layoutPtr;
- TkFont *fontPtr;
- int xx, yy, width, height;
-
- 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);
- }
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * Tk_PointToChar --
- *
- * Use the information in the Tk_TextLayout token to determine the
- * character closest to the given point. The point must be
- * specified with respect to the upper-left hand corner of the
- * text layout, which is considered to be located at (0, 0).
- *
- * Any point whose y-value is less that 0 will be considered closest
- * to the first character in the text layout; any point whose y-value
- * is greater than the height of the text layout will be considered
- * closest to the last character in the text layout.
- *
- * Any point whose x-value is less than 0 will be considered closest
- * to the first character on that line; any point whose x-value is
- * greater than the width of the text layout will be considered
- * closest to the last character on that line.
- *
- * Results:
- * The return value is the index of the character that was
- * closest to the point. Given a text layout with no characters,
- * the value 0 will always be returned, referring to a hypothetical
- * zero-width placeholder character.
- *
- * Side effects:
- * None.
- *
- *---------------------------------------------------------------------------
- */
-
-int
-Tk_PointToChar(layout, x, y)
- Tk_TextLayout layout; /* Layout information, from a previous call
- * to Tk_ComputeTextLayout(). */
- int x, y; /* Coordinates of point to check, with
- * respect to the upper-left corner of the
- * text layout. */
-{
- TextLayout *layoutPtr;
- LayoutChunk *chunkPtr, *lastPtr;
- TkFont *fontPtr;
- int i, n, dummy, baseline, pos;
-
- if (y < 0) {
- /*
- * Point lies above any line in this layout. Return the index of
- * the first char.
- */
-
- return 0;
- }
-
- /*
- * Find which line contains the point.
- */
-
- layoutPtr = (TextLayout *) layout;
- fontPtr = (TkFont *) layoutPtr->tkfont;
- lastPtr = chunkPtr = layoutPtr->chunks;
- for (i = 0; i < layoutPtr->numChunks; i++) {
- baseline = chunkPtr->y;
- if (y < baseline + fontPtr->fm.descent) {
- if (x < chunkPtr->x) {
- /*
- * Point is to the left of all chunks on this line. Return
- * the index of the first character on this line.
- */
-
- return chunkPtr->start - layoutPtr->string;
- }
- if (x >= layoutPtr->width) {
- /*
- * If point lies off right side of the text layout, return
- * the last char in the last chunk on this line. Without
- * this, it might return the index of the first char that
- * was located outside of the text layout.
- */
-
- x = INT_MAX;
- }
-
- /*
- * Examine all chunks on this line to see which one contains
- * the specified point.
- */
-
- lastPtr = chunkPtr;
- while ((i < layoutPtr->numChunks) && (chunkPtr->y == baseline)) {
- if (x < chunkPtr->x + chunkPtr->totalWidth) {
- /*
- * Point falls on one of the characters in this chunk.
- */
-
- if (chunkPtr->numDisplayChars < 0) {
- /*
- * This is a special chunk that encapsulates a single
- * tab or newline char.
- */
-
- return chunkPtr->start - layoutPtr->string;
- }
- n = Tk_MeasureChars((Tk_Font) fontPtr, chunkPtr->start,
- chunkPtr->numChars, x + 1 - chunkPtr->x,
- TK_PARTIAL_OK, &dummy);
- return (chunkPtr->start + n - 1) - layoutPtr->string;
- }
- lastPtr = chunkPtr;
- chunkPtr++;
- i++;
- }
-
- /*
- * Point is to the right of all chars in all the chunks on this
- * line. Return the index just past the last char in the last
- * chunk on this line.
- */
-
- pos = (lastPtr->start + lastPtr->numChars) - layoutPtr->string;
- if (i < layoutPtr->numChunks) {
- pos--;
- }
- return pos;
- }
- lastPtr = chunkPtr;
- chunkPtr++;
- }
-
- /*
- * Point lies below any line in this text layout. Return the index
- * just past the last char.
- */
-
- return (lastPtr->start + lastPtr->numChars) - layoutPtr->string;
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * Tk_CharBbox --
- *
- * Use the information in the Tk_TextLayout token to return the
- * bounding box for the character specified by index.
- *
- * The width of the bounding box is the advance width of the
- * character, and does not include and left- or right-bearing.
- * Any character that extends partially outside of the
- * text layout is considered to be truncated at the edge. Any
- * character which is located completely outside of the text
- * layout is considered to be zero-width and pegged against
- * the edge.
- *
- * The height of the bounding box is the line height for this font,
- * extending from the top of the ascent to the bottom of the
- * descent. Information about the actual height of the individual
- * letter is not available.
- *
- * A text layout that contains no characters is considered to
- * contain a single zero-width placeholder character.
- *
- * Results:
- * The return value is 0 if the index did not specify a character
- * in the text layout, or non-zero otherwise. In that case,
- * *bbox is filled with the bounding box of the character.
- *
- * Side effects:
- * None.
- *
- *---------------------------------------------------------------------------
- */
-
-int
-Tk_CharBbox(layout, index, xPtr, yPtr, widthPtr, heightPtr)
- Tk_TextLayout layout; /* Layout information, from a previous call to
- * Tk_ComputeTextLayout(). */
- int index; /* The index of the character whose bbox is
- * desired. */
- int *xPtr, *yPtr; /* Filled with the upper-left hand corner, in
- * pixels, of the bounding box for the character
- * specified by index, if non-NULL. */
- int *widthPtr, *heightPtr;
- /* Filled with the width and height of the
- * bounding box for the character specified by
- * index, if non-NULL. */
-{
- TextLayout *layoutPtr;
- LayoutChunk *chunkPtr;
- int i, x, w;
- Tk_Font tkfont;
- TkFont *fontPtr;
-
- if (index < 0) {
- return 0;
- }
-
- layoutPtr = (TextLayout *) layout;
- chunkPtr = layoutPtr->chunks;
- tkfont = layoutPtr->tkfont;
- fontPtr = (TkFont *) tkfont;
-
- for (i = 0; i < layoutPtr->numChunks; i++) {
- if (chunkPtr->numDisplayChars < 0) {
- if (index == 0) {
- x = chunkPtr->x;
- w = chunkPtr->totalWidth;
- goto check;
- }
- } else if (index < chunkPtr->numChars) {
- if (xPtr != NULL) {
- Tk_MeasureChars(tkfont, chunkPtr->start, index, 0, 0, &x);
- x += chunkPtr->x;
- }
- if (widthPtr != NULL) {
- Tk_MeasureChars(tkfont, chunkPtr->start + index, 1, 0, 0, &w);
- }
- goto check;
- }
- index -= chunkPtr->numChars;
- chunkPtr++;
- }
- if (index == 0) {
- /*
- * Special case to get location just past last char in layout.
- */
-
- chunkPtr--;
- x = chunkPtr->x + chunkPtr->totalWidth;
- w = 0;
- } else {
- return 0;
- }
-
- /*
- * Ensure that the bbox lies within the text layout. This forces all
- * chars that extend off the right edge of the text layout to have
- * truncated widths, and all chars that are completely off the right
- * edge of the text layout to peg to the edge and have 0 width.
- */
- check:
- if (yPtr != NULL) {
- *yPtr = chunkPtr->y - fontPtr->fm.ascent;
- }
- if (heightPtr != NULL) {
- *heightPtr = fontPtr->fm.ascent + fontPtr->fm.descent;
- }
-
- if (x > layoutPtr->width) {
- x = layoutPtr->width;
- }
- if (xPtr != NULL) {
- *xPtr = x;
- }
- if (widthPtr != NULL) {
- if (x + w > layoutPtr->width) {
- w = layoutPtr->width - x;
- }
- *widthPtr = w;
- }
-
- return 1;
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * Tk_DistanceToTextLayout --
- *
- * Computes the distance in pixels from the given point to the
- * given text layout. Non-displaying space characters that occur
- * at the end of individual lines in the text layout are ignored
- * for hit detection purposes.
- *
- * Results:
- * The return value is 0 if the point (x, y) is inside the text
- * layout. If the point isn't inside the text layout then the
- * return value is the distance in pixels from the point to the
- * text item.
- *
- * Side effects:
- * None.
- *
- *---------------------------------------------------------------------------
- */
-
-int
-Tk_DistanceToTextLayout(layout, x, y)
- Tk_TextLayout layout; /* Layout information, from a previous call
- * to Tk_ComputeTextLayout(). */
- int x, y; /* Coordinates of point to check, with
- * respect to the upper-left corner of the
- * text layout (in pixels). */
-{
- int i, x1, x2, y1, y2, xDiff, yDiff, dist, minDist, ascent, descent;
- LayoutChunk *chunkPtr;
- TextLayout *layoutPtr;
- TkFont *fontPtr;
-
- layoutPtr = (TextLayout *) layout;
- fontPtr = (TkFont *) layoutPtr->tkfont;
- ascent = fontPtr->fm.ascent;
- descent = fontPtr->fm.descent;
-
- minDist = 0;
- chunkPtr = layoutPtr->chunks;
- for (i = 0; i < layoutPtr->numChunks; i++) {
- if (chunkPtr->start[0] == '\n') {
- /*
- * Newline characters are not counted when computing distance
- * (but tab characters would still be considered).
- */
-
- chunkPtr++;
- continue;
- }
-
- x1 = chunkPtr->x;
- y1 = chunkPtr->y - ascent;
- x2 = chunkPtr->x + chunkPtr->displayWidth;
- y2 = chunkPtr->y + descent;
-
- if (x < x1) {
- xDiff = x1 - x;
- } else if (x >= x2) {
- xDiff = x - x2 + 1;
- } else {
- xDiff = 0;
- }
-
- if (y < y1) {
- yDiff = y1 - y;
- } else if (y >= y2) {
- yDiff = y - y2 + 1;
- } else {
- yDiff = 0;
- }
- if ((xDiff == 0) && (yDiff == 0)) {
- return 0;
- }
- dist = (int) hypot((double) xDiff, (double) yDiff);
- if ((dist < minDist) || (minDist == 0)) {
- minDist = dist;
- }
- chunkPtr++;
- }
- return minDist;
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * Tk_IntersectTextLayout --
- *
- * Determines whether a text layout lies entirely inside,
- * entirely outside, or overlaps a given rectangle. Non-displaying
- * space characters that occur at the end of individual lines in
- * the text layout are ignored for intersection calculations.
- *
- * Results:
- * The return value is -1 if the text layout is entirely outside of
- * the rectangle, 0 if it overlaps, and 1 if it is entirely inside
- * of the rectangle.
- *
- * Side effects:
- * None.
- *
- *---------------------------------------------------------------------------
- */
-
-int
-Tk_IntersectTextLayout(layout, x, y, width, height)
- Tk_TextLayout layout; /* Layout information, from a previous call
- * to Tk_ComputeTextLayout(). */
- int x, y; /* Upper-left hand corner, in pixels, of
- * rectangular area to compare with text
- * layout. Coordinates are with respect to
- * the upper-left hand corner of the text
- * layout itself. */
- int width, height; /* The width and height of the above
- * rectangular area, in pixels. */
-{
- int result, i, x1, y1, x2, y2;
- TextLayout *layoutPtr;
- LayoutChunk *chunkPtr;
- TkFont *fontPtr;
- int left, top, right, bottom;
-
- /*
- * Scan the chunks one at a time, seeing whether each is entirely in,
- * entirely out, or overlapping the rectangle. If an overlap is
- * detected, return immediately; otherwise wait until all chunks have
- * been processed and see if they were all inside or all outside.
- */
-
- layoutPtr = (TextLayout *) layout;
- chunkPtr = layoutPtr->chunks;
- fontPtr = (TkFont *) layoutPtr->tkfont;
-
- left = x;
- top = y;
- right = x + width;
- bottom = y + height;
-
- result = 0;
- for (i = 0; i < layoutPtr->numChunks; i++) {
- if (chunkPtr->start[0] == '\n') {
- /*
- * Newline characters are not counted when computing area
- * intersection (but tab characters would still be considered).
- */
-
- chunkPtr++;
- continue;
- }
-
- x1 = chunkPtr->x;
- y1 = chunkPtr->y - fontPtr->fm.ascent;
- x2 = chunkPtr->x + chunkPtr->displayWidth;
- y2 = chunkPtr->y + fontPtr->fm.descent;
-
- if ((right < x1) || (left >= x2)
- || (bottom < y1) || (top >= y2)) {
- if (result == 1) {
- return 0;
- }
- result = -1;
- } else if ((x1 < left) || (x2 >= right)
- || (y1 < top) || (y2 >= bottom)) {
- return 0;
- } else if (result == -1) {
- return 0;
- } else {
- result = 1;
- }
- chunkPtr++;
- }
- return result;
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * Tk_TextLayoutToPostscript --
- *
- * Outputs the contents of a text layout in Postscript format.
- * The set of lines in the text layout will be rendered by the user
- * supplied Postscript function. The function should be of the form:
- *
- * justify x y string function --
- *
- * Justify is -1, 0, or 1, depending on whether the following string
- * should be left, center, or right justified, x and y is the
- * location for the origin of the string, string is the sequence
- * of characters to be printed, and function is the name of the
- * caller-provided function; the function should leave nothing
- * on the stack.
- *
- * The meaning of the origin of the string (x and y) depends on
- * the justification. For left justification, x is where the
- * left edge of the string should appear. For center justification,
- * x is where the center of the string should appear. And for right
- * justification, x is where the right edge of the string should
- * appear. This behavior is necessary because, for example, right
- * justified text on the screen is justified with screen metrics.
- * The same string needs to be justified with printer metrics on
- * the printer to appear in the correct place with respect to other
- * similarly justified strings. In all circumstances, y is the
- * location of the baseline for the string.
- *
- * Results:
- * Interp->result is modified to hold the Postscript code that
- * will render the text layout.
- *
- * Side effects:
- * None.
- *
- *---------------------------------------------------------------------------
- */
-
-void
-Tk_TextLayoutToPostscript(interp, layout)
- Tcl_Interp *interp; /* Filled with Postscript code. */
- Tk_TextLayout layout; /* The layout to be rendered. */
-{
-#define MAXUSE 128
- char buf[MAXUSE+10];
- LayoutChunk *chunkPtr;
- int i, j, used, c, baseline;
- TextLayout *layoutPtr;
-
- layoutPtr = (TextLayout *) layout;
- chunkPtr = layoutPtr->chunks;
- baseline = chunkPtr->y;
- used = 0;
- buf[used++] = '(';
- for (i = 0; i < layoutPtr->numChunks; i++) {
- if (baseline != chunkPtr->y) {
- buf[used++] = ')';
- buf[used++] = '\n';
- buf[used++] = '(';
- baseline = chunkPtr->y;
- }
- if (chunkPtr->numDisplayChars <= 0) {
- if (chunkPtr->start[0] == '\t') {
- buf[used++] = '\\';
- buf[used++] = 't';
- }
- } else {
- for (j = 0; j < chunkPtr->numDisplayChars; j++) {
- c = UCHAR(chunkPtr->start[j]);
- 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;
- } else {
- buf[used++] = c;
- }
- if (used >= MAXUSE) {
- buf[used] = '\0';
- Tcl_AppendResult(interp, buf, (char *) NULL);
- used = 0;
- }
- }
- }
- if (used >= MAXUSE) {
- /*
- * If there are a whole bunch of returns or tabs in a row,
- * then buf[] could get filled up.
- */
-
- buf[used] = '\0';
- Tcl_AppendResult(interp, buf, (char *) NULL);
- used = 0;
- }
- chunkPtr++;
- }
- buf[used++] = ')';
- buf[used++] = '\n';
- buf[used] = '\0';
- Tcl_AppendResult(interp, buf, (char *) NULL);
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * TkInitFontAttributes --
- *
- * Initialize the font attributes structure to contain sensible
- * values. This must be called before using any other font
- * attributes functions.
- *
- * Results:
- * None.
- *
- * Side effects.
- * None.
- *
- *---------------------------------------------------------------------------
- */
-
-void
-TkInitFontAttributes(faPtr)
- TkFontAttributes *faPtr; /* The attributes structure to initialize. */
-{
- faPtr->family = NULL;
- faPtr->pointsize = 0;
- faPtr->weight = TK_FW_NORMAL;
- faPtr->slant = TK_FS_ROMAN;
- faPtr->underline = 0;
- faPtr->overstrike = 0;
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * ConfigAttributesObj --
- *
- * Process command line options to fill in fields of a properly
- * initialized font attributes structure.
- *
- * Results:
- * A standard Tcl return value. If TCL_ERROR is returned, an
- * error message will be left in interp's result object.
- *
- * Side effects:
- * The fields of the font attributes structure get filled in with
- * information from argc/argv. If an error occurs while parsing,
- * the font attributes structure will contain all modifications
- * specified in the command line options up to the point of the
- * error.
- *
- *---------------------------------------------------------------------------
- */
-
-static int
-ConfigAttributesObj(interp, tkwin, objc, objv, faPtr)
- Tcl_Interp *interp; /* Interp for error return. */
- Tk_Window tkwin; /* For display on which font will be used. */
- int objc; /* Number of elements in argv. */
- Tcl_Obj *CONST objv[]; /* Command line options. */
- TkFontAttributes *faPtr; /* Font attributes structure whose fields
- * are to be modified. Structure must already
- * be properly initialized. */
-{
- int i, n, index;
- Tcl_Obj *value;
- char *option, *string;
-
- if (objc & 1) {
- string = Tcl_GetStringFromObj(objv[objc - 1], NULL);
- Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "missing value for \"",
- string, "\" option", (char *) NULL);
- return TCL_ERROR;
- }
-
- for (i = 0; i < objc; i += 2) {
- option = Tcl_GetStringFromObj(objv[i], NULL);
- value = objv[i + 1];
-
- if (Tcl_GetIndexFromObj(interp, objv[i], fontOpt, "option", 1,
- &index) != TCL_OK) {
- return TCL_ERROR;
- }
- switch (index) {
- case FONT_FAMILY:
- string = Tcl_GetStringFromObj(value, NULL);
- faPtr->family = Tk_GetUid(string);
- break;
-
- case FONT_SIZE:
- if (Tcl_GetIntFromObj(interp, value, &n) != TCL_OK) {
- return TCL_ERROR;
- }
- faPtr->pointsize = n;
- break;
-
- case FONT_WEIGHT:
- string = Tcl_GetStringFromObj(value, NULL);
- n = TkFindStateNum(interp, option, weightMap, string);
- if (n == TK_FW_UNKNOWN) {
- return TCL_ERROR;
- }
- faPtr->weight = n;
- break;
-
- case FONT_SLANT:
- string = Tcl_GetStringFromObj(value, NULL);
- n = TkFindStateNum(interp, option, slantMap, string);
- if (n == TK_FS_UNKNOWN) {
- return TCL_ERROR;
- }
- faPtr->slant = n;
- break;
-
- case FONT_UNDERLINE:
- if (Tcl_GetBooleanFromObj(interp, value, &n) != TCL_OK) {
- return TCL_ERROR;
- }
- faPtr->underline = n;
- break;
-
- case FONT_OVERSTRIKE:
- if (Tcl_GetBooleanFromObj(interp, value, &n) != TCL_OK) {
- return TCL_ERROR;
- }
- faPtr->overstrike = n;
- break;
- }
- }
- return TCL_OK;
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * GetAttributeInfoObj --
- *
- * Return information about the font attributes as a Tcl list.
- *
- * Results:
- * The return value is TCL_OK if the objPtr was non-NULL and
- * specified a valid font attribute, TCL_ERROR otherwise. If TCL_OK
- * is returned, the interp's result object is modified to hold a
- * description of either the current value of a single option, or a
- * list of all options and their current values for the given font
- * attributes. If TCL_ERROR is returned, the interp's result is
- * set to an error message describing that the objPtr did not refer
- * to a valid option.
- *
- * Side effects:
- * None.
- *
- *---------------------------------------------------------------------------
- */
-
-static int
-GetAttributeInfoObj(interp, faPtr, objPtr)
- Tcl_Interp *interp; /* Interp to hold result. */
- CONST TkFontAttributes *faPtr; /* The font attributes to inspect. */
- Tcl_Obj *objPtr; /* If non-NULL, indicates the single
- * option whose value is to be
- * returned. Otherwise
- * information is returned for
- * all options. */
-{
- int i, index, start, end, num;
- char *str;
- Tcl_Obj *newPtr;
-
- start = 0;
- end = FONT_NUMFIELDS;
- if (objPtr != NULL) {
- if (Tcl_GetIndexFromObj(interp, objPtr, fontOpt, "option", 1,
- &index) != TCL_OK) {
- return TCL_ERROR;
- }
- start = index;
- end = index + 1;
- }
-
- for (i = start; i < end; i++) {
- str = NULL;
- num = 0; /* Needed only to prevent compiler
- * warning. */
- switch (i) {
- case FONT_FAMILY:
- str = faPtr->family;
- if (str == NULL) {
- str = "";
- }
- break;
-
- case FONT_SIZE:
- num = faPtr->pointsize;
- break;
-
- case FONT_WEIGHT:
- str = TkFindStateString(weightMap, faPtr->weight);
- break;
-
- case FONT_SLANT:
- str = TkFindStateString(slantMap, faPtr->slant);
- break;
-
- case FONT_UNDERLINE:
- num = faPtr->underline;
- break;
-
- case FONT_OVERSTRIKE:
- num = faPtr->overstrike;
- break;
- }
- if (objPtr == NULL) {
- Tcl_ListObjAppendElement(NULL, Tcl_GetObjResult(interp),
- Tcl_NewStringObj(fontOpt[i], -1));
- if (str != NULL) {
- newPtr = Tcl_NewStringObj(str, -1);
- } else {
- newPtr = Tcl_NewIntObj(num);
- }
- Tcl_ListObjAppendElement(NULL, Tcl_GetObjResult(interp),
- newPtr);
- } else {
- if (str != NULL) {
- Tcl_SetStringObj(Tcl_GetObjResult(interp), str, -1);
- } else {
- Tcl_SetIntObj(Tcl_GetObjResult(interp), num);
- }
- }
- }
- return TCL_OK;
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * ParseFontNameObj --
- *
- * Converts a object into a set of font attributes that can be used
- * to construct a font.
- *
- * The string rep of the object can be one of the following forms:
- * XLFD (see X documentation)
- * "Family [size [style] [style ...]]"
- * "-option value [-option value ...]"
- *
- * Results:
- * The return value is TCL_ERROR if the object was syntactically
- * invalid. In that case an error message is left in interp's
- * result object. Otherwise, fills the font attribute buffer with
- * the values parsed from the string and returns TCL_OK;
- *
- * Side effects:
- * None.
- *
- *---------------------------------------------------------------------------
- */
-
-static int
-ParseFontNameObj(interp, tkwin, objPtr, faPtr)
- Tcl_Interp *interp; /* Interp for error return. */
- Tk_Window tkwin; /* For display on which font is used. */
- Tcl_Obj *objPtr; /* Parseable font description object. */
- TkFontAttributes *faPtr; /* Font attributes structure whose fields
- * are to be modified. Structure must already
- * be properly initialized. */
-{
- char *dash;
- int objc, result, i, n;
- Tcl_Obj **objv;
- TkXLFDAttributes xa;
- char *string;
-
- string = Tcl_GetStringFromObj(objPtr, NULL);
- if (*string == '-') {
- /*
- * This may be an XLFD or an "-option value" string.
- *
- * If the string begins with "-*" or a "-foundry-family-*" pattern,
- * then consider it an XLFD.
- */
-
- if (string[1] == '*') {
- goto xlfd;
- }
- dash = strchr(string + 1, '-');
- if ((dash != NULL) && (!isspace(UCHAR(dash[-1])))) {
- goto xlfd;
- }
-
- if (Tcl_ListObjGetElements(interp, objPtr, &objc, &objv) != TCL_OK) {
- return TCL_ERROR;
- }
-
- return ConfigAttributesObj(interp, tkwin, objc, objv, faPtr);
- }
-
- if (*string == '*') {
- /*
- * This appears to be an XLFD.
- */
-
- xlfd:
- xa.fa = *faPtr;
- result = TkParseXLFD(string, &xa);
- if (result == TCL_OK) {
- *faPtr = xa.fa;
- return result;
- }
- }
-
- /*
- * Wasn't an XLFD or "-option value" string. Try it as a
- * "font size style" list.
- */
-
- if (Tcl_ListObjGetElements(interp, objPtr, &objc, &objv) != TCL_OK) {
- return TCL_ERROR;
- }
- if (objc < 1) {
- Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), "font \"", string,
- "\" doesn't exist", (char *) NULL);
- return TCL_ERROR;
- }
-
- faPtr->family = Tk_GetUid(Tcl_GetStringFromObj(objv[0], NULL));
- if (objc > 1) {
- if (Tcl_GetIntFromObj(interp, objv[1], &n) != TCL_OK) {
- return TCL_ERROR;
- }
- faPtr->pointsize = n;
- }
-
- i = 2;
- if (objc == 3) {
- if (Tcl_ListObjGetElements(interp, objv[2], &objc, &objv) != TCL_OK) {
- return TCL_ERROR;
- }
- i = 0;
- }
- for ( ; i < objc; i++) {
- string = Tcl_GetStringFromObj(objv[i], NULL);
- n = TkFindStateNum(NULL, NULL, weightMap, string);
- if (n != TK_FW_UNKNOWN) {
- faPtr->weight = n;
- continue;
- }
- n = TkFindStateNum(NULL, NULL, slantMap, string);
- if (n != TK_FS_UNKNOWN) {
- faPtr->slant = n;
- continue;
- }
- n = TkFindStateNum(NULL, NULL, underlineMap, string);
- if (n != 0) {
- faPtr->underline = n;
- continue;
- }
- n = TkFindStateNum(NULL, NULL, overstrikeMap, string);
- if (n != 0) {
- faPtr->overstrike = n;
- continue;
- }
-
- /*
- * Unknown style.
- */
-
- Tcl_AppendStringsToObj(Tcl_GetObjResult(interp),
- "unknown font style \"", string, "\"",
- (char *) NULL);
- return TCL_ERROR;
- }
- return TCL_OK;
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * TkParseXLFD --
- *
- * Break up a fully specified XLFD into a set of font attributes.
- *
- * Results:
- * Return value is TCL_ERROR if string was not a fully specified XLFD.
- * Otherwise, fills font attribute buffer with the values parsed
- * from the XLFD and returns TCL_OK.
- *
- * Side effects:
- * None.
- *
- *---------------------------------------------------------------------------
- */
-
-int
-TkParseXLFD(string, xaPtr)
- CONST char *string; /* Parseable font description string. */
- TkXLFDAttributes *xaPtr; /* XLFD attributes structure whose fields
- * are to be modified. Structure must already
- * be properly initialized. */
-{
- char *src;
- CONST char *str;
- int i, j;
- char *field[XLFD_NUMFIELDS + 2];
- Tcl_DString ds;
-
- memset(field, '\0', sizeof(field));
-
- str = string;
- if (*str == '-') {
- str++;
- }
-
- Tcl_DStringInit(&ds);
- Tcl_DStringAppend(&ds, (char *) str, -1);
- src = Tcl_DStringValue(&ds);
-
- field[0] = src;
- for (i = 0; *src != '\0'; src++) {
- if (isupper(UCHAR(*src))) {
- *src = tolower(UCHAR(*src));
- }
- if (*src == '-') {
- i++;
- if (i > XLFD_NUMFIELDS) {
- break;
- }
- *src = '\0';
- field[i] = src + 1;
- }
- }
-
- /*
- * An XLFD of the form -adobe-times-medium-r-*-12-*-* is pretty common,
- * but it is (strictly) malformed, because the first * is eliding both
- * the Setwidth and the Addstyle fields. If the Addstyle field is a
- * number, then assume the above incorrect form was used and shift all
- * the rest of the fields up by one, so the number gets interpreted
- * as a pixelsize. This fix is so that we don't get a million reports
- * that "it works under X, but gives a syntax error under Windows".
- */
-
- if ((i > XLFD_ADD_STYLE) && (FieldSpecified(field[XLFD_ADD_STYLE]))) {
- if (atoi(field[XLFD_ADD_STYLE]) != 0) {
- for (j = XLFD_NUMFIELDS - 1; j >= XLFD_ADD_STYLE; j--) {
- field[j + 1] = field[j];
- }
- field[XLFD_ADD_STYLE] = NULL;
- i++;
- }
- }
-
- /*
- * Bail if we don't have enough of the fields (up to pointsize).
- */
-
- if (i < XLFD_FAMILY) {
- Tcl_DStringFree(&ds);
- return TCL_ERROR;
- }
-
- if (FieldSpecified(field[XLFD_FOUNDRY])) {
- xaPtr->foundry = Tk_GetUid(field[XLFD_FOUNDRY]);
- }
-
- if (FieldSpecified(field[XLFD_FAMILY])) {
- xaPtr->fa.family = Tk_GetUid(field[XLFD_FAMILY]);
- }
- if (FieldSpecified(field[XLFD_WEIGHT])) {
- xaPtr->fa.weight = TkFindStateNum(NULL, NULL, xlfdWeightMap,
- field[XLFD_WEIGHT]);
- }
- if (FieldSpecified(field[XLFD_SLANT])) {
- xaPtr->slant = TkFindStateNum(NULL, NULL, xlfdSlantMap,
- field[XLFD_SLANT]);
- if (xaPtr->slant == TK_FS_ROMAN) {
- xaPtr->fa.slant = TK_FS_ROMAN;
- } else {
- xaPtr->fa.slant = TK_FS_ITALIC;
- }
- }
- if (FieldSpecified(field[XLFD_SETWIDTH])) {
- xaPtr->setwidth = TkFindStateNum(NULL, NULL, xlfdSetwidthMap,
- field[XLFD_SETWIDTH]);
- }
-
- /* XLFD_ADD_STYLE ignored. */
-
- /*
- * Pointsize in tenths of a point, but treat it as tenths of a pixel.
- */
-
- if (FieldSpecified(field[XLFD_POINT_SIZE])) {
- if (field[XLFD_POINT_SIZE][0] == '[') {
- /*
- * Some X fonts have the point size specified as follows:
- *
- * [ N1 N2 N3 N4 ]
- *
- * where N1 is the point size (in points, not decipoints!), and
- * N2, N3, and N4 are some additional numbers that I don't know
- * the purpose of, so I ignore them.
- */
-
- xaPtr->fa.pointsize = atoi(field[XLFD_POINT_SIZE] + 1);
- } else if (Tcl_GetInt(NULL, field[XLFD_POINT_SIZE],
- &xaPtr->fa.pointsize) == TCL_OK) {
- xaPtr->fa.pointsize /= 10;
- } else {
- return TCL_ERROR;
- }
- }
-
- /*
- * Pixel height of font. If specified, overrides pointsize.
- */
-
- if (FieldSpecified(field[XLFD_PIXEL_SIZE])) {
- if (field[XLFD_PIXEL_SIZE][0] == '[') {
- /*
- * Some X fonts have the pixel size specified as follows:
- *
- * [ N1 N2 N3 N4 ]
- *
- * where N1 is the pixel size, and where N2, N3, and N4
- * are some additional numbers that I don't know
- * the purpose of, so I ignore them.
- */
-
- xaPtr->fa.pointsize = atoi(field[XLFD_PIXEL_SIZE] + 1);
- } else if (Tcl_GetInt(NULL, field[XLFD_PIXEL_SIZE],
- &xaPtr->fa.pointsize) != TCL_OK) {
- return TCL_ERROR;
- }
- }
-
- xaPtr->fa.pointsize = -xaPtr->fa.pointsize;
-
- /* XLFD_RESOLUTION_X ignored. */
-
- /* XLFD_RESOLUTION_Y ignored. */
-
- /* XLFD_SPACING ignored. */
-
- /* XLFD_AVERAGE_WIDTH ignored. */
-
- if (FieldSpecified(field[XLFD_REGISTRY])) {
- xaPtr->charset = TkFindStateNum(NULL, NULL, xlfdCharsetMap,
- field[XLFD_REGISTRY]);
- }
- if (FieldSpecified(field[XLFD_ENCODING])) {
- xaPtr->encoding = atoi(field[XLFD_ENCODING]);
- }
-
- Tcl_DStringFree(&ds);
- return TCL_OK;
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * FieldSpecified --
- *
- * Helper function for TkParseXLFD(). Determines if a field in the
- * XLFD was set to a non-null, non-don't-care value.
- *
- * Results:
- * The return value is 0 if the field in the XLFD was not set and
- * should be ignored, non-zero otherwise.
- *
- * Side effects:
- * None.
- *
- *---------------------------------------------------------------------------
- */
-
-static int
-FieldSpecified(field)
- CONST char *field; /* The field of the XLFD to check. Strictly
- * speaking, only when the string is "*" does it mean
- * don't-care. However, an unspecified or question
- * mark is also interpreted as don't-care. */
-{
- char ch;
-
- if (field == NULL) {
- return 0;
- }
- ch = field[0];
- return (ch != '*' && ch != '?');
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * NewChunk --
- *
- * Helper function for Tk_ComputeTextLayout(). Encapsulates a
- * measured set of characters in a chunk that can be quickly
- * drawn.
- *
- * Results:
- * A pointer to the new chunk in the text layout.
- *
- * Side effects:
- * The text layout is reallocated to hold more chunks as necessary.
- *
- * Currently, Tk_ComputeTextLayout() stores contiguous ranges of
- * "normal" characters in a chunk, along with individual tab
- * and newline chars in their own chunks. All characters in the
- * text layout are accounted for.
- *
- *---------------------------------------------------------------------------
- */
-static LayoutChunk *
-NewChunk(layoutPtrPtr, maxPtr, start, numChars, curX, newX, y)
- TextLayout **layoutPtrPtr;
- int *maxPtr;
- CONST char *start;
- int numChars;
- int curX;
- int newX;
- int y;
-{
- TextLayout *layoutPtr;
- LayoutChunk *chunkPtr;
- int maxChunks;
- size_t s;
-
- layoutPtr = *layoutPtrPtr;
- maxChunks = *maxPtr;
- if (layoutPtr->numChunks == maxChunks) {
- maxChunks *= 2;
- s = sizeof(TextLayout) + ((maxChunks - 1) * sizeof(LayoutChunk));
- layoutPtr = (TextLayout *) ckrealloc((char *) layoutPtr, s);
-
- *layoutPtrPtr = layoutPtr;
- *maxPtr = maxChunks;
- }
- chunkPtr = &layoutPtr->chunks[layoutPtr->numChunks];
- chunkPtr->start = start;
- chunkPtr->numChars = numChars;
- chunkPtr->numDisplayChars = numChars;
- chunkPtr->x = curX;
- chunkPtr->y = y;
- chunkPtr->totalWidth = newX - curX;
- chunkPtr->displayWidth = newX - curX;
- layoutPtr->numChunks++;
-
- return chunkPtr;
-}
-
diff --git a/generic/tkFont.h b/generic/tkFont.h
deleted file mode 100644
index e2a7e04..0000000
--- a/generic/tkFont.h
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * tkFont.h --
- *
- * Declarations for interfaces between the generic and platform-
- * specific parts of the font package. This information is not
- * visible outside of the font package.
- *
- * Copyright (c) 1996 Sun Microsystems, Inc.
- *
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- *
- * RCS: @(#) $Id: tkFont.h,v 1.4 1998/09/14 18:23:10 stanton Exp $
- */
-
-#ifndef _TKFONT
-#define _TKFONT
-
-#ifdef BUILD_tk
-# undef TCL_STORAGE_CLASS
-# define TCL_STORAGE_CLASS DLLEXPORT
-#endif
-
-/*
- * The following structure keeps track of the attributes of a font. It can
- * be used to keep track of either the desired attributes or the actual
- * attributes gotten when the font was instantiated.
- */
-
-typedef struct TkFontAttributes {
- Tk_Uid family; /* Font family. The most important field. */
- int pointsize; /* Pointsize of font, 0 for default size, or
- * negative number meaning pixel size. */
- int weight; /* Weight flag; see below for def'n. */
- int slant; /* Slant flag; see below for def'n. */
- int underline; /* Non-zero for underline font. */
- int overstrike; /* Non-zero for overstrike font. */
-} TkFontAttributes;
-
-/*
- * Possible values for the "weight" field in a TkFontAttributes structure.
- * Weight is a subjective term and depends on what the company that created
- * the font considers bold.
- */
-
-#define TK_FW_NORMAL 0
-#define TK_FW_BOLD 1
-
-#define TK_FW_UNKNOWN -1 /* Unknown weight. This value is used for
- * error checking and is never actually stored
- * in the weight field. */
-
-/*
- * Possible values for the "slant" field in a TkFontAttributes structure.
- */
-
-#define TK_FS_ROMAN 0
-#define TK_FS_ITALIC 1
-#define TK_FS_OBLIQUE 2 /* This value is only used when parsing X
- * font names to determine the closest
- * match. It is only stored in the
- * XLFDAttributes structure, never in the
- * slant field of the TkFontAttributes. */
-
-#define TK_FS_UNKNOWN -1 /* Unknown slant. This value is used for
- * error checking and is never actually stored
- * in the slant field. */
-
-/*
- * The following structure keeps track of the metrics for an instantiated
- * font. The metrics are the physical properties of the font itself.
- */
-
-typedef struct TkFontMetrics {
- int ascent; /* From baseline to top of font. */
- int descent; /* From baseline to bottom of font. */
- int maxWidth; /* Width of widest character in font. */
- int fixed; /* Non-zero if this is a fixed-width font,
- * 0 otherwise. */
-} TkFontMetrics;
-
-/*
- * The following structure is used to keep track of the generic information
- * about a font. Each platform-specific font is represented by a structure
- * with the following structure at its beginning, plus any platform-
- * specific stuff after that.
- */
-
-typedef struct TkFont {
- /*
- * Fields used and maintained exclusively by generic code.
- */
-
- int refCount; /* Number of users of the TkFont. */
- Tcl_HashEntry *cacheHashPtr;/* Entry in font cache for this structure,
- * used when deleting it. */
- Tcl_HashEntry *namedHashPtr;/* Pointer to hash table entry that
- * corresponds to the named font that the
- * tkfont was based on, or NULL if the tkfont
- * was not based on a named font. */
- int tabWidth; /* Width of tabs in this font (pixels). */
- int underlinePos; /* Offset from baseline to origin of
- * underline bar (used for drawing underlines
- * on a non-underlined font). */
- int underlineHeight; /* Height of underline bar (used for drawing
- * underlines on a non-underlined font). */
-
- /*
- * Fields in the generic font structure that are filled in by
- * platform-specific code.
- */
-
- Font fid; /* For backwards compatibility with XGCValues
- * structures. Remove when TkGCValues is
- * implemented. */
- TkFontAttributes fa; /* Actual font attributes obtained when the
- * the font was created, as opposed to the
- * desired attributes passed in to
- * TkpGetFontFromAttributes(). The desired
- * metrics can be determined from the string
- * that was used to create this font. */
- TkFontMetrics fm; /* Font metrics determined when font was
- * created. */
-} TkFont;
-
-/*
- * The following structure is used to return attributes when parsing an
- * XLFD. The extra information is of interest to the Unix-specific code
- * when attempting to find the closest matching font.
- */
-
-typedef struct TkXLFDAttributes {
- TkFontAttributes fa; /* Standard set of font attributes. */
- Tk_Uid foundry; /* The foundry of the font. */
- int slant; /* The tristate value for the slant, which
- * is significant under X. */
- int setwidth; /* The proportionate width, see below for
- * definition. */
- int charset; /* The character set encoding (the glyph
- * family), see below for definition. */
- int encoding; /* Variations within a charset for the
- * glyphs above character 127. */
-} TkXLFDAttributes;
-
-/*
- * Possible values for the "setwidth" field in a TkXLFDAttributes structure.
- * The setwidth is whether characters are considered wider or narrower than
- * normal.
- */
-
-#define TK_SW_NORMAL 0
-#define TK_SW_CONDENSE 1
-#define TK_SW_EXPAND 2
-#define TK_SW_UNKNOWN 3 /* Unknown setwidth. This value may be
- * stored in the setwidth field. */
-
-/*
- * Possible values for the "charset" field in a TkXLFDAttributes structure.
- * The charset is the set of glyphs that are used in the font.
- */
-
-#define TK_CS_NORMAL 0
-#define TK_CS_SYMBOL 1
-#define TK_CS_OTHER 2
-
-/*
- * The following defines specify the meaning of the fields in a fully
- * qualified XLFD.
- */
-
-#define XLFD_FOUNDRY 0
-#define XLFD_FAMILY 1
-#define XLFD_WEIGHT 2
-#define XLFD_SLANT 3
-#define XLFD_SETWIDTH 4
-#define XLFD_ADD_STYLE 5
-#define XLFD_PIXEL_SIZE 6
-#define XLFD_POINT_SIZE 7
-#define XLFD_RESOLUTION_X 8
-#define XLFD_RESOLUTION_Y 9
-#define XLFD_SPACING 10
-#define XLFD_AVERAGE_WIDTH 11
-#define XLFD_REGISTRY 12
-#define XLFD_ENCODING 13
-#define XLFD_NUMFIELDS 14 /* Number of fields in XLFD. */
-
-/*
- * Exported from generic code to platform-specific code.
- */
-
-EXTERN int TkCreateNamedFont _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Window tkwin, CONST char *name,
- TkFontAttributes *faPtr));
-EXTERN void TkInitFontAttributes _ANSI_ARGS_((
- TkFontAttributes *faPtr));
-EXTERN int TkParseXLFD _ANSI_ARGS_((CONST char *string,
- TkXLFDAttributes *xaPtr));
-
-/*
- * Common APIs exported to tkFont.c from all platform-specific
- * implementations.
- */
-
-EXTERN void TkpDeleteFont _ANSI_ARGS_((TkFont *tkFontPtr));
-EXTERN TkFont * TkpGetFontFromAttributes _ANSI_ARGS_((
- TkFont *tkFontPtr, Tk_Window tkwin,
- CONST TkFontAttributes *faPtr));
-EXTERN void TkpGetFontFamilies _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Window tkwin));
-EXTERN TkFont * TkpGetNativeFont _ANSI_ARGS_((Tk_Window tkwin,
- CONST char *name));
-
-# undef TCL_STORAGE_CLASS
-# define TCL_STORAGE_CLASS DLLIMPORT
-
-#endif /* _TKFONT */
diff --git a/generic/tkFrame.c b/generic/tkFrame.c
deleted file mode 100644
index 18ce64f..0000000
--- a/generic/tkFrame.c
+++ /dev/null
@@ -1,939 +0,0 @@
-/*
- * tkFrame.c --
- *
- * This module implements "frame" 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.
- *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1995 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: tkFrame.c,v 1.2 1998/09/14 18:23:10 stanton Exp $
- */
-
-#include "default.h"
-#include "tkPort.h"
-#include "tkInt.h"
-
-/*
- * A data structure of the following type is kept for each
- * frame that currently exists for this process:
- */
-
-typedef struct {
- Tk_Window tkwin; /* Window that embodies the frame. NULL
- * means that the window has been destroyed
- * but the data structures haven't yet been
- * cleaned up. */
- Display *display; /* Display containing widget. Used, among
- * other things, so that resources can be
- * freed even after tkwin has gone away. */
- Tcl_Interp *interp; /* Interpreter associated with widget. Used
- * to delete widget command. */
- Tcl_Command widgetCmd; /* Token for frame's widget command. */
- 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. */
- char *screenName; /* Screen on which widget is created. Non-null
- * only for top-levels. Malloc-ed, may be
- * NULL. */
- char *visualName; /* Textual description of visual for window,
- * from -visual option. Malloc-ed, may be
- * NULL. */
- char *colormapName; /* Textual description of colormap for window,
- * from -colormap option. Malloc-ed, may be
- * NULL. */
- char *menuName; /* Textual description of menu to use for
- * menubar. Malloc-ed, may be NULL. */
- Colormap colormap; /* If not None, identifies a colormap
- * allocated for this window, which must be
- * freed when the window is deleted. */
- Tk_3DBorder border; /* Structure used to draw 3-D border and
- * background. NULL means no background
- * or border. */
- int borderWidth; /* Width of 3-D border (if any). */
- int relief; /* 3-d effect: TK_RELIEF_RAISED etc. */
- int highlightWidth; /* Width in pixels of highlight to draw
- * around widget when it has the focus.
- * 0 means don't draw a highlight. */
- XColor *highlightBgColorPtr;
- /* Color for drawing traversal highlight
- * area when highlight is off. */
- XColor *highlightColorPtr; /* Color for drawing traversal highlight. */
- int width; /* Width to request for window. <= 0 means
- * don't request any size. */
- int height; /* Height to request for window. <= 0 means
- * don't request any size. */
- Tk_Cursor cursor; /* Current cursor for window, or None. */
- char *takeFocus; /* Value of -takefocus option; not used in
- * the C code, but used by keyboard traversal
- * scripts. Malloc'ed, but may be NULL. */
- int isContainer; /* 1 means this window is a container, 0 means
- * that it isn't. */
- char *useThis; /* If the window is embedded, this points to
- * the name of the window in which it is
- * embedded (malloc'ed). For non-embedded
- * windows this is NULL. */
- int flags; /* Various flags; see below for
- * definitions. */
-} Frame;
-
-/*
- * Flag bits for frames:
- *
- * REDRAW_PENDING: Non-zero means a DoWhenIdle handler
- * has already been queued to redraw
- * this window.
- * GOT_FOCUS: Non-zero means this widget currently
- * has the input focus.
- */
-
-#define REDRAW_PENDING 1
-#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.
- */
-
-#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}
-};
-
-/*
- * Forward declarations for procedures defined later in this file:
- */
-
-static int ConfigureFrame _ANSI_ARGS_((Tcl_Interp *interp,
- Frame *framePtr, int argc, char **argv,
- int flags));
-static void DestroyFrame _ANSI_ARGS_((char *memPtr));
-static void DisplayFrame _ANSI_ARGS_((ClientData clientData));
-static void FrameCmdDeletedProc _ANSI_ARGS_((
- ClientData clientData));
-static void FrameEventProc _ANSI_ARGS_((ClientData clientData,
- XEvent *eventPtr));
-static int FrameWidgetCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-static void MapFrame _ANSI_ARGS_((ClientData clientData));
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_FrameCmd, Tk_ToplevelCmd --
- *
- * These procedures are invoked to process the "frame" and
- * "toplevel" 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.
- *
- *--------------------------------------------------------------
- */
-
-int
-Tk_FrameCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Main window associated with
- * interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- return TkCreateFrame(clientData, interp, argc, argv, 0, (char *) NULL);
-}
-
-int
-Tk_ToplevelCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Main window associated with
- * interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- return TkCreateFrame(clientData, interp, argc, argv, 1, (char *) NULL);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * TkFrameCreate --
- *
- * 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.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *--------------------------------------------------------------
- */
-
-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. */
- 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
- * new application. */
-{
- Tk_Window tkwin = (Tk_Window) clientData;
- Frame *framePtr;
- Tk_Window new;
- char *className, *screenName, *visualName, *colormapName, *arg, *useOption;
- int i, c, length, depth;
- unsigned int mask;
- Colormap colormap;
- Visual *visual;
-
- if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " pathName ?options?\"", (char *) NULL);
- return TCL_ERROR;
- }
-
- /*
- * Pre-process the argument list. Scan through it to find any
- * "-class", "-screen", "-visual", and "-colormap" options. These
- * arguments need to be processed specially, before the window
- * is configured using the usual Tk mechanisms.
- */
-
- className = colormapName = screenName = visualName = useOption = NULL;
- colormap = None;
- for (i = 2; i < argc; i += 2) {
- arg = argv[i];
- length = strlen(arg);
- if (length < 2) {
- continue;
- }
- c = arg[1];
- if ((c == 'c') && (strncmp(arg, "-class", strlen(arg)) == 0)
- && (length >= 3)) {
- className = argv[i+1];
- } else if ((c == 'c')
- && (strncmp(arg, "-colormap", strlen(arg)) == 0)) {
- colormapName = argv[i+1];
- } else if ((c == 's') && toplevel
- && (strncmp(arg, "-screen", strlen(arg)) == 0)) {
- screenName = argv[i+1];
- } else if ((c == 'u') && toplevel
- && (strncmp(arg, "-use", strlen(arg)) == 0)) {
- useOption = argv[i+1];
- } else if ((c == 'v')
- && (strncmp(arg, "-visual", strlen(arg)) == 0)) {
- visualName = argv[i+1];
- }
- }
-
- /*
- * Create the window, and deal with the special options -use,
- * -classname, -colormap, -screenname, and -visual. These options
- * must be handle before calling ConfigureFrame below, and they must
- * also be processed in a particular order, for the following
- * reasons:
- * 1. Must set the window's class before calling ConfigureFrame,
- * so that unspecified options are looked up in the option
- * database using the correct class.
- * 2. Must set visual information before calling ConfigureFrame
- * so that colors are allocated in a proper colormap.
- * 3. Must call TkpUseWindow before setting non-default visual
- * information, since TkpUseWindow changes the defaults.
- */
-
- if (screenName == NULL) {
- screenName = (toplevel) ? "" : NULL;
- }
- if (tkwin != NULL) {
- new = Tk_CreateWindowFromPath(interp, tkwin, argv[1], screenName);
- } else {
- /*
- * We were called from Tk_Init; create a new application.
- */
-
- if (appName == NULL) {
- panic("TkCreateFrame didn't get application name");
- }
- new = TkCreateMainWindow(interp, screenName, appName);
- }
- if (new == NULL) {
- goto error;
- }
- if (className == NULL) {
- className = Tk_GetOption(new, "class", "Class");
- if (className == NULL) {
- className = (toplevel) ? "Toplevel" : "Frame";
- }
- }
- Tk_SetClass(new, className);
- if (useOption == NULL) {
- useOption = Tk_GetOption(new, "use", "Use");
- }
- if (useOption != NULL) {
- if (TkpUseWindow(interp, new, useOption) != TCL_OK) {
- goto error;
- }
- }
- if (visualName == NULL) {
- visualName = Tk_GetOption(new, "visual", "Visual");
- }
- if (colormapName == NULL) {
- colormapName = Tk_GetOption(new, "colormap", "Colormap");
- }
- if (visualName != NULL) {
- visual = Tk_GetVisual(interp, new, visualName, &depth,
- (colormapName == NULL) ? &colormap : (Colormap *) NULL);
- if (visual == NULL) {
- goto error;
- }
- Tk_SetWindowVisual(new, visual, depth, colormap);
- }
- if (colormapName != NULL) {
- colormap = Tk_GetColormap(interp, new, colormapName);
- if (colormap == None) {
- goto error;
- }
- Tk_SetWindowColormap(new, colormap);
- }
-
- /*
- * For top-level windows, provide an initial geometry request of
- * 200x200, just so the window looks nicer on the screen if it
- * doesn't request a size for itself.
- */
-
- if (toplevel) {
- Tk_GeometryRequest(new, 200, 200);
- }
-
- /*
- * Create the widget record, process configuration options, and
- * create event handlers. Then fill in a few additional fields
- * in the widget record from the special options.
- */
-
- framePtr = (Frame *) ckalloc(sizeof(Frame));
- framePtr->tkwin = new;
- framePtr->display = Tk_Display(new);
- framePtr->interp = interp;
- framePtr->widgetCmd = Tcl_CreateCommand(interp,
- Tk_PathName(new), FrameWidgetCmd,
- (ClientData) framePtr, FrameCmdDeletedProc);
- framePtr->className = NULL;
- framePtr->mask = (toplevel) ? TOPLEVEL : FRAME;
- framePtr->screenName = NULL;
- framePtr->visualName = NULL;
- framePtr->colormapName = NULL;
- 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;
-
- /*
- * Store backreference to frame widget in window structure.
- */
- TkSetClassProcs(new, NULL, (ClientData) framePtr);
-
- mask = ExposureMask | StructureNotifyMask | FocusChangeMask;
- if (toplevel) {
- mask |= ActivateMask;
- }
- Tk_CreateEventHandler(new, mask, FrameEventProc, (ClientData) framePtr);
- if (ConfigureFrame(interp, framePtr, argc-2, argv+2, 0) != 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;
- }
- }
- if (toplevel) {
- Tcl_DoWhenIdle(MapFrame, (ClientData) framePtr);
- }
- interp->result = Tk_PathName(new);
- return TCL_OK;
-
- error:
- if (new != NULL) {
- Tk_DestroyWindow(new);
- }
- return TCL_ERROR;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * FrameWidgetCmd --
- *
- * This procedure is invoked to process the Tcl command
- * that corresponds to a frame widget. See the user
- * documentation for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *--------------------------------------------------------------
- */
-
-static int
-FrameWidgetCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Information about frame widget. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- register Frame *framePtr = (Frame *) clientData;
- int result;
- size_t length;
- int c, i;
-
- if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " option ?arg arg ...?\"", (char *) NULL);
- return TCL_ERROR;
- }
- Tcl_Preserve((ClientData) framePtr);
- 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);
- result = TCL_ERROR;
- goto done;
- }
- result = Tk_ConfigureValue(interp, framePtr->tkwin, configSpecs,
- (char *) framePtr, argv[2], framePtr->mask);
- } else if ((c == 'c') && (strncmp(argv[1], "configure", length) == 0)
- && (length >= 2)) {
- if (argc == 2) {
- result = Tk_ConfigureInfo(interp, framePtr->tkwin, configSpecs,
- (char *) framePtr, (char *) NULL, framePtr->mask);
- } else if (argc == 3) {
- result = Tk_ConfigureInfo(interp, framePtr->tkwin, configSpecs,
- (char *) framePtr, argv[2], framePtr->mask);
- } else {
- /*
- * Don't allow the options -class, -colormap, -container,
- * -newcmap, -screen, -use, or -visual to be changed.
- */
-
- for (i = 2; i < argc; i++) {
- length = strlen(argv[i]);
- if (length < 2) {
- continue;
- }
- c = argv[i][1];
- if (((c == 'c') && (strncmp(argv[i], "-class", length) == 0)
- && (length >= 2))
- || ((c == 'c') && (framePtr->mask == TOPLEVEL)
- && (strncmp(argv[i], "-colormap", length) == 0)
- && (length >= 3))
- || ((c == 'c')
- && (strncmp(argv[i], "-container", length) == 0)
- && (length >= 3))
- || ((c == 's') && (framePtr->mask == TOPLEVEL)
- && (strncmp(argv[i], "-screen", length) == 0))
- || ((c == 'u') && (framePtr->mask == TOPLEVEL)
- && (strncmp(argv[i], "-use", length) == 0))
- || ((c == 'v') && (framePtr->mask == TOPLEVEL)
- && (strncmp(argv[i], "-visual", length) == 0))) {
- Tcl_AppendResult(interp, "can't modify ", argv[i],
- " option after widget is created", (char *) NULL);
- result = TCL_ERROR;
- goto done;
- }
- }
- result = ConfigureFrame(interp, framePtr, argc-2, argv+2,
- TK_CONFIG_ARGV_ONLY);
- }
- } else {
- Tcl_AppendResult(interp, "bad option \"", argv[1],
- "\": must be cget or configure", (char *) NULL);
- result = TCL_ERROR;
- }
-
- done:
- Tcl_Release((ClientData) framePtr);
- return result;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * DestroyFrame --
- *
- * This procedure is invoked by Tcl_EventuallyFree or Tcl_Release
- * to clean up the internal structure of a frame at a safe time
- * (when no-one is using it anymore).
- *
- * Results:
- * None.
- *
- * Side effects:
- * Everything associated with the frame is freed up.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-DestroyFrame(memPtr)
- char *memPtr; /* Info about frame widget. */
-{
- register Frame *framePtr = (Frame *) memPtr;
-
- Tk_FreeOptions(configSpecs, (char *) framePtr, framePtr->display,
- framePtr->mask);
- if (framePtr->colormap != None) {
- Tk_FreeColormap(framePtr->display, framePtr->colormap);
- }
- ckfree((char *) framePtr);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ConfigureFrame --
- *
- * This procedure is called to process an argv/argc list, plus
- * the Tk option database, in order to configure (or
- * reconfigure) a frame widget.
- *
- * Results:
- * The return value is a standard Tcl result. If TCL_ERROR is
- * returned, then interp->result contains an error message.
- *
- * Side effects:
- * Configuration information, such as text string, colors, font,
- * etc. get set for framePtr; old resources get freed, if there
- * were any.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-ConfigureFrame(interp, framePtr, argc, argv, flags)
- Tcl_Interp *interp; /* Used for error reporting. */
- register Frame *framePtr; /* 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 flags; /* Flags to pass to Tk_ConfigureWidget. */
-{
- char *oldMenuName;
-
- /*
- * Need the old menubar name for the menu code to delete it.
- */
-
- if (framePtr->menuName == NULL) {
- oldMenuName = NULL;
- } else {
- oldMenuName = ckalloc(strlen(framePtr->menuName) + 1);
- strcpy(oldMenuName, framePtr->menuName);
- }
-
- if (Tk_ConfigureWidget(interp, framePtr->tkwin, configSpecs,
- argc, argv, (char *) framePtr, flags | framePtr->mask) != TCL_OK) {
- return TCL_ERROR;
- }
-
- if (((oldMenuName == NULL) && (framePtr->menuName != NULL))
- || ((oldMenuName != NULL) && (framePtr->menuName == NULL))
- || ((oldMenuName != NULL) && (framePtr->menuName != NULL)
- && strcmp(oldMenuName, framePtr->menuName) != 0)) {
- TkSetWindowMenuBar(interp, framePtr->tkwin, oldMenuName,
- framePtr->menuName);
- }
-
- if (framePtr->border != NULL) {
- Tk_SetBackgroundFromBorder(framePtr->tkwin, framePtr->border);
- } else {
- Tk_SetWindowBackgroundPixmap(framePtr->tkwin, None);
- }
-
- 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 (oldMenuName != NULL) {
- ckfree(oldMenuName);
- }
-
- if (Tk_IsMapped(framePtr->tkwin)) {
- if (!(framePtr->flags & REDRAW_PENDING)) {
- Tcl_DoWhenIdle(DisplayFrame, (ClientData) framePtr);
- }
- framePtr->flags |= REDRAW_PENDING;
- }
- return TCL_OK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * DisplayFrame --
- *
- * This procedure is invoked to display a frame widget.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Commands are output to X to display the frame in its
- * current mode.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-DisplayFrame(clientData)
- ClientData clientData; /* Information about widget. */
-{
- register Frame *framePtr = (Frame *) clientData;
- register Tk_Window tkwin = framePtr->tkwin;
- GC gc;
-
- framePtr->flags &= ~REDRAW_PENDING;
- if ((framePtr->tkwin == NULL) || !Tk_IsMapped(tkwin)
- || framePtr->isContainer) {
- return;
- }
-
- if (framePtr->border != NULL) {
- Tk_Fill3DRectangle(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) {
- if (framePtr->flags & GOT_FOCUS) {
- gc = Tk_GCForColor(framePtr->highlightColorPtr,
- Tk_WindowId(tkwin));
- } else {
- gc = Tk_GCForColor(framePtr->highlightBgColorPtr,
- Tk_WindowId(tkwin));
- }
- Tk_DrawFocusHighlight(tkwin, gc, framePtr->highlightWidth,
- Tk_WindowId(tkwin));
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * FrameEventProc --
- *
- * This procedure is invoked by the Tk dispatcher on
- * structure changes to a frame. For frames with 3D
- * borders, this procedure is also invoked for exposures.
- *
- * Results:
- * None.
- *
- * Side effects:
- * When the window gets deleted, internal structures get
- * cleaned up. When it gets exposed, it is redisplayed.
- *
- *--------------------------------------------------------------
- */
-
-static void
-FrameEventProc(clientData, eventPtr)
- ClientData clientData; /* Information about window. */
- register XEvent *eventPtr; /* Information about event. */
-{
- register Frame *framePtr = (Frame *) clientData;
-
- if (((eventPtr->type == Expose) && (eventPtr->xexpose.count == 0))
- || (eventPtr->type == ConfigureNotify)) {
- goto redraw;
- } else if (eventPtr->type == DestroyNotify) {
- if (framePtr->menuName != NULL) {
- TkSetWindowMenuBar(framePtr->interp, framePtr->tkwin,
- framePtr->menuName, NULL);
- ckfree(framePtr->menuName);
- framePtr->menuName = NULL;
- }
- if (framePtr->tkwin != NULL) {
-
- /*
- * If this window is a container, then this event could be
- * coming from the embedded application, in which case
- * Tk_DestroyWindow hasn't been called yet. When Tk_DestroyWindow
- * is called later, then another destroy event will be generated.
- * We need to be sure we ignore the second event, since the frame
- * could be gone by then. To do so, delete the event handler
- * explicitly (normally it's done implicitly by Tk_DestroyWindow).
- */
-
- Tk_DeleteEventHandler(framePtr->tkwin,
- ExposureMask|StructureNotifyMask|FocusChangeMask,
- FrameEventProc, (ClientData) framePtr);
- framePtr->tkwin = NULL;
- Tcl_DeleteCommandFromToken(framePtr->interp, framePtr->widgetCmd);
- }
- if (framePtr->flags & REDRAW_PENDING) {
- Tcl_CancelIdleCall(DisplayFrame, (ClientData) framePtr);
- }
- Tcl_CancelIdleCall(MapFrame, (ClientData) framePtr);
- Tcl_EventuallyFree((ClientData) framePtr, DestroyFrame);
- } else if (eventPtr->type == FocusIn) {
- if (eventPtr->xfocus.detail != NotifyInferior) {
- framePtr->flags |= GOT_FOCUS;
- if (framePtr->highlightWidth > 0) {
- goto redraw;
- }
- }
- } else if (eventPtr->type == FocusOut) {
- if (eventPtr->xfocus.detail != NotifyInferior) {
- framePtr->flags &= ~GOT_FOCUS;
- if (framePtr->highlightWidth > 0) {
- goto redraw;
- }
- }
- } else if (eventPtr->type == ActivateNotify) {
- TkpSetMainMenubar(framePtr->interp, framePtr->tkwin,
- framePtr->menuName);
- }
- return;
-
- redraw:
- if ((framePtr->tkwin != NULL) && !(framePtr->flags & REDRAW_PENDING)) {
- Tcl_DoWhenIdle(DisplayFrame, (ClientData) framePtr);
- framePtr->flags |= REDRAW_PENDING;
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * FrameCmdDeletedProc --
- *
- * 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
-FrameCmdDeletedProc(clientData)
- ClientData clientData; /* Pointer to widget record for widget. */
-{
- Frame *framePtr = (Frame *) clientData;
- Tk_Window tkwin = framePtr->tkwin;
-
- if (framePtr->menuName != NULL) {
- TkSetWindowMenuBar(framePtr->interp, framePtr->tkwin,
- framePtr->menuName, NULL);
- ckfree(framePtr->menuName);
- framePtr->menuName = NULL;
- }
-
- /*
- * This procedure could be invoked either because the window was
- * destroyed and the command was then deleted (in which case tkwin
- * is NULL) or because the command was deleted, and then this procedure
- * destroys the widget.
- */
-
- if (tkwin != NULL) {
- framePtr->tkwin = NULL;
- Tk_DestroyWindow(tkwin);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * MapFrame --
- *
- * This procedure is invoked as a when-idle handler to map a
- * newly-created top-level frame.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The frame given by the clientData argument is mapped.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-MapFrame(clientData)
- ClientData clientData; /* Pointer to frame structure. */
-{
- Frame *framePtr = (Frame *) clientData;
-
- /*
- * Wait for all other background events to be processed before
- * mapping window. This ensures that the window's correct geometry
- * will have been determined before it is first mapped, so that the
- * window manager doesn't get a false idea of its desired geometry.
- */
-
- Tcl_Preserve((ClientData) framePtr);
- while (1) {
- if (Tcl_DoOneEvent(TCL_IDLE_EVENTS) == 0) {
- break;
- }
-
- /*
- * After each event, make sure that the window still exists
- * and quit if the window has been destroyed.
- */
-
- if (framePtr->tkwin == NULL) {
- Tcl_Release((ClientData) framePtr);
- return;
- }
- }
- Tk_MapWindow(framePtr->tkwin);
- Tcl_Release((ClientData) framePtr);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * TkInstallFrameMenu --
- *
- * This function is needed when a Windows HWND is created
- * and a menubar has been set to the window with a system
- * menu. It notifies the menu package so that the system
- * menu can be rebuilt.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The system menu (if any) is created for the menubar
- * associated with this frame.
- *
- *--------------------------------------------------------------
- */
-
-void
-TkInstallFrameMenu(tkwin)
- Tk_Window tkwin; /* The window that was just created. */
-{
- TkWindow *winPtr = (TkWindow *) tkwin;
-
- if (winPtr->mainPtr != NULL) {
- Frame *framePtr;
- framePtr = (Frame*) winPtr->instanceData;
- TkpMenuNotifyToplevelCreate(winPtr->mainPtr->interp,
- framePtr->menuName);
- }
-}
diff --git a/generic/tkGC.c b/generic/tkGC.c
deleted file mode 100644
index dd53e32..0000000
--- a/generic/tkGC.c
+++ /dev/null
@@ -1,363 +0,0 @@
-/*
- * tkGC.c --
- *
- * This file maintains a database of read-only graphics contexts
- * for the Tk toolkit, in order to allow GC's to be shared.
- *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994 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: tkGC.c,v 1.2 1998/09/14 18:23:11 stanton Exp $
- */
-
-#include "tkPort.h"
-#include "tk.h"
-
-/*
- * One of the following data structures exists for each GC that is
- * currently active. The structure is indexed with two hash tables,
- * one based on the values in the graphics context and the other
- * based on the display and GC identifier.
- */
-
-typedef struct {
- GC gc; /* Graphics context. */
- Display *display; /* Display to which gc belongs. */
- int refCount; /* Number of active uses of gc. */
- Tcl_HashEntry *valueHashPtr;/* Entry in valueTable (needed when deleting
- * this structure). */
-} TkGC;
-
-/*
- * Hash table to map from a GC's values to a TkGC structure describing
- * a GC with those values (used by Tk_GetGC).
- */
-
-static Tcl_HashTable valueTable;
-typedef struct {
- XGCValues values; /* Desired values for GC. */
- Display *display; /* Display for which GC is valid. */
- int screenNum; /* screen number of display */
- int depth; /* and depth for which GC is valid. */
-} ValueKey;
-
-/*
- * Hash table for <display + GC> -> TkGC mapping. This table is used by
- * Tk_FreeGC.
- */
-
-static Tcl_HashTable idTable;
-typedef struct {
- Display *display; /* Display for which GC was allocated. */
- GC gc; /* X's identifier for GC. */
-} IdKey;
-
-static int initialized = 0; /* 0 means static structures haven't been
- * initialized yet. */
-
-/*
- * Forward declarations for procedures defined in this file:
- */
-
-static void GCInit _ANSI_ARGS_((void));
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_GetGC --
- *
- * Given a desired set of values for a graphics context, find
- * a read-only graphics context with the desired values.
- *
- * Results:
- * The return value is the X identifer for the desired graphics
- * context. The caller should never modify this GC, and should
- * call Tk_FreeGC when the GC is no longer needed.
- *
- * Side effects:
- * The GC is added to an internal database with a reference count.
- * For each call to this procedure, there should eventually be a call
- * to Tk_FreeGC, so that the database can be cleaned up when GC's
- * aren't needed anymore.
- *
- *----------------------------------------------------------------------
- */
-
-GC
-Tk_GetGC(tkwin, valueMask, valuePtr)
- Tk_Window tkwin; /* Window in which GC will be used. */
- register unsigned long valueMask;
- /* 1 bits correspond to values specified
- * in *valuesPtr; other values are set
- * from defaults. */
- register XGCValues *valuePtr;
- /* Values are specified here for bits set
- * in valueMask. */
-{
- ValueKey valueKey;
- IdKey idKey;
- Tcl_HashEntry *valueHashPtr, *idHashPtr;
- register TkGC *gcPtr;
- int new;
- Drawable d, freeDrawable;
-
- if (!initialized) {
- GCInit();
- }
-
- /*
- * Must zero valueKey at start to clear out pad bytes that may be
- * part of structure on some systems.
- */
-
- memset((VOID *) &valueKey, 0, sizeof(valueKey));
-
- /*
- * First, check to see if there's already a GC that will work
- * for this request (exact matches only, sorry).
- */
-
- if (valueMask & GCFunction) {
- valueKey.values.function = valuePtr->function;
- } else {
- valueKey.values.function = GXcopy;
- }
- if (valueMask & GCPlaneMask) {
- valueKey.values.plane_mask = valuePtr->plane_mask;
- } else {
- valueKey.values.plane_mask = (unsigned) ~0;
- }
- if (valueMask & GCForeground) {
- valueKey.values.foreground = valuePtr->foreground;
- } else {
- valueKey.values.foreground = 0;
- }
- if (valueMask & GCBackground) {
- valueKey.values.background = valuePtr->background;
- } else {
- valueKey.values.background = 1;
- }
- if (valueMask & GCLineWidth) {
- valueKey.values.line_width = valuePtr->line_width;
- } else {
- valueKey.values.line_width = 0;
- }
- if (valueMask & GCLineStyle) {
- valueKey.values.line_style = valuePtr->line_style;
- } else {
- valueKey.values.line_style = LineSolid;
- }
- if (valueMask & GCCapStyle) {
- valueKey.values.cap_style = valuePtr->cap_style;
- } else {
- valueKey.values.cap_style = CapButt;
- }
- if (valueMask & GCJoinStyle) {
- valueKey.values.join_style = valuePtr->join_style;
- } else {
- valueKey.values.join_style = JoinMiter;
- }
- if (valueMask & GCFillStyle) {
- valueKey.values.fill_style = valuePtr->fill_style;
- } else {
- valueKey.values.fill_style = FillSolid;
- }
- if (valueMask & GCFillRule) {
- valueKey.values.fill_rule = valuePtr->fill_rule;
- } else {
- valueKey.values.fill_rule = EvenOddRule;
- }
- if (valueMask & GCArcMode) {
- valueKey.values.arc_mode = valuePtr->arc_mode;
- } else {
- valueKey.values.arc_mode = ArcPieSlice;
- }
- if (valueMask & GCTile) {
- valueKey.values.tile = valuePtr->tile;
- } else {
- valueKey.values.tile = None;
- }
- if (valueMask & GCStipple) {
- valueKey.values.stipple = valuePtr->stipple;
- } else {
- valueKey.values.stipple = None;
- }
- if (valueMask & GCTileStipXOrigin) {
- valueKey.values.ts_x_origin = valuePtr->ts_x_origin;
- } else {
- valueKey.values.ts_x_origin = 0;
- }
- if (valueMask & GCTileStipYOrigin) {
- valueKey.values.ts_y_origin = valuePtr->ts_y_origin;
- } else {
- valueKey.values.ts_y_origin = 0;
- }
- if (valueMask & GCFont) {
- valueKey.values.font = valuePtr->font;
- } else {
- valueKey.values.font = None;
- }
- if (valueMask & GCSubwindowMode) {
- valueKey.values.subwindow_mode = valuePtr->subwindow_mode;
- } else {
- valueKey.values.subwindow_mode = ClipByChildren;
- }
- if (valueMask & GCGraphicsExposures) {
- valueKey.values.graphics_exposures = valuePtr->graphics_exposures;
- } else {
- valueKey.values.graphics_exposures = True;
- }
- if (valueMask & GCClipXOrigin) {
- valueKey.values.clip_x_origin = valuePtr->clip_x_origin;
- } else {
- valueKey.values.clip_x_origin = 0;
- }
- if (valueMask & GCClipYOrigin) {
- valueKey.values.clip_y_origin = valuePtr->clip_y_origin;
- } else {
- valueKey.values.clip_y_origin = 0;
- }
- if (valueMask & GCClipMask) {
- valueKey.values.clip_mask = valuePtr->clip_mask;
- } else {
- valueKey.values.clip_mask = None;
- }
- if (valueMask & GCDashOffset) {
- valueKey.values.dash_offset = valuePtr->dash_offset;
- } else {
- valueKey.values.dash_offset = 0;
- }
- if (valueMask & GCDashList) {
- valueKey.values.dashes = valuePtr->dashes;
- } else {
- valueKey.values.dashes = 4;
- }
- valueKey.display = Tk_Display(tkwin);
- valueKey.screenNum = Tk_ScreenNumber(tkwin);
- valueKey.depth = Tk_Depth(tkwin);
- valueHashPtr = Tcl_CreateHashEntry(&valueTable, (char *) &valueKey, &new);
- if (!new) {
- gcPtr = (TkGC *) Tcl_GetHashValue(valueHashPtr);
- gcPtr->refCount++;
- return gcPtr->gc;
- }
-
- /*
- * No GC is currently available for this set of values. Allocate a
- * new GC and add a new structure to the database.
- */
-
- gcPtr = (TkGC *) ckalloc(sizeof(TkGC));
-
- /*
- * Find or make a drawable to use to specify the screen and depth
- * of the GC. We may have to make a small pixmap, to avoid doing
- * Tk_MakeWindowExist on the window.
- */
-
- freeDrawable = None;
- if (Tk_WindowId(tkwin) != None) {
- d = Tk_WindowId(tkwin);
- } else if (valueKey.depth ==
- DefaultDepth(valueKey.display, valueKey.screenNum)) {
- d = RootWindow(valueKey.display, valueKey.screenNum);
- } else {
- d = Tk_GetPixmap(valueKey.display,
- RootWindow(valueKey.display, valueKey.screenNum),
- 1, 1, valueKey.depth);
- freeDrawable = d;
- }
-
- gcPtr->gc = XCreateGC(valueKey.display, d, valueMask, &valueKey.values);
- gcPtr->display = valueKey.display;
- gcPtr->refCount = 1;
- gcPtr->valueHashPtr = valueHashPtr;
- idKey.display = valueKey.display;
- idKey.gc = gcPtr->gc;
- idHashPtr = Tcl_CreateHashEntry(&idTable, (char *) &idKey, &new);
- if (!new) {
- panic("GC already registered in Tk_GetGC");
- }
- Tcl_SetHashValue(valueHashPtr, gcPtr);
- Tcl_SetHashValue(idHashPtr, gcPtr);
- if (freeDrawable != None) {
- Tk_FreePixmap(valueKey.display, freeDrawable);
- }
-
- return gcPtr->gc;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_FreeGC --
- *
- * This procedure is called to release a graphics context allocated by
- * Tk_GetGC.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The reference count associated with gc is decremented, and
- * gc is officially deallocated if no-one is using it anymore.
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tk_FreeGC(display, gc)
- Display *display; /* Display for which gc was allocated. */
- GC gc; /* Graphics context to be released. */
-{
- IdKey idKey;
- Tcl_HashEntry *idHashPtr;
- register TkGC *gcPtr;
-
- if (!initialized) {
- panic("Tk_FreeGC called before Tk_GetGC");
- }
-
- idKey.display = display;
- idKey.gc = gc;
- idHashPtr = Tcl_FindHashEntry(&idTable, (char *) &idKey);
- if (idHashPtr == NULL) {
- panic("Tk_FreeGC received unknown gc argument");
- }
- gcPtr = (TkGC *) Tcl_GetHashValue(idHashPtr);
- gcPtr->refCount--;
- if (gcPtr->refCount == 0) {
- Tk_FreeXId(gcPtr->display, (XID) XGContextFromGC(gcPtr->gc));
- XFreeGC(gcPtr->display, gcPtr->gc);
- Tcl_DeleteHashEntry(gcPtr->valueHashPtr);
- Tcl_DeleteHashEntry(idHashPtr);
- ckfree((char *) gcPtr);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * GCInit --
- *
- * Initialize the structures used for GC management.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Read the code.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-GCInit()
-{
- initialized = 1;
- Tcl_InitHashTable(&valueTable, sizeof(ValueKey)/sizeof(int));
- Tcl_InitHashTable(&idTable, sizeof(IdKey)/sizeof(int));
-}
diff --git a/generic/tkGeometry.c b/generic/tkGeometry.c
deleted file mode 100644
index 64f0b26..0000000
--- a/generic/tkGeometry.c
+++ /dev/null
@@ -1,582 +0,0 @@
-/*
- * tkGeometry.c --
- *
- * This file contains generic Tk code for geometry management
- * (stuff that's used by all geometry managers).
- *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1995 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: tkGeometry.c,v 1.2 1998/09/14 18:23:11 stanton Exp $
- */
-
-#include "tkPort.h"
-#include "tkInt.h"
-
-/*
- * Data structures of the following type are used by Tk_MaintainGeometry.
- * For each slave managed by Tk_MaintainGeometry, there is one of these
- * structures associated with its master.
- */
-
-typedef struct MaintainSlave {
- Tk_Window slave; /* The slave window being positioned. */
- Tk_Window master; /* The master that determines slave's
- * position; it must be a descendant of
- * slave's parent. */
- int x, y; /* Desired position of slave relative to
- * master. */
- int width, height; /* Desired dimensions of slave. */
- struct MaintainSlave *nextPtr;
- /* Next in list of Maintains associated
- * with master. */
-} MaintainSlave;
-
-/*
- * For each window that has been specified as a master to
- * Tk_MaintainGeometry, there is a structure of the following type:
- */
-
-typedef struct MaintainMaster {
- Tk_Window ancestor; /* The lowest ancestor of this window
- * for which we have *not* created a
- * StructureNotify handler. May be the
- * same as the window itself. */
- int checkScheduled; /* Non-zero means that there is already a
- * call to MaintainCheckProc scheduled as
- * an idle handler. */
- MaintainSlave *slavePtr; /* First in list of all slaves associated
- * with this master. */
-} MaintainMaster;
-
-/*
- * Hash table that maps from a master's Tk_Window token to a list of
- * Maintains for that master:
- */
-
-static Tcl_HashTable maintainHashTable;
-
-/*
- * Has maintainHashTable been initialized yet?
- */
-
-static int initialized = 0;
-
-/*
- * Prototypes for static procedures in this file:
- */
-
-static void MaintainCheckProc _ANSI_ARGS_((ClientData clientData));
-static void MaintainMasterProc _ANSI_ARGS_((ClientData clientData,
- XEvent *eventPtr));
-static void MaintainSlaveProc _ANSI_ARGS_((ClientData clientData,
- XEvent *eventPtr));
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_ManageGeometry --
- *
- * Arrange for a particular procedure to manage the geometry
- * of a given slave window.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Proc becomes the new geometry manager for tkwin, replacing
- * any previous geometry manager. The geometry manager will
- * be notified (by calling procedures in *mgrPtr) when interesting
- * things happen in the future. If there was an existing geometry
- * manager for tkwin different from the new one, it is notified
- * by calling its lostSlaveProc.
- *
- *--------------------------------------------------------------
- */
-
-void
-Tk_ManageGeometry(tkwin, mgrPtr, clientData)
- Tk_Window tkwin; /* Window whose geometry is to
- * be managed by proc. */
- Tk_GeomMgr *mgrPtr; /* Static structure describing the
- * geometry manager. This structure
- * must never go away. */
- ClientData clientData; /* Arbitrary one-word argument to
- * pass to geometry manager procedures. */
-{
- register TkWindow *winPtr = (TkWindow *) tkwin;
-
- if ((winPtr->geomMgrPtr != NULL) && (mgrPtr != NULL)
- && ((winPtr->geomMgrPtr != mgrPtr)
- || (winPtr->geomData != clientData))
- && (winPtr->geomMgrPtr->lostSlaveProc != NULL)) {
- (*winPtr->geomMgrPtr->lostSlaveProc)(winPtr->geomData, tkwin);
- }
-
- winPtr->geomMgrPtr = mgrPtr;
- winPtr->geomData = clientData;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_GeometryRequest --
- *
- * This procedure is invoked by widget code to indicate
- * its preferences about the size of a window it manages.
- * In general, widget code should call this procedure
- * rather than Tk_ResizeWindow.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The geometry manager for tkwin (if any) is invoked to
- * handle the request. If possible, it will reconfigure
- * tkwin and/or other windows to satisfy the request. The
- * caller gets no indication of success or failure, but it
- * will get X events if the window size was actually
- * changed.
- *
- *--------------------------------------------------------------
- */
-
-void
-Tk_GeometryRequest(tkwin, reqWidth, reqHeight)
- Tk_Window tkwin; /* Window that geometry information
- * pertains to. */
- int reqWidth, reqHeight; /* Minimum desired dimensions for
- * window, in pixels. */
-{
- register TkWindow *winPtr = (TkWindow *) tkwin;
-
- /*
- * X gets very upset if a window requests a width or height of
- * zero, so rounds requested sizes up to at least 1.
- */
-
- if (reqWidth <= 0) {
- reqWidth = 1;
- }
- if (reqHeight <= 0) {
- reqHeight = 1;
- }
- if ((reqWidth == winPtr->reqWidth) && (reqHeight == winPtr->reqHeight)) {
- return;
- }
- winPtr->reqWidth = reqWidth;
- winPtr->reqHeight = reqHeight;
- if ((winPtr->geomMgrPtr != NULL)
- && (winPtr->geomMgrPtr->requestProc != NULL)) {
- (*winPtr->geomMgrPtr->requestProc)(winPtr->geomData, tkwin);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_SetInternalBorder --
- *
- * 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 width is recorded for the window, and all geometry
- * managers of all children are notified so that can re-layout, if
- * necessary.
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tk_SetInternalBorder(tkwin, width)
- Tk_Window tkwin; /* Window that will have internal border. */
- int width; /* Width of internal border, in pixels. */
-{
- register TkWindow *winPtr = (TkWindow *) tkwin;
-
- if (width == winPtr->internalBorderWidth) {
- return;
- }
- if (width < 0) {
- width = 0;
- }
- winPtr->internalBorderWidth = width;
-
- /*
- * 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.
- */
-
- Tk_ResizeWindow(tkwin, Tk_Width(tkwin), Tk_Height(tkwin));
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_MaintainGeometry --
- *
- * This procedure is invoked by geometry managers to handle slaves
- * whose master's are not their parents. It translates the desired
- * geometry for the slave into the coordinate system of the parent
- * and respositions the slave if it isn't already at the right place.
- * Furthermore, it sets up event handlers so that if the master (or
- * any of its ancestors up to the slave's parent) is mapped, unmapped,
- * or moved, then the slave will be adjusted to match.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Event handlers are created and state is allocated to keep track
- * of slave. Note: if slave was already managed for master by
- * Tk_MaintainGeometry, then the previous information is replaced
- * with the new information. The caller must eventually call
- * Tk_UnmaintainGeometry to eliminate the correspondence (or, the
- * state is automatically freed when either window is destroyed).
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tk_MaintainGeometry(slave, master, x, y, width, height)
- Tk_Window slave; /* Slave for geometry management. */
- Tk_Window master; /* Master for slave; must be a descendant
- * of slave's parent. */
- int x, y; /* Desired position of slave within master. */
- int width, height; /* Desired dimensions for slave. */
-{
- Tcl_HashEntry *hPtr;
- MaintainMaster *masterPtr;
- register MaintainSlave *slavePtr;
- int new, map;
- Tk_Window ancestor, parent;
-
- if (!initialized) {
- initialized = 1;
- Tcl_InitHashTable(&maintainHashTable, TCL_ONE_WORD_KEYS);
- }
-
- /*
- * See if there is already a MaintainMaster structure for the master;
- * if not, then create one.
- */
-
- parent = Tk_Parent(slave);
- hPtr = Tcl_CreateHashEntry(&maintainHashTable, (char *) master, &new);
- if (!new) {
- masterPtr = (MaintainMaster *) Tcl_GetHashValue(hPtr);
- } else {
- masterPtr = (MaintainMaster *) ckalloc(sizeof(MaintainMaster));
- masterPtr->ancestor = master;
- masterPtr->checkScheduled = 0;
- masterPtr->slavePtr = NULL;
- Tcl_SetHashValue(hPtr, masterPtr);
- }
-
- /*
- * Create a MaintainSlave structure for the slave if there isn't
- * already one.
- */
-
- for (slavePtr = masterPtr->slavePtr; slavePtr != NULL;
- slavePtr = slavePtr->nextPtr) {
- if (slavePtr->slave == slave) {
- goto gotSlave;
- }
- }
- slavePtr = (MaintainSlave *) ckalloc(sizeof(MaintainSlave));
- slavePtr->slave = slave;
- slavePtr->master = master;
- slavePtr->nextPtr = masterPtr->slavePtr;
- masterPtr->slavePtr = slavePtr;
- Tk_CreateEventHandler(slave, StructureNotifyMask, MaintainSlaveProc,
- (ClientData) slavePtr);
-
- /*
- * Make sure that there are event handlers registered for all
- * the windows between master and slave's parent (including master
- * but not slave's parent). There may already be handlers for master
- * and some of its ancestors (masterPtr->ancestor tells how many).
- */
-
- for (ancestor = master; ancestor != parent;
- ancestor = Tk_Parent(ancestor)) {
- if (ancestor == masterPtr->ancestor) {
- Tk_CreateEventHandler(ancestor, StructureNotifyMask,
- MaintainMasterProc, (ClientData) masterPtr);
- masterPtr->ancestor = Tk_Parent(ancestor);
- }
- }
-
- /*
- * Fill in up-to-date information in the structure, then update the
- * window if it's not currently in the right place or state.
- */
-
- gotSlave:
- slavePtr->x = x;
- slavePtr->y = y;
- slavePtr->width = width;
- slavePtr->height = height;
- map = 1;
- for (ancestor = slavePtr->master; ; ancestor = Tk_Parent(ancestor)) {
- if (!Tk_IsMapped(ancestor) && (ancestor != parent)) {
- map = 0;
- }
- if (ancestor == parent) {
- if ((x != Tk_X(slavePtr->slave))
- || (y != Tk_Y(slavePtr->slave))
- || (width != Tk_Width(slavePtr->slave))
- || (height != Tk_Height(slavePtr->slave))) {
- Tk_MoveResizeWindow(slavePtr->slave, x, y, width, height);
- }
- if (map) {
- Tk_MapWindow(slavePtr->slave);
- } else {
- Tk_UnmapWindow(slavePtr->slave);
- }
- break;
- }
- x += Tk_X(ancestor) + Tk_Changes(ancestor)->border_width;
- y += Tk_Y(ancestor) + Tk_Changes(ancestor)->border_width;
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_UnmaintainGeometry --
- *
- * This procedure cancels a previous Tk_MaintainGeometry call,
- * so that the relationship between slave and master is no longer
- * maintained.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The slave is unmapped and state is released, so that slave won't
- * track master any more. If we weren't previously managing slave
- * relative to master, then this procedure has no effect.
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tk_UnmaintainGeometry(slave, master)
- Tk_Window slave; /* Slave for geometry management. */
- Tk_Window master; /* Master for slave; must be a descendant
- * of slave's parent. */
-{
- Tcl_HashEntry *hPtr;
- MaintainMaster *masterPtr;
- register MaintainSlave *slavePtr, *prevPtr;
- Tk_Window ancestor;
-
- if (!initialized) {
- initialized = 1;
- Tcl_InitHashTable(&maintainHashTable, TCL_ONE_WORD_KEYS);
- }
-
- if (!(((TkWindow *) slave)->flags & TK_ALREADY_DEAD)) {
- Tk_UnmapWindow(slave);
- }
- hPtr = Tcl_FindHashEntry(&maintainHashTable, (char *) master);
- if (hPtr == NULL) {
- return;
- }
- masterPtr = (MaintainMaster *) Tcl_GetHashValue(hPtr);
- slavePtr = masterPtr->slavePtr;
- if (slavePtr->slave == slave) {
- masterPtr->slavePtr = slavePtr->nextPtr;
- } else {
- for (prevPtr = slavePtr, slavePtr = slavePtr->nextPtr; ;
- prevPtr = slavePtr, slavePtr = slavePtr->nextPtr) {
- if (slavePtr == NULL) {
- return;
- }
- if (slavePtr->slave == slave) {
- prevPtr->nextPtr = slavePtr->nextPtr;
- break;
- }
- }
- }
- Tk_DeleteEventHandler(slavePtr->slave, StructureNotifyMask,
- MaintainSlaveProc, (ClientData) slavePtr);
- ckfree((char *) slavePtr);
- if (masterPtr->slavePtr == NULL) {
- if (masterPtr->ancestor != NULL) {
- for (ancestor = master; ; ancestor = Tk_Parent(ancestor)) {
- Tk_DeleteEventHandler(ancestor, StructureNotifyMask,
- MaintainMasterProc, (ClientData) masterPtr);
- if (ancestor == masterPtr->ancestor) {
- break;
- }
- }
- }
- if (masterPtr->checkScheduled) {
- Tcl_CancelIdleCall(MaintainCheckProc, (ClientData) masterPtr);
- }
- Tcl_DeleteHashEntry(hPtr);
- ckfree((char *) masterPtr);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * MaintainMasterProc --
- *
- * This procedure is invoked by the Tk event dispatcher in
- * response to StructureNotify events on the master or one
- * of its ancestors, on behalf of Tk_MaintainGeometry.
- *
- * Results:
- * None.
- *
- * Side effects:
- * It schedules a call to MaintainCheckProc, which will eventually
- * caused the postions and mapped states to be recalculated for all
- * the maintained slaves of the master. Or, if the master window is
- * being deleted then state is cleaned up.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-MaintainMasterProc(clientData, eventPtr)
- ClientData clientData; /* Pointer to MaintainMaster structure
- * for the master window. */
- XEvent *eventPtr; /* Describes what just happened. */
-{
- MaintainMaster *masterPtr = (MaintainMaster *) clientData;
- MaintainSlave *slavePtr;
- int done;
-
- if ((eventPtr->type == ConfigureNotify)
- || (eventPtr->type == MapNotify)
- || (eventPtr->type == UnmapNotify)) {
- if (!masterPtr->checkScheduled) {
- masterPtr->checkScheduled = 1;
- Tcl_DoWhenIdle(MaintainCheckProc, (ClientData) masterPtr);
- }
- } else if (eventPtr->type == DestroyNotify) {
- /*
- * Delete all of the state associated with this master, but
- * be careful not to use masterPtr after the last slave is
- * deleted, since its memory will have been freed.
- */
-
- done = 0;
- do {
- slavePtr = masterPtr->slavePtr;
- if (slavePtr->nextPtr == NULL) {
- done = 1;
- }
- Tk_UnmaintainGeometry(slavePtr->slave, slavePtr->master);
- } while (!done);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * MaintainSlaveProc --
- *
- * This procedure is invoked by the Tk event dispatcher in
- * response to StructureNotify events on a slave being managed
- * by Tk_MaintainGeometry.
- *
- * Results:
- * None.
- *
- * Side effects:
- * If the event is a DestroyNotify event then the Maintain state
- * and event handlers for this slave are deleted.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-MaintainSlaveProc(clientData, eventPtr)
- ClientData clientData; /* Pointer to MaintainSlave structure
- * for master-slave pair. */
- XEvent *eventPtr; /* Describes what just happened. */
-{
- MaintainSlave *slavePtr = (MaintainSlave *) clientData;
-
- if (eventPtr->type == DestroyNotify) {
- Tk_UnmaintainGeometry(slavePtr->slave, slavePtr->master);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * MaintainCheckProc --
- *
- * This procedure is invoked by the Tk event dispatcher as an
- * idle handler, when a master or one of its ancestors has been
- * reconfigured, mapped, or unmapped. Its job is to scan all of
- * the slaves for the master and reposition them, map them, or
- * unmap them as needed to maintain their geometry relative to
- * the master.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Slaves can get repositioned, mapped, or unmapped.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-MaintainCheckProc(clientData)
- ClientData clientData; /* Pointer to MaintainMaster structure
- * for the master window. */
-{
- MaintainMaster *masterPtr = (MaintainMaster *) clientData;
- MaintainSlave *slavePtr;
- Tk_Window ancestor, parent;
- int x, y, map;
-
- masterPtr->checkScheduled = 0;
- for (slavePtr = masterPtr->slavePtr; slavePtr != NULL;
- slavePtr = slavePtr->nextPtr) {
- parent = Tk_Parent(slavePtr->slave);
- x = slavePtr->x;
- y = slavePtr->y;
- map = 1;
- for (ancestor = slavePtr->master; ; ancestor = Tk_Parent(ancestor)) {
- if (!Tk_IsMapped(ancestor) && (ancestor != parent)) {
- map = 0;
- }
- if (ancestor == parent) {
- if ((x != Tk_X(slavePtr->slave))
- || (y != Tk_Y(slavePtr->slave))) {
- Tk_MoveWindow(slavePtr->slave, x, y);
- }
- if (map) {
- Tk_MapWindow(slavePtr->slave);
- } else {
- Tk_UnmapWindow(slavePtr->slave);
- }
- break;
- }
- x += Tk_X(ancestor) + Tk_Changes(ancestor)->border_width;
- y += Tk_Y(ancestor) + Tk_Changes(ancestor)->border_width;
- }
- }
-}
diff --git a/generic/tkGet.c b/generic/tkGet.c
deleted file mode 100644
index 3507e9b..0000000
--- a/generic/tkGet.c
+++ /dev/null
@@ -1,586 +0,0 @@
-/*
- * tkGet.c --
- *
- * This file contains a number of "Tk_GetXXX" procedures, which
- * parse text strings into useful forms for Tk. This file has
- * the simpler procedures, like Tk_GetDirection and Tk_GetUid.
- * The more complex procedures like Tk_GetColor are in separate
- * files.
- *
- * Copyright (c) 1991-1994 The Regents of the University of California.
- * Copyright (c) 1994-1995 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: tkGet.c,v 1.2 1998/09/14 18:23:11 stanton Exp $
- */
-
-#include "tkInt.h"
-#include "tkPort.h"
-
-/*
- * The hash table below is used to keep track of all the Tk_Uids created
- * so far.
- */
-
-static Tcl_HashTable uidTable;
-static int initialized = 0;
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_GetAnchor --
- *
- * Given a string, return the corresponding Tk_Anchor.
- *
- * Results:
- * The return value is a standard Tcl return result. If
- * TCL_OK is returned, then everything went well and the
- * position is stored at *anchorPtr; otherwise TCL_ERROR
- * is returned and an error message is left in
- * interp->result.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-int
-Tk_GetAnchor(interp, string, anchorPtr)
- Tcl_Interp *interp; /* Use this for error reporting. */
- char *string; /* String describing a direction. */
- Tk_Anchor *anchorPtr; /* Where to store Tk_Anchor corresponding
- * to string. */
-{
- switch (string[0]) {
- case 'n':
- if (string[1] == 0) {
- *anchorPtr = TK_ANCHOR_N;
- return TCL_OK;
- } else if ((string[1] == 'e') && (string[2] == 0)) {
- *anchorPtr = TK_ANCHOR_NE;
- return TCL_OK;
- } else if ((string[1] == 'w') && (string[2] == 0)) {
- *anchorPtr = TK_ANCHOR_NW;
- return TCL_OK;
- }
- goto error;
- case 's':
- if (string[1] == 0) {
- *anchorPtr = TK_ANCHOR_S;
- return TCL_OK;
- } else if ((string[1] == 'e') && (string[2] == 0)) {
- *anchorPtr = TK_ANCHOR_SE;
- return TCL_OK;
- } else if ((string[1] == 'w') && (string[2] == 0)) {
- *anchorPtr = TK_ANCHOR_SW;
- return TCL_OK;
- } else {
- goto error;
- }
- case 'e':
- if (string[1] == 0) {
- *anchorPtr = TK_ANCHOR_E;
- return TCL_OK;
- }
- goto error;
- case 'w':
- if (string[1] == 0) {
- *anchorPtr = TK_ANCHOR_W;
- return TCL_OK;
- }
- goto error;
- case 'c':
- if (strncmp(string, "center", strlen(string)) == 0) {
- *anchorPtr = TK_ANCHOR_CENTER;
- return TCL_OK;
- }
- goto error;
- }
-
- error:
- Tcl_AppendResult(interp, "bad anchor position \"", string,
- "\": must be n, ne, e, se, s, sw, w, nw, or center",
- (char *) NULL);
- return TCL_ERROR;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_NameOfAnchor --
- *
- * Given a Tk_Anchor, return the string that corresponds
- * to it.
- *
- * Results:
- * None.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-char *
-Tk_NameOfAnchor(anchor)
- Tk_Anchor anchor; /* Anchor for which identifying string
- * is desired. */
-{
- switch (anchor) {
- case TK_ANCHOR_N: return "n";
- case TK_ANCHOR_NE: return "ne";
- case TK_ANCHOR_E: return "e";
- case TK_ANCHOR_SE: return "se";
- case TK_ANCHOR_S: return "s";
- case TK_ANCHOR_SW: return "sw";
- case TK_ANCHOR_W: return "w";
- case TK_ANCHOR_NW: return "nw";
- case TK_ANCHOR_CENTER: return "center";
- }
- return "unknown anchor position";
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_GetJoinStyle --
- *
- * Given a string, return the corresponding Tk_JoinStyle.
- *
- * Results:
- * The return value is a standard Tcl return result. If
- * TCL_OK is returned, then everything went well and the
- * justification is stored at *joinPtr; otherwise
- * TCL_ERROR is returned and an error message is left in
- * interp->result.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-int
-Tk_GetJoinStyle(interp, string, joinPtr)
- Tcl_Interp *interp; /* Use this for error reporting. */
- char *string; /* String describing a justification style. */
- int *joinPtr; /* Where to store join style corresponding
- * to string. */
-{
- int c;
- size_t length;
-
- c = string[0];
- length = strlen(string);
-
- if ((c == 'b') && (strncmp(string, "bevel", length) == 0)) {
- *joinPtr = JoinBevel;
- return TCL_OK;
- }
- if ((c == 'm') && (strncmp(string, "miter", length) == 0)) {
- *joinPtr = JoinMiter;
- return TCL_OK;
- }
- if ((c == 'r') && (strncmp(string, "round", length) == 0)) {
- *joinPtr = JoinRound;
- return TCL_OK;
- }
-
- Tcl_AppendResult(interp, "bad join style \"", string,
- "\": must be bevel, miter, or round",
- (char *) NULL);
- return TCL_ERROR;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_NameOfJoinStyle --
- *
- * Given a Tk_JoinStyle, return the string that corresponds
- * to it.
- *
- * Results:
- * None.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-char *
-Tk_NameOfJoinStyle(join)
- int join; /* Join style for which identifying string
- * is desired. */
-{
- switch (join) {
- case JoinBevel: return "bevel";
- case JoinMiter: return "miter";
- case JoinRound: return "round";
- }
- return "unknown join style";
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_GetCapStyle --
- *
- * Given a string, return the corresponding Tk_CapStyle.
- *
- * Results:
- * The return value is a standard Tcl return result. If
- * TCL_OK is returned, then everything went well and the
- * justification is stored at *capPtr; otherwise
- * TCL_ERROR is returned and an error message is left in
- * interp->result.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-int
-Tk_GetCapStyle(interp, string, capPtr)
- Tcl_Interp *interp; /* Use this for error reporting. */
- char *string; /* String describing a justification style. */
- int *capPtr; /* Where to store cap style corresponding
- * to string. */
-{
- int c;
- size_t length;
-
- c = string[0];
- length = strlen(string);
-
- if ((c == 'b') && (strncmp(string, "butt", length) == 0)) {
- *capPtr = CapButt;
- return TCL_OK;
- }
- if ((c == 'p') && (strncmp(string, "projecting", length) == 0)) {
- *capPtr = CapProjecting;
- return TCL_OK;
- }
- if ((c == 'r') && (strncmp(string, "round", length) == 0)) {
- *capPtr = CapRound;
- return TCL_OK;
- }
-
- Tcl_AppendResult(interp, "bad cap style \"", string,
- "\": must be butt, projecting, or round",
- (char *) NULL);
- return TCL_ERROR;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_NameOfCapStyle --
- *
- * Given a Tk_CapStyle, return the string that corresponds
- * to it.
- *
- * Results:
- * None.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-char *
-Tk_NameOfCapStyle(cap)
- int cap; /* Cap style for which identifying string
- * is desired. */
-{
- switch (cap) {
- case CapButt: return "butt";
- case CapProjecting: return "projecting";
- case CapRound: return "round";
- }
- return "unknown cap style";
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_GetJustify --
- *
- * Given a string, return the corresponding Tk_Justify.
- *
- * Results:
- * The return value is a standard Tcl return result. If
- * TCL_OK is returned, then everything went well and the
- * justification is stored at *justifyPtr; otherwise
- * TCL_ERROR is returned and an error message is left in
- * interp->result.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-int
-Tk_GetJustify(interp, string, justifyPtr)
- Tcl_Interp *interp; /* Use this for error reporting. */
- char *string; /* String describing a justification style. */
- Tk_Justify *justifyPtr; /* Where to store Tk_Justify corresponding
- * to string. */
-{
- int c;
- size_t length;
-
- c = string[0];
- length = strlen(string);
-
- if ((c == 'l') && (strncmp(string, "left", length) == 0)) {
- *justifyPtr = TK_JUSTIFY_LEFT;
- return TCL_OK;
- }
- if ((c == 'r') && (strncmp(string, "right", length) == 0)) {
- *justifyPtr = TK_JUSTIFY_RIGHT;
- return TCL_OK;
- }
- if ((c == 'c') && (strncmp(string, "center", length) == 0)) {
- *justifyPtr = TK_JUSTIFY_CENTER;
- return TCL_OK;
- }
-
- Tcl_AppendResult(interp, "bad justification \"", string,
- "\": must be left, right, or center",
- (char *) NULL);
- return TCL_ERROR;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_NameOfJustify --
- *
- * Given a Tk_Justify, return the string that corresponds
- * to it.
- *
- * Results:
- * None.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-char *
-Tk_NameOfJustify(justify)
- Tk_Justify justify; /* Justification style for which
- * identifying string is desired. */
-{
- switch (justify) {
- case TK_JUSTIFY_LEFT: return "left";
- case TK_JUSTIFY_RIGHT: return "right";
- case TK_JUSTIFY_CENTER: return "center";
- }
- return "unknown justification style";
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_GetUid --
- *
- * Given a string, this procedure returns a unique identifier
- * for the string.
- *
- * Results:
- * This procedure returns a Tk_Uid corresponding to the "string"
- * argument. The Tk_Uid has a string value identical to string
- * (strcmp will return 0), but it's guaranteed that any other
- * calls to this procedure with a string equal to "string" will
- * return exactly the same result (i.e. can compare Tk_Uid
- * *values* directly, without having to call strcmp on what they
- * point to).
- *
- * Side effects:
- * New information may be entered into the identifier table.
- *
- *----------------------------------------------------------------------
- */
-
-Tk_Uid
-Tk_GetUid(string)
- CONST char *string; /* String to convert. */
-{
- int dummy;
-
- if (!initialized) {
- Tcl_InitHashTable(&uidTable, TCL_STRING_KEYS);
- initialized = 1;
- }
- return (Tk_Uid) Tcl_GetHashKey(&uidTable,
- Tcl_CreateHashEntry(&uidTable, string, &dummy));
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_GetScreenMM --
- *
- * Given a string, returns the number of screen millimeters
- * corresponding to that string.
- *
- * Results:
- * The return value is a standard Tcl return result. If
- * TCL_OK is returned, then everything went well and the
- * screen distance is stored at *doublePtr; otherwise
- * TCL_ERROR is returned and an error message is left in
- * interp->result.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-int
-Tk_GetScreenMM(interp, tkwin, string, doublePtr)
- Tcl_Interp *interp; /* Use this for error reporting. */
- Tk_Window tkwin; /* Window whose screen determines conversion
- * from centimeters and other absolute
- * units. */
- char *string; /* String describing a screen distance. */
- double *doublePtr; /* Place to store converted result. */
-{
- char *end;
- double d;
-
- d = strtod(string, &end);
- if (end == string) {
- error:
- Tcl_AppendResult(interp, "bad screen distance \"", string,
- "\"", (char *) NULL);
- return TCL_ERROR;
- }
- while ((*end != '\0') && isspace(UCHAR(*end))) {
- end++;
- }
- switch (*end) {
- case 0:
- d /= WidthOfScreen(Tk_Screen(tkwin));
- d *= WidthMMOfScreen(Tk_Screen(tkwin));
- break;
- case 'c':
- d *= 10;
- end++;
- break;
- case 'i':
- d *= 25.4;
- end++;
- break;
- case 'm':
- end++;
- break;
- case 'p':
- d *= 25.4/72.0;
- end++;
- break;
- default:
- goto error;
- }
- while ((*end != '\0') && isspace(UCHAR(*end))) {
- end++;
- }
- if (*end != 0) {
- goto error;
- }
- *doublePtr = d;
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_GetPixels --
- *
- * Given a string, returns the number of pixels corresponding
- * to that string.
- *
- * Results:
- * The return value is a standard Tcl return result. If
- * TCL_OK is returned, then everything went well and the
- * rounded pixel distance is stored at *intPtr; otherwise
- * TCL_ERROR is returned and an error message is left in
- * interp->result.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-int
-Tk_GetPixels(interp, tkwin, string, intPtr)
- Tcl_Interp *interp; /* Use this for error reporting. */
- Tk_Window tkwin; /* Window whose screen determines conversion
- * from centimeters and other absolute
- * units. */
- char *string; /* String describing a justification style. */
- int *intPtr; /* Place to store converted result. */
-{
- char *end;
- double d;
-
- d = strtod(string, &end);
- if (end == string) {
- error:
- Tcl_AppendResult(interp, "bad screen distance \"", string,
- "\"", (char *) NULL);
- return TCL_ERROR;
- }
- while ((*end != '\0') && isspace(UCHAR(*end))) {
- end++;
- }
- switch (*end) {
- case 0:
- break;
- case 'c':
- d *= 10*WidthOfScreen(Tk_Screen(tkwin));
- d /= WidthMMOfScreen(Tk_Screen(tkwin));
- end++;
- break;
- case 'i':
- d *= 25.4*WidthOfScreen(Tk_Screen(tkwin));
- d /= WidthMMOfScreen(Tk_Screen(tkwin));
- end++;
- break;
- case 'm':
- d *= WidthOfScreen(Tk_Screen(tkwin));
- d /= WidthMMOfScreen(Tk_Screen(tkwin));
- end++;
- break;
- case 'p':
- d *= (25.4/72.0)*WidthOfScreen(Tk_Screen(tkwin));
- d /= WidthMMOfScreen(Tk_Screen(tkwin));
- end++;
- break;
- default:
- goto error;
- }
- while ((*end != '\0') && isspace(UCHAR(*end))) {
- end++;
- }
- if (*end != 0) {
- goto error;
- }
- if (d < 0) {
- *intPtr = (int) (d - 0.5);
- } else {
- *intPtr = (int) (d + 0.5);
- }
- return TCL_OK;
-}
diff --git a/generic/tkGrab.c b/generic/tkGrab.c
deleted file mode 100644
index bbb4f65..0000000
--- a/generic/tkGrab.c
+++ /dev/null
@@ -1,1535 +0,0 @@
-/*
- * tkGrab.c --
- *
- * This file provides procedures that implement grabs for Tk.
- *
- * Copyright (c) 1992-1994 The Regents of the University of California.
- * Copyright (c) 1994-1995 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: tkGrab.c,v 1.2 1998/09/14 18:23:11 stanton Exp $
- */
-
-#include "tkPort.h"
-#include "tkInt.h"
-
-/*
- * The grab state machine has four states: ungrabbed, button pressed,
- * grabbed, and button pressed while grabbed. In addition, there are
- * three pieces of grab state information: the current grab window,
- * the current restrict window, and whether the mouse is captured.
- *
- * The current grab window specifies the point in the Tk window
- * heirarchy above which pointer events will not be reported. Any
- * window within the subtree below the grab window will continue to
- * receive events as normal. Events outside of the grab tree will be
- * reported to the grab window.
- *
- * If the current restrict window is set, then all pointer events will
- * be reported only to the restrict window. The restrict window is
- * normally set during an automatic button grab.
- *
- * The mouse capture state specifies whether the window system will
- * report mouse events outside of any Tk toplevels. This is set
- * during a global grab or an automatic button grab.
- *
- * The transitions between different states is given in the following
- * table:
- *
- * Event\State U B G GB
- * ----------- -- -- -- --
- * FirstPress B B GB GB
- * Press B B G GB
- * Release U B G GB
- * LastRelease U U G G
- * Grab G G G G
- * Ungrab U B U U
- *
- * Note: U=Ungrabbed, B=Button, G=Grabbed, GB=Grab and Button
- *
- * In addition, the following conditions are always true:
- *
- * State\Variable Grab Restrict Capture
- * -------------- ---- -------- -------
- * Ungrabbed 0 0 0
- * Button 0 1 1
- * Grabbed 1 0 b/g
- * Grab and Button 1 1 1
- *
- * Note: 0 means variable is set to NULL, 1 means variable is set to
- * some window, b/g means the variable is set to a window if a button
- * is currently down or a global grab is in effect.
- *
- * The final complication to all of this is enter and leave events.
- * In order to correctly handle all of the various cases, Tk cannot
- * rely on X enter/leave events in all situations. The following
- * describes the correct sequence of enter and leave events that
- * should be observed by Tk scripts:
- *
- * Event(state) Enter/Leave From -> To
- * ------------ ----------------------
- * LastRelease(B | GB): restrict window -> anc(grab window, event window)
- * Grab(U | B): event window -> anc(grab window, event window)
- * Grab(G): anc(old grab window, event window) ->
- * anc(new grab window, event window)
- * Grab(GB): restrict window -> anc(new grab window, event window)
- * Ungrab(G): anc(grab window, event window) -> event window
- * Ungrab(GB): restrict window -> event window
- *
- * Note: anc(x,y) returns the least ancestor of y that is in the tree
- * of x, terminating at toplevels.
- */
-
-/*
- * The following structure is used to pass information to
- * GrabRestrictProc from EatGrabEvents.
- */
-
-typedef struct {
- Display *display; /* Display from which to discard events. */
- unsigned int serial; /* Serial number with which to compare. */
-} GrabInfo;
-
-/*
- * Bit definitions for grabFlags field of TkDisplay structures:
- *
- * GRAB_GLOBAL 1 means this is a global grab (we grabbed via
- * the server so all applications are locked out).
- * 0 means this is a local grab that affects
- * only this application.
- * GRAB_TEMP_GLOBAL 1 means we've temporarily grabbed via the
- * server because a button is down and we want
- * to make sure that we get the button-up
- * event. The grab will be released when the
- * last mouse button goes up.
- */
-
-#define GRAB_GLOBAL 1
-#define GRAB_TEMP_GLOBAL 4
-
-/*
- * The following structure is a Tcl_Event that triggers a change in
- * the grabWinPtr field of a display. This event guarantees that
- * the change occurs in the proper order relative to enter and leave
- * events.
- */
-
-typedef struct NewGrabWinEvent {
- Tcl_Event header; /* Standard information for all Tcl events. */
- TkDisplay *dispPtr; /* Display whose grab window is to change. */
- Window grabWindow; /* New grab window for display. This is
- * recorded instead of a (TkWindow *) because
- * it will allow us to detect cases where
- * the window is destroyed before this event
- * is processed. */
-} NewGrabWinEvent;
-
-/*
- * The following magic value is stored in the "send_event" field of
- * EnterNotify and LeaveNotify events that are generated in this
- * file. This allows us to separate "real" events coming from the
- * server from those that we generated.
- */
-
-#define GENERATED_EVENT_MAGIC ((Bool) 0x147321ac)
-
-/*
- * Mask that selects any of the state bits corresponding to buttons,
- * plus masks that select individual buttons' bits:
- */
-
-#define ALL_BUTTONS \
- (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask)
-static unsigned int buttonStates[] = {
- Button1Mask, Button2Mask, Button3Mask, Button4Mask, Button5Mask
-};
-
-/*
- * Forward declarations for procedures declared later in this file:
- */
-
-static void EatGrabEvents _ANSI_ARGS_((TkDisplay *dispPtr,
- unsigned int serial));
-static TkWindow * FindCommonAncestor _ANSI_ARGS_((TkWindow *winPtr1,
- TkWindow *winPtr2, int *countPtr1,
- int *countPtr2));
-static Tk_RestrictAction GrabRestrictProc _ANSI_ARGS_((ClientData arg,
- XEvent *eventPtr));
-static int GrabWinEventProc _ANSI_ARGS_((Tcl_Event *evPtr,
- int flags));
-static void MovePointer2 _ANSI_ARGS_((TkWindow *sourcePtr,
- TkWindow *destPtr, int mode, int leaveEvents,
- int EnterEvents));
-static void QueueGrabWindowChange _ANSI_ARGS_((TkDisplay *dispPtr,
- TkWindow *grabWinPtr));
-static void ReleaseButtonGrab _ANSI_ARGS_((TkDisplay *dispPtr));
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_GrabCmd --
- *
- * This procedure is invoked to process the "grab" Tcl command.
- * See the user documentation for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
-
- /* ARGSUSED */
-int
-Tk_GrabCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Main window associated with
- * interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- int globalGrab, c;
- Tk_Window tkwin;
- TkDisplay *dispPtr;
- size_t length;
-
- if (argc < 2) {
- badArgs:
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " ?-global? window\" or \"", argv[0],
- " option ?arg arg ...?\"", (char *) NULL);
- return TCL_ERROR;
- }
- c = argv[1][0];
- length = strlen(argv[1]);
- if (c == '.') {
- if (argc != 2) {
- goto badArgs;
- }
- tkwin = Tk_NameToWindow(interp, argv[1], (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;
- }
- tkwin = Tk_NameToWindow(interp, argv[2], (Tk_Window) clientData);
- if (tkwin == NULL) {
- 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);
- return TCL_ERROR;
- }
- if (argc == 3) {
- tkwin = Tk_NameToWindow(interp, argv[2], (Tk_Window) clientData);
- if (tkwin == NULL) {
- return TCL_ERROR;
- }
- dispPtr = ((TkWindow *) tkwin)->dispPtr;
- if (dispPtr->eventualGrabWinPtr != NULL) {
- interp->result = dispPtr->eventualGrabWinPtr->pathName;
- }
- } else {
- for (dispPtr = tkDisplayList; dispPtr != NULL;
- dispPtr = dispPtr->nextPtr) {
- if (dispPtr->eventualGrabWinPtr != NULL) {
- Tcl_AppendElement(interp,
- dispPtr->eventualGrabWinPtr->pathName);
- }
- }
- }
- 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);
- 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;
- }
- winPtr = (TkWindow *) Tk_NameToWindow(interp, argv[2],
- (Tk_Window) clientData);
- if (winPtr == NULL) {
- return TCL_ERROR;
- }
- dispPtr = winPtr->dispPtr;
- if (dispPtr->eventualGrabWinPtr != winPtr) {
- interp->result = "none";
- } else if (dispPtr->grabFlags & GRAB_GLOBAL) {
- interp->result = "global";
- } else {
- interp->result = "local";
- }
- } 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;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_Grab --
- *
- * Grabs the pointer and keyboard, so that mouse-related events are
- * only reported relative to a given window and its descendants.
- *
- * Results:
- * A standard Tcl result is returned. TCL_OK is the normal return
- * value; if the grab could not be set then TCL_ERROR is returned
- * and interp->result will hold an error message.
- *
- * Side effects:
- * Once this call completes successfully, no window outside the
- * tree rooted at tkwin will receive pointer- or keyboard-related
- * events until the next call to Tk_Ungrab. If a previous grab was
- * in effect within this application, then it is replaced with a new
- * one.
- *
- *----------------------------------------------------------------------
- */
-
-int
-Tk_Grab(interp, tkwin, grabGlobal)
- Tcl_Interp *interp; /* Used for error reporting. */
- Tk_Window tkwin; /* Window on whose behalf the pointer
- * is to be grabbed. */
- int grabGlobal; /* Non-zero means issue a grab to the
- * server so that no other application
- * gets mouse or keyboard events.
- * Zero means the grab only applies
- * within this application. */
-{
- int grabResult, numTries;
- TkWindow *winPtr = (TkWindow *) tkwin;
- TkDisplay *dispPtr = winPtr->dispPtr;
- TkWindow *winPtr2;
- unsigned int serial;
-
- ReleaseButtonGrab(dispPtr);
- if (dispPtr->eventualGrabWinPtr != NULL) {
- if ((dispPtr->eventualGrabWinPtr == winPtr)
- && (grabGlobal == ((dispPtr->grabFlags & GRAB_GLOBAL) != 0))) {
- return TCL_OK;
- }
- if (dispPtr->eventualGrabWinPtr->mainPtr != winPtr->mainPtr) {
- alreadyGrabbed:
- interp->result = "grab failed: another application has grab";
- return TCL_ERROR;
- }
- Tk_Ungrab((Tk_Window) dispPtr->eventualGrabWinPtr);
- }
-
- Tk_MakeWindowExist(tkwin);
- if (!grabGlobal) {
- Window dummy1, dummy2;
- int dummy3, dummy4, dummy5, dummy6;
- unsigned int state;
-
- /*
- * Local grab. However, if any mouse buttons are down, turn
- * it into a global grab temporarily, until the last button
- * goes up. This does two things: (a) it makes sure that we
- * see the button-up event; and (b) it allows us to track mouse
- * motion among all of the windows of this application.
- */
-
- dispPtr->grabFlags &= ~(GRAB_GLOBAL|GRAB_TEMP_GLOBAL);
- XQueryPointer(dispPtr->display, winPtr->window, &dummy1,
- &dummy2, &dummy3, &dummy4, &dummy5, &dummy6, &state);
- if ((state & ALL_BUTTONS) != 0) {
- dispPtr->grabFlags |= GRAB_TEMP_GLOBAL;
- goto setGlobalGrab;
- }
- } else {
- dispPtr->grabFlags |= GRAB_GLOBAL;
- setGlobalGrab:
-
- /*
- * Tricky point: must ungrab before grabbing. This is needed
- * in case there is a button auto-grab already in effect. If
- * there is, and the mouse has moved to a different window, X
- * won't generate enter and leave events to move the mouse if
- * we grab without ungrabbing.
- */
-
- XUngrabPointer(dispPtr->display, CurrentTime);
- serial = NextRequest(dispPtr->display);
-
- /*
- * Another tricky point: there are races with some window
- * managers that can cause grabs to fail because the window
- * manager hasn't released its grab quickly enough. To work
- * around this problem, retry a few times after AlreadyGrabbed
- * errors to give the grab release enough time to register with
- * the server.
- */
-
- grabResult = 0; /* Needed only to prevent gcc
- * compiler warnings. */
- for (numTries = 0; numTries < 10; numTries++) {
- grabResult = XGrabPointer(dispPtr->display, winPtr->window,
- True, ButtonPressMask|ButtonReleaseMask|ButtonMotionMask
- |PointerMotionMask, GrabModeAsync, GrabModeAsync, None,
- None, CurrentTime);
- if (grabResult != AlreadyGrabbed) {
- break;
- }
- Tcl_Sleep(100);
- }
- if (grabResult != 0) {
- grabError:
- if (grabResult == GrabNotViewable) {
- interp->result = "grab failed: window not viewable";
- } else if (grabResult == AlreadyGrabbed) {
- goto alreadyGrabbed;
- } else if (grabResult == GrabFrozen) {
- interp->result = "grab failed: keyboard or pointer frozen";
- } else if (grabResult == GrabInvalidTime) {
- interp->result = "grab failed: invalid time";
- } else {
- char msg[100];
-
- sprintf(msg, "grab failed for unknown reason (code %d)",
- grabResult);
- Tcl_AppendResult(interp, msg, (char *) NULL);
- }
- return TCL_ERROR;
- }
- grabResult = XGrabKeyboard(dispPtr->display, Tk_WindowId(tkwin),
- False, GrabModeAsync, GrabModeAsync, CurrentTime);
- if (grabResult != 0) {
- XUngrabPointer(dispPtr->display, CurrentTime);
- goto grabError;
- }
-
- /*
- * Eat up any grab-related events generated by the server for the
- * grab. There are several reasons for doing this:
- *
- * 1. We have to synthesize the events for local grabs anyway, since
- * the server doesn't participate in them.
- * 2. The server doesn't always generate the right events for global
- * grabs (e.g. it generates events even if the current window is
- * in the grab tree, which we don't want).
- * 3. We want all the grab-related events to be processed immediately
- * (before other events that are already queued); events coming
- * from the server will be in the wrong place, but events we
- * synthesize here will go to the front of the queue.
- */
-
- EatGrabEvents(dispPtr, serial);
- }
-
- /*
- * Synthesize leave events to move the pointer from its current window
- * up to the lowest ancestor that it has in common with the grab window.
- * However, only do this if the pointer is outside the grab window's
- * subtree but inside the grab window's application.
- */
-
- if ((dispPtr->serverWinPtr != NULL)
- && (dispPtr->serverWinPtr->mainPtr == winPtr->mainPtr)) {
- for (winPtr2 = dispPtr->serverWinPtr; ; winPtr2 = winPtr2->parentPtr) {
- if (winPtr2 == winPtr) {
- break;
- }
- if (winPtr2 == NULL) {
- MovePointer2(dispPtr->serverWinPtr, winPtr, NotifyGrab, 1, 0);
- break;
- }
- }
- }
- QueueGrabWindowChange(dispPtr, winPtr);
- return TCL_OK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_Ungrab --
- *
- * Releases a grab on the mouse pointer and keyboard, if there
- * is one set on the specified window.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Pointer and keyboard events will start being delivered to other
- * windows again.
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tk_Ungrab(tkwin)
- Tk_Window tkwin; /* Window whose grab should be
- * released. */
-{
- TkDisplay *dispPtr;
- TkWindow *grabWinPtr, *winPtr;
- unsigned int serial;
-
- grabWinPtr = (TkWindow *) tkwin;
- dispPtr = grabWinPtr->dispPtr;
- if (grabWinPtr != dispPtr->eventualGrabWinPtr) {
- return;
- }
- ReleaseButtonGrab(dispPtr);
- QueueGrabWindowChange(dispPtr, (TkWindow *) NULL);
- if (dispPtr->grabFlags & (GRAB_GLOBAL|GRAB_TEMP_GLOBAL)) {
- dispPtr->grabFlags &= ~(GRAB_GLOBAL|GRAB_TEMP_GLOBAL);
- serial = NextRequest(dispPtr->display);
- XUngrabPointer(dispPtr->display, CurrentTime);
- XUngrabKeyboard(dispPtr->display, CurrentTime);
- EatGrabEvents(dispPtr, serial);
- }
-
- /*
- * Generate events to move the pointer back to the window where it
- * really is. Some notes:
- * 1. As with grabs, only do this if the "real" window is not a
- * descendant of the grab window, since in this case the pointer
- * is already where it's supposed to be.
- * 2. If the "real" window is in some other application then don't
- * generate any events at all, since everything's already been
- * reported correctly.
- * 3. Only generate enter events. Don't generate leave events,
- * because we never told the lower-level windows that they
- * had the pointer in the first place.
- */
-
- for (winPtr = dispPtr->serverWinPtr; ; winPtr = winPtr->parentPtr) {
- if (winPtr == grabWinPtr) {
- break;
- }
- if (winPtr == NULL) {
- if ((dispPtr->serverWinPtr == NULL) ||
- (dispPtr->serverWinPtr->mainPtr == grabWinPtr->mainPtr)) {
- MovePointer2(grabWinPtr, dispPtr->serverWinPtr,
- NotifyUngrab, 0, 1);
- }
- break;
- }
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ReleaseButtonGrab --
- *
- * This procedure is called to release a simulated button grab, if
- * there is one in effect. A button grab is present whenever
- * dispPtr->buttonWinPtr is non-NULL or when the GRAB_TEMP_GLOBAL
- * flag is set.
- *
- * Results:
- * None.
- *
- * Side effects:
- * DispPtr->buttonWinPtr is reset to NULL, and enter and leave
- * events are generated if necessary to move the pointer from
- * the button grab window to its current window.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-ReleaseButtonGrab(dispPtr)
- register TkDisplay *dispPtr; /* Display whose button grab is to be
- * released. */
-{
- unsigned int serial;
-
- if (dispPtr->buttonWinPtr != NULL) {
- if (dispPtr->buttonWinPtr != dispPtr->serverWinPtr) {
- MovePointer2(dispPtr->buttonWinPtr, dispPtr->serverWinPtr,
- NotifyUngrab, 1, 1);
- }
- dispPtr->buttonWinPtr = NULL;
- }
- if (dispPtr->grabFlags & GRAB_TEMP_GLOBAL) {
- dispPtr->grabFlags &= ~GRAB_TEMP_GLOBAL;
- serial = NextRequest(dispPtr->display);
- XUngrabPointer(dispPtr->display, CurrentTime);
- XUngrabKeyboard(dispPtr->display, CurrentTime);
- EatGrabEvents(dispPtr, serial);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkPointerEvent --
- *
- * This procedure is called for each pointer-related event, before
- * the event has been processed. It does various things to make
- * grabs work correctly.
- *
- * Results:
- * If the return value is 1 it means the event should be processed
- * (event handlers should be invoked). If the return value is 0
- * it means the event should be ignored in order to make grabs
- * work correctly. In some cases this procedure modifies the event.
- *
- * Side effects:
- * Grab state information may be updated. New events may also be
- * pushed back onto the event queue to replace or augment the
- * one passed in here.
- *
- *----------------------------------------------------------------------
- */
-
-int
-TkPointerEvent(eventPtr, winPtr)
- register XEvent *eventPtr; /* Pointer to the event. */
- TkWindow *winPtr; /* Tk's information for window
- * where event was reported. */
-{
- register TkWindow *winPtr2;
- TkDisplay *dispPtr = winPtr->dispPtr;
- unsigned int serial;
- int outsideGrabTree = 0;
- int ancestorOfGrab = 0;
- int appGrabbed = 0; /* Non-zero means event is being
- * reported to an application that is
- * affected by the grab. */
-
- /*
- * Collect information about the grab (if any).
- */
-
- switch (TkGrabState(winPtr)) {
- case TK_GRAB_IN_TREE:
- appGrabbed = 1;
- break;
- case TK_GRAB_ANCESTOR:
- appGrabbed = 1;
- outsideGrabTree = 1;
- ancestorOfGrab = 1;
- break;
- case TK_GRAB_EXCLUDED:
- appGrabbed = 1;
- outsideGrabTree = 1;
- break;
- }
-
- if ((eventPtr->type == EnterNotify) || (eventPtr->type == LeaveNotify)) {
- /*
- * Keep track of what window the mouse is *really* over.
- * Any events that we generate have a special send_event value,
- * which is detected below and used to ignore the event for
- * purposes of setting serverWinPtr.
- */
-
- if (eventPtr->xcrossing.send_event != GENERATED_EVENT_MAGIC) {
- if ((eventPtr->type == LeaveNotify) &&
- (winPtr->flags & TK_TOP_LEVEL)) {
- dispPtr->serverWinPtr = NULL;
- } else {
- dispPtr->serverWinPtr = winPtr;
- }
- }
-
- /*
- * When a grab is active, X continues to report enter and leave
- * events for windows outside the tree of the grab window:
- * 1. Detect these events and ignore them except for
- * windows above the grab window.
- * 2. Allow Enter and Leave events to pass through the
- * windows above the grab window, but never let them
- * end up with the pointer *in* one of those windows.
- */
-
- if (dispPtr->grabWinPtr != NULL) {
- if (outsideGrabTree && appGrabbed) {
- if (!ancestorOfGrab) {
- return 0;
- }
- switch (eventPtr->xcrossing.detail) {
- case NotifyInferior:
- return 0;
- case NotifyAncestor:
- eventPtr->xcrossing.detail = NotifyVirtual;
- break;
- case NotifyNonlinear:
- eventPtr->xcrossing.detail = NotifyNonlinearVirtual;
- break;
- }
- }
-
- /*
- * Make buttons have the same grab-like behavior inside a grab
- * as they do outside a grab: do this by ignoring enter and
- * leave events except for the window in which the button was
- * pressed.
- */
-
- if ((dispPtr->buttonWinPtr != NULL)
- && (winPtr != dispPtr->buttonWinPtr)) {
- return 0;
- }
- }
- return 1;
- }
-
- if (!appGrabbed) {
- return 1;
- }
-
- if (eventPtr->type == MotionNotify) {
- /*
- * When grabs are active, X reports motion events relative to the
- * window under the pointer. Instead, it should report the events
- * relative to the window the button went down in, if there is a
- * button down. Otherwise, if the pointer window is outside the
- * subtree of the grab window, the events should be reported
- * relative to the grab window. Otherwise, the event should be
- * reported to the pointer window.
- */
-
- winPtr2 = winPtr;
- if (dispPtr->buttonWinPtr != NULL) {
- winPtr2 = dispPtr->buttonWinPtr;
- } else if (outsideGrabTree || (dispPtr->serverWinPtr == NULL)) {
- winPtr2 = dispPtr->grabWinPtr;
- }
- if (winPtr2 != winPtr) {
- TkChangeEventWindow(eventPtr, winPtr2);
- Tk_QueueWindowEvent(eventPtr, TCL_QUEUE_HEAD);
- return 0;
- }
- return 1;
- }
-
- /*
- * Process ButtonPress and ButtonRelease events:
- * 1. Keep track of whether a button is down and what window it
- * went down in.
- * 2. If the first button goes down outside the grab tree, pretend
- * it went down in the grab window. Note: it's important to
- * redirect events to the grab window like this in order to make
- * things like menus work, where button presses outside the
- * grabbed menu need to be seen. An application can always
- * ignore the events if they occur outside its window.
- * 3. If a button press or release occurs outside the window where
- * the first button was pressed, retarget the event so it's reported
- * to the window where the first button was pressed.
- * 4. If the last button is released in a window different than where
- * the first button was pressed, generate Enter/Leave events to
- * move the mouse from the button window to its current window.
- * 5. If the grab is set at a time when a button is already down, or
- * if the window where the button was pressed was deleted, then
- * dispPtr->buttonWinPtr will stay NULL. Just forget about the
- * auto-grab for the button press; events will go to whatever
- * window contains the pointer. If this window isn't in the grab
- * tree then redirect events to the grab window.
- * 6. When a button is pressed during a local grab, the X server sets
- * a grab of its own, since it doesn't even know about our local
- * grab. This causes enter and leave events no longer to be
- * generated in the same way as for global grabs. To eliminate this
- * problem, set a temporary global grab when the first button goes
- * down and release it when the last button comes up.
- */
-
- if ((eventPtr->type == ButtonPress) || (eventPtr->type == ButtonRelease)) {
- winPtr2 = dispPtr->buttonWinPtr;
- if (winPtr2 == NULL) {
- if (outsideGrabTree) {
- winPtr2 = dispPtr->grabWinPtr; /* Note 5. */
- } else {
- winPtr2 = winPtr; /* Note 5. */
- }
- }
- if (eventPtr->type == ButtonPress) {
- if ((eventPtr->xbutton.state & ALL_BUTTONS) == 0) {
- if (outsideGrabTree) {
- TkChangeEventWindow(eventPtr, dispPtr->grabWinPtr);
- Tk_QueueWindowEvent(eventPtr, TCL_QUEUE_HEAD);
- return 0; /* Note 2. */
- }
- if (!(dispPtr->grabFlags & GRAB_GLOBAL)) { /* Note 6. */
- serial = NextRequest(dispPtr->display);
- if (XGrabPointer(dispPtr->display,
- dispPtr->grabWinPtr->window, True,
- ButtonPressMask|ButtonReleaseMask|ButtonMotionMask,
- GrabModeAsync, GrabModeAsync, None, None,
- CurrentTime) == 0) {
- EatGrabEvents(dispPtr, serial);
- if (XGrabKeyboard(dispPtr->display, winPtr->window,
- False, GrabModeAsync, GrabModeAsync,
- CurrentTime) == 0) {
- dispPtr->grabFlags |= GRAB_TEMP_GLOBAL;
- } else {
- XUngrabPointer(dispPtr->display, CurrentTime);
- }
- }
- }
- dispPtr->buttonWinPtr = winPtr;
- return 1;
- }
- } else {
- if ((eventPtr->xbutton.state & ALL_BUTTONS)
- == buttonStates[eventPtr->xbutton.button - Button1]) {
- ReleaseButtonGrab(dispPtr); /* Note 4. */
- }
- }
- if (winPtr2 != winPtr) {
- TkChangeEventWindow(eventPtr, winPtr2);
- Tk_QueueWindowEvent(eventPtr, TCL_QUEUE_HEAD);
- return 0; /* Note 3. */
- }
- }
-
- return 1;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkChangeEventWindow --
- *
- * Given an event and a new window to which the event should be
- * retargeted, modify fields of the event so that the event is
- * properly retargeted to the new window.
- *
- * Results:
- * The following fields of eventPtr are modified: window,
- * subwindow, x, y, same_screen.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkChangeEventWindow(eventPtr, winPtr)
- register XEvent *eventPtr; /* Event to retarget. Must have
- * type ButtonPress, ButtonRelease, KeyPress,
- * KeyRelease, MotionNotify, EnterNotify,
- * or LeaveNotify. */
- TkWindow *winPtr; /* New target window for event. */
-{
- int x, y, sameScreen, bd;
- register TkWindow *childPtr;
-
- eventPtr->xmotion.window = Tk_WindowId(winPtr);
- if (eventPtr->xmotion.root ==
- RootWindow(winPtr->display, winPtr->screenNum)) {
- Tk_GetRootCoords((Tk_Window) winPtr, &x, &y);
- eventPtr->xmotion.x = eventPtr->xmotion.x_root - x;
- eventPtr->xmotion.y = eventPtr->xmotion.y_root - y;
- eventPtr->xmotion.subwindow = None;
- for (childPtr = winPtr->childList; childPtr != NULL;
- childPtr = childPtr->nextPtr) {
- if (childPtr->flags & TK_TOP_LEVEL) {
- continue;
- }
- x = eventPtr->xmotion.x - childPtr->changes.x;
- y = eventPtr->xmotion.y - childPtr->changes.y;
- bd = childPtr->changes.border_width;
- if ((x >= -bd) && (y >= -bd)
- && (x < (childPtr->changes.width + bd))
- && (y < (childPtr->changes.height + bd))) {
- eventPtr->xmotion.subwindow = childPtr->window;
- }
- }
- sameScreen = 1;
- } else {
- eventPtr->xmotion.x = 0;
- eventPtr->xmotion.y = 0;
- eventPtr->xmotion.subwindow = None;
- sameScreen = 0;
- }
- if (eventPtr->type == MotionNotify) {
- eventPtr->xmotion.same_screen = sameScreen;
- } else {
- eventPtr->xbutton.same_screen = sameScreen;
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkInOutEvents --
- *
- * This procedure synthesizes EnterNotify and LeaveNotify events
- * to correctly transfer the pointer from one window to another.
- * It can also be used to generate FocusIn and FocusOut events
- * to move the input focus.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Synthesized events may be pushed back onto the event queue.
- * The event pointed to by eventPtr is modified.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkInOutEvents(eventPtr, sourcePtr, destPtr, leaveType, enterType, position)
- XEvent *eventPtr; /* A template X event. Must have all fields
- * properly set except for type, window,
- * subwindow, x, y, detail, and same_screen
- * (Not all of these fields are valid for
- * FocusIn/FocusOut events; x_root and y_root
- * must be valid for Enter/Leave events, even
- * though x and y needn't be valid). */
- TkWindow *sourcePtr; /* Window that used to have the pointer or
- * focus (NULL means it was not in a window
- * managed by this process). */
- TkWindow *destPtr; /* Window that is to end up with the pointer
- * or focus (NULL means it's not one managed
- * by this process). */
- int leaveType; /* Type of events to generate for windows
- * being left (LeaveNotify or FocusOut). 0
- * means don't generate leave events. */
- int enterType; /* Type of events to generate for windows
- * being entered (EnterNotify or FocusIn). 0
- * means don't generate enter events. */
- Tcl_QueuePosition position; /* Position at which events are added to
- * the system event queue. */
-{
- register TkWindow *winPtr;
- int upLevels, downLevels, i, j, focus;
-
- /*
- * There are four possible cases to deal with:
- *
- * 1. SourcePtr and destPtr are the same. There's nothing to do in
- * this case.
- * 2. SourcePtr is an ancestor of destPtr in the same top-level
- * window. Must generate events down the window tree from source
- * to dest.
- * 3. DestPtr is an ancestor of sourcePtr in the same top-level
- * window. Must generate events up the window tree from sourcePtr
- * to destPtr.
- * 4. All other cases. Must first generate events up the window tree
- * from sourcePtr to its top-level, then down from destPtr's
- * top-level to destPtr. This form is called "non-linear."
- *
- * The call to FindCommonAncestor separates these four cases and decides
- * how many levels up and down events have to be generated for.
- */
-
- if (sourcePtr == destPtr) {
- return;
- }
- if ((leaveType == FocusOut) || (enterType == FocusIn)) {
- focus = 1;
- } else {
- focus = 0;
- }
- FindCommonAncestor(sourcePtr, destPtr, &upLevels, &downLevels);
-
- /*
- * Generate enter/leave events and add them to the grab event queue.
- */
-
-
-#define QUEUE(w, t, d) \
- if (w->window != None) { \
- eventPtr->type = t; \
- if (focus) { \
- eventPtr->xfocus.window = w->window; \
- eventPtr->xfocus.detail = d; \
- } else { \
- eventPtr->xcrossing.detail = d; \
- TkChangeEventWindow(eventPtr, w); \
- } \
- Tk_QueueWindowEvent(eventPtr, position); \
- }
-
- if (downLevels == 0) {
-
- /*
- * SourcePtr is an inferior of destPtr.
- */
-
- if (leaveType != 0) {
- QUEUE(sourcePtr, leaveType, NotifyAncestor);
- for (winPtr = sourcePtr->parentPtr, i = upLevels-1; i > 0;
- winPtr = winPtr->parentPtr, i--) {
- QUEUE(winPtr, leaveType, NotifyVirtual);
- }
- }
- if ((enterType != 0) && (destPtr != NULL)) {
- QUEUE(destPtr, enterType, NotifyInferior);
- }
- } else if (upLevels == 0) {
-
- /*
- * DestPtr is an inferior of sourcePtr.
- */
-
- if ((leaveType != 0) && (sourcePtr != NULL)) {
- QUEUE(sourcePtr, leaveType, NotifyInferior);
- }
- if (enterType != 0) {
- for (i = downLevels-1; i > 0; i--) {
- for (winPtr = destPtr->parentPtr, j = 1; j < i;
- winPtr = winPtr->parentPtr, j++) {
- }
- QUEUE(winPtr, enterType, NotifyVirtual);
- }
- if (destPtr != NULL) {
- QUEUE(destPtr, enterType, NotifyAncestor);
- }
- }
- } else {
-
- /*
- * Non-linear: neither window is an inferior of the other.
- */
-
- if (leaveType != 0) {
- QUEUE(sourcePtr, leaveType, NotifyNonlinear);
- for (winPtr = sourcePtr->parentPtr, i = upLevels-1; i > 0;
- winPtr = winPtr->parentPtr, i--) {
- QUEUE(winPtr, leaveType, NotifyNonlinearVirtual);
- }
- }
- if (enterType != 0) {
- for (i = downLevels-1; i > 0; i--) {
- for (winPtr = destPtr->parentPtr, j = 1; j < i;
- winPtr = winPtr->parentPtr, j++) {
- }
- QUEUE(winPtr, enterType, NotifyNonlinearVirtual);
- }
- if (destPtr != NULL) {
- QUEUE(destPtr, enterType, NotifyNonlinear);
- }
- }
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * MovePointer2 --
- *
- * This procedure synthesizes EnterNotify and LeaveNotify events
- * to correctly transfer the pointer from one window to another.
- * It is different from TkInOutEvents in that no template X event
- * needs to be supplied; this procedure generates the template
- * event and calls TkInOutEvents.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Synthesized events may be pushed back onto the event queue.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-MovePointer2(sourcePtr, destPtr, mode, leaveEvents, enterEvents)
- TkWindow *sourcePtr; /* Window currently containing pointer (NULL
- * means it's not one managed by this
- * process). */
- TkWindow *destPtr; /* Window that is to end up containing the
- * pointer (NULL means it's not one managed
- * by this process). */
- int mode; /* Mode for enter/leave events, such as
- * NotifyNormal or NotifyUngrab. */
- int leaveEvents; /* Non-zero means generate leave events for the
- * windows being left. Zero means don't
- * generate leave events. */
- int enterEvents; /* Non-zero means generate enter events for the
- * windows being entered. Zero means don't
- * generate enter events. */
-{
- XEvent event;
- Window dummy1, dummy2;
- int dummy3, dummy4;
- TkWindow *winPtr;
-
- winPtr = sourcePtr;
- if ((winPtr == NULL) || (winPtr->window == None)) {
- winPtr = destPtr;
- if ((winPtr == NULL) || (winPtr->window == None)) {
- return;
- }
- }
-
- event.xcrossing.serial = LastKnownRequestProcessed(
- winPtr->display);
- event.xcrossing.send_event = GENERATED_EVENT_MAGIC;
- event.xcrossing.display = winPtr->display;
- event.xcrossing.root = RootWindow(winPtr->display,
- winPtr->screenNum);
- event.xcrossing.time = TkCurrentTime(winPtr->dispPtr);
- XQueryPointer(winPtr->display, winPtr->window, &dummy1, &dummy2,
- &event.xcrossing.x_root, &event.xcrossing.y_root,
- &dummy3, &dummy4, &event.xcrossing.state);
- event.xcrossing.mode = mode;
- event.xcrossing.focus = False;
- TkInOutEvents(&event, sourcePtr, destPtr, (leaveEvents) ? LeaveNotify : 0,
- (enterEvents) ? EnterNotify : 0, TCL_QUEUE_MARK);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkGrabDeadWindow --
- *
- * This procedure is invoked whenever a window is deleted, so that
- * grab-related cleanup can be performed.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Various cleanups happen, such as generating events to move the
- * pointer back to its "natural" window as if an ungrab had been
- * done. See the code.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkGrabDeadWindow(winPtr)
- register TkWindow *winPtr; /* Window that is in the process
- * of being deleted. */
-{
- TkDisplay *dispPtr = winPtr->dispPtr;
-
- if (dispPtr->eventualGrabWinPtr == winPtr) {
- /*
- * Grab window was deleted. Release the grab.
- */
-
- Tk_Ungrab((Tk_Window) dispPtr->eventualGrabWinPtr);
- } else if (dispPtr->buttonWinPtr == winPtr) {
- ReleaseButtonGrab(dispPtr);
- }
- if (dispPtr->serverWinPtr == winPtr) {
- if (winPtr->flags & TK_TOP_LEVEL) {
- dispPtr->serverWinPtr = NULL;
- } else {
- dispPtr->serverWinPtr = winPtr->parentPtr;
- }
- }
- if (dispPtr->grabWinPtr == winPtr) {
- dispPtr->grabWinPtr = NULL;
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * EatGrabEvents --
- *
- * This procedure is called to eliminate any Enter, Leave,
- * FocusIn, or FocusOut events in the event queue for a
- * display that have mode NotifyGrab or NotifyUngrab and
- * have a serial number no less than a given value and are not
- * generated by the grab module.
- *
- * Results:
- * None.
- *
- * Side effects:
- * DispPtr's display gets sync-ed, and some of the events get
- * removed from the Tk event queue.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-EatGrabEvents(dispPtr, serial)
- TkDisplay *dispPtr; /* Display from which to consume events. */
- unsigned int serial; /* Only discard events that have a serial
- * number at least this great. */
-{
- Tk_RestrictProc *oldProc;
- GrabInfo info;
- ClientData oldArg, dummy;
-
- info.display = dispPtr->display;
- info.serial = serial;
- TkpSync(info.display);
- oldProc = Tk_RestrictEvents(GrabRestrictProc, (ClientData)&info, &oldArg);
- while (Tcl_ServiceEvent(TCL_WINDOW_EVENTS)) {
- }
- Tk_RestrictEvents(oldProc, oldArg, &dummy);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * GrabRestrictProc --
- *
- * A Tk_RestrictProc used by EatGrabEvents to eliminate any
- * Enter, Leave, FocusIn, or FocusOut events in the event queue
- * for a display that has mode NotifyGrab or NotifyUngrab and
- * have a serial number no less than a given value.
- *
- * Results:
- * Returns either TK_DISCARD_EVENT or TK_DEFER_EVENT.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static Tk_RestrictAction
-GrabRestrictProc(arg, eventPtr)
- ClientData arg;
- XEvent *eventPtr;
-{
- GrabInfo *info = (GrabInfo *) arg;
- int mode, diff;
-
- /*
- * The diff caculation is trickier than it may seem. Don't forget
- * that serial numbers can wrap around, so can't compare the two
- * serial numbers directly.
- */
-
- diff = eventPtr->xany.serial - info->serial;
- if ((eventPtr->type == EnterNotify)
- || (eventPtr->type == LeaveNotify)) {
- mode = eventPtr->xcrossing.mode;
- } else if ((eventPtr->type == FocusIn)
- || (eventPtr->type == FocusOut)) {
- mode = eventPtr->xfocus.mode;
- } else {
- mode = NotifyNormal;
- }
- if ((info->display != eventPtr->xany.display) || (mode == NotifyNormal)
- || (diff < 0)) {
- return TK_DEFER_EVENT;
- } else {
- return TK_DISCARD_EVENT;
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * QueueGrabWindowChange --
- *
- * This procedure queues a special event in the Tcl event queue,
- * which will cause the "grabWinPtr" field for the display to get
- * modified when the event is processed. This is needed to make
- * sure that the grab window changes at the proper time relative
- * to grab-related enter and leave events that are also in the
- * queue. In particular, this approach works even when multiple
- * grabs and ungrabs happen back-to-back.
- *
- * Results:
- * None.
- *
- * Side effects:
- * DispPtr->grabWinPtr will be modified later (by GrabWinEventProc)
- * when the event is removed from the grab event queue.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-QueueGrabWindowChange(dispPtr, grabWinPtr)
- TkDisplay *dispPtr; /* Display on which to change the grab
- * window. */
- TkWindow *grabWinPtr; /* Window that is to become the new grab
- * window (may be NULL). */
-{
- NewGrabWinEvent *grabEvPtr;
-
- grabEvPtr = (NewGrabWinEvent *) ckalloc(sizeof(NewGrabWinEvent));
- grabEvPtr->header.proc = GrabWinEventProc;
- grabEvPtr->dispPtr = dispPtr;
- if (grabWinPtr == NULL) {
- grabEvPtr->grabWindow = None;
- } else {
- grabEvPtr->grabWindow = grabWinPtr->window;
- }
- Tcl_QueueEvent(&grabEvPtr->header, TCL_QUEUE_MARK);
- dispPtr->eventualGrabWinPtr = grabWinPtr;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * GrabWinEventProc --
- *
- * This procedure is invoked as a handler for Tcl_Events of type
- * NewGrabWinEvent. It updates the current grab window field in
- * a display.
- *
- * Results:
- * Returns 1 if the event was processed, 0 if it should be deferred
- * for processing later.
- *
- * Side effects:
- * The grabWinPtr field is modified in the display associated with
- * the event.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-GrabWinEventProc(evPtr, flags)
- Tcl_Event *evPtr; /* Event of type NewGrabWinEvent. */
- int flags; /* Flags argument to Tk_DoOneEvent: indicates
- * what kinds of events are being processed
- * right now. */
-{
- NewGrabWinEvent *grabEvPtr = (NewGrabWinEvent *) evPtr;
-
- grabEvPtr->dispPtr->grabWinPtr = (TkWindow *) Tk_IdToWindow(
- grabEvPtr->dispPtr->display, grabEvPtr->grabWindow);
- return 1;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * FindCommonAncestor --
- *
- * Given two windows, this procedure finds their least common
- * ancestor and also computes how many levels up this ancestor
- * is from each of the original windows.
- *
- * Results:
- * If the windows are in different applications or top-level
- * windows, then NULL is returned and *countPtr1 and *countPtr2
- * are set to the depths of the two windows in their respective
- * top-level windows (1 means the window is a top-level, 2 means
- * its parent is a top-level, and so on). Otherwise, the return
- * value is a pointer to the common ancestor and the counts are
- * set to the distance of winPtr1 and winPtr2 from this ancestor
- * (1 means they're children, 2 means grand-children, etc.).
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static TkWindow *
-FindCommonAncestor(winPtr1, winPtr2, countPtr1, countPtr2)
- TkWindow *winPtr1; /* First window. May be NULL. */
- TkWindow *winPtr2; /* Second window. May be NULL. */
- int *countPtr1; /* Store nesting level of winPtr1 within
- * common ancestor here. */
- int *countPtr2; /* Store nesting level of winPtr2 within
- * common ancestor here. */
-{
- register TkWindow *winPtr;
- TkWindow *ancestorPtr;
- int count1, count2, i;
-
- /*
- * Mark winPtr1 and all of its ancestors with a special flag bit.
- */
-
- if (winPtr1 != NULL) {
- for (winPtr = winPtr1; winPtr != NULL; winPtr = winPtr->parentPtr) {
- winPtr->flags |= TK_GRAB_FLAG;
- if (winPtr->flags & TK_TOP_LEVEL) {
- break;
- }
- }
- }
-
- /*
- * Search upwards from winPtr2 until an ancestor of winPtr1 is
- * found or a top-level window is reached.
- */
-
- winPtr = winPtr2;
- count2 = 0;
- ancestorPtr = NULL;
- if (winPtr2 != NULL) {
- for (; winPtr != NULL; count2++, winPtr = winPtr->parentPtr) {
- if (winPtr->flags & TK_GRAB_FLAG) {
- ancestorPtr = winPtr;
- break;
- }
- if (winPtr->flags & TK_TOP_LEVEL) {
- count2++;
- break;
- }
- }
- }
-
- /*
- * Search upwards from winPtr1 again, clearing the flag bits and
- * remembering how many levels up we had to go.
- */
-
- if (winPtr1 == NULL) {
- count1 = 0;
- } else {
- count1 = -1;
- for (i = 0, winPtr = winPtr1; winPtr != NULL;
- i++, winPtr = winPtr->parentPtr) {
- winPtr->flags &= ~TK_GRAB_FLAG;
- if (winPtr == ancestorPtr) {
- count1 = i;
- }
- if (winPtr->flags & TK_TOP_LEVEL) {
- if (count1 == -1) {
- count1 = i+1;
- }
- break;
- }
- }
- }
-
- *countPtr1 = count1;
- *countPtr2 = count2;
- return ancestorPtr;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkPositionInTree --
- *
- * Compute where the given window is relative to a particular
- * subtree of the window hierarchy.
- *
- * Results:
- *
- * Returns TK_GRAB_IN_TREE if the window is contained in the
- * subtree. Returns TK_GRAB_ANCESTOR if the window is an
- * ancestor of the subtree, in the same toplevel. Otherwise
- * it returns TK_GRAB_EXCLUDED.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-int
-TkPositionInTree(winPtr, treePtr)
- TkWindow *winPtr; /* Window to be checked. */
- TkWindow *treePtr; /* Root of tree to compare against. */
-{
- TkWindow *winPtr2;
-
- for (winPtr2 = winPtr; winPtr2 != treePtr;
- winPtr2 = winPtr2->parentPtr) {
- if (winPtr2 == NULL) {
- for (winPtr2 = treePtr; winPtr2 != NULL;
- winPtr2 = winPtr2->parentPtr) {
- if (winPtr2 == winPtr) {
- return TK_GRAB_ANCESTOR;
- }
- if (winPtr2->flags & TK_TOP_LEVEL) {
- break;
- }
- }
- return TK_GRAB_EXCLUDED;
- }
- }
- return TK_GRAB_IN_TREE;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkGrabState --
- *
- * Given a window, this procedure returns a value that indicates
- * the grab state of the application relative to the window.
- *
- * Results:
- * The return value is one of three things:
- * TK_GRAB_NONE - no grab is in effect.
- * TK_GRAB_IN_TREE - there is a grab in effect, and winPtr
- * is in the grabbed subtree.
- * TK_GRAB_ANCESTOR - there is a grab in effect; winPtr is
- * an ancestor of the grabbed window, in
- * the same toplevel.
- * TK_GRAB_EXCLUDED - there is a grab in effect; winPtr is
- * outside the tree of the grab and is not
- * an ancestor of the grabbed window in the
- * same toplevel.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-int
-TkGrabState(winPtr)
- TkWindow *winPtr; /* Window for which grab information is
- * needed. */
-{
- TkWindow *grabWinPtr = winPtr->dispPtr->grabWinPtr;
-
- if (grabWinPtr == NULL) {
- return TK_GRAB_NONE;
- }
- if ((winPtr->mainPtr != grabWinPtr->mainPtr)
- && !(winPtr->dispPtr->grabFlags & GRAB_GLOBAL)) {
- return TK_GRAB_NONE;
- }
-
- return TkPositionInTree(winPtr, grabWinPtr);
-}
diff --git a/generic/tkGrid.c b/generic/tkGrid.c
deleted file mode 100644
index 46aa699..0000000
--- a/generic/tkGrid.c
+++ /dev/null
@@ -1,2615 +0,0 @@
-/*
- * tkGrid.c --
- *
- * Grid based geometry manager.
- *
- * Copyright (c) 1996-1997 by 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: tkGrid.c,v 1.2 1998/09/14 18:23:12 stanton Exp $
- */
-
-#include "tkInt.h"
-
-/*
- * Convenience Macros
- */
-
-#ifdef MAX
-# undef MAX
-#endif
-#define MAX(x,y) ((x) > (y) ? (x) : (y))
-#ifdef MIN
-# undef MIN
-#endif
-#define MIN(x,y) ((x) > (y) ? (y) : (x))
-
-#define COLUMN (1) /* working on column offsets */
-#define ROW (2) /* working on row offsets */
-
-#define CHECK_ONLY (1) /* check max slot constraint */
-#define CHECK_SPACE (2) /* alloc more space, don't change max */
-
-/*
- * Pre-allocate enough row and column slots for "typical" sized tables
- * this value should be chosen so by the time the extra malloc's are
- * required, the layout calculations overwehlm them. [A "slot" contains
- * information for either a row or column, depending upon the context.]
- */
-
-#define TYPICAL_SIZE 25 /* (arbitrary guess) */
-#define PREALLOC 10 /* extra slots to allocate */
-
-/*
- * Data structures are allocated dynamically to support arbitrary sized tables.
- * However, the space is proportional to the highest numbered slot with
- * some non-default property. This limit is used to head off mistakes and
- * denial of service attacks by limiting the amount of storage required.
- */
-
-#define MAX_ELEMENT 10000
-
-/*
- * Special characters to support relative layouts.
- */
-
-#define REL_SKIP 'x' /* Skip this column. */
-#define REL_HORIZ '-' /* Extend previous widget horizontally. */
-#define REL_VERT '^' /* Extend widget from row above. */
-
-/*
- * Structure to hold information for grid masters. A slot is either
- * a row or column.
- */
-
-typedef struct SlotInfo {
- int minSize; /* The minimum size of this slot (in pixels).
- * It is set via the rowconfigure or
- * columnconfigure commands. */
- int weight; /* The resize weight of this slot. (0) means
- * this slot doesn't resize. Extra space in
- * the layout is given distributed among slots
- * inproportion to their weights. */
- int pad; /* Extra padding, in pixels, required for
- * this slot. This amount is "added" to the
- * largest slave in the slot. */
- int offset; /* This is a cached value used for
- * introspection. It is the pixel
- * offset of the right or bottom edge
- * of this slot from the beginning of the
- * layout. */
- int temp; /* This is a temporary value used for
- * calculating adjusted weights when
- * shrinking the layout below its
- * nominal size. */
-} SlotInfo;
-
-/*
- * Structure to hold information during layout calculations. There
- * is one of these for each slot, an array for each of the rows or columns.
- */
-
-typedef struct GridLayout {
- struct Gridder *binNextPtr; /* The next slave window in this bin.
- * Each bin contains a list of all
- * slaves whose spans are >1 and whose
- * right edges fall in this slot. */
- int minSize; /* Minimum size needed for this slot,
- * in pixels. This is the space required
- * to hold any slaves contained entirely
- * in this slot, adjusted for any slot
- * constrants, such as size or padding. */
- int pad; /* Padding needed for this slot */
- int weight; /* Slot weight, controls resizing. */
- int minOffset; /* The minimum offset, in pixels, from
- * the beginning of the layout to the
- * right/bottom edge of the slot calculated
- * from top/left to bottom/right. */
- int maxOffset; /* The maximum offset, in pixels, from
- * the beginning of the layout to the
- * right-or-bottom edge of the slot calculated
- * from bottom-or-right to top-or-left. */
-} GridLayout;
-
-/*
- * Keep one of these for each geometry master.
- */
-
-typedef struct {
- SlotInfo *columnPtr; /* Pointer to array of column constraints. */
- SlotInfo *rowPtr; /* Pointer to array of row constraints. */
- int columnEnd; /* The last column occupied by any slave. */
- int columnMax; /* The number of columns with constraints. */
- int columnSpace; /* The number of slots currently allocated for
- * column constraints. */
- int rowEnd; /* The last row occupied by any slave. */
- int rowMax; /* The number of rows with constraints. */
- int rowSpace; /* The number of slots currently allocated
- * for row constraints. */
- int startX; /* Pixel offset of this layout within its
- * parent. */
- int startY; /* Pixel offset of this layout within its
- * parent. */
-} GridMaster;
-
-/*
- * For each window that the grid cares about (either because
- * the window is managed by the grid or because the window
- * has slaves that are managed by the grid), there is a
- * structure of the following type:
- */
-
-typedef struct Gridder {
- Tk_Window tkwin; /* Tk token for window. NULL means that
- * the window has been deleted, but the
- * gridder hasn't had a chance to clean up
- * yet because the structure is still in
- * use. */
- struct Gridder *masterPtr; /* Master window within which this window
- * is managed (NULL means this window
- * isn't managed by the gridder). */
- struct Gridder *nextPtr; /* Next window managed within same
- * parent. List order doesn't matter. */
- struct Gridder *slavePtr; /* First in list of slaves managed
- * inside this window (NULL means
- * no grid slaves). */
- GridMaster *masterDataPtr; /* Additional data for geometry master. */
- int column, row; /* Location in the grid (starting
- * from zero). */
- 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:
- * we'll allocate extra space in frame but
- * won't enlarge window). */
- int iPadX, iPadY; /* Total extra pixels to allocate inside the
- * window (half this amount will appear on
- * each side). */
- int sticky; /* which sides of its cavity this window
- * sticks to. See below for definitions */
- int doubleBw; /* Twice the window's last known border
- * width. If this changes, the window
- * must be re-arranged within its parent. */
- int *abortPtr; /* If non-NULL, it means that there is a nested
- * call to ArrangeGrid already working on
- * this window. *abortPtr may be set to 1 to
- * abort that nested call. This happens, for
- * example, if tkwin or any of its slaves
- * is deleted. */
- int flags; /* Miscellaneous flags; see below
- * for definitions. */
-
- /*
- * These fields are used temporarily for layout calculations only.
- */
-
- struct Gridder *binNextPtr; /* Link to next span>1 slave in this bin. */
- int size; /* Nominal size (width or height) in pixels
- * of the slave. This includes the padding. */
-} Gridder;
-
-/* 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
-
-/*
- * Flag values for Grid structures:
- *
- * REQUESTED_RELAYOUT: 1 means a Tcl_DoWhenIdle request
- * has already been made to re-arrange
- * all the slaves of this window.
- *
- * DONT_PROPAGATE: 1 means don't set this window's requested
- * size. 0 means if this window is a master
- * then Tk will set its requested size to fit
- * the needs of its slaves.
- */
-
-#define REQUESTED_RELAYOUT 1
-#define DONT_PROPAGATE 2
-
-/*
- * Hash table used to map from Tk_Window tokens to corresponding
- * Grid structures:
- */
-
-static Tcl_HashTable gridHashTable;
-static int initialized = 0;
-
-/*
- * Prototypes for procedures used only in this file:
- */
-
-static void AdjustForSticky _ANSI_ARGS_((Gridder *slavePtr, int *xPtr,
- int *yPtr, int *widthPtr, int *heightPtr));
-static int AdjustOffsets _ANSI_ARGS_((int width,
- int elements, SlotInfo *slotPtr));
-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[]));
-static void DestroyGrid _ANSI_ARGS_((char *memPtr));
-static Gridder *GetGrid _ANSI_ARGS_((Tk_Window tkwin));
-static void GridStructureProc _ANSI_ARGS_((
- ClientData clientData, XEvent *eventPtr));
-static void GridLostSlaveProc _ANSI_ARGS_((ClientData clientData,
- Tk_Window tkwin));
-static void GridReqProc _ANSI_ARGS_((ClientData clientData,
- Tk_Window tkwin));
-static void InitMasterData _ANSI_ARGS_((Gridder *masterPtr));
-static int ResolveConstraints _ANSI_ARGS_((Gridder *gridPtr,
- int rowOrColumn, int maxOffset));
-static void SetGridSize _ANSI_ARGS_((Gridder *gridPtr));
-static void StickyToString _ANSI_ARGS_((int flags, char *result));
-static int StringToSticky _ANSI_ARGS_((char *string));
-static void Unlink _ANSI_ARGS_((Gridder *gridPtr));
-
-static Tk_GeomMgr gridMgrType = {
- "grid", /* name */
- GridReqProc, /* requestProc */
- GridLostSlaveProc, /* lostSlaveProc */
-};
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_GridCmd --
- *
- * This procedure is invoked to process the "grid" 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_GridCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Main window associated with
- * interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- 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 */
-
- 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 (argc < 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " option arg ?arg ...?\"", (char *) NULL);
- 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 */
-
- 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) {
- sprintf(interp->result, "%d %d %d %d",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)) {
- sprintf(interp->result, "%d %d %d %d",0,0,0,0);
- return(TCL_OK);
- }
- if (argc == 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;
- }
-
- sprintf(interp->result, "%d %d %d %d",
- x + gridPtr->startX, y + gridPtr->startY, width, height);
- } 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;
-
- 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;
- 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[70];
-
- 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) {
- interp->result[0] = '\0';
- 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);
- 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 */
-
- if (argc != 5) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " location master x y\"", (char *)NULL);
- return TCL_ERROR;
- }
-
- master = Tk_NameToWindow(interp, argv[2], tkwin);
- if (master == NULL) {
- return TCL_ERROR;
- }
-
- if (Tk_GetPixels(interp, master, argv[3], &x) != TCL_OK) {
- return TCL_ERROR;
- }
- if (Tk_GetPixels(interp, master, argv[4], &y) != TCL_OK) {
- return TCL_ERROR;
- }
-
- masterPtr = GetGrid(master);
- if (masterPtr->masterDataPtr == NULL) {
- sprintf(interp->result, "%d %d", -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) {
- Tk_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(interp->result, "%d %d", i, j);
- } else if ((c == 'p') && (strncmp(argv[1], "propagate", length) == 0)) {
- Tk_Window master;
- int propagate;
-
- 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) {
- return TCL_ERROR;
- }
- masterPtr = GetGrid(master);
- if (argc == 3) {
- interp->result = (masterPtr->flags & DONT_PROPAGATE) ? "0" : "1";
- return TCL_OK;
- }
- if (Tcl_GetBoolean(interp, argv[3], &propagate) != TCL_OK) {
- return TCL_ERROR;
- }
- if ((!propagate) ^ (masterPtr->flags&DONT_PROPAGATE)) {
- masterPtr->flags ^= DONT_PROPAGATE;
-
- /*
- * Re-arrange the master to allow new geometry information to
- * propagate upwards to the master's master.
- */
-
- if (masterPtr->abortPtr != NULL) {
- *masterPtr->abortPtr = 1;
- }
- if (!(masterPtr->flags & REQUESTED_RELAYOUT)) {
- masterPtr->flags |= REQUESTED_RELAYOUT;
- Tcl_DoWhenIdle(ArrangeGrid, (ClientData) masterPtr);
- }
- }
- } else if ((c == 's') && (strncmp(argv[1], "size", length) == 0)
- && (length > 1)) {
- Tk_Window master;
-
- if (argc != 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " size window\"", (char *) NULL);
- return TCL_ERROR;
- }
- master = Tk_NameToWindow(interp, argv[2], tkwin);
- if (master == NULL) {
- return TCL_ERROR;
- }
- masterPtr = GetGrid(master);
-
- if (masterPtr->masterDataPtr != NULL) {
- SetGridSize(masterPtr);
- gridPtr = masterPtr->masterDataPtr;
- sprintf(interp->result, "%d %d",
- MAX(gridPtr->columnEnd, gridPtr->columnMax),
- MAX(gridPtr->rowEnd, gridPtr->rowMax));
- } else {
- sprintf(interp->result, "%d %d",0, 0);
- }
- } 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; i<argc; i+=2) {
- length = strlen(argv[i]);
- if ((*argv[i] != '-') || (length < 2)) {
- Tcl_AppendResult(interp, "invalid args: should be \"",
- argv[0], " slaves window ?-option value...?\"",
- (char *) NULL);
- return TCL_ERROR;
- }
- if (Tcl_GetInt(interp, argv[i+1], &value) != TCL_OK) {
- return TCL_ERROR;
- }
- if (value < 0) {
- Tcl_AppendResult(interp, argv[i],
- " is an invalid value: should NOT be < 0",
- (char *) NULL);
- return TCL_ERROR;
- }
- if (strncmp(argv[i], "-column", length) == 0) {
- column = value;
- } else if (strncmp(argv[i], "-row", length) == 0) {
- row = value;
- } else {
- Tcl_AppendResult(interp, argv[i],
- " is an invalid option: should be \"",
- "-row, -column\"",
- (char *) NULL);
- return TCL_ERROR;
- }
- }
- master = Tk_NameToWindow(interp, argv[2], tkwin);
- if (master == NULL) {
- return TCL_ERROR;
- }
- masterPtr = GetGrid(master);
-
- 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_AppendElement(interp, Tk_PathName(slavePtr->tkwin));
- }
-
- /*
- * Sample argument combinations:
- * grid columnconfigure <master> <index> -option
- * grid columnconfigure <master> <index> -option value -option value
- * grid rowconfigure <master> <index>
- * grid rowconfigure <master> <index> -option
- * grid rowconfigure <master> <index> -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;
- }
-
- master = Tk_NameToWindow(interp, argv[2], tkwin);
- if (master == NULL) {
- return TCL_ERROR;
- }
-
- if (Tcl_SplitList(interp, argv[3], &argcPtr, &argvPtr) != 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);
- return TCL_ERROR;
- }
- for (indexP=argvPtr; *indexP != NULL; indexP++) {
- if (Tcl_GetInt(interp, *indexP, &slot) != TCL_OK) {
- Tcl_Free((char *)argvPtr);
- return TCL_ERROR;
- }
- 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);
- 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)) {
- sprintf(interp->result,"-minsize %d -pad %d -weight %d",
- slotPtr[slot].minSize,slotPtr[slot].pad,
- slotPtr[slot].weight);
- return (TCL_OK);
- } else if (argc == 4) {
- sprintf(interp->result,"-minsize %d -pad %d -weight %d", 0,0,0);
- 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<argc; i+=2) {
- length = strlen(argv[i]);
- if ((*argv[i] != '-') || length < 2) {
- Tcl_AppendResult(interp, "invalid arg \"",
- argv[i], "\" :expecting -minsize, -pad, or -weight.",
- (char *) NULL);
- Tcl_Free((char *)argvPtr);
- return TCL_ERROR;
- }
- if (strncmp(argv[i], "-minsize", length) == 0) {
- if (argc == 5) {
- int value = ok == TCL_OK ? slotPtr[slot].minSize : 0;
- sprintf(interp->result,"%d",value);
- } else if (Tk_GetPixels(interp, master, argv[i+1], &size)
- != TCL_OK) {
- Tcl_Free((char *)argvPtr);
- return TCL_ERROR;
- } else {
- slotPtr[slot].minSize = size;
- }
- }
- else if (strncmp(argv[i], "-weight", length) == 0) {
- int wt;
- if (argc == 5) {
- int value = ok == TCL_OK ? slotPtr[slot].weight : 0;
- sprintf(interp->result,"%d",value);
- } else if (Tcl_GetInt(interp, argv[i+1], &wt) != TCL_OK) {
- Tcl_Free((char *)argvPtr);
- return TCL_ERROR;
- } else if (wt < 0) {
- Tcl_AppendResult(interp, "invalid arg \"", argv[i],
- "\": should be non-negative", (char *) NULL);
- Tcl_Free((char *)argvPtr);
- return TCL_ERROR;
- } else {
- slotPtr[slot].weight = wt;
- }
- }
- else if (strncmp(argv[i], "-pad", length) == 0) {
- if (argc == 5) {
- int value = ok == TCL_OK ? slotPtr[slot].pad : 0;
- sprintf(interp->result,"%d",value);
- } else if (Tk_GetPixels(interp, master, argv[i+1], &size)
- != TCL_OK) {
- Tcl_Free((char *)argvPtr);
- return TCL_ERROR;
- } else if (size < 0) {
- Tcl_AppendResult(interp, "invalid arg \"", argv[i],
- "\": should be non-negative", (char *) NULL);
- Tcl_Free((char *)argvPtr);
- return TCL_ERROR;
- } else {
- slotPtr[slot].pad = size;
- }
- } else {
- Tcl_AppendResult(interp, "invalid arg \"",
- argv[i], "\": expecting -minsize, -pad, or -weight.",
- (char *) NULL);
- Tcl_Free((char *)argvPtr);
- return TCL_ERROR;
- }
- }
- }
- Tcl_Free((char *)argvPtr);
-
- /*
- * If we changed a property, re-arrange the table,
- * and check for constraint shrinkage.
- */
-
- if (argc != 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)) {
- 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 (!(masterPtr->flags & REQUESTED_RELAYOUT)) {
- masterPtr->flags |= REQUESTED_RELAYOUT;
- Tcl_DoWhenIdle(ArrangeGrid, (ClientData) masterPtr);
- }
- }
- } else {
- Tcl_AppendResult(interp, "bad option \"", argv[1],
- "\": must be bbox, columnconfigure, configure, forget, info, ",
- "location, propagate, remove, rowconfigure, size, or slaves.",
- (char *) NULL);
- return TCL_ERROR;
- }
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * GridReqProc --
- *
- * This procedure is invoked by Tk_GeometryRequest for
- * windows managed by the grid.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Arranges for tkwin, and all its managed siblings, to
- * be re-arranged at the next idle point.
- *
- *--------------------------------------------------------------
- */
-
-static void
-GridReqProc(clientData, tkwin)
- ClientData clientData; /* Grid's information about
- * window that got new preferred
- * geometry. */
- Tk_Window tkwin; /* Other Tk-related information
- * about the window. */
-{
- register Gridder *gridPtr = (Gridder *) clientData;
-
- gridPtr = gridPtr->masterPtr;
- if (!(gridPtr->flags & REQUESTED_RELAYOUT)) {
- gridPtr->flags |= REQUESTED_RELAYOUT;
- Tcl_DoWhenIdle(ArrangeGrid, (ClientData) gridPtr);
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * GridLostSlaveProc --
- *
- * 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 grid-related information about the slave.
- *
- *--------------------------------------------------------------
- */
-
-static void
-GridLostSlaveProc(clientData, tkwin)
- ClientData clientData; /* Grid structure for slave window that
- * was stolen away. */
- Tk_Window tkwin; /* Tk's handle for the slave window. */
-{
- register Gridder *slavePtr = (Gridder *) clientData;
-
- if (slavePtr->masterPtr->tkwin != Tk_Parent(slavePtr->tkwin)) {
- Tk_UnmaintainGeometry(slavePtr->tkwin, slavePtr->masterPtr->tkwin);
- }
- Unlink(slavePtr);
- Tk_UnmapWindow(slavePtr->tkwin);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * AdjustOffsets --
- *
- * This procedure adjusts the size of the layout to fit in the
- * space provided. If it needs more space, the extra is added
- * according to the weights. If it needs less, the space is removed
- * according to the weights, but at no time does the size drop below
- * the minsize specified for that slot.
- *
- * Results:
- * The initial offset of the layout,
- * if all the weights are zero, else 0.
- *
- * Side effects:
- * The slot offsets are modified to shrink the layout.
- *
- *--------------------------------------------------------------
- */
-
-static int
-AdjustOffsets(size, slots, slotPtr)
- int size; /* The total layout size (in pixels). */
- int slots; /* Number of slots. */
- register SlotInfo *slotPtr; /* Pointer to slot array. */
-{
- register int slot; /* Current slot. */
- int diff; /* Extra pixels needed to add to the layout. */
- int totalWeight = 0; /* Sum of the weights for all the slots. */
- int weight = 0; /* Sum of the weights so far. */
- int minSize = 0; /* Minimum possible layout size. */
- int newDiff; /* The most pixels that can be added on
- * the current pass. */
-
- diff = size - slotPtr[slots-1].offset;
-
- /*
- * The layout is already the correct size; all done.
- */
-
- if (diff == 0) {
- return(0);
- }
-
- /*
- * If all the weights are zero, center the layout in its parent if
- * there is extra space, else clip on the bottom/right.
- */
-
- for (slot=0; slot < slots; slot++) {
- totalWeight += slotPtr[slot].weight;
- }
-
- if (totalWeight == 0 ) {
- return(diff > 0 ? diff/2 : 0);
- }
-
- /*
- * Add extra space according to the slot weights. This is done
- * cumulatively to prevent round-off error accumulation.
- */
-
- if (diff > 0) {
- for (weight=slot=0; slot < slots; slot++) {
- weight += slotPtr[slot].weight;
- slotPtr[slot].offset += diff * weight / totalWeight;
- }
- return(0);
- }
-
- /*
- * The layout must shrink below its requested size. Compute the
- * minimum possible size by looking at the slot minSizes.
- */
-
- for (slot=0; slot < slots; slot++) {
- if (slotPtr[slot].weight > 0) {
- minSize += slotPtr[slot].minSize;
- } else if (slot > 0) {
- minSize += slotPtr[slot].offset - slotPtr[slot-1].offset;
- } else {
- minSize += slotPtr[slot].offset;
- }
- }
-
- /*
- * If the requested size is less than the minimum required size,
- * set the slot sizes to their minimum values, then clip on the
- * bottom/right.
- */
-
- if (size <= minSize) {
- int offset = 0;
- for (slot=0; slot < slots; slot++) {
- if (slotPtr[slot].weight > 0) {
- offset += slotPtr[slot].minSize;
- } else if (slot > 0) {
- offset += slotPtr[slot].offset - slotPtr[slot-1].offset;
- } else {
- offset += slotPtr[slot].offset;
- }
- slotPtr[slot].offset = offset;
- }
- return(0);
- }
-
- /*
- * Remove space from slots according to their weights. The weights
- * get renormalized anytime a slot shrinks to its minimum size.
- */
-
- while (diff < 0) {
-
- /*
- * Find the total weight for the shrinkable slots.
- */
-
- for (totalWeight=slot=0; slot < slots; slot++) {
- int current = (slot == 0) ? slotPtr[slot].offset :
- slotPtr[slot].offset - slotPtr[slot-1].offset;
- if (current > slotPtr[slot].minSize) {
- totalWeight += slotPtr[slot].weight;
- slotPtr[slot].temp = slotPtr[slot].weight;
- } else {
- slotPtr[slot].temp = 0;
- }
- }
- if (totalWeight == 0) {
- break;
- }
-
- /*
- * Find the maximum amount of space we can distribute this pass.
- */
-
- newDiff = diff;
- for (slot = 0; slot < slots; slot++) {
- int current; /* current size of this slot */
- int maxDiff; /* max diff that would cause
- * this slot to equal its minsize */
- if (slotPtr[slot].temp == 0) {
- continue;
- }
- current = (slot == 0) ? slotPtr[slot].offset :
- slotPtr[slot].offset - slotPtr[slot-1].offset;
- maxDiff = totalWeight * (slotPtr[slot].minSize - current)
- / slotPtr[slot].temp;
- if (maxDiff > newDiff) {
- newDiff = maxDiff;
- }
- }
-
- /*
- * Now distribute the space.
- */
-
- for (weight=slot=0; slot < slots; slot++) {
- weight += slotPtr[slot].temp;
- slotPtr[slot].offset += newDiff * weight / totalWeight;
- }
- diff -= newDiff;
- }
- return(0);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * AdjustForSticky --
- *
- * This procedure adjusts the size of a slave in its cavity based
- * on its "sticky" flags.
- *
- * Results:
- * The input x, y, width, and height are changed to represent the
- * desired coordinates of the slave.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-static void
-AdjustForSticky(slavePtr, xPtr, yPtr, widthPtr, heightPtr)
- Gridder *slavePtr; /* Slave window to arrange in its cavity. */
- int *xPtr; /* Pixel location of the left edge of the cavity. */
- int *yPtr; /* Pixel location of the top edge of the cavity. */
- int *widthPtr; /* Width of the cavity (in pixels). */
- int *heightPtr; /* Height of the cavity (in pixels). */
-{
- int diffx=0; /* Cavity width - slave width. */
- int diffy=0; /* Cavity hight - slave height. */
- int sticky = slavePtr->sticky;
-
- *xPtr += slavePtr->padX/2;
- *widthPtr -= slavePtr->padX;
- *yPtr += slavePtr->padY/2;
- *heightPtr -= slavePtr->padY;
-
- if (*widthPtr > (Tk_ReqWidth(slavePtr->tkwin) + slavePtr->iPadX)) {
- diffx = *widthPtr - (Tk_ReqWidth(slavePtr->tkwin) + slavePtr->iPadX);
- *widthPtr = Tk_ReqWidth(slavePtr->tkwin) + slavePtr->iPadX;
- }
-
- if (*heightPtr > (Tk_ReqHeight(slavePtr->tkwin) + slavePtr->iPadY)) {
- diffy = *heightPtr - (Tk_ReqHeight(slavePtr->tkwin) + slavePtr->iPadY);
- *heightPtr = Tk_ReqHeight(slavePtr->tkwin) + slavePtr->iPadY;
- }
-
- if (sticky&STICK_EAST && sticky&STICK_WEST) {
- *widthPtr += diffx;
- }
- if (sticky&STICK_NORTH && sticky&STICK_SOUTH) {
- *heightPtr += diffy;
- }
- if (!(sticky&STICK_WEST)) {
- *xPtr += (sticky&STICK_EAST) ? diffx : diffx/2;
- }
- if (!(sticky&STICK_NORTH)) {
- *yPtr += (sticky&STICK_SOUTH) ? diffy : diffy/2;
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ArrangeGrid --
- *
- * This procedure is invoked (using the Tcl_DoWhenIdle
- * mechanism) to re-layout a set of windows managed by
- * the grid. It is invoked at idle time so that a
- * series of grid requests can be merged into a single
- * layout operation.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The slaves of masterPtr may get resized or moved.
- *
- *--------------------------------------------------------------
- */
-
-static void
-ArrangeGrid(clientData)
- ClientData clientData; /* Structure describing parent whose slaves
- * are to be re-layed out. */
-{
- register Gridder *masterPtr = (Gridder *) clientData;
- register Gridder *slavePtr;
- GridMaster *slotPtr = masterPtr->masterDataPtr;
- int abort;
- int width, height; /* requested size of layout, in pixels */
- int realWidth, realHeight; /* actual size layout should take-up */
-
- masterPtr->flags &= ~REQUESTED_RELAYOUT;
-
- /*
- * 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 (masterPtr->slavePtr == NULL) {
- return;
- }
-
- if (masterPtr->masterDataPtr == NULL) {
- return;
- }
-
- /*
- * Abort any nested call to ArrangeGrid for this window, since
- * we'll do everything necessary here, and set up so this call
- * can be aborted if necessary.
- */
-
- if (masterPtr->abortPtr != NULL) {
- *masterPtr->abortPtr = 1;
- }
- masterPtr->abortPtr = &abort;
- abort = 0;
- Tcl_Preserve((ClientData) masterPtr);
-
- /*
- * Call the constraint engine to fill in the row and column offsets.
- */
-
- SetGridSize(masterPtr);
- width = ResolveConstraints(masterPtr, COLUMN, 0);
- height = ResolveConstraints(masterPtr, ROW, 0);
- width += 2*Tk_InternalBorderWidth(masterPtr->tkwin);
- height += 2*Tk_InternalBorderWidth(masterPtr->tkwin);
-
- if (((width != Tk_ReqWidth(masterPtr->tkwin))
- || (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);
- }
- masterPtr->abortPtr = NULL;
- Tcl_Release((ClientData) masterPtr);
- return;
- }
-
- /*
- * If the currently requested layout size doesn't match the parent's
- * window size, then adjust the slot offsets according to the
- * weights. If all of the weights are zero, center the layout in
- * its parent. I haven't decided what to do if the parent is smaller
- * than the requested size.
- */
-
- realWidth = Tk_Width(masterPtr->tkwin) -
- 2*Tk_InternalBorderWidth(masterPtr->tkwin);
- realHeight = Tk_Height(masterPtr->tkwin) -
- 2*Tk_InternalBorderWidth(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);
-
- /*
- * Now adjust the actual size of the slave to its cavity by
- * computing the cavity size, and adjusting the widget according
- * to its stickyness.
- */
-
- for (slavePtr = masterPtr->slavePtr; slavePtr != NULL && !abort;
- slavePtr = slavePtr->nextPtr) {
- int x, y; /* top left coordinate */
- int width, height; /* slot or slave size */
- int col = slavePtr->column;
- int row = slavePtr->row;
-
- x = (col>0) ? slotPtr->columnPtr[col-1].offset : 0;
- y = (row>0) ? slotPtr->rowPtr[row-1].offset : 0;
-
- width = slotPtr->columnPtr[slavePtr->numCols+col-1].offset - x;
- height = slotPtr->rowPtr[slavePtr->numRows+row-1].offset - y;
-
- x += slotPtr->startX;
- y += slotPtr->startY;
-
- AdjustForSticky(slavePtr, &x, &y, &width, &height);
-
- /*
- * Now put the window in the proper spot. (This was taken directly
- * from tkPack.c.) If the slave is a child of the master, then
- * do this here. Otherwise let Tk_MaintainGeometry do the work.
- */
-
- if (masterPtr->tkwin == Tk_Parent(slavePtr->tkwin)) {
- if ((width <= 0) || (height <= 0)) {
- Tk_UnmapWindow(slavePtr->tkwin);
- } else {
- if ((x != Tk_X(slavePtr->tkwin))
- || (y != Tk_Y(slavePtr->tkwin))
- || (width != Tk_Width(slavePtr->tkwin))
- || (height != Tk_Height(slavePtr->tkwin))) {
- Tk_MoveResizeWindow(slavePtr->tkwin, x, y, width, height);
- }
- if (abort) {
- break;
- }
-
- /*
- * Don't map the slave if the master isn't mapped: wait
- * until the master gets mapped later.
- */
-
- if (Tk_IsMapped(masterPtr->tkwin)) {
- Tk_MapWindow(slavePtr->tkwin);
- }
- }
- } else {
- if ((width <= 0) || (height <= 0)) {
- Tk_UnmaintainGeometry(slavePtr->tkwin, masterPtr->tkwin);
- Tk_UnmapWindow(slavePtr->tkwin);
- } else {
- Tk_MaintainGeometry(slavePtr->tkwin, masterPtr->tkwin,
- x, y, width, height);
- }
- }
- }
-
- masterPtr->abortPtr = NULL;
- Tcl_Release((ClientData) masterPtr);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ResolveConstraints --
- *
- * Resolve all of the column and row boundaries. Most of
- * the calculations are identical for rows and columns, so this procedure
- * is called twice, once for rows, and again for columns.
- *
- * Results:
- * The offset (in pixels) from the left/top edge of this layout is
- * returned.
- *
- * Side effects:
- * The slot offsets are copied into the SlotInfo structure for the
- * geometry master.
- *
- *--------------------------------------------------------------
- */
-
-static int
-ResolveConstraints(masterPtr, slotType, maxOffset)
- Gridder *masterPtr; /* The geometry master for this grid. */
- int slotType; /* Either ROW or COLUMN. */
- int maxOffset; /* The actual maximum size of this layout
- * in pixels, or 0 (not currently used). */
-{
- register SlotInfo *slotPtr; /* Pointer to row/col constraints. */
- register Gridder *slavePtr; /* List of slave windows in this grid. */
- int constraintCount; /* Count of rows or columns that have
- * constraints. */
- int slotCount; /* Last occupied row or column. */
- int gridCount; /* The larger of slotCount and constraintCount.
- */
- GridLayout *layoutPtr; /* Temporary layout structure. */
- int requiredSize; /* The natural size of the grid (pixels).
- * This is the minimum size needed to
- * accomodate all of the slaves at their
- * requested sizes. */
- int offset; /* The pixel offset of the right edge of the
- * current slot from the beginning of the
- * layout. */
- int slot; /* The current slot. */
- int start; /* The first slot of a contiguous set whose
- * constraints are not yet fully resolved. */
- int end; /* The Last slot of a contiguous set whose
- * constraints are not yet fully resolved. */
-
- /*
- * For typical sized tables, we'll use stack space for the layout data
- * to avoid the overhead of a malloc and free for every layout.
- */
-
- GridLayout layoutData[TYPICAL_SIZE + 1];
-
- if (slotType == COLUMN) {
- constraintCount = masterPtr->masterDataPtr->columnMax;
- slotCount = masterPtr->masterDataPtr->columnEnd;
- slotPtr = masterPtr->masterDataPtr->columnPtr;
- } else {
- constraintCount = masterPtr->masterDataPtr->rowMax;
- slotCount = masterPtr->masterDataPtr->rowEnd;
- slotPtr = masterPtr->masterDataPtr->rowPtr;
- }
-
- /*
- * Make sure there is enough memory for the layout.
- */
-
- gridCount = MAX(constraintCount,slotCount);
- if (gridCount >= TYPICAL_SIZE) {
- layoutPtr = (GridLayout *) Tcl_Alloc(sizeof(GridLayout) * (1+gridCount));
- } else {
- layoutPtr = layoutData;
- }
-
- /*
- * Allocate an extra layout slot to represent the left/top edge of
- * the 0th slot to make it easier to calculate slot widths from
- * offsets without special case code.
- * Initialize the "dummy" slot to the left/top of the table.
- * This slot avoids special casing the first slot.
- */
-
- layoutPtr->minOffset = 0;
- layoutPtr->maxOffset = 0;
- layoutPtr++;
-
- /*
- * Step 1.
- * Copy the slot constraints into the layout structure,
- * and initialize the rest of the fields.
- */
-
- for (slot=0; slot < constraintCount; slot++) {
- layoutPtr[slot].minSize = slotPtr[slot].minSize;
- layoutPtr[slot].weight = slotPtr[slot].weight;
- layoutPtr[slot].pad = slotPtr[slot].pad;
- layoutPtr[slot].binNextPtr = NULL;
- }
- for(;slot<gridCount;slot++) {
- layoutPtr[slot].minSize = 0;
- layoutPtr[slot].weight = 0;
- layoutPtr[slot].pad = 0;
- layoutPtr[slot].binNextPtr = NULL;
- }
-
- /*
- * Step 2.
- * Slaves with a span of 1 are used to determine the minimum size of
- * each slot. Slaves whose span is two or more slots don't
- * contribute to the minimum size of each slot directly, but can cause
- * slots to grow if their size exceeds the the sizes of the slots they
- * span.
- *
- * Bin all slaves whose spans are > 1 by their right edges. This
- * allows the computation on minimum and maximum possible layout
- * sizes at each slot boundary, without the need to re-sort the slaves.
- */
-
- switch (slotType) {
- case COLUMN:
- for (slavePtr = masterPtr->slavePtr; slavePtr != NULL;
- slavePtr = slavePtr->nextPtr) {
- int rightEdge = slavePtr->column + slavePtr->numCols - 1;
- slavePtr->size = Tk_ReqWidth(slavePtr->tkwin) +
- slavePtr->padX + slavePtr->iPadX + slavePtr->doubleBw;
- if (slavePtr->numCols > 1) {
- slavePtr->binNextPtr = layoutPtr[rightEdge].binNextPtr;
- layoutPtr[rightEdge].binNextPtr = slavePtr;
- } else {
- int size = slavePtr->size + layoutPtr[rightEdge].pad;
- if (size > layoutPtr[rightEdge].minSize) {
- layoutPtr[rightEdge].minSize = size;
- }
- }
- }
- break;
- case ROW:
- for (slavePtr = masterPtr->slavePtr; slavePtr != NULL;
- slavePtr = slavePtr->nextPtr) {
- int rightEdge = slavePtr->row + slavePtr->numRows - 1;
- slavePtr->size = Tk_ReqHeight(slavePtr->tkwin) +
- slavePtr->padY + slavePtr->iPadY + slavePtr->doubleBw;
- if (slavePtr->numRows > 1) {
- slavePtr->binNextPtr = layoutPtr[rightEdge].binNextPtr;
- layoutPtr[rightEdge].binNextPtr = slavePtr;
- } else {
- int size = slavePtr->size + layoutPtr[rightEdge].pad;
- if (size > layoutPtr[rightEdge].minSize) {
- layoutPtr[rightEdge].minSize = size;
- }
- }
- }
- break;
- }
-
- /*
- * Step 3.
- * Determine the minimum slot offsets going from left to right
- * that would fit all of the slaves. This determines the minimum
- */
-
- for (offset=slot=0; slot < gridCount; slot++) {
- layoutPtr[slot].minOffset = layoutPtr[slot].minSize + offset;
- for (slavePtr = layoutPtr[slot].binNextPtr; slavePtr != NULL;
- slavePtr = slavePtr->binNextPtr) {
- int span = (slotType == COLUMN) ? slavePtr->numCols : slavePtr->numRows;
- int required = slavePtr->size + layoutPtr[slot - span].minOffset;
- if (required > layoutPtr[slot].minOffset) {
- layoutPtr[slot].minOffset = required;
- }
- }
- offset = layoutPtr[slot].minOffset;
- }
-
- /*
- * At this point, we know the minimum required size of the entire layout.
- * It might be prudent to stop here if our "master" will resize itself
- * to this size.
- */
-
- requiredSize = offset;
- if (maxOffset > offset) {
- offset=maxOffset;
- }
-
- /*
- * Step 4.
- * Determine the minimum slot offsets going from right to left,
- * bounding the pixel range of each slot boundary.
- * Pre-fill all of the right offsets with the actual size of the table;
- * they will be reduced as required.
- */
-
- for (slot=0; slot < gridCount; slot++) {
- layoutPtr[slot].maxOffset = offset;
- }
- for (slot=gridCount-1; slot > 0;) {
- for (slavePtr = layoutPtr[slot].binNextPtr; slavePtr != NULL;
- slavePtr = slavePtr->binNextPtr) {
- int span = (slotType == COLUMN) ? slavePtr->numCols : slavePtr->numRows;
- int require = offset - slavePtr->size;
- int startSlot = slot - span;
- if (startSlot >=0 && require < layoutPtr[startSlot].maxOffset) {
- layoutPtr[startSlot].maxOffset = require;
- }
- }
- offset -= layoutPtr[slot].minSize;
- slot--;
- if (layoutPtr[slot].maxOffset < offset) {
- offset = layoutPtr[slot].maxOffset;
- } else {
- layoutPtr[slot].maxOffset = offset;
- }
- }
-
- /*
- * Step 5.
- * At this point, each slot boundary has a range of values that
- * will satisfy the overall layout size.
- * Make repeated passes over the layout structure looking for
- * spans of slot boundaries where the minOffsets are less than
- * the maxOffsets, and adjust the offsets according to the slot
- * weights. At each pass, at least one slot boundary will have
- * its range of possible values fixed at a single value.
- */
-
- for (start=0; start < gridCount;) {
- int totalWeight = 0; /* Sum of the weights for all of the
- * slots in this span. */
- int need = 0; /* The minimum space needed to layout
- * this span. */
- int have; /* The actual amount of space that will
- * be taken up by this span. */
- int weight; /* Cumulative weights of the columns in
- * this span. */
- int noWeights = 0; /* True if the span has no weights. */
-
- /*
- * Find a span by identifying ranges of slots whose edges are
- * already constrained at fixed offsets, but whose internal
- * slot boundaries have a range of possible positions.
- */
-
- if (layoutPtr[start].minOffset == layoutPtr[start].maxOffset) {
- start++;
- continue;
- }
-
- for (end=start+1; end<gridCount; end++) {
- if (layoutPtr[end].minOffset == layoutPtr[end].maxOffset) {
- break;
- }
- }
-
- /*
- * We found a span. Compute the total weight, minumum space required,
- * for this span, and the actual amount of space the span should
- * use.
- */
-
- for (slot=start; slot<=end; slot++) {
- totalWeight += layoutPtr[slot].weight;
- need += layoutPtr[slot].minSize;
- }
- have = layoutPtr[end].maxOffset - layoutPtr[start-1].minOffset;
-
- /*
- * If all the weights in the span are zero, then distribute the
- * extra space evenly.
- */
-
- if (totalWeight == 0) {
- noWeights++;
- totalWeight = end - start + 1;
- }
-
- /*
- * It might not be possible to give the span all of the space
- * available on this pass without violating the size constraints
- * of one or more of the internal slot boundaries.
- * Determine the maximum amount of space that when added to the
- * entire span, would cause a slot boundary to have its possible
- * range reduced to one value, and reduce the amount of extra
- * space allocated on this pass accordingly.
- *
- * The calculation is done cumulatively to avoid accumulating
- * roundoff errors.
- */
-
- for (weight=0,slot=start; slot<end; slot++) {
- int diff = layoutPtr[slot].maxOffset - layoutPtr[slot].minOffset;
- weight += noWeights ? 1 : layoutPtr[slot].weight;
- if ((noWeights || layoutPtr[slot].weight>0) &&
- (diff*totalWeight/weight) < (have-need)) {
- have = diff * totalWeight / weight + need;
- }
- }
-
- /*
- * Now distribute the extra space among the slots by
- * adjusting the minSizes and minOffsets.
- */
-
- for (weight=0,slot=start; slot<end; slot++) {
- weight += noWeights ? 1 : layoutPtr[slot].weight;
- layoutPtr[slot].minOffset +=
- (int)((double) (have-need) * weight/totalWeight + 0.5);
- layoutPtr[slot].minSize = layoutPtr[slot].minOffset
- - layoutPtr[slot-1].minOffset;
- }
- layoutPtr[slot].minSize = layoutPtr[slot].minOffset
- - layoutPtr[slot-1].minOffset;
-
- /*
- * Having pushed the top/left boundaries of the slots to
- * take up extra space, the bottom/right space is recalculated
- * to propagate the new space allocation.
- */
-
- for (slot=end; slot > start; slot--) {
- layoutPtr[slot-1].maxOffset =
- layoutPtr[slot].maxOffset-layoutPtr[slot].minSize;
- }
- }
-
-
- /*
- * Step 6.
- * All of the space has been apportioned; copy the
- * layout information back into the master.
- */
-
- for (slot=0; slot < gridCount; slot++) {
- slotPtr[slot].offset = layoutPtr[slot].minOffset;
- }
-
- --layoutPtr;
- if (layoutPtr != layoutData) {
- Tcl_Free((char *)layoutPtr);
- }
- return requiredSize;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * GetGrid --
- *
- * This internal procedure is used to locate a Grid
- * structure for a given window, creating one if one
- * doesn't exist already.
- *
- * Results:
- * The return value is a pointer to the Grid structure
- * corresponding to tkwin.
- *
- * Side effects:
- * A new grid structure may be created. If so, then
- * a callback is set up to clean things up when the
- * window is deleted.
- *
- *--------------------------------------------------------------
- */
-
-static Gridder *
-GetGrid(tkwin)
- Tk_Window tkwin; /* Token for window for which
- * grid structure is desired. */
-{
- register Gridder *gridPtr;
- Tcl_HashEntry *hPtr;
- int new;
-
- if (!initialized) {
- initialized = 1;
- Tcl_InitHashTable(&gridHashTable, TCL_ONE_WORD_KEYS);
- }
-
- /*
- * See if there's already grid for this window. If not,
- * then create a new one.
- */
-
- hPtr = Tcl_CreateHashEntry(&gridHashTable, (char *) tkwin, &new);
- if (!new) {
- return (Gridder *) Tcl_GetHashValue(hPtr);
- }
- gridPtr = (Gridder *) Tcl_Alloc(sizeof(Gridder));
- gridPtr->tkwin = tkwin;
- gridPtr->masterPtr = NULL;
- gridPtr->masterDataPtr = NULL;
- gridPtr->nextPtr = NULL;
- gridPtr->slavePtr = NULL;
- gridPtr->binNextPtr = NULL;
-
- gridPtr->column = gridPtr->row = -1;
- gridPtr->numCols = 1;
- gridPtr->numRows = 1;
-
- gridPtr->padX = gridPtr->padY = 0;
- gridPtr->iPadX = gridPtr->iPadY = 0;
- gridPtr->doubleBw = 2*Tk_Changes(tkwin)->border_width;
- gridPtr->abortPtr = NULL;
- gridPtr->flags = 0;
- gridPtr->sticky = 0;
- gridPtr->size = 0;
- gridPtr->masterDataPtr = NULL;
- Tcl_SetHashValue(hPtr, gridPtr);
- Tk_CreateEventHandler(tkwin, StructureNotifyMask,
- GridStructureProc, (ClientData) gridPtr);
- return gridPtr;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * SetGridSize --
- *
- * This internal procedure sets the size of the grid occupied
- * by slaves.
- *
- * Results:
- * none
- *
- * Side effects:
- * The width and height arguments are filled in the master data structure.
- * Additional space is allocated for the constraints to accomodate
- * the offsets.
- *
- *--------------------------------------------------------------
- */
-
-static void
-SetGridSize(masterPtr)
- Gridder *masterPtr; /* The geometry master for this grid. */
-{
- register Gridder *slavePtr; /* Current slave window. */
- int maxX = 0, maxY = 0;
-
- for (slavePtr = masterPtr->slavePtr; slavePtr != NULL;
- slavePtr = slavePtr->nextPtr) {
- maxX = MAX(maxX,slavePtr->numCols + slavePtr->column);
- maxY = MAX(maxY,slavePtr->numRows + slavePtr->row);
- }
- masterPtr->masterDataPtr->columnEnd = maxX;
- masterPtr->masterDataPtr->rowEnd = maxY;
- CheckSlotData(masterPtr, maxX, COLUMN, CHECK_SPACE);
- CheckSlotData(masterPtr, maxY, ROW, CHECK_SPACE);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * CheckSlotData --
- *
- * This internal procedure is used to manage the storage for
- * row and column (slot) constraints.
- *
- * Results:
- * TRUE if the index is OK, False otherwise.
- *
- * Side effects:
- * A new master grid structure may be created. If so, then
- * it is initialized. In addition, additional storage for
- * a row or column constraints may be allocated, and the constraint
- * maximums are adjusted.
- *
- *--------------------------------------------------------------
- */
-
-static int
-CheckSlotData(masterPtr, slot, slotType, checkOnly)
- Gridder *masterPtr; /* the geometry master for this grid */
- int slot; /* which slot to look at */
- int slotType; /* ROW or COLUMN */
- int checkOnly; /* don't allocate new space if true */
-{
- int numSlot; /* number of slots already allocated (Space) */
- int end; /* last used constraint */
-
- /*
- * If slot is out of bounds, return immediately.
- */
-
- if (slot < 0 || slot >= MAX_ELEMENT) {
- return TCL_ERROR;
- }
-
- if ((checkOnly == CHECK_ONLY) && (masterPtr->masterDataPtr == NULL)) {
- return TCL_ERROR;
- }
-
- /*
- * If we need to allocate more space, allocate a little extra to avoid
- * repeated re-alloc's for large tables. We need enough space to
- * hold all of the offsets as well.
- */
-
- InitMasterData(masterPtr);
- end = (slotType == ROW) ? masterPtr->masterDataPtr->rowMax :
- masterPtr->masterDataPtr->columnMax;
- if (checkOnly == CHECK_ONLY) {
- return (end < slot) ? TCL_ERROR : TCL_OK;
- } else {
- numSlot = (slotType == ROW) ? masterPtr->masterDataPtr->rowSpace
- : masterPtr->masterDataPtr->columnSpace;
- if (slot >= numSlot) {
- int newNumSlot = slot + PREALLOC ;
- size_t oldSize = numSlot * sizeof(SlotInfo) ;
- size_t newSize = newNumSlot * sizeof(SlotInfo) ;
- SlotInfo *new = (SlotInfo *) Tcl_Alloc(newSize);
- SlotInfo *old = (slotType == ROW) ?
- masterPtr->masterDataPtr->rowPtr :
- masterPtr->masterDataPtr->columnPtr;
- memcpy((VOID *) new, (VOID *) old, oldSize );
- memset((VOID *) (new+numSlot), 0, newSize - oldSize );
- Tcl_Free((char *) old);
- if (slotType == ROW) {
- masterPtr->masterDataPtr->rowPtr = new ;
- masterPtr->masterDataPtr->rowSpace = newNumSlot ;
- } else {
- masterPtr->masterDataPtr->columnPtr = new;
- masterPtr->masterDataPtr->columnSpace = newNumSlot ;
- }
- }
- if (slot >= end && checkOnly != CHECK_SPACE) {
- if (slotType == ROW) {
- masterPtr->masterDataPtr->rowMax = slot+1;
- } else {
- masterPtr->masterDataPtr->columnMax = slot+1;
- }
- }
- return TCL_OK;
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * InitMasterData --
- *
- * This internal procedure is used to allocate and initialize
- * the data for a geometry master, if the data
- * doesn't exist already.
- *
- * Results:
- * none
- *
- * Side effects:
- * A new master grid structure may be created. If so, then
- * it is initialized.
- *
- *--------------------------------------------------------------
- */
-
-static void
-InitMasterData(masterPtr)
- Gridder *masterPtr;
-{
- size_t size;
- if (masterPtr->masterDataPtr == NULL) {
- GridMaster *gridPtr = masterPtr->masterDataPtr =
- (GridMaster *) Tcl_Alloc(sizeof(GridMaster));
- size = sizeof(SlotInfo) * TYPICAL_SIZE;
-
- gridPtr->columnEnd = 0;
- gridPtr->columnMax = 0;
- gridPtr->columnPtr = (SlotInfo *) Tcl_Alloc(size);
- gridPtr->columnSpace = 0;
- gridPtr->columnSpace = TYPICAL_SIZE;
- gridPtr->rowEnd = 0;
- gridPtr->rowMax = 0;
- gridPtr->rowPtr = (SlotInfo *) Tcl_Alloc(size);
- gridPtr->rowSpace = 0;
- gridPtr->rowSpace = TYPICAL_SIZE;
-
- memset((VOID *) gridPtr->columnPtr, 0, size);
- memset((VOID *) gridPtr->rowPtr, 0, size);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Unlink --
- *
- * Remove a grid from its parent's list of slaves.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The parent will be scheduled for re-arranging, and the size of the
- * grid will be adjusted accordingly
- *
- *----------------------------------------------------------------------
- */
-
-static void
-Unlink(slavePtr)
- register Gridder *slavePtr; /* Window to unlink. */
-{
- register Gridder *masterPtr, *slavePtr2;
- GridMaster *gridPtr; /* pointer to grid data */
-
- masterPtr = slavePtr->masterPtr;
- if (masterPtr == NULL) {
- return;
- }
-
- gridPtr = masterPtr->masterDataPtr;
- if (masterPtr->slavePtr == slavePtr) {
- masterPtr->slavePtr = slavePtr->nextPtr;
- }
- else {
- for (slavePtr2 = masterPtr->slavePtr; ; slavePtr2 = slavePtr2->nextPtr) {
- if (slavePtr2 == NULL) {
- panic("Unlink couldn't find previous window");
- }
- if (slavePtr2->nextPtr == slavePtr) {
- slavePtr2->nextPtr = slavePtr->nextPtr;
- break;
- }
- }
- }
- if (!(masterPtr->flags & REQUESTED_RELAYOUT)) {
- masterPtr->flags |= REQUESTED_RELAYOUT;
- Tcl_DoWhenIdle(ArrangeGrid, (ClientData) masterPtr);
- }
- if (masterPtr->abortPtr != NULL) {
- *masterPtr->abortPtr = 1;
- }
-
- if ((slavePtr->numCols+slavePtr->column == gridPtr->columnMax)
- || (slavePtr->numRows+slavePtr->row == gridPtr->rowMax)) {
- }
- slavePtr->masterPtr = NULL;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * DestroyGrid --
- *
- * This procedure is invoked by Tk_EventuallyFree or Tcl_Release
- * to clean up the internal structure of a grid at a safe time
- * (when no-one is using it anymore). Cleaning up the grid involves
- * freeing the main structure for all windows. and the master structure
- * for geometry managers.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Everything associated with the grid is freed up.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-DestroyGrid(memPtr)
- char *memPtr; /* Info about window that is now dead. */
-{
- register Gridder *gridPtr = (Gridder *) memPtr;
-
- if (gridPtr->masterDataPtr != NULL) {
- if (gridPtr->masterDataPtr->rowPtr != NULL) {
- Tcl_Free((char *) gridPtr->masterDataPtr -> rowPtr);
- }
- if (gridPtr->masterDataPtr->columnPtr != NULL) {
- Tcl_Free((char *) gridPtr->masterDataPtr -> columnPtr);
- }
- Tcl_Free((char *) gridPtr->masterDataPtr);
- }
- Tcl_Free((char *) gridPtr);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * GridStructureProc --
- *
- * This procedure is invoked by the Tk event dispatcher in response
- * to StructureNotify events.
- *
- * Results:
- * None.
- *
- * Side effects:
- * If a window was just deleted, clean up all its grid-related
- * information. If it was just resized, re-configure its slaves, if
- * any.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-GridStructureProc(clientData, eventPtr)
- ClientData clientData; /* Our information about window
- * referred to by eventPtr. */
- XEvent *eventPtr; /* Describes what just happened. */
-{
- register Gridder *gridPtr = (Gridder *) clientData;
-
- if (eventPtr->type == ConfigureNotify) {
- if (!(gridPtr->flags & REQUESTED_RELAYOUT)) {
- gridPtr->flags |= REQUESTED_RELAYOUT;
- Tcl_DoWhenIdle(ArrangeGrid, (ClientData) gridPtr);
- }
- if (gridPtr->doubleBw != 2*Tk_Changes(gridPtr->tkwin)->border_width) {
- if ((gridPtr->masterPtr != NULL) &&
- !(gridPtr->masterPtr->flags & REQUESTED_RELAYOUT)) {
- gridPtr->doubleBw = 2*Tk_Changes(gridPtr->tkwin)->border_width;
- gridPtr->masterPtr->flags |= REQUESTED_RELAYOUT;
- Tcl_DoWhenIdle(ArrangeGrid, (ClientData) gridPtr->masterPtr);
- }
- }
- } else if (eventPtr->type == DestroyNotify) {
- register Gridder *gridPtr2, *nextPtr;
-
- if (gridPtr->masterPtr != NULL) {
- Unlink(gridPtr);
- }
- for (gridPtr2 = gridPtr->slavePtr; gridPtr2 != NULL;
- gridPtr2 = nextPtr) {
- Tk_UnmapWindow(gridPtr2->tkwin);
- gridPtr2->masterPtr = NULL;
- nextPtr = gridPtr2->nextPtr;
- gridPtr2->nextPtr = NULL;
- }
- Tcl_DeleteHashEntry(Tcl_FindHashEntry(&gridHashTable,
- (char *) gridPtr->tkwin));
- if (gridPtr->flags & REQUESTED_RELAYOUT) {
- Tk_CancelIdleCall(ArrangeGrid, (ClientData) gridPtr);
- }
- gridPtr->tkwin = NULL;
- Tk_EventuallyFree((ClientData) gridPtr, DestroyGrid);
- } else if (eventPtr->type == MapNotify) {
- if (!(gridPtr->flags & REQUESTED_RELAYOUT)) {
- gridPtr->flags |= REQUESTED_RELAYOUT;
- Tcl_DoWhenIdle(ArrangeGrid, (ClientData) gridPtr);
- }
- } else if (eventPtr->type == UnmapNotify) {
- register Gridder *gridPtr2;
-
- for (gridPtr2 = gridPtr->slavePtr; gridPtr2 != NULL;
- gridPtr2 = gridPtr2->nextPtr) {
- Tk_UnmapWindow(gridPtr2->tkwin);
- }
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ConfigureSlaves --
- *
- * This implements the guts of the "grid configure" command. Given
- * a list of slaves and configuration options, it arranges for the
- * grid to manage the slaves and sets the specified options.
- * arguments consist of windows or window shortcuts followed by
- * "-option value" pairs.
- *
- * Results:
- * TCL_OK is returned if all went well. Otherwise, TCL_ERROR is
- * returned and interp->result is set to contain an error message.
- *
- * Side effects:
- * Slave windows get taken over by the grid.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-ConfigureSlaves(interp, tkwin, argc, argv)
- 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
- * window names followed by any number
- * of "option value" pairs. Caller must
- * make sure that there is at least one
- * window name. */
-{
- Gridder *masterPtr;
- Gridder *slavePtr;
- Tk_Window other, slave, parent, ancestor;
- int i, j, c, tmp;
- size_t 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 */
-
- /*
- * Count the number of windows, or window short-cuts.
- */
-
- for(numWindows=i=0;i<argc;i++) {
- char firstChar = *argv[i];
- if (firstChar == '.') {
- numWindows++;
- continue;
- }
- length = strlen(argv[i]);
- if (length > 1 && firstChar == '-') {
- break;
- }
- if (length > 1) {
- Tcl_AppendResult(interp, "unexpected parameter, \"",
- argv[i], "\", 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))) {
- Tcl_AppendResult(interp,
- "Must specify window before shortcut '-'.",
- (char *) NULL);
- return TCL_ERROR;
- }
-
- if ((firstChar == REL_VERT) || (firstChar == REL_SKIP)
- || (firstChar == REL_HORIZ)) {
- continue;
- }
-
- Tcl_AppendResult(interp, "invalid window shortcut, \"",
- argv[i], "\" should be '-', 'x', or '^'", (char *) NULL);
- return TCL_ERROR;
- }
- numWindows = i;
-
- if ((argc-numWindows)&1) {
- Tcl_AppendResult(interp, "extra option or",
- " option with no value", (char *) NULL);
- return TCL_ERROR;
- }
-
- /*
- * Iterate over all of the slave windows and short-cuts, parsing
- * options for each slave. It's a bit wasteful to re-parse the
- * options for each slave, but things get too messy if we try to
- * parse the arguments just once at the beginning. For example,
- * if a slave already is managed we want to just change a few
- * existing values without resetting everything. If there are
- * multiple windows, the -in option only gets processed for the
- * first window.
- */
-
- masterPtr = NULL;
- for (j = 0; j < numWindows; j++) {
- char firstChar = *argv[j];
-
- /*
- * '^' and 'x' cause us to skip a column. '-' is processed
- * as part of its preceeding slave.
- */
-
- if ((firstChar == REL_VERT) || (firstChar == REL_SKIP)) {
- defaultColumn++;
- continue;
- }
- if (firstChar == REL_HORIZ) {
- continue;
- }
-
- for (defaultColumnSpan=1;
- j + defaultColumnSpan < numWindows &&
- (*argv[j+defaultColumnSpan] == REL_HORIZ);
- defaultColumnSpan++) {
- /* null body */
- }
-
- slave = Tk_NameToWindow(interp, argv[j], tkwin);
- if (slave == NULL) {
- return TCL_ERROR;
- }
- if (Tk_IsTopLevel(slave)) {
- Tcl_AppendResult(interp, "can't manage \"", argv[j],
- "\": it's a top-level window", (char *) NULL);
- return TCL_ERROR;
- }
- slavePtr = GetGrid(slave);
-
- /*
- * The following statement is taken from tkPack.c:
- *
- * "If the slave isn't currently managed, reset all of its
- * configuration information to default values (there could
- * be old values left from a previous packer)."
- *
- * I [D.S.] disagree with this statement. If a slave is disabled (using
- * "forget") and then re-enabled, I submit that 90% of the time the
- * programmer will want it to retain its old configuration information.
- * If the programmer doesn't want this behavior, then the
- * defaults can be reestablished by hand, without having to worry
- * 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);
- return TCL_ERROR;
- }
- if ((c == 'c') && (strncmp(argv[i], "-column", length) == 0)) {
- if (Tcl_GetInt(interp, argv[i+1], &tmp) != TCL_OK || tmp<0) {
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "bad column value \"", argv[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) {
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "bad columnspan value \"", argv[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) {
- return TCL_ERROR;
- }
- if (other == slave) {
- sprintf(interp->result,"Window can't be managed in itself");
- return TCL_ERROR;
- }
- 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)
- || (tmp < 0)) {
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "bad ipadx value \"", argv[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)) {
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "bad ipady value \"", argv[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);
- 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);
- 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) {
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "bad grid value \"", argv[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) {
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "bad rowspan value \"", argv[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]);
- if (sticky == -1) {
- Tcl_AppendResult(interp, "bad stickyness value \"", argv[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;
- }
- }
-
- /*
- * Make sure we have a geometry master. We look at:
- * 1) the -in flag
- * 2) the geometry master of the first slave (if specified)
- * 3) the parent of the first slave.
- */
-
- if (masterPtr == NULL) {
- masterPtr = slavePtr->masterPtr;
- }
- parent = Tk_Parent(slave);
- if (masterPtr == NULL) {
- masterPtr = GetGrid(parent);
- InitMasterData(masterPtr);
- }
-
- if (slavePtr->masterPtr != NULL && slavePtr->masterPtr != masterPtr) {
- Unlink(slavePtr);
- slavePtr->masterPtr = NULL;
- }
-
- if (slavePtr->masterPtr == NULL) {
- Gridder *tempPtr = masterPtr->slavePtr;
- slavePtr->masterPtr = masterPtr;
- masterPtr->slavePtr = slavePtr;
- slavePtr->nextPtr = tempPtr;
- }
-
- /*
- * Make sure that the slave's parent is either the master or
- * an ancestor of the master, and that the master and slave
- * aren't the same.
- */
-
- for (ancestor = masterPtr->tkwin; ; ancestor = Tk_Parent(ancestor)) {
- if (ancestor == parent) {
- break;
- }
- if (Tk_IsTopLevel(ancestor)) {
- Tcl_AppendResult(interp, "can't put ", argv[j],
- " inside ", Tk_PathName(masterPtr->tkwin),
- (char *) NULL);
- Unlink(slavePtr);
- return TCL_ERROR;
- }
- }
-
- /*
- * Try to make sure our master isn't managed by us.
- */
-
- if (masterPtr->masterPtr == slavePtr) {
- Tcl_AppendResult(interp, "can't put ", argv[j],
- " inside ", Tk_PathName(masterPtr->tkwin),
- ", would cause management loop.",
- (char *) NULL);
- Unlink(slavePtr);
- return TCL_ERROR;
- }
-
- Tk_ManageGeometry(slave, &gridMgrType, (ClientData) slavePtr);
-
- /*
- * Assign default position information.
- */
-
- if (slavePtr->column == -1) {
- slavePtr->column = defaultColumn;
- }
- slavePtr->numCols += defaultColumnSpan - 1;
- if (slavePtr->row == -1) {
- if (masterPtr->masterDataPtr == NULL) {
- slavePtr->row = 0;
- } else {
- slavePtr->row = masterPtr->masterDataPtr->rowEnd;
- }
- }
- defaultColumn += slavePtr->numCols;
- defaultColumnSpan = 1;
-
- /*
- * Arrange for the parent to be re-arranged at the first
- * idle moment.
- */
-
- if (masterPtr->abortPtr != NULL) {
- *masterPtr->abortPtr = 1;
- }
- if (!(masterPtr->flags & REQUESTED_RELAYOUT)) {
- masterPtr->flags |= REQUESTED_RELAYOUT;
- Tcl_DoWhenIdle(ArrangeGrid, (ClientData) masterPtr);
- }
- }
-
- /* Now look for all the "^"'s. */
-
- lastWindow = NULL;
- for (j = 0; j < numWindows; j++) {
- struct Gridder *otherPtr;
- int match; /* found a match for the ^ */
- int lastRow, lastColumn; /* implied end of table */
-
- if (*argv[j] == '.') {
- lastWindow = argv[j];
- }
- if (*argv[j] != REL_VERT) {
- continue;
- }
-
- if (masterPtr == NULL) {
- Tcl_AppendResult(interp, "can't use '^', cant find master",
- (char *) NULL);
- return TCL_ERROR;
- }
-
- for (width=1; width+j < numWindows && *argv[j+width] == REL_VERT;
- width++) {
- /* Null Body */
- }
-
- /*
- * Find the implied grid location of the ^
- */
-
- if (lastWindow == NULL) {
- if (masterPtr->masterDataPtr != NULL) {
- SetGridSize(masterPtr);
- lastRow = masterPtr->masterDataPtr->rowEnd - 1;
- } else {
- lastRow = 0;
- }
- lastColumn = 0;
- } else {
- other = Tk_NameToWindow(interp, lastWindow, tkwin);
- otherPtr = GetGrid(other);
- lastRow = otherPtr->row;
- lastColumn = otherPtr->column + otherPtr->numCols;
- }
-
- for (match=0, slavePtr = masterPtr->slavePtr; slavePtr != NULL;
- slavePtr = slavePtr->nextPtr) {
-
- if (slavePtr->numCols == width
- && slavePtr->column == lastColumn
- && slavePtr->row + slavePtr->numRows == lastRow) {
- slavePtr->numRows++;
- match++;
- }
- lastWindow = Tk_PathName(slavePtr->tkwin);
- }
- if (!match) {
- Tcl_AppendResult(interp, "can't find slave to extend with \"^\".",
- (char *) NULL);
- return TCL_ERROR;
- }
- j += width - 1;
- }
-
- if (masterPtr == NULL) {
- Tcl_AppendResult(interp, "can't determine master window",
- (char *) NULL);
- return TCL_ERROR;
- }
- SetGridSize(masterPtr);
- return TCL_OK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * StickyToString
- *
- * Converts the internal boolean combination of "sticky" bits onto
- * a TCL list element containing zero or mor of n, s, e, or w.
- *
- * Results:
- * A string is placed into the "result" pointer.
- *
- * Side effects:
- * none.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-StickyToString(flags, result)
- int flags; /* the sticky flags */
- char *result; /* where to put the result */
-{
- int count = 0;
- if (flags&STICK_NORTH) {
- result[count++] = 'n';
- }
- if (flags&STICK_EAST) {
- result[count++] = 'e';
- }
- if (flags&STICK_SOUTH) {
- result[count++] = 's';
- }
- if (flags&STICK_WEST) {
- result[count++] = 'w';
- }
- if (count) {
- result[count] = '\0';
- } else {
- sprintf(result,"{}");
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * StringToSticky --
- *
- * Converts an ascii string representing a widgets stickyness
- * into the boolean result.
- *
- * Results:
- * The boolean combination of the "sticky" bits is retuned. If an
- * error occurs, such as an invalid character, -1 is returned instead.
- *
- * Side effects:
- * none
- *
- *----------------------------------------------------------------------
- */
-
-static int
-StringToSticky(string)
- char *string;
-{
- int sticky = 0;
- char c;
-
- 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: return -1;
- }
- }
- return sticky;
-}
diff --git a/generic/tkImage.c b/generic/tkImage.c
deleted file mode 100644
index d2733ba..0000000
--- a/generic/tkImage.c
+++ /dev/null
@@ -1,789 +0,0 @@
-/*
- * tkImage.c --
- *
- * This module implements the image protocol, which allows lots
- * of different kinds of images to be used in lots of different
- * widgets.
- *
- * Copyright (c) 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: tkImage.c,v 1.2 1998/09/14 18:23:12 stanton Exp $
- */
-
-#include "tkInt.h"
-#include "tkPort.h"
-
-/*
- * Each call to Tk_GetImage returns a pointer to one of the following
- * structures, which is used as a token by clients (widgets) that
- * display images.
- */
-
-typedef struct Image {
- Tk_Window tkwin; /* Window passed to Tk_GetImage (needed to
- * "re-get" the image later if the manager
- * changes). */
- Display *display; /* Display for tkwin. Needed because when
- * the image is eventually freed tkwin may
- * not exist anymore. */
- struct ImageMaster *masterPtr;
- /* Master for this image (identifiers image
- * manager, for example). */
- ClientData instanceData;
- /* One word argument to pass to image manager
- * when dealing with this image instance. */
- Tk_ImageChangedProc *changeProc;
- /* Code in widget to call when image changes
- * in a way that affects redisplay. */
- ClientData widgetClientData;
- /* Argument to pass to changeProc. */
- struct Image *nextPtr; /* Next in list of all image instances
- * associated with the same name. */
-
-} Image;
-
-/*
- * For each image master there is one of the following structures,
- * which represents a name in the image table and all of the images
- * instantiated from it. Entries in mainPtr->imageTable point to
- * these structures.
- */
-
-typedef struct ImageMaster {
- Tk_ImageType *typePtr; /* Information about image type. NULL means
- * that no image manager owns this image: the
- * image was deleted. */
- ClientData masterData; /* One-word argument to pass to image mgr
- * when dealing with the master, as opposed
- * to instances. */
- int width, height; /* Last known dimensions for image. */
- Tcl_HashTable *tablePtr; /* Pointer to hash table containing image
- * (the imageTable field in some TkMainInfo
- * structure). */
- Tcl_HashEntry *hPtr; /* Hash entry in mainPtr->imageTable for
- * this structure (used to delete the hash
- * entry). */
- Image *instancePtr; /* Pointer to first in list of instances
- * derived from this name. */
-} ImageMaster;
-
-/*
- * The following variable points to the first in a list of all known
- * image types.
- */
-
-static Tk_ImageType *imageTypeList = NULL;
-
-/*
- * Prototypes for local procedures:
- */
-
-static void DeleteImage _ANSI_ARGS_((ImageMaster *masterPtr));
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_CreateImageType --
- *
- * This procedure is invoked by an image manager to tell Tk about
- * a new kind of image and the procedures that manage the new type.
- * The procedure is typically invoked during Tcl_AppInit.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The new image type is entered into a table used in the "image
- * create" command.
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tk_CreateImageType(typePtr)
- Tk_ImageType *typePtr; /* Structure describing the type. All of
- * the fields except "nextPtr" must be filled
- * in by caller. Must not have been passed
- * to Tk_CreateImageType previously. */
-{
- typePtr->nextPtr = imageTypeList;
- imageTypeList = typePtr;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_ImageCmd --
- *
- * This procedure is invoked to process the "image" 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_ImageCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Main window associated with interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- TkWindow *winPtr = (TkWindow *) clientData;
- int c, i, new, firstOption;
- size_t length;
- Tk_ImageType *typePtr;
- ImageMaster *masterPtr;
- Image *imagePtr;
- Tcl_HashEntry *hPtr;
- Tcl_HashSearch search;
- char idString[30], *name;
- static int id = 0;
-
- if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
- " option ?args?\"", (char *) NULL);
- return TCL_ERROR;
- }
- c = argv[1][0];
- length = strlen(argv[1]);
- if ((c == 'c') && (strncmp(argv[1], "create", length) == 0)) {
- if (argc < 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
- " create type ?name? ?options?\"", (char *) NULL);
- return TCL_ERROR;
- }
- c = argv[2][0];
-
- /*
- * Look up the image type.
- */
-
- for (typePtr = imageTypeList; typePtr != NULL;
- typePtr = typePtr->nextPtr) {
- if ((c == typePtr->name[0])
- && (strcmp(argv[2], typePtr->name) == 0)) {
- break;
- }
- }
- if (typePtr == NULL) {
- Tcl_AppendResult(interp, "image type \"", argv[2],
- "\" doesn't exist", (char *) NULL);
- return TCL_ERROR;
- }
-
- /*
- * Figure out a name to use for the new image.
- */
-
- if ((argc == 3) || (argv[3][0] == '-')) {
- id++;
- sprintf(idString, "image%d", id);
- name = idString;
- firstOption = 3;
- } else {
- name = argv[3];
- firstOption = 4;
- }
-
- /*
- * Create the data structure for the new image.
- */
-
- hPtr = Tcl_CreateHashEntry(&winPtr->mainPtr->imageTable, name, &new);
- if (new) {
- masterPtr = (ImageMaster *) ckalloc(sizeof(ImageMaster));
- masterPtr->typePtr = NULL;
- masterPtr->masterData = NULL;
- masterPtr->width = masterPtr->height = 1;
- masterPtr->tablePtr = &winPtr->mainPtr->imageTable;
- masterPtr->hPtr = hPtr;
- masterPtr->instancePtr = NULL;
- Tcl_SetHashValue(hPtr, masterPtr);
- } else {
- /*
- * An image already exists by this name. Disconnect the
- * instances from the master.
- */
-
- masterPtr = (ImageMaster *) Tcl_GetHashValue(hPtr);
- if (masterPtr->typePtr != NULL) {
- for (imagePtr = masterPtr->instancePtr; imagePtr != NULL;
- imagePtr = imagePtr->nextPtr) {
- (*masterPtr->typePtr->freeProc)(
- imagePtr->instanceData, imagePtr->display);
- (*imagePtr->changeProc)(imagePtr->widgetClientData, 0, 0,
- masterPtr->width, masterPtr->height, masterPtr->width,
- masterPtr->height);
- }
- (*masterPtr->typePtr->deleteProc)(masterPtr->masterData);
- masterPtr->typePtr = NULL;
- }
- }
-
- /*
- * Call the image type manager so that it can perform its own
- * initialization, then re-"get" for any existing instances of
- * the image.
- */
-
- if ((*typePtr->createProc)(interp, name, argc-firstOption,
- argv+firstOption, typePtr, (Tk_ImageMaster) masterPtr,
- &masterPtr->masterData) != TCL_OK) {
- DeleteImage(masterPtr);
- return TCL_ERROR;
- }
- masterPtr->typePtr = typePtr;
- for (imagePtr = masterPtr->instancePtr; imagePtr != NULL;
- imagePtr = imagePtr->nextPtr) {
- imagePtr->instanceData = (*typePtr->getProc)(
- imagePtr->tkwin, masterPtr->masterData);
- }
- interp->result = Tcl_GetHashKey(&winPtr->mainPtr->imageTable, hPtr);
- } else if ((c == 'd') && (strncmp(argv[1], "delete", length) == 0)) {
- for (i = 2; i < argc; i++) {
- hPtr = Tcl_FindHashEntry(&winPtr->mainPtr->imageTable, argv[i]);
- if (hPtr == NULL) {
- Tcl_AppendResult(interp, "image \"", argv[i],
- "\" doesn't exist", (char *) NULL);
- return TCL_ERROR;
- }
- masterPtr = (ImageMaster *) Tcl_GetHashValue(hPtr);
- DeleteImage(masterPtr);
- }
- } else if ((c == 'h') && (strncmp(argv[1], "height", length) == 0)) {
- if (argc != 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
- " height name\"", (char *) NULL);
- return TCL_ERROR;
- }
- hPtr = Tcl_FindHashEntry(&winPtr->mainPtr->imageTable, argv[2]);
- if (hPtr == NULL) {
- Tcl_AppendResult(interp, "image \"", argv[2],
- "\" doesn't exist", (char *) NULL);
- return TCL_ERROR;
- }
- masterPtr = (ImageMaster *) Tcl_GetHashValue(hPtr);
- sprintf(interp->result, "%d", masterPtr->height);
- } else if ((c == 'n') && (strncmp(argv[1], "names", length) == 0)) {
- if (argc != 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
- " names\"", (char *) NULL);
- return TCL_ERROR;
- }
- for (hPtr = Tcl_FirstHashEntry(&winPtr->mainPtr->imageTable, &search);
- hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
- Tcl_AppendElement(interp, Tcl_GetHashKey(
- &winPtr->mainPtr->imageTable, hPtr));
- }
- } else if ((c == 't') && (strcmp(argv[1], "type") == 0)) {
- if (argc != 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
- " type name\"", (char *) NULL);
- return TCL_ERROR;
- }
- hPtr = Tcl_FindHashEntry(&winPtr->mainPtr->imageTable, argv[2]);
- if (hPtr == NULL) {
- Tcl_AppendResult(interp, "image \"", argv[2],
- "\" doesn't exist", (char *) NULL);
- return TCL_ERROR;
- }
- masterPtr = (ImageMaster *) Tcl_GetHashValue(hPtr);
- if (masterPtr->typePtr != NULL) {
- interp->result = masterPtr->typePtr->name;
- }
- } else if ((c == 't') && (strcmp(argv[1], "types") == 0)) {
- if (argc != 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
- " types\"", (char *) NULL);
- return TCL_ERROR;
- }
- for (typePtr = imageTypeList; typePtr != NULL;
- typePtr = typePtr->nextPtr) {
- Tcl_AppendElement(interp, typePtr->name);
- }
- } else if ((c == 'w') && (strncmp(argv[1], "width", length) == 0)) {
- if (argc != 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
- " width name\"", (char *) NULL);
- return TCL_ERROR;
- }
- hPtr = Tcl_FindHashEntry(&winPtr->mainPtr->imageTable, argv[2]);
- if (hPtr == NULL) {
- Tcl_AppendResult(interp, "image \"", argv[2],
- "\" doesn't exist", (char *) NULL);
- return TCL_ERROR;
- }
- masterPtr = (ImageMaster *) Tcl_GetHashValue(hPtr);
- sprintf(interp->result, "%d", masterPtr->width);
- } else {
- Tcl_AppendResult(interp, "bad option \"", argv[1],
- "\": must be create, delete, height, names, type, types,",
- " or width", (char *) NULL);
- return TCL_ERROR;
- }
- return TCL_OK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_ImageChanged --
- *
- * This procedure is called by an image manager whenever something
- * has happened that requires the image to be redrawn (some of its
- * pixels have changed, or its size has changed).
- *
- * Results:
- * None.
- *
- * Side effects:
- * Any widgets that display the image are notified so that they
- * can redisplay themselves as appropriate.
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tk_ImageChanged(imageMaster, x, y, width, height, imageWidth,
- imageHeight)
- Tk_ImageMaster imageMaster; /* Image that needs redisplay. */
- int x, y; /* Coordinates of upper-left pixel of
- * region of image that needs to be
- * redrawn. */
- int width, height; /* Dimensions (in pixels) of region of
- * image to redraw. If either dimension
- * is zero then the image doesn't need to
- * be redrawn (perhaps all that happened is
- * that its size changed). */
- int imageWidth, imageHeight;/* New dimensions of image. */
-{
- ImageMaster *masterPtr = (ImageMaster *) imageMaster;
- Image *imagePtr;
-
- masterPtr->width = imageWidth;
- masterPtr->height = imageHeight;
- for (imagePtr = masterPtr->instancePtr; imagePtr != NULL;
- imagePtr = imagePtr->nextPtr) {
- (*imagePtr->changeProc)(imagePtr->widgetClientData, x, y,
- width, height, imageWidth, imageHeight);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_NameOfImage --
- *
- * Given a token for an image master, this procedure returns
- * the name of the image.
- *
- * Results:
- * The return value is the string name for imageMaster.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-char *
-Tk_NameOfImage(imageMaster)
- Tk_ImageMaster imageMaster; /* Token for image. */
-{
- ImageMaster *masterPtr = (ImageMaster *) imageMaster;
-
- return Tcl_GetHashKey(masterPtr->tablePtr, masterPtr->hPtr);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_GetImage --
- *
- * This procedure is invoked by a widget when it wants to use
- * a particular image in a particular window.
- *
- * Results:
- * The return value is a token for the image. If there is no image
- * by the given name, then NULL is returned and an error message is
- * left in interp->result.
- *
- * Side effects:
- * Tk records the fact that the widget is using the image, and
- * it will invoke changeProc later if the widget needs redisplay
- * (i.e. its size changes or some of its pixels change). The
- * caller must eventually invoke Tk_FreeImage when it no longer
- * needs the image.
- *
- *----------------------------------------------------------------------
- */
-
-Tk_Image
-Tk_GetImage(interp, tkwin, name, changeProc, clientData)
- Tcl_Interp *interp; /* Place to leave error message if image
- * can't be found. */
- Tk_Window tkwin; /* Token for window in which image will
- * be used. */
- char *name; /* Name of desired image. */
- Tk_ImageChangedProc *changeProc;
- /* Procedure to invoke when redisplay is
- * needed because image's pixels or size
- * changed. */
- ClientData clientData; /* One-word argument to pass to damageProc. */
-{
- Tcl_HashEntry *hPtr;
- ImageMaster *masterPtr;
- Image *imagePtr;
-
- hPtr = Tcl_FindHashEntry(&((TkWindow *) tkwin)->mainPtr->imageTable, name);
- if (hPtr == NULL) {
- goto noSuchImage;
- }
- masterPtr = (ImageMaster *) Tcl_GetHashValue(hPtr);
- if (masterPtr->typePtr == NULL) {
- goto noSuchImage;
- }
- imagePtr = (Image *) ckalloc(sizeof(Image));
- imagePtr->tkwin = tkwin;
- imagePtr->display = Tk_Display(tkwin);
- imagePtr->masterPtr = masterPtr;
- imagePtr->instanceData =
- (*masterPtr->typePtr->getProc)(tkwin, masterPtr->masterData);
- imagePtr->changeProc = changeProc;
- imagePtr->widgetClientData = clientData;
- imagePtr->nextPtr = masterPtr->instancePtr;
- masterPtr->instancePtr = imagePtr;
- return (Tk_Image) imagePtr;
-
- noSuchImage:
- Tcl_AppendResult(interp, "image \"", name, "\" doesn't exist",
- (char *) NULL);
- return NULL;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_FreeImage --
- *
- * This procedure is invoked by a widget when it no longer needs
- * an image acquired by a previous call to Tk_GetImage. For each
- * call to Tk_GetImage there must be exactly one call to Tk_FreeImage.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The association between the image and the widget is removed.
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tk_FreeImage(image)
- Tk_Image image; /* Token for image that is no longer
- * needed by a widget. */
-{
- Image *imagePtr = (Image *) image;
- ImageMaster *masterPtr = imagePtr->masterPtr;
- Image *prevPtr;
-
- /*
- * Clean up the particular instance.
- */
-
- if (masterPtr->typePtr != NULL) {
- (*masterPtr->typePtr->freeProc)(imagePtr->instanceData,
- imagePtr->display);
- }
- prevPtr = masterPtr->instancePtr;
- if (prevPtr == imagePtr) {
- masterPtr->instancePtr = imagePtr->nextPtr;
- } else {
- while (prevPtr->nextPtr != imagePtr) {
- prevPtr = prevPtr->nextPtr;
- }
- prevPtr->nextPtr = imagePtr->nextPtr;
- }
- ckfree((char *) imagePtr);
-
- /*
- * If there are no more instances left for the master, and if the
- * master image has been deleted, then delete the master too.
- */
-
- if ((masterPtr->typePtr == NULL) && (masterPtr->instancePtr == NULL)) {
- Tcl_DeleteHashEntry(masterPtr->hPtr);
- ckfree((char *) masterPtr);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_RedrawImage --
- *
- * This procedure is called by widgets that contain images in order
- * to redisplay an image on the screen or an off-screen pixmap.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The image's manager is notified, and it redraws the desired
- * portion of the image before returning.
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tk_RedrawImage(image, imageX, imageY, width, height, drawable,
- drawableX, drawableY)
- Tk_Image image; /* Token for image to redisplay. */
- int imageX, imageY; /* Upper-left pixel of region in image that
- * needs to be redisplayed. */
- int width, height; /* Dimensions of region to redraw. */
- Drawable drawable; /* Drawable in which to display image
- * (window or pixmap). If this is a pixmap,
- * it must have the same depth as the window
- * used in the Tk_GetImage call for the
- * image. */
- int drawableX, drawableY; /* Coordinates in drawable that correspond
- * to imageX and imageY. */
-{
- Image *imagePtr = (Image *) image;
-
- if (imagePtr->masterPtr->typePtr == NULL) {
- /*
- * No master for image, so nothing to display.
- */
-
- return;
- }
-
- /*
- * Clip the redraw area to the area of the image.
- */
-
- if (imageX < 0) {
- width += imageX;
- drawableX -= imageX;
- imageX = 0;
- }
- if (imageY < 0) {
- height += imageY;
- drawableY -= imageY;
- imageY = 0;
- }
- if ((imageX + width) > imagePtr->masterPtr->width) {
- width = imagePtr->masterPtr->width - imageX;
- }
- if ((imageY + height) > imagePtr->masterPtr->height) {
- height = imagePtr->masterPtr->height - imageY;
- }
- (*imagePtr->masterPtr->typePtr->displayProc)(
- imagePtr->instanceData, imagePtr->display, drawable,
- imageX, imageY, width, height, drawableX, drawableY);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_SizeOfImage --
- *
- * This procedure returns the current dimensions of an image.
- *
- * Results:
- * The width and height of the image are returned in *widthPtr
- * and *heightPtr.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tk_SizeOfImage(image, widthPtr, heightPtr)
- Tk_Image image; /* Token for image whose size is wanted. */
- int *widthPtr; /* Return width of image here. */
- int *heightPtr; /* Return height of image here. */
-{
- Image *imagePtr = (Image *) image;
-
- *widthPtr = imagePtr->masterPtr->width;
- *heightPtr = imagePtr->masterPtr->height;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_DeleteImage --
- *
- * Given the name of an image, this procedure destroys the
- * image.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The image is destroyed; existing instances will display as
- * blank areas. If no such image exists then the procedure does
- * nothing.
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tk_DeleteImage(interp, name)
- Tcl_Interp *interp; /* Interpreter in which the image was
- * created. */
- char *name; /* Name of image. */
-{
- Tcl_HashEntry *hPtr;
- TkWindow *winPtr;
-
- winPtr = (TkWindow *) Tk_MainWindow(interp);
- if (winPtr == NULL) {
- return;
- }
- hPtr = Tcl_FindHashEntry(&winPtr->mainPtr->imageTable, name);
- if (hPtr == NULL) {
- return;
- }
- DeleteImage((ImageMaster *) Tcl_GetHashValue(hPtr));
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * DeleteImage --
- *
- * This procedure is responsible for deleting an image.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The connection is dropped between instances of this image and
- * an image master. Image instances will redisplay themselves
- * as empty areas, but existing instances will not be deleted.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-DeleteImage(masterPtr)
- ImageMaster *masterPtr; /* Pointer to main data structure for image. */
-{
- Image *imagePtr;
- Tk_ImageType *typePtr;
-
- typePtr = masterPtr->typePtr;
- masterPtr->typePtr = NULL;
- if (typePtr != NULL) {
- for (imagePtr = masterPtr->instancePtr; imagePtr != NULL;
- imagePtr = imagePtr->nextPtr) {
- (*typePtr->freeProc)(imagePtr->instanceData,
- imagePtr->display);
- (*imagePtr->changeProc)(imagePtr->widgetClientData, 0, 0,
- masterPtr->width, masterPtr->height, masterPtr->width,
- masterPtr->height);
- }
- (*typePtr->deleteProc)(masterPtr->masterData);
- }
- if (masterPtr->instancePtr == NULL) {
- Tcl_DeleteHashEntry(masterPtr->hPtr);
- ckfree((char *) masterPtr);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkDeleteAllImages --
- *
- * This procedure is called when an application is deleted. It
- * calls back all of the managers for all images so that they
- * can cleanup, then it deletes all of Tk's internal information
- * about images.
- *
- * Results:
- * None.
- *
- * Side effects:
- * All information for all images gets deleted.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkDeleteAllImages(mainPtr)
- TkMainInfo *mainPtr; /* Structure describing application that is
- * going away. */
-{
- 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);
- }
- Tcl_DeleteHashTable(&mainPtr->imageTable);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_GetImageMasterData --
- *
- * Given the name of an image, this procedure returns the type
- * of the image and the clientData associated with its master.
- *
- * Results:
- * If there is no image by the given name, then NULL is returned
- * and a NULL value is stored at *typePtrPtr. Otherwise the return
- * value is the clientData returned by the createProc when the
- * image was created and a pointer to the type structure for the
- * image is stored at *typePtrPtr.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-ClientData
-Tk_GetImageMasterData(interp, name, typePtrPtr)
- Tcl_Interp *interp; /* Interpreter in which the image was
- * created. */
- char *name; /* Name of image. */
- Tk_ImageType **typePtrPtr; /* Points to location to fill in with
- * pointer to type information for image. */
-{
- Tcl_HashEntry *hPtr;
- TkWindow *winPtr;
- ImageMaster *masterPtr;
-
- winPtr = (TkWindow *) Tk_MainWindow(interp);
- hPtr = Tcl_FindHashEntry(&winPtr->mainPtr->imageTable, name);
- if (hPtr == NULL) {
- *typePtrPtr = NULL;
- return NULL;
- }
- masterPtr = (ImageMaster *) Tcl_GetHashValue(hPtr);
- *typePtrPtr = masterPtr->typePtr;
- return masterPtr->masterData;
-}
diff --git a/generic/tkImgBmap.c b/generic/tkImgBmap.c
deleted file mode 100644
index d3e9f41..0000000
--- a/generic/tkImgBmap.c
+++ /dev/null
@@ -1,1068 +0,0 @@
-/*
- * tkImgBmap.c --
- *
- * This procedure implements images of type "bitmap" for Tk.
- *
- * Copyright (c) 1994 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: tkImgBmap.c,v 1.4 1998/09/14 18:23:12 stanton Exp $
- */
-
-#include "tkInt.h"
-#include "tkPort.h"
-
-/*
- * The following data structure represents the master for a bitmap
- * image:
- */
-
-typedef struct BitmapMaster {
- Tk_ImageMaster tkMaster; /* Tk's token for image master. NULL means
- * the image is being deleted. */
- Tcl_Interp *interp; /* Interpreter for application that is
- * using image. */
- Tcl_Command imageCmd; /* Token for image command (used to delete
- * it when the image goes away). NULL means
- * the image command has already been
- * deleted. */
- int width, height; /* Dimensions of image. */
- char *data; /* Data comprising bitmap (suitable for
- * input to XCreateBitmapFromData). May
- * be NULL if no data. Malloc'ed. */
- char *maskData; /* Data for bitmap's mask (suitable for
- * input to XCreateBitmapFromData).
- * Malloc'ed. */
- Tk_Uid fgUid; /* Value of -foreground option (malloc'ed). */
- Tk_Uid bgUid; /* Value of -background option (malloc'ed). */
- char *fileString; /* Value of -file option (malloc'ed). */
- char *dataString; /* Value of -data option (malloc'ed). */
- char *maskFileString; /* Value of -maskfile option (malloc'ed). */
- char *maskDataString; /* Value of -maskdata option (malloc'ed). */
- struct BitmapInstance *instancePtr;
- /* First in list of all instances associated
- * with this master. */
-} BitmapMaster;
-
-/*
- * The following data structure represents all of the instances of an
- * image that lie within a particular window:
- */
-
-typedef struct BitmapInstance {
- int refCount; /* Number of instances that share this
- * data structure. */
- BitmapMaster *masterPtr; /* Pointer to master for image. */
- Tk_Window tkwin; /* Window in which the instances will be
- * displayed. */
- XColor *fg; /* Foreground color for displaying image. */
- XColor *bg; /* Background color for displaying image. */
- Pixmap bitmap; /* The bitmap to display. */
- Pixmap mask; /* Mask: only display bitmap pixels where
- * there are 1's here. */
- GC gc; /* Graphics context for displaying bitmap.
- * None means there was an error while
- * setting up the instance, so it cannot
- * be displayed. */
- struct BitmapInstance *nextPtr;
- /* Next in list of all instance structures
- * associated with masterPtr (NULL means
- * end of list). */
-} BitmapInstance;
-
-/*
- * The type record for bitmap images:
- */
-
-static int GetByte _ANSI_ARGS_((Tcl_Channel chan));
-static int ImgBmapCreate _ANSI_ARGS_((Tcl_Interp *interp,
- char *name, int argc, char **argv,
- Tk_ImageType *typePtr, Tk_ImageMaster master,
- ClientData *clientDataPtr));
-static ClientData ImgBmapGet _ANSI_ARGS_((Tk_Window tkwin,
- ClientData clientData));
-static void ImgBmapDisplay _ANSI_ARGS_((ClientData clientData,
- Display *display, Drawable drawable,
- int imageX, int imageY, int width, int height,
- int drawableX, int drawableY));
-static void ImgBmapFree _ANSI_ARGS_((ClientData clientData,
- Display *display));
-static void ImgBmapDelete _ANSI_ARGS_((ClientData clientData));
-
-Tk_ImageType tkBitmapImageType = {
- "bitmap", /* name */
- ImgBmapCreate, /* createProc */
- ImgBmapGet, /* getProc */
- ImgBmapDisplay, /* displayProc */
- ImgBmapFree, /* freeProc */
- ImgBmapDelete, /* deleteProc */
- (Tk_ImageType *) NULL /* nextPtr */
-};
-
-/*
- * Information used for parsing configuration specs:
- */
-
-static Tk_ConfigSpec configSpecs[] = {
- {TK_CONFIG_UID, "-background", (char *) NULL, (char *) NULL,
- "", Tk_Offset(BitmapMaster, bgUid), 0},
- {TK_CONFIG_STRING, "-data", (char *) NULL, (char *) NULL,
- (char *) NULL, Tk_Offset(BitmapMaster, dataString), TK_CONFIG_NULL_OK},
- {TK_CONFIG_STRING, "-file", (char *) NULL, (char *) NULL,
- (char *) NULL, Tk_Offset(BitmapMaster, fileString), TK_CONFIG_NULL_OK},
- {TK_CONFIG_UID, "-foreground", (char *) NULL, (char *) NULL,
- "#000000", Tk_Offset(BitmapMaster, fgUid), 0},
- {TK_CONFIG_STRING, "-maskdata", (char *) NULL, (char *) NULL,
- (char *) NULL, Tk_Offset(BitmapMaster, maskDataString),
- TK_CONFIG_NULL_OK},
- {TK_CONFIG_STRING, "-maskfile", (char *) NULL, (char *) NULL,
- (char *) NULL, Tk_Offset(BitmapMaster, maskFileString),
- TK_CONFIG_NULL_OK},
- {TK_CONFIG_END, (char *) NULL, (char *) NULL, (char *) NULL,
- (char *) NULL, 0, 0}
-};
-
-/*
- * The following data structure is used to describe the state of
- * parsing a bitmap file or string. It is used for communication
- * between TkGetBitmapData and NextBitmapWord.
- */
-
-#define MAX_WORD_LENGTH 100
-typedef struct ParseInfo {
- char *string; /* Next character of string data for bitmap,
- * or NULL if bitmap is being read from
- * file. */
- Tcl_Channel chan; /* File containing bitmap data, or NULL
- * if no file. */
- char word[MAX_WORD_LENGTH+1];
- /* Current word of bitmap data, NULL
- * terminated. */
- int wordLength; /* Number of non-NULL bytes in word. */
-} ParseInfo;
-
-/*
- * Prototypes for procedures used only locally in this file:
- */
-
-static int ImgBmapCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-static void ImgBmapCmdDeletedProc _ANSI_ARGS_((
- ClientData clientData));
-static void ImgBmapConfigureInstance _ANSI_ARGS_((
- BitmapInstance *instancePtr));
-static int ImgBmapConfigureMaster _ANSI_ARGS_((
- BitmapMaster *masterPtr, int argc, char **argv,
- int flags));
-static int NextBitmapWord _ANSI_ARGS_((ParseInfo *parseInfoPtr));
-
-/*
- *----------------------------------------------------------------------
- *
- * ImgBmapCreate --
- *
- * This procedure is called by the Tk image code to create "test"
- * images.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * The data structure for a new image is allocated.
- *
- *----------------------------------------------------------------------
- */
-
- /* ARGSUSED */
-static int
-ImgBmapCreate(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. */
- 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
- * later callbacks. */
- ClientData *clientDataPtr; /* Store manager's token for image here;
- * it will be returned in later callbacks. */
-{
- BitmapMaster *masterPtr;
-
- masterPtr = (BitmapMaster *) ckalloc(sizeof(BitmapMaster));
- masterPtr->tkMaster = master;
- masterPtr->interp = interp;
- masterPtr->imageCmd = Tcl_CreateCommand(interp, name, ImgBmapCmd,
- (ClientData) masterPtr, ImgBmapCmdDeletedProc);
- masterPtr->width = masterPtr->height = 0;
- masterPtr->data = NULL;
- masterPtr->maskData = NULL;
- masterPtr->fgUid = NULL;
- masterPtr->bgUid = NULL;
- masterPtr->fileString = NULL;
- masterPtr->dataString = NULL;
- masterPtr->maskFileString = NULL;
- masterPtr->maskDataString = NULL;
- masterPtr->instancePtr = NULL;
- if (ImgBmapConfigureMaster(masterPtr, argc, argv, 0) != TCL_OK) {
- ImgBmapDelete((ClientData) masterPtr);
- return TCL_ERROR;
- }
- *clientDataPtr = (ClientData) masterPtr;
- return TCL_OK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ImgBmapConfigureMaster --
- *
- * This procedure is called when a bitmap image is created or
- * reconfigured. It process configuration options and resets
- * any instances of the image.
- *
- * Results:
- * A standard Tcl return value. If TCL_ERROR is returned then
- * an error message is left in masterPtr->interp->result.
- *
- * Side effects:
- * Existing instances of the image will be redisplayed to match
- * the new configuration options.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-ImgBmapConfigureMaster(masterPtr, argc, argv, flags)
- BitmapMaster *masterPtr; /* Pointer to data structure describing
- * overall bitmap image to (reconfigure). */
- int argc; /* Number of entries in argv. */
- char **argv; /* Pairs of configuration options for image. */
- int flags; /* Flags to pass to Tk_ConfigureWidget,
- * such as TK_CONFIG_ARGV_ONLY. */
-{
- BitmapInstance *instancePtr;
- int maskWidth, maskHeight, dummy1, dummy2;
-
- if (Tk_ConfigureWidget(masterPtr->interp, Tk_MainWindow(masterPtr->interp),
- configSpecs, argc, argv, (char *) masterPtr, flags)
- != TCL_OK) {
- return TCL_ERROR;
- }
-
- /*
- * Parse the bitmap and/or mask to create binary data. Make sure that
- * the bitmap and mask have the same dimensions.
- */
-
- if (masterPtr->data != NULL) {
- ckfree(masterPtr->data);
- masterPtr->data = NULL;
- }
- if ((masterPtr->fileString != NULL) || (masterPtr->dataString != NULL)) {
- masterPtr->data = TkGetBitmapData(masterPtr->interp,
- masterPtr->dataString, masterPtr->fileString,
- &masterPtr->width, &masterPtr->height, &dummy1, &dummy2);
- if (masterPtr->data == NULL) {
- return TCL_ERROR;
- }
- }
- if (masterPtr->maskData != NULL) {
- ckfree(masterPtr->maskData);
- masterPtr->maskData = NULL;
- }
- if ((masterPtr->maskFileString != NULL)
- || (masterPtr->maskDataString != NULL)) {
- if (masterPtr->data == NULL) {
- masterPtr->interp->result = "can't have mask without bitmap";
- return TCL_ERROR;
- }
- masterPtr->maskData = TkGetBitmapData(masterPtr->interp,
- masterPtr->maskDataString, masterPtr->maskFileString,
- &maskWidth, &maskHeight, &dummy1, &dummy2);
- if (masterPtr->maskData == NULL) {
- return TCL_ERROR;
- }
- if ((maskWidth != masterPtr->width)
- || (maskHeight != masterPtr->height)) {
- ckfree(masterPtr->maskData);
- masterPtr->maskData = NULL;
- masterPtr->interp->result = "bitmap and mask have different sizes";
- return TCL_ERROR;
- }
- }
-
- /*
- * Cycle through all of the instances of this image, regenerating
- * the information for each instance. Then force the image to be
- * redisplayed everywhere that it is used.
- */
-
- for (instancePtr = masterPtr->instancePtr; instancePtr != NULL;
- instancePtr = instancePtr->nextPtr) {
- ImgBmapConfigureInstance(instancePtr);
- }
- Tk_ImageChanged(masterPtr->tkMaster, 0, 0, masterPtr->width,
- masterPtr->height, masterPtr->width, masterPtr->height);
- return TCL_OK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ImgBmapConfigureInstance --
- *
- * This procedure is called to create displaying information for
- * a bitmap image instance based on the configuration information
- * in the master. It is invoked both when new instances are
- * created and when the master is reconfigured.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Generates errors via Tcl_BackgroundError if there are problems
- * in setting up the instance.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-ImgBmapConfigureInstance(instancePtr)
- BitmapInstance *instancePtr; /* Instance to reconfigure. */
-{
- BitmapMaster *masterPtr = instancePtr->masterPtr;
- XColor *colorPtr;
- XGCValues gcValues;
- GC gc;
- unsigned int mask;
-
- /*
- * For each of the options in masterPtr, translate the string
- * form into an internal form appropriate for instancePtr.
- */
-
- if (*masterPtr->bgUid != 0) {
- colorPtr = Tk_GetColor(masterPtr->interp, instancePtr->tkwin,
- masterPtr->bgUid);
- if (colorPtr == NULL) {
- goto error;
- }
- } else {
- colorPtr = NULL;
- }
- if (instancePtr->bg != NULL) {
- Tk_FreeColor(instancePtr->bg);
- }
- instancePtr->bg = colorPtr;
-
- colorPtr = Tk_GetColor(masterPtr->interp, instancePtr->tkwin,
- masterPtr->fgUid);
- if (colorPtr == NULL) {
- goto error;
- }
- if (instancePtr->fg != NULL) {
- Tk_FreeColor(instancePtr->fg);
- }
- instancePtr->fg = colorPtr;
-
- if (instancePtr->bitmap != None) {
- Tk_FreePixmap(Tk_Display(instancePtr->tkwin), instancePtr->bitmap);
- instancePtr->bitmap = None;
- }
- if (masterPtr->data != NULL) {
- instancePtr->bitmap = XCreateBitmapFromData(
- Tk_Display(instancePtr->tkwin),
- RootWindowOfScreen(Tk_Screen(instancePtr->tkwin)),
- masterPtr->data, (unsigned) masterPtr->width,
- (unsigned) masterPtr->height);
- }
-
- if (instancePtr->mask != None) {
- Tk_FreePixmap(Tk_Display(instancePtr->tkwin), instancePtr->mask);
- instancePtr->mask = None;
- }
- if (masterPtr->maskData != NULL) {
- instancePtr->mask = XCreateBitmapFromData(
- Tk_Display(instancePtr->tkwin),
- RootWindowOfScreen(Tk_Screen(instancePtr->tkwin)),
- masterPtr->maskData, (unsigned) masterPtr->width,
- (unsigned) masterPtr->height);
- }
-
- if (masterPtr->data != NULL) {
- gcValues.foreground = instancePtr->fg->pixel;
- gcValues.graphics_exposures = False;
- mask = GCForeground|GCGraphicsExposures;
- if (instancePtr->bg != NULL) {
- gcValues.background = instancePtr->bg->pixel;
- mask |= GCBackground;
- if (instancePtr->mask != None) {
- gcValues.clip_mask = instancePtr->mask;
- mask |= GCClipMask;
- }
- } else {
- gcValues.clip_mask = instancePtr->bitmap;
- mask |= GCClipMask;
- }
- gc = Tk_GetGC(instancePtr->tkwin, mask, &gcValues);
- } else {
- gc = None;
- }
- if (instancePtr->gc != None) {
- Tk_FreeGC(Tk_Display(instancePtr->tkwin), instancePtr->gc);
- }
- instancePtr->gc = gc;
- return;
-
- error:
- /*
- * An error occurred: clear the graphics context in the instance to
- * make it clear that this instance cannot be displayed. Then report
- * the error.
- */
-
- if (instancePtr->gc != None) {
- Tk_FreeGC(Tk_Display(instancePtr->tkwin), instancePtr->gc);
- }
- instancePtr->gc = None;
- Tcl_AddErrorInfo(masterPtr->interp, "\n (while configuring image \"");
- Tcl_AddErrorInfo(masterPtr->interp, Tk_NameOfImage(masterPtr->tkMaster));
- Tcl_AddErrorInfo(masterPtr->interp, "\")");
- Tcl_BackgroundError(masterPtr->interp);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkGetBitmapData --
- *
- * Given a file name or ASCII string, this procedure parses the
- * file or string contents to produce binary data for a bitmap.
- *
- * Results:
- * If the bitmap description was parsed successfully then the
- * return value is a malloc-ed array containing the bitmap data.
- * The dimensions of the data are stored in *widthPtr and
- * *heightPtr. *hotXPtr and *hotYPtr are set to the bitmap
- * hotspot if one is defined, otherwise they are set to -1, -1.
- * If an error occurred, NULL is returned and an error message is
- * left in interp->result.
- *
- * Side effects:
- * A bitmap is created.
- *
- *----------------------------------------------------------------------
- */
-
-char *
-TkGetBitmapData(interp, string, fileName, widthPtr, heightPtr,
- hotXPtr, hotYPtr)
- Tcl_Interp *interp; /* For reporting errors, or NULL. */
- char *string; /* String describing bitmap. May
- * be NULL. */
- char *fileName; /* Name of file containing bitmap
- * description. Used only if string
- * is NULL. Must not be NULL if
- * string is NULL. */
- int *widthPtr, *heightPtr; /* Dimensions of bitmap get returned
- * here. */
- int *hotXPtr, *hotYPtr; /* Position of hot spot or -1,-1. */
-{
- int width, height, numBytes, hotX, hotY;
- char *p, *end, *expandedFileName;
- ParseInfo pi;
- char *data = NULL;
- Tcl_DString buffer;
-
- pi.string = string;
- if (string == NULL) {
- if ((interp != NULL) && Tcl_IsSafe(interp)) {
- Tcl_AppendResult(interp, "can't get bitmap data from a file in a",
- " safe interpreter", (char *) NULL);
- return NULL;
- }
- expandedFileName = Tcl_TranslateFileName(interp, fileName, &buffer);
- if (expandedFileName == NULL) {
- return NULL;
- }
- pi.chan = Tcl_OpenFileChannel(interp, expandedFileName, "r", 0);
- Tcl_DStringFree(&buffer);
- if (pi.chan == NULL) {
- if (interp != NULL) {
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "couldn't read bitmap file \"",
- fileName, "\": ", Tcl_PosixError(interp),
- (char *) NULL);
- }
- return NULL;
- }
- } else {
- pi.chan = NULL;
- }
-
- /*
- * Parse the lines that define the dimensions of the bitmap,
- * plus the first line that defines the bitmap data (it declares
- * the name of a data variable but doesn't include any actual
- * data). These lines look something like the following:
- *
- * #define foo_width 16
- * #define foo_height 16
- * #define foo_x_hot 3
- * #define foo_y_hot 3
- * static char foo_bits[] = {
- *
- * The x_hot and y_hot lines may or may not be present. It's
- * important to check for "char" in the last line, in order to
- * reject old X10-style bitmaps that used shorts.
- */
-
- width = 0;
- height = 0;
- hotX = -1;
- hotY = -1;
- while (1) {
- if (NextBitmapWord(&pi) != TCL_OK) {
- goto error;
- }
- if ((pi.wordLength >= 6) && (pi.word[pi.wordLength-6] == '_')
- && (strcmp(pi.word+pi.wordLength-6, "_width") == 0)) {
- if (NextBitmapWord(&pi) != TCL_OK) {
- goto error;
- }
- width = strtol(pi.word, &end, 0);
- if ((end == pi.word) || (*end != 0)) {
- goto error;
- }
- } else if ((pi.wordLength >= 7) && (pi.word[pi.wordLength-7] == '_')
- && (strcmp(pi.word+pi.wordLength-7, "_height") == 0)) {
- if (NextBitmapWord(&pi) != TCL_OK) {
- goto error;
- }
- height = strtol(pi.word, &end, 0);
- if ((end == pi.word) || (*end != 0)) {
- goto error;
- }
- } else if ((pi.wordLength >= 6) && (pi.word[pi.wordLength-6] == '_')
- && (strcmp(pi.word+pi.wordLength-6, "_x_hot") == 0)) {
- if (NextBitmapWord(&pi) != TCL_OK) {
- goto error;
- }
- hotX = strtol(pi.word, &end, 0);
- if ((end == pi.word) || (*end != 0)) {
- goto error;
- }
- } else if ((pi.wordLength >= 6) && (pi.word[pi.wordLength-6] == '_')
- && (strcmp(pi.word+pi.wordLength-6, "_y_hot") == 0)) {
- if (NextBitmapWord(&pi) != TCL_OK) {
- goto error;
- }
- hotY = strtol(pi.word, &end, 0);
- if ((end == pi.word) || (*end != 0)) {
- goto error;
- }
- } else if ((pi.word[0] == 'c') && (strcmp(pi.word, "char") == 0)) {
- while (1) {
- if (NextBitmapWord(&pi) != TCL_OK) {
- goto error;
- }
- if ((pi.word[0] == '{') && (pi.word[1] == 0)) {
- goto getData;
- }
- }
- } else if ((pi.word[0] == '{') && (pi.word[1] == 0)) {
- if (interp != NULL) {
- Tcl_AppendResult(interp, "format error in bitmap data; ",
- "looks like it's an obsolete X10 bitmap file",
- (char *) NULL);
- }
- goto errorCleanup;
- }
- }
-
- /*
- * Now we've read everything but the data. Allocate an array
- * and read in the data.
- */
-
- getData:
- if ((width <= 0) || (height <= 0)) {
- goto error;
- }
- numBytes = ((width+7)/8) * height;
- data = (char *) ckalloc((unsigned) numBytes);
- for (p = data; numBytes > 0; p++, numBytes--) {
- if (NextBitmapWord(&pi) != TCL_OK) {
- goto error;
- }
- *p = (char) strtol(pi.word, &end, 0);
- if (end == pi.word) {
- goto error;
- }
- }
-
- /*
- * All done. Clean up and return.
- */
-
- if (pi.chan != NULL) {
- Tcl_Close(NULL, pi.chan);
- }
- *widthPtr = width;
- *heightPtr = height;
- *hotXPtr = hotX;
- *hotYPtr = hotY;
- return data;
-
- error:
- if (interp != NULL) {
- interp->result = "format error in bitmap data";
- }
- errorCleanup:
- if (data != NULL) {
- ckfree(data);
- }
- if (pi.chan != NULL) {
- Tcl_Close(NULL, pi.chan);
- }
- return NULL;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * NextBitmapWord --
- *
- * This procedure retrieves the next word of information (stuff
- * between commas or white space) from a bitmap description.
- *
- * Results:
- * Returns TCL_OK if all went well. In this case the next word,
- * and its length, will be availble in *parseInfoPtr. If the end
- * of the bitmap description was reached then TCL_ERROR is returned.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-NextBitmapWord(parseInfoPtr)
- ParseInfo *parseInfoPtr; /* Describes what we're reading
- * and where we are in it. */
-{
- char *src, *dst;
- int c;
-
- parseInfoPtr->wordLength = 0;
- dst = parseInfoPtr->word;
- if (parseInfoPtr->string != NULL) {
- for (src = parseInfoPtr->string; isspace(UCHAR(*src)) || (*src == ',');
- src++) {
- if (*src == 0) {
- return TCL_ERROR;
- }
- }
- for ( ; !isspace(UCHAR(*src)) && (*src != ',') && (*src != 0); src++) {
- *dst = *src;
- dst++;
- parseInfoPtr->wordLength++;
- if (parseInfoPtr->wordLength > MAX_WORD_LENGTH) {
- return TCL_ERROR;
- }
- }
- parseInfoPtr->string = src;
- } else {
- for (c = GetByte(parseInfoPtr->chan); isspace(UCHAR(c)) || (c == ',');
- c = GetByte(parseInfoPtr->chan)) {
- if (c == EOF) {
- return TCL_ERROR;
- }
- }
- for ( ; !isspace(UCHAR(c)) && (c != ',') && (c != EOF);
- c = GetByte(parseInfoPtr->chan)) {
- *dst = c;
- dst++;
- parseInfoPtr->wordLength++;
- if (parseInfoPtr->wordLength > MAX_WORD_LENGTH) {
- return TCL_ERROR;
- }
- }
- }
- if (parseInfoPtr->wordLength == 0) {
- return TCL_ERROR;
- }
- parseInfoPtr->word[parseInfoPtr->wordLength] = 0;
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ImgBmapCmd --
- *
- * This procedure is invoked to process the Tcl command
- * that corresponds to an image 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
-ImgBmapCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Information about the image master. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- BitmapMaster *masterPtr = (BitmapMaster *) clientData;
- int c, code;
- size_t length;
-
- if (argc < 2) {
- sprintf(interp->result,
- "wrong # args: should be \"%.50s option ?arg arg ...?\"",
- argv[0]);
- 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;
- }
- return Tk_ConfigureValue(interp, Tk_MainWindow(interp), configSpecs,
- (char *) masterPtr, argv[2], 0);
- } else if ((c == 'c') && (strncmp(argv[1], "configure", length) == 0)
- && (length >= 2)) {
- if (argc == 2) {
- code = Tk_ConfigureInfo(interp, Tk_MainWindow(interp),
- configSpecs, (char *) masterPtr, (char *) NULL, 0);
- } else if (argc == 3) {
- code = Tk_ConfigureInfo(interp, Tk_MainWindow(interp),
- configSpecs, (char *) masterPtr, argv[2], 0);
- } else {
- code = ImgBmapConfigureMaster(masterPtr, argc-2, argv+2,
- TK_CONFIG_ARGV_ONLY);
- }
- return code;
- } else {
- Tcl_AppendResult(interp, "bad option \"", argv[1],
- "\": must be cget or configure", (char *) NULL);
- return TCL_ERROR;
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ImgBmapGet --
- *
- * This procedure is called for each use of a bitmap image in a
- * widget.
- *
- * Results:
- * The return value is a token for the instance, which is passed
- * back to us in calls to ImgBmapDisplay and ImgBmapFree.
- *
- * Side effects:
- * A data structure is set up for the instance (or, an existing
- * instance is re-used for the new one).
- *
- *----------------------------------------------------------------------
- */
-
-static ClientData
-ImgBmapGet(tkwin, masterData)
- Tk_Window tkwin; /* Window in which the instance will be
- * used. */
- ClientData masterData; /* Pointer to our master structure for the
- * image. */
-{
- BitmapMaster *masterPtr = (BitmapMaster *) masterData;
- BitmapInstance *instancePtr;
-
- /*
- * See if there is already an instance for this window. If so
- * then just re-use it.
- */
-
- for (instancePtr = masterPtr->instancePtr; instancePtr != NULL;
- instancePtr = instancePtr->nextPtr) {
- if (instancePtr->tkwin == tkwin) {
- instancePtr->refCount++;
- return (ClientData) instancePtr;
- }
- }
-
- /*
- * The image isn't already in use in this window. Make a new
- * instance of the image.
- */
-
- instancePtr = (BitmapInstance *) ckalloc(sizeof(BitmapInstance));
- instancePtr->refCount = 1;
- instancePtr->masterPtr = masterPtr;
- instancePtr->tkwin = tkwin;
- instancePtr->fg = NULL;
- instancePtr->bg = NULL;
- instancePtr->bitmap = None;
- instancePtr->mask = None;
- instancePtr->gc = None;
- instancePtr->nextPtr = masterPtr->instancePtr;
- masterPtr->instancePtr = instancePtr;
- ImgBmapConfigureInstance(instancePtr);
-
- /*
- * If this is the first instance, must set the size of the image.
- */
-
- if (instancePtr->nextPtr == NULL) {
- Tk_ImageChanged(masterPtr->tkMaster, 0, 0, 0, 0, masterPtr->width,
- masterPtr->height);
- }
-
- return (ClientData) instancePtr;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ImgBmapDisplay --
- *
- * This procedure is invoked to draw a bitmap image.
- *
- * Results:
- * None.
- *
- * Side effects:
- * A portion of the image gets rendered in a pixmap or window.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-ImgBmapDisplay(clientData, display, drawable, imageX, imageY, width,
- height, drawableX, drawableY)
- ClientData clientData; /* Pointer to BitmapInstance structure for
- * for instance to be displayed. */
- Display *display; /* Display on which to draw image. */
- Drawable drawable; /* Pixmap or window in which to draw image. */
- int imageX, imageY; /* Upper-left corner of region within image
- * to draw. */
- int width, height; /* Dimensions of region within image to draw. */
- int drawableX, drawableY; /* Coordinates within drawable that
- * correspond to imageX and imageY. */
-{
- BitmapInstance *instancePtr = (BitmapInstance *) clientData;
- int masking;
-
- /*
- * If there's no graphics context, it means that an error occurred
- * while creating the image instance so it can't be displayed.
- */
-
- if (instancePtr->gc == None) {
- return;
- }
-
- /*
- * If masking is in effect, must modify the mask origin within
- * the graphics context to line up with the image's origin.
- * Then draw the image and reset the clip origin, if there's
- * a mask.
- */
-
- masking = (instancePtr->mask != None) || (instancePtr->bg == NULL);
- if (masking) {
- XSetClipOrigin(display, instancePtr->gc, drawableX - imageX,
- drawableY - imageY);
- }
- XCopyPlane(display, instancePtr->bitmap, drawable, instancePtr->gc,
- imageX, imageY, (unsigned) width, (unsigned) height,
- drawableX, drawableY, 1);
- if (masking) {
- XSetClipOrigin(display, instancePtr->gc, 0, 0);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ImgBmapFree --
- *
- * This procedure is called when a widget ceases to use a
- * particular instance of an image.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Internal data structures get cleaned up.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-ImgBmapFree(clientData, display)
- ClientData clientData; /* Pointer to BitmapInstance structure for
- * for instance to be displayed. */
- Display *display; /* Display containing window that used image. */
-{
- BitmapInstance *instancePtr = (BitmapInstance *) clientData;
- BitmapInstance *prevPtr;
-
- instancePtr->refCount--;
- if (instancePtr->refCount > 0) {
- return;
- }
-
- /*
- * There are no more uses of the image within this widget. Free
- * the instance structure.
- */
-
- if (instancePtr->fg != NULL) {
- Tk_FreeColor(instancePtr->fg);
- }
- if (instancePtr->bg != NULL) {
- Tk_FreeColor(instancePtr->bg);
- }
- if (instancePtr->bitmap != None) {
- Tk_FreePixmap(display, instancePtr->bitmap);
- }
- if (instancePtr->mask != None) {
- Tk_FreePixmap(display, instancePtr->mask);
- }
- if (instancePtr->gc != None) {
- Tk_FreeGC(display, instancePtr->gc);
- }
- if (instancePtr->masterPtr->instancePtr == instancePtr) {
- instancePtr->masterPtr->instancePtr = instancePtr->nextPtr;
- } else {
- for (prevPtr = instancePtr->masterPtr->instancePtr;
- prevPtr->nextPtr != instancePtr; prevPtr = prevPtr->nextPtr) {
- /* Empty loop body */
- }
- prevPtr->nextPtr = instancePtr->nextPtr;
- }
- ckfree((char *) instancePtr);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ImgBmapDelete --
- *
- * This procedure is called by the image code to delete the
- * master structure for an image.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Resources associated with the image get freed.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-ImgBmapDelete(masterData)
- ClientData masterData; /* Pointer to BitmapMaster structure for
- * image. Must not have any more instances. */
-{
- BitmapMaster *masterPtr = (BitmapMaster *) masterData;
-
- if (masterPtr->instancePtr != NULL) {
- panic("tried to delete bitmap image when instances still exist");
- }
- masterPtr->tkMaster = NULL;
- if (masterPtr->imageCmd != NULL) {
- Tcl_DeleteCommandFromToken(masterPtr->interp, masterPtr->imageCmd);
- }
- if (masterPtr->data != NULL) {
- ckfree(masterPtr->data);
- }
- if (masterPtr->maskData != NULL) {
- ckfree(masterPtr->maskData);
- }
- Tk_FreeOptions(configSpecs, (char *) masterPtr, (Display *) NULL, 0);
- ckfree((char *) masterPtr);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ImgBmapCmdDeletedProc --
- *
- * This procedure is invoked when the image command for an image
- * is deleted. It deletes the image.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The image is deleted.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-ImgBmapCmdDeletedProc(clientData)
- ClientData clientData; /* Pointer to BitmapMaster structure for
- * image. */
-{
- BitmapMaster *masterPtr = (BitmapMaster *) clientData;
-
- masterPtr->imageCmd = NULL;
- if (masterPtr->tkMaster != NULL) {
- Tk_DeleteImage(masterPtr->interp, Tk_NameOfImage(masterPtr->tkMaster));
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * GetByte --
- *
- * Get the next byte from the open channel.
- *
- * Results:
- * The next byte or EOF.
- *
- * Side effects:
- * We read from the channel.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-GetByte(chan)
- Tcl_Channel chan; /* The channel we read from. */
-{
- char buffer;
- int size;
-
- size = Tcl_Read(chan, &buffer, 1);
- if (size <= 0) {
- return EOF;
- } else {
- return buffer;
- }
-}
diff --git a/generic/tkImgGIF.c b/generic/tkImgGIF.c
deleted file mode 100644
index d9dd900..0000000
--- a/generic/tkImgGIF.c
+++ /dev/null
@@ -1,1059 +0,0 @@
-/*
- * tkImgGIF.c --
- *
- * A photo image file handler for GIF files. Reads 87a and 89a GIF
- * files. At present there is no write function. GIF images may be
- * read using the -data option of the photo image by representing
- * the data as BASE64 encoded ascii. Derived from the giftoppm code
- * found in the pbmplus package and tkImgFmtPPM.c in the tk4.0b2
- * distribution.
- *
- * Copyright (c) Reed Wade (wade@cs.utk.edu), University of Tennessee
- * Copyright (c) 1995-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.
- *
- * 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. |
- * +-------------------------------------------------------------------+
- *
- * RCS: @(#) $Id: tkImgGIF.c,v 1.2 1998/09/14 18:23:12 stanton Exp $
- */
-
-/*
- * GIF's are represented as data in base64 format.
- * base64 strings consist of 4 6-bit characters -> 3 8 bit bytes.
- * A-Z, a-z, 0-9, + and / represent the 64 values (in order).
- * '=' is a trailing padding char when the un-encoded data is not a
- * multiple of 3 bytes. We'll ignore white space when encountered.
- * Any other invalid character is treated as an EOF
- */
-
-#define GIF_SPECIAL (256)
-#define GIF_PAD (GIF_SPECIAL+1)
-#define GIF_SPACE (GIF_SPECIAL+2)
-#define GIF_BAD (GIF_SPECIAL+3)
-#define GIF_DONE (GIF_SPECIAL+4)
-
-/*
- * structure to "mimic" FILE for Mread, so we can look like fread.
- * The decoder state keeps track of which byte we are about to read,
- * or EOF.
- */
-
-typedef struct mFile {
- unsigned char *data; /* mmencoded source string */
- int c; /* bits left over from previous character */
- int state; /* decoder state (0-4 or GIF_DONE) */
-} MFile;
-
-#include "tkInt.h"
-#include "tkPort.h"
-
-/*
- * The format record for the GIF file format:
- */
-
-static int FileMatchGIF _ANSI_ARGS_((Tcl_Channel chan, char *fileName,
- char *formatString, int *widthPtr, int *heightPtr));
-static int FileReadGIF _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));
-static int StringMatchGIF _ANSI_ARGS_(( char *string,
- char *formatString, int *widthPtr, int *heightPtr));
-static int StringReadGIF _ANSI_ARGS_((Tcl_Interp *interp, char *string,
- char *formatString, Tk_PhotoHandle imageHandle,
- int destX, int destY, int width, int height,
- int srcX, int srcY));
-
-Tk_PhotoImageFormat tkImgFmtGIF = {
- "GIF", /* name */
- FileMatchGIF, /* fileMatchProc */
- StringMatchGIF, /* stringMatchProc */
- FileReadGIF, /* fileReadProc */
- StringReadGIF, /* stringReadProc */
- NULL, /* fileWriteProc */
- NULL, /* stringWriteProc */
-};
-
-#define INTERLACE 0x40
-#define LOCALCOLORMAP 0x80
-#define BitSet(byte, bit) (((byte) & (bit)) == (bit))
-#define MAXCOLORMAPSIZE 256
-#define CM_RED 0
-#define CM_GREEN 1
-#define CM_BLUE 2
-#define CM_ALPHA 3
-#define MAX_LWZ_BITS 12
-#define LM_to_uint(a,b) (((b)<<8)|(a))
-#define ReadOK(file,buffer,len) (Fread(buffer, len, 1, file) != 0)
-
-/*
- * HACK ALERT!! HACK ALERT!! HACK ALERT!!
- * This code is hard-wired for reading from files. In order to read
- * from a data stream, we'll trick fread so we can reuse the same code
- */
-
-static int fromData=0;
-
-/*
- * Prototypes for local procedures defined in this file:
- */
-
-static int DoExtension _ANSI_ARGS_((Tcl_Channel chan, int label,
- int *transparent));
-static int GetCode _ANSI_ARGS_((Tcl_Channel chan, int code_size,
- int flag));
-static int GetDataBlock _ANSI_ARGS_((Tcl_Channel chan,
- unsigned char *buf));
-static int LWZReadByte _ANSI_ARGS_((Tcl_Channel chan, int flag,
- int input_code_size));
-static int ReadColorMap _ANSI_ARGS_((Tcl_Channel chan, int number,
- unsigned char buffer[MAXCOLORMAPSIZE][4]));
-static int ReadGIFHeader _ANSI_ARGS_((Tcl_Channel chan,
- int *widthPtr, int *heightPtr));
-static int ReadImage _ANSI_ARGS_((Tcl_Interp *interp,
- char *imagePtr, Tcl_Channel chan,
- int len, int rows,
- unsigned char cmap[MAXCOLORMAPSIZE][4],
- int width, int height, int srcX, int srcY,
- int interlace, int transparent));
-
-/*
- * these are for the BASE64 image reader code only
- */
-
-static int Fread _ANSI_ARGS_((unsigned char *dst, size_t size,
- size_t count, Tcl_Channel chan));
-static int Mread _ANSI_ARGS_((unsigned char *dst, size_t size,
- size_t count, MFile *handle));
-static int Mgetc _ANSI_ARGS_((MFile *handle));
-static int char64 _ANSI_ARGS_((int c));
-static void mInit _ANSI_ARGS_((unsigned char *string,
- MFile *handle));
-
-/*
- *----------------------------------------------------------------------
- *
- * FileMatchGIF --
- *
- * This procedure is invoked by the photo image type to see if
- * a file contains image data in GIF format.
- *
- * Results:
- * The return value is 1 if the first characters in file f look
- * like GIF data, and 0 otherwise.
- *
- * Side effects:
- * The access position in f may change.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-FileMatchGIF(chan, fileName, formatString, widthPtr, heightPtr)
- Tcl_Channel chan; /* The image file, open for reading. */
- char *fileName; /* The name of the image file. */
- char *formatString; /* User-specified format string, or NULL. */
- int *widthPtr, *heightPtr; /* The dimensions of the image are
- * returned here if the file is a valid
- * raw GIF file. */
-{
- return ReadGIFHeader(chan, widthPtr, heightPtr);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * FileReadGIF --
- *
- * This procedure is called by the photo image type to read
- * GIF format data from a file and write it into a given
- * photo image.
- *
- * Results:
- * A standard TCL completion code. If TCL_ERROR is returned
- * then an error message is left in interp->result.
- *
- * Side effects:
- * The access position in file f is changed, and new data is
- * added to the image given by imageHandle.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-FileReadGIF(interp, chan, fileName, formatString, imageHandle, destX, destY,
- width, height, srcX, srcY)
- Tcl_Interp *interp; /* Interpreter to use for reporting errors. */
- Tcl_Channel chan; /* The image file, open for reading. */
- char *fileName; /* The name of the image file. */
- char *formatString; /* User-specified format string, or NULL. */
- Tk_PhotoHandle imageHandle; /* The photo image to write into. */
- int destX, destY; /* Coordinates of top-left pixel in
- * photo image to be written to. */
- int width, height; /* Dimensions of block of photo image to
- * be written to. */
- int srcX, srcY; /* Coordinates of top-left pixel to be used
- * in image being read. */
-{
- int fileWidth, fileHeight;
- int nBytes;
- Tk_PhotoImageBlock block;
- unsigned char buf[100];
- int bitPixel;
- unsigned char colorMap[MAXCOLORMAPSIZE][4];
- int transparent = -1;
-
- if (!ReadGIFHeader(chan, &fileWidth, &fileHeight)) {
- Tcl_AppendResult(interp, "couldn't read GIF header from file \"",
- fileName, "\"", NULL);
- return TCL_ERROR;
- }
- if ((fileWidth <= 0) || (fileHeight <= 0)) {
- Tcl_AppendResult(interp, "GIF image file \"", fileName,
- "\" has dimension(s) <= 0", (char *) NULL);
- return TCL_ERROR;
- }
-
- if (Fread(buf, 1, 3, chan) != 3) {
- return TCL_OK;
- }
- bitPixel = 2<<(buf[0]&0x07);
-
- if (BitSet(buf[0], LOCALCOLORMAP)) { /* Global Colormap */
- if (!ReadColorMap(chan, bitPixel, colorMap)) {
- Tcl_AppendResult(interp, "error reading color map",
- (char *) NULL);
- return TCL_ERROR;
- }
- }
-
- if ((srcX + width) > fileWidth) {
- width = fileWidth - srcX;
- }
- if ((srcY + height) > fileHeight) {
- height = fileHeight - srcY;
- }
- if ((width <= 0) || (height <= 0)
- || (srcX >= fileWidth) || (srcY >= fileHeight)) {
- return TCL_OK;
- }
-
- Tk_PhotoExpand(imageHandle, destX + width, destY + height);
-
- block.width = width;
- block.height = height;
- block.pixelSize = 4;
- block.pitch = block.pixelSize * block.width;
- block.offset[0] = 0;
- block.offset[1] = 1;
- block.offset[2] = 2;
- nBytes = height * block.pitch;
- block.pixelPtr = (unsigned char *) ckalloc((unsigned) nBytes);
-
- while (1) {
- if (Fread(buf, 1, 1, chan) != 1) {
- /*
- * Premature end of image. We should really notify
- * the user, but for now just show garbage.
- */
-
- break;
- }
-
- if (buf[0] == ';') {
- /*
- * GIF terminator.
- */
-
- break;
- }
-
- if (buf[0] == '!') {
- /*
- * This is a GIF extension.
- */
-
- if (Fread(buf, 1, 1, chan) != 1) {
- interp->result =
- "error reading extension function code in GIF image";
- goto error;
- }
- if (DoExtension(chan, buf[0], &transparent) < 0) {
- interp->result = "error reading extension in GIF image";
- goto error;
- }
- continue;
- }
-
- if (buf[0] != ',') {
- /*
- * Not a valid start character; ignore it.
- */
- continue;
- }
-
- if (Fread(buf, 1, 9, chan) != 9) {
- interp->result = "couldn't read left/top/width/height in GIF image";
- goto error;
- }
-
- bitPixel = 1<<((buf[8]&0x07)+1);
-
- if (BitSet(buf[8], LOCALCOLORMAP)) {
- if (!ReadColorMap(chan, bitPixel, colorMap)) {
- Tcl_AppendResult(interp, "error reading color map",
- (char *) NULL);
- goto error;
- }
- }
- if (ReadImage(interp, (char *) block.pixelPtr, chan, width,
- height, colorMap, fileWidth, fileHeight, srcX, srcY,
- BitSet(buf[8], INTERLACE), transparent) != TCL_OK) {
- goto error;
- }
- break;
- }
-
- if (transparent == -1) {
- Tk_PhotoPutBlock(imageHandle, &block, destX, destY, width, height);
- } else {
- int x, y, end;
- unsigned char *imagePtr, *rowPtr, *pixelPtr;
-
- imagePtr = rowPtr = block.pixelPtr;
- for (y = 0; y < height; y++) {
- x = 0;
- pixelPtr = rowPtr;
- while(x < width) {
- /* search for first non-transparent pixel */
- while ((x < width) && !(pixelPtr[CM_ALPHA])) {
- x++; pixelPtr += 4;
- }
- end = x;
- /* search for first transparent pixel */
- while ((end < width) && pixelPtr[CM_ALPHA]) {
- end++; pixelPtr += 4;
- }
- if (end > x) {
- block.pixelPtr = rowPtr + 4 * x;
- Tk_PhotoPutBlock(imageHandle, &block, destX+x,
- destY+y, end-x, 1);
- }
- x = end;
- }
- rowPtr += block.pitch;
- }
- block.pixelPtr = imagePtr;
- }
- ckfree((char *) block.pixelPtr);
- return TCL_OK;
-
- error:
- ckfree((char *) block.pixelPtr);
- return TCL_ERROR;
-
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * StringMatchGIF --
- *
- * This procedure is invoked by the photo image type to see if
- * a string contains image data in GIF format.
- *
- * Results:
- * The return value is 1 if the first characters in the string
- * like GIF data, and 0 otherwise.
- *
- * Side effects:
- * the size of the image is placed in widthPre and heightPtr.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-StringMatchGIF(string, formatString, widthPtr, heightPtr)
- char *string; /* the string containing the image data */
- char *formatString; /* the image format string */
- int *widthPtr; /* where to put the string width */
- int *heightPtr; /* where to put the string height */
-{
- unsigned char header[10];
- int got;
- MFile handle;
- mInit((unsigned char *) string, &handle);
- got = Mread(header, 10, 1, &handle);
- if (got != 10
- || ((strncmp("GIF87a", (char *) header, 6) != 0)
- && (strncmp("GIF89a", (char *) header, 6) != 0))) {
- return 0;
- }
- *widthPtr = LM_to_uint(header[6],header[7]);
- *heightPtr = LM_to_uint(header[8],header[9]);
- return 1;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * StringReadGif -- --
- *
- * This procedure is called by the photo image type to read
- * GIF format data from a base64 encoded string, and give it to
- * the photo image.
- *
- * Results:
- * A standard TCL completion code. If TCL_ERROR is returned
- * then an error message is left in interp->result.
- *
- * Side effects:
- * new data is added to the image given by imageHandle. This
- * procedure calls FileReadGif by redefining the operation of
- * fprintf temporarily.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-StringReadGIF(interp,string,formatString,imageHandle,
- destX, destY, width, height, srcX, srcY)
- Tcl_Interp *interp; /* interpreter for reporting errors in */
- char *string; /* string containing the image */
- char *formatString; /* format string if any */
- 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 srcX, srcY;
-{
- int result;
- MFile handle;
- mInit((unsigned char *)string,&handle);
- fromData = 1;
- result = FileReadGIF(interp, (Tcl_Channel) &handle, "inline data",
- formatString, imageHandle, destX, destY, width, height,
- srcX, srcY);
- fromData = 0;
- return(result);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ReadGIFHeader --
- *
- * This procedure reads the GIF header from the beginning of a
- * GIF file and returns the dimensions of the image.
- *
- * Results:
- * The return value is 1 if file "f" appears to start with
- * a valid GIF header, 0 otherwise. If the header is valid,
- * then *widthPtr and *heightPtr are modified to hold the
- * dimensions of the image.
- *
- * Side effects:
- * The access position in f advances.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-ReadGIFHeader(chan, widthPtr, heightPtr)
- Tcl_Channel chan; /* Image file to read the header from */
- int *widthPtr, *heightPtr; /* The dimensions of the image are
- * returned here. */
-{
- unsigned char buf[7];
-
- if ((Fread(buf, 1, 6, chan) != 6)
- || ((strncmp("GIF87a", (char *) buf, 6) != 0)
- && (strncmp("GIF89a", (char *) buf, 6) != 0))) {
- return 0;
- }
-
- if (Fread(buf, 1, 4, chan) != 4) {
- return 0;
- }
-
- *widthPtr = LM_to_uint(buf[0],buf[1]);
- *heightPtr = LM_to_uint(buf[2],buf[3]);
- return 1;
-}
-
-/*
- *-----------------------------------------------------------------
- * The code below is copied from the giftoppm program and modified
- * just slightly.
- *-----------------------------------------------------------------
- */
-
-static int
-ReadColorMap(chan, number, buffer)
- Tcl_Channel chan;
- int number;
- unsigned char buffer[MAXCOLORMAPSIZE][4];
-{
- int i;
- unsigned char rgb[3];
-
- for (i = 0; i < number; ++i) {
- if (! ReadOK(chan, rgb, sizeof(rgb))) {
- return 0;
- }
-
- 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;
-{
- static unsigned char buf[256];
- int count;
-
- switch (label) {
- case 0x01: /* Plain Text Extension */
- break;
-
- case 0xff: /* Application Extension */
- break;
-
- case 0xfe: /* Comment Extension */
- do {
- count = GetDataBlock(chan, (unsigned char*) buf);
- } 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;
-}
-
-static int ZeroDataBlock = 0;
-
-static int
-GetDataBlock(chan, buf)
- Tcl_Channel chan;
- unsigned char *buf;
-{
- unsigned char count;
-
- if (! ReadOK(chan, &count,1)) {
- return -1;
- }
-
- ZeroDataBlock = count == 0;
-
- if ((count != 0) && (! ReadOK(chan, buf, count))) {
- return -1;
- }
-
- return count;
-}
-
-
-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;
-{
- unsigned char c;
- int v;
- int xpos = 0, ypos = 0, pass = 0;
- char *pixelPtr;
-
-
- /*
- * Initialize the Compression routines
- */
- if (! ReadOK(chan, &c, 1)) {
- Tcl_AppendResult(interp, "error reading GIF image: ",
- Tcl_PosixError(interp), (char *) NULL);
- return TCL_ERROR;
- }
-
- if (LWZReadByte(chan, 1, c) < 0) {
- interp->result = "format error in GIF image";
- return TCL_ERROR;
- }
-
- if (transparent!=-1) {
- cmap[transparent][CM_RED] = 0;
- cmap[transparent][CM_GREEN] = 0;
- cmap[transparent][CM_BLUE] = 0;
- cmap[transparent][CM_ALPHA] = 0;
- }
-
- pixelPtr = imagePtr;
- while ((v = LWZReadByte(chan, 0, c)) >= 0 ) {
-
- if ((xpos>=srcX) && (xpos<srcX+len) &&
- (ypos>=srcY) && (ypos<srcY+rows)) {
- *pixelPtr++ = cmap[v][CM_RED];
- *pixelPtr++ = cmap[v][CM_GREEN];
- *pixelPtr++ = cmap[v][CM_BLUE];
- *pixelPtr++ = cmap[v][CM_ALPHA];
- }
-
- ++xpos;
- if (xpos == width) {
- xpos = 0;
- if (interlace) {
- switch (pass) {
- case 0:
- case 1:
- ypos += 8; break;
- case 2:
- ypos += 4; break;
- case 3:
- ypos += 2; break;
- }
-
- while (ypos >= height) {
- ++pass;
- switch (pass) {
- case 1:
- ypos = 4; break;
- case 2:
- ypos = 2; break;
- case 3:
- ypos = 1; break;
- default:
- return TCL_OK;
- }
- }
- } else {
- ++ypos;
- }
- pixelPtr = imagePtr + (ypos-srcY) * len * 4;
- }
- if (ypos >= height)
- break;
- }
- return TCL_OK;
-}
-
-static int
-LWZReadByte(chan, flag, input_code_size)
- Tcl_Channel chan;
- int flag;
- int input_code_size;
-{
- static int fresh = 0;
- int code, incode;
- static int code_size, set_code_size;
- static int max_code, max_code_size;
- static int firstcode, oldcode;
- static int clear_code, end_code;
- static int table[2][(1<< MAX_LWZ_BITS)];
- static int stack[(1<<(MAX_LWZ_BITS))*2], *sp;
- register int i;
-
- if (flag) {
- set_code_size = input_code_size;
- code_size = set_code_size+1;
- clear_code = 1 << set_code_size ;
- end_code = clear_code + 1;
- max_code_size = 2*clear_code;
- max_code = clear_code+2;
-
- GetCode(chan, 0, 1);
-
- fresh = 1;
-
- for (i = 0; i < clear_code; ++i) {
- table[0][i] = 0;
- table[1][i] = i;
- }
- for (; i < (1<<MAX_LWZ_BITS); ++i) {
- table[0][i] = table[1][0] = 0;
- }
-
- sp = stack;
-
- return 0;
- } else if (fresh) {
- fresh = 0;
- do {
- firstcode = oldcode = GetCode(chan, code_size, 0);
- } while (firstcode == clear_code);
- return firstcode;
- }
-
- if (sp > stack) {
- return *--sp;
- }
-
- while ((code = GetCode(chan, code_size, 0)) >= 0) {
- if (code == clear_code) {
- for (i = 0; i < clear_code; ++i) {
- table[0][i] = 0;
- table[1][i] = i;
- }
-
- for (; i < (1<<MAX_LWZ_BITS); ++i) {
- table[0][i] = table[1][i] = 0;
- }
-
- code_size = set_code_size+1;
- max_code_size = 2*clear_code;
- max_code = clear_code+2;
- sp = stack;
- firstcode = oldcode = GetCode(chan, code_size, 0);
- return firstcode;
-
- } else if (code == end_code) {
- int count;
- unsigned char buf[260];
-
- if (ZeroDataBlock) {
- return -2;
- }
-
- while ((count = GetDataBlock(chan, buf)) > 0)
- /* Empty body */;
-
- if (count != 0) {
- return -2;
- }
- }
-
- incode = code;
-
- if (code >= max_code) {
- *sp++ = firstcode;
- code = oldcode;
- }
-
- while (code >= clear_code) {
- *sp++ = table[1][code];
- if (code == table[0][code]) {
- return -2;
-
- /*
- * Used to be this instead, Steve Ball suggested
- * the change to just return.
- printf("circular table entry BIG ERROR\n");
- */
- }
- code = table[0][code];
- }
-
- *sp++ = firstcode = table[1][code];
-
- if ((code = max_code) <(1<<MAX_LWZ_BITS)) {
- table[0][code] = oldcode;
- table[1][code] = firstcode;
- ++max_code;
- if ((max_code>=max_code_size) && (max_code_size < (1<<MAX_LWZ_BITS))) {
- max_code_size *= 2;
- ++code_size;
- }
- }
-
- oldcode = incode;
-
- if (sp > stack)
- return *--sp;
- }
- return code;
-}
-
-
-static int
-GetCode(chan, code_size, flag)
- Tcl_Channel chan;
- int code_size;
- int flag;
-{
- static unsigned char buf[280];
- static int curbit, lastbit, done, last_byte;
- int i, j, ret;
- unsigned char count;
-
- if (flag) {
- curbit = 0;
- lastbit = 0;
- done = 0;
- return 0;
- }
-
-
- if ( (curbit+code_size) >= lastbit) {
- if (done) {
- /* ran off the end of my bits */
- return -1;
- }
- if (last_byte >= 2) {
- buf[0] = buf[last_byte-2];
- }
- if (last_byte >= 1) {
- buf[1] = buf[last_byte-1];
- }
-
- if ((count = GetDataBlock(chan, &buf[2])) == 0) {
- done = 1;
- }
-
- last_byte = 2 + count;
- curbit = (curbit - lastbit) + 16;
- lastbit = (2+count)*8 ;
- }
-
- ret = 0;
- for (i = curbit, j = 0; j < code_size; ++i, ++j) {
- ret |= ((buf[ i / 8 ] & (1 << (i % 8))) != 0) << j;
- }
-
- curbit += code_size;
-
- return ret;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Minit -- --
- *
- * This procedure initializes a base64 decoder handle
- *
- * Results:
- * none
- *
- * Side effects:
- * the base64 handle is initialized
- *
- *----------------------------------------------------------------------
- */
-
-static void
-mInit(string, handle)
- unsigned char *string; /* string containing initial mmencoded data */
- MFile *handle; /* mmdecode "file" handle */
-{
- handle->data = string;
- handle->state = 0;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Mread --
- *
- * This procedure is invoked by the GIF file reader as a
- * temporary replacement for "fread", to get GIF data out
- * of a string (using Mgetc).
- *
- * Results:
- * The return value is the number of characters "read"
- *
- * Side effects:
- * The base64 handle will change state.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-Mread(dst, chunkSize, numChunks, handle)
- unsigned char *dst; /* where to put the result */
- size_t chunkSize; /* size of each transfer */
- size_t numChunks; /* number of chunks */
- MFile *handle; /* mmdecode "file" handle */
-{
- register int i, c;
- int count = chunkSize * numChunks;
-
- for(i=0; i<count && (c=Mgetc(handle)) != GIF_DONE; i++) {
- *dst++ = c;
- }
- return i;
-}
-
-/*
- * get the next decoded character from an mmencode handle
- * This causes at least 1 character to be "read" from the encoded string
- */
-
-/*
- *----------------------------------------------------------------------
- *
- * Mgetc --
- *
- * This procedure decodes and returns the next byte from a base64
- * encoded string.
- *
- * Results:
- * The next byte (or GIF_DONE) is returned.
- *
- * Side effects:
- * The base64 handle will change state.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-Mgetc(handle)
- 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);
- }
-
- do {
- c = char64(*handle->data);
- handle->data++;
- } while (c==GIF_SPACE);
-
- if (c>GIF_SPECIAL) {
- handle->state = GIF_DONE;
- return(handle->state ? handle->c : GIF_DONE);
- }
-
- 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);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * char64 --
- *
- * This procedure converts a base64 ascii character into its binary
- * equivalent. This code is a slightly modified version of the
- * char64 proc in N. Borenstein's metamail decoder.
- *
- * Results:
- * The binary value, or an error code.
- *
- * Side effects:
- * None.
- *----------------------------------------------------------------------
- */
-
-static int
-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);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Fread --
- *
- * This procedure calls either fread or Mread to read data
- * from a file or a base64 encoded string.
- *
- * Results: - same as fread
- *
- *----------------------------------------------------------------------
- */
-
-static int
-Fread(dst, hunk, count, chan)
- unsigned char *dst; /* where to put the result */
- size_t hunk,count; /* how many */
- Tcl_Channel chan;
-{
- if (fromData) {
- return(Mread(dst, hunk, count, (MFile *) chan));
- } else {
- return Tcl_Read(chan, (char *) dst, (int) (hunk * count));
- }
-}
diff --git a/generic/tkImgPPM.c b/generic/tkImgPPM.c
deleted file mode 100644
index 7573955..0000000
--- a/generic/tkImgPPM.c
+++ /dev/null
@@ -1,421 +0,0 @@
-/*
- * tkImgPPM.c --
- *
- * A photo image file handler for PPM (Portable PixMap) files.
- *
- * Copyright (c) 1994 The Australian National University.
- * 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.
- *
- * Author: Paul Mackerras (paulus@cs.anu.edu.au),
- * Department of Computer Science,
- * Australian National University.
- *
- * RCS: @(#) $Id: tkImgPPM.c,v 1.2 1998/09/14 18:23:13 stanton Exp $
- */
-
-#include "tkInt.h"
-#include "tkPort.h"
-
-/*
- * The maximum amount of memory to allocate for data read from the
- * file. If we need more than this, we do it in pieces.
- */
-
-#define MAX_MEMORY 10000 /* don't allocate > 10KB */
-
-/*
- * Define PGM and PPM, i.e. gray images and color images.
- */
-
-#define PGM 1
-#define PPM 2
-
-/*
- * The format record for the PPM file format:
- */
-
-static int FileMatchPPM _ANSI_ARGS_((Tcl_Channel chan,
- char *fileName, char *formatString,
- int *widthPtr, int *heightPtr));
-static int FileReadPPM _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));
-static int FileWritePPM _ANSI_ARGS_((Tcl_Interp *interp,
- char *fileName, char *formatString,
- Tk_PhotoImageBlock *blockPtr));
-
-Tk_PhotoImageFormat tkImgFmtPPM = {
- "PPM", /* name */
- FileMatchPPM, /* fileMatchProc */
- NULL, /* stringMatchProc */
- FileReadPPM, /* fileReadProc */
- NULL, /* stringReadProc */
- FileWritePPM, /* fileWriteProc */
- NULL, /* stringWriteProc */
-};
-
-/*
- * Prototypes for local procedures defined in this file:
- */
-
-static int ReadPPMFileHeader _ANSI_ARGS_((Tcl_Channel chan,
- int *widthPtr, int *heightPtr,
- int *maxIntensityPtr));
-
-/*
- *----------------------------------------------------------------------
- *
- * FileMatchPPM --
- *
- * This procedure is invoked by the photo image type to see if
- * a file contains image data in PPM format.
- *
- * Results:
- * The return value is >0 if the first characters in file "f" look
- * like PPM data, and 0 otherwise.
- *
- * Side effects:
- * The access position in f may change.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-FileMatchPPM(chan, fileName, formatString, widthPtr, heightPtr)
- Tcl_Channel chan; /* The image file, open for reading. */
- char *fileName; /* The name of the image file. */
- char *formatString; /* User-specified format string, or NULL. */
- int *widthPtr, *heightPtr; /* The dimensions of the image are
- * returned here if the file is a valid
- * raw PPM file. */
-{
- int dummy;
-
- return ReadPPMFileHeader(chan, widthPtr, heightPtr, &dummy);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * FileReadPPM --
- *
- * This procedure is called by the photo image type to read
- * PPM format data from a file and write it into a given
- * photo image.
- *
- * Results:
- * A standard TCL completion code. If TCL_ERROR is returned
- * then an error message is left in interp->result.
- *
- * Side effects:
- * The access position in file f is changed, and new data is
- * added to the image given by imageHandle.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-FileReadPPM(interp, chan, fileName, formatString, imageHandle, destX, destY,
- width, height, srcX, srcY)
- Tcl_Interp *interp; /* Interpreter to use for reporting errors. */
- Tcl_Channel chan; /* The image file, open for reading. */
- char *fileName; /* The name of the image file. */
- char *formatString; /* User-specified format string, or NULL. */
- Tk_PhotoHandle imageHandle; /* The photo image to write into. */
- int destX, destY; /* Coordinates of top-left pixel in
- * photo image to be written to. */
- int width, height; /* Dimensions of block of photo image to
- * be written to. */
- int srcX, srcY; /* Coordinates of top-left pixel to be used
- * in image being read. */
-{
- int fileWidth, fileHeight, maxIntensity;
- int nLines, nBytes, h, type, count;
- unsigned char *pixelPtr;
- Tk_PhotoImageBlock block;
-
- type = ReadPPMFileHeader(chan, &fileWidth, &fileHeight, &maxIntensity);
- if (type == 0) {
- Tcl_AppendResult(interp, "couldn't read raw PPM header from file \"",
- fileName, "\"", NULL);
- return TCL_ERROR;
- }
- if ((fileWidth <= 0) || (fileHeight <= 0)) {
- Tcl_AppendResult(interp, "PPM image file \"", fileName,
- "\" has dimension(s) <= 0", (char *) NULL);
- return TCL_ERROR;
- }
- if ((maxIntensity <= 0) || (maxIntensity >= 256)) {
- char buffer[30];
-
- sprintf(buffer, "%d", maxIntensity);
- Tcl_AppendResult(interp, "PPM image file \"", fileName,
- "\" has bad maximum intensity value ", buffer,
- (char *) NULL);
- return TCL_ERROR;
- }
-
- if ((srcX + width) > fileWidth) {
- width = fileWidth - srcX;
- }
- if ((srcY + height) > fileHeight) {
- height = fileHeight - srcY;
- }
- if ((width <= 0) || (height <= 0)
- || (srcX >= fileWidth) || (srcY >= fileHeight)) {
- return TCL_OK;
- }
-
- if (type == PGM) {
- block.pixelSize = 1;
- block.offset[0] = 0;
- block.offset[1] = 0;
- block.offset[2] = 0;
- }
- else {
- block.pixelSize = 3;
- block.offset[0] = 0;
- block.offset[1] = 1;
- block.offset[2] = 2;
- }
- block.width = width;
- block.pitch = block.pixelSize * fileWidth;
-
- Tk_PhotoExpand(imageHandle, destX + width, destY + height);
-
- if (srcY > 0) {
- Tcl_Seek(chan, (srcY * block.pitch), SEEK_CUR);
- }
-
- nLines = (MAX_MEMORY + block.pitch - 1) / block.pitch;
- if (nLines > height) {
- nLines = height;
- }
- if (nLines <= 0) {
- nLines = 1;
- }
- nBytes = nLines * block.pitch;
- pixelPtr = (unsigned char *) ckalloc((unsigned) nBytes);
- block.pixelPtr = pixelPtr + srcX * block.pixelSize;
-
- for (h = height; h > 0; h -= nLines) {
- if (nLines > h) {
- nLines = h;
- nBytes = nLines * block.pitch;
- }
- count = Tcl_Read(chan, (char *) pixelPtr, nBytes);
- if (count != nBytes) {
- Tcl_AppendResult(interp, "error reading PPM image file \"",
- fileName, "\": ",
- Tcl_Eof(chan) ? "not enough data" : Tcl_PosixError(interp),
- (char *) NULL);
- ckfree((char *) pixelPtr);
- return TCL_ERROR;
- }
- if (maxIntensity != 255) {
- unsigned char *p;
-
- for (p = pixelPtr; count > 0; count--, p++) {
- *p = (((int) *p) * 255)/maxIntensity;
- }
- }
- block.height = nLines;
- Tk_PhotoPutBlock(imageHandle, &block, destX, destY, width, nLines);
- destY += nLines;
- }
-
- ckfree((char *) pixelPtr);
- return TCL_OK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * FileWritePPM --
- *
- * This procedure is invoked to write image data to a file in PPM
- * format.
- *
- * Results:
- * A standard TCL completion code. If TCL_ERROR is returned
- * then an error message is left in interp->result.
- *
- * Side effects:
- * Data is written to the file given by "fileName".
- *
- *----------------------------------------------------------------------
- */
-
-static int
-FileWritePPM(interp, fileName, formatString, blockPtr)
- Tcl_Interp *interp;
- char *fileName;
- char *formatString;
- Tk_PhotoImageBlock *blockPtr;
-{
- Tcl_Channel chan;
- int w, h;
- int greenOffset, blueOffset, nBytes;
- unsigned char *pixelPtr, *pixLinePtr;
- char header[30];
-
- chan = Tcl_OpenFileChannel(interp, fileName, "w", 0666);
- if (chan == NULL) {
- return TCL_ERROR;
- }
-
- sprintf(header, "P6\n%d %d\n255\n", blockPtr->width, blockPtr->height);
- Tcl_Write(chan, header, -1);
-
- pixLinePtr = blockPtr->pixelPtr + blockPtr->offset[0];
- greenOffset = blockPtr->offset[1] - blockPtr->offset[0];
- blueOffset = blockPtr->offset[2] - blockPtr->offset[0];
-
- if ((greenOffset == 1) && (blueOffset == 2) && (blockPtr->pixelSize == 3)
- && (blockPtr->pitch == (blockPtr->width * 3))) {
- nBytes = blockPtr->height * blockPtr->pitch;
- if (Tcl_Write(chan, (char *) pixLinePtr, nBytes) != nBytes) {
- goto writeerror;
- }
- } else {
- for (h = blockPtr->height; h > 0; h--) {
- pixelPtr = pixLinePtr;
- for (w = blockPtr->width; w > 0; w--) {
- if ((Tcl_Write(chan, (char *) &pixelPtr[0], 1) == -1)
- || (Tcl_Write(chan, (char *) &pixelPtr[greenOffset], 1) == -1)
- || (Tcl_Write(chan, (char *) &pixelPtr[blueOffset], 1) == -1)) {
- goto writeerror;
- }
- pixelPtr += blockPtr->pixelSize;
- }
- pixLinePtr += blockPtr->pitch;
- }
- }
-
- if (Tcl_Close(NULL, chan) == 0) {
- return TCL_OK;
- }
- chan = NULL;
-
- writeerror:
- Tcl_AppendResult(interp, "error writing \"", fileName, "\": ",
- Tcl_PosixError(interp), (char *) NULL);
- if (chan != NULL) {
- Tcl_Close(NULL, chan);
- }
- return TCL_ERROR;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ReadPPMFileHeader --
- *
- * This procedure reads the PPM header from the beginning of a
- * PPM file and returns information from the header.
- *
- * Results:
- * The return value is PGM if file "f" appears to start with
- * a valid PGM header, PPM if "f" appears to start with a valid
- * PPM header, and 0 otherwise. If the header is valid,
- * then *widthPtr and *heightPtr are modified to hold the
- * dimensions of the image and *maxIntensityPtr is modified to
- * hold the value of a "fully on" intensity value.
- *
- * Side effects:
- * The access position in f advances.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-ReadPPMFileHeader(chan, widthPtr, heightPtr, maxIntensityPtr)
- Tcl_Channel chan; /* Image file to read the header from */
- int *widthPtr, *heightPtr; /* The dimensions of the image are
- * returned here. */
- int *maxIntensityPtr; /* The maximum intensity value for
- * the image is stored here. */
-{
-#define BUFFER_SIZE 1000
- char buffer[BUFFER_SIZE];
- int i, numFields, firstInLine;
- int type = 0;
- char c;
-
- /*
- * Read 4 space-separated fields from the file, ignoring
- * comments (any line that starts with "#").
- */
-
- if (Tcl_Read(chan, &c, 1) != 1) {
- return 0;
- }
- firstInLine = 1;
- i = 0;
- for (numFields = 0; numFields < 4; numFields++) {
- /*
- * Skip comments and white space.
- */
-
- while (1) {
- while (isspace(UCHAR(c))) {
- firstInLine = (c == '\n');
- if (Tcl_Read(chan, &c, 1) != 1) {
- return 0;
- }
- }
- if (c != '#') {
- break;
- }
- do {
- if (Tcl_Read(chan, &c, 1) != 1) {
- return 0;
- }
- } while (c != '\n');
- firstInLine = 1;
- }
-
- /*
- * Read a field (everything up to the next white space).
- */
-
- while (!isspace(UCHAR(c))) {
- if (i < (BUFFER_SIZE-2)) {
- buffer[i] = c;
- i++;
- }
- if (Tcl_Read(chan, &c, 1) != 1) {
- goto done;
- }
- }
- if (i < (BUFFER_SIZE-1)) {
- buffer[i] = ' ';
- i++;
- }
- firstInLine = 0;
- }
- done:
- buffer[i] = 0;
-
- /*
- * Parse the fields, which are: id, width, height, maxIntensity.
- */
-
- if (strncmp(buffer, "P6 ", 3) == 0) {
- type = PPM;
- } else if (strncmp(buffer, "P5 ", 3) == 0) {
- type = PGM;
- } else {
- return 0;
- }
- if (sscanf(buffer+3, "%d %d %d", widthPtr, heightPtr, maxIntensityPtr)
- != 3) {
- return 0;
- }
- return type;
-}
diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c
deleted file mode 100644
index 1f3aaea..0000000
--- a/generic/tkImgPhoto.c
+++ /dev/null
@@ -1,4144 +0,0 @@
-/*
- * tkImgPhoto.c --
- *
- * Implements images of type "photo" for Tk. Photo images are
- * stored in full color (24 bits per pixel) and displayed using
- * dithering if necessary.
- *
- * Copyright (c) 1994 The Australian National University.
- * 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.
- *
- * Author: Paul Mackerras (paulus@cs.anu.edu.au),
- * Department of Computer Science,
- * Australian National University.
- *
- * RCS: @(#) $Id: tkImgPhoto.c,v 1.2 1998/09/14 18:23:13 stanton Exp $
- */
-
-#include "tkInt.h"
-#include "tkPort.h"
-#include "tclMath.h"
-#include <ctype.h>
-
-/*
- * Declaration for internal Xlib function used here:
- */
-
-extern _XInitImageFuncPtrs _ANSI_ARGS_((XImage *image));
-
-/*
- * A signed 8-bit integral type. If chars are unsigned and the compiler
- * isn't an ANSI one, then we have to use short instead (which wastes
- * space) to get signed behavior.
- */
-
-#if defined(__STDC__) || defined(_AIX)
- typedef signed char schar;
-#else
-# ifndef __CHAR_UNSIGNED__
- typedef char schar;
-# else
- typedef short schar;
-# endif
-#endif
-
-/*
- * An unsigned 32-bit integral type, used for pixel values.
- * We use int rather than long here to accommodate those systems
- * where longs are 64 bits.
- */
-
-typedef unsigned int pixel;
-
-/*
- * The maximum number of pixels to transmit to the server in a
- * single XPutImage call.
- */
-
-#define MAX_PIXELS 65536
-
-/*
- * The set of colors required to display a photo image in a window depends on:
- * - the visual used by the window
- * - the palette, which specifies how many levels of each primary
- * color to use, and
- * - the gamma value for the image.
- *
- * Pixel values allocated for specific colors are valid only for the
- * colormap in which they were allocated. Sets of pixel values
- * allocated for displaying photos are re-used in other windows if
- * possible, that is, if the display, colormap, palette and gamma
- * values match. A hash table is used to locate these sets of pixel
- * values, using the following data structure as key:
- */
-
-typedef struct {
- Display *display; /* Qualifies the colormap resource ID */
- Colormap colormap; /* Colormap that the windows are using. */
- double gamma; /* Gamma exponent value for images. */
- Tk_Uid palette; /* Specifies how many shades of each primary
- * we want to allocate. */
-} ColorTableId;
-
-/*
- * For a particular (display, colormap, palette, gamma) combination,
- * a data structure of the following type is used to store the allocated
- * pixel values and other information:
- */
-
-typedef struct ColorTable {
- ColorTableId id; /* Information used in selecting this
- * color table. */
- int flags; /* See below. */
- int refCount; /* Number of instances using this map. */
- int liveRefCount; /* Number of instances which are actually
- * in use, using this map. */
- int numColors; /* Number of colors allocated for this map. */
-
- XVisualInfo visualInfo; /* Information about the visual for windows
- * using this color table. */
-
- pixel redValues[256]; /* Maps 8-bit values of red intensity
- * to a pixel value or index in pixelMap. */
- pixel greenValues[256]; /* Ditto for green intensity */
- pixel blueValues[256]; /* Ditto for blue intensity */
- unsigned long *pixelMap; /* Actual pixel values allocated. */
-
- unsigned char colorQuant[3][256];
- /* Maps 8-bit intensities to quantized
- * intensities. The first index is 0 for
- * red, 1 for green, 2 for blue. */
-} ColorTable;
-
-/*
- * Bit definitions for the flags field of a ColorTable.
- * BLACK_AND_WHITE: 1 means only black and white colors are
- * available.
- * COLOR_WINDOW: 1 means a full 3-D color cube has been
- * allocated.
- * DISPOSE_PENDING: 1 means a call to DisposeColorTable has
- * been scheduled as an idle handler, but it
- * hasn't been invoked yet.
- * MAP_COLORS: 1 means pixel values should be mapped
- * through pixelMap.
- */
-
-#define BLACK_AND_WHITE 1
-#define COLOR_WINDOW 2
-#define DISPOSE_PENDING 4
-#define MAP_COLORS 8
-
-/*
- * Definition of the data associated with each photo image master.
- */
-
-typedef struct PhotoMaster {
- Tk_ImageMaster tkMaster; /* Tk's token for image master. NULL means
- * the image is being deleted. */
- Tcl_Interp *interp; /* Interpreter associated with the
- * application using this image. */
- Tcl_Command imageCmd; /* Token for image command (used to delete
- * it when the image goes away). NULL means
- * the image command has already been
- * deleted. */
- int flags; /* Sundry flags, defined below. */
- int width, height; /* Dimensions of image. */
- int userWidth, userHeight; /* User-declared image dimensions. */
- Tk_Uid palette; /* User-specified default palette for
- * instances of this image. */
- double gamma; /* Display gamma value to correct for. */
- char *fileString; /* Name of file to read into image. */
- char *dataString; /* String value to use as contents of image. */
- char *format; /* User-specified format of data in image
- * file or string value. */
- unsigned char *pix24; /* Local storage for 24-bit image. */
- int ditherX, ditherY; /* Location of first incorrectly
- * dithered pixel in image. */
- TkRegion validRegion; /* Tk region indicating which parts of
- * the image have valid image data. */
- struct PhotoInstance *instancePtr;
- /* First in the list of instances
- * associated with this master. */
-} PhotoMaster;
-
-/*
- * Bit definitions for the flags field of a PhotoMaster.
- * COLOR_IMAGE: 1 means that the image has different color
- * components.
- * IMAGE_CHANGED: 1 means that the instances of this image
- * need to be redithered.
- */
-
-#define COLOR_IMAGE 1
-#define IMAGE_CHANGED 2
-
-/*
- * The following data structure represents all of the instances of
- * a photo image in windows on a given screen that are using the
- * same colormap.
- */
-
-typedef struct PhotoInstance {
- PhotoMaster *masterPtr; /* Pointer to master for image. */
- Display *display; /* Display for windows using this instance. */
- Colormap colormap; /* The image may only be used in windows with
- * this particular colormap. */
- struct PhotoInstance *nextPtr;
- /* Pointer to the next instance in the list
- * of instances associated with this master. */
- int refCount; /* Number of instances using this structure. */
- Tk_Uid palette; /* Palette for these particular instances. */
- double gamma; /* Gamma value for these instances. */
- Tk_Uid defaultPalette; /* Default palette to use if a palette
- * is not specified for the master. */
- ColorTable *colorTablePtr; /* Pointer to information about colors
- * allocated for image display in windows
- * like this one. */
- Pixmap pixels; /* X pixmap containing dithered image. */
- int width, height; /* Dimensions of the pixmap. */
- schar *error; /* Error image, used in dithering. */
- XImage *imagePtr; /* Image structure for converted pixels. */
- XVisualInfo visualInfo; /* Information about the visual that these
- * windows are using. */
- GC gc; /* Graphics context for writing images
- * to the pixmap. */
-} PhotoInstance;
-
-/*
- * The following data structure is used to return information
- * from ParseSubcommandOptions:
- */
-
-struct SubcommandOptions {
- int options; /* Individual bits indicate which
- * options were specified - see below. */
- char *name; /* Name specified without an option. */
- int fromX, fromY; /* Values specified for -from option. */
- int fromX2, fromY2; /* Second coordinate pair for -from option. */
- int toX, toY; /* Values specified for -to option. */
- int toX2, toY2; /* Second coordinate pair for -to option. */
- int zoomX, zoomY; /* Values specified for -zoom option. */
- int subsampleX, subsampleY; /* Values specified for -subsample option. */
- char *format; /* Value specified for -format option. */
-};
-
-/*
- * Bit definitions for use with ParseSubcommandOptions:
- * Each bit is set in the allowedOptions parameter on a call to
- * ParseSubcommandOptions if that option is allowed for the current
- * photo image subcommand. On return, the bit is set in the options
- * field of the SubcommandOptions structure if that option was specified.
- *
- * OPT_FORMAT: Set if -format option allowed/specified.
- * OPT_FROM: Set if -from option allowed/specified.
- * OPT_SHRINK: Set if -shrink option allowed/specified.
- * OPT_SUBSAMPLE: Set if -subsample option allowed/spec'd.
- * OPT_TO: Set if -to option allowed/specified.
- * OPT_ZOOM: Set if -zoom option allowed/specified.
- */
-
-#define OPT_FORMAT 1
-#define OPT_FROM 2
-#define OPT_SHRINK 4
-#define OPT_SUBSAMPLE 8
-#define OPT_TO 0x10
-#define OPT_ZOOM 0x20
-
-/*
- * List of option names. The order here must match the order of
- * declarations of the OPT_* constants above.
- */
-
-static char *optionNames[] = {
- "-format",
- "-from",
- "-shrink",
- "-subsample",
- "-to",
- "-zoom",
- (char *) NULL
-};
-
-/*
- * The type record for photo images:
- */
-
-static int ImgPhotoCreate _ANSI_ARGS_((Tcl_Interp *interp,
- char *name, int argc, char **argv,
- Tk_ImageType *typePtr, Tk_ImageMaster master,
- ClientData *clientDataPtr));
-static ClientData ImgPhotoGet _ANSI_ARGS_((Tk_Window tkwin,
- ClientData clientData));
-static void ImgPhotoDisplay _ANSI_ARGS_((ClientData clientData,
- Display *display, Drawable drawable,
- int imageX, int imageY, int width, int height,
- int drawableX, int drawableY));
-static void ImgPhotoFree _ANSI_ARGS_((ClientData clientData,
- Display *display));
-static void ImgPhotoDelete _ANSI_ARGS_((ClientData clientData));
-
-Tk_ImageType tkPhotoImageType = {
- "photo", /* name */
- ImgPhotoCreate, /* createProc */
- ImgPhotoGet, /* getProc */
- ImgPhotoDisplay, /* displayProc */
- ImgPhotoFree, /* freeProc */
- ImgPhotoDelete, /* deleteProc */
- (Tk_ImageType *) NULL /* nextPtr */
-};
-
-/*
- * Default configuration
- */
-
-#define DEF_PHOTO_GAMMA "1"
-#define DEF_PHOTO_HEIGHT "0"
-#define DEF_PHOTO_PALETTE ""
-#define DEF_PHOTO_WIDTH "0"
-
-/*
- * Information used for parsing configuration specifications:
- */
-static Tk_ConfigSpec configSpecs[] = {
- {TK_CONFIG_STRING, "-data", (char *) NULL, (char *) NULL,
- (char *) NULL, Tk_Offset(PhotoMaster, dataString), TK_CONFIG_NULL_OK},
- {TK_CONFIG_STRING, "-format", (char *) NULL, (char *) NULL,
- (char *) NULL, Tk_Offset(PhotoMaster, format), TK_CONFIG_NULL_OK},
- {TK_CONFIG_STRING, "-file", (char *) NULL, (char *) NULL,
- (char *) NULL, Tk_Offset(PhotoMaster, fileString), TK_CONFIG_NULL_OK},
- {TK_CONFIG_DOUBLE, "-gamma", (char *) NULL, (char *) NULL,
- DEF_PHOTO_GAMMA, Tk_Offset(PhotoMaster, gamma), 0},
- {TK_CONFIG_INT, "-height", (char *) NULL, (char *) NULL,
- DEF_PHOTO_HEIGHT, Tk_Offset(PhotoMaster, userHeight), 0},
- {TK_CONFIG_UID, "-palette", (char *) NULL, (char *) NULL,
- DEF_PHOTO_PALETTE, Tk_Offset(PhotoMaster, palette), 0},
- {TK_CONFIG_INT, "-width", (char *) NULL, (char *) NULL,
- DEF_PHOTO_WIDTH, Tk_Offset(PhotoMaster, userWidth), 0},
- {TK_CONFIG_END, (char *) NULL, (char *) NULL, (char *) NULL,
- (char *) NULL, 0, 0}
-};
-
-/*
- * Hash table used to hash from (display, colormap, palette, gamma)
- * to ColorTable address.
- */
-
-static Tcl_HashTable imgPhotoColorHash;
-static int imgPhotoColorHashInitialized;
-#define N_COLOR_HASH (sizeof(ColorTableId) / sizeof(int))
-
-/*
- * Pointer to the first in the list of known photo image formats.
- */
-
-static Tk_PhotoImageFormat *formatList = NULL;
-
-/*
- * Forward declarations
- */
-
-static int ImgPhotoCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-static int ParseSubcommandOptions _ANSI_ARGS_((
- struct SubcommandOptions *optPtr,
- Tcl_Interp *interp, int allowedOptions,
- int *indexPtr, int argc, char **argv));
-static void ImgPhotoCmdDeletedProc _ANSI_ARGS_((
- ClientData clientData));
-static int ImgPhotoConfigureMaster _ANSI_ARGS_((
- Tcl_Interp *interp, PhotoMaster *masterPtr,
- int argc, char **argv, int flags));
-static void ImgPhotoConfigureInstance _ANSI_ARGS_((
- PhotoInstance *instancePtr));
-static void ImgPhotoSetSize _ANSI_ARGS_((PhotoMaster *masterPtr,
- int width, int height));
-static void ImgPhotoInstanceSetSize _ANSI_ARGS_((
- PhotoInstance *instancePtr));
-static int IsValidPalette _ANSI_ARGS_((PhotoInstance *instancePtr,
- char *palette));
-static int CountBits _ANSI_ARGS_((pixel mask));
-static void GetColorTable _ANSI_ARGS_((PhotoInstance *instancePtr));
-static void FreeColorTable _ANSI_ARGS_((ColorTable *colorPtr));
-static void AllocateColors _ANSI_ARGS_((ColorTable *colorPtr));
-static void DisposeColorTable _ANSI_ARGS_((ClientData clientData));
-static void DisposeInstance _ANSI_ARGS_((ClientData clientData));
-static int ReclaimColors _ANSI_ARGS_((ColorTableId *id,
- int numColors));
-static int MatchFileFormat _ANSI_ARGS_((Tcl_Interp *interp,
- Tcl_Channel chan, char *fileName,
- char *formatString,
- Tk_PhotoImageFormat **imageFormatPtr,
- int *widthPtr, int *heightPtr));
-static int MatchStringFormat _ANSI_ARGS_((Tcl_Interp *interp,
- char *string, char *formatString,
- Tk_PhotoImageFormat **imageFormatPtr,
- int *widthPtr, int *heightPtr));
-static void Dither _ANSI_ARGS_((PhotoMaster *masterPtr,
- int x, int y, int width, int height));
-static void DitherInstance _ANSI_ARGS_((PhotoInstance *instancePtr,
- int x, int y, int width, int height));
-
-#undef MIN
-#define MIN(a, b) ((a) < (b)? (a): (b))
-#undef MAX
-#define MAX(a, b) ((a) > (b)? (a): (b))
-
-/*
- *----------------------------------------------------------------------
- *
- * 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.
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tk_CreatePhotoImageFormat(formatPtr)
- Tk_PhotoImageFormat *formatPtr;
- /* Structure describing the format. All of
- * the fields except "nextPtr" must be filled
- * in by caller. Must not have been passed
- * to Tk_CreatePhotoImageFormat previously. */
-{
- Tk_PhotoImageFormat *copyPtr;
-
- copyPtr = (Tk_PhotoImageFormat *) ckalloc(sizeof(Tk_PhotoImageFormat));
- *copyPtr = *formatPtr;
- copyPtr->name = (char *) ckalloc((unsigned) (strlen(formatPtr->name) + 1));
- strcpy(copyPtr->name, formatPtr->name);
- copyPtr->nextPtr = formatList;
- formatList = copyPtr;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ImgPhotoCreate --
- *
- * This procedure is called by the Tk image code to create
- * a new photo image.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * The data structure for a new photo image is allocated and
- * initialized.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-ImgPhotoCreate(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. */
- 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
- * later callbacks. */
- ClientData *clientDataPtr; /* Store manager's token for image here;
- * it will be returned in later callbacks. */
-{
- PhotoMaster *masterPtr;
-
- /*
- * Allocate and initialize the photo image master record.
- */
-
- masterPtr = (PhotoMaster *) ckalloc(sizeof(PhotoMaster));
- memset((void *) masterPtr, 0, sizeof(PhotoMaster));
- masterPtr->tkMaster = master;
- masterPtr->interp = interp;
- masterPtr->imageCmd = Tcl_CreateCommand(interp, name, ImgPhotoCmd,
- (ClientData) masterPtr, ImgPhotoCmdDeletedProc);
- masterPtr->palette = NULL;
- masterPtr->pix24 = NULL;
- masterPtr->instancePtr = NULL;
- masterPtr->validRegion = TkCreateRegion();
-
- /*
- * Process configuration options given in the image create command.
- */
-
- if (ImgPhotoConfigureMaster(interp, masterPtr, argc, argv, 0) != TCL_OK) {
- ImgPhotoDelete((ClientData) masterPtr);
- return TCL_ERROR;
- }
-
- *clientDataPtr = (ClientData) masterPtr;
- return TCL_OK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ImgPhotoCmd --
- *
- * This procedure is invoked to process the Tcl command that
- * corresponds to a photo image. See the user documentation
- * for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-ImgPhotoCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Information about photo master. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- PhotoMaster *masterPtr = (PhotoMaster *) clientData;
- int c, result, index;
- int x, y, width, height;
- int dataWidth, dataHeight;
- struct SubcommandOptions options;
- int listArgc;
- char **listArgv;
- char **srcArgv;
- unsigned char *pixelPtr;
- Tk_PhotoImageBlock block;
- Tk_Window tkwin;
- char string[16];
- XColor color;
- Tk_PhotoImageFormat *imageFormat;
- int imageWidth, imageHeight;
- int matched;
- Tcl_Channel chan;
- Tk_PhotoHandle srcHandle;
- size_t length;
-
- if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
- " option ?arg arg ...?\"", (char *) NULL);
- return TCL_ERROR;
- }
- c = argv[1][0];
- length = strlen(argv[1]);
-
- if ((c == 'b') && (strncmp(argv[1], "blank", length) == 0)) {
- /*
- * photo blank command - just call Tk_PhotoBlank.
- */
-
- if (argc == 2) {
- Tk_PhotoBlank(masterPtr);
- } else {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " blank\"", (char *) NULL);
- return TCL_ERROR;
- }
- } else if ((c == 'c') && (length >= 2)
- && (strncmp(argv[1], "cget", length) == 0)) {
- if (argc != 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " cget option\"",
- (char *) NULL);
- return TCL_ERROR;
- }
- Tk_ConfigureValue(interp, Tk_MainWindow(interp), configSpecs,
- (char *) masterPtr, argv[2], 0);
- } else if ((c == 'c') && (length >= 3)
- && (strncmp(argv[1], "configure", length) == 0)) {
- /*
- * photo configure command - handle this in the standard way.
- */
-
- if (argc == 2) {
- return Tk_ConfigureInfo(interp, Tk_MainWindow(interp),
- configSpecs, (char *) masterPtr, (char *) NULL, 0);
- }
- if (argc == 3) {
- return Tk_ConfigureInfo(interp, Tk_MainWindow(interp),
- configSpecs, (char *) masterPtr, argv[2], 0);
- }
- return ImgPhotoConfigureMaster(interp, masterPtr, argc-2, argv+2,
- TK_CONFIG_ARGV_ONLY);
- } else if ((c == 'c') && (length >= 3)
- && (strncmp(argv[1], "copy", length) == 0)) {
- /*
- * photo copy command - first parse options.
- */
-
- index = 2;
- memset((VOID *) &options, 0, sizeof(options));
- options.zoomX = options.zoomY = 1;
- options.subsampleX = options.subsampleY = 1;
- options.name = NULL;
- if (ParseSubcommandOptions(&options, interp,
- OPT_FROM | OPT_TO | OPT_ZOOM | OPT_SUBSAMPLE | OPT_SHRINK,
- &index, argc, argv) != TCL_OK) {
- return TCL_ERROR;
- }
- if (options.name == NULL || index < argc) {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
- " copy source-image ?-from x1 y1 x2 y2?",
- " ?-to x1 y1 x2 y2? ?-zoom x y? ?-subsample x y?",
- "\"", (char *) NULL);
- return TCL_ERROR;
- }
-
- /*
- * Look for the source image and get a pointer to its image data.
- * Check the values given for the -from option.
- */
-
- if ((srcHandle = Tk_FindPhoto(interp, options.name)) == NULL) {
- Tcl_AppendResult(interp, "image \"", argv[2], "\" doesn't",
- " exist or is not a photo image", (char *) NULL);
- return TCL_ERROR;
- }
- Tk_PhotoGetImage(srcHandle, &block);
- if ((options.fromX2 > block.width) || (options.fromY2 > block.height)
- || (options.fromX2 > block.width)
- || (options.fromY2 > block.height)) {
- Tcl_AppendResult(interp, "coordinates for -from option extend ",
- "outside source image", (char *) NULL);
- return TCL_ERROR;
- }
-
- /*
- * Fill in default values for unspecified parameters.
- */
-
- if (((options.options & OPT_FROM) == 0) || (options.fromX2 < 0)) {
- options.fromX2 = block.width;
- options.fromY2 = block.height;
- }
- if (((options.options & OPT_TO) == 0) || (options.toX2 < 0)) {
- width = options.fromX2 - options.fromX;
- if (options.subsampleX > 0) {
- width = (width + options.subsampleX - 1) / options.subsampleX;
- } else if (options.subsampleX == 0) {
- width = 0;
- } else {
- width = (width - options.subsampleX - 1) / -options.subsampleX;
- }
- options.toX2 = options.toX + width * options.zoomX;
-
- height = options.fromY2 - options.fromY;
- if (options.subsampleY > 0) {
- height = (height + options.subsampleY - 1)
- / options.subsampleY;
- } else if (options.subsampleY == 0) {
- height = 0;
- } else {
- height = (height - options.subsampleY - 1)
- / -options.subsampleY;
- }
- options.toY2 = options.toY + height * options.zoomY;
- }
-
- /*
- * Set the destination image size if the -shrink option was specified.
- */
-
- if (options.options & OPT_SHRINK) {
- ImgPhotoSetSize(masterPtr, options.toX2, options.toY2);
- }
-
- /*
- * Copy the image data over using Tk_PhotoPutZoomedBlock.
- */
-
- block.pixelPtr += options.fromX * block.pixelSize
- + 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);
-
- } else if ((c == 'g') && (strncmp(argv[1], "get", length) == 0)) {
- /*
- * photo get command - first parse and check parameters.
- */
-
- if (argc != 4) {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
- " get x y\"", (char *) NULL);
- return TCL_ERROR;
- }
- if ((Tcl_GetInt(interp, argv[2], &x) != TCL_OK)
- || (Tcl_GetInt(interp, argv[3], &y) != TCL_OK)) {
- return TCL_ERROR;
- }
- if ((x < 0) || (x >= masterPtr->width)
- || (y < 0) || (y >= masterPtr->height)) {
- Tcl_AppendResult(interp, argv[0], " get: ",
- "coordinates out of range", (char *) NULL);
- return TCL_ERROR;
- }
-
- /*
- * Extract the value of the desired pixel and format it as a string.
- */
-
- pixelPtr = masterPtr->pix24 + (y * masterPtr->width + x) * 3;
- sprintf(string, "%d %d %d", pixelPtr[0], pixelPtr[1],
- pixelPtr[2]);
- Tcl_AppendResult(interp, string, (char *) NULL);
- } else if ((c == 'p') && (strncmp(argv[1], "put", length) == 0)) {
- /*
- * photo put command - first parse the options and colors specified.
- */
-
- index = 2;
- memset((VOID *) &options, 0, sizeof(options));
- options.name = NULL;
- if (ParseSubcommandOptions(&options, interp, OPT_TO,
- &index, argc, argv) != TCL_OK) {
- return TCL_ERROR;
- }
- if ((options.name == NULL) || (index < argc)) {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
- " put {{colors...}...} ?-to x1 y1 x2 y2?\"",
- (char *) NULL);
- return TCL_ERROR;
- }
- if (Tcl_SplitList(interp, options.name, &dataHeight, &srcArgv)
- != TCL_OK) {
- return TCL_ERROR;
- }
- tkwin = Tk_MainWindow(interp);
- block.pixelPtr = NULL;
- dataWidth = 0;
- pixelPtr = NULL;
- for (y = 0; y < dataHeight; ++y) {
- if (Tcl_SplitList(interp, srcArgv[y], &listArgc, &listArgv)
- != TCL_OK) {
- break;
- }
- if (y == 0) {
- dataWidth = listArgc;
- 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;
- }
- }
- for (x = 0; x < dataWidth; ++x) {
- if (!XParseColor(Tk_Display(tkwin), Tk_Colormap(tkwin),
- listArgv[x], &color)) {
- Tcl_AppendResult(interp, "can't parse color \"",
- listArgv[x], "\"", (char *) NULL);
- break;
- }
- *pixelPtr++ = color.red >> 8;
- *pixelPtr++ = color.green >> 8;
- *pixelPtr++ = color.blue >> 8;
- }
- ckfree((char *) listArgv);
- if (x < dataWidth)
- break;
- }
- ckfree((char *) srcArgv);
- if (y < dataHeight || dataHeight == 0 || dataWidth == 0) {
- if (block.pixelPtr != NULL) {
- ckfree((char *) block.pixelPtr);
- }
- if (y < dataHeight) {
- return TCL_ERROR;
- }
- return TCL_OK;
- }
-
- /*
- * Fill in default values for the -to option, then
- * copy the block in using Tk_PhotoPutBlock.
- */
-
- if (((options.options & OPT_TO) == 0) || (options.toX2 < 0)) {
- options.toX2 = options.toX + dataWidth;
- options.toY2 = options.toY + dataHeight;
- }
- block.width = dataWidth;
- block.height = dataHeight;
- block.pitch = dataWidth * 3;
- block.pixelSize = 3;
- block.offset[0] = 0;
- block.offset[1] = 1;
- block.offset[2] = 2;
- Tk_PhotoPutBlock((ClientData)masterPtr, &block,
- options.toX, options.toY, options.toX2 - options.toX,
- options.toY2 - options.toY);
- ckfree((char *) block.pixelPtr);
- } else if ((c == 'r') && (length >= 3)
- && (strncmp(argv[1], "read", length) == 0)) {
- /*
- * photo read command - first parse the options specified.
- */
-
- index = 2;
- memset((VOID *) &options, 0, sizeof(options));
- options.name = NULL;
- options.format = NULL;
- if (ParseSubcommandOptions(&options, interp,
- OPT_FORMAT | OPT_FROM | OPT_TO | OPT_SHRINK,
- &index, argc, argv) != TCL_OK) {
- return TCL_ERROR;
- }
- if ((options.name == NULL) || (index < argc)) {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
- " read fileName ?-format format-name?",
- " ?-from x1 y1 x2 y2? ?-to x y? ?-shrink?\"",
- (char *) NULL);
- return TCL_ERROR;
- }
-
- /*
- * Prevent file system access in safe interpreters.
- */
-
- if (Tcl_IsSafe(interp)) {
- Tcl_AppendResult(interp, "can't get image from a file in a",
- " safe interpreter", (char *) NULL);
- return TCL_ERROR;
- }
-
- /*
- * Open the image file and look for a handler for it.
- */
-
- chan = Tcl_OpenFileChannel(interp, options.name, "r", 0);
- if (chan == NULL) {
- return TCL_ERROR;
- }
- if (Tcl_SetChannelOption(interp, chan, "-translation", "binary")
- != TCL_OK) {
- return TCL_ERROR;
- }
- if (MatchFileFormat(interp, chan, options.name, options.format,
- &imageFormat, &imageWidth, &imageHeight) != TCL_OK) {
- Tcl_Close(NULL, chan);
- return TCL_ERROR;
- }
-
- /*
- * Check the values given for the -from option.
- */
-
- if ((options.fromX > imageWidth) || (options.fromY > imageHeight)
- || (options.fromX2 > imageWidth)
- || (options.fromY2 > imageHeight)) {
- Tcl_AppendResult(interp, "coordinates for -from option extend ",
- "outside source image", (char *) NULL);
- Tcl_Close(NULL, chan);
- return TCL_ERROR;
- }
- if (((options.options & OPT_FROM) == 0) || (options.fromX2 < 0)) {
- width = imageWidth - options.fromX;
- height = imageHeight - options.fromY;
- } else {
- width = options.fromX2 - options.fromX;
- height = options.fromY2 - options.fromY;
- }
-
- /*
- * If the -shrink option was specified, set the size of the image.
- */
-
- if (options.options & OPT_SHRINK) {
- ImgPhotoSetSize(masterPtr, options.toX + width,
- options.toY + height);
- }
-
- /*
- * Call the handler's file read procedure to read the data
- * into the image.
- */
-
- result = (*imageFormat->fileReadProc)(interp, chan, options.name,
- options.format, (Tk_PhotoHandle) masterPtr, options.toX,
- options.toY, width, height, options.fromX, options.fromY);
- if (chan != NULL) {
- Tcl_Close(NULL, chan);
- }
- return result;
- } else if ((c == 'r') && (length >= 3)
- && (strncmp(argv[1], "redither", length) == 0)) {
-
- if (argc == 2) {
- /*
- * Call Dither if any part of the image is not correctly
- * dithered at present.
- */
-
- x = masterPtr->ditherX;
- y = masterPtr->ditherY;
- if (masterPtr->ditherX != 0) {
- Dither(masterPtr, x, y, masterPtr->width - x, 1);
- }
- if (masterPtr->ditherY < masterPtr->height) {
- x = 0;
- Dither(masterPtr, 0, masterPtr->ditherY, masterPtr->width,
- masterPtr->height - masterPtr->ditherY);
- }
-
- if (y < masterPtr->height) {
- /*
- * Tell the core image code that part of the image has changed.
- */
-
- Tk_ImageChanged(masterPtr->tkMaster, x, y,
- (masterPtr->width - x), (masterPtr->height - y),
- masterPtr->width, masterPtr->height);
- }
-
- } else {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
- " redither\"", (char *) NULL);
- return TCL_ERROR;
- }
- } else if ((c == 'w') && (strncmp(argv[1], "write", length) == 0)) {
-
- /*
- * Prevent file system access in safe interpreters.
- */
-
- if (Tcl_IsSafe(interp)) {
- Tcl_AppendResult(interp, "can't write image to a file in a",
- " safe interpreter", (char *) NULL);
- return TCL_ERROR;
- }
-
- /*
- * photo write command - first parse and check any options given.
- */
-
- index = 2;
- memset((VOID *) &options, 0, sizeof(options));
- options.name = NULL;
- options.format = NULL;
- if (ParseSubcommandOptions(&options, interp, OPT_FORMAT | OPT_FROM,
- &index, argc, argv) != TCL_OK) {
- return TCL_ERROR;
- }
- if ((options.name == NULL) || (index < argc)) {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
- " write fileName ?-format format-name?",
- "?-from x1 y1 x2 y2?\"", (char *) NULL);
- return TCL_ERROR;
- }
- if ((options.fromX > masterPtr->width)
- || (options.fromY > masterPtr->height)
- || (options.fromX2 > masterPtr->width)
- || (options.fromY2 > masterPtr->height)) {
- Tcl_AppendResult(interp, "coordinates for -from option extend ",
- "outside image", (char *) NULL);
- return TCL_ERROR;
- }
-
- /*
- * Fill in default values for unspecified parameters.
- */
-
- if (((options.options & OPT_FROM) == 0) || (options.fromX2 < 0)) {
- options.fromX2 = masterPtr->width;
- options.fromY2 = masterPtr->height;
- }
-
- /*
- * Search for an appropriate image file format handler,
- * and give an error if none is found.
- */
-
- matched = 0;
- for (imageFormat = formatList; imageFormat != NULL;
- imageFormat = imageFormat->nextPtr) {
- if ((options.format == NULL)
- || (strncasecmp(options.format, imageFormat->name,
- strlen(imageFormat->name)) == 0)) {
- matched = 1;
- if (imageFormat->fileWriteProc != NULL) {
- break;
- }
- }
- }
- if (imageFormat == NULL) {
- if (options.format == NULL) {
- Tcl_AppendResult(interp, "no available image file format ",
- "has file writing capability", (char *) NULL);
- } else if (!matched) {
- Tcl_AppendResult(interp, "image file format \"",
- options.format, "\" is unknown", (char *) NULL);
- } else {
- Tcl_AppendResult(interp, "image file format \"",
- options.format, "\" has no file writing capability",
- (char *) NULL);
- }
- return TCL_ERROR;
- }
-
- /*
- * Call the handler's file write procedure to write out
- * the image.
- */
-
- Tk_PhotoGetImage((Tk_PhotoHandle) masterPtr, &block);
- block.pixelPtr += options.fromY * block.pitch + options.fromX * 3;
- block.width = options.fromX2 - options.fromX;
- block.height = options.fromY2 - options.fromY;
- return (*imageFormat->fileWriteProc)(interp, options.name,
- options.format, &block);
- } else {
- Tcl_AppendResult(interp, "bad option \"", argv[1],
- "\": must be blank, cget, configure, copy, get, put,",
- " read, redither, or write", (char *) NULL);
- return TCL_ERROR;
- }
-
- return TCL_OK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ParseSubcommandOptions --
- *
- * 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.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * Fields in *optPtr get filled in.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-ParseSubcommandOptions(optPtr, interp, allowedOptions, optIndexPtr, argc, argv)
- struct SubcommandOptions *optPtr;
- /* Information about the options specified
- * and the values given is returned here. */
- Tcl_Interp *interp; /* Interpreter to use for reporting errors. */
- int allowedOptions; /* Indicates which options are valid for
- * the current command. */
- int *optIndexPtr; /* Points to a variable containing the
- * current index in argv; this variable is
- * updated by this procedure. */
- int argc; /* Number of arguments in argv[]. */
- char **argv; /* Arguments to be parsed. */
-{
- int index, c, bit, currentBit;
- size_t length;
- char *option, **listPtr;
- int values[4];
- int numValues, maxValues, argIndex;
-
- for (index = *optIndexPtr; index < argc; *optIndexPtr = ++index) {
- /*
- * We can have one value specified without an option;
- * it goes into optPtr->name.
- */
-
- option = argv[index];
- if (option[0] != '-') {
- if (optPtr->name == NULL) {
- optPtr->name = option;
- continue;
- }
- break;
- }
-
- /*
- * Work out which option this is.
- */
-
- length = strlen(option);
- c = option[0];
- bit = 0;
- currentBit = 1;
- for (listPtr = optionNames; *listPtr != NULL; ++listPtr) {
- if ((c == *listPtr[0])
- && (strncmp(option, *listPtr, length) == 0)) {
- if (bit != 0) {
- bit = 0; /* An ambiguous option. */
- break;
- }
- bit = currentBit;
- }
- currentBit <<= 1;
- }
-
- /*
- * If this option is not recognized and allowed, put
- * an error message in the interpreter and return.
- */
-
- if ((allowedOptions & bit) == 0) {
- Tcl_AppendResult(interp, "unrecognized option \"", argv[index],
- "\": must be ", (char *)NULL);
- bit = 1;
- for (listPtr = optionNames; *listPtr != NULL; ++listPtr) {
- if ((allowedOptions & bit) != 0) {
- if ((allowedOptions & (bit - 1)) != 0) {
- Tcl_AppendResult(interp, ", ", (char *) NULL);
- if ((allowedOptions & ~((bit << 1) - 1)) == 0) {
- Tcl_AppendResult(interp, "or ", (char *) NULL);
- }
- }
- Tcl_AppendResult(interp, *listPtr, (char *) NULL);
- }
- bit <<= 1;
- }
- return TCL_ERROR;
- }
-
- /*
- * For the -from, -to, -zoom and -subsample options,
- * parse the values given. Report an error if too few
- * or too many values are given.
- */
-
- if ((bit != OPT_SHRINK) && (bit != OPT_FORMAT)) {
- maxValues = ((bit == OPT_FROM) || (bit == OPT_TO))? 4: 2;
- argIndex = index + 1;
- for (numValues = 0; numValues < maxValues; ++numValues) {
- if ((argIndex < argc) && (isdigit(UCHAR(argv[argIndex][0]))
- || ((argv[argIndex][0] == '-')
- && (isdigit(UCHAR(argv[argIndex][1])))))) {
- if (Tcl_GetInt(interp, argv[argIndex], &values[numValues])
- != TCL_OK) {
- return TCL_ERROR;
- }
- } else {
- break;
- }
- ++argIndex;
- }
-
- if (numValues == 0) {
- Tcl_AppendResult(interp, "the \"", argv[index], "\" option ",
- "requires one ", maxValues == 2? "or two": "to four",
- " integer values", (char *) NULL);
- return TCL_ERROR;
- }
- *optIndexPtr = (index += numValues);
-
- /*
- * Y values default to the corresponding X value if not specified.
- */
-
- if (numValues == 1) {
- values[1] = values[0];
- }
- if (numValues == 3) {
- values[3] = values[2];
- }
-
- /*
- * Check the values given and put them in the appropriate
- * field of the SubcommandOptions structure.
- */
-
- switch (bit) {
- case OPT_FROM:
- if ((values[0] < 0) || (values[1] < 0) || ((numValues > 2)
- && ((values[2] < 0) || (values[3] < 0)))) {
- Tcl_AppendResult(interp, "value(s) for the -from",
- " option must be non-negative", (char *) NULL);
- return TCL_ERROR;
- }
- if (numValues <= 2) {
- optPtr->fromX = values[0];
- optPtr->fromY = values[1];
- optPtr->fromX2 = -1;
- optPtr->fromY2 = -1;
- } else {
- optPtr->fromX = MIN(values[0], values[2]);
- optPtr->fromY = MIN(values[1], values[3]);
- optPtr->fromX2 = MAX(values[0], values[2]);
- optPtr->fromY2 = MAX(values[1], values[3]);
- }
- break;
- case OPT_SUBSAMPLE:
- optPtr->subsampleX = values[0];
- optPtr->subsampleY = values[1];
- break;
- case OPT_TO:
- if ((values[0] < 0) || (values[1] < 0) || ((numValues > 2)
- && ((values[2] < 0) || (values[3] < 0)))) {
- Tcl_AppendResult(interp, "value(s) for the -to",
- " option must be non-negative", (char *) NULL);
- return TCL_ERROR;
- }
- if (numValues <= 2) {
- optPtr->toX = values[0];
- optPtr->toY = values[1];
- optPtr->toX2 = -1;
- optPtr->toY2 = -1;
- } else {
- optPtr->toX = MIN(values[0], values[2]);
- optPtr->toY = MIN(values[1], values[3]);
- optPtr->toX2 = MAX(values[0], values[2]);
- optPtr->toY2 = MAX(values[1], values[3]);
- }
- break;
- case OPT_ZOOM:
- if ((values[0] <= 0) || (values[1] <= 0)) {
- Tcl_AppendResult(interp, "value(s) for the -zoom",
- " option must be positive", (char *) NULL);
- return TCL_ERROR;
- }
- optPtr->zoomX = values[0];
- optPtr->zoomY = values[1];
- break;
- }
- } else if (bit == OPT_FORMAT) {
- /*
- * The -format option takes a single string value.
- */
-
- if (index + 1 < argc) {
- *optIndexPtr = ++index;
- optPtr->format = argv[index];
- } else {
- Tcl_AppendResult(interp, "the \"-format\" option ",
- "requires a value", (char *) NULL);
- return TCL_ERROR;
- }
- }
-
- /*
- * Remember that we saw this option.
- */
-
- optPtr->options |= bit;
- }
-
- return TCL_OK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ImgPhotoConfigureMaster --
- *
- * This procedure is called when a photo image is created or
- * reconfigured. It processes configuration options and resets
- * any instances of the image.
- *
- * Results:
- * A standard Tcl return value. If TCL_ERROR is returned then
- * an error message is left in masterPtr->interp->result.
- *
- * Side effects:
- * Existing instances of the image will be redisplayed to match
- * the new configuration options.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-ImgPhotoConfigureMaster(interp, masterPtr, argc, argv, flags)
- Tcl_Interp *interp; /* Interpreter to use for reporting errors. */
- PhotoMaster *masterPtr; /* Pointer to data structure describing
- * overall photo image to (re)configure. */
- int argc; /* Number of entries in argv. */
- char **argv; /* Pairs of configuration options for image. */
- int flags; /* Flags to pass to Tk_ConfigureWidget,
- * such as TK_CONFIG_ARGV_ONLY. */
-{
- PhotoInstance *instancePtr;
- char *oldFileString, *oldDataString, *oldPaletteString;
- double oldGamma;
- int result;
- Tcl_Channel chan;
- Tk_PhotoImageFormat *imageFormat;
- int imageWidth, imageHeight;
-
- /*
- * Save the current values for fileString and dataString, so we
- * can tell if the user specifies them anew.
- */
-
- oldFileString = masterPtr->fileString;
- oldDataString = (oldFileString == NULL)? masterPtr->dataString: NULL;
- oldPaletteString = masterPtr->palette;
- oldGamma = masterPtr->gamma;
-
- /*
- * Process the configuration options specified.
- */
-
- if (Tk_ConfigureWidget(interp, Tk_MainWindow(interp), configSpecs,
- argc, argv, (char *) masterPtr, flags) != TCL_OK) {
- return TCL_ERROR;
- }
-
- /*
- * Regard the empty string for -file, -data or -format as the null
- * value.
- */
-
- if ((masterPtr->fileString != NULL) && (masterPtr->fileString[0] == 0)) {
- ckfree(masterPtr->fileString);
- masterPtr->fileString = NULL;
- }
- if ((masterPtr->dataString != NULL) && (masterPtr->dataString[0] == 0)) {
- ckfree(masterPtr->dataString);
- masterPtr->dataString = NULL;
- }
- if ((masterPtr->format != NULL) && (masterPtr->format[0] == 0)) {
- ckfree(masterPtr->format);
- masterPtr->format = NULL;
- }
-
- /*
- * Set the image to the user-requested size, if any,
- * and make sure storage is correctly allocated for this image.
- */
-
- ImgPhotoSetSize(masterPtr, masterPtr->width, masterPtr->height);
-
- /*
- * Read in the image from the file or string if the user has
- * specified the -file or -data option.
- */
-
- if ((masterPtr->fileString != NULL)
- && (masterPtr->fileString != oldFileString)) {
-
- /*
- * Prevent file system access in a safe interpreter.
- */
-
- if (Tcl_IsSafe(interp)) {
- Tcl_AppendResult(interp, "can't get image from a file in a",
- " safe interpreter", (char *) NULL);
- return TCL_ERROR;
- }
-
- chan = Tcl_OpenFileChannel(interp, masterPtr->fileString, "r", 0);
- if (chan == NULL) {
- return TCL_ERROR;
- }
- if (Tcl_SetChannelOption(interp, chan, "-translation", "binary")
- != TCL_OK) {
- return TCL_ERROR;
- }
- if (MatchFileFormat(interp, chan, masterPtr->fileString,
- masterPtr->format, &imageFormat, &imageWidth,
- &imageHeight) != TCL_OK) {
- Tcl_Close(NULL, chan);
- return TCL_ERROR;
- }
- ImgPhotoSetSize(masterPtr, imageWidth, imageHeight);
- result = (*imageFormat->fileReadProc)(interp, chan,
- masterPtr->fileString, masterPtr->format,
- (Tk_PhotoHandle) masterPtr, 0, 0,
- imageWidth, imageHeight, 0, 0);
- Tcl_Close(NULL, chan);
- if (result != TCL_OK) {
- return TCL_ERROR;
- }
-
- masterPtr->flags |= IMAGE_CHANGED;
- }
-
- if ((masterPtr->fileString == NULL) && (masterPtr->dataString != NULL)
- && (masterPtr->dataString != oldDataString)) {
-
- if (MatchStringFormat(interp, masterPtr->dataString,
- masterPtr->format, &imageFormat, &imageWidth,
- &imageHeight) != TCL_OK) {
- return TCL_ERROR;
- }
- ImgPhotoSetSize(masterPtr, imageWidth, imageHeight);
- if ((*imageFormat->stringReadProc)(interp, masterPtr->dataString,
- masterPtr->format, (Tk_PhotoHandle) masterPtr,
- 0, 0, imageWidth, imageHeight, 0, 0) != TCL_OK) {
- return TCL_ERROR;
- }
-
- masterPtr->flags |= IMAGE_CHANGED;
- }
-
- /*
- * Enforce a reasonable value for gamma.
- */
-
- if (masterPtr->gamma <= 0) {
- masterPtr->gamma = 1.0;
- }
-
- if ((masterPtr->gamma != oldGamma)
- || (masterPtr->palette != oldPaletteString)) {
- masterPtr->flags |= IMAGE_CHANGED;
- }
-
- /*
- * Cycle through all of the instances of this image, regenerating
- * the information for each instance. Then force the image to be
- * redisplayed everywhere that it is used.
- */
-
- for (instancePtr = masterPtr->instancePtr; instancePtr != NULL;
- instancePtr = instancePtr->nextPtr) {
- ImgPhotoConfigureInstance(instancePtr);
- }
-
- /*
- * Inform the generic image code that the image
- * has (potentially) changed.
- */
-
- Tk_ImageChanged(masterPtr->tkMaster, 0, 0, masterPtr->width,
- masterPtr->height, masterPtr->width, masterPtr->height);
- masterPtr->flags &= ~IMAGE_CHANGED;
-
- return TCL_OK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ImgPhotoConfigureInstance --
- *
- * This procedure is called to create displaying information for
- * a photo image instance based on the configuration information
- * in the master. It is invoked both when new instances are
- * created and when the master is reconfigured.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Generates errors via Tcl_BackgroundError if there are problems
- * in setting up the instance.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-ImgPhotoConfigureInstance(instancePtr)
- PhotoInstance *instancePtr; /* Instance to reconfigure. */
-{
- PhotoMaster *masterPtr = instancePtr->masterPtr;
- XImage *imagePtr;
- int bitsPerPixel;
- ColorTable *colorTablePtr;
- XRectangle validBox;
-
- /*
- * If the -palette configuration option has been set for the master,
- * use the value specified for our palette, but only if it is
- * a valid palette for our windows. Use the gamma value specified
- * the master.
- */
-
- if ((masterPtr->palette && masterPtr->palette[0])
- && IsValidPalette(instancePtr, masterPtr->palette)) {
- instancePtr->palette = masterPtr->palette;
- } else {
- instancePtr->palette = instancePtr->defaultPalette;
- }
- instancePtr->gamma = masterPtr->gamma;
-
- /*
- * If we don't currently have a color table, or if the one we
- * have no longer applies (e.g. because our palette or gamma
- * has changed), get a new one.
- */
-
- colorTablePtr = instancePtr->colorTablePtr;
- if ((colorTablePtr == NULL)
- || (instancePtr->colormap != colorTablePtr->id.colormap)
- || (instancePtr->palette != colorTablePtr->id.palette)
- || (instancePtr->gamma != colorTablePtr->id.gamma)) {
- /*
- * Free up our old color table, and get a new one.
- */
-
- if (colorTablePtr != NULL) {
- colorTablePtr->liveRefCount -= 1;
- FreeColorTable(colorTablePtr);
- }
- GetColorTable(instancePtr);
-
- /*
- * Create a new XImage structure for sending data to
- * the X server, if necessary.
- */
-
- if (instancePtr->colorTablePtr->flags & BLACK_AND_WHITE) {
- bitsPerPixel = 1;
- } else {
- bitsPerPixel = instancePtr->visualInfo.depth;
- }
-
- if ((instancePtr->imagePtr == NULL)
- || (instancePtr->imagePtr->bits_per_pixel != bitsPerPixel)) {
- if (instancePtr->imagePtr != NULL) {
- XFree((char *) instancePtr->imagePtr);
- }
- imagePtr = XCreateImage(instancePtr->display,
- instancePtr->visualInfo.visual, (unsigned) bitsPerPixel,
- (bitsPerPixel > 1? ZPixmap: XYBitmap), 0, (char *) NULL,
- 1, 1, 32, 0);
- instancePtr->imagePtr = imagePtr;
-
- /*
- * Determine the endianness of this machine.
- * We create images using the local host's endianness, rather
- * than the endianness of the server; otherwise we would have
- * 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.
- */
-
- if (imagePtr != NULL) {
- union {
- int i;
- char c[sizeof(int)];
- } kludge;
-
- imagePtr->bitmap_unit = sizeof(pixel) * NBBY;
- kludge.i = 0;
- kludge.c[0] = 1;
- imagePtr->byte_order = (kludge.i == 1) ? LSBFirst : MSBFirst;
- _XInitImageFuncPtrs(imagePtr);
- }
- }
- }
-
- /*
- * If the user has specified a width and/or height for the master
- * which is different from our current width/height, set the size
- * to the values specified by the user. If we have no pixmap, we
- * do this also, since it has the side effect of allocating a
- * pixmap for us.
- */
-
- if ((instancePtr->pixels == None) || (instancePtr->error == NULL)
- || (instancePtr->width != masterPtr->width)
- || (instancePtr->height != masterPtr->height)) {
- ImgPhotoInstanceSetSize(instancePtr);
- }
-
- /*
- * Redither this instance if necessary.
- */
-
- if ((masterPtr->flags & IMAGE_CHANGED)
- || (instancePtr->colorTablePtr != colorTablePtr)) {
- TkClipBox(masterPtr->validRegion, &validBox);
- if ((validBox.width > 0) && (validBox.height > 0)) {
- DitherInstance(instancePtr, validBox.x, validBox.y,
- validBox.width, validBox.height);
- }
- }
-
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ImgPhotoGet --
- *
- * This procedure is called for each use of a photo image in a
- * widget.
- *
- * Results:
- * The return value is a token for the instance, which is passed
- * back to us in calls to ImgPhotoDisplay and ImgPhotoFree.
- *
- * Side effects:
- * A data structure is set up for the instance (or, an existing
- * instance is re-used for the new one).
- *
- *----------------------------------------------------------------------
- */
-
-static ClientData
-ImgPhotoGet(tkwin, masterData)
- Tk_Window tkwin; /* Window in which the instance will be
- * used. */
- ClientData masterData; /* Pointer to our master structure for the
- * image. */
-{
- PhotoMaster *masterPtr = (PhotoMaster *) masterData;
- PhotoInstance *instancePtr;
- Colormap colormap;
- int mono, nRed, nGreen, nBlue;
- XVisualInfo visualInfo, *visInfoPtr;
- XRectangle validBox;
- char buf[16];
- int numVisuals;
- XColor *white, *black;
- XGCValues gcValues;
-
- /*
- * Table of "best" choices for palette for PseudoColor displays
- * with between 3 and 15 bits/pixel.
- */
-
- static int paletteChoice[13][3] = {
- /* #red, #green, #blue */
- {2, 2, 2, /* 3 bits, 8 colors */},
- {2, 3, 2, /* 4 bits, 12 colors */},
- {3, 4, 2, /* 5 bits, 24 colors */},
- {4, 5, 3, /* 6 bits, 60 colors */},
- {5, 6, 4, /* 7 bits, 120 colors */},
- {7, 7, 4, /* 8 bits, 198 colors */},
- {8, 10, 6, /* 9 bits, 480 colors */},
- {10, 12, 8, /* 10 bits, 960 colors */},
- {14, 15, 9, /* 11 bits, 1890 colors */},
- {16, 20, 12, /* 12 bits, 3840 colors */},
- {20, 24, 16, /* 13 bits, 7680 colors */},
- {26, 30, 20, /* 14 bits, 15600 colors */},
- {32, 32, 30, /* 15 bits, 30720 colors */}
- };
-
- /*
- * See if there is already an instance for windows using
- * the same colormap. If so then just re-use it.
- */
-
- colormap = Tk_Colormap(tkwin);
- for (instancePtr = masterPtr->instancePtr; instancePtr != NULL;
- instancePtr = instancePtr->nextPtr) {
- if ((colormap == instancePtr->colormap)
- && (Tk_Display(tkwin) == instancePtr->display)) {
-
- /*
- * Re-use this instance.
- */
-
- if (instancePtr->refCount == 0) {
- /*
- * We are resurrecting this instance.
- */
-
- Tcl_CancelIdleCall(DisposeInstance, (ClientData) instancePtr);
- if (instancePtr->colorTablePtr != NULL) {
- FreeColorTable(instancePtr->colorTablePtr);
- }
- GetColorTable(instancePtr);
- }
- instancePtr->refCount++;
- return (ClientData) instancePtr;
- }
- }
-
- /*
- * The image isn't already in use in a window with the same colormap.
- * Make a new instance of the image.
- */
-
- instancePtr = (PhotoInstance *) ckalloc(sizeof(PhotoInstance));
- instancePtr->masterPtr = masterPtr;
- instancePtr->display = Tk_Display(tkwin);
- instancePtr->colormap = Tk_Colormap(tkwin);
- Tk_PreserveColormap(instancePtr->display, instancePtr->colormap);
- instancePtr->refCount = 1;
- instancePtr->colorTablePtr = NULL;
- instancePtr->pixels = None;
- instancePtr->error = NULL;
- instancePtr->width = 0;
- instancePtr->height = 0;
- instancePtr->imagePtr = 0;
- instancePtr->nextPtr = masterPtr->instancePtr;
- masterPtr->instancePtr = instancePtr;
-
- /*
- * Obtain information about the visual and decide on the
- * default palette.
- */
-
- visualInfo.screen = Tk_ScreenNumber(tkwin);
- visualInfo.visualid = XVisualIDFromVisual(Tk_Visual(tkwin));
- visInfoPtr = XGetVisualInfo(Tk_Display(tkwin),
- VisualScreenMask | VisualIDMask, &visualInfo, &numVisuals);
- nRed = 2;
- nGreen = nBlue = 0;
- mono = 1;
- if (visInfoPtr != NULL) {
- instancePtr->visualInfo = *visInfoPtr;
- switch (visInfoPtr->class) {
- case DirectColor:
- case TrueColor:
- nRed = 1 << CountBits(visInfoPtr->red_mask);
- nGreen = 1 << CountBits(visInfoPtr->green_mask);
- nBlue = 1 << CountBits(visInfoPtr->blue_mask);
- mono = 0;
- break;
- case PseudoColor:
- case StaticColor:
- if (visInfoPtr->depth > 15) {
- nRed = 32;
- nGreen = 32;
- nBlue = 32;
- mono = 0;
- } else if (visInfoPtr->depth >= 3) {
- int *ip = paletteChoice[visInfoPtr->depth - 3];
-
- nRed = ip[0];
- nGreen = ip[1];
- nBlue = ip[2];
- mono = 0;
- }
- break;
- case GrayScale:
- case StaticGray:
- nRed = 1 << visInfoPtr->depth;
- break;
- }
- XFree((char *) visInfoPtr);
-
- } else {
- panic("ImgPhotoGet couldn't find visual for window");
- }
-
- sprintf(buf, ((mono) ? "%d": "%d/%d/%d"), nRed, nGreen, nBlue);
- instancePtr->defaultPalette = Tk_GetUid(buf);
-
- /*
- * Make a GC with background = black and foreground = white.
- */
-
- white = Tk_GetColor(masterPtr->interp, tkwin, "white");
- black = Tk_GetColor(masterPtr->interp, tkwin, "black");
- gcValues.foreground = (white != NULL)? white->pixel:
- WhitePixelOfScreen(Tk_Screen(tkwin));
- gcValues.background = (black != NULL)? black->pixel:
- BlackPixelOfScreen(Tk_Screen(tkwin));
- gcValues.graphics_exposures = False;
- instancePtr->gc = Tk_GetGC(tkwin,
- GCForeground|GCBackground|GCGraphicsExposures, &gcValues);
-
- /*
- * Set configuration options and finish the initialization of the instance.
- */
-
- ImgPhotoConfigureInstance(instancePtr);
-
- /*
- * If this is the first instance, must set the size of the image.
- */
-
- if (instancePtr->nextPtr == NULL) {
- Tk_ImageChanged(masterPtr->tkMaster, 0, 0, 0, 0,
- 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;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ImgPhotoDisplay --
- *
- * This procedure is invoked to draw a photo image.
- *
- * Results:
- * None.
- *
- * Side effects:
- * A portion of the image gets rendered in a pixmap or window.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-ImgPhotoDisplay(clientData, display, drawable, imageX, imageY, width,
- height, drawableX, drawableY)
- ClientData clientData; /* Pointer to PhotoInstance structure for
- * for instance to be displayed. */
- Display *display; /* Display on which to draw image. */
- Drawable drawable; /* Pixmap or window in which to draw image. */
- int imageX, imageY; /* Upper-left corner of region within image
- * to draw. */
- int width, height; /* Dimensions of region within image to draw. */
- int drawableX, drawableY; /* Coordinates within drawable that
- * correspond to imageX and imageY. */
-{
- PhotoInstance *instancePtr = (PhotoInstance *) clientData;
-
- /*
- * If there's no pixmap, it means that an error occurred
- * while creating the image instance so it can't be displayed.
- */
-
- if (instancePtr->pixels == None) {
- return;
- }
-
- /*
- * masterPtr->region describes which parts of the image contain
- * valid data. We set this region as the clip mask for the gc,
- * setting its origin appropriately, and use it when drawing the
- * image.
- */
-
- TkSetRegion(display, instancePtr->gc, instancePtr->masterPtr->validRegion);
- XSetClipOrigin(display, instancePtr->gc, drawableX - imageX,
- drawableY - imageY);
- XCopyArea(display, instancePtr->pixels, drawable, instancePtr->gc,
- imageX, imageY, (unsigned) width, (unsigned) height,
- drawableX, drawableY);
- XSetClipMask(display, instancePtr->gc, None);
- XSetClipOrigin(display, instancePtr->gc, 0, 0);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ImgPhotoFree --
- *
- * This procedure is called when a widget ceases to use a
- * particular instance of an image. We don't actually get
- * rid of the instance until later because we may be about
- * to get this instance again.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Internal data structures get cleaned up, later.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-ImgPhotoFree(clientData, display)
- ClientData clientData; /* Pointer to PhotoInstance structure for
- * for instance to be displayed. */
- Display *display; /* Display containing window that used image. */
-{
- PhotoInstance *instancePtr = (PhotoInstance *) clientData;
- ColorTable *colorPtr;
-
- instancePtr->refCount -= 1;
- if (instancePtr->refCount > 0) {
- return;
- }
-
- /*
- * There are no more uses of the image within this widget.
- * Decrement the count of live uses of its color table, so
- * that its colors can be reclaimed if necessary, and
- * set up an idle call to free the instance structure.
- */
-
- colorPtr = instancePtr->colorTablePtr;
- if (colorPtr != NULL) {
- colorPtr->liveRefCount -= 1;
- }
-
- Tcl_DoWhenIdle(DisposeInstance, (ClientData) instancePtr);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ImgPhotoDelete --
- *
- * This procedure is called by the image code to delete the
- * master structure for an image.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Resources associated with the image get freed.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-ImgPhotoDelete(masterData)
- ClientData masterData; /* Pointer to PhotoMaster structure for
- * image. Must not have any more instances. */
-{
- PhotoMaster *masterPtr = (PhotoMaster *) masterData;
- PhotoInstance *instancePtr;
-
- while ((instancePtr = masterPtr->instancePtr) != NULL) {
- if (instancePtr->refCount > 0) {
- panic("tried to delete photo image when instances still exist");
- }
- Tcl_CancelIdleCall(DisposeInstance, (ClientData) instancePtr);
- DisposeInstance((ClientData) instancePtr);
- }
- masterPtr->tkMaster = NULL;
- if (masterPtr->imageCmd != NULL) {
- Tcl_DeleteCommandFromToken(masterPtr->interp, masterPtr->imageCmd);
- }
- if (masterPtr->pix24 != NULL) {
- ckfree((char *) masterPtr->pix24);
- }
- if (masterPtr->validRegion != NULL) {
- TkDestroyRegion(masterPtr->validRegion);
- }
- Tk_FreeOptions(configSpecs, (char *) masterPtr, (Display *) NULL, 0);
- ckfree((char *) masterPtr);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ImgPhotoCmdDeletedProc --
- *
- * This procedure is invoked when the image command for an image
- * is deleted. It deletes the image.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The image is deleted.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-ImgPhotoCmdDeletedProc(clientData)
- ClientData clientData; /* Pointer to PhotoMaster structure for
- * image. */
-{
- PhotoMaster *masterPtr = (PhotoMaster *) clientData;
-
- masterPtr->imageCmd = NULL;
- if (masterPtr->tkMaster != NULL) {
- Tk_DeleteImage(masterPtr->interp, Tk_NameOfImage(masterPtr->tkMaster));
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ImgPhotoSetSize --
- *
- * This procedure reallocates the image storage and instance
- * pixmaps for a photo image, as necessary, to change the
- * image's size to `width' x `height' pixels.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Storage gets reallocated, for the master and all its instances.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-ImgPhotoSetSize(masterPtr, width, height)
- PhotoMaster *masterPtr;
- int width, height;
-{
- unsigned char *newPix24;
- int h, offset, pitch;
- unsigned char *srcPtr, *destPtr;
- XRectangle validBox, clipBox;
- TkRegion clipRegion;
- PhotoInstance *instancePtr;
-
- if (masterPtr->userWidth > 0) {
- width = masterPtr->userWidth;
- }
- if (masterPtr->userHeight > 0) {
- height = masterPtr->userHeight;
- }
-
- /*
- * We have to trim the valid region if it is currently
- * larger than the new image size.
- */
-
- TkClipBox(masterPtr->validRegion, &validBox);
- if ((validBox.x + validBox.width > width)
- || (validBox.y + validBox.height > height)) {
- clipBox.x = 0;
- clipBox.y = 0;
- clipBox.width = width;
- clipBox.height = height;
- clipRegion = TkCreateRegion();
- TkUnionRectWithRegion(&clipBox, clipRegion, clipRegion);
- TkIntersectRegion(masterPtr->validRegion, clipRegion,
- masterPtr->validRegion);
- TkDestroyRegion(clipRegion);
- 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 * 3;
- newPix24 = (unsigned char *) ckalloc((unsigned) (height * pitch));
-
- /*
- * Zero the new array. The dithering code shouldn't read the
- * areas outside validBox, but they might be copied to another
- * photo image or written to a file.
- */
-
- if ((masterPtr->pix24 != NULL)
- && ((width == masterPtr->width) || (width == validBox.width))) {
- if (validBox.y > 0) {
- memset((VOID *) newPix24, 0, (size_t) (validBox.y * pitch));
- }
- h = validBox.y + validBox.height;
- if (h < height) {
- memset((VOID *) (newPix24 + h * pitch), 0,
- (size_t) ((height - h) * pitch));
- }
- } else {
- memset((VOID *) newPix24, 0, (size_t) (height * pitch));
- }
-
- if (masterPtr->pix24 != NULL) {
-
- /*
- * Copy the common area over to the new array array and
- * free the old array.
- */
-
- if (width == masterPtr->width) {
-
- /*
- * The region to be copied is contiguous.
- */
-
- offset = validBox.y * pitch;
- memcpy((VOID *) (newPix24 + offset),
- (VOID *) (masterPtr->pix24 + offset),
- (size_t) (validBox.height * pitch));
-
- } else if ((validBox.width > 0) && (validBox.height > 0)) {
-
- /*
- * Area to be copied is not contiguous - copy line by line.
- */
-
- destPtr = newPix24 + (validBox.y * width + validBox.x) * 3;
- srcPtr = masterPtr->pix24 + (validBox.y * masterPtr->width
- + validBox.x) * 3;
- for (h = validBox.height; h > 0; h--) {
- memcpy((VOID *) destPtr, (VOID *) srcPtr,
- (size_t) (validBox.width * 3));
- destPtr += width * 3;
- srcPtr += masterPtr->width * 3;
- }
- }
-
- ckfree((char *) masterPtr->pix24);
- }
-
- masterPtr->pix24 = newPix24;
- masterPtr->width = width;
- masterPtr->height = height;
-
- /*
- * Dithering will be correct up to the end of the last
- * pre-existing complete scanline.
- */
-
- if ((validBox.x > 0) || (validBox.y > 0)) {
- masterPtr->ditherX = 0;
- masterPtr->ditherY = 0;
- } else if (validBox.width == width) {
- if ((int) validBox.height < masterPtr->ditherY) {
- masterPtr->ditherX = 0;
- masterPtr->ditherY = validBox.height;
- }
- } else {
- if ((masterPtr->ditherY > 0)
- || ((int) validBox.width < masterPtr->ditherX)) {
- masterPtr->ditherX = validBox.width;
- masterPtr->ditherY = 0;
- }
- }
- }
-
- /*
- * Now adjust the sizes of the pixmaps for all of the instances.
- */
-
- for (instancePtr = masterPtr->instancePtr; instancePtr != NULL;
- instancePtr = instancePtr->nextPtr) {
- ImgPhotoInstanceSetSize(instancePtr);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ImgPhotoInstanceSetSize --
- *
- * This procedure reallocates the instance pixmap and dithering
- * error array for a photo instance, as necessary, to change the
- * image's size to `width' x `height' pixels.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Storage gets reallocated, here and in the X server.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-ImgPhotoInstanceSetSize(instancePtr)
- PhotoInstance *instancePtr; /* Instance whose size is to be
- * changed. */
-{
- PhotoMaster *masterPtr;
- schar *newError;
- schar *errSrcPtr, *errDestPtr;
- int h, offset;
- XRectangle validBox;
- Pixmap newPixmap;
-
- masterPtr = instancePtr->masterPtr;
- TkClipBox(masterPtr->validRegion, &validBox);
-
- if ((instancePtr->width != masterPtr->width)
- || (instancePtr->height != masterPtr->height)
- || (instancePtr->pixels == None)) {
- newPixmap = Tk_GetPixmap(instancePtr->display,
- RootWindow(instancePtr->display,
- instancePtr->visualInfo.screen),
- (masterPtr->width > 0) ? masterPtr->width: 1,
- (masterPtr->height > 0) ? masterPtr->height: 1,
- instancePtr->visualInfo.depth);
-
- /*
- * The following is a gross hack needed to properly support colormaps
- * under Windows. Before the pixels can be copied to the pixmap,
- * the relevent colormap must be associated with the drawable.
- * Normally we can infer this association from the window that
- * was used to create the pixmap. However, in this case we're
- * using the root window, so we have to be more explicit.
- */
-
- TkSetPixmapColormap(newPixmap, instancePtr->colormap);
-
- if (instancePtr->pixels != None) {
- /*
- * Copy any common pixels from the old pixmap and free it.
- */
- XCopyArea(instancePtr->display, instancePtr->pixels, newPixmap,
- instancePtr->gc, validBox.x, validBox.y,
- validBox.width, validBox.height, validBox.x, validBox.y);
- Tk_FreePixmap(instancePtr->display, instancePtr->pixels);
- }
- instancePtr->pixels = newPixmap;
- }
-
- if ((instancePtr->width != masterPtr->width)
- || (instancePtr->height != masterPtr->height)
- || (instancePtr->error == NULL)) {
-
- newError = (schar *) ckalloc((unsigned)
- (masterPtr->height * masterPtr->width * 3 * sizeof(schar)));
-
- /*
- * Zero the new array so that we don't get bogus error values
- * propagating into areas we dither later.
- */
-
- if ((instancePtr->error != NULL)
- && ((instancePtr->width == masterPtr->width)
- || (validBox.width == masterPtr->width))) {
- if (validBox.y > 0) {
- memset((VOID *) newError, 0, (size_t)
- (validBox.y * masterPtr->width * 3 * sizeof(schar)));
- }
- h = validBox.y + validBox.height;
- if (h < masterPtr->height) {
- memset((VOID *) (newError + h * masterPtr->width * 3), 0,
- (size_t) ((masterPtr->height - h)
- * masterPtr->width * 3 * sizeof(schar)));
- }
- } else {
- memset((VOID *) newError, 0, (size_t)
- (masterPtr->height * masterPtr->width * 3 * sizeof(schar)));
- }
-
- if (instancePtr->error != NULL) {
-
- /*
- * Copy the common area over to the new array
- * and free the old array.
- */
-
- if (masterPtr->width == instancePtr->width) {
-
- offset = validBox.y * masterPtr->width * 3;
- memcpy((VOID *) (newError + offset),
- (VOID *) (instancePtr->error + offset),
- (size_t) (validBox.height
- * masterPtr->width * 3 * sizeof(schar)));
-
- } else if (validBox.width > 0 && validBox.height > 0) {
-
- errDestPtr = newError
- + (validBox.y * masterPtr->width + validBox.x) * 3;
- errSrcPtr = instancePtr->error
- + (validBox.y * instancePtr->width + validBox.x) * 3;
- for (h = validBox.height; h > 0; --h) {
- memcpy((VOID *) errDestPtr, (VOID *) errSrcPtr,
- validBox.width * 3 * sizeof(schar));
- errDestPtr += masterPtr->width * 3;
- errSrcPtr += instancePtr->width * 3;
- }
- }
- ckfree((char *) instancePtr->error);
- }
-
- instancePtr->error = newError;
- }
-
- instancePtr->width = masterPtr->width;
- instancePtr->height = masterPtr->height;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * IsValidPalette --
- *
- * This procedure is called to check whether a value given for
- * the -palette option is valid for a particular instance
- * of a photo image.
- *
- * Results:
- * A boolean value: 1 if the palette is acceptable, 0 otherwise.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-IsValidPalette(instancePtr, palette)
- PhotoInstance *instancePtr; /* Instance to which the palette
- * specification is to be applied. */
- char *palette; /* Palette specification string. */
-{
- int nRed, nGreen, nBlue, mono, numColors;
- char *endp;
-
- /*
- * First parse the specification: it must be of the form
- * %d or %d/%d/%d.
- */
-
- nRed = strtol(palette, &endp, 10);
- if ((endp == palette) || ((*endp != 0) && (*endp != '/'))
- || (nRed < 2) || (nRed > 256)) {
- return 0;
- }
-
- if (*endp == 0) {
- mono = 1;
- nGreen = nBlue = nRed;
- } else {
- palette = endp + 1;
- nGreen = strtol(palette, &endp, 10);
- if ((endp == palette) || (*endp != '/') || (nGreen < 2)
- || (nGreen > 256)) {
- return 0;
- }
- palette = endp + 1;
- nBlue = strtol(palette, &endp, 10);
- if ((endp == palette) || (*endp != 0) || (nBlue < 2)
- || (nBlue > 256)) {
- return 0;
- }
- mono = 0;
- }
-
- switch (instancePtr->visualInfo.class) {
- case DirectColor:
- case TrueColor:
- if ((nRed > (1 << CountBits(instancePtr->visualInfo.red_mask)))
- || (nGreen > (1
- << CountBits(instancePtr->visualInfo.green_mask)))
- || (nBlue > (1
- << CountBits(instancePtr->visualInfo.blue_mask)))) {
- return 0;
- }
- break;
- case PseudoColor:
- case StaticColor:
- numColors = nRed;
- if (!mono) {
- numColors *= nGreen*nBlue;
- }
- if (numColors > (1 << instancePtr->visualInfo.depth)) {
- return 0;
- }
- break;
- case GrayScale:
- case StaticGray:
- if (!mono || (nRed > (1 << instancePtr->visualInfo.depth))) {
- return 0;
- }
- break;
- }
-
- return 1;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * CountBits --
- *
- * This procedure counts how many bits are set to 1 in `mask'.
- *
- * Results:
- * The integer number of bits.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-CountBits(mask)
- pixel mask; /* Value to count the 1 bits in. */
-{
- int n;
-
- for( n = 0; mask != 0; mask &= mask - 1 )
- n++;
- return n;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * GetColorTable --
- *
- * This procedure is called to allocate a table of colormap
- * information for an instance of a photo image. Only one such
- * table is allocated for all photo instances using the same
- * display, colormap, palette and gamma values, so that the
- * application need only request a set of colors from the X
- * server once for all such photo widgets. This procedure
- * maintains a hash table to find previously-allocated
- * ColorTables.
- *
- * Results:
- * None.
- *
- * Side effects:
- * A new ColorTable may be allocated and placed in the hash
- * table, and have colors allocated for it.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-GetColorTable(instancePtr)
- PhotoInstance *instancePtr; /* Instance needing a color table. */
-{
- ColorTable *colorPtr;
- Tcl_HashEntry *entry;
- ColorTableId id;
- int isNew;
-
- /*
- * Look for an existing ColorTable in the hash table.
- */
-
- memset((VOID *) &id, 0, sizeof(id));
- id.display = instancePtr->display;
- id.colormap = instancePtr->colormap;
- id.palette = instancePtr->palette;
- id.gamma = instancePtr->gamma;
- if (!imgPhotoColorHashInitialized) {
- Tcl_InitHashTable(&imgPhotoColorHash, N_COLOR_HASH);
- imgPhotoColorHashInitialized = 1;
- }
- entry = Tcl_CreateHashEntry(&imgPhotoColorHash, (char *) &id, &isNew);
-
- if (!isNew) {
- /*
- * Re-use the existing entry.
- */
-
- colorPtr = (ColorTable *) Tcl_GetHashValue(entry);
-
- } else {
- /*
- * No color table currently available; need to make one.
- */
-
- colorPtr = (ColorTable *) ckalloc(sizeof(ColorTable));
-
- /*
- * The following line of code should not normally be needed due
- * to the assignment in the following line. However, it compensates
- * for bugs in some compilers (HP, for example) where
- * sizeof(ColorTable) is 24 but the assignment only copies 20 bytes,
- * leaving 4 bytes uninitialized; these cause problems when using
- * the id for lookups in imgPhotoColorHash, and can result in
- * core dumps.
- */
-
- memset((VOID *) &colorPtr->id, 0, sizeof(ColorTableId));
- colorPtr->id = id;
- Tk_PreserveColormap(colorPtr->id.display, colorPtr->id.colormap);
- colorPtr->flags = 0;
- colorPtr->refCount = 0;
- colorPtr->liveRefCount = 0;
- colorPtr->numColors = 0;
- colorPtr->visualInfo = instancePtr->visualInfo;
- colorPtr->pixelMap = NULL;
- Tcl_SetHashValue(entry, colorPtr);
- }
-
- colorPtr->refCount++;
- colorPtr->liveRefCount++;
- instancePtr->colorTablePtr = colorPtr;
- if (colorPtr->flags & DISPOSE_PENDING) {
- Tcl_CancelIdleCall(DisposeColorTable, (ClientData) colorPtr);
- colorPtr->flags &= ~DISPOSE_PENDING;
- }
-
- /*
- * Allocate colors for this color table if necessary.
- */
-
- if ((colorPtr->numColors == 0)
- && ((colorPtr->flags & BLACK_AND_WHITE) == 0)) {
- AllocateColors(colorPtr);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * FreeColorTable --
- *
- * This procedure is called when an instance ceases using a
- * color table.
- *
- * Results:
- * None.
- *
- * Side effects:
- * If no other instances are using this color table, a when-idle
- * handler is registered to free up the color table and the colors
- * allocated for it.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-FreeColorTable(colorPtr)
- ColorTable *colorPtr; /* Pointer to the color table which is
- * no longer required by an instance. */
-{
- colorPtr->refCount--;
- if (colorPtr->refCount > 0) {
- return;
- }
- if ((colorPtr->flags & DISPOSE_PENDING) == 0) {
- Tcl_DoWhenIdle(DisposeColorTable, (ClientData) colorPtr);
- colorPtr->flags |= DISPOSE_PENDING;
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * AllocateColors --
- *
- * This procedure allocates the colors required by a color table,
- * and sets up the fields in the color table data structure which
- * are used in dithering.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Colors are allocated from the X server. Fields in the
- * color table data structure are updated.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-AllocateColors(colorPtr)
- ColorTable *colorPtr; /* Pointer to the color table requiring
- * colors to be allocated. */
-{
- int i, r, g, b, rMult, mono;
- int numColors, nRed, nGreen, nBlue;
- double fr, fg, fb, igam;
- XColor *colors;
- unsigned long *pixels;
-
- /* 16-bit intensity value for i/n of full intensity. */
-# define CFRAC(i, n) ((i) * 65535 / (n))
-
- /* As for CFRAC, but apply exponent of g. */
-# define CGFRAC(i, n, g) ((int)(65535 * pow((double)(i) / (n), (g))))
-
- /*
- * First parse the palette specification to get the required number of
- * shades of each primary.
- */
-
- mono = sscanf(colorPtr->id.palette, "%d/%d/%d", &nRed, &nGreen, &nBlue)
- <= 1;
- igam = 1.0 / colorPtr->id.gamma;
-
- /*
- * Each time around this loop, we reduce the number of colors we're
- * trying to allocate until we succeed in allocating all of the colors
- * we need.
- */
-
- for (;;) {
- /*
- * If we are using 1 bit/pixel, we don't need to allocate
- * any colors (we just use the foreground and background
- * colors in the GC).
- */
-
- if (mono && (nRed <= 2)) {
- colorPtr->flags |= BLACK_AND_WHITE;
- return;
- }
-
- /*
- * Calculate the RGB coordinates of the colors we want to
- * allocate and store them in *colors.
- */
-
- if ((colorPtr->visualInfo.class == DirectColor)
- || (colorPtr->visualInfo.class == TrueColor)) {
-
- /*
- * Direct/True Color: allocate shades of red, green, blue
- * independently.
- */
-
- if (mono) {
- numColors = nGreen = nBlue = nRed;
- } else {
- numColors = MAX(MAX(nRed, nGreen), nBlue);
- }
- colors = (XColor *) ckalloc(numColors * sizeof(XColor));
-
- for (i = 0; i < numColors; ++i) {
- if (igam == 1.0) {
- colors[i].red = CFRAC(i, nRed - 1);
- colors[i].green = CFRAC(i, nGreen - 1);
- colors[i].blue = CFRAC(i, nBlue - 1);
- } else {
- colors[i].red = CGFRAC(i, nRed - 1, igam);
- colors[i].green = CGFRAC(i, nGreen - 1, igam);
- colors[i].blue = CGFRAC(i, nBlue - 1, igam);
- }
- }
- } else {
- /*
- * PseudoColor, StaticColor, GrayScale or StaticGray visual:
- * we have to allocate each color in the color cube separately.
- */
-
- numColors = (mono) ? nRed: (nRed * nGreen * nBlue);
- colors = (XColor *) ckalloc(numColors * sizeof(XColor));
-
- if (!mono) {
- /*
- * Color display using a PseudoColor or StaticColor visual.
- */
-
- i = 0;
- for (r = 0; r < nRed; ++r) {
- for (g = 0; g < nGreen; ++g) {
- for (b = 0; b < nBlue; ++b) {
- if (igam == 1.0) {
- colors[i].red = CFRAC(r, nRed - 1);
- colors[i].green = CFRAC(g, nGreen - 1);
- colors[i].blue = CFRAC(b, nBlue - 1);
- } else {
- colors[i].red = CGFRAC(r, nRed - 1, igam);
- colors[i].green = CGFRAC(g, nGreen - 1, igam);
- colors[i].blue = CGFRAC(b, nBlue - 1, igam);
- }
- i++;
- }
- }
- }
- } else {
- /*
- * Monochrome display - allocate the shades of grey we want.
- */
-
- for (i = 0; i < numColors; ++i) {
- if (igam == 1.0) {
- r = CFRAC(i, numColors - 1);
- } else {
- r = CGFRAC(i, numColors - 1, igam);
- }
- colors[i].red = colors[i].green = colors[i].blue = r;
- }
- }
- }
-
- /*
- * Now try to allocate the colors we've calculated.
- */
-
- pixels = (unsigned long *) ckalloc(numColors * sizeof(unsigned long));
- for (i = 0; i < numColors; ++i) {
- if (!XAllocColor(colorPtr->id.display, colorPtr->id.colormap,
- &colors[i])) {
-
- /*
- * Can't get all the colors we want in the default colormap;
- * first try freeing colors from other unused color tables.
- */
-
- if (!ReclaimColors(&colorPtr->id, numColors - i)
- || !XAllocColor(colorPtr->id.display,
- colorPtr->id.colormap, &colors[i])) {
- /*
- * Still can't allocate the color.
- */
- break;
- }
- }
- pixels[i] = colors[i].pixel;
- }
-
- /*
- * If we didn't get all of the colors, reduce the
- * resolution of the color cube, free the ones we got,
- * and try again.
- */
-
- if (i >= numColors) {
- break;
- }
- XFreeColors(colorPtr->id.display, colorPtr->id.colormap, pixels, i, 0);
- ckfree((char *) colors);
- ckfree((char *) pixels);
-
- if (!mono) {
- if ((nRed == 2) && (nGreen == 2) && (nBlue == 2)) {
- /*
- * Fall back to 1-bit monochrome display.
- */
-
- mono = 1;
- } else {
- /*
- * Reduce the number of shades of each primary to about
- * 3/4 of the previous value. This should reduce the
- * total number of colors required to about half the
- * previous value for PseudoColor displays.
- */
-
- nRed = (nRed * 3 + 2) / 4;
- nGreen = (nGreen * 3 + 2) / 4;
- nBlue = (nBlue * 3 + 2) / 4;
- }
- } else {
- /*
- * Reduce the number of shades of gray to about 1/2.
- */
-
- nRed = nRed / 2;
- }
- }
-
- /*
- * We have allocated all of the necessary colors:
- * fill in various fields of the ColorTable record.
- */
-
- if (!mono) {
- colorPtr->flags |= COLOR_WINDOW;
-
- /*
- * The following is a hairy hack. We only want to index into
- * the pixelMap on colormap displays. However, if the display
- * is on Windows, then we actually want to store the index not
- * the value since we will be passing the color table into the
- * TkPutImage call.
- */
-
-#ifndef __WIN32__
- if ((colorPtr->visualInfo.class != DirectColor)
- && (colorPtr->visualInfo.class != TrueColor)) {
- colorPtr->flags |= MAP_COLORS;
- }
-#endif /* __WIN32__ */
- }
-
- colorPtr->numColors = numColors;
- colorPtr->pixelMap = pixels;
-
- /*
- * Set up quantization tables for dithering.
- */
- rMult = nGreen * nBlue;
- for (i = 0; i < 256; ++i) {
- r = (i * (nRed - 1) + 127) / 255;
- if (mono) {
- fr = (double) colors[r].red / 65535.0;
- if (colorPtr->id.gamma != 1.0 ) {
- fr = pow(fr, colorPtr->id.gamma);
- }
- colorPtr->colorQuant[0][i] = (int)(fr * 255.99);
- colorPtr->redValues[i] = colors[r].pixel;
- } else {
- g = (i * (nGreen - 1) + 127) / 255;
- b = (i * (nBlue - 1) + 127) / 255;
- if ((colorPtr->visualInfo.class == DirectColor)
- || (colorPtr->visualInfo.class == TrueColor)) {
- colorPtr->redValues[i] = colors[r].pixel
- & colorPtr->visualInfo.red_mask;
- colorPtr->greenValues[i] = colors[g].pixel
- & colorPtr->visualInfo.green_mask;
- colorPtr->blueValues[i] = colors[b].pixel
- & colorPtr->visualInfo.blue_mask;
- } else {
- r *= rMult;
- g *= nBlue;
- colorPtr->redValues[i] = r;
- colorPtr->greenValues[i] = g;
- colorPtr->blueValues[i] = b;
- }
- fr = (double) colors[r].red / 65535.0;
- fg = (double) colors[g].green / 65535.0;
- fb = (double) colors[b].blue / 65535.0;
- if (colorPtr->id.gamma != 1.0) {
- fr = pow(fr, colorPtr->id.gamma);
- fg = pow(fg, colorPtr->id.gamma);
- fb = pow(fb, colorPtr->id.gamma);
- }
- colorPtr->colorQuant[0][i] = (int)(fr * 255.99);
- colorPtr->colorQuant[1][i] = (int)(fg * 255.99);
- colorPtr->colorQuant[2][i] = (int)(fb * 255.99);
- }
- }
-
- ckfree((char *) colors);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * DisposeColorTable --
- *
- *
- * Results:
- * None.
- *
- * Side effects:
- * The colors in the argument color table are freed, as is the
- * color table structure itself. The color table is removed
- * from the hash table which is used to locate color tables.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-DisposeColorTable(clientData)
- ClientData clientData; /* Pointer to the ColorTable whose
- * colors are to be released. */
-{
- ColorTable *colorPtr;
- Tcl_HashEntry *entry;
-
- colorPtr = (ColorTable *) clientData;
- if (colorPtr->pixelMap != NULL) {
- if (colorPtr->numColors > 0) {
- XFreeColors(colorPtr->id.display, colorPtr->id.colormap,
- colorPtr->pixelMap, colorPtr->numColors, 0);
- Tk_FreeColormap(colorPtr->id.display, colorPtr->id.colormap);
- }
- ckfree((char *) colorPtr->pixelMap);
- }
-
- entry = Tcl_FindHashEntry(&imgPhotoColorHash, (char *) &colorPtr->id);
- if (entry == NULL) {
- panic("DisposeColorTable couldn't find hash entry");
- }
- Tcl_DeleteHashEntry(entry);
-
- ckfree((char *) colorPtr);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ReclaimColors --
- *
- * This procedure is called to try to free up colors in the
- * colormap used by a color table. It looks for other color
- * tables with the same colormap and with a zero live reference
- * count, and frees their colors. It only does so if there is
- * the possibility of freeing up at least `numColors' colors.
- *
- * Results:
- * The return value is TRUE if any colors were freed, FALSE
- * otherwise.
- *
- * Side effects:
- * ColorTables which are not currently in use may lose their
- * color allocations.
- *
- *---------------------------------------------------------------------- */
-
-static int
-ReclaimColors(id, numColors)
- ColorTableId *id; /* Pointer to information identifying
- * the color table which needs more colors. */
- int numColors; /* Number of colors required. */
-{
- Tcl_HashSearch srch;
- Tcl_HashEntry *entry;
- ColorTable *colorPtr;
- int nAvail;
-
- /*
- * First scan through the color hash table to get an
- * upper bound on how many colors we might be able to free.
- */
-
- nAvail = 0;
- entry = Tcl_FirstHashEntry(&imgPhotoColorHash, &srch);
- while (entry != NULL) {
- colorPtr = (ColorTable *) Tcl_GetHashValue(entry);
- if ((colorPtr->id.display == id->display)
- && (colorPtr->id.colormap == id->colormap)
- && (colorPtr->liveRefCount == 0 )&& (colorPtr->numColors != 0)
- && ((colorPtr->id.palette != id->palette)
- || (colorPtr->id.gamma != id->gamma))) {
-
- /*
- * We could take this guy's colors off him.
- */
-
- nAvail += colorPtr->numColors;
- }
- entry = Tcl_NextHashEntry(&srch);
- }
-
- /*
- * nAvail is an (over)estimate of the number of colors we could free.
- */
-
- if (nAvail < numColors) {
- return 0;
- }
-
- /*
- * Scan through a second time freeing colors.
- */
-
- entry = Tcl_FirstHashEntry(&imgPhotoColorHash, &srch);
- while ((entry != NULL) && (numColors > 0)) {
- colorPtr = (ColorTable *) Tcl_GetHashValue(entry);
- if ((colorPtr->id.display == id->display)
- && (colorPtr->id.colormap == id->colormap)
- && (colorPtr->liveRefCount == 0) && (colorPtr->numColors != 0)
- && ((colorPtr->id.palette != id->palette)
- || (colorPtr->id.gamma != id->gamma))) {
-
- /*
- * Free the colors that this ColorTable has.
- */
-
- XFreeColors(colorPtr->id.display, colorPtr->id.colormap,
- colorPtr->pixelMap, colorPtr->numColors, 0);
- numColors -= colorPtr->numColors;
- colorPtr->numColors = 0;
- ckfree((char *) colorPtr->pixelMap);
- colorPtr->pixelMap = NULL;
- }
-
- entry = Tcl_NextHashEntry(&srch);
- }
- return 1; /* we freed some colors */
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * DisposeInstance --
- *
- * This procedure is called to finally free up an instance
- * of a photo image which is no longer required.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The instance data structure and the resources it references
- * are freed.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-DisposeInstance(clientData)
- ClientData clientData; /* Pointer to the instance whose resources
- * are to be released. */
-{
- PhotoInstance *instancePtr = (PhotoInstance *) clientData;
- PhotoInstance *prevPtr;
-
- if (instancePtr->pixels != None) {
- Tk_FreePixmap(instancePtr->display, instancePtr->pixels);
- }
- if (instancePtr->gc != None) {
- Tk_FreeGC(instancePtr->display, instancePtr->gc);
- }
- if (instancePtr->imagePtr != NULL) {
- XFree((char *) instancePtr->imagePtr);
- }
- if (instancePtr->error != NULL) {
- ckfree((char *) instancePtr->error);
- }
- if (instancePtr->colorTablePtr != NULL) {
- FreeColorTable(instancePtr->colorTablePtr);
- }
-
- if (instancePtr->masterPtr->instancePtr == instancePtr) {
- instancePtr->masterPtr->instancePtr = instancePtr->nextPtr;
- } else {
- for (prevPtr = instancePtr->masterPtr->instancePtr;
- prevPtr->nextPtr != instancePtr; prevPtr = prevPtr->nextPtr) {
- /* Empty loop body */
- }
- prevPtr->nextPtr = instancePtr->nextPtr;
- }
- Tk_FreeColormap(instancePtr->display, instancePtr->colormap);
- ckfree((char *) instancePtr);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * MatchFileFormat --
- *
- * This procedure is called to find a photo image file format
- * handler which can parse the image data in the given file.
- * If a user-specified format string is provided, only handlers
- * whose names match a prefix of the format string are tried.
- *
- * Results:
- * A standard TCL return value. If the return value is TCL_OK, a
- * pointer to the image format record is returned in
- * *imageFormatPtr, and the width and height of the image are
- * returned in *widthPtr and *heightPtr.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-MatchFileFormat(interp, chan, fileName, formatString, imageFormatPtr,
- widthPtr, heightPtr)
- Tcl_Interp *interp; /* Interpreter to use for reporting errors. */
- Tcl_Channel chan; /* The image file, open for reading. */
- char *fileName; /* The name of the image file. */
- char *formatString; /* User-specified format string, or NULL. */
- Tk_PhotoImageFormat **imageFormatPtr;
- /* A pointer to the photo image format
- * record is returned here. */
- int *widthPtr, *heightPtr; /* The dimensions of the image are
- * returned here. */
-{
- int matched;
- Tk_PhotoImageFormat *formatPtr;
-
- /*
- * Scan through the table of file format handlers to find
- * one which can handle the image.
- */
-
- matched = 0;
- for (formatPtr = formatList; 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, formatString,
- widthPtr, heightPtr)) {
- if (*widthPtr < 1) {
- *widthPtr = 1;
- }
- if (*heightPtr < 1) {
- *heightPtr = 1;
- }
- break;
- }
- }
- }
-
- if (formatPtr == NULL) {
- if ((formatString != NULL) && !matched) {
- Tcl_AppendResult(interp, "image file format \"", formatString,
- "\" is not supported", (char *) NULL);
- } else {
- Tcl_AppendResult(interp,
- "couldn't recognize data in image file \"",
- fileName, "\"", (char *) NULL);
- }
- return TCL_ERROR;
- }
-
- *imageFormatPtr = formatPtr;
- (void) Tcl_Seek(chan, 0L, SEEK_SET);
- return TCL_OK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * MatchStringFormat --
- *
- * This procedure is called to find a photo image file format
- * handler which can parse the image data in the given string.
- * If a user-specified format string is provided, only handlers
- * whose names match a prefix of the format string are tried.
- *
- * Results:
- * A standard TCL return value. If the return value is TCL_OK, a
- * pointer to the image format record is returned in
- * *imageFormatPtr, and the width and height of the image are
- * returned in *widthPtr and *heightPtr.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-MatchStringFormat(interp, string, formatString, imageFormatPtr,
- widthPtr, heightPtr)
- Tcl_Interp *interp; /* Interpreter to use for reporting errors. */
- char *string; /* String containing the image data. */
- char *formatString; /* User-specified format string, or NULL. */
- Tk_PhotoImageFormat **imageFormatPtr;
- /* A pointer to the photo image format
- * record is returned here. */
- int *widthPtr, *heightPtr; /* The dimensions of the image are
- * returned here. */
-{
- int matched;
- Tk_PhotoImageFormat *formatPtr;
-
- /*
- * Scan through the table of file format handlers to find
- * one which can handle the image.
- */
-
- matched = 0;
- for (formatPtr = formatList; formatPtr != NULL;
- formatPtr = formatPtr->nextPtr) {
- if (formatString != 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;
- }
- }
- if ((formatPtr->stringMatchProc != NULL)
- && (*formatPtr->stringMatchProc)(string, formatString,
- widthPtr, heightPtr)) {
- break;
- }
- }
-
- if (formatPtr == NULL) {
- if ((formatString != NULL) && !matched) {
- Tcl_AppendResult(interp, "image format \"", formatString,
- "\" is not supported", (char *) NULL);
- } else {
- Tcl_AppendResult(interp, "couldn't recognize image data",
- (char *) NULL);
- }
- return TCL_ERROR;
- }
-
- *imageFormatPtr = formatPtr;
- return TCL_OK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_FindPhoto --
- *
- * This procedure is called to get an opaque handle (actually a
- * PhotoMaster *) for a given image, which can be used in
- * subsequent calls to Tk_PhotoPutBlock, etc. The `name'
- * parameter is the name of the image.
- *
- * Results:
- * The handle for the photo image, or NULL if there is no
- * photo image with the name given.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-Tk_PhotoHandle
-Tk_FindPhoto(interp, imageName)
- Tcl_Interp *interp; /* Interpreter (application) in which image
- * exists. */
- char *imageName; /* Name of the desired photo image. */
-{
- ClientData clientData;
- Tk_ImageType *typePtr;
-
- clientData = Tk_GetImageMasterData(interp, imageName, &typePtr);
- if (typePtr != &tkPhotoImageType) {
- return NULL;
- }
- return (Tk_PhotoHandle) clientData;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_PhotoPutBlock --
- *
- * This procedure is called to put image data into a photo image.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The image data is stored. The image may be expanded.
- * The Tk image code is informed that the image has changed.
- *
- *---------------------------------------------------------------------- */
-
-void
-Tk_PhotoPutBlock(handle, blockPtr, x, y, width, height)
- Tk_PhotoHandle handle; /* Opaque handle for the photo image
- * to be updated. */
- register Tk_PhotoImageBlock *blockPtr;
- /* Pointer to a structure describing the
- * pixel data to be copied into the image. */
- int x, y; /* Coordinates of the top-left pixel to
- * be updated in the image. */
- int width, height; /* Dimensions of the area of the image
- * to be updated. */
-{
- register PhotoMaster *masterPtr;
- int xEnd, yEnd;
- int greenOffset, blueOffset;
- int wLeft, hLeft;
- int wCopy, hCopy;
- unsigned char *srcPtr, *srcLinePtr;
- unsigned char *destPtr, *destLinePtr;
- int pitch;
- XRectangle rect;
-
- masterPtr = (PhotoMaster *) handle;
-
- if ((masterPtr->userWidth != 0) && ((x + width) > masterPtr->userWidth)) {
- width = masterPtr->userWidth - x;
- }
- if ((masterPtr->userHeight != 0)
- && ((y + height) > masterPtr->userHeight)) {
- height = masterPtr->userHeight - y;
- }
- 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 ((y < masterPtr->ditherY) || ((y == masterPtr->ditherY)
- && (x < masterPtr->ditherX))) {
- /*
- * The dithering isn't correct past the start of this block.
- */
- masterPtr->ditherX = x;
- masterPtr->ditherY = y;
- }
-
- /*
- * If this image block could have different red, green and blue
- * components, mark it as a color image.
- */
-
- greenOffset = blockPtr->offset[1] - blockPtr->offset[0];
- blueOffset = blockPtr->offset[2] - blockPtr->offset[0];
- if ((greenOffset != 0) || (blueOffset != 0)) {
- masterPtr->flags |= COLOR_IMAGE;
- }
-
- /*
- * Copy the data into our local 24-bit/pixel array.
- * If we can do it with a single memcpy, we do.
- */
-
- destLinePtr = masterPtr->pix24 + (y * masterPtr->width + x) * 3;
- pitch = masterPtr->width * 3;
-
- if ((blockPtr->pixelSize == 3) && (greenOffset == 1) && (blueOffset == 2)
- && (width <= blockPtr->width) && (height <= blockPtr->height)
- && ((height == 1) || ((x == 0) && (width == masterPtr->width)
- && (blockPtr->pitch == pitch)))) {
- memcpy((VOID *) destLinePtr,
- (VOID *) (blockPtr->pixelPtr + blockPtr->offset[0]),
- (size_t) (height * width * 3));
- } else {
- 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) {
- *destPtr++ = srcPtr[0];
- *destPtr++ = srcPtr[greenOffset];
- *destPtr++ = srcPtr[blueOffset];
- srcPtr += blockPtr->pixelSize;
- }
- }
- srcLinePtr += blockPtr->pitch;
- destLinePtr += pitch;
- }
- }
- }
-
- /*
- * Add this new block to the region which specifies which data is valid.
- */
-
- rect.x = x;
- rect.y = y;
- rect.width = width;
- rect.height = height;
- TkUnionRectWithRegion(&rect, masterPtr->validRegion,
- masterPtr->validRegion);
-
- /*
- * Update each instance.
- */
-
- Dither(masterPtr, x, y, width, height);
-
- /*
- * Tell the core image code that this image has changed.
- */
-
- Tk_ImageChanged(masterPtr->tkMaster, x, y, width, height, masterPtr->width,
- masterPtr->height);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_PhotoPutZoomedBlock --
- *
- * This procedure is called to put image data into a photo image,
- * with possible subsampling and/or zooming of the pixels.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The image data is stored. The image may be expanded.
- * The Tk image code is informed that the image has changed.
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tk_PhotoPutZoomedBlock(handle, blockPtr, x, y, width, height, zoomX, zoomY,
- subsampleX, subsampleY)
- Tk_PhotoHandle handle; /* Opaque handle for the photo image
- * to be updated. */
- register Tk_PhotoImageBlock *blockPtr;
- /* Pointer to a structure describing the
- * pixel data to be copied into the image. */
- int x, y; /* Coordinates of the top-left pixel to
- * be updated in the image. */
- int width, height; /* Dimensions of the area of the image
- * 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. */
-{
- register PhotoMaster *masterPtr;
- int xEnd, yEnd;
- int greenOffset, blueOffset;
- int wLeft, hLeft;
- int wCopy, hCopy;
- int blockWid, blockHt;
- unsigned char *srcPtr, *srcLinePtr, *srcOrigPtr;
- unsigned char *destPtr, *destLinePtr;
- int pitch;
- int xRepeat, yRepeat;
- int blockXSkip, blockYSkip;
- XRectangle rect;
-
- if ((zoomX == 1) && (zoomY == 1) && (subsampleX == 1)
- && (subsampleY == 1)) {
- Tk_PhotoPutBlock(handle, blockPtr, x, y, width, height);
- return;
- }
-
- masterPtr = (PhotoMaster *) handle;
-
- if ((zoomX <= 0) || (zoomY <= 0))
- return;
- if ((masterPtr->userWidth != 0) && ((x + width) > masterPtr->userWidth)) {
- width = masterPtr->userWidth - x;
- }
- if ((masterPtr->userHeight != 0)
- && ((y + height) > masterPtr->userHeight)) {
- height = masterPtr->userHeight - y;
- }
- 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 (sameSrc) {
- blockPtr->pixelPtr = masterPtr->pix24;
- }
- }
-
- if ((y < masterPtr->ditherY) || ((y == masterPtr->ditherY)
- && (x < masterPtr->ditherX))) {
- /*
- * The dithering isn't correct past the start of this block.
- */
-
- masterPtr->ditherX = x;
- masterPtr->ditherY = y;
- }
-
- /*
- * If this image block could have different red, green and blue
- * components, mark it as a color image.
- */
-
- greenOffset = blockPtr->offset[1] - blockPtr->offset[0];
- blueOffset = blockPtr->offset[2] - blockPtr->offset[0];
- if ((greenOffset != 0) || (blueOffset != 0)) {
- masterPtr->flags |= COLOR_IMAGE;
- }
-
- /*
- * Work out what area the pixel data in the block expands to after
- * subsampling and zooming.
- */
-
- blockXSkip = subsampleX * blockPtr->pixelSize;
- blockYSkip = subsampleY * blockPtr->pitch;
- if (subsampleX > 0)
- blockWid = ((blockPtr->width + subsampleX - 1) / subsampleX) * zoomX;
- else if (subsampleX == 0)
- blockWid = width;
- else
- blockWid = ((blockPtr->width - subsampleX - 1) / -subsampleX) * zoomX;
- if (subsampleY > 0)
- blockHt = ((blockPtr->height + subsampleY - 1) / subsampleY) * zoomY;
- else if (subsampleY == 0)
- blockHt = height;
- else
- blockHt = ((blockPtr->height - subsampleY - 1) / -subsampleY) * zoomY;
-
- /*
- * Copy the data into our local 24-bit/pixel array.
- */
-
- destLinePtr = masterPtr->pix24 + (y * masterPtr->width + x) * 3;
- srcOrigPtr = blockPtr->pixelPtr + blockPtr->offset[0];
- if (subsampleX < 0) {
- srcOrigPtr += (blockPtr->width - 1) * blockPtr->pixelSize;
- }
- if (subsampleY < 0) {
- srcOrigPtr += (blockPtr->height - 1) * blockPtr->pitch;
- }
-
- pitch = masterPtr->width * 3;
- for (hLeft = height; hLeft > 0; ) {
- hCopy = MIN(hLeft, blockHt);
- hLeft -= hCopy;
- yRepeat = zoomY;
- srcLinePtr = srcOrigPtr;
- for (; hCopy > 0; --hCopy) {
- destPtr = destLinePtr;
- for (wLeft = width; wLeft > 0;) {
- wCopy = MIN(wLeft, blockWid);
- wLeft -= wCopy;
- srcPtr = srcLinePtr;
- for (; wCopy > 0; wCopy -= zoomX) {
- for (xRepeat = MIN(wCopy, zoomX); xRepeat > 0; xRepeat--) {
- *destPtr++ = srcPtr[0];
- *destPtr++ = srcPtr[greenOffset];
- *destPtr++ = srcPtr[blueOffset];
- }
- srcPtr += blockXSkip;
- }
- }
- destLinePtr += pitch;
- yRepeat--;
- if (yRepeat <= 0) {
- srcLinePtr += blockYSkip;
- yRepeat = zoomY;
- }
- }
- }
-
- /*
- * Add this new block to the region that specifies which data is valid.
- */
-
- rect.x = x;
- rect.y = y;
- rect.width = width;
- rect.height = height;
- TkUnionRectWithRegion(&rect, masterPtr->validRegion,
- masterPtr->validRegion);
-
- /*
- * Update each instance.
- */
-
- Dither(masterPtr, x, y, width, height);
-
- /*
- * Tell the core image code that this image has changed.
- */
-
- Tk_ImageChanged(masterPtr->tkMaster, x, y, width, height, masterPtr->width,
- masterPtr->height);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Dither --
- *
- * This procedure is called to update an area of each instance's
- * pixmap by dithering the corresponding area of the image master.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The pixmap of each instance of this image gets updated.
- * The fields in *masterPtr indicating which area of the image
- * is correctly dithered get updated.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-Dither(masterPtr, x, y, width, height)
- PhotoMaster *masterPtr; /* Image master whose instances are
- * to be updated. */
- int x, y; /* Coordinates of the top-left pixel
- * in the area to be dithered. */
- int width, height; /* Dimensions of the area to be dithered. */
-{
- PhotoInstance *instancePtr;
-
- if ((width <= 0) || (height <= 0)) {
- return;
- }
-
- for (instancePtr = masterPtr->instancePtr; instancePtr != NULL;
- instancePtr = instancePtr->nextPtr) {
- DitherInstance(instancePtr, x, y, width, height);
- }
-
- /*
- * Work out whether this block will be correctly dithered
- * and whether it will extend the correctly dithered region.
- */
-
- if (((y < masterPtr->ditherY)
- || ((y == masterPtr->ditherY) && (x <= masterPtr->ditherX)))
- && ((y + height) > (masterPtr->ditherY))) {
-
- /*
- * This block starts inside (or immediately after) the correctly
- * dithered region, so the first scan line at least will be right.
- * Furthermore this block extends into scanline masterPtr->ditherY.
- */
-
- if ((x == 0) && (width == masterPtr->width)) {
- /*
- * We are doing the full width, therefore the dithering
- * will be correct to the end.
- */
-
- masterPtr->ditherX = 0;
- masterPtr->ditherY = y + height;
- } else {
- /*
- * We are doing partial scanlines, therefore the
- * correctly-dithered region will be extended by
- * at most one scan line.
- */
-
- if (x <= masterPtr->ditherX) {
- masterPtr->ditherX = x + width;
- if (masterPtr->ditherX >= masterPtr->width) {
- masterPtr->ditherX = 0;
- masterPtr->ditherY++;
- }
- }
- }
- }
-
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * DitherInstance --
- *
- * This procedure is called to update an area of an instance's
- * pixmap by dithering the corresponding area of the master.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The instance's pixmap gets updated.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-DitherInstance(instancePtr, xStart, yStart, width, height)
- PhotoInstance *instancePtr; /* The instance to be updated. */
- int xStart, yStart; /* Coordinates of the top-left pixel in the
- * block to be dithered. */
- int width, height; /* Dimensions of the block to be dithered. */
-{
- PhotoMaster *masterPtr;
- ColorTable *colorPtr;
- XImage *imagePtr;
- int nLines, bigEndian;
- int i, c, x, y;
- int xEnd, yEnd;
- int bitsPerPixel, bytesPerLine, lineLength;
- unsigned char *srcLinePtr, *srcPtr;
- schar *errLinePtr, *errPtr;
- unsigned char *destBytePtr, *dstLinePtr;
- pixel *destLongPtr;
- pixel firstBit, word, mask;
- int col[3];
- int doDithering = 1;
-
- colorPtr = instancePtr->colorTablePtr;
- masterPtr = instancePtr->masterPtr;
-
- /*
- * Turn dithering off in certain cases where it is not
- * needed (TrueColor, DirectColor with many colors).
- */
-
- if ((colorPtr->visualInfo.class == DirectColor)
- || (colorPtr->visualInfo.class == TrueColor)) {
- int nRed, nGreen, nBlue, result;
-
- result = sscanf(colorPtr->id.palette, "%d/%d/%d", &nRed,
- &nGreen, &nBlue);
- if ((nRed >= 256)
- && ((result == 1) || ((nGreen >= 256) && (nBlue >= 256)))) {
- doDithering = 0;
- }
- }
-
- /*
- * First work out how many lines to do at a time,
- * then how many bytes we'll need for pixel storage,
- * and allocate it.
- */
-
- nLines = (MAX_PIXELS + width - 1) / width;
- if (nLines < 1) {
- nLines = 1;
- }
- if (nLines > height ) {
- nLines = height;
- }
-
- imagePtr = instancePtr->imagePtr;
- if (imagePtr == NULL) {
- return; /* we must be really tight on memory */
- }
- bitsPerPixel = imagePtr->bits_per_pixel;
- bytesPerLine = ((bitsPerPixel * width + 31) >> 3) & ~3;
- imagePtr->width = width;
- imagePtr->height = nLines;
- imagePtr->bytes_per_line = bytesPerLine;
- imagePtr->data = (char *) ckalloc((unsigned) (imagePtr->bytes_per_line * nLines));
- bigEndian = imagePtr->bitmap_bit_order == MSBFirst;
- firstBit = bigEndian? (1 << (imagePtr->bitmap_unit - 1)): 1;
-
- lineLength = masterPtr->width * 3;
- srcLinePtr = masterPtr->pix24 + yStart * lineLength + xStart * 3;
- errLinePtr = instancePtr->error + yStart * lineLength + xStart * 3;
- xEnd = xStart + width;
-
- /*
- * Loop over the image, doing at most nLines lines before
- * updating the screen image.
- */
-
- for (; height > 0; height -= nLines) {
- if (nLines > height) {
- nLines = height;
- }
- dstLinePtr = (unsigned char *) imagePtr->data;
- yEnd = yStart + nLines;
- for (y = yStart; y < yEnd; ++y) {
- srcPtr = srcLinePtr;
- errPtr = errLinePtr;
- destBytePtr = dstLinePtr;
- destLongPtr = (pixel *) dstLinePtr;
- if (colorPtr->flags & COLOR_WINDOW) {
- /*
- * Color window. We dither the three components
- * independently, using Floyd-Steinberg dithering,
- * which propagates errors from the quantization of
- * pixels to the pixels below and to the right.
- */
-
- for (x = xStart; x < xEnd; ++x) {
- if (doDithering) {
- for (i = 0; i < 3; ++i) {
- /*
- * Compute the error propagated into this pixel
- * for this component.
- * If e[x,y] is the array of quantization error
- * values, we compute
- * 7/16 * e[x-1,y] + 1/16 * e[x-1,y-1]
- * + 5/16 * e[x,y-1] + 3/16 * e[x+1,y-1]
- * and round it to an integer.
- *
- * The expression ((c + 2056) >> 4) - 128
- * computes round(c / 16), and works correctly on
- * machines without a sign-extending right shift.
- */
-
- c = (x > 0) ? errPtr[-3] * 7: 0;
- if (y > 0) {
- if (x > 0) {
- c += errPtr[-lineLength-3];
- }
- c += errPtr[-lineLength] * 5;
- if ((x + 1) < masterPtr->width) {
- c += errPtr[-lineLength+3] * 3;
- }
- }
-
- /*
- * Add the propagated error to the value of this
- * component, quantize it, and store the
- * quantization error.
- */
-
- c = ((c + 2056) >> 4) - 128 + *srcPtr++;
- if (c < 0) {
- c = 0;
- } else if (c > 255) {
- c = 255;
- }
- col[i] = colorPtr->colorQuant[i][c];
- *errPtr++ = c - col[i];
- }
- } else {
- /*
- * Output is virtually continuous in this case,
- * so don't bother dithering.
- */
-
- col[0] = *srcPtr++;
- col[1] = *srcPtr++;
- col[2] = *srcPtr++;
- }
-
- /*
- * Translate the quantized component values into
- * an X pixel value, and store it in the image.
- */
-
- i = colorPtr->redValues[col[0]]
- + colorPtr->greenValues[col[1]]
- + colorPtr->blueValues[col[2]];
- if (colorPtr->flags & MAP_COLORS) {
- i = colorPtr->pixelMap[i];
- }
- switch (bitsPerPixel) {
- case NBBY:
- *destBytePtr++ = i;
- break;
-#ifndef __WIN32__
-/*
- * This case is not valid for Windows because the image format is different
- * from the pixel format in Win32. Eventually we need to fix the image
- * code in Tk to use the Windows native image ordering. This would speed
- * up the image code for all of the common sizes.
- */
-
- case NBBY * sizeof(pixel):
- *destLongPtr++ = i;
- break;
-#endif
- default:
- XPutPixel(imagePtr, x - xStart, y - yStart,
- (unsigned) i);
- }
- }
-
- } else if (bitsPerPixel > 1) {
- /*
- * Multibit monochrome window. The operation here is similar
- * to the color window case above, except that there is only
- * one component. If the master image is in color, use the
- * luminance computed as
- * 0.344 * red + 0.5 * green + 0.156 * blue.
- */
-
- for (x = xStart; x < xEnd; ++x) {
- c = (x > 0) ? errPtr[-1] * 7: 0;
- if (y > 0) {
- if (x > 0) {
- c += errPtr[-lineLength-1];
- }
- c += errPtr[-lineLength] * 5;
- if (x + 1 < masterPtr->width) {
- c += errPtr[-lineLength+1] * 3;
- }
- }
- c = ((c + 2056) >> 4) - 128;
-
- if ((masterPtr->flags & COLOR_IMAGE) == 0) {
- c += srcPtr[0];
- } else {
- c += (unsigned)(srcPtr[0] * 11 + srcPtr[1] * 16
- + srcPtr[2] * 5 + 16) >> 5;
- }
- srcPtr += 3;
-
- if (c < 0) {
- c = 0;
- } else if (c > 255) {
- c = 255;
- }
- i = colorPtr->colorQuant[0][c];
- *errPtr++ = c - i;
- i = colorPtr->redValues[i];
- switch (bitsPerPixel) {
- case NBBY:
- *destBytePtr++ = i;
- break;
-#ifndef __WIN32__
-/*
- * This case is not valid for Windows because the image format is different
- * from the pixel format in Win32. Eventually we need to fix the image
- * code in Tk to use the Windows native image ordering. This would speed
- * up the image code for all of the common sizes.
- */
-
- case NBBY * sizeof(pixel):
- *destLongPtr++ = i;
- break;
-#endif
- default:
- XPutPixel(imagePtr, x - xStart, y - yStart,
- (unsigned) i);
- }
- }
- } else {
- /*
- * 1-bit monochrome window. This is similar to the
- * multibit monochrome case above, except that the
- * quantization is simpler (we only have black = 0
- * and white = 255), and we produce an XY-Bitmap.
- */
-
- word = 0;
- mask = firstBit;
- for (x = xStart; x < xEnd; ++x) {
- /*
- * If we have accumulated a whole word, store it
- * in the image and start a new word.
- */
-
- if (mask == 0) {
- *destLongPtr++ = word;
- mask = firstBit;
- word = 0;
- }
-
- c = (x > 0) ? errPtr[-1] * 7: 0;
- if (y > 0) {
- if (x > 0) {
- c += errPtr[-lineLength-1];
- }
- c += errPtr[-lineLength] * 5;
- if (x + 1 < masterPtr->width) {
- c += errPtr[-lineLength+1] * 3;
- }
- }
- c = ((c + 2056) >> 4) - 128;
-
- if ((masterPtr->flags & COLOR_IMAGE) == 0) {
- c += srcPtr[0];
- } else {
- c += (unsigned)(srcPtr[0] * 11 + srcPtr[1] * 16
- + srcPtr[2] * 5 + 16) >> 5;
- }
- srcPtr += 3;
-
- if (c < 0) {
- c = 0;
- } else if (c > 255) {
- c = 255;
- }
- if (c >= 128) {
- word |= mask;
- *errPtr++ = c - 255;
- } else {
- *errPtr++ = c;
- }
- mask = bigEndian? (mask >> 1): (mask << 1);
- }
- *destLongPtr = word;
- }
- srcLinePtr += lineLength;
- errLinePtr += lineLength;
- dstLinePtr += bytesPerLine;
- }
-
- /*
- * Update the pixmap for this instance with the block of
- * pixels that we have just computed.
- */
-
- TkPutImage(colorPtr->pixelMap, colorPtr->numColors,
- instancePtr->display, instancePtr->pixels,
- instancePtr->gc, imagePtr, 0, 0, xStart, yStart,
- (unsigned) width, (unsigned) nLines);
- yStart = yEnd;
-
- }
-
- ckfree(imagePtr->data);
- imagePtr->data = NULL;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_PhotoBlank --
- *
- * This procedure is called to clear an entire photo image.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The valid region for the image is set to the null region.
- * The generic image code is notified that the image has changed.
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tk_PhotoBlank(handle)
- Tk_PhotoHandle handle; /* Handle for the image to be blanked. */
-{
- PhotoMaster *masterPtr;
- PhotoInstance *instancePtr;
-
- masterPtr = (PhotoMaster *) handle;
- masterPtr->ditherX = masterPtr->ditherY = 0;
- masterPtr->flags = 0;
-
- /*
- * The image has valid data nowhere.
- */
-
- if (masterPtr->validRegion != NULL) {
- TkDestroyRegion(masterPtr->validRegion);
- }
- masterPtr->validRegion = TkCreateRegion();
-
- /*
- * Clear out the 24-bit pixel storage array.
- * Clear out the dithering error arrays for each instance.
- */
-
- memset((VOID *) masterPtr->pix24, 0,
- (size_t) (masterPtr->width * masterPtr->height * 3));
- for (instancePtr = masterPtr->instancePtr; instancePtr != NULL;
- instancePtr = instancePtr->nextPtr) {
- if (instancePtr->error) {
- memset((VOID *) instancePtr->error, 0,
- (size_t) (masterPtr->width * masterPtr->height
- * 3 * sizeof(schar)));
- }
- }
-
- /*
- * Tell the core image code that this image has changed.
- */
-
- Tk_ImageChanged(masterPtr->tkMaster, 0, 0, masterPtr->width,
- masterPtr->height, masterPtr->width, masterPtr->height);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_PhotoExpand --
- *
- * This procedure is called to request that a photo image be
- * expanded if necessary to be at least `width' pixels wide and
- * `height' pixels high. If the user has declared a definite
- * image size (using the -width and -height configuration
- * options) then this call has no effect.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The size of the photo image may change; if so the generic
- * image code is informed.
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tk_PhotoExpand(handle, width, height)
- Tk_PhotoHandle handle; /* Handle for the image to be expanded. */
- int width, height; /* Desired minimum dimensions of the image. */
-{
- PhotoMaster *masterPtr;
-
- masterPtr = (PhotoMaster *) handle;
-
- if (width <= masterPtr->width) {
- width = masterPtr->width;
- }
- if (height <= masterPtr->height) {
- height = masterPtr->height;
- }
- if ((width != masterPtr->width) || (height != masterPtr->height)) {
- ImgPhotoSetSize(masterPtr, MAX(width, masterPtr->width),
- MAX(height, masterPtr->height));
- Tk_ImageChanged(masterPtr->tkMaster, 0, 0, 0, 0, masterPtr->width,
- masterPtr->height);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_PhotoGetSize --
- *
- * This procedure is called to obtain the current size of a photo
- * image.
- *
- * Results:
- * The image's width and height are returned in *widthp
- * and *heightp.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tk_PhotoGetSize(handle, widthPtr, heightPtr)
- Tk_PhotoHandle handle; /* Handle for the image whose dimensions
- * are requested. */
- int *widthPtr, *heightPtr; /* The dimensions of the image are returned
- * here. */
-{
- PhotoMaster *masterPtr;
-
- masterPtr = (PhotoMaster *) handle;
- *widthPtr = masterPtr->width;
- *heightPtr = masterPtr->height;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_PhotoSetSize --
- *
- * This procedure is called to set size of a photo image.
- * This call is equivalent to using the -width and -height
- * configuration options.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The size of the image may change; if so the generic
- * image code is informed.
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tk_PhotoSetSize(handle, width, height)
- Tk_PhotoHandle handle; /* Handle for the image whose size is to
- * be set. */
- int width, height; /* New dimensions for the image. */
-{
- PhotoMaster *masterPtr;
-
- masterPtr = (PhotoMaster *) handle;
-
- masterPtr->userWidth = width;
- masterPtr->userHeight = height;
- ImgPhotoSetSize(masterPtr, ((width > 0) ? width: masterPtr->width),
- ((height > 0) ? height: masterPtr->height));
- Tk_ImageChanged(masterPtr->tkMaster, 0, 0, 0, 0,
- masterPtr->width, masterPtr->height);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_PhotoGetImage --
- *
- * This procedure is called to obtain image data from a photo
- * image. This procedure fills in the Tk_PhotoImageBlock structure
- * pointed to by `blockPtr' with details of the address and
- * layout of the image data in memory.
- *
- * Results:
- * TRUE (1) indicating that image data is available,
- * for backwards compatibility with the old photo widget.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-int
-Tk_PhotoGetImage(handle, blockPtr)
- Tk_PhotoHandle handle; /* Handle for the photo image from which
- * image data is desired. */
- Tk_PhotoImageBlock *blockPtr;
- /* Information about the address and layout
- * of the image data is returned here. */
-{
- PhotoMaster *masterPtr;
-
- masterPtr = (PhotoMaster *) handle;
- blockPtr->pixelPtr = masterPtr->pix24;
- blockPtr->width = masterPtr->width;
- blockPtr->height = masterPtr->height;
- blockPtr->pitch = masterPtr->width * 3;
- blockPtr->pixelSize = 3;
- blockPtr->offset[0] = 0;
- blockPtr->offset[1] = 1;
- blockPtr->offset[2] = 2;
- return 1;
-}
diff --git a/generic/tkImgUtil.c b/generic/tkImgUtil.c
deleted file mode 100644
index 00c8b7d..0000000
--- a/generic/tkImgUtil.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * tkImgUtil.c --
- *
- * This file contains image related utility functions.
- *
- * Copyright (c) 1995 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: tkImgUtil.c,v 1.2 1998/09/14 18:23:13 stanton Exp $
- */
-
-#include "tkInt.h"
-#include "tkPort.h"
-#include "xbytes.h"
-
-
-/*
- *----------------------------------------------------------------------
- *
- * TkAlignImageData --
- *
- * This function takes an image and copies the data into an
- * aligned buffer, performing any necessary bit swapping.
- *
- * Results:
- * Returns a newly allocated buffer that should be freed by the
- * caller.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-char *
-TkAlignImageData(image, alignment, bitOrder)
- XImage *image; /* Image to be aligned. */
- int alignment; /* Number of bytes to which the data should
- * be aligned (e.g. 2 or 4) */
- int bitOrder; /* Desired bit order: LSBFirst or MSBFirst. */
-{
- long dataWidth;
- char *data, *srcPtr, *destPtr;
- int i, j;
-
- if (image->bits_per_pixel != 1) {
- panic("TkAlignImageData: Can't handle image depths greater than 1.");
- }
-
- /*
- * Compute line width for output data buffer.
- */
-
- dataWidth = image->bytes_per_line;
- if (dataWidth % alignment) {
- dataWidth += (alignment - (dataWidth % alignment));
- }
-
- data = ckalloc(dataWidth * image->height);
-
- destPtr = data;
- for (i = 0; i < image->height; i++) {
- srcPtr = &image->data[i * image->bytes_per_line];
- for (j = 0; j < dataWidth; j++) {
- if (j >= image->bytes_per_line) {
- *destPtr = 0;
- } else if (image->bitmap_bit_order != bitOrder) {
- *destPtr = xBitReverseTable[(unsigned char)(*(srcPtr++))];
- } else {
- *destPtr = *(srcPtr++);
- }
- destPtr++;
- }
- }
- return data;
-}
diff --git a/generic/tkInitScript.h b/generic/tkInitScript.h
deleted file mode 100644
index a478fd0..0000000
--- a/generic/tkInitScript.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * tkInitScript.h --
- *
- * This file contains Unix & Windows common init script
- * It is not used on the Mac. (the mac init script is in tkMacInit.c)
- *
- * Copyright (c) 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: tkInitScript.h,v 1.7 1998/09/14 18:23:13 stanton Exp $
- */
-
-/*
- * In order to find tk.tcl during initialization, the following script
- * is invoked by Tk_Init(). It looks in several different directories:
- *
- * $tk_library - can specify a primary location, if set
- * no other locations will be checked
- *
- * $env(TK_LIBRARY) - highest priority so user can always override
- * the search path unless the application has
- * specified an exact directory above
- *
- * $tcl_library/../tk$tk_version
- * - look relative to init.tcl in an installed
- * lib directory (e.g. /usr/local)
- *
- * <executable directory>/../lib/tk$tk_version
- * - look for a lib/tk<ver> in a sibling of
- * the bin directory (e.g. /usr/local)
- *
- * <executable directory>/../library
- * - look in Tk build directory
- *
- * <executable directory>/../../tk$tk_patchLevel/library
- * - look for Tk build directory relative
- * to a parallel build directory
- *
- * The first directory on this path that contains a valid tk.tcl script
- * will be set ast the value of tk_library.
- *
- * Note that this entire search mechanism can be bypassed by defining an
- * alternate tkInit procedure before calling Tk_Init().
- */
-
-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\
-}\n\
-tkInit";
-
diff --git a/generic/tkInt.h b/generic/tkInt.h
deleted file mode 100644
index d07155f..0000000
--- a/generic/tkInt.h
+++ /dev/null
@@ -1,1008 +0,0 @@
-/*
- * tkInt.h --
- *
- * Declarations for things used internally by the Tk
- * procedures but not exported outside the module.
- *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
- * Copyright (c) 1998 by Scriptics Corporation.
- *
- * See the file "license.terms" for information on usage and redistribution
- * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
- *
- * RCS: $Id: tkInt.h,v 1.7 1998/09/14 18:23:13 stanton Exp $
- */
-
-#ifndef _TKINT
-#define _TKINT
-
-#ifndef _TK
-#include "tk.h"
-#endif
-#ifndef _TCL
-#include "tcl.h"
-#endif
-#ifndef _TKPORT
-#include <tkPort.h>
-#endif
-
-#ifdef BUILD_tk
-# undef TCL_STORAGE_CLASS
-# define TCL_STORAGE_CLASS DLLEXPORT
-#endif
-
-/*
- * Opaque type declarations:
- */
-
-typedef struct TkColormap TkColormap;
-typedef struct TkGrabEvent TkGrabEvent;
-typedef struct Tk_PostscriptInfo Tk_PostscriptInfo;
-typedef struct TkpCursor_ *TkpCursor;
-typedef struct TkRegion_ *TkRegion;
-typedef struct TkStressedCmap TkStressedCmap;
-typedef struct TkBindInfo_ *TkBindInfo;
-
-/*
- * Procedure types.
- */
-
-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
- * use in the system. This structure is used by tkCursor.c and the
- * various system specific cursor files.
- */
-
-typedef struct TkCursor {
- Tk_Cursor cursor; /* System specific identifier for cursor. */
- int refCount; /* Number of active uses of cursor. */
- Tcl_HashTable *otherTable; /* Second table (other than idTable) used
- * to index this entry. */
- Tcl_HashEntry *hashPtr; /* Entry in otherTable for this structure
- * (needed when deleting). */
-} TkCursor;
-
-/*
- * One of the following structures is maintained for each display
- * containing a window managed by Tk:
- */
-
-typedef struct TkDisplay {
- Display *display; /* Xlib's info about display. */
- struct TkDisplay *nextPtr; /* Next in list of all displays. */
- char *name; /* Name of display (with any screen
- * identifier removed). Malloc-ed. */
- Time lastEventTime; /* Time of last event received for this
- * display. */
-
- /*
- * Information used primarily by tkBind.c:
- */
-
- int bindInfoStale; /* Non-zero means the variables in this
- * part of the structure are potentially
- * incorrect and should be recomputed. */
- unsigned int modeModMask; /* Has one bit set to indicate the modifier
- * corresponding to "mode shift". If no
- * such modifier, than this is zero. */
- unsigned int metaModMask; /* Has one bit set to indicate the modifier
- * corresponding to the "Meta" key. If no
- * such modifier, then this is zero. */
- unsigned int altModMask; /* Has one bit set to indicate the modifier
- * corresponding to the "Meta" key. If no
- * such modifier, then this is zero. */
- enum {LU_IGNORE, LU_CAPS, LU_SHIFT} lockUsage;
- /* Indicates how to interpret lock modifier. */
- int numModKeyCodes; /* Number of entries in modKeyCodes array
- * below. */
- KeyCode *modKeyCodes; /* Pointer to an array giving keycodes for
- * all of the keys that have modifiers
- * associated with them. Malloc'ed, but
- * may be NULL. */
-
- /*
- * Information used by tkError.c only:
- */
-
- struct TkErrorHandler *errorPtr;
- /* First in list of error handlers
- * for this display. NULL means
- * no handlers exist at present. */
- int deleteCount; /* Counts # of handlers deleted since
- * last time inactive handlers were
- * garbage-collected. When this number
- * gets big, handlers get cleaned up. */
-
- /*
- * Information used by tkSend.c only:
- */
-
- Tk_Window commTkwin; /* Window used for communication
- * between interpreters during "send"
- * commands. NULL means send info hasn't
- * been initialized yet. */
- Atom commProperty; /* X's name for comm property. */
- Atom registryProperty; /* X's name for property containing
- * registry of interpreter names. */
- Atom appNameProperty; /* X's name for property used to hold the
- * application name on each comm window. */
-
- /*
- * Information used by tkSelect.c and tkClipboard.c only:
- */
-
- struct TkSelectionInfo *selectionInfoPtr;
- /* First in list of selection information
- * records. Each entry contains information
- * about the current owner of a particular
- * selection on this display. */
- Atom multipleAtom; /* Atom for MULTIPLE. None means
- * selection stuff isn't initialized. */
- Atom incrAtom; /* Atom for INCR. */
- Atom targetsAtom; /* Atom for TARGETS. */
- Atom timestampAtom; /* Atom for TIMESTAMP. */
- Atom textAtom; /* Atom for TEXT. */
- Atom compoundTextAtom; /* Atom for COMPOUND_TEXT. */
- Atom applicationAtom; /* Atom for TK_APPLICATION. */
- Atom windowAtom; /* Atom for TK_WINDOW. */
- Atom clipboardAtom; /* Atom for CLIPBOARD. */
-
- Tk_Window clipWindow; /* Window used for clipboard ownership and to
- * retrieve selections between processes. NULL
- * means clipboard info hasn't been
- * initialized. */
- int clipboardActive; /* 1 means we currently own the clipboard
- * selection, 0 means we don't. */
- struct TkMainInfo *clipboardAppPtr;
- /* Last application that owned clipboard. */
- struct TkClipboardTarget *clipTargetPtr;
- /* First in list of clipboard type information
- * records. Each entry contains information
- * about the buffers for a given selection
- * target. */
-
- /*
- * Information used by tkAtom.c only:
- */
-
- int atomInit; /* 0 means stuff below hasn't been
- * initialized yet. */
- Tcl_HashTable nameTable; /* Maps from names to Atom's. */
- Tcl_HashTable atomTable; /* Maps from Atom's back to names. */
-
- /*
- * Information used by tkCursor.c only:
- */
-
- Font cursorFont; /* Font to use for standard cursors.
- * None means font not loaded yet. */
-
- /*
- * Information used by tkGrab.c only:
- */
-
- struct TkWindow *grabWinPtr;
- /* Window in which the pointer is currently
- * grabbed, or NULL if none. */
- struct TkWindow *eventualGrabWinPtr;
- /* Value that grabWinPtr will have once the
- * grab event queue (below) has been
- * completely emptied. */
- struct TkWindow *buttonWinPtr;
- /* Window in which first mouse button was
- * pressed while grab was in effect, or NULL
- * if no such press in effect. */
- struct TkWindow *serverWinPtr;
- /* If no application contains the pointer then
- * this is NULL. Otherwise it contains the
- * last window for which we've gotten an
- * Enter or Leave event from the server (i.e.
- * the last window known to have contained
- * the pointer). Doesn't reflect events
- * that were synthesized in tkGrab.c. */
- TkGrabEvent *firstGrabEventPtr;
- /* First in list of enter/leave events
- * synthesized by grab code. These events
- * must be processed in order before any other
- * events are processed. NULL means no such
- * events. */
- TkGrabEvent *lastGrabEventPtr;
- /* Last in list of synthesized events, or NULL
- * if list is empty. */
- int grabFlags; /* Miscellaneous flag values. See definitions
- * in tkGrab.c. */
-
- /*
- * Information used by tkXId.c only:
- */
-
- struct TkIdStack *idStackPtr;
- /* First in list of chunks of free resource
- * identifiers, or NULL if there are no free
- * resources. */
- XID (*defaultAllocProc) _ANSI_ARGS_((Display *display));
- /* Default resource allocator for display. */
- struct TkIdStack *windowStackPtr;
- /* 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
- * hasn't. */
-
- /*
- * Information maintained by tkWindow.c for use later on by tkXId.c:
- */
-
-
- int destroyCount; /* Number of Tk_DestroyWindow operations
- * in progress. */
- unsigned long lastDestroyRequest;
- /* Id of most recent XDestroyWindow request;
- * can re-use ids in windowStackPtr when
- * server has seen this request and event
- * queue is empty. */
-
- /*
- * Information used by tkVisual.c only:
- */
-
- TkColormap *cmapPtr; /* First in list of all non-default colormaps
- * allocated for this display. */
-
- /*
- * Information used by tkFocus.c only:
- */
-
- struct TkWindow *implicitWinPtr;
- /* If the focus arrived at a toplevel window
- * implicitly via an Enter event (rather
- * than via a FocusIn event), this points
- * to the toplevel window. Otherwise it is
- * NULL. */
- struct TkWindow *focusPtr; /* Points to the window on this display that
- * should be receiving keyboard events. When
- * multiple applications on the display have
- * the focus, this will refer to the
- * innermost window in the innermost
- * application. This information isn't used
- * under Unix or Windows, but it's needed on
- * the Macintosh. */
-
- /*
- * Used by tkColor.c only:
- */
-
- TkStressedCmap *stressPtr; /* First in list of colormaps that have
- * filled up, so we have to pick an
- * approximate color. */
-
- /*
- * Used by tkEvent.c only:
- */
-
- struct TkWindowEvent *delayedMotionPtr;
- /* Points to a malloc-ed motion event
- * whose processing has been delayed in
- * the hopes that another motion event
- * will come along right away and we can
- * merge the two of them together. NULL
- * means that there is no delayed motion
- * event. */
-
- /*
- * Miscellaneous information:
- */
-
-#ifdef TK_USE_INPUT_METHODS
- XIM inputMethod; /* Input method for this display */
-#endif /* TK_USE_INPUT_METHODS */
- Tcl_HashTable winTable; /* Maps from X window ids to TkWindow ptrs. */
-
- int refCount; /* Reference count of how many Tk applications
- * are using this display. Used to clean up
- * the display when we no longer have any
- * Tk applications using it.
- */
-} TkDisplay;
-
-/*
- * One of the following structures exists for each error handler
- * created by a call to Tk_CreateErrorHandler. The structure
- * is managed by tkError.c.
- */
-
-typedef struct TkErrorHandler {
- TkDisplay *dispPtr; /* Display to which handler applies. */
- unsigned long firstRequest; /* Only errors with serial numbers
- * >= to this are considered. */
- unsigned long lastRequest; /* Only errors with serial numbers
- * <= to this are considered. This
- * field is filled in when XUnhandle
- * is called. -1 means XUnhandle
- * hasn't been called yet. */
- int error; /* Consider only errors with this
- * error_code (-1 means consider
- * all errors). */
- int request; /* Consider only errors with this
- * major request code (-1 means
- * consider all major codes). */
- int minorCode; /* Consider only errors with this
- * minor request code (-1 means
- * consider all minor codes). */
- Tk_ErrorProc *errorProc; /* Procedure to invoke when a matching
- * error occurs. NULL means just ignore
- * errors. */
- ClientData clientData; /* Arbitrary value to pass to
- * errorProc. */
- struct TkErrorHandler *nextPtr;
- /* Pointer to next older handler for
- * this display, or NULL for end of
- * list. */
-} TkErrorHandler;
-
-/*
- * One of the following structures exists for each event handler
- * created by calling Tk_CreateEventHandler. This information
- * is used by tkEvent.c only.
- */
-
-typedef struct TkEventHandler {
- unsigned long mask; /* Events for which to invoke
- * proc. */
- Tk_EventProc *proc; /* Procedure to invoke when an event
- * in mask occurs. */
- ClientData clientData; /* Argument to pass to proc. */
- struct TkEventHandler *nextPtr;
- /* Next in list of handlers
- * associated with window (NULL means
- * end of list). */
-} TkEventHandler;
-
-/*
- * Tk keeps one of the following data structures for each main
- * window (created by a call to Tk_CreateMainWindow). It stores
- * information that is shared by all of the windows associated
- * with a particular main window.
- */
-
-typedef struct TkMainInfo {
- int refCount; /* Number of windows whose "mainPtr" fields
- * point here. When this becomes zero, can
- * free up the structure (the reference
- * count is zero because windows can get
- * deleted in almost any order; the main
- * window isn't necessarily the last one
- * deleted). */
- struct TkWindow *winPtr; /* Pointer to main window. */
- Tcl_Interp *interp; /* Interpreter associated with application. */
- Tcl_HashTable nameTable; /* Hash table mapping path names to TkWindow
- * structs for all windows related to this
- * main window. Managed by tkWindow.c. */
- Tk_BindingTable bindingTable;
- /* Used in conjunction with "bind" command
- * to bind events to Tcl commands. */
- TkBindInfo bindInfo; /* Information used by tkBind.c on a per
- * interpreter basis. */
- struct TkFontInfo *fontInfoPtr;
- /* Hold named font tables. Used only by
- * tkFont.c. */
-
- /*
- * Information used only by tkFocus.c and tk*Embed.c:
- */
-
- struct TkToplevelFocusInfo *tlFocusPtr;
- /* First in list of records containing focus
- * information for each top-level in the
- * application. Used only by tkFocus.c. */
- struct TkDisplayFocusInfo *displayFocusPtr;
- /* First in list of records containing focus
- * information for each display that this
- * application has ever used. Used only
- * by tkFocus.c. */
-
- struct ElArray *optionRootPtr;
- /* Top level of option hierarchy for this
- * main window. NULL means uninitialized.
- * Managed by tkOption.c. */
- Tcl_HashTable imageTable; /* Maps from image names to Tk_ImageMaster
- * structures. Managed by tkImage.c. */
- int strictMotif; /* This is linked to the tk_strictMotif
- * global variable. */
- struct TkMainInfo *nextPtr; /* Next in list of all main windows managed by
- * this process. */
-} TkMainInfo;
-
-/*
- * Tk keeps the following data structure for each of it's builtin
- * bitmaps. This structure is only used by tkBitmap.c and other
- * platform specific bitmap files.
- */
-
-typedef struct {
- char *source; /* Bits for bitmap. */
- int width, height; /* Dimensions of bitmap. */
- int native; /* 0 means generic (X style) bitmap,
- * 1 means native style bitmap. */
-} TkPredefBitmap;
-
-/*
- * Tk keeps one of the following structures for each window.
- * Some of the information (like size and location) is a shadow
- * of information managed by the X server, and some is special
- * information used here, such as event and geometry management
- * information. This information is (mostly) managed by tkWindow.c.
- * WARNING: the declaration below must be kept consistent with the
- * Tk_FakeWin structure in tk.h. If you change one, be sure to
- * change the other!!
- */
-
-typedef struct TkWindow {
-
- /*
- * Structural information:
- */
-
- Display *display; /* Display containing window. */
- TkDisplay *dispPtr; /* Tk's information about display
- * for window. */
- int screenNum; /* Index of screen for window, among all
- * those for dispPtr. */
- Visual *visual; /* Visual to use for window. If not default,
- * MUST be set before X window is created. */
- int depth; /* Number of bits/pixel. */
- Window window; /* X's id for window. NULL means window
- * hasn't actually been created yet, or it's
- * been deleted. */
- struct TkWindow *childList; /* First in list of child windows,
- * or NULL if no children. List is in
- * stacking order, lowest window first.*/
- struct TkWindow *lastChildPtr;
- /* Last in list of child windows (highest
- * in stacking order), or NULL if no
- * children. */
- struct TkWindow *parentPtr; /* Pointer to parent window (logical
- * parent, not necessarily X parent). NULL
- * means either this is the main window, or
- * the window's parent has already been
- * deleted. */
- struct TkWindow *nextPtr; /* Next higher sibling (in stacking order)
- * in list of children with same parent. NULL
- * means end of list. */
- TkMainInfo *mainPtr; /* Information shared by all windows
- * associated with a particular main
- * window. NULL means this window is
- * a rogue that isn't associated with
- * any application (at present, this
- * only happens for the dummy windows
- * used for "send" communication). */
-
- /*
- * Name and type information for the window:
- */
-
- char *pathName; /* Path name of window (concatenation
- * of all names between this window and
- * its top-level ancestor). This is a
- * pointer into an entry in
- * mainPtr->nameTable. NULL means that
- * the window hasn't been completely
- * created yet. */
- Tk_Uid nameUid; /* Name of the window within its parent
- * (unique within the parent). */
- Tk_Uid classUid; /* Class of the window. NULL means window
- * hasn't been given a class yet. */
-
- /*
- * Geometry and other attributes of window. This information
- * may not be updated on the server immediately; stuff that
- * hasn't been reflected in the server yet is called "dirty".
- * At present, information can be dirty only if the window
- * hasn't yet been created.
- */
-
- XWindowChanges changes; /* Geometry and other info about
- * window. */
- unsigned int dirtyChanges; /* Bits indicate fields of "changes"
- * that are dirty. */
- XSetWindowAttributes atts; /* Current attributes of window. */
- unsigned long dirtyAtts; /* Bits indicate fields of "atts"
- * that are dirty. */
-
- unsigned int flags; /* Various flag values: these are all
- * defined in tk.h (confusing, but they're
- * needed there for some query macros). */
-
- /*
- * Information kept by the event manager (tkEvent.c):
- */
-
- TkEventHandler *handlerList;/* First in list of event handlers
- * declared for this window, or
- * NULL if none. */
-#ifdef TK_USE_INPUT_METHODS
- XIC inputContext; /* Input context (for input methods). */
-#endif /* TK_USE_INPUT_METHODS */
-
- /*
- * Information used for event bindings (see "bind" and "bindtags"
- * commands in tkCmds.c):
- */
-
- ClientData *tagPtr; /* Points to array of tags used for bindings
- * on this window. Each tag is a Tk_Uid.
- * Malloc'ed. NULL means no tags. */
- int numTags; /* Number of tags at *tagPtr. */
-
- /*
- * Information used by tkOption.c to manage options for the
- * window.
- */
-
- int optionLevel; /* -1 means no option information is
- * currently cached for this window.
- * Otherwise this gives the level in
- * the option stack at which info is
- * cached. */
- /*
- * Information used by tkSelect.c to manage the selection.
- */
-
- struct TkSelHandler *selHandlerList;
- /* First in list of handlers for
- * returning the selection in various
- * forms. */
-
- /*
- * Information used by tkGeometry.c for geometry management.
- */
-
- Tk_GeomMgr *geomMgrPtr; /* Information about geometry manager for
- * this window. */
- ClientData geomData; /* Argument for geometry manager procedures. */
- int reqWidth, reqHeight; /* Arguments from last call to
- * Tk_GeometryRequest, or 0's if
- * Tk_GeometryRequest hasn't been
- * called. */
- int internalBorderWidth; /* Width of internal border of window
- * (0 means no internal border). Geometry
- * managers should not normally place children
- * on top of the border. */
-
- /*
- * Information maintained by tkWm.c for window manager communication.
- */
-
- struct TkWmInfo *wmInfoPtr; /* For top-level windows (and also
- * for special Unix menubar and wrapper
- * windows), points to structure with
- * wm-related info (see tkWm.c). For
- * other windows, this is NULL. */
-
- /*
- * Information used by widget classes.
- */
-
- TkClassProcs *classProcsPtr;
- ClientData instanceData;
-
- /*
- * Platform specific information private to each port.
- */
-
- struct TkWindowPrivate *privatePtr;
-} TkWindow;
-
-/*
- * The following structure is used as a two way map between integers
- * and strings, usually to map between an internal C representation
- * and the strings used in Tcl.
- */
-
-typedef struct TkStateMap {
- int numKey; /* Integer representation of a value. */
- char *strKey; /* String representation of a value. */
-} TkStateMap;
-
-/*
- * This structure is used by the Mac and Window porting layers as
- * the internal representation of a clip_mask in a GC.
- */
-
-typedef struct TkpClipMask {
- int type; /* One of TKP_CLIP_PIXMAP or TKP_CLIP_REGION */
- union {
- Pixmap pixmap;
- TkRegion region;
- } value;
-} TkpClipMask;
-
-#define TKP_CLIP_PIXMAP 0
-#define TKP_CLIP_REGION 1
-
-/*
- * Pointer to first entry in list of all displays currently known.
- */
-
-extern TkDisplay *tkDisplayList;
-
-/*
- * Return values from TkGrabState:
- */
-
-#define TK_GRAB_NONE 0
-#define TK_GRAB_IN_TREE 1
-#define TK_GRAB_ANCESTOR 2
-#define TK_GRAB_EXCLUDED 3
-
-/*
- * The macro below is used to modify a "char" value (e.g. by casting
- * it to an unsigned character) so that it can be used safely with
- * macros such as isspace.
- */
-
-#define UCHAR(c) ((unsigned char) (c))
-
-/*
- * The following symbol is used in the mode field of FocusIn events
- * generated by an embedded application to request the input focus from
- * its container.
- */
-
-#define EMBEDDED_APP_WANTS_FOCUS (NotifyNormal + 20)
-
-/*
- * Miscellaneous variables shared among Tk modules but not exported
- * to the outside world:
- */
-
-extern Tk_Uid tkActiveUid;
-extern Tk_ImageType tkBitmapImageType;
-extern Tk_Uid tkDisabledUid;
-extern Tk_PhotoImageFormat tkImgFmtGIF;
-extern void (*tkHandleEventProc) _ANSI_ARGS_((
- XEvent* eventPtr));
-extern Tk_PhotoImageFormat tkImgFmtPPM;
-extern TkMainInfo *tkMainWindowList;
-extern Tk_Uid tkNormalUid;
-extern Tk_ImageType tkPhotoImageType;
-extern Tcl_HashTable tkPredefBitmapTable;
-extern int tkSendSerial;
-
-/*
- * Internal procedures shared among Tk modules but not exported
- * to the outside world:
- */
-
-EXTERN char * TkAlignImageData _ANSI_ARGS_((XImage *image,
- int alignment, int bitOrder));
-EXTERN TkWindow * TkAllocWindow _ANSI_ARGS_((TkDisplay *dispPtr,
- int screenNum, TkWindow *parentPtr));
-EXTERN int TkAreaToPolygon _ANSI_ARGS_((double *polyPtr,
- int numPoints, double *rectPtr));
-EXTERN void TkBezierPoints _ANSI_ARGS_((double control[],
- int numSteps, double *coordPtr));
-EXTERN void TkBezierScreenPoints _ANSI_ARGS_((Tk_Canvas canvas,
- double control[], int numSteps,
- XPoint *xPointPtr));
-EXTERN void TkBindDeadWindow _ANSI_ARGS_((TkWindow *winPtr));
-EXTERN void TkBindEventProc _ANSI_ARGS_((TkWindow *winPtr,
- XEvent *eventPtr));
-EXTERN void TkBindFree _ANSI_ARGS_((TkMainInfo *mainPtr));
-EXTERN void TkBindInit _ANSI_ARGS_((TkMainInfo *mainPtr));
-EXTERN void TkChangeEventWindow _ANSI_ARGS_((XEvent *eventPtr,
- TkWindow *winPtr));
-#ifndef TkClipBox
-EXTERN void TkClipBox _ANSI_ARGS_((TkRegion rgn,
- XRectangle* rect_return));
-#endif
-EXTERN int TkClipInit _ANSI_ARGS_((Tcl_Interp *interp,
- TkDisplay *dispPtr));
-EXTERN void TkComputeAnchor _ANSI_ARGS_((Tk_Anchor anchor,
- Tk_Window tkwin, int padX, int padY,
- int innerWidth, int innerHeight, int *xPtr,
- int *yPtr));
-EXTERN int TkCopyAndGlobalEval _ANSI_ARGS_((Tcl_Interp *interp,
- char *script));
-EXTERN unsigned long TkCreateBindingProcedure _ANSI_ARGS_((
- Tcl_Interp *interp, Tk_BindingTable bindingTable,
- ClientData object, char *eventString,
- TkBindEvalProc *evalProc, TkBindFreeProc *freeProc,
- ClientData clientData));
-EXTERN Pixmap TkCreateBitmapFromData _ANSI_ARGS_((Display* display,
- Drawable d, CONST char* data,
- unsigned int width, unsigned int height));
-EXTERN TkCursor * TkCreateCursorFromData _ANSI_ARGS_((Tk_Window tkwin,
- char *source, char *mask, int width, int height,
- int xHot, int yHot, XColor fg, XColor bg));
-EXTERN int TkCreateFrame _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv,
- int toplevel, char *appName));
-EXTERN Tk_Window TkCreateMainWindow _ANSI_ARGS_((Tcl_Interp *interp,
- char *screenName, char *baseName));
-#ifndef TkCreateRegion
-EXTERN TkRegion TkCreateRegion _ANSI_ARGS_((void));
-#endif
-EXTERN Time TkCurrentTime _ANSI_ARGS_((TkDisplay *dispPtr));
-EXTERN int TkDeadAppCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-EXTERN void TkDeleteAllImages _ANSI_ARGS_((TkMainInfo *mainPtr));
-#ifndef TkDestroyRegion
-EXTERN void TkDestroyRegion _ANSI_ARGS_((TkRegion rgn));
-#endif
-EXTERN void TkDoConfigureNotify _ANSI_ARGS_((TkWindow *winPtr));
-EXTERN void TkDrawInsetFocusHighlight _ANSI_ARGS_((
- Tk_Window tkwin, GC gc, int width,
- Drawable drawable, int padding));
-EXTERN void TkEventCleanupProc _ANSI_ARGS_((
- ClientData clientData, Tcl_Interp *interp));
-EXTERN void TkEventDeadWindow _ANSI_ARGS_((TkWindow *winPtr));
-EXTERN void TkFillPolygon _ANSI_ARGS_((Tk_Canvas canvas,
- double *coordPtr, int numPoints, Display *display,
- Drawable drawable, GC gc, GC outlineGC));
-EXTERN int TkFindStateNum _ANSI_ARGS_((Tcl_Interp *interp,
- CONST char *option, CONST TkStateMap *mapPtr,
- CONST char *strKey));
-EXTERN char * TkFindStateString _ANSI_ARGS_((
- CONST TkStateMap *mapPtr, int numKey));
-EXTERN void TkFocusDeadWindow _ANSI_ARGS_((TkWindow *winPtr));
-EXTERN int TkFocusFilterEvent _ANSI_ARGS_((TkWindow *winPtr,
- XEvent *eventPtr));
-EXTERN TkWindow * TkFocusKeyEvent _ANSI_ARGS_((TkWindow *winPtr,
- XEvent *eventPtr));
-EXTERN void TkFontPkgInit _ANSI_ARGS_((TkMainInfo *mainPtr));
-EXTERN void TkFontPkgFree _ANSI_ARGS_((TkMainInfo *mainPtr));
-EXTERN void TkFreeBindingTags _ANSI_ARGS_((TkWindow *winPtr));
-EXTERN void TkFreeCursor _ANSI_ARGS_((TkCursor *cursorPtr));
-EXTERN void TkFreeWindowId _ANSI_ARGS_((TkDisplay *dispPtr,
- Window w));
-EXTERN void TkGenerateActivateEvents _ANSI_ARGS_((
- TkWindow *winPtr, int active));
-EXTERN char * TkGetBitmapData _ANSI_ARGS_((Tcl_Interp *interp,
- char *string, char *fileName, int *widthPtr,
- int *heightPtr, int *hotXPtr, int *hotYPtr));
-EXTERN void TkGetButtPoints _ANSI_ARGS_((double p1[], double p2[],
- double width, int project, double m1[],
- double m2[]));
-EXTERN TkCursor * TkGetCursorByName _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Window tkwin, Tk_Uid string));
-EXTERN char * TkGetDefaultScreenName _ANSI_ARGS_((Tcl_Interp *interp,
- char *screenName));
-EXTERN TkDisplay * TkGetDisplay _ANSI_ARGS_((Display *display));
-EXTERN int TkGetDisplayOf _ANSI_ARGS_((Tcl_Interp *interp,
- int objc, Tcl_Obj *CONST objv[],
- Tk_Window *tkwinPtr));
-EXTERN TkWindow * TkGetFocusWin _ANSI_ARGS_((TkWindow *winPtr));
-EXTERN int TkGetInterpNames _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Window tkwin));
-EXTERN int TkGetMiterPoints _ANSI_ARGS_((double p1[], double p2[],
- double p3[], double width, double m1[],
- double m2[]));
-#ifndef TkGetNativeProlog
-EXTERN int TkGetNativeProlog _ANSI_ARGS_((Tcl_Interp *interp));
-#endif
-EXTERN void TkGetPointerCoords _ANSI_ARGS_((Tk_Window tkwin,
- int *xPtr, int *yPtr));
-EXTERN int TkGetProlog _ANSI_ARGS_((Tcl_Interp *interp));
-EXTERN void TkGetServerInfo _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Window tkwin));
-EXTERN void TkGrabDeadWindow _ANSI_ARGS_((TkWindow *winPtr));
-EXTERN int TkGrabState _ANSI_ARGS_((TkWindow *winPtr));
-EXTERN TkWindow * TkIDToWindow _ANSI_ARGS_((Window window,
- TkDisplay *display));
-EXTERN void TkIncludePoint _ANSI_ARGS_((Tk_Item *itemPtr,
- double *pointPtr));
-EXTERN void TkInitXId _ANSI_ARGS_((TkDisplay *dispPtr));
-EXTERN void TkInOutEvents _ANSI_ARGS_((XEvent *eventPtr,
- TkWindow *sourcePtr, TkWindow *destPtr,
- int leaveType, int enterType,
- Tcl_QueuePosition position));
-EXTERN void TkInstallFrameMenu _ANSI_ARGS_((Tk_Window tkwin));
-#ifndef TkIntersectRegion
-EXTERN void TkIntersectRegion _ANSI_ARGS_((TkRegion sra,
- TkRegion srcb, TkRegion dr_return));
-#endif
-EXTERN char * TkKeysymToString _ANSI_ARGS_((KeySym keysym));
-EXTERN int TkLineToArea _ANSI_ARGS_((double end1Ptr[2],
- double end2Ptr[2], double rectPtr[4]));
-EXTERN double TkLineToPoint _ANSI_ARGS_((double end1Ptr[2],
- double end2Ptr[2], double pointPtr[2]));
-EXTERN int TkListAppend _ANSI_ARGS_((void **headPtrPtr,
- void *itemPtr, size_t size));
-EXTERN int TkListDelete _ANSI_ARGS_((void **headPtrPtr,
- void *itemPtr, size_t size));
-EXTERN void * TkListFind _ANSI_ARGS_((void *headPtr, void *itemPtr,
- size_t size));
-EXTERN int TkMakeBezierCurve _ANSI_ARGS_((Tk_Canvas canvas,
- double *pointPtr, int numPoints, int numSteps,
- XPoint xPoints[], double dblPoints[]));
-EXTERN void TkMakeBezierPostscript _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Canvas canvas, double *pointPtr,
- int numPoints));
-EXTERN void TkOptionClassChanged _ANSI_ARGS_((TkWindow *winPtr));
-EXTERN void TkOptionDeadWindow _ANSI_ARGS_((TkWindow *winPtr));
-EXTERN int TkOvalToArea _ANSI_ARGS_((double *ovalPtr,
- double *rectPtr));
-EXTERN double TkOvalToPoint _ANSI_ARGS_((double ovalPtr[4],
- double width, int filled, double pointPtr[2]));
-EXTERN int TkpChangeFocus _ANSI_ARGS_((TkWindow *winPtr,
- int force));
-EXTERN void TkpCloseDisplay _ANSI_ARGS_((TkDisplay *dispPtr));
-EXTERN void TkpClaimFocus _ANSI_ARGS_((TkWindow *topLevelPtr,
- int force));
-#ifndef TkpCmapStressed
-EXTERN int TkpCmapStressed _ANSI_ARGS_((Tk_Window tkwin,
- Colormap colormap));
-#endif
-#ifndef TkpCreateNativeBitmap
-EXTERN Pixmap TkpCreateNativeBitmap _ANSI_ARGS_((Display *display,
- char * source));
-#endif
-#ifndef TkpDefineNativeBitmaps
-EXTERN void TkpDefineNativeBitmaps _ANSI_ARGS_((void));
-#endif
-EXTERN void TkpDisplayWarning _ANSI_ARGS_((char *msg,
- char *title));
-EXTERN void TkpGetAppName _ANSI_ARGS_((Tcl_Interp *interp,
- Tcl_DString *name));
-EXTERN unsigned long TkpGetMS _ANSI_ARGS_((void));
-#ifndef TkpGetNativeAppBitmap
-EXTERN Pixmap TkpGetNativeAppBitmap _ANSI_ARGS_((Display *display,
- char *name, int *width, int *height));
-#endif
-EXTERN TkWindow * TkpGetOtherWindow _ANSI_ARGS_((TkWindow *winPtr));
-EXTERN TkWindow * TkpGetWrapperWindow _ANSI_ARGS_((TkWindow *winPtr));
-EXTERN int TkpInit _ANSI_ARGS_((Tcl_Interp *interp));
-EXTERN void TkpInitializeMenuBindings _ANSI_ARGS_((
- Tcl_Interp *interp, Tk_BindingTable bindingTable));
-EXTERN void TkpMakeContainer _ANSI_ARGS_((Tk_Window tkwin));
-EXTERN void TkpMakeMenuWindow _ANSI_ARGS_((Tk_Window tkwin,
- int transient));
-EXTERN Window TkpMakeWindow _ANSI_ARGS_((TkWindow *winPtr,
- Window parent));
-EXTERN void TkpMenuNotifyToplevelCreate _ANSI_ARGS_((
- Tcl_Interp *, char *menuName));
-EXTERN TkDisplay * TkpOpenDisplay _ANSI_ARGS_((char *display_name));
-EXTERN void TkPointerDeadWindow _ANSI_ARGS_((TkWindow *winPtr));
-EXTERN int TkPointerEvent _ANSI_ARGS_((XEvent *eventPtr,
- TkWindow *winPtr));
-EXTERN int TkPolygonToArea _ANSI_ARGS_((double *polyPtr,
- int numPoints, double *rectPtr));
-EXTERN double TkPolygonToPoint _ANSI_ARGS_((double *polyPtr,
- int numPoints, double *pointPtr));
-EXTERN int TkPositionInTree _ANSI_ARGS_((TkWindow *winPtr,
- TkWindow *treePtr));
-#ifndef TkpPrintWindowId
-EXTERN void TkpPrintWindowId _ANSI_ARGS_((char *buf,
- Window window));
-#endif
-EXTERN void TkpRedirectKeyEvent _ANSI_ARGS_((TkWindow *winPtr,
- XEvent *eventPtr));
-#ifndef TkpScanWindowId
-EXTERN int TkpScanWindowId _ANSI_ARGS_((Tcl_Interp *interp,
- char *string, int *idPtr));
-#endif
-EXTERN void TkpSetCapture _ANSI_ARGS_((TkWindow *winPtr));
-EXTERN void TkpSetCursor _ANSI_ARGS_((TkpCursor cursor));
-EXTERN void TkpSetMainMenubar _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Window tkwin, char *menuName));
-#ifndef TkpSync
-EXTERN void TkpSync _ANSI_ARGS_((Display *display));
-#endif
-EXTERN int TkpTestembedCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-EXTERN int TkpUseWindow _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Window tkwin, char *string));
-#ifndef TkPutImage
-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));
-#endif
-EXTERN int TkpWindowWasRecentlyDeleted _ANSI_ARGS_((Window win,
- TkDisplay *dispPtr));
-EXTERN void TkpWmSetState _ANSI_ARGS_((TkWindow *winPtr,
- int state));
-EXTERN void TkQueueEventForAllChildren _ANSI_ARGS_((
- TkWindow *winPtr, XEvent *eventPtr));
-EXTERN 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));
-#ifndef TkRectInRegion
-EXTERN int TkRectInRegion _ANSI_ARGS_((TkRegion rgn,
- int x, int y, unsigned int width,
- unsigned int height));
-#endif
-EXTERN int TkScrollWindow _ANSI_ARGS_((Tk_Window tkwin, GC gc,
- int x, int y, int width, int height, int dx,
- int dy, TkRegion damageRgn));
-EXTERN void TkSelDeadWindow _ANSI_ARGS_((TkWindow *winPtr));
-EXTERN void TkSelEventProc _ANSI_ARGS_((Tk_Window tkwin,
- XEvent *eventPtr));
-EXTERN void TkSelInit _ANSI_ARGS_((Tk_Window tkwin));
-EXTERN void TkSelPropProc _ANSI_ARGS_((XEvent *eventPtr));
-EXTERN void TkSetClassProcs _ANSI_ARGS_((Tk_Window tkwin,
- TkClassProcs *procs, ClientData instanceData));
-#ifndef TkSetPixmapColormap
-EXTERN void TkSetPixmapColormap _ANSI_ARGS_((Pixmap pixmap,
- Colormap colormap));
-#endif
-#ifndef TkSetRegion
-EXTERN void TkSetRegion _ANSI_ARGS_((Display* display, GC gc,
- TkRegion rgn));
-#endif
-EXTERN void TkSetWindowMenuBar _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Window tkwin, char *oldMenuName,
- char *menuName));
-EXTERN KeySym TkStringToKeysym _ANSI_ARGS_((char *name));
-EXTERN int TkThickPolyLineToArea _ANSI_ARGS_((double *coordPtr,
- int numPoints, double width, int capStyle,
- int joinStyle, double *rectPtr));
-#ifndef TkUnionRectWithRegion
-EXTERN void TkUnionRectWithRegion _ANSI_ARGS_((XRectangle* rect,
- TkRegion src, TkRegion dr_return));
-#endif
-EXTERN void TkWmAddToColormapWindows _ANSI_ARGS_((
- TkWindow *winPtr));
-EXTERN void TkWmDeadWindow _ANSI_ARGS_((TkWindow *winPtr));
-EXTERN TkWindow * TkWmFocusToplevel _ANSI_ARGS_((TkWindow *winPtr));
-EXTERN void TkWmMapWindow _ANSI_ARGS_((TkWindow *winPtr));
-EXTERN void TkWmNewWindow _ANSI_ARGS_((TkWindow *winPtr));
-EXTERN void TkWmProtocolEventProc _ANSI_ARGS_((TkWindow *winPtr,
- XEvent *evenvPtr));
-EXTERN void TkWmRemoveFromColormapWindows _ANSI_ARGS_((
- TkWindow *winPtr));
-EXTERN void TkWmRestackToplevel _ANSI_ARGS_((TkWindow *winPtr,
- int aboveBelow, TkWindow *otherPtr));
-EXTERN void TkWmSetClass _ANSI_ARGS_((TkWindow *winPtr));
-EXTERN void TkWmUnmapWindow _ANSI_ARGS_((TkWindow *winPtr));
-EXTERN int TkXFileProc _ANSI_ARGS_((ClientData clientData,
- int mask, int flags));
-
-/*
- * Unsupported commands.
- */
-EXTERN int TkUnsupported1Cmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-
-# undef TCL_STORAGE_CLASS
-# define TCL_STORAGE_CLASS DLLIMPORT
-
-#endif /* _TKINT */
diff --git a/generic/tkListbox.c b/generic/tkListbox.c
deleted file mode 100644
index 34189c7..0000000
--- a/generic/tkListbox.c
+++ /dev/null
@@ -1,2335 +0,0 @@
-/*
- * tkListbox.c --
- *
- * This module implements listbox widgets for the Tk
- * toolkit. A listbox displays a collection of strings,
- * one per line, and provides scrolling and selection.
- *
- * Copyright (c) 1990-1994 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: tkListbox.c,v 1.2 1998/09/14 18:23:13 stanton Exp $
- */
-
-#include "tkPort.h"
-#include "default.h"
-#include "tkInt.h"
-
-/*
- * One record of the following type is kept for each element
- * associated with a listbox widget:
- */
-
-typedef struct Element {
- int textLength; /* # non-NULL characters in text. */
- int lBearing; /* Distance from first character's
- * origin to left edge of character. */
- int pixelWidth; /* Total width of element in pixels (including
- * left bearing and right bearing). */
- int selected; /* 1 means this item is selected, 0 means
- * it isn't. */
- struct Element *nextPtr; /* Next in list of all elements of this
- * listbox, or NULL for last element. */
- char text[4]; /* Characters of this element, NULL-
- * terminated. The actual space allocated
- * here will be as large as needed (> 4,
- * most likely). Must be the last field
- * of the record. */
-} Element;
-
-#define ElementSize(stringLength) \
- ((unsigned) (sizeof(Element) - 3 + stringLength))
-
-/*
- * A data structure of the following type is kept for each listbox
- * widget managed by this file:
- */
-
-typedef struct {
- Tk_Window tkwin; /* Window that embodies the listbox. NULL
- * means that the window has been destroyed
- * but the data structures haven't yet been
- * cleaned up.*/
- Display *display; /* Display containing widget. Used, among
- * other things, so that resources can be
- * freed even after tkwin has gone away. */
- Tcl_Interp *interp; /* Interpreter associated with listbox. */
- Tcl_Command widgetCmd; /* Token for listbox's widget command. */
- int numElements; /* Total number of elements in this listbox. */
- Element *firstPtr; /* First in list of elements (NULL if no
- * elements). */
- Element *lastPtr; /* Last in list of elements (NULL if no
- * elements). */
-
- /*
- * Information used when displaying widget:
- */
-
- Tk_3DBorder normalBorder; /* Used for drawing border around whole
- * window, plus used for background. */
- int borderWidth; /* Width of 3-D border around window. */
- int relief; /* 3-D effect: TK_RELIEF_RAISED, etc. */
- int highlightWidth; /* Width in pixels of highlight to draw
- * around widget when it has the focus.
- * <= 0 means don't draw a highlight. */
- XColor *highlightBgColorPtr;
- /* Color for drawing traversal highlight
- * area when highlight is off. */
- XColor *highlightColorPtr; /* Color for drawing traversal highlight. */
- int inset; /* Total width of all borders, including
- * traversal highlight and 3-D border.
- * Indicates how much interior stuff must
- * be offset from outside edges to leave
- * room for borders. */
- Tk_Font tkfont; /* Information about text font, or NULL. */
- XColor *fgColorPtr; /* Text color in normal mode. */
- GC textGC; /* For drawing normal text. */
- Tk_3DBorder selBorder; /* Borders and backgrounds for selected
- * elements. */
- int selBorderWidth; /* Width of border around selection. */
- XColor *selFgColorPtr; /* Foreground color for selected elements. */
- GC selTextGC; /* For drawing selected text. */
- int width; /* Desired width of window, in characters. */
- int height; /* Desired height of window, in lines. */
- int lineHeight; /* Number of pixels allocated for each line
- * in display. */
- int topIndex; /* Index of top-most element visible in
- * window. */
- int fullLines; /* Number of lines that fit are completely
- * visible in window. There may be one
- * additional line at the bottom that is
- * partially visible. */
- int partialLine; /* 0 means that the window holds exactly
- * fullLines lines. 1 means that there is
- * one additional line that is partially
- * visble. */
- int setGrid; /* Non-zero means pass gridding information
- * to window manager. */
-
- /*
- * Information to support horizontal scrolling:
- */
-
- int maxWidth; /* Width (in pixels) of widest string in
- * listbox. */
- int xScrollUnit; /* Number of pixels in one "unit" for
- * horizontal scrolling (window scrolls
- * horizontally in increments of this size).
- * This is an average character size. */
- int xOffset; /* The left edge of each string in the
- * listbox is offset to the left by this
- * many pixels (0 means no offset, positive
- * means there is an offset). */
-
- /*
- * Information about what's selected or active, if any.
- */
-
- Tk_Uid selectMode; /* Selection style: single, browse, multiple,
- * or extended. This value isn't used in C
- * code, but the Tcl bindings use it. */
- int numSelected; /* Number of elements currently selected. */
- int selectAnchor; /* Fixed end of selection (i.e. element
- * at which selection was started.) */
- int exportSelection; /* Non-zero means tie internal listbox
- * to X selection. */
- int active; /* Index of "active" element (the one that
- * has been selected by keyboard traversal).
- * -1 means none. */
-
- /*
- * Information for scanning:
- */
-
- int scanMarkX; /* X-position at which scan started (e.g.
- * button was pressed here). */
- int scanMarkY; /* Y-position at which scan started (e.g.
- * button was pressed here). */
- int scanMarkXOffset; /* Value of "xOffset" field when scan
- * started. */
- int scanMarkYIndex; /* Index of line that was at top of window
- * when scan started. */
-
- /*
- * Miscellaneous information:
- */
-
- Tk_Cursor cursor; /* Current cursor for window, or None. */
- 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 *yScrollCmd; /* Command prefix for communicating with
- * vertical scrollbar. NULL means no command
- * to issue. Malloc'ed. */
- char *xScrollCmd; /* Command prefix for communicating with
- * horizontal scrollbar. NULL means no command
- * to issue. Malloc'ed. */
- int flags; /* Various flag bits: see below for
- * definitions. */
-} Listbox;
-
-/*
- * Flag bits for listboxes:
- *
- * REDRAW_PENDING: Non-zero means a DoWhenIdle handler
- * has already been queued to redraw
- * this window.
- * UPDATE_V_SCROLLBAR: Non-zero means vertical scrollbar needs
- * to be updated.
- * UPDATE_H_SCROLLBAR: Non-zero means horizontal scrollbar needs
- * to be updated.
- * GOT_FOCUS: Non-zero means this widget currently
- * has the input focus.
- */
-
-#define REDRAW_PENDING 1
-#define UPDATE_V_SCROLLBAR 2
-#define UPDATE_H_SCROLLBAR 4
-#define GOT_FOCUS 8
-
-/*
- * Information used for argv parsing:
- */
-
-static Tk_ConfigSpec configSpecs[] = {
- {TK_CONFIG_BORDER, "-background", "background", "Background",
- DEF_LISTBOX_BG_COLOR, Tk_Offset(Listbox, normalBorder),
- TK_CONFIG_COLOR_ONLY},
- {TK_CONFIG_BORDER, "-background", "background", "Background",
- DEF_LISTBOX_BG_MONO, Tk_Offset(Listbox, normalBorder),
- 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_LISTBOX_BORDER_WIDTH, Tk_Offset(Listbox, borderWidth), 0},
- {TK_CONFIG_ACTIVE_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_LISTBOX_CURSOR, Tk_Offset(Listbox, cursor), TK_CONFIG_NULL_OK},
- {TK_CONFIG_BOOLEAN, "-exportselection", "exportSelection",
- "ExportSelection", DEF_LISTBOX_EXPORT_SELECTION,
- Tk_Offset(Listbox, exportSelection), 0},
- {TK_CONFIG_SYNONYM, "-fg", "foreground", (char *) NULL,
- (char *) NULL, 0, 0},
- {TK_CONFIG_FONT, "-font", "font", "Font",
- DEF_LISTBOX_FONT, Tk_Offset(Listbox, tkfont), 0},
- {TK_CONFIG_COLOR, "-foreground", "foreground", "Foreground",
- DEF_LISTBOX_FG, Tk_Offset(Listbox, fgColorPtr), 0},
- {TK_CONFIG_INT, "-height", "height", "Height",
- DEF_LISTBOX_HEIGHT, Tk_Offset(Listbox, height), 0},
- {TK_CONFIG_COLOR, "-highlightbackground", "highlightBackground",
- "HighlightBackground", DEF_LISTBOX_HIGHLIGHT_BG,
- Tk_Offset(Listbox, highlightBgColorPtr), 0},
- {TK_CONFIG_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_LISTBOX_HIGHLIGHT, Tk_Offset(Listbox, highlightColorPtr), 0},
- {TK_CONFIG_PIXELS, "-highlightthickness", "highlightThickness",
- "HighlightThickness",
- DEF_LISTBOX_HIGHLIGHT_WIDTH, Tk_Offset(Listbox, highlightWidth), 0},
- {TK_CONFIG_RELIEF, "-relief", "relief", "Relief",
- DEF_LISTBOX_RELIEF, Tk_Offset(Listbox, relief), 0},
- {TK_CONFIG_BORDER, "-selectbackground", "selectBackground", "Foreground",
- DEF_LISTBOX_SELECT_COLOR, Tk_Offset(Listbox, selBorder),
- TK_CONFIG_COLOR_ONLY},
- {TK_CONFIG_BORDER, "-selectbackground", "selectBackground", "Foreground",
- DEF_LISTBOX_SELECT_MONO, Tk_Offset(Listbox, selBorder),
- TK_CONFIG_MONO_ONLY},
- {TK_CONFIG_PIXELS, "-selectborderwidth", "selectBorderWidth", "BorderWidth",
- DEF_LISTBOX_SELECT_BD, Tk_Offset(Listbox, selBorderWidth), 0},
- {TK_CONFIG_COLOR, "-selectforeground", "selectForeground", "Background",
- DEF_LISTBOX_SELECT_FG_COLOR, Tk_Offset(Listbox, selFgColorPtr),
- TK_CONFIG_COLOR_ONLY},
- {TK_CONFIG_COLOR, "-selectforeground", "selectForeground", "Background",
- DEF_LISTBOX_SELECT_FG_MONO, Tk_Offset(Listbox, selFgColorPtr),
- TK_CONFIG_MONO_ONLY},
- {TK_CONFIG_UID, "-selectmode", "selectMode", "SelectMode",
- DEF_LISTBOX_SELECT_MODE, Tk_Offset(Listbox, selectMode), 0},
- {TK_CONFIG_BOOLEAN, "-setgrid", "setGrid", "SetGrid",
- DEF_LISTBOX_SET_GRID, Tk_Offset(Listbox, setGrid), 0},
- {TK_CONFIG_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_LISTBOX_TAKE_FOCUS, Tk_Offset(Listbox, takeFocus),
- TK_CONFIG_NULL_OK},
- {TK_CONFIG_INT, "-width", "width", "Width",
- DEF_LISTBOX_WIDTH, Tk_Offset(Listbox, width), 0},
- {TK_CONFIG_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand",
- DEF_LISTBOX_SCROLL_COMMAND, Tk_Offset(Listbox, xScrollCmd),
- TK_CONFIG_NULL_OK},
- {TK_CONFIG_STRING, "-yscrollcommand", "yScrollCommand", "ScrollCommand",
- DEF_LISTBOX_SCROLL_COMMAND, Tk_Offset(Listbox, yScrollCmd),
- TK_CONFIG_NULL_OK},
- {TK_CONFIG_END, (char *) NULL, (char *) NULL, (char *) NULL,
- (char *) NULL, 0, 0}
-};
-
-/*
- * Forward declarations for procedures defined later in this file:
- */
-
-static void ChangeListboxOffset _ANSI_ARGS_((Listbox *listPtr,
- int offset));
-static void ChangeListboxView _ANSI_ARGS_((Listbox *listPtr,
- int index));
-static int ConfigureListbox _ANSI_ARGS_((Tcl_Interp *interp,
- Listbox *listPtr, int argc, char **argv,
- int flags));
-static void DeleteEls _ANSI_ARGS_((Listbox *listPtr, int first,
- int last));
-static void DestroyListbox _ANSI_ARGS_((char *memPtr));
-static void DisplayListbox _ANSI_ARGS_((ClientData clientData));
-static int GetListboxIndex _ANSI_ARGS_((Tcl_Interp *interp,
- Listbox *listPtr, char *string, int endIsSize,
- int *indexPtr));
-static void InsertEls _ANSI_ARGS_((Listbox *listPtr, int index,
- int argc, char **argv));
-static void ListboxCmdDeletedProc _ANSI_ARGS_((
- ClientData clientData));
-static void ListboxComputeGeometry _ANSI_ARGS_((Listbox *listPtr,
- int fontChanged, int maxIsStale, int updateGrid));
-static void ListboxEventProc _ANSI_ARGS_((ClientData clientData,
- XEvent *eventPtr));
-static int ListboxFetchSelection _ANSI_ARGS_((
- ClientData clientData, int offset, char *buffer,
- int maxBytes));
-static void ListboxLostSelection _ANSI_ARGS_((
- ClientData clientData));
-static void ListboxRedrawRange _ANSI_ARGS_((Listbox *listPtr,
- int first, int last));
-static void ListboxScanTo _ANSI_ARGS_((Listbox *listPtr,
- int x, int y));
-static void ListboxSelect _ANSI_ARGS_((Listbox *listPtr,
- int first, int last, int select));
-static void ListboxUpdateHScrollbar _ANSI_ARGS_((Listbox *listPtr));
-static void ListboxUpdateVScrollbar _ANSI_ARGS_((Listbox *listPtr));
-static int ListboxWidgetCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-static void ListboxWorldChanged _ANSI_ARGS_((
- ClientData instanceData));
-static int NearestListboxElement _ANSI_ARGS_((Listbox *listPtr,
- int y));
-
-/*
- * The structure below defines button class behavior by means of procedures
- * that can be invoked from generic window code.
- */
-
-static TkClassProcs listboxClass = {
- NULL, /* createProc. */
- ListboxWorldChanged, /* geometryProc. */
- NULL /* modalProc. */
-};
-
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_ListboxCmd --
- *
- * This procedure is invoked to process the "listbox" 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_ListboxCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Main window associated with
- * interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- register Listbox *listPtr;
- Tk_Window new;
- Tk_Window tkwin = (Tk_Window) clientData;
-
- if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " pathName ?options?\"", (char *) NULL);
- return TCL_ERROR;
- }
-
- new = Tk_CreateWindowFromPath(interp, tkwin, argv[1], (char *) NULL);
- if (new == NULL) {
- return TCL_ERROR;
- }
-
- /*
- * Initialize the fields of the structure that won't be initialized
- * by ConfigureListbox, or that ConfigureListbox requires to be
- * initialized already (e.g. resource pointers).
- */
-
- listPtr = (Listbox *) ckalloc(sizeof(Listbox));
- listPtr->tkwin = new;
- listPtr->display = Tk_Display(new);
- listPtr->interp = interp;
- listPtr->widgetCmd = Tcl_CreateCommand(interp,
- Tk_PathName(listPtr->tkwin), ListboxWidgetCmd,
- (ClientData) listPtr, ListboxCmdDeletedProc);
- listPtr->numElements = 0;
- listPtr->firstPtr = NULL;
- listPtr->lastPtr = NULL;
- 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;
-
- Tk_SetClass(listPtr->tkwin, "Listbox");
- TkSetClassProcs(listPtr->tkwin, &listboxClass, (ClientData) listPtr);
- Tk_CreateEventHandler(listPtr->tkwin,
- ExposureMask|StructureNotifyMask|FocusChangeMask,
- ListboxEventProc, (ClientData) listPtr);
- Tk_CreateSelHandler(listPtr->tkwin, XA_PRIMARY, XA_STRING,
- ListboxFetchSelection, (ClientData) listPtr, XA_STRING);
- if (ConfigureListbox(interp, listPtr, argc-2, argv+2, 0) != TCL_OK) {
- goto error;
- }
-
- interp->result = Tk_PathName(listPtr->tkwin);
- return TCL_OK;
-
- error:
- Tk_DestroyWindow(listPtr->tkwin);
- return TCL_ERROR;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ListboxWidgetCmd --
- *
- * 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
-ListboxWidgetCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Information about listbox widget. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- register Listbox *listPtr = (Listbox *) clientData;
- int result = TCL_OK;
- size_t length;
- int c;
- Tk_FontMetrics fm;
-
- if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " option ?arg arg ...?\"", (char *) NULL);
- return TCL_ERROR;
- }
- Tcl_Preserve((ClientData) listPtr);
- c = argv[1][0];
- length = strlen(argv[1]);
- if ((c == 'a') && (strncmp(argv[1], "activate", length) == 0)) {
- int index;
-
- if (argc != 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " activate index\"",
- (char *) NULL);
- goto error;
- }
- ListboxRedrawRange(listPtr, listPtr->active, listPtr->active);
- if (GetListboxIndex(interp, listPtr, argv[2], 0, &index) != TCL_OK) {
- goto error;
- }
- if (index >= listPtr->numElements) {
- index = listPtr->numElements-1;
- }
- if (index < 0) {
- index = 0;
- }
- listPtr->active = index;
- ListboxRedrawRange(listPtr, listPtr->active, listPtr->active);
- } else if ((c == 'b') && (strncmp(argv[1], "bbox", length) == 0)) {
- int index, x, y, i;
- Element *elPtr;
-
- if (argc != 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " bbox index\"", (char *) NULL);
- goto error;
- }
- if (GetListboxIndex(interp, listPtr, argv[2], 0, &index) != TCL_OK) {
- goto error;
- }
- if ((index >= listPtr->numElements) || (index < 0)) {
- goto done;
- }
- for (i = 0, elPtr = listPtr->firstPtr; i < index;
- i++, elPtr = elPtr->nextPtr) {
- /* Empty loop body. */
- }
- if ((index >= listPtr->topIndex) && (index < listPtr->numElements)
- && (index < (listPtr->topIndex + listPtr->fullLines
- + listPtr->partialLine))) {
- x = listPtr->inset + listPtr->selBorderWidth - listPtr->xOffset;
- y = ((index - listPtr->topIndex)*listPtr->lineHeight)
- + listPtr->inset + listPtr->selBorderWidth;
- Tk_GetFontMetrics(listPtr->tkfont, &fm);
- sprintf(interp->result, "%d %d %d %d", x, y, elPtr->pixelWidth,
- fm.linespace);
- }
- } else 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);
- goto error;
- }
- result = Tk_ConfigureValue(interp, listPtr->tkwin, configSpecs,
- (char *) listPtr, argv[2], 0);
- } else if ((c == 'c') && (strncmp(argv[1], "configure", length) == 0)
- && (length >= 2)) {
- if (argc == 2) {
- result = Tk_ConfigureInfo(interp, listPtr->tkwin, configSpecs,
- (char *) listPtr, (char *) NULL, 0);
- } else if (argc == 3) {
- result = Tk_ConfigureInfo(interp, listPtr->tkwin, configSpecs,
- (char *) listPtr, argv[2], 0);
- } else {
- result = ConfigureListbox(interp, listPtr, argc-2, argv+2,
- TK_CONFIG_ARGV_ONLY);
- }
- } else if ((c == 'c') && (strncmp(argv[1], "curselection", length) == 0)
- && (length >= 2)) {
- int i, count;
- char index[20];
- Element *elPtr;
-
- if (argc != 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " curselection\"",
- (char *) NULL);
- goto error;
- }
- count = 0;
- for (i = 0, elPtr = listPtr->firstPtr; elPtr != NULL;
- i++, elPtr = elPtr->nextPtr) {
- if (elPtr->selected) {
- sprintf(index, "%d", i);
- Tcl_AppendElement(interp, index);
- count++;
- }
- }
- if (count != listPtr->numSelected) {
- panic("ListboxWidgetCmd: selection count incorrect");
- }
- } else if ((c == 'd') && (strncmp(argv[1], "delete", length) == 0)) {
- int first, last;
-
- if ((argc < 3) || (argc > 4)) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " delete firstIndex ?lastIndex?\"",
- (char *) NULL);
- goto error;
- }
- if (GetListboxIndex(interp, listPtr, argv[2], 0, &first) != TCL_OK) {
- goto error;
- }
- if (first < listPtr->numElements) {
- if (argc == 3) {
- last = first;
- } else {
- if (GetListboxIndex(interp, listPtr, argv[3], 0,
- &last) != TCL_OK) {
- goto error;
- }
- if (last >= listPtr->numElements) {
- last = listPtr->numElements-1;
- }
- }
- DeleteEls(listPtr, first, last);
- }
- } else if ((c == 'g') && (strncmp(argv[1], "get", length) == 0)) {
- int first, last, i;
- Element *elPtr;
-
- if ((argc != 3) && (argc != 4)) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " get first ?last?\"", (char *) NULL);
- goto error;
- }
- if (GetListboxIndex(interp, listPtr, argv[2], 0, &first) != TCL_OK) {
- goto error;
- }
- if ((argc == 4) && (GetListboxIndex(interp, listPtr, argv[3],
- 0, &last) != TCL_OK)) {
- goto error;
- }
- if (first >= listPtr->numElements) {
- goto done;
- }
- if (last >= listPtr->numElements) {
- last = listPtr->numElements-1;
- }
-
- for (elPtr = listPtr->firstPtr, i = 0; i < first;
- i++, elPtr = elPtr->nextPtr) {
- /* Empty loop body. */
- }
- if (elPtr != NULL) {
- if (argc == 3) {
- if (first >= 0) {
- interp->result = elPtr->text;
- }
- } else {
- for ( ; i <= last; i++, elPtr = elPtr->nextPtr) {
- Tcl_AppendElement(interp, elPtr->text);
- }
- }
- }
- } else if ((c == 'i') && (strncmp(argv[1], "index", length) == 0)
- && (length >= 3)) {
- int index;
-
- if (argc != 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " index index\"",
- (char *) NULL);
- goto error;
- }
- if (GetListboxIndex(interp, listPtr, argv[2], 1, &index)
- != TCL_OK) {
- goto error;
- }
- sprintf(interp->result, "%d", index);
- } else if ((c == 'i') && (strncmp(argv[1], "insert", length) == 0)
- && (length >= 3)) {
- int index;
-
- if (argc < 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " insert index ?element element ...?\"",
- (char *) NULL);
- goto error;
- }
- if (GetListboxIndex(interp, listPtr, argv[2], 1, &index)
- != TCL_OK) {
- goto error;
- }
- InsertEls(listPtr, index, argc-3, argv+3);
- } else if ((c == 'n') && (strncmp(argv[1], "nearest", length) == 0)) {
- int index, y;
-
- if (argc != 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " nearest y\"", (char *) NULL);
- goto error;
- }
- if (Tcl_GetInt(interp, argv[2], &y) != TCL_OK) {
- goto error;
- }
- index = NearestListboxElement(listPtr, y);
- sprintf(interp->result, "%d", index);
- } else if ((c == 's') && (length >= 2)
- && (strncmp(argv[1], "scan", length) == 0)) {
- int x, y;
-
- if (argc != 5) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " scan mark|dragto x y\"", (char *) NULL);
- goto error;
- }
- if ((Tcl_GetInt(interp, argv[3], &x) != TCL_OK)
- || (Tcl_GetInt(interp, argv[4], &y) != TCL_OK)) {
- goto error;
- }
- if ((argv[2][0] == 'm')
- && (strncmp(argv[2], "mark", strlen(argv[2])) == 0)) {
- listPtr->scanMarkX = x;
- listPtr->scanMarkY = y;
- listPtr->scanMarkXOffset = listPtr->xOffset;
- listPtr->scanMarkYIndex = listPtr->topIndex;
- } else if ((argv[2][0] == 'd')
- && (strncmp(argv[2], "dragto", strlen(argv[2])) == 0)) {
- ListboxScanTo(listPtr, x, y);
- } else {
- Tcl_AppendResult(interp, "bad scan option \"", argv[2],
- "\": must be mark or dragto", (char *) NULL);
- goto error;
- }
- } else if ((c == 's') && (strncmp(argv[1], "see", length) == 0)
- && (length >= 3)) {
- int index, diff;
- if (argc != 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " see index\"",
- (char *) NULL);
- goto error;
- }
- if (GetListboxIndex(interp, listPtr, argv[2], 0, &index) != TCL_OK) {
- goto error;
- }
- if (index >= listPtr->numElements) {
- index = listPtr->numElements-1;
- }
- if (index < 0) {
- index = 0;
- }
- diff = listPtr->topIndex-index;
- if (diff > 0) {
- if (diff <= (listPtr->fullLines/3)) {
- ChangeListboxView(listPtr, index);
- } else {
- ChangeListboxView(listPtr, index - (listPtr->fullLines-1)/2);
- }
- } else {
- diff = index - (listPtr->topIndex + listPtr->fullLines - 1);
- if (diff > 0) {
- if (diff <= (listPtr->fullLines/3)) {
- ChangeListboxView(listPtr, listPtr->topIndex + diff);
- } else {
- ChangeListboxView(listPtr,
- index - (listPtr->fullLines-1)/2);
- }
- }
- }
- } else if ((c == 's') && (length >= 3)
- && (strncmp(argv[1], "selection", length) == 0)) {
- int first, last;
-
- if ((argc != 4) && (argc != 5)) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " selection option index ?index?\"",
- (char *) NULL);
- goto error;
- }
- if (GetListboxIndex(interp, listPtr, argv[3], 0, &first) != TCL_OK) {
- goto error;
- }
- if (argc == 5) {
- if (GetListboxIndex(interp, listPtr, argv[4], 0, &last) != TCL_OK) {
- goto error;
- }
- } else {
- last = first;
- }
- length = strlen(argv[2]);
- c = argv[2][0];
- if ((c == 'a') && (strncmp(argv[2], "anchor", length) == 0)) {
- if (argc != 4) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " selection anchor index\"", (char *) NULL);
- goto error;
- }
- if (first >= listPtr->numElements) {
- first = listPtr->numElements-1;
- }
- if (first < 0) {
- first = 0;
- }
- listPtr->selectAnchor = first;
- } else if ((c == 'c') && (strncmp(argv[2], "clear", length) == 0)) {
- ListboxSelect(listPtr, first, last, 0);
- } else if ((c == 'i') && (strncmp(argv[2], "includes", length) == 0)) {
- int i;
- Element *elPtr;
-
- if (argc != 4) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " selection includes index\"", (char *) NULL);
- goto error;
- }
- if ((first < 0) || (first >= listPtr->numElements)) {
- interp->result = "0";
- goto done;
- }
- for (elPtr = listPtr->firstPtr, i = 0; i < first;
- i++, elPtr = elPtr->nextPtr) {
- /* Empty loop body. */
- }
- if (elPtr->selected) {
- interp->result = "1";
- } else {
- interp->result = "0";
- }
- } else if ((c == 's') && (strncmp(argv[2], "set", length) == 0)) {
- ListboxSelect(listPtr, first, last, 1);
- } else {
- Tcl_AppendResult(interp, "bad selection option \"", argv[2],
- "\": must be anchor, clear, includes, or set",
- (char *) NULL);
- goto error;
- }
- } else if ((c == 's') && (length >= 2)
- && (strncmp(argv[1], "size", length) == 0)) {
- if (argc != 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " size\"", (char *) NULL);
- goto error;
- }
- sprintf(interp->result, "%d", listPtr->numElements);
- } else if ((c == 'x') && (strncmp(argv[1], "xview", length) == 0)) {
- int index, count, type, windowWidth, windowUnits;
- int offset = 0; /* Initialized to stop gcc warnings. */
- double fraction, fraction2;
-
- windowWidth = Tk_Width(listPtr->tkwin)
- - 2*(listPtr->inset + listPtr->selBorderWidth);
- if (argc == 2) {
- if (listPtr->maxWidth == 0) {
- interp->result = "0 1";
- } else {
- fraction = listPtr->xOffset/((double) listPtr->maxWidth);
- fraction2 = (listPtr->xOffset + windowWidth)
- /((double) listPtr->maxWidth);
- if (fraction2 > 1.0) {
- fraction2 = 1.0;
- }
- sprintf(interp->result, "%g %g", fraction, fraction2);
- }
- } else if (argc == 3) {
- if (Tcl_GetInt(interp, argv[2], &index) != TCL_OK) {
- goto error;
- }
- ChangeListboxOffset(listPtr, index*listPtr->xScrollUnit);
- } else {
- type = Tk_GetScrollInfo(interp, argc, argv, &fraction, &count);
- switch (type) {
- case TK_SCROLL_ERROR:
- goto error;
- case TK_SCROLL_MOVETO:
- offset = (int) (fraction*listPtr->maxWidth + 0.5);
- break;
- case TK_SCROLL_PAGES:
- windowUnits = windowWidth/listPtr->xScrollUnit;
- if (windowUnits > 2) {
- offset = listPtr->xOffset
- + count*listPtr->xScrollUnit*(windowUnits-2);
- } else {
- offset = listPtr->xOffset + count*listPtr->xScrollUnit;
- }
- break;
- case TK_SCROLL_UNITS:
- offset = listPtr->xOffset + count*listPtr->xScrollUnit;
- break;
- }
- ChangeListboxOffset(listPtr, offset);
- }
- } else if ((c == 'y') && (strncmp(argv[1], "yview", length) == 0)) {
- int index, count, type;
- double fraction, fraction2;
-
- if (argc == 2) {
- if (listPtr->numElements == 0) {
- interp->result = "0 1";
- } else {
- fraction = listPtr->topIndex/((double) listPtr->numElements);
- fraction2 = (listPtr->topIndex+listPtr->fullLines)
- /((double) listPtr->numElements);
- if (fraction2 > 1.0) {
- fraction2 = 1.0;
- }
- sprintf(interp->result, "%g %g", fraction, fraction2);
- }
- } else if (argc == 3) {
- if (GetListboxIndex(interp, listPtr, argv[2], 0, &index)
- != TCL_OK) {
- goto error;
- }
- ChangeListboxView(listPtr, index);
- } else {
- type = Tk_GetScrollInfo(interp, argc, argv, &fraction, &count);
- switch (type) {
- case TK_SCROLL_ERROR:
- goto error;
- case TK_SCROLL_MOVETO:
- index = (int) (listPtr->numElements*fraction + 0.5);
- break;
- case TK_SCROLL_PAGES:
- if (listPtr->fullLines > 2) {
- index = listPtr->topIndex
- + count*(listPtr->fullLines-2);
- } else {
- index = listPtr->topIndex + count;
- }
- break;
- case TK_SCROLL_UNITS:
- index = listPtr->topIndex + count;
- break;
- }
- ChangeListboxView(listPtr, index);
- }
- } else {
- Tcl_AppendResult(interp, "bad option \"", argv[1],
- "\": must be activate, bbox, cget, configure, ",
- "curselection, delete, get, index, insert, nearest, ",
- "scan, see, selection, size, ",
- "xview, or yview", (char *) NULL);
- goto error;
- }
- done:
- Tcl_Release((ClientData) listPtr);
- return result;
-
- error:
- Tcl_Release((ClientData) listPtr);
- return TCL_ERROR;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * DestroyListbox --
- *
- * This procedure is invoked by Tcl_EventuallyFree or Tcl_Release
- * to clean up the internal structure of a listbox at a safe time
- * (when no-one is using it anymore).
- *
- * Results:
- * None.
- *
- * Side effects:
- * Everything associated with the listbox is freed up.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-DestroyListbox(memPtr)
- char *memPtr; /* Info about listbox widget. */
-{
- register Listbox *listPtr = (Listbox *) memPtr;
- register Element *elPtr, *nextPtr;
-
- /*
- * Free up all of the list elements.
- */
-
- for (elPtr = listPtr->firstPtr; elPtr != NULL; ) {
- nextPtr = elPtr->nextPtr;
- ckfree((char *) elPtr);
- elPtr = nextPtr;
- }
-
- /*
- * Free up all the stuff that requires special handling, then
- * let Tk_FreeOptions handle all the standard option-related
- * stuff.
- */
-
- if (listPtr->textGC != None) {
- Tk_FreeGC(listPtr->display, listPtr->textGC);
- }
- if (listPtr->selTextGC != None) {
- Tk_FreeGC(listPtr->display, listPtr->selTextGC);
- }
- Tk_FreeOptions(configSpecs, (char *) listPtr, listPtr->display, 0);
- ckfree((char *) listPtr);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ConfigureListbox --
- *
- * This procedure is called to process an argv/argc list, plus
- * the Tk option database, in order to configure (or reconfigure)
- * a listbox widget.
- *
- * Results:
- * The return value is a standard Tcl result. If TCL_ERROR is
- * returned, then interp->result contains an error message.
- *
- * Side effects:
- * Configuration information, such as colors, border width,
- * etc. get set for listPtr; old resources get freed,
- * if there were any.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-ConfigureListbox(interp, listPtr, argc, argv, flags)
- Tcl_Interp *interp; /* Used for error reporting. */
- register Listbox *listPtr; /* 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 flags; /* Flags to pass to Tk_ConfigureWidget. */
-{
- int oldExport;
-
- oldExport = listPtr->exportSelection;
- if (Tk_ConfigureWidget(interp, listPtr->tkwin, configSpecs,
- argc, argv, (char *) listPtr, flags) != TCL_OK) {
- 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);
-
- 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);
- }
-
- ListboxWorldChanged((ClientData) listPtr);
- return TCL_OK;
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * ListboxWorldChanged --
- *
- * 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:
- * Listbox will be relayed out and redisplayed.
- *
- *---------------------------------------------------------------------------
- */
-
-static void
-ListboxWorldChanged(instanceData)
- ClientData instanceData; /* Information about widget. */
-{
- XGCValues gcValues;
- GC gc;
- unsigned long mask;
- Listbox *listPtr;
-
- listPtr = (Listbox *) instanceData;
-
- gcValues.foreground = listPtr->fgColorPtr->pixel;
- 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);
- }
- listPtr->textGC = gc;
-
- gcValues.foreground = listPtr->selFgColorPtr->pixel;
- gcValues.font = Tk_FontId(listPtr->tkfont);
- mask = GCForeground | GCFont;
- gc = Tk_GetGC(listPtr->tkwin, mask, &gcValues);
- if (listPtr->selTextGC != None) {
- Tk_FreeGC(listPtr->display, listPtr->selTextGC);
- }
- listPtr->selTextGC = gc;
-
- /*
- * Register the desired geometry for the window and arrange for
- * the window to be redisplayed.
- */
-
- ListboxComputeGeometry(listPtr, 1, 1, 1);
- listPtr->flags |= UPDATE_V_SCROLLBAR|UPDATE_H_SCROLLBAR;
- ListboxRedrawRange(listPtr, 0, listPtr->numElements-1);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * DisplayListbox --
- *
- * This procedure redraws the contents of a listbox window.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Information appears on the screen.
- *
- *--------------------------------------------------------------
- */
-
-static void
-DisplayListbox(clientData)
- ClientData clientData; /* Information about window. */
-{
- register Listbox *listPtr = (Listbox *) clientData;
- register Tk_Window tkwin = listPtr->tkwin;
- register Element *elPtr;
- GC gc;
- int i, limit, x, y, width, prevSelected;
- Tk_FontMetrics fm;
- int left, right; /* Non-zero values here indicate
- * that the left or right edge of
- * the listbox is off-screen. */
- Pixmap pixmap;
-
- listPtr->flags &= ~REDRAW_PENDING;
- if (listPtr->flags & UPDATE_V_SCROLLBAR) {
- ListboxUpdateVScrollbar(listPtr);
- }
- if (listPtr->flags & UPDATE_H_SCROLLBAR) {
- ListboxUpdateHScrollbar(listPtr);
- }
- listPtr->flags &= ~(REDRAW_PENDING|UPDATE_V_SCROLLBAR|UPDATE_H_SCROLLBAR);
- if ((listPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) {
- return;
- }
-
- /*
- * Redrawing is done in a temporary pixmap that is allocated
- * here and freed at the end of the procedure. All drawing is
- * done to the pixmap, and the pixmap is copied to the screen
- * at the end of the procedure. This provides the smoothest
- * possible visual effects (no flashing on the screen).
- */
-
- pixmap = Tk_GetPixmap(listPtr->display, Tk_WindowId(tkwin),
- Tk_Width(tkwin), Tk_Height(tkwin), Tk_Depth(tkwin));
- Tk_Fill3DRectangle(tkwin, pixmap, listPtr->normalBorder, 0, 0,
- Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT);
-
- /*
- * Iterate through all of the elements of the listbox, displaying each
- * in turn. Selected elements use a different GC and have a raised
- * background.
- */
-
- limit = listPtr->topIndex + listPtr->fullLines + listPtr->partialLine - 1;
- if (limit >= listPtr->numElements) {
- limit = listPtr->numElements-1;
- }
- left = right = 0;
- if (listPtr->xOffset > 0) {
- left = listPtr->selBorderWidth+1;
- }
- if ((listPtr->maxWidth - listPtr->xOffset) > (Tk_Width(listPtr->tkwin)
- - 2*(listPtr->inset + listPtr->selBorderWidth))) {
- right = listPtr->selBorderWidth+1;
- }
- prevSelected = 0;
- for (elPtr = listPtr->firstPtr, i = 0; (elPtr != NULL) && (i <= limit);
- prevSelected = elPtr->selected, elPtr = elPtr->nextPtr, i++) {
- if (i < listPtr->topIndex) {
- continue;
- }
- x = listPtr->inset;
- y = ((i - listPtr->topIndex) * listPtr->lineHeight)
- + listPtr->inset;
- gc = listPtr->textGC;
- if (elPtr->selected) {
- gc = listPtr->selTextGC;
- width = Tk_Width(tkwin) - 2*listPtr->inset;
- Tk_Fill3DRectangle(tkwin, pixmap, listPtr->selBorder, 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.
- */
-
- if (left == 0) {
- Tk_3DVerticalBevel(tkwin, pixmap, listPtr->selBorder,
- x, y, listPtr->selBorderWidth, listPtr->lineHeight,
- 1, TK_RELIEF_RAISED);
- }
- if (right == 0) {
- Tk_3DVerticalBevel(tkwin, pixmap, listPtr->selBorder,
- x + width - listPtr->selBorderWidth, y,
- listPtr->selBorderWidth, listPtr->lineHeight,
- 0, TK_RELIEF_RAISED);
- }
- if (!prevSelected) {
- Tk_3DHorizontalBevel(tkwin, pixmap, listPtr->selBorder,
- x-left, y, width+left+right, listPtr->selBorderWidth,
- 1, 1, 1, TK_RELIEF_RAISED);
- }
- if ((elPtr->nextPtr == NULL) || !elPtr->nextPtr->selected) {
- Tk_3DHorizontalBevel(tkwin, pixmap, listPtr->selBorder, x-left,
- y + listPtr->lineHeight - listPtr->selBorderWidth,
- width+left+right, listPtr->selBorderWidth, 0, 0, 0,
- TK_RELIEF_RAISED);
- }
- }
- Tk_GetFontMetrics(listPtr->tkfont, &fm);
- y += fm.ascent + listPtr->selBorderWidth;
- x = listPtr->inset + listPtr->selBorderWidth - elPtr->lBearing
- - listPtr->xOffset;
- Tk_DrawChars(listPtr->display, pixmap, gc, listPtr->tkfont,
- elPtr->text, elPtr->textLength, x, y);
-
- /*
- * If this is the active element, underline it.
- */
-
- if ((i == listPtr->active) && (listPtr->flags & GOT_FOCUS)) {
- Tk_UnderlineChars(listPtr->display, pixmap, gc, listPtr->tkfont,
- elPtr->text, x, y, 0, elPtr->textLength);
- }
- }
-
- /*
- * Redraw the border for the listbox to make sure that it's on top
- * of any of the text of the listbox entries.
- */
-
- Tk_Draw3DRectangle(tkwin, pixmap, listPtr->normalBorder,
- listPtr->highlightWidth, listPtr->highlightWidth,
- Tk_Width(tkwin) - 2*listPtr->highlightWidth,
- Tk_Height(tkwin) - 2*listPtr->highlightWidth,
- listPtr->borderWidth, listPtr->relief);
- if (listPtr->highlightWidth > 0) {
- GC gc;
-
- if (listPtr->flags & GOT_FOCUS) {
- gc = Tk_GCForColor(listPtr->highlightColorPtr, pixmap);
- } else {
- gc = Tk_GCForColor(listPtr->highlightBgColorPtr, pixmap);
- }
- Tk_DrawFocusHighlight(tkwin, gc, listPtr->highlightWidth, pixmap);
- }
- XCopyArea(listPtr->display, pixmap, Tk_WindowId(tkwin),
- listPtr->textGC, 0, 0, (unsigned) Tk_Width(tkwin),
- (unsigned) Tk_Height(tkwin), 0, 0);
- Tk_FreePixmap(listPtr->display, pixmap);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ListboxComputeGeometry --
- *
- * This procedure is invoked to recompute geometry information
- * such as the sizes of the elements and the overall dimensions
- * desired for the listbox.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Geometry information is updated and a new requested size is
- * registered for the widget. Internal border and gridding
- * information is also set.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-ListboxComputeGeometry(listPtr, fontChanged, maxIsStale, updateGrid)
- Listbox *listPtr; /* Listbox whose geometry is to be
- * recomputed. */
- int fontChanged; /* Non-zero means the font may have changed
- * so per-element width information also
- * has to be computed. */
- int maxIsStale; /* Non-zero means the "maxWidth" field may
- * no longer be up-to-date and must
- * be recomputed. If fontChanged is 1 then
- * this must be 1. */
- int updateGrid; /* Non-zero means call Tk_SetGrid or
- * Tk_UnsetGrid to update gridding for
- * the window. */
-{
- register Element *elPtr;
- int width, height, pixelWidth, pixelHeight;
- Tk_FontMetrics fm;
-
- if (fontChanged || maxIsStale) {
- listPtr->xScrollUnit = Tk_TextWidth(listPtr->tkfont, "0", 1);
- if (listPtr->xScrollUnit == 0) {
- listPtr->xScrollUnit = 1;
- }
- listPtr->maxWidth = 0;
- for (elPtr = listPtr->firstPtr; elPtr != NULL; elPtr = elPtr->nextPtr) {
- if (fontChanged) {
- elPtr->pixelWidth = Tk_TextWidth(listPtr->tkfont,
- elPtr->text, elPtr->textLength);
- elPtr->lBearing = 0;
- }
- if (elPtr->pixelWidth > listPtr->maxWidth) {
- listPtr->maxWidth = elPtr->pixelWidth;
- }
- }
- }
-
- Tk_GetFontMetrics(listPtr->tkfont, &fm);
- listPtr->lineHeight = fm.linespace + 1 + 2*listPtr->selBorderWidth;
- width = listPtr->width;
- if (width <= 0) {
- width = (listPtr->maxWidth + listPtr->xScrollUnit - 1)
- /listPtr->xScrollUnit;
- if (width < 1) {
- width = 1;
- }
- }
- pixelWidth = width*listPtr->xScrollUnit + 2*listPtr->inset
- + 2*listPtr->selBorderWidth;
- height = listPtr->height;
- if (listPtr->height <= 0) {
- height = listPtr->numElements;
- if (height < 1) {
- height = 1;
- }
- }
- pixelHeight = height*listPtr->lineHeight + 2*listPtr->inset;
- Tk_GeometryRequest(listPtr->tkwin, pixelWidth, pixelHeight);
- Tk_SetInternalBorder(listPtr->tkwin, listPtr->inset);
- if (updateGrid) {
- if (listPtr->setGrid) {
- Tk_SetGrid(listPtr->tkwin, width, height, listPtr->xScrollUnit,
- listPtr->lineHeight);
- } else {
- Tk_UnsetGrid(listPtr->tkwin);
- }
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * InsertEls --
- *
- * Add new elements to a listbox widget.
- *
- * Results:
- * None.
- *
- * Side effects:
- * New information gets added to listPtr; it will be redisplayed
- * soon, but not immediately.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-InsertEls(listPtr, index, argc, argv)
- register Listbox *listPtr; /* Listbox that is to get the new
- * elements. */
- int index; /* Add the new elements before this
- * element. */
- int argc; /* Number of new elements to add. */
- char **argv; /* New elements (one per entry). */
-{
- register Element *prevPtr, *newPtr;
- int length, i, oldMaxWidth;
-
- /*
- * Find the element before which the new ones will be inserted.
- */
-
- if (index <= 0) {
- index = 0;
- }
- if (index > listPtr->numElements) {
- index = listPtr->numElements;
- }
- if (index == 0) {
- prevPtr = NULL;
- } else if (index == listPtr->numElements) {
- prevPtr = listPtr->lastPtr;
- } else {
- for (prevPtr = listPtr->firstPtr, i = index - 1; i > 0; i--) {
- prevPtr = prevPtr->nextPtr;
- }
- }
-
- /*
- * For each new element, create a record, initialize it, and link
- * it into the list of elements.
- */
-
- oldMaxWidth = listPtr->maxWidth;
- for (i = argc ; i > 0; i--, argv++, prevPtr = newPtr) {
- length = strlen(*argv);
- newPtr = (Element *) ckalloc(ElementSize(length));
- newPtr->textLength = length;
- strcpy(newPtr->text, *argv);
- newPtr->pixelWidth = Tk_TextWidth(listPtr->tkfont, newPtr->text,
- newPtr->textLength);
- newPtr->lBearing = 0;
- if (newPtr->pixelWidth > listPtr->maxWidth) {
- listPtr->maxWidth = newPtr->pixelWidth;
- }
- newPtr->selected = 0;
- if (prevPtr == NULL) {
- newPtr->nextPtr = listPtr->firstPtr;
- listPtr->firstPtr = newPtr;
- } else {
- newPtr->nextPtr = prevPtr->nextPtr;
- prevPtr->nextPtr = newPtr;
- }
- }
- if ((prevPtr != NULL) && (prevPtr->nextPtr == NULL)) {
- listPtr->lastPtr = prevPtr;
- }
- listPtr->numElements += argc;
-
- /*
- * Update the selection and other indexes to account for the
- * renumbering that has just occurred. Then arrange for the new
- * information to be displayed.
- */
-
- if (index <= listPtr->selectAnchor) {
- listPtr->selectAnchor += argc;
- }
- if (index < listPtr->topIndex) {
- listPtr->topIndex += argc;
- }
- if (index <= listPtr->active) {
- listPtr->active += argc;
- if ((listPtr->active >= listPtr->numElements)
- && (listPtr->numElements > 0)) {
- listPtr->active = listPtr->numElements-1;
- }
- }
- listPtr->flags |= UPDATE_V_SCROLLBAR;
- if (listPtr->maxWidth != oldMaxWidth) {
- listPtr->flags |= UPDATE_H_SCROLLBAR;
- }
- ListboxComputeGeometry(listPtr, 0, 0, 0);
- ListboxRedrawRange(listPtr, index, listPtr->numElements-1);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * DeleteEls --
- *
- * Remove one or more elements from a listbox widget.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Memory gets freed, the listbox gets modified and (eventually)
- * redisplayed.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-DeleteEls(listPtr, first, last)
- register Listbox *listPtr; /* Listbox widget to modify. */
- int first; /* Index of first element to delete. */
- int last; /* Index of last element to delete. */
-{
- register Element *prevPtr, *elPtr;
- int count, i, widthChanged;
-
- /*
- * Adjust the range to fit within the existing elements of the
- * listbox, and make sure there's something to delete.
- */
-
- if (first < 0) {
- first = 0;
- }
- if (last >= listPtr->numElements) {
- last = listPtr->numElements-1;
- }
- count = last + 1 - first;
- if (count <= 0) {
- return;
- }
-
- /*
- * Find the element just before the ones to delete.
- */
-
- if (first == 0) {
- prevPtr = NULL;
- } else {
- for (i = first-1, prevPtr = listPtr->firstPtr; i > 0; i--) {
- prevPtr = prevPtr->nextPtr;
- }
- }
-
- /*
- * Delete the requested number of elements.
- */
-
- widthChanged = 0;
- for (i = count; i > 0; i--) {
- if (prevPtr == NULL) {
- elPtr = listPtr->firstPtr;
- listPtr->firstPtr = elPtr->nextPtr;
- if (listPtr->firstPtr == NULL) {
- listPtr->lastPtr = NULL;
- }
- } else {
- elPtr = prevPtr->nextPtr;
- prevPtr->nextPtr = elPtr->nextPtr;
- if (prevPtr->nextPtr == NULL) {
- listPtr->lastPtr = prevPtr;
- }
- }
- if (elPtr->pixelWidth == listPtr->maxWidth) {
- widthChanged = 1;
- }
- if (elPtr->selected) {
- listPtr->numSelected -= 1;
- }
- ckfree((char *) elPtr);
- }
- listPtr->numElements -= count;
-
- /*
- * Update the selection and viewing information to reflect the change
- * in the element numbering, and redisplay to slide information up over
- * the elements that were deleted.
- */
-
- if (first <= listPtr->selectAnchor) {
- listPtr->selectAnchor -= count;
- if (listPtr->selectAnchor < first) {
- listPtr->selectAnchor = first;
- }
- }
- if (first <= listPtr->topIndex) {
- listPtr->topIndex -= count;
- if (listPtr->topIndex < first) {
- listPtr->topIndex = first;
- }
- }
- if (listPtr->topIndex > (listPtr->numElements - listPtr->fullLines)) {
- listPtr->topIndex = listPtr->numElements - listPtr->fullLines;
- if (listPtr->topIndex < 0) {
- listPtr->topIndex = 0;
- }
- }
- if (listPtr->active > last) {
- listPtr->active -= count;
- } else if (listPtr->active >= first) {
- listPtr->active = first;
- if ((listPtr->active >= listPtr->numElements)
- && (listPtr->numElements > 0)) {
- listPtr->active = listPtr->numElements-1;
- }
- }
- listPtr->flags |= UPDATE_V_SCROLLBAR;
- ListboxComputeGeometry(listPtr, 0, widthChanged, 0);
- if (widthChanged) {
- listPtr->flags |= UPDATE_H_SCROLLBAR;
- }
- ListboxRedrawRange(listPtr, first, listPtr->numElements-1);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ListboxEventProc --
- *
- * This procedure is invoked by the Tk dispatcher for various
- * events on listboxes.
- *
- * Results:
- * None.
- *
- * Side effects:
- * When the window gets deleted, internal structures get
- * cleaned up. When it gets exposed, it is redisplayed.
- *
- *--------------------------------------------------------------
- */
-
-static void
-ListboxEventProc(clientData, eventPtr)
- ClientData clientData; /* Information about window. */
- XEvent *eventPtr; /* Information about event. */
-{
- Listbox *listPtr = (Listbox *) clientData;
-
- if (eventPtr->type == Expose) {
- ListboxRedrawRange(listPtr,
- NearestListboxElement(listPtr, eventPtr->xexpose.y),
- NearestListboxElement(listPtr, eventPtr->xexpose.y
- + eventPtr->xexpose.height));
- } else if (eventPtr->type == DestroyNotify) {
- if (listPtr->tkwin != NULL) {
- if (listPtr->setGrid) {
- Tk_UnsetGrid(listPtr->tkwin);
- }
- listPtr->tkwin = NULL;
- Tcl_DeleteCommandFromToken(listPtr->interp, listPtr->widgetCmd);
- }
- if (listPtr->flags & REDRAW_PENDING) {
- Tcl_CancelIdleCall(DisplayListbox, (ClientData) listPtr);
- }
- Tcl_EventuallyFree((ClientData) listPtr, DestroyListbox);
- } else if (eventPtr->type == ConfigureNotify) {
- int vertSpace;
-
- vertSpace = Tk_Height(listPtr->tkwin) - 2*listPtr->inset;
- listPtr->fullLines = vertSpace / listPtr->lineHeight;
- if ((listPtr->fullLines*listPtr->lineHeight) < vertSpace) {
- listPtr->partialLine = 1;
- } else {
- listPtr->partialLine = 0;
- }
- listPtr->flags |= UPDATE_V_SCROLLBAR|UPDATE_H_SCROLLBAR;
- ChangeListboxView(listPtr, listPtr->topIndex);
- ChangeListboxOffset(listPtr, listPtr->xOffset);
-
- /*
- * Redraw the whole listbox. It's hard to tell what needs
- * to be redrawn (e.g. if the listbox has shrunk then we
- * may only need to redraw the borders), so just redraw
- * everything for safety.
- */
-
- ListboxRedrawRange(listPtr, 0, listPtr->numElements-1);
- } else if (eventPtr->type == FocusIn) {
- if (eventPtr->xfocus.detail != NotifyInferior) {
- listPtr->flags |= GOT_FOCUS;
- ListboxRedrawRange(listPtr, 0, listPtr->numElements-1);
- }
- } else if (eventPtr->type == FocusOut) {
- if (eventPtr->xfocus.detail != NotifyInferior) {
- listPtr->flags &= ~GOT_FOCUS;
- ListboxRedrawRange(listPtr, 0, listPtr->numElements-1);
- }
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ListboxCmdDeletedProc --
- *
- * 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
-ListboxCmdDeletedProc(clientData)
- ClientData clientData; /* Pointer to widget record for widget. */
-{
- Listbox *listPtr = (Listbox *) clientData;
- Tk_Window tkwin = listPtr->tkwin;
-
- /*
- * This procedure could be invoked either because the window was
- * destroyed and the command was then deleted (in which case tkwin
- * is NULL) or because the command was deleted, and then this procedure
- * destroys the widget.
- */
-
- if (tkwin != NULL) {
- if (listPtr->setGrid) {
- Tk_UnsetGrid(listPtr->tkwin);
- }
- listPtr->tkwin = NULL;
- Tk_DestroyWindow(tkwin);
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * GetListboxIndex --
- *
- * Parse an index into a listbox and return either its value
- * or an error.
- *
- * Results:
- * A standard Tcl result. If all went well, then *indexPtr is
- * filled in with the index (into listPtr) corresponding to
- * string. Otherwise an error message is left in interp->result.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-static int
-GetListboxIndex(interp, listPtr, string, endIsSize, indexPtr)
- Tcl_Interp *interp; /* For error messages. */
- Listbox *listPtr; /* Listbox for which the index is being
- * specified. */
- char *string; /* Specifies an element in the listbox. */
- int endIsSize; /* If 1, "end" refers to the number of
- * entries in the listbox. If 0, "end"
- * refers to 1 less than the number of
- * entries. */
- int *indexPtr; /* Where to store converted index. */
-{
- int c;
- size_t length;
-
- length = strlen(string);
- c = string[0];
- if ((c == 'a') && (strncmp(string, "active", length) == 0)
- && (length >= 2)) {
- *indexPtr = listPtr->active;
- } else if ((c == 'a') && (strncmp(string, "anchor", length) == 0)
- && (length >= 2)) {
- *indexPtr = listPtr->selectAnchor;
- } else if ((c == 'e') && (strncmp(string, "end", length) == 0)) {
- if (endIsSize) {
- *indexPtr = listPtr->numElements;
- } else {
- *indexPtr = listPtr->numElements - 1;
- }
- } else if (c == '@') {
- int y;
- char *p, *end;
-
- p = string+1;
- strtol(p, &end, 0);
- if ((end == p) || (*end != ',')) {
- goto badIndex;
- }
- p = end+1;
- y = strtol(p, &end, 0);
- if ((end == p) || (*end != 0)) {
- goto badIndex;
- }
- *indexPtr = NearestListboxElement(listPtr, y);
- } else {
- if (Tcl_GetInt(interp, string, indexPtr) != TCL_OK) {
- Tcl_ResetResult(interp);
- goto badIndex;
- }
- }
- return TCL_OK;
-
- badIndex:
- Tcl_AppendResult(interp, "bad listbox index \"", string,
- "\": must be active, anchor, end, @x,y, or a number",
- (char *) NULL);
- return TCL_ERROR;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ChangeListboxView --
- *
- * Change the view on a listbox widget so that a given element
- * is displayed at the top.
- *
- * Results:
- * None.
- *
- * Side effects:
- * What's displayed on the screen is changed. If there is a
- * scrollbar associated with this widget, then the scrollbar
- * is instructed to change its display too.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-ChangeListboxView(listPtr, index)
- register Listbox *listPtr; /* Information about widget. */
- int index; /* Index of element in listPtr
- * that should now appear at the
- * top of the listbox. */
-{
- if (index >= (listPtr->numElements - listPtr->fullLines)) {
- index = listPtr->numElements - listPtr->fullLines;
- }
- if (index < 0) {
- index = 0;
- }
- if (listPtr->topIndex != index) {
- listPtr->topIndex = index;
- if (!(listPtr->flags & REDRAW_PENDING)) {
- Tcl_DoWhenIdle(DisplayListbox, (ClientData) listPtr);
- listPtr->flags |= REDRAW_PENDING;
- }
- listPtr->flags |= UPDATE_V_SCROLLBAR;
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ChangListboxOffset --
- *
- * Change the horizontal offset for a listbox.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The listbox may be redrawn to reflect its new horizontal
- * offset.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-ChangeListboxOffset(listPtr, offset)
- register Listbox *listPtr; /* Information about widget. */
- int offset; /* Desired new "xOffset" for
- * listbox. */
-{
- int maxOffset;
-
- /*
- * Make sure that the new offset is within the allowable range, and
- * round it off to an even multiple of xScrollUnit.
- */
-
- maxOffset = listPtr->maxWidth - (Tk_Width(listPtr->tkwin) -
- 2*listPtr->inset - 2*listPtr->selBorderWidth)
- + listPtr->xScrollUnit - 1;
- if (offset > maxOffset) {
- offset = maxOffset;
- }
- if (offset < 0) {
- offset = 0;
- }
- offset -= offset % listPtr->xScrollUnit;
- if (offset != listPtr->xOffset) {
- listPtr->xOffset = offset;
- listPtr->flags |= UPDATE_H_SCROLLBAR;
- ListboxRedrawRange(listPtr, 0, listPtr->numElements);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ListboxScanTo --
- *
- * Given a point (presumably of the curent mouse location)
- * drag the view in the window to implement the scan operation.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The view in the window may change.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-ListboxScanTo(listPtr, x, y)
- register Listbox *listPtr; /* Information about widget. */
- int x; /* X-coordinate to use for scan
- * operation. */
- int y; /* Y-coordinate to use for scan
- * operation. */
-{
- int newTopIndex, newOffset, maxIndex, maxOffset;
-
- maxIndex = listPtr->numElements - listPtr->fullLines;
- maxOffset = listPtr->maxWidth + (listPtr->xScrollUnit - 1)
- - (Tk_Width(listPtr->tkwin) - 2*listPtr->inset
- - 2*listPtr->selBorderWidth - listPtr->xScrollUnit);
-
- /*
- * Compute new top line for screen by amplifying the difference
- * between the current position and the place where the scan
- * started (the "mark" position). If we run off the top or bottom
- * of the list, then reset the mark point so that the current
- * position continues to correspond to the edge of the window.
- * This means that the picture will start dragging as soon as the
- * mouse reverses direction (without this reset, might have to slide
- * mouse a long ways back before the picture starts moving again).
- */
-
- newTopIndex = listPtr->scanMarkYIndex
- - (10*(y - listPtr->scanMarkY))/listPtr->lineHeight;
- if (newTopIndex > maxIndex) {
- newTopIndex = listPtr->scanMarkYIndex = maxIndex;
- listPtr->scanMarkY = y;
- } else if (newTopIndex < 0) {
- newTopIndex = listPtr->scanMarkYIndex = 0;
- listPtr->scanMarkY = y;
- }
- ChangeListboxView(listPtr, newTopIndex);
-
- /*
- * Compute new left edge for display in a similar fashion by amplifying
- * the difference between the current position and the place where the
- * scan started.
- */
-
- newOffset = listPtr->scanMarkXOffset - (10*(x - listPtr->scanMarkX));
- if (newOffset > maxOffset) {
- newOffset = listPtr->scanMarkXOffset = maxOffset;
- listPtr->scanMarkX = x;
- } else if (newOffset < 0) {
- newOffset = listPtr->scanMarkXOffset = 0;
- listPtr->scanMarkX = x;
- }
- ChangeListboxOffset(listPtr, newOffset);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * NearestListboxElement --
- *
- * Given a y-coordinate inside a listbox, compute the index of
- * the element under that y-coordinate (or closest to that
- * y-coordinate).
- *
- * Results:
- * The return value is an index of an element of listPtr. If
- * listPtr has no elements, then 0 is always returned.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-NearestListboxElement(listPtr, y)
- register Listbox *listPtr; /* Information about widget. */
- int y; /* Y-coordinate in listPtr's window. */
-{
- int index;
-
- index = (y - listPtr->inset)/listPtr->lineHeight;
- if (index >= (listPtr->fullLines + listPtr->partialLine)) {
- index = listPtr->fullLines + listPtr->partialLine - 1;
- }
- if (index < 0) {
- index = 0;
- }
- index += listPtr->topIndex;
- if (index >= listPtr->numElements) {
- index = listPtr->numElements-1;
- }
- return index;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ListboxSelect --
- *
- * Select or deselect one or more elements in a listbox..
- *
- * Results:
- * None.
- *
- * Side effects:
- * All of the elements in the range between first and last are
- * marked as either selected or deselected, depending on the
- * "select" argument. Any items whose state changes are redisplayed.
- * The selection is claimed from X when the number of selected
- * elements changes from zero to non-zero.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-ListboxSelect(listPtr, first, last, select)
- register Listbox *listPtr; /* Information about widget. */
- int first; /* Index of first element to
- * select or deselect. */
- int last; /* Index of last element to
- * select or deselect. */
- int select; /* 1 means select items, 0 means
- * deselect them. */
-{
- int i, firstRedisplay, increment, oldCount;
- Element *elPtr;
-
- if (last < first) {
- i = first;
- first = last;
- last = i;
- }
- if ((last < 0) || (first >= listPtr->numElements)) {
- return;
- }
- if (first < 0) {
- first = 0;
- }
- if (last >= listPtr->numElements) {
- last = listPtr->numElements - 1;
- }
- oldCount = listPtr->numSelected;
- firstRedisplay = -1;
- increment = select ? 1 : -1;
- for (i = 0, elPtr = listPtr->firstPtr; i < first;
- i++, elPtr = elPtr->nextPtr) {
- /* Empty loop body. */
- }
- for ( ; i <= last; i++, elPtr = elPtr->nextPtr) {
- if (elPtr->selected == select) {
- continue;
- }
- listPtr->numSelected += increment;
- elPtr->selected = select;
- if (firstRedisplay < 0) {
- firstRedisplay = i;
- }
- }
- if (firstRedisplay >= 0) {
- ListboxRedrawRange(listPtr, first, last);
- }
- if ((oldCount == 0) && (listPtr->numSelected > 0)
- && (listPtr->exportSelection)) {
- Tk_OwnSelection(listPtr->tkwin, XA_PRIMARY, ListboxLostSelection,
- (ClientData) listPtr);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ListboxFetchSelection --
- *
- * This procedure is called back by Tk when the selection is
- * requested by someone. It returns part or all of the selection
- * in a buffer provided by the caller.
- *
- * Results:
- * The return value is the number of non-NULL bytes stored
- * at buffer. Buffer is filled (or partially filled) with a
- * NULL-terminated string containing part or all of the selection,
- * as given by offset and maxBytes. The selection is returned
- * as a Tcl list with one list element for each element in the
- * listbox.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-ListboxFetchSelection(clientData, offset, buffer, maxBytes)
- ClientData clientData; /* Information about listbox widget. */
- int offset; /* Offset within selection of first
- * byte to be returned. */
- char *buffer; /* Location in which to place
- * selection. */
- int maxBytes; /* Maximum number of bytes to place
- * at buffer, not including terminating
- * NULL character. */
-{
- register Listbox *listPtr = (Listbox *) clientData;
- register Element *elPtr;
- Tcl_DString selection;
- int length, count, needNewline;
-
- if (!listPtr->exportSelection) {
- return -1;
- }
-
- /*
- * Use a dynamic string to accumulate the contents of the selection.
- */
-
- needNewline = 0;
- Tcl_DStringInit(&selection);
- for (elPtr = listPtr->firstPtr; elPtr != NULL; elPtr = elPtr->nextPtr) {
- if (elPtr->selected) {
- if (needNewline) {
- Tcl_DStringAppend(&selection, "\n", 1);
- }
- Tcl_DStringAppend(&selection, elPtr->text, elPtr->textLength);
- needNewline = 1;
- }
- }
-
- length = Tcl_DStringLength(&selection);
- if (length == 0) {
- return -1;
- }
-
- /*
- * Copy the requested portion of the selection to the buffer.
- */
-
- count = length - offset;
- if (count <= 0) {
- count = 0;
- } else {
- if (count > maxBytes) {
- count = maxBytes;
- }
- memcpy((VOID *) buffer,
- (VOID *) (Tcl_DStringValue(&selection) + offset),
- (size_t) count);
- }
- buffer[count] = '\0';
- Tcl_DStringFree(&selection);
- return count;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ListboxLostSelection --
- *
- * This procedure is called back by Tk when the selection is
- * grabbed away from a listbox widget.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The existing selection is unhighlighted, and the window is
- * marked as not containing a selection.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-ListboxLostSelection(clientData)
- ClientData clientData; /* Information about listbox widget. */
-{
- register Listbox *listPtr = (Listbox *) clientData;
-
- if ((listPtr->exportSelection) && (listPtr->numElements > 0)) {
- ListboxSelect(listPtr, 0, listPtr->numElements-1, 0);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ListboxRedrawRange --
- *
- * Ensure that a given range of elements is eventually redrawn on
- * the display (if those elements in fact appear on the display).
- *
- * Results:
- * None.
- *
- * Side effects:
- * Information gets redisplayed.
- *
- *----------------------------------------------------------------------
- */
-
- /* ARGSUSED */
-static void
-ListboxRedrawRange(listPtr, first, last)
- register Listbox *listPtr; /* Information about widget. */
- int first; /* Index of first element in list
- * that needs to be redrawn. */
- int last; /* Index of last element in list
- * that needs to be redrawn. May
- * be less than first;
- * these just bracket a range. */
-{
- if ((listPtr->tkwin == NULL) || !Tk_IsMapped(listPtr->tkwin)
- || (listPtr->flags & REDRAW_PENDING)) {
- return;
- }
- Tcl_DoWhenIdle(DisplayListbox, (ClientData) listPtr);
- listPtr->flags |= REDRAW_PENDING;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ListboxUpdateVScrollbar --
- *
- * This procedure is invoked whenever information has changed in
- * a listbox in a way that would invalidate a vertical scrollbar
- * display. If there is an associated scrollbar, then this command
- * updates it by invoking a Tcl command.
- *
- * Results:
- * None.
- *
- * Side effects:
- * A Tcl command is invoked, and an additional command may be
- * invoked to process errors in the command.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-ListboxUpdateVScrollbar(listPtr)
- register Listbox *listPtr; /* Information about widget. */
-{
- char string[100];
- double first, last;
- int result;
- Tcl_Interp *interp;
-
- if (listPtr->yScrollCmd == NULL) {
- return;
- }
- if (listPtr->numElements == 0) {
- first = 0.0;
- last = 1.0;
- } else {
- first = listPtr->topIndex/((double) listPtr->numElements);
- last = (listPtr->topIndex+listPtr->fullLines)
- /((double) listPtr->numElements);
- if (last > 1.0) {
- last = 1.0;
- }
- }
- sprintf(string, " %g %g", first, last);
-
- /*
- * We must hold onto the interpreter from the listPtr because the data
- * at listPtr might be freed as a result of the Tcl_VarEval.
- */
-
- interp = listPtr->interp;
- Tcl_Preserve((ClientData) interp);
- result = Tcl_VarEval(interp, listPtr->yScrollCmd, string,
- (char *) NULL);
- if (result != TCL_OK) {
- Tcl_AddErrorInfo(interp,
- "\n (vertical scrolling command executed by listbox)");
- Tcl_BackgroundError(interp);
- }
- Tcl_Release((ClientData) interp);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ListboxUpdateHScrollbar --
- *
- * This procedure is invoked whenever information has changed in
- * a listbox in a way that would invalidate a horizontal scrollbar
- * display. If there is an associated horizontal scrollbar, then
- * this command updates it by invoking a Tcl command.
- *
- * Results:
- * None.
- *
- * Side effects:
- * A Tcl command is invoked, and an additional command may be
- * invoked to process errors in the command.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-ListboxUpdateHScrollbar(listPtr)
- register Listbox *listPtr; /* Information about widget. */
-{
- char string[60];
- int result, windowWidth;
- double first, last;
- Tcl_Interp *interp;
-
- if (listPtr->xScrollCmd == NULL) {
- return;
- }
- windowWidth = Tk_Width(listPtr->tkwin) - 2*(listPtr->inset
- + listPtr->selBorderWidth);
- if (listPtr->maxWidth == 0) {
- first = 0;
- last = 1.0;
- } else {
- first = listPtr->xOffset/((double) listPtr->maxWidth);
- last = (listPtr->xOffset + windowWidth)
- /((double) listPtr->maxWidth);
- if (last > 1.0) {
- last = 1.0;
- }
- }
- sprintf(string, " %g %g", first, last);
-
- /*
- * We must hold onto the interpreter because the data referred to at
- * listPtr might be freed as a result of the call to Tcl_VarEval.
- */
-
- interp = listPtr->interp;
- Tcl_Preserve((ClientData) interp);
- result = Tcl_VarEval(interp, listPtr->xScrollCmd, string,
- (char *) NULL);
- if (result != TCL_OK) {
- Tcl_AddErrorInfo(interp,
- "\n (horizontal scrolling command executed by listbox)");
- Tcl_BackgroundError(interp);
- }
- Tcl_Release((ClientData) interp);
-}
diff --git a/generic/tkMacWinMenu.c b/generic/tkMacWinMenu.c
deleted file mode 100644
index 6453a5f..0000000
--- a/generic/tkMacWinMenu.c
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * tkMacWinMenu.c --
- *
- * This module implements the common elements of the Mac and Windows
- * specific features of menus. This file is not used for UNIX.
- *
- * Copyright (c) 1996-1997 by 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: tkMacWinMenu.c,v 1.2 1998/09/14 18:23:14 stanton Exp $
- */
-
-#include "tkMenu.h"
-
-static int postCommandGeneration;
-
-static int PreprocessMenu _ANSI_ARGS_((TkMenu *menuPtr));
-
-
-/*
- *----------------------------------------------------------------------
- *
- * PreprocessMenu --
- *
- * The guts of the preprocessing. Recursive.
- *
- * Results:
- * The return value is a standard Tcl result (errors can occur
- * while the postcommands are being processed).
- *
- * Side effects:
- * Since commands can get executed while this routine is being executed,
- * the entire world can change.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-PreprocessMenu(menuPtr)
- TkMenu *menuPtr;
-{
- int index, result, finished;
- TkMenu *cascadeMenuPtr;
-
- Tcl_Preserve((ClientData) menuPtr);
-
- /*
- * First, let's process the post command on ourselves. If this command
- * destroys this menu, or if there was an error, we are done.
- */
-
- result = TkPostCommand(menuPtr);
- if ((result != TCL_OK) || (menuPtr->tkwin == NULL)) {
- goto done;
- }
-
- /*
- * Now, we go through structure and process all of the commands.
- * Since the structure is changing, we stop after we do one command,
- * and start over. When we get through without doing any, we are done.
- */
-
-
- do {
- finished = 1;
- for (index = 0; index < menuPtr->numEntries; index++) {
- if ((menuPtr->entries[index]->type == CASCADE_ENTRY)
- && (menuPtr->entries[index]->name != NULL)) {
- if ((menuPtr->entries[index]->childMenuRefPtr != NULL)
- && (menuPtr->entries[index]->childMenuRefPtr->menuPtr
- != NULL)) {
- cascadeMenuPtr =
- menuPtr->entries[index]->childMenuRefPtr->menuPtr;
- if (cascadeMenuPtr->postCommandGeneration !=
- postCommandGeneration) {
- cascadeMenuPtr->postCommandGeneration =
- postCommandGeneration;
- result = PreprocessMenu(cascadeMenuPtr);
- if (result != TCL_OK) {
- goto done;
- }
- finished = 0;
- break;
- }
- }
- }
- }
- } while (!finished);
-
- done:
- Tcl_Release((ClientData)menuPtr);
- return result;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkPreprocessMenu --
- *
- * On the Mac and on Windows, all of the postcommand processing has
- * to be done on the entire tree underneath the main window to be
- * posted. This means that we have to traverse the menu tree and
- * issue the postcommands for all of the menus that have cascades
- * attached. Since the postcommands can change the menu structure while
- * we are traversing, we have to be extremely careful. Basically, the
- * idea is to traverse the structure until we succesfully process
- * one postcommand. Then we start over, and do it again until
- * we traverse the whole structure without processing any postcommands.
- *
- * We are also going to set up the cascade back pointers in here
- * since we have to traverse the entire structure underneath the menu
- * anyway, We can clear the postcommand marks while we do that.
- *
- * Results:
- * The return value is a standard Tcl result (errors can occur
- * while the postcommands are being processed).
- *
- * Side effects:
- * Since commands can get executed while this routine is being executed,
- * the entire world can change.
- *
- *----------------------------------------------------------------------
- */
-
-int
-TkPreprocessMenu(menuPtr)
- TkMenu *menuPtr;
-{
- postCommandGeneration++;
- menuPtr->postCommandGeneration = postCommandGeneration;
- return PreprocessMenu(menuPtr);
-}
diff --git a/generic/tkMain.c b/generic/tkMain.c
deleted file mode 100644
index 0583408..0000000
--- a/generic/tkMain.c
+++ /dev/null
@@ -1,390 +0,0 @@
-/*
- * tkMain.c --
- *
- * This file contains a generic main program for Tk-based applications.
- * It can be used as-is for many applications, just by supplying a
- * different appInitProc procedure for each specific application.
- * Or, it can be used as a template for creating new main programs
- * for Tk applications.
- *
- * 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: tkMain.c,v 1.2 1998/09/14 18:23:14 stanton Exp $
- */
-
-#include <ctype.h>
-#include <stdio.h>
-#include <string.h>
-#include <tcl.h>
-#include <tk.h>
-#ifdef NO_STDLIB_H
-# include "../compat/stdlib.h"
-#else
-# include <stdlib.h>
-#endif
-
-/*
- * Declarations for various library procedures and variables (don't want
- * to include tkInt.h or tkPort.h here, because people might copy this
- * file out of the Tk source directory to make their own modified versions).
- * Note: don't declare "exit" here even though a declaration is really
- * needed, because it will conflict with a declaration elsewhere on
- * some systems.
- */
-
-extern int isatty _ANSI_ARGS_((int fd));
-#if !defined(__WIN32__) && !defined(_WIN32)
-extern char * strrchr _ANSI_ARGS_((CONST char *string, int c));
-#endif
-extern void TkpDisplayWarning _ANSI_ARGS_((char *msg,
- char *title));
-
-/*
- * Global variables used by the main program:
- */
-
-static Tcl_Interp *interp; /* Interpreter for this application. */
-static Tcl_DString command; /* Used to assemble lines of terminal input
- * into Tcl commands. */
-static Tcl_DString line; /* Used to read the next line from the
- * terminal input. */
-static int tty; /* Non-zero means standard input is a
- * terminal-like device. Zero means it's
- * a file. */
-
-/*
- * Forward declarations for procedures defined later in this file.
- */
-
-static void Prompt _ANSI_ARGS_((Tcl_Interp *interp, int partial));
-static void StdinProc _ANSI_ARGS_((ClientData clientData,
- int mask));
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_Main --
- *
- * Main program for Wish and most other Tk-based applications.
- *
- * Results:
- * None. This procedure never returns (it exits the process when
- * it's done.
- *
- * Side effects:
- * This procedure initializes the Tk world and then starts
- * interpreting commands; almost anything could happen, depending
- * on the script being interpreted.
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tk_Main(argc, argv, appInitProc)
- int argc; /* Number of arguments. */
- char **argv; /* Array of argument strings. */
- Tcl_AppInitProc *appInitProc; /* Application-specific initialization
- * procedure to call after most
- * initialization but before starting
- * to execute commands. */
-{
- char *args, *fileName;
- char buf[20];
- int code;
- size_t length;
- Tcl_Channel inChannel, outChannel;
-
- Tcl_FindExecutable(argv[0]);
- interp = Tcl_CreateInterp();
-#ifdef TCL_MEM_DEBUG
- Tcl_InitMemory(interp);
-#endif
-
- /*
- * Parse command-line arguments. A leading "-file" argument is
- * ignored (a historical relic from the distant past). If the
- * next argument doesn't start with a "-" then strip it off and
- * use it as the name of a script file to process.
- */
-
- fileName = NULL;
- if (argc > 1) {
- length = strlen(argv[1]);
- if ((length >= 2) && (strncmp(argv[1], "-file", length) == 0)) {
- argc--;
- argv++;
- }
- }
- if ((argc > 1) && (argv[1][0] != '-')) {
- fileName = argv[1];
- argc--;
- argv++;
- }
-
- /*
- * Make command-line arguments available in the Tcl variables "argc"
- * and "argv".
- */
-
- args = Tcl_Merge(argc-1, argv+1);
- Tcl_SetVar(interp, "argv", args, TCL_GLOBAL_ONLY);
- ckfree(args);
- sprintf(buf, "%d", argc-1);
- Tcl_SetVar(interp, "argc", buf, TCL_GLOBAL_ONLY);
- Tcl_SetVar(interp, "argv0", (fileName != NULL) ? fileName : argv[0],
- TCL_GLOBAL_ONLY);
-
- /*
- * Set the "tcl_interactive" variable.
- */
-
- /*
- * For now, under Windows, we assume we are not running as a console mode
- * app, so we need to use the GUI console. In order to enable this, we
- * always claim to be running on a tty. This probably isn't the right
- * way to do it.
- */
-
-#ifdef __WIN32__
- tty = 1;
-#else
- tty = isatty(0);
-#endif
- Tcl_SetVar(interp, "tcl_interactive",
- ((fileName == NULL) && tty) ? "1" : "0", TCL_GLOBAL_ONLY);
-
- /*
- * Invoke application-specific initialization.
- */
-
- if ((*appInitProc)(interp) != TCL_OK) {
- TkpDisplayWarning(interp->result, "Application initialization failed");
- }
-
- /*
- * Invoke the script specified on the command line, if any.
- */
-
- if (fileName != NULL) {
- code = Tcl_EvalFile(interp, fileName);
- if (code != TCL_OK) {
- /*
- * The following statement guarantees that the errorInfo
- * variable is set properly.
- */
-
- Tcl_AddErrorInfo(interp, "");
- TkpDisplayWarning(Tcl_GetVar(interp, "errorInfo",
- TCL_GLOBAL_ONLY), "Error in startup script");
- Tcl_DeleteInterp(interp);
- Tcl_Exit(1);
- }
- tty = 0;
- } else {
-
- /*
- * Evaluate the .rc file, if one has been specified.
- */
-
- Tcl_SourceRCFile(interp);
-
- /*
- * Establish a channel handler for stdin.
- */
-
- inChannel = Tcl_GetStdChannel(TCL_STDIN);
- if (inChannel) {
- Tcl_CreateChannelHandler(inChannel, TCL_READABLE, StdinProc,
- (ClientData) inChannel);
- }
- if (tty) {
- Prompt(interp, 0);
- }
- }
-
- outChannel = Tcl_GetStdChannel(TCL_STDOUT);
- if (outChannel) {
- Tcl_Flush(outChannel);
- }
- Tcl_DStringInit(&command);
- Tcl_DStringInit(&line);
- Tcl_ResetResult(interp);
-
- /*
- * Loop infinitely, waiting for commands to execute. When there
- * are no windows left, Tk_MainLoop returns and we exit.
- */
-
- Tk_MainLoop();
- Tcl_DeleteInterp(interp);
- Tcl_Exit(0);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * StdinProc --
- *
- * This procedure is invoked by the event dispatcher whenever
- * standard input becomes readable. It grabs the next line of
- * input characters, adds them to a command being assembled, and
- * executes the command if it's complete.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Could be almost arbitrary, depending on the command that's
- * typed.
- *
- *----------------------------------------------------------------------
- */
-
- /* ARGSUSED */
-static void
-StdinProc(clientData, mask)
- ClientData clientData; /* Not used. */
- int mask; /* Not used. */
-{
- static int gotPartial = 0;
- char *cmd;
- int code, count;
- Tcl_Channel chan = (Tcl_Channel) clientData;
-
- count = Tcl_Gets(chan, &line);
-
- if (count < 0) {
- if (!gotPartial) {
- if (tty) {
- Tcl_Exit(0);
- } else {
- Tcl_DeleteChannelHandler(chan, StdinProc, (ClientData) chan);
- }
- return;
- }
- }
-
- (void) Tcl_DStringAppend(&command, Tcl_DStringValue(&line), -1);
- cmd = Tcl_DStringAppend(&command, "\n", -1);
- Tcl_DStringFree(&line);
- if (!Tcl_CommandComplete(cmd)) {
- gotPartial = 1;
- goto prompt;
- }
- gotPartial = 0;
-
- /*
- * Disable the stdin channel handler while evaluating the command;
- * otherwise if the command re-enters the event loop we might
- * process commands from stdin before the current command is
- * finished. Among other things, this will trash the text of the
- * command being evaluated.
- */
-
- Tcl_CreateChannelHandler(chan, 0, StdinProc, (ClientData) chan);
- code = Tcl_RecordAndEval(interp, cmd, TCL_EVAL_GLOBAL);
-
- chan = Tcl_GetStdChannel(TCL_STDIN);
- if (chan) {
- Tcl_CreateChannelHandler(chan, TCL_READABLE, StdinProc,
- (ClientData) chan);
- }
- Tcl_DStringFree(&command);
- if (*interp->result != 0) {
- if ((code != TCL_OK) || (tty)) {
- /*
- * The statement below used to call "printf", but that resulted
- * in core dumps under Solaris 2.3 if the result was very long.
- *
- * NOTE: This probably will not work under Windows either.
- */
-
- puts(interp->result);
- }
- }
-
- /*
- * Output a prompt.
- */
-
- prompt:
- if (tty) {
- Prompt(interp, gotPartial);
- }
- Tcl_ResetResult(interp);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Prompt --
- *
- * Issue a prompt on standard output, or invoke a script
- * to issue the prompt.
- *
- * Results:
- * None.
- *
- * Side effects:
- * A prompt gets output, and a Tcl script may be evaluated
- * in interp.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-Prompt(interp, partial)
- Tcl_Interp *interp; /* Interpreter to use for prompting. */
- int partial; /* Non-zero means there already
- * exists a partial command, so use
- * the secondary prompt. */
-{
- char *promptCmd;
- int code;
- Tcl_Channel outChannel, errChannel;
-
- promptCmd = Tcl_GetVar(interp,
- partial ? "tcl_prompt2" : "tcl_prompt1", TCL_GLOBAL_ONLY);
- if (promptCmd == NULL) {
-defaultPrompt:
- if (!partial) {
-
- /*
- * We must check that outChannel is a real channel - it
- * is possible that someone has transferred stdout out of
- * this interpreter with "interp transfer".
- */
-
- outChannel = Tcl_GetChannel(interp, "stdout", NULL);
- if (outChannel != (Tcl_Channel) NULL) {
- Tcl_Write(outChannel, "% ", 2);
- }
- }
- } else {
- code = Tcl_Eval(interp, promptCmd);
- if (code != TCL_OK) {
- Tcl_AddErrorInfo(interp,
- "\n (script that generates prompt)");
- /*
- * We must check that errChannel is a real channel - it
- * is possible that someone has transferred stderr out of
- * this interpreter with "interp transfer".
- */
-
- errChannel = Tcl_GetChannel(interp, "stderr", NULL);
- if (errChannel != (Tcl_Channel) NULL) {
- Tcl_Write(errChannel, interp->result, -1);
- Tcl_Write(errChannel, "\n", 1);
- }
- goto defaultPrompt;
- }
- }
- outChannel = Tcl_GetChannel(interp, "stdout", NULL);
- if (outChannel != (Tcl_Channel) NULL) {
- Tcl_Flush(outChannel);
- }
-}
diff --git a/generic/tkMenu.c b/generic/tkMenu.c
deleted file mode 100644
index cbcdcb8..0000000
--- a/generic/tkMenu.c
+++ /dev/null
@@ -1,3057 +0,0 @@
-/*
- * tkMenu.c --
- *
- * This file contains most of the code for implementing menus in Tk. It takes
- * care of all of the generic (platform-independent) parts of menus, and
- * is supplemented by platform-specific files. The geometry calculation
- * and drawing code for menus is in the file tkMenuDraw.c
- *
- * Copyright (c) 1990-1994 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: tkMenu.c,v 1.2 1998/09/14 18:23:14 stanton Exp $
- */
-
-/*
- * Notes on implementation of menus:
- *
- * Menus can be used in three ways:
- * - as a popup menu, either as part of a menubutton or standalone.
- * - as a menubar. The menu's cascade items are arranged according to
- * the specific platform to provide the user access to the menus at all
- * times
- * - as a tearoff palette. This is a window with the menu's items in it.
- *
- * The goal is to provide the Tk developer with a way to use a common
- * set of menus for all of these tasks.
- *
- * In order to make the bindings for cascade menus work properly under Unix,
- * the cascade menus' pathnames must be proper children of the menu that
- * they are cascade from. So if there is a menu .m, and it has two
- * cascades labelled "File" and "Edit", the cascade menus might have
- * the pathnames .m.file and .m.edit. Another constraint is that the menus
- * used for menubars must be children of the toplevel widget that they
- * are attached to. And on the Macintosh, the platform specific menu handle
- * for cascades attached to a menu bar must have a title that matches the
- * label for the cascade menu.
- *
- * To handle all of the constraints, Tk menubars and tearoff menus are
- * implemented using menu clones. Menu clones are full menus in their own
- * right; they have a Tk window and pathname associated with them; they have
- * a TkMenu structure and array of entries. However, they are linked with the
- * original menu that they were cloned from. The reflect the attributes of
- * the original, or "master", menu. So if an item is added to a menu, and
- * that menu has clones, then the item must be added to all of its clones
- * also. Menus are cloned when a menu is torn-off or when a menu is assigned
- * as a menubar using the "-menu" option of the toplevel's pathname configure
- * subcommand. When a clone is destroyed, only the clone is destroyed, but
- * when the master menu is destroyed, all clones are also destroyed. This
- * allows the developer to just deal with one set of menus when creating
- * and destroying.
- *
- * Clones are rather tricky when a menu with cascade entries is cloned (such
- * as a menubar). Not only does the menu have to be cloned, but each cascade
- * entry's corresponding menu must also be cloned. This maintains the pathname
- * parent-child hierarchy necessary for menubars and toplevels to work.
- * This leads to several special cases:
- *
- * 1. When a new menu is created, and it is pointed to by cascade entries in
- * cloned menus, the new menu has to be cloned to parallel the cascade
- * structure.
- * 2. When a cascade item is added to a menu that has been cloned, and the
- * menu that the cascade item points to exists, that menu has to be cloned.
- * 3. When the menu that a cascade entry points to is changed, the old
- * cloned cascade menu has to be discarded, and the new one has to be cloned.
- *
- */
-
-#include "tkPort.h"
-#include "tkMenu.h"
-
-#define MENU_HASH_KEY "tkMenus"
-
-static int menusInitialized; /* Whether or not the hash tables, etc., have
- * been setup */
-
-/*
- * Configuration specs for individual menu entries. If this changes, be sure
- * to update code in TkpMenuInit that changes the font string entry.
- */
-
-Tk_ConfigSpec tkMenuEntryConfigSpecs[] = {
- {TK_CONFIG_BORDER, "-activebackground", (char *) NULL, (char *) NULL,
- DEF_MENU_ENTRY_ACTIVE_BG, Tk_Offset(TkMenuEntry, activeBorder),
- COMMAND_MASK|CHECK_BUTTON_MASK|RADIO_BUTTON_MASK|CASCADE_MASK
- |TK_CONFIG_NULL_OK},
- {TK_CONFIG_COLOR, "-activeforeground", (char *) NULL, (char *) NULL,
- DEF_MENU_ENTRY_ACTIVE_FG, Tk_Offset(TkMenuEntry, activeFg),
- COMMAND_MASK|CHECK_BUTTON_MASK|RADIO_BUTTON_MASK|CASCADE_MASK
- |TK_CONFIG_NULL_OK},
- {TK_CONFIG_STRING, "-accelerator", (char *) NULL, (char *) NULL,
- DEF_MENU_ENTRY_ACCELERATOR, Tk_Offset(TkMenuEntry, accel),
- COMMAND_MASK|CHECK_BUTTON_MASK|RADIO_BUTTON_MASK|CASCADE_MASK
- |TK_CONFIG_NULL_OK},
- {TK_CONFIG_BORDER, "-background", (char *) NULL, (char *) NULL,
- DEF_MENU_ENTRY_BG, Tk_Offset(TkMenuEntry, border),
- COMMAND_MASK|CHECK_BUTTON_MASK|RADIO_BUTTON_MASK|CASCADE_MASK
- |SEPARATOR_MASK|TEAROFF_MASK|TK_CONFIG_NULL_OK},
- {TK_CONFIG_BITMAP, "-bitmap", (char *) NULL, (char *) NULL,
- DEF_MENU_ENTRY_BITMAP, Tk_Offset(TkMenuEntry, bitmap),
- COMMAND_MASK|CHECK_BUTTON_MASK|RADIO_BUTTON_MASK|CASCADE_MASK
- |TK_CONFIG_NULL_OK},
- {TK_CONFIG_BOOLEAN, "-columnbreak", (char *) NULL, (char *) NULL,
- DEF_MENU_ENTRY_COLUMN_BREAK, Tk_Offset(TkMenuEntry, columnBreak),
- COMMAND_MASK|CHECK_BUTTON_MASK|RADIO_BUTTON_MASK|CASCADE_MASK},
- {TK_CONFIG_STRING, "-command", (char *) NULL, (char *) NULL,
- DEF_MENU_ENTRY_COMMAND, Tk_Offset(TkMenuEntry, command),
- COMMAND_MASK|CHECK_BUTTON_MASK|RADIO_BUTTON_MASK|CASCADE_MASK
- |TK_CONFIG_NULL_OK},
- {TK_CONFIG_FONT, "-font", (char *) NULL, (char *) NULL,
- DEF_MENU_ENTRY_FONT, Tk_Offset(TkMenuEntry, tkfont),
- COMMAND_MASK|CHECK_BUTTON_MASK|RADIO_BUTTON_MASK|CASCADE_MASK
- |TK_CONFIG_NULL_OK},
- {TK_CONFIG_COLOR, "-foreground", (char *) NULL, (char *) NULL,
- DEF_MENU_ENTRY_FG, Tk_Offset(TkMenuEntry, fg),
- COMMAND_MASK|CHECK_BUTTON_MASK|RADIO_BUTTON_MASK|CASCADE_MASK
- |TK_CONFIG_NULL_OK},
- {TK_CONFIG_BOOLEAN, "-hidemargin", (char *) NULL, (char *) NULL,
- DEF_MENU_ENTRY_HIDE_MARGIN, Tk_Offset(TkMenuEntry, hideMargin),
- COMMAND_MASK|CHECK_BUTTON_MASK|RADIO_BUTTON_MASK|CASCADE_MASK
- |SEPARATOR_MASK|TEAROFF_MASK},
- {TK_CONFIG_STRING, "-image", (char *) NULL, (char *) NULL,
- DEF_MENU_ENTRY_IMAGE, Tk_Offset(TkMenuEntry, imageString),
- COMMAND_MASK|CHECK_BUTTON_MASK|RADIO_BUTTON_MASK|CASCADE_MASK
- |TK_CONFIG_NULL_OK},
- {TK_CONFIG_BOOLEAN, "-indicatoron", (char *) NULL, (char *) NULL,
- DEF_MENU_ENTRY_INDICATOR, Tk_Offset(TkMenuEntry, indicatorOn),
- CHECK_BUTTON_MASK|RADIO_BUTTON_MASK|TK_CONFIG_DONT_SET_DEFAULT},
- {TK_CONFIG_STRING, "-label", (char *) NULL, (char *) NULL,
- DEF_MENU_ENTRY_LABEL, Tk_Offset(TkMenuEntry, label),
- COMMAND_MASK|CHECK_BUTTON_MASK|RADIO_BUTTON_MASK|CASCADE_MASK},
- {TK_CONFIG_STRING, "-menu", (char *) NULL, (char *) NULL,
- DEF_MENU_ENTRY_MENU, Tk_Offset(TkMenuEntry, name),
- CASCADE_MASK|TK_CONFIG_NULL_OK},
- {TK_CONFIG_STRING, "-offvalue", (char *) NULL, (char *) NULL,
- DEF_MENU_ENTRY_OFF_VALUE, Tk_Offset(TkMenuEntry, offValue),
- CHECK_BUTTON_MASK},
- {TK_CONFIG_STRING, "-onvalue", (char *) NULL, (char *) NULL,
- DEF_MENU_ENTRY_ON_VALUE, Tk_Offset(TkMenuEntry, onValue),
- CHECK_BUTTON_MASK},
- {TK_CONFIG_COLOR, "-selectcolor", (char *) NULL, (char *) NULL,
- DEF_MENU_ENTRY_SELECT, Tk_Offset(TkMenuEntry, indicatorFg),
- CHECK_BUTTON_MASK|RADIO_BUTTON_MASK|TK_CONFIG_NULL_OK},
- {TK_CONFIG_STRING, "-selectimage", (char *) NULL, (char *) NULL,
- DEF_MENU_ENTRY_SELECT_IMAGE, Tk_Offset(TkMenuEntry, selectImageString),
- CHECK_BUTTON_MASK|RADIO_BUTTON_MASK|TK_CONFIG_NULL_OK},
- {TK_CONFIG_UID, "-state", (char *) NULL, (char *) NULL,
- DEF_MENU_ENTRY_STATE, Tk_Offset(TkMenuEntry, state),
- COMMAND_MASK|CHECK_BUTTON_MASK|RADIO_BUTTON_MASK|CASCADE_MASK
- |TEAROFF_MASK|TK_CONFIG_DONT_SET_DEFAULT},
- {TK_CONFIG_STRING, "-value", (char *) NULL, (char *) NULL,
- DEF_MENU_ENTRY_VALUE, Tk_Offset(TkMenuEntry, onValue),
- RADIO_BUTTON_MASK|TK_CONFIG_NULL_OK},
- {TK_CONFIG_STRING, "-variable", (char *) NULL, (char *) NULL,
- DEF_MENU_ENTRY_CHECK_VARIABLE, Tk_Offset(TkMenuEntry, name),
- CHECK_BUTTON_MASK|TK_CONFIG_NULL_OK},
- {TK_CONFIG_STRING, "-variable", (char *) NULL, (char *) NULL,
- DEF_MENU_ENTRY_RADIO_VARIABLE, Tk_Offset(TkMenuEntry, name),
- RADIO_BUTTON_MASK},
- {TK_CONFIG_INT, "-underline", (char *) NULL, (char *) NULL,
- DEF_MENU_ENTRY_UNDERLINE, Tk_Offset(TkMenuEntry, underline),
- COMMAND_MASK|CHECK_BUTTON_MASK|RADIO_BUTTON_MASK|CASCADE_MASK
- |TK_CONFIG_DONT_SET_DEFAULT},
- {TK_CONFIG_END, (char *) NULL, (char *) NULL, (char *) NULL,
- (char *) NULL, 0, 0}
-};
-
-/*
- * Configuration specs valid for the menu as a whole. If this changes, be sure
- * to update code in TkpMenuInit that changes the font string entry.
- */
-
-Tk_ConfigSpec tkMenuConfigSpecs[] = {
- {TK_CONFIG_BORDER, "-activebackground", "activeBackground", "Foreground",
- DEF_MENU_ACTIVE_BG_COLOR, Tk_Offset(TkMenu, activeBorder),
- TK_CONFIG_COLOR_ONLY},
- {TK_CONFIG_BORDER, "-activebackground", "activeBackground", "Foreground",
- DEF_MENU_ACTIVE_BG_MONO, Tk_Offset(TkMenu, activeBorder),
- TK_CONFIG_MONO_ONLY},
- {TK_CONFIG_PIXELS, "-activeborderwidth", "activeBorderWidth",
- "BorderWidth", DEF_MENU_ACTIVE_BORDER_WIDTH,
- Tk_Offset(TkMenu, activeBorderWidth), 0},
- {TK_CONFIG_COLOR, "-activeforeground", "activeForeground", "Background",
- DEF_MENU_ACTIVE_FG_COLOR, Tk_Offset(TkMenu, activeFg),
- TK_CONFIG_COLOR_ONLY},
- {TK_CONFIG_COLOR, "-activeforeground", "activeForeground", "Background",
- DEF_MENU_ACTIVE_FG_MONO, Tk_Offset(TkMenu, activeFg),
- TK_CONFIG_MONO_ONLY},
- {TK_CONFIG_BORDER, "-background", "background", "Background",
- DEF_MENU_BG_COLOR, Tk_Offset(TkMenu, border), TK_CONFIG_COLOR_ONLY},
- {TK_CONFIG_BORDER, "-background", "background", "Background",
- DEF_MENU_BG_MONO, Tk_Offset(TkMenu, 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_MENU_BORDER_WIDTH, Tk_Offset(TkMenu, borderWidth), 0},
- {TK_CONFIG_ACTIVE_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_MENU_CURSOR, Tk_Offset(TkMenu, cursor), TK_CONFIG_NULL_OK},
- {TK_CONFIG_COLOR, "-disabledforeground", "disabledForeground",
- "DisabledForeground", DEF_MENU_DISABLED_FG_COLOR,
- Tk_Offset(TkMenu, disabledFg), TK_CONFIG_COLOR_ONLY|TK_CONFIG_NULL_OK},
- {TK_CONFIG_COLOR, "-disabledforeground", "disabledForeground",
- "DisabledForeground", DEF_MENU_DISABLED_FG_MONO,
- Tk_Offset(TkMenu, disabledFg), TK_CONFIG_MONO_ONLY|TK_CONFIG_NULL_OK},
- {TK_CONFIG_SYNONYM, "-fg", "foreground", (char *) NULL,
- (char *) NULL, 0, 0},
- {TK_CONFIG_FONT, "-font", "font", "Font",
- DEF_MENU_FONT, Tk_Offset(TkMenu, tkfont), 0},
- {TK_CONFIG_COLOR, "-foreground", "foreground", "Foreground",
- DEF_MENU_FG, Tk_Offset(TkMenu, fg), 0},
- {TK_CONFIG_STRING, "-postcommand", "postCommand", "Command",
- DEF_MENU_POST_COMMAND, Tk_Offset(TkMenu, postCommand),
- TK_CONFIG_NULL_OK},
- {TK_CONFIG_RELIEF, "-relief", "relief", "Relief",
- DEF_MENU_RELIEF, Tk_Offset(TkMenu, relief), 0},
- {TK_CONFIG_COLOR, "-selectcolor", "selectColor", "Background",
- DEF_MENU_SELECT_COLOR, Tk_Offset(TkMenu, indicatorFg),
- TK_CONFIG_COLOR_ONLY},
- {TK_CONFIG_COLOR, "-selectcolor", "selectColor", "Background",
- DEF_MENU_SELECT_MONO, Tk_Offset(TkMenu, indicatorFg),
- TK_CONFIG_MONO_ONLY},
- {TK_CONFIG_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_MENU_TAKE_FOCUS, Tk_Offset(TkMenu, takeFocus), TK_CONFIG_NULL_OK},
- {TK_CONFIG_BOOLEAN, "-tearoff", "tearOff", "TearOff",
- DEF_MENU_TEAROFF, Tk_Offset(TkMenu, tearOff), 0},
- {TK_CONFIG_STRING, "-tearoffcommand", "tearOffCommand", "TearOffCommand",
- DEF_MENU_TEAROFF_CMD, Tk_Offset(TkMenu, tearOffCommand),
- TK_CONFIG_NULL_OK},
- {TK_CONFIG_STRING, "-title", "title", "Title",
- DEF_MENU_TITLE, Tk_Offset(TkMenu, title), TK_CONFIG_NULL_OK},
- {TK_CONFIG_STRING, "-type", "type", "Type",
- DEF_MENU_TYPE, Tk_Offset(TkMenu, menuTypeName), TK_CONFIG_NULL_OK},
- {TK_CONFIG_END, (char *) NULL, (char *) NULL, (char *) NULL,
- (char *) NULL, 0, 0}
-};
-
-/*
- * Prototypes for static procedures in this file:
- */
-
-static int CloneMenu _ANSI_ARGS_((TkMenu *menuPtr,
- char *newMenuName, char *newMenuTypeString));
-static int ConfigureMenu _ANSI_ARGS_((Tcl_Interp *interp,
- TkMenu *menuPtr, int argc, char **argv,
- int flags));
-static int ConfigureMenuCloneEntries _ANSI_ARGS_((
- Tcl_Interp *interp, TkMenu *menuPtr, int index,
- int argc, char **argv, int flags));
-static int ConfigureMenuEntry _ANSI_ARGS_((TkMenuEntry *mePtr,
- int argc, char **argv, int flags));
-static void DeleteMenuCloneEntries _ANSI_ARGS_((TkMenu *menuPtr,
- int first, int last));
-static void DestroyMenuHashTable _ANSI_ARGS_((
- ClientData clientData, Tcl_Interp *interp));
-static void DestroyMenuInstance _ANSI_ARGS_((TkMenu *menuPtr));
-static void DestroyMenuEntry _ANSI_ARGS_((char *memPtr));
-static int GetIndexFromCoords
- _ANSI_ARGS_((Tcl_Interp *interp, TkMenu *menuPtr,
- char *string, int *indexPtr));
-static int MenuDoYPosition _ANSI_ARGS_((Tcl_Interp *interp,
- TkMenu *menuPtr, char *arg));
-static int MenuAddOrInsert _ANSI_ARGS_((Tcl_Interp *interp,
- TkMenu *menuPtr, char *indexString, int argc,
- char **argv));
-static void MenuCmdDeletedProc _ANSI_ARGS_((
- ClientData clientData));
-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));
-static int MenuWidgetCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-static void MenuWorldChanged _ANSI_ARGS_((
- ClientData instanceData));
-static void RecursivelyDeleteMenu _ANSI_ARGS_((TkMenu *menuPtr));
-static void UnhookCascadeEntry _ANSI_ARGS_((TkMenuEntry *mePtr));
-
-/*
- * The structure below is a list of procs that respond to certain window
- * manager events. One of these includes a font change, which forces
- * the geometry proc to be called.
- */
-
-static TkClassProcs menuClass = {
- NULL, /* createProc. */
- MenuWorldChanged /* geometryProc. */
-};
-
-
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_MenuCmd --
- *
- * This procedure is invoked to process the "menu" 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_MenuCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Main window associated with
- * interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- Tk_Window tkwin = (Tk_Window) clientData;
- Tk_Window new;
- register TkMenu *menuPtr;
- TkMenuReferences *menuRefPtr;
- int i, len;
- char *arg, c;
- int toplevel;
-
- if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " pathName ?options?\"", (char *) NULL);
- return TCL_ERROR;
- }
-
- TkMenuInit();
-
- toplevel = 1;
- for (i = 2; i < argc; i += 2) {
- arg = argv[i];
- len = strlen(arg);
- if (len < 2) {
- continue;
- }
- c = arg[1];
- if ((c == 't') && (strncmp(arg, "-type", strlen(arg)) == 0)
- && (len >= 3)) {
- if (strcmp(argv[i + 1], "menubar") == 0) {
- toplevel = 0;
- }
- break;
- }
- }
-
- new = Tk_CreateWindowFromPath(interp, tkwin, argv[1], toplevel ? ""
- : NULL);
- if (new == NULL) {
- return TCL_ERROR;
- }
-
- /*
- * Initialize the data structure for the menu.
- */
-
- menuPtr = (TkMenu *) ckalloc(sizeof(TkMenu));
- menuPtr->tkwin = new;
- menuPtr->display = Tk_Display(new);
- menuPtr->interp = interp;
- menuPtr->widgetCmd = Tcl_CreateCommand(interp,
- Tk_PathName(menuPtr->tkwin), MenuWidgetCmd,
- (ClientData) menuPtr, MenuCmdDeletedProc);
- menuPtr->entries = NULL;
- menuPtr->numEntries = 0;
- menuPtr->active = -1;
- menuPtr->border = NULL;
- menuPtr->borderWidth = 0;
- menuPtr->relief = TK_RELIEF_FLAT;
- menuPtr->activeBorder = NULL;
- menuPtr->activeBorderWidth = 0;
- menuPtr->tkfont = NULL;
- menuPtr->fg = NULL;
- menuPtr->disabledFg = NULL;
- menuPtr->activeFg = NULL;
- menuPtr->indicatorFg = NULL;
- menuPtr->tearOff = 1;
- menuPtr->tearOffCommand = NULL;
- menuPtr->cursor = None;
- menuPtr->takeFocus = NULL;
- menuPtr->postCommand = NULL;
- menuPtr->postCommandGeneration = 0;
- menuPtr->postedCascade = NULL;
- menuPtr->nextInstancePtr = NULL;
- menuPtr->masterMenuPtr = menuPtr;
- menuPtr->menuType = UNKNOWN_TYPE;
- menuPtr->menuFlags = 0;
- menuPtr->parentTopLevelPtr = NULL;
- menuPtr->menuTypeName = NULL;
- menuPtr->title = NULL;
- TkMenuInitializeDrawingFields(menuPtr);
-
- menuRefPtr = TkCreateMenuReferences(menuPtr->interp,
- Tk_PathName(menuPtr->tkwin));
- menuRefPtr->menuPtr = menuPtr;
- menuPtr->menuRefPtr = menuRefPtr;
- if (TCL_OK != TkpNewMenu(menuPtr)) {
- goto error;
- }
-
- Tk_SetClass(menuPtr->tkwin, "Menu");
- TkSetClassProcs(menuPtr->tkwin, &menuClass, (ClientData) menuPtr);
- Tk_CreateEventHandler(new, ExposureMask|StructureNotifyMask|ActivateMask,
- TkMenuEventProc, (ClientData) menuPtr);
- if (ConfigureMenu(interp, menuPtr, argc-2, argv+2, 0) != TCL_OK) {
- goto error;
- }
-
- /*
- * If a menu has a parent menu pointing to it as a cascade entry, the
- * parent menu needs to be told that this menu now exists so that
- * the platform-part of the menu is correctly updated.
- *
- * If a menu has an instance and has cascade entries, then each cascade
- * menu must also have a parallel instance. This is especially true on
- * the Mac, where each menu has to have a separate title everytime it is in
- * a menubar. For instance, say you have a menu .m1 with a cascade entry
- * for .m2, where .m2 does not exist yet. You then put .m1 into a menubar.
- * This creates a menubar instance for .m1, but since .m2 is not there,
- * nothing else happens. When we go to create .m2, we hook it up properly
- * with .m1. However, we now need to clone .m2 and assign the clone of .m2
- * to be the cascade entry for the clone of .m1. This is special case
- * #1 listed in the introductory comment.
- */
-
- if (menuRefPtr->parentEntryPtr != NULL) {
- TkMenuEntry *cascadeListPtr = menuRefPtr->parentEntryPtr;
- TkMenuEntry *nextCascadePtr;
- char *newMenuName;
- char *newArgv[2];
-
- while (cascadeListPtr != NULL) {
-
- nextCascadePtr = cascadeListPtr->nextCascadePtr;
-
- /*
- * If we have a new master menu, and an existing cloned menu
- * points to this menu in a cascade entry, we have to clone
- * the new menu and point the entry to the clone instead
- * of the menu we are creating. Otherwise, ConfigureMenuEntry
- * will hook up the platform-specific cascade linkages now
- * that the menu we are creating exists.
- */
-
- if ((menuPtr->masterMenuPtr != menuPtr)
- || ((menuPtr->masterMenuPtr == menuPtr)
- && ((cascadeListPtr->menuPtr->masterMenuPtr
- == cascadeListPtr->menuPtr)))) {
- newArgv[0] = "-menu";
- newArgv[1] = Tk_PathName(menuPtr->tkwin);
- ConfigureMenuEntry(cascadeListPtr, 2, newArgv,
- TK_CONFIG_ARGV_ONLY);
- } else {
- newMenuName = TkNewMenuName(menuPtr->interp,
- Tk_PathName(cascadeListPtr->menuPtr->tkwin),
- menuPtr);
- CloneMenu(menuPtr, newMenuName, "normal");
-
- /*
- * Now we can set the new menu instance to be the cascade entry
- * of the parent's instance.
- */
-
- newArgv[0] = "-menu";
- newArgv[1] = newMenuName;
- ConfigureMenuEntry(cascadeListPtr, 2, newArgv,
- TK_CONFIG_ARGV_ONLY);
- if (newMenuName != NULL) {
- ckfree(newMenuName);
- }
- }
- cascadeListPtr = nextCascadePtr;
- }
- }
-
- /*
- * If there already exist toplevel widgets that refer to this menu,
- * find them and notify them so that they can reconfigure their
- * geometry to reflect the menu.
- */
-
- if (menuRefPtr->topLevelListPtr != NULL) {
- TkMenuTopLevelList *topLevelListPtr = menuRefPtr->topLevelListPtr;
- TkMenuTopLevelList *nextPtr;
- Tk_Window listtkwin;
- while (topLevelListPtr != NULL) {
-
- /*
- * Need to get the next pointer first. TkSetWindowMenuBar
- * changes the list, so that the next pointer is different
- * after calling it.
- */
-
- nextPtr = topLevelListPtr->nextPtr;
- listtkwin = topLevelListPtr->tkwin;
- TkSetWindowMenuBar(menuPtr->interp, listtkwin,
- Tk_PathName(menuPtr->tkwin), Tk_PathName(menuPtr->tkwin));
- topLevelListPtr = nextPtr;
- }
- }
-
- interp->result = Tk_PathName(menuPtr->tkwin);
- return TCL_OK;
-
- error:
- Tk_DestroyWindow(menuPtr->tkwin);
- return TCL_ERROR;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * MenuWidgetCmd --
- *
- * 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
-MenuWidgetCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Information about menu widget. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- register TkMenu *menuPtr = (TkMenu *) clientData;
- register TkMenuEntry *mePtr;
- int result = TCL_OK;
- size_t length;
- int c;
-
- if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " option ?arg arg ...?\"", (char *) NULL);
- return TCL_ERROR;
- }
- Tcl_Preserve((ClientData) menuPtr);
- c = argv[1][0];
- length = strlen(argv[1]);
- if ((c == 'a') && (strncmp(argv[1], "activate", length) == 0)
- && (length >= 2)) {
- int index;
-
- if (argc != 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " activate index\"", (char *) NULL);
- goto error;
- }
- if (TkGetMenuIndex(interp, menuPtr, argv[2], 0, &index) != TCL_OK) {
- goto error;
- }
- if (menuPtr->active == index) {
- goto done;
- }
- if (index >= 0) {
- if ((menuPtr->entries[index]->type == SEPARATOR_ENTRY)
- || (menuPtr->entries[index]->state == tkDisabledUid)) {
- index = -1;
- }
- }
- result = TkActivateMenuEntry(menuPtr, index);
- } else if ((c == 'a') && (strncmp(argv[1], "add", length) == 0)
- && (length >= 2)) {
- if (argc < 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " add type ?options?\"", (char *) NULL);
- goto error;
- }
- if (MenuAddOrInsert(interp, menuPtr, (char *) NULL,
- argc-2, argv+2) != TCL_OK) {
- goto error;
- }
- } else 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);
- goto error;
- }
- result = Tk_ConfigureValue(interp, menuPtr->tkwin, tkMenuConfigSpecs,
- (char *) menuPtr, argv[2], 0);
- } else if ((c == 'c') && (strncmp(argv[1], "clone", length) == 0)
- && (length >=2)) {
- if ((argc < 3) || (argc > 4)) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " clone newMenuName ?menuType?\"",
- (char *) NULL);
- goto error;
- }
- result = CloneMenu(menuPtr, argv[2], (argc == 3) ? NULL : argv[3]);
- } else if ((c == 'c') && (strncmp(argv[1], "configure", length) == 0)
- && (length >= 2)) {
- if (argc == 2) {
- result = Tk_ConfigureInfo(interp, menuPtr->tkwin,
- tkMenuConfigSpecs, (char *) menuPtr, (char *) NULL, 0);
- } else if (argc == 3) {
- result = Tk_ConfigureInfo(interp, menuPtr->tkwin,
- tkMenuConfigSpecs, (char *) menuPtr, argv[2], 0);
- } else {
- result = ConfigureMenu(interp, menuPtr, argc-2, argv+2,
- TK_CONFIG_ARGV_ONLY);
- }
- } else if ((c == 'd') && (strncmp(argv[1], "delete", length) == 0)) {
- int first, last;
-
- if ((argc != 3) && (argc != 4)) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " delete first ?last?\"", (char *) NULL);
- goto error;
- }
- if (TkGetMenuIndex(interp, menuPtr, argv[2], 0, &first) != TCL_OK) {
- goto error;
- }
- if (argc == 3) {
- last = first;
- } else {
- if (TkGetMenuIndex(interp, menuPtr, argv[3], 0, &last) != TCL_OK) {
- goto error;
- }
- }
- if (menuPtr->tearOff && (first == 0)) {
-
- /*
- * Sorry, can't delete the tearoff entry; must reconfigure
- * the menu.
- */
-
- first = 1;
- }
- if ((first < 0) || (last < first)) {
- goto done;
- }
- DeleteMenuCloneEntries(menuPtr, first, last);
- } else if ((c == 'e') && (length >= 7)
- && (strncmp(argv[1], "entrycget", length) == 0)) {
- int index;
-
- if (argc != 4) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " entrycget index option\"",
- (char *) NULL);
- goto error;
- }
- if (TkGetMenuIndex(interp, menuPtr, argv[2], 0, &index) != TCL_OK) {
- goto error;
- }
- if (index < 0) {
- goto done;
- }
- mePtr = menuPtr->entries[index];
- Tcl_Preserve((ClientData) mePtr);
- result = Tk_ConfigureValue(interp, menuPtr->tkwin,
- tkMenuEntryConfigSpecs, (char *) mePtr, argv[3],
- COMMAND_MASK << mePtr->type);
- Tcl_Release((ClientData) mePtr);
- } else if ((c == 'e') && (length >= 7)
- && (strncmp(argv[1], "entryconfigure", length) == 0)) {
- int index;
-
- if (argc < 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " entryconfigure index ?option value ...?\"",
- (char *) NULL);
- goto error;
- }
- if (TkGetMenuIndex(interp, menuPtr, argv[2], 0, &index) != TCL_OK) {
- goto error;
- }
- if (index < 0) {
- goto done;
- }
- mePtr = menuPtr->entries[index];
- Tcl_Preserve((ClientData) mePtr);
- if (argc == 3) {
- result = Tk_ConfigureInfo(interp, menuPtr->tkwin,
- tkMenuEntryConfigSpecs, (char *) mePtr, (char *) NULL,
- COMMAND_MASK << mePtr->type);
- } else if (argc == 4) {
- result = Tk_ConfigureInfo(interp, menuPtr->tkwin,
- tkMenuEntryConfigSpecs, (char *) mePtr, argv[3],
- COMMAND_MASK << mePtr->type);
- } else {
- result = ConfigureMenuCloneEntries(interp, menuPtr, index,
- argc-3, argv+3,
- TK_CONFIG_ARGV_ONLY | COMMAND_MASK << mePtr->type);
- }
- Tcl_Release((ClientData) mePtr);
- } else if ((c == 'i') && (strncmp(argv[1], "index", length) == 0)
- && (length >= 3)) {
- int index;
-
- if (argc != 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " index string\"", (char *) NULL);
- goto error;
- }
- if (TkGetMenuIndex(interp, menuPtr, argv[2], 0, &index) != TCL_OK) {
- goto error;
- }
- if (index < 0) {
- interp->result = "none";
- } else {
- sprintf(interp->result, "%d", index);
- }
- } else if ((c == 'i') && (strncmp(argv[1], "insert", length) == 0)
- && (length >= 3)) {
- if (argc < 4) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " insert index type ?options?\"", (char *) NULL);
- goto error;
- }
- if (MenuAddOrInsert(interp, menuPtr, argv[2],
- argc-3, argv+3) != TCL_OK) {
- goto error;
- }
- } else if ((c == 'i') && (strncmp(argv[1], "invoke", length) == 0)
- && (length >= 3)) {
- int index;
-
- if (argc != 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " invoke index\"", (char *) NULL);
- goto error;
- }
- if (TkGetMenuIndex(interp, menuPtr, argv[2], 0, &index) != TCL_OK) {
- goto error;
- }
- if (index < 0) {
- goto done;
- }
- result = TkInvokeMenu(interp, menuPtr, index);
- } else if ((c == 'p') && (strncmp(argv[1], "post", length) == 0)
- && (length == 4)) {
- int x, y;
-
- if (argc != 4) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " post x y\"", (char *) NULL);
- goto error;
- }
- if ((Tcl_GetInt(interp, argv[2], &x) != TCL_OK)
- || (Tcl_GetInt(interp, argv[3], &y) != TCL_OK)) {
- goto error;
- }
-
- /*
- * Tearoff menus are posted differently on Mac and Windows than
- * non-tearoffs. TkpPostMenu does not actually map the menu's
- * window on those platforms, and popup menus have to be
- * handled specially.
- */
-
- if (menuPtr->menuType != TEAROFF_MENU) {
- result = TkpPostMenu(interp, menuPtr, x, y);
- } else {
- result = TkPostTearoffMenu(interp, menuPtr, x, y);
- }
- } else if ((c == 'p') && (strncmp(argv[1], "postcascade", length) == 0)
- && (length > 4)) {
- int index;
- if (argc != 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " postcascade index\"", (char *) NULL);
- goto error;
- }
- if (TkGetMenuIndex(interp, menuPtr, argv[2], 0, &index) != TCL_OK) {
- goto error;
- }
- if ((index < 0) || (menuPtr->entries[index]->type != CASCADE_ENTRY)) {
- result = TkPostSubmenu(interp, menuPtr, (TkMenuEntry *) NULL);
- } else {
- result = TkPostSubmenu(interp, menuPtr, menuPtr->entries[index]);
- }
- } else if ((c == 't') && (strncmp(argv[1], "type", length) == 0)) {
- int index;
- if (argc != 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " type index\"", (char *) NULL);
- goto error;
- }
- if (TkGetMenuIndex(interp, menuPtr, argv[2], 0, &index) != TCL_OK) {
- goto error;
- }
- if (index < 0) {
- goto done;
- }
- mePtr = menuPtr->entries[index];
- switch (mePtr->type) {
- case COMMAND_ENTRY:
- interp->result = "command";
- break;
- case SEPARATOR_ENTRY:
- interp->result = "separator";
- break;
- case CHECK_BUTTON_ENTRY:
- interp->result = "checkbutton";
- break;
- case RADIO_BUTTON_ENTRY:
- interp->result = "radiobutton";
- break;
- case CASCADE_ENTRY:
- interp->result = "cascade";
- break;
- case TEAROFF_ENTRY:
- interp->result = "tearoff";
- break;
- }
- } else if ((c == 'u') && (strncmp(argv[1], "unpost", length) == 0)) {
- if (argc != 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " unpost\"", (char *) NULL);
- goto error;
- }
- Tk_UnmapWindow(menuPtr->tkwin);
- result = TkPostSubmenu(interp, menuPtr, (TkMenuEntry *) NULL);
- } else if ((c == 'y') && (strncmp(argv[1], "yposition", length) == 0)) {
- if (argc != 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " yposition index\"", (char *) NULL);
- goto error;
- }
- result = MenuDoYPosition(interp, menuPtr, argv[2]);
- } else {
- Tcl_AppendResult(interp, "bad option \"", argv[1],
- "\": must be activate, add, cget, clone, configure, delete, ",
- "entrycget, entryconfigure, index, insert, invoke, ",
- "post, postcascade, type, unpost, or yposition",
- (char *) NULL);
- goto error;
- }
- done:
- Tcl_Release((ClientData) menuPtr);
- return result;
-
- error:
- Tcl_Release((ClientData) menuPtr);
- return TCL_ERROR;
-}
-
-
-/*
- *----------------------------------------------------------------------
- *
- * TkInvokeMenu --
- *
- * Given a menu and an index, takes the appropriate action for the
- * entry associated with that index.
- *
- * Results:
- * Standard Tcl result.
- *
- * Side effects:
- * Commands may get excecuted; variables may get set; sub-menus may
- * get posted.
- *
- *----------------------------------------------------------------------
- */
-
-int
-TkInvokeMenu(interp, menuPtr, index)
- Tcl_Interp *interp; /* The interp that the menu lives in. */
- TkMenu *menuPtr; /* The menu we are invoking. */
- int index; /* The zero based index of the item we
- * are invoking */
-{
- int result = TCL_OK;
- TkMenuEntry *mePtr;
-
- if (index < 0) {
- goto done;
- }
- mePtr = menuPtr->entries[index];
- if (mePtr->state == tkDisabledUid) {
- goto done;
- }
- Tcl_Preserve((ClientData) mePtr);
- if (mePtr->type == TEAROFF_ENTRY) {
- Tcl_DString commandDString;
-
- Tcl_DStringInit(&commandDString);
- Tcl_DStringAppendElement(&commandDString, "tkTearOffMenu");
- Tcl_DStringAppendElement(&commandDString, Tk_PathName(menuPtr->tkwin));
- result = Tcl_Eval(interp, Tcl_DStringValue(&commandDString));
- Tcl_DStringFree(&commandDString);
- } else if (mePtr->type == CHECK_BUTTON_ENTRY) {
- if (mePtr->entryFlags & ENTRY_SELECTED) {
- if (Tcl_SetVar(interp, mePtr->name, mePtr->offValue,
- TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG) == NULL) {
- result = TCL_ERROR;
- }
- } else {
- if (Tcl_SetVar(interp, mePtr->name, mePtr->onValue,
- TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG) == NULL) {
- result = TCL_ERROR;
- }
- }
- } else if (mePtr->type == RADIO_BUTTON_ENTRY) {
- if (Tcl_SetVar(interp, mePtr->name, mePtr->onValue,
- TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG) == NULL) {
- result = TCL_ERROR;
- }
- }
- if ((result == TCL_OK) && (mePtr->command != NULL)) {
- result = TkCopyAndGlobalEval(interp, mePtr->command);
- }
- Tcl_Release((ClientData) mePtr);
- done:
- return result;
-}
-
-
-
-/*
- *----------------------------------------------------------------------
- *
- * DestroyMenuInstance --
- *
- * This procedure is invoked by TkDestroyMenu
- * to clean up the internal structure of a menu at a safe time
- * (when no-one is using it anymore). Only takes care of one instance
- * of the menu.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Everything associated with the menu is freed up.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-DestroyMenuInstance(menuPtr)
- TkMenu *menuPtr; /* Info about menu widget. */
-{
- int i, numEntries = menuPtr->numEntries;
- TkMenu *menuInstancePtr;
- TkMenuEntry *cascadePtr, *nextCascadePtr;
- char *newArgv[2];
- TkMenu *parentMasterMenuPtr;
- TkMenuEntry *parentMasterEntryPtr;
- TkMenu *parentMenuPtr;
-
- /*
- * If the menu has any cascade menu entries pointing to it, the cascade
- * entries need to be told that the menu is going away. We need to clear
- * the menu ptr field in the menu reference at this point in the code
- * so that everything else can forget about this menu properly. We also
- * need to reset -menu field of all entries that are not master menus
- * back to this entry name if this is a master menu pointed to by another
- * master menu. If there is a clone menu that points to this menu,
- * then this menu is itself a clone, so when this menu goes away,
- * the -menu field of the pointing entry must be set back to this
- * menu's master menu name so that later if another menu is created
- * the cascade hierarchy can be maintained.
- */
-
- TkpDestroyMenu(menuPtr);
- cascadePtr = menuPtr->menuRefPtr->parentEntryPtr;
- menuPtr->menuRefPtr->menuPtr = NULL;
- TkFreeMenuReferences(menuPtr->menuRefPtr);
-
- for (; cascadePtr != NULL; cascadePtr = nextCascadePtr) {
- parentMenuPtr = cascadePtr->menuPtr;
- nextCascadePtr = cascadePtr->nextCascadePtr;
-
- if (menuPtr->masterMenuPtr != menuPtr) {
- parentMasterMenuPtr = cascadePtr->menuPtr->masterMenuPtr;
- parentMasterEntryPtr =
- parentMasterMenuPtr->entries[cascadePtr->index];
- newArgv[0] = "-menu";
- newArgv[1] = parentMasterEntryPtr->name;
- ConfigureMenuEntry(cascadePtr, 2, newArgv, TK_CONFIG_ARGV_ONLY);
- } else {
- ConfigureMenuEntry(cascadePtr, 0, (char **) NULL, 0);
- }
- }
-
- if (menuPtr->masterMenuPtr != menuPtr) {
- for (menuInstancePtr = menuPtr->masterMenuPtr;
- menuInstancePtr != NULL;
- menuInstancePtr = menuInstancePtr->nextInstancePtr) {
- if (menuInstancePtr->nextInstancePtr == menuPtr) {
- menuInstancePtr->nextInstancePtr =
- menuInstancePtr->nextInstancePtr->nextInstancePtr;
- break;
- }
- }
- } else if (menuPtr->nextInstancePtr != NULL) {
- panic("Attempting to delete master menu when there are still clones.");
- }
-
- /*
- * Free up all the stuff that requires special handling, then
- * let Tk_FreeOptions handle all the standard option-related
- * stuff.
- */
-
- for (i = numEntries - 1; i >= 0; i--) {
- DestroyMenuEntry((char *) menuPtr->entries[i]);
- }
- if (menuPtr->entries != NULL) {
- ckfree((char *) menuPtr->entries);
- }
- TkMenuFreeDrawOptions(menuPtr);
- Tk_FreeOptions(tkMenuConfigSpecs, (char *) menuPtr, menuPtr->display, 0);
-
- Tcl_EventuallyFree((ClientData) menuPtr, TCL_DYNAMIC);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkDestroyMenu --
- *
- * This procedure is invoked by Tcl_EventuallyFree or Tcl_Release
- * to clean up the internal structure of a menu at a safe time
- * (when no-one is using it anymore). If called on a master instance,
- * destroys all of the slave instances. If called on a non-master
- * instance, just destroys that instance.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Everything associated with the menu is freed up.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkDestroyMenu(menuPtr)
- TkMenu *menuPtr; /* Info about menu widget. */
-{
- TkMenu *menuInstancePtr;
- TkMenuTopLevelList *topLevelListPtr, *nextTopLevelPtr;
-
- 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) {
- menuInstancePtr = menuPtr->nextInstancePtr;
- menuPtr->nextInstancePtr = menuInstancePtr->nextInstancePtr;
- if (menuInstancePtr->tkwin != NULL) {
- Tk_DestroyWindow(menuInstancePtr->tkwin);
- }
- }
- menuPtr->menuFlags &= ~MENU_DELETION_PENDING;
- }
-
- /*
- * 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);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * UnhookCascadeEntry --
- *
- * This entry is removed from the list of entries that point to the
- * cascade menu. This is done in preparation for changing the menu
- * that this entry points to.
- *
- * Results:
- * None
- *
- * Side effects:
- * The appropriate lists are modified.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-UnhookCascadeEntry(mePtr)
- TkMenuEntry *mePtr; /* The cascade entry we are removing
- * from the cascade list. */
-{
- TkMenuEntry *cascadeEntryPtr;
- TkMenuEntry *prevCascadePtr;
- TkMenuReferences *menuRefPtr;
-
- menuRefPtr = mePtr->childMenuRefPtr;
- if (menuRefPtr == NULL) {
- return;
- }
-
- cascadeEntryPtr = menuRefPtr->parentEntryPtr;
- if (cascadeEntryPtr == NULL) {
- return;
- }
-
- /*
- * Singularly linked list deletion. The two special cases are
- * 1. one element; 2. The first element is the one we want.
- */
-
- if (cascadeEntryPtr == mePtr) {
- if (cascadeEntryPtr->nextCascadePtr == NULL) {
-
- /*
- * This is the last menu entry which points to this
- * menu, so we need to clear out the list pointer in the
- * cascade itself.
- */
-
- menuRefPtr->parentEntryPtr = NULL;
- TkFreeMenuReferences(menuRefPtr);
- } else {
- menuRefPtr->parentEntryPtr = cascadeEntryPtr->nextCascadePtr;
- }
- mePtr->nextCascadePtr = NULL;
- } else {
- for (prevCascadePtr = cascadeEntryPtr,
- cascadeEntryPtr = cascadeEntryPtr->nextCascadePtr;
- cascadeEntryPtr != NULL;
- prevCascadePtr = cascadeEntryPtr,
- cascadeEntryPtr = cascadeEntryPtr->nextCascadePtr) {
- if (cascadeEntryPtr == mePtr){
- prevCascadePtr->nextCascadePtr =
- cascadeEntryPtr->nextCascadePtr;
- cascadeEntryPtr->nextCascadePtr = NULL;
- break;
- }
- }
- }
- mePtr->childMenuRefPtr = NULL;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * DestroyMenuEntry --
- *
- * This procedure is invoked by Tcl_EventuallyFree or Tcl_Release
- * to clean up the internal structure of a menu entry at a safe time
- * (when no-one is using it anymore).
- *
- * Results:
- * None.
- *
- * Side effects:
- * Everything associated with the menu entry is freed.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-DestroyMenuEntry(memPtr)
- char *memPtr; /* Pointer to entry to be freed. */
-{
- register TkMenuEntry *mePtr = (TkMenuEntry *) memPtr;
- TkMenu *menuPtr = mePtr->menuPtr;
-
- if (menuPtr->postedCascade == mePtr) {
-
- /*
- * Ignore errors while unposting the menu, since it's possible
- * that the menu has already been deleted and the unpost will
- * generate an error.
- */
-
- TkPostSubmenu(menuPtr->interp, menuPtr, (TkMenuEntry *) NULL);
- }
-
- /*
- * Free up all the stuff that requires special handling, then
- * let Tk_FreeOptions handle all the standard option-related
- * stuff.
- */
-
- if (mePtr->type == CASCADE_ENTRY) {
- UnhookCascadeEntry(mePtr);
- }
- if (mePtr->image != NULL) {
- Tk_FreeImage(mePtr->image);
- }
- if (mePtr->selectImage != NULL) {
- Tk_FreeImage(mePtr->selectImage);
- }
- if (mePtr->name != NULL) {
- Tcl_UntraceVar(menuPtr->interp, mePtr->name,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- MenuVarProc, (ClientData) mePtr);
- }
- TkpDestroyMenuEntry(mePtr);
- TkMenuEntryFreeDrawOptions(mePtr);
- Tk_FreeOptions(tkMenuEntryConfigSpecs, (char *) mePtr, menuPtr->display,
- (COMMAND_MASK << mePtr->type));
- ckfree((char *) mePtr);
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * MenuWorldChanged --
- *
- * This procedure is called when the world has changed in some
- * way (such as the fonts in the system changing) and the widget needs
- * to recompute all its graphics contexts and determine its new geometry.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Menu will be relayed out and redisplayed.
- *
- *---------------------------------------------------------------------------
- */
-
-static void
-MenuWorldChanged(instanceData)
- ClientData instanceData; /* Information about widget. */
-{
- TkMenu *menuPtr = (TkMenu *) instanceData;
- int i;
-
- TkMenuConfigureDrawOptions(menuPtr);
- for (i = 0; i < menuPtr->numEntries; i++) {
- TkMenuConfigureEntryDrawOptions(menuPtr->entries[i],
- menuPtr->entries[i]->index);
- TkpConfigureMenuEntry(menuPtr->entries[i]);
- }
-}
-
-
-/*
- *----------------------------------------------------------------------
- *
- * ConfigureMenu --
- *
- * This procedure is called to process an argv/argc list, plus
- * the Tk option database, in order to configure (or
- * reconfigure) a menu widget.
- *
- * Results:
- * The return value is a standard Tcl result. If TCL_ERROR is
- * returned, then interp->result contains an error message.
- *
- * Side effects:
- * Configuration information, such as colors, font, etc. get set
- * for menuPtr; old resources get freed, if there were any.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-ConfigureMenu(interp, menuPtr, argc, argv, flags)
- Tcl_Interp *interp; /* Used for error reporting. */
- register TkMenu *menuPtr; /* 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 flags; /* Flags to pass to Tk_ConfigureWidget. */
-{
- int i;
- TkMenu* menuListPtr;
-
- for (menuListPtr = menuPtr->masterMenuPtr; menuListPtr != NULL;
- menuListPtr = menuListPtr->nextInstancePtr) {
-
- if (Tk_ConfigureWidget(interp, menuListPtr->tkwin,
- tkMenuConfigSpecs, argc, argv, (char *) menuListPtr,
- flags) != TCL_OK) {
- return TCL_ERROR;
- }
-
- /*
- * When a menu is created, the type is in all of the arguments
- * to the menu command. Let Tk_ConfigureWidget take care of
- * parsing them, and then set the type after we can look at
- * the type string. Once set, a menu's type cannot be changed
- */
-
- if (menuListPtr->menuType == UNKNOWN_TYPE) {
- if (strcmp(menuListPtr->menuTypeName, "menubar") == 0) {
- menuListPtr->menuType = MENUBAR;
- } else if (strcmp(menuListPtr->menuTypeName, "tearoff") == 0) {
- menuListPtr->menuType = TEAROFF_MENU;
- } else {
- menuListPtr->menuType = MASTER_MENU;
- }
- }
-
- /*
- * Depending on the -tearOff option, make sure that there is or
- * isn't an initial tear-off entry at the beginning of the menu.
- */
-
- if (menuListPtr->tearOff) {
- if ((menuListPtr->numEntries == 0)
- || (menuListPtr->entries[0]->type != TEAROFF_ENTRY)) {
- if (MenuNewEntry(menuListPtr, 0, TEAROFF_ENTRY) == NULL) {
- return TCL_ERROR;
- }
- }
- } else if ((menuListPtr->numEntries > 0)
- && (menuListPtr->entries[0]->type == TEAROFF_ENTRY)) {
- int i;
-
- Tcl_EventuallyFree((ClientData) menuListPtr->entries[0],
- DestroyMenuEntry);
- for (i = 0; i < menuListPtr->numEntries - 1; i++) {
- menuListPtr->entries[i] = menuListPtr->entries[i + 1];
- menuListPtr->entries[i]->index = i;
- }
- menuListPtr->numEntries--;
- if (menuListPtr->numEntries == 0) {
- ckfree((char *) menuListPtr->entries);
- menuListPtr->entries = NULL;
- }
- }
-
- TkMenuConfigureDrawOptions(menuListPtr);
-
- /*
- * Configure the new window to be either a pop-up menu
- * or a tear-off menu.
- * We don't do this for menubars since they are not toplevel
- * windows. Also, since this gets called before CloneMenu has
- * a chance to set the menuType field, we have to look at the
- * menuTypeName field to tell that this is a menu bar.
- */
-
- if (strcmp(menuListPtr->menuTypeName, "normal") == 0) {
- TkpMakeMenuWindow(menuListPtr->tkwin, 1);
- } else if (strcmp(menuListPtr->menuTypeName, "tearoff") == 0) {
- TkpMakeMenuWindow(menuListPtr->tkwin, 0);
- }
-
- /*
- * After reconfiguring a menu, we need to reconfigure all of the
- * entries in the menu, since some of the things in the children
- * (such as graphics contexts) may have to change to reflect changes
- * in the parent.
- */
-
- for (i = 0; i < menuListPtr->numEntries; i++) {
- TkMenuEntry *mePtr;
-
- mePtr = menuListPtr->entries[i];
- ConfigureMenuEntry(mePtr, 0,
- (char **) NULL, TK_CONFIG_ARGV_ONLY
- | COMMAND_MASK << mePtr->type);
- }
-
- TkEventuallyRecomputeMenu(menuListPtr);
- }
-
- return TCL_OK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ConfigureMenuEntry --
- *
- * This procedure is called to process an argv/argc list in order
- * to configure (or reconfigure) one entry in a menu.
- *
- * Results:
- * The return value is a standard Tcl result. If TCL_ERROR is
- * returned, then interp->result contains an error message.
- *
- * Side effects:
- * Configuration information such as label and accelerator get
- * set for mePtr; old resources get freed, if there were any.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-ConfigureMenuEntry(mePtr, argc, argv, flags)
- register TkMenuEntry *mePtr; /* Information about menu entry; may
- * or may not already have values for
- * some fields. */
- int argc; /* Number of valid entries in argv. */
- char **argv; /* Arguments. */
- int flags; /* Additional flags to pass to
- * Tk_ConfigureWidget. */
-{
- TkMenu *menuPtr = mePtr->menuPtr;
- int index = mePtr->index;
- Tk_Image image;
-
- /*
- * If this entry is a check button or radio button, then remove
- * its old trace procedure.
- */
-
- if ((mePtr->name != NULL)
- && ((mePtr->type == CHECK_BUTTON_ENTRY)
- || (mePtr->type == RADIO_BUTTON_ENTRY))) {
- Tcl_UntraceVar(menuPtr->interp, mePtr->name,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- MenuVarProc, (ClientData) mePtr);
- }
-
- if (menuPtr->tkwin != NULL) {
- if (Tk_ConfigureWidget(menuPtr->interp, menuPtr->tkwin,
- tkMenuEntryConfigSpecs, argc, argv, (char *) mePtr,
- flags | (COMMAND_MASK << mePtr->type)) != TCL_OK) {
- return TCL_ERROR;
- }
- }
-
- /*
- * The code below handles special configuration stuff not taken
- * care of by Tk_ConfigureWidget, such as special processing for
- * defaults, sizing strings, graphics contexts, etc.
- */
-
- if (mePtr->label == NULL) {
- mePtr->labelLength = 0;
- } else {
- mePtr->labelLength = strlen(mePtr->label);
- }
- if (mePtr->accel == NULL) {
- mePtr->accelLength = 0;
- } else {
- mePtr->accelLength = strlen(mePtr->accel);
- }
-
- /*
- * If this is a cascade entry, the platform-specific data of the child
- * menu has to be updated. Also, the links that point to parents and
- * cascades have to be updated.
- */
-
- if ((mePtr->type == CASCADE_ENTRY) && (mePtr->name != NULL)) {
- TkMenuEntry *cascadeEntryPtr;
- TkMenu *cascadeMenuPtr;
- int alreadyThere;
- TkMenuReferences *menuRefPtr;
- char *oldHashKey = NULL; /* Initialization only needed to
- * prevent compiler warning. */
-
- /*
- * This is a cascade entry. If the menu that the cascade entry
- * is pointing to has changed, we need to remove this entry
- * from the list of entries pointing to the old menu, and add a
- * cascade reference to the list of entries pointing to the
- * new menu.
- *
- * BUG: We are not recloning for special case #3 yet.
- */
-
- if (mePtr->childMenuRefPtr != NULL) {
- oldHashKey = Tcl_GetHashKey(TkGetMenuHashTable(menuPtr->interp),
- mePtr->childMenuRefPtr->hashEntryPtr);
- if (strcmp(oldHashKey, mePtr->name) != 0) {
- UnhookCascadeEntry(mePtr);
- }
- }
-
- if ((mePtr->childMenuRefPtr == NULL)
- || (strcmp(oldHashKey, mePtr->name) != 0)) {
- menuRefPtr = TkCreateMenuReferences(menuPtr->interp,
- mePtr->name);
- cascadeMenuPtr = menuRefPtr->menuPtr;
- mePtr->childMenuRefPtr = menuRefPtr;
-
- if (menuRefPtr->parentEntryPtr == NULL) {
- menuRefPtr->parentEntryPtr = mePtr;
- } else {
- alreadyThere = 0;
- for (cascadeEntryPtr = menuRefPtr->parentEntryPtr;
- cascadeEntryPtr != NULL;
- cascadeEntryPtr =
- cascadeEntryPtr->nextCascadePtr) {
- if (cascadeEntryPtr == mePtr) {
- alreadyThere = 1;
- break;
- }
- }
-
- /*
- * Put the item at the front of the list.
- */
-
- if (!alreadyThere) {
- mePtr->nextCascadePtr = menuRefPtr->parentEntryPtr;
- menuRefPtr->parentEntryPtr = mePtr;
- }
- }
- }
- }
-
- if (TkMenuConfigureEntryDrawOptions(mePtr, index) != TCL_OK) {
- return TCL_ERROR;
- }
-
- if (TkpConfigureMenuEntry(mePtr) != TCL_OK) {
- return TCL_ERROR;
- }
-
- if ((mePtr->type == CHECK_BUTTON_ENTRY)
- || (mePtr->type == RADIO_BUTTON_ENTRY)) {
- char *value;
-
- if (mePtr->name == NULL) {
- mePtr->name =
- (char *) ckalloc((unsigned) (mePtr->labelLength + 1));
- strcpy(mePtr->name, (mePtr->label == NULL) ? "" : mePtr->label);
- }
- if (mePtr->onValue == NULL) {
- mePtr->onValue = (char *) ckalloc((unsigned)
- (mePtr->labelLength + 1));
- strcpy(mePtr->onValue, (mePtr->label == NULL) ? "" : mePtr->label);
- }
-
- /*
- * Select the entry if the associated variable has the
- * appropriate value, initialize the variable if it doesn't
- * exist, then set a trace on the variable to monitor future
- * changes to its value.
- */
-
- value = Tcl_GetVar(menuPtr->interp, mePtr->name, TCL_GLOBAL_ONLY);
- mePtr->entryFlags &= ~ENTRY_SELECTED;
- if (value != NULL) {
- if (strcmp(value, mePtr->onValue) == 0) {
- mePtr->entryFlags |= ENTRY_SELECTED;
- }
- } else {
- Tcl_SetVar(menuPtr->interp, mePtr->name,
- (mePtr->type == CHECK_BUTTON_ENTRY) ? mePtr->offValue : "",
- TCL_GLOBAL_ONLY);
- }
- Tcl_TraceVar(menuPtr->interp, mePtr->name,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- MenuVarProc, (ClientData) mePtr);
- }
-
- /*
- * Get the images for the entry, if there are any. Allocate the
- * new images before freeing the old ones, so that the reference
- * counts don't go to zero and cause image data to be discarded.
- */
-
- if (mePtr->imageString != NULL) {
- image = Tk_GetImage(menuPtr->interp, menuPtr->tkwin, mePtr->imageString,
- TkMenuImageProc, (ClientData) mePtr);
- if (image == NULL) {
- return TCL_ERROR;
- }
- } else {
- image = NULL;
- }
- if (mePtr->image != NULL) {
- Tk_FreeImage(mePtr->image);
- }
- mePtr->image = image;
- if (mePtr->selectImageString != NULL) {
- image = Tk_GetImage(menuPtr->interp, menuPtr->tkwin, mePtr->selectImageString,
- TkMenuSelectImageProc, (ClientData) mePtr);
- if (image == NULL) {
- return TCL_ERROR;
- }
- } else {
- image = NULL;
- }
- if (mePtr->selectImage != NULL) {
- Tk_FreeImage(mePtr->selectImage);
- }
- mePtr->selectImage = image;
-
- TkEventuallyRecomputeMenu(menuPtr);
-
- return TCL_OK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ConfigureMenuCloneEntries --
- *
- * Calls ConfigureMenuEntry for each menu in the clone chain.
- *
- * Results:
- * The return value is a standard Tcl result. If TCL_ERROR is
- * returned, then interp->result contains an error message.
- *
- * Side effects:
- * Configuration information such as label and accelerator get
- * set for mePtr; old resources get freed, if there were any.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-ConfigureMenuCloneEntries(interp, menuPtr, index, argc, argv, flags)
- Tcl_Interp *interp; /* Used for error reporting. */
- TkMenu *menuPtr; /* Information about whole menu. */
- int index; /* Index of mePtr within menuPtr's
- * entries. */
- int argc; /* Number of valid entries in argv. */
- char **argv; /* Arguments. */
- int flags; /* Additional flags to pass to
- * Tk_ConfigureWidget. */
-{
- TkMenuEntry *mePtr;
- TkMenu *menuListPtr;
- char *oldCascadeName = NULL, *newMenuName = NULL;
- int cascadeEntryChanged;
- TkMenuReferences *oldCascadeMenuRefPtr, *cascadeMenuRefPtr = NULL;
-
- /*
- * Cascades are kind of tricky here. This is special case #3 in the comment
- * at the top of this file. Basically, if a menu is the master menu of a
- * clone chain, and has an entry with a cascade menu, the clones of
- * the menu will point to clones of the cascade menu. We have
- * to destroy the clones of the cascades, clone the new cascade
- * menu, and configure the entry to point to the new clone.
- */
-
- mePtr = menuPtr->masterMenuPtr->entries[index];
- if (mePtr->type == CASCADE_ENTRY) {
- oldCascadeName = mePtr->name;
- }
-
- if (ConfigureMenuEntry(mePtr, argc, argv, flags) != TCL_OK) {
- return TCL_ERROR;
- }
-
- cascadeEntryChanged = (mePtr->type == CASCADE_ENTRY)
- && (oldCascadeName != mePtr->name);
-
- if (cascadeEntryChanged) {
- newMenuName = mePtr->name;
- if (newMenuName != NULL) {
- cascadeMenuRefPtr = TkFindMenuReferences(menuPtr->interp,
- mePtr->name);
- }
- }
-
- for (menuListPtr = menuPtr->masterMenuPtr->nextInstancePtr;
- menuListPtr != NULL;
- menuListPtr = menuListPtr->nextInstancePtr) {
-
- mePtr = menuListPtr->entries[index];
-
- if (cascadeEntryChanged && (mePtr->name != NULL)) {
- oldCascadeMenuRefPtr = TkFindMenuReferences(menuPtr->interp,
- mePtr->name);
-
- if ((oldCascadeMenuRefPtr != NULL)
- && (oldCascadeMenuRefPtr->menuPtr != NULL)) {
- RecursivelyDeleteMenu(oldCascadeMenuRefPtr->menuPtr);
- }
- }
-
- if (ConfigureMenuEntry(mePtr, argc, argv, flags) != TCL_OK) {
- return TCL_ERROR;
- }
-
- if (cascadeEntryChanged && (newMenuName != NULL)) {
- if (cascadeMenuRefPtr->menuPtr != NULL) {
- char *newArgV[2];
- char *newCloneName;
-
- newCloneName = TkNewMenuName(menuPtr->interp,
- Tk_PathName(menuListPtr->tkwin),
- cascadeMenuRefPtr->menuPtr);
- CloneMenu(cascadeMenuRefPtr->menuPtr, newCloneName,
- "normal");
-
- newArgV[0] = "-menu";
- newArgV[1] = newCloneName;
- ConfigureMenuEntry(mePtr, 2, newArgV, flags);
- ckfree(newCloneName);
- }
- }
- }
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * TkGetMenuIndex --
- *
- * Parse a textual index into a menu and return the numerical
- * index of the indicated entry.
- *
- * Results:
- * A standard Tcl result. If all went well, then *indexPtr is
- * filled in with the entry index corresponding to string
- * (ranges from -1 to the number of entries in the menu minus
- * one). Otherwise an error message is left in interp->result.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-int
-TkGetMenuIndex(interp, menuPtr, string, lastOK, indexPtr)
- Tcl_Interp *interp; /* For error messages. */
- TkMenu *menuPtr; /* Menu for which the index is being
- * specified. */
- char *string; /* Specification of an entry in menu. See
- * manual entry for valid .*/
- int lastOK; /* Non-zero means its OK to return index
- * just *after* last entry. */
- int *indexPtr; /* Where to store converted relief. */
-{
- int i;
-
- if ((string[0] == 'a') && (strcmp(string, "active") == 0)) {
- *indexPtr = menuPtr->active;
- return TCL_OK;
- }
-
- if (((string[0] == 'l') && (strcmp(string, "last") == 0))
- || ((string[0] == 'e') && (strcmp(string, "end") == 0))) {
- *indexPtr = menuPtr->numEntries - ((lastOK) ? 0 : 1);
- return TCL_OK;
- }
-
- if ((string[0] == 'n') && (strcmp(string, "none") == 0)) {
- *indexPtr = -1;
- return TCL_OK;
- }
-
- if (string[0] == '@') {
- if (GetIndexFromCoords(interp, menuPtr, string, indexPtr)
- == TCL_OK) {
- return TCL_OK;
- }
- }
-
- if (isdigit(UCHAR(string[0]))) {
- if (Tcl_GetInt(interp, string, &i) == TCL_OK) {
- if (i >= menuPtr->numEntries) {
- if (lastOK) {
- i = menuPtr->numEntries;
- } else {
- i = menuPtr->numEntries-1;
- }
- } else if (i < 0) {
- i = -1;
- }
- *indexPtr = i;
- return TCL_OK;
- }
- Tcl_SetResult(interp, (char *) NULL, TCL_STATIC);
- }
-
- for (i = 0; i < menuPtr->numEntries; i++) {
- char *label;
-
- label = menuPtr->entries[i]->label;
- if ((label != NULL)
- && (Tcl_StringMatch(menuPtr->entries[i]->label, string))) {
- *indexPtr = i;
- return TCL_OK;
- }
- }
-
- Tcl_AppendResult(interp, "bad menu entry index \"",
- string, "\"", (char *) NULL);
- return TCL_ERROR;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * MenuCmdDeletedProc --
- *
- * 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
-MenuCmdDeletedProc(clientData)
- ClientData clientData; /* Pointer to widget record for widget. */
-{
- TkMenu *menuPtr = (TkMenu *) clientData;
- Tk_Window tkwin = menuPtr->tkwin;
-
- /*
- * This procedure could be invoked either because the window was
- * destroyed and the command was then deleted (in which case tkwin
- * is NULL) or because the command was deleted, and then this procedure
- * destroys the widget.
- */
-
- if (tkwin != NULL) {
- menuPtr->tkwin = NULL;
- Tk_DestroyWindow(tkwin);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * MenuNewEntry --
- *
- * This procedure allocates and initializes a new menu entry.
- *
- * Results:
- * The return value is a pointer to a new menu entry structure,
- * which has been malloc-ed, initialized, and entered into the
- * entry array for the menu.
- *
- * Side effects:
- * Storage gets allocated.
- *
- *----------------------------------------------------------------------
- */
-
-static TkMenuEntry *
-MenuNewEntry(menuPtr, index, type)
- TkMenu *menuPtr; /* Menu that will hold the new entry. */
- int index; /* Where in the menu the new entry is to
- * go. */
- int type; /* The type of the new entry. */
-{
- TkMenuEntry *mePtr;
- TkMenuEntry **newEntries;
- int i;
-
- /*
- * Create a new array of entries with an empty slot for the
- * new entry.
- */
-
- newEntries = (TkMenuEntry **) ckalloc((unsigned)
- ((menuPtr->numEntries+1)*sizeof(TkMenuEntry *)));
- for (i = 0; i < index; i++) {
- newEntries[i] = menuPtr->entries[i];
- }
- for ( ; i < menuPtr->numEntries; i++) {
- newEntries[i+1] = menuPtr->entries[i];
- newEntries[i+1]->index = i + 1;
- }
- if (menuPtr->numEntries != 0) {
- ckfree((char *) menuPtr->entries);
- }
- menuPtr->entries = newEntries;
- menuPtr->numEntries++;
- mePtr = (TkMenuEntry *) ckalloc(sizeof(TkMenuEntry));
- menuPtr->entries[index] = mePtr;
- mePtr->type = type;
- mePtr->menuPtr = menuPtr;
- mePtr->label = NULL;
- mePtr->labelLength = 0;
- mePtr->underline = -1;
- mePtr->bitmap = None;
- mePtr->imageString = NULL;
- mePtr->image = NULL;
- mePtr->selectImageString = NULL;
- mePtr->selectImage = NULL;
- mePtr->accel = NULL;
- mePtr->accelLength = 0;
- mePtr->state = tkNormalUid;
- mePtr->border = NULL;
- mePtr->fg = NULL;
- mePtr->activeBorder = NULL;
- mePtr->activeFg = NULL;
- mePtr->tkfont = NULL;
- mePtr->indicatorOn = 1;
- mePtr->indicatorFg = NULL;
- mePtr->columnBreak = 0;
- mePtr->hideMargin = 0;
- mePtr->command = NULL;
- mePtr->name = NULL;
- mePtr->childMenuRefPtr = NULL;
- mePtr->onValue = NULL;
- mePtr->offValue = NULL;
- mePtr->entryFlags = 0;
- mePtr->index = index;
- mePtr->nextCascadePtr = NULL;
- TkMenuInitializeEntryDrawingFields(mePtr);
- if (TkpMenuNewEntry(mePtr) != TCL_OK) {
- ckfree((char *) mePtr);
- return NULL;
- }
-
- return mePtr;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * MenuAddOrInsert --
- *
- * This procedure does all of the work of the "add" and "insert"
- * widget commands, allowing the code for these to be shared.
- *
- * Results:
- * A standard Tcl return value.
- *
- * Side effects:
- * A new menu entry is created in menuPtr.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-MenuAddOrInsert(interp, menuPtr, indexString, argc, argv)
- Tcl_Interp *interp; /* Used for error reporting. */
- TkMenu *menuPtr; /* Widget in which to create new
- * entry. */
- char *indexString; /* String describing index at which
- * to insert. NULL means insert at
- * end. */
- int argc; /* Number of elements in argv. */
- char **argv; /* Arguments to command: first arg
- * is type of entry, others are
- * config options. */
-{
- int c, type, index;
- size_t length;
- TkMenuEntry *mePtr;
- TkMenu *menuListPtr;
-
- if (indexString != NULL) {
- if (TkGetMenuIndex(interp, menuPtr, indexString, 1, &index)
- != TCL_OK) {
- return TCL_ERROR;
- }
- } else {
- index = menuPtr->numEntries;
- }
- if (index < 0) {
- Tcl_AppendResult(interp, "bad index \"", indexString, "\"",
- (char *) NULL);
- return TCL_ERROR;
- }
- if (menuPtr->tearOff && (index == 0)) {
- index = 1;
- }
-
- /*
- * Figure out the type of the new entry.
- */
-
- c = argv[0][0];
- length = strlen(argv[0]);
- if ((c == 'c') && (strncmp(argv[0], "cascade", length) == 0)
- && (length >= 2)) {
- type = CASCADE_ENTRY;
- } else if ((c == 'c') && (strncmp(argv[0], "checkbutton", length) == 0)
- && (length >= 2)) {
- type = CHECK_BUTTON_ENTRY;
- } else if ((c == 'c') && (strncmp(argv[0], "command", length) == 0)
- && (length >= 2)) {
- type = COMMAND_ENTRY;
- } else if ((c == 'r')
- && (strncmp(argv[0], "radiobutton", length) == 0)) {
- type = RADIO_BUTTON_ENTRY;
- } else if ((c == 's')
- && (strncmp(argv[0], "separator", length) == 0)) {
- type = SEPARATOR_ENTRY;
- } else {
- Tcl_AppendResult(interp, "bad menu entry type \"",
- argv[0], "\": must be cascade, checkbutton, ",
- "command, radiobutton, or separator", (char *) NULL);
- return TCL_ERROR;
- }
-
- /*
- * Now we have to add an entry for every instance related to this menu.
- */
-
- for (menuListPtr = menuPtr->masterMenuPtr; menuListPtr != NULL;
- menuListPtr = menuListPtr->nextInstancePtr) {
-
- mePtr = MenuNewEntry(menuListPtr, index, type);
- if (mePtr == NULL) {
- return TCL_ERROR;
- }
- if (ConfigureMenuEntry(mePtr, argc-1, argv+1, 0) != TCL_OK) {
- TkMenu *errorMenuPtr;
- int i;
-
- for (errorMenuPtr = menuPtr->masterMenuPtr;
- errorMenuPtr != NULL;
- errorMenuPtr = errorMenuPtr->nextInstancePtr) {
- Tcl_EventuallyFree((ClientData) errorMenuPtr->entries[index],
- DestroyMenuEntry);
- for (i = index; i < errorMenuPtr->numEntries - 1; i++) {
- errorMenuPtr->entries[i] = errorMenuPtr->entries[i + 1];
- errorMenuPtr->entries[i]->index = i;
- }
- errorMenuPtr->numEntries--;
- if (errorMenuPtr->numEntries == 0) {
- ckfree((char *) errorMenuPtr->entries);
- errorMenuPtr->entries = NULL;
- }
- if (errorMenuPtr == menuListPtr) {
- break;
- }
- }
- return TCL_ERROR;
- }
-
- /*
- * If a menu has cascades, then every instance of the menu has
- * to have its own parallel cascade structure. So adding an
- * entry to a menu with clones means that the menu that the
- * entry points to has to be cloned for every clone the
- * master menu has. This is special case #2 in the comment
- * at the top of this file.
- */
-
- if ((menuPtr != menuListPtr) && (type == CASCADE_ENTRY)) {
- if ((mePtr->name != NULL) && (mePtr->childMenuRefPtr != NULL)
- && (mePtr->childMenuRefPtr->menuPtr != NULL)) {
- TkMenu *cascadeMenuPtr =
- mePtr->childMenuRefPtr->menuPtr->masterMenuPtr;
- char *newCascadeName;
- char *newArgv[2];
- TkMenuReferences *menuRefPtr;
-
- newCascadeName = TkNewMenuName(menuListPtr->interp,
- Tk_PathName(menuListPtr->tkwin),
- cascadeMenuPtr);
- CloneMenu(cascadeMenuPtr, newCascadeName, "normal");
-
- menuRefPtr = TkFindMenuReferences(menuListPtr->interp,
- newCascadeName);
- if (menuRefPtr == NULL) {
- panic("CloneMenu failed inside of MenuAddOrInsert.");
- }
- newArgv[0] = "-menu";
- newArgv[1] = newCascadeName;
- ConfigureMenuEntry(mePtr, 2, newArgv, 0);
- ckfree(newCascadeName);
- }
- }
- }
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * MenuVarProc --
- *
- * This procedure is invoked when someone changes the
- * state variable associated with a radiobutton or checkbutton
- * menu entry. The entry's selected state is set to match
- * the value of the variable.
- *
- * Results:
- * NULL is always returned.
- *
- * Side effects:
- * The menu entry may become selected or deselected.
- *
- *--------------------------------------------------------------
- */
-
-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. */
- int flags; /* Describes what just happened. */
-{
- TkMenuEntry *mePtr = (TkMenuEntry *) clientData;
- TkMenu *menuPtr;
- char *value;
-
- menuPtr = mePtr->menuPtr;
-
- /*
- * If the variable is being unset, then re-establish the
- * trace unless the whole interpreter is going away.
- */
-
- if (flags & TCL_TRACE_UNSETS) {
- mePtr->entryFlags &= ~ENTRY_SELECTED;
- if ((flags & TCL_TRACE_DESTROYED) && !(flags & TCL_INTERP_DESTROYED)) {
- Tcl_TraceVar(interp, mePtr->name,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- MenuVarProc, clientData);
- }
- TkpConfigureMenuEntry(mePtr);
- TkEventuallyRedrawMenu(menuPtr, (TkMenuEntry *) NULL);
- return (char *) NULL;
- }
-
- /*
- * Use the value of the variable to update the selected status of
- * the menu entry.
- */
-
- value = Tcl_GetVar(interp, mePtr->name, TCL_GLOBAL_ONLY);
- if (value == NULL) {
- value = "";
- }
- if (strcmp(value, mePtr->onValue) == 0) {
- if (mePtr->entryFlags & ENTRY_SELECTED) {
- return (char *) NULL;
- }
- mePtr->entryFlags |= ENTRY_SELECTED;
- } else if (mePtr->entryFlags & ENTRY_SELECTED) {
- mePtr->entryFlags &= ~ENTRY_SELECTED;
- } else {
- return (char *) NULL;
- }
- TkpConfigureMenuEntry(mePtr);
- TkEventuallyRedrawMenu(menuPtr, mePtr);
- return (char *) NULL;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkActivateMenuEntry --
- *
- * This procedure is invoked to make a particular menu entry
- * the active one, deactivating any other entry that might
- * currently be active.
- *
- * Results:
- * The return value is a standard Tcl result (errors can occur
- * while posting and unposting submenus).
- *
- * Side effects:
- * Menu entries get redisplayed, and the active entry changes.
- * Submenus may get posted and unposted.
- *
- *----------------------------------------------------------------------
- */
-
-int
-TkActivateMenuEntry(menuPtr, index)
- register TkMenu *menuPtr; /* Menu in which to activate. */
- int index; /* Index of entry to activate, or
- * -1 to deactivate all entries. */
-{
- register TkMenuEntry *mePtr;
- int result = TCL_OK;
-
- if (menuPtr->active >= 0) {
- mePtr = menuPtr->entries[menuPtr->active];
-
- /*
- * Don't change the state unless it's currently active (state
- * might already have been changed to disabled).
- */
-
- if (mePtr->state == tkActiveUid) {
- mePtr->state = tkNormalUid;
- }
- TkEventuallyRedrawMenu(menuPtr, menuPtr->entries[menuPtr->active]);
- }
- menuPtr->active = index;
- if (index >= 0) {
- mePtr = menuPtr->entries[index];
- mePtr->state = tkActiveUid;
- TkEventuallyRedrawMenu(menuPtr, mePtr);
- }
- return result;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkPostCommand --
- *
- * Execute the postcommand for the given menu.
- *
- * Results:
- * The return value is a standard Tcl result (errors can occur
- * while the postcommands are being processed).
- *
- * Side effects:
- * Since commands can get executed while this routine is being executed,
- * the entire world can change.
- *
- *----------------------------------------------------------------------
- */
-
-int
-TkPostCommand(menuPtr)
- TkMenu *menuPtr;
-{
- int result;
-
- /*
- * If there is a command for the menu, execute it. This
- * may change the size of the menu, so be sure to recompute
- * the menu's geometry if needed.
- */
-
- if (menuPtr->postCommand != NULL) {
- result = TkCopyAndGlobalEval(menuPtr->interp,
- menuPtr->postCommand);
- if (result != TCL_OK) {
- return result;
- }
- TkRecomputeMenu(menuPtr);
- }
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * CloneMenu --
- *
- * Creates a child copy of the menu. It will be inserted into
- * the menu's instance chain. All attributes and entry
- * attributes will be duplicated.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * Allocates storage. After the menu is created, any
- * configuration done with this menu or any related one
- * will be reflected in all of them.
- *
- *--------------------------------------------------------------
- */
-
-static int
-CloneMenu(menuPtr, newMenuName, newMenuTypeString)
- TkMenu *menuPtr; /* The menu we are going to clone */
- char *newMenuName; /* The name to give the new menu */
- char *newMenuTypeString; /* What kind of menu is this, a normal menu
- * a menubar, or a tearoff? */
-{
- int returnResult;
- int menuType;
- size_t length;
- TkMenuReferences *menuRefPtr;
- Tcl_Obj *commandObjPtr;
-
- if (newMenuTypeString == NULL) {
- menuType = MASTER_MENU;
- } else {
- length = strlen(newMenuTypeString);
- if (strncmp(newMenuTypeString, "normal", length) == 0) {
- menuType = MASTER_MENU;
- } else if (strncmp(newMenuTypeString, "tearoff", length) == 0) {
- menuType = TEAROFF_MENU;
- } else if (strncmp(newMenuTypeString, "menubar", length) == 0) {
- menuType = MENUBAR;
- } else {
- Tcl_AppendResult(menuPtr->interp,
- "bad menu type - must be normal, tearoff, or menubar",
- (char *) NULL);
- return TCL_ERROR;
- }
- }
-
- commandObjPtr = Tcl_NewListObj(0, (Tcl_Obj **) NULL);
- Tcl_ListObjAppendElement(menuPtr->interp, commandObjPtr,
- Tcl_NewStringObj("tkMenuDup", -1));
- Tcl_ListObjAppendElement(menuPtr->interp, commandObjPtr,
- Tcl_NewStringObj(Tk_PathName(menuPtr->tkwin), -1));
- Tcl_ListObjAppendElement(menuPtr->interp, commandObjPtr,
- Tcl_NewStringObj(newMenuName, -1));
- if ((newMenuTypeString == NULL) || (newMenuTypeString[0] == '\0')) {
- Tcl_ListObjAppendElement(menuPtr->interp, commandObjPtr,
- Tcl_NewStringObj("normal", -1));
- } else {
- Tcl_ListObjAppendElement(menuPtr->interp, commandObjPtr,
- Tcl_NewStringObj(newMenuTypeString, -1));
- }
- Tcl_IncrRefCount(commandObjPtr);
- Tcl_Preserve((ClientData) menuPtr);
- returnResult = Tcl_EvalObj(menuPtr->interp, commandObjPtr);
- Tcl_DecrRefCount(commandObjPtr);
-
- /*
- * Make sure the tcl command actually created the clone.
- */
-
- if ((returnResult == TCL_OK) &&
- ((menuRefPtr = TkFindMenuReferences(menuPtr->interp, newMenuName))
- != (TkMenuReferences *) NULL)
- && (menuPtr->numEntries == menuRefPtr->menuPtr->numEntries)) {
- TkMenu *newMenuPtr = menuRefPtr->menuPtr;
- char *newArgv[3];
- int i, numElements;
-
- /*
- * Now put this newly created menu into the parent menu's instance
- * chain.
- */
-
- if (menuPtr->nextInstancePtr == NULL) {
- menuPtr->nextInstancePtr = newMenuPtr;
- newMenuPtr->masterMenuPtr = menuPtr->masterMenuPtr;
- } else {
- TkMenu *masterMenuPtr;
-
- masterMenuPtr = menuPtr->masterMenuPtr;
- newMenuPtr->nextInstancePtr = masterMenuPtr->nextInstancePtr;
- masterMenuPtr->nextInstancePtr = newMenuPtr;
- newMenuPtr->masterMenuPtr = masterMenuPtr;
- }
-
- /*
- * Add the master menu's window to the bind tags for this window
- * after this window's tag. This is so the user can bind to either
- * this clone (which may not be easy to do) or the entire menu
- * clone structure.
- */
-
- newArgv[0] = "bindtags";
- newArgv[1] = Tk_PathName(newMenuPtr->tkwin);
- if (Tk_BindtagsCmd((ClientData)newMenuPtr->tkwin,
- newMenuPtr->interp, 2, newArgv) == TCL_OK) {
- char *windowName;
- Tcl_Obj *bindingsPtr =
- Tcl_NewStringObj(newMenuPtr->interp->result, -1);
- Tcl_Obj *elementPtr;
-
- Tcl_ListObjLength(newMenuPtr->interp, bindingsPtr, &numElements);
- for (i = 0; i < numElements; i++) {
- Tcl_ListObjIndex(newMenuPtr->interp, bindingsPtr, i,
- &elementPtr);
- windowName = Tcl_GetStringFromObj(elementPtr, NULL);
- if (strcmp(windowName, Tk_PathName(newMenuPtr->tkwin))
- == 0) {
- Tcl_Obj *newElementPtr = Tcl_NewStringObj(
- Tk_PathName(newMenuPtr->masterMenuPtr->tkwin), -1);
- 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);
- break;
- }
- }
- Tcl_DecrRefCount(bindingsPtr);
- }
- Tcl_ResetResult(menuPtr->interp);
-
- /*
- * Clone all of the cascade menus that this menu points to.
- */
-
- for (i = 0; i < menuPtr->numEntries; i++) {
- char *newCascadeName;
- TkMenuReferences *cascadeRefPtr;
- TkMenu *oldCascadePtr;
-
- if ((menuPtr->entries[i]->type == CASCADE_ENTRY)
- && (menuPtr->entries[i]->name != NULL)) {
- cascadeRefPtr =
- TkFindMenuReferences(menuPtr->interp,
- menuPtr->entries[i]->name);
- if ((cascadeRefPtr != NULL) && (cascadeRefPtr->menuPtr)) {
- char *nameString;
-
- oldCascadePtr = cascadeRefPtr->menuPtr;
-
- nameString = Tk_PathName(newMenuPtr->tkwin);
- newCascadeName = TkNewMenuName(menuPtr->interp,
- nameString, oldCascadePtr);
- CloneMenu(oldCascadePtr, newCascadeName, NULL);
-
- newArgv[0] = "-menu";
- newArgv[1] = newCascadeName;
- ConfigureMenuEntry(newMenuPtr->entries[i], 2, newArgv,
- TK_CONFIG_ARGV_ONLY);
- ckfree(newCascadeName);
- }
- }
- }
-
- returnResult = TCL_OK;
- } else {
- returnResult = TCL_ERROR;
- }
- Tcl_Release((ClientData) menuPtr);
- return returnResult;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * MenuDoYPosition --
- *
- * Given arguments from an option command line, returns the Y position.
- *
- * Results:
- * Returns TCL_OK or TCL_Error
- *
- * Side effects:
- * yPosition is set to the Y-position of the menu entry.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-MenuDoYPosition(interp, menuPtr, arg)
- Tcl_Interp *interp;
- TkMenu *menuPtr;
- char *arg;
-{
- int index;
-
- TkRecomputeMenu(menuPtr);
- if (TkGetMenuIndex(interp, menuPtr, arg, 0, &index) != TCL_OK) {
- goto error;
- }
- if (index < 0) {
- interp->result = "0";
- } else {
- sprintf(interp->result, "%d", menuPtr->entries[index]->y);
- }
- return TCL_OK;
-
-error:
- return TCL_ERROR;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * GetIndexFromCoords --
- *
- * Given a string of the form "@int", return the menu item corresponding
- * to int.
- *
- * Results:
- * If int is a valid number, *indexPtr will be the number of the menuentry
- * that is the correct height. If int is invaled, *indexPtr will be
- * unchanged. Returns appropriate Tcl error number.
- *
- * Side effects:
- * If int is invalid, interp's result will set to NULL.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-GetIndexFromCoords(interp, menuPtr, string, indexPtr)
- Tcl_Interp *interp; /* interp of menu */
- TkMenu *menuPtr; /* the menu we are searching */
- char *string; /* The @string we are parsing */
- int *indexPtr; /* The index of the item that matches */
-{
- int x, y, i;
- char *p, *end;
-
- TkRecomputeMenu(menuPtr);
- p = string + 1;
- y = strtol(p, &end, 0);
- if (end == p) {
- goto error;
- }
- if (*end == ',') {
- x = y;
- p = end + 1;
- y = strtol(p, &end, 0);
- if (end == p) {
- goto error;
- }
- } else {
- x = menuPtr->borderWidth;
- }
-
- for (i = 0; i < menuPtr->numEntries; i++) {
- if ((x >= menuPtr->entries[i]->x) && (y >= menuPtr->entries[i]->y)
- && (x < (menuPtr->entries[i]->x + menuPtr->entries[i]->width))
- && (y < (menuPtr->entries[i]->y
- + menuPtr->entries[i]->height))) {
- break;
- }
- }
- if (i >= menuPtr->numEntries) {
- /* i = menuPtr->numEntries - 1; */
- i = -1;
- }
- *indexPtr = i;
- return TCL_OK;
-
- error:
- Tcl_SetResult(interp, (char *) NULL, TCL_STATIC);
- return TCL_ERROR;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * RecursivelyDeleteMenu --
- *
- * Deletes a menu and any cascades underneath it. Used for deleting
- * instances when a menu is no longer being used as a menubar,
- * for instance.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Destroys the menu and all cascade menus underneath it.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-RecursivelyDeleteMenu(menuPtr)
- TkMenu *menuPtr; /* The menubar instance we are deleting */
-{
- int i;
- TkMenuEntry *mePtr;
-
- for (i = 0; i < menuPtr->numEntries; i++) {
- mePtr = menuPtr->entries[i];
- if ((mePtr->type == CASCADE_ENTRY)
- && (mePtr->childMenuRefPtr != NULL)
- && (mePtr->childMenuRefPtr->menuPtr != NULL)) {
- RecursivelyDeleteMenu(mePtr->childMenuRefPtr->menuPtr);
- }
- }
- Tk_DestroyWindow(menuPtr->tkwin);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkNewMenuName --
- *
- * Makes a new unique name for a cloned menu. Will be a child
- * of oldName.
- *
- * Results:
- * Returns a char * which has been allocated; caller must free.
- *
- * Side effects:
- * Memory is allocated.
- *
- *----------------------------------------------------------------------
- */
-
-char *
-TkNewMenuName(interp, parentName, menuPtr)
- Tcl_Interp *interp; /* The interp the new name has to live in.*/
- char *parentName; /* The prefix path of the new name. */
- TkMenu *menuPtr; /* The menu we are cloning. */
-{
- Tcl_DString resultDString;
- Tcl_DString childDString;
- char *destString;
- int offset, i;
- int doDot = parentName[strlen(parentName) - 1] != '.';
- Tcl_CmdInfo cmdInfo;
- char *returnString;
- Tcl_HashTable *nameTablePtr = NULL;
- TkWindow *winPtr = (TkWindow *) menuPtr->tkwin;
- if (winPtr->mainPtr != NULL) {
- nameTablePtr = &(winPtr->mainPtr->nameTable);
- }
-
- Tcl_DStringInit(&childDString);
- Tcl_DStringAppend(&childDString, Tk_PathName(menuPtr->tkwin), -1);
- for (destString = Tcl_DStringValue(&childDString);
- *destString != '\0'; destString++) {
- if (*destString == '.') {
- *destString = '#';
- }
- }
-
- offset = 0;
-
- for (i = 0; ; i++) {
- if (i == 0) {
- Tcl_DStringInit(&resultDString);
- Tcl_DStringAppend(&resultDString, parentName, -1);
- if (doDot) {
- Tcl_DStringAppend(&resultDString, ".", -1);
- }
- Tcl_DStringAppend(&resultDString,
- Tcl_DStringValue(&childDString), -1);
- destString = Tcl_DStringValue(&resultDString);
- } else {
- if (i == 1) {
- offset = Tcl_DStringLength(&resultDString);
- Tcl_DStringSetLength(&resultDString, offset + 10);
- destString = Tcl_DStringValue(&resultDString);
- }
- sprintf(destString + offset, "%d", i);
- }
- if ((Tcl_GetCommandInfo(interp, destString, &cmdInfo) == 0)
- && ((nameTablePtr == NULL)
- || (Tcl_FindHashEntry(nameTablePtr, destString) == NULL))) {
- break;
- }
- }
- returnString = ckalloc(strlen(destString) + 1);
- strcpy(returnString, destString);
- Tcl_DStringFree(&resultDString);
- Tcl_DStringFree(&childDString);
- return returnString;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkSetWindowMenuBar --
- *
- * Associates a menu with a window. Called by ConfigureFrame in
- * in response to a "-menu .foo" configuration option for a top
- * level.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The old menu clones for the menubar are thrown away, and a
- * handler is set up to allocate the new ones.
- *
- *----------------------------------------------------------------------
- */
-void
-TkSetWindowMenuBar(interp, tkwin, oldMenuName, menuName)
- Tcl_Interp *interp; /* The interpreter the toplevel lives in. */
- Tk_Window tkwin; /* The toplevel window */
- char *oldMenuName; /* The name of the menubar previously set in
- * this toplevel. NULL means no menu was
- * set previously. */
- char *menuName; /* The name of the new menubar that the
- * toplevel needs to be set to. NULL means
- * that their is no menu now. */
-{
- TkMenuTopLevelList *topLevelListPtr, *prevTopLevelPtr;
- TkMenu *menuPtr;
- TkMenuReferences *menuRefPtr;
-
- TkMenuInit();
-
- /*
- * Destroy the menubar instances of the old menu. Take this window
- * out of the old menu's top level reference list.
- */
-
- if (oldMenuName != NULL) {
- menuRefPtr = TkFindMenuReferences(interp, oldMenuName);
- if (menuRefPtr != NULL) {
-
- /*
- * Find the menubar instance that is to be removed. Destroy
- * it and all of the cascades underneath it.
- */
-
- if (menuRefPtr->menuPtr != NULL) {
- TkMenu *instancePtr;
-
- menuPtr = menuRefPtr->menuPtr;
-
- for (instancePtr = menuPtr->masterMenuPtr;
- instancePtr != NULL;
- instancePtr = instancePtr->nextInstancePtr) {
- if (instancePtr->menuType == MENUBAR
- && instancePtr->parentTopLevelPtr == tkwin) {
- RecursivelyDeleteMenu(instancePtr);
- break;
- }
- }
- }
-
- /*
- * Now we need to remove this toplevel from the list of toplevels
- * that reference this menu.
- */
-
- for (topLevelListPtr = menuRefPtr->topLevelListPtr,
- prevTopLevelPtr = NULL;
- (topLevelListPtr != NULL)
- && (topLevelListPtr->tkwin != tkwin);
- prevTopLevelPtr = topLevelListPtr,
- topLevelListPtr = topLevelListPtr->nextPtr) {
-
- /*
- * Empty loop body.
- */
-
- }
-
- /*
- * Now we have found the toplevel reference that matches the
- * tkwin; remove this reference from the list.
- */
-
- if (topLevelListPtr != NULL) {
- if (prevTopLevelPtr == NULL) {
- menuRefPtr->topLevelListPtr =
- menuRefPtr->topLevelListPtr->nextPtr;
- } else {
- prevTopLevelPtr->nextPtr = topLevelListPtr->nextPtr;
- }
- ckfree((char *) topLevelListPtr);
- TkFreeMenuReferences(menuRefPtr);
- }
- }
- }
-
- /*
- * Now, add the clone references for the new menu.
- */
-
- if (menuName != NULL && menuName[0] != 0) {
- TkMenu *menuBarPtr = NULL;
-
- menuRefPtr = TkCreateMenuReferences(interp, menuName);
-
- menuPtr = menuRefPtr->menuPtr;
- if (menuPtr != NULL) {
- char *cloneMenuName;
- TkMenuReferences *cloneMenuRefPtr;
- char *newArgv[4];
-
- /*
- * Clone the menu and all of the cascades underneath it.
- */
-
- cloneMenuName = TkNewMenuName(interp, Tk_PathName(tkwin),
- menuPtr);
- CloneMenu(menuPtr, cloneMenuName, "menubar");
-
- cloneMenuRefPtr = TkFindMenuReferences(interp, cloneMenuName);
- if ((cloneMenuRefPtr != NULL)
- && (cloneMenuRefPtr->menuPtr != NULL)) {
- cloneMenuRefPtr->menuPtr->parentTopLevelPtr = tkwin;
- menuBarPtr = cloneMenuRefPtr->menuPtr;
- newArgv[0] = "-cursor";
- newArgv[1] = "";
- ConfigureMenu(menuPtr->interp, cloneMenuRefPtr->menuPtr,
- 2, newArgv, TK_CONFIG_ARGV_ONLY);
- }
-
- TkpSetWindowMenuBar(tkwin, menuBarPtr);
-
- ckfree(cloneMenuName);
- } else {
- TkpSetWindowMenuBar(tkwin, NULL);
- }
-
-
- /*
- * Add this window to the menu's list of windows that refer
- * to this menu.
- */
-
- topLevelListPtr = (TkMenuTopLevelList *)
- ckalloc(sizeof(TkMenuTopLevelList));
- topLevelListPtr->tkwin = tkwin;
- topLevelListPtr->nextPtr = menuRefPtr->topLevelListPtr;
- menuRefPtr->topLevelListPtr = topLevelListPtr;
- } else {
- TkpSetWindowMenuBar(tkwin, NULL);
- }
- TkpSetMainMenubar(interp, tkwin, menuName);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * DestroyMenuHashTable --
- *
- * Called when an interp is deleted and a menu hash table has
- * been set in it.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The hash table is destroyed.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-DestroyMenuHashTable(clientData, interp)
- ClientData clientData; /* The menu hash table we are destroying */
- Tcl_Interp *interp; /* The interpreter we are destroying */
-{
- Tcl_DeleteHashTable((Tcl_HashTable *) clientData);
- ckfree((char *) clientData);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkGetMenuHashTable --
- *
- * For a given interp, give back the menu hash table that goes with
- * it. If the hash table does not exist, it is created.
- *
- * Results:
- * Returns a hash table pointer.
- *
- * Side effects:
- * A new hash table is created if there were no table in the interp
- * originally.
- *
- *----------------------------------------------------------------------
- */
-
-Tcl_HashTable *
-TkGetMenuHashTable(interp)
- Tcl_Interp *interp; /* The interp we need the hash table in.*/
-{
- Tcl_HashTable *menuTablePtr;
-
- menuTablePtr = (Tcl_HashTable *) Tcl_GetAssocData(interp, MENU_HASH_KEY,
- NULL);
- if (menuTablePtr == NULL) {
- menuTablePtr = (Tcl_HashTable *) ckalloc(sizeof(Tcl_HashTable));
- Tcl_InitHashTable(menuTablePtr, TCL_STRING_KEYS);
- Tcl_SetAssocData(interp, MENU_HASH_KEY, DestroyMenuHashTable,
- (ClientData) menuTablePtr);
- }
- return menuTablePtr;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkCreateMenuReferences --
- *
- * Given a pathname, gives back a pointer to a TkMenuReferences structure.
- * If a reference is not already in the hash table, one is created.
- *
- * Results:
- * Returns a pointer to a menu reference structure. Should not
- * be freed by calller; when a field of the reference is cleared,
- * TkFreeMenuReferences should be called.
- *
- * Side effects:
- * A new hash table entry is created if there were no references
- * to the menu originally.
- *
- *----------------------------------------------------------------------
- */
-
-TkMenuReferences *
-TkCreateMenuReferences(interp, pathName)
- Tcl_Interp *interp;
- char *pathName; /* The path of the menu widget */
-{
- Tcl_HashEntry *hashEntryPtr;
- TkMenuReferences *menuRefPtr;
- int newEntry;
- Tcl_HashTable *menuTablePtr = TkGetMenuHashTable(interp);
-
- hashEntryPtr = Tcl_CreateHashEntry(menuTablePtr, pathName, &newEntry);
- if (newEntry) {
- menuRefPtr = (TkMenuReferences *) ckalloc(sizeof(TkMenuReferences));
- menuRefPtr->menuPtr = NULL;
- menuRefPtr->topLevelListPtr = NULL;
- menuRefPtr->parentEntryPtr = NULL;
- menuRefPtr->hashEntryPtr = hashEntryPtr;
- Tcl_SetHashValue(hashEntryPtr, (char *) menuRefPtr);
- } else {
- menuRefPtr = (TkMenuReferences *) Tcl_GetHashValue(hashEntryPtr);
- }
- return menuRefPtr;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkFindMenuReferences --
- *
- * Given a pathname, gives back a pointer to the TkMenuReferences
- * structure.
- *
- * Results:
- * Returns a pointer to a menu reference structure. Should not
- * be freed by calller; when a field of the reference is cleared,
- * TkFreeMenuReferences should be called. Returns NULL if no reference
- * with this pathname exists.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-TkMenuReferences *
-TkFindMenuReferences(interp, pathName)
- Tcl_Interp *interp; /* The interp the menu is living in. */
- char *pathName; /* The path of the menu widget */
-{
- Tcl_HashEntry *hashEntryPtr;
- TkMenuReferences *menuRefPtr = NULL;
- Tcl_HashTable *menuTablePtr;
-
- menuTablePtr = TkGetMenuHashTable(interp);
- hashEntryPtr = Tcl_FindHashEntry(menuTablePtr, pathName);
- if (hashEntryPtr != NULL) {
- menuRefPtr = (TkMenuReferences *) Tcl_GetHashValue(hashEntryPtr);
- }
- return menuRefPtr;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkFreeMenuReferences --
- *
- * This is called after one of the fields in a menu reference
- * is cleared. It cleans up the ref if it is now empty.
- *
- * Results:
- * None.
- *
- * Side effects:
- * If this is the last field to be cleared, the menu ref is
- * taken out of the hash table.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkFreeMenuReferences(menuRefPtr)
- TkMenuReferences *menuRefPtr; /* The menu reference to
- * free */
-{
- if ((menuRefPtr->menuPtr == NULL)
- && (menuRefPtr->parentEntryPtr == NULL)
- && (menuRefPtr->topLevelListPtr == NULL)) {
- Tcl_DeleteHashEntry(menuRefPtr->hashEntryPtr);
- ckfree((char *) menuRefPtr);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * DeleteMenuCloneEntries --
- *
- * For every clone in this clone chain, delete the menu entries
- * given by the parameters.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The appropriate entries are deleted from all clones of this menu.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-DeleteMenuCloneEntries(menuPtr, first, last)
- TkMenu *menuPtr; /* the menu the command was issued with */
- int first; /* the zero-based first entry in the set
- * of entries to delete. */
- int last; /* the zero-based last entry */
-{
-
- TkMenu *menuListPtr;
- int numDeleted, i;
-
- numDeleted = last + 1 - first;
- for (menuListPtr = menuPtr->masterMenuPtr; menuListPtr != NULL;
- menuListPtr = menuListPtr->nextInstancePtr) {
- for (i = last; i >= first; i--) {
- Tcl_EventuallyFree((ClientData) menuListPtr->entries[i],
- DestroyMenuEntry);
- }
- for (i = last + 1; i < menuListPtr->numEntries; i++) {
- menuListPtr->entries[i - numDeleted] = menuListPtr->entries[i];
- menuListPtr->entries[i - numDeleted]->index = i;
- }
- menuListPtr->numEntries -= numDeleted;
- if (menuListPtr->numEntries == 0) {
- ckfree((char *) menuListPtr->entries);
- menuListPtr->entries = NULL;
- }
- if ((menuListPtr->active >= first)
- && (menuListPtr->active <= last)) {
- menuListPtr->active = -1;
- } else if (menuListPtr->active > last) {
- menuListPtr->active -= numDeleted;
- }
- TkEventuallyRecomputeMenu(menuListPtr);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkMenuInit --
- *
- * Sets up the hash tables and the variables used by the menu package.
- *
- * Results:
- * None.
- *
- * Side effects:
- * lastMenuID gets initialized, and the parent hash and the command hash
- * are allocated.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkMenuInit()
-{
- if (!menusInitialized) {
- TkpMenuInit();
- menusInitialized = 1;
- }
-}
diff --git a/generic/tkMenu.h b/generic/tkMenu.h
deleted file mode 100644
index c6fd3fe..0000000
--- a/generic/tkMenu.h
+++ /dev/null
@@ -1,549 +0,0 @@
-/*
- * tkMenu.h --
- *
- * Declarations shared among all of the files that implement menu widgets.
- *
- * Copyright (c) 1996-1997 by 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: tkMenu.h,v 1.4 1998/09/14 18:23:14 stanton Exp $
- */
-
-#ifndef _TKMENU
-#define _TKMENU
-
-#ifndef _TK
-#include "tk.h"
-#endif
-
-#ifndef _TKINT
-#include "tkInt.h"
-#endif
-
-#ifndef _DEFAULT
-#include "default.h"
-#endif
-
-#ifdef BUILD_tk
-# undef TCL_STORAGE_CLASS
-# define TCL_STORAGE_CLASS DLLEXPORT
-#endif
-
-/*
- * Dummy types used by the platform menu code.
- */
-
-typedef struct TkMenuPlatformData_ *TkMenuPlatformData;
-typedef struct TkMenuPlatformEntryData_ *TkMenuPlatformEntryData;
-
-/*
- * One of the following data structures is kept for each entry of each
- * menu managed by this file:
- */
-
-typedef struct TkMenuEntry {
- int type; /* Type of menu entry; see below for
- * valid types. */
- struct TkMenu *menuPtr; /* Menu with which this entry is associated. */
- char *label; /* Main text label displayed in entry (NULL
- * if no label). Malloc'ed. */
- int labelLength; /* Number of non-NULL characters in label. */
- Tk_Uid state; /* State of button for display purposes:
- * normal, active, or disabled. */
- int underline; /* Index of character to underline. */
- Pixmap bitmap; /* Bitmap to display in menu entry, or None.
- * If not None then label is ignored. */
- char *imageString; /* Name of image to display (malloc'ed), or
- * NULL. If non-NULL, bitmap, text, and
- * textVarName are ignored. */
- Tk_Image image; /* Image to display in menu entry, or NULL if
- * none. */
- char *selectImageString; /* Name of image to display when selected
- * (malloc'ed), or NULL. */
- Tk_Image selectImage; /* Image to display in entry when selected,
- * or NULL if none. Ignored if image is
- * NULL. */
- char *accel; /* Accelerator string displayed at right
- * of menu entry. NULL means no such
- * accelerator. Malloc'ed. */
- int accelLength; /* Number of non-NULL characters in
- * accelerator. */
- int indicatorOn; /* True means draw indicator, false means
- * don't draw it. */
- /*
- * Display attributes
- */
-
- Tk_3DBorder border; /* Structure used to draw background for
- * entry. NULL means use overall border
- * for menu. */
- XColor *fg; /* Foreground color to use for entry. NULL
- * means use foreground color from menu. */
- Tk_3DBorder activeBorder; /* Used to draw background and border when
- * element is active. NULL means use
- * activeBorder from menu. */
- XColor *activeFg; /* Foreground color to use when entry is
- * active. NULL means use active foreground
- * from menu. */
- XColor *indicatorFg; /* Color for indicators in radio and check
- * button entries. NULL means use indicatorFg
- * GC from menu. */
- Tk_Font tkfont; /* Text font for menu entries. NULL means
- * use overall font for menu. */
- int columnBreak; /* If this is 0, this item appears below
- * the item in front of it. If this is
- * 1, this item starts a new column. */
- int hideMargin; /* If this is 0, then the item has enough
- * margin to accomodate a standard check
- * mark and a default right margin. If this
- * is 1, then the item has no such margins.
- * and checkbuttons and radiobuttons with
- * this set will have a rectangle drawn
- * in the indicator around the item if
- * the item is checked.
- * This is useful palette menus.*/
- int indicatorSpace; /* The width of the indicator space for this
- * entry.
- */
- int labelWidth; /* Number of pixels to allow for displaying
- * labels in menu entries. */
-
- /*
- * Information used to implement this entry's action:
- */
-
- char *command; /* Command to invoke when entry is invoked.
- * Malloc'ed. */
- char *name; /* Name of variable (for check buttons and
- * radio buttons) or menu (for cascade
- * entries). Malloc'ed.*/
- char *onValue; /* Value to store in variable when selected
- * (only for radio and check buttons).
- * Malloc'ed. */
- char *offValue; /* Value to store in variable when not
- * selected (only for check buttons).
- * Malloc'ed. */
-
- /*
- * Information used for drawing this menu entry.
- */
-
- int width; /* Number of pixels occupied by entry in
- * horizontal dimension. Not used except
- * in menubars. The width of norma menus
- * is dependent on the rest of the menu. */
- int x; /* X-coordinate of leftmost pixel in entry */
- int height; /* Number of pixels occupied by entry in
- * vertical dimension, including raised
- * border drawn around entry when active. */
- int y; /* Y-coordinate of topmost pixel in entry. */
- GC textGC; /* GC for drawing text in entry. NULL means
- * use overall textGC for menu. */
- GC activeGC; /* GC for drawing text in entry when active.
- * NULL means use overall activeGC for
- * menu. */
- GC disabledGC; /* Used to produce disabled effect for entry.
- * NULL means use overall disabledGC from
- * menu structure. See comments for
- * disabledFg in menu structure for more
- * information. */
- GC indicatorGC; /* For drawing indicators. None means use
- * GC from menu. */
-
- /*
- * Miscellaneous fields.
- */
-
- int entryFlags; /* Various flags. See below for
- definitions. */
- int index; /* Need to know which index we are. This
- * is zero-based. This is the top-left entry
- * of the menu. */
-
- /*
- * Bookeeping for master menus and cascade menus.
- */
-
- struct TkMenuReferences *childMenuRefPtr;
- /* A pointer to the hash table entry for
- * the child menu. Stored here when the menu
- * entry is configured so that a hash lookup
- * is not necessary later.*/
- struct TkMenuEntry *nextCascadePtr;
- /* The next cascade entry that is a parent of
- * this entry's child cascade menu. NULL
- * end of list, this is not a cascade entry,
- * or the menu that this entry point to
- * does not yet exist. */
- TkMenuPlatformEntryData platformEntryData;
- /* The data for the specific type of menu.
- * Depends on platform and menu type what
- * kind of options are in this structure.
- */
-} TkMenuEntry;
-
-/*
- * Flag values defined for menu entries:
- *
- * ENTRY_SELECTED: Non-zero means this is a radio or check
- * button and that it should be drawn in
- * the "selected" state.
- * ENTRY_NEEDS_REDISPLAY: Non-zero means the entry should be redisplayed.
- * ENTRY_LAST_COLUMN: Used by the drawing code. If the entry is in the
- * last column, the space to its right needs to
- * be filled.
- * ENTRY_PLATFORM_FLAG1 - 4 These flags are reserved for use by the
- * platform-dependent implementation of menus
- * and should not be used by anything else.
- */
-
-#define ENTRY_SELECTED 1
-#define ENTRY_NEEDS_REDISPLAY 2
-#define ENTRY_LAST_COLUMN 4
-#define ENTRY_PLATFORM_FLAG1 (1 << 30)
-#define ENTRY_PLATFORM_FLAG2 (1 << 29)
-#define ENTRY_PLATFORM_FLAG3 (1 << 28)
-#define ENTRY_PLATFORM_FLAG4 (1 << 27)
-
-/*
- * Types defined for MenuEntries:
- */
-
-#define COMMAND_ENTRY 0
-#define SEPARATOR_ENTRY 1
-#define CHECK_BUTTON_ENTRY 2
-#define RADIO_BUTTON_ENTRY 3
-#define CASCADE_ENTRY 4
-#define TEAROFF_ENTRY 5
-
-/*
- * Mask bits for above types:
- */
-
-#define COMMAND_MASK TK_CONFIG_USER_BIT
-#define SEPARATOR_MASK (TK_CONFIG_USER_BIT << 1)
-#define CHECK_BUTTON_MASK (TK_CONFIG_USER_BIT << 2)
-#define RADIO_BUTTON_MASK (TK_CONFIG_USER_BIT << 3)
-#define CASCADE_MASK (TK_CONFIG_USER_BIT << 4)
-#define TEAROFF_MASK (TK_CONFIG_USER_BIT << 5)
-#define ALL_MASK (COMMAND_MASK | SEPARATOR_MASK \
- | CHECK_BUTTON_MASK | RADIO_BUTTON_MASK | CASCADE_MASK | TEAROFF_MASK)
-
-/*
- * A data structure of the following type is kept for each
- * menu widget:
- */
-
-typedef struct TkMenu {
- Tk_Window tkwin; /* Window that embodies the pane. NULL
- * means that the window has been destroyed
- * but the data structures haven't yet been
- * cleaned up.*/
- Display *display; /* Display containing widget. Needed, among
- * other things, so that resources can be
- * freed up even after tkwin has gone away. */
- Tcl_Interp *interp; /* Interpreter associated with menu. */
- Tcl_Command widgetCmd; /* Token for menu's widget command. */
- TkMenuEntry **entries; /* Array of pointers to all the entries
- * in the menu. NULL means no entries. */
- int numEntries; /* Number of elements in entries. */
- int active; /* Index of active entry. -1 means
- * nothing active. */
- int menuType; /* MASTER_MENU, TEAROFF_MENU, or MENUBAR.
- * See below for definitions. */
- char *menuTypeName; /* Used to control whether created tkwin
- * is a toplevel or not. "normal", "menubar",
- * or "toplevel" */
-
- /*
- * Information used when displaying widget:
- */
-
- Tk_3DBorder border; /* Structure used to draw 3-D
- * border and background for menu. */
- int borderWidth; /* Width of border around whole menu. */
- Tk_3DBorder activeBorder; /* Used to draw background and border for
- * active element (if any). */
- int activeBorderWidth; /* Width of border around active element. */
- int relief; /* 3-d effect: TK_RELIEF_RAISED, etc. */
- Tk_Font tkfont; /* Text font for menu entries. */
- XColor *fg; /* Foreground color for entries. */
- XColor *disabledFg; /* Foreground color when disabled. NULL
- * means use normalFg with a 50% stipple
- * instead. */
- XColor *activeFg; /* Foreground color for active entry. */
- XColor *indicatorFg; /* Color for indicators in radio and check
- * button entries. */
- Pixmap gray; /* Bitmap for drawing disabled entries in
- * a stippled fashion. None means not
- * allocated yet. */
- GC textGC; /* GC for drawing text and other features
- * of menu entries. */
- GC disabledGC; /* Used to produce disabled effect. If
- * disabledFg isn't NULL, this GC is used to
- * draw text and icons for disabled entries.
- * Otherwise text and icons are drawn with
- * normalGC and this GC is used to stipple
- * background across them. */
- GC activeGC; /* GC for drawing active entry. */
- GC indicatorGC; /* For drawing indicators. */
- GC disabledImageGC; /* Used for drawing disabled images. They
- * have to be stippled. This is created
- * when the image is about to be drawn the
- * first time. */
-
- /*
- * Information about geometry of menu.
- */
-
- int totalWidth; /* Width of entire menu */
- int totalHeight; /* Height of entire menu */
-
- /*
- * Miscellaneous information:
- */
-
- int tearOff; /* 1 means this menu can be torn off. On some
- * platforms, the user can drag an outline
- * of the menu by just dragging outside of
- * the menu, and the tearoff is created where
- * the mouse is released. On others, an
- * indicator (such as a dashed stripe) is
- * drawn, and when the menu is selected, the
- * tearoff is created. */
- char *title; /* The title to use when this menu is torn
- * off. If this is NULL, a default scheme
- * will be used to generate a title for
- * tearoff. */
- char *tearOffCommand; /* If non-NULL, points to a command to
- * run whenever the menu is torn-off. */
- char *takeFocus; /* Value of -takefocus option; not used in
- * the C code, but used by keyboard traversal
- * scripts. Malloc'ed, but may be NULL. */
- Tk_Cursor cursor; /* Current cursor for window, or None. */
- char *postCommand; /* Used to detect cycles in cascade hierarchy
- * trees when preprocessing postcommands
- * on some platforms. See PostMenu for
- * more details. */
- int postCommandGeneration; /* Need to do pre-invocation post command
- * traversal */
- int menuFlags; /* Flags for use by X; see below for
- definition */
- TkMenuEntry *postedCascade; /* Points to menu entry for cascaded submenu
- * that is currently posted or NULL if no
- * submenu posted. */
- struct TkMenu *nextInstancePtr;
- /* The next instance of this menu in the
- * chain. */
- struct TkMenu *masterMenuPtr;
- /* A pointer to the original menu for this
- * clone chain. Points back to this structure
- * if this menu is a master menu. */
- Tk_Window parentTopLevelPtr;/* If this menu is a menubar, this is the
- * toplevel that owns the menu. Only applicable
- * for menubar clones.
- */
- struct TkMenuReferences *menuRefPtr;
- /* Each menu is hashed into a table with the
- * name of the menu's window as the key.
- * The information in this hash table includes
- * a pointer to the menu (so that cascades
- * can find this menu), a pointer to the
- * list of toplevel widgets that have this
- * menu as its menubar, and a list of menu
- * entries that have this menu specified
- * as a cascade. */
- TkMenuPlatformData platformData;
- /* The data for the specific type of menu.
- * Depends on platform and menu type what
- * kind of options are in this structure.
- */
-} TkMenu;
-
-/*
- * When the toplevel configure -menu command is executed, the menu may not
- * exist yet. We need to keep a linked list of windows that reference
- * a particular menu.
- */
-
-typedef struct TkMenuTopLevelList {
- struct TkMenuTopLevelList *nextPtr;
- /* The next window in the list */
- Tk_Window tkwin; /* The window that has this menu as its
- * menubar. */
-} TkMenuTopLevelList;
-
-/*
- * The following structure is used to keep track of things which
- * reference a menu. It is created when:
- * - a menu is created.
- * - a cascade entry is added to a menu with a non-null name
- * - the "-menu" configuration option is used on a toplevel widget
- * with a non-null parameter.
- *
- * One of these three fields must be non-NULL, but any of the fields may
- * be NULL. This structure makes it easy to determine whether or not
- * anything like recalculating platform data or geometry is necessary
- * when one of the three actions above is performed.
- */
-
-typedef struct TkMenuReferences {
- struct TkMenu *menuPtr; /* The menu data structure. This is NULL
- * if the menu does not exist. */
- TkMenuTopLevelList *topLevelListPtr;
- /* First in the list of all toplevels that
- * have this menu as its menubar. NULL if no
- * toplevel widgets have this menu as its
- * menubar. */
- TkMenuEntry *parentEntryPtr;/* First in the list of all cascade menu
- * entries that have this menu as their child.
- * NULL means no cascade entries. */
- Tcl_HashEntry *hashEntryPtr;/* This is needed because the pathname of the
- * window (which is what we hash on) may not
- * be around when we are deleting.
- */
-} TkMenuReferences;
-
-/*
- * Flag bits for menus:
- *
- * REDRAW_PENDING: Non-zero means a DoWhenIdle handler
- * has already been queued to redraw
- * this window.
- * RESIZE_PENDING: Non-zero means a call to ComputeMenuGeometry
- * has already been scheduled.
- * MENU_DELETION_PENDING Non-zero means that we are currently destroying
- * this menu. This is useful when we are in the
- * middle of cleaning this master menu's chain of
- * menus up when TkDestroyMenu was called again on
- * this menu (via a destroy binding or somesuch).
- * MENU_PLATFORM_FLAG1... Reserved for use by the platform-specific menu
- * code.
- */
-
-#define REDRAW_PENDING 1
-#define RESIZE_PENDING 2
-#define MENU_DELETION_PENDING 4
-#define MENU_PLATFORM_FLAG1 (1 << 30)
-#define MENU_PLATFORM_FLAG2 (1 << 29)
-#define MENU_PLATFORM_FLAG3 (1 << 28)
-
-/*
- * Each menu created by the user is a MASTER_MENU. When a menu is torn off,
- * a TEAROFF_MENU instance is created. When a menu is assigned to a toplevel
- * as a menu bar, a MENUBAR instance is created. All instances have the same
- * configuration information. If the master instance is deleted, all instances
- * are deleted. If one of the other instances is deleted, only that instance
- * is deleted.
- */
-
-#define UNKNOWN_TYPE -1
-#define MASTER_MENU 0
-#define TEAROFF_MENU 1
-#define MENUBAR 2
-
-/*
- * Various geometry definitions:
- */
-
-#define CASCADE_ARROW_HEIGHT 10
-#define CASCADE_ARROW_WIDTH 8
-#define DECORATION_BORDER_WIDTH 2
-
-/*
- * Configuration specs. Needed for platform-specific default initializations.
- */
-
-EXTERN Tk_ConfigSpec tkMenuEntryConfigSpecs[];
-EXTERN Tk_ConfigSpec tkMenuConfigSpecs[];
-
-/*
- * Menu-related procedures that are shared among Tk modules but not exported
- * to the outside world:
- */
-
-EXTERN int TkActivateMenuEntry _ANSI_ARGS_((TkMenu *menuPtr,
- int index));
-EXTERN void TkBindMenu _ANSI_ARGS_((
- Tk_Window tkwin, TkMenu *menuPtr));
-EXTERN TkMenuReferences *
- TkCreateMenuReferences _ANSI_ARGS_((Tcl_Interp *interp,
- char *pathName));
-EXTERN void TkDestroyMenu _ANSI_ARGS_((TkMenu *menuPtr));
-EXTERN void TkEventuallyRecomputeMenu _ANSI_ARGS_((TkMenu *menuPtr));
-EXTERN void TkEventuallyRedrawMenu _ANSI_ARGS_((
- TkMenu *menuPtr, TkMenuEntry *mePtr));
-EXTERN TkMenuReferences *
- TkFindMenuReferences _ANSI_ARGS_((Tcl_Interp *interp,
- char *pathName));
-EXTERN void TkFreeMenuReferences _ANSI_ARGS_((
- TkMenuReferences *menuRefPtr));
-EXTERN Tcl_HashTable * TkGetMenuHashTable _ANSI_ARGS_((Tcl_Interp *interp));
-EXTERN int TkGetMenuIndex _ANSI_ARGS_((Tcl_Interp *interp,
- TkMenu *menuPtr, char *string, int lastOK,
- int *indexPtr));
-EXTERN void TkMenuInitializeDrawingFields _ANSI_ARGS_((TkMenu *menuPtr));
-EXTERN void TkMenuInitializeEntryDrawingFields _ANSI_ARGS_((
- TkMenuEntry *mePtr));
-EXTERN int TkInvokeMenu _ANSI_ARGS_((Tcl_Interp *interp,
- TkMenu *menuPtr, int index));
-EXTERN void TkMenuConfigureDrawOptions _ANSI_ARGS_((
- TkMenu *menuPtr));
-EXTERN int TkMenuConfigureEntryDrawOptions _ANSI_ARGS_((
- TkMenuEntry *mePtr, int index));
-EXTERN void TkMenuFreeDrawOptions _ANSI_ARGS_((TkMenu *menuPtr));
-EXTERN void TkMenuEntryFreeDrawOptions _ANSI_ARGS_((
- TkMenuEntry *mePtr));
-EXTERN void TkMenuEventProc _ANSI_ARGS_((ClientData clientData,
- XEvent *eventPtr));
-EXTERN void TkMenuImageProc _ANSI_ARGS_((
- ClientData clientData, int x, int y, int width,
- int height, int imgWidth, int imgHeight));
-EXTERN void TkMenuInit _ANSI_ARGS_((void));
-EXTERN void TkMenuSelectImageProc _ANSI_ARGS_
- ((ClientData clientData, int x, int y,
- int width, int height, int imgWidth,
- int imgHeight));
-EXTERN char * TkNewMenuName _ANSI_ARGS_((Tcl_Interp *interp,
- char *parentName, TkMenu *menuPtr));
-EXTERN int TkPostCommand _ANSI_ARGS_((TkMenu *menuPtr));
-EXTERN int TkPostSubmenu _ANSI_ARGS_((Tcl_Interp *interp,
- TkMenu *menuPtr, TkMenuEntry *mePtr));
-EXTERN int TkPostTearoffMenu _ANSI_ARGS_((Tcl_Interp *interp,
- TkMenu *menuPtr, int x, int y));
-EXTERN int TkPreprocessMenu _ANSI_ARGS_((TkMenu *menuPtr));
-EXTERN void TkRecomputeMenu _ANSI_ARGS_((TkMenu *menuPtr));
-
-/*
- * These routines are the platform-dependent routines called by the
- * common code.
- */
-
-EXTERN void TkpComputeMenubarGeometry _ANSI_ARGS_((TkMenu *menuPtr));
-EXTERN void TkpComputeStandardMenuGeometry _ANSI_ARGS_
- ((TkMenu *menuPtr));
-EXTERN int TkpConfigureMenuEntry
- _ANSI_ARGS_((TkMenuEntry *mePtr));
-EXTERN void TkpDestroyMenu _ANSI_ARGS_((TkMenu *menuPtr));
-EXTERN void TkpDestroyMenuEntry
- _ANSI_ARGS_((TkMenuEntry *mEntryPtr));
-EXTERN void TkpDrawMenuEntry _ANSI_ARGS_((TkMenuEntry *mePtr,
- Drawable d, Tk_Font tkfont,
- CONST Tk_FontMetrics *menuMetricsPtr, int x,
- int y, int width, int height, int strictMotif,
- int drawArrow));
-EXTERN void TkpMenuInit _ANSI_ARGS_((void));
-EXTERN int TkpMenuNewEntry _ANSI_ARGS_((TkMenuEntry *mePtr));
-EXTERN int TkpNewMenu _ANSI_ARGS_((TkMenu *menuPtr));
-EXTERN int TkpPostMenu _ANSI_ARGS_((Tcl_Interp *interp,
- TkMenu *menuPtr, int x, int y));
-EXTERN void TkpSetWindowMenuBar _ANSI_ARGS_((Tk_Window tkwin,
- TkMenu *menuPtr));
-
-# undef TCL_STORAGE_CLASS
-# define TCL_STORAGE_CLASS DLLIMPORT
-
-#endif /* _TKMENU */
-
diff --git a/generic/tkMenuDraw.c b/generic/tkMenuDraw.c
deleted file mode 100644
index c08e902..0000000
--- a/generic/tkMenuDraw.c
+++ /dev/null
@@ -1,1018 +0,0 @@
-/*
- * tkMenuDraw.c --
- *
- * This module implements the platform-independent drawing and
- * geometry calculations of menu widgets.
- *
- * Copyright (c) 1996-1997 by 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: tkMenuDraw.c,v 1.2 1998/09/14 18:23:14 stanton Exp $
- */
-
-#include "tkMenu.h"
-
-/*
- * Forward declarations for procedures defined later in this file:
- */
-
-static void AdjustMenuCoords _ANSI_ARGS_ ((TkMenu *menuPtr,
- TkMenuEntry *mePtr, int *xPtr, int *yPtr,
- char *string));
-static void ComputeMenuGeometry _ANSI_ARGS_((
- ClientData clientData));
-static void DisplayMenu _ANSI_ARGS_((ClientData clientData));
-
-/*
- *----------------------------------------------------------------------
- *
- * TkMenuInitializeDrawingFields --
- *
- * Fills in drawing fields of a new menu. Called when new menu is
- * created by Tk_MenuCmd.
- *
- * Results:
- * None.
- *
- * Side effects:
- * menuPtr fields are initialized.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkMenuInitializeDrawingFields(menuPtr)
- TkMenu *menuPtr; /* The menu we are initializing. */
-{
- menuPtr->textGC = None;
- menuPtr->gray = None;
- menuPtr->disabledGC = None;
- menuPtr->activeGC = None;
- menuPtr->indicatorGC = None;
- menuPtr->disabledImageGC = None;
- menuPtr->totalWidth = menuPtr->totalHeight = 0;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkMenuInitializeEntryDrawingFields --
- *
- * Fills in drawing fields of a new menu entry. Called when an
- * entry is created.
- *
- * Results:
- * None.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkMenuInitializeEntryDrawingFields(mePtr)
- TkMenuEntry *mePtr; /* The menu we are initializing. */
-{
- mePtr->width = 0;
- mePtr->height = 0;
- mePtr->x = 0;
- mePtr->y = 0;
- mePtr->indicatorSpace = 0;
- mePtr->labelWidth = 0;
- mePtr->textGC = None;
- mePtr->activeGC = None;
- mePtr->disabledGC = None;
- mePtr->indicatorGC = None;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkMenuFreeDrawOptions --
- *
- * Frees up any structures allocated for the drawing of a menu.
- * Called when menu is deleted.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Storage is released.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkMenuFreeDrawOptions(menuPtr)
- TkMenu *menuPtr;
-{
- if (menuPtr->textGC != None) {
- Tk_FreeGC(menuPtr->display, menuPtr->textGC);
- }
- if (menuPtr->disabledImageGC != None) {
- Tk_FreeGC(menuPtr->display, menuPtr->disabledImageGC);
- }
- if (menuPtr->gray != None) {
- Tk_FreeBitmap(menuPtr->display, menuPtr->gray);
- }
- if (menuPtr->disabledGC != None) {
- Tk_FreeGC(menuPtr->display, menuPtr->disabledGC);
- }
- if (menuPtr->activeGC != None) {
- Tk_FreeGC(menuPtr->display, menuPtr->activeGC);
- }
- if (menuPtr->indicatorGC != None) {
- Tk_FreeGC(menuPtr->display, menuPtr->indicatorGC);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkMenuEntryFreeDrawOptions --
- *
- * Frees up drawing structures for a menu entry. Called when
- * menu entry is freed.
- *
- * RESULTS:
- * None.
- *
- * Side effects:
- * Storage is freed.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkMenuEntryFreeDrawOptions(mePtr)
- TkMenuEntry *mePtr;
-{
- if (mePtr->textGC != None) {
- Tk_FreeGC(mePtr->menuPtr->display, mePtr->textGC);
- }
- if (mePtr->disabledGC != None) {
- Tk_FreeGC(mePtr->menuPtr->display, mePtr->disabledGC);
- }
- if (mePtr->activeGC != None) {
- Tk_FreeGC(mePtr->menuPtr->display, mePtr->activeGC);
- }
- if (mePtr->indicatorGC != None) {
- Tk_FreeGC(mePtr->menuPtr->display, mePtr->indicatorGC);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkMenuConfigureDrawOptions --
- *
- * Sets the menu's drawing attributes in preparation for drawing
- * the menu.
- *
- * RESULTS:
- * None.
- *
- * Side effects:
- * Storage is allocated.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkMenuConfigureDrawOptions(menuPtr)
- TkMenu *menuPtr; /* The menu we are configuring. */
-{
- XGCValues gcValues;
- GC newGC;
- unsigned long mask;
-
- /*
- * A few options need special processing, such as setting the
- * background from a 3-D border, or filling in complicated
- * defaults that couldn't be specified to Tk_ConfigureWidget.
- */
-
- Tk_SetBackgroundFromBorder(menuPtr->tkwin, menuPtr->border);
-
- gcValues.font = Tk_FontId(menuPtr->tkfont);
- gcValues.foreground = menuPtr->fg->pixel;
- gcValues.background = Tk_3DBorderColor(menuPtr->border)->pixel;
- newGC = Tk_GetGC(menuPtr->tkwin, GCForeground|GCBackground|GCFont,
- &gcValues);
- if (menuPtr->textGC != None) {
- Tk_FreeGC(menuPtr->display, menuPtr->textGC);
- }
- menuPtr->textGC = newGC;
-
- gcValues.font = Tk_FontId(menuPtr->tkfont);
- gcValues.background = Tk_3DBorderColor(menuPtr->border)->pixel;
- if (menuPtr->disabledFg != NULL) {
- gcValues.foreground = menuPtr->disabledFg->pixel;
- mask = GCForeground|GCBackground|GCFont;
- } else {
- gcValues.foreground = gcValues.background;
- mask = GCForeground;
- if (menuPtr->gray == None) {
- menuPtr->gray = Tk_GetBitmap(menuPtr->interp, menuPtr->tkwin,
- Tk_GetUid("gray50"));
- }
- if (menuPtr->gray != None) {
- gcValues.fill_style = FillStippled;
- gcValues.stipple = menuPtr->gray;
- mask = GCForeground|GCFillStyle|GCStipple;
- }
- }
- newGC = Tk_GetGC(menuPtr->tkwin, mask, &gcValues);
- if (menuPtr->disabledGC != None) {
- Tk_FreeGC(menuPtr->display, menuPtr->disabledGC);
- }
- menuPtr->disabledGC = newGC;
-
- gcValues.foreground = Tk_3DBorderColor(menuPtr->border)->pixel;
- if (menuPtr->gray == None) {
- menuPtr->gray = Tk_GetBitmap(menuPtr->interp, menuPtr->tkwin,
- Tk_GetUid("gray50"));
- }
- if (menuPtr->gray != None) {
- gcValues.fill_style = FillStippled;
- gcValues.stipple = menuPtr->gray;
- newGC = Tk_GetGC(menuPtr->tkwin,
- GCForeground|GCFillStyle|GCStipple, &gcValues);
- }
- if (menuPtr->disabledImageGC != None) {
- Tk_FreeGC(menuPtr->display, menuPtr->disabledImageGC);
- }
- menuPtr->disabledImageGC = newGC;
-
- gcValues.font = Tk_FontId(menuPtr->tkfont);
- gcValues.foreground = menuPtr->activeFg->pixel;
- gcValues.background =
- Tk_3DBorderColor(menuPtr->activeBorder)->pixel;
- newGC = Tk_GetGC(menuPtr->tkwin, GCForeground|GCBackground|GCFont,
- &gcValues);
- if (menuPtr->activeGC != None) {
- Tk_FreeGC(menuPtr->display, menuPtr->activeGC);
- }
- menuPtr->activeGC = newGC;
-
- gcValues.foreground = menuPtr->indicatorFg->pixel;
- gcValues.background = Tk_3DBorderColor(menuPtr->border)->pixel;
- newGC = Tk_GetGC(menuPtr->tkwin, GCForeground|GCBackground|GCFont,
- &gcValues);
- if (menuPtr->indicatorGC != None) {
- Tk_FreeGC(menuPtr->display, menuPtr->indicatorGC);
- }
- menuPtr->indicatorGC = newGC;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkMenuConfigureEntryDrawOptions --
- *
- * Calculates any entry-specific draw options for the given menu
- * entry.
- *
- * Results:
- * Returns a standard Tcl error.
- *
- * Side effects:
- * Storage may be allocated.
- *
- *----------------------------------------------------------------------
- */
-
-int
-TkMenuConfigureEntryDrawOptions(mePtr, index)
- TkMenuEntry *mePtr;
- int index;
-{
-
- XGCValues gcValues;
- GC newGC, newActiveGC, newDisabledGC, newIndicatorGC;
- unsigned long mask;
- Tk_Font tkfont;
- TkMenu *menuPtr = mePtr->menuPtr;
-
- tkfont = (mePtr->tkfont == NULL) ? menuPtr->tkfont : mePtr->tkfont;
-
- if (mePtr->state == tkActiveUid) {
- if (index != menuPtr->active) {
- TkActivateMenuEntry(menuPtr, index);
- }
- } else {
- if (index == menuPtr->active) {
- TkActivateMenuEntry(menuPtr, -1);
- }
- if ((mePtr->state != tkNormalUid)
- && (mePtr->state != tkDisabledUid)) {
- Tcl_AppendResult(menuPtr->interp, "bad state value \"",
- mePtr->state,
- "\": must be normal, active, or disabled", (char *) NULL);
- mePtr->state = tkNormalUid;
- return TCL_ERROR;
- }
- }
-
- if ((mePtr->tkfont != NULL)
- || (mePtr->border != NULL)
- || (mePtr->fg != NULL)
- || (mePtr->activeBorder != NULL)
- || (mePtr->activeFg != NULL)
- || (mePtr->indicatorFg != NULL)) {
- gcValues.foreground = (mePtr->fg != NULL)
- ? mePtr->fg->pixel
- : menuPtr->fg->pixel;
- gcValues.background = Tk_3DBorderColor(
- (mePtr->border != NULL)
- ? mePtr->border
- : menuPtr->border)
- ->pixel;
-
- gcValues.font = Tk_FontId(tkfont);
-
- /*
- * Note: disable GraphicsExpose events; we know there won't be
- * obscured areas when copying from an off-screen pixmap to the
- * screen and this gets rid of unnecessary events.
- */
-
- gcValues.graphics_exposures = False;
- newGC = Tk_GetGC(menuPtr->tkwin,
- GCForeground|GCBackground|GCFont|GCGraphicsExposures,
- &gcValues);
-
- if (mePtr->indicatorFg != NULL) {
- gcValues.foreground = mePtr->indicatorFg->pixel;
- } else if (menuPtr->indicatorFg != NULL) {
- gcValues.foreground = menuPtr->indicatorFg->pixel;
- }
- newIndicatorGC = Tk_GetGC(menuPtr->tkwin,
- GCForeground|GCBackground|GCGraphicsExposures,
- &gcValues);
-
- if ((menuPtr->disabledFg != NULL) || (mePtr->image != NULL)) {
- gcValues.foreground = menuPtr->disabledFg->pixel;
- mask = GCForeground|GCBackground|GCFont|GCGraphicsExposures;
- } else {
- gcValues.foreground = gcValues.background;
- gcValues.fill_style = FillStippled;
- gcValues.stipple = menuPtr->gray;
- mask = GCForeground|GCFillStyle|GCStipple;
- }
- newDisabledGC = Tk_GetGC(menuPtr->tkwin, mask, &gcValues);
-
- gcValues.foreground = (mePtr->activeFg != NULL)
- ? mePtr->activeFg->pixel
- : menuPtr->activeFg->pixel;
- gcValues.background = Tk_3DBorderColor(
- (mePtr->activeBorder != NULL)
- ? mePtr->activeBorder
- : menuPtr->activeBorder)->pixel;
- newActiveGC = Tk_GetGC(menuPtr->tkwin,
- GCForeground|GCBackground|GCFont|GCGraphicsExposures,
- &gcValues);
- } else {
- newGC = None;
- newActiveGC = None;
- newDisabledGC = None;
- newIndicatorGC = None;
- }
- if (mePtr->textGC != None) {
- Tk_FreeGC(menuPtr->display, mePtr->textGC);
- }
- mePtr->textGC = newGC;
- if (mePtr->activeGC != None) {
- Tk_FreeGC(menuPtr->display, mePtr->activeGC);
- }
- mePtr->activeGC = newActiveGC;
- if (mePtr->disabledGC != None) {
- Tk_FreeGC(menuPtr->display, mePtr->disabledGC);
- }
- mePtr->disabledGC = newDisabledGC;
- if (mePtr->indicatorGC != None) {
- Tk_FreeGC(menuPtr->display, mePtr->indicatorGC);
- }
- mePtr->indicatorGC = newIndicatorGC;
- return TCL_OK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkEventuallyRecomputeMenu --
- *
- * Tells Tcl to redo the geometry because this menu has changed.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Menu geometry is recomputed at idle time, and the menu will be
- * redisplayed.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkEventuallyRecomputeMenu(menuPtr)
- TkMenu *menuPtr;
-{
- if (!(menuPtr->menuFlags & RESIZE_PENDING)) {
- menuPtr->menuFlags |= RESIZE_PENDING;
- Tcl_DoWhenIdle(ComputeMenuGeometry, (ClientData) menuPtr);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkRecomputeMenu --
- *
- * Tells Tcl to redo the geometry because this menu has changed.
- * Does it now; removes any ComputeMenuGeometries from the idler.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Menu geometry is immediately reconfigured.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkRecomputeMenu(menuPtr)
- TkMenu *menuPtr;
-{
- if (menuPtr->menuFlags & RESIZE_PENDING) {
- Tcl_CancelIdleCall(ComputeMenuGeometry, (ClientData) menuPtr);
- ComputeMenuGeometry((ClientData) menuPtr);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkEventuallyRedrawMenu --
- *
- * Arrange for an entry of a menu, or the whole menu, to be
- * redisplayed at some point in the future.
- *
- * Results:
- * None.
- *
- * Side effects:
- * A when-idle hander is scheduled to do the redisplay, if there
- * isn't one already scheduled.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkEventuallyRedrawMenu(menuPtr, mePtr)
- register TkMenu *menuPtr; /* Information about menu to redraw. */
- register TkMenuEntry *mePtr; /* Entry to redraw. NULL means redraw
- * all the entries in the menu. */
-{
- int i;
-
- if (menuPtr->tkwin == NULL) {
- return;
- }
- if (mePtr != NULL) {
- mePtr->entryFlags |= ENTRY_NEEDS_REDISPLAY;
- } else {
- for (i = 0; i < menuPtr->numEntries; i++) {
- menuPtr->entries[i]->entryFlags |= ENTRY_NEEDS_REDISPLAY;
- }
- }
- if (!Tk_IsMapped(menuPtr->tkwin)
- || (menuPtr->menuFlags & REDRAW_PENDING)) {
- return;
- }
- Tcl_DoWhenIdle(DisplayMenu, (ClientData) menuPtr);
- menuPtr->menuFlags |= REDRAW_PENDING;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ComputeMenuGeometry --
- *
- * This procedure is invoked to recompute the size and
- * layout of a menu. It is called as a when-idle handler so
- * that it only gets done once, even if a group of changes is
- * made to the menu.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Fields of menu entries are changed to reflect their
- * current positions, and the size of the menu window
- * itself may be changed.
- *
- *--------------------------------------------------------------
- */
-
-static void
-ComputeMenuGeometry(clientData)
- ClientData clientData; /* Structure describing menu. */
-{
- TkMenu *menuPtr = (TkMenu *) clientData;
-
- if (menuPtr->tkwin == NULL) {
- return;
- }
-
- if (menuPtr->menuType == MENUBAR) {
- TkpComputeMenubarGeometry(menuPtr);
- } else {
- TkpComputeStandardMenuGeometry(menuPtr);
- }
-
- if ((menuPtr->totalWidth != Tk_ReqWidth(menuPtr->tkwin)) ||
- (menuPtr->totalHeight != Tk_ReqHeight(menuPtr->tkwin))) {
- Tk_GeometryRequest(menuPtr->tkwin, menuPtr->totalWidth,
- menuPtr->totalHeight);
- }
-
- /*
- * Must always force a redisplay here if the window is mapped
- * (even if the size didn't change, something else might have
- * changed in the menu, such as a label or accelerator). The
- * resize will force a redisplay above.
- */
-
- TkEventuallyRedrawMenu(menuPtr, (TkMenuEntry *) NULL);
-
- menuPtr->menuFlags &= ~RESIZE_PENDING;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkMenuSelectImageProc --
- *
- * This procedure is invoked by the image code whenever the manager
- * for an image does something that affects the size of contents
- * of an image displayed in a menu entry when it is selected.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Arranges for the menu to get redisplayed.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkMenuSelectImageProc(clientData, x, y, width, height, imgWidth,
- imgHeight)
- ClientData clientData; /* Pointer to widget record. */
- int x, y; /* Upper left pixel (within image)
- * that must be redisplayed. */
- int width, height; /* Dimensions of area to redisplay
- * (may be <= 0). */
- int imgWidth, imgHeight; /* New dimensions of image. */
-{
- register TkMenuEntry *mePtr = (TkMenuEntry *) clientData;
-
- if ((mePtr->entryFlags & ENTRY_SELECTED)
- && !(mePtr->menuPtr->menuFlags &
- REDRAW_PENDING)) {
- mePtr->menuPtr->menuFlags |= REDRAW_PENDING;
- Tcl_DoWhenIdle(DisplayMenu, (ClientData) mePtr->menuPtr);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * DisplayMenu --
- *
- * This procedure is invoked to display a menu widget.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Commands are output to X to display the menu in its
- * current mode.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-DisplayMenu(clientData)
- ClientData clientData; /* Information about widget. */
-{
- register TkMenu *menuPtr = (TkMenu *) clientData;
- register TkMenuEntry *mePtr;
- register Tk_Window tkwin = menuPtr->tkwin;
- int index, strictMotif;
- Tk_Font tkfont = menuPtr->tkfont;
- Tk_FontMetrics menuMetrics;
- int width;
-
- menuPtr->menuFlags &= ~REDRAW_PENDING;
- if ((menuPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) {
- return;
- }
-
- if (menuPtr->menuType == MENUBAR) {
- Tk_Fill3DRectangle(tkwin, Tk_WindowId(tkwin), menuPtr->border,
- menuPtr->borderWidth, menuPtr->borderWidth,
- Tk_Width(tkwin) - 2 * menuPtr->borderWidth,
- Tk_Height(tkwin) - 2 * menuPtr->borderWidth, 0,
- TK_RELIEF_FLAT);
- }
-
- strictMotif = Tk_StrictMotif(menuPtr->tkwin);
-
- /*
- * See note in ComputeMenuGeometry. We don't want to be doing font metrics
- * all of the time.
- */
-
- Tk_GetFontMetrics(menuPtr->tkfont, &menuMetrics);
-
- /*
- * Loop through all of the entries, drawing them one at a time.
- */
-
- for (index = 0; index < menuPtr->numEntries; index++) {
- mePtr = menuPtr->entries[index];
- if (menuPtr->menuType != MENUBAR) {
- if (!(mePtr->entryFlags & ENTRY_NEEDS_REDISPLAY)) {
- continue;
- }
- }
- mePtr->entryFlags &= ~ENTRY_NEEDS_REDISPLAY;
-
- if (menuPtr->menuType == MENUBAR) {
- width = mePtr->width;
- } else {
- if (mePtr->entryFlags & ENTRY_LAST_COLUMN) {
- width = Tk_Width(menuPtr->tkwin) - mePtr->x
- - menuPtr->activeBorderWidth;
- } else {
- width = mePtr->width + menuPtr->borderWidth;
- }
- }
- TkpDrawMenuEntry(mePtr, Tk_WindowId(menuPtr->tkwin), tkfont,
- &menuMetrics, mePtr->x, mePtr->y, width,
- mePtr->height, strictMotif, 1);
- if ((index > 0) && (menuPtr->menuType != MENUBAR)
- && mePtr->columnBreak) {
- mePtr = menuPtr->entries[index - 1];
- Tk_Fill3DRectangle(tkwin, Tk_WindowId(tkwin), menuPtr->border,
- mePtr->x, mePtr->y + mePtr->height,
- mePtr->width,
- Tk_Height(tkwin) - mePtr->y - mePtr->height
- - menuPtr->activeBorderWidth, 0,
- TK_RELIEF_FLAT);
- }
- }
-
- if (menuPtr->menuType != MENUBAR) {
- int x, y, height;
-
- if (menuPtr->numEntries == 0) {
- x = y = menuPtr->borderWidth;
- width = Tk_Width(tkwin) - 2 * menuPtr->activeBorderWidth;
- height = Tk_Height(tkwin) - 2 * menuPtr->activeBorderWidth;
- } else {
- mePtr = menuPtr->entries[menuPtr->numEntries - 1];
- Tk_Fill3DRectangle(tkwin, Tk_WindowId(tkwin),
- menuPtr->border, mePtr->x, mePtr->y + mePtr->height,
- mePtr->width, Tk_Height(tkwin) - mePtr->y - mePtr->height
- - menuPtr->activeBorderWidth, 0,
- TK_RELIEF_FLAT);
- x = mePtr->x + mePtr->width;
- y = mePtr->y + mePtr->height;
- width = Tk_Width(tkwin) - x - menuPtr->activeBorderWidth;
- height = Tk_Height(tkwin) - y - menuPtr->activeBorderWidth;
- }
- Tk_Fill3DRectangle(tkwin, Tk_WindowId(tkwin), menuPtr->border, x, y,
- width, height, 0, TK_RELIEF_FLAT);
- }
-
- Tk_Draw3DRectangle(menuPtr->tkwin, Tk_WindowId(tkwin),
- menuPtr->border, 0, 0, Tk_Width(tkwin), Tk_Height(tkwin),
- menuPtr->borderWidth, menuPtr->relief);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * TkMenuEventProc --
- *
- * This procedure is invoked by the Tk dispatcher for various
- * events on menus.
- *
- * Results:
- * None.
- *
- * Side effects:
- * When the window gets deleted, internal structures get
- * cleaned up. When it gets exposed, it is redisplayed.
- *
- *--------------------------------------------------------------
- */
-
-void
-TkMenuEventProc(clientData, eventPtr)
- ClientData clientData; /* Information about window. */
- XEvent *eventPtr; /* Information about event. */
-{
- TkMenu *menuPtr = (TkMenu *) clientData;
-
- if ((eventPtr->type == Expose) && (eventPtr->xexpose.count == 0)) {
- TkEventuallyRedrawMenu(menuPtr, (TkMenuEntry *) NULL);
- } else if (eventPtr->type == ConfigureNotify) {
- TkEventuallyRecomputeMenu(menuPtr);
- TkEventuallyRedrawMenu(menuPtr, (TkMenuEntry *) NULL);
- } else if (eventPtr->type == ActivateNotify) {
- if (menuPtr->menuType == TEAROFF_MENU) {
- TkpSetMainMenubar(menuPtr->interp, menuPtr->tkwin, NULL);
- }
- } else if (eventPtr->type == DestroyNotify) {
- if (menuPtr->tkwin != NULL) {
- menuPtr->tkwin = NULL;
- Tcl_DeleteCommandFromToken(menuPtr->interp, menuPtr->widgetCmd);
- }
- if (menuPtr->menuFlags & REDRAW_PENDING) {
- Tcl_CancelIdleCall(DisplayMenu, (ClientData) menuPtr);
- }
- if (menuPtr->menuFlags & RESIZE_PENDING) {
- Tcl_CancelIdleCall(ComputeMenuGeometry, (ClientData) menuPtr);
- }
- TkDestroyMenu(menuPtr);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkMenuImageProc --
- *
- * This procedure is invoked by the image code whenever the manager
- * for an image does something that affects the size of contents
- * of an image displayed in a menu entry.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Arranges for the menu to get redisplayed.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkMenuImageProc(clientData, x, y, width, height, imgWidth,
- imgHeight)
- ClientData clientData; /* Pointer to widget record. */
- int x, y; /* Upper left pixel (within image)
- * that must be redisplayed. */
- int width, height; /* Dimensions of area to redisplay
- * (may be <= 0). */
- int imgWidth, imgHeight; /* New dimensions of image. */
-{
- register TkMenu *menuPtr = ((TkMenuEntry *)clientData)->menuPtr;
-
- if ((menuPtr->tkwin != NULL) && !(menuPtr->menuFlags
- & RESIZE_PENDING)) {
- menuPtr->menuFlags |= RESIZE_PENDING;
- Tcl_DoWhenIdle(ComputeMenuGeometry, (ClientData) menuPtr);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkPostTearoffMenu --
- *
- * Posts a menu on the screen. Used to post tearoff menus. On Unix,
- * all menus are posted this way. Adjusts the menu's position
- * so that it fits on the screen, and maps and raises the menu.
- *
- * Results:
- * Returns a standard Tcl Error.
- *
- * Side effects:
- * The menu is posted.
- *
- *----------------------------------------------------------------------
- */
-
-int
-TkPostTearoffMenu(interp, menuPtr, x, y)
- Tcl_Interp *interp; /* The interpreter of the menu */
- TkMenu *menuPtr; /* The menu we are posting */
- int x; /* The root X coordinate where we
- * are posting */
- int y; /* The root Y coordinate where we
- * are posting */
-{
- int vRootX, vRootY, vRootWidth, vRootHeight;
- int tmp, result;
-
- TkActivateMenuEntry(menuPtr, -1);
- TkRecomputeMenu(menuPtr);
- result = TkPostCommand(menuPtr);
- if (result != TCL_OK) {
- return result;
- }
-
- /*
- * The post commands could have deleted the menu, which means
- * we are dead and should go away.
- */
-
- if (menuPtr->tkwin == NULL) {
- return TCL_OK;
- }
-
- /*
- * Adjust the position of the menu if necessary to keep it
- * visible on the screen. There are two special tricks to
- * make this work right:
- *
- * 1. If a virtual root window manager is being used then
- * the coordinates are in the virtual root window of
- * menuPtr's parent; since the menu uses override-redirect
- * mode it will be in the *real* root window for the screen,
- * so we have to map the coordinates from the virtual root
- * (if any) to the real root. Can't get the virtual root
- * from the menu itself (it will never be seen by the wm)
- * so use its parent instead (it would be better to have an
- * an option that names a window to use for this...).
- * 2. The menu may not have been mapped yet, so its current size
- * might be the default 1x1. To compute how much space it
- * needs, use its requested size, not its actual size.
- *
- * Note that this code assumes square screen regions and all
- * positive coordinates. This does not work on a Mac with
- * multiple monitors. But then again, Tk has other problems
- * with this.
- */
-
- Tk_GetVRootGeometry(Tk_Parent(menuPtr->tkwin), &vRootX, &vRootY,
- &vRootWidth, &vRootHeight);
- x += vRootX;
- y += vRootY;
- tmp = WidthOfScreen(Tk_Screen(menuPtr->tkwin))
- - Tk_ReqWidth(menuPtr->tkwin);
- if (x > tmp) {
- x = tmp;
- }
- if (x < 0) {
- x = 0;
- }
- tmp = HeightOfScreen(Tk_Screen(menuPtr->tkwin))
- - Tk_ReqHeight(menuPtr->tkwin);
- if (y > tmp) {
- y = tmp;
- }
- if (y < 0) {
- y = 0;
- }
- Tk_MoveToplevelWindow(menuPtr->tkwin, x, y);
- if (!Tk_IsMapped(menuPtr->tkwin)) {
- Tk_MapWindow(menuPtr->tkwin);
- }
- TkWmRestackToplevel((TkWindow *) menuPtr->tkwin, Above, NULL);
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * TkPostSubmenu --
- *
- * This procedure arranges for a particular submenu (i.e. the
- * menu corresponding to a given cascade entry) to be
- * posted.
- *
- * Results:
- * A standard Tcl return result. Errors may occur in the
- * Tcl commands generated to post and unpost submenus.
- *
- * Side effects:
- * If there is already a submenu posted, it is unposted.
- * The new submenu is then posted.
- *
- *--------------------------------------------------------------
- */
-
-int
-TkPostSubmenu(interp, menuPtr, mePtr)
- Tcl_Interp *interp; /* Used for invoking sub-commands and
- * reporting errors. */
- register TkMenu *menuPtr; /* Information about menu as a whole. */
- register TkMenuEntry *mePtr; /* Info about submenu that is to be
- * posted. NULL means make sure that
- * no submenu is posted. */
-{
- char string[30];
- int result, x, y;
-
- if (mePtr == menuPtr->postedCascade) {
- return TCL_OK;
- }
-
- if (menuPtr->postedCascade != NULL) {
-
- /*
- * Note: when unposting a submenu, we have to redraw the entire
- * parent menu. This is because of a combination of the following
- * things:
- * (a) the submenu partially overlaps the parent.
- * (b) the submenu specifies "save under", which causes the X
- * server to make a copy of the information under it when it
- * is posted. When the submenu is unposted, the X server
- * copies this data back and doesn't generate any Expose
- * events for the parent.
- * (c) the parent may have redisplayed itself after the submenu
- * was posted, in which case the saved information is no
- * longer correct.
- * The simplest solution is just force a complete redisplay of
- * the parent.
- */
-
- TkEventuallyRedrawMenu(menuPtr, (TkMenuEntry *) NULL);
- result = Tcl_VarEval(interp, menuPtr->postedCascade->name,
- " unpost", (char *) NULL);
- menuPtr->postedCascade = NULL;
- if (result != TCL_OK) {
- return result;
- }
- }
-
- if ((mePtr != NULL) && (mePtr->name != NULL)
- && Tk_IsMapped(menuPtr->tkwin)) {
-
- /*
- * Position the cascade with its upper left corner slightly
- * below and to the left of the upper right corner of the
- * menu entry (this is an attempt to match Motif behavior).
- *
- * The menu has to redrawn so that the entry can change relief.
- */
-
- Tk_GetRootCoords(menuPtr->tkwin, &x, &y);
- AdjustMenuCoords(menuPtr, mePtr, &x, &y, string);
- result = Tcl_VarEval(interp, mePtr->name, " post ", string,
- (char *) NULL);
- if (result != TCL_OK) {
- return result;
- }
- menuPtr->postedCascade = mePtr;
- TkEventuallyRedrawMenu(menuPtr, mePtr);
- }
- return TCL_OK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * AdjustMenuCoords --
- *
- * Adjusts the given coordinates down and the left to give a Motif
- * look.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The menu is eventually redrawn if necessary.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-AdjustMenuCoords(menuPtr, mePtr, xPtr, yPtr, string)
- TkMenu *menuPtr;
- TkMenuEntry *mePtr;
- int *xPtr;
- int *yPtr;
- char *string;
-{
- if (menuPtr->menuType == MENUBAR) {
- *xPtr += mePtr->x;
- *yPtr += mePtr->y + mePtr->height;
- } else {
- *xPtr += Tk_Width(menuPtr->tkwin) - menuPtr->borderWidth
- - menuPtr->activeBorderWidth - 2;
- *yPtr += mePtr->y
- + menuPtr->activeBorderWidth + 2;
- }
- sprintf(string, "%d %d", *xPtr, *yPtr);
-}
diff --git a/generic/tkMenubutton.c b/generic/tkMenubutton.c
deleted file mode 100644
index da6d901..0000000
--- a/generic/tkMenubutton.c
+++ /dev/null
@@ -1,865 +0,0 @@
-/*
- * tkMenubutton.c --
- *
- * This module implements button-like widgets that are used
- * to invoke pull-down menus.
- *
- * Copyright (c) 1990-1994 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: tkMenubutton.c,v 1.2 1998/09/14 18:23:14 stanton Exp $
- */
-
-#include "tkMenubutton.h"
-#include "tkPort.h"
-#include "default.h"
-
-/*
- * Uids internal to menubuttons.
- */
-
-static Tk_Uid aboveUid = NULL;
-static Tk_Uid belowUid = NULL;
-static Tk_Uid leftUid = NULL;
-static Tk_Uid rightUid = NULL;
-static Tk_Uid flushUid = NULL;
-
-/*
- * Information used for parsing configuration specs:
- */
-
-static Tk_ConfigSpec configSpecs[] = {
- {TK_CONFIG_BORDER, "-activebackground", "activeBackground", "Foreground",
- DEF_MENUBUTTON_ACTIVE_BG_COLOR, Tk_Offset(TkMenuButton, activeBorder),
- TK_CONFIG_COLOR_ONLY},
- {TK_CONFIG_BORDER, "-activebackground", "activeBackground", "Foreground",
- DEF_MENUBUTTON_ACTIVE_BG_MONO, Tk_Offset(TkMenuButton, activeBorder),
- TK_CONFIG_MONO_ONLY},
- {TK_CONFIG_COLOR, "-activeforeground", "activeForeground", "Background",
- DEF_MENUBUTTON_ACTIVE_FG_COLOR, Tk_Offset(TkMenuButton, activeFg),
- TK_CONFIG_COLOR_ONLY},
- {TK_CONFIG_COLOR, "-activeforeground", "activeForeground", "Background",
- DEF_MENUBUTTON_ACTIVE_FG_MONO, Tk_Offset(TkMenuButton, activeFg),
- TK_CONFIG_MONO_ONLY},
- {TK_CONFIG_ANCHOR, "-anchor", "anchor", "Anchor",
- DEF_MENUBUTTON_ANCHOR, Tk_Offset(TkMenuButton, anchor), 0},
- {TK_CONFIG_BORDER, "-background", "background", "Background",
- DEF_MENUBUTTON_BG_COLOR, Tk_Offset(TkMenuButton, normalBorder),
- TK_CONFIG_COLOR_ONLY},
- {TK_CONFIG_BORDER, "-background", "background", "Background",
- DEF_MENUBUTTON_BG_MONO, Tk_Offset(TkMenuButton, normalBorder),
- 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_BITMAP, "-bitmap", "bitmap", "Bitmap",
- DEF_MENUBUTTON_BITMAP, Tk_Offset(TkMenuButton, bitmap),
- TK_CONFIG_NULL_OK},
- {TK_CONFIG_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_MENUBUTTON_BORDER_WIDTH, Tk_Offset(TkMenuButton, borderWidth), 0},
- {TK_CONFIG_ACTIVE_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_MENUBUTTON_CURSOR, Tk_Offset(TkMenuButton, cursor),
- TK_CONFIG_NULL_OK},
- {TK_CONFIG_UID, "-direction", "direction", "Direction",
- DEF_MENUBUTTON_DIRECTION, Tk_Offset(TkMenuButton, direction),
- 0},
- {TK_CONFIG_COLOR, "-disabledforeground", "disabledForeground",
- "DisabledForeground", DEF_MENUBUTTON_DISABLED_FG_COLOR,
- Tk_Offset(TkMenuButton, disabledFg),
- TK_CONFIG_COLOR_ONLY|TK_CONFIG_NULL_OK},
- {TK_CONFIG_COLOR, "-disabledforeground", "disabledForeground",
- "DisabledForeground", DEF_MENUBUTTON_DISABLED_FG_MONO,
- Tk_Offset(TkMenuButton, disabledFg),
- TK_CONFIG_MONO_ONLY|TK_CONFIG_NULL_OK},
- {TK_CONFIG_SYNONYM, "-fg", "foreground", (char *) NULL,
- (char *) NULL, 0, 0},
- {TK_CONFIG_FONT, "-font", "font", "Font",
- DEF_MENUBUTTON_FONT, Tk_Offset(TkMenuButton, tkfont), 0},
- {TK_CONFIG_COLOR, "-foreground", "foreground", "Foreground",
- DEF_MENUBUTTON_FG, Tk_Offset(TkMenuButton, normalFg), 0},
- {TK_CONFIG_STRING, "-height", "height", "Height",
- DEF_MENUBUTTON_HEIGHT, Tk_Offset(TkMenuButton, heightString), 0},
- {TK_CONFIG_COLOR, "-highlightbackground", "highlightBackground",
- "HighlightBackground", DEF_MENUBUTTON_HIGHLIGHT_BG,
- Tk_Offset(TkMenuButton, highlightBgColorPtr), 0},
- {TK_CONFIG_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_MENUBUTTON_HIGHLIGHT, Tk_Offset(TkMenuButton, highlightColorPtr),
- 0},
- {TK_CONFIG_PIXELS, "-highlightthickness", "highlightThickness",
- "HighlightThickness", DEF_MENUBUTTON_HIGHLIGHT_WIDTH,
- Tk_Offset(TkMenuButton, highlightWidth), 0},
- {TK_CONFIG_STRING, "-image", "image", "Image",
- DEF_MENUBUTTON_IMAGE, Tk_Offset(TkMenuButton, imageString),
- TK_CONFIG_NULL_OK},
- {TK_CONFIG_BOOLEAN, "-indicatoron", "indicatorOn", "IndicatorOn",
- DEF_MENUBUTTON_INDICATOR, Tk_Offset(TkMenuButton, indicatorOn), 0},
- {TK_CONFIG_JUSTIFY, "-justify", "justify", "Justify",
- DEF_MENUBUTTON_JUSTIFY, Tk_Offset(TkMenuButton, justify), 0},
- {TK_CONFIG_STRING, "-menu", "menu", "Menu",
- DEF_MENUBUTTON_MENU, Tk_Offset(TkMenuButton, menuName),
- TK_CONFIG_NULL_OK},
- {TK_CONFIG_PIXELS, "-padx", "padX", "Pad",
- DEF_MENUBUTTON_PADX, Tk_Offset(TkMenuButton, padX), 0},
- {TK_CONFIG_PIXELS, "-pady", "padY", "Pad",
- DEF_MENUBUTTON_PADY, Tk_Offset(TkMenuButton, padY), 0},
- {TK_CONFIG_RELIEF, "-relief", "relief", "Relief",
- DEF_MENUBUTTON_RELIEF, Tk_Offset(TkMenuButton, relief), 0},
- {TK_CONFIG_UID, "-state", "state", "State",
- DEF_MENUBUTTON_STATE, Tk_Offset(TkMenuButton, state), 0},
- {TK_CONFIG_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_MENUBUTTON_TAKE_FOCUS, Tk_Offset(TkMenuButton, takeFocus),
- TK_CONFIG_NULL_OK},
- {TK_CONFIG_STRING, "-text", "text", "Text",
- DEF_MENUBUTTON_TEXT, Tk_Offset(TkMenuButton, text), 0},
- {TK_CONFIG_STRING, "-textvariable", "textVariable", "Variable",
- DEF_MENUBUTTON_TEXT_VARIABLE, Tk_Offset(TkMenuButton, textVarName),
- TK_CONFIG_NULL_OK},
- {TK_CONFIG_INT, "-underline", "underline", "Underline",
- DEF_MENUBUTTON_UNDERLINE, Tk_Offset(TkMenuButton, underline), 0},
- {TK_CONFIG_STRING, "-width", "width", "Width",
- DEF_MENUBUTTON_WIDTH, Tk_Offset(TkMenuButton, widthString), 0},
- {TK_CONFIG_PIXELS, "-wraplength", "wrapLength", "WrapLength",
- DEF_MENUBUTTON_WRAP_LENGTH, Tk_Offset(TkMenuButton, wrapLength), 0},
- {TK_CONFIG_END, (char *) NULL, (char *) NULL, (char *) NULL,
- (char *) NULL, 0, 0}
-};
-
-/*
- * Forward declarations for procedures defined later in this file:
- */
-
-static void MenuButtonCmdDeletedProc _ANSI_ARGS_((
- ClientData clientData));
-static void MenuButtonEventProc _ANSI_ARGS_((ClientData clientData,
- XEvent *eventPtr));
-static void MenuButtonImageProc _ANSI_ARGS_((ClientData clientData,
- int x, int y, int width, int height, int imgWidth,
- int imgHeight));
-static char * MenuButtonTextVarProc _ANSI_ARGS_((
- ClientData clientData, Tcl_Interp *interp,
- char *name1, char *name2, int flags));
-static int MenuButtonWidgetCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-static int ConfigureMenuButton _ANSI_ARGS_((Tcl_Interp *interp,
- TkMenuButton *mbPtr, int argc, char **argv,
- int flags));
-static void DestroyMenuButton _ANSI_ARGS_((char *memPtr));
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_MenubuttonCmd --
- *
- * This procedure is invoked to process the "button", "label",
- * "radiobutton", and "checkbutton" Tcl commands. See the
- * user documentation for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *--------------------------------------------------------------
- */
-
-int
-Tk_MenubuttonCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Main window associated with
- * interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- register TkMenuButton *mbPtr;
- Tk_Window tkwin = (Tk_Window) clientData;
- Tk_Window new;
-
- if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " pathName ?options?\"", (char *) NULL);
- return TCL_ERROR;
- }
-
- /*
- * Create the new window.
- */
-
- new = Tk_CreateWindowFromPath(interp, tkwin, argv[1], (char *) NULL);
- if (new == NULL) {
- return TCL_ERROR;
- }
-
- Tk_SetClass(new, "Menubutton");
- mbPtr = TkpCreateMenuButton(new);
-
- TkSetClassProcs(new, &tkpMenubuttonClass, (ClientData) mbPtr);
-
- /*
- * Initialize the data structure for the button.
- */
-
- mbPtr->tkwin = new;
- mbPtr->display = Tk_Display (new);
- mbPtr->interp = interp;
- mbPtr->widgetCmd = Tcl_CreateCommand(interp, Tk_PathName(mbPtr->tkwin),
- MenuButtonWidgetCmd, (ClientData) mbPtr, MenuButtonCmdDeletedProc);
- mbPtr->menuName = NULL;
- mbPtr->text = NULL;
- mbPtr->underline = -1;
- mbPtr->textVarName = NULL;
- mbPtr->bitmap = None;
- mbPtr->imageString = NULL;
- mbPtr->image = NULL;
- mbPtr->state = tkNormalUid;
- mbPtr->normalBorder = NULL;
- mbPtr->activeBorder = NULL;
- mbPtr->borderWidth = 0;
- mbPtr->relief = TK_RELIEF_FLAT;
- mbPtr->highlightWidth = 0;
- mbPtr->highlightBgColorPtr = NULL;
- mbPtr->highlightColorPtr = NULL;
- mbPtr->inset = 0;
- mbPtr->tkfont = NULL;
- mbPtr->normalFg = NULL;
- mbPtr->activeFg = NULL;
- mbPtr->disabledFg = NULL;
- mbPtr->normalTextGC = None;
- mbPtr->activeTextGC = None;
- mbPtr->gray = None;
- mbPtr->disabledGC = None;
- mbPtr->leftBearing = 0;
- mbPtr->rightBearing = 0;
- mbPtr->widthString = NULL;
- mbPtr->heightString = NULL;
- mbPtr->width = 0;
- mbPtr->width = 0;
- mbPtr->wrapLength = 0;
- mbPtr->padX = 0;
- mbPtr->padY = 0;
- mbPtr->anchor = TK_ANCHOR_CENTER;
- mbPtr->justify = TK_JUSTIFY_CENTER;
- mbPtr->textLayout = NULL;
- mbPtr->indicatorOn = 0;
- mbPtr->indicatorWidth = 0;
- mbPtr->indicatorHeight = 0;
- mbPtr->cursor = None;
- mbPtr->takeFocus = NULL;
- mbPtr->flags = 0;
- if (aboveUid == NULL) {
- aboveUid = Tk_GetUid("above");
- belowUid = Tk_GetUid("below");
- leftUid = Tk_GetUid("left");
- rightUid = Tk_GetUid("right");
- flushUid = Tk_GetUid("flush");
- }
- mbPtr->direction = flushUid;
-
- Tk_CreateEventHandler(mbPtr->tkwin,
- ExposureMask|StructureNotifyMask|FocusChangeMask,
- MenuButtonEventProc, (ClientData) mbPtr);
- if (ConfigureMenuButton(interp, mbPtr, argc-2, argv+2, 0) != TCL_OK) {
- Tk_DestroyWindow(mbPtr->tkwin);
- return TCL_ERROR;
- }
-
- interp->result = Tk_PathName(mbPtr->tkwin);
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * MenuButtonWidgetCmd --
- *
- * 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
-MenuButtonWidgetCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Information about button widget. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- register TkMenuButton *mbPtr = (TkMenuButton *) clientData;
- int result;
- size_t length;
- int c;
-
- if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
- " option ?arg arg ...?\"", (char *) NULL);
- return TCL_ERROR;
- }
- Tcl_Preserve((ClientData) mbPtr);
- 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);
- result = TCL_ERROR;
- } else {
- result = Tk_ConfigureValue(interp, mbPtr->tkwin, configSpecs,
- (char *) mbPtr, argv[2], 0);
- }
- } else if ((c == 'c') && (strncmp(argv[1], "configure", length) == 0)
- && (length >= 2)) {
- if (argc == 2) {
- result = Tk_ConfigureInfo(interp, mbPtr->tkwin, configSpecs,
- (char *) mbPtr, (char *) NULL, 0);
- } else if (argc == 3) {
- result = Tk_ConfigureInfo(interp, mbPtr->tkwin, configSpecs,
- (char *) mbPtr, argv[2], 0);
- } else {
- result = ConfigureMenuButton(interp, mbPtr, argc-2, argv+2,
- TK_CONFIG_ARGV_ONLY);
- }
- } else {
- Tcl_AppendResult(interp, "bad option \"", argv[1],
- "\": must be cget or configure",
- (char *) NULL);
- result = TCL_ERROR;
- }
- Tcl_Release((ClientData) mbPtr);
- return result;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * DestroyMenuButton --
- *
- * This procedure is invoked to recycle all of the resources
- * associated with a button widget. It is invoked as a
- * when-idle handler in order to make sure that there is no
- * other use of the button pending at the time of the deletion.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Everything associated with the widget is freed up.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-DestroyMenuButton(memPtr)
- char *memPtr; /* Info about button widget. */
-{
- register TkMenuButton *mbPtr = (TkMenuButton *) memPtr;
-
- /*
- * Free up all the stuff that requires special handling, then
- * let Tk_FreeOptions handle all the standard option-related
- * stuff.
- */
-
- if (mbPtr->textVarName != NULL) {
- Tcl_UntraceVar(mbPtr->interp, mbPtr->textVarName,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- MenuButtonTextVarProc, (ClientData) mbPtr);
- }
- if (mbPtr->image != NULL) {
- Tk_FreeImage(mbPtr->image);
- }
- if (mbPtr->normalTextGC != None) {
- Tk_FreeGC(mbPtr->display, mbPtr->normalTextGC);
- }
- if (mbPtr->activeTextGC != None) {
- Tk_FreeGC(mbPtr->display, mbPtr->activeTextGC);
- }
- if (mbPtr->gray != None) {
- Tk_FreeBitmap(mbPtr->display, mbPtr->gray);
- }
- if (mbPtr->disabledGC != None) {
- Tk_FreeGC(mbPtr->display, mbPtr->disabledGC);
- }
- Tk_FreeTextLayout(mbPtr->textLayout);
- Tk_FreeOptions(configSpecs, (char *) mbPtr, mbPtr->display, 0);
- ckfree((char *) mbPtr);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ConfigureMenuButton --
- *
- * This procedure is called to process an argv/argc list, plus
- * the Tk option database, in order to configure (or
- * reconfigure) a menubutton widget.
- *
- * Results:
- * The return value is a standard Tcl result. If TCL_ERROR is
- * returned, then interp->result contains an error message.
- *
- * Side effects:
- * Configuration information, such as text string, colors, font,
- * etc. get set for mbPtr; old resources get freed, if there
- * were any. The menubutton is redisplayed.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-ConfigureMenuButton(interp, mbPtr, argc, argv, flags)
- Tcl_Interp *interp; /* Used for error reporting. */
- register TkMenuButton *mbPtr; /* 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 flags; /* Flags to pass to Tk_ConfigureWidget. */
-{
- int result;
- Tk_Image image;
-
- /*
- * Eliminate any existing trace on variables monitored by the menubutton.
- */
-
- if (mbPtr->textVarName != NULL) {
- Tcl_UntraceVar(interp, mbPtr->textVarName,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- MenuButtonTextVarProc, (ClientData) mbPtr);
- }
-
- result = Tk_ConfigureWidget(interp, mbPtr->tkwin, configSpecs,
- argc, argv, (char *) mbPtr, flags);
- if (result != TCL_OK) {
- return TCL_ERROR;
- }
-
- /*
- * A few options need special processing, such as setting the
- * background from a 3-D border, or filling in complicated
- * defaults that couldn't be specified to Tk_ConfigureWidget.
- */
-
- if ((mbPtr->state == tkActiveUid) && !Tk_StrictMotif(mbPtr->tkwin)) {
- Tk_SetBackgroundFromBorder(mbPtr->tkwin, mbPtr->activeBorder);
- } else {
- Tk_SetBackgroundFromBorder(mbPtr->tkwin, mbPtr->normalBorder);
- if ((mbPtr->state != tkNormalUid) && (mbPtr->state != tkActiveUid)
- && (mbPtr->state != tkDisabledUid)) {
- Tcl_AppendResult(interp, "bad state value \"", mbPtr->state,
- "\": must be normal, active, or disabled", (char *) NULL);
- mbPtr->state = tkNormalUid;
- return TCL_ERROR;
- }
- }
-
- if ((mbPtr->direction != aboveUid) && (mbPtr->direction != belowUid)
- && (mbPtr->direction != leftUid) && (mbPtr->direction != rightUid)
- && (mbPtr->direction != flushUid)) {
- Tcl_AppendResult(interp, "bad direction value \"", mbPtr->direction,
- "\": must be above, below, left, right, or flush",
- (char *) NULL);
- mbPtr->direction = belowUid;
- return TCL_ERROR;
- }
-
- if (mbPtr->highlightWidth < 0) {
- mbPtr->highlightWidth = 0;
- }
-
- if (mbPtr->padX < 0) {
- mbPtr->padX = 0;
- }
- if (mbPtr->padY < 0) {
- mbPtr->padY = 0;
- }
-
- /*
- * Get the image for the widget, if there is one. Allocate the
- * new image before freeing the old one, so that the reference
- * count doesn't go to zero and cause image data to be discarded.
- */
-
- if (mbPtr->imageString != NULL) {
- image = Tk_GetImage(mbPtr->interp, mbPtr->tkwin,
- mbPtr->imageString, MenuButtonImageProc, (ClientData) mbPtr);
- if (image == NULL) {
- return TCL_ERROR;
- }
- } else {
- image = NULL;
- }
- if (mbPtr->image != NULL) {
- Tk_FreeImage(mbPtr->image);
- }
- mbPtr->image = image;
-
- if ((mbPtr->image == NULL) && (mbPtr->bitmap == None)
- && (mbPtr->textVarName != NULL)) {
- /*
- * The menubutton displays a variable. Set up a trace to watch
- * for any changes in it.
- */
-
- char *value;
-
- value = Tcl_GetVar(interp, mbPtr->textVarName, TCL_GLOBAL_ONLY);
- if (value == NULL) {
- Tcl_SetVar(interp, mbPtr->textVarName, mbPtr->text,
- TCL_GLOBAL_ONLY);
- } else {
- if (mbPtr->text != NULL) {
- ckfree(mbPtr->text);
- }
- mbPtr->text = (char *) ckalloc((unsigned) (strlen(value) + 1));
- strcpy(mbPtr->text, value);
- }
- Tcl_TraceVar(interp, mbPtr->textVarName,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- MenuButtonTextVarProc, (ClientData) mbPtr);
- }
-
- /*
- * Recompute the geometry for the button.
- */
-
- if ((mbPtr->bitmap != None) || (mbPtr->image != NULL)) {
- if (Tk_GetPixels(interp, mbPtr->tkwin, mbPtr->widthString,
- &mbPtr->width) != TCL_OK) {
- widthError:
- Tcl_AddErrorInfo(interp, "\n (processing -width option)");
- return TCL_ERROR;
- }
- if (Tk_GetPixels(interp, mbPtr->tkwin, mbPtr->heightString,
- &mbPtr->height) != TCL_OK) {
- heightError:
- Tcl_AddErrorInfo(interp, "\n (processing -height option)");
- return TCL_ERROR;
- }
- } else {
- if (Tcl_GetInt(interp, mbPtr->widthString, &mbPtr->width)
- != TCL_OK) {
- goto widthError;
- }
- if (Tcl_GetInt(interp, mbPtr->heightString, &mbPtr->height)
- != TCL_OK) {
- goto heightError;
- }
- }
- TkMenuButtonWorldChanged((ClientData) mbPtr);
- return TCL_OK;
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * TkMenuButtonWorldChanged --
- *
- * 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:
- * TkMenuButton will be relayed out and redisplayed.
- *
- *---------------------------------------------------------------------------
- */
-
-void
-TkMenuButtonWorldChanged(instanceData)
- ClientData instanceData; /* Information about widget. */
-{
- XGCValues gcValues;
- GC gc;
- unsigned long mask;
- TkMenuButton *mbPtr;
-
- mbPtr = (TkMenuButton *) instanceData;
-
- gcValues.font = Tk_FontId(mbPtr->tkfont);
- gcValues.foreground = mbPtr->normalFg->pixel;
- gcValues.background = Tk_3DBorderColor(mbPtr->normalBorder)->pixel;
-
- /*
- * Note: GraphicsExpose events are disabled in GC's because they're
- * used to copy stuff from an off-screen pixmap onto the screen (we know
- * that there's no problem with obscured areas).
- */
-
- gcValues.graphics_exposures = False;
- mask = GCForeground | GCBackground | GCFont | GCGraphicsExposures;
- gc = Tk_GetGC(mbPtr->tkwin, mask, &gcValues);
- if (mbPtr->normalTextGC != None) {
- Tk_FreeGC(mbPtr->display, mbPtr->normalTextGC);
- }
- mbPtr->normalTextGC = gc;
-
- gcValues.font = Tk_FontId(mbPtr->tkfont);
- gcValues.foreground = mbPtr->activeFg->pixel;
- gcValues.background = Tk_3DBorderColor(mbPtr->activeBorder)->pixel;
- mask = GCForeground | GCBackground | GCFont;
- gc = Tk_GetGC(mbPtr->tkwin, mask, &gcValues);
- if (mbPtr->activeTextGC != None) {
- Tk_FreeGC(mbPtr->display, mbPtr->activeTextGC);
- }
- mbPtr->activeTextGC = gc;
-
- gcValues.font = Tk_FontId(mbPtr->tkfont);
- gcValues.background = Tk_3DBorderColor(mbPtr->normalBorder)->pixel;
- if ((mbPtr->disabledFg != NULL) && (mbPtr->imageString == NULL)) {
- gcValues.foreground = mbPtr->disabledFg->pixel;
- mask = GCForeground | GCBackground | GCFont;
- } else {
- gcValues.foreground = gcValues.background;
- mask = GCForeground;
- if (mbPtr->gray == None) {
- mbPtr->gray = Tk_GetBitmap(NULL, mbPtr->tkwin,
- Tk_GetUid("gray50"));
- }
- if (mbPtr->gray != None) {
- gcValues.fill_style = FillStippled;
- gcValues.stipple = mbPtr->gray;
- mask |= GCFillStyle | GCStipple;
- }
- }
- gc = Tk_GetGC(mbPtr->tkwin, mask, &gcValues);
- if (mbPtr->disabledGC != None) {
- Tk_FreeGC(mbPtr->display, mbPtr->disabledGC);
- }
- mbPtr->disabledGC = gc;
-
- TkpComputeMenuButtonGeometry(mbPtr);
-
- /*
- * Lastly, arrange for the button to be redisplayed.
- */
-
- if (Tk_IsMapped(mbPtr->tkwin) && !(mbPtr->flags & REDRAW_PENDING)) {
- Tcl_DoWhenIdle(TkpDisplayMenuButton, (ClientData) mbPtr);
- mbPtr->flags |= REDRAW_PENDING;
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * MenuButtonEventProc --
- *
- * This procedure is invoked by the Tk dispatcher for various
- * events on buttons.
- *
- * Results:
- * None.
- *
- * Side effects:
- * When the window gets deleted, internal structures get
- * cleaned up. When it gets exposed, it is redisplayed.
- *
- *--------------------------------------------------------------
- */
-
-static void
-MenuButtonEventProc(clientData, eventPtr)
- ClientData clientData; /* Information about window. */
- XEvent *eventPtr; /* Information about event. */
-{
- TkMenuButton *mbPtr = (TkMenuButton *) clientData;
- if ((eventPtr->type == Expose) && (eventPtr->xexpose.count == 0)) {
- goto redraw;
- } else if (eventPtr->type == ConfigureNotify) {
- /*
- * Must redraw after size changes, since layout could have changed
- * and borders will need to be redrawn.
- */
-
- goto redraw;
- } else if (eventPtr->type == DestroyNotify) {
- TkpDestroyMenuButton(mbPtr);
- if (mbPtr->tkwin != NULL) {
- mbPtr->tkwin = NULL;
- Tcl_DeleteCommandFromToken(mbPtr->interp, mbPtr->widgetCmd);
- }
- if (mbPtr->flags & REDRAW_PENDING) {
- Tcl_CancelIdleCall(TkpDisplayMenuButton, (ClientData) mbPtr);
- }
- Tcl_EventuallyFree((ClientData) mbPtr, DestroyMenuButton);
- } else if (eventPtr->type == FocusIn) {
- if (eventPtr->xfocus.detail != NotifyInferior) {
- mbPtr->flags |= GOT_FOCUS;
- if (mbPtr->highlightWidth > 0) {
- goto redraw;
- }
- }
- } else if (eventPtr->type == FocusOut) {
- if (eventPtr->xfocus.detail != NotifyInferior) {
- mbPtr->flags &= ~GOT_FOCUS;
- if (mbPtr->highlightWidth > 0) {
- goto redraw;
- }
- }
- }
- return;
-
- redraw:
- if ((mbPtr->tkwin != NULL) && !(mbPtr->flags & REDRAW_PENDING)) {
- Tcl_DoWhenIdle(TkpDisplayMenuButton, (ClientData) mbPtr);
- mbPtr->flags |= REDRAW_PENDING;
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * MenuButtonCmdDeletedProc --
- *
- * 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
-MenuButtonCmdDeletedProc(clientData)
- ClientData clientData; /* Pointer to widget record for widget. */
-{
- TkMenuButton *mbPtr = (TkMenuButton *) clientData;
- Tk_Window tkwin = mbPtr->tkwin;
-
- /*
- * This procedure could be invoked either because the window was
- * destroyed and the command was then deleted (in which case tkwin
- * is NULL) or because the command was deleted, and then this procedure
- * destroys the widget.
- */
-
- if (tkwin != NULL) {
- mbPtr->tkwin = NULL;
- Tk_DestroyWindow(tkwin);
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * MenuButtonTextVarProc --
- *
- * This procedure is invoked when someone changes the variable
- * whose contents are to be displayed in a menu button.
- *
- * Results:
- * NULL is always returned.
- *
- * Side effects:
- * The text displayed in the menu button will change to match the
- * variable.
- *
- *--------------------------------------------------------------
- */
-
- /* ARGSUSED */
-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. */
- int flags; /* Information about what happened. */
-{
- register TkMenuButton *mbPtr = (TkMenuButton *) clientData;
- char *value;
-
- /*
- * If the variable is unset, then immediately recreate it unless
- * the whole interpreter is going away.
- */
-
- if (flags & TCL_TRACE_UNSETS) {
- if ((flags & TCL_TRACE_DESTROYED) && !(flags & TCL_INTERP_DESTROYED)) {
- Tcl_SetVar(interp, mbPtr->textVarName, mbPtr->text,
- TCL_GLOBAL_ONLY);
- Tcl_TraceVar(interp, mbPtr->textVarName,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- MenuButtonTextVarProc, clientData);
- }
- return (char *) NULL;
- }
-
- value = Tcl_GetVar(interp, mbPtr->textVarName, TCL_GLOBAL_ONLY);
- if (value == NULL) {
- value = "";
- }
- if (mbPtr->text != NULL) {
- ckfree(mbPtr->text);
- }
- mbPtr->text = (char *) ckalloc((unsigned) (strlen(value) + 1));
- strcpy(mbPtr->text, value);
- TkpComputeMenuButtonGeometry(mbPtr);
-
- if ((mbPtr->tkwin != NULL) && Tk_IsMapped(mbPtr->tkwin)
- && !(mbPtr->flags & REDRAW_PENDING)) {
- Tcl_DoWhenIdle(TkpDisplayMenuButton, (ClientData) mbPtr);
- mbPtr->flags |= REDRAW_PENDING;
- }
- return (char *) NULL;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * MenuButtonImageProc --
- *
- * This procedure is invoked by the image code whenever the manager
- * for an image does something that affects the size of contents
- * of an image displayed in a button.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Arranges for the button to get redisplayed.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-MenuButtonImageProc(clientData, x, y, width, height, imgWidth, imgHeight)
- ClientData clientData; /* Pointer to widget record. */
- int x, y; /* Upper left pixel (within image)
- * that must be redisplayed. */
- int width, height; /* Dimensions of area to redisplay
- * (may be <= 0). */
- int imgWidth, imgHeight; /* New dimensions of image. */
-{
- register TkMenuButton *mbPtr = (TkMenuButton *) clientData;
-
- if (mbPtr->tkwin != NULL) {
- TkpComputeMenuButtonGeometry(mbPtr);
- if (Tk_IsMapped(mbPtr->tkwin) && !(mbPtr->flags & REDRAW_PENDING)) {
- Tcl_DoWhenIdle(TkpDisplayMenuButton, (ClientData) mbPtr);
- mbPtr->flags |= REDRAW_PENDING;
- }
- }
-}
diff --git a/generic/tkMenubutton.h b/generic/tkMenubutton.h
deleted file mode 100644
index b032274..0000000
--- a/generic/tkMenubutton.h
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * tkMenubutton.h --
- *
- * Declarations of types and functions used to implement
- * the menubutton widget.
- *
- * Copyright (c) 1996-1997 by 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: tkMenubutton.h,v 1.4 1998/09/14 18:23:15 stanton Exp $
- */
-
-#ifndef _TKMENUBUTTON
-#define _TKMENUBUTTON
-
-#ifndef _TKINT
-#include "tkInt.h"
-#endif
-
-#ifdef BUILD_tk
-# undef TCL_STORAGE_CLASS
-# define TCL_STORAGE_CLASS DLLEXPORT
-#endif
-
-/*
- * A data structure of the following type is kept for each
- * widget managed by this file:
- */
-
-typedef struct {
- Tk_Window tkwin; /* Window that embodies the widget. NULL
- * means that the window has been destroyed
- * but the data structures haven't yet been
- * cleaned up.*/
- Display *display; /* Display containing widget. Needed, among
- * other things, so that resources can bee
- * freed up even after tkwin has gone away. */
- Tcl_Interp *interp; /* Interpreter associated with menubutton. */
- Tcl_Command widgetCmd; /* Token for menubutton's widget command. */
- char *menuName; /* Name of menu associated with widget.
- * Malloc-ed. */
-
- /*
- * Information about what's displayed in the menu button:
- */
-
- char *text; /* Text to display in button (malloc'ed)
- * or NULL. */
- int underline; /* Index of character to underline. */
- char *textVarName; /* Name of variable (malloc'ed) or NULL.
- * If non-NULL, button displays the contents
- * of this variable. */
- Pixmap bitmap; /* Bitmap to display or None. If not None
- * then text and textVar and underline
- * are ignored. */
- char *imageString; /* Name of image to display (malloc'ed), or
- * NULL. If non-NULL, bitmap, text, and
- * textVarName are ignored. */
- Tk_Image image; /* Image to display in window, or NULL if
- * none. */
-
- /*
- * Information used when displaying widget:
- */
-
- Tk_Uid state; /* State of button for display purposes:
- * normal, active, or disabled. */
- Tk_3DBorder normalBorder; /* Structure used to draw 3-D
- * border and background when window
- * isn't active. NULL means no such
- * border exists. */
- Tk_3DBorder activeBorder; /* Structure used to draw 3-D
- * border and background when window
- * is active. NULL means no such
- * border exists. */
- int borderWidth; /* Width of border. */
- int relief; /* 3-d effect: TK_RELIEF_RAISED, etc. */
- int highlightWidth; /* Width in pixels of highlight to draw
- * around widget when it has the focus.
- * <= 0 means don't draw a highlight. */
- XColor *highlightBgColorPtr;
- /* Color for drawing traversal highlight
- * area when highlight is off. */
- XColor *highlightColorPtr; /* Color for drawing traversal highlight. */
- int inset; /* Total width of all borders, including
- * traversal highlight and 3-D border.
- * Indicates how much interior stuff must
- * be offset from outside edges to leave
- * room for borders. */
- Tk_Font tkfont; /* Information about text font, or NULL. */
- XColor *normalFg; /* Foreground color in normal mode. */
- XColor *activeFg; /* Foreground color in active mode. NULL
- * means use normalFg instead. */
- XColor *disabledFg; /* Foreground color when disabled. NULL
- * means use normalFg with a 50% stipple
- * instead. */
- GC normalTextGC; /* GC for drawing text in normal mode. */
- GC activeTextGC; /* GC for drawing text in active mode (NULL
- * means use normalTextGC). */
- Pixmap gray; /* Pixmap for displaying disabled text/icon if
- * disabledFg is NULL. */
- GC disabledGC; /* Used to produce disabled effect. If
- * disabledFg isn't NULL, this GC is used to
- * draw button text or icon. Otherwise
- * text or icon is drawn with normalGC and
- * this GC is used to stipple background
- * across it. */
- int leftBearing; /* Distance from text origin to leftmost drawn
- * pixel (positive means to right). */
- int rightBearing; /* Amount text sticks right from its origin. */
- char *widthString; /* Value of -width option. Malloc'ed. */
- char *heightString; /* Value of -height option. Malloc'ed. */
- int width, height; /* If > 0, these specify dimensions to request
- * for window, in characters for text and in
- * pixels for bitmaps. In this case the actual
- * size of the text string or bitmap is
- * ignored in computing desired window size. */
- int wrapLength; /* Line length (in pixels) at which to wrap
- * onto next line. <= 0 means don't wrap
- * except at newlines. */
- int padX, padY; /* Extra space around text or bitmap (pixels
- * on each side). */
- Tk_Anchor anchor; /* Where text/bitmap should be displayed
- * inside window region. */
- Tk_Justify justify; /* Justification to use for multi-line text. */
- int textWidth; /* Width needed to display text as requested,
- * in pixels. */
- int textHeight; /* Height needed to display text as requested,
- * in pixels. */
- Tk_TextLayout textLayout; /* Saved text layout information. */
- int indicatorOn; /* Non-zero means display indicator; 0 means
- * don't display. */
- int indicatorHeight; /* Height of indicator in pixels. This same
- * amount of extra space is also left on each
- * side of the indicator. 0 if no indicator. */
- int indicatorWidth; /* Width of indicator in pixels, including
- * indicatorHeight in padding on each side.
- * 0 if no indicator. */
-
- /*
- * Miscellaneous information:
- */
-
- Tk_Uid direction; /* Direction for where to pop the menu.
- * Valid directions are "above", "below",
- * "left", "right", and "flush". "flush"
- * means that the upper left corner of the
- * menubutton is where the menu pops up.
- * "above" and "below" will attempt to pop
- * the menu compleletly above or below
- * the menu respectively.
- * "left" and "right" will pop the menu
- * left or right, and the active item
- * will be next to the button. */
- Tk_Cursor cursor; /* Current cursor for window, or None. */
- char *takeFocus; /* Value of -takefocus option; not used in
- * the C code, but used by keyboard traversal
- * scripts. Malloc'ed, but may be NULL. */
- int flags; /* Various flags; see below for
- * definitions. */
-} TkMenuButton;
-
-/*
- * Flag bits for buttons:
- *
- * REDRAW_PENDING: Non-zero means a DoWhenIdle handler
- * has already been queued to redraw
- * this window.
- * POSTED: Non-zero means that the menu associated
- * with this button has been posted (typically
- * because of an active button press).
- * GOT_FOCUS: Non-zero means this button currently
- * has the input focus.
- */
-
-#define REDRAW_PENDING 1
-#define POSTED 2
-#define GOT_FOCUS 4
-
-/*
- * The following constants define the dimensions of the cascade indicator,
- * which is displayed if the "-indicatoron" option is true. The units for
- * these options are 1/10 millimeters.
- */
-
-#define INDICATOR_WIDTH 40
-#define INDICATOR_HEIGHT 17
-
-/*
- * Declaration of variables shared between the files in the button module.
- */
-
-extern TkClassProcs tkpMenubuttonClass;
-
-/*
- * Declaration of procedures used in the implementation of the button
- * widget.
- */
-
-EXTERN void TkpComputeMenuButtonGeometry _ANSI_ARGS_((
- TkMenuButton *mbPtr));
-EXTERN TkMenuButton * TkpCreateMenuButton _ANSI_ARGS_((Tk_Window tkwin));
-EXTERN void TkpDisplayMenuButton _ANSI_ARGS_((
- ClientData clientData));
-EXTERN void TkpDestroyMenuButton _ANSI_ARGS_((
- TkMenuButton *mbPtr));
-EXTERN void TkMenuButtonWorldChanged _ANSI_ARGS_((
- ClientData instanceData));
-
-# undef TCL_STORAGE_CLASS
-# define TCL_STORAGE_CLASS DLLIMPORT
-
-#endif /* _TKMENUBUTTON */
diff --git a/generic/tkMessage.c b/generic/tkMessage.c
deleted file mode 100644
index d12c0a3..0000000
--- a/generic/tkMessage.c
+++ /dev/null
@@ -1,848 +0,0 @@
-/*
- * tkMessage.c --
- *
- * This module implements a message widgets for the Tk
- * toolkit. A message widget displays a multi-line string
- * in a window according to a particular aspect ratio.
- *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1995 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: tkMessage.c,v 1.2 1998/09/14 18:23:15 stanton Exp $
- */
-
-#include "tkPort.h"
-#include "default.h"
-#include "tkInt.h"
-
-/*
- * A data structure of the following type is kept for each message
- * widget managed by this file:
- */
-
-typedef struct {
- Tk_Window tkwin; /* Window that embodies the message. NULL
- * means that the window has been destroyed
- * but the data structures haven't yet been
- * cleaned up.*/
- Display *display; /* Display containing widget. Used, among
- * other things, so that resources can be
- * freed even after tkwin has gone away. */
- Tcl_Interp *interp; /* Interpreter associated with message. */
- Tcl_Command widgetCmd; /* Token for message's widget command. */
-
- /*
- * Information used when displaying widget:
- */
-
- char *string; /* String displayed in message. */
- int numChars; /* Number of characters in string, not
- * including terminating NULL character. */
- char *textVarName; /* Name of variable (malloc'ed) or NULL.
- * If non-NULL, message displays the contents
- * of this variable. */
- Tk_3DBorder border; /* Structure used to draw 3-D border and
- * background. NULL means a border hasn't
- * been created yet. */
- int borderWidth; /* Width of border. */
- int relief; /* 3-D effect: TK_RELIEF_RAISED, etc. */
- int highlightWidth; /* Width in pixels of highlight to draw
- * around widget when it has the focus.
- * <= 0 means don't draw a highlight. */
- XColor *highlightBgColorPtr;
- /* Color for drawing traversal highlight
- * area when highlight is off. */
- XColor *highlightColorPtr; /* Color for drawing traversal highlight. */
- Tk_Font tkfont; /* Information about text font, or NULL. */
- XColor *fgColorPtr; /* Foreground color in normal mode. */
- int padX, padY; /* User-requested extra space around text. */
- int width; /* User-requested width, in pixels. 0 means
- * compute width using aspect ratio below. */
- int aspect; /* Desired aspect ratio for window
- * (100*width/height). */
- int msgWidth; /* Width in pixels needed to display
- * message. */
- int msgHeight; /* Height in pixels needed to display
- * message. */
- Tk_Anchor anchor; /* Where to position text within window region
- * if window is larger or smaller than
- * needed. */
- Tk_Justify justify; /* Justification for text. */
-
- GC textGC; /* GC for drawing text in normal mode. */
- Tk_TextLayout textLayout; /* Saved layout information. */
-
- /*
- * Miscellaneous information:
- */
-
- Tk_Cursor cursor; /* Current cursor for window, or None. */
- char *takeFocus; /* Value of -takefocus option; not used in
- * the C code, but used by keyboard traversal
- * scripts. Malloc'ed, but may be NULL. */
- int flags; /* Various flags; see below for
- * definitions. */
-} Message;
-
-/*
- * Flag bits for messages:
- *
- * REDRAW_PENDING: Non-zero means a DoWhenIdle handler
- * has already been queued to redraw
- * this window.
- * GOT_FOCUS: Non-zero means this button currently
- * has the input focus.
- */
-
-#define REDRAW_PENDING 1
-#define GOT_FOCUS 4
-
-/*
- * 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}
-};
-
-/*
- * Forward declarations for procedures defined later in this file:
- */
-
-static void MessageCmdDeletedProc _ANSI_ARGS_((
- ClientData clientData));
-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));
-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,
- int flags));
-static void DestroyMessage _ANSI_ARGS_((char *memPtr));
-static void DisplayMessage _ANSI_ARGS_((ClientData clientData));
-
-/*
- * The structure below defines message class behavior by means of procedures
- * that can be invoked from generic window code.
- */
-
-static TkClassProcs messageClass = {
- NULL, /* createProc. */
- MessageWorldChanged, /* geometryProc. */
- NULL /* modalProc. */
-};
-
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_MessageCmd --
- *
- * This procedure is invoked to process the "message" 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_MessageCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Main window associated with
- * interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- register Message *msgPtr;
- Tk_Window new;
- Tk_Window tkwin = (Tk_Window) clientData;
-
- if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " pathName ?options?\"", (char *) NULL);
- return TCL_ERROR;
- }
-
- new = Tk_CreateWindowFromPath(interp, tkwin, argv[1], (char *) NULL);
- if (new == NULL) {
- return TCL_ERROR;
- }
-
- 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;
-
- Tk_SetClass(msgPtr->tkwin, "Message");
- TkSetClassProcs(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;
- }
-
- interp->result = Tk_PathName(msgPtr->tkwin);
- return TCL_OK;
-
- error:
- Tk_DestroyWindow(msgPtr->tkwin);
- return TCL_ERROR;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * MessageWidgetCmd --
- *
- * 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
-MessageWidgetCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Information about message widget. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- register Message *msgPtr = (Message *) clientData;
- size_t length;
- int c;
-
- if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
- " option ?arg arg ...?\"", (char *) NULL);
- 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;
- }
- 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);
- }
- } else {
- Tcl_AppendResult(interp, "bad option \"", argv[1],
- "\": must be cget or configure", (char *) NULL);
- return TCL_ERROR;
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * DestroyMessage --
- *
- * This procedure is invoked by Tcl_EventuallyFree or Tcl_Release
- * to clean up the internal structure of a message at a safe time
- * (when no-one is using it anymore).
- *
- * Results:
- * None.
- *
- * Side effects:
- * Everything associated with the message is freed up.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-DestroyMessage(memPtr)
- char *memPtr; /* Info about message widget. */
-{
- register Message *msgPtr = (Message *) memPtr;
-
- /*
- * Free up all the stuff that requires special handling, then
- * let Tk_FreeOptions handle all the standard option-related
- * stuff.
- */
-
- 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);
- ckfree((char *) msgPtr);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ConfigureMessage --
- *
- * This procedure is called to process an argv/argc list, plus
- * the Tk option database, in order to configure (or
- * reconfigure) a message widget.
- *
- * Results:
- * The return value is a standard Tcl result. If TCL_ERROR is
- * returned, then interp->result contains an error message.
- *
- * Side effects:
- * Configuration information, such as text string, colors, font,
- * etc. get set for msgPtr; old resources get freed, if there
- * were any.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-ConfigureMessage(interp, msgPtr, argc, argv, 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 flags; /* Flags to pass to Tk_ConfigureWidget. */
-{
- /*
- * Eliminate any existing trace on a variable monitored by the message.
- */
-
- if (msgPtr->textVarName != NULL) {
- Tcl_UntraceVar(interp, msgPtr->textVarName,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- MessageTextVarProc, (ClientData) msgPtr);
- }
-
- if (Tk_ConfigureWidget(interp, msgPtr->tkwin, configSpecs,
- argc, argv, (char *) msgPtr, flags) != TCL_OK) {
- return TCL_ERROR;
- }
-
- /*
- * If the message is to display the value of a variable, then set up
- * a trace on the variable's value, create the variable if it doesn't
- * exist, and fetch its current value.
- */
-
- if (msgPtr->textVarName != NULL) {
- char *value;
-
- value = Tcl_GetVar(interp, msgPtr->textVarName, TCL_GLOBAL_ONLY);
- if (value == NULL) {
- Tcl_SetVar(interp, msgPtr->textVarName, msgPtr->string,
- TCL_GLOBAL_ONLY);
- } else {
- if (msgPtr->string != NULL) {
- ckfree(msgPtr->string);
- }
- msgPtr->string = strcpy(ckalloc(strlen(value) + 1), value);
- }
- Tcl_TraceVar(interp, msgPtr->textVarName,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- MessageTextVarProc, (ClientData) msgPtr);
- }
-
- /*
- * A few other options need special processing, such as setting
- * the background from a 3-D border or handling special defaults
- * that couldn't be specified to Tk_ConfigureWidget.
- */
-
- msgPtr->numChars = strlen(msgPtr->string);
-
- Tk_SetBackgroundFromBorder(msgPtr->tkwin, msgPtr->border);
-
- if (msgPtr->highlightWidth < 0) {
- msgPtr->highlightWidth = 0;
- }
-
- MessageWorldChanged((ClientData) msgPtr);
- return TCL_OK;
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * MessageWorldChanged --
- *
- * 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:
- * Message will be relayed out and redisplayed.
- *
- *---------------------------------------------------------------------------
- */
-
-static void
-MessageWorldChanged(instanceData)
- ClientData instanceData; /* Information about widget. */
-{
- XGCValues gcValues;
- GC gc;
- Tk_FontMetrics fm;
- Message *msgPtr;
-
- msgPtr = (Message *) instanceData;
-
- gcValues.font = Tk_FontId(msgPtr->tkfont);
- gcValues.foreground = msgPtr->fgColorPtr->pixel;
- gc = Tk_GetGC(msgPtr->tkwin, GCForeground | GCFont, &gcValues);
- if (msgPtr->textGC != None) {
- Tk_FreeGC(msgPtr->display, msgPtr->textGC);
- }
- msgPtr->textGC = gc;
-
- Tk_GetFontMetrics(msgPtr->tkfont, &fm);
- if (msgPtr->padX < 0) {
- msgPtr->padX = fm.ascent / 2;
- }
- if (msgPtr->padY == -1) {
- msgPtr->padY = fm.ascent / 4;
- }
-
- /*
- * Recompute the desired geometry for the window, and arrange for
- * the window to be redisplayed.
- */
-
- ComputeMessageGeometry(msgPtr);
- if ((msgPtr->tkwin != NULL) && Tk_IsMapped(msgPtr->tkwin)
- && !(msgPtr->flags & REDRAW_PENDING)) {
- Tcl_DoWhenIdle(DisplayMessage, (ClientData) msgPtr);
- msgPtr->flags |= REDRAW_PENDING;
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ComputeMessageGeometry --
- *
- * Compute the desired geometry for a message window,
- * taking into account the desired aspect ratio for the
- * window.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Tk_GeometryRequest is called to inform the geometry
- * manager of the desired geometry for this window.
- *
- *--------------------------------------------------------------
- */
-
-static void
-ComputeMessageGeometry(msgPtr)
- register Message *msgPtr; /* Information about window. */
-{
- int width, inc, height;
- int thisWidth, thisHeight, maxWidth;
- int aspect, lowerBound, upperBound, inset;
-
- Tk_FreeTextLayout(msgPtr->textLayout);
-
- inset = msgPtr->borderWidth + msgPtr->highlightWidth;
-
- /*
- * Compute acceptable bounds for the final aspect ratio.
- */
-
- aspect = msgPtr->aspect/10;
- if (aspect < 5) {
- aspect = 5;
- }
- lowerBound = msgPtr->aspect - aspect;
- upperBound = msgPtr->aspect + aspect;
-
- /*
- * Do the computation in multiple passes: start off with
- * a very wide window, and compute its height. Then change
- * the width and try again. Reduce the size of the change
- * and iterate until dimensions are found that approximate
- * the desired aspect ratio. Or, if the user gave an explicit
- * width then just use that.
- */
-
- if (msgPtr->width > 0) {
- width = msgPtr->width;
- inc = 0;
- } else {
- width = WidthOfScreen(Tk_Screen(msgPtr->tkwin))/2;
- inc = width/2;
- }
-
- for ( ; ; inc /= 2) {
- msgPtr->textLayout = Tk_ComputeTextLayout(msgPtr->tkfont,
- msgPtr->string, msgPtr->numChars, width, msgPtr->justify,
- 0, &thisWidth, &thisHeight);
- maxWidth = thisWidth + 2 * (inset + msgPtr->padX);
- height = thisHeight + 2 * (inset + msgPtr->padY);
-
- if (inc <= 2) {
- break;
- }
- aspect = (100 * maxWidth) / height;
-
- if (aspect < lowerBound) {
- width += inc;
- } else if (aspect > upperBound) {
- width -= inc;
- } else {
- break;
- }
- Tk_FreeTextLayout(msgPtr->textLayout);
- }
- msgPtr->msgWidth = thisWidth;
- msgPtr->msgHeight = thisHeight;
- Tk_GeometryRequest(msgPtr->tkwin, maxWidth, height);
- Tk_SetInternalBorder(msgPtr->tkwin, inset);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * DisplayMessage --
- *
- * This procedure redraws the contents of a message window.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Information appears on the screen.
- *
- *--------------------------------------------------------------
- */
-
-static void
-DisplayMessage(clientData)
- ClientData clientData; /* Information about window. */
-{
- register Message *msgPtr = (Message *) clientData;
- register Tk_Window tkwin = msgPtr->tkwin;
- int x, y;
-
- msgPtr->flags &= ~REDRAW_PENDING;
- if ((msgPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) {
- return;
- }
- Tk_Fill3DRectangle(tkwin, Tk_WindowId(tkwin), msgPtr->border, 0, 0,
- Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT);
-
- /*
- * Compute starting y-location for message based on message size
- * and anchor option.
- */
-
- TkComputeAnchor(msgPtr->anchor, tkwin, msgPtr->padX, msgPtr->padY,
- msgPtr->msgWidth, msgPtr->msgHeight, &x, &y);
- Tk_DrawTextLayout(Tk_Display(tkwin), Tk_WindowId(tkwin), msgPtr->textGC,
- msgPtr->textLayout, x, y, 0, -1);
-
- if (msgPtr->relief != TK_RELIEF_FLAT) {
- Tk_Draw3DRectangle(tkwin, Tk_WindowId(tkwin), msgPtr->border,
- msgPtr->highlightWidth, msgPtr->highlightWidth,
- Tk_Width(tkwin) - 2*msgPtr->highlightWidth,
- Tk_Height(tkwin) - 2*msgPtr->highlightWidth,
- msgPtr->borderWidth, msgPtr->relief);
- }
- if (msgPtr->highlightWidth != 0) {
- GC gc;
-
- if (msgPtr->flags & GOT_FOCUS) {
- gc = Tk_GCForColor(msgPtr->highlightColorPtr, Tk_WindowId(tkwin));
- } else {
- gc = Tk_GCForColor(msgPtr->highlightBgColorPtr, Tk_WindowId(tkwin));
- }
- Tk_DrawFocusHighlight(tkwin, gc, msgPtr->highlightWidth,
- Tk_WindowId(tkwin));
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * MessageEventProc --
- *
- * This procedure is invoked by the Tk dispatcher for various
- * events on messages.
- *
- * Results:
- * None.
- *
- * Side effects:
- * When the window gets deleted, internal structures get
- * cleaned up. When it gets exposed, it is redisplayed.
- *
- *--------------------------------------------------------------
- */
-
-static void
-MessageEventProc(clientData, eventPtr)
- ClientData clientData; /* Information about window. */
- XEvent *eventPtr; /* Information about event. */
-{
- Message *msgPtr = (Message *) clientData;
-
- if (((eventPtr->type == Expose) && (eventPtr->xexpose.count == 0))
- || (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);
- } else if (eventPtr->type == FocusIn) {
- if (eventPtr->xfocus.detail != NotifyInferior) {
- msgPtr->flags |= GOT_FOCUS;
- if (msgPtr->highlightWidth > 0) {
- goto redraw;
- }
- }
- } else if (eventPtr->type == FocusOut) {
- if (eventPtr->xfocus.detail != NotifyInferior) {
- msgPtr->flags &= ~GOT_FOCUS;
- if (msgPtr->highlightWidth > 0) {
- goto redraw;
- }
- }
- }
- return;
-
- redraw:
- if ((msgPtr->tkwin != NULL) && !(msgPtr->flags & REDRAW_PENDING)) {
- Tcl_DoWhenIdle(DisplayMessage, (ClientData) msgPtr);
- msgPtr->flags |= REDRAW_PENDING;
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * MessageCmdDeletedProc --
- *
- * 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
-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
- * destroyed and the command was then deleted (in which case tkwin
- * is NULL) or because the command was deleted, and then this procedure
- * destroys the widget.
- */
-
- if (tkwin != NULL) {
- msgPtr->tkwin = NULL;
- Tk_DestroyWindow(tkwin);
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * MessageTextVarProc --
- *
- * This procedure is invoked when someone changes the variable
- * whose contents are to be displayed in a message.
- *
- * Results:
- * NULL is always returned.
- *
- * Side effects:
- * The text displayed in the message will change to match the
- * variable.
- *
- *--------------------------------------------------------------
- */
-
- /* ARGSUSED */
-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. */
- int flags; /* Information about what happened. */
-{
- register Message *msgPtr = (Message *) clientData;
- char *value;
-
- /*
- * If the variable is unset, then immediately recreate it unless
- * the whole interpreter is going away.
- */
-
- if (flags & TCL_TRACE_UNSETS) {
- if ((flags & TCL_TRACE_DESTROYED) && !(flags & TCL_INTERP_DESTROYED)) {
- Tcl_SetVar(interp, msgPtr->textVarName, msgPtr->string,
- TCL_GLOBAL_ONLY);
- Tcl_TraceVar(interp, msgPtr->textVarName,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- MessageTextVarProc, clientData);
- }
- return (char *) NULL;
- }
-
- value = Tcl_GetVar(interp, msgPtr->textVarName, TCL_GLOBAL_ONLY);
- if (value == NULL) {
- value = "";
- }
- if (msgPtr->string != NULL) {
- ckfree(msgPtr->string);
- }
- msgPtr->numChars = strlen(value);
- msgPtr->string = (char *) ckalloc((unsigned) (msgPtr->numChars + 1));
- strcpy(msgPtr->string, value);
- ComputeMessageGeometry(msgPtr);
-
- if ((msgPtr->tkwin != NULL) && Tk_IsMapped(msgPtr->tkwin)
- && !(msgPtr->flags & REDRAW_PENDING)) {
- Tcl_DoWhenIdle(DisplayMessage, (ClientData) msgPtr);
- msgPtr->flags |= REDRAW_PENDING;
- }
- return (char *) NULL;
-}
diff --git a/generic/tkOption.c b/generic/tkOption.c
deleted file mode 100644
index 9b7e17d..0000000
--- a/generic/tkOption.c
+++ /dev/null
@@ -1,1397 +0,0 @@
-/*
- * tkOption.c --
- *
- * This module contains procedures to manage the option
- * database, which allows various strings to be associated
- * with windows either by name or by class or both.
- *
- * 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: tkOption.c,v 1.2 1998/09/14 18:23:15 stanton Exp $
- */
-
-#include "tkPort.h"
-#include "tkInt.h"
-
-/*
- * The option database is stored as one tree for each main window.
- * Each name or class field in an option is associated with a node or
- * leaf of the tree. For example, the options "x.y.z" and "x.y*a"
- * each correspond to three nodes in the tree; they share the nodes
- * "x" and "x.y", but have different leaf nodes. One of the following
- * 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.
- */
-
-typedef struct Element {
- Tk_Uid nameUid; /* Name or class from one element of
- * an option spec. */
- union {
- struct ElArray *arrayPtr; /* If this is an intermediate node,
- * a pointer to a structure describing
- * the remaining elements of all
- * options whose prefixes are the
- * same up through this element. */
- Tk_Uid valueUid; /* For leaf nodes, this is the string
- * value of the option. */
- } child;
- int priority; /* Used to select among matching
- * options. Includes both the
- * priority level and a serial #.
- * Greater value means higher
- * priority. Irrelevant except in
- * leaf nodes. */
- int flags; /* OR-ed combination of bits. See
- * below for values. */
-} Element;
-
-/*
- * Flags in Element structures:
- *
- * CLASS - Non-zero means this element refers to a class,
- * Zero means this element refers to a name.
- * NODE - Zero means this is a leaf element (the child
- * field is a value, not a pointer to another node).
- * One means this is a node element.
- * WILDCARD - Non-zero means this there was a star in the
- * original specification just before this element.
- * Zero means there was a dot.
- */
-
-#define TYPE_MASK 0x7
-
-#define CLASS 0x1
-#define NODE 0x2
-#define WILDCARD 0x4
-
-#define EXACT_LEAF_NAME 0x0
-#define EXACT_LEAF_CLASS 0x1
-#define EXACT_NODE_NAME 0x2
-#define EXACT_NODE_CLASS 0x3
-#define WILDCARD_LEAF_NAME 0x4
-#define WILDCARD_LEAF_CLASS 0x5
-#define WILDCARD_NODE_NAME 0x6
-#define WILDCARD_NODE_CLASS 0x7
-
-/*
- * The following structure is used to manage a dynamic array of
- * Elements. These structures are used for two purposes: to store
- * the contents of a node in the option tree, and for the option
- * stacks described below.
- */
-
-typedef struct ElArray {
- int arraySize; /* Number of elements actually
- * allocated in the "els" array. */
- int numUsed; /* Number of elements currently in
- * use out of els. */
- Element *nextToUse; /* Pointer to &els[numUsed]. */
- Element els[1]; /* Array of structures describing
- * children of this node. The
- * array will actually contain enough
- * elements for all of the children
- * (and even a few extras, perhaps).
- * This must be the last field in
- * the structure. */
-} ElArray;
-
-#define EL_ARRAY_SIZE(numEls) ((unsigned) (sizeof(ElArray) \
- + ((numEls)-1)*sizeof(Element)))
-#define INITIAL_SIZE 5
-
-/*
- * In addition to the option tree, which is a relatively static structure,
- * there are eight additional structures called "stacks", which are used
- * to speed up queries into the option database. The stack structures
- * are designed for the situation where an individual widget makes repeated
- * requests for its particular options. The requests differ only in
- * their last name/class, so during the first request we extract all
- * the options pertaining to the particular widget and save them in a
- * stack-like cache; subsequent requests for the same widget can search
- * the cache relatively quickly. In fact, the cache is a hierarchical
- * one, storing a list of relevant options for this widget and all of
- * its ancestors up to the application root; hence the name "stack".
- *
- * Each of the eight stacks consists of an array of Elements, ordered in
- * terms of levels in the window hierarchy. All the elements relevant
- * for the top-level widget appear first in the array, followed by all
- * those from the next-level widget on the path to the current widget,
- * etc. down to those for the current widget.
- *
- * Cached information is divided into eight stacks according to the
- * CLASS, NODE, and WILDCARD flags. Leaf and non-leaf information is
- * kept separate to speed up individual probes (non-leaf information is
- * only relevant when building the stacks, but isn't relevant when
- * making probes; similarly, only non-leaf information is relevant
- * when the stacks are being extended to the next widget down in the
- * widget hierarchy). Wildcard elements are handled separately from
- * "exact" elements because once they appear at a particular level in
- * the stack they remain active for all deeper levels; exact elements
- * are only relevant at a particular level. For example, when searching
- * for options relevant in a particular window, the entire wildcard
- * stacks get checked, but only the portions of the exact stacks that
- * pertain to the window's parent. Lastly, name and class stacks are
- * kept separate because different search keys are used when searching
- * them; keeping them separate speeds up the searches.
- */
-
-#define NUM_STACKS 8
-static ElArray *stacks[NUM_STACKS];
-static TkWindow *cachedWindow = NULL; /* Lowest-level window currently
- * loaded in stacks at present.
- * NULL means stacks have never
- * been used, or have been
- * invalidated because of a change
- * to the database. */
-
-/*
- * One of the following structures is used to keep track of each
- * level in the stacks.
- */
-
-typedef struct StackLevel {
- TkWindow *winPtr; /* Window corresponding to this stack
- * level. */
- int bases[NUM_STACKS]; /* For each stack, index of first
- * element on stack corresponding to
- * this level (used to restore "numUsed"
- * fields when popping out of a level. */
-} StackLevel;
-
-/*
- * Information about all of the stack levels that are currently
- * active. This array grows dynamically to become as large as needed.
- */
-
-static StackLevel *levels = NULL;
- /* Array describing current stack. */
-static int numLevels = 0; /* Total space allocated. */
-static int curLevel = -1; /* Highest level currently in use. Note:
- * curLevel is never 0! (I don't remember
- * why anymore...) */
-
-/*
- * The variable below is a serial number for all options entered into
- * the database so far. It increments on each addition to the option
- * database. It is used in computing option priorities, so that the
- * most recent entry wins when choosing between options at the same
- * priority level.
- */
-
-static int serial = 0;
-
-/*
- * Special "no match" Element to use as default for searches.
- */
-
-static Element defaultMatch;
-
-/*
- * Forward declarations for procedures defined in this file:
- */
-
-static int AddFromString _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Window tkwin, char *string, int priority));
-static void ClearOptionTree _ANSI_ARGS_((ElArray *arrayPtr));
-static ElArray * ExtendArray _ANSI_ARGS_((ElArray *arrayPtr,
- Element *elPtr));
-static void ExtendStacks _ANSI_ARGS_((ElArray *arrayPtr,
- int leaf));
-static int GetDefaultOptions _ANSI_ARGS_((Tcl_Interp *interp,
- TkWindow *winPtr));
-static ElArray * NewArray _ANSI_ARGS_((int numEls));
-static void OptionInit _ANSI_ARGS_((TkMainInfo *mainPtr));
-static int ParsePriority _ANSI_ARGS_((Tcl_Interp *interp,
- char *string));
-static int ReadOptionFile _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Window tkwin, char *fileName, int priority));
-static void SetupStacks _ANSI_ARGS_((TkWindow *winPtr, int leaf));
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_AddOption --
- *
- * Add a new option to the option database.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Information is added to the option database.
- *
- *--------------------------------------------------------------
- */
-
-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. */
- int priority; /* Overall priority level to use for
- * this option, such as TK_USER_DEFAULT_PRIO
- * or TK_INTERACTIVE_PRIO. Must be between
- * 0 and TK_MAX_PRIO. */
-{
- TkWindow *winPtr = ((TkWindow *) tkwin)->mainPtr->winPtr;
- register ElArray **arrayPtrPtr;
- register Element *elPtr;
- Element newEl;
- register char *p;
- char *field;
- int count, firstField, length;
-#define TMP_SIZE 100
- char tmp[TMP_SIZE+1];
-
- if (winPtr->mainPtr->optionRootPtr == NULL) {
- OptionInit(winPtr->mainPtr);
- }
- cachedWindow = NULL; /* Invalidate the cache. */
-
- /*
- * Compute the priority for the new element, including both the
- * overall level and the serial number (to disambiguate with the
- * level).
- */
-
- if (priority < 0) {
- priority = 0;
- } else if (priority > TK_MAX_PRIO) {
- priority = TK_MAX_PRIO;
- }
- newEl.priority = (priority << 24) + serial;
- serial++;
-
- /*
- * Parse the option one field at a time.
- */
-
- arrayPtrPtr = &(((TkWindow *) tkwin)->mainPtr->optionRootPtr);
- p = name;
- for (firstField = 1; ; firstField = 0) {
-
- /*
- * Scan the next field from the name and convert it to a Tk_Uid.
- * Must copy the field before calling Tk_Uid, so that a terminating
- * NULL may be added without modifying the source string.
- */
-
- if (*p == '*') {
- newEl.flags = WILDCARD;
- p++;
- } else {
- newEl.flags = 0;
- }
- field = p;
- while ((*p != 0) && (*p != '.') && (*p != '*')) {
- p++;
- }
- length = p - field;
- if (length > TMP_SIZE) {
- length = TMP_SIZE;
- }
- strncpy(tmp, field, (size_t) length);
- tmp[length] = 0;
- newEl.nameUid = Tk_GetUid(tmp);
- if (isupper(UCHAR(*field))) {
- newEl.flags |= CLASS;
- }
-
- if (*p != 0) {
-
- /*
- * New element will be a node. If this option can't possibly
- * apply to this main window, then just skip it. Otherwise,
- * add it to the parent, if it isn't already there, and descend
- * into it.
- */
-
- newEl.flags |= NODE;
- if (firstField && !(newEl.flags & WILDCARD)
- && (newEl.nameUid != winPtr->nameUid)
- && (newEl.nameUid != winPtr->classUid)) {
- return;
- }
- for (elPtr = (*arrayPtrPtr)->els, count = (*arrayPtrPtr)->numUsed;
- ; elPtr++, count--) {
- if (count == 0) {
- newEl.child.arrayPtr = NewArray(5);
- *arrayPtrPtr = ExtendArray(*arrayPtrPtr, &newEl);
- arrayPtrPtr = &((*arrayPtrPtr)->nextToUse[-1].child.arrayPtr);
- break;
- }
- if ((elPtr->nameUid == newEl.nameUid)
- && (elPtr->flags == newEl.flags)) {
- arrayPtrPtr = &(elPtr->child.arrayPtr);
- break;
- }
- }
- if (*p == '.') {
- p++;
- }
- } else {
-
- /*
- * New element is a leaf. Add it to the parent, if it isn't
- * already there. If it exists already, keep whichever value
- * has highest priority.
- */
-
- newEl.child.valueUid = Tk_GetUid(value);
- for (elPtr = (*arrayPtrPtr)->els, count = (*arrayPtrPtr)->numUsed;
- ; elPtr++, count--) {
- if (count == 0) {
- *arrayPtrPtr = ExtendArray(*arrayPtrPtr, &newEl);
- return;
- }
- if ((elPtr->nameUid == newEl.nameUid)
- && (elPtr->flags == newEl.flags)) {
- if (elPtr->priority < newEl.priority) {
- elPtr->priority = newEl.priority;
- elPtr->child.valueUid = newEl.child.valueUid;
- }
- return;
- }
- }
- }
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_GetOption --
- *
- * Retrieve an option from the option database.
- *
- * Results:
- * The return value is the value specified in the option
- * database for the given name and class on the given
- * window. If there is nothing specified in the database
- * for that option, then NULL is returned.
- *
- * Side effects:
- * The internal caches used to speed up option mapping
- * may be modified, if this tkwin is different from the
- * last tkwin used for option retrieval.
- *
- *--------------------------------------------------------------
- */
-
-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
- * is no class for this option: just
- * check for name. */
-{
- Tk_Uid nameId, classId;
- register Element *elPtr, *bestPtr;
- register int count;
-
- /*
- * Note: no need to call OptionInit here: it will be done by
- * the SetupStacks call below (squeeze out those nanoseconds).
- */
-
- if (tkwin != (Tk_Window) cachedWindow) {
- SetupStacks((TkWindow *) tkwin, 1);
- }
-
- nameId = Tk_GetUid(name);
- bestPtr = &defaultMatch;
- for (elPtr = stacks[EXACT_LEAF_NAME]->els,
- count = stacks[EXACT_LEAF_NAME]->numUsed; count > 0;
- elPtr++, count--) {
- if ((elPtr->nameUid == nameId)
- && (elPtr->priority > bestPtr->priority)) {
- bestPtr = elPtr;
- }
- }
- for (elPtr = stacks[WILDCARD_LEAF_NAME]->els,
- count = stacks[WILDCARD_LEAF_NAME]->numUsed; count > 0;
- elPtr++, count--) {
- if ((elPtr->nameUid == nameId)
- && (elPtr->priority > bestPtr->priority)) {
- bestPtr = elPtr;
- }
- }
- if (className != NULL) {
- classId = Tk_GetUid(className);
- for (elPtr = stacks[EXACT_LEAF_CLASS]->els,
- count = stacks[EXACT_LEAF_CLASS]->numUsed; count > 0;
- elPtr++, count--) {
- if ((elPtr->nameUid == classId)
- && (elPtr->priority > bestPtr->priority)) {
- bestPtr = elPtr;
- }
- }
- for (elPtr = stacks[WILDCARD_LEAF_CLASS]->els,
- count = stacks[WILDCARD_LEAF_CLASS]->numUsed; count > 0;
- elPtr++, count--) {
- if ((elPtr->nameUid == classId)
- && (elPtr->priority > bestPtr->priority)) {
- bestPtr = elPtr;
- }
- }
- }
- return bestPtr->child.valueUid;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_OptionCmd --
- *
- * This procedure is invoked to process the "option" 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_OptionCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Main window associated with
- * interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- Tk_Window tkwin = (Tk_Window) clientData;
- size_t length;
- char c;
-
- if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"", argv[0],
- " cmd arg ?arg ...?\"", (char *) NULL);
- return TCL_ERROR;
- }
- c = argv[1][0];
- length = strlen(argv[1]);
- if ((c == 'a') && (strncmp(argv[1], "add", length) == 0)) {
- int priority;
-
- if ((argc != 4) && (argc != 5)) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " add pattern value ?priority?\"", (char *) NULL);
- return TCL_ERROR;
- }
- if (argc == 4) {
- priority = TK_INTERACTIVE_PRIO;
- } else {
- priority = ParsePriority(interp, argv[4]);
- if (priority < 0) {
- return TCL_ERROR;
- }
- }
- Tk_AddOption(tkwin, argv[2], argv[3], priority);
- return TCL_OK;
- } else if ((c == 'c') && (strncmp(argv[1], "clear", length) == 0)) {
- TkMainInfo *mainPtr;
-
- if (argc != 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " clear\"", (char *) NULL);
- return TCL_ERROR;
- }
- mainPtr = ((TkWindow *) tkwin)->mainPtr;
- if (mainPtr->optionRootPtr != NULL) {
- ClearOptionTree(mainPtr->optionRootPtr);
- mainPtr->optionRootPtr = NULL;
- }
- cachedWindow = NULL;
- return TCL_OK;
- } else if ((c == 'g') && (strncmp(argv[1], "get", length) == 0)) {
- Tk_Window window;
- Tk_Uid value;
-
- if (argc != 5) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " get window name class\"", (char *) NULL);
- return TCL_ERROR;
- }
- window = Tk_NameToWindow(interp, argv[2], tkwin);
- if (window == NULL) {
- return TCL_ERROR;
- }
- value = Tk_GetOption(window, argv[3], argv[4]);
- if (value != NULL) {
- interp->result = value;
- }
- return TCL_OK;
- } else if ((c == 'r') && (strncmp(argv[1], "readfile", length) == 0)) {
- int priority;
-
- if ((argc != 3) && (argc != 4)) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " readfile fileName ?priority?\"",
- (char *) NULL);
- return TCL_ERROR;
- }
- if (argc == 4) {
- priority = ParsePriority(interp, argv[3]);
- if (priority < 0) {
- return TCL_ERROR;
- }
- } else {
- priority = TK_INTERACTIVE_PRIO;
- }
- return ReadOptionFile(interp, tkwin, argv[2], priority);
- } else {
- Tcl_AppendResult(interp, "bad option \"", argv[1],
- "\": must be add, clear, get, or readfile", (char *) NULL);
- return TCL_ERROR;
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * TkOptionDeadWindow --
- *
- * This procedure is called whenever a window is deleted.
- * It cleans up any option-related stuff associated with
- * the window.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Option-related resources are freed. See code below
- * for details.
- *
- *--------------------------------------------------------------
- */
-
-void
-TkOptionDeadWindow(winPtr)
- register TkWindow *winPtr; /* Window to be cleaned up. */
-{
- /*
- * If this window is in the option stacks, then clear the stacks.
- */
-
- if (winPtr->optionLevel != -1) {
- int i;
-
- for (i = 1; i <= curLevel; i++) {
- levels[i].winPtr->optionLevel = -1;
- }
- curLevel = -1;
- cachedWindow = NULL;
- }
-
- /*
- * If this window was a main window, then delete its option
- * database.
- */
-
- if ((winPtr->mainPtr->winPtr == winPtr)
- && (winPtr->mainPtr->optionRootPtr != NULL)) {
- ClearOptionTree(winPtr->mainPtr->optionRootPtr);
- winPtr->mainPtr->optionRootPtr = NULL;
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkOptionClassChanged --
- *
- * This procedure is invoked when a window's class changes. If
- * the window is on the option cache, this procedure flushes
- * any information for the window, since the new class could change
- * what is relevant.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The option cache may be flushed in part or in whole.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkOptionClassChanged(winPtr)
- TkWindow *winPtr; /* Window whose class changed. */
-{
- int i, j, *basePtr;
- ElArray *arrayPtr;
-
- if (winPtr->optionLevel == -1) {
- return;
- }
-
- /*
- * Find the lowest stack level that refers to this window, then
- * flush all of the levels above the matching one.
- */
-
- for (i = 1; i <= curLevel; i++) {
- if (levels[i].winPtr == winPtr) {
- for (j = i; j <= curLevel; j++) {
- levels[j].winPtr->optionLevel = -1;
- }
- curLevel = i-1;
- basePtr = levels[i].bases;
- for (j = 0; j < NUM_STACKS; j++) {
- arrayPtr = stacks[j];
- arrayPtr->numUsed = basePtr[j];
- arrayPtr->nextToUse = &arrayPtr->els[arrayPtr->numUsed];
- }
- if (curLevel <= 0) {
- cachedWindow = NULL;
- } else {
- cachedWindow = levels[curLevel].winPtr;
- }
- break;
- }
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ParsePriority --
- *
- * Parse a string priority value.
- *
- * Results:
- * The return value is the integer priority level corresponding
- * to string, or -1 if string doesn't point to a valid priority level.
- * In this case, an error message is left in interp->result.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-ParsePriority(interp, string)
- Tcl_Interp *interp; /* Interpreter to use for error reporting. */
- char *string; /* Describes a priority level, either
- * symbolically or numerically. */
-{
- int priority, c;
- size_t length;
-
- c = string[0];
- length = strlen(string);
- if ((c == 'w')
- && (strncmp(string, "widgetDefault", length) == 0)) {
- return TK_WIDGET_DEFAULT_PRIO;
- } else if ((c == 's')
- && (strncmp(string, "startupFile", length) == 0)) {
- return TK_STARTUP_FILE_PRIO;
- } else if ((c == 'u')
- && (strncmp(string, "userDefault", length) == 0)) {
- return TK_USER_DEFAULT_PRIO;
- } else if ((c == 'i')
- && (strncmp(string, "interactive", length) == 0)) {
- return TK_INTERACTIVE_PRIO;
- } else {
- char *end;
-
- priority = strtoul(string, &end, 0);
- if ((end == string) || (*end != 0) || (priority < 0)
- || (priority > 100)) {
- Tcl_AppendResult(interp, "bad priority level \"", string,
- "\": must be widgetDefault, startupFile, userDefault, ",
- "interactive, or a number between 0 and 100",
- (char *) NULL);
- return -1;
- }
- }
- return priority;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * AddFromString --
- *
- * Given a string containing lines in the standard format for
- * X resources (see other documentation for details on what this
- * is), parse the resource specifications and enter them as options
- * for tkwin's main window.
- *
- * Results:
- * The return value is a standard Tcl return code. In the case of
- * an error in parsing string, TCL_ERROR will be returned and an
- * error message will be left in interp->result. The memory at
- * string is totally trashed by this procedure. If you care about
- * its contents, make a copy before calling here.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-AddFromString(interp, tkwin, string, priority)
- Tcl_Interp *interp; /* Interpreter to use for reporting results. */
- Tk_Window tkwin; /* Token for window: options are entered
- * for this window's main window. */
- char *string; /* String containing option specifiers. */
- int priority; /* Priority level to use for options in
- * this string, such as TK_USER_DEFAULT_PRIO
- * or TK_INTERACTIVE_PRIO. Must be between
- * 0 and TK_MAX_PRIO. */
-{
- register char *src, *dst;
- char *name, *value;
- int lineNum;
-
- src = string;
- lineNum = 1;
- while (1) {
-
- /*
- * Skip leading white space and empty lines and comment lines, and
- * check for the end of the spec.
- */
-
- while ((*src == ' ') || (*src == '\t')) {
- src++;
- }
- if ((*src == '#') || (*src == '!')) {
- do {
- src++;
- if ((src[0] == '\\') && (src[1] == '\n')) {
- src += 2;
- lineNum++;
- }
- } while ((*src != '\n') && (*src != 0));
- }
- if (*src == '\n') {
- src++;
- lineNum++;
- continue;
- }
- if (*src == '\0') {
- break;
- }
-
- /*
- * Parse off the option name, collapsing out backslash-newline
- * sequences of course.
- */
-
- dst = name = src;
- while (*src != ':') {
- if ((*src == '\0') || (*src == '\n')) {
- sprintf(interp->result, "missing colon on line %d",
- lineNum);
- return TCL_ERROR;
- }
- if ((src[0] == '\\') && (src[1] == '\n')) {
- src += 2;
- lineNum++;
- } else {
- *dst = *src;
- dst++;
- src++;
- }
- }
-
- /*
- * Eliminate trailing white space on the name, and null-terminate
- * it.
- */
-
- while ((dst != name) && ((dst[-1] == ' ') || (dst[-1] == '\t'))) {
- dst--;
- }
- *dst = '\0';
-
- /*
- * Skip white space between the name and the value.
- */
-
- src++;
- while ((*src == ' ') || (*src == '\t')) {
- src++;
- }
- if (*src == '\0') {
- sprintf(interp->result, "missing value on line %d", lineNum);
- return TCL_ERROR;
- }
-
- /*
- * Parse off the value, squeezing out backslash-newline sequences
- * along the way.
- */
-
- dst = value = src;
- while (*src != '\n') {
- if (*src == '\0') {
- sprintf(interp->result, "missing newline on line %d",
- lineNum);
- return TCL_ERROR;
- }
- if ((src[0] == '\\') && (src[1] == '\n')) {
- src += 2;
- lineNum++;
- } else {
- *dst = *src;
- dst++;
- src++;
- }
- }
- *dst = 0;
-
- /*
- * Enter the option into the database.
- */
-
- Tk_AddOption(tkwin, name, value, priority);
- src++;
- lineNum++;
- }
- return TCL_OK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ReadOptionFile --
- *
- * Read a file of options ("resources" in the old X terminology)
- * and load them into the option database.
- *
- * Results:
- * The return value is a standard Tcl return code. In the case of
- * an error in parsing string, TCL_ERROR will be returned and an
- * error message will be left in interp->result.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-ReadOptionFile(interp, tkwin, fileName, priority)
- Tcl_Interp *interp; /* Interpreter to use for reporting results. */
- Tk_Window tkwin; /* Token for window: options are entered
- * for this window's main window. */
- char *fileName; /* Name of file containing options. */
- int priority; /* Priority level to use for options in
- * this file, such as TK_USER_DEFAULT_PRIO
- * or TK_INTERACTIVE_PRIO. Must be between
- * 0 and TK_MAX_PRIO. */
-{
- char *realName, *buffer;
- int result, bufferSize;
- Tcl_Channel chan;
- Tcl_DString newName;
-
- /*
- * Prevent file system access in a safe interpreter.
- */
-
- if (Tcl_IsSafe(interp)) {
- Tcl_AppendResult(interp, "can't read options from a file in a",
- " safe interpreter", (char *) NULL);
- return TCL_ERROR;
- }
-
- realName = Tcl_TranslateFileName(interp, fileName, &newName);
- if (realName == NULL) {
- return TCL_ERROR;
- }
- chan = Tcl_OpenFileChannel(interp, realName, "r", 0);
- Tcl_DStringFree(&newName);
- if (chan == NULL) {
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "couldn't open \"", fileName,
- "\": ", Tcl_PosixError(interp), (char *) NULL);
- return TCL_ERROR;
- }
-
- /*
- * Compute size of file by seeking to the end of the file. This will
- * overallocate if we are performing CRLF translation.
- */
-
- bufferSize = Tcl_Seek(chan, 0L, SEEK_END);
- (void) Tcl_Seek(chan, 0L, SEEK_SET);
-
- if (bufferSize < 0) {
- Tcl_AppendResult(interp, "error seeking to end of file \"",
- fileName, "\":", Tcl_PosixError(interp), (char *) NULL);
- Tcl_Close(NULL, chan);
- return TCL_ERROR;
-
- }
- buffer = (char *) ckalloc((unsigned) bufferSize+1);
- bufferSize = Tcl_Read(chan, buffer, bufferSize);
- if (bufferSize < 0) {
- Tcl_AppendResult(interp, "error reading file \"", fileName, "\":",
- Tcl_PosixError(interp), (char *) NULL);
- Tcl_Close(NULL, chan);
- return TCL_ERROR;
- }
- Tcl_Close(NULL, chan);
- buffer[bufferSize] = 0;
- result = AddFromString(interp, tkwin, buffer, priority);
- ckfree(buffer);
- return result;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * NewArray --
- *
- * Create a new ElArray structure of a given size.
- *
- * Results:
- * The return value is a pointer to a properly initialized
- * element array with "numEls" space. The array is marked
- * as having no active elements.
- *
- * Side effects:
- * Memory is allocated.
- *
- *--------------------------------------------------------------
- */
-
-static ElArray *
-NewArray(numEls)
- int numEls; /* How many elements of space to allocate. */
-{
- register ElArray *arrayPtr;
-
- arrayPtr = (ElArray *) ckalloc(EL_ARRAY_SIZE(numEls));
- arrayPtr->arraySize = numEls;
- arrayPtr->numUsed = 0;
- arrayPtr->nextToUse = arrayPtr->els;
- return arrayPtr;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ExtendArray --
- *
- * Add a new element to an array, extending the array if
- * necessary.
- *
- * Results:
- * The return value is a pointer to the new array, which
- * will be different from arrayPtr if the array got expanded.
- *
- * Side effects:
- * Memory may be allocated or freed.
- *
- *--------------------------------------------------------------
- */
-
-static ElArray *
-ExtendArray(arrayPtr, elPtr)
- register ElArray *arrayPtr; /* Array to be extended. */
- register Element *elPtr; /* Element to be copied into array. */
-{
- /*
- * If the current array has filled up, make it bigger.
- */
-
- if (arrayPtr->numUsed >= arrayPtr->arraySize) {
- register ElArray *newPtr;
-
- newPtr = (ElArray *) ckalloc(EL_ARRAY_SIZE(2*arrayPtr->arraySize));
- newPtr->arraySize = 2*arrayPtr->arraySize;
- newPtr->numUsed = arrayPtr->numUsed;
- newPtr->nextToUse = &newPtr->els[newPtr->numUsed];
- memcpy((VOID *) newPtr->els, (VOID *) arrayPtr->els,
- (arrayPtr->arraySize*sizeof(Element)));
- ckfree((char *) arrayPtr);
- arrayPtr = newPtr;
- }
-
- *arrayPtr->nextToUse = *elPtr;
- arrayPtr->nextToUse++;
- arrayPtr->numUsed++;
- return arrayPtr;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * SetupStacks --
- *
- * Arrange the stacks so that they cache all the option
- * information for a particular window.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The stacks are modified to hold information for tkwin
- * and all its ancestors in the window hierarchy.
- *
- *--------------------------------------------------------------
- */
-
-static void
-SetupStacks(winPtr, leaf)
- TkWindow *winPtr; /* Window for which information is to
- * be cached. */
- int leaf; /* Non-zero means this is the leaf
- * window being probed. Zero means this
- * is an ancestor of the desired leaf. */
-{
- int level, i, *iPtr;
- register StackLevel *levelPtr;
- register ElArray *arrayPtr;
-
- /*
- * The following array defines the order in which the current
- * stacks are searched to find matching entries to add to the
- * stacks. Given the current priority-based scheme, the order
- * below is no longer relevant; all that matters is that an
- * element is on the list *somewhere*. The ordering is a relic
- * of the old days when priorities were determined differently.
- */
-
- static int searchOrder[] = {WILDCARD_NODE_CLASS, WILDCARD_NODE_NAME,
- EXACT_NODE_CLASS, EXACT_NODE_NAME, -1};
-
- if (winPtr->mainPtr->optionRootPtr == NULL) {
- OptionInit(winPtr->mainPtr);
- }
-
- /*
- * Step 1: make sure that options are cached for this window's
- * parent.
- */
-
- if (winPtr->parentPtr != NULL) {
- level = winPtr->parentPtr->optionLevel;
- if ((level == -1) || (cachedWindow == NULL)) {
- SetupStacks(winPtr->parentPtr, 0);
- level = winPtr->parentPtr->optionLevel;
- }
- level++;
- } else {
- level = 1;
- }
-
- /*
- * Step 2: pop extra unneeded information off the stacks and
- * mark those windows as no longer having cached information.
- */
-
- if (curLevel >= level) {
- while (curLevel >= level) {
- levels[curLevel].winPtr->optionLevel = -1;
- curLevel--;
- }
- levelPtr = &levels[level];
- for (i = 0; i < NUM_STACKS; i++) {
- arrayPtr = stacks[i];
- arrayPtr->numUsed = levelPtr->bases[i];
- arrayPtr->nextToUse = &arrayPtr->els[arrayPtr->numUsed];
- }
- }
- curLevel = winPtr->optionLevel = level;
-
- /*
- * Step 3: if the root database information isn't loaded or
- * isn't valid, initialize level 0 of the stack from the
- * database root (this only happens if winPtr is a main window).
- */
-
- if ((curLevel == 1)
- && ((cachedWindow == NULL)
- || (cachedWindow->mainPtr != winPtr->mainPtr))) {
- for (i = 0; i < NUM_STACKS; i++) {
- arrayPtr = stacks[i];
- arrayPtr->numUsed = 0;
- arrayPtr->nextToUse = arrayPtr->els;
- }
- ExtendStacks(winPtr->mainPtr->optionRootPtr, 0);
- }
-
- /*
- * Step 4: create a new stack level; grow the level array if
- * we've run out of levels. Clear the stacks for EXACT_LEAF_NAME
- * and EXACT_LEAF_CLASS (anything that was there is of no use
- * any more).
- */
-
- if (curLevel >= numLevels) {
- StackLevel *newLevels;
-
- newLevels = (StackLevel *) ckalloc((unsigned)
- (numLevels*2*sizeof(StackLevel)));
- memcpy((VOID *) newLevels, (VOID *) levels,
- (numLevels*sizeof(StackLevel)));
- ckfree((char *) levels);
- numLevels *= 2;
- levels = newLevels;
- }
- levelPtr = &levels[curLevel];
- levelPtr->winPtr = winPtr;
- arrayPtr = stacks[EXACT_LEAF_NAME];
- arrayPtr->numUsed = 0;
- arrayPtr->nextToUse = arrayPtr->els;
- arrayPtr = stacks[EXACT_LEAF_CLASS];
- arrayPtr->numUsed = 0;
- arrayPtr->nextToUse = arrayPtr->els;
- levelPtr->bases[EXACT_LEAF_NAME] = stacks[EXACT_LEAF_NAME]->numUsed;
- levelPtr->bases[EXACT_LEAF_CLASS] = stacks[EXACT_LEAF_CLASS]->numUsed;
- levelPtr->bases[EXACT_NODE_NAME] = stacks[EXACT_NODE_NAME]->numUsed;
- levelPtr->bases[EXACT_NODE_CLASS] = stacks[EXACT_NODE_CLASS]->numUsed;
- levelPtr->bases[WILDCARD_LEAF_NAME] = stacks[WILDCARD_LEAF_NAME]->numUsed;
- levelPtr->bases[WILDCARD_LEAF_CLASS] = stacks[WILDCARD_LEAF_CLASS]->numUsed;
- levelPtr->bases[WILDCARD_NODE_NAME] = stacks[WILDCARD_NODE_NAME]->numUsed;
- levelPtr->bases[WILDCARD_NODE_CLASS] = stacks[WILDCARD_NODE_CLASS]->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
- * stacks.
- */
-
- for (iPtr = searchOrder; *iPtr != -1; iPtr++) {
- register Element *elPtr;
- int count;
- Tk_Uid id;
-
- i = *iPtr;
- if (i & CLASS) {
- id = winPtr->classUid;
- } else {
- id = winPtr->nameUid;
- }
- elPtr = stacks[i]->els;
- count = levelPtr->bases[i];
-
- /*
- * For wildcard stacks, check all entries; for non-wildcard
- * stacks, only check things that matched in the parent.
- */
-
- if (!(i & WILDCARD)) {
- elPtr += levelPtr[-1].bases[i];
- count -= levelPtr[-1].bases[i];
- }
- for ( ; count > 0; elPtr++, count--) {
- if (elPtr->nameUid != id) {
- continue;
- }
- ExtendStacks(elPtr->child.arrayPtr, leaf);
- }
- }
- cachedWindow = winPtr;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ExtendStacks --
- *
- * Given an element array, copy all the elements from the
- * array onto the system stacks (except for irrelevant leaf
- * elements).
- *
- * Results:
- * None.
- *
- * Side effects:
- * The option stacks are extended.
- *
- *--------------------------------------------------------------
- */
-
-static void
-ExtendStacks(arrayPtr, leaf)
- ElArray *arrayPtr; /* Array of elements to copy onto stacks. */
- int leaf; /* If zero, then don't copy exact leaf
- * elements. */
-{
- register int count;
- register Element *elPtr;
-
- for (elPtr = arrayPtr->els, count = arrayPtr->numUsed;
- count > 0; elPtr++, count--) {
- if (!(elPtr->flags & (NODE|WILDCARD)) && !leaf) {
- continue;
- }
- stacks[elPtr->flags] = ExtendArray(stacks[elPtr->flags], elPtr);
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * OptionInit --
- *
- * Initialize data structures for option handling.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Option-related data structures get initialized.
- *
- *--------------------------------------------------------------
- */
-
-static void
-OptionInit(mainPtr)
- register TkMainInfo *mainPtr; /* Top-level information about
- * window that isn't initialized
- * yet. */
-{
- int i;
- Tcl_Interp *interp;
-
- /*
- * First, once-only initialization.
- */
-
- if (numLevels == 0) {
-
- numLevels = 5;
- levels = (StackLevel *) ckalloc((unsigned) (5*sizeof(StackLevel)));
- for (i = 0; i < NUM_STACKS; i++) {
- stacks[i] = NewArray(10);
- levels[0].bases[i] = 0;
- }
-
- defaultMatch.nameUid = NULL;
- defaultMatch.child.valueUid = NULL;
- defaultMatch.priority = -1;
- defaultMatch.flags = 0;
- }
-
- /*
- * Then, per-main-window initialization. Create and delete dummy
- * interpreter for message logging.
- */
-
- mainPtr->optionRootPtr = NewArray(20);
- interp = Tcl_CreateInterp();
- (void) GetDefaultOptions(interp, mainPtr->winPtr);
- Tcl_DeleteInterp(interp);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ClearOptionTree --
- *
- * This procedure is called to erase everything in a
- * hierarchical option database.
- *
- * Results:
- * None.
- *
- * Side effects:
- * All the options associated with arrayPtr are deleted,
- * along with all option subtrees. The space pointed to
- * by arrayPtr is freed.
- *
- *--------------------------------------------------------------
- */
-
-static void
-ClearOptionTree(arrayPtr)
- ElArray *arrayPtr; /* Array of options; delete everything
- * referred to recursively by this. */
-{
- register Element *elPtr;
- int count;
-
- for (count = arrayPtr->numUsed, elPtr = arrayPtr->els; count > 0;
- count--, elPtr++) {
- if (elPtr->flags & NODE) {
- ClearOptionTree(elPtr->child.arrayPtr);
- }
- }
- ckfree((char *) arrayPtr);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * GetDefaultOptions --
- *
- * This procedure is invoked to load the default set of options
- * for a window.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Options are added to those for winPtr's main window. If
- * there exists a RESOURCE_MANAGER proprety for winPtr's
- * display, that is used. Otherwise, the .Xdefaults file in
- * the user's home directory is used.
- *
- *--------------------------------------------------------------
- */
-
-static int
-GetDefaultOptions(interp, winPtr)
- Tcl_Interp *interp; /* Interpreter to use for error reporting. */
- TkWindow *winPtr; /* Fetch option defaults for main window
- * associated with this. */
-{
- char *regProp;
- int result, actualFormat;
- unsigned long numItems, bytesAfter;
- Atom actualType;
-
- /*
- * Try the RESOURCE_MANAGER property on the root window first.
- */
-
- regProp = NULL;
- result = XGetWindowProperty(winPtr->display,
- RootWindow(winPtr->display, 0),
- XA_RESOURCE_MANAGER, 0, 100000,
- False, XA_STRING, &actualType, &actualFormat,
- &numItems, &bytesAfter, (unsigned char **) &regProp);
-
- if ((result == Success) && (actualType == XA_STRING)
- && (actualFormat == 8)) {
- result = AddFromString(interp, (Tk_Window) winPtr, regProp,
- TK_USER_DEFAULT_PRIO);
- XFree(regProp);
- return result;
- }
-
- /*
- * No luck there. Try a .Xdefaults file in the user's home
- * directory.
- */
-
- if (regProp != NULL) {
- XFree(regProp);
- }
- result = ReadOptionFile(interp, (Tk_Window) winPtr, "~/.Xdefaults",
- TK_USER_DEFAULT_PRIO);
- return result;
-}
diff --git a/generic/tkPack.c b/generic/tkPack.c
deleted file mode 100644
index 380315a..0000000
--- a/generic/tkPack.c
+++ /dev/null
@@ -1,1727 +0,0 @@
-/*
- * tkPack.c --
- *
- * This file contains code to implement the "packer"
- * geometry manager for Tk.
- *
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1995 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: tkPack.c,v 1.2 1998/09/14 18:23:15 stanton Exp $
- */
-
-#include "tkPort.h"
-#include "tkInt.h"
-
-typedef enum {TOP, BOTTOM, LEFT, RIGHT} Side;
-
-/* For each window that the packer cares about (either because
- * the window is managed by the packer or because the window
- * has slaves that are managed by the packer), there is a
- * structure of the following type:
- */
-
-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
- * yet because the structure is still in
- * use. */
- struct Packer *masterPtr; /* Master window within which this window
- * is packed (NULL means this window
- * isn't managed by the packer). */
- struct Packer *nextPtr; /* Next window packed within same
- * parent. List is priority-ordered:
- * first on list gets packed first. */
- struct Packer *slavePtr; /* First in list of slaves packed
- * inside this window (NULL means
- * no packed slaves). */
- Side side; /* Side of parent against which
- * this window is packed. */
- Tk_Anchor anchor; /* If frame allocated for window is larger
- * 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:
- * we'll allocate extra space in frame but
- * won't enlarge window). */
- int iPadX, iPadY; /* Total extra pixels to allocate inside the
- * window (half this amount will appear on
- * each side). */
- int doubleBw; /* Twice the window's last known border
- * width. If this changes, the window
- * must be repacked within its parent. */
- int *abortPtr; /* If non-NULL, it means that there is a nested
- * call to ArrangePacking already working on
- * this window. *abortPtr may be set to 1 to
- * abort that nested call. This happens, for
- * example, if tkwin or any of its slaves
- * is deleted. */
- int flags; /* Miscellaneous flags; see below
- * for definitions. */
-} Packer;
-
-/*
- * Flag values for Packer structures:
- *
- * REQUESTED_REPACK: 1 means a Tcl_DoWhenIdle request
- * has already been made to repack
- * all the slaves of this window.
- * FILLX: 1 means if frame allocated for window
- * is wider than window needs, expand window
- * to fill frame. 0 means don't make window
- * any larger than needed.
- * FILLY: Same as FILLX, except for height.
- * EXPAND: 1 means this window's frame will absorb any
- * extra space in the parent window.
- * OLD_STYLE: 1 means this window is being managed with
- * the old-style packer algorithms (before
- * Tk version 3.3). The main difference is
- * that padding and filling are done differently.
- * DONT_PROPAGATE: 1 means don't set this window's requested
- * size. 0 means if this window is a master
- * then Tk will set its requested size to fit
- * the needs of its slaves.
- */
-
-#define REQUESTED_REPACK 1
-#define FILLX 2
-#define FILLY 4
-#define EXPAND 8
-#define OLD_STYLE 16
-#define DONT_PROPAGATE 32
-
-/*
- * Hash table used to map from Tk_Window tokens to corresponding
- * Packer structures:
- */
-
-static Tcl_HashTable packerHashTable;
-
-/*
- * Have statics in this module been initialized?
- */
-
-static int initialized = 0;
-
-/*
- * The following structure is the official type record for the
- * packer:
- */
-
-static void PackReqProc _ANSI_ARGS_((ClientData clientData,
- Tk_Window tkwin));
-static void PackLostSlaveProc _ANSI_ARGS_((ClientData clientData,
- Tk_Window tkwin));
-
-static Tk_GeomMgr packerType = {
- "pack", /* name */
- PackReqProc, /* requestProc */
- PackLostSlaveProc, /* lostSlaveProc */
-};
-
-/*
- * Forward declarations for procedures defined later in this file:
- */
-
-static void ArrangePacking _ANSI_ARGS_((ClientData clientData));
-static int ConfigureSlaves _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Window tkwin, int argc, char *argv[]));
-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));
-static void PackReqProc _ANSI_ARGS_((ClientData clientData,
- Tk_Window tkwin));
-static void PackStructureProc _ANSI_ARGS_((ClientData clientData,
- XEvent *eventPtr));
-static void Unlink _ANSI_ARGS_((Packer *packPtr));
-static int XExpansion _ANSI_ARGS_((Packer *slavePtr,
- int cavityWidth));
-static int YExpansion _ANSI_ARGS_((Packer *slavePtr,
- int cavityHeight));
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_PackCmd --
- *
- * This procedure is invoked to process the "pack" 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_PackCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Main window associated with
- * interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- 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);
- }
- if (argc < 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " option arg ?arg ...?\"", (char *) NULL);
- return TCL_ERROR;
- }
- c = argv[1][0];
- length = strlen(argv[1]);
- if ((c == 'a') && (length >= 2)
- && (strncmp(argv[1], "after", length) == 0)) {
- Packer *prevPtr;
- Tk_Window tkwin2;
-
- tkwin2 = Tk_NameToWindow(interp, argv[2], tkwin);
- if (tkwin2 == NULL) {
- return TCL_ERROR;
- }
- prevPtr = GetPacker(tkwin2);
- if (prevPtr->masterPtr == NULL) {
- Tcl_AppendResult(interp, "window \"", argv[2],
- "\" 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)) {
- Packer *masterPtr;
- register Packer *prevPtr;
- Tk_Window tkwin2;
-
- tkwin2 = Tk_NameToWindow(interp, argv[2], tkwin);
- if (tkwin2 == NULL) {
- return TCL_ERROR;
- }
- masterPtr = GetPacker(tkwin2);
- prevPtr = masterPtr->slavePtr;
- if (prevPtr != NULL) {
- while (prevPtr->nextPtr != NULL) {
- prevPtr = prevPtr->nextPtr;
- }
- }
- return PackAfter(interp, prevPtr, masterPtr, argc-3, argv+3);
- } else if ((c == 'b') && (strncmp(argv[1], "before", length) == 0)) {
- Packer *packPtr, *masterPtr;
- register Packer *prevPtr;
- Tk_Window tkwin2;
-
- tkwin2 = Tk_NameToWindow(interp, argv[2], tkwin);
- if (tkwin2 == NULL) {
- return TCL_ERROR;
- }
- packPtr = GetPacker(tkwin2);
- if (packPtr->masterPtr == NULL) {
- Tcl_AppendResult(interp, "window \"", argv[2],
- "\" isn't packed", (char *) NULL);
- return TCL_ERROR;
- }
- masterPtr = packPtr->masterPtr;
- prevPtr = masterPtr->slavePtr;
- if (prevPtr == packPtr) {
- prevPtr = NULL;
- } else {
- for ( ; ; prevPtr = prevPtr->nextPtr) {
- if (prevPtr == NULL) {
- panic("\"pack before\" couldn't find predecessor");
- }
- if (prevPtr->nextPtr == packPtr) {
- break;
- }
- }
- }
- 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],
- "\": 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)) {
- Tk_Window slave;
- Packer *slavePtr;
- int i;
-
- for (i = 2; i < argc; i++) {
- slave = Tk_NameToWindow(interp, argv[i], tkwin);
- if (slave == NULL) {
- continue;
- }
- slavePtr = GetPacker(slave);
- if ((slavePtr != NULL) && (slavePtr->masterPtr != NULL)) {
- 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 Packer *slavePtr;
- Tk_Window slave;
- char buffer[300];
- static char *sideNames[] = {"top", "bottom", "left", "right"};
-
- 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 = GetPacker(slave);
- if (slavePtr->masterPtr == NULL) {
- Tcl_AppendResult(interp, "window \"", argv[2],
- "\" isn't packed", (char *) NULL);
- return TCL_ERROR;
- }
- Tcl_AppendElement(interp, "-in");
- Tcl_AppendElement(interp, Tk_PathName(slavePtr->masterPtr->tkwin));
- Tcl_AppendElement(interp, "-anchor");
- Tcl_AppendElement(interp, Tk_NameOfAnchor(slavePtr->anchor));
- Tcl_AppendResult(interp, " -expand ",
- (slavePtr->flags & EXPAND) ? "1" : "0", " -fill ",
- (char *) NULL);
- switch (slavePtr->flags & (FILLX|FILLY)) {
- case 0:
- Tcl_AppendResult(interp, "none", (char *) NULL);
- break;
- case FILLX:
- Tcl_AppendResult(interp, "x", (char *) NULL);
- break;
- case FILLY:
- Tcl_AppendResult(interp, "y", (char *) NULL);
- break;
- case FILLX|FILLY:
- 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],
- (char *) NULL);
- } else if ((c == 'p') && (strncmp(argv[1], "propagate", length) == 0)) {
- Tk_Window master;
- Packer *masterPtr;
- int propagate;
-
- 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) {
- return TCL_ERROR;
- }
- masterPtr = GetPacker(master);
- if (argc == 3) {
- if (masterPtr->flags & DONT_PROPAGATE) {
- interp->result = "0";
- } else {
- interp->result = "1";
- }
- return TCL_OK;
- }
- if (Tcl_GetBoolean(interp, argv[3], &propagate) != TCL_OK) {
- return TCL_ERROR;
- }
- if (propagate) {
- masterPtr->flags &= ~DONT_PROPAGATE;
-
- /*
- * Repack the master to allow new geometry information to
- * propagate upwards to the master's master.
- */
-
- if (masterPtr->abortPtr != NULL) {
- *masterPtr->abortPtr = 1;
- }
- if (!(masterPtr->flags & REQUESTED_REPACK)) {
- masterPtr->flags |= REQUESTED_REPACK;
- Tcl_DoWhenIdle(ArrangePacking, (ClientData) masterPtr);
- }
- } else {
- masterPtr->flags |= DONT_PROPAGATE;
- }
- } else if ((c == 's') && (strncmp(argv[1], "slaves", length) == 0)) {
- Tk_Window master;
- Packer *masterPtr, *slavePtr;
-
- if (argc != 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " slaves window\"", (char *) NULL);
- return TCL_ERROR;
- }
- master = Tk_NameToWindow(interp, argv[2], tkwin);
- if (master == NULL) {
- return TCL_ERROR;
- }
- masterPtr = GetPacker(master);
- for (slavePtr = masterPtr->slavePtr; slavePtr != NULL;
- slavePtr = slavePtr->nextPtr) {
- Tcl_AppendElement(interp, Tk_PathName(slavePtr->tkwin));
- }
- } else if ((c == 'u') && (strncmp(argv[1], "unpack", length) == 0)) {
- Tk_Window tkwin2;
- Packer *packPtr;
-
- if (argc != 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " unpack window\"", (char *) NULL);
- return TCL_ERROR;
- }
- tkwin2 = Tk_NameToWindow(interp, argv[2], tkwin);
- if (tkwin2 == NULL) {
- return TCL_ERROR;
- }
- packPtr = GetPacker(tkwin2);
- if ((packPtr != NULL) && (packPtr->masterPtr != NULL)) {
- Tk_ManageGeometry(tkwin2, (Tk_GeomMgr *) NULL,
- (ClientData) NULL);
- if (packPtr->masterPtr->tkwin != Tk_Parent(packPtr->tkwin)) {
- Tk_UnmaintainGeometry(packPtr->tkwin,
- packPtr->masterPtr->tkwin);
- }
- 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;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * PackReqProc --
- *
- * This procedure is invoked by Tk_GeometryRequest for
- * windows managed by the packer.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Arranges for tkwin, and all its managed siblings, to
- * be re-packed at the next idle point.
- *
- *--------------------------------------------------------------
- */
-
- /* ARGSUSED */
-static void
-PackReqProc(clientData, tkwin)
- ClientData clientData; /* Packer's information about
- * window that got new preferred
- * geometry. */
- Tk_Window tkwin; /* Other Tk-related information
- * about the window. */
-{
- register Packer *packPtr = (Packer *) clientData;
-
- packPtr = packPtr->masterPtr;
- if (!(packPtr->flags & REQUESTED_REPACK)) {
- packPtr->flags |= REQUESTED_REPACK;
- Tcl_DoWhenIdle(ArrangePacking, (ClientData) packPtr);
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * PackLostSlaveProc --
- *
- * 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 packer-related information about the slave.
- *
- *--------------------------------------------------------------
- */
-
- /* ARGSUSED */
-static void
-PackLostSlaveProc(clientData, tkwin)
- ClientData clientData; /* Packer structure for slave window that
- * was stolen away. */
- Tk_Window tkwin; /* Tk's handle for the slave window. */
-{
- register Packer *slavePtr = (Packer *) clientData;
-
- if (slavePtr->masterPtr->tkwin != Tk_Parent(slavePtr->tkwin)) {
- Tk_UnmaintainGeometry(slavePtr->tkwin, slavePtr->masterPtr->tkwin);
- }
- Unlink(slavePtr);
- Tk_UnmapWindow(slavePtr->tkwin);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ArrangePacking --
- *
- * This procedure is invoked (using the Tcl_DoWhenIdle
- * mechanism) to re-layout a set of windows managed by
- * the packer. It is invoked at idle time so that a
- * series of packer requests can be merged into a single
- * layout operation.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The packed slaves of masterPtr may get resized or
- * moved.
- *
- *--------------------------------------------------------------
- */
-
-static void
-ArrangePacking(clientData)
- ClientData clientData; /* Structure describing parent whose slaves
- * are to be re-layed out. */
-{
- register Packer *masterPtr = (Packer *) clientData;
- register Packer *slavePtr;
- int cavityX, cavityY, cavityWidth, cavityHeight;
- /* These variables keep track of the
- * as-yet-unallocated space remaining in
- * the middle of the parent window. */
- int frameX, frameY, frameWidth, frameHeight;
- /* These variables keep track of the frame
- * 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 maxWidth, maxHeight, tmp;
-
- masterPtr->flags &= ~REQUESTED_REPACK;
-
- /*
- * If the parent has no slaves anymore, then don't do anything
- * at all: just leave the parent's size as-is.
- */
-
- if (masterPtr->slavePtr == NULL) {
- return;
- }
-
- /*
- * Abort any nested call to ArrangePacking for this window, since
- * we'll do everything necessary here, and set up so this call
- * can be aborted if necessary.
- */
-
- if (masterPtr->abortPtr != NULL) {
- *masterPtr->abortPtr = 1;
- }
- masterPtr->abortPtr = &abort;
- abort = 0;
- Tcl_Preserve((ClientData) masterPtr);
-
- /*
- * Pass #1: scan all the slaves to figure out the total amount
- * of space needed. Two separate width and height values are
- * computed:
- *
- * width - Holds the sum of the widths (plus padding) of
- * all the slaves seen so far that were packed LEFT
- * or RIGHT.
- * height - Holds the sum of the heights (plus padding) of
- * all the slaves seen so far that were packed TOP
- * or BOTTOM.
- *
- * maxWidth - Gradually builds up the width needed by the master
- * to just barely satisfy all the slave's needs. For
- * each slave, the code computes the width needed for
- * all the slaves so far and updates maxWidth if the
- * new value is greater.
- * maxHeight - Same as maxWidth, except keeps height info.
- */
-
- intBWidth = Tk_InternalBorderWidth(masterPtr->tkwin);
- width = height = maxWidth = maxHeight = 2*intBWidth;
- for (slavePtr = masterPtr->slavePtr; slavePtr != NULL;
- slavePtr = slavePtr->nextPtr) {
- if ((slavePtr->side == TOP) || (slavePtr->side == BOTTOM)) {
- tmp = Tk_ReqWidth(slavePtr->tkwin) + slavePtr->doubleBw
- + slavePtr->padX + slavePtr->iPadX + width;
- if (tmp > maxWidth) {
- maxWidth = tmp;
- }
- height += Tk_ReqHeight(slavePtr->tkwin) + slavePtr->doubleBw
- + slavePtr->padY + slavePtr->iPadY;
- } else {
- tmp = Tk_ReqHeight(slavePtr->tkwin) + slavePtr->doubleBw
- + slavePtr->padY + slavePtr->iPadY + height;
- if (tmp > maxHeight) {
- maxHeight = tmp;
- }
- width += Tk_ReqWidth(slavePtr->tkwin) + slavePtr->doubleBw
- + slavePtr->padX + slavePtr->iPadX;
- }
- }
- if (width > maxWidth) {
- maxWidth = width;
- }
- if (height > maxHeight) {
- maxHeight = height;
- }
-
- /*
- * If the total amount of space needed in the parent window has
- * changed, and if we're propagating geometry information, then
- * notify the next geometry manager up and requeue ourselves to
- * start again after the parent has had a chance to
- * resize us.
- */
-
- if (((maxWidth != Tk_ReqWidth(masterPtr->tkwin))
- || (maxHeight != Tk_ReqHeight(masterPtr->tkwin)))
- && !(masterPtr->flags & DONT_PROPAGATE)) {
- Tk_GeometryRequest(masterPtr->tkwin, maxWidth, maxHeight);
- masterPtr->flags |= REQUESTED_REPACK;
- Tcl_DoWhenIdle(ArrangePacking, (ClientData) masterPtr);
- goto done;
- }
-
- /*
- * Pass #2: scan the slaves a second time assigning
- * new sizes. The "cavity" variables keep track of the
- * unclaimed space in the cavity of the window; this
- * shrinks inward as we allocate windows around the
- * edges. The "frame" variables keep track of the space
- * allocated to the current window and its frame. The
- * current window is then placed somewhere inside the
- * frame, depending on anchor.
- */
-
- cavityX = cavityY = x = y = intBWidth;
- cavityWidth = Tk_Width(masterPtr->tkwin) - 2*intBWidth;
- cavityHeight = Tk_Height(masterPtr->tkwin) - 2*intBWidth;
- for (slavePtr = masterPtr->slavePtr; slavePtr != NULL;
- slavePtr = slavePtr->nextPtr) {
- if ((slavePtr->side == TOP) || (slavePtr->side == BOTTOM)) {
- frameWidth = cavityWidth;
- frameHeight = Tk_ReqHeight(slavePtr->tkwin) + slavePtr->doubleBw
- + slavePtr->padY + slavePtr->iPadY;
- if (slavePtr->flags & EXPAND) {
- frameHeight += YExpansion(slavePtr, cavityHeight);
- }
- cavityHeight -= frameHeight;
- if (cavityHeight < 0) {
- frameHeight += cavityHeight;
- cavityHeight = 0;
- }
- frameX = cavityX;
- if (slavePtr->side == TOP) {
- frameY = cavityY;
- cavityY += frameHeight;
- } else {
- frameY = cavityY + cavityHeight;
- }
- } else {
- frameHeight = cavityHeight;
- frameWidth = Tk_ReqWidth(slavePtr->tkwin) + slavePtr->doubleBw
- + slavePtr->padX + slavePtr->iPadX;
- if (slavePtr->flags & EXPAND) {
- frameWidth += XExpansion(slavePtr, cavityWidth);
- }
- cavityWidth -= frameWidth;
- if (cavityWidth < 0) {
- frameWidth += cavityWidth;
- cavityWidth = 0;
- }
- frameY = cavityY;
- if (slavePtr->side == LEFT) {
- frameX = cavityX;
- cavityX += frameWidth;
- } else {
- frameX = cavityX + cavityWidth;
- }
- }
-
- /*
- * Now that we've got the size of the frame for the window,
- * compute the window's actual size and location using the
- * fill, padding, and frame factors. The variables "borderX"
- * and "borderY" are used to handle the differences between
- * old-style packing and the new style (in old-style, iPadX
- * and iPadY are always zero and padding is completely ignored
- * except when computing frame size).
- */
-
- if (slavePtr->flags & OLD_STYLE) {
- borderX = borderY = 0;
- } else {
- borderX = slavePtr->padX;
- borderY = slavePtr->padY;
- }
- width = Tk_ReqWidth(slavePtr->tkwin) + slavePtr->doubleBw
- + slavePtr->iPadX;
- if ((slavePtr->flags & FILLX)
- || (width > (frameWidth - borderX))) {
- width = frameWidth - borderX;
- }
- height = Tk_ReqHeight(slavePtr->tkwin) + slavePtr->doubleBw
- + slavePtr->iPadY;
- if ((slavePtr->flags & FILLY)
- || (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;
- break;
- case TK_ANCHOR_NE:
- x = frameX + frameWidth - width - borderX;
- y = frameY + borderY;
- break;
- case TK_ANCHOR_E:
- x = frameX + frameWidth - width - borderX;
- y = frameY + (frameHeight - height)/2;
- break;
- case TK_ANCHOR_SE:
- x = frameX + frameWidth - width - borderX;
- y = frameY + frameHeight - height - borderY;
- break;
- case TK_ANCHOR_S:
- x = frameX + (frameWidth - width)/2;
- y = frameY + frameHeight - height - borderY;
- break;
- case TK_ANCHOR_SW:
- x = frameX + borderX;
- y = frameY + frameHeight - height - borderY;
- break;
- case TK_ANCHOR_W:
- x = frameX + borderX;
- y = frameY + (frameHeight - height)/2;
- break;
- case TK_ANCHOR_NW:
- x = frameX + borderX;
- y = frameY + borderY;
- break;
- case TK_ANCHOR_CENTER:
- x = frameX + (frameWidth - width)/2;
- y = frameY + (frameHeight - height)/2;
- break;
- default:
- panic("bad frame factor in ArrangePacking");
- }
- width -= slavePtr->doubleBw;
- height -= slavePtr->doubleBw;
-
- /*
- * The final step is to set the position, size, and mapped/unmapped
- * state of the slave. If the slave is a child of the master, then
- * do this here. Otherwise let Tk_MaintainGeometry do the work.
- */
-
- if (masterPtr->tkwin == Tk_Parent(slavePtr->tkwin)) {
- if ((width <= 0) || (height <= 0)) {
- Tk_UnmapWindow(slavePtr->tkwin);
- } else {
- if ((x != Tk_X(slavePtr->tkwin))
- || (y != Tk_Y(slavePtr->tkwin))
- || (width != Tk_Width(slavePtr->tkwin))
- || (height != Tk_Height(slavePtr->tkwin))) {
- Tk_MoveResizeWindow(slavePtr->tkwin, x, y, width, height);
- }
- if (abort) {
- goto done;
- }
-
- /*
- * Don't map the slave if the master isn't mapped: wait
- * until the master gets mapped later.
- */
-
- if (Tk_IsMapped(masterPtr->tkwin)) {
- Tk_MapWindow(slavePtr->tkwin);
- }
- }
- } else {
- if ((width <= 0) || (height <= 0)) {
- Tk_UnmaintainGeometry(slavePtr->tkwin, masterPtr->tkwin);
- Tk_UnmapWindow(slavePtr->tkwin);
- } else {
- Tk_MaintainGeometry(slavePtr->tkwin, masterPtr->tkwin,
- x, y, width, height);
- }
- }
-
- /*
- * Changes to the window's structure could cause almost anything
- * to happen, including deleting the parent or child. If this
- * happens, we'll be told to abort.
- */
-
- if (abort) {
- goto done;
- }
- }
-
- done:
- masterPtr->abortPtr = NULL;
- Tcl_Release((ClientData) masterPtr);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * XExpansion --
- *
- * Given a list of packed slaves, the first of which is packed
- * on the left or right and is expandable, compute how much to
- * expand the child.
- *
- * Results:
- * The return value is the number of additional pixels to give to
- * the child.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-XExpansion(slavePtr, cavityWidth)
- register Packer *slavePtr; /* First in list of remaining
- * slaves. */
- int cavityWidth; /* Horizontal space left for all
- * remaining slaves. */
-{
- int numExpand, minExpand, curExpand;
- int childWidth;
-
- /*
- * This procedure is tricky because windows packed top or bottom can
- * be interspersed among expandable windows packed left or right.
- * Scan through the list, keeping a running sum of the widths of
- * all left and right windows (actually, count the cavity space not
- * allocated) and a running count of all expandable left and right
- * windows. At each top or bottom window, and at the end of the
- * list, compute the expansion factor that seems reasonable at that
- * point. Return the smallest factor seen at any of these points.
- */
-
- minExpand = cavityWidth;
- numExpand = 0;
- for ( ; slavePtr != NULL; slavePtr = slavePtr->nextPtr) {
- childWidth = Tk_ReqWidth(slavePtr->tkwin) + slavePtr->doubleBw
- + slavePtr->padX + slavePtr->iPadX;
- if ((slavePtr->side == TOP) || (slavePtr->side == BOTTOM)) {
- curExpand = (cavityWidth - childWidth)/numExpand;
- if (curExpand < minExpand) {
- minExpand = curExpand;
- }
- } else {
- cavityWidth -= childWidth;
- if (slavePtr->flags & EXPAND) {
- numExpand++;
- }
- }
- }
- curExpand = cavityWidth/numExpand;
- if (curExpand < minExpand) {
- minExpand = curExpand;
- }
- return (minExpand < 0) ? 0 : minExpand;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * YExpansion --
- *
- * Given a list of packed slaves, the first of which is packed
- * on the top or bottom and is expandable, compute how much to
- * expand the child.
- *
- * Results:
- * The return value is the number of additional pixels to give to
- * the child.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-YExpansion(slavePtr, cavityHeight)
- register Packer *slavePtr; /* First in list of remaining
- * slaves. */
- int cavityHeight; /* Vertical space left for all
- * remaining slaves. */
-{
- int numExpand, minExpand, curExpand;
- int childHeight;
-
- /*
- * See comments for XExpansion.
- */
-
- minExpand = cavityHeight;
- numExpand = 0;
- for ( ; slavePtr != NULL; slavePtr = slavePtr->nextPtr) {
- childHeight = Tk_ReqHeight(slavePtr->tkwin) + slavePtr->doubleBw
- + slavePtr->padY + slavePtr->iPadY;
- if ((slavePtr->side == LEFT) || (slavePtr->side == RIGHT)) {
- curExpand = (cavityHeight - childHeight)/numExpand;
- if (curExpand < minExpand) {
- minExpand = curExpand;
- }
- } else {
- cavityHeight -= childHeight;
- if (slavePtr->flags & EXPAND) {
- numExpand++;
- }
- }
- }
- curExpand = cavityHeight/numExpand;
- if (curExpand < minExpand) {
- minExpand = curExpand;
- }
- return (minExpand < 0) ? 0 : minExpand;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * GetPacker --
- *
- * This internal procedure is used to locate a Packer
- * structure for a given window, creating one if one
- * doesn't exist already.
- *
- * Results:
- * The return value is a pointer to the Packer structure
- * corresponding to tkwin.
- *
- * Side effects:
- * A new packer structure may be created. If so, then
- * a callback is set up to clean things up when the
- * window is deleted.
- *
- *--------------------------------------------------------------
- */
-
-static Packer *
-GetPacker(tkwin)
- Tk_Window tkwin; /* Token for window for which
- * packer structure is desired. */
-{
- register Packer *packPtr;
- Tcl_HashEntry *hPtr;
- int new;
-
- if (!initialized) {
- initialized = 1;
- Tcl_InitHashTable(&packerHashTable, TCL_ONE_WORD_KEYS);
- }
-
- /*
- * See if there's already packer for this window. If not,
- * then create a new one.
- */
-
- hPtr = Tcl_CreateHashEntry(&packerHashTable, (char *) tkwin, &new);
- if (!new) {
- return (Packer *) Tcl_GetHashValue(hPtr);
- }
- packPtr = (Packer *) ckalloc(sizeof(Packer));
- packPtr->tkwin = tkwin;
- packPtr->masterPtr = NULL;
- packPtr->nextPtr = NULL;
- packPtr->slavePtr = NULL;
- packPtr->side = TOP;
- packPtr->anchor = TK_ANCHOR_CENTER;
- packPtr->padX = packPtr->padY = 0;
- packPtr->iPadX = packPtr->iPadY = 0;
- packPtr->doubleBw = 2*Tk_Changes(tkwin)->border_width;
- packPtr->abortPtr = NULL;
- packPtr->flags = 0;
- Tcl_SetHashValue(hPtr, packPtr);
- Tk_CreateEventHandler(tkwin, StructureNotifyMask,
- PackStructureProc, (ClientData) packPtr);
- return packPtr;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * PackAfter --
- *
- * This procedure does most of the real work of adding
- * one or more windows into the packing order for its parent.
- *
- * Results:
- * A standard Tcl return value.
- *
- * Side effects:
- * The geometry of the specified windows may change, both now and
- * again in the future.
- *
- *--------------------------------------------------------------
- */
-
-static int
-PackAfter(interp, prevPtr, masterPtr, argc, argv)
- 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
- * 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;
-
- /*
- * Iterate over all of the window specifiers, each consisting of
- * two arguments. The first argument contains the window name and
- * the additional arguments contain options such as "top" or
- * "padx 20".
- */
-
- for ( ; argc > 0; argc -= 2, argv += 2, prevPtr = packPtr) {
- if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args: window \"",
- argv[0], "\" should be followed by options",
- (char *) NULL);
- return TCL_ERROR;
- }
-
- /*
- * Find the packer for the window to be packed, and make sure
- * that the window in which it will be packed is either its
- * or a descendant of its parent.
- */
-
- tkwin = Tk_NameToWindow(interp, argv[0], masterPtr->tkwin);
- if (tkwin == NULL) {
- return TCL_ERROR;
- }
-
- parent = Tk_Parent(tkwin);
- for (ancestor = masterPtr->tkwin; ; ancestor = Tk_Parent(ancestor)) {
- if (ancestor == parent) {
- break;
- }
- if (((Tk_FakeWin *) (ancestor))->flags & TK_TOP_LEVEL) {
- badWindow:
- Tcl_AppendResult(interp, "can't pack ", argv[0],
- " inside ", Tk_PathName(masterPtr->tkwin),
- (char *) NULL);
- return TCL_ERROR;
- }
- }
- if (((Tk_FakeWin *) (tkwin))->flags & TK_TOP_LEVEL) {
- goto badWindow;
- }
- if (tkwin == masterPtr->tkwin) {
- goto badWindow;
- }
- packPtr = GetPacker(tkwin);
-
- /*
- * Process options for this window.
- */
-
- if (Tcl_SplitList(interp, argv[1], &optionCount, &options) != TCL_OK) {
- return TCL_ERROR;
- }
- packPtr->side = TOP;
- packPtr->anchor = TK_ANCHOR_CENTER;
- packPtr->padX = packPtr->padY = 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];
-
- c = curOpt[0];
- length = strlen(curOpt);
-
- if ((c == 't')
- && (strncmp(curOpt, "top", length)) == 0) {
- packPtr->side = TOP;
- } else if ((c == 'b')
- && (strncmp(curOpt, "bottom", length)) == 0) {
- packPtr->side = BOTTOM;
- } else if ((c == 'l')
- && (strncmp(curOpt, "left", length)) == 0) {
- packPtr->side = LEFT;
- } else if ((c == 'r')
- && (strncmp(curOpt, "right", length)) == 0) {
- packPtr->side = RIGHT;
- } else if ((c == 'e')
- && (strncmp(curOpt, "expand", length)) == 0) {
- packPtr->flags |= EXPAND;
- } else if ((c == 'f')
- && (strcmp(curOpt, "fill")) == 0) {
- packPtr->flags |= FILLX|FILLY;
- } else if ((length == 5) && (strcmp(curOpt, "fillx")) == 0) {
- packPtr->flags |= FILLX;
- } else if ((length == 5) && (strcmp(curOpt, "filly")) == 0) {
- packPtr->flags |= FILLY;
- } else if ((c == 'p') && (strcmp(curOpt, "padx")) == 0) {
- if (optionCount < (index+2)) {
- missingPad:
- Tcl_AppendResult(interp, "wrong # args: \"", curOpt,
- "\" option must be followed by screen distance",
- (char *) NULL);
- goto 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;
- }
- packPtr->padX = tmp;
- 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;
- }
- packPtr->padY = tmp;
- packPtr->iPadY = 0;
- index++;
- } else if ((c == 'f') && (length > 1)
- && (strncmp(curOpt, "frame", length) == 0)) {
- if (optionCount < (index+2)) {
- Tcl_AppendResult(interp, "wrong # args: \"frame\" ",
- "option must be followed by anchor point",
- (char *) NULL);
- goto error;
- }
- if (Tk_GetAnchor(interp, options[index+1],
- &packPtr->anchor) != TCL_OK) {
- goto error;
- }
- index++;
- } else {
- Tcl_AppendResult(interp, "bad option \"", curOpt,
- "\": should be top, bottom, left, right, ",
- "expand, fill, fillx, filly, padx, pady, or frame",
- (char *) NULL);
- goto error;
- }
- }
-
- if (packPtr != prevPtr) {
-
- /*
- * Unpack this window if it's currently packed.
- */
-
- if (packPtr->masterPtr != NULL) {
- if ((packPtr->masterPtr != masterPtr) &&
- (packPtr->masterPtr->tkwin
- != Tk_Parent(packPtr->tkwin))) {
- Tk_UnmaintainGeometry(packPtr->tkwin,
- packPtr->masterPtr->tkwin);
- }
- Unlink(packPtr);
- }
-
- /*
- * Add the window in the correct place in its parent's
- * packing order, then make sure that the window is
- * managed by us.
- */
-
- packPtr->masterPtr = masterPtr;
- if (prevPtr == NULL) {
- packPtr->nextPtr = masterPtr->slavePtr;
- masterPtr->slavePtr = packPtr;
- } else {
- packPtr->nextPtr = prevPtr->nextPtr;
- prevPtr->nextPtr = packPtr;
- }
- Tk_ManageGeometry(tkwin, &packerType, (ClientData) packPtr);
- }
- ckfree((char *) options);
- }
-
- /*
- * Arrange for the parent to be re-packed at the first
- * idle moment.
- */
-
- if (masterPtr->abortPtr != NULL) {
- *masterPtr->abortPtr = 1;
- }
- if (!(masterPtr->flags & REQUESTED_REPACK)) {
- masterPtr->flags |= REQUESTED_REPACK;
- Tcl_DoWhenIdle(ArrangePacking, (ClientData) masterPtr);
- }
- return TCL_OK;
-
- error:
- ckfree((char *) options);
- return TCL_ERROR;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Unlink --
- *
- * Remove a packer from its parent's list of slaves.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The parent will be scheduled for repacking.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-Unlink(packPtr)
- register Packer *packPtr; /* Window to unlink. */
-{
- register Packer *masterPtr, *packPtr2;
-
- masterPtr = packPtr->masterPtr;
- if (masterPtr == NULL) {
- return;
- }
- if (masterPtr->slavePtr == packPtr) {
- masterPtr->slavePtr = packPtr->nextPtr;
- } else {
- for (packPtr2 = masterPtr->slavePtr; ; packPtr2 = packPtr2->nextPtr) {
- if (packPtr2 == NULL) {
- panic("Unlink couldn't find previous window");
- }
- if (packPtr2->nextPtr == packPtr) {
- packPtr2->nextPtr = packPtr->nextPtr;
- break;
- }
- }
- }
- if (!(masterPtr->flags & REQUESTED_REPACK)) {
- masterPtr->flags |= REQUESTED_REPACK;
- Tcl_DoWhenIdle(ArrangePacking, (ClientData) masterPtr);
- }
- if (masterPtr->abortPtr != NULL) {
- *masterPtr->abortPtr = 1;
- }
-
- packPtr->masterPtr = NULL;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * DestroyPacker --
- *
- * This procedure is invoked by Tcl_EventuallyFree or Tcl_Release
- * to clean up the internal structure of a packer at a safe time
- * (when no-one is using it anymore).
- *
- * Results:
- * None.
- *
- * Side effects:
- * Everything associated with the packer is freed up.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-DestroyPacker(memPtr)
- char *memPtr; /* Info about packed window that
- * is now dead. */
-{
- register Packer *packPtr = (Packer *) memPtr;
- ckfree((char *) packPtr);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * PackStructureProc --
- *
- * This procedure is invoked by the Tk event dispatcher in response
- * to StructureNotify events.
- *
- * Results:
- * None.
- *
- * Side effects:
- * If a window was just deleted, clean up all its packer-related
- * information. If it was just resized, repack its slaves, if
- * any.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-PackStructureProc(clientData, eventPtr)
- ClientData clientData; /* Our information about window
- * referred to by eventPtr. */
- XEvent *eventPtr; /* Describes what just happened. */
-{
- register Packer *packPtr = (Packer *) clientData;
- if (eventPtr->type == ConfigureNotify) {
- if ((packPtr->slavePtr != NULL)
- && !(packPtr->flags & REQUESTED_REPACK)) {
- packPtr->flags |= REQUESTED_REPACK;
- Tcl_DoWhenIdle(ArrangePacking, (ClientData) packPtr);
- }
- if (packPtr->doubleBw != 2*Tk_Changes(packPtr->tkwin)->border_width) {
- if ((packPtr->masterPtr != NULL)
- && !(packPtr->masterPtr->flags & REQUESTED_REPACK)) {
- packPtr->doubleBw = 2*Tk_Changes(packPtr->tkwin)->border_width;
- packPtr->masterPtr->flags |= REQUESTED_REPACK;
- Tcl_DoWhenIdle(ArrangePacking, (ClientData) packPtr->masterPtr);
- }
- }
- } else if (eventPtr->type == DestroyNotify) {
- register Packer *slavePtr, *nextPtr;
-
- if (packPtr->masterPtr != NULL) {
- Unlink(packPtr);
- }
- for (slavePtr = packPtr->slavePtr; slavePtr != NULL;
- slavePtr = nextPtr) {
- Tk_ManageGeometry(slavePtr->tkwin, (Tk_GeomMgr *) NULL,
- (ClientData) NULL);
- Tk_UnmapWindow(slavePtr->tkwin);
- slavePtr->masterPtr = NULL;
- nextPtr = slavePtr->nextPtr;
- slavePtr->nextPtr = NULL;
- }
- Tcl_DeleteHashEntry(Tcl_FindHashEntry(&packerHashTable,
- (char *) packPtr->tkwin));
- if (packPtr->flags & REQUESTED_REPACK) {
- Tcl_CancelIdleCall(ArrangePacking, (ClientData) packPtr);
- }
- packPtr->tkwin = NULL;
- Tcl_EventuallyFree((ClientData) packPtr, DestroyPacker);
- } else if (eventPtr->type == MapNotify) {
- /*
- * When a master gets mapped, must redo the geometry computation
- * so that all of its slaves get remapped.
- */
-
- if ((packPtr->slavePtr != NULL)
- && !(packPtr->flags & REQUESTED_REPACK)) {
- packPtr->flags |= REQUESTED_REPACK;
- Tcl_DoWhenIdle(ArrangePacking, (ClientData) packPtr);
- }
- } else if (eventPtr->type == UnmapNotify) {
- Packer *packPtr2;
-
- /*
- * Unmap all of the slaves when the master gets unmapped,
- * so that they don't bother to keep redisplaying
- * themselves.
- */
-
- for (packPtr2 = packPtr->slavePtr; packPtr2 != NULL;
- packPtr2 = packPtr2->nextPtr) {
- Tk_UnmapWindow(packPtr2->tkwin);
- }
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ConfigureSlaves --
- *
- * This implements the guts of the "pack configure" command. Given
- * a list of slaves and configuration options, it arranges for the
- * packer to manage the slaves and sets the specified options.
- *
- * Results:
- * TCL_OK is returned if all went well. Otherwise, TCL_ERROR is
- * returned and interp->result is set to contain an error message.
- *
- * Side effects:
- * Slave windows get taken over by the packer.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-ConfigureSlaves(interp, tkwin, argc, argv)
- 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
- * window names followed by any number
- * of "option value" pairs. Caller must
- * make sure that there is at least one
- * window name. */
-{
- Packer *masterPtr, *slavePtr, *prevPtr, *otherPtr;
- Tk_Window other, slave, parent, ancestor;
- int i, j, numWindows, c, tmp, positionGiven;
- size_t length;
-
- /*
- * Find out how many windows are specified.
- */
-
- for (numWindows = 0; numWindows < argc; numWindows++) {
- if (argv[numWindows][0] != '.') {
- break;
- }
- }
-
- /*
- * Iterate over all of the slave windows, parsing the configuration
- * options for each slave. It's a bit wasteful to re-parse the
- * options for each slave, but things get too messy if we try to
- * parse the arguments just once at the beginning. For example,
- * if a slave already is packed we want to just change a few
- * existing values without resetting everything. If there are
- * multiple windows, the -after, -before, and -in options only
- * get processed for the first window.
- */
-
- masterPtr = NULL;
- prevPtr = NULL;
- positionGiven = 0;
- for (j = 0; j < numWindows; j++) {
- slave = Tk_NameToWindow(interp, argv[j], tkwin);
- if (slave == NULL) {
- return TCL_ERROR;
- }
- if (Tk_IsTopLevel(slave)) {
- Tcl_AppendResult(interp, "can't pack \"", argv[j],
- "\": it's a top-level window", (char *) NULL);
- return TCL_ERROR;
- }
- slavePtr = GetPacker(slave);
- slavePtr->flags &= ~OLD_STYLE;
-
- /*
- * If the slave isn't currently packed, reset all of its
- * configuration information to default values (there could
- * be old values left from a previous packing).
- */
-
- if (slavePtr->masterPtr == NULL) {
- slavePtr->side = TOP;
- slavePtr->anchor = TK_ANCHOR_CENTER;
- slavePtr->padX = slavePtr->padY = 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],
- "\" (option with no value?)", (char *) NULL);
- return TCL_ERROR;
- }
- length = strlen(argv[i]);
- if (length < 2) {
- goto badOption;
- }
- c = argv[i][1];
- if ((c == 'a') && (strncmp(argv[i], "-after", length) == 0)
- && (length >= 2)) {
- if (j == 0) {
- other = Tk_NameToWindow(interp, argv[i+1], tkwin);
- if (other == NULL) {
- return TCL_ERROR;
- }
- prevPtr = GetPacker(other);
- if (prevPtr->masterPtr == NULL) {
- notPacked:
- Tcl_AppendResult(interp, "window \"", argv[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)
- != TCL_OK) {
- return TCL_ERROR;
- }
- } else if ((c == 'b')
- && (strncmp(argv[i], "-before", length) == 0)) {
- if (j == 0) {
- other = Tk_NameToWindow(interp, argv[i+1], tkwin);
- if (other == NULL) {
- return TCL_ERROR;
- }
- otherPtr = GetPacker(other);
- if (otherPtr->masterPtr == NULL) {
- goto notPacked;
- }
- masterPtr = otherPtr->masterPtr;
- prevPtr = masterPtr->slavePtr;
- if (prevPtr == otherPtr) {
- prevPtr = NULL;
- } else {
- while (prevPtr->nextPtr != otherPtr) {
- prevPtr = prevPtr->nextPtr;
- }
- }
- positionGiven = 1;
- }
- } else if ((c == 'e')
- && (strncmp(argv[i], "-expand", length) == 0)) {
- if (Tcl_GetBoolean(interp, argv[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) {
- slavePtr->flags &= ~(FILLX|FILLY);
- } else if (strcmp(argv[i+1], "x") == 0) {
- slavePtr->flags = (slavePtr->flags & ~FILLY) | FILLX;
- } else if (strcmp(argv[i+1], "y") == 0) {
- slavePtr->flags = (slavePtr->flags & ~FILLX) | FILLY;
- } else if (strcmp(argv[i+1], "both") == 0) {
- slavePtr->flags |= FILLX|FILLY;
- } else {
- Tcl_AppendResult(interp, "bad fill style \"", argv[i+1],
- "\": must be none, x, y, or both", (char *) NULL);
- return TCL_ERROR;
- }
- } else if ((c == 'i') && (strcmp(argv[i], "-in") == 0)) {
- if (j == 0) {
- other = Tk_NameToWindow(interp, argv[i+1], tkwin);
- if (other == NULL) {
- return TCL_ERROR;
- }
- masterPtr = GetPacker(other);
- prevPtr = masterPtr->slavePtr;
- if (prevPtr != NULL) {
- while (prevPtr->nextPtr != NULL) {
- prevPtr = prevPtr->nextPtr;
- }
- }
- positionGiven = 1;
- }
- } else if ((c == 'i') && (strcmp(argv[i], "-ipadx") == 0)) {
- if ((Tk_GetPixels(interp, slave, argv[i+1], &tmp) != TCL_OK)
- || (tmp < 0)) {
- badPad:
- Tcl_ResetResult(interp);
- Tcl_AppendResult(interp, "bad pad value \"", argv[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->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->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;
- }
- 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);
- 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;
- }
- }
-
- /*
- * If no position in a packing list was specified and the slave
- * is already packed, then leave it in its current location in
- * its current packing list.
- */
-
- if (!positionGiven && (slavePtr->masterPtr != NULL)) {
- masterPtr = slavePtr->masterPtr;
- goto scheduleLayout;
- }
-
- /*
- * If the slave is going to be put back after itself then
- * skip the whole operation, since it won't work anyway.
- */
-
- if (prevPtr == slavePtr) {
- masterPtr = slavePtr->masterPtr;
- goto scheduleLayout;
- }
-
- /*
- * If none of the "-in", "-before", or "-after" options has
- * been specified, arrange for the slave to go at the end of
- * the order for its parent.
- */
-
- if (!positionGiven) {
- masterPtr = GetPacker(Tk_Parent(slave));
- prevPtr = masterPtr->slavePtr;
- if (prevPtr != NULL) {
- while (prevPtr->nextPtr != NULL) {
- prevPtr = prevPtr->nextPtr;
- }
- }
- }
-
- /*
- * Make sure that the slave's parent is either the master or
- * an ancestor of the master, and that the master and slave
- * aren't the same.
- */
-
- parent = Tk_Parent(slave);
- for (ancestor = masterPtr->tkwin; ; ancestor = Tk_Parent(ancestor)) {
- if (ancestor == parent) {
- break;
- }
- if (Tk_IsTopLevel(ancestor)) {
- Tcl_AppendResult(interp, "can't pack ", argv[j],
- " inside ", Tk_PathName(masterPtr->tkwin),
- (char *) NULL);
- return TCL_ERROR;
- }
- }
- if (slave == masterPtr->tkwin) {
- Tcl_AppendResult(interp, "can't pack ", argv[j],
- " inside itself", (char *) NULL);
- return TCL_ERROR;
- }
-
- /*
- * Unpack the slave if it's currently packed, then position it
- * after prevPtr.
- */
-
- if (slavePtr->masterPtr != NULL) {
- if ((slavePtr->masterPtr != masterPtr) &&
- (slavePtr->masterPtr->tkwin
- != Tk_Parent(slavePtr->tkwin))) {
- Tk_UnmaintainGeometry(slavePtr->tkwin,
- slavePtr->masterPtr->tkwin);
- }
- Unlink(slavePtr);
- }
- slavePtr->masterPtr = masterPtr;
- if (prevPtr == NULL) {
- slavePtr->nextPtr = masterPtr->slavePtr;
- masterPtr->slavePtr = slavePtr;
- } else {
- slavePtr->nextPtr = prevPtr->nextPtr;
- prevPtr->nextPtr = slavePtr;
- }
- Tk_ManageGeometry(slave, &packerType, (ClientData) slavePtr);
- prevPtr = slavePtr;
-
- /*
- * Arrange for the parent to be re-packed at the first
- * idle moment.
- */
-
- scheduleLayout:
- if (masterPtr->abortPtr != NULL) {
- *masterPtr->abortPtr = 1;
- }
- if (!(masterPtr->flags & REQUESTED_REPACK)) {
- masterPtr->flags |= REQUESTED_REPACK;
- Tcl_DoWhenIdle(ArrangePacking, (ClientData) masterPtr);
- }
- }
- return TCL_OK;
-}
diff --git a/generic/tkPlace.c b/generic/tkPlace.c
deleted file mode 100644
index 4e3784d..0000000
--- a/generic/tkPlace.c
+++ /dev/null
@@ -1,1060 +0,0 @@
-/*
- * tkPlace.c --
- *
- * This file contains code to implement a simple geometry manager
- * for Tk based on absolute placement or "rubber-sheet" placement.
- *
- * Copyright (c) 1992-1994 The Regents of the University of California.
- * Copyright (c) 1994-1995 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: tkPlace.c,v 1.2 1998/09/14 18:23:15 stanton Exp $
- */
-
-#include "tkPort.h"
-#include "tkInt.h"
-
-/*
- * Border modes for relative placement:
- *
- * BM_INSIDE: relative distances computed using area inside
- * all borders of master window.
- * BM_OUTSIDE: relative distances computed using outside area
- * that includes all borders of master.
- * BM_IGNORE: border issues are ignored: place relative to
- * master's actual window size.
- */
-
-typedef enum {BM_INSIDE, BM_OUTSIDE, BM_IGNORE} BorderMode;
-
-/*
- * For each window whose geometry is managed by the placer there is
- * a structure of the following type:
- */
-
-typedef struct Slave {
- Tk_Window tkwin; /* Tk's token for window. */
- struct Master *masterPtr; /* Pointer to information for window
- * relative to which tkwin is placed.
- * This isn't necessarily the logical
- * parent of tkwin. NULL means the
- * 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
- * one of them is actually used, depending on flags.
- */
-
- int x, y; /* X and Y pixel coordinates for tkwin. */
- float 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
- * master. */
- Tk_Anchor anchor; /* Which point on tkwin is placed at the
- * given position. */
- BorderMode borderMode; /* How to treat borders of master window. */
- int flags; /* Various flags; see below for bit
- * definitions. */
-} Slave;
-
-/*
- * Flag definitions for Slave structures:
- *
- * CHILD_WIDTH - 1 means -width was specified;
- * CHILD_REL_WIDTH - 1 means -relwidth was specified.
- * CHILD_HEIGHT - 1 means -height was specified;
- * CHILD_REL_HEIGHT - 1 means -relheight was specified.
- */
-
-#define CHILD_WIDTH 1
-#define CHILD_REL_WIDTH 2
-#define CHILD_HEIGHT 4
-#define CHILD_REL_HEIGHT 8
-
-/*
- * For each master window that has a slave managed by the placer there
- * is a structure of the following form:
- */
-
-typedef struct Master {
- Tk_Window tkwin; /* Tk's token for master window. */
- struct Slave *slavePtr; /* First in linked list of slaves
- * placed relative to this master. */
- int flags; /* See below for bit definitions. */
-} Master;
-
-/*
- * Flag definitions for masters:
- *
- * PARENT_RECONFIG_PENDING - 1 means that a call to RecomputePlacement
- * is already pending via a Do_When_Idle handler.
- */
-
-#define PARENT_RECONFIG_PENDING 1
-
-/*
- * The hash tables below both use Tk_Window tokens as keys. They map
- * from Tk_Windows to Slave and Master structures for windows, if they
- * exist.
- */
-
-static int initialized = 0;
-static Tcl_HashTable masterTable;
-static Tcl_HashTable slaveTable;
-/*
- * The following structure is the official type record for the
- * placer:
- */
-
-static void PlaceRequestProc _ANSI_ARGS_((ClientData clientData,
- Tk_Window tkwin));
-static void PlaceLostSlaveProc _ANSI_ARGS_((ClientData clientData,
- Tk_Window tkwin));
-
-static Tk_GeomMgr placerType = {
- "place", /* name */
- PlaceRequestProc, /* requestProc */
- PlaceLostSlaveProc, /* lostSlaveProc */
-};
-
-/*
- * Forward declarations for procedures defined later in this file:
- */
-
-static void SlaveStructureProc _ANSI_ARGS_((ClientData clientData,
- XEvent *eventPtr));
-static int ConfigureSlave _ANSI_ARGS_((Tcl_Interp *interp,
- Slave *slavePtr, int argc, char **argv));
-static Slave * FindSlave _ANSI_ARGS_((Tk_Window tkwin));
-static Master * FindMaster _ANSI_ARGS_((Tk_Window tkwin));
-static void MasterStructureProc _ANSI_ARGS_((ClientData clientData,
- XEvent *eventPtr));
-static void RecomputePlacement _ANSI_ARGS_((ClientData clientData));
-static void UnlinkSlave _ANSI_ARGS_((Slave *slavePtr));
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_PlaceCmd --
- *
- * This procedure is invoked to process the "place" Tcl
- * commands. See the user documentation for details on
- * what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *--------------------------------------------------------------
- */
-
-int
-Tk_PlaceCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Main window associated with interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- Tk_Window tkwin;
- Slave *slavePtr;
- Tcl_HashEntry *hPtr;
- size_t length;
- int c;
-
- /*
- * Initialize, if that hasn't been done yet.
- */
-
- if (!initialized) {
- Tcl_InitHashTable(&masterTable, TCL_ONE_WORD_KEYS);
- Tcl_InitHashTable(&slaveTable, TCL_ONE_WORD_KEYS);
- initialized = 1;
- }
-
- if (argc < 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " option|pathName args", (char *) NULL);
- return TCL_ERROR;
- }
- c = argv[1][0];
- length = strlen(argv[1]);
-
- /*
- * Handle special shortcut where window name is first argument.
- */
-
- if (c == '.') {
- tkwin = Tk_NameToWindow(interp, argv[1], (Tk_Window) clientData);
- if (tkwin == NULL) {
- return TCL_ERROR;
- }
- slavePtr = FindSlave(tkwin);
- return ConfigureSlave(interp, slavePtr, argc-2, argv+2);
- }
-
- /*
- * Handle more general case of option followed by window name followed
- * by possible additional arguments.
- */
-
- tkwin = Tk_NameToWindow(interp, argv[2], (Tk_Window) clientData);
- if (tkwin == NULL) {
- return TCL_ERROR;
- }
- 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(&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[50];
-
- if (argc != 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " info pathName\"", (char *) NULL);
- return TCL_ERROR;
- }
- hPtr = Tcl_FindHashEntry(&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);
- }
- 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);
- }
- } 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(&masterTable, (char *) tkwin);
- if (hPtr != NULL) {
- Master *masterPtr;
- masterPtr = (Master *) Tcl_GetHashValue(hPtr);
- for (slavePtr = masterPtr->slavePtr; slavePtr != NULL;
- slavePtr = slavePtr->nextPtr) {
- Tcl_AppendElement(interp, Tk_PathName(slavePtr->tkwin));
- }
- }
- } 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 --
- *
- * Given a Tk_Window token, find the Slave structure corresponding
- * to that token (making a new one if necessary).
- *
- * Results:
- * None.
- *
- * Side effects:
- * A new Slave structure may be created.
- *
- *----------------------------------------------------------------------
- */
-
-static Slave *
-FindSlave(tkwin)
- Tk_Window tkwin; /* Token for desired slave. */
-{
- Tcl_HashEntry *hPtr;
- register Slave *slavePtr;
- int new;
-
- hPtr = Tcl_CreateHashEntry(&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;
- Tcl_SetHashValue(hPtr, slavePtr);
- Tk_CreateEventHandler(tkwin, StructureNotifyMask, SlaveStructureProc,
- (ClientData) slavePtr);
- Tk_ManageGeometry(tkwin, &placerType, (ClientData) slavePtr);
- } else {
- slavePtr = (Slave *) Tcl_GetHashValue(hPtr);
- }
- return slavePtr;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * UnlinkSlave --
- *
- * This procedure removes a slave window from the chain of slaves
- * in its master.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The slave list of slavePtr's master changes.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-UnlinkSlave(slavePtr)
- Slave *slavePtr; /* Slave structure to be unlinked. */
-{
- register Master *masterPtr;
- register Slave *prevPtr;
-
- masterPtr = slavePtr->masterPtr;
- if (masterPtr == NULL) {
- return;
- }
- if (masterPtr->slavePtr == slavePtr) {
- masterPtr->slavePtr = slavePtr->nextPtr;
- } else {
- for (prevPtr = masterPtr->slavePtr; ;
- prevPtr = prevPtr->nextPtr) {
- if (prevPtr == NULL) {
- panic("UnlinkSlave couldn't find slave to unlink");
- }
- if (prevPtr->nextPtr == slavePtr) {
- prevPtr->nextPtr = slavePtr->nextPtr;
- break;
- }
- }
- }
- slavePtr->masterPtr = NULL;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * FindMaster --
- *
- * Given a Tk_Window token, find the Master structure corresponding
- * to that token (making a new one if necessary).
- *
- * Results:
- * None.
- *
- * Side effects:
- * A new Master structure may be created.
- *
- *----------------------------------------------------------------------
- */
-
-static Master *
-FindMaster(tkwin)
- Tk_Window tkwin; /* Token for desired master. */
-{
- Tcl_HashEntry *hPtr;
- register Master *masterPtr;
- int new;
-
- hPtr = Tcl_CreateHashEntry(&masterTable, (char *) tkwin, &new);
- if (new) {
- masterPtr = (Master *) ckalloc(sizeof(Master));
- masterPtr->tkwin = tkwin;
- masterPtr->slavePtr = NULL;
- masterPtr->flags = 0;
- Tcl_SetHashValue(hPtr, masterPtr);
- Tk_CreateEventHandler(masterPtr->tkwin, StructureNotifyMask,
- MasterStructureProc, (ClientData) masterPtr);
- } else {
- masterPtr = (Master *) Tcl_GetHashValue(hPtr);
- }
- return masterPtr;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ConfigureSlave --
- *
- * This procedure is called to process an argv/argc list to
- * reconfigure the placement of a window.
- *
- * Results:
- * A standard Tcl result. If an error occurs then a message is
- * left in interp->result.
- *
- * Side effects:
- * Information in slavePtr may change, and slavePtr's master is
- * scheduled for reconfiguration.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-ConfigureSlave(interp, slavePtr, argc, argv)
- 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. */
-{
- register Master *masterPtr;
- int c, result;
- size_t length;
- double d;
-
- result = TCL_OK;
- if (Tk_IsTopLevel(slavePtr->tkwin)) {
- Tcl_AppendResult(interp, "can't use placer on top-level window \"",
- Tk_PathName(slavePtr->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.
- */
-
- 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 (slavePtr->tkwin == tkwin) {
- 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) {
- result = TCL_ERROR;
- 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);
- result = TCL_ERROR;
- goto done;
- }
- }
-
- /*
- * If there's no master specified for this slave, use its Tk_Parent.
- * Then arrange for a placement recalculation in the master.
- */
-
- done:
- masterPtr = slavePtr->masterPtr;
- if (masterPtr == NULL) {
- masterPtr = FindMaster(Tk_Parent(slavePtr->tkwin));
- slavePtr->masterPtr = masterPtr;
- slavePtr->nextPtr = masterPtr->slavePtr;
- masterPtr->slavePtr = slavePtr;
- }
- if (!(masterPtr->flags & PARENT_RECONFIG_PENDING)) {
- masterPtr->flags |= PARENT_RECONFIG_PENDING;
- Tcl_DoWhenIdle(RecomputePlacement, (ClientData) masterPtr);
- }
- return result;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * RecomputePlacement --
- *
- * This procedure is called as a when-idle handler. It recomputes
- * the geometries of all the slaves of a given master.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Windows may change size or shape.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-RecomputePlacement(clientData)
- ClientData clientData; /* Pointer to Master record. */
-{
- register Master *masterPtr = (Master *) clientData;
- register Slave *slavePtr;
- int x, y, width, height, tmp;
- int masterWidth, masterHeight, masterBW;
- double x1, y1, x2, y2;
-
- masterPtr->flags &= ~PARENT_RECONFIG_PENDING;
-
- /*
- * Iterate over all the slaves for the master. Each slave's
- * geometry can be computed independently of the other slaves.
- */
-
- for (slavePtr = masterPtr->slavePtr; slavePtr != NULL;
- slavePtr = slavePtr->nextPtr) {
- /*
- * Step 1: compute size and borderwidth of master, taking into
- * account desired border mode.
- */
-
- masterBW = 0;
- masterWidth = Tk_Width(masterPtr->tkwin);
- masterHeight = Tk_Height(masterPtr->tkwin);
- if (slavePtr->borderMode == BM_INSIDE) {
- masterBW = Tk_InternalBorderWidth(masterPtr->tkwin);
- } else if (slavePtr->borderMode == BM_OUTSIDE) {
- masterBW = -Tk_Changes(masterPtr->tkwin)->border_width;
- }
- 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);
- x = (int) (x1 + ((x1 > 0) ? 0.5 : -0.5));
- y1 = slavePtr->y + masterBW + (slavePtr->relY*masterHeight);
- y = (int) (y1 + ((y1 > 0) ? 0.5 : -0.5));
- if (slavePtr->flags & (CHILD_WIDTH|CHILD_REL_WIDTH)) {
- width = 0;
- if (slavePtr->flags & CHILD_WIDTH) {
- width += slavePtr->width;
- }
- if (slavePtr->flags & CHILD_REL_WIDTH) {
- /*
- * The code below is a bit tricky. In order to round
- * correctly when both relX and relWidth are specified,
- * compute the location of the right edge and round that,
- * then compute width. If we compute the width and round
- * it, rounding errors in relX and relWidth accumulate.
- */
-
- x2 = x1 + (slavePtr->relWidth*masterWidth);
- tmp = (int) (x2 + ((x2 > 0) ? 0.5 : -0.5));
- width += tmp - x;
- }
- } else {
- width = Tk_ReqWidth(slavePtr->tkwin)
- + 2*Tk_Changes(slavePtr->tkwin)->border_width;
- }
- if (slavePtr->flags & (CHILD_HEIGHT|CHILD_REL_HEIGHT)) {
- height = 0;
- if (slavePtr->flags & CHILD_HEIGHT) {
- height += slavePtr->height;
- }
- if (slavePtr->flags & CHILD_REL_HEIGHT) {
- /*
- * See note above for rounding errors in width computation.
- */
-
- y2 = y1 + (slavePtr->relHeight*masterHeight);
- tmp = (int) (y2 + ((y2 > 0) ? 0.5 : -0.5));
- height += tmp - y;
- }
- } else {
- height = Tk_ReqHeight(slavePtr->tkwin)
- + 2*Tk_Changes(slavePtr->tkwin)->border_width;
- }
-
- /*
- * Step 3: adjust the x and y positions so that the desired
- * anchor point on the slave appears at that position. Also
- * adjust for the border mode and master's border.
- */
-
- switch (slavePtr->anchor) {
- case TK_ANCHOR_N:
- x -= width/2;
- break;
- case TK_ANCHOR_NE:
- x -= width;
- break;
- case TK_ANCHOR_E:
- x -= width;
- y -= height/2;
- break;
- case TK_ANCHOR_SE:
- x -= width;
- y -= height;
- break;
- case TK_ANCHOR_S:
- x -= width/2;
- y -= height;
- break;
- case TK_ANCHOR_SW:
- y -= height;
- break;
- case TK_ANCHOR_W:
- y -= height/2;
- break;
- case TK_ANCHOR_NW:
- break;
- case TK_ANCHOR_CENTER:
- x -= width/2;
- y -= height/2;
- break;
- }
-
- /*
- * Step 4: adjust width and height again to reflect inside dimensions
- * of window rather than outside. Also make sure that the width and
- * height aren't zero.
- */
-
- width -= 2*Tk_Changes(slavePtr->tkwin)->border_width;
- height -= 2*Tk_Changes(slavePtr->tkwin)->border_width;
- if (width <= 0) {
- width = 1;
- }
- if (height <= 0) {
- height = 1;
- }
-
- /*
- * Step 5: reconfigure the window and map it if needed. If the
- * slave is a child of the master, we do this ourselves. If the
- * slave isn't a child of the master, let Tk_MaintainWindow do
- * the work (it will re-adjust things as relevant windows map,
- * unmap, and move).
- */
-
- if (masterPtr->tkwin == Tk_Parent(slavePtr->tkwin)) {
- if ((x != Tk_X(slavePtr->tkwin))
- || (y != Tk_Y(slavePtr->tkwin))
- || (width != Tk_Width(slavePtr->tkwin))
- || (height != Tk_Height(slavePtr->tkwin))) {
- Tk_MoveResizeWindow(slavePtr->tkwin, x, y, width, height);
- }
-
- /*
- * Don't map the slave unless the master is mapped: the slave
- * will get mapped later, when the master is mapped.
- */
-
- if (Tk_IsMapped(masterPtr->tkwin)) {
- Tk_MapWindow(slavePtr->tkwin);
- }
- } else {
- if ((width <= 0) || (height <= 0)) {
- Tk_UnmaintainGeometry(slavePtr->tkwin, masterPtr->tkwin);
- Tk_UnmapWindow(slavePtr->tkwin);
- } else {
- Tk_MaintainGeometry(slavePtr->tkwin, masterPtr->tkwin,
- x, y, width, height);
- }
- }
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * MasterStructureProc --
- *
- * This procedure is invoked by the Tk event handler when
- * StructureNotify events occur for a master window.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Structures get cleaned up if the window was deleted. If the
- * window was resized then slave geometries get recomputed.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-MasterStructureProc(clientData, eventPtr)
- ClientData clientData; /* Pointer to Master structure for window
- * referred to by eventPtr. */
- XEvent *eventPtr; /* Describes what just happened. */
-{
- register Master *masterPtr = (Master *) clientData;
- register Slave *slavePtr, *nextPtr;
-
- if (eventPtr->type == ConfigureNotify) {
- if ((masterPtr->slavePtr != NULL)
- && !(masterPtr->flags & PARENT_RECONFIG_PENDING)) {
- masterPtr->flags |= PARENT_RECONFIG_PENDING;
- Tcl_DoWhenIdle(RecomputePlacement, (ClientData) masterPtr);
- }
- } else if (eventPtr->type == DestroyNotify) {
- for (slavePtr = masterPtr->slavePtr; slavePtr != NULL;
- slavePtr = nextPtr) {
- slavePtr->masterPtr = NULL;
- nextPtr = slavePtr->nextPtr;
- slavePtr->nextPtr = NULL;
- }
- Tcl_DeleteHashEntry(Tcl_FindHashEntry(&masterTable,
- (char *) masterPtr->tkwin));
- if (masterPtr->flags & PARENT_RECONFIG_PENDING) {
- Tcl_CancelIdleCall(RecomputePlacement, (ClientData) masterPtr);
- }
- masterPtr->tkwin = NULL;
- ckfree((char *) masterPtr);
- } else if (eventPtr->type == MapNotify) {
- /*
- * When a master gets mapped, must redo the geometry computation
- * so that all of its slaves get remapped.
- */
-
- if ((masterPtr->slavePtr != NULL)
- && !(masterPtr->flags & PARENT_RECONFIG_PENDING)) {
- masterPtr->flags |= PARENT_RECONFIG_PENDING;
- Tcl_DoWhenIdle(RecomputePlacement, (ClientData) masterPtr);
- }
- } else if (eventPtr->type == UnmapNotify) {
- /*
- * Unmap all of the slaves when the master gets unmapped,
- * so that they don't keep redisplaying themselves.
- */
-
- for (slavePtr = masterPtr->slavePtr; slavePtr != NULL;
- slavePtr = slavePtr->nextPtr) {
- Tk_UnmapWindow(slavePtr->tkwin);
- }
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * SlaveStructureProc --
- *
- * This procedure is invoked by the Tk event handler when
- * StructureNotify events occur for a slave window.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Structures get cleaned up if the window was deleted.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-SlaveStructureProc(clientData, eventPtr)
- ClientData clientData; /* Pointer to Slave structure for window
- * referred to by eventPtr. */
- XEvent *eventPtr; /* Describes what just happened. */
-{
- register Slave *slavePtr = (Slave *) clientData;
-
- if (eventPtr->type == DestroyNotify) {
- UnlinkSlave(slavePtr);
- Tcl_DeleteHashEntry(Tcl_FindHashEntry(&slaveTable,
- (char *) slavePtr->tkwin));
- ckfree((char *) slavePtr);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * PlaceRequestProc --
- *
- * This procedure is invoked by Tk whenever a slave managed by us
- * changes its requested geometry.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The window will get relayed out, if its requested size has
- * anything to do with its actual size.
- *
- *----------------------------------------------------------------------
- */
-
- /* ARGSUSED */
-static void
-PlaceRequestProc(clientData, tkwin)
- ClientData clientData; /* Pointer to our record for slave. */
- Tk_Window tkwin; /* Window that changed its desired
- * size. */
-{
- Slave *slavePtr = (Slave *) clientData;
- Master *masterPtr;
-
- if (((slavePtr->flags & (CHILD_WIDTH|CHILD_REL_WIDTH)) != 0)
- && ((slavePtr->flags & (CHILD_HEIGHT|CHILD_REL_HEIGHT)) != 0)) {
- return;
- }
- masterPtr = slavePtr->masterPtr;
- if (masterPtr == NULL) {
- return;
- }
- if (!(masterPtr->flags & PARENT_RECONFIG_PENDING)) {
- masterPtr->flags |= PARENT_RECONFIG_PENDING;
- Tcl_DoWhenIdle(RecomputePlacement, (ClientData) masterPtr);
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * PlaceLostSlaveProc --
- *
- * 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 placer-related information about the slave.
- *
- *--------------------------------------------------------------
- */
-
- /* ARGSUSED */
-static void
-PlaceLostSlaveProc(clientData, tkwin)
- ClientData clientData; /* Slave structure for slave window that
- * was stolen away. */
- Tk_Window tkwin; /* Tk's handle for the slave window. */
-{
- register Slave *slavePtr = (Slave *) clientData;
-
- if (slavePtr->masterPtr->tkwin != Tk_Parent(slavePtr->tkwin)) {
- Tk_UnmaintainGeometry(slavePtr->tkwin, slavePtr->masterPtr->tkwin);
- }
- Tk_UnmapWindow(tkwin);
- UnlinkSlave(slavePtr);
- Tcl_DeleteHashEntry(Tcl_FindHashEntry(&slaveTable, (char *) tkwin));
- Tk_DeleteEventHandler(tkwin, StructureNotifyMask, SlaveStructureProc,
- (ClientData) slavePtr);
- ckfree((char *) slavePtr);
-}
diff --git a/generic/tkPointer.c b/generic/tkPointer.c
deleted file mode 100644
index 1817914..0000000
--- a/generic/tkPointer.c
+++ /dev/null
@@ -1,623 +0,0 @@
-/*
- * tkPointer.c --
- *
- * This file contains functions for emulating the X server
- * pointer and grab state machine. This file is used by the
- * Mac and Windows platforms to generate appropriate enter/leave
- * events, and to update the global grab window information.
- *
- * Copyright (c) 1996 by 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: tkPointer.c,v 1.2 1998/09/14 18:23:16 stanton Exp $
- */
-
-#include "tkInt.h"
-
-#ifdef MAC_TCL
-#define Cursor XCursor
-#endif
-
-/*
- * Mask that selects any of the state bits corresponding to buttons,
- * plus masks that select individual buttons' bits:
- */
-
-#define ALL_BUTTONS \
- (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask)
-static unsigned int buttonMasks[] = {
- Button1Mask, Button2Mask, Button3Mask, Button4Mask, Button5Mask
-};
-#define ButtonMask(b) (buttonMasks[(b)-Button1])
-
-/*
- * Declarations of static variables used in the pointer module.
- */
-
-static TkWindow *cursorWinPtr = NULL; /* Window that is currently
- * controlling the global cursor. */
-static TkWindow *grabWinPtr = NULL; /* Window that defines the top of the
- * grab tree in a global grab. */
-static XPoint lastPos = { 0, 0}; /* Last reported mouse position. */
-static int lastState = 0; /* Last known state flags. */
-static TkWindow *lastWinPtr = NULL; /* Last reported mouse window. */
-static TkWindow *restrictWinPtr = NULL; /* Window to which all mouse events
- * will be reported. */
-
-/*
- * Forward declarations of procedures used in this file.
- */
-
-static int GenerateEnterLeave _ANSI_ARGS_((TkWindow *winPtr,
- int x, int y, int state));
-static void InitializeEvent _ANSI_ARGS_((XEvent* eventPtr,
- TkWindow *winPtr, int type, int x, int y,
- int state, int detail));
-static void UpdateCursor _ANSI_ARGS_((TkWindow *winPtr));
-
-/*
- *----------------------------------------------------------------------
- *
- * InitializeEvent --
- *
- * Initializes the common fields for several X events.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Fills in the specified event structure.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-InitializeEvent(eventPtr, winPtr, type, x, y, state, detail)
- XEvent* eventPtr; /* Event structure to initialize. */
- TkWindow *winPtr; /* Window to make event relative to. */
- int type; /* Message type. */
- int x, y; /* Root coords of event. */
- int state; /* State flags. */
- int detail; /* Detail value. */
-{
- eventPtr->type = type;
- eventPtr->xany.serial = LastKnownRequestProcessed(winPtr->display);
- eventPtr->xany.send_event = False;
- eventPtr->xany.display = winPtr->display;
-
- eventPtr->xcrossing.root = RootWindow(winPtr->display, winPtr->screenNum);
- eventPtr->xcrossing.time = TkpGetMS();
- eventPtr->xcrossing.x_root = x;
- eventPtr->xcrossing.y_root = y;
-
- switch (type) {
- case EnterNotify:
- case LeaveNotify:
- eventPtr->xcrossing.mode = NotifyNormal;
- eventPtr->xcrossing.state = state;
- eventPtr->xcrossing.detail = detail;
- eventPtr->xcrossing.focus = False;
- break;
- case MotionNotify:
- eventPtr->xmotion.state = state;
- eventPtr->xmotion.is_hint = detail;
- break;
- case ButtonPress:
- case ButtonRelease:
- eventPtr->xbutton.state = state;
- eventPtr->xbutton.button = detail;
- break;
- }
- TkChangeEventWindow(eventPtr, winPtr);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * GenerateEnterLeave --
- *
- * Update the current mouse window and position, and generate
- * any enter/leave events that are needed.
- *
- * Results:
- * Returns 1 if enter/leave events were generated.
- *
- * Side effects:
- * May insert events into the Tk event queue.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-GenerateEnterLeave(winPtr, x, y, state)
- TkWindow *winPtr; /* Current Tk window (or NULL). */
- int x,y; /* Current mouse position in root coords. */
- int state; /* State flags. */
-{
- int crossed = 0; /* 1 if mouse crossed a window boundary */
-
- if (winPtr != lastWinPtr) {
- if (restrictWinPtr) {
- int newPos, oldPos;
-
- newPos = TkPositionInTree(winPtr, restrictWinPtr);
- oldPos = TkPositionInTree(lastWinPtr, restrictWinPtr);
-
- /*
- * Check if the mouse crossed into or out of the restrict
- * window. If so, we need to generate an Enter or Leave event.
- */
-
- if ((newPos != oldPos) && ((newPos == TK_GRAB_IN_TREE)
- || (oldPos == TK_GRAB_IN_TREE))) {
- XEvent event;
- int type, detail;
-
- if (newPos == TK_GRAB_IN_TREE) {
- type = EnterNotify;
- } else {
- type = LeaveNotify;
- }
- if ((oldPos == TK_GRAB_ANCESTOR)
- || (newPos == TK_GRAB_ANCESTOR)) {
- detail = NotifyAncestor;
- } else {
- detail = NotifyVirtual;
- }
- InitializeEvent(&event, restrictWinPtr, type, x, y,
- state, detail);
- Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
- }
-
- } else {
- TkWindow *targetPtr;
-
- if ((lastWinPtr == NULL)
- || (lastWinPtr->window == None)) {
- targetPtr = winPtr;
- } else {
- targetPtr = lastWinPtr;
- }
-
- if (targetPtr && (targetPtr->window != None)) {
- XEvent event;
-
- /*
- * Generate appropriate Enter/Leave events.
- */
-
- InitializeEvent(&event, targetPtr, LeaveNotify, x, y, state,
- NotifyNormal);
-
- TkInOutEvents(&event, lastWinPtr, winPtr, LeaveNotify,
- EnterNotify, TCL_QUEUE_TAIL);
- crossed = 1;
- }
- }
- lastWinPtr = winPtr;
- }
-
- return crossed;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_UpdatePointer --
- *
- * This function updates the pointer state machine given an
- * the current window, position and modifier state.
- *
- * Results:
- * None.
- *
- * Side effects:
- * May queue new events and update the grab state.
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tk_UpdatePointer(tkwin, x, y, state)
- Tk_Window tkwin; /* Window to which pointer event
- * is reported. May be NULL. */
- int x, y; /* Pointer location in root coords. */
- int state; /* Modifier state mask. */
-{
- TkWindow *winPtr = (TkWindow *)tkwin;
- TkWindow *targetWinPtr;
- XPoint pos;
- XEvent event;
- int changes = (state ^ lastState) & ALL_BUTTONS;
- int type, b, mask;
-
- pos.x = x;
- pos.y = y;
-
- /*
- * Use the current keyboard state, but the old mouse button
- * state since we haven't generated the button events yet.
- */
-
- lastState = (state & ~ALL_BUTTONS) | (lastState & ALL_BUTTONS);
-
- /*
- * Generate Enter/Leave events. If the pointer has crossed window
- * boundaries, update the current mouse position so we don't generate
- * redundant motion events.
- */
-
- if (GenerateEnterLeave(winPtr, x, y, lastState)) {
- lastPos = pos;
- }
-
- /*
- * Generate ButtonPress/ButtonRelease events based on the differences
- * between the current button state and the last known button state.
- */
-
- for (b = Button1; b <= Button3; b++) {
- mask = ButtonMask(b);
- if (changes & mask) {
- if (state & mask) {
- type = ButtonPress;
-
- /*
- * ButtonPress - Set restrict window if we aren't grabbed, or
- * if this is the first button down.
- */
-
- if (!restrictWinPtr) {
- if (!grabWinPtr) {
-
- /*
- * Mouse is not grabbed, so set a button grab.
- */
-
- restrictWinPtr = winPtr;
- TkpSetCapture(restrictWinPtr);
-
- } else if ((lastState & ALL_BUTTONS) == 0) {
-
- /*
- * Mouse is in a non-button grab, so ensure
- * the button grab is inside the grab tree.
- */
-
- if (TkPositionInTree(winPtr, grabWinPtr)
- == TK_GRAB_IN_TREE) {
- restrictWinPtr = winPtr;
- } else {
- restrictWinPtr = grabWinPtr;
- }
- TkpSetCapture(restrictWinPtr);
- }
- }
-
- } else {
- type = ButtonRelease;
-
- /*
- * ButtonRelease - Release the mouse capture and clear the
- * restrict window when the last button is released and we
- * aren't in a global grab.
- */
-
- if ((lastState & ALL_BUTTONS) == mask) {
- if (!grabWinPtr) {
- TkpSetCapture(NULL);
- }
- }
-
- /*
- * If we are releasing a restrict window, then we need
- * to send the button event followed by mouse motion from
- * the restrict window to the current mouse position.
- */
-
- if (restrictWinPtr) {
- InitializeEvent(&event, restrictWinPtr, type, x, y,
- lastState, b);
- Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
- lastState &= ~mask;
- lastWinPtr = restrictWinPtr;
- restrictWinPtr = NULL;
-
- GenerateEnterLeave(winPtr, x, y, lastState);
- lastPos = pos;
- continue;
- }
- }
-
- /*
- * If a restrict window is set, make sure the pointer event
- * is reported relative to that window. Otherwise, if a
- * global grab is in effect then events outside of windows
- * managed by Tk should be reported to the grab window.
- */
-
- if (restrictWinPtr) {
- targetWinPtr = restrictWinPtr;
- } else if (grabWinPtr && !winPtr) {
- targetWinPtr = grabWinPtr;
- } else {
- targetWinPtr = winPtr;
- }
-
- /*
- * If we still have a target window, send the event.
- */
-
- if (winPtr != NULL) {
- InitializeEvent(&event, targetWinPtr, type, x, y,
- lastState, b);
- Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
- }
-
- /*
- * Update the state for the next iteration.
- */
-
- lastState = (type == ButtonPress)
- ? (lastState | mask) : (lastState & ~mask);
- lastPos = pos;
- }
- }
-
- /*
- * Make sure the cursor window is up to date.
- */
-
- if (restrictWinPtr) {
- targetWinPtr = restrictWinPtr;
- } else if (grabWinPtr) {
- targetWinPtr = (TkPositionInTree(winPtr, grabWinPtr)
- == TK_GRAB_IN_TREE) ? winPtr : grabWinPtr;
- } else {
- targetWinPtr = winPtr;
- }
- UpdateCursor(targetWinPtr);
-
- /*
- * If no other events caused the position to be updated,
- * generate a motion event.
- */
-
- if (lastPos.x != pos.x || lastPos.y != pos.y) {
- if (restrictWinPtr) {
- targetWinPtr = restrictWinPtr;
- } else if (grabWinPtr && !winPtr) {
- targetWinPtr = grabWinPtr;
- }
-
- if (targetWinPtr != NULL) {
- InitializeEvent(&event, targetWinPtr, MotionNotify, x, y,
- lastState, NotifyNormal);
- Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
- }
- lastPos = pos;
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * XGrabPointer --
- *
- * Capture the mouse so event are reported outside of toplevels.
- * Note that this is a very limited implementation that only
- * supports GrabModeAsync and owner_events True.
- *
- * Results:
- * Always returns GrabSuccess.
- *
- * Side effects:
- * Turns on mouse capture, sets the global grab pointer, and
- * clears any window restrictions.
- *
- *----------------------------------------------------------------------
- */
-
-int
-XGrabPointer(display, grab_window, owner_events, event_mask, pointer_mode,
- keyboard_mode, confine_to, cursor, time)
- Display* display;
- Window grab_window;
- Bool owner_events;
- unsigned int event_mask;
- int pointer_mode;
- int keyboard_mode;
- Window confine_to;
- Cursor cursor;
- Time time;
-{
- display->request++;
- grabWinPtr = (TkWindow *) Tk_IdToWindow(display, grab_window);
- restrictWinPtr = NULL;
- TkpSetCapture(grabWinPtr);
- if (TkPositionInTree(lastWinPtr, grabWinPtr) != TK_GRAB_IN_TREE) {
- UpdateCursor(grabWinPtr);
- }
- return GrabSuccess;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * XUngrabPointer --
- *
- * Release the current grab.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Releases the mouse capture.
- *
- *----------------------------------------------------------------------
- */
-
-void
-XUngrabPointer(display, time)
- Display* display;
- Time time;
-{
- display->request++;
- grabWinPtr = NULL;
- restrictWinPtr = NULL;
- TkpSetCapture(NULL);
- UpdateCursor(lastWinPtr);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkPointerDeadWindow --
- *
- * Clean up pointer module state when a window is destroyed.
- *
- * Results:
- * None.
- *
- * Side effects:
- * May release the current capture window.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkPointerDeadWindow(winPtr)
- TkWindow *winPtr;
-{
- if (winPtr == lastWinPtr) {
- lastWinPtr = NULL;
- }
- if (winPtr == grabWinPtr) {
- grabWinPtr = NULL;
- }
- if (winPtr == restrictWinPtr) {
- restrictWinPtr = NULL;
- }
- if (!(restrictWinPtr || grabWinPtr)) {
- TkpSetCapture(NULL);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * UpdateCursor --
- *
- * Set the windows global cursor to the cursor associated with
- * the given Tk window.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Changes the mouse cursor.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-UpdateCursor(winPtr)
- TkWindow *winPtr;
-{
- Cursor cursor = None;
-
- /*
- * A window inherits its cursor from its parent if it doesn't
- * have one of its own. Top level windows inherit the default
- * cursor.
- */
-
- cursorWinPtr = winPtr;
- while (winPtr != NULL) {
- if (winPtr->atts.cursor != None) {
- cursor = winPtr->atts.cursor;
- break;
- } else if (winPtr->flags & TK_TOP_LEVEL) {
- break;
- }
- winPtr = winPtr->parentPtr;
- }
- TkpSetCursor((TkpCursor) cursor);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * XDefineCursor --
- *
- * This function is called to update the cursor on a window.
- * Since the mouse might be in the specified window, we need to
- * check the specified window against the current mouse position
- * and grab state.
- *
- * Results:
- * None.
- *
- * Side effects:
- * May update the cursor.
- *
- *----------------------------------------------------------------------
- */
-
-void
-XDefineCursor(display, w, cursor)
- Display* display;
- Window w;
- Cursor cursor;
-{
- TkWindow *winPtr = (TkWindow *)Tk_IdToWindow(display, w);
-
- if (cursorWinPtr == winPtr) {
- UpdateCursor(winPtr);
- }
- display->request++;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkGenerateActivateEvents --
- *
- * This function is called by the Mac and Windows window manager
- * routines when a toplevel window is activated or deactivated.
- * Activate/Deactivate events will be sent to every subwindow of
- * the toplevel followed by a FocusIn/FocusOut message.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Generates X events.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkGenerateActivateEvents(winPtr, active)
- TkWindow *winPtr; /* Toplevel to activate. */
- int active; /* Non-zero if the window is being
- * activated, else 0.*/
-{
- XEvent event;
-
- /*
- * Generate Activate and Deactivate events. This event
- * is sent to every subwindow in a toplevel window.
- */
-
- event.xany.serial = winPtr->display->request++;
- event.xany.send_event = False;
- event.xany.display = winPtr->display;
- event.xany.window = winPtr->window;
-
- event.xany.type = active ? ActivateNotify : DeactivateNotify;
- TkQueueEventForAllChildren(winPtr, &event);
-
-}
diff --git a/generic/tkPort.h b/generic/tkPort.h
deleted file mode 100644
index 04e1dab..0000000
--- a/generic/tkPort.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * tkPort.h --
- *
- * This header file handles porting issues that occur because of
- * differences between systems. It reads in platform specific
- * portability files.
- *
- * Copyright (c) 1995 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: tkPort.h,v 1.2 1998/09/14 18:23:16 stanton Exp $
- */
-
-#ifndef _TKPORT
-#define _TKPORT
-
-#ifndef _TK
-#include "tk.h"
-#endif
-#ifndef _TCL
-#include "tcl.h"
-#endif
-
-#if defined(__WIN32__) || defined(_WIN32)
-# include "tkWinPort.h"
-#else
-# if defined(MAC_TCL)
-# include "tkMacPort.h"
-# else
-# include "../unix/tkUnixPort.h"
-# endif
-#endif
-
-#endif /* _TKPORT */
diff --git a/generic/tkRectOval.c b/generic/tkRectOval.c
deleted file mode 100644
index beba5a0..0000000
--- a/generic/tkRectOval.c
+++ /dev/null
@@ -1,1030 +0,0 @@
-/*
- * tkRectOval.c --
- *
- * This file implements rectangle and oval items for canvas
- * widgets.
- *
- * Copyright (c) 1991-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: tkRectOval.c,v 1.2 1998/09/14 18:23:16 stanton Exp $
- */
-
-#include <stdio.h>
-#include "tk.h"
-#include "tkInt.h"
-#include "tkPort.h"
-
-/*
- * The structure below defines the record for each rectangle/oval item.
- */
-
-typedef struct RectOvalItem {
- Tk_Item header; /* Generic stuff that's the same for all
- * types. MUST BE FIRST IN STRUCTURE. */
- double bbox[4]; /* Coordinates of bounding box for rectangle
- * or oval (x1, y1, x2, y2). Item includes
- * x1 and x2 but not y1 and y2. */
- int width; /* Width of outline. */
- XColor *outlineColor; /* Color for outline. */
- XColor *fillColor; /* Color for filling rectangle/oval. */
- Pixmap fillStipple; /* Stipple bitmap for filling item. */
- GC outlineGC; /* Graphics context for outline. */
- GC fillGC; /* Graphics context for filling item. */
-} RectOvalItem;
-
-/*
- * Information used for parsing configuration specs:
- */
-
-static Tk_CustomOption tagsOption = {Tk_CanvasTagsParseProc,
- Tk_CanvasTagsPrintProc, (ClientData) NULL
-};
-
-static Tk_ConfigSpec configSpecs[] = {
- {TK_CONFIG_COLOR, "-fill", (char *) NULL, (char *) NULL,
- (char *) NULL, Tk_Offset(RectOvalItem, fillColor), TK_CONFIG_NULL_OK},
- {TK_CONFIG_COLOR, "-outline", (char *) NULL, (char *) NULL,
- "black", Tk_Offset(RectOvalItem, outlineColor), TK_CONFIG_NULL_OK},
- {TK_CONFIG_BITMAP, "-stipple", (char *) NULL, (char *) NULL,
- (char *) NULL, Tk_Offset(RectOvalItem, fillStipple), TK_CONFIG_NULL_OK},
- {TK_CONFIG_CUSTOM, "-tags", (char *) NULL, (char *) NULL,
- (char *) NULL, 0, TK_CONFIG_NULL_OK, &tagsOption},
- {TK_CONFIG_PIXELS, "-width", (char *) NULL, (char *) NULL,
- "1", Tk_Offset(RectOvalItem, width), TK_CONFIG_DONT_SET_DEFAULT},
- {TK_CONFIG_END, (char *) NULL, (char *) NULL, (char *) NULL,
- (char *) NULL, 0, 0}
-};
-
-/*
- * Prototypes for procedures defined in this file:
- */
-
-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,
- char **argv, int flags));
-static int CreateRectOval _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Canvas canvas, struct Tk_Item *itemPtr,
- int argc, char **argv));
-static void DeleteRectOval _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, Display *display));
-static void DisplayRectOval _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, Display *display, Drawable dst,
- int x, int y, int width, int height));
-static int OvalToArea _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double *areaPtr));
-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,
- char **argv));
-static int RectOvalToPostscript _ANSI_ARGS_((Tcl_Interp *interp,
- Tk_Canvas canvas, Tk_Item *itemPtr, int prepass));
-static int RectToArea _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double *areaPtr));
-static double RectToPoint _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double *pointPtr));
-static void ScaleRectOval _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double originX, double originY,
- double scaleX, double scaleY));
-static void TranslateRectOval _ANSI_ARGS_((Tk_Canvas canvas,
- Tk_Item *itemPtr, double deltaX, double deltaY));
-
-/*
- * The structures below defines the rectangle and oval item types
- * by means of procedures that can be invoked by generic item code.
- */
-
-Tk_ItemType tkRectangleType = {
- "rectangle", /* name */
- sizeof(RectOvalItem), /* itemSize */
- CreateRectOval, /* createProc */
- configSpecs, /* configSpecs */
- ConfigureRectOval, /* configureProc */
- RectOvalCoords, /* coordProc */
- DeleteRectOval, /* deleteProc */
- DisplayRectOval, /* displayProc */
- 0, /* alwaysRedraw */
- RectToPoint, /* pointProc */
- RectToArea, /* areaProc */
- RectOvalToPostscript, /* postscriptProc */
- ScaleRectOval, /* scaleProc */
- TranslateRectOval, /* translateProc */
- (Tk_ItemIndexProc *) NULL, /* indexProc */
- (Tk_ItemCursorProc *) NULL, /* icursorProc */
- (Tk_ItemSelectionProc *) NULL, /* selectionProc */
- (Tk_ItemInsertProc *) NULL, /* insertProc */
- (Tk_ItemDCharsProc *) NULL, /* dTextProc */
- (Tk_ItemType *) NULL /* nextPtr */
-};
-
-Tk_ItemType tkOvalType = {
- "oval", /* name */
- sizeof(RectOvalItem), /* itemSize */
- CreateRectOval, /* createProc */
- configSpecs, /* configSpecs */
- ConfigureRectOval, /* configureProc */
- RectOvalCoords, /* coordProc */
- DeleteRectOval, /* deleteProc */
- DisplayRectOval, /* displayProc */
- 0, /* alwaysRedraw */
- OvalToPoint, /* pointProc */
- OvalToArea, /* areaProc */
- RectOvalToPostscript, /* postscriptProc */
- ScaleRectOval, /* scaleProc */
- TranslateRectOval, /* translateProc */
- (Tk_ItemIndexProc *) NULL, /* indexProc */
- (Tk_ItemCursorProc *) NULL, /* cursorProc */
- (Tk_ItemSelectionProc *) NULL, /* selectionProc */
- (Tk_ItemInsertProc *) NULL, /* insertProc */
- (Tk_ItemDCharsProc *) NULL, /* dTextProc */
- (Tk_ItemType *) NULL /* nextPtr */
-};
-
-/*
- *--------------------------------------------------------------
- *
- * CreateRectOval --
- *
- * This procedure is invoked to create a new rectangle
- * or oval item in a canvas.
- *
- * Results:
- * A standard Tcl return value. If an error occurred in
- * creating the item, then an error message is left in
- * interp->result; in this case itemPtr is left uninitialized,
- * so it can be safely freed by the caller.
- *
- * Side effects:
- * A new rectangle or oval item is created.
- *
- *--------------------------------------------------------------
- */
-
-static int
-CreateRectOval(interp, canvas, itemPtr, argc, argv)
- 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. */
- char **argv; /* Arguments describing rectangle. */
-{
- RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr;
-
- if (argc < 4) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- Tk_PathName(Tk_CanvasTkwin(canvas)), " create ",
- itemPtr->typePtr->name, " x1 y1 x2 y2 ?options?\"",
- (char *) NULL);
- return TCL_ERROR;
- }
-
- /*
- * Carry out initialization that is needed in order to clean
- * up after errors during the the remainder of this procedure.
- */
-
- rectOvalPtr->width = 1;
- rectOvalPtr->outlineColor = NULL;
- rectOvalPtr->fillColor = NULL;
- rectOvalPtr->fillStipple = None;
- rectOvalPtr->outlineGC = None;
- rectOvalPtr->fillGC = None;
-
- /*
- * Process the arguments to fill in the item record.
- */
-
- if ((Tk_CanvasGetCoord(interp, canvas, argv[0],
- &rectOvalPtr->bbox[0]) != TCL_OK)
- || (Tk_CanvasGetCoord(interp, canvas, argv[1],
- &rectOvalPtr->bbox[1]) != TCL_OK)
- || (Tk_CanvasGetCoord(interp, canvas, argv[2],
- &rectOvalPtr->bbox[2]) != TCL_OK)
- || (Tk_CanvasGetCoord(interp, canvas, argv[3],
- &rectOvalPtr->bbox[3]) != TCL_OK)) {
- return TCL_ERROR;
- }
-
- if (ConfigureRectOval(interp, canvas, itemPtr, argc-4, argv+4, 0)
- != TCL_OK) {
- DeleteRectOval(canvas, itemPtr, Tk_Display(Tk_CanvasTkwin(canvas)));
- return TCL_ERROR;
- }
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * RectOvalCoords --
- *
- * This procedure is invoked to process the "coords" widget
- * command on rectangles and ovals. See the user documentation
- * for details on what it does.
- *
- * Results:
- * Returns TCL_OK or TCL_ERROR, and sets interp->result.
- *
- * Side effects:
- * The coordinates for the given item may be changed.
- *
- *--------------------------------------------------------------
- */
-
-static int
-RectOvalCoords(interp, canvas, itemPtr, argc, argv)
- 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. */
- char **argv; /* Array of coordinates: x1, y1,
- * x2, y2, ... */
-{
- RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr;
- char c0[TCL_DOUBLE_SPACE], c1[TCL_DOUBLE_SPACE];
- char c2[TCL_DOUBLE_SPACE], c3[TCL_DOUBLE_SPACE];
-
- if (argc == 0) {
- Tcl_PrintDouble(interp, rectOvalPtr->bbox[0], c0);
- Tcl_PrintDouble(interp, rectOvalPtr->bbox[1], c1);
- Tcl_PrintDouble(interp, rectOvalPtr->bbox[2], c2);
- Tcl_PrintDouble(interp, rectOvalPtr->bbox[3], c3);
- Tcl_AppendResult(interp, c0, " ", c1, " ", c2, " ", c3,
- (char *) NULL);
- } else if (argc == 4) {
- if ((Tk_CanvasGetCoord(interp, canvas, argv[0],
- &rectOvalPtr->bbox[0]) != TCL_OK)
- || (Tk_CanvasGetCoord(interp, canvas, argv[1],
- &rectOvalPtr->bbox[1]) != TCL_OK)
- || (Tk_CanvasGetCoord(interp, canvas, argv[2],
- &rectOvalPtr->bbox[2]) != TCL_OK)
- || (Tk_CanvasGetCoord(interp, canvas, argv[3],
- &rectOvalPtr->bbox[3]) != TCL_OK)) {
- return TCL_ERROR;
- }
- ComputeRectOvalBbox(canvas, rectOvalPtr);
- } else {
- sprintf(interp->result,
- "wrong # coordinates: expected 0 or 4, got %d",
- argc);
- return TCL_ERROR;
- }
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ConfigureRectOval --
- *
- * This procedure is invoked to configure various aspects
- * of a rectangle or oval item, such as its border and
- * background colors.
- *
- * Results:
- * A standard Tcl result code. If an error occurs, then
- * an error message is left in interp->result.
- *
- * Side effects:
- * Configuration information, such as colors and stipple
- * patterns, may be set for itemPtr.
- *
- *--------------------------------------------------------------
- */
-
-static int
-ConfigureRectOval(interp, canvas, itemPtr, argc, argv, 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. */
- char **argv; /* Arguments describing things to configure. */
- int flags; /* Flags to pass to Tk_ConfigureWidget. */
-{
- RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr;
- XGCValues gcValues;
- GC newGC;
- unsigned long mask;
- Tk_Window tkwin;
-
- tkwin = Tk_CanvasTkwin(canvas);
- if (Tk_ConfigureWidget(interp, tkwin, configSpecs, argc, argv,
- (char *) rectOvalPtr, flags) != TCL_OK) {
- return TCL_ERROR;
- }
-
- /*
- * A few of the options require additional processing, such as
- * graphics contexts.
- */
-
- if (rectOvalPtr->width < 1) {
- rectOvalPtr->width = 1;
- }
- if (rectOvalPtr->outlineColor == NULL) {
- newGC = None;
- } else {
- gcValues.foreground = rectOvalPtr->outlineColor->pixel;
- gcValues.cap_style = CapProjecting;
- gcValues.line_width = rectOvalPtr->width;
- mask = GCForeground|GCCapStyle|GCLineWidth;
- newGC = Tk_GetGC(tkwin, mask, &gcValues);
- }
- if (rectOvalPtr->outlineGC != None) {
- Tk_FreeGC(Tk_Display(tkwin), rectOvalPtr->outlineGC);
- }
- rectOvalPtr->outlineGC = newGC;
-
- if (rectOvalPtr->fillColor == NULL) {
- newGC = None;
- } else {
- gcValues.foreground = rectOvalPtr->fillColor->pixel;
- if (rectOvalPtr->fillStipple != None) {
- gcValues.stipple = rectOvalPtr->fillStipple;
- gcValues.fill_style = FillStippled;
- mask = GCForeground|GCStipple|GCFillStyle;
- } else {
- mask = GCForeground;
- }
- newGC = Tk_GetGC(tkwin, mask, &gcValues);
- }
- if (rectOvalPtr->fillGC != None) {
- Tk_FreeGC(Tk_Display(tkwin), rectOvalPtr->fillGC);
- }
- rectOvalPtr->fillGC = newGC;
- ComputeRectOvalBbox(canvas, rectOvalPtr);
-
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * DeleteRectOval --
- *
- * This procedure is called to clean up the data structure
- * associated with a rectangle or oval item.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Resources associated with itemPtr are released.
- *
- *--------------------------------------------------------------
- */
-
-static void
-DeleteRectOval(canvas, itemPtr, display)
- Tk_Canvas canvas; /* Info about overall widget. */
- Tk_Item *itemPtr; /* Item that is being deleted. */
- Display *display; /* Display containing window for
- * canvas. */
-{
- RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr;
-
- if (rectOvalPtr->outlineColor != NULL) {
- Tk_FreeColor(rectOvalPtr->outlineColor);
- }
- if (rectOvalPtr->fillColor != NULL) {
- Tk_FreeColor(rectOvalPtr->fillColor);
- }
- if (rectOvalPtr->fillStipple != None) {
- Tk_FreeBitmap(display, rectOvalPtr->fillStipple);
- }
- if (rectOvalPtr->outlineGC != None) {
- Tk_FreeGC(display, rectOvalPtr->outlineGC);
- }
- if (rectOvalPtr->fillGC != None) {
- Tk_FreeGC(display, rectOvalPtr->fillGC);
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ComputeRectOvalBbox --
- *
- * This procedure is invoked to compute the bounding box of
- * all the pixels that may be drawn as part of a rectangle
- * or oval.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The fields x1, y1, x2, and y2 are updated in the header
- * for itemPtr.
- *
- *--------------------------------------------------------------
- */
-
- /* ARGSUSED */
-static void
-ComputeRectOvalBbox(canvas, rectOvalPtr)
- Tk_Canvas canvas; /* Canvas that contains item. */
- RectOvalItem *rectOvalPtr; /* Item whose bbox is to be
- * recomputed. */
-{
- int bloat, tmp;
- double dtmp;
-
- /*
- * Make sure that the first coordinates are the lowest ones.
- */
-
- if (rectOvalPtr->bbox[1] > rectOvalPtr->bbox[3]) {
- double tmp;
- tmp = rectOvalPtr->bbox[3];
- rectOvalPtr->bbox[3] = rectOvalPtr->bbox[1];
- rectOvalPtr->bbox[1] = tmp;
- }
- if (rectOvalPtr->bbox[0] > rectOvalPtr->bbox[2]) {
- double tmp;
- tmp = rectOvalPtr->bbox[2];
- rectOvalPtr->bbox[2] = rectOvalPtr->bbox[0];
- rectOvalPtr->bbox[0] = tmp;
- }
-
- if (rectOvalPtr->outlineColor == NULL) {
- bloat = 0;
- } else {
- bloat = (rectOvalPtr->width+1)/2;
- }
-
- /*
- * Special note: the rectangle is always drawn at least 1x1 in
- * size, so round up the upper coordinates to be at least 1 unit
- * greater than the lower ones.
- */
-
- tmp = (int) ((rectOvalPtr->bbox[0] >= 0) ? rectOvalPtr->bbox[0] + .5
- : rectOvalPtr->bbox[0] - .5);
- rectOvalPtr->header.x1 = tmp - bloat;
- tmp = (int) ((rectOvalPtr->bbox[1] >= 0) ? rectOvalPtr->bbox[1] + .5
- : rectOvalPtr->bbox[1] - .5);
- rectOvalPtr->header.y1 = tmp - bloat;
- dtmp = rectOvalPtr->bbox[2];
- if (dtmp < (rectOvalPtr->bbox[0] + 1)) {
- dtmp = rectOvalPtr->bbox[0] + 1;
- }
- tmp = (int) ((dtmp >= 0) ? dtmp + .5 : dtmp - .5);
- rectOvalPtr->header.x2 = tmp + bloat;
- dtmp = rectOvalPtr->bbox[3];
- if (dtmp < (rectOvalPtr->bbox[1] + 1)) {
- dtmp = rectOvalPtr->bbox[1] + 1;
- }
- tmp = (int) ((dtmp >= 0) ? dtmp + .5 : dtmp - .5);
- rectOvalPtr->header.y2 = tmp + bloat;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * DisplayRectOval --
- *
- * This procedure is invoked to draw a rectangle or oval
- * item in a given drawable.
- *
- * Results:
- * None.
- *
- * Side effects:
- * ItemPtr is drawn in drawable using the transformation
- * information in canvas.
- *
- *--------------------------------------------------------------
- */
-
-static void
-DisplayRectOval(canvas, itemPtr, display, drawable, x, y, width, height)
- Tk_Canvas canvas; /* Canvas that contains item. */
- Tk_Item *itemPtr; /* Item to be displayed. */
- Display *display; /* Display on which to draw item. */
- Drawable drawable; /* Pixmap or window in which to draw
- * item. */
- int x, y, width, height; /* Describes region of canvas that
- * must be redisplayed (not used). */
-{
- RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr;
- short x1, y1, x2, y2;
-
- /*
- * Compute the screen coordinates of the bounding box for the item.
- * Make sure that the bbox is at least one pixel large, since some
- * X servers will die if it isn't.
- */
-
- Tk_CanvasDrawableCoords(canvas, rectOvalPtr->bbox[0], rectOvalPtr->bbox[1],
- &x1, &y1);
- Tk_CanvasDrawableCoords(canvas, rectOvalPtr->bbox[2], rectOvalPtr->bbox[3],
- &x2, &y2);
- if (x2 <= x1) {
- x2 = x1+1;
- }
- if (y2 <= y1) {
- y2 = y1+1;
- }
-
- /*
- * Display filled part first (if wanted), then outline. If we're
- * stippling, then modify the stipple offset in the GC. Be sure to
- * reset the offset when done, since the GC is supposed to be
- * read-only.
- */
-
- if (rectOvalPtr->fillGC != None) {
- if (rectOvalPtr->fillStipple != None) {
- Tk_CanvasSetStippleOrigin(canvas, rectOvalPtr->fillGC);
- }
- if (rectOvalPtr->header.typePtr == &tkRectangleType) {
- XFillRectangle(display, drawable, rectOvalPtr->fillGC,
- x1, y1, (unsigned int) (x2-x1), (unsigned int) (y2-y1));
- } else {
- XFillArc(display, drawable, rectOvalPtr->fillGC,
- x1, y1, (unsigned) (x2-x1), (unsigned) (y2-y1),
- 0, 360*64);
- }
- if (rectOvalPtr->fillStipple != None) {
- XSetTSOrigin(display, rectOvalPtr->fillGC, 0, 0);
- }
- }
- if (rectOvalPtr->outlineGC != None) {
- if (rectOvalPtr->header.typePtr == &tkRectangleType) {
- XDrawRectangle(display, drawable, rectOvalPtr->outlineGC,
- x1, y1, (unsigned) (x2-x1), (unsigned) (y2-y1));
- } else {
- XDrawArc(display, drawable, rectOvalPtr->outlineGC,
- x1, y1, (unsigned) (x2-x1), (unsigned) (y2-y1), 0, 360*64);
- }
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * RectToPoint --
- *
- * Computes the distance from a given point to a given
- * rectangle, in canvas units.
- *
- * Results:
- * The return value is 0 if the point whose x and y coordinates
- * are coordPtr[0] and coordPtr[1] is inside the rectangle. If the
- * point isn't inside the rectangle then the return value is the
- * distance from the point to the rectangle. If itemPtr is filled,
- * then anywhere in the interior is considered "inside"; if
- * itemPtr isn't filled, then "inside" means only the area
- * occupied by the outline.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
- /* ARGSUSED */
-static double
-RectToPoint(canvas, itemPtr, pointPtr)
- Tk_Canvas canvas; /* Canvas containing item. */
- Tk_Item *itemPtr; /* Item to check against point. */
- double *pointPtr; /* Pointer to x and y coordinates. */
-{
- RectOvalItem *rectPtr = (RectOvalItem *) itemPtr;
- double xDiff, yDiff, x1, y1, x2, y2, inc, tmp;
-
- /*
- * Generate a new larger rectangle that includes the border
- * width, if there is one.
- */
-
- x1 = rectPtr->bbox[0];
- y1 = rectPtr->bbox[1];
- x2 = rectPtr->bbox[2];
- y2 = rectPtr->bbox[3];
- if (rectPtr->outlineGC != None) {
- inc = rectPtr->width/2.0;
- x1 -= inc;
- y1 -= inc;
- x2 += inc;
- y2 += inc;
- }
-
- /*
- * If the point is inside the rectangle, handle specially:
- * distance is 0 if rectangle is filled, otherwise compute
- * distance to nearest edge of rectangle and subtract width
- * of edge.
- */
-
- if ((pointPtr[0] >= x1) && (pointPtr[0] < x2)
- && (pointPtr[1] >= y1) && (pointPtr[1] < y2)) {
- if ((rectPtr->fillGC != None) || (rectPtr->outlineGC == None)) {
- return 0.0;
- }
- xDiff = pointPtr[0] - x1;
- tmp = x2 - pointPtr[0];
- if (tmp < xDiff) {
- xDiff = tmp;
- }
- yDiff = pointPtr[1] - y1;
- tmp = y2 - pointPtr[1];
- if (tmp < yDiff) {
- yDiff = tmp;
- }
- if (yDiff < xDiff) {
- xDiff = yDiff;
- }
- xDiff -= rectPtr->width;
- if (xDiff < 0.0) {
- return 0.0;
- }
- return xDiff;
- }
-
- /*
- * Point is outside rectangle.
- */
-
- if (pointPtr[0] < x1) {
- xDiff = x1 - pointPtr[0];
- } else if (pointPtr[0] > x2) {
- xDiff = pointPtr[0] - x2;
- } else {
- xDiff = 0;
- }
-
- if (pointPtr[1] < y1) {
- yDiff = y1 - pointPtr[1];
- } else if (pointPtr[1] > y2) {
- yDiff = pointPtr[1] - y2;
- } else {
- yDiff = 0;
- }
-
- return hypot(xDiff, yDiff);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * OvalToPoint --
- *
- * Computes the distance from a given point to a given
- * oval, in canvas units.
- *
- * Results:
- * The return value is 0 if the point whose x and y coordinates
- * are coordPtr[0] and coordPtr[1] is inside the oval. If the
- * point isn't inside the oval then the return value is the
- * distance from the point to the oval. If itemPtr is filled,
- * then anywhere in the interior is considered "inside"; if
- * itemPtr isn't filled, then "inside" means only the area
- * occupied by the outline.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
- /* ARGSUSED */
-static double
-OvalToPoint(canvas, itemPtr, pointPtr)
- Tk_Canvas canvas; /* Canvas containing item. */
- Tk_Item *itemPtr; /* Item to check against point. */
- double *pointPtr; /* Pointer to x and y coordinates. */
-{
- RectOvalItem *ovalPtr = (RectOvalItem *) itemPtr;
- double width;
- int filled;
-
- width = ovalPtr->width;
- filled = ovalPtr->fillGC != None;
- if (ovalPtr->outlineGC == None) {
- width = 0.0;
- filled = 1;
- }
- return TkOvalToPoint(ovalPtr->bbox, width, filled, pointPtr);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * RectToArea --
- *
- * This procedure is called to determine whether an item
- * lies entirely inside, entirely outside, or overlapping
- * a given rectangle.
- *
- * Results:
- * -1 is returned if the item is entirely outside the area
- * given by rectPtr, 0 if it overlaps, and 1 if it is entirely
- * inside the given area.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
- /* ARGSUSED */
-static int
-RectToArea(canvas, itemPtr, areaPtr)
- Tk_Canvas canvas; /* Canvas containing item. */
- Tk_Item *itemPtr; /* Item to check against rectangle. */
- double *areaPtr; /* Pointer to array of four coordinates
- * (x1, y1, x2, y2) describing rectangular
- * area. */
-{
- RectOvalItem *rectPtr = (RectOvalItem *) itemPtr;
- double halfWidth;
-
- halfWidth = rectPtr->width/2.0;
- if (rectPtr->outlineGC == None) {
- halfWidth = 0.0;
- }
-
- if ((areaPtr[2] <= (rectPtr->bbox[0] - halfWidth))
- || (areaPtr[0] >= (rectPtr->bbox[2] + halfWidth))
- || (areaPtr[3] <= (rectPtr->bbox[1] - halfWidth))
- || (areaPtr[1] >= (rectPtr->bbox[3] + halfWidth))) {
- return -1;
- }
- if ((rectPtr->fillGC == None) && (rectPtr->outlineGC != None)
- && (areaPtr[0] >= (rectPtr->bbox[0] + halfWidth))
- && (areaPtr[1] >= (rectPtr->bbox[1] + halfWidth))
- && (areaPtr[2] <= (rectPtr->bbox[2] - halfWidth))
- && (areaPtr[3] <= (rectPtr->bbox[3] - halfWidth))) {
- return -1;
- }
- if ((areaPtr[0] <= (rectPtr->bbox[0] - halfWidth))
- && (areaPtr[1] <= (rectPtr->bbox[1] - halfWidth))
- && (areaPtr[2] >= (rectPtr->bbox[2] + halfWidth))
- && (areaPtr[3] >= (rectPtr->bbox[3] + halfWidth))) {
- return 1;
- }
- return 0;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * OvalToArea --
- *
- * This procedure is called to determine whether an item
- * lies entirely inside, entirely outside, or overlapping
- * a given rectangular area.
- *
- * Results:
- * -1 is returned if the item is entirely outside the area
- * given by rectPtr, 0 if it overlaps, and 1 if it is entirely
- * inside the given area.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
- /* ARGSUSED */
-static int
-OvalToArea(canvas, itemPtr, areaPtr)
- Tk_Canvas canvas; /* Canvas containing item. */
- Tk_Item *itemPtr; /* Item to check against oval. */
- double *areaPtr; /* Pointer to array of four coordinates
- * (x1, y1, x2, y2) describing rectangular
- * area. */
-{
- RectOvalItem *ovalPtr = (RectOvalItem *) itemPtr;
- double oval[4], halfWidth;
- int result;
-
- /*
- * Expand the oval to include the width of the outline, if any.
- */
-
- halfWidth = ovalPtr->width/2.0;
- if (ovalPtr->outlineGC == None) {
- halfWidth = 0.0;
- }
- oval[0] = ovalPtr->bbox[0] - halfWidth;
- oval[1] = ovalPtr->bbox[1] - halfWidth;
- oval[2] = ovalPtr->bbox[2] + halfWidth;
- oval[3] = ovalPtr->bbox[3] + halfWidth;
-
- result = TkOvalToArea(oval, areaPtr);
-
- /*
- * If the rectangle appears to overlap the oval and the oval
- * isn't filled, do one more check to see if perhaps all four
- * of the rectangle's corners are totally inside the oval's
- * unfilled center, in which case we should return "outside".
- */
-
- if ((result == 0) && (ovalPtr->outlineGC != None)
- && (ovalPtr->fillGC == None)) {
- double centerX, centerY, width, height;
- double xDelta1, yDelta1, xDelta2, yDelta2;
-
- centerX = (ovalPtr->bbox[0] + ovalPtr->bbox[2])/2.0;
- centerY = (ovalPtr->bbox[1] + ovalPtr->bbox[3])/2.0;
- width = (ovalPtr->bbox[2] - ovalPtr->bbox[0])/2.0 - halfWidth;
- height = (ovalPtr->bbox[3] - ovalPtr->bbox[1])/2.0 - halfWidth;
- xDelta1 = (areaPtr[0] - centerX)/width;
- xDelta1 *= xDelta1;
- yDelta1 = (areaPtr[1] - centerY)/height;
- yDelta1 *= yDelta1;
- xDelta2 = (areaPtr[2] - centerX)/width;
- xDelta2 *= xDelta2;
- yDelta2 = (areaPtr[3] - centerY)/height;
- yDelta2 *= yDelta2;
- if (((xDelta1 + yDelta1) < 1.0)
- && ((xDelta1 + yDelta2) < 1.0)
- && ((xDelta2 + yDelta1) < 1.0)
- && ((xDelta2 + yDelta2) < 1.0)) {
- return -1;
- }
- }
- return result;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ScaleRectOval --
- *
- * This procedure is invoked to rescale a rectangle or oval
- * item.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The rectangle or oval referred to by itemPtr is rescaled
- * so that the following transformation is applied to all
- * point coordinates:
- * x' = originX + scaleX*(x-originX)
- * y' = originY + scaleY*(y-originY)
- *
- *--------------------------------------------------------------
- */
-
-static void
-ScaleRectOval(canvas, itemPtr, originX, originY, scaleX, scaleY)
- Tk_Canvas canvas; /* Canvas containing rectangle. */
- Tk_Item *itemPtr; /* Rectangle to be scaled. */
- double originX, originY; /* Origin about which to scale rect. */
- double scaleX; /* Amount to scale in X direction. */
- double scaleY; /* Amount to scale in Y direction. */
-{
- RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr;
-
- rectOvalPtr->bbox[0] = originX + scaleX*(rectOvalPtr->bbox[0] - originX);
- rectOvalPtr->bbox[1] = originY + scaleY*(rectOvalPtr->bbox[1] - originY);
- rectOvalPtr->bbox[2] = originX + scaleX*(rectOvalPtr->bbox[2] - originX);
- rectOvalPtr->bbox[3] = originY + scaleY*(rectOvalPtr->bbox[3] - originY);
- ComputeRectOvalBbox(canvas, rectOvalPtr);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * TranslateRectOval --
- *
- * This procedure is called to move a rectangle or oval by a
- * given amount.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The position of the rectangle or oval is offset by
- * (xDelta, yDelta), and the bounding box is updated in the
- * generic part of the item structure.
- *
- *--------------------------------------------------------------
- */
-
-static void
-TranslateRectOval(canvas, itemPtr, deltaX, deltaY)
- Tk_Canvas canvas; /* Canvas containing item. */
- Tk_Item *itemPtr; /* Item that is being moved. */
- double deltaX, deltaY; /* Amount by which item is to be
- * moved. */
-{
- RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr;
-
- rectOvalPtr->bbox[0] += deltaX;
- rectOvalPtr->bbox[1] += deltaY;
- rectOvalPtr->bbox[2] += deltaX;
- rectOvalPtr->bbox[3] += deltaY;
- ComputeRectOvalBbox(canvas, rectOvalPtr);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * RectOvalToPostscript --
- *
- * This procedure is called to generate Postscript for
- * rectangle and oval items.
- *
- * Results:
- * The return value is a standard Tcl result. If an error
- * occurs in generating Postscript then an error message is
- * left in interp->result, replacing whatever used to be there.
- * If no error occurs, then Postscript for the rectangle is
- * appended to the result.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-static int
-RectOvalToPostscript(interp, canvas, itemPtr, prepass)
- Tcl_Interp *interp; /* Interpreter for error reporting. */
- Tk_Canvas canvas; /* Information about overall canvas. */
- Tk_Item *itemPtr; /* Item for which Postscript is
- * wanted. */
- int prepass; /* 1 means this is a prepass to
- * collect font information; 0 means
- * final Postscript is being created. */
-{
- char pathCmd[500], string[100];
- RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr;
- double y1, y2;
-
- y1 = Tk_CanvasPsY(canvas, rectOvalPtr->bbox[1]);
- y2 = Tk_CanvasPsY(canvas, rectOvalPtr->bbox[3]);
-
- /*
- * Generate a string that creates a path for the rectangle or oval.
- * This is the only part of the procedure's code that is type-
- * specific.
- */
-
-
- if (rectOvalPtr->header.typePtr == &tkRectangleType) {
- sprintf(pathCmd, "%.15g %.15g moveto %.15g 0 rlineto 0 %.15g rlineto %.15g 0 rlineto closepath\n",
- rectOvalPtr->bbox[0], y1,
- rectOvalPtr->bbox[2]-rectOvalPtr->bbox[0], y2-y1,
- rectOvalPtr->bbox[0]-rectOvalPtr->bbox[2]);
- } else {
- sprintf(pathCmd, "matrix currentmatrix\n%.15g %.15g translate %.15g %.15g scale 1 0 moveto 0 0 1 0 360 arc\nsetmatrix\n",
- (rectOvalPtr->bbox[0] + rectOvalPtr->bbox[2])/2, (y1 + y2)/2,
- (rectOvalPtr->bbox[2] - rectOvalPtr->bbox[0])/2, (y1 - y2)/2);
- }
-
- /*
- * First draw the filled area of the rectangle.
- */
-
- if (rectOvalPtr->fillColor != NULL) {
- Tcl_AppendResult(interp, pathCmd, (char *) NULL);
- if (Tk_CanvasPsColor(interp, canvas, rectOvalPtr->fillColor)
- != TCL_OK) {
- return TCL_ERROR;
- }
- if (rectOvalPtr->fillStipple != None) {
- Tcl_AppendResult(interp, "clip ", (char *) NULL);
- if (Tk_CanvasPsStipple(interp, canvas, rectOvalPtr->fillStipple)
- != TCL_OK) {
- return TCL_ERROR;
- }
- if (rectOvalPtr->outlineColor != NULL) {
- Tcl_AppendResult(interp, "grestore gsave\n", (char *) NULL);
- }
- } else {
- Tcl_AppendResult(interp, "fill\n", (char *) NULL);
- }
- }
-
- /*
- * Now draw the outline, if there is one.
- */
-
- if (rectOvalPtr->outlineColor != NULL) {
- Tcl_AppendResult(interp, pathCmd, (char *) NULL);
- sprintf(string, "%d setlinewidth", rectOvalPtr->width);
- Tcl_AppendResult(interp, string,
- " 0 setlinejoin 2 setlinecap\n", (char *) NULL);
- if (Tk_CanvasPsColor(interp, canvas, rectOvalPtr->outlineColor)
- != TCL_OK) {
- return TCL_ERROR;
- }
- Tcl_AppendResult(interp, "stroke\n", (char *) NULL);
- }
- return TCL_OK;
-}
diff --git a/generic/tkScale.c b/generic/tkScale.c
deleted file mode 100644
index 8cdfc3c..0000000
--- a/generic/tkScale.c
+++ /dev/null
@@ -1,1143 +0,0 @@
-/*
- * tkScale.c --
- *
- * This module implements a scale widgets for the Tk toolkit.
- * A scale displays a slider that can be adjusted to change a
- * value; it also displays numeric labels and a textual label,
- * if desired.
- *
- * The modifications to use floating-point values are based on
- * an implementation by Paul Mackerras. The -variable option
- * is due to Henning Schulzrinne. All of these are used with
- * permission.
- *
- * 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: tkScale.c,v 1.2 1998/09/14 18:23:16 stanton Exp $
- */
-
-#include "tkPort.h"
-#include "default.h"
-#include "tkInt.h"
-#include "tclMath.h"
-#include "tkScale.h"
-
-static Tk_ConfigSpec configSpecs[] = {
- {TK_CONFIG_BORDER, "-activebackground", "activeBackground", "Foreground",
- DEF_SCALE_ACTIVE_BG_COLOR, Tk_Offset(TkScale, activeBorder),
- TK_CONFIG_COLOR_ONLY},
- {TK_CONFIG_BORDER, "-activebackground", "activeBackground", "Foreground",
- DEF_SCALE_ACTIVE_BG_MONO, Tk_Offset(TkScale, activeBorder),
- TK_CONFIG_MONO_ONLY},
- {TK_CONFIG_BORDER, "-background", "background", "Background",
- DEF_SCALE_BG_COLOR, Tk_Offset(TkScale, bgBorder),
- TK_CONFIG_COLOR_ONLY},
- {TK_CONFIG_BORDER, "-background", "background", "Background",
- DEF_SCALE_BG_MONO, Tk_Offset(TkScale, bgBorder),
- TK_CONFIG_MONO_ONLY},
- {TK_CONFIG_DOUBLE, "-bigincrement", "bigIncrement", "BigIncrement",
- DEF_SCALE_BIG_INCREMENT, Tk_Offset(TkScale, bigIncrement), 0},
- {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_SCALE_BORDER_WIDTH, Tk_Offset(TkScale, borderWidth), 0},
- {TK_CONFIG_STRING, "-command", "command", "Command",
- DEF_SCALE_COMMAND, Tk_Offset(TkScale, command), TK_CONFIG_NULL_OK},
- {TK_CONFIG_ACTIVE_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_SCALE_CURSOR, Tk_Offset(TkScale, cursor), TK_CONFIG_NULL_OK},
- {TK_CONFIG_INT, "-digits", "digits", "Digits",
- DEF_SCALE_DIGITS, Tk_Offset(TkScale, digits), 0},
- {TK_CONFIG_SYNONYM, "-fg", "foreground", (char *) NULL,
- (char *) NULL, 0, 0},
- {TK_CONFIG_FONT, "-font", "font", "Font",
- DEF_SCALE_FONT, Tk_Offset(TkScale, tkfont),
- 0},
- {TK_CONFIG_COLOR, "-foreground", "foreground", "Foreground",
- DEF_SCALE_FG_COLOR, Tk_Offset(TkScale, textColorPtr),
- TK_CONFIG_COLOR_ONLY},
- {TK_CONFIG_COLOR, "-foreground", "foreground", "Foreground",
- DEF_SCALE_FG_MONO, Tk_Offset(TkScale, textColorPtr),
- TK_CONFIG_MONO_ONLY},
- {TK_CONFIG_DOUBLE, "-from", "from", "From",
- DEF_SCALE_FROM, Tk_Offset(TkScale, fromValue), 0},
- {TK_CONFIG_COLOR, "-highlightbackground", "highlightBackground",
- "HighlightBackground", DEF_SCALE_HIGHLIGHT_BG,
- Tk_Offset(TkScale, highlightBgColorPtr), 0},
- {TK_CONFIG_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_SCALE_HIGHLIGHT, Tk_Offset(TkScale, highlightColorPtr), 0},
- {TK_CONFIG_PIXELS, "-highlightthickness", "highlightThickness",
- "HighlightThickness",
- DEF_SCALE_HIGHLIGHT_WIDTH, Tk_Offset(TkScale, highlightWidth), 0},
- {TK_CONFIG_STRING, "-label", "label", "Label",
- DEF_SCALE_LABEL, Tk_Offset(TkScale, label), TK_CONFIG_NULL_OK},
- {TK_CONFIG_PIXELS, "-length", "length", "Length",
- DEF_SCALE_LENGTH, Tk_Offset(TkScale, length), 0},
- {TK_CONFIG_UID, "-orient", "orient", "Orient",
- DEF_SCALE_ORIENT, Tk_Offset(TkScale, orientUid), 0},
- {TK_CONFIG_RELIEF, "-relief", "relief", "Relief",
- DEF_SCALE_RELIEF, Tk_Offset(TkScale, relief), 0},
- {TK_CONFIG_INT, "-repeatdelay", "repeatDelay", "RepeatDelay",
- DEF_SCALE_REPEAT_DELAY, Tk_Offset(TkScale, repeatDelay), 0},
- {TK_CONFIG_INT, "-repeatinterval", "repeatInterval", "RepeatInterval",
- DEF_SCALE_REPEAT_INTERVAL, Tk_Offset(TkScale, repeatInterval), 0},
- {TK_CONFIG_DOUBLE, "-resolution", "resolution", "Resolution",
- DEF_SCALE_RESOLUTION, Tk_Offset(TkScale, resolution), 0},
- {TK_CONFIG_BOOLEAN, "-showvalue", "showValue", "ShowValue",
- DEF_SCALE_SHOW_VALUE, Tk_Offset(TkScale, showValue), 0},
- {TK_CONFIG_PIXELS, "-sliderlength", "sliderLength", "SliderLength",
- DEF_SCALE_SLIDER_LENGTH, Tk_Offset(TkScale, sliderLength), 0},
- {TK_CONFIG_RELIEF, "-sliderrelief", "sliderRelief", "SliderRelief",
- DEF_SCALE_SLIDER_RELIEF, Tk_Offset(TkScale, sliderRelief),
- TK_CONFIG_DONT_SET_DEFAULT},
- {TK_CONFIG_UID, "-state", "state", "State",
- DEF_SCALE_STATE, Tk_Offset(TkScale, state), 0},
- {TK_CONFIG_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_SCALE_TAKE_FOCUS, Tk_Offset(TkScale, takeFocus),
- TK_CONFIG_NULL_OK},
- {TK_CONFIG_DOUBLE, "-tickinterval", "tickInterval", "TickInterval",
- DEF_SCALE_TICK_INTERVAL, Tk_Offset(TkScale, tickInterval), 0},
- {TK_CONFIG_DOUBLE, "-to", "to", "To",
- DEF_SCALE_TO, Tk_Offset(TkScale, toValue), 0},
- {TK_CONFIG_COLOR, "-troughcolor", "troughColor", "Background",
- DEF_SCALE_TROUGH_COLOR, Tk_Offset(TkScale, troughColorPtr),
- TK_CONFIG_COLOR_ONLY},
- {TK_CONFIG_COLOR, "-troughcolor", "troughColor", "Background",
- DEF_SCALE_TROUGH_MONO, Tk_Offset(TkScale, troughColorPtr),
- TK_CONFIG_MONO_ONLY},
- {TK_CONFIG_STRING, "-variable", "variable", "Variable",
- DEF_SCALE_VARIABLE, Tk_Offset(TkScale, varName), TK_CONFIG_NULL_OK},
- {TK_CONFIG_PIXELS, "-width", "width", "Width",
- DEF_SCALE_WIDTH, Tk_Offset(TkScale, width), 0},
- {TK_CONFIG_END, (char *) NULL, (char *) NULL, (char *) NULL,
- (char *) NULL, 0, 0}
-};
-
-/*
- * Forward declarations for procedures defined later in this file:
- */
-
-static void ComputeFormat _ANSI_ARGS_((TkScale *scalePtr));
-static void ComputeScaleGeometry _ANSI_ARGS_((TkScale *scalePtr));
-static int ConfigureScale _ANSI_ARGS_((Tcl_Interp *interp,
- TkScale *scalePtr, int argc, char **argv,
- int flags));
-static void DestroyScale _ANSI_ARGS_((char *memPtr));
-static void ScaleCmdDeletedProc _ANSI_ARGS_((
- ClientData clientData));
-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));
-static int ScaleWidgetCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, int argc, char **argv));
-static void ScaleWorldChanged _ANSI_ARGS_((
- ClientData instanceData));
-
-/*
- * The structure below defines scale class behavior by means of procedures
- * that can be invoked from generic window code.
- */
-
-static TkClassProcs scaleClass = {
- NULL, /* createProc. */
- ScaleWorldChanged, /* geometryProc. */
- NULL /* modalProc. */
-};
-
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_ScaleCmd --
- *
- * This procedure is invoked to process the "scale" 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_ScaleCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Main window associated with
- * interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- Tk_Window tkwin = (Tk_Window) clientData;
- register TkScale *scalePtr;
- Tk_Window new;
-
- if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " pathName ?options?\"", (char *) NULL);
- return TCL_ERROR;
- }
-
- new = Tk_CreateWindowFromPath(interp, tkwin, argv[1], (char *) NULL);
- if (new == NULL) {
- return TCL_ERROR;
- }
- scalePtr = TkpCreateScale(new);
-
- /*
- * Initialize fields that won't be initialized by ConfigureScale,
- * or which ConfigureScale expects to have reasonable values
- * (e.g. resource pointers).
- */
-
- scalePtr->tkwin = new;
- scalePtr->display = Tk_Display(new);
- scalePtr->interp = interp;
- scalePtr->widgetCmd = Tcl_CreateCommand(interp,
- Tk_PathName(scalePtr->tkwin), ScaleWidgetCmd,
- (ClientData) scalePtr, ScaleCmdDeletedProc);
- scalePtr->orientUid = NULL;
- scalePtr->vertical = 0;
- scalePtr->width = 0;
- scalePtr->length = 0;
- scalePtr->value = 0;
- scalePtr->varName = NULL;
- scalePtr->fromValue = 0;
- scalePtr->toValue = 0;
- scalePtr->tickInterval = 0;
- scalePtr->resolution = 1;
- scalePtr->bigIncrement = 0.0;
- scalePtr->command = NULL;
- scalePtr->repeatDelay = 0;
- scalePtr->repeatInterval = 0;
- scalePtr->label = NULL;
- scalePtr->labelLength = 0;
- scalePtr->state = tkNormalUid;
- scalePtr->borderWidth = 0;
- scalePtr->bgBorder = NULL;
- scalePtr->activeBorder = NULL;
- scalePtr->sliderRelief = TK_RELIEF_RAISED;
- scalePtr->troughColorPtr = NULL;
- scalePtr->troughGC = None;
- scalePtr->copyGC = None;
- scalePtr->tkfont = NULL;
- scalePtr->textColorPtr = NULL;
- scalePtr->textGC = None;
- scalePtr->relief = TK_RELIEF_FLAT;
- scalePtr->highlightWidth = 0;
- scalePtr->highlightBgColorPtr = NULL;
- scalePtr->highlightColorPtr = NULL;
- scalePtr->inset = 0;
- scalePtr->sliderLength = 0;
- scalePtr->showValue = 0;
- scalePtr->horizLabelY = 0;
- scalePtr->horizValueY = 0;
- scalePtr->horizTroughY = 0;
- scalePtr->horizTickY = 0;
- scalePtr->vertTickRightX = 0;
- scalePtr->vertValueRightX = 0;
- scalePtr->vertTroughX = 0;
- scalePtr->vertLabelX = 0;
- scalePtr->cursor = None;
- scalePtr->takeFocus = NULL;
- scalePtr->flags = NEVER_SET;
-
- Tk_SetClass(scalePtr->tkwin, "Scale");
- TkSetClassProcs(scalePtr->tkwin, &scaleClass, (ClientData) scalePtr);
- Tk_CreateEventHandler(scalePtr->tkwin,
- ExposureMask|StructureNotifyMask|FocusChangeMask,
- ScaleEventProc, (ClientData) scalePtr);
- if (ConfigureScale(interp, scalePtr, argc-2, argv+2, 0) != TCL_OK) {
- goto error;
- }
-
- interp->result = Tk_PathName(scalePtr->tkwin);
- return TCL_OK;
-
- error:
- Tk_DestroyWindow(scalePtr->tkwin);
- return TCL_ERROR;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ScaleWidgetCmd --
- *
- * 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
-ScaleWidgetCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Information about scale
- * widget. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- register TkScale *scalePtr = (TkScale *) clientData;
- int result = TCL_OK;
- size_t length;
- int c;
-
- if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " option ?arg arg ...?\"", (char *) NULL);
- return TCL_ERROR;
- }
- Tcl_Preserve((ClientData) scalePtr);
- 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);
- goto error;
- }
- result = Tk_ConfigureValue(interp, scalePtr->tkwin, configSpecs,
- (char *) scalePtr, argv[2], 0);
- } else if ((c == 'c') && (strncmp(argv[1], "configure", length) == 0)
- && (length >= 3)) {
- if (argc == 2) {
- result = Tk_ConfigureInfo(interp, scalePtr->tkwin, configSpecs,
- (char *) scalePtr, (char *) NULL, 0);
- } else if (argc == 3) {
- result = Tk_ConfigureInfo(interp, scalePtr->tkwin, configSpecs,
- (char *) scalePtr, argv[2], 0);
- } else {
- result = ConfigureScale(interp, scalePtr, argc-2, argv+2,
- TK_CONFIG_ARGV_ONLY);
- }
- } else if ((c == 'c') && (strncmp(argv[1], "coords", length) == 0)
- && (length >= 3)) {
- int x, y ;
- double value;
-
- if ((argc != 2) && (argc != 3)) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " coords ?value?\"", (char *) NULL);
- goto error;
- }
- if (argc == 3) {
- if (Tcl_GetDouble(interp, argv[2], &value) != TCL_OK) {
- goto error;
- }
- } else {
- value = scalePtr->value;
- }
- if (scalePtr->vertical) {
- x = scalePtr->vertTroughX + scalePtr->width/2
- + scalePtr->borderWidth;
- y = TkpValueToPixel(scalePtr, value);
- } else {
- x = TkpValueToPixel(scalePtr, value);
- y = scalePtr->horizTroughY + scalePtr->width/2
- + scalePtr->borderWidth;
- }
- sprintf(interp->result, "%d %d", x, y);
- } else if ((c == 'g') && (strncmp(argv[1], "get", length) == 0)) {
- double value;
- int x, y;
-
- if ((argc != 2) && (argc != 4)) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " get ?x y?\"", (char *) NULL);
- goto error;
- }
- if (argc == 2) {
- value = scalePtr->value;
- } else {
- if ((Tcl_GetInt(interp, argv[2], &x) != TCL_OK)
- || (Tcl_GetInt(interp, argv[3], &y) != TCL_OK)) {
- goto error;
- }
- value = TkpPixelToValue(scalePtr, x, y);
- }
- sprintf(interp->result, scalePtr->format, value);
- } else if ((c == 'i') && (strncmp(argv[1], "identify", length) == 0)) {
- int x, y, thing;
-
- if (argc != 4) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " identify x y\"", (char *) NULL);
- goto error;
- }
- if ((Tcl_GetInt(interp, argv[2], &x) != TCL_OK)
- || (Tcl_GetInt(interp, argv[3], &y) != TCL_OK)) {
- goto error;
- }
- thing = TkpScaleElement(scalePtr, x,y);
- switch (thing) {
- case TROUGH1: interp->result = "trough1"; break;
- case SLIDER: interp->result = "slider"; break;
- case TROUGH2: interp->result = "trough2"; break;
- }
- } else if ((c == 's') && (strncmp(argv[1], "set", length) == 0)) {
- double value;
-
- if (argc != 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " set value\"", (char *) NULL);
- goto error;
- }
- if (Tcl_GetDouble(interp, argv[2], &value) != TCL_OK) {
- goto error;
- }
- if (scalePtr->state != tkDisabledUid) {
- TkpSetScaleValue(scalePtr, value, 1, 1);
- }
- } else {
- Tcl_AppendResult(interp, "bad option \"", argv[1],
- "\": must be cget, configure, coords, get, identify, or set",
- (char *) NULL);
- goto error;
- }
- Tcl_Release((ClientData) scalePtr);
- return result;
-
- error:
- Tcl_Release((ClientData) scalePtr);
- return TCL_ERROR;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * DestroyScale --
- *
- * This procedure is invoked by Tcl_EventuallyFree or Tcl_Release
- * to clean up the internal structure of a button at a safe time
- * (when no-one is using it anymore).
- *
- * Results:
- * None.
- *
- * Side effects:
- * Everything associated with the scale is freed up.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-DestroyScale(memPtr)
- char *memPtr; /* Info about scale widget. */
-{
- register TkScale *scalePtr = (TkScale *) memPtr;
-
- /*
- * Free up all the stuff that requires special handling, then
- * let Tk_FreeOptions handle all the standard option-related
- * stuff.
- */
-
- if (scalePtr->varName != NULL) {
- Tcl_UntraceVar(scalePtr->interp, scalePtr->varName,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- ScaleVarProc, (ClientData) scalePtr);
- }
- if (scalePtr->troughGC != None) {
- Tk_FreeGC(scalePtr->display, scalePtr->troughGC);
- }
- if (scalePtr->copyGC != None) {
- Tk_FreeGC(scalePtr->display, scalePtr->copyGC);
- }
- if (scalePtr->textGC != None) {
- Tk_FreeGC(scalePtr->display, scalePtr->textGC);
- }
- Tk_FreeOptions(configSpecs, (char *) scalePtr, scalePtr->display, 0);
- TkpDestroyScale(scalePtr);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ConfigureScale --
- *
- * This procedure is called to process an argv/argc list, plus
- * the Tk option database, in order to configure (or
- * reconfigure) a scale widget.
- *
- * Results:
- * The return value is a standard Tcl result. If TCL_ERROR is
- * returned, then interp->result contains an error message.
- *
- * Side effects:
- * Configuration information, such as colors, border width,
- * etc. get set for scalePtr; old resources get freed,
- * if there were any.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-ConfigureScale(interp, scalePtr, argc, argv, flags)
- Tcl_Interp *interp; /* Used for error reporting. */
- register TkScale *scalePtr; /* 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 flags; /* Flags to pass to Tk_ConfigureWidget. */
-{
- size_t length;
-
- /*
- * Eliminate any existing trace on a variable monitored by the scale.
- */
-
- if (scalePtr->varName != NULL) {
- Tcl_UntraceVar(interp, scalePtr->varName,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- ScaleVarProc, (ClientData) scalePtr);
- }
-
- if (Tk_ConfigureWidget(interp, scalePtr->tkwin, configSpecs,
- argc, argv, (char *) scalePtr, flags) != TCL_OK) {
- return TCL_ERROR;
- }
-
- /*
- * If the scale is tied to the value of a variable, then set up
- * a trace on the variable's value and set the scale's value from
- * the value of the variable, if it exists.
- */
-
- if (scalePtr->varName != NULL) {
- char *stringValue, *end;
- double value;
-
- stringValue = Tcl_GetVar(interp, scalePtr->varName, TCL_GLOBAL_ONLY);
- if (stringValue != NULL) {
- value = strtod(stringValue, &end);
- if ((end != stringValue) && (*end == 0)) {
- scalePtr->value = TkRoundToResolution(scalePtr, value);
- }
- }
- Tcl_TraceVar(interp, scalePtr->varName,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- ScaleVarProc, (ClientData) scalePtr);
- }
-
- /*
- * Several options need special processing, such as parsing the
- * orientation and creating GCs.
- */
-
- length = strlen(scalePtr->orientUid);
- if (strncmp(scalePtr->orientUid, "vertical", length) == 0) {
- scalePtr->vertical = 1;
- } else if (strncmp(scalePtr->orientUid, "horizontal", length) == 0) {
- scalePtr->vertical = 0;
- } else {
- Tcl_AppendResult(interp, "bad orientation \"", scalePtr->orientUid,
- "\": must be vertical or horizontal", (char *) NULL);
- return TCL_ERROR;
- }
-
- scalePtr->fromValue = TkRoundToResolution(scalePtr, scalePtr->fromValue);
- scalePtr->toValue = TkRoundToResolution(scalePtr, scalePtr->toValue);
- scalePtr->tickInterval = TkRoundToResolution(scalePtr,
- scalePtr->tickInterval);
-
- /*
- * Make sure that the tick interval has the right sign so that
- * addition moves from fromValue to toValue.
- */
-
- if ((scalePtr->tickInterval < 0)
- ^ ((scalePtr->toValue - scalePtr->fromValue) < 0)) {
- scalePtr->tickInterval = -scalePtr->tickInterval;
- }
-
- /*
- * Set the scale value to itself; all this does is to make sure
- * that the scale's value is within the new acceptable range for
- * the scale and reflect the value in the associated variable,
- * if any.
- */
-
- ComputeFormat(scalePtr);
- TkpSetScaleValue(scalePtr, scalePtr->value, 1, 1);
-
- if (scalePtr->label != NULL) {
- scalePtr->labelLength = strlen(scalePtr->label);
- } else {
- scalePtr->labelLength = 0;
- }
-
- if ((scalePtr->state != tkNormalUid)
- && (scalePtr->state != tkDisabledUid)
- && (scalePtr->state != tkActiveUid)) {
- Tcl_AppendResult(interp, "bad state value \"", scalePtr->state,
- "\": must be normal, active, or disabled", (char *) NULL);
- scalePtr->state = tkNormalUid;
- return TCL_ERROR;
- }
-
- Tk_SetBackgroundFromBorder(scalePtr->tkwin, scalePtr->bgBorder);
-
- if (scalePtr->highlightWidth < 0) {
- scalePtr->highlightWidth = 0;
- }
- scalePtr->inset = scalePtr->highlightWidth + scalePtr->borderWidth;
-
- ScaleWorldChanged((ClientData) scalePtr);
- return TCL_OK;
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * ScaleWorldChanged --
- *
- * 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:
- * Scale will be relayed out and redisplayed.
- *
- *---------------------------------------------------------------------------
- */
-
-static void
-ScaleWorldChanged(instanceData)
- ClientData instanceData; /* Information about widget. */
-{
- XGCValues gcValues;
- GC gc;
- TkScale *scalePtr;
-
- scalePtr = (TkScale *) instanceData;
-
- gcValues.foreground = scalePtr->troughColorPtr->pixel;
- gc = Tk_GetGC(scalePtr->tkwin, GCForeground, &gcValues);
- if (scalePtr->troughGC != None) {
- Tk_FreeGC(scalePtr->display, scalePtr->troughGC);
- }
- scalePtr->troughGC = gc;
-
- gcValues.font = Tk_FontId(scalePtr->tkfont);
- gcValues.foreground = scalePtr->textColorPtr->pixel;
- gc = Tk_GetGC(scalePtr->tkwin, GCForeground | GCFont, &gcValues);
- if (scalePtr->textGC != None) {
- Tk_FreeGC(scalePtr->display, scalePtr->textGC);
- }
- scalePtr->textGC = gc;
-
- if (scalePtr->copyGC == None) {
- gcValues.graphics_exposures = False;
- scalePtr->copyGC = Tk_GetGC(scalePtr->tkwin, GCGraphicsExposures,
- &gcValues);
- }
- scalePtr->inset = scalePtr->highlightWidth + scalePtr->borderWidth;
-
- /*
- * Recompute display-related information, and let the geometry
- * manager know how much space is needed now.
- */
-
- ComputeScaleGeometry(scalePtr);
-
- TkEventuallyRedrawScale(scalePtr, REDRAW_ALL);
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ComputeFormat --
- *
- * This procedure is invoked to recompute the "format" field
- * of a scale's widget record, which determines how the value
- * of the scale is converted to a string.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The format field of scalePtr is modified.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-ComputeFormat(scalePtr)
- TkScale *scalePtr; /* Information about scale 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 scale's range.
- */
-
- maxValue = fabs(scalePtr->fromValue);
- x = fabs(scalePtr->toValue);
- if (x > maxValue) {
- maxValue = x;
- }
- if (maxValue == 0) {
- maxValue = 1;
- }
- mostSigDigit = (int) floor(log10(maxValue));
-
- /*
- * If the number of significant digits wasn't specified explicitly,
- * compute it. It's the difference between the most significant
- * digit needed to represent any number on the scale and the
- * most significant digit of the smallest difference between
- * numbers on the scale. In other words, display enough digits so
- * that at least one digit will be different between any two adjacent
- * positions of the scale.
- */
-
- numDigits = scalePtr->digits;
- if (numDigits <= 0) {
- if (scalePtr->resolution > 0) {
- /*
- * A resolution was specified for the scale, so just use it.
- */
-
- leastSigDigit = (int) floor(log10(scalePtr->resolution));
- } else {
- /*
- * No resolution was specified, so compute the difference
- * in value between adjacent pixels and use it for the least
- * significant digit.
- */
-
- x = fabs(scalePtr->fromValue - scalePtr->toValue);
- if (scalePtr->length > 0) {
- x /= scalePtr->length;
- }
- if (x > 0){
- leastSigDigit = (int) floor(log10(x));
- } 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(scalePtr->format, "%%.%df", afterDecimal);
- } else {
- sprintf(scalePtr->format, "%%.%de", numDigits-1);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ComputeScaleGeometry --
- *
- * This procedure is called to compute various geometrical
- * information for a scale, 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 *scalePtr. The
- * geometry manager gets told about the window's preferred size.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-ComputeScaleGeometry(scalePtr)
- register TkScale *scalePtr; /* Information about widget. */
-{
- char valueString[PRINT_CHARS];
- int tmp, valuePixels, x, y, extraSpace;
- Tk_FontMetrics fm;
-
- /*
- * Horizontal scales are simpler than vertical ones because
- * all sizes are the same (the height of a line of text);
- * handle them first and then quit.
- */
-
- Tk_GetFontMetrics(scalePtr->tkfont, &fm);
- if (!scalePtr->vertical) {
- y = scalePtr->inset;
- extraSpace = 0;
- if (scalePtr->labelLength != 0) {
- scalePtr->horizLabelY = y + SPACING;
- y += fm.linespace + SPACING;
- extraSpace = SPACING;
- }
- if (scalePtr->showValue) {
- scalePtr->horizValueY = y + SPACING;
- y += fm.linespace + SPACING;
- extraSpace = SPACING;
- } else {
- scalePtr->horizValueY = y;
- }
- y += extraSpace;
- scalePtr->horizTroughY = y;
- y += scalePtr->width + 2*scalePtr->borderWidth;
- if (scalePtr->tickInterval != 0) {
- scalePtr->horizTickY = y + SPACING;
- y += fm.linespace + 2*SPACING;
- }
- Tk_GeometryRequest(scalePtr->tkwin,
- scalePtr->length + 2*scalePtr->inset, y + scalePtr->inset);
- Tk_SetInternalBorder(scalePtr->tkwin, scalePtr->inset);
- return;
- }
-
- /*
- * Vertical scale: compute the amount of space needed to display
- * the scales value by formatting strings for the two end points;
- * use whichever length is longer.
- */
-
- sprintf(valueString, scalePtr->format, scalePtr->fromValue);
- valuePixels = Tk_TextWidth(scalePtr->tkfont, valueString, -1);
-
- sprintf(valueString, scalePtr->format, scalePtr->toValue);
- tmp = Tk_TextWidth(scalePtr->tkfont, valueString, -1);
- if (valuePixels < tmp) {
- valuePixels = tmp;
- }
-
- /*
- * Assign x-locations to the elements of the scale, working from
- * left to right.
- */
-
- x = scalePtr->inset;
- if ((scalePtr->tickInterval != 0) && (scalePtr->showValue)) {
- scalePtr->vertTickRightX = x + SPACING + valuePixels;
- scalePtr->vertValueRightX = scalePtr->vertTickRightX + valuePixels
- + fm.ascent/2;
- x = scalePtr->vertValueRightX + SPACING;
- } else if (scalePtr->tickInterval != 0) {
- scalePtr->vertTickRightX = x + SPACING + valuePixels;
- scalePtr->vertValueRightX = scalePtr->vertTickRightX;
- x = scalePtr->vertTickRightX + SPACING;
- } else if (scalePtr->showValue) {
- scalePtr->vertTickRightX = x;
- scalePtr->vertValueRightX = x + SPACING + valuePixels;
- x = scalePtr->vertValueRightX + SPACING;
- } else {
- scalePtr->vertTickRightX = x;
- scalePtr->vertValueRightX = x;
- }
- scalePtr->vertTroughX = x;
- x += 2*scalePtr->borderWidth + scalePtr->width;
- if (scalePtr->labelLength == 0) {
- scalePtr->vertLabelX = 0;
- } else {
- scalePtr->vertLabelX = x + fm.ascent/2;
- x = scalePtr->vertLabelX + fm.ascent/2
- + Tk_TextWidth(scalePtr->tkfont, scalePtr->label,
- scalePtr->labelLength);
- }
- Tk_GeometryRequest(scalePtr->tkwin, x + scalePtr->inset,
- scalePtr->length + 2*scalePtr->inset);
- Tk_SetInternalBorder(scalePtr->tkwin, scalePtr->inset);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ScaleEventProc --
- *
- * This procedure is invoked by the Tk dispatcher for various
- * events on scales.
- *
- * Results:
- * None.
- *
- * Side effects:
- * When the window gets deleted, internal structures get
- * cleaned up. When it gets exposed, it is redisplayed.
- *
- *--------------------------------------------------------------
- */
-
-static void
-ScaleEventProc(clientData, eventPtr)
- ClientData clientData; /* Information about window. */
- XEvent *eventPtr; /* Information about event. */
-{
- TkScale *scalePtr = (TkScale *) clientData;
-
- if ((eventPtr->type == Expose) && (eventPtr->xexpose.count == 0)) {
- TkEventuallyRedrawScale(scalePtr, REDRAW_ALL);
- } else if (eventPtr->type == DestroyNotify) {
- if (scalePtr->tkwin != NULL) {
- scalePtr->tkwin = NULL;
- Tcl_DeleteCommandFromToken(scalePtr->interp, scalePtr->widgetCmd);
- }
- if (scalePtr->flags & REDRAW_ALL) {
- Tcl_CancelIdleCall(TkpDisplayScale, (ClientData) scalePtr);
- }
- Tcl_EventuallyFree((ClientData) scalePtr, DestroyScale);
- } else if (eventPtr->type == ConfigureNotify) {
- ComputeScaleGeometry(scalePtr);
- TkEventuallyRedrawScale(scalePtr, REDRAW_ALL);
- } else if (eventPtr->type == FocusIn) {
- if (eventPtr->xfocus.detail != NotifyInferior) {
- scalePtr->flags |= GOT_FOCUS;
- if (scalePtr->highlightWidth > 0) {
- TkEventuallyRedrawScale(scalePtr, REDRAW_ALL);
- }
- }
- } else if (eventPtr->type == FocusOut) {
- if (eventPtr->xfocus.detail != NotifyInferior) {
- scalePtr->flags &= ~GOT_FOCUS;
- if (scalePtr->highlightWidth > 0) {
- TkEventuallyRedrawScale(scalePtr, REDRAW_ALL);
- }
- }
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ScaleCmdDeletedProc --
- *
- * 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
-ScaleCmdDeletedProc(clientData)
- ClientData clientData; /* Pointer to widget record for widget. */
-{
- TkScale *scalePtr = (TkScale *) clientData;
- Tk_Window tkwin = scalePtr->tkwin;
-
- /*
- * This procedure could be invoked either because the window was
- * destroyed and the command was then deleted (in which case tkwin
- * is NULL) or because the command was deleted, and then this procedure
- * destroys the widget.
- */
-
- if (tkwin != NULL) {
- scalePtr->tkwin = NULL;
- Tk_DestroyWindow(tkwin);
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * TkEventuallyRedrawScale --
- *
- * Arrange for part or all of a scale widget to redrawn at
- * the next convenient time in the future.
- *
- * Results:
- * None.
- *
- * Side effects:
- * If "what" is REDRAW_SLIDER then just the slider and the
- * value readout will be redrawn; if "what" is REDRAW_ALL
- * then the entire widget will be redrawn.
- *
- *--------------------------------------------------------------
- */
-
-void
-TkEventuallyRedrawScale(scalePtr, what)
- register TkScale *scalePtr; /* Information about widget. */
- int what; /* What to redraw: REDRAW_SLIDER
- * or REDRAW_ALL. */
-{
- if ((what == 0) || (scalePtr->tkwin == NULL)
- || !Tk_IsMapped(scalePtr->tkwin)) {
- return;
- }
- if ((scalePtr->flags & REDRAW_ALL) == 0) {
- Tcl_DoWhenIdle(TkpDisplayScale, (ClientData) scalePtr);
- }
- scalePtr->flags |= what;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * TkRoundToResolution --
- *
- * Round a given floating-point value to the nearest multiple
- * of the scale's resolution.
- *
- * Results:
- * The return value is the rounded result.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-double
-TkRoundToResolution(scalePtr, value)
- TkScale *scalePtr; /* Information about scale widget. */
- double value; /* Value to round. */
-{
- double rem, new;
-
- if (scalePtr->resolution <= 0) {
- return value;
- }
- new = scalePtr->resolution * floor(value/scalePtr->resolution);
- rem = value - new;
- if (rem < 0) {
- if (rem <= -scalePtr->resolution/2) {
- new -= scalePtr->resolution;
- }
- } else {
- if (rem >= scalePtr->resolution/2) {
- new += scalePtr->resolution;
- }
- }
- return new;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ScaleVarProc --
- *
- * This procedure is invoked by Tcl whenever someone modifies a
- * variable associated with a scale widget.
- *
- * Results:
- * NULL is always returned.
- *
- * Side effects:
- * The value displayed in the scale will change to match the
- * variable's new value. If the variable has a bogus value then
- * it is reset to the value of the scale.
- *
- *----------------------------------------------------------------------
- */
-
- /* ARGSUSED */
-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. */
- int flags; /* Information about what happened. */
-{
- register TkScale *scalePtr = (TkScale *) clientData;
- char *stringValue, *end, *result;
- double value;
-
- /*
- * If the variable is unset, then immediately recreate it unless
- * the whole interpreter is going away.
- */
-
- if (flags & TCL_TRACE_UNSETS) {
- if ((flags & TCL_TRACE_DESTROYED) && !(flags & TCL_INTERP_DESTROYED)) {
- Tcl_TraceVar(interp, scalePtr->varName,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- ScaleVarProc, clientData);
- scalePtr->flags |= NEVER_SET;
- TkpSetScaleValue(scalePtr, scalePtr->value, 1, 0);
- }
- return (char *) NULL;
- }
-
- /*
- * If we came here because we updated the variable (in TkpSetScaleValue),
- * then ignore the trace. Otherwise update the scale with the value
- * of the variable.
- */
-
- if (scalePtr->flags & SETTING_VAR) {
- return (char *) NULL;
- }
- result = NULL;
- stringValue = Tcl_GetVar(interp, scalePtr->varName, TCL_GLOBAL_ONLY);
- if (stringValue != NULL) {
- value = strtod(stringValue, &end);
- if ((end == stringValue) || (*end != 0)) {
- result = "can't assign non-numeric value to scale variable";
- } else {
- scalePtr->value = TkRoundToResolution(scalePtr, value);
- }
-
- /*
- * This code is a bit tricky because it sets the scale's value before
- * calling TkpSetScaleValue. This way, TkpSetScaleValue won't bother
- * to set the variable again or to invoke the -command. However, it
- * also won't redisplay the scale, so we have to ask for that
- * explicitly.
- */
-
- TkpSetScaleValue(scalePtr, scalePtr->value, 1, 0);
- TkEventuallyRedrawScale(scalePtr, REDRAW_SLIDER);
- }
-
- return result;
-}
diff --git a/generic/tkScale.h b/generic/tkScale.h
deleted file mode 100644
index 7200fb2..0000000
--- a/generic/tkScale.h
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * tkScale.h --
- *
- * Declarations of types and functions used to implement
- * the scale widget.
- *
- * Copyright (c) 1996 by 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: tkScale.h,v 1.4 1998/09/14 18:23:17 stanton Exp $
- */
-
-#ifndef _TKSCALE
-#define _TKSCALE
-
-#ifndef _TK
-#include "tk.h"
-#endif
-
-#ifdef BUILD_tk
-# undef TCL_STORAGE_CLASS
-# define TCL_STORAGE_CLASS DLLEXPORT
-#endif
-
-/*
- * A data structure of the following type is kept for each scale
- * widget managed by this file:
- */
-
-typedef struct TkScale {
- Tk_Window tkwin; /* Window that embodies the scale. NULL
- * means that the window has been destroyed
- * but the data structures haven't yet been
- * cleaned up.*/
- Display *display; /* Display containing widget. Used, among
- * other things, so that resources can be
- * freed even after tkwin has gone away. */
- Tcl_Interp *interp; /* Interpreter associated with scale. */
- Tcl_Command widgetCmd; /* Token for scale's widget command. */
- Tk_Uid orientUid; /* Orientation for window ("vertical" or
- * "horizontal"). */
- int vertical; /* Non-zero means vertical orientation,
- * zero means horizontal. */
- int width; /* Desired narrow dimension of scale,
- * in pixels. */
- int length; /* Desired long dimension of scale,
- * in pixels. */
- double value; /* Current value of scale. */
- char *varName; /* Name of variable (malloc'ed) or NULL.
- * If non-NULL, scale's value tracks
- * the contents of this variable and
- * vice versa. */
- double fromValue; /* Value corresponding to left or top of
- * scale. */
- double toValue; /* Value corresponding to right or bottom
- * of scale. */
- double tickInterval; /* Distance between tick marks; 0 means
- * don't display any tick marks. */
- double resolution; /* If > 0, all values are rounded to an
- * even multiple of this value. */
- int digits; /* Number of significant digits to print
- * in values. 0 means we get to choose the
- * number based on resolution and/or the
- * range of the scale. */
- char format[10]; /* Sprintf conversion specifier computed from
- * digits and other information. */
- double bigIncrement; /* Amount to use for large increments to
- * scale value. (0 means we pick a value). */
- char *command; /* Command prefix to use when invoking Tcl
- * commands because the scale value changed.
- * NULL means don't invoke commands.
- * Malloc'ed. */
- int repeatDelay; /* How long to wait before auto-repeating
- * on scrolling actions (in ms). */
- int repeatInterval; /* Interval between autorepeats (in ms). */
- char *label; /* Label to display above or to right of
- * scale; NULL means don't display a
- * label. Malloc'ed. */
- int labelLength; /* Number of non-NULL chars. in label. */
- Tk_Uid state; /* Normal or disabled. Value cannot be
- * changed when scale is disabled. */
-
- /*
- * Information used when displaying widget:
- */
-
- int borderWidth; /* Width of 3-D border around window. */
- Tk_3DBorder bgBorder; /* Used for drawing slider and other
- * background areas. */
- Tk_3DBorder activeBorder; /* For drawing the slider when active. */
- int sliderRelief; /* Is slider to be drawn raised, sunken, etc. */
- XColor *troughColorPtr; /* Color for drawing trough. */
- GC troughGC; /* For drawing trough. */
- GC copyGC; /* Used for copying from pixmap onto screen. */
- Tk_Font tkfont; /* Information about text font, or NULL. */
- XColor *textColorPtr; /* Color for drawing text. */
- GC textGC; /* GC for drawing text in normal mode. */
- int relief; /* Indicates whether window as a whole is
- * raised, sunken, or flat. */
- int highlightWidth; /* Width in pixels of highlight to draw
- * around widget when it has the focus.
- * <= 0 means don't draw a highlight. */
- XColor *highlightBgColorPtr;
- /* Color for drawing traversal highlight
- * area when highlight is off. */
- XColor *highlightColorPtr; /* Color for drawing traversal highlight. */
- int inset; /* Total width of all borders, including
- * traversal highlight and 3-D border.
- * Indicates how much interior stuff must
- * be offset from outside edges to leave
- * room for borders. */
- int sliderLength; /* Length of slider, measured in pixels along
- * long dimension of scale. */
- int showValue; /* Non-zero means to display the scale value
- * below or to the left of the slider; zero
- * means don't display the value. */
-
- /*
- * Layout information for horizontal scales, assuming that window
- * gets the size it requested:
- */
-
- int horizLabelY; /* Y-coord at which to draw label. */
- int horizValueY; /* Y-coord at which to draw value text. */
- int horizTroughY; /* Y-coord of top of slider trough. */
- int horizTickY; /* Y-coord at which to draw tick text. */
- /*
- * Layout information for vertical scales, assuming that window
- * gets the size it requested:
- */
-
- int vertTickRightX; /* X-location of right side of tick-marks. */
- int vertValueRightX; /* X-location of right side of value string. */
- int vertTroughX; /* X-location of scale's slider trough. */
- int vertLabelX; /* X-location of origin of label. */
-
- /*
- * Miscellaneous information:
- */
-
- Tk_Cursor cursor; /* Current cursor for window, or None. */
- char *takeFocus; /* Value of -takefocus option; not used in
- * the C code, but used by keyboard traversal
- * scripts. Malloc'ed, but may be NULL. */
- int flags; /* Various flags; see below for
- * definitions. */
-} TkScale;
-
-/*
- * Flag bits for scales:
- *
- * REDRAW_SLIDER - 1 means slider (and numerical readout) need
- * to be redrawn.
- * REDRAW_OTHER - 1 means other stuff besides slider and value
- * need to be redrawn.
- * REDRAW_ALL - 1 means the entire widget needs to be redrawn.
- * ACTIVE - 1 means the widget is active (the mouse is
- * in its window).
- * INVOKE_COMMAND - 1 means the scale's command needs to be
- * invoked during the next redisplay (the
- * value of the scale has changed since the
- * last time the command was invoked).
- * SETTING_VAR - 1 means that the associated variable is
- * being set by us, so there's no need for
- * ScaleVarProc to do anything.
- * NEVER_SET - 1 means that the scale's value has never
- * been set before (so must invoke -command and
- * set associated variable even if the value
- * doesn't appear to have changed).
- * GOT_FOCUS - 1 means that the focus is currently in
- * this widget.
- */
-
-#define REDRAW_SLIDER 1
-#define REDRAW_OTHER 2
-#define REDRAW_ALL 3
-#define ACTIVE 4
-#define INVOKE_COMMAND 0x10
-#define SETTING_VAR 0x20
-#define NEVER_SET 0x40
-#define GOT_FOCUS 0x80
-
-/*
- * Symbolic values for the active parts of a slider. These are
- * the values that may be returned by the ScaleElement procedure.
- */
-
-#define OTHER 0
-#define TROUGH1 1
-#define SLIDER 2
-#define TROUGH2 3
-
-/*
- * Space to leave between scale area and text, and between text and
- * edge of window.
- */
-
-#define SPACING 2
-
-/*
- * How many characters of space to provide when formatting the
- * scale's value:
- */
-
-#define PRINT_CHARS 150
-
-/*
- * Declaration of procedures used in the implementation of the scrollbar
- * widget.
- */
-
-EXTERN void TkEventuallyRedrawScale _ANSI_ARGS_((TkScale *scalePtr,
- int what));
-EXTERN double TkRoundToResolution _ANSI_ARGS_((TkScale *scalePtr,
- double value));
-EXTERN TkScale * TkpCreateScale _ANSI_ARGS_((Tk_Window tkwin));
-EXTERN void TkpDestroyScale _ANSI_ARGS_((TkScale *scalePtr));
-EXTERN void TkpDisplayScale _ANSI_ARGS_((ClientData clientData));
-EXTERN double TkpPixelToValue _ANSI_ARGS_((TkScale *scalePtr,
- int x, int y));
-EXTERN int TkpScaleElement _ANSI_ARGS_((TkScale *scalePtr,
- int x, int y));
-EXTERN void TkpSetScaleValue _ANSI_ARGS_((TkScale *scalePtr,
- double value, int setVar, int invokeCommand));
-EXTERN int TkpValueToPixel _ANSI_ARGS_((TkScale *scalePtr,
- double value));
-
-# undef TCL_STORAGE_CLASS
-# define TCL_STORAGE_CLASS DLLIMPORT
-
-#endif /* _TKSCALE */
diff --git a/generic/tkScrollbar.c b/generic/tkScrollbar.c
deleted file mode 100644
index 0b90160..0000000
--- a/generic/tkScrollbar.c
+++ /dev/null
@@ -1,691 +0,0 @@
-/*
- * tkScrollbar.c --
- *
- * This module implements a scrollbar widgets for the Tk
- * toolkit. A scrollbar displays a slider and two arrows;
- * mouse clicks on features within the scrollbar cause
- * scrolling commands to be invoked.
- *
- * Copyright (c) 1990-1994 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: tkScrollbar.c,v 1.2 1998/09/14 18:23:17 stanton Exp $
- */
-
-#include "tkPort.h"
-#include "tkScrollbar.h"
-#include "default.h"
-
-/*
- * Information used for argv parsing.
- */
-
-Tk_ConfigSpec tkpScrollbarConfigSpecs[] = {
- {TK_CONFIG_BORDER, "-activebackground", "activeBackground", "Foreground",
- DEF_SCROLLBAR_ACTIVE_BG_COLOR, Tk_Offset(TkScrollbar, activeBorder),
- TK_CONFIG_COLOR_ONLY},
- {TK_CONFIG_BORDER, "-activebackground", "activeBackground", "Foreground",
- DEF_SCROLLBAR_ACTIVE_BG_MONO, Tk_Offset(TkScrollbar, activeBorder),
- TK_CONFIG_MONO_ONLY},
- {TK_CONFIG_RELIEF, "-activerelief", "activeRelief", "Relief",
- DEF_SCROLLBAR_ACTIVE_RELIEF, Tk_Offset(TkScrollbar, activeRelief), 0},
- {TK_CONFIG_BORDER, "-background", "background", "Background",
- DEF_SCROLLBAR_BG_COLOR, Tk_Offset(TkScrollbar, bgBorder),
- TK_CONFIG_COLOR_ONLY},
- {TK_CONFIG_BORDER, "-background", "background", "Background",
- DEF_SCROLLBAR_BG_MONO, Tk_Offset(TkScrollbar, bgBorder),
- 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_SCROLLBAR_BORDER_WIDTH, Tk_Offset(TkScrollbar, borderWidth), 0},
- {TK_CONFIG_STRING, "-command", "command", "Command",
- DEF_SCROLLBAR_COMMAND, Tk_Offset(TkScrollbar, command),
- TK_CONFIG_NULL_OK},
- {TK_CONFIG_ACTIVE_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_SCROLLBAR_CURSOR, Tk_Offset(TkScrollbar, cursor), TK_CONFIG_NULL_OK},
- {TK_CONFIG_PIXELS, "-elementborderwidth", "elementBorderWidth",
- "BorderWidth", DEF_SCROLLBAR_EL_BORDER_WIDTH,
- Tk_Offset(TkScrollbar, elementBorderWidth), 0},
- {TK_CONFIG_COLOR, "-highlightbackground", "highlightBackground",
- "HighlightBackground", DEF_SCROLLBAR_HIGHLIGHT_BG,
- Tk_Offset(TkScrollbar, highlightBgColorPtr), 0},
- {TK_CONFIG_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_SCROLLBAR_HIGHLIGHT,
- Tk_Offset(TkScrollbar, highlightColorPtr), 0},
- {TK_CONFIG_PIXELS, "-highlightthickness", "highlightThickness",
- "HighlightThickness",
- DEF_SCROLLBAR_HIGHLIGHT_WIDTH, Tk_Offset(TkScrollbar, highlightWidth), 0},
- {TK_CONFIG_BOOLEAN, "-jump", "jump", "Jump",
- DEF_SCROLLBAR_JUMP, Tk_Offset(TkScrollbar, jump), 0},
- {TK_CONFIG_UID, "-orient", "orient", "Orient",
- DEF_SCROLLBAR_ORIENT, Tk_Offset(TkScrollbar, orientUid), 0},
- {TK_CONFIG_RELIEF, "-relief", "relief", "Relief",
- DEF_SCROLLBAR_RELIEF, Tk_Offset(TkScrollbar, relief), 0},
- {TK_CONFIG_INT, "-repeatdelay", "repeatDelay", "RepeatDelay",
- DEF_SCROLLBAR_REPEAT_DELAY, Tk_Offset(TkScrollbar, repeatDelay), 0},
- {TK_CONFIG_INT, "-repeatinterval", "repeatInterval", "RepeatInterval",
- DEF_SCROLLBAR_REPEAT_INTERVAL, Tk_Offset(TkScrollbar, repeatInterval), 0},
- {TK_CONFIG_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_SCROLLBAR_TAKE_FOCUS, Tk_Offset(TkScrollbar, takeFocus),
- TK_CONFIG_NULL_OK},
- {TK_CONFIG_COLOR, "-troughcolor", "troughColor", "Background",
- DEF_SCROLLBAR_TROUGH_COLOR, Tk_Offset(TkScrollbar, troughColorPtr),
- TK_CONFIG_COLOR_ONLY},
- {TK_CONFIG_COLOR, "-troughcolor", "troughColor", "Background",
- DEF_SCROLLBAR_TROUGH_MONO, Tk_Offset(TkScrollbar, troughColorPtr),
- TK_CONFIG_MONO_ONLY},
- {TK_CONFIG_PIXELS, "-width", "width", "Width",
- DEF_SCROLLBAR_WIDTH, Tk_Offset(TkScrollbar, width), 0},
- {TK_CONFIG_END, (char *) NULL, (char *) NULL, (char *) NULL,
- (char *) NULL, 0, 0}
-};
-
-/*
- * Forward declarations for procedures defined later in this file:
- */
-
-static int ConfigureScrollbar _ANSI_ARGS_((Tcl_Interp *interp,
- TkScrollbar *scrollPtr, int argc, char **argv,
- int flags));
-static void ScrollbarCmdDeletedProc _ANSI_ARGS_((
- ClientData clientData));
-static int ScrollbarWidgetCmd _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *, int argc, char **argv));
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_ScrollbarCmd --
- *
- * This procedure is invoked to process the "scrollbar" 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_ScrollbarCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Main window associated with
- * interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- Tk_Window tkwin = (Tk_Window) clientData;
- register TkScrollbar *scrollPtr;
- Tk_Window new;
-
- if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " pathName ?options?\"", (char *) NULL);
- return TCL_ERROR;
- }
-
- new = Tk_CreateWindowFromPath(interp, tkwin, argv[1], (char *) NULL);
- if (new == NULL) {
- return TCL_ERROR;
- }
-
- Tk_SetClass(new, "Scrollbar");
- scrollPtr = TkpCreateScrollbar(new);
-
- TkSetClassProcs(new, &tkpScrollbarProcs, (ClientData) scrollPtr);
-
- /*
- * Initialize fields that won't be initialized by ConfigureScrollbar,
- * or which ConfigureScrollbar expects to have reasonable values
- * (e.g. resource pointers).
- */
-
- scrollPtr->tkwin = new;
- scrollPtr->display = Tk_Display(new);
- scrollPtr->interp = interp;
- scrollPtr->widgetCmd = Tcl_CreateCommand(interp,
- Tk_PathName(scrollPtr->tkwin), ScrollbarWidgetCmd,
- (ClientData) scrollPtr, ScrollbarCmdDeletedProc);
- scrollPtr->orientUid = NULL;
- scrollPtr->vertical = 0;
- scrollPtr->width = 0;
- scrollPtr->command = NULL;
- scrollPtr->commandSize = 0;
- scrollPtr->repeatDelay = 0;
- scrollPtr->repeatInterval = 0;
- scrollPtr->borderWidth = 0;
- scrollPtr->bgBorder = NULL;
- scrollPtr->activeBorder = NULL;
- scrollPtr->troughColorPtr = NULL;
- scrollPtr->relief = TK_RELIEF_FLAT;
- scrollPtr->highlightWidth = 0;
- scrollPtr->highlightBgColorPtr = NULL;
- scrollPtr->highlightColorPtr = NULL;
- scrollPtr->inset = 0;
- scrollPtr->elementBorderWidth = -1;
- scrollPtr->arrowLength = 0;
- scrollPtr->sliderFirst = 0;
- scrollPtr->sliderLast = 0;
- scrollPtr->activeField = 0;
- scrollPtr->activeRelief = TK_RELIEF_RAISED;
- scrollPtr->totalUnits = 0;
- scrollPtr->windowUnits = 0;
- scrollPtr->firstUnit = 0;
- scrollPtr->lastUnit = 0;
- scrollPtr->firstFraction = 0.0;
- scrollPtr->lastFraction = 0.0;
- scrollPtr->cursor = None;
- scrollPtr->takeFocus = NULL;
- scrollPtr->flags = 0;
-
- if (ConfigureScrollbar(interp, scrollPtr, argc-2, argv+2, 0) != TCL_OK) {
- Tk_DestroyWindow(scrollPtr->tkwin);
- return TCL_ERROR;
- }
-
- interp->result = Tk_PathName(scrollPtr->tkwin);
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * ScrollbarWidgetCmd --
- *
- * 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
-ScrollbarWidgetCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Information about scrollbar
- * widget. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- register TkScrollbar *scrollPtr = (TkScrollbar *) clientData;
- int result = TCL_OK;
- size_t length;
- int c;
-
- if (argc < 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " option ?arg arg ...?\"", (char *) NULL);
- return TCL_ERROR;
- }
- Tcl_Preserve((ClientData) scrollPtr);
- c = argv[1][0];
- length = strlen(argv[1]);
- if ((c == 'a') && (strncmp(argv[1], "activate", length) == 0)) {
- int oldActiveField;
- if (argc == 2) {
- switch (scrollPtr->activeField) {
- case TOP_ARROW: interp->result = "arrow1"; break;
- case SLIDER: interp->result = "slider"; break;
- case BOTTOM_ARROW: interp->result = "arrow2"; break;
- }
- goto done;
- }
- if (argc != 3) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " activate element\"", (char *) NULL);
- goto error;
- }
- c = argv[2][0];
- length = strlen(argv[2]);
- oldActiveField = scrollPtr->activeField;
- if ((c == 'a') && (strcmp(argv[2], "arrow1") == 0)) {
- scrollPtr->activeField = TOP_ARROW;
- } else if ((c == 'a') && (strcmp(argv[2], "arrow2") == 0)) {
- scrollPtr->activeField = BOTTOM_ARROW;
- } else if ((c == 's') && (strncmp(argv[2], "slider", length) == 0)) {
- scrollPtr->activeField = SLIDER;
- } else {
- scrollPtr->activeField = OUTSIDE;
- }
- if (oldActiveField != scrollPtr->activeField) {
- TkScrollbarEventuallyRedraw(scrollPtr);
- }
- } else 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);
- goto error;
- }
- result = Tk_ConfigureValue(interp, scrollPtr->tkwin,
- tkpScrollbarConfigSpecs, (char *) scrollPtr, argv[2], 0);
- } else if ((c == 'c') && (strncmp(argv[1], "configure", length) == 0)
- && (length >= 2)) {
- if (argc == 2) {
- result = Tk_ConfigureInfo(interp, scrollPtr->tkwin,
- tkpScrollbarConfigSpecs, (char *) scrollPtr,
- (char *) NULL, 0);
- } else if (argc == 3) {
- result = Tk_ConfigureInfo(interp, scrollPtr->tkwin,
- tkpScrollbarConfigSpecs, (char *) scrollPtr, argv[2], 0);
- } else {
- result = ConfigureScrollbar(interp, scrollPtr, argc-2, argv+2,
- TK_CONFIG_ARGV_ONLY);
- }
- } else if ((c == 'd') && (strncmp(argv[1], "delta", length) == 0)) {
- int xDelta, yDelta, pixels, length;
- double fraction;
-
- if (argc != 4) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " delta xDelta yDelta\"", (char *) NULL);
- goto error;
- }
- if ((Tcl_GetInt(interp, argv[2], &xDelta) != TCL_OK)
- || (Tcl_GetInt(interp, argv[3], &yDelta) != TCL_OK)) {
- goto error;
- }
- if (scrollPtr->vertical) {
- pixels = yDelta;
- length = Tk_Height(scrollPtr->tkwin) - 1
- - 2*(scrollPtr->arrowLength + scrollPtr->inset);
- } else {
- pixels = xDelta;
- length = Tk_Width(scrollPtr->tkwin) - 1
- - 2*(scrollPtr->arrowLength + scrollPtr->inset);
- }
- if (length == 0) {
- fraction = 0.0;
- } else {
- fraction = ((double) pixels / (double) length);
- }
- sprintf(interp->result, "%g", fraction);
- } else if ((c == 'f') && (strncmp(argv[1], "fraction", length) == 0)) {
- int x, y, pos, length;
- double fraction;
-
- if (argc != 4) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " fraction x y\"", (char *) NULL);
- goto error;
- }
- if ((Tcl_GetInt(interp, argv[2], &x) != TCL_OK)
- || (Tcl_GetInt(interp, argv[3], &y) != TCL_OK)) {
- goto error;
- }
- if (scrollPtr->vertical) {
- pos = y - (scrollPtr->arrowLength + scrollPtr->inset);
- length = Tk_Height(scrollPtr->tkwin) - 1
- - 2*(scrollPtr->arrowLength + scrollPtr->inset);
- } else {
- pos = x - (scrollPtr->arrowLength + scrollPtr->inset);
- length = Tk_Width(scrollPtr->tkwin) - 1
- - 2*(scrollPtr->arrowLength + scrollPtr->inset);
- }
- if (length == 0) {
- fraction = 0.0;
- } else {
- fraction = ((double) pos / (double) length);
- }
- if (fraction < 0) {
- fraction = 0;
- } else if (fraction > 1.0) {
- fraction = 1.0;
- }
- sprintf(interp->result, "%g", fraction);
- } else if ((c == 'g') && (strncmp(argv[1], "get", length) == 0)) {
- if (argc != 2) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " get\"", (char *) NULL);
- goto error;
- }
- if (scrollPtr->flags & NEW_STYLE_COMMANDS) {
- char first[TCL_DOUBLE_SPACE], last[TCL_DOUBLE_SPACE];
-
- Tcl_PrintDouble(interp, scrollPtr->firstFraction, first);
- Tcl_PrintDouble(interp, scrollPtr->lastFraction, last);
- Tcl_AppendResult(interp, first, " ", last, (char *) NULL);
- } else {
- sprintf(interp->result, "%d %d %d %d", scrollPtr->totalUnits,
- scrollPtr->windowUnits, scrollPtr->firstUnit,
- scrollPtr->lastUnit);
- }
- } else if ((c == 'i') && (strncmp(argv[1], "identify", length) == 0)) {
- int x, y, thing;
-
- if (argc != 4) {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " identify x y\"", (char *) NULL);
- goto error;
- }
- if ((Tcl_GetInt(interp, argv[2], &x) != TCL_OK)
- || (Tcl_GetInt(interp, argv[3], &y) != TCL_OK)) {
- goto error;
- }
- thing = TkpScrollbarPosition(scrollPtr, x,y);
- switch (thing) {
- case TOP_ARROW: interp->result = "arrow1"; break;
- case TOP_GAP: interp->result = "trough1"; break;
- case SLIDER: interp->result = "slider"; break;
- case BOTTOM_GAP: interp->result = "trough2"; break;
- case BOTTOM_ARROW: interp->result = "arrow2"; break;
- }
- } else if ((c == 's') && (strncmp(argv[1], "set", length) == 0)) {
- int totalUnits, windowUnits, firstUnit, lastUnit;
-
- if (argc == 4) {
- double first, last;
-
- if (Tcl_GetDouble(interp, argv[2], &first) != TCL_OK) {
- goto error;
- }
- if (Tcl_GetDouble(interp, argv[3], &last) != TCL_OK) {
- goto error;
- }
- if (first < 0) {
- scrollPtr->firstFraction = 0;
- } else if (first > 1.0) {
- scrollPtr->firstFraction = 1.0;
- } else {
- scrollPtr->firstFraction = first;
- }
- if (last < scrollPtr->firstFraction) {
- scrollPtr->lastFraction = scrollPtr->firstFraction;
- } else if (last > 1.0) {
- scrollPtr->lastFraction = 1.0;
- } else {
- scrollPtr->lastFraction = last;
- }
- scrollPtr->flags |= NEW_STYLE_COMMANDS;
- } else if (argc == 6) {
- if (Tcl_GetInt(interp, argv[2], &totalUnits) != TCL_OK) {
- goto error;
- }
- if (totalUnits < 0) {
- totalUnits = 0;
- }
- if (Tcl_GetInt(interp, argv[3], &windowUnits) != TCL_OK) {
- goto error;
- }
- if (windowUnits < 0) {
- windowUnits = 0;
- }
- if (Tcl_GetInt(interp, argv[4], &firstUnit) != TCL_OK) {
- goto error;
- }
- if (Tcl_GetInt(interp, argv[5], &lastUnit) != TCL_OK) {
- goto error;
- }
- if (totalUnits > 0) {
- if (lastUnit < firstUnit) {
- lastUnit = firstUnit;
- }
- } else {
- firstUnit = lastUnit = 0;
- }
- scrollPtr->totalUnits = totalUnits;
- scrollPtr->windowUnits = windowUnits;
- scrollPtr->firstUnit = firstUnit;
- scrollPtr->lastUnit = lastUnit;
- if (scrollPtr->totalUnits == 0) {
- scrollPtr->firstFraction = 0.0;
- scrollPtr->lastFraction = 1.0;
- } else {
- scrollPtr->firstFraction = ((double) firstUnit)/totalUnits;
- scrollPtr->lastFraction = ((double) (lastUnit+1))/totalUnits;
- }
- scrollPtr->flags &= ~NEW_STYLE_COMMANDS;
- } else {
- Tcl_AppendResult(interp, "wrong # args: should be \"",
- argv[0], " set firstFraction lastFraction\" or \"",
- argv[0],
- " set totalUnits windowUnits firstUnit lastUnit\"",
- (char *) NULL);
- goto error;
- }
- TkpComputeScrollbarGeometry(scrollPtr);
- TkScrollbarEventuallyRedraw(scrollPtr);
- } else {
- Tcl_AppendResult(interp, "bad option \"", argv[1],
- "\": must be activate, cget, configure, delta, fraction, ",
- "get, identify, or set", (char *) NULL);
- goto error;
- }
- done:
- Tcl_Release((ClientData) scrollPtr);
- return result;
-
- error:
- Tcl_Release((ClientData) scrollPtr);
- return TCL_ERROR;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ConfigureScrollbar --
- *
- * This procedure is called to process an argv/argc list, plus
- * the Tk option database, in order to configure (or
- * reconfigure) a scrollbar widget.
- *
- * Results:
- * The return value is a standard Tcl result. If TCL_ERROR is
- * returned, then interp->result contains an error message.
- *
- * Side effects:
- * Configuration information, such as colors, border width,
- * etc. get set for scrollPtr; old resources get freed,
- * if there were any.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-ConfigureScrollbar(interp, scrollPtr, argc, argv, flags)
- Tcl_Interp *interp; /* Used for error reporting. */
- register TkScrollbar *scrollPtr; /* 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 flags; /* Flags to pass to
- * Tk_ConfigureWidget. */
-{
- size_t length;
-
- if (Tk_ConfigureWidget(interp, scrollPtr->tkwin, tkpScrollbarConfigSpecs,
- argc, argv, (char *) scrollPtr, flags) != TCL_OK) {
- return TCL_ERROR;
- }
-
- /*
- * A few options need special processing, such as parsing the
- * orientation or setting the background from a 3-D border.
- */
-
- length = strlen(scrollPtr->orientUid);
- if (strncmp(scrollPtr->orientUid, "vertical", length) == 0) {
- scrollPtr->vertical = 1;
- } else if (strncmp(scrollPtr->orientUid, "horizontal", length) == 0) {
- scrollPtr->vertical = 0;
- } else {
- Tcl_AppendResult(interp, "bad orientation \"", scrollPtr->orientUid,
- "\": must be vertical or horizontal", (char *) NULL);
- return TCL_ERROR;
- }
-
- if (scrollPtr->command != NULL) {
- scrollPtr->commandSize = strlen(scrollPtr->command);
- } else {
- scrollPtr->commandSize = 0;
- }
-
- /*
- * Configure platform specific options.
- */
-
- TkpConfigureScrollbar(scrollPtr);
-
- /*
- * Register the desired geometry for the window (leave enough space
- * for the two arrows plus a minimum-size slider, plus border around
- * the whole window, if any). Then arrange for the window to be
- * redisplayed.
- */
-
- TkpComputeScrollbarGeometry(scrollPtr);
- TkScrollbarEventuallyRedraw(scrollPtr);
- return TCL_OK;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * TkScrollbarEventProc --
- *
- * This procedure is invoked by the Tk dispatcher for various
- * events on scrollbars.
- *
- * Results:
- * None.
- *
- * Side effects:
- * When the window gets deleted, internal structures get
- * cleaned up. When it gets exposed, it is redisplayed.
- *
- *--------------------------------------------------------------
- */
-
-void
-TkScrollbarEventProc(clientData, eventPtr)
- ClientData clientData; /* Information about window. */
- XEvent *eventPtr; /* Information about event. */
-{
- TkScrollbar *scrollPtr = (TkScrollbar *) clientData;
-
- if ((eventPtr->type == Expose) && (eventPtr->xexpose.count == 0)) {
- TkScrollbarEventuallyRedraw(scrollPtr);
- } else if (eventPtr->type == DestroyNotify) {
- TkpDestroyScrollbar(scrollPtr);
- if (scrollPtr->tkwin != NULL) {
- scrollPtr->tkwin = NULL;
- Tcl_DeleteCommandFromToken(scrollPtr->interp,
- scrollPtr->widgetCmd);
- }
- if (scrollPtr->flags & REDRAW_PENDING) {
- Tcl_CancelIdleCall(TkpDisplayScrollbar, (ClientData) scrollPtr);
- }
- /*
- * Free up all the stuff that requires special handling, then
- * let Tk_FreeOptions handle all the standard option-related
- * stuff.
- */
-
- Tk_FreeOptions(tkpScrollbarConfigSpecs, (char *) scrollPtr,
- scrollPtr->display, 0);
- Tcl_EventuallyFree((ClientData) scrollPtr, TCL_DYNAMIC);
- } else if (eventPtr->type == ConfigureNotify) {
- TkpComputeScrollbarGeometry(scrollPtr);
- TkScrollbarEventuallyRedraw(scrollPtr);
- } else if (eventPtr->type == FocusIn) {
- if (eventPtr->xfocus.detail != NotifyInferior) {
- scrollPtr->flags |= GOT_FOCUS;
- if (scrollPtr->highlightWidth > 0) {
- TkScrollbarEventuallyRedraw(scrollPtr);
- }
- }
- } else if (eventPtr->type == FocusOut) {
- if (eventPtr->xfocus.detail != NotifyInferior) {
- scrollPtr->flags &= ~GOT_FOCUS;
- if (scrollPtr->highlightWidth > 0) {
- TkScrollbarEventuallyRedraw(scrollPtr);
- }
- }
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * ScrollbarCmdDeletedProc --
- *
- * 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
-ScrollbarCmdDeletedProc(clientData)
- ClientData clientData; /* Pointer to widget record for widget. */
-{
- TkScrollbar *scrollPtr = (TkScrollbar *) clientData;
- Tk_Window tkwin = scrollPtr->tkwin;
-
- /*
- * This procedure could be invoked either because the window was
- * destroyed and the command was then deleted (in which case tkwin
- * is NULL) or because the command was deleted, and then this procedure
- * destroys the widget.
- */
-
- if (tkwin != NULL) {
- scrollPtr->tkwin = NULL;
- Tk_DestroyWindow(tkwin);
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * TkScrollbarEventuallyRedraw --
- *
- * Arrange for one or more of the fields of a scrollbar
- * to be redrawn.
- *
- * Results:
- * None.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-void
-TkScrollbarEventuallyRedraw(scrollPtr)
- register TkScrollbar *scrollPtr; /* Information about widget. */
-{
- if ((scrollPtr->tkwin == NULL) || (!Tk_IsMapped(scrollPtr->tkwin))) {
- return;
- }
- if ((scrollPtr->flags & REDRAW_PENDING) == 0) {
- Tcl_DoWhenIdle(TkpDisplayScrollbar, (ClientData) scrollPtr);
- scrollPtr->flags |= REDRAW_PENDING;
- }
-}
diff --git a/generic/tkScrollbar.h b/generic/tkScrollbar.h
deleted file mode 100644
index a1f3d4a..0000000
--- a/generic/tkScrollbar.h
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * tkScrollbar.h --
- *
- * Declarations of types and functions used to implement
- * the scrollbar widget.
- *
- * Copyright (c) 1996 by 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: tkScrollbar.h,v 1.4 1998/09/14 18:23:17 stanton Exp $
- */
-
-#ifndef _TKSCROLLBAR
-#define _TKSCROLLBAR
-
-#ifndef _TKINT
-#include "tkInt.h"
-#endif
-
-#ifdef BUILD_tk
-# undef TCL_STORAGE_CLASS
-# define TCL_STORAGE_CLASS DLLEXPORT
-#endif
-
-/*
- * A data structure of the following type is kept for each scrollbar
- * widget.
- */
-
-typedef struct TkScrollbar {
- Tk_Window tkwin; /* Window that embodies the scrollbar. NULL
- * means that the window has been destroyed
- * but the data structures haven't yet been
- * cleaned up.*/
- Display *display; /* Display containing widget. Used, among
- * other things, so that resources can be
- * freed even after tkwin has gone away. */
- Tcl_Interp *interp; /* Interpreter associated with scrollbar. */
- Tcl_Command widgetCmd; /* Token for scrollbar's widget command. */
- Tk_Uid orientUid; /* Orientation for window ("vertical" or
- * "horizontal"). */
- int vertical; /* Non-zero means vertical orientation
- * requested, zero means horizontal. */
- int width; /* Desired narrow dimension of scrollbar,
- * in pixels. */
- char *command; /* Command prefix to use when invoking
- * scrolling commands. NULL means don't
- * invoke commands. Malloc'ed. */
- int commandSize; /* Number of non-NULL bytes in command. */
- int repeatDelay; /* How long to wait before auto-repeating
- * on scrolling actions (in ms). */
- int repeatInterval; /* Interval between autorepeats (in ms). */
- int jump; /* Value of -jump option. */
-
- /*
- * Information used when displaying widget:
- */
-
- int borderWidth; /* Width of 3-D borders. */
- Tk_3DBorder bgBorder; /* Used for drawing background (all flat
- * surfaces except for trough). */
- Tk_3DBorder activeBorder; /* For drawing backgrounds when active (i.e.
- * when mouse is positioned over element). */
- XColor *troughColorPtr; /* Color for drawing trough. */
- int relief; /* Indicates whether window as a whole is
- * raised, sunken, or flat. */
- int highlightWidth; /* Width in pixels of highlight to draw
- * around widget when it has the focus.
- * <= 0 means don't draw a highlight. */
- XColor *highlightBgColorPtr;
- /* Color for drawing traversal highlight
- * area when highlight is off. */
- XColor *highlightColorPtr; /* Color for drawing traversal highlight. */
- int inset; /* Total width of all borders, including
- * traversal highlight and 3-D border.
- * Indicates how much interior stuff must
- * be offset from outside edges to leave
- * room for borders. */
- int elementBorderWidth; /* Width of border to draw around elements
- * inside scrollbar (arrows and slider).
- * -1 means use borderWidth. */
- int arrowLength; /* Length of arrows along long dimension of
- * scrollbar, including space for a small gap
- * between the arrow and the slider.
- * Recomputed on window size changes. */
- int sliderFirst; /* Pixel coordinate of top or left edge
- * of slider area, including border. */
- int sliderLast; /* Coordinate of pixel just after bottom
- * or right edge of slider area, including
- * border. */
- int activeField; /* Names field to be displayed in active
- * colors, such as TOP_ARROW, or 0 for
- * no field. */
- int activeRelief; /* Value of -activeRelief option: relief
- * to use for active element. */
-
- /*
- * Information describing the application related to the scrollbar.
- * This information is provided by the application by invoking the
- * "set" widget command. This information can now be provided in
- * two ways: the "old" form (totalUnits, windowUnits, firstUnit,
- * and lastUnit), or the "new" form (firstFraction and lastFraction).
- * FirstFraction and lastFraction will always be valid, but
- * the old-style information is only valid if the NEW_STYLE_COMMANDS
- * flag is 0.
- */
-
- int totalUnits; /* Total dimension of application, in
- * units. Valid only if the NEW_STYLE_COMMANDS
- * flag isn't set. */
- int windowUnits; /* Maximum number of units that can be
- * displayed in the window at once. Valid
- * only if the NEW_STYLE_COMMANDS flag isn't
- * set. */
- int firstUnit; /* Number of last unit visible in
- * application's window. Valid only if the
- * NEW_STYLE_COMMANDS flag isn't set. */
- int lastUnit; /* Index of last unit visible in window.
- * Valid only if the NEW_STYLE_COMMANDS
- * flag isn't set. */
- double firstFraction; /* Position of first visible thing in window,
- * specified as a fraction between 0 and
- * 1.0. */
- double lastFraction; /* Position of last visible thing in window,
- * specified as a fraction between 0 and
- * 1.0. */
-
- /*
- * Miscellaneous information:
- */
-
- Tk_Cursor cursor; /* Current cursor for window, or None. */
- char *takeFocus; /* Value of -takefocus option; not used in
- * the C code, but used by keyboard traversal
- * scripts. Malloc'ed, but may be NULL. */
- int flags; /* Various flags; see below for
- * definitions. */
-} TkScrollbar;
-
-/*
- * Legal values for "activeField" field of Scrollbar structures. These
- * are also the return values from the ScrollbarPosition procedure.
- */
-
-#define OUTSIDE 0
-#define TOP_ARROW 1
-#define TOP_GAP 2
-#define SLIDER 3
-#define BOTTOM_GAP 4
-#define BOTTOM_ARROW 5
-
-/*
- * Flag bits for scrollbars:
- *
- * REDRAW_PENDING: Non-zero means a DoWhenIdle handler
- * has already been queued to redraw
- * this window.
- * NEW_STYLE_COMMANDS: Non-zero means the new style of commands
- * should be used to communicate with the
- * widget: ".t yview scroll 2 lines", instead
- * of ".t yview 40", for example.
- * GOT_FOCUS: Non-zero means this window has the input
- * focus.
- */
-
-#define REDRAW_PENDING 1
-#define NEW_STYLE_COMMANDS 2
-#define GOT_FOCUS 4
-
-/*
- * Declaration of scrollbar class procedures structure.
- */
-
-extern TkClassProcs tkpScrollbarProcs;
-
-/*
- * Declaration of scrollbar configuration options.
- */
-
-extern Tk_ConfigSpec tkpScrollbarConfigSpecs[];
-
-/*
- * Declaration of procedures used in the implementation of the scrollbar
- * widget.
- */
-
-EXTERN void TkScrollbarEventProc _ANSI_ARGS_((
- ClientData clientData, XEvent *eventPtr));
-EXTERN void TkScrollbarEventuallyRedraw _ANSI_ARGS_((
- TkScrollbar *scrollPtr));
-EXTERN void TkpComputeScrollbarGeometry _ANSI_ARGS_((
- TkScrollbar *scrollPtr));
-EXTERN TkScrollbar * TkpCreateScrollbar _ANSI_ARGS_((Tk_Window tkwin));
-EXTERN void TkpDestroyScrollbar _ANSI_ARGS_((
- TkScrollbar *scrollPtr));
-EXTERN void TkpDisplayScrollbar _ANSI_ARGS_((
- ClientData clientData));
-EXTERN void TkpConfigureScrollbar _ANSI_ARGS_((
- TkScrollbar *scrollPtr));
-EXTERN int TkpScrollbarPosition _ANSI_ARGS_((
- TkScrollbar *scrollPtr, int x, int y));
-
-# undef TCL_STORAGE_CLASS
-# define TCL_STORAGE_CLASS DLLIMPORT
-
-#endif /* _TKSCROLLBAR */
diff --git a/generic/tkSelect.c b/generic/tkSelect.c
deleted file mode 100644
index 01e8af4..0000000
--- a/generic/tkSelect.c
+++ /dev/null
@@ -1,1341 +0,0 @@
-/*
- * tkSelect.c --
- *
- * This file manages the selection for the Tk toolkit,
- * translating between the standard X ICCCM conventions
- * and Tcl commands.
- *
- * Copyright (c) 1990-1993 The Regents of the University of California.
- * Copyright (c) 1994-1995 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: tkSelect.c,v 1.2 1998/09/14 18:23:17 stanton Exp $
- */
-
-#include "tkInt.h"
-#include "tkSelect.h"
-
-/*
- * When a selection handler is set up by invoking "selection handle",
- * one of the following data structures is set up to hold information
- * about the command to invoke and its interpreter.
- */
-
-typedef struct {
- Tcl_Interp *interp; /* Interpreter in which to invoke command. */
- int cmdLength; /* # of non-NULL bytes in command. */
- char command[4]; /* Command to invoke. Actual space is
- * allocated as large as necessary. This
- * must be the last entry in the structure. */
-} CommandInfo;
-
-/*
- * When selection ownership is claimed with the "selection own" Tcl command,
- * one of the following structures is created to record the Tcl command
- * to be executed when the selection is lost again.
- */
-
-typedef struct LostCommand {
- Tcl_Interp *interp; /* Interpreter in which to invoke command. */
- char command[4]; /* Command to invoke. Actual space is
- * allocated as large as necessary. This
- * must be the last entry in the structure. */
-} LostCommand;
-
-/*
- * Shared variables:
- */
-
-TkSelInProgress *pendingPtr = NULL;
- /* Topmost search in progress, or
- * NULL if none. */
-
-/*
- * Forward declarations for procedures defined in this file:
- */
-
-static int HandleTclCommand _ANSI_ARGS_((ClientData clientData,
- int offset, char *buffer, int maxBytes));
-static void LostSelection _ANSI_ARGS_((ClientData clientData));
-static int SelGetProc _ANSI_ARGS_((ClientData clientData,
- Tcl_Interp *interp, char *portion));
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_CreateSelHandler --
- *
- * This procedure is called to register a procedure
- * as the handler for selection requests of a particular
- * target type on a particular window for a particular
- * selection.
- *
- * Results:
- * None.
- *
- * Side effects:
- * In the future, whenever the selection is in tkwin's
- * window and someone requests the selection in the
- * form given by target, proc will be invoked to provide
- * part or all of the selection in the given form. If
- * there was already a handler declared for the given
- * window, target and selection type, then it is replaced.
- * Proc should have the following form:
- *
- * int
- * proc(clientData, offset, buffer, maxBytes)
- * ClientData clientData;
- * int offset;
- * char *buffer;
- * int maxBytes;
- * {
- * }
- *
- * The clientData argument to proc will be the same as
- * the clientData argument to this procedure. The offset
- * argument indicates which portion of the selection to
- * return: skip the first offset bytes. Buffer is a
- * pointer to an area in which to place the converted
- * selection, and maxBytes gives the number of bytes
- * available at buffer. Proc should place the selection
- * in buffer as a string, and return a count of the number
- * of bytes of selection actually placed in buffer (not
- * including the terminating NULL character). If the
- * return value equals maxBytes, this is a sign that there
- * is probably still more selection information available.
- *
- *--------------------------------------------------------------
- */
-
-void
-Tk_CreateSelHandler(tkwin, selection, target, proc, clientData, format)
- Tk_Window tkwin; /* Token for window. */
- Atom selection; /* Selection to be handled. */
- Atom target; /* The kind of selection conversions
- * that can be handled by proc,
- * e.g. TARGETS or STRING. */
- Tk_SelectionProc *proc; /* Procedure to invoke to convert
- * selection to type "target". */
- ClientData clientData; /* Value to pass to proc. */
- Atom format; /* Format in which the selection
- * information should be returned to
- * the requestor. XA_STRING is best by
- * far, but anything listed in the ICCCM
- * will be tolerated (blech). */
-{
- register TkSelHandler *selPtr;
- TkWindow *winPtr = (TkWindow *) tkwin;
-
- if (winPtr->dispPtr->multipleAtom == None) {
- TkSelInit(tkwin);
- }
-
- /*
- * See if there's already a handler for this target and selection on
- * this window. If so, re-use it. If not, create a new one.
- */
-
- for (selPtr = winPtr->selHandlerList; ; selPtr = selPtr->nextPtr) {
- if (selPtr == NULL) {
- selPtr = (TkSelHandler *) ckalloc(sizeof(TkSelHandler));
- selPtr->nextPtr = winPtr->selHandlerList;
- winPtr->selHandlerList = selPtr;
- break;
- }
- if ((selPtr->selection == selection) && (selPtr->target == target)) {
-
- /*
- * Special case: when replacing handler created by
- * "selection handle", free up memory. Should there be a
- * callback to allow other clients to do this too?
- */
-
- if (selPtr->proc == HandleTclCommand) {
- ckfree((char *) selPtr->clientData);
- }
- break;
- }
- }
- selPtr->selection = selection;
- selPtr->target = target;
- selPtr->format = format;
- selPtr->proc = proc;
- selPtr->clientData = clientData;
- if (format == XA_STRING) {
- selPtr->size = 8;
- } else {
- selPtr->size = 32;
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_DeleteSelHandler --
- *
- * Remove the selection handler for a given window, target, and
- * selection, if it exists.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The selection handler for tkwin and target is removed. If there
- * is no such handler then nothing happens.
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tk_DeleteSelHandler(tkwin, selection, target)
- Tk_Window tkwin; /* Token for window. */
- Atom selection; /* The selection whose handler
- * is to be removed. */
- Atom target; /* The target whose selection
- * handler is to be removed. */
-{
- TkWindow *winPtr = (TkWindow *) tkwin;
- register TkSelHandler *selPtr, *prevPtr;
- register TkSelInProgress *ipPtr;
-
- /*
- * Find the selection handler to be deleted, or return if it doesn't
- * exist.
- */
-
- for (selPtr = winPtr->selHandlerList, prevPtr = NULL; ;
- prevPtr = selPtr, selPtr = selPtr->nextPtr) {
- if (selPtr == NULL) {
- return;
- }
- if ((selPtr->selection == selection) && (selPtr->target == target)) {
- break;
- }
- }
-
- /*
- * If ConvertSelection is processing this handler, tell it that the
- * handler is dead.
- */
-
- for (ipPtr = pendingPtr; ipPtr != NULL; ipPtr = ipPtr->nextPtr) {
- if (ipPtr->selPtr == selPtr) {
- ipPtr->selPtr = NULL;
- }
- }
-
- /*
- * Free resources associated with the handler.
- */
-
- if (prevPtr == NULL) {
- winPtr->selHandlerList = selPtr->nextPtr;
- } else {
- prevPtr->nextPtr = selPtr->nextPtr;
- }
- if (selPtr->proc == HandleTclCommand) {
- ckfree((char *) selPtr->clientData);
- }
- ckfree((char *) selPtr);
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_OwnSelection --
- *
- * Arrange for tkwin to become the owner of a selection.
- *
- * Results:
- * None.
- *
- * Side effects:
- * From now on, requests for the selection will be directed
- * to procedures associated with tkwin (they must have been
- * declared with calls to Tk_CreateSelHandler). When the
- * selection is lost by this window, proc will be invoked
- * (see the manual entry for details). This procedure may
- * invoke callbacks, including Tcl scripts, so any calling
- * function should be reentrant at the point where
- * Tk_OwnSelection is invoked.
- *
- *--------------------------------------------------------------
- */
-
-void
-Tk_OwnSelection(tkwin, selection, proc, clientData)
- Tk_Window tkwin; /* Window to become new selection
- * owner. */
- Atom selection; /* Selection that window should own. */
- Tk_LostSelProc *proc; /* Procedure to call when selection
- * is taken away from tkwin. */
- ClientData clientData; /* Arbitrary one-word argument to
- * pass to proc. */
-{
- register TkWindow *winPtr = (TkWindow *) tkwin;
- TkDisplay *dispPtr = winPtr->dispPtr;
- TkSelectionInfo *infoPtr;
- Tk_LostSelProc *clearProc = NULL;
- ClientData clearData = NULL; /* Initialization needed only to
- * prevent compiler warning. */
-
-
- if (dispPtr->multipleAtom == None) {
- TkSelInit(tkwin);
- }
- Tk_MakeWindowExist(tkwin);
-
- /*
- * This code is somewhat tricky. First, we find the specified selection
- * on the selection list. If the previous owner is in this process, and
- * is a different window, then we need to invoke the clearProc. However,
- * it's dangerous to call the clearProc right now, because it could
- * invoke a Tcl script that wrecks the current state (e.g. it could
- * delete the window). To be safe, defer the call until the end of the
- * procedure when we no longer care about the state.
- */
-
- for (infoPtr = dispPtr->selectionInfoPtr; infoPtr != NULL;
- infoPtr = infoPtr->nextPtr) {
- if (infoPtr->selection == selection) {
- break;
- }
- }
- if (infoPtr == NULL) {
- infoPtr = (TkSelectionInfo*) ckalloc(sizeof(TkSelectionInfo));
- infoPtr->selection = selection;
- infoPtr->nextPtr = dispPtr->selectionInfoPtr;
- dispPtr->selectionInfoPtr = infoPtr;
- } else if (infoPtr->clearProc != NULL) {
- if (infoPtr->owner != tkwin) {
- clearProc = infoPtr->clearProc;
- clearData = infoPtr->clearData;
- } else if (infoPtr->clearProc == LostSelection) {
- /*
- * If the selection handler is one created by "selection own",
- * be sure to free the record for it; otherwise there will be
- * a memory leak.
- */
-
- ckfree((char *) infoPtr->clearData);
- }
- }
-
- infoPtr->owner = tkwin;
- infoPtr->serial = NextRequest(winPtr->display);
- infoPtr->clearProc = proc;
- infoPtr->clearData = clientData;
-
- /*
- * Note that we are using CurrentTime, even though ICCCM recommends against
- * this practice (the problem is that we don't necessarily have a valid
- * time to use). We will not be able to retrieve a useful timestamp for
- * the TIMESTAMP target later.
- */
-
- infoPtr->time = CurrentTime;
-
- /*
- * Note that we are not checking to see if the selection claim succeeded.
- * If the ownership does not change, then the clearProc may never be
- * invoked, and we will return incorrect information when queried for the
- * current selection owner.
- */
-
- XSetSelectionOwner(winPtr->display, infoPtr->selection, winPtr->window,
- infoPtr->time);
-
- /*
- * Now that we are done, we can invoke clearProc without running into
- * reentrancy problems.
- */
-
- if (clearProc != NULL) {
- (*clearProc)(clearData);
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_ClearSelection --
- *
- * Eliminate the specified selection on tkwin's display, if there is one.
- *
- * Results:
- * None.
- *
- * Side effects:
- * The specified selection is cleared, so that future requests to retrieve
- * it will fail until some application owns it again. This procedure
- * invokes callbacks, possibly including Tcl scripts, so any calling
- * function should be reentrant at the point Tk_ClearSelection is invoked.
- *
- *----------------------------------------------------------------------
- */
-
-void
-Tk_ClearSelection(tkwin, selection)
- Tk_Window tkwin; /* Window that selects a display. */
- Atom selection; /* Selection to be cancelled. */
-{
- register TkWindow *winPtr = (TkWindow *) tkwin;
- TkDisplay *dispPtr = winPtr->dispPtr;
- TkSelectionInfo *infoPtr;
- TkSelectionInfo *prevPtr;
- TkSelectionInfo *nextPtr;
- Tk_LostSelProc *clearProc = NULL;
- ClientData clearData = NULL; /* Initialization needed only to
- * prevent compiler warning. */
-
- if (dispPtr->multipleAtom == None) {
- TkSelInit(tkwin);
- }
-
- for (infoPtr = dispPtr->selectionInfoPtr, prevPtr = NULL;
- infoPtr != NULL; infoPtr = nextPtr) {
- nextPtr = infoPtr->nextPtr;
- if (infoPtr->selection == selection) {
- if (prevPtr == NULL) {
- dispPtr->selectionInfoPtr = nextPtr;
- } else {
- prevPtr->nextPtr = nextPtr;
- }
- break;
- }
- prevPtr = infoPtr;
- }
-
- if (infoPtr != NULL) {
- clearProc = infoPtr->clearProc;
- clearData = infoPtr->clearData;
- ckfree((char *) infoPtr);
- }
- XSetSelectionOwner(winPtr->display, selection, None, CurrentTime);
-
- if (clearProc != NULL) {
- (*clearProc)(clearData);
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_GetSelection --
- *
- * Retrieve the value of a selection and pass it off (in
- * pieces, possibly) to a given procedure.
- *
- * Results:
- * The return value is a standard Tcl return value.
- * If an error occurs (such as no selection exists)
- * then an error message is left in interp->result.
- *
- * Side effects:
- * The standard X11 protocols are used to retrieve the
- * selection. When it arrives, it is passed to proc. If
- * the selection is very large, it will be passed to proc
- * in several pieces. Proc should have the following
- * structure:
- *
- * int
- * proc(clientData, interp, portion)
- * ClientData clientData;
- * Tcl_Interp *interp;
- * char *portion;
- * {
- * }
- *
- * The interp and clientData arguments to proc will be the
- * same as the corresponding arguments to Tk_GetSelection.
- * The portion argument points to a character string
- * containing part of the selection, and numBytes indicates
- * the length of the portion, not including the terminating
- * NULL character. If the selection arrives in several pieces,
- * the "portion" arguments in separate calls will contain
- * successive parts of the selection. Proc should normally
- * return TCL_OK. If it detects an error then it should return
- * TCL_ERROR and leave an error message in interp->result; the
- * remainder of the selection retrieval will be aborted.
- *
- *--------------------------------------------------------------
- */
-
-int
-Tk_GetSelection(interp, tkwin, selection, target, proc, clientData)
- Tcl_Interp *interp; /* Interpreter to use for reporting
- * errors. */
- Tk_Window tkwin; /* Window on whose behalf to retrieve
- * the selection (determines display
- * from which to retrieve). */
- Atom selection; /* Selection to retrieve. */
- Atom target; /* Desired form in which selection
- * is to be returned. */
- Tk_GetSelProc *proc; /* Procedure to call to process the
- * selection, once it has been retrieved. */
- ClientData clientData; /* Arbitrary value to pass to proc. */
-{
- TkWindow *winPtr = (TkWindow *) tkwin;
- TkDisplay *dispPtr = winPtr->dispPtr;
- TkSelectionInfo *infoPtr;
-
- if (dispPtr->multipleAtom == None) {
- TkSelInit(tkwin);
- }
-
- /*
- * If the selection is owned by a window managed by this
- * process, then call the retrieval procedure directly,
- * rather than going through the X server (it's dangerous
- * to go through the X server in this case because it could
- * result in deadlock if an INCR-style selection results).
- */
-
- for (infoPtr = dispPtr->selectionInfoPtr; infoPtr != NULL;
- infoPtr = infoPtr->nextPtr) {
- if (infoPtr->selection == selection)
- break;
- }
- if (infoPtr != NULL) {
- register TkSelHandler *selPtr;
- int offset, result, count;
- char buffer[TK_SEL_BYTES_AT_ONCE+1];
- TkSelInProgress ip;
-
- for (selPtr = ((TkWindow *) infoPtr->owner)->selHandlerList;
- selPtr != NULL; selPtr = selPtr->nextPtr) {
- if ((selPtr->target == target)
- && (selPtr->selection == selection)) {
- break;
- }
- }
- if (selPtr == NULL) {
- Atom type;
-
- count = TkSelDefaultSelection(infoPtr, target, buffer,
- TK_SEL_BYTES_AT_ONCE, &type);
- if (count > TK_SEL_BYTES_AT_ONCE) {
- panic("selection handler returned too many bytes");
- }
- if (count < 0) {
- goto cantget;
- }
- buffer[count] = 0;
- result = (*proc)(clientData, interp, buffer);
- } else {
- offset = 0;
- result = TCL_OK;
- ip.selPtr = selPtr;
- ip.nextPtr = pendingPtr;
- pendingPtr = &ip;
- while (1) {
- count = (selPtr->proc)(selPtr->clientData, offset, buffer,
- TK_SEL_BYTES_AT_ONCE);
- if ((count < 0) || (ip.selPtr == NULL)) {
- pendingPtr = ip.nextPtr;
- goto cantget;
- }
- if (count > TK_SEL_BYTES_AT_ONCE) {
- panic("selection handler returned too many bytes");
- }
- buffer[count] = '\0';
- result = (*proc)(clientData, interp, buffer);
- if ((result != TCL_OK) || (count < TK_SEL_BYTES_AT_ONCE)
- || (ip.selPtr == NULL)) {
- break;
- }
- offset += count;
- }
- pendingPtr = ip.nextPtr;
- }
- return result;
- }
-
- /*
- * The selection is owned by some other process.
- */
-
- return TkSelGetSelection(interp, tkwin, selection, target, proc,
- clientData);
-
- cantget:
- Tcl_AppendResult(interp, Tk_GetAtomName(tkwin, selection),
- " selection doesn't exist or form \"", Tk_GetAtomName(tkwin, target),
- "\" not defined", (char *) NULL);
- return TCL_ERROR;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * Tk_SelectionCmd --
- *
- * This procedure is invoked to process the "selection" 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_SelectionCmd(clientData, interp, argc, argv)
- ClientData clientData; /* Main window associated with
- * interpreter. */
- Tcl_Interp *interp; /* Current interpreter. */
- int argc; /* Number of arguments. */
- char **argv; /* Argument strings. */
-{
- 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) {
- sprintf(interp->result,
- "wrong # args: should be \"%.50s option ?arg arg ...?\"",
- argv[0]);
- 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 (count < 2) {
- Tcl_AppendResult(interp, "value for \"", *args,
- "\" missing", (char *) 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 {
- Tcl_AppendResult(interp, "unknown option \"", args[0],
- "\"", (char *) NULL);
- return TCL_ERROR;
- }
- }
- 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;
- }
-
- 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;
- }
- if (count < 2) {
- Tcl_AppendResult(interp, "value for \"", *args,
- "\" missing", (char *) 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];
- } else {
- Tcl_AppendResult(interp, "unknown option \"", args[0],
- "\"", (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;
- }
- 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);
- }
- 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;
- }
- if (count < 2) {
- Tcl_AppendResult(interp, "value for \"", *args,
- "\" missing", (char *) NULL);
- 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);
- 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 (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) (
- sizeof(CommandInfo) - 3 + cmdLength));
- cmdInfoPtr->interp = interp;
- cmdInfoPtr->cmdLength = cmdLength;
- strcpy(cmdInfoPtr->command, args[1]);
- Tk_CreateSelHandler(tkwin, selection, target, HandleTclCommand,
- (ClientData) cmdInfoPtr, format);
- }
- 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;
- }
- if (count < 2) {
- Tcl_AppendResult(interp, "value for \"", *args,
- "\" missing", (char *) NULL);
- 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];
- } else {
- Tcl_AppendResult(interp, "unknown option \"", args[0],
- "\"", (char *) NULL);
- return TCL_ERROR;
- }
- }
-
- 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 (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)) {
- interp->result = Tk_PathName(infoPtr->owner);
- }
- 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 {
- sprintf(interp->result,
- "bad option \"%.50s\": must be clear, get, handle, or own",
- argv[1]);
- return TCL_ERROR;
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkSelDeadWindow --
- *
- * This procedure is invoked just before a TkWindow is deleted.
- * It performs selection-related cleanup.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Frees up memory associated with the selection.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkSelDeadWindow(winPtr)
- register TkWindow *winPtr; /* Window that's being deleted. */
-{
- register TkSelHandler *selPtr;
- register TkSelInProgress *ipPtr;
- TkSelectionInfo *infoPtr, *prevPtr, *nextPtr;
-
- /*
- * While deleting all the handlers, be careful to check whether
- * ConvertSelection or TkSelPropProc are about to process one of the
- * deleted handlers.
- */
-
- while (winPtr->selHandlerList != NULL) {
- selPtr = winPtr->selHandlerList;
- winPtr->selHandlerList = selPtr->nextPtr;
- for (ipPtr = pendingPtr; ipPtr != NULL; ipPtr = ipPtr->nextPtr) {
- if (ipPtr->selPtr == selPtr) {
- ipPtr->selPtr = NULL;
- }
- }
- if (selPtr->proc == HandleTclCommand) {
- ckfree((char *) selPtr->clientData);
- }
- ckfree((char *) selPtr);
- }
-
- /*
- * Remove selections owned by window being deleted.
- */
-
- for (infoPtr = winPtr->dispPtr->selectionInfoPtr, prevPtr = NULL;
- infoPtr != NULL; infoPtr = nextPtr) {
- nextPtr = infoPtr->nextPtr;
- if (infoPtr->owner == (Tk_Window) winPtr) {
- if (infoPtr->clearProc == LostSelection) {
- ckfree((char *) infoPtr->clearData);
- }
- ckfree((char *) infoPtr);
- infoPtr = prevPtr;
- if (prevPtr == NULL) {
- winPtr->dispPtr->selectionInfoPtr = nextPtr;
- } else {
- prevPtr->nextPtr = nextPtr;
- }
- }
- prevPtr = infoPtr;
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkSelInit --
- *
- * Initialize selection-related information for a display.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Selection-related information is initialized.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkSelInit(tkwin)
- Tk_Window tkwin; /* Window token (used to find
- * display to initialize). */
-{
- register TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
-
- /*
- * 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");
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkSelClearSelection --
- *
- * This procedure is invoked to process a SelectionClear event.
- *
- * Results:
- * None.
- *
- * Side effects:
- * Invokes the clear procedure for the window which lost the
- * selection.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkSelClearSelection(tkwin, eventPtr)
- Tk_Window tkwin; /* Window for which event was targeted. */
- register XEvent *eventPtr; /* X SelectionClear event. */
-{
- register TkWindow *winPtr = (TkWindow *) tkwin;
- TkDisplay *dispPtr = winPtr->dispPtr;
- TkSelectionInfo *infoPtr;
- TkSelectionInfo *prevPtr;
-
- /*
- * Invoke clear procedure for window that just lost the selection. This
- * code is a bit tricky, because any callbacks due to selection changes
- * between windows managed by the process have already been made. Thus,
- * ignore the event unless it refers to the window that's currently the
- * selection owner and the event was generated after the server saw the
- * SetSelectionOwner request.
- */
-
- for (infoPtr = dispPtr->selectionInfoPtr, prevPtr = NULL;
- infoPtr != NULL; infoPtr = infoPtr->nextPtr) {
- if (infoPtr->selection == eventPtr->xselectionclear.selection) {
- break;
- }
- prevPtr = infoPtr;
- }
-
- if (infoPtr != NULL && (infoPtr->owner == tkwin)
- && (eventPtr->xselectionclear.serial >= (unsigned) infoPtr->serial)) {
- if (prevPtr == NULL) {
- dispPtr->selectionInfoPtr = infoPtr->nextPtr;
- } else {
- prevPtr->nextPtr = infoPtr->nextPtr;
- }
-
- /*
- * Because of reentrancy problems, calling clearProc must be done
- * after the infoPtr has been removed from the selectionInfoPtr
- * list (clearProc could modify the list, e.g. by creating
- * a new selection).
- */
-
- if (infoPtr->clearProc != NULL) {
- (*infoPtr->clearProc)(infoPtr->clearData);
- }
- ckfree((char *) infoPtr);
- }
-}
-
-/*
- *--------------------------------------------------------------
- *
- * SelGetProc --
- *
- * This procedure is invoked to process pieces of the selection
- * as they arrive during "selection 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
-SelGetProc(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;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * HandleTclCommand --
- *
- * This procedure acts as selection handler for handlers created
- * by the "selection handle" command. It invokes a Tcl command to
- * retrieve the selection.
- *
- * Results:
- * The return value is a count of the number of bytes actually
- * stored at buffer, or -1 if an error occurs while executing
- * the Tcl command to retrieve the selection.
- *
- * Side effects:
- * None except for things done by the Tcl command.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-HandleTclCommand(clientData, offset, buffer, maxBytes)
- ClientData clientData; /* Information about command to execute. */
- int offset; /* Return selection bytes starting at this
- * offset. */
- char *buffer; /* Place to store converted selection. */
- int maxBytes; /* Maximum # of bytes to store at buffer. */
-{
- CommandInfo *cmdInfoPtr = (CommandInfo *) clientData;
- int spaceNeeded, length;
-#define MAX_STATIC_SIZE 100
- char staticSpace[MAX_STATIC_SIZE];
- char *command;
- Tcl_Interp *interp;
- Tcl_DString oldResult;
-
- /*
- * We must copy the interpreter pointer from CommandInfo because the
- * command could delete the handler, freeing the CommandInfo data before we
- * are done using it. We must also protect the interpreter from being
- * deleted too soo.
- */
-
- interp = cmdInfoPtr->interp;
- Tcl_Preserve((ClientData) interp);
-
- /*
- * First, generate a command by taking the command string
- * and appending the offset and maximum # of bytes.
- */
-
- spaceNeeded = cmdInfoPtr->cmdLength + 30;
- if (spaceNeeded < MAX_STATIC_SIZE) {
- command = staticSpace;
- } else {
- command = (char *) ckalloc((unsigned) spaceNeeded);
- }
- sprintf(command, "%s %d %d", cmdInfoPtr->command, offset, maxBytes);
-
- /*
- * Execute the command. Be sure to restore the state of the
- * interpreter after executing the command.
- */
-
- Tcl_DStringInit(&oldResult);
- Tcl_DStringGetResult(interp, &oldResult);
- if (TkCopyAndGlobalEval(interp, command) == TCL_OK) {
- length = strlen(interp->result);
- if (length > maxBytes) {
- length = maxBytes;
- }
- memcpy((VOID *) buffer, (VOID *) interp->result, (size_t) length);
- buffer[length] = '\0';
- } else {
- length = -1;
- }
- Tcl_DStringResult(interp, &oldResult);
-
- if (command != staticSpace) {
- ckfree(command);
- }
-
- Tcl_Release((ClientData) interp);
- return length;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * TkSelDefaultSelection --
- *
- * This procedure is called to generate selection information
- * for a few standard targets such as TIMESTAMP and TARGETS.
- * It is invoked only if no handler has been declared by the
- * application.
- *
- * Results:
- * If "target" is a standard target understood by this procedure,
- * the selection is converted to that form and stored as a
- * character string in buffer. The type of the selection (e.g.
- * STRING or ATOM) is stored in *typePtr, and the return value is
- * a count of the # of non-NULL bytes at buffer. If the target
- * wasn't understood, or if there isn't enough space at buffer
- * to hold the entire selection (no INCR-mode transfers for this
- * stuff!), then -1 is returned.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-int
-TkSelDefaultSelection(infoPtr, target, buffer, maxBytes, typePtr)
- TkSelectionInfo *infoPtr; /* Info about selection being retrieved. */
- Atom target; /* Desired form of selection. */
- char *buffer; /* Place to put selection characters. */
- int maxBytes; /* Maximum # of bytes to store at buffer. */
- Atom *typePtr; /* Store here the type of the selection,
- * for use in converting to proper X format. */
-{
- register TkWindow *winPtr = (TkWindow *) infoPtr->owner;
- TkDisplay *dispPtr = winPtr->dispPtr;
-
- if (target == dispPtr->timestampAtom) {
- if (maxBytes < 20) {
- return -1;
- }
- sprintf(buffer, "0x%x", (unsigned int) infoPtr->time);
- *typePtr = XA_INTEGER;
- return strlen(buffer);
- }
-
- if (target == dispPtr->targetsAtom) {
- register TkSelHandler *selPtr;
- char *atomString;
- int length, atomLength;
-
- if (maxBytes < 50) {
- return -1;
- }
- strcpy(buffer, "MULTIPLE TARGETS TIMESTAMP TK_APPLICATION TK_WINDOW");
- length = strlen(buffer);
- for (selPtr = winPtr->selHandlerList; selPtr != NULL;
- selPtr = selPtr->nextPtr) {
- if ((selPtr->selection == infoPtr->selection)
- && (selPtr->target != dispPtr->applicationAtom)
- && (selPtr->target != dispPtr->windowAtom)) {
- atomString = Tk_GetAtomName((Tk_Window) winPtr,
- selPtr->target);
- atomLength = strlen(atomString) + 1;
- if ((length + atomLength) >= maxBytes) {
- return -1;
- }
- sprintf(buffer+length, " %s", atomString);
- length += atomLength;
- }
- }
- *typePtr = XA_ATOM;
- return length;
- }
-
- if (target == dispPtr->applicationAtom) {
- int length;
- char *name = winPtr->mainPtr->winPtr->nameUid;
-
- length = strlen(name);
- if (maxBytes <= length) {
- return -1;
- }
- strcpy(buffer, name);
- *typePtr = XA_STRING;
- return length;
- }
-
- if (target == dispPtr->windowAtom) {
- int length;
- char *name = winPtr->pathName;
-
- length = strlen(name);
- if (maxBytes <= length) {
- return -1;
- }
- strcpy(buffer, name);
- *typePtr = XA_STRING;
- return length;
- }
-
- return -1;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * LostSelection --
- *
- * This procedure is invoked when a window has lost ownership of
- * the selection and the ownership was claimed with the command
- * "selection own".
- *
- * Results:
- * None.
- *
- * Side effects:
- * A Tcl script is executed; it can do almost anything.
- *
- *----------------------------------------------------------------------
- */
-
-static void
-LostSelection(clientData)
- ClientData clientData; /* Pointer to CommandInfo structure. */
-{
- LostCommand *lostPtr = (LostCommand *) clientData;
- char *oldResultString;
- Tcl_FreeProc *oldFreeProc;
- Tcl_Interp *interp;
-
- interp = lostPtr->interp;
- Tcl_Preserve((ClientData) interp);
-
- /*
- * Execute the command. Save the interpreter's result, if any, and
- * restore it after executing the command.
- */
-
- oldFreeProc = interp->freeProc;
- if (oldFreeProc != TCL_STATIC) {
- oldResultString = interp->result;
- } else {
- oldResultString = (char *) ckalloc((unsigned)
- (strlen(interp->result) + 1));
- strcpy(oldResultString, interp->result);
- oldFreeProc = TCL_DYNAMIC;
- }
- interp->freeProc = TCL_STATIC;
- if (TkCopyAndGlobalEval(interp, lostPtr->command) != TCL_OK) {
- Tcl_BackgroundError(interp);
- }
- Tcl_FreeResult(interp);
- interp->result = oldResultString;
- interp->freeProc = oldFreeProc;
-
- Tcl_Release((ClientData) interp);
-
- /*
- * Free the storage for the command, since we're done with it now.
- */
-
- ckfree((char *) lostPtr);
-}
diff --git a/generic/tkSelect.h b/generic/tkSelect.h
deleted file mode 100644
index 4963f71..0000000
--- a/generic/tkSelect.h
+++ /dev/null