summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
Diffstat (limited to 'generic')
-rw-r--r--generic/default.h4
-rw-r--r--generic/ks_names.h160
-rw-r--r--generic/nanosvg.h3216
-rw-r--r--generic/nanosvgrast.h1477
-rw-r--r--generic/tk.decls266
-rw-r--r--generic/tk.h418
-rw-r--r--generic/tk3d.c77
-rw-r--r--generic/tk3d.h6
-rw-r--r--generic/tkArgv.c51
-rw-r--r--generic/tkArray.h2
-rw-r--r--generic/tkAtom.c8
-rw-r--r--generic/tkBind.c439
-rw-r--r--generic/tkBitmap.c38
-rw-r--r--generic/tkBusy.c85
-rw-r--r--generic/tkButton.c500
-rw-r--r--generic/tkButton.h8
-rw-r--r--generic/tkCanvArc.c348
-rw-r--r--generic/tkCanvBmap.c123
-rw-r--r--generic/tkCanvImg.c97
-rw-r--r--generic/tkCanvLine.c338
-rw-r--r--generic/tkCanvPoly.c257
-rw-r--r--generic/tkCanvPs.c217
-rw-r--r--generic/tkCanvText.c308
-rw-r--r--generic/tkCanvUtil.c159
-rw-r--r--generic/tkCanvWind.c135
-rw-r--r--generic/tkCanvas.c1498
-rw-r--r--generic/tkCanvas.h14
-rw-r--r--generic/tkClipboard.c71
-rw-r--r--generic/tkCmds.c376
-rw-r--r--generic/tkColor.c22
-rw-r--r--generic/tkColor.h6
-rw-r--r--generic/tkConfig.c701
-rw-r--r--generic/tkConsole.c81
-rw-r--r--generic/tkCursor.c28
-rw-r--r--generic/tkDList.h2
-rw-r--r--generic/tkDecls.h523
-rw-r--r--generic/tkEntry.c736
-rw-r--r--generic/tkEntry.h33
-rw-r--r--generic/tkError.c15
-rw-r--r--generic/tkEvent.c94
-rw-r--r--generic/tkFileFilter.c41
-rw-r--r--generic/tkFileFilter.h10
-rw-r--r--generic/tkFocus.c22
-rw-r--r--generic/tkFont.c255
-rw-r--r--generic/tkFont.h14
-rw-r--r--generic/tkFrame.c436
-rw-r--r--generic/tkGC.c8
-rw-r--r--generic/tkGeometry.c30
-rw-r--r--generic/tkGet.c152
-rw-r--r--generic/tkGrab.c53
-rw-r--r--generic/tkGrid.c215
-rw-r--r--generic/tkIcu.c322
-rw-r--r--generic/tkImage.c52
-rw-r--r--generic/tkImgBmap.c54
-rw-r--r--generic/tkImgGIF.c538
-rw-r--r--generic/tkImgListFormat.c1138
-rw-r--r--generic/tkImgPNG.c493
-rw-r--r--generic/tkImgPPM.c31
-rw-r--r--generic/tkImgPhInstance.c122
-rw-r--r--generic/tkImgPhoto.c1315
-rw-r--r--generic/tkImgPhoto.h60
-rw-r--r--generic/tkImgSVGnano.c876
-rw-r--r--generic/tkImgUtil.c8
-rw-r--r--generic/tkInt.decls567
-rw-r--r--generic/tkInt.h567
-rw-r--r--generic/tkIntDecls.h371
-rw-r--r--generic/tkIntPlatDecls.h69
-rw-r--r--generic/tkIntXlibDecls.h542
-rw-r--r--generic/tkListbox.c583
-rw-r--r--generic/tkMacWinMenu.c6
-rw-r--r--generic/tkMain.c37
-rw-r--r--generic/tkMenu.c712
-rw-r--r--generic/tkMenu.h49
-rw-r--r--generic/tkMenuDraw.c67
-rw-r--r--generic/tkMenubutton.c178
-rw-r--r--generic/tkMenubutton.h16
-rw-r--r--generic/tkMessage.c339
-rw-r--r--generic/tkObj.c233
-rw-r--r--generic/tkOldConfig.c114
-rw-r--r--generic/tkOldTest.c72
-rw-r--r--generic/tkOption.c43
-rw-r--r--generic/tkPack.c165
-rw-r--r--generic/tkPanedWindow.c350
-rw-r--r--generic/tkPkgConfig.c171
-rw-r--r--generic/tkPlace.c260
-rw-r--r--generic/tkPlatDecls.h63
-rw-r--r--generic/tkPointer.c30
-rw-r--r--generic/tkPort.h2
-rw-r--r--generic/tkRectOval.c166
-rw-r--r--generic/tkScale.c151
-rw-r--r--generic/tkScale.h8
-rw-r--r--generic/tkScrollbar.c124
-rw-r--r--generic/tkScrollbar.h32
-rw-r--r--generic/tkSelect.c123
-rw-r--r--generic/tkSelect.h22
-rw-r--r--generic/tkSquare.c73
-rw-r--r--generic/tkStubInit.c430
-rw-r--r--generic/tkStubLib.c30
-rw-r--r--generic/tkStyle.c121
-rw-r--r--generic/tkTest.c538
-rw-r--r--generic/tkText.c641
-rw-r--r--generic/tkText.h203
-rw-r--r--generic/tkTextBTree.c131
-rw-r--r--generic/tkTextDisp.c971
-rw-r--r--generic/tkTextImage.c99
-rw-r--r--generic/tkTextIndex.c193
-rw-r--r--generic/tkTextMark.c72
-rw-r--r--generic/tkTextTag.c293
-rw-r--r--generic/tkTextWind.c100
-rw-r--r--generic/tkTrig.c7
-rw-r--r--generic/tkUndo.c12
-rw-r--r--generic/tkUndo.h8
-rw-r--r--generic/tkUtil.c321
-rw-r--r--generic/tkVisual.c36
-rw-r--r--generic/tkWindow.c241
-rw-r--r--generic/ttk/ttk.decls8
-rw-r--r--generic/ttk/ttkBlink.c86
-rw-r--r--generic/ttk/ttkButton.c127
-rw-r--r--generic/ttk/ttkCache.c39
-rw-r--r--generic/ttk/ttkClamTheme.c550
-rw-r--r--generic/ttk/ttkClassicTheme.c476
-rw-r--r--generic/ttk/ttkDecls.h32
-rw-r--r--generic/ttk/ttkDefaultTheme.c729
-rw-r--r--generic/ttk/ttkElements.c1010
-rw-r--r--generic/ttk/ttkEntry.c348
-rw-r--r--generic/ttk/ttkFrame.c63
-rw-r--r--generic/ttk/ttkGenStubs.tcl1009
-rw-r--r--generic/ttk/ttkImage.c83
-rw-r--r--generic/ttk/ttkInit.c124
-rw-r--r--generic/ttk/ttkLabel.c149
-rw-r--r--generic/ttk/ttkLayout.c64
-rw-r--r--generic/ttk/ttkManager.c93
-rw-r--r--generic/ttk/ttkManager.h64
-rw-r--r--generic/ttk/ttkNotebook.c236
-rw-r--r--generic/ttk/ttkPanedwindow.c111
-rw-r--r--generic/ttk/ttkProgress.c92
-rw-r--r--generic/ttk/ttkScale.c68
-rw-r--r--generic/ttk/ttkScroll.c20
-rw-r--r--generic/ttk/ttkScrollbar.c23
-rw-r--r--generic/ttk/ttkSeparator.c22
-rw-r--r--generic/ttk/ttkSquare.c41
-rw-r--r--generic/ttk/ttkState.c69
-rw-r--r--generic/ttk/ttkStubInit.c12
-rw-r--r--generic/ttk/ttkStubLib.c12
-rw-r--r--generic/ttk/ttkTagSet.c95
-rw-r--r--generic/ttk/ttkTheme.c117
-rw-r--r--generic/ttk/ttkTheme.h81
-rw-r--r--generic/ttk/ttkThemeInt.h23
-rw-r--r--generic/ttk/ttkTrack.c12
-rw-r--r--generic/ttk/ttkTreeview.c1780
-rw-r--r--generic/ttk/ttkWidget.c116
-rw-r--r--generic/ttk/ttkWidget.h54
152 files changed, 25225 insertions, 12747 deletions
diff --git a/generic/default.h b/generic/default.h
index e6ef132..c312bc9 100644
--- a/generic/default.h
+++ b/generic/default.h
@@ -4,8 +4,8 @@
* 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.
+ * Copyright © 1991-1994 The Regents of the University of California.
+ * Copyright © 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.
diff --git a/generic/ks_names.h b/generic/ks_names.h
index 2462e79..6978f03 100644
--- a/generic/ks_names.h
+++ b/generic/ks_names.h
@@ -59,14 +59,15 @@
{ "Right", 0xFF53 },
{ "Down", 0xFF54 },
{ "Prior", 0xFF55 },
+#ifndef TK_NO_DEPRECATED
{ "Page_Up", 0xFF55 },
+#endif
{ "Next", 0xFF56 },
+#ifndef TK_NO_DEPRECATED
{ "Page_Down", 0xFF56 },
+#endif
{ "End", 0xFF57 },
{ "Begin", 0xFF58 },
-{ "Win_L", 0xFF5B },
-{ "Win_R", 0xFF5C },
-{ "App", 0xFF5D },
{ "Select", 0xFF60 },
{ "Print", 0xFF61 },
{ "Execute", 0xFF62 },
@@ -74,6 +75,9 @@
{ "Undo", 0xFF65 },
{ "Redo", 0xFF66 },
{ "Menu", 0xFF67 },
+#ifndef TK_NO_DEPRECATED
+{ "App", 0xFF67 },
+#endif
{ "Find", 0xFF68 },
{ "Cancel", 0xFF69 },
{ "Help", 0xFF6A },
@@ -133,55 +137,105 @@
{ "F9", 0xFFC6 },
{ "F10", 0xFFC7 },
{ "F11", 0xFFC8 },
+#ifndef TK_NO_DEPRECATED
{ "L1", 0xFFC8 },
+#endif
{ "F12", 0xFFC9 },
+#ifndef TK_NO_DEPRECATED
{ "L2", 0xFFC9 },
+#endif
{ "F13", 0xFFCA },
+#ifndef TK_NO_DEPRECATED
{ "L3", 0xFFCA },
+#endif
{ "F14", 0xFFCB },
+#ifndef TK_NO_DEPRECATED
{ "L4", 0xFFCB },
+#endif
{ "F15", 0xFFCC },
+#ifndef TK_NO_DEPRECATED
{ "L5", 0xFFCC },
+#endif
{ "F16", 0xFFCD },
+#ifndef TK_NO_DEPRECATED
{ "L6", 0xFFCD },
+#endif
{ "F17", 0xFFCE },
+#ifndef TK_NO_DEPRECATED
{ "L7", 0xFFCE },
+#endif
{ "F18", 0xFFCF },
+#ifndef TK_NO_DEPRECATED
{ "L8", 0xFFCF },
+#endif
{ "F19", 0xFFD0 },
+#ifndef TK_NO_DEPRECATED
{ "L9", 0xFFD0 },
+#endif
{ "F20", 0xFFD1 },
+#ifndef TK_NO_DEPRECATED
{ "L10", 0xFFD1 },
+#endif
{ "F21", 0xFFD2 },
+#ifndef TK_NO_DEPRECATED
{ "R1", 0xFFD2 },
+#endif
{ "F22", 0xFFD3 },
+#ifndef TK_NO_DEPRECATED
{ "R2", 0xFFD3 },
+#endif
{ "F23", 0xFFD4 },
+#ifndef TK_NO_DEPRECATED
{ "R3", 0xFFD4 },
+#endif
{ "F24", 0xFFD5 },
+#ifndef TK_NO_DEPRECATED
{ "R4", 0xFFD5 },
+#endif
{ "F25", 0xFFD6 },
+#ifndef TK_NO_DEPRECATED
{ "R5", 0xFFD6 },
+#endif
{ "F26", 0xFFD7 },
+#ifndef TK_NO_DEPRECATED
{ "R6", 0xFFD7 },
+#endif
{ "F27", 0xFFD8 },
+#ifndef TK_NO_DEPRECATED
{ "R7", 0xFFD8 },
+#endif
{ "F28", 0xFFD9 },
+#ifndef TK_NO_DEPRECATED
{ "R8", 0xFFD9 },
+#endif
{ "F29", 0xFFDA },
+#ifndef TK_NO_DEPRECATED
{ "R9", 0xFFDA },
+#endif
{ "F30", 0xFFDB },
+#ifndef TK_NO_DEPRECATED
{ "R10", 0xFFDB },
+#endif
{ "F31", 0xFFDC },
+#ifndef TK_NO_DEPRECATED
{ "R11", 0xFFDC },
+#endif
{ "F32", 0xFFDD },
+#ifndef TK_NO_DEPRECATED
{ "R12", 0xFFDD },
+#endif
{ "F33", 0xFFDE },
+#ifndef TK_NO_DEPRECATED
{ "R13", 0xFFDE },
+#endif
{ "F34", 0xFFDF },
+#ifndef TK_NO_DEPRECATED
{ "R14", 0xFFDF },
+#endif
{ "F35", 0xFFE0 },
+#ifndef TK_NO_DEPRECATED
{ "R15", 0xFFE0 },
+#endif
{ "Shift_L", 0xFFE1 },
{ "Shift_R", 0xFFE2 },
{ "Control_L", 0xFFE3 },
@@ -193,7 +247,13 @@
{ "Alt_L", 0xFFE9 },
{ "Alt_R", 0xFFEA },
{ "Super_L", 0xFFEB },
+#ifndef TK_NO_DEPRECATED
+{ "Win_L", 0xFFEB },
+#endif
{ "Super_R", 0xFFEC },
+#ifndef TK_NO_DEPRECATED
+{ "Win_R", 0xFFEC },
+#endif
{ "Hyper_L", 0xFFED },
{ "Hyper_R", 0xFFEE },
{ "braille_dot_1", 0xFFF1 },
@@ -304,9 +364,13 @@
{ "dead_u", 0xFE88 },
{ "dead_U", 0xFE89 },
{ "dead_schwa", 0xFE8A },
+#ifndef TK_NO_DEPRECATED
{ "dead_small_schwa", 0xFE8A },
+#endif
{ "dead_SCHWA", 0xFE8B },
+#ifndef TK_NO_DEPRECATED
{ "dead_capital_schwa", 0xFE8B },
+#endif
{ "dead_greek", 0xFE8C },
{ "dead_hamza", 0xFE8D },
{ "dead_lowline", 0xFE90 },
@@ -355,10 +419,13 @@
{ "Pointer_DfltBtnPrev", 0xFEFC },
{ "Pointer_Drag5", 0xFEFD },
{ "space", 0x20 },
+#ifndef TK_NO_DEPRECATED
{ "exclam", 0x21 },
+#endif
{ "quotedbl", 0x22 },
{ "numbersign", 0x23 },
{ "dollar", 0x24 },
+#ifndef TK_NO_DEPRECATED
{ "percent", 0x25 },
{ "ampersand", 0x26 },
{ "apostrophe", 0x27 },
@@ -368,7 +435,9 @@
{ "asterisk", 0x2A },
{ "plus", 0x2B },
{ "comma", 0x2C },
+#endif
{ "minus", 0x2D },
+#ifndef TK_NO_DEPRECATED
{ "period", 0x2E },
{ "slash", 0x2F },
{ "0", 0x30 },
@@ -382,10 +451,14 @@
{ "8", 0x38 },
{ "9", 0x39 },
{ "colon", 0x3A },
+#endif
{ "semicolon", 0x3B },
{ "less", 0x3C },
+#ifndef TK_NO_DEPRECATED
{ "equal", 0x3D },
+#endif
{ "greater", 0x3E },
+#ifndef TK_NO_DEPRECATED
{ "question", 0x3F },
{ "at", 0x40 },
{ "A", 0x41 },
@@ -414,9 +487,11 @@
{ "X", 0x58 },
{ "Y", 0x59 },
{ "Z", 0x5A },
+#endif
{ "bracketleft", 0x5B },
{ "backslash", 0x5C },
{ "bracketright", 0x5D },
+#ifndef TK_NO_DEPRECATED
{ "asciicircum", 0x5E },
{ "underscore", 0x5F },
{ "grave", 0x60 },
@@ -447,11 +522,17 @@
{ "x", 0x78 },
{ "y", 0x79 },
{ "z", 0x7A },
+#endif
{ "braceleft", 0x7B },
+#ifndef TK_NO_DEPRECATED
{ "bar", 0x7C },
+#endif
{ "braceright", 0x7D },
+#ifndef TK_NO_DEPRECATED
{ "asciitilde", 0x7E },
+#endif
{ "nobreakspace", 0xA0 },
+#ifndef TK_NO_DEPRECATED
{ "exclamdown", 0xA1 },
{ "cent", 0xA2 },
{ "sterling", 0xA3 },
@@ -512,7 +593,9 @@
{ "Odiaeresis", 0xD6 },
{ "multiply", 0xD7 },
{ "Oslash", 0xD8 },
+#ifndef TK_NO_DEPRECATED
{ "Ooblique", 0xD8 },
+#endif
{ "Ugrave", 0xD9 },
{ "Uacute", 0xDA },
{ "Ucircumflex", 0xDB },
@@ -546,7 +629,9 @@
{ "odiaeresis", 0xF6 },
{ "division", 0xF7 },
{ "oslash", 0xF8 },
+#ifndef TK_NO_DEPRECATED
{ "ooblique", 0xF8 },
+#endif
{ "ugrave", 0xF9 },
{ "uacute", 0xFA },
{ "ucircumflex", 0xFB },
@@ -554,6 +639,7 @@
{ "yacute", 0xFD },
{ "thorn", 0xFE },
{ "ydiaeresis", 0xFF },
+#endif
{ "Aogonek", 0x1A1 },
{ "breve", 0x1A2 },
{ "Lstroke", 0x1A3 },
@@ -634,7 +720,9 @@
{ "ubreve", 0x2FD },
{ "scircumflex", 0x2FE },
{ "kra", 0x3A2 },
+#ifndef TK_NO_DEPRECATED
{ "kappa", 0x3A2 },
+#endif
{ "Rcedilla", 0x3A3 },
{ "Itilde", 0x3A5 },
{ "Lcedilla", 0x3A6 },
@@ -646,7 +734,9 @@
{ "lcedilla", 0x3B6 },
{ "emacron", 0x3BA },
{ "gcedilla", 0x3BB },
+#ifndef TK_NO_DEPRECATED
{ "gacute", 0x3BB },
+#endif
{ "tslash", 0x3BC },
{ "ENG", 0x3BD },
{ "eng", 0x3BF },
@@ -679,7 +769,9 @@
{ "kana_closingbracket", 0x4A3 },
{ "kana_comma", 0x4A4 },
{ "kana_conjunctive", 0x4A5 },
+#ifndef TK_NO_DEPRECATED
{ "kana_middledot", 0x4A5 },
+#endif
{ "kana_WO", 0x4A6 },
{ "kana_a", 0x4A7 },
{ "kana_i", 0x4A8 },
@@ -690,7 +782,9 @@
{ "kana_yu", 0x4AD },
{ "kana_yo", 0x4AE },
{ "kana_tsu", 0x4AF },
+#ifndef TK_NO_DEPRECATED
{ "kana_tu", 0x4AF },
+#endif
{ "prolongedsound", 0x4B0 },
{ "kana_A", 0x4B1 },
{ "kana_I", 0x4B2 },
@@ -709,9 +803,13 @@
{ "kana_SO", 0x4BF },
{ "kana_TA", 0x4C0 },
{ "kana_CHI", 0x4C1 },
+#ifndef TK_NO_DEPRECATED
{ "kana_TI", 0x4C1 },
+#endif
{ "kana_TSU", 0x4C2 },
+#ifndef TK_NO_DEPRECATED
{ "kana_TU", 0x4C2 },
+#endif
{ "kana_TE", 0x4C3 },
{ "kana_TO", 0x4C4 },
{ "kana_NA", 0x4C5 },
@@ -722,7 +820,9 @@
{ "kana_HA", 0x4CA },
{ "kana_HI", 0x4CB },
{ "kana_FU", 0x4CC },
+#ifndef TK_NO_DEPRECATED
{ "kana_HU", 0x4CC },
+#endif
{ "kana_HE", 0x4CD },
{ "kana_HO", 0x4CE },
{ "kana_MA", 0x4CF },
@@ -779,7 +879,9 @@
{ "Arabic_meem", 0x5E5 },
{ "Arabic_noon", 0x5E6 },
{ "Arabic_ha", 0x5E7 },
+#ifndef TK_NO_DEPRECATED
{ "Arabic_heh", 0x5E7 },
+#endif
{ "Arabic_waw", 0x5E8 },
{ "Arabic_alefmaksura", 0x5E9 },
{ "Arabic_yeh", 0x5EA },
@@ -795,47 +897,75 @@
{ "Macedonia_gje", 0x6A2 },
{ "Cyrillic_io", 0x6A3 },
{ "Ukrainian_ie", 0x6A4 },
+#ifndef TK_NO_DEPRECATED
{ "Ukranian_je", 0x6A4 },
+#endif
{ "Macedonia_dse", 0x6A5 },
{ "Ukrainian_i", 0x6A6 },
+#ifndef TK_NO_DEPRECATED
{ "Ukranian_i", 0x6A6 },
+#endif
{ "Ukrainian_yi", 0x6A7 },
+#ifndef TK_NO_DEPRECATED
{ "Ukranian_yi", 0x6A7 },
+#endif
{ "Cyrillic_je", 0x6A8 },
+#ifndef TK_NO_DEPRECATED
{ "Serbian_je", 0x6A8 },
+#endif
{ "Cyrillic_lje", 0x6A9 },
+#ifndef TK_NO_DEPRECATED
{ "Serbian_lje", 0x6A9 },
+#endif
{ "Cyrillic_nje", 0x6AA },
+#ifndef TK_NO_DEPRECATED
{ "Serbian_nje", 0x6AA },
+#endif
{ "Serbian_tshe", 0x6AB },
{ "Macedonia_kje", 0x6AC },
{ "Ukrainian_ghe_with_upturn", 0x6AD },
{ "Byelorussian_shortu", 0x6AE },
{ "Cyrillic_dzhe", 0x6AF },
+#ifndef TK_NO_DEPRECATED
{ "Serbian_dze", 0x6AF },
+#endif
{ "numerosign", 0x6B0 },
{ "Serbian_DJE", 0x6B1 },
{ "Macedonia_GJE", 0x6B2 },
{ "Cyrillic_IO", 0x6B3 },
{ "Ukrainian_IE", 0x6B4 },
+#ifndef TK_NO_DEPRECATED
{ "Ukranian_JE", 0x6B4 },
+#endif
{ "Macedonia_DSE", 0x6B5 },
{ "Ukrainian_I", 0x6B6 },
+#ifndef TK_NO_DEPRECATED
{ "Ukranian_I", 0x6B6 },
+#endif
{ "Ukrainian_YI", 0x6B7 },
+#ifndef TK_NO_DEPRECATED
{ "Ukranian_YI", 0x6B7 },
+#endif
{ "Cyrillic_JE", 0x6B8 },
+#ifndef TK_NO_DEPRECATED
{ "Serbian_JE", 0x6B8 },
+#endif
{ "Cyrillic_LJE", 0x6B9 },
+#ifndef TK_NO_DEPRECATED
{ "Serbian_LJE", 0x6B9 },
+#endif
{ "Cyrillic_NJE", 0x6BA },
+#ifndef TK_NO_DEPRECATED
{ "Serbian_NJE", 0x6BA },
+#endif
{ "Serbian_TSHE", 0x6BB },
{ "Macedonia_KJE", 0x6BC },
{ "Ukrainian_GHE_WITH_UPTURN", 0x6BD },
{ "Byelorussian_SHORTU", 0x6BE },
{ "Cyrillic_DZHE", 0x6BF },
+#ifndef TK_NO_DEPRECATED
{ "Serbian_DZE", 0x6BF },
+#endif
{ "Cyrillic_yu", 0x6C0 },
{ "Cyrillic_a", 0x6C1 },
{ "Cyrillic_be", 0x6C2 },
@@ -905,7 +1035,9 @@
{ "Greek_ETAaccent", 0x7A3 },
{ "Greek_IOTAaccent", 0x7A4 },
{ "Greek_IOTAdieresis", 0x7A5 },
+#ifndef TK_NO_DEPRECATED
{ "Greek_IOTAdiaeresis", 0x7A5 },
+#endif
{ "Greek_IOTAaccentdiaeresis", 0x7A6 },
{ "Greek_OMICRONaccent", 0x7A7 },
{ "Greek_UPSILONaccent", 0x7A8 },
@@ -1155,19 +1287,31 @@
{ "hebrew_doublelowline", 0xCDF },
{ "hebrew_aleph", 0xCE0 },
{ "hebrew_bet", 0xCE1 },
+#ifndef TK_NO_DEPRECATED
{ "hebrew_beth", 0xCE1 },
+#endif
{ "hebrew_gimel", 0xCE2 },
+#ifndef TK_NO_DEPRECATED
{ "hebrew_gimmel", 0xCE2 },
+#endif
{ "hebrew_dalet", 0xCE3 },
+#ifndef TK_NO_DEPRECATED
{ "hebrew_daleth", 0xCE3 },
+#endif
{ "hebrew_he", 0xCE4 },
{ "hebrew_waw", 0xCE5 },
{ "hebrew_zain", 0xCE6 },
+#ifndef TK_NO_DEPRECATED
{ "hebrew_zayin", 0xCE6 },
+#endif
{ "hebrew_chet", 0xCE7 },
+#ifndef TK_NO_DEPRECATED
{ "hebrew_het", 0xCE7 },
+#endif
{ "hebrew_tet", 0xCE8 },
+#ifndef TK_NO_DEPRECATED
{ "hebrew_teth", 0xCE8 },
+#endif
{ "hebrew_yod", 0xCE9 },
{ "hebrew_finalkaph", 0xCEA },
{ "hebrew_kaph", 0xCEB },
@@ -1177,20 +1321,30 @@
{ "hebrew_finalnun", 0xCEF },
{ "hebrew_nun", 0xCF0 },
{ "hebrew_samech", 0xCF1 },
+#ifndef TK_NO_DEPRECATED
{ "hebrew_samekh", 0xCF1 },
+#endif
{ "hebrew_ayin", 0xCF2 },
{ "hebrew_finalpe", 0xCF3 },
{ "hebrew_pe", 0xCF4 },
{ "hebrew_finalzade", 0xCF5 },
+#ifndef TK_NO_DEPRECATED
{ "hebrew_finalzadi", 0xCF5 },
+#endif
{ "hebrew_zade", 0xCF6 },
+#ifndef TK_NO_DEPRECATED
{ "hebrew_zadi", 0xCF6 },
+#endif
{ "hebrew_qoph", 0xCF7 },
+#ifndef TK_NO_DEPRECATED
{ "hebrew_kuf", 0xCF7 },
+#endif
{ "hebrew_resh", 0xCF8 },
{ "hebrew_shin", 0xCF9 },
{ "hebrew_taw", 0xCFA },
+#ifndef TK_NO_DEPRECATED
{ "hebrew_taf", 0xCFA },
+#endif
{ "Thai_kokai", 0xDA1 },
{ "Thai_khokhai", 0xDA2 },
{ "Thai_khokhuat", 0xDA3 },
diff --git a/generic/nanosvg.h b/generic/nanosvg.h
new file mode 100644
index 0000000..04d6d88
--- /dev/null
+++ b/generic/nanosvg.h
@@ -0,0 +1,3216 @@
+/*
+ * Copyright (c) 2013-14 Mikko Mononen memon@inside.org
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty. In no event will the authors be held liable for any damages
+ * arising from the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it
+ * freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ * claim that you wrote the original software. If you use this software
+ * in a product, an acknowledgment in the product documentation would be
+ * appreciated but is not required.
+ * 2. Altered source versions must be plainly marked as such, and must not be
+ * misrepresented as being the original software.
+ * 3. This notice may not be removed or altered from any source distribution.
+ *
+ * The SVG parser is based on Anti-Grain Geometry 2.4 SVG example
+ * Copyright (C) 2002-2004 Maxim Shemanarev (McSeem) (http://www.antigrain.com/)
+ *
+ * Arc calculation code based on canvg (https://code.google.com/p/canvg/)
+ *
+ * Bounding box calculation based on http://blog.hackers-cafe.net/2009/06/how-to-calculate-bezier-curves-bounding.html
+ *
+ */
+
+#ifndef NANOSVG_H
+#define NANOSVG_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* NanoSVG is a simple stupid single-header-file SVG parse. The output of the parser is a list of cubic bezier shapes.
+ *
+ * The library suits well for anything from rendering scalable icons in your editor application to prototyping a game.
+ *
+ * NanoSVG supports a wide range of SVG features, but something may be missing, feel free to create a pull request!
+ *
+ * The shapes in the SVG images are transformed by the viewBox and converted to specified units.
+ * That is, you should get the same looking data as your designed in your favorite app.
+ *
+ * NanoSVG can return the paths in few different units. For example if you want to render an image, you may choose
+ * to get the paths in pixels, or if you are feeding the data into a CNC-cutter, you may want to use millimeters.
+ *
+ * The units passed to NanoSVG should be one of: 'px', 'pt', 'pc' 'mm', 'cm', or 'in'.
+ * DPI (dots-per-inch) controls how the unit conversion is done.
+ *
+ * If you don't know or care about the units stuff, "px" and 96 should get you going.
+ */
+
+
+/* Example Usage:
+ // Load SVG
+ NSVGimage* image;
+ image = nsvgParseFromFile("test.svg", "px", 96);
+ printf("size: %f x %f\n", image->width, image->height);
+ // Use...
+ for (NSVGshape *shape = image->shapes; shape != NULL; shape = shape->next) {
+ for (NSVGpath *path = shape->paths; path != NULL; path = path->next) {
+ for (int i = 0; i < path->npts-1; i += 3) {
+ float* p = &path->pts[i*2];
+ drawCubicBez(p[0],p[1], p[2],p[3], p[4],p[5], p[6],p[7]);
+ }
+ }
+ }
+ // Delete
+ nsvgDelete(image);
+*/
+
+#ifndef NANOSVG_SCOPE
+#define NANOSVG_SCOPE
+#endif
+
+#ifndef NANOSVG_malloc
+#define NANOSVG_malloc malloc
+#endif
+
+#ifndef NANOSVG_realloc
+#define NANOSVG_realloc realloc
+#endif
+
+#ifndef NANOSVG_free
+#define NANOSVG_free free
+#endif
+
+/* float emulation for MS VC6++ compiler */
+#if defined(_MSC_VER) && (_MSC_VER == 1200)
+#define tanf(a) (float)tan(a)
+#define cosf(a) (float)cos(a)
+#define sinf(a) (float)sin(a)
+#define sqrtf(a) (float)sqrt(a)
+#define fabsf(a) (float)fabs(a)
+#define acosf(a) (float)acos(a)
+#define atan2f(a,b) (float)atan2(a,b)
+#define ceilf(a) (float)ceil(a)
+#define fmodf(a,b) (float)fmod(a,b)
+#define floorf(a) (float)floor(a)
+#endif
+/* float emulation for MS VC8++ compiler */
+#if defined(_MSC_VER) && (_MSC_VER == 1400)
+#define fabsf(a) (float)fabs(a)
+#endif
+
+enum NSVGpaintType {
+ NSVG_PAINT_UNDEF = -1,
+ NSVG_PAINT_NONE = 0,
+ NSVG_PAINT_COLOR = 1,
+ NSVG_PAINT_LINEAR_GRADIENT = 2,
+ NSVG_PAINT_RADIAL_GRADIENT = 3
+};
+
+enum NSVGspreadType {
+ NSVG_SPREAD_PAD = 0,
+ NSVG_SPREAD_REFLECT = 1,
+ NSVG_SPREAD_REPEAT = 2
+};
+
+enum NSVGlineJoin {
+ NSVG_JOIN_MITER = 0,
+ NSVG_JOIN_ROUND = 1,
+ NSVG_JOIN_BEVEL = 2
+};
+
+enum NSVGlineCap {
+ NSVG_CAP_BUTT = 0,
+ NSVG_CAP_ROUND = 1,
+ NSVG_CAP_SQUARE = 2
+};
+
+enum NSVGfillRule {
+ NSVG_FILLRULE_NONZERO = 0,
+ NSVG_FILLRULE_EVENODD = 1
+};
+
+enum NSVGflags {
+ NSVG_FLAGS_VISIBLE = 0x01
+};
+
+typedef struct NSVGgradientStop {
+ unsigned int color;
+ float offset;
+} NSVGgradientStop;
+
+typedef struct NSVGgradient {
+ float xform[6];
+ char spread;
+ float fx, fy;
+ int nstops;
+ NSVGgradientStop stops[1];
+} NSVGgradient;
+
+typedef struct NSVGpaint {
+ signed char type;
+ union {
+ unsigned int color;
+ NSVGgradient* gradient;
+ };
+} NSVGpaint;
+
+typedef struct NSVGpath
+{
+ float* pts; /* Cubic bezier points: x0,y0, [cpx1,cpx1,cpx2,cpy2,x1,y1], ... */
+ int npts; /* Total number of bezier points. */
+ char closed; /* Flag indicating if shapes should be treated as closed. */
+ float bounds[4]; /* Tight bounding box of the shape [minx,miny,maxx,maxy]. */
+ struct NSVGpath* next; /* Pointer to next path, or NULL if last element. */
+} NSVGpath;
+
+typedef struct NSVGshape
+{
+ char id[64]; /* Optional 'id' attr of the shape or its group */
+ NSVGpaint fill; /* Fill paint */
+ NSVGpaint stroke; /* Stroke paint */
+ float opacity; /* Opacity of the shape. */
+ float strokeWidth; /* Stroke width (scaled). */
+ float strokeDashOffset; /* Stroke dash offset (scaled). */
+ float strokeDashArray[8]; /* Stroke dash array (scaled). */
+ char strokeDashCount; /* Number of dash values in dash array. */
+ char strokeLineJoin; /* Stroke join type. */
+ char strokeLineCap; /* Stroke cap type. */
+ float miterLimit; /* Miter limit */
+ char fillRule; /* Fill rule, see NSVGfillRule. */
+ unsigned char flags; /* Logical or of NSVG_FLAGS_* flags */
+ float bounds[4]; /* Tight bounding box of the shape [minx,miny,maxx,maxy]. */
+ char fillGradient[64]; // Optional 'id' of fill gradient
+ char strokeGradient[64]; // Optional 'id' of stroke gradient
+ float xform[6]; // Root transformation for fill/stroke gradient
+ NSVGpath* paths; /* Linked list of paths in the image. */
+ struct NSVGshape* next; /* Pointer to next shape, or NULL if last element. */
+} NSVGshape;
+
+typedef struct NSVGimage
+{
+ float width; /* Width of the image. */
+ float height; /* Height of the image. */
+ NSVGshape* shapes; /* Linked list of shapes in the image. */
+} NSVGimage;
+
+/* Parses SVG file from a file, returns SVG image as paths. */
+NANOSVG_SCOPE NSVGimage* nsvgParseFromFile(const char* filename, const char* units, float dpi);
+
+/* Parses SVG file from a null terminated string, returns SVG image as paths. */
+/* Important note: changes the string. */
+NANOSVG_SCOPE NSVGimage* nsvgParse(char* input, const char* units, float dpi);
+
+/* Deletes list of paths. */
+NANOSVG_SCOPE void nsvgDelete(NSVGimage* image);
+
+#ifdef __cplusplus
+}
+#endif
+
+#ifdef NANOSVG_IMPLEMENTATION
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+
+#define NSVG_PI (3.14159265358979323846264338327f)
+#define NSVG_KAPPA90 (0.5522847493f) /* Length proportional to radius of a cubic bezier handle for 90deg arcs. */
+
+#define NSVG_ALIGN_MIN 0
+#define NSVG_ALIGN_MID 1
+#define NSVG_ALIGN_MAX 2
+#define NSVG_ALIGN_NONE 0
+#define NSVG_ALIGN_MEET 1
+#define NSVG_ALIGN_SLICE 2
+
+#define NSVG_NOTUSED(v) do { (void)(1 ? (void)0 : ( (void)(v) ) ); } while(0)
+#define NSVG_RGB(r, g, b) (((unsigned int)r) | ((unsigned int)g << 8) | ((unsigned int)b << 16))
+
+#ifdef _MSC_VER
+ #pragma warning (disable: 4996) /* Switch off security warnings */
+ #pragma warning (disable: 4100) /* Switch off unreferenced formal parameter warnings */
+ #ifdef __cplusplus
+ #define NSVG_INLINE inline
+ #else
+ #define NSVG_INLINE
+ #endif
+ #if !defined(strtoll) /* old MSVC versions do not have strtoll() */
+ #define strtoll _strtoi64
+ #endif
+#else
+ #define NSVG_INLINE inline
+#endif
+
+
+static int nsvg__isspace(char c)
+{
+ return strchr(" \t\n\v\f\r", c) != 0;
+}
+
+static int nsvg__isdigit(char c)
+{
+ return c >= '0' && c <= '9';
+}
+
+static NSVG_INLINE float nsvg__minf(float a, float b) { return a < b ? a : b; }
+static NSVG_INLINE float nsvg__maxf(float a, float b) { return a > b ? a : b; }
+
+
+/* Simple XML parser */
+
+#define NSVG_XML_TAG 1
+#define NSVG_XML_CONTENT 2
+#define NSVG_XML_MAX_ATTRIBS 256
+
+static void nsvg__parseContent(char* s,
+ void (*contentCb)(void* ud, const char* s),
+ void* ud)
+{
+ /* Trim start white spaces */
+ while (*s && nsvg__isspace(*s)) s++;
+ if (!*s) return;
+
+ if (contentCb)
+ (*contentCb)(ud, s);
+}
+
+static void nsvg__parseElement(char* s,
+ void (*startelCb)(void* ud, const char* el, const char** attr),
+ void (*endelCb)(void* ud, const char* el),
+ void* ud)
+{
+ const char* attr[NSVG_XML_MAX_ATTRIBS];
+ int nattr = 0;
+ char* cbname;
+ int start = 0;
+ int end = 0;
+ char quote;
+
+ /* Skip white space after the '<' */
+ while (*s && nsvg__isspace(*s)) s++;
+
+ /* Check if the tag is end tag */
+ if (*s == '/') {
+ s++;
+ end = 1;
+ } else {
+ start = 1;
+ }
+
+ /* Skip comments, data and preprocessor stuff. */
+ if (!*s || *s == '?' || *s == '!')
+ return;
+
+ /* Get tag name */
+ cbname = s;
+ while (*s && !nsvg__isspace(*s)) s++;
+ if (*s) { *s++ = '\0'; }
+
+ /* Get attribs */
+ while (!end && *s && nattr < NSVG_XML_MAX_ATTRIBS-3) {
+ char* name = NULL;
+ char* value = NULL;
+
+ /* Skip white space before the attrib name */
+ while (*s && nsvg__isspace(*s)) s++;
+ if (!*s) break;
+ if (*s == '/') {
+ end = 1;
+ break;
+ }
+ name = s;
+ /* Find end of the attrib name. */
+ while (*s && !nsvg__isspace(*s) && *s != '=') s++;
+ if (*s) { *s++ = '\0'; }
+ /* Skip until the beginning of the value. */
+ while (*s && *s != '\"' && *s != '\'') s++;
+ if (!*s) break;
+ quote = *s;
+ s++;
+ /* Store value and find the end of it. */
+ value = s;
+ while (*s && *s != quote) s++;
+ if (*s) { *s++ = '\0'; }
+
+ /* Store only well formed attributes */
+ if (name && value) {
+ attr[nattr++] = name;
+ attr[nattr++] = value;
+ }
+ }
+
+ /* List terminator */
+ attr[nattr++] = 0;
+ attr[nattr++] = 0;
+
+ /* Call callbacks. */
+ if (start && startelCb)
+ (*startelCb)(ud, cbname, attr);
+ if (end && endelCb)
+ (*endelCb)(ud, cbname);
+}
+
+NANOSVG_SCOPE
+int nsvg__parseXML(char* input,
+ void (*startelCb)(void* ud, const char* el, const char** attr),
+ void (*endelCb)(void* ud, const char* el),
+ void (*contentCb)(void* ud, const char* s),
+ void* ud)
+{
+ char* s = input;
+ char* mark = s;
+ int state = NSVG_XML_CONTENT;
+ while (*s) {
+ if (*s == '<' && state == NSVG_XML_CONTENT) {
+ /* Start of a tag */
+ *s++ = '\0';
+ nsvg__parseContent(mark, contentCb, ud);
+ mark = s;
+ state = NSVG_XML_TAG;
+ } else if (*s == '>' && state == NSVG_XML_TAG) {
+ /* Start of a content or new tag. */
+ *s++ = '\0';
+ nsvg__parseContent(mark, contentCb, ud);
+ nsvg__parseElement(mark, startelCb, endelCb, ud);
+ mark = s;
+ state = NSVG_XML_CONTENT;
+ } else {
+ s++;
+ }
+ }
+
+ return 1;
+}
+
+
+/* Simple SVG parser. */
+
+#define NSVG_MAX_ATTR 128
+
+enum NSVGgradientUnits {
+ NSVG_USER_SPACE = 0,
+ NSVG_OBJECT_SPACE = 1
+};
+
+#define NSVG_MAX_DASHES 8
+
+enum NSVGunits {
+ NSVG_UNITS_USER,
+ NSVG_UNITS_PX,
+ NSVG_UNITS_PT,
+ NSVG_UNITS_PC,
+ NSVG_UNITS_MM,
+ NSVG_UNITS_CM,
+ NSVG_UNITS_IN,
+ NSVG_UNITS_PERCENT,
+ NSVG_UNITS_EM,
+ NSVG_UNITS_EX
+};
+
+enum NSVGvisible {
+ NSVG_VIS_DISPLAY = 1,
+ NSVG_VIS_VISIBLE = 2
+};
+
+typedef struct NSVGcoordinate {
+ float value;
+ int units;
+} NSVGcoordinate;
+
+typedef struct NSVGlinearData {
+ NSVGcoordinate x1, y1, x2, y2;
+} NSVGlinearData;
+
+typedef struct NSVGradialData {
+ NSVGcoordinate cx, cy, r, fx, fy;
+} NSVGradialData;
+
+typedef struct NSVGgradientData
+{
+ char id[64];
+ char ref[64];
+ signed char type;
+ union {
+ NSVGlinearData linear;
+ NSVGradialData radial;
+ };
+ char spread;
+ char units;
+ float xform[6];
+ int nstops;
+ NSVGgradientStop* stops;
+ struct NSVGgradientData* next;
+} NSVGgradientData;
+
+typedef struct NSVGattrib
+{
+ char id[64];
+ float xform[6];
+ unsigned int fillColor;
+ unsigned int strokeColor;
+ float opacity;
+ float fillOpacity;
+ float strokeOpacity;
+ char fillGradient[64];
+ char strokeGradient[64];
+ float strokeWidth;
+ float strokeDashOffset;
+ float strokeDashArray[NSVG_MAX_DASHES];
+ int strokeDashCount;
+ char strokeLineJoin;
+ char strokeLineCap;
+ float miterLimit;
+ char fillRule;
+ float fontSize;
+ unsigned int stopColor;
+ float stopOpacity;
+ float stopOffset;
+ char hasFill;
+ char hasStroke;
+ char visible;
+} NSVGattrib;
+
+typedef struct NSVGstyles
+{
+ char* name;
+ char* description;
+ struct NSVGstyles* next;
+} NSVGstyles;
+
+typedef struct NSVGparser
+{
+ NSVGattrib attr[NSVG_MAX_ATTR];
+ int attrHead;
+ float* pts;
+ int npts;
+ int cpts;
+ NSVGpath* plist;
+ NSVGimage* image;
+ NSVGstyles* styles;
+ NSVGgradientData* gradients;
+ NSVGshape* shapesTail;
+ float viewMinx, viewMiny, viewWidth, viewHeight;
+ int alignX, alignY, alignType;
+ float dpi;
+ char pathFlag;
+ char defsFlag;
+ char styleFlag;
+} NSVGparser;
+
+static void nsvg__xformIdentity(float* t)
+{
+ t[0] = 1.0f; t[1] = 0.0f;
+ t[2] = 0.0f; t[3] = 1.0f;
+ t[4] = 0.0f; t[5] = 0.0f;
+}
+
+static void nsvg__xformSetTranslation(float* t, float tx, float ty)
+{
+ t[0] = 1.0f; t[1] = 0.0f;
+ t[2] = 0.0f; t[3] = 1.0f;
+ t[4] = tx; t[5] = ty;
+}
+
+static void nsvg__xformSetScale(float* t, float sx, float sy)
+{
+ t[0] = sx; t[1] = 0.0f;
+ t[2] = 0.0f; t[3] = sy;
+ t[4] = 0.0f; t[5] = 0.0f;
+}
+
+static void nsvg__xformSetSkewX(float* t, float a)
+{
+ t[0] = 1.0f; t[1] = 0.0f;
+ t[2] = tanf(a); t[3] = 1.0f;
+ t[4] = 0.0f; t[5] = 0.0f;
+}
+
+static void nsvg__xformSetSkewY(float* t, float a)
+{
+ t[0] = 1.0f; t[1] = tanf(a);
+ t[2] = 0.0f; t[3] = 1.0f;
+ t[4] = 0.0f; t[5] = 0.0f;
+}
+
+static void nsvg__xformSetRotation(float* t, float a)
+{
+ float cs = cosf(a), sn = sinf(a);
+ t[0] = cs; t[1] = sn;
+ t[2] = -sn; t[3] = cs;
+ t[4] = 0.0f; t[5] = 0.0f;
+}
+
+static void nsvg__xformMultiply(float* t, float* s)
+{
+ float t0 = t[0] * s[0] + t[1] * s[2];
+ float t2 = t[2] * s[0] + t[3] * s[2];
+ float t4 = t[4] * s[0] + t[5] * s[2] + s[4];
+ t[1] = t[0] * s[1] + t[1] * s[3];
+ t[3] = t[2] * s[1] + t[3] * s[3];
+ t[5] = t[4] * s[1] + t[5] * s[3] + s[5];
+ t[0] = t0;
+ t[2] = t2;
+ t[4] = t4;
+}
+
+static void nsvg__xformInverse(float* inv, float* t)
+{
+ double invdet, det = (double)t[0] * t[3] - (double)t[2] * t[1];
+ if (det > -1e-6 && det < 1e-6) {
+ nsvg__xformIdentity(t);
+ return;
+ }
+ invdet = 1.0 / det;
+ inv[0] = (float)(t[3] * invdet);
+ inv[2] = (float)(-t[2] * invdet);
+ inv[4] = (float)(((double)t[2] * t[5] - (double)t[3] * t[4]) * invdet);
+ inv[1] = (float)(-t[1] * invdet);
+ inv[3] = (float)(t[0] * invdet);
+ inv[5] = (float)(((double)t[1] * t[4] - (double)t[0] * t[5]) * invdet);
+}
+
+static void nsvg__xformPremultiply(float* t, float* s)
+{
+ float s2[6];
+ memcpy(s2, s, sizeof(float)*6);
+ nsvg__xformMultiply(s2, t);
+ memcpy(t, s2, sizeof(float)*6);
+}
+
+static void nsvg__xformPoint(float* dx, float* dy, float x, float y, float* t)
+{
+ *dx = x*t[0] + y*t[2] + t[4];
+ *dy = x*t[1] + y*t[3] + t[5];
+}
+
+static void nsvg__xformVec(float* dx, float* dy, float x, float y, float* t)
+{
+ *dx = x*t[0] + y*t[2];
+ *dy = x*t[1] + y*t[3];
+}
+
+#define NSVG_EPSILON (1e-12)
+
+static int nsvg__ptInBounds(float* pt, float* bounds)
+{
+ return pt[0] >= bounds[0] && pt[0] <= bounds[2] && pt[1] >= bounds[1] && pt[1] <= bounds[3];
+}
+
+
+static double nsvg__evalBezier(double t, double p0, double p1, double p2, double p3)
+{
+ double it = 1.0-t;
+ return it*it*it*p0 + 3.0*it*it*t*p1 + 3.0*it*t*t*p2 + t*t*t*p3;
+}
+
+static void nsvg__curveBounds(float* bounds, float* curve)
+{
+ int i, j, count;
+ double roots[2], a, b, c, b2ac, t, v;
+ float* v0 = &curve[0];
+ float* v1 = &curve[2];
+ float* v2 = &curve[4];
+ float* v3 = &curve[6];
+
+ /* Start the bounding box by end points */
+ bounds[0] = nsvg__minf(v0[0], v3[0]);
+ bounds[1] = nsvg__minf(v0[1], v3[1]);
+ bounds[2] = nsvg__maxf(v0[0], v3[0]);
+ bounds[3] = nsvg__maxf(v0[1], v3[1]);
+
+ /* Bezier curve fits inside the convex hull of it's control points. */
+ /* If control points are inside the bounds, we're done. */
+ if (nsvg__ptInBounds(v1, bounds) && nsvg__ptInBounds(v2, bounds))
+ return;
+
+ /* Add bezier curve inflection points in X and Y. */
+ for (i = 0; i < 2; i++) {
+ a = -3.0 * v0[i] + 9.0 * v1[i] - 9.0 * v2[i] + 3.0 * v3[i];
+ b = 6.0 * v0[i] - 12.0 * v1[i] + 6.0 * v2[i];
+ c = 3.0 * v1[i] - 3.0 * v0[i];
+ count = 0;
+ if (fabs(a) < NSVG_EPSILON) {
+ if (fabs(b) > NSVG_EPSILON) {
+ t = -c / b;
+ if (t > NSVG_EPSILON && t < 1.0-NSVG_EPSILON)
+ roots[count++] = t;
+ }
+ } else {
+ b2ac = b*b - 4.0*c*a;
+ if (b2ac > NSVG_EPSILON) {
+ t = (-b + sqrt(b2ac)) / (2.0 * a);
+ if (t > NSVG_EPSILON && t < 1.0-NSVG_EPSILON)
+ roots[count++] = t;
+ t = (-b - sqrt(b2ac)) / (2.0 * a);
+ if (t > NSVG_EPSILON && t < 1.0-NSVG_EPSILON)
+ roots[count++] = t;
+ }
+ }
+ for (j = 0; j < count; j++) {
+ v = nsvg__evalBezier(roots[j], v0[i], v1[i], v2[i], v3[i]);
+ bounds[0+i] = nsvg__minf(bounds[0+i], (float)v);
+ bounds[2+i] = nsvg__maxf(bounds[2+i], (float)v);
+ }
+ }
+}
+
+static NSVGparser* nsvg__createParser(void)
+{
+ NSVGparser* p;
+ p = (NSVGparser*)NANOSVG_malloc(sizeof(NSVGparser));
+ if (p == NULL) goto error;
+ memset(p, 0, sizeof(NSVGparser));
+
+ p->image = (NSVGimage*)NANOSVG_malloc(sizeof(NSVGimage));
+ if (p->image == NULL) goto error;
+ memset(p->image, 0, sizeof(NSVGimage));
+
+ /* Init style */
+ nsvg__xformIdentity(p->attr[0].xform);
+ memset(p->attr[0].id, 0, sizeof p->attr[0].id);
+ p->attr[0].fillColor = NSVG_RGB(0,0,0);
+ p->attr[0].strokeColor = NSVG_RGB(0,0,0);
+ p->attr[0].opacity = 1;
+ p->attr[0].fillOpacity = 1;
+ p->attr[0].strokeOpacity = 1;
+ p->attr[0].stopOpacity = 1;
+ p->attr[0].strokeWidth = 1;
+ p->attr[0].strokeLineJoin = NSVG_JOIN_MITER;
+ p->attr[0].strokeLineCap = NSVG_CAP_BUTT;
+ p->attr[0].miterLimit = 4;
+ p->attr[0].fillRule = NSVG_FILLRULE_NONZERO;
+ p->attr[0].hasFill = 1;
+ p->attr[0].visible = NSVG_VIS_DISPLAY | NSVG_VIS_VISIBLE;
+
+ return p;
+
+error:
+ if (p) {
+ if (p->image) NANOSVG_free(p->image);
+ NANOSVG_free(p);
+ }
+ return NULL;
+}
+
+static void nsvg__deleteStyles(NSVGstyles* style) {
+ while (style) {
+ NSVGstyles *next = style->next;
+ if (style->name!= NULL)
+ NANOSVG_free(style->name);
+ if (style->description != NULL)
+ NANOSVG_free(style->description);
+ NANOSVG_free(style);
+ style = next;
+ }
+}
+
+static void nsvg__deletePaths(NSVGpath* path)
+{
+ while (path) {
+ NSVGpath *next = path->next;
+ if (path->pts != NULL)
+ NANOSVG_free(path->pts);
+ NANOSVG_free(path);
+ path = next;
+ }
+}
+
+static void nsvg__deletePaint(NSVGpaint* paint)
+{
+ if (paint->type == NSVG_PAINT_LINEAR_GRADIENT || paint->type == NSVG_PAINT_RADIAL_GRADIENT)
+ NANOSVG_free(paint->gradient);
+}
+
+static void nsvg__deleteGradientData(NSVGgradientData* grad)
+{
+ NSVGgradientData* next;
+ while (grad != NULL) {
+ next = grad->next;
+ NANOSVG_free(grad->stops);
+ NANOSVG_free(grad);
+ grad = next;
+ }
+}
+
+static void nsvg__deleteParser(NSVGparser* p)
+{
+ if (p != NULL) {
+ nsvg__deleteStyles(p->styles);
+ nsvg__deletePaths(p->plist);
+ nsvg__deleteGradientData(p->gradients);
+ nsvgDelete(p->image);
+ NANOSVG_free(p->pts);
+ NANOSVG_free(p);
+ }
+}
+
+static void nsvg__resetPath(NSVGparser* p)
+{
+ p->npts = 0;
+}
+
+static void nsvg__addPoint(NSVGparser* p, float x, float y)
+{
+ if (p->npts+1 > p->cpts) {
+ p->cpts = p->cpts ? p->cpts*2 : 8;
+ p->pts = (float*)NANOSVG_realloc(p->pts, p->cpts*2*sizeof(float));
+ if (!p->pts) return;
+ }
+ p->pts[p->npts*2+0] = x;
+ p->pts[p->npts*2+1] = y;
+ p->npts++;
+}
+
+static void nsvg__moveTo(NSVGparser* p, float x, float y)
+{
+ if (p->npts > 0) {
+ p->pts[(p->npts-1)*2+0] = x;
+ p->pts[(p->npts-1)*2+1] = y;
+ } else {
+ nsvg__addPoint(p, x, y);
+ }
+}
+
+static void nsvg__lineTo(NSVGparser* p, float x, float y)
+{
+ float px,py, dx,dy;
+ if (p->npts > 0) {
+ px = p->pts[(p->npts-1)*2+0];
+ py = p->pts[(p->npts-1)*2+1];
+ dx = x - px;
+ dy = y - py;
+ nsvg__addPoint(p, px + dx/3.0f, py + dy/3.0f);
+ nsvg__addPoint(p, x - dx/3.0f, y - dy/3.0f);
+ nsvg__addPoint(p, x, y);
+ }
+}
+
+static void nsvg__cubicBezTo(NSVGparser* p, float cpx1, float cpy1, float cpx2, float cpy2, float x, float y)
+{
+ if (p->npts > 0) {
+ nsvg__addPoint(p, cpx1, cpy1);
+ nsvg__addPoint(p, cpx2, cpy2);
+ nsvg__addPoint(p, x, y);
+ }
+}
+
+static NSVGattrib* nsvg__getAttr(NSVGparser* p)
+{
+ return &p->attr[p->attrHead];
+}
+
+static void nsvg__pushAttr(NSVGparser* p)
+{
+ if (p->attrHead < NSVG_MAX_ATTR-1) {
+ p->attrHead++;
+ memcpy(&p->attr[p->attrHead], &p->attr[p->attrHead-1], sizeof(NSVGattrib));
+ }
+}
+
+static void nsvg__popAttr(NSVGparser* p)
+{
+ if (p->attrHead > 0)
+ p->attrHead--;
+}
+
+static float nsvg__actualOrigX(NSVGparser* p)
+{
+ return p->viewMinx;
+}
+
+static float nsvg__actualOrigY(NSVGparser* p)
+{
+ return p->viewMiny;
+}
+
+static float nsvg__actualWidth(NSVGparser* p)
+{
+ return p->viewWidth;
+}
+
+static float nsvg__actualHeight(NSVGparser* p)
+{
+ return p->viewHeight;
+}
+
+static float nsvg__actualLength(NSVGparser* p)
+{
+ float w = nsvg__actualWidth(p), h = nsvg__actualHeight(p);
+ return sqrtf(w*w + h*h) / sqrtf(2.0f);
+}
+
+static float nsvg__convertToPixels(NSVGparser* p, NSVGcoordinate c, float orig, float length)
+{
+ NSVGattrib* attr = nsvg__getAttr(p);
+ switch (c.units) {
+ case NSVG_UNITS_USER: return c.value;
+ case NSVG_UNITS_PX: return c.value;
+ case NSVG_UNITS_PT: return c.value / 72.0f * p->dpi;
+ case NSVG_UNITS_PC: return c.value / 6.0f * p->dpi;
+ case NSVG_UNITS_MM: return c.value / 25.4f * p->dpi;
+ case NSVG_UNITS_CM: return c.value / 2.54f * p->dpi;
+ case NSVG_UNITS_IN: return c.value * p->dpi;
+ case NSVG_UNITS_EM: return c.value * attr->fontSize;
+ case NSVG_UNITS_EX: return c.value * attr->fontSize * 0.52f; /* x-height of Helvetica. */
+ case NSVG_UNITS_PERCENT: return orig + c.value / 100.0f * length;
+ default: return c.value;
+ }
+ return c.value;
+}
+
+static NSVGgradientData* nsvg__findGradientData(NSVGparser* p, const char* id)
+{
+ NSVGgradientData* grad = p->gradients;
+ if (id == NULL || *id == '\0')
+ return NULL;
+ while (grad != NULL) {
+ if (strcmp(grad->id, id) == 0)
+ return grad;
+ grad = grad->next;
+ }
+ return NULL;
+}
+
+static NSVGgradient* nsvg__createGradient(NSVGparser* p, const char* id, const float* localBounds, float *xform, signed char* paintType)
+{
+ NSVGgradientData* data = NULL;
+ NSVGgradientData* ref = NULL;
+ NSVGgradientStop* stops = NULL;
+ NSVGgradient* grad;
+ float ox, oy, sw, sh, sl;
+ int nstops = 0;
+ int refIter;
+
+ data = nsvg__findGradientData(p, id);
+ if (data == NULL) return NULL;
+
+ /* TODO: use ref to fill in all unset values too. */
+ ref = data;
+ refIter = 0;
+ while (ref != NULL) {
+ NSVGgradientData* nextRef = NULL;
+ if (stops == NULL && ref->stops != NULL) {
+ stops = ref->stops;
+ nstops = ref->nstops;
+ break;
+ }
+ nextRef = nsvg__findGradientData(p, ref->ref);
+ if (nextRef == ref) break; /* prevent infite loops on malformed data */
+ ref = nextRef;
+ refIter++;
+ if (refIter > 32) break; /* prevent infite loops on malformed data */
+ }
+ if (stops == NULL) return NULL;
+
+ grad = (NSVGgradient*)NANOSVG_malloc(sizeof(NSVGgradient) + sizeof(NSVGgradientStop)*(nstops-1));
+ if (grad == NULL) return NULL;
+
+ /* The shape width and height. */
+ if (data->units == NSVG_OBJECT_SPACE) {
+ ox = localBounds[0];
+ oy = localBounds[1];
+ sw = localBounds[2] - localBounds[0];
+ sh = localBounds[3] - localBounds[1];
+ } else {
+ ox = nsvg__actualOrigX(p);
+ oy = nsvg__actualOrigY(p);
+ sw = nsvg__actualWidth(p);
+ sh = nsvg__actualHeight(p);
+ }
+ sl = sqrtf(sw*sw + sh*sh) / sqrtf(2.0f);
+
+ if (data->type == NSVG_PAINT_LINEAR_GRADIENT) {
+ float x1, y1, x2, y2, dx, dy;
+ x1 = nsvg__convertToPixels(p, data->linear.x1, ox, sw);
+ y1 = nsvg__convertToPixels(p, data->linear.y1, oy, sh);
+ x2 = nsvg__convertToPixels(p, data->linear.x2, ox, sw);
+ y2 = nsvg__convertToPixels(p, data->linear.y2, oy, sh);
+ /* Calculate transform aligned to the line */
+ dx = x2 - x1;
+ dy = y2 - y1;
+ grad->xform[0] = dy; grad->xform[1] = -dx;
+ grad->xform[2] = dx; grad->xform[3] = dy;
+ grad->xform[4] = x1; grad->xform[5] = y1;
+ } else {
+ float cx, cy, fx, fy, r;
+ cx = nsvg__convertToPixels(p, data->radial.cx, ox, sw);
+ cy = nsvg__convertToPixels(p, data->radial.cy, oy, sh);
+ fx = nsvg__convertToPixels(p, data->radial.fx, ox, sw);
+ fy = nsvg__convertToPixels(p, data->radial.fy, oy, sh);
+ r = nsvg__convertToPixels(p, data->radial.r, 0, sl);
+ /* Calculate transform aligned to the circle */
+ grad->xform[0] = r; grad->xform[1] = 0;
+ grad->xform[2] = 0; grad->xform[3] = r;
+ grad->xform[4] = cx; grad->xform[5] = cy;
+ grad->fx = fx / r;
+ grad->fy = fy / r;
+ }
+
+ nsvg__xformMultiply(grad->xform, data->xform);
+ nsvg__xformMultiply(grad->xform, xform);
+
+ grad->spread = data->spread;
+ memcpy(grad->stops, stops, nstops*sizeof(NSVGgradientStop));
+ grad->nstops = nstops;
+
+ *paintType = data->type;
+
+ return grad;
+}
+
+static float nsvg__getAverageScale(float* t)
+{
+ float sx = sqrtf(t[0]*t[0] + t[2]*t[2]);
+ float sy = sqrtf(t[1]*t[1] + t[3]*t[3]);
+ return (sx + sy) * 0.5f;
+}
+
+static void nsvg__getLocalBounds(float* bounds, NSVGshape *shape, float* xform)
+{
+ NSVGpath* path;
+ float curve[4*2], curveBounds[4];
+ int i, first = 1;
+ for (path = shape->paths; path != NULL; path = path->next) {
+ nsvg__xformPoint(&curve[0], &curve[1], path->pts[0], path->pts[1], xform);
+ for (i = 0; i < path->npts-1; i += 3) {
+ nsvg__xformPoint(&curve[2], &curve[3], path->pts[(i+1)*2], path->pts[(i+1)*2+1], xform);
+ nsvg__xformPoint(&curve[4], &curve[5], path->pts[(i+2)*2], path->pts[(i+2)*2+1], xform);
+ nsvg__xformPoint(&curve[6], &curve[7], path->pts[(i+3)*2], path->pts[(i+3)*2+1], xform);
+ nsvg__curveBounds(curveBounds, curve);
+ if (first) {
+ bounds[0] = curveBounds[0];
+ bounds[1] = curveBounds[1];
+ bounds[2] = curveBounds[2];
+ bounds[3] = curveBounds[3];
+ first = 0;
+ } else {
+ bounds[0] = nsvg__minf(bounds[0], curveBounds[0]);
+ bounds[1] = nsvg__minf(bounds[1], curveBounds[1]);
+ bounds[2] = nsvg__maxf(bounds[2], curveBounds[2]);
+ bounds[3] = nsvg__maxf(bounds[3], curveBounds[3]);
+ }
+ curve[0] = curve[6];
+ curve[1] = curve[7];
+ }
+ }
+}
+
+static void nsvg__addShape(NSVGparser* p)
+{
+ NSVGattrib* attr = nsvg__getAttr(p);
+ float scale = 1.0f;
+ NSVGshape* shape;
+ NSVGpath* path;
+ int i;
+
+ if (p->plist == NULL)
+ return;
+
+ shape = (NSVGshape*)NANOSVG_malloc(sizeof(NSVGshape));
+ if (shape == NULL) goto error;
+ memset(shape, 0, sizeof(NSVGshape));
+
+ memcpy(shape->id, attr->id, sizeof shape->id);
+ memcpy(shape->fillGradient, attr->fillGradient, sizeof shape->fillGradient);
+ memcpy(shape->strokeGradient, attr->strokeGradient, sizeof shape->strokeGradient);
+ memcpy(shape->xform, attr->xform, sizeof shape->xform);
+ scale = nsvg__getAverageScale(attr->xform);
+ shape->strokeWidth = attr->strokeWidth * scale;
+ shape->strokeDashOffset = attr->strokeDashOffset * scale;
+ shape->strokeDashCount = (char)attr->strokeDashCount;
+ for (i = 0; i < attr->strokeDashCount; i++)
+ shape->strokeDashArray[i] = attr->strokeDashArray[i] * scale;
+ shape->strokeLineJoin = attr->strokeLineJoin;
+ shape->strokeLineCap = attr->strokeLineCap;
+ shape->miterLimit = attr->miterLimit;
+ shape->fillRule = attr->fillRule;
+ shape->opacity = attr->opacity;
+
+ shape->paths = p->plist;
+ p->plist = NULL;
+
+ /* Calculate shape bounds */
+ shape->bounds[0] = shape->paths->bounds[0];
+ shape->bounds[1] = shape->paths->bounds[1];
+ shape->bounds[2] = shape->paths->bounds[2];
+ shape->bounds[3] = shape->paths->bounds[3];
+ for (path = shape->paths->next; path != NULL; path = path->next) {
+ shape->bounds[0] = nsvg__minf(shape->bounds[0], path->bounds[0]);
+ shape->bounds[1] = nsvg__minf(shape->bounds[1], path->bounds[1]);
+ shape->bounds[2] = nsvg__maxf(shape->bounds[2], path->bounds[2]);
+ shape->bounds[3] = nsvg__maxf(shape->bounds[3], path->bounds[3]);
+ }
+
+ /* Set fill */
+ if (attr->hasFill == 0) {
+ shape->fill.type = NSVG_PAINT_NONE;
+ } else if (attr->hasFill == 1) {
+ shape->fill.type = NSVG_PAINT_COLOR;
+ shape->fill.color = attr->fillColor;
+ shape->fill.color |= (unsigned int)(attr->fillOpacity*255) << 24;
+ } else if (attr->hasFill == 2) {
+ shape->fill.type = NSVG_PAINT_UNDEF;
+ }
+
+ /* Set stroke */
+ if (attr->hasStroke == 0) {
+ shape->stroke.type = NSVG_PAINT_NONE;
+ } else if (attr->hasStroke == 1) {
+ shape->stroke.type = NSVG_PAINT_COLOR;
+ shape->stroke.color = attr->strokeColor;
+ shape->stroke.color |= (unsigned int)(attr->strokeOpacity*255) << 24;
+ } else if (attr->hasStroke == 2) {
+ shape->stroke.type = NSVG_PAINT_UNDEF;
+ }
+
+ /* Set flags */
+ shape->flags = ((attr->visible & NSVG_VIS_DISPLAY) && (attr->visible & NSVG_VIS_VISIBLE) ? NSVG_FLAGS_VISIBLE : 0x00);
+
+ /* Add to tail */
+ if (p->image->shapes == NULL)
+ p->image->shapes = shape;
+ else
+ p->shapesTail->next = shape;
+ p->shapesTail = shape;
+
+ return;
+
+error:
+ if (shape) NANOSVG_free(shape);
+}
+
+static void nsvg__addPath(NSVGparser* p, char closed)
+{
+ NSVGattrib* attr = nsvg__getAttr(p);
+ NSVGpath* path = NULL;
+ float bounds[4];
+ float* curve;
+ int i;
+
+ if (p->npts < 4)
+ return;
+
+ if (closed)
+ nsvg__lineTo(p, p->pts[0], p->pts[1]);
+
+ /* Expect 1 + N*3 points (N = number of cubic bezier segments). */
+ if ((p->npts % 3) != 1)
+ return;
+
+ path = (NSVGpath*)NANOSVG_malloc(sizeof(NSVGpath));
+ if (path == NULL) goto error;
+ memset(path, 0, sizeof(NSVGpath));
+
+ path->pts = (float*)NANOSVG_malloc(p->npts*2*sizeof(float));
+ if (path->pts == NULL) goto error;
+ path->closed = closed;
+ path->npts = p->npts;
+
+ /* Transform path. */
+ for (i = 0; i < p->npts; ++i)
+ nsvg__xformPoint(&path->pts[i*2], &path->pts[i*2+1], p->pts[i*2], p->pts[i*2+1], attr->xform);
+
+ /* Find bounds */
+ for (i = 0; i < path->npts-1; i += 3) {
+ curve = &path->pts[i*2];
+ nsvg__curveBounds(bounds, curve);
+ if (i == 0) {
+ path->bounds[0] = bounds[0];
+ path->bounds[1] = bounds[1];
+ path->bounds[2] = bounds[2];
+ path->bounds[3] = bounds[3];
+ } else {
+ path->bounds[0] = nsvg__minf(path->bounds[0], bounds[0]);
+ path->bounds[1] = nsvg__minf(path->bounds[1], bounds[1]);
+ path->bounds[2] = nsvg__maxf(path->bounds[2], bounds[2]);
+ path->bounds[3] = nsvg__maxf(path->bounds[3], bounds[3]);
+ }
+ }
+
+ path->next = p->plist;
+ p->plist = path;
+
+ return;
+
+error:
+ if (path != NULL) {
+ if (path->pts != NULL) NANOSVG_free(path->pts);
+ NANOSVG_free(path);
+ }
+}
+
+/* We roll our own string to float because the std library one uses locale and messes things up. */
+static double nsvg__atof(const char* s)
+{
+ char* cur = (char*)s;
+ char* end = NULL;
+ double res = 0.0, sign = 1.0;
+#if defined(_MSC_VER) && (_MSC_VER == 1200)
+ __int64 intPart = 0, fracPart = 0;
+#else
+ long long intPart = 0, fracPart = 0;
+#endif
+ char hasIntPart = 0, hasFracPart = 0;
+
+ /* Parse optional sign */
+ if (*cur == '+') {
+ cur++;
+ } else if (*cur == '-') {
+ sign = -1;
+ cur++;
+ }
+
+ /* Parse integer part */
+ if (nsvg__isdigit(*cur)) {
+ /* Parse digit sequence */
+#if defined(_MSC_VER) && (_MSC_VER == 1200)
+ intPart = strtol(cur, &end, 10);
+#else
+ intPart = strtoll(cur, &end, 10);
+#endif
+ if (cur != end) {
+ res = (double)intPart;
+ hasIntPart = 1;
+ cur = end;
+ }
+ }
+
+ /* Parse fractional part. */
+ if (*cur == '.') {
+ cur++; /* Skip '.' */
+ if (nsvg__isdigit(*cur)) {
+ /* Parse digit sequence */
+#if defined(_MSC_VER) && (_MSC_VER == 1200)
+ fracPart = strtol(cur, &end, 10);
+#else
+ fracPart = strtoll(cur, &end, 10);
+#endif
+ if (cur != end) {
+ res += (double)fracPart / pow(10.0, (double)(end - cur));
+ hasFracPart = 1;
+ cur = end;
+ }
+ }
+ }
+
+ /* A valid number should have integer or fractional part. */
+ if (!hasIntPart && !hasFracPart)
+ return 0.0;
+
+ /* Parse optional exponent */
+ if (*cur == 'e' || *cur == 'E') {
+ int expPart = 0;
+ cur++; /* skip 'E' */
+ expPart = strtol(cur, &end, 10); /* Parse digit sequence with sign */
+ if (cur != end) {
+ res *= pow(10.0, (double)expPart);
+ }
+ }
+
+ return res * sign;
+}
+
+
+static const char* nsvg__parseNumber(const char* s, char* it, const int size)
+{
+ const int last = size-1;
+ int i = 0;
+
+ /* sign */
+ if (*s == '-' || *s == '+') {
+ if (i < last) it[i++] = *s;
+ s++;
+ }
+ /* integer part */
+ while (*s && nsvg__isdigit(*s)) {
+ if (i < last) it[i++] = *s;
+ s++;
+ }
+ if (*s == '.') {
+ /* decimal point */
+ if (i < last) it[i++] = *s;
+ s++;
+ /* fraction part */
+ while (*s && nsvg__isdigit(*s)) {
+ if (i < last) it[i++] = *s;
+ s++;
+ }
+ }
+ /* exponent */
+ if (*s == 'e' || *s == 'E') {
+ if (i < last) it[i++] = *s;
+ s++;
+ if (*s == '-' || *s == '+') {
+ if (i < last) it[i++] = *s;
+ s++;
+ }
+ while (*s && nsvg__isdigit(*s)) {
+ if (i < last) it[i++] = *s;
+ s++;
+ }
+ }
+ it[i] = '\0';
+
+ return s;
+}
+
+static const char* nsvg__getNextPathItemWhenArcFlag(const char* s, char* it)
+{
+ it[0] = '\0';
+ while (*s && (nsvg__isspace(*s) || *s == ',')) s++;
+ if (!*s) return s;
+ if (*s == '0' || *s == '1') {
+ it[0] = *s++;
+ it[1] = '\0';
+ return s;
+ }
+ return s;
+}
+
+static const char* nsvg__getNextPathItem(const char* s, char* it)
+{
+ it[0] = '\0';
+ /* Skip white spaces and commas */
+ while (*s && (nsvg__isspace(*s) || *s == ',')) s++;
+ if (!*s) return s;
+ if (*s == '-' || *s == '+' || *s == '.' || nsvg__isdigit(*s)) {
+ s = nsvg__parseNumber(s, it, 64);
+ } else {
+ /* Parse command */
+ it[0] = *s++;
+ it[1] = '\0';
+ return s;
+ }
+
+ return s;
+}
+
+static unsigned int nsvg__parseColorHex(const char* str)
+{
+ unsigned int r=0, g=0, b=0;
+ if (sscanf(str, "#%2x%2x%2x", &r, &g, &b) == 3 ) /* 2 digit hex */
+ return NSVG_RGB(r, g, b);
+ if (sscanf(str, "#%1x%1x%1x", &r, &g, &b) == 3 ) /* 1 digit hex, e.g. #abc -> 0xccbbaa */
+ return NSVG_RGB(r*17, g*17, b*17); /* same effect as (r<<4|r), (g<<4|g), .. */
+ return NSVG_RGB(128, 128, 128);
+}
+
+/*
+ * Parse rgb color. The pointer 'str' must point at "rgb(" (4+ characters).
+ * This function returns gray (rgb(128, 128, 128) == '#808080') on parse errors
+ * for backwards compatibility. Note: other image viewers return black instead.
+ */
+
+static unsigned int nsvg__parseColorRGB(const char* str)
+{
+ int i;
+ unsigned int rgbi[3];
+ float rgbf[3];
+ /* try decimal integers first */
+ if (sscanf(str, "rgb(%u, %u, %u)", &rgbi[0], &rgbi[1], &rgbi[2]) != 3) {
+ /* integers failed, try percent values (float, locale independent) */
+ const char delimiter[3] = {',', ',', ')'};
+ str += 4; /* skip "rgb(" */
+ for (i = 0; i < 3; i++) {
+ while (*str && (nsvg__isspace(*str))) str++; /* skip leading spaces */
+ if (*str == '+') str++; /* skip '+' (don't allow '-') */
+ if (!*str) break;
+ rgbf[i] = nsvg__atof(str);
+
+ /*
+ * Note 1: it would be great if nsvg__atof() returned how many
+ * bytes it consumed but it doesn't. We need to skip the number,
+ * the '%' character, spaces, and the delimiter ',' or ')'.
+ *
+ * Note 2: The following code does not allow values like "33.%",
+ * i.e. a decimal point w/o fractional part, but this is consistent
+ * with other image viewers, e.g. firefox, chrome, eog, gimp.
+ */
+
+ while (*str && nsvg__isdigit(*str)) str++; /* skip integer part */
+ if (*str == '.') {
+ str++;
+ if (!nsvg__isdigit(*str)) break; /* error: no digit after '.' */
+ while (*str && nsvg__isdigit(*str)) str++; /* skip fractional part */
+ }
+ if (*str == '%') str++; else break;
+ while (nsvg__isspace(*str)) str++;
+ if (*str == delimiter[i]) str++;
+ else break;
+ }
+ if (i == 3) {
+ rgbi[0] = roundf(rgbf[0] * 2.55f);
+ rgbi[1] = roundf(rgbf[1] * 2.55f);
+ rgbi[2] = roundf(rgbf[2] * 2.55f);
+ } else {
+ rgbi[0] = rgbi[1] = rgbi[2] = 128;
+ }
+ }
+ /* clip values as the CSS spec requires */
+ for (i = 0; i < 3; i++) {
+ if (rgbi[i] > 255) rgbi[i] = 255;
+ }
+ return NSVG_RGB(rgbi[0], rgbi[1], rgbi[2]);
+}
+
+typedef struct NSVGNamedColor {
+ const char* name;
+ unsigned int color;
+} NSVGNamedColor;
+
+NSVGNamedColor nsvg__colors[] = {
+
+ { "red", NSVG_RGB(255, 0, 0) },
+ { "green", NSVG_RGB( 0, 128, 0) },
+ { "blue", NSVG_RGB( 0, 0, 255) },
+ { "yellow", NSVG_RGB(255, 255, 0) },
+ { "cyan", NSVG_RGB( 0, 255, 255) },
+ { "magenta", NSVG_RGB(255, 0, 255) },
+ { "black", NSVG_RGB( 0, 0, 0) },
+ { "grey", NSVG_RGB(128, 128, 128) },
+ { "gray", NSVG_RGB(128, 128, 128) },
+ { "white", NSVG_RGB(255, 255, 255) },
+
+#ifdef NANOSVG_ALL_COLOR_KEYWORDS
+ { "aliceblue", NSVG_RGB(240, 248, 255) },
+ { "antiquewhite", NSVG_RGB(250, 235, 215) },
+ { "aqua", NSVG_RGB( 0, 255, 255) },
+ { "aquamarine", NSVG_RGB(127, 255, 212) },
+ { "azure", NSVG_RGB(240, 255, 255) },
+ { "beige", NSVG_RGB(245, 245, 220) },
+ { "bisque", NSVG_RGB(255, 228, 196) },
+ { "blanchedalmond", NSVG_RGB(255, 235, 205) },
+ { "blueviolet", NSVG_RGB(138, 43, 226) },
+ { "brown", NSVG_RGB(165, 42, 42) },
+ { "burlywood", NSVG_RGB(222, 184, 135) },
+ { "cadetblue", NSVG_RGB( 95, 158, 160) },
+ { "chartreuse", NSVG_RGB(127, 255, 0) },
+ { "chocolate", NSVG_RGB(210, 105, 30) },
+ { "coral", NSVG_RGB(255, 127, 80) },
+ { "cornflowerblue", NSVG_RGB(100, 149, 237) },
+ { "cornsilk", NSVG_RGB(255, 248, 220) },
+ { "crimson", NSVG_RGB(220, 20, 60) },
+ { "darkblue", NSVG_RGB( 0, 0, 139) },
+ { "darkcyan", NSVG_RGB( 0, 139, 139) },
+ { "darkgoldenrod", NSVG_RGB(184, 134, 11) },
+ { "darkgray", NSVG_RGB(169, 169, 169) },
+ { "darkgreen", NSVG_RGB( 0, 100, 0) },
+ { "darkgrey", NSVG_RGB(169, 169, 169) },
+ { "darkkhaki", NSVG_RGB(189, 183, 107) },
+ { "darkmagenta", NSVG_RGB(139, 0, 139) },
+ { "darkolivegreen", NSVG_RGB( 85, 107, 47) },
+ { "darkorange", NSVG_RGB(255, 140, 0) },
+ { "darkorchid", NSVG_RGB(153, 50, 204) },
+ { "darkred", NSVG_RGB(139, 0, 0) },
+ { "darksalmon", NSVG_RGB(233, 150, 122) },
+ { "darkseagreen", NSVG_RGB(143, 188, 143) },
+ { "darkslateblue", NSVG_RGB( 72, 61, 139) },
+ { "darkslategray", NSVG_RGB( 47, 79, 79) },
+ { "darkslategrey", NSVG_RGB( 47, 79, 79) },
+ { "darkturquoise", NSVG_RGB( 0, 206, 209) },
+ { "darkviolet", NSVG_RGB(148, 0, 211) },
+ { "deeppink", NSVG_RGB(255, 20, 147) },
+ { "deepskyblue", NSVG_RGB( 0, 191, 255) },
+ { "dimgray", NSVG_RGB(105, 105, 105) },
+ { "dimgrey", NSVG_RGB(105, 105, 105) },
+ { "dodgerblue", NSVG_RGB( 30, 144, 255) },
+ { "firebrick", NSVG_RGB(178, 34, 34) },
+ { "floralwhite", NSVG_RGB(255, 250, 240) },
+ { "forestgreen", NSVG_RGB( 34, 139, 34) },
+ { "fuchsia", NSVG_RGB(255, 0, 255) },
+ { "gainsboro", NSVG_RGB(220, 220, 220) },
+ { "ghostwhite", NSVG_RGB(248, 248, 255) },
+ { "gold", NSVG_RGB(255, 215, 0) },
+ { "goldenrod", NSVG_RGB(218, 165, 32) },
+ { "greenyellow", NSVG_RGB(173, 255, 47) },
+ { "honeydew", NSVG_RGB(240, 255, 240) },
+ { "hotpink", NSVG_RGB(255, 105, 180) },
+ { "indianred", NSVG_RGB(205, 92, 92) },
+ { "indigo", NSVG_RGB( 75, 0, 130) },
+ { "ivory", NSVG_RGB(255, 255, 240) },
+ { "khaki", NSVG_RGB(240, 230, 140) },
+ { "lavender", NSVG_RGB(230, 230, 250) },
+ { "lavenderblush", NSVG_RGB(255, 240, 245) },
+ { "lawngreen", NSVG_RGB(124, 252, 0) },
+ { "lemonchiffon", NSVG_RGB(255, 250, 205) },
+ { "lightblue", NSVG_RGB(173, 216, 230) },
+ { "lightcoral", NSVG_RGB(240, 128, 128) },
+ { "lightcyan", NSVG_RGB(224, 255, 255) },
+ { "lightgoldenrodyellow", NSVG_RGB(250, 250, 210) },
+ { "lightgray", NSVG_RGB(211, 211, 211) },
+ { "lightgreen", NSVG_RGB(144, 238, 144) },
+ { "lightgrey", NSVG_RGB(211, 211, 211) },
+ { "lightpink", NSVG_RGB(255, 182, 193) },
+ { "lightsalmon", NSVG_RGB(255, 160, 122) },
+ { "lightseagreen", NSVG_RGB( 32, 178, 170) },
+ { "lightskyblue", NSVG_RGB(135, 206, 250) },
+ { "lightslategray", NSVG_RGB(119, 136, 153) },
+ { "lightslategrey", NSVG_RGB(119, 136, 153) },
+ { "lightsteelblue", NSVG_RGB(176, 196, 222) },
+ { "lightyellow", NSVG_RGB(255, 255, 224) },
+ { "lime", NSVG_RGB( 0, 255, 0) },
+ { "limegreen", NSVG_RGB( 50, 205, 50) },
+ { "linen", NSVG_RGB(250, 240, 230) },
+ { "maroon", NSVG_RGB(128, 0, 0) },
+ { "mediumaquamarine", NSVG_RGB(102, 205, 170) },
+ { "mediumblue", NSVG_RGB( 0, 0, 205) },
+ { "mediumorchid", NSVG_RGB(186, 85, 211) },
+ { "mediumpurple", NSVG_RGB(147, 112, 219) },
+ { "mediumseagreen", NSVG_RGB( 60, 179, 113) },
+ { "mediumslateblue", NSVG_RGB(123, 104, 238) },
+ { "mediumspringgreen", NSVG_RGB( 0, 250, 154) },
+ { "mediumturquoise", NSVG_RGB( 72, 209, 204) },
+ { "mediumvioletred", NSVG_RGB(199, 21, 133) },
+ { "midnightblue", NSVG_RGB( 25, 25, 112) },
+ { "mintcream", NSVG_RGB(245, 255, 250) },
+ { "mistyrose", NSVG_RGB(255, 228, 225) },
+ { "moccasin", NSVG_RGB(255, 228, 181) },
+ { "navajowhite", NSVG_RGB(255, 222, 173) },
+ { "navy", NSVG_RGB( 0, 0, 128) },
+ { "oldlace", NSVG_RGB(253, 245, 230) },
+ { "olive", NSVG_RGB(128, 128, 0) },
+ { "olivedrab", NSVG_RGB(107, 142, 35) },
+ { "orange", NSVG_RGB(255, 165, 0) },
+ { "orangered", NSVG_RGB(255, 69, 0) },
+ { "orchid", NSVG_RGB(218, 112, 214) },
+ { "palegoldenrod", NSVG_RGB(238, 232, 170) },
+ { "palegreen", NSVG_RGB(152, 251, 152) },
+ { "paleturquoise", NSVG_RGB(175, 238, 238) },
+ { "palevioletred", NSVG_RGB(219, 112, 147) },
+ { "papayawhip", NSVG_RGB(255, 239, 213) },
+ { "peachpuff", NSVG_RGB(255, 218, 185) },
+ { "peru", NSVG_RGB(205, 133, 63) },
+ { "pink", NSVG_RGB(255, 192, 203) },
+ { "plum", NSVG_RGB(221, 160, 221) },
+ { "powderblue", NSVG_RGB(176, 224, 230) },
+ { "purple", NSVG_RGB(128, 0, 128) },
+ { "rosybrown", NSVG_RGB(188, 143, 143) },
+ { "royalblue", NSVG_RGB( 65, 105, 225) },
+ { "saddlebrown", NSVG_RGB(139, 69, 19) },
+ { "salmon", NSVG_RGB(250, 128, 114) },
+ { "sandybrown", NSVG_RGB(244, 164, 96) },
+ { "seagreen", NSVG_RGB( 46, 139, 87) },
+ { "seashell", NSVG_RGB(255, 245, 238) },
+ { "sienna", NSVG_RGB(160, 82, 45) },
+ { "silver", NSVG_RGB(192, 192, 192) },
+ { "skyblue", NSVG_RGB(135, 206, 235) },
+ { "slateblue", NSVG_RGB(106, 90, 205) },
+ { "slategray", NSVG_RGB(112, 128, 144) },
+ { "slategrey", NSVG_RGB(112, 128, 144) },
+ { "snow", NSVG_RGB(255, 250, 250) },
+ { "springgreen", NSVG_RGB( 0, 255, 127) },
+ { "steelblue", NSVG_RGB( 70, 130, 180) },
+ { "tan", NSVG_RGB(210, 180, 140) },
+ { "teal", NSVG_RGB( 0, 128, 128) },
+ { "thistle", NSVG_RGB(216, 191, 216) },
+ { "tomato", NSVG_RGB(255, 99, 71) },
+ { "turquoise", NSVG_RGB( 64, 224, 208) },
+ { "violet", NSVG_RGB(238, 130, 238) },
+ { "wheat", NSVG_RGB(245, 222, 179) },
+ { "whitesmoke", NSVG_RGB(245, 245, 245) },
+ { "yellowgreen", NSVG_RGB(154, 205, 50) },
+#endif
+};
+
+static unsigned int nsvg__parseColorName(const char* str)
+{
+ int i, ncolors = sizeof(nsvg__colors) / sizeof(NSVGNamedColor);
+
+ for (i = 0; i < ncolors; i++) {
+ if (strcmp(nsvg__colors[i].name, str) == 0) {
+ return nsvg__colors[i].color;
+ }
+ }
+
+ return NSVG_RGB(128, 128, 128);
+}
+
+static unsigned int nsvg__parseColor(const char* str)
+{
+ size_t len = 0;
+ while(*str == ' ') ++str;
+ len = strlen(str);
+ if (len >= 1 && *str == '#')
+ return nsvg__parseColorHex(str);
+ else if (len >= 4 && str[0] == 'r' && str[1] == 'g' && str[2] == 'b' && str[3] == '(')
+ return nsvg__parseColorRGB(str);
+ return nsvg__parseColorName(str);
+}
+
+static float nsvg__parseOpacity(const char* str)
+{
+ float val = 0;
+ sscanf(str, "%f", &val);
+ if (val < 0.0f) val = 0.0f;
+ if (val > 1.0f) val = 1.0f;
+ return val;
+}
+
+static float nsvg__parseMiterLimit(const char* str)
+{
+ float val = 0;
+ sscanf(str, "%f", &val);
+ if (val < 0.0f) val = 0.0f;
+ return val;
+}
+
+static int nsvg__parseUnits(const char* units)
+{
+ if (units[0] == 'p' && units[1] == 'x')
+ return NSVG_UNITS_PX;
+ else if (units[0] == 'p' && units[1] == 't')
+ return NSVG_UNITS_PT;
+ else if (units[0] == 'p' && units[1] == 'c')
+ return NSVG_UNITS_PC;
+ else if (units[0] == 'm' && units[1] == 'm')
+ return NSVG_UNITS_MM;
+ else if (units[0] == 'c' && units[1] == 'm')
+ return NSVG_UNITS_CM;
+ else if (units[0] == 'i' && units[1] == 'n')
+ return NSVG_UNITS_IN;
+ else if (units[0] == '%')
+ return NSVG_UNITS_PERCENT;
+ else if (units[0] == 'e' && units[1] == 'm')
+ return NSVG_UNITS_EM;
+ else if (units[0] == 'e' && units[1] == 'x')
+ return NSVG_UNITS_EX;
+ return NSVG_UNITS_USER;
+}
+
+static int nsvg__isCoordinate(const char* s)
+{
+ /* optional sign */
+ if (*s == '-' || *s == '+')
+ s++;
+ /* must have at least one digit, or start by a dot */
+ return (nsvg__isdigit(*s) || *s == '.');
+}
+
+static NSVGcoordinate nsvg__parseCoordinateRaw(const char* str)
+{
+ NSVGcoordinate coord = {0, NSVG_UNITS_USER};
+ char units[32]="";
+ sscanf(str, "%f%s", &coord.value, units);
+ coord.units = nsvg__parseUnits(units);
+ return coord;
+}
+
+static NSVGcoordinate nsvg__coord(float v, int units)
+{
+ NSVGcoordinate coord = {v, units};
+ return coord;
+}
+
+static float nsvg__parseCoordinate(NSVGparser* p, const char* str, float orig, float length)
+{
+ NSVGcoordinate coord = nsvg__parseCoordinateRaw(str);
+ return nsvg__convertToPixels(p, coord, orig, length);
+}
+
+static int nsvg__parseTransformArgs(const char* str, float* args, int maxNa, int* na)
+{
+ const char* end;
+ const char* ptr;
+ char it[64];
+
+ *na = 0;
+ ptr = str;
+ while (*ptr && *ptr != '(') ++ptr;
+ if (*ptr == 0)
+ return 1;
+ end = ptr;
+ while (*end && *end != ')') ++end;
+ if (*end == 0)
+ return 1;
+
+ while (ptr < end) {
+ if (*ptr == '-' || *ptr == '+' || *ptr == '.' || nsvg__isdigit(*ptr)) {
+ if (*na >= maxNa) return 0;
+ ptr = nsvg__parseNumber(ptr, it, 64);
+ args[(*na)++] = (float)nsvg__atof(it);
+ } else {
+ ++ptr;
+ }
+ }
+ return (int)(end - str);
+}
+
+
+static int nsvg__parseMatrix(float* xform, const char* str)
+{
+ float t[6];
+ int na = 0;
+ int len = nsvg__parseTransformArgs(str, t, 6, &na);
+ if (na != 6) return len;
+ memcpy(xform, t, sizeof(float)*6);
+ return len;
+}
+
+static int nsvg__parseTranslate(float* xform, const char* str)
+{
+ float args[2];
+ float t[6];
+ int na = 0;
+ int len = nsvg__parseTransformArgs(str, args, 2, &na);
+ if (na == 1) args[1] = 0.0;
+
+ nsvg__xformSetTranslation(t, args[0], args[1]);
+ memcpy(xform, t, sizeof(float)*6);
+ return len;
+}
+
+static int nsvg__parseScale(float* xform, const char* str)
+{
+ float args[2];
+ int na = 0;
+ float t[6];
+ int len = nsvg__parseTransformArgs(str, args, 2, &na);
+ if (na == 1) args[1] = args[0];
+ nsvg__xformSetScale(t, args[0], args[1]);
+ memcpy(xform, t, sizeof(float)*6);
+ return len;
+}
+
+static int nsvg__parseSkewX(float* xform, const char* str)
+{
+ float args[1];
+ int na = 0;
+ float t[6];
+ int len = nsvg__parseTransformArgs(str, args, 1, &na);
+ nsvg__xformSetSkewX(t, args[0]/180.0f*NSVG_PI);
+ memcpy(xform, t, sizeof(float)*6);
+ return len;
+}
+
+static int nsvg__parseSkewY(float* xform, const char* str)
+{
+ float args[1];
+ int na = 0;
+ float t[6];
+ int len = nsvg__parseTransformArgs(str, args, 1, &na);
+ nsvg__xformSetSkewY(t, args[0]/180.0f*NSVG_PI);
+ memcpy(xform, t, sizeof(float)*6);
+ return len;
+}
+
+static int nsvg__parseRotate(float* xform, const char* str)
+{
+ float args[3];
+ int na = 0;
+ float m[6];
+ float t[6];
+ int len = nsvg__parseTransformArgs(str, args, 3, &na);
+ if (na == 1)
+ args[1] = args[2] = 0.0f;
+ nsvg__xformIdentity(m);
+
+ if (na > 1) {
+ nsvg__xformSetTranslation(t, -args[1], -args[2]);
+ nsvg__xformMultiply(m, t);
+ }
+
+ nsvg__xformSetRotation(t, args[0]/180.0f*NSVG_PI);
+ nsvg__xformMultiply(m, t);
+
+ if (na > 1) {
+ nsvg__xformSetTranslation(t, args[1], args[2]);
+ nsvg__xformMultiply(m, t);
+ }
+
+ memcpy(xform, m, sizeof(float)*6);
+
+ return len;
+}
+
+static void nsvg__parseTransform(float* xform, const char* str)
+{
+ float t[6];
+ int len;
+ nsvg__xformIdentity(xform);
+ while (*str)
+ {
+ if (strncmp(str, "matrix", 6) == 0)
+ len = nsvg__parseMatrix(t, str);
+ else if (strncmp(str, "translate", 9) == 0)
+ len = nsvg__parseTranslate(t, str);
+ else if (strncmp(str, "scale", 5) == 0)
+ len = nsvg__parseScale(t, str);
+ else if (strncmp(str, "rotate", 6) == 0)
+ len = nsvg__parseRotate(t, str);
+ else if (strncmp(str, "skewX", 5) == 0)
+ len = nsvg__parseSkewX(t, str);
+ else if (strncmp(str, "skewY", 5) == 0)
+ len = nsvg__parseSkewY(t, str);
+ else{
+ ++str;
+ continue;
+ }
+ if (len != 0) {
+ str += len;
+ } else {
+ ++str;
+ continue;
+ }
+
+ nsvg__xformPremultiply(xform, t);
+ }
+}
+
+static void nsvg__parseUrl(char* id, const char* str)
+{
+ int i = 0;
+ str += 4; /* "url("; */
+ if (*str && *str == '#')
+ str++;
+ while (i < 63 && *str && *str != ')') {
+ id[i] = *str++;
+ i++;
+ }
+ id[i] = '\0';
+}
+
+static char nsvg__parseLineCap(const char* str)
+{
+ if (strcmp(str, "butt") == 0)
+ return NSVG_CAP_BUTT;
+ else if (strcmp(str, "round") == 0)
+ return NSVG_CAP_ROUND;
+ else if (strcmp(str, "square") == 0)
+ return NSVG_CAP_SQUARE;
+ /* TODO: handle inherit. */
+ return NSVG_CAP_BUTT;
+}
+
+static char nsvg__parseLineJoin(const char* str)
+{
+ if (strcmp(str, "miter") == 0)
+ return NSVG_JOIN_MITER;
+ else if (strcmp(str, "round") == 0)
+ return NSVG_JOIN_ROUND;
+ else if (strcmp(str, "bevel") == 0)
+ return NSVG_JOIN_BEVEL;
+ /* TODO: handle inherit. */
+ return NSVG_JOIN_MITER;
+}
+
+static char nsvg__parseFillRule(const char* str)
+{
+ if (strcmp(str, "nonzero") == 0)
+ return NSVG_FILLRULE_NONZERO;
+ else if (strcmp(str, "evenodd") == 0)
+ return NSVG_FILLRULE_EVENODD;
+ /* TODO: handle inherit. */
+ return NSVG_FILLRULE_NONZERO;
+}
+
+static const char* nsvg__getNextDashItem(const char* s, char* it)
+{
+ int n = 0;
+ it[0] = '\0';
+ /* Skip white spaces and commas */
+ while (*s && (nsvg__isspace(*s) || *s == ',')) s++;
+ /* Advance until whitespace, comma or end. */
+ while (*s && (!nsvg__isspace(*s) && *s != ',')) {
+ if (n < 63)
+ it[n++] = *s;
+ s++;
+ }
+ it[n++] = '\0';
+ return s;
+}
+
+static int nsvg__parseStrokeDashArray(NSVGparser* p, const char* str, float* strokeDashArray)
+{
+ char item[64];
+ int count = 0, i;
+ float sum = 0.0f;
+
+ /* Handle "none" */
+ if (str[0] == 'n')
+ return 0;
+
+ /* Parse dashes */
+ while (*str) {
+ str = nsvg__getNextDashItem(str, item);
+ if (!*item) break;
+ if (count < NSVG_MAX_DASHES)
+ strokeDashArray[count++] = fabsf(nsvg__parseCoordinate(p, item, 0.0f, nsvg__actualLength(p)));
+ }
+
+ for (i = 0; i < count; i++)
+ sum += strokeDashArray[i];
+ if (sum <= 1e-6f)
+ count = 0;
+
+ return count;
+}
+
+static void nsvg__parseStyle(NSVGparser* p, const char* str);
+
+static int nsvg__parseAttr(NSVGparser* p, const char* name, const char* value)
+{
+ float xform[6];
+ NSVGattrib* attr = nsvg__getAttr(p);
+ if (!attr) return 0;
+
+ if (strcmp(name, "style") == 0) {
+ nsvg__parseStyle(p, value);
+ } else if (strcmp(name, "display") == 0) {
+ if (strcmp(value, "none") == 0)
+ attr->visible &= ~NSVG_VIS_DISPLAY;
+ /* Don't reset ->visible on display:inline, one display:none hides the whole subtree */
+
+ } else if (strcmp(name, "visibility") == 0) {
+ if (strcmp(value, "hidden") == 0) {
+ attr->visible &= ~NSVG_VIS_VISIBLE;
+ } else if (strcmp(value, "visible") == 0) {
+ attr->visible |= NSVG_VIS_VISIBLE;
+ }
+ } else if (strcmp(name, "fill") == 0) {
+ if (strcmp(value, "none") == 0) {
+ attr->hasFill = 0;
+ } else if (strncmp(value, "url(", 4) == 0) {
+ attr->hasFill = 2;
+ nsvg__parseUrl(attr->fillGradient, value);
+ } else {
+ attr->hasFill = 1;
+ attr->fillColor = nsvg__parseColor(value);
+ }
+ } else if (strcmp(name, "opacity") == 0) {
+ attr->opacity = nsvg__parseOpacity(value);
+ } else if (strcmp(name, "fill-opacity") == 0) {
+ attr->fillOpacity = nsvg__parseOpacity(value);
+ } else if (strcmp(name, "stroke") == 0) {
+ if (strcmp(value, "none") == 0) {
+ attr->hasStroke = 0;
+ } else if (strncmp(value, "url(", 4) == 0) {
+ attr->hasStroke = 2;
+ nsvg__parseUrl(attr->strokeGradient, value);
+ } else {
+ attr->hasStroke = 1;
+ attr->strokeColor = nsvg__parseColor(value);
+ }
+ } else if (strcmp(name, "stroke-width") == 0) {
+ attr->strokeWidth = nsvg__parseCoordinate(p, value, 0.0f, nsvg__actualLength(p));
+ } else if (strcmp(name, "stroke-dasharray") == 0) {
+ attr->strokeDashCount = nsvg__parseStrokeDashArray(p, value, attr->strokeDashArray);
+ } else if (strcmp(name, "stroke-dashoffset") == 0) {
+ attr->strokeDashOffset = nsvg__parseCoordinate(p, value, 0.0f, nsvg__actualLength(p));
+ } else if (strcmp(name, "stroke-opacity") == 0) {
+ attr->strokeOpacity = nsvg__parseOpacity(value);
+ } else if (strcmp(name, "stroke-linecap") == 0) {
+ attr->strokeLineCap = nsvg__parseLineCap(value);
+ } else if (strcmp(name, "stroke-linejoin") == 0) {
+ attr->strokeLineJoin = nsvg__parseLineJoin(value);
+ } else if (strcmp(name, "stroke-miterlimit") == 0) {
+ attr->miterLimit = nsvg__parseMiterLimit(value);
+ } else if (strcmp(name, "fill-rule") == 0) {
+ attr->fillRule = nsvg__parseFillRule(value);
+ } else if (strcmp(name, "font-size") == 0) {
+ attr->fontSize = nsvg__parseCoordinate(p, value, 0.0f, nsvg__actualLength(p));
+ } else if (strcmp(name, "transform") == 0) {
+ nsvg__parseTransform(xform, value);
+ nsvg__xformPremultiply(attr->xform, xform);
+ } else if (strcmp(name, "stop-color") == 0) {
+ attr->stopColor = nsvg__parseColor(value);
+ } else if (strcmp(name, "stop-opacity") == 0) {
+ attr->stopOpacity = nsvg__parseOpacity(value);
+ } else if (strcmp(name, "offset") == 0) {
+ attr->stopOffset = nsvg__parseCoordinate(p, value, 0.0f, 1.0f);
+ } else if (strcmp(name, "id") == 0) {
+ strncpy(attr->id, value, 63);
+ attr->id[63] = '\0';
+ } else if (strcmp(name, "class") == 0) {
+ NSVGstyles* style = p->styles;
+ while (style) {
+ if (strcmp(style->name + 1, value) == 0) {
+ break;
+ }
+ style = style->next;
+ }
+ if (style) {
+ nsvg__parseStyle(p, style->description);
+ }
+ } else {
+ return 0;
+ }
+ return 1;
+}
+
+static int nsvg__parseNameValue(NSVGparser* p, const char* start, const char* end)
+{
+ const char* str;
+ const char* val;
+ char name[512];
+ char value[512];
+ int n;
+
+ str = start;
+ while (str < end && *str != ':') ++str;
+
+ val = str;
+
+ /* Right Trim */
+ while (str > start && (*str == ':' || nsvg__isspace(*str))) --str;
+ ++str;
+
+ n = (int)(str - start);
+ if (n > 511) n = 511;
+ if (n) memcpy(name, start, n);
+ name[n] = 0;
+
+ while (val < end && (*val == ':' || nsvg__isspace(*val))) ++val;
+
+ n = (int)(end - val);
+ if (n > 511) n = 511;
+ if (n) memcpy(value, val, n);
+ value[n] = 0;
+
+ return nsvg__parseAttr(p, name, value);
+}
+
+static void nsvg__parseStyle(NSVGparser* p, const char* str)
+{
+ const char* start;
+ const char* end;
+
+ while (*str) {
+ /* Left Trim */
+ while(*str && nsvg__isspace(*str)) ++str;
+ start = str;
+ while(*str && *str != ';') ++str;
+ end = str;
+
+ /* Right Trim */
+ while (end > start && (*end == ';' || nsvg__isspace(*end))) --end;
+ ++end;
+
+ nsvg__parseNameValue(p, start, end);
+ if (*str) ++str;
+ }
+}
+
+static void nsvg__parseAttribs(NSVGparser* p, const char** attr)
+{
+ int i;
+ for (i = 0; attr[i]; i += 2)
+ {
+ if (strcmp(attr[i], "style") == 0)
+ nsvg__parseStyle(p, attr[i + 1]);
+ else
+ nsvg__parseAttr(p, attr[i], attr[i + 1]);
+ }
+}
+
+static int nsvg__getArgsPerElement(char cmd)
+{
+ switch (cmd) {
+ case 'v':
+ case 'V':
+ case 'h':
+ case 'H':
+ return 1;
+ case 'm':
+ case 'M':
+ case 'l':
+ case 'L':
+ case 't':
+ case 'T':
+ return 2;
+ case 'q':
+ case 'Q':
+ case 's':
+ case 'S':
+ return 4;
+ case 'c':
+ case 'C':
+ return 6;
+ case 'a':
+ case 'A':
+ return 7;
+ case 'z':
+ case 'Z':
+ return 0;
+ }
+ return -1;
+}
+
+static void nsvg__pathMoveTo(NSVGparser* p, float* cpx, float* cpy, float* args, int rel)
+{
+ if (rel) {
+ *cpx += args[0];
+ *cpy += args[1];
+ } else {
+ *cpx = args[0];
+ *cpy = args[1];
+ }
+ nsvg__moveTo(p, *cpx, *cpy);
+}
+
+static void nsvg__pathLineTo(NSVGparser* p, float* cpx, float* cpy, float* args, int rel)
+{
+ if (rel) {
+ *cpx += args[0];
+ *cpy += args[1];
+ } else {
+ *cpx = args[0];
+ *cpy = args[1];
+ }
+ nsvg__lineTo(p, *cpx, *cpy);
+}
+
+static void nsvg__pathHLineTo(NSVGparser* p, float* cpx, float* cpy, float* args, int rel)
+{
+ if (rel)
+ *cpx += args[0];
+ else
+ *cpx = args[0];
+ nsvg__lineTo(p, *cpx, *cpy);
+}
+
+static void nsvg__pathVLineTo(NSVGparser* p, float* cpx, float* cpy, float* args, int rel)
+{
+ if (rel)
+ *cpy += args[0];
+ else
+ *cpy = args[0];
+ nsvg__lineTo(p, *cpx, *cpy);
+}
+
+static void nsvg__pathCubicBezTo(NSVGparser* p, float* cpx, float* cpy,
+ float* cpx2, float* cpy2, float* args, int rel)
+{
+ float x2, y2, cx1, cy1, cx2, cy2;
+
+ if (rel) {
+ cx1 = *cpx + args[0];
+ cy1 = *cpy + args[1];
+ cx2 = *cpx + args[2];
+ cy2 = *cpy + args[3];
+ x2 = *cpx + args[4];
+ y2 = *cpy + args[5];
+ } else {
+ cx1 = args[0];
+ cy1 = args[1];
+ cx2 = args[2];
+ cy2 = args[3];
+ x2 = args[4];
+ y2 = args[5];
+ }
+
+ nsvg__cubicBezTo(p, cx1,cy1, cx2,cy2, x2,y2);
+
+ *cpx2 = cx2;
+ *cpy2 = cy2;
+ *cpx = x2;
+ *cpy = y2;
+}
+
+static void nsvg__pathCubicBezShortTo(NSVGparser* p, float* cpx, float* cpy,
+ float* cpx2, float* cpy2, float* args, int rel)
+{
+ float x1, y1, x2, y2, cx1, cy1, cx2, cy2;
+
+ x1 = *cpx;
+ y1 = *cpy;
+ if (rel) {
+ cx2 = *cpx + args[0];
+ cy2 = *cpy + args[1];
+ x2 = *cpx + args[2];
+ y2 = *cpy + args[3];
+ } else {
+ cx2 = args[0];
+ cy2 = args[1];
+ x2 = args[2];
+ y2 = args[3];
+ }
+
+ cx1 = 2*x1 - *cpx2;
+ cy1 = 2*y1 - *cpy2;
+
+ nsvg__cubicBezTo(p, cx1,cy1, cx2,cy2, x2,y2);
+
+ *cpx2 = cx2;
+ *cpy2 = cy2;
+ *cpx = x2;
+ *cpy = y2;
+}
+
+static void nsvg__pathQuadBezTo(NSVGparser* p, float* cpx, float* cpy,
+ float* cpx2, float* cpy2, float* args, int rel)
+{
+ float x1, y1, x2, y2, cx, cy;
+ float cx1, cy1, cx2, cy2;
+
+ x1 = *cpx;
+ y1 = *cpy;
+ if (rel) {
+ cx = *cpx + args[0];
+ cy = *cpy + args[1];
+ x2 = *cpx + args[2];
+ y2 = *cpy + args[3];
+ } else {
+ cx = args[0];
+ cy = args[1];
+ x2 = args[2];
+ y2 = args[3];
+ }
+
+ /* Convert to cubic bezier */
+ cx1 = x1 + 2.0f/3.0f*(cx - x1);
+ cy1 = y1 + 2.0f/3.0f*(cy - y1);
+ cx2 = x2 + 2.0f/3.0f*(cx - x2);
+ cy2 = y2 + 2.0f/3.0f*(cy - y2);
+
+ nsvg__cubicBezTo(p, cx1,cy1, cx2,cy2, x2,y2);
+
+ *cpx2 = cx;
+ *cpy2 = cy;
+ *cpx = x2;
+ *cpy = y2;
+}
+
+static void nsvg__pathQuadBezShortTo(NSVGparser* p, float* cpx, float* cpy,
+ float* cpx2, float* cpy2, float* args, int rel)
+{
+ float x1, y1, x2, y2, cx, cy;
+ float cx1, cy1, cx2, cy2;
+
+ x1 = *cpx;
+ y1 = *cpy;
+ if (rel) {
+ x2 = *cpx + args[0];
+ y2 = *cpy + args[1];
+ } else {
+ x2 = args[0];
+ y2 = args[1];
+ }
+
+ cx = 2*x1 - *cpx2;
+ cy = 2*y1 - *cpy2;
+
+ /* Convert to cubix bezier */
+ cx1 = x1 + 2.0f/3.0f*(cx - x1);
+ cy1 = y1 + 2.0f/3.0f*(cy - y1);
+ cx2 = x2 + 2.0f/3.0f*(cx - x2);
+ cy2 = y2 + 2.0f/3.0f*(cy - y2);
+
+ nsvg__cubicBezTo(p, cx1,cy1, cx2,cy2, x2,y2);
+
+ *cpx2 = cx;
+ *cpy2 = cy;
+ *cpx = x2;
+ *cpy = y2;
+}
+
+static float nsvg__sqr(float x) { return x*x; }
+static float nsvg__vmag(float x, float y) { return sqrtf(x*x + y*y); }
+
+static float nsvg__vecrat(float ux, float uy, float vx, float vy)
+{
+ return (ux*vx + uy*vy) / (nsvg__vmag(ux,uy) * nsvg__vmag(vx,vy));
+}
+
+static float nsvg__vecang(float ux, float uy, float vx, float vy)
+{
+ float r = nsvg__vecrat(ux,uy, vx,vy);
+ if (r < -1.0f) r = -1.0f;
+ if (r > 1.0f) r = 1.0f;
+ return ((ux*vy < uy*vx) ? -1.0f : 1.0f) * acosf(r);
+}
+
+static void nsvg__pathArcTo(NSVGparser* p, float* cpx, float* cpy, float* args, int rel)
+{
+ /* Ported from canvg (https://code.google.com/p/canvg/) */
+ float rx, ry, rotx;
+ float x1, y1, x2, y2, cx, cy, dx, dy, d;
+ float x1p, y1p, cxp, cyp, s, sa, sb;
+ float ux, uy, vx, vy, a1, da;
+ float x, y, tanx, tany, a, px = 0, py = 0, ptanx = 0, ptany = 0, t[6];
+ float sinrx, cosrx;
+ int fa, fs;
+ int i, ndivs;
+ float hda, kappa;
+
+ rx = fabsf(args[0]); /* y radius */
+ ry = fabsf(args[1]); /* x radius */
+ rotx = args[2] / 180.0f * NSVG_PI; /* x rotation angle */
+ fa = fabsf(args[3]) > 1e-6 ? 1 : 0; /* Large arc */
+ fs = fabsf(args[4]) > 1e-6 ? 1 : 0; /* Sweep direction */
+ x1 = *cpx; /* start point */
+ y1 = *cpy;
+ if (rel) { /* end point */
+ x2 = *cpx + args[5];
+ y2 = *cpy + args[6];
+ } else {
+ x2 = args[5];
+ y2 = args[6];
+ }
+
+ dx = x1 - x2;
+ dy = y1 - y2;
+ d = sqrtf(dx*dx + dy*dy);
+ if (d < 1e-6f || rx < 1e-6f || ry < 1e-6f) {
+ /* The arc degenerates to a line */
+ nsvg__lineTo(p, x2, y2);
+ *cpx = x2;
+ *cpy = y2;
+ return;
+ }
+
+ sinrx = sinf(rotx);
+ cosrx = cosf(rotx);
+
+ /* Convert to center point parameterization. */
+ /* http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes */
+ /* 1) Compute x1', y1' */
+ x1p = cosrx * dx / 2.0f + sinrx * dy / 2.0f;
+ y1p = -sinrx * dx / 2.0f + cosrx * dy / 2.0f;
+ d = nsvg__sqr(x1p)/nsvg__sqr(rx) + nsvg__sqr(y1p)/nsvg__sqr(ry);
+ if (d > 1) {
+ d = sqrtf(d);
+ rx *= d;
+ ry *= d;
+ }
+ /* 2) Compute cx', cy' */
+ s = 0.0f;
+ sa = nsvg__sqr(rx)*nsvg__sqr(ry) - nsvg__sqr(rx)*nsvg__sqr(y1p) - nsvg__sqr(ry)*nsvg__sqr(x1p);
+ sb = nsvg__sqr(rx)*nsvg__sqr(y1p) + nsvg__sqr(ry)*nsvg__sqr(x1p);
+ if (sa < 0.0f) sa = 0.0f;
+ if (sb > 0.0f)
+ s = sqrtf(sa / sb);
+ if (fa == fs)
+ s = -s;
+ cxp = s * rx * y1p / ry;
+ cyp = s * -ry * x1p / rx;
+
+ /* 3) Compute cx,cy from cx',cy' */
+ cx = (x1 + x2)/2.0f + cosrx*cxp - sinrx*cyp;
+ cy = (y1 + y2)/2.0f + sinrx*cxp + cosrx*cyp;
+
+ /* 4) Calculate theta1, and delta theta. */
+ ux = (x1p - cxp) / rx;
+ uy = (y1p - cyp) / ry;
+ vx = (-x1p - cxp) / rx;
+ vy = (-y1p - cyp) / ry;
+ a1 = nsvg__vecang(1.0f,0.0f, ux,uy); /* Initial angle */
+ da = nsvg__vecang(ux,uy, vx,vy); /* Delta angle */
+
+/* if (vecrat(ux,uy,vx,vy) <= -1.0f) da = NSVG_PI; */
+/* if (vecrat(ux,uy,vx,vy) >= 1.0f) da = 0; */
+
+ if (fs == 0 && da > 0)
+ da -= 2 * NSVG_PI;
+ else if (fs == 1 && da < 0)
+ da += 2 * NSVG_PI;
+
+ /* Approximate the arc using cubic spline segments. */
+ t[0] = cosrx; t[1] = sinrx;
+ t[2] = -sinrx; t[3] = cosrx;
+ t[4] = cx; t[5] = cy;
+
+ /* Split arc into max 90 degree segments. */
+ /* The loop assumes an iteration per end point (including start and end), this +1. */
+ ndivs = (int)(fabsf(da) / (NSVG_PI*0.5f) + 1.0f);
+ hda = (da / (float)ndivs) / 2.0f;
+ /* Fix for ticket #179: division by 0: avoid cotangens around 0 (infinite) */
+ if ((hda < 1e-3f) && (hda > -1e-3f))
+ hda *= 0.5f;
+ else
+ hda = (1.0f - cosf(hda)) / sinf(hda);
+ kappa = fabsf(4.0f / 3.0f * hda);
+ if (da < 0.0f)
+ kappa = -kappa;
+
+ for (i = 0; i <= ndivs; i++) {
+ a = a1 + da * ((float)i/(float)ndivs);
+ dx = cosf(a);
+ dy = sinf(a);
+ nsvg__xformPoint(&x, &y, dx*rx, dy*ry, t); /* position */
+ nsvg__xformVec(&tanx, &tany, -dy*rx * kappa, dx*ry * kappa, t); /* tangent */
+ if (i > 0)
+ nsvg__cubicBezTo(p, px+ptanx,py+ptany, x-tanx, y-tany, x, y);
+ px = x;
+ py = y;
+ ptanx = tanx;
+ ptany = tany;
+ }
+
+ *cpx = x2;
+ *cpy = y2;
+}
+
+static void nsvg__parsePath(NSVGparser* p, const char** attr)
+{
+ const char* s = NULL;
+ char cmd = '\0';
+ float args[10];
+ int nargs;
+ int rargs = 0;
+ char initPoint;
+ float cpx, cpy, cpx2, cpy2;
+ const char* tmp[4];
+ char closedFlag;
+ int i;
+ char item[64];
+
+ for (i = 0; attr[i]; i += 2) {
+ if (strcmp(attr[i], "d") == 0) {
+ s = attr[i + 1];
+ } else {
+ tmp[0] = attr[i];
+ tmp[1] = attr[i + 1];
+ tmp[2] = 0;
+ tmp[3] = 0;
+ nsvg__parseAttribs(p, tmp);
+ }
+ }
+
+ if (s) {
+ nsvg__resetPath(p);
+ cpx = 0; cpy = 0;
+ cpx2 = 0; cpy2 = 0;
+ initPoint = 0;
+ closedFlag = 0;
+ nargs = 0;
+
+ while (*s) {
+ item[0] = '\0';
+ if ((cmd == 'A' || cmd == 'a') && (nargs == 3 || nargs == 4))
+ s = nsvg__getNextPathItemWhenArcFlag(s, item);
+ if (!*item)
+ s = nsvg__getNextPathItem(s, item);
+ if (!*item) break;
+ if (cmd != '\0' && nsvg__isCoordinate(item)) {
+ if (nargs < 10)
+ args[nargs++] = (float)nsvg__atof(item);
+ if (nargs >= rargs) {
+ switch (cmd) {
+ case 'm':
+ case 'M':
+ nsvg__pathMoveTo(p, &cpx, &cpy, args, cmd == 'm' ? 1 : 0);
+ /* Moveto can be followed by multiple coordinate pairs, */
+ /* which should be treated as linetos. */
+ cmd = (cmd == 'm') ? 'l' : 'L';
+ rargs = nsvg__getArgsPerElement(cmd);
+ cpx2 = cpx; cpy2 = cpy;
+ initPoint = 1;
+ break;
+ case 'l':
+ case 'L':
+ nsvg__pathLineTo(p, &cpx, &cpy, args, cmd == 'l' ? 1 : 0);
+ cpx2 = cpx; cpy2 = cpy;
+ break;
+ case 'H':
+ case 'h':
+ nsvg__pathHLineTo(p, &cpx, &cpy, args, cmd == 'h' ? 1 : 0);
+ cpx2 = cpx; cpy2 = cpy;
+ break;
+ case 'V':
+ case 'v':
+ nsvg__pathVLineTo(p, &cpx, &cpy, args, cmd == 'v' ? 1 : 0);
+ cpx2 = cpx; cpy2 = cpy;
+ break;
+ case 'C':
+ case 'c':
+ nsvg__pathCubicBezTo(p, &cpx, &cpy, &cpx2, &cpy2, args, cmd == 'c' ? 1 : 0);
+ break;
+ case 'S':
+ case 's':
+ nsvg__pathCubicBezShortTo(p, &cpx, &cpy, &cpx2, &cpy2, args, cmd == 's' ? 1 : 0);
+ break;
+ case 'Q':
+ case 'q':
+ nsvg__pathQuadBezTo(p, &cpx, &cpy, &cpx2, &cpy2, args, cmd == 'q' ? 1 : 0);
+ break;
+ case 'T':
+ case 't':
+ nsvg__pathQuadBezShortTo(p, &cpx, &cpy, &cpx2, &cpy2, args, cmd == 't' ? 1 : 0);
+ break;
+ case 'A':
+ case 'a':
+ nsvg__pathArcTo(p, &cpx, &cpy, args, cmd == 'a' ? 1 : 0);
+ cpx2 = cpx; cpy2 = cpy;
+ break;
+ default:
+ if (nargs >= 2) {
+ cpx = args[nargs-2];
+ cpy = args[nargs-1];
+ cpx2 = cpx; cpy2 = cpy;
+ }
+ break;
+ }
+ nargs = 0;
+ }
+ } else {
+ cmd = item[0];
+ if (cmd == 'M' || cmd == 'm') {
+ /* Commit path. */
+ if (p->npts > 0)
+ nsvg__addPath(p, closedFlag);
+ /* Start new subpath. */
+ nsvg__resetPath(p);
+ closedFlag = 0;
+ nargs = 0;
+ } else if (initPoint == 0) {
+ /* Do not allow other commands until initial point has been set (moveTo called once). */
+ cmd = '\0';
+ }
+ if (cmd == 'Z' || cmd == 'z') {
+ closedFlag = 1;
+ /* Commit path. */
+ if (p->npts > 0) {
+ /* Move current point to first point */
+ cpx = p->pts[0];
+ cpy = p->pts[1];
+ cpx2 = cpx; cpy2 = cpy;
+ nsvg__addPath(p, closedFlag);
+ }
+ /* Start new subpath. */
+ nsvg__resetPath(p);
+ nsvg__moveTo(p, cpx, cpy);
+ closedFlag = 0;
+ nargs = 0;
+ }
+ rargs = nsvg__getArgsPerElement(cmd);
+ if (rargs == -1) {
+ /* Command not recognized */
+ cmd = '\0';
+ rargs = 0;
+ }
+ }
+ }
+ /* Commit path. */
+ if (p->npts)
+ nsvg__addPath(p, closedFlag);
+ }
+
+ nsvg__addShape(p);
+}
+
+static void nsvg__parseRect(NSVGparser* p, const char** attr)
+{
+ float x = 0.0f;
+ float y = 0.0f;
+ float w = 0.0f;
+ float h = 0.0f;
+ float rx = -1.0f; /* marks not set */
+ float ry = -1.0f;
+ int i;
+
+ for (i = 0; attr[i]; i += 2) {
+ if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) {
+ if (strcmp(attr[i], "x") == 0) x = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigX(p), nsvg__actualWidth(p));
+ if (strcmp(attr[i], "y") == 0) y = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigY(p), nsvg__actualHeight(p));
+ if (strcmp(attr[i], "width") == 0) w = nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualWidth(p));
+ if (strcmp(attr[i], "height") == 0) h = nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualHeight(p));
+ if (strcmp(attr[i], "rx") == 0) rx = fabsf(nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualWidth(p)));
+ if (strcmp(attr[i], "ry") == 0) ry = fabsf(nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualHeight(p)));
+ }
+ }
+
+ if (rx < 0.0f && ry > 0.0f) rx = ry;
+ if (ry < 0.0f && rx > 0.0f) ry = rx;
+ if (rx < 0.0f) rx = 0.0f;
+ if (ry < 0.0f) ry = 0.0f;
+ if (rx > w/2.0f) rx = w/2.0f;
+ if (ry > h/2.0f) ry = h/2.0f;
+
+ if (w != 0.0f && h != 0.0f) {
+ nsvg__resetPath(p);
+
+ if (rx < 0.00001f || ry < 0.0001f) {
+ nsvg__moveTo(p, x, y);
+ nsvg__lineTo(p, x+w, y);
+ nsvg__lineTo(p, x+w, y+h);
+ nsvg__lineTo(p, x, y+h);
+ } else {
+ /* Rounded rectangle */
+ nsvg__moveTo(p, x+rx, y);
+ nsvg__lineTo(p, x+w-rx, y);
+ nsvg__cubicBezTo(p, x+w-rx*(1-NSVG_KAPPA90), y, x+w, y+ry*(1-NSVG_KAPPA90), x+w, y+ry);
+ nsvg__lineTo(p, x+w, y+h-ry);
+ nsvg__cubicBezTo(p, x+w, y+h-ry*(1-NSVG_KAPPA90), x+w-rx*(1-NSVG_KAPPA90), y+h, x+w-rx, y+h);
+ nsvg__lineTo(p, x+rx, y+h);
+ nsvg__cubicBezTo(p, x+rx*(1-NSVG_KAPPA90), y+h, x, y+h-ry*(1-NSVG_KAPPA90), x, y+h-ry);
+ nsvg__lineTo(p, x, y+ry);
+ nsvg__cubicBezTo(p, x, y+ry*(1-NSVG_KAPPA90), x+rx*(1-NSVG_KAPPA90), y, x+rx, y);
+ }
+
+ nsvg__addPath(p, 1);
+
+ nsvg__addShape(p);
+ }
+}
+
+static void nsvg__parseCircle(NSVGparser* p, const char** attr)
+{
+ float cx = 0.0f;
+ float cy = 0.0f;
+ float r = 0.0f;
+ int i;
+
+ for (i = 0; attr[i]; i += 2) {
+ if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) {
+ if (strcmp(attr[i], "cx") == 0) cx = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigX(p), nsvg__actualWidth(p));
+ if (strcmp(attr[i], "cy") == 0) cy = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigY(p), nsvg__actualHeight(p));
+ if (strcmp(attr[i], "r") == 0) r = fabsf(nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualLength(p)));
+ }
+ }
+
+ if (r > 0.0f) {
+ nsvg__resetPath(p);
+
+ nsvg__moveTo(p, cx+r, cy);
+ nsvg__cubicBezTo(p, cx+r, cy+r*NSVG_KAPPA90, cx+r*NSVG_KAPPA90, cy+r, cx, cy+r);
+ nsvg__cubicBezTo(p, cx-r*NSVG_KAPPA90, cy+r, cx-r, cy+r*NSVG_KAPPA90, cx-r, cy);
+ nsvg__cubicBezTo(p, cx-r, cy-r*NSVG_KAPPA90, cx-r*NSVG_KAPPA90, cy-r, cx, cy-r);
+ nsvg__cubicBezTo(p, cx+r*NSVG_KAPPA90, cy-r, cx+r, cy-r*NSVG_KAPPA90, cx+r, cy);
+
+ nsvg__addPath(p, 1);
+
+ nsvg__addShape(p);
+ }
+}
+
+static void nsvg__parseEllipse(NSVGparser* p, const char** attr)
+{
+ float cx = 0.0f;
+ float cy = 0.0f;
+ float rx = 0.0f;
+ float ry = 0.0f;
+ int i;
+
+ for (i = 0; attr[i]; i += 2) {
+ if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) {
+ if (strcmp(attr[i], "cx") == 0) cx = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigX(p), nsvg__actualWidth(p));
+ if (strcmp(attr[i], "cy") == 0) cy = nsvg__parseCoordinate(p, attr[i+1], nsvg__actualOrigY(p), nsvg__actualHeight(p));
+ if (strcmp(attr[i], "rx") == 0) rx = fabsf(nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualWidth(p)));
+ if (strcmp(attr[i], "ry") == 0) ry = fabsf(nsvg__parseCoordinate(p, attr[i+1], 0.0f, nsvg__actualHeight(p)));
+ }
+ }
+
+ if (rx > 0.0f && ry > 0.0f) {
+
+ nsvg__resetPath(p);
+
+ nsvg__moveTo(p, cx+rx, cy);
+ nsvg__cubicBezTo(p, cx+rx, cy+ry*NSVG_KAPPA90, cx+rx*NSVG_KAPPA90, cy+ry, cx, cy+ry);
+ nsvg__cubicBezTo(p, cx-rx*NSVG_KAPPA90, cy+ry, cx-rx, cy+ry*NSVG_KAPPA90, cx-rx, cy);
+ nsvg__cubicBezTo(p, cx-rx, cy-ry*NSVG_KAPPA90, cx-rx*NSVG_KAPPA90, cy-ry, cx, cy-ry);
+ nsvg__cubicBezTo(p, cx+rx*NSVG_KAPPA90, cy-ry, cx+rx, cy-ry*NSVG_KAPPA90, cx+rx, cy);
+
+ nsvg__addPath(p, 1);
+
+ nsvg__addShape(p);
+ }
+}
+
+static void nsvg__parseLine(NSVGparser* p, const char** attr)
+{
+ float x1 = 0.0;
+ float y1 = 0.0;
+ float x2 = 0.0;
+ float y2 = 0.0;
+ int i;
+
+ for (i = 0; attr[i]; i += 2) {
+ if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) {
+ if (strcmp(attr[i], "x1") == 0) x1 = nsvg__parseCoordinate(p, attr[i + 1], nsvg__actualOrigX(p), nsvg__actualWidth(p));
+ if (strcmp(attr[i], "y1") == 0) y1 = nsvg__parseCoordinate(p, attr[i + 1], nsvg__actualOrigY(p), nsvg__actualHeight(p));
+ if (strcmp(attr[i], "x2") == 0) x2 = nsvg__parseCoordinate(p, attr[i + 1], nsvg__actualOrigX(p), nsvg__actualWidth(p));
+ if (strcmp(attr[i], "y2") == 0) y2 = nsvg__parseCoordinate(p, attr[i + 1], nsvg__actualOrigY(p), nsvg__actualHeight(p));
+ }
+ }
+
+ nsvg__resetPath(p);
+
+ nsvg__moveTo(p, x1, y1);
+ nsvg__lineTo(p, x2, y2);
+
+ nsvg__addPath(p, 0);
+
+ nsvg__addShape(p);
+}
+
+static void nsvg__parsePoly(NSVGparser* p, const char** attr, int closeFlag)
+{
+ int i;
+ const char* s;
+ float args[2];
+ int nargs, npts = 0;
+ char item[64];
+
+ nsvg__resetPath(p);
+
+ for (i = 0; attr[i]; i += 2) {
+ if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) {
+ if (strcmp(attr[i], "points") == 0) {
+ s = attr[i + 1];
+ nargs = 0;
+ while (*s) {
+ s = nsvg__getNextPathItem(s, item);
+ args[nargs++] = (float)nsvg__atof(item);
+ if (nargs >= 2) {
+ if (npts == 0)
+ nsvg__moveTo(p, args[0], args[1]);
+ else
+ nsvg__lineTo(p, args[0], args[1]);
+ nargs = 0;
+ npts++;
+ }
+ }
+ }
+ }
+ }
+
+ nsvg__addPath(p, (char)closeFlag);
+
+ nsvg__addShape(p);
+}
+
+static void nsvg__parseSVG(NSVGparser* p, const char** attr)
+{
+ int i;
+ for (i = 0; attr[i]; i += 2) {
+ if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) {
+ if (strcmp(attr[i], "width") == 0) {
+ p->image->width = nsvg__parseCoordinate(p, attr[i + 1], 0.0f, 0.0f);
+ } else if (strcmp(attr[i], "height") == 0) {
+ p->image->height = nsvg__parseCoordinate(p, attr[i + 1], 0.0f, 0.0f);
+ } else if (strcmp(attr[i], "viewBox") == 0) {
+ sscanf(attr[i + 1], "%f%*[%%, \t]%f%*[%%, \t]%f%*[%%, \t]%f", &p->viewMinx, &p->viewMiny, &p->viewWidth, &p->viewHeight);
+ } else if (strcmp(attr[i], "preserveAspectRatio") == 0) {
+ if (strstr(attr[i + 1], "none") != 0) {
+ /* No uniform scaling */
+ p->alignType = NSVG_ALIGN_NONE;
+ } else {
+ /* Parse X align */
+ if (strstr(attr[i + 1], "xMin") != 0)
+ p->alignX = NSVG_ALIGN_MIN;
+ else if (strstr(attr[i + 1], "xMid") != 0)
+ p->alignX = NSVG_ALIGN_MID;
+ else if (strstr(attr[i + 1], "xMax") != 0)
+ p->alignX = NSVG_ALIGN_MAX;
+ /* Parse X align */
+ if (strstr(attr[i + 1], "yMin") != 0)
+ p->alignY = NSVG_ALIGN_MIN;
+ else if (strstr(attr[i + 1], "yMid") != 0)
+ p->alignY = NSVG_ALIGN_MID;
+ else if (strstr(attr[i + 1], "yMax") != 0)
+ p->alignY = NSVG_ALIGN_MAX;
+ /* Parse meet/slice */
+ p->alignType = NSVG_ALIGN_MEET;
+ if (strstr(attr[i + 1], "slice") != 0)
+ p->alignType = NSVG_ALIGN_SLICE;
+ }
+ }
+ }
+ }
+}
+
+static void nsvg__parseGradient(NSVGparser* p, const char** attr, signed char type)
+{
+ int i;
+ NSVGgradientData* grad = (NSVGgradientData*)NANOSVG_malloc(sizeof(NSVGgradientData));
+ if (grad == NULL) return;
+ memset(grad, 0, sizeof(NSVGgradientData));
+ grad->units = NSVG_OBJECT_SPACE;
+ grad->type = type;
+ if (grad->type == NSVG_PAINT_LINEAR_GRADIENT) {
+ grad->linear.x1 = nsvg__coord(0.0f, NSVG_UNITS_PERCENT);
+ grad->linear.y1 = nsvg__coord(0.0f, NSVG_UNITS_PERCENT);
+ grad->linear.x2 = nsvg__coord(100.0f, NSVG_UNITS_PERCENT);
+ grad->linear.y2 = nsvg__coord(0.0f, NSVG_UNITS_PERCENT);
+ } else if (grad->type == NSVG_PAINT_RADIAL_GRADIENT) {
+ grad->radial.cx = nsvg__coord(50.0f, NSVG_UNITS_PERCENT);
+ grad->radial.cy = nsvg__coord(50.0f, NSVG_UNITS_PERCENT);
+ grad->radial.r = nsvg__coord(50.0f, NSVG_UNITS_PERCENT);
+ }
+
+ nsvg__xformIdentity(grad->xform);
+
+ for (i = 0; attr[i]; i += 2) {
+ if (strcmp(attr[i], "id") == 0) {
+ strncpy(grad->id, attr[i+1], 63);
+ grad->id[63] = '\0';
+ } else if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) {
+ if (strcmp(attr[i], "gradientUnits") == 0) {
+ if (strcmp(attr[i+1], "objectBoundingBox") == 0)
+ grad->units = NSVG_OBJECT_SPACE;
+ else
+ grad->units = NSVG_USER_SPACE;
+ } else if (strcmp(attr[i], "gradientTransform") == 0) {
+ nsvg__parseTransform(grad->xform, attr[i + 1]);
+ } else if (strcmp(attr[i], "cx") == 0) {
+ grad->radial.cx = nsvg__parseCoordinateRaw(attr[i + 1]);
+ } else if (strcmp(attr[i], "cy") == 0) {
+ grad->radial.cy = nsvg__parseCoordinateRaw(attr[i + 1]);
+ } else if (strcmp(attr[i], "r") == 0) {
+ grad->radial.r = nsvg__parseCoordinateRaw(attr[i + 1]);
+ } else if (strcmp(attr[i], "fx") == 0) {
+ grad->radial.fx = nsvg__parseCoordinateRaw(attr[i + 1]);
+ } else if (strcmp(attr[i], "fy") == 0) {
+ grad->radial.fy = nsvg__parseCoordinateRaw(attr[i + 1]);
+ } else if (strcmp(attr[i], "x1") == 0) {
+ grad->linear.x1 = nsvg__parseCoordinateRaw(attr[i + 1]);
+ } else if (strcmp(attr[i], "y1") == 0) {
+ grad->linear.y1 = nsvg__parseCoordinateRaw(attr[i + 1]);
+ } else if (strcmp(attr[i], "x2") == 0) {
+ grad->linear.x2 = nsvg__parseCoordinateRaw(attr[i + 1]);
+ } else if (strcmp(attr[i], "y2") == 0) {
+ grad->linear.y2 = nsvg__parseCoordinateRaw(attr[i + 1]);
+ } else if (strcmp(attr[i], "spreadMethod") == 0) {
+ if (strcmp(attr[i+1], "pad") == 0)
+ grad->spread = NSVG_SPREAD_PAD;
+ else if (strcmp(attr[i+1], "reflect") == 0)
+ grad->spread = NSVG_SPREAD_REFLECT;
+ else if (strcmp(attr[i+1], "repeat") == 0)
+ grad->spread = NSVG_SPREAD_REPEAT;
+ } else if (strcmp(attr[i], "xlink:href") == 0) {
+ const char *href = attr[i+1];
+ strncpy(grad->ref, href+1, 62);
+ grad->ref[62] = '\0';
+ }
+ }
+ }
+
+ grad->next = p->gradients;
+ p->gradients = grad;
+}
+
+static void nsvg__parseGradientStop(NSVGparser* p, const char** attr)
+{
+ NSVGattrib* curAttr = nsvg__getAttr(p);
+ NSVGgradientData* grad;
+ NSVGgradientStop* stop;
+ int i, idx;
+
+ curAttr->stopOffset = 0;
+ curAttr->stopColor = 0;
+ curAttr->stopOpacity = 1.0f;
+
+ for (i = 0; attr[i]; i += 2) {
+ nsvg__parseAttr(p, attr[i], attr[i + 1]);
+ }
+
+ /* Add stop to the last gradient. */
+ grad = p->gradients;
+ if (grad == NULL) return;
+
+ grad->nstops++;
+ grad->stops = (NSVGgradientStop*)NANOSVG_realloc(grad->stops, sizeof(NSVGgradientStop)*grad->nstops);
+ if (grad->stops == NULL) return;
+
+ /* Insert */
+ idx = grad->nstops-1;
+ for (i = 0; i < grad->nstops-1; i++) {
+ if (curAttr->stopOffset < grad->stops[i].offset) {
+ idx = i;
+ break;
+ }
+ }
+ if (idx != grad->nstops-1) {
+ for (i = grad->nstops-1; i > idx; i--)
+ grad->stops[i] = grad->stops[i-1];
+ }
+
+ stop = &grad->stops[idx];
+ stop->color = curAttr->stopColor;
+ stop->color |= (unsigned int)(curAttr->stopOpacity*255) << 24;
+ stop->offset = curAttr->stopOffset;
+}
+
+static void nsvg__startElement(void* ud, const char* el, const char** attr)
+{
+ NSVGparser* p = (NSVGparser*)ud;
+
+ if (p->defsFlag) {
+ /* Skip everything but gradients in defs */
+ if (strcmp(el, "linearGradient") == 0) {
+ nsvg__parseGradient(p, attr, NSVG_PAINT_LINEAR_GRADIENT);
+ } else if (strcmp(el, "radialGradient") == 0) {
+ nsvg__parseGradient(p, attr, NSVG_PAINT_RADIAL_GRADIENT);
+ } else if (strcmp(el, "stop") == 0) {
+ nsvg__parseGradientStop(p, attr);
+ }
+ return;
+ }
+
+ if (strcmp(el, "g") == 0) {
+ nsvg__pushAttr(p);
+ nsvg__parseAttribs(p, attr);
+ } else if (strcmp(el, "path") == 0) {
+ if (p->pathFlag) /* Do not allow nested paths. */
+ return;
+ nsvg__pushAttr(p);
+ nsvg__parsePath(p, attr);
+ nsvg__popAttr(p);
+ } else if (strcmp(el, "rect") == 0) {
+ nsvg__pushAttr(p);
+ nsvg__parseRect(p, attr);
+ nsvg__popAttr(p);
+ } else if (strcmp(el, "circle") == 0) {
+ nsvg__pushAttr(p);
+ nsvg__parseCircle(p, attr);
+ nsvg__popAttr(p);
+ } else if (strcmp(el, "ellipse") == 0) {
+ nsvg__pushAttr(p);
+ nsvg__parseEllipse(p, attr);
+ nsvg__popAttr(p);
+ } else if (strcmp(el, "line") == 0) {
+ nsvg__pushAttr(p);
+ nsvg__parseLine(p, attr);
+ nsvg__popAttr(p);
+ } else if (strcmp(el, "polyline") == 0) {
+ nsvg__pushAttr(p);
+ nsvg__parsePoly(p, attr, 0);
+ nsvg__popAttr(p);
+ } else if (strcmp(el, "polygon") == 0) {
+ nsvg__pushAttr(p);
+ nsvg__parsePoly(p, attr, 1);
+ nsvg__popAttr(p);
+ } else if (strcmp(el, "linearGradient") == 0) {
+ nsvg__parseGradient(p, attr, NSVG_PAINT_LINEAR_GRADIENT);
+ } else if (strcmp(el, "radialGradient") == 0) {
+ nsvg__parseGradient(p, attr, NSVG_PAINT_RADIAL_GRADIENT);
+ } else if (strcmp(el, "stop") == 0) {
+ nsvg__parseGradientStop(p, attr);
+ } else if (strcmp(el, "defs") == 0) {
+ p->defsFlag = 1;
+ } else if (strcmp(el, "svg") == 0) {
+ nsvg__parseSVG(p, attr);
+ } else if (strcmp(el, "style") == 0) {
+ p->styleFlag = 1;
+ }
+}
+
+static void nsvg__endElement(void* ud, const char* el)
+{
+ NSVGparser* p = (NSVGparser*)ud;
+
+ if (strcmp(el, "g") == 0) {
+ nsvg__popAttr(p);
+ } else if (strcmp(el, "path") == 0) {
+ p->pathFlag = 0;
+ } else if (strcmp(el, "defs") == 0) {
+ p->defsFlag = 0;
+ } else if (strcmp(el, "style") == 0) {
+ p->styleFlag = 0;
+ }
+}
+
+static char *nsvg__strndup(const char *s, size_t n)
+{
+ char *result;
+ size_t len = strlen(s);
+
+ if (n < len)
+ len = n;
+
+ result = (char*)NANOSVG_malloc(len+1);
+ if (!result)
+ return 0;
+
+ result[len] = '\0';
+ return (char *)memcpy(result, s, len);
+}
+
+static void nsvg__content(void* ud, const char* s)
+{
+ NSVGparser* p = (NSVGparser*)ud;
+ if (p->styleFlag) {
+
+ int state = 0;
+ const char* start = NULL;
+ while (*s) {
+ char c = *s;
+ if (nsvg__isspace(c) || c == '{') {
+ if (state == 1) {
+ NSVGstyles* next = p->styles;
+
+ p->styles = (NSVGstyles*)NANOSVG_malloc(sizeof(NSVGstyles));
+ p->styles->next = next;
+ p->styles->name = nsvg__strndup(start, (size_t)(s - start));
+ start = s + 1;
+ state = 2;
+ }
+ } else if (state == 2 && c == '}') {
+ p->styles->description = nsvg__strndup(start, (size_t)(s - start));
+ state = 0;
+ }
+ else if (state == 0) {
+ start = s;
+ state = 1;
+ }
+ s++;
+ /*
+ if (*s == '{' && state == NSVG_XML_CONTENT) {
+ // Start of a tag
+ *s++ = '\0';
+ nsvg__parseContent(mark, contentCb, ud);
+ mark = s;
+ state = NSVG_XML_TAG;
+ }
+ else if (*s == '>' && state == NSVG_XML_TAG) {
+ // Start of a content or new tag.
+ *s++ = '\0';
+ nsvg__parseElement(mark, startelCb, endelCb, ud);
+ mark = s;
+ state = NSVG_XML_CONTENT;
+ }
+ else {
+ s++;
+ }
+ */
+ }
+
+ }
+}
+
+static void nsvg__imageBounds(NSVGparser* p, float* bounds)
+{
+ NSVGshape* shape;
+ shape = p->image->shapes;
+ if (shape == NULL) {
+ bounds[0] = bounds[1] = bounds[2] = bounds[3] = 0.0;
+ return;
+ }
+ bounds[0] = shape->bounds[0];
+ bounds[1] = shape->bounds[1];
+ bounds[2] = shape->bounds[2];
+ bounds[3] = shape->bounds[3];
+ for (shape = shape->next; shape != NULL; shape = shape->next) {
+ bounds[0] = nsvg__minf(bounds[0], shape->bounds[0]);
+ bounds[1] = nsvg__minf(bounds[1], shape->bounds[1]);
+ bounds[2] = nsvg__maxf(bounds[2], shape->bounds[2]);
+ bounds[3] = nsvg__maxf(bounds[3], shape->bounds[3]);
+ }
+}
+
+static float nsvg__viewAlign(float content, float container, int type)
+{
+ if (type == NSVG_ALIGN_MIN)
+ return 0;
+ else if (type == NSVG_ALIGN_MAX)
+ return container - content;
+ /* mid */
+ return (container - content) * 0.5f;
+}
+
+static void nsvg__scaleGradient(NSVGgradient* grad, float tx, float ty, float sx, float sy)
+{
+ float t[6];
+ nsvg__xformSetTranslation(t, tx, ty);
+ nsvg__xformMultiply (grad->xform, t);
+
+ nsvg__xformSetScale(t, sx, sy);
+ nsvg__xformMultiply (grad->xform, t);
+}
+
+static void nsvg__scaleToViewbox(NSVGparser* p, const char* units)
+{
+ NSVGshape* shape;
+ NSVGpath* path;
+ float tx, ty, sx, sy, us, bounds[4], t[6], avgs;
+ int i;
+ float* pt;
+
+ /* Guess image size if not set completely. */
+ nsvg__imageBounds(p, bounds);
+
+ if (p->viewWidth == 0) {
+ if (p->image->width > 0) {
+ p->viewWidth = p->image->width;
+ } else {
+ p->viewMinx = bounds[0];
+ p->viewWidth = bounds[2] - bounds[0];
+ }
+ }
+ if (p->viewHeight == 0) {
+ if (p->image->height > 0) {
+ p->viewHeight = p->image->height;
+ } else {
+ p->viewMiny = bounds[1];
+ p->viewHeight = bounds[3] - bounds[1];
+ }
+ }
+ if (p->image->width == 0)
+ p->image->width = p->viewWidth;
+ if (p->image->height == 0)
+ p->image->height = p->viewHeight;
+
+ tx = -p->viewMinx;
+ ty = -p->viewMiny;
+ sx = p->viewWidth > 0 ? p->image->width / p->viewWidth : 0;
+ sy = p->viewHeight > 0 ? p->image->height / p->viewHeight : 0;
+ /* Unit scaling */
+ us = 1.0f / nsvg__convertToPixels(p, nsvg__coord(1.0f, nsvg__parseUnits(units)), 0.0f, 1.0f);
+
+ /* Fix aspect ratio */
+ if (p->alignType == NSVG_ALIGN_MEET) {
+ /* fit whole image into viewbox */
+ sx = sy = nsvg__minf(sx, sy);
+ tx += nsvg__viewAlign(p->viewWidth*sx, p->image->width, p->alignX) / sx;
+ ty += nsvg__viewAlign(p->viewHeight*sy, p->image->height, p->alignY) / sy;
+ } else if (p->alignType == NSVG_ALIGN_SLICE) {
+ /* fill whole viewbox with image */
+ sx = sy = nsvg__maxf(sx, sy);
+ tx += nsvg__viewAlign(p->viewWidth*sx, p->image->width, p->alignX) / sx;
+ ty += nsvg__viewAlign(p->viewHeight*sy, p->image->height, p->alignY) / sy;
+ }
+
+ /* Transform */
+ sx *= us;
+ sy *= us;
+ avgs = (sx+sy) / 2.0f;
+ for (shape = p->image->shapes; shape != NULL; shape = shape->next) {
+ shape->bounds[0] = (shape->bounds[0] + tx) * sx;
+ shape->bounds[1] = (shape->bounds[1] + ty) * sy;
+ shape->bounds[2] = (shape->bounds[2] + tx) * sx;
+ shape->bounds[3] = (shape->bounds[3] + ty) * sy;
+ for (path = shape->paths; path != NULL; path = path->next) {
+ path->bounds[0] = (path->bounds[0] + tx) * sx;
+ path->bounds[1] = (path->bounds[1] + ty) * sy;
+ path->bounds[2] = (path->bounds[2] + tx) * sx;
+ path->bounds[3] = (path->bounds[3] + ty) * sy;
+ for (i =0; i < path->npts; i++) {
+ pt = &path->pts[i*2];
+ pt[0] = (pt[0] + tx) * sx;
+ pt[1] = (pt[1] + ty) * sy;
+ }
+ }
+
+ if (shape->fill.type == NSVG_PAINT_LINEAR_GRADIENT || shape->fill.type == NSVG_PAINT_RADIAL_GRADIENT) {
+ nsvg__scaleGradient(shape->fill.gradient, tx,ty, sx,sy);
+ memcpy(t, shape->fill.gradient->xform, sizeof(float)*6);
+ nsvg__xformInverse(shape->fill.gradient->xform, t);
+ }
+ if (shape->stroke.type == NSVG_PAINT_LINEAR_GRADIENT || shape->stroke.type == NSVG_PAINT_RADIAL_GRADIENT) {
+ nsvg__scaleGradient(shape->stroke.gradient, tx,ty, sx,sy);
+ memcpy(t, shape->stroke.gradient->xform, sizeof(float)*6);
+ nsvg__xformInverse(shape->stroke.gradient->xform, t);
+ }
+
+ shape->strokeWidth *= avgs;
+ shape->strokeDashOffset *= avgs;
+ for (i = 0; i < shape->strokeDashCount; i++)
+ shape->strokeDashArray[i] *= avgs;
+ }
+}
+
+static void nsvg__createGradients(NSVGparser* p)
+{
+ NSVGshape* shape;
+
+ for (shape = p->image->shapes; shape != NULL; shape = shape->next) {
+ if (shape->fill.type == NSVG_PAINT_UNDEF) {
+ if (shape->fillGradient[0] != '\0') {
+ float inv[6], localBounds[4];
+ nsvg__xformInverse(inv, shape->xform);
+ nsvg__getLocalBounds(localBounds, shape, inv);
+ shape->fill.gradient = nsvg__createGradient(p, shape->fillGradient, localBounds, shape->xform, &shape->fill.type);
+ }
+ if (shape->fill.type == NSVG_PAINT_UNDEF) {
+ shape->fill.type = NSVG_PAINT_NONE;
+ }
+ }
+ if (shape->stroke.type == NSVG_PAINT_UNDEF) {
+ if (shape->strokeGradient[0] != '\0') {
+ float inv[6], localBounds[4];
+ nsvg__xformInverse(inv, shape->xform);
+ nsvg__getLocalBounds(localBounds, shape, inv);
+ shape->stroke.gradient = nsvg__createGradient(p, shape->strokeGradient, localBounds, shape->xform, &shape->stroke.type);
+ }
+ if (shape->stroke.type == NSVG_PAINT_UNDEF) {
+ shape->stroke.type = NSVG_PAINT_NONE;
+ }
+ }
+ }
+}
+
+NANOSVG_SCOPE
+NSVGimage* nsvgParse(char* input, const char* units, float dpi)
+{
+ NSVGparser* p;
+ NSVGimage* ret = 0;
+
+ p = nsvg__createParser();
+ if (p == NULL) {
+ return NULL;
+ }
+ p->dpi = dpi;
+
+ nsvg__parseXML(input, nsvg__startElement, nsvg__endElement, nsvg__content, p);
+
+ // Create gradients after all definitions have been parsed
+ nsvg__createGradients(p);
+
+ /* Scale to viewBox */
+ nsvg__scaleToViewbox(p, units);
+
+ ret = p->image;
+ p->image = NULL;
+
+ nsvg__deleteParser(p);
+
+ return ret;
+}
+
+NANOSVG_SCOPE
+NSVGimage* nsvgParseFromFile(const char* filename, const char* units, float dpi)
+{
+ FILE* fp = NULL;
+ size_t size;
+ char* data = NULL;
+ NSVGimage* image = NULL;
+
+ fp = fopen(filename, "rb");
+ if (!fp) goto error;
+ fseek(fp, 0, SEEK_END);
+ size = ftell(fp);
+ fseek(fp, 0, SEEK_SET);
+ data = (char*)NANOSVG_malloc(size+1);
+ if (data == NULL) goto error;
+ if (fread(data, 1, size, fp) != size) goto error;
+ data[size] = '\0'; /* Must be null terminated. */
+ fclose(fp);
+ image = nsvgParse(data, units, dpi);
+ NANOSVG_free(data);
+
+ return image;
+
+error:
+ if (fp) fclose(fp);
+ if (data) NANOSVG_free(data);
+ if (image) nsvgDelete(image);
+ return NULL;
+}
+
+NANOSVG_SCOPE
+void nsvgDelete(NSVGimage* image)
+{
+ NSVGshape *snext, *shape;
+ if (image == NULL) return;
+ shape = image->shapes;
+ while (shape != NULL) {
+ snext = shape->next;
+ nsvg__deletePaths(shape->paths);
+ nsvg__deletePaint(&shape->fill);
+ nsvg__deletePaint(&shape->stroke);
+ NANOSVG_free(shape);
+ shape = snext;
+ }
+ NANOSVG_free(image);
+}
+
+#endif
+
+#endif /* NANOSVG_H */
diff --git a/generic/nanosvgrast.h b/generic/nanosvgrast.h
new file mode 100644
index 0000000..b4fac60
--- /dev/null
+++ b/generic/nanosvgrast.h
@@ -0,0 +1,1477 @@
+/*
+ * Copyright (c) 2013-14 Mikko Mononen memon@inside.org
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty. In no event will the authors be held liable for any damages
+ * arising from the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it
+ * freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ * claim that you wrote the original software. If you use this software
+ * in a product, an acknowledgment in the product documentation would be
+ * appreciated but is not required.
+ * 2. Altered source versions must be plainly marked as such, and must not be
+ * misrepresented as being the original software.
+ * 3. This notice may not be removed or altered from any source distribution.
+ *
+ * The polygon rasterization is heavily based on stb_truetype rasterizer
+ * by Sean Barrett - http://nothings.org/
+ *
+ */
+
+#ifndef NANOSVGRAST_H
+#define NANOSVGRAST_H
+
+#include "nanosvg.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef NANOSVG_SCOPE
+#define NANOSVG_SCOPE
+#endif
+
+#ifndef NANOSVG_malloc
+#define NANOSVG_malloc malloc
+#endif
+
+#ifndef NANOSVG_realloc
+#define NANOSVG_realloc realloc
+#endif
+
+#ifndef NANOSVG_free
+#define NANOSVG_free free
+#endif
+
+typedef struct NSVGrasterizer NSVGrasterizer;
+
+/* Example Usage:
+ // Load SVG
+ struct SNVGImage* image = nsvgParseFromFile("test.svg.");
+
+ // Create rasterizer (can be used to render multiple images).
+ struct NSVGrasterizer* rast = nsvgCreateRasterizer();
+ // Allocate memory for image
+ unsigned char* img = malloc(w*h*4);
+ // Rasterize
+ nsvgRasterize(rast, image, 0,0,1, img, w, h, w*4);
+*/
+
+/* Allocated rasterizer context. */
+NANOSVG_SCOPE NSVGrasterizer* nsvgCreateRasterizer(void);
+
+/* Rasterizes SVG image, returns RGBA image (non-premultiplied alpha)
+ * r - pointer to rasterizer context
+ * image - pointer to image to rasterize
+ * tx,ty - image offset (applied after scaling)
+ * scale - image scale
+ * dst - pointer to destination image data, 4 bytes per pixel (RGBA)
+ * w - width of the image to render
+ * h - height of the image to render
+ * stride - number of bytes per scaleline in the destination buffer
+ */
+NANOSVG_SCOPE void nsvgRasterize(NSVGrasterizer* r,
+ NSVGimage* image, float tx, float ty, float scale,
+ unsigned char* dst, int w, int h, int stride);
+
+/* Deletes rasterizer context. */
+NANOSVG_SCOPE void nsvgDeleteRasterizer(NSVGrasterizer*);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#ifdef NANOSVGRAST_IMPLEMENTATION
+
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define NSVG__SUBSAMPLES 5
+#define NSVG__FIXSHIFT 10
+#define NSVG__FIX (1 << NSVG__FIXSHIFT)
+#define NSVG__FIXMASK (NSVG__FIX-1)
+#define NSVG__MEMPAGE_SIZE 1024
+
+typedef struct NSVGedge {
+ float x0,y0, x1,y1;
+ int dir;
+ struct NSVGedge* next;
+} NSVGedge;
+
+typedef struct NSVGpoint {
+ float x, y;
+ float dx, dy;
+ float len;
+ float dmx, dmy;
+ unsigned char flags;
+} NSVGpoint;
+
+typedef struct NSVGactiveEdge {
+ int x,dx;
+ float ey;
+ int dir;
+ struct NSVGactiveEdge *next;
+} NSVGactiveEdge;
+
+typedef struct NSVGmemPage {
+ unsigned char mem[NSVG__MEMPAGE_SIZE];
+ int size;
+ struct NSVGmemPage* next;
+} NSVGmemPage;
+
+typedef struct NSVGcachedPaint {
+ signed char type;
+ char spread;
+ float xform[6];
+ unsigned int colors[256];
+} NSVGcachedPaint;
+
+struct NSVGrasterizer
+{
+ float px, py;
+
+ float tessTol;
+ float distTol;
+
+ NSVGedge* edges;
+ int nedges;
+ int cedges;
+
+ NSVGpoint* points;
+ int npoints;
+ int cpoints;
+
+ NSVGpoint* points2;
+ int npoints2;
+ int cpoints2;
+
+ NSVGactiveEdge* freelist;
+ NSVGmemPage* pages;
+ NSVGmemPage* curpage;
+
+ unsigned char* scanline;
+ int cscanline;
+
+ unsigned char* bitmap;
+ int width, height, stride;
+};
+
+NANOSVG_SCOPE
+NSVGrasterizer* nsvgCreateRasterizer(void)
+{
+ NSVGrasterizer* r = (NSVGrasterizer*)NANOSVG_malloc(sizeof(NSVGrasterizer));
+ if (r == NULL) goto error;
+ memset(r, 0, sizeof(NSVGrasterizer));
+
+ r->tessTol = 0.25f;
+ r->distTol = 0.01f;
+
+ return r;
+
+error:
+ nsvgDeleteRasterizer(r);
+ return NULL;
+}
+
+NANOSVG_SCOPE
+void nsvgDeleteRasterizer(NSVGrasterizer* r)
+{
+ NSVGmemPage* p;
+
+ if (r == NULL) return;
+
+ p = r->pages;
+ while (p != NULL) {
+ NSVGmemPage* next = p->next;
+ NANOSVG_free(p);
+ p = next;
+ }
+
+ if (r->edges) NANOSVG_free(r->edges);
+ if (r->points) NANOSVG_free(r->points);
+ if (r->points2) NANOSVG_free(r->points2);
+ if (r->scanline) NANOSVG_free(r->scanline);
+
+ NANOSVG_free(r);
+}
+
+static NSVGmemPage* nsvg__nextPage(NSVGrasterizer* r, NSVGmemPage* cur)
+{
+ NSVGmemPage *newp;
+
+ /* If using existing chain, return the next page in chain */
+ if (cur != NULL && cur->next != NULL) {
+ return cur->next;
+ }
+
+ /* Alloc new page */
+ newp = (NSVGmemPage*)NANOSVG_malloc(sizeof(NSVGmemPage));
+ if (newp == NULL) return NULL;
+ memset(newp, 0, sizeof(NSVGmemPage));
+
+ /* Add to linked list */
+ if (cur != NULL)
+ cur->next = newp;
+ else
+ r->pages = newp;
+
+ return newp;
+}
+
+static void nsvg__resetPool(NSVGrasterizer* r)
+{
+ NSVGmemPage* p = r->pages;
+ while (p != NULL) {
+ p->size = 0;
+ p = p->next;
+ }
+ r->curpage = r->pages;
+}
+
+static unsigned char* nsvg__alloc(NSVGrasterizer* r, int size)
+{
+ unsigned char* buf;
+ if (size > NSVG__MEMPAGE_SIZE) return NULL;
+ if (r->curpage == NULL || r->curpage->size+size > NSVG__MEMPAGE_SIZE) {
+ r->curpage = nsvg__nextPage(r, r->curpage);
+ }
+ buf = &r->curpage->mem[r->curpage->size];
+ r->curpage->size += size;
+ return buf;
+}
+
+static int nsvg__ptEquals(float x1, float y1, float x2, float y2, float tol)
+{
+ float dx = x2 - x1;
+ float dy = y2 - y1;
+ return dx*dx + dy*dy < tol*tol;
+}
+
+static void nsvg__addPathPoint(NSVGrasterizer* r, float x, float y, int flags)
+{
+ NSVGpoint* pt;
+
+ if (r->npoints > 0) {
+ pt = &r->points[r->npoints-1];
+ if (nsvg__ptEquals(pt->x,pt->y, x,y, r->distTol)) {
+ pt->flags = (unsigned char)(pt->flags | flags);
+ return;
+ }
+ }
+
+ if (r->npoints+1 > r->cpoints) {
+ r->cpoints = r->cpoints > 0 ? r->cpoints * 2 : 64;
+ r->points = (NSVGpoint*)NANOSVG_realloc(r->points, sizeof(NSVGpoint) * r->cpoints);
+ if (r->points == NULL) return;
+ }
+
+ pt = &r->points[r->npoints];
+ pt->x = x;
+ pt->y = y;
+ pt->flags = (unsigned char)flags;
+ r->npoints++;
+}
+
+static void nsvg__appendPathPoint(NSVGrasterizer* r, NSVGpoint pt)
+{
+ if (r->npoints+1 > r->cpoints) {
+ r->cpoints = r->cpoints > 0 ? r->cpoints * 2 : 64;
+ r->points = (NSVGpoint*)NANOSVG_realloc(r->points, sizeof(NSVGpoint) * r->cpoints);
+ if (r->points == NULL) return;
+ }
+ r->points[r->npoints] = pt;
+ r->npoints++;
+}
+
+static void nsvg__duplicatePoints(NSVGrasterizer* r)
+{
+ if (r->npoints > r->cpoints2) {
+ r->cpoints2 = r->npoints;
+ r->points2 = (NSVGpoint*)NANOSVG_realloc(r->points2, sizeof(NSVGpoint) * r->cpoints2);
+ if (r->points2 == NULL) return;
+ }
+
+ memcpy(r->points2, r->points, sizeof(NSVGpoint) * r->npoints);
+ r->npoints2 = r->npoints;
+}
+
+static void nsvg__addEdge(NSVGrasterizer* r, float x0, float y0, float x1, float y1)
+{
+ NSVGedge* e;
+
+ /* Skip horizontal edges */
+ if (y0 == y1)
+ return;
+
+ if (r->nedges+1 > r->cedges) {
+ r->cedges = r->cedges > 0 ? r->cedges * 2 : 64;
+ r->edges = (NSVGedge*)NANOSVG_realloc(r->edges, sizeof(NSVGedge) * r->cedges);
+ if (r->edges == NULL) return;
+ }
+
+ e = &r->edges[r->nedges];
+ r->nedges++;
+
+ if (y0 < y1) {
+ e->x0 = x0;
+ e->y0 = y0;
+ e->x1 = x1;
+ e->y1 = y1;
+ e->dir = 1;
+ } else {
+ e->x0 = x1;
+ e->y0 = y1;
+ e->x1 = x0;
+ e->y1 = y0;
+ e->dir = -1;
+ }
+}
+
+static float nsvg__normalize(float *x, float* y)
+{
+ float d = sqrtf((*x)*(*x) + (*y)*(*y));
+ if (d > 1e-6f) {
+ float id = 1.0f / d;
+ *x *= id;
+ *y *= id;
+ }
+ return d;
+}
+
+static float nsvg__absf(float x) { return x < 0 ? -x : x; }
+static float nsvg__roundf(float x) { return (x >= 0) ? floorf(x + 0.5) : ceilf(x - 0.5); }
+
+static void nsvg__flattenCubicBez(NSVGrasterizer* r,
+ float x1, float y1, float x2, float y2,
+ float x3, float y3, float x4, float y4,
+ int level, int type)
+{
+ float x12,y12,x23,y23,x34,y34,x123,y123,x234,y234,x1234,y1234;
+ float dx,dy,d2,d3;
+
+ if (level > 10) return;
+
+ x12 = (x1+x2)*0.5f;
+ y12 = (y1+y2)*0.5f;
+ x23 = (x2+x3)*0.5f;
+ y23 = (y2+y3)*0.5f;
+ x34 = (x3+x4)*0.5f;
+ y34 = (y3+y4)*0.5f;
+ x123 = (x12+x23)*0.5f;
+ y123 = (y12+y23)*0.5f;
+
+ dx = x4 - x1;
+ dy = y4 - y1;
+ d2 = nsvg__absf((x2 - x4) * dy - (y2 - y4) * dx);
+ d3 = nsvg__absf((x3 - x4) * dy - (y3 - y4) * dx);
+
+ if ((d2 + d3)*(d2 + d3) < r->tessTol * (dx*dx + dy*dy)) {
+ nsvg__addPathPoint(r, x4, y4, type);
+ return;
+ }
+
+ x234 = (x23+x34)*0.5f;
+ y234 = (y23+y34)*0.5f;
+ x1234 = (x123+x234)*0.5f;
+ y1234 = (y123+y234)*0.5f;
+
+ nsvg__flattenCubicBez(r, x1,y1, x12,y12, x123,y123, x1234,y1234, level+1, 0);
+ nsvg__flattenCubicBez(r, x1234,y1234, x234,y234, x34,y34, x4,y4, level+1, type);
+}
+
+static void nsvg__flattenShape(NSVGrasterizer* r, NSVGshape* shape, float scale)
+{
+ int i, j;
+ NSVGpath* path;
+
+ for (path = shape->paths; path != NULL; path = path->next) {
+ r->npoints = 0;
+ /* Flatten path */
+ nsvg__addPathPoint(r, path->pts[0]*scale, path->pts[1]*scale, 0);
+ for (i = 0; i < path->npts-1; i += 3) {
+ float* p = &path->pts[i*2];
+ nsvg__flattenCubicBez(r, p[0]*scale,p[1]*scale, p[2]*scale,p[3]*scale, p[4]*scale,p[5]*scale, p[6]*scale,p[7]*scale, 0, 0);
+ }
+ /* Close path */
+ nsvg__addPathPoint(r, path->pts[0]*scale, path->pts[1]*scale, 0);
+ /* Build edges */
+ for (i = 0, j = r->npoints-1; i < r->npoints; j = i++)
+ nsvg__addEdge(r, r->points[j].x, r->points[j].y, r->points[i].x, r->points[i].y);
+ }
+}
+
+enum NSVGpointFlags
+{
+ NSVG_PT_CORNER = 0x01,
+ NSVG_PT_BEVEL = 0x02,
+ NSVG_PT_LEFT = 0x04
+};
+
+static void nsvg__initClosed(NSVGpoint* left, NSVGpoint* right, NSVGpoint* p0, NSVGpoint* p1, float lineWidth)
+{
+ float w = lineWidth * 0.5f;
+ float dx = p1->x - p0->x;
+ float dy = p1->y - p0->y;
+ float len = nsvg__normalize(&dx, &dy);
+ float px = p0->x + dx*len*0.5f, py = p0->y + dy*len*0.5f;
+ float dlx = dy, dly = -dx;
+ float lx = px - dlx*w, ly = py - dly*w;
+ float rx = px + dlx*w, ry = py + dly*w;
+ left->x = lx; left->y = ly;
+ right->x = rx; right->y = ry;
+}
+
+static void nsvg__buttCap(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right, NSVGpoint* p, float dx, float dy, float lineWidth, int connect)
+{
+ float w = lineWidth * 0.5f;
+ float px = p->x, py = p->y;
+ float dlx = dy, dly = -dx;
+ float lx = px - dlx*w, ly = py - dly*w;
+ float rx = px + dlx*w, ry = py + dly*w;
+
+ nsvg__addEdge(r, lx, ly, rx, ry);
+
+ if (connect) {
+ nsvg__addEdge(r, left->x, left->y, lx, ly);
+ nsvg__addEdge(r, rx, ry, right->x, right->y);
+ }
+ left->x = lx; left->y = ly;
+ right->x = rx; right->y = ry;
+}
+
+static void nsvg__squareCap(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right, NSVGpoint* p, float dx, float dy, float lineWidth, int connect)
+{
+ float w = lineWidth * 0.5f;
+ float px = p->x - dx*w, py = p->y - dy*w;
+ float dlx = dy, dly = -dx;
+ float lx = px - dlx*w, ly = py - dly*w;
+ float rx = px + dlx*w, ry = py + dly*w;
+
+ nsvg__addEdge(r, lx, ly, rx, ry);
+
+ if (connect) {
+ nsvg__addEdge(r, left->x, left->y, lx, ly);
+ nsvg__addEdge(r, rx, ry, right->x, right->y);
+ }
+ left->x = lx; left->y = ly;
+ right->x = rx; right->y = ry;
+}
+
+#ifndef NSVG_PI
+#define NSVG_PI (3.14159265358979323846264338327f)
+#endif
+
+static void nsvg__roundCap(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right, NSVGpoint* p, float dx, float dy, float lineWidth, int ncap, int connect)
+{
+ int i;
+ float w = lineWidth * 0.5f;
+ float px = p->x, py = p->y;
+ float dlx = dy, dly = -dx;
+ float lx = 0, ly = 0, rx = 0, ry = 0, prevx = 0, prevy = 0;
+
+ for (i = 0; i < ncap; i++) {
+ float a = (float)i/(float)(ncap-1)*NSVG_PI;
+ float ax = cosf(a) * w, ay = sinf(a) * w;
+ float x = px - dlx*ax - dx*ay;
+ float y = py - dly*ax - dy*ay;
+
+ if (i > 0)
+ nsvg__addEdge(r, prevx, prevy, x, y);
+
+ prevx = x;
+ prevy = y;
+
+ if (i == 0) {
+ lx = x; ly = y;
+ } else if (i == ncap-1) {
+ rx = x; ry = y;
+ }
+ }
+
+ if (connect) {
+ nsvg__addEdge(r, left->x, left->y, lx, ly);
+ nsvg__addEdge(r, rx, ry, right->x, right->y);
+ }
+
+ left->x = lx; left->y = ly;
+ right->x = rx; right->y = ry;
+}
+
+static void nsvg__bevelJoin(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right, NSVGpoint* p0, NSVGpoint* p1, float lineWidth)
+{
+ float w = lineWidth * 0.5f;
+ float dlx0 = p0->dy, dly0 = -p0->dx;
+ float dlx1 = p1->dy, dly1 = -p1->dx;
+ float lx0 = p1->x - (dlx0 * w), ly0 = p1->y - (dly0 * w);
+ float rx0 = p1->x + (dlx0 * w), ry0 = p1->y + (dly0 * w);
+ float lx1 = p1->x - (dlx1 * w), ly1 = p1->y - (dly1 * w);
+ float rx1 = p1->x + (dlx1 * w), ry1 = p1->y + (dly1 * w);
+
+ nsvg__addEdge(r, lx0, ly0, left->x, left->y);
+ nsvg__addEdge(r, lx1, ly1, lx0, ly0);
+
+ nsvg__addEdge(r, right->x, right->y, rx0, ry0);
+ nsvg__addEdge(r, rx0, ry0, rx1, ry1);
+
+ left->x = lx1; left->y = ly1;
+ right->x = rx1; right->y = ry1;
+}
+
+static void nsvg__miterJoin(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right, NSVGpoint* p0, NSVGpoint* p1, float lineWidth)
+{
+ float w = lineWidth * 0.5f;
+ float dlx0 = p0->dy, dly0 = -p0->dx;
+ float dlx1 = p1->dy, dly1 = -p1->dx;
+ float lx0, rx0, lx1, rx1;
+ float ly0, ry0, ly1, ry1;
+
+ if (p1->flags & NSVG_PT_LEFT) {
+ lx0 = lx1 = p1->x - p1->dmx * w;
+ ly0 = ly1 = p1->y - p1->dmy * w;
+ nsvg__addEdge(r, lx1, ly1, left->x, left->y);
+
+ rx0 = p1->x + (dlx0 * w);
+ ry0 = p1->y + (dly0 * w);
+ rx1 = p1->x + (dlx1 * w);
+ ry1 = p1->y + (dly1 * w);
+ nsvg__addEdge(r, right->x, right->y, rx0, ry0);
+ nsvg__addEdge(r, rx0, ry0, rx1, ry1);
+ } else {
+ lx0 = p1->x - (dlx0 * w);
+ ly0 = p1->y - (dly0 * w);
+ lx1 = p1->x - (dlx1 * w);
+ ly1 = p1->y - (dly1 * w);
+ nsvg__addEdge(r, lx0, ly0, left->x, left->y);
+ nsvg__addEdge(r, lx1, ly1, lx0, ly0);
+
+ rx0 = rx1 = p1->x + p1->dmx * w;
+ ry0 = ry1 = p1->y + p1->dmy * w;
+ nsvg__addEdge(r, right->x, right->y, rx1, ry1);
+ }
+
+ left->x = lx1; left->y = ly1;
+ right->x = rx1; right->y = ry1;
+}
+
+static void nsvg__roundJoin(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right, NSVGpoint* p0, NSVGpoint* p1, float lineWidth, int ncap)
+{
+ int i, n;
+ float w = lineWidth * 0.5f;
+ float dlx0 = p0->dy, dly0 = -p0->dx;
+ float dlx1 = p1->dy, dly1 = -p1->dx;
+ float a0 = atan2f(dly0, dlx0);
+ float a1 = atan2f(dly1, dlx1);
+ float da = a1 - a0;
+ float lx, ly, rx, ry;
+
+ if (da < NSVG_PI) da += NSVG_PI*2;
+ if (da > NSVG_PI) da -= NSVG_PI*2;
+
+ n = (int)ceilf((nsvg__absf(da) / NSVG_PI) * (float)ncap);
+ if (n < 2) n = 2;
+ if (n > ncap) n = ncap;
+
+ lx = left->x;
+ ly = left->y;
+ rx = right->x;
+ ry = right->y;
+
+ for (i = 0; i < n; i++) {
+ float u = (float)i/(float)(n-1);
+ float a = a0 + u*da;
+ float ax = cosf(a) * w, ay = sinf(a) * w;
+ float lx1 = p1->x - ax, ly1 = p1->y - ay;
+ float rx1 = p1->x + ax, ry1 = p1->y + ay;
+
+ nsvg__addEdge(r, lx1, ly1, lx, ly);
+ nsvg__addEdge(r, rx, ry, rx1, ry1);
+
+ lx = lx1; ly = ly1;
+ rx = rx1; ry = ry1;
+ }
+
+ left->x = lx; left->y = ly;
+ right->x = rx; right->y = ry;
+}
+
+static void nsvg__straightJoin(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right, NSVGpoint* p1, float lineWidth)
+{
+ float w = lineWidth * 0.5f;
+ float lx = p1->x - (p1->dmx * w), ly = p1->y - (p1->dmy * w);
+ float rx = p1->x + (p1->dmx * w), ry = p1->y + (p1->dmy * w);
+
+ nsvg__addEdge(r, lx, ly, left->x, left->y);
+ nsvg__addEdge(r, right->x, right->y, rx, ry);
+
+ left->x = lx; left->y = ly;
+ right->x = rx; right->y = ry;
+}
+
+static int nsvg__curveDivs(float r, float arc, float tol)
+{
+ float da = acosf(r / (r + tol)) * 2.0f;
+ int divs = (int)ceilf(arc / da);
+ if (divs < 2) divs = 2;
+ return divs;
+}
+
+static void nsvg__expandStroke(NSVGrasterizer* r, NSVGpoint* points, int npoints, int closed, int lineJoin, int lineCap, float lineWidth)
+{
+ int ncap = nsvg__curveDivs(lineWidth*0.5f, NSVG_PI, r->tessTol); /* Calculate divisions per half circle. */
+ NSVGpoint left = {0,0,0,0,0,0,0,0}, right = {0,0,0,0,0,0,0,0}, firstLeft = {0,0,0,0,0,0,0,0}, firstRight = {0,0,0,0,0,0,0,0};
+ NSVGpoint* p0, *p1;
+ int j, s, e;
+
+ /* Build stroke edges */
+ if (closed) {
+ /* Looping */
+ p0 = &points[npoints-1];
+ p1 = &points[0];
+ s = 0;
+ e = npoints;
+ } else {
+ /* Add cap */
+ p0 = &points[0];
+ p1 = &points[1];
+ s = 1;
+ e = npoints-1;
+ }
+
+ if (closed) {
+ nsvg__initClosed(&left, &right, p0, p1, lineWidth);
+ firstLeft = left;
+ firstRight = right;
+ } else {
+ /* Add cap */
+ float dx = p1->x - p0->x;
+ float dy = p1->y - p0->y;
+ nsvg__normalize(&dx, &dy);
+ if (lineCap == NSVG_CAP_BUTT)
+ nsvg__buttCap(r, &left, &right, p0, dx, dy, lineWidth, 0);
+ else if (lineCap == NSVG_CAP_SQUARE)
+ nsvg__squareCap(r, &left, &right, p0, dx, dy, lineWidth, 0);
+ else if (lineCap == NSVG_CAP_ROUND)
+ nsvg__roundCap(r, &left, &right, p0, dx, dy, lineWidth, ncap, 0);
+ }
+
+ for (j = s; j < e; ++j) {
+ if (p1->flags & NSVG_PT_CORNER) {
+ if (lineJoin == NSVG_JOIN_ROUND)
+ nsvg__roundJoin(r, &left, &right, p0, p1, lineWidth, ncap);
+ else if (lineJoin == NSVG_JOIN_BEVEL || (p1->flags & NSVG_PT_BEVEL))
+ nsvg__bevelJoin(r, &left, &right, p0, p1, lineWidth);
+ else
+ nsvg__miterJoin(r, &left, &right, p0, p1, lineWidth);
+ } else {
+ nsvg__straightJoin(r, &left, &right, p1, lineWidth);
+ }
+ p0 = p1++;
+ }
+
+ if (closed) {
+ /* Loop it */
+ nsvg__addEdge(r, firstLeft.x, firstLeft.y, left.x, left.y);
+ nsvg__addEdge(r, right.x, right.y, firstRight.x, firstRight.y);
+ } else {
+ /* Add cap */
+ float dx = p1->x - p0->x;
+ float dy = p1->y - p0->y;
+ nsvg__normalize(&dx, &dy);
+ if (lineCap == NSVG_CAP_BUTT)
+ nsvg__buttCap(r, &right, &left, p1, -dx, -dy, lineWidth, 1);
+ else if (lineCap == NSVG_CAP_SQUARE)
+ nsvg__squareCap(r, &right, &left, p1, -dx, -dy, lineWidth, 1);
+ else if (lineCap == NSVG_CAP_ROUND)
+ nsvg__roundCap(r, &right, &left, p1, -dx, -dy, lineWidth, ncap, 1);
+ }
+}
+
+static void nsvg__prepareStroke(NSVGrasterizer* r, float miterLimit, int lineJoin)
+{
+ int i, j;
+ NSVGpoint* p0, *p1;
+
+ p0 = &r->points[r->npoints-1];
+ p1 = &r->points[0];
+ for (i = 0; i < r->npoints; i++) {
+ /* Calculate segment direction and length */
+ p0->dx = p1->x - p0->x;
+ p0->dy = p1->y - p0->y;
+ p0->len = nsvg__normalize(&p0->dx, &p0->dy);
+ /* Advance */
+ p0 = p1++;
+ }
+
+ /* calculate joins */
+ p0 = &r->points[r->npoints-1];
+ p1 = &r->points[0];
+ for (j = 0; j < r->npoints; j++) {
+ float dlx0, dly0, dlx1, dly1, dmr2, cross;
+ dlx0 = p0->dy;
+ dly0 = -p0->dx;
+ dlx1 = p1->dy;
+ dly1 = -p1->dx;
+ /* Calculate extrusions */
+ p1->dmx = (dlx0 + dlx1) * 0.5f;
+ p1->dmy = (dly0 + dly1) * 0.5f;
+ dmr2 = p1->dmx*p1->dmx + p1->dmy*p1->dmy;
+ if (dmr2 > 0.000001f) {
+ float s2 = 1.0f / dmr2;
+ if (s2 > 600.0f) {
+ s2 = 600.0f;
+ }
+ p1->dmx *= s2;
+ p1->dmy *= s2;
+ }
+
+ /* Clear flags, but keep the corner. */
+ p1->flags = (p1->flags & NSVG_PT_CORNER) ? NSVG_PT_CORNER : 0;
+
+ /* Keep track of left turns. */
+ cross = p1->dx * p0->dy - p0->dx * p1->dy;
+ if (cross > 0.0f)
+ p1->flags |= NSVG_PT_LEFT;
+
+ /* Check to see if the corner needs to be beveled. */
+ if (p1->flags & NSVG_PT_CORNER) {
+ if ((dmr2 * miterLimit*miterLimit) < 1.0f || lineJoin == NSVG_JOIN_BEVEL || lineJoin == NSVG_JOIN_ROUND) {
+ p1->flags |= NSVG_PT_BEVEL;
+ }
+ }
+
+ p0 = p1++;
+ }
+}
+
+static void nsvg__flattenShapeStroke(NSVGrasterizer* r, NSVGshape* shape, float scale)
+{
+ int i, j, closed;
+ NSVGpath* path;
+ NSVGpoint* p0, *p1;
+ float miterLimit = shape->miterLimit;
+ int lineJoin = shape->strokeLineJoin;
+ int lineCap = shape->strokeLineCap;
+ float lineWidth = shape->strokeWidth * scale;
+
+ for (path = shape->paths; path != NULL; path = path->next) {
+ /* Flatten path */
+ r->npoints = 0;
+ nsvg__addPathPoint(r, path->pts[0]*scale, path->pts[1]*scale, NSVG_PT_CORNER);
+ for (i = 0; i < path->npts-1; i += 3) {
+ float* p = &path->pts[i*2];
+ nsvg__flattenCubicBez(r, p[0]*scale,p[1]*scale, p[2]*scale,p[3]*scale, p[4]*scale,p[5]*scale, p[6]*scale,p[7]*scale, 0, NSVG_PT_CORNER);
+ }
+ if (r->npoints < 2)
+ continue;
+
+ closed = path->closed;
+
+ /* If the first and last points are the same, remove the last, mark as closed path. */
+ p0 = &r->points[r->npoints-1];
+ p1 = &r->points[0];
+ if (nsvg__ptEquals(p0->x,p0->y, p1->x,p1->y, r->distTol)) {
+ r->npoints--;
+ p0 = &r->points[r->npoints-1];
+ closed = 1;
+ }
+
+ if (shape->strokeDashCount > 0) {
+ int idash = 0, dashState = 1;
+ float totalDist = 0, dashLen, allDashLen, dashOffset;
+ NSVGpoint cur;
+
+ if (closed)
+ nsvg__appendPathPoint(r, r->points[0]);
+
+ /* Duplicate points -> points2. */
+ nsvg__duplicatePoints(r);
+
+ r->npoints = 0;
+ cur = r->points2[0];
+ nsvg__appendPathPoint(r, cur);
+
+ /* Figure out dash offset. */
+ allDashLen = 0;
+ for (j = 0; j < shape->strokeDashCount; j++)
+ allDashLen += shape->strokeDashArray[j];
+ if (shape->strokeDashCount & 1)
+ allDashLen *= 2.0f;
+ /* Find location inside pattern */
+ dashOffset = fmodf(shape->strokeDashOffset, allDashLen);
+ if (dashOffset < 0.0f)
+ dashOffset += allDashLen;
+
+ while (dashOffset > shape->strokeDashArray[idash]) {
+ dashOffset -= shape->strokeDashArray[idash];
+ idash = (idash + 1) % shape->strokeDashCount;
+ }
+ dashLen = (shape->strokeDashArray[idash] - dashOffset) * scale;
+
+ for (j = 1; j < r->npoints2; ) {
+ float dx = r->points2[j].x - cur.x;
+ float dy = r->points2[j].y - cur.y;
+ float dist = sqrtf(dx*dx + dy*dy);
+
+ if ((totalDist + dist) > dashLen) {
+ /* Calculate intermediate point */
+ float d = (dashLen - totalDist) / dist;
+ float x = cur.x + dx * d;
+ float y = cur.y + dy * d;
+ nsvg__addPathPoint(r, x, y, NSVG_PT_CORNER);
+
+ /* Stroke */
+ if (r->npoints > 1 && dashState) {
+ nsvg__prepareStroke(r, miterLimit, lineJoin);
+ nsvg__expandStroke(r, r->points, r->npoints, 0, lineJoin, lineCap, lineWidth);
+ }
+ /* Advance dash pattern */
+ dashState = !dashState;
+ idash = (idash+1) % shape->strokeDashCount;
+ dashLen = shape->strokeDashArray[idash] * scale;
+ /* Restart */
+ cur.x = x;
+ cur.y = y;
+ cur.flags = NSVG_PT_CORNER;
+ totalDist = 0.0f;
+ r->npoints = 0;
+ nsvg__appendPathPoint(r, cur);
+ } else {
+ totalDist += dist;
+ cur = r->points2[j];
+ nsvg__appendPathPoint(r, cur);
+ j++;
+ }
+ }
+ /* Stroke any leftover path */
+ if (r->npoints > 1 && dashState)
+ nsvg__expandStroke(r, r->points, r->npoints, 0, lineJoin, lineCap, lineWidth);
+ } else {
+ nsvg__prepareStroke(r, miterLimit, lineJoin);
+ nsvg__expandStroke(r, r->points, r->npoints, closed, lineJoin, lineCap, lineWidth);
+ }
+ }
+}
+
+static int nsvg__cmpEdge(const void *p, const void *q)
+{
+ const NSVGedge* a = (const NSVGedge*)p;
+ const NSVGedge* b = (const NSVGedge*)q;
+
+ if (a->y0 < b->y0) return -1;
+ if (a->y0 > b->y0) return 1;
+ return 0;
+}
+
+
+static NSVGactiveEdge* nsvg__addActive(NSVGrasterizer* r, NSVGedge* e, float startPoint)
+{
+ NSVGactiveEdge* z;
+ float dxdy;
+
+ if (r->freelist != NULL) {
+ /* Restore from freelist. */
+ z = r->freelist;
+ r->freelist = z->next;
+ } else {
+ /* Alloc new edge. */
+ z = (NSVGactiveEdge*)nsvg__alloc(r, sizeof(NSVGactiveEdge));
+ if (z == NULL) return NULL;
+ }
+
+ dxdy = (e->x1 - e->x0) / (e->y1 - e->y0);
+/* STBTT_assert(e->y0 <= start_point); */
+ /* round dx down to avoid going too far */
+ if (dxdy < 0)
+ z->dx = (int)(-nsvg__roundf(NSVG__FIX * -dxdy));
+ else
+ z->dx = (int)nsvg__roundf(NSVG__FIX * dxdy);
+ z->x = (int)nsvg__roundf(NSVG__FIX * (e->x0 + dxdy * (startPoint - e->y0)));
+/* z->x -= off_x * FIX; */
+ z->ey = e->y1;
+ z->next = 0;
+ z->dir = e->dir;
+
+ return z;
+}
+
+static void nsvg__freeActive(NSVGrasterizer* r, NSVGactiveEdge* z)
+{
+ z->next = r->freelist;
+ r->freelist = z;
+}
+
+static void nsvg__fillScanline(unsigned char* scanline, int len, int x0, int x1, int maxWeight, int* xmin, int* xmax)
+{
+ int i = x0 >> NSVG__FIXSHIFT;
+ int j = x1 >> NSVG__FIXSHIFT;
+ if (i < *xmin) *xmin = i;
+ if (j > *xmax) *xmax = j;
+ if (i < len && j >= 0) {
+ if (i == j) {
+ /* x0,x1 are the same pixel, so compute combined coverage */
+ scanline[i] = (unsigned char)(scanline[i] + ((x1 - x0) * maxWeight >> NSVG__FIXSHIFT));
+ } else {
+ if (i >= 0) /* add antialiasing for x0 */
+ scanline[i] = (unsigned char)(scanline[i] + (((NSVG__FIX - (x0 & NSVG__FIXMASK)) * maxWeight) >> NSVG__FIXSHIFT));
+ else
+ i = -1; /* clip */
+
+ if (j < len) /* add antialiasing for x1 */
+ scanline[j] = (unsigned char)(scanline[j] + (((x1 & NSVG__FIXMASK) * maxWeight) >> NSVG__FIXSHIFT));
+ else
+ j = len; /* clip */
+
+ for (++i; i < j; ++i) /* fill pixels between x0 and x1 */
+ scanline[i] = (unsigned char)(scanline[i] + maxWeight);
+ }
+ }
+}
+
+/* note: this routine clips fills that extend off the edges... ideally this
+ * wouldn't happen, but it could happen if the truetype glyph bounding boxes
+ * are wrong, or if the user supplies a too-small bitmap
+ */
+static void nsvg__fillActiveEdges(unsigned char* scanline, int len, NSVGactiveEdge* e, int maxWeight, int* xmin, int* xmax, char fillRule)
+{
+ /* non-zero winding fill */
+ int x0 = 0, w = 0;
+
+ if (fillRule == NSVG_FILLRULE_NONZERO) {
+ /* Non-zero */
+ while (e != NULL) {
+ if (w == 0) {
+ /* if we're currently at zero, we need to record the edge start point */
+ x0 = e->x; w += e->dir;
+ } else {
+ int x1 = e->x; w += e->dir;
+ /* if we went to zero, we need to draw */
+ if (w == 0)
+ nsvg__fillScanline(scanline, len, x0, x1, maxWeight, xmin, xmax);
+ }
+ e = e->next;
+ }
+ } else if (fillRule == NSVG_FILLRULE_EVENODD) {
+ /* Even-odd */
+ while (e != NULL) {
+ if (w == 0) {
+ /* if we're currently at zero, we need to record the edge start point */
+ x0 = e->x; w = 1;
+ } else {
+ int x1 = e->x; w = 0;
+ nsvg__fillScanline(scanline, len, x0, x1, maxWeight, xmin, xmax);
+ }
+ e = e->next;
+ }
+ }
+}
+
+static float nsvg__clampf(float a, float mn, float mx) { return a < mn ? mn : (a > mx ? mx : a); }
+
+static unsigned int nsvg__RGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
+{
+ return ((unsigned int)r) | ((unsigned int)g << 8) | ((unsigned int)b << 16) | ((unsigned int)a << 24);
+}
+
+static unsigned int nsvg__lerpRGBA(unsigned int c0, unsigned int c1, float u)
+{
+ int iu = (int)(nsvg__clampf(u, 0.0f, 1.0f) * 256.0f);
+ int r = (((c0) & 0xff)*(256-iu) + (((c1) & 0xff)*iu)) >> 8;
+ int g = (((c0>>8) & 0xff)*(256-iu) + (((c1>>8) & 0xff)*iu)) >> 8;
+ int b = (((c0>>16) & 0xff)*(256-iu) + (((c1>>16) & 0xff)*iu)) >> 8;
+ int a = (((c0>>24) & 0xff)*(256-iu) + (((c1>>24) & 0xff)*iu)) >> 8;
+ return nsvg__RGBA((unsigned char)r, (unsigned char)g, (unsigned char)b, (unsigned char)a);
+}
+
+static unsigned int nsvg__applyOpacity(unsigned int c, float u)
+{
+ int iu = (int)(nsvg__clampf(u, 0.0f, 1.0f) * 256.0f);
+ int r = (c) & 0xff;
+ int g = (c>>8) & 0xff;
+ int b = (c>>16) & 0xff;
+ int a = (((c>>24) & 0xff)*iu) >> 8;
+ return nsvg__RGBA((unsigned char)r, (unsigned char)g, (unsigned char)b, (unsigned char)a);
+}
+
+static inline int nsvg__div255(int x)
+{
+ return ((x+1) * 257) >> 16;
+}
+
+static void nsvg__scanlineSolid(unsigned char* dst, int count, unsigned char* cover, int x, int y,
+ float tx, float ty, float scale, NSVGcachedPaint* cache)
+{
+
+ if (cache->type == NSVG_PAINT_COLOR) {
+ int i, cr, cg, cb, ca;
+ cr = cache->colors[0] & 0xff;
+ cg = (cache->colors[0] >> 8) & 0xff;
+ cb = (cache->colors[0] >> 16) & 0xff;
+ ca = (cache->colors[0] >> 24) & 0xff;
+
+ for (i = 0; i < count; i++) {
+ int r,g,b;
+ int a = nsvg__div255((int)cover[0] * ca);
+ int ia = 255 - a;
+ /* Premultiply */
+ r = nsvg__div255(cr * a);
+ g = nsvg__div255(cg * a);
+ b = nsvg__div255(cb * a);
+
+ /* Blend over */
+ r += nsvg__div255(ia * (int)dst[0]);
+ g += nsvg__div255(ia * (int)dst[1]);
+ b += nsvg__div255(ia * (int)dst[2]);
+ a += nsvg__div255(ia * (int)dst[3]);
+
+ dst[0] = (unsigned char)r;
+ dst[1] = (unsigned char)g;
+ dst[2] = (unsigned char)b;
+ dst[3] = (unsigned char)a;
+
+ cover++;
+ dst += 4;
+ }
+ } else if (cache->type == NSVG_PAINT_LINEAR_GRADIENT) {
+ /* TODO: spread modes. */
+ /* TODO: plenty of opportunities to optimize. */
+ float fx, fy, dx, gy;
+ float* t = cache->xform;
+ int i, cr, cg, cb, ca;
+ unsigned int c;
+
+ fx = ((float)x - tx) / scale;
+ fy = ((float)y - ty) / scale;
+ dx = 1.0f / scale;
+
+ for (i = 0; i < count; i++) {
+ int r,g,b,a,ia;
+ gy = fx*t[1] + fy*t[3] + t[5];
+ c = cache->colors[(int)nsvg__clampf(gy*255.0f, 0, 255.0f)];
+ cr = (c) & 0xff;
+ cg = (c >> 8) & 0xff;
+ cb = (c >> 16) & 0xff;
+ ca = (c >> 24) & 0xff;
+
+ a = nsvg__div255((int)cover[0] * ca);
+ ia = 255 - a;
+
+ /* Premultiply */
+ r = nsvg__div255(cr * a);
+ g = nsvg__div255(cg * a);
+ b = nsvg__div255(cb * a);
+
+ /* Blend over */
+ r += nsvg__div255(ia * (int)dst[0]);
+ g += nsvg__div255(ia * (int)dst[1]);
+ b += nsvg__div255(ia * (int)dst[2]);
+ a += nsvg__div255(ia * (int)dst[3]);
+
+ dst[0] = (unsigned char)r;
+ dst[1] = (unsigned char)g;
+ dst[2] = (unsigned char)b;
+ dst[3] = (unsigned char)a;
+
+ cover++;
+ dst += 4;
+ fx += dx;
+ }
+ } else if (cache->type == NSVG_PAINT_RADIAL_GRADIENT) {
+ /* TODO: spread modes. */
+ /* TODO: plenty of opportunities to optimize. */
+ /* TODO: focus (fx,fy) */
+ float fx, fy, dx, gx, gy, gd;
+ float* t = cache->xform;
+ int i, cr, cg, cb, ca;
+ unsigned int c;
+
+ fx = ((float)x - tx) / scale;
+ fy = ((float)y - ty) / scale;
+ dx = 1.0f / scale;
+
+ for (i = 0; i < count; i++) {
+ int r,g,b,a,ia;
+ gx = fx*t[0] + fy*t[2] + t[4];
+ gy = fx*t[1] + fy*t[3] + t[5];
+ gd = sqrtf(gx*gx + gy*gy);
+ c = cache->colors[(int)nsvg__clampf(gd*255.0f, 0, 255.0f)];
+ cr = (c) & 0xff;
+ cg = (c >> 8) & 0xff;
+ cb = (c >> 16) & 0xff;
+ ca = (c >> 24) & 0xff;
+
+ a = nsvg__div255((int)cover[0] * ca);
+ ia = 255 - a;
+
+ /* Premultiply */
+ r = nsvg__div255(cr * a);
+ g = nsvg__div255(cg * a);
+ b = nsvg__div255(cb * a);
+
+ /* Blend over */
+ r += nsvg__div255(ia * (int)dst[0]);
+ g += nsvg__div255(ia * (int)dst[1]);
+ b += nsvg__div255(ia * (int)dst[2]);
+ a += nsvg__div255(ia * (int)dst[3]);
+
+ dst[0] = (unsigned char)r;
+ dst[1] = (unsigned char)g;
+ dst[2] = (unsigned char)b;
+ dst[3] = (unsigned char)a;
+
+ cover++;
+ dst += 4;
+ fx += dx;
+ }
+ }
+}
+
+static void nsvg__rasterizeSortedEdges(NSVGrasterizer *r, float tx, float ty, float scale, NSVGcachedPaint* cache, char fillRule)
+{
+ NSVGactiveEdge *active = NULL;
+ int y, s;
+ int e = 0;
+ int maxWeight = (255 / NSVG__SUBSAMPLES); /* weight per vertical scanline */
+ int xmin, xmax;
+
+ for (y = 0; y < r->height; y++) {
+ memset(r->scanline, 0, r->width);
+ xmin = r->width;
+ xmax = 0;
+ for (s = 0; s < NSVG__SUBSAMPLES; ++s) {
+ /* find center of pixel for this scanline */
+ float scany = (float)(y*NSVG__SUBSAMPLES + s) + 0.5f;
+ NSVGactiveEdge **step = &active;
+
+ /* update all active edges; */
+ /* remove all active edges that terminate before the center of this scanline */
+ while (*step) {
+ NSVGactiveEdge *z = *step;
+ if (z->ey <= scany) {
+ *step = z->next; /* delete from list */
+/* NSVG__assert(z->valid); */
+ nsvg__freeActive(r, z);
+ } else {
+ z->x += z->dx; /* advance to position for current scanline */
+ step = &((*step)->next); /* advance through list */
+ }
+ }
+
+ /* resort the list if needed */
+ for (;;) {
+ int changed = 0;
+ step = &active;
+ while (*step && (*step)->next) {
+ if ((*step)->x > (*step)->next->x) {
+ NSVGactiveEdge* t = *step;
+ NSVGactiveEdge* q = t->next;
+ t->next = q->next;
+ q->next = t;
+ *step = q;
+ changed = 1;
+ }
+ step = &(*step)->next;
+ }
+ if (!changed) break;
+ }
+
+ /* insert all edges that start before the center of this scanline -- omit ones that also end on this scanline */
+ while (e < r->nedges && r->edges[e].y0 <= scany) {
+ if (r->edges[e].y1 > scany) {
+ NSVGactiveEdge* z = nsvg__addActive(r, &r->edges[e], scany);
+ if (z == NULL) break;
+ /* find insertion point */
+ if (active == NULL) {
+ active = z;
+ } else if (z->x < active->x) {
+ /* insert at front */
+ z->next = active;
+ active = z;
+ } else {
+ /* find thing to insert AFTER */
+ NSVGactiveEdge* p = active;
+ while (p->next && p->next->x < z->x)
+ p = p->next;
+ /* at this point, p->next->x is NOT < z->x */
+ z->next = p->next;
+ p->next = z;
+ }
+ }
+ e++;
+ }
+
+ /* now process all active edges in non-zero fashion */
+ if (active != NULL)
+ nsvg__fillActiveEdges(r->scanline, r->width, active, maxWeight, &xmin, &xmax, fillRule);
+ }
+ /* Blit */
+ if (xmin < 0) xmin = 0;
+ if (xmax > r->width-1) xmax = r->width-1;
+ if (xmin <= xmax) {
+ nsvg__scanlineSolid(&r->bitmap[y * r->stride] + xmin*4, xmax-xmin+1, &r->scanline[xmin], xmin, y, tx,ty, scale, cache);
+ }
+ }
+
+}
+
+static void nsvg__unpremultiplyAlpha(unsigned char* image, int w, int h, int stride)
+{
+ int x,y;
+
+ /* Unpremultiply */
+ for (y = 0; y < h; y++) {
+ unsigned char *row = &image[y*stride];
+ for (x = 0; x < w; x++) {
+ int r = row[0], g = row[1], b = row[2], a = row[3];
+ if (a != 0) {
+ row[0] = (unsigned char)(r*255/a);
+ row[1] = (unsigned char)(g*255/a);
+ row[2] = (unsigned char)(b*255/a);
+ }
+ row += 4;
+ }
+ }
+
+ /* Defringe */
+ for (y = 0; y < h; y++) {
+ unsigned char *row = &image[y*stride];
+ for (x = 0; x < w; x++) {
+ int r = 0, g = 0, b = 0, a = row[3], n = 0;
+ if (a == 0) {
+ if (x-1 > 0 && row[-1] != 0) {
+ r += row[-4];
+ g += row[-3];
+ b += row[-2];
+ n++;
+ }
+ if (x+1 < w && row[7] != 0) {
+ r += row[4];
+ g += row[5];
+ b += row[6];
+ n++;
+ }
+ if (y-1 > 0 && row[-stride+3] != 0) {
+ r += row[-stride];
+ g += row[-stride+1];
+ b += row[-stride+2];
+ n++;
+ }
+ if (y+1 < h && row[stride+3] != 0) {
+ r += row[stride];
+ g += row[stride+1];
+ b += row[stride+2];
+ n++;
+ }
+ if (n > 0) {
+ row[0] = (unsigned char)(r/n);
+ row[1] = (unsigned char)(g/n);
+ row[2] = (unsigned char)(b/n);
+ }
+ }
+ row += 4;
+ }
+ }
+}
+
+
+static void nsvg__initPaint(NSVGcachedPaint* cache, NSVGpaint* paint, float opacity)
+{
+ int i, j;
+ NSVGgradient* grad;
+
+ cache->type = paint->type;
+
+ if (paint->type == NSVG_PAINT_COLOR) {
+ cache->colors[0] = nsvg__applyOpacity(paint->color, opacity);
+ return;
+ }
+
+ grad = paint->gradient;
+
+ cache->spread = grad->spread;
+ memcpy(cache->xform, grad->xform, sizeof(float)*6);
+
+ if (grad->nstops == 0) {
+ for (i = 0; i < 256; i++)
+ cache->colors[i] = 0;
+ } else if (grad->nstops == 1) {
+ unsigned int color = nsvg__applyOpacity(grad->stops[0].color, opacity);
+ for (i = 0; i < 256; i++)
+ cache->colors[i] = color;
+ } else {
+ unsigned int ca, cb = 0;
+ float ua, ub, du, u;
+ int ia, ib, count;
+
+ ca = nsvg__applyOpacity(grad->stops[0].color, opacity);
+ ua = nsvg__clampf(grad->stops[0].offset, 0, 1);
+ ub = nsvg__clampf(grad->stops[grad->nstops-1].offset, ua, 1);
+ ia = (int)(ua * 255.0f);
+ ib = (int)(ub * 255.0f);
+ for (i = 0; i < ia; i++) {
+ cache->colors[i] = ca;
+ }
+
+ for (i = 0; i < grad->nstops-1; i++) {
+ ca = nsvg__applyOpacity(grad->stops[i].color, opacity);
+ cb = nsvg__applyOpacity(grad->stops[i+1].color, opacity);
+ ua = nsvg__clampf(grad->stops[i].offset, 0, 1);
+ ub = nsvg__clampf(grad->stops[i+1].offset, 0, 1);
+ ia = (int)(ua * 255.0f);
+ ib = (int)(ub * 255.0f);
+ count = ib - ia;
+ if (count <= 0) continue;
+ u = 0;
+ du = 1.0f / (float)count;
+ for (j = 0; j < count; j++) {
+ cache->colors[ia+j] = nsvg__lerpRGBA(ca,cb,u);
+ u += du;
+ }
+ }
+
+ for (i = ib; i < 256; i++)
+ cache->colors[i] = cb;
+ }
+
+}
+
+/*
+static void dumpEdges(NSVGrasterizer* r, const char* name)
+{
+ float xmin = 0, xmax = 0, ymin = 0, ymax = 0;
+ NSVGedge *e = NULL;
+ int i;
+ if (r->nedges == 0) return;
+ FILE* fp = fopen(name, "w");
+ if (fp == NULL) return;
+
+ xmin = xmax = r->edges[0].x0;
+ ymin = ymax = r->edges[0].y0;
+ for (i = 0; i < r->nedges; i++) {
+ e = &r->edges[i];
+ xmin = nsvg__minf(xmin, e->x0);
+ xmin = nsvg__minf(xmin, e->x1);
+ xmax = nsvg__maxf(xmax, e->x0);
+ xmax = nsvg__maxf(xmax, e->x1);
+ ymin = nsvg__minf(ymin, e->y0);
+ ymin = nsvg__minf(ymin, e->y1);
+ ymax = nsvg__maxf(ymax, e->y0);
+ ymax = nsvg__maxf(ymax, e->y1);
+ }
+
+ fprintf(fp, "<svg viewBox=\"%f %f %f %f\" xmlns=\"http://www.w3.org/2000/svg\">", xmin, ymin, (xmax - xmin), (ymax - ymin));
+
+ for (i = 0; i < r->nedges; i++) {
+ e = &r->edges[i];
+ fprintf(fp ,"<line x1=\"%f\" y1=\"%f\" x2=\"%f\" y2=\"%f\" style=\"stroke:#000;\" />", e->x0,e->y0, e->x1,e->y1);
+ }
+
+ for (i = 0; i < r->npoints; i++) {
+ if (i+1 < r->npoints)
+ fprintf(fp ,"<line x1=\"%f\" y1=\"%f\" x2=\"%f\" y2=\"%f\" style=\"stroke:#f00;\" />", r->points[i].x, r->points[i].y, r->points[i+1].x, r->points[i+1].y);
+ fprintf(fp ,"<circle cx=\"%f\" cy=\"%f\" r=\"1\" style=\"fill:%s;\" />", r->points[i].x, r->points[i].y, r->points[i].flags == 0 ? "#f00" : "#0f0");
+ }
+
+ fprintf(fp, "</svg>");
+ fclose(fp);
+}
+*/
+
+NANOSVG_SCOPE
+void nsvgRasterize(NSVGrasterizer* r,
+ NSVGimage* image, float tx, float ty, float scale,
+ unsigned char* dst, int w, int h, int stride)
+{
+ NSVGshape *shape = NULL;
+ NSVGedge *e = NULL;
+ NSVGcachedPaint cache;
+ int i;
+
+ r->bitmap = dst;
+ r->width = w;
+ r->height = h;
+ r->stride = stride;
+
+ if (w > r->cscanline) {
+ r->cscanline = w;
+ r->scanline = (unsigned char*)NANOSVG_realloc(r->scanline, w);
+ if (r->scanline == NULL) return;
+ }
+
+ for (i = 0; i < h; i++)
+ memset(&dst[i*stride], 0, w*4);
+
+ for (shape = image->shapes; shape != NULL; shape = shape->next) {
+ if (!(shape->flags & NSVG_FLAGS_VISIBLE))
+ continue;
+
+ if (shape->fill.type != NSVG_PAINT_NONE) {
+ nsvg__resetPool(r);
+ r->freelist = NULL;
+ r->nedges = 0;
+
+ nsvg__flattenShape(r, shape, scale);
+
+ /* Scale and translate edges */
+ for (i = 0; i < r->nedges; i++) {
+ e = &r->edges[i];
+ e->x0 = tx + e->x0;
+ e->y0 = (ty + e->y0) * NSVG__SUBSAMPLES;
+ e->x1 = tx + e->x1;
+ e->y1 = (ty + e->y1) * NSVG__SUBSAMPLES;
+ }
+
+ /* Rasterize edges */
+ if (r->nedges != 0)
+ qsort(r->edges, r->nedges, sizeof(NSVGedge), nsvg__cmpEdge);
+
+ /* now, traverse the scanlines and find the intersections on each scanline, use non-zero rule */
+ nsvg__initPaint(&cache, &shape->fill, shape->opacity);
+
+ nsvg__rasterizeSortedEdges(r, tx,ty,scale, &cache, shape->fillRule);
+ }
+ if (shape->stroke.type != NSVG_PAINT_NONE && (shape->strokeWidth * scale) > 0.01f) {
+ nsvg__resetPool(r);
+ r->freelist = NULL;
+ r->nedges = 0;
+
+ nsvg__flattenShapeStroke(r, shape, scale);
+
+/* dumpEdges(r, "edge.svg"); */
+
+ /* Scale and translate edges */
+ for (i = 0; i < r->nedges; i++) {
+ e = &r->edges[i];
+ e->x0 = tx + e->x0;
+ e->y0 = (ty + e->y0) * NSVG__SUBSAMPLES;
+ e->x1 = tx + e->x1;
+ e->y1 = (ty + e->y1) * NSVG__SUBSAMPLES;
+ }
+
+ /* Rasterize edges */
+ if (r->nedges != 0)
+ qsort(r->edges, r->nedges, sizeof(NSVGedge), nsvg__cmpEdge);
+
+ /* now, traverse the scanlines and find the intersections on each scanline, use non-zero rule */
+ nsvg__initPaint(&cache, &shape->stroke, shape->opacity);
+
+ nsvg__rasterizeSortedEdges(r, tx,ty,scale, &cache, NSVG_FILLRULE_NONZERO);
+ }
+ }
+
+ nsvg__unpremultiplyAlpha(dst, w, h, stride);
+
+ r->bitmap = NULL;
+ r->width = 0;
+ r->height = 0;
+ r->stride = 0;
+}
+
+#endif
+
+#endif /* NANOSVGRAST_H */
diff --git a/generic/tk.decls b/generic/tk.decls
index 5363c92..3c94054 100644
--- a/generic/tk.decls
+++ b/generic/tk.decls
@@ -5,8 +5,8 @@
# This file is used to generate the tkDecls.h, tkPlatDecls.h,
# tkStub.c, and tkPlatStub.c files.
#
-# Copyright (c) 1998-2000 Ajuba Solutions.
-# Copyright (c) 2007 Daniel A. Steffen <das@users.sourceforge.net>
+# Copyright © 1998-2000 Ajuba Solutions.
+# Copyright © 2007 Daniel A. Steffen <das@users.sourceforge.net>
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -54,8 +54,8 @@ declare 5 {
}
declare 6 {
void Tk_BindEvent(Tk_BindingTable bindingTable,
- XEvent *eventPtr, Tk_Window tkwin, int numObjects,
- ClientData *objectPtr)
+ XEvent *eventPtr, Tk_Window tkwin, Tcl_Size numObjects,
+ void **objectPtr)
}
declare 7 {
void Tk_CanvasDrawableCoords(Tk_Canvas canvas,
@@ -88,7 +88,7 @@ declare 13 {
}
declare 14 {
void Tk_CanvasPsPath(Tcl_Interp *interp,
- Tk_Canvas canvas, double *coordPtr, int numPoints)
+ Tk_Canvas canvas, double *coordPtr, Tcl_Size numPoints)
}
declare 15 {
int Tk_CanvasPsStipple(Tcl_Interp *interp,
@@ -101,12 +101,12 @@ declare 17 {
void Tk_CanvasSetStippleOrigin(Tk_Canvas canvas, GC gc)
}
declare 18 {
- int Tk_CanvasTagsParseProc(ClientData clientData, Tcl_Interp *interp,
- Tk_Window tkwin, const char *value, char *widgRec, int offset)
+ int Tk_CanvasTagsParseProc(void *clientData, Tcl_Interp *interp,
+ Tk_Window tkwin, const char *value, char *widgRec, Tcl_Size offset)
}
declare 19 {
- CONST86 char *Tk_CanvasTagsPrintProc(ClientData clientData, Tk_Window tkwin,
- char *widgRec, int offset, Tcl_FreeProc **freeProcPtr)
+ const char *Tk_CanvasTagsPrintProc(void *clientData, Tk_Window tkwin,
+ char *widgRec, Tcl_Size offset, Tcl_FreeProc **freeProcPtr)
}
declare 20 {
Tk_Window Tk_CanvasTkwin(Tk_Canvas canvas)
@@ -120,7 +120,7 @@ declare 22 {
XSetWindowAttributes *attsPtr)
}
declare 23 {
- int Tk_CharBbox(Tk_TextLayout layout, int index, int *xPtr,
+ int Tk_CharBbox(Tk_TextLayout layout, Tcl_Size index, int *xPtr,
int *yPtr, int *widthPtr, int *heightPtr)
}
declare 24 {
@@ -136,17 +136,17 @@ declare 26 {
declare 27 {
int Tk_ConfigureInfo(Tcl_Interp *interp,
Tk_Window tkwin, const Tk_ConfigSpec *specs,
- char *widgRec, const char *argvName, int flags)
+ void *widgRec, const char *argvName, int flags)
}
declare 28 {
int Tk_ConfigureValue(Tcl_Interp *interp,
Tk_Window tkwin, const Tk_ConfigSpec *specs,
- char *widgRec, const char *argvName, int flags)
+ void *widgRec, const char *argvName, int flags)
}
declare 29 {
int Tk_ConfigureWidget(Tcl_Interp *interp,
Tk_Window tkwin, const Tk_ConfigSpec *specs,
- int argc, CONST84 char **argv, char *widgRec,
+ Tcl_Size argc, const char **argv, void *widgRec,
int flags)
}
declare 30 {
@@ -155,7 +155,7 @@ declare 30 {
}
declare 31 {
Tk_TextLayout Tk_ComputeTextLayout(Tk_Font font,
- const char *str, int numChars, int wrapLength,
+ const char *str, Tcl_Size numChars, int wrapLength,
Tk_Justify justify, int flags, int *widthPtr,
int *heightPtr)
}
@@ -164,7 +164,7 @@ declare 32 {
}
declare 33 {
unsigned long Tk_CreateBinding(Tcl_Interp *interp,
- Tk_BindingTable bindingTable, ClientData object,
+ Tk_BindingTable bindingTable, void *object,
const char *eventStr, const char *script, int append)
}
declare 34 {
@@ -173,15 +173,15 @@ declare 34 {
declare 35 {
Tk_ErrorHandler Tk_CreateErrorHandler(Display *display,
int errNum, int request, int minorCode,
- Tk_ErrorProc *errorProc, ClientData clientData)
+ Tk_ErrorProc *errorProc, void *clientData)
}
declare 36 {
void Tk_CreateEventHandler(Tk_Window token,
unsigned long mask, Tk_EventProc *proc,
- ClientData clientData)
+ void *clientData)
}
declare 37 {
- void Tk_CreateGenericHandler(Tk_GenericProc *proc, ClientData clientData)
+ void Tk_CreateGenericHandler(Tk_GenericProc *proc, void *clientData)
}
declare 38 {
void Tk_CreateImageType(const Tk_ImageType *typePtr)
@@ -195,7 +195,7 @@ declare 40 {
declare 41 {
void Tk_CreateSelHandler(Tk_Window tkwin,
Atom selection, Atom target,
- Tk_SelectionProc *proc, ClientData clientData,
+ Tk_SelectionProc *proc, void *clientData,
Atom format)
}
declare 42 {
@@ -214,11 +214,11 @@ declare 45 {
void Tk_DefineCursor(Tk_Window window, Tk_Cursor cursor)
}
declare 46 {
- void Tk_DeleteAllBindings(Tk_BindingTable bindingTable, ClientData object)
+ void Tk_DeleteAllBindings(Tk_BindingTable bindingTable, void *object)
}
declare 47 {
int Tk_DeleteBinding(Tcl_Interp *interp,
- Tk_BindingTable bindingTable, ClientData object,
+ Tk_BindingTable bindingTable, void *object,
const char *eventStr)
}
declare 48 {
@@ -230,10 +230,10 @@ declare 49 {
declare 50 {
void Tk_DeleteEventHandler(Tk_Window token,
unsigned long mask, Tk_EventProc *proc,
- ClientData clientData)
+ void *clientData)
}
declare 51 {
- void Tk_DeleteGenericHandler(Tk_GenericProc *proc, ClientData clientData)
+ void Tk_DeleteGenericHandler(Tk_GenericProc *proc, void *clientData)
}
declare 52 {
void Tk_DeleteImage(Tcl_Interp *interp, const char *name)
@@ -245,7 +245,7 @@ declare 54 {
void Tk_DestroyWindow(Tk_Window tkwin)
}
declare 55 {
- CONST84_RETURN char *Tk_DisplayName(Tk_Window tkwin)
+ const char *Tk_DisplayName(Tk_Window tkwin)
}
declare 56 {
int Tk_DistanceToTextLayout(Tk_TextLayout layout, int x, int y)
@@ -253,7 +253,7 @@ declare 56 {
declare 57 {
void Tk_Draw3DPolygon(Tk_Window tkwin,
Drawable drawable, Tk_3DBorder border,
- XPoint *pointPtr, int numPoints, int borderWidth,
+ XPoint *pointPtr, Tcl_Size numPoints, int borderWidth,
int leftRelief)
}
declare 58 {
@@ -263,7 +263,7 @@ declare 58 {
}
declare 59 {
void Tk_DrawChars(Display *display, Drawable drawable, GC gc,
- Tk_Font tkfont, const char *source, int numBytes, int x, int y)
+ Tk_Font tkfont, const char *source, Tcl_Size numBytes, int x, int y)
}
declare 60 {
void Tk_DrawFocusHighlight(Tk_Window tkwin, GC gc, int width,
@@ -272,12 +272,12 @@ declare 60 {
declare 61 {
void Tk_DrawTextLayout(Display *display,
Drawable drawable, GC gc, Tk_TextLayout layout,
- int x, int y, int firstChar, int lastChar)
+ int x, int y, Tcl_Size firstChar, Tcl_Size lastChar)
}
declare 62 {
void Tk_Fill3DPolygon(Tk_Window tkwin,
Drawable drawable, Tk_3DBorder border,
- XPoint *pointPtr, int numPoints, int borderWidth,
+ XPoint *pointPtr, Tcl_Size numPoints, int borderWidth,
int leftRelief)
}
declare 63 {
@@ -318,7 +318,7 @@ declare 73 {
}
declare 74 {
void Tk_FreeOptions(const Tk_ConfigSpec *specs,
- char *widgRec, Display *display, int needFlags)
+ void *widgRec, Display *display, int needFlags)
}
declare 75 {
void Tk_FreePixmap(Display *display, Pixmap pixmap)
@@ -326,7 +326,7 @@ declare 75 {
declare 76 {
void Tk_FreeTextLayout(Tk_TextLayout textLayout)
}
-declare 77 {
+declare 77 {deprecated {function does nothing, call can be removed}} {
void Tk_FreeXId(Display *display, XID xid)
}
declare 78 {
@@ -341,18 +341,18 @@ declare 80 {
}
declare 81 {
void Tk_GetAllBindings(Tcl_Interp *interp,
- Tk_BindingTable bindingTable, ClientData object)
+ Tk_BindingTable bindingTable, void *object)
}
declare 82 {
int Tk_GetAnchor(Tcl_Interp *interp,
const char *str, Tk_Anchor *anchorPtr)
}
declare 83 {
- CONST84_RETURN char *Tk_GetAtomName(Tk_Window tkwin, Atom atom)
+ const char *Tk_GetAtomName(Tk_Window tkwin, Atom atom)
}
declare 84 {
- CONST84_RETURN char *Tk_GetBinding(Tcl_Interp *interp,
- Tk_BindingTable bindingTable, ClientData object,
+ const char *Tk_GetBinding(Tcl_Interp *interp,
+ Tk_BindingTable bindingTable, void *object,
const char *eventStr)
}
declare 85 {
@@ -400,11 +400,11 @@ declare 96 {
}
declare 97 {
Tk_Image Tk_GetImage(Tcl_Interp *interp, Tk_Window tkwin, const char *name,
- Tk_ImageChangedProc *changeProc, ClientData clientData)
+ Tk_ImageChangedProc *changeProc, void *clientData)
}
declare 98 {
- ClientData Tk_GetImageMasterData(Tcl_Interp *interp,
- const char *name, CONST86 Tk_ImageType **typePtrPtr)
+ void *Tk_GetImageModelData(Tcl_Interp *interp,
+ const char *name, const Tk_ImageType **typePtrPtr)
}
declare 99 {
Tk_ItemType *Tk_GetItemTypes(void)
@@ -439,7 +439,7 @@ declare 107 {
}
declare 108 {
int Tk_GetScrollInfo(Tcl_Interp *interp,
- int argc, CONST84 char **argv, double *dblPtr, int *intPtr)
+ Tcl_Size argc, const char **argv, double *dblPtr, int *intPtr)
}
declare 109 {
int Tk_GetScreenMM(Tcl_Interp *interp,
@@ -448,7 +448,7 @@ declare 109 {
declare 110 {
int Tk_GetSelection(Tcl_Interp *interp,
Tk_Window tkwin, Atom selection, Atom target,
- Tk_GetSelProc *proc, ClientData clientData)
+ Tk_GetSelProc *proc, void *clientData)
}
declare 111 {
Tk_Uid Tk_GetUid(const char *str)
@@ -472,7 +472,7 @@ declare 116 {
Tk_Window Tk_IdToWindow(Display *display, Window window)
}
declare 117 {
- void Tk_ImageChanged(Tk_ImageMaster model, int x, int y,
+ void Tk_ImageChanged(Tk_ImageModel model, int x, int y,
int width, int height, int imageWidth, int imageHeight)
}
declare 118 {
@@ -497,14 +497,14 @@ declare 123 {
}
declare 124 {
void Tk_ManageGeometry(Tk_Window tkwin,
- const Tk_GeomMgr *mgrPtr, ClientData clientData)
+ const Tk_GeomMgr *mgrPtr, void *clientData)
}
declare 125 {
void Tk_MapWindow(Tk_Window tkwin)
}
declare 126 {
int Tk_MeasureChars(Tk_Font tkfont,
- const char *source, int numBytes, int maxPixels,
+ const char *source, Tcl_Size numBytes, int maxPixels,
int flags, int *lengthPtr)
}
declare 127 {
@@ -518,37 +518,37 @@ declare 129 {
void Tk_MoveToplevelWindow(Tk_Window tkwin, int x, int y)
}
declare 130 {
- CONST84_RETURN char *Tk_NameOf3DBorder(Tk_3DBorder border)
+ const char *Tk_NameOf3DBorder(Tk_3DBorder border)
}
declare 131 {
- CONST84_RETURN char *Tk_NameOfAnchor(Tk_Anchor anchor)
+ const char *Tk_NameOfAnchor(Tk_Anchor anchor)
}
declare 132 {
- CONST84_RETURN char *Tk_NameOfBitmap(Display *display, Pixmap bitmap)
+ const char *Tk_NameOfBitmap(Display *display, Pixmap bitmap)
}
declare 133 {
- CONST84_RETURN char *Tk_NameOfCapStyle(int cap)
+ const char *Tk_NameOfCapStyle(int cap)
}
declare 134 {
- CONST84_RETURN char *Tk_NameOfColor(XColor *colorPtr)
+ const char *Tk_NameOfColor(XColor *colorPtr)
}
declare 135 {
- CONST84_RETURN char *Tk_NameOfCursor(Display *display, Tk_Cursor cursor)
+ const char *Tk_NameOfCursor(Display *display, Tk_Cursor cursor)
}
declare 136 {
- CONST84_RETURN char *Tk_NameOfFont(Tk_Font font)
+ const char *Tk_NameOfFont(Tk_Font font)
}
declare 137 {
- CONST84_RETURN char *Tk_NameOfImage(Tk_ImageMaster model)
+ const char *Tk_NameOfImage(Tk_ImageModel model)
}
declare 138 {
- CONST84_RETURN char *Tk_NameOfJoinStyle(int join)
+ const char *Tk_NameOfJoinStyle(int join)
}
declare 139 {
- CONST84_RETURN char *Tk_NameOfJustify(Tk_Justify justify)
+ const char *Tk_NameOfJustify(Tk_Justify justify)
}
declare 140 {
- CONST84_RETURN char *Tk_NameOfRelief(int relief)
+ const char *Tk_NameOfRelief(int relief)
}
declare 141 {
Tk_Window Tk_NameToWindow(Tcl_Interp *interp,
@@ -557,19 +557,19 @@ declare 141 {
declare 142 {
void Tk_OwnSelection(Tk_Window tkwin,
Atom selection, Tk_LostSelProc *proc,
- ClientData clientData)
+ void *clientData)
}
declare 143 {
int Tk_ParseArgv(Tcl_Interp *interp,
- Tk_Window tkwin, int *argcPtr, CONST84 char **argv,
+ Tk_Window tkwin, int *argcPtr, const char **argv,
const Tk_ArgvInfo *argTable, int flags)
}
-declare 144 {
+declare 144 {deprecated {function signature changed}} {
void Tk_PhotoPutBlock_NoComposite(Tk_PhotoHandle handle,
Tk_PhotoImageBlock *blockPtr, int x, int y,
int width, int height)
}
-declare 145 {
+declare 145 {deprecated {function signature changed}} {
void Tk_PhotoPutZoomedBlock_NoComposite(Tk_PhotoHandle handle,
Tk_PhotoImageBlock *blockPtr, int x, int y,
int width, int height, int zoomX, int zoomY,
@@ -581,13 +581,13 @@ declare 146 {
declare 147 {
void Tk_PhotoBlank(Tk_PhotoHandle handle)
}
-declare 148 {
+declare 148 {deprecated {function signature changed}} {
void Tk_PhotoExpand_Panic(Tk_PhotoHandle handle, int width, int height )
}
declare 149 {
void Tk_PhotoGetSize(Tk_PhotoHandle handle, int *widthPtr, int *heightPtr)
}
-declare 150 {
+declare 150 {deprecated {function signature changed}} {
void Tk_PhotoSetSize_Panic(Tk_PhotoHandle handle, int width, int height)
}
declare 151 {
@@ -615,7 +615,7 @@ declare 157 {
}
declare 158 {
Tk_RestrictProc *Tk_RestrictEvents(Tk_RestrictProc *proc,
- ClientData arg, ClientData *prevArgPtr)
+ void *arg, void **prevArgPtr)
}
declare 159 {
int Tk_SafeInit(Tcl_Interp *interp)
@@ -672,7 +672,7 @@ declare 175 {
void Tk_TextLayoutToPostscript(Tcl_Interp *interp, Tk_TextLayout layout)
}
declare 176 {
- int Tk_TextWidth(Tk_Font font, const char *str, int numBytes)
+ int Tk_TextWidth(Tk_Font font, const char *str, Tcl_Size numBytes)
}
declare 177 {
void Tk_UndefineCursor(Tk_Window window)
@@ -680,8 +680,8 @@ declare 177 {
declare 178 {
void Tk_UnderlineChars(Display *display,
Drawable drawable, GC gc, Tk_Font tkfont,
- const char *source, int x, int y, int firstByte,
- int lastByte)
+ const char *source, int x, int y, Tcl_Size firstByte,
+ Tcl_Size lastByte)
}
declare 179 {
void Tk_UnderlineTextLayout(Display *display, Drawable drawable, GC gc,
@@ -744,7 +744,7 @@ declare 194 {
void Tk_FreeColorFromObj(Tk_Window tkwin, Tcl_Obj *objPtr)
}
declare 195 {
- void Tk_FreeConfigOptions(char *recordPtr, Tk_OptionTable optionToken,
+ void Tk_FreeConfigOptions(void *recordPtr, Tk_OptionTable optionToken,
Tk_Window tkwin)
}
declare 196 {
@@ -774,11 +774,11 @@ declare 203 {
}
declare 204 {
Tcl_Obj *Tk_GetOptionInfo(Tcl_Interp *interp,
- char *recordPtr, Tk_OptionTable optionTable,
+ void *recordPtr, Tk_OptionTable optionTable,
Tcl_Obj *namePtr, Tk_Window tkwin)
}
declare 205 {
- Tcl_Obj *Tk_GetOptionValue(Tcl_Interp *interp, char *recordPtr,
+ Tcl_Obj *Tk_GetOptionValue(Tcl_Interp *interp, void *recordPtr,
Tk_OptionTable optionTable, Tcl_Obj *namePtr, Tk_Window tkwin)
}
declare 206 {
@@ -799,22 +799,22 @@ declare 209 {
}
declare 210 {
int Tk_GetScrollInfoObj(Tcl_Interp *interp,
- int objc, Tcl_Obj *const objv[], double *dblPtr, int *intPtr)
+ Tcl_Size objc, Tcl_Obj *const objv[], double *dblPtr, int *intPtr)
}
declare 211 {
- int Tk_InitOptions(Tcl_Interp *interp, char *recordPtr,
+ int Tk_InitOptions(Tcl_Interp *interp, void *recordPtr,
Tk_OptionTable optionToken, Tk_Window tkwin)
}
-declare 212 {
- TCL_NORETURN1 void Tk_MainEx(int argc, char **argv, Tcl_AppInitProc *appInitProc,
+declare 212 {nostub {Don't use this function in a stub-enabled extension}} {
+ TCL_NORETURN1 void Tk_MainEx(Tcl_Size argc, char **argv, Tcl_AppInitProc *appInitProc,
Tcl_Interp *interp)
}
declare 213 {
void Tk_RestoreSavedOptions(Tk_SavedOptions *savePtr)
}
declare 214 {
- int Tk_SetOptions(Tcl_Interp *interp, char *recordPtr,
- Tk_OptionTable optionTable, int objc,
+ int Tk_SetOptions(Tcl_Interp *interp, void *recordPtr,
+ Tk_OptionTable optionTable, Tcl_Size objc,
Tcl_Obj *const objv[], Tk_Window tkwin,
Tk_SavedOptions *savePtr, int *maskPtr)
}
@@ -892,7 +892,7 @@ declare 234 {
}
declare 235 {
void Tk_PostscriptPath(Tcl_Interp *interp, Tk_PostscriptInfo psInfo,
- double *coordPtr, int numPoints)
+ double *coordPtr, Tcl_Size numPoints)
}
declare 236 {
int Tk_PostscriptStipple(Tcl_Interp *interp, Tk_Window tkwin,
@@ -924,7 +924,7 @@ declare 241 {
}
declare 242 {
void Tk_SetClassProcs(Tk_Window tkwin,
- const Tk_ClassProcs *procs, ClientData instanceData)
+ const Tk_ClassProcs *procs, void *instanceData)
}
# New in 8.4a4
@@ -943,12 +943,12 @@ declare 244 {
declare 245 {
void Tk_SetCaretPos(Tk_Window tkwin, int x, int y, int height)
}
-declare 246 {
+declare 246 {deprecated {function signature changed}} {
void Tk_PhotoPutBlock_Panic(Tk_PhotoHandle handle,
Tk_PhotoImageBlock *blockPtr, int x, int y,
int width, int height, int compRule)
}
-declare 247 {
+declare 247 {deprecated {function signature changed}} {
void Tk_PhotoPutZoomedBlock_Panic(Tk_PhotoHandle handle,
Tk_PhotoImageBlock *blockPtr, int x, int y,
int width, int height, int zoomX, int zoomY,
@@ -975,7 +975,7 @@ declare 252 {
}
declare 253 {
Tk_Style Tk_CreateStyle(const char *name, Tk_StyleEngine engine,
- ClientData clientData)
+ void *clientData)
}
declare 254 {
Tk_Style Tk_GetStyle(Tcl_Interp *interp, const char *name)
@@ -996,27 +996,27 @@ declare 259 {
void Tk_FreeStyleFromObj(Tcl_Obj *objPtr)
}
declare 260 {
- Tk_StyledElement Tk_GetStyledElement(Tk_Style style, int elementId,
+ Tk_StyledElement Tk_GetStyledElement(Tk_Style style, Tcl_Size elementId,
Tk_OptionTable optionTable)
}
declare 261 {
void Tk_GetElementSize(Tk_Style style, Tk_StyledElement element,
- char *recordPtr, Tk_Window tkwin, int width, int height,
+ void *recordPtr, Tk_Window tkwin, int width, int height,
int inner, int *widthPtr, int *heightPtr)
}
declare 262 {
void Tk_GetElementBox(Tk_Style style, Tk_StyledElement element,
- char *recordPtr, Tk_Window tkwin, int x, int y, int width,
+ void *recordPtr, Tk_Window tkwin, int x, int y, int width,
int height, int inner, int *xPtr, int *yPtr, int *widthPtr,
int *heightPtr)
}
declare 263 {
int Tk_GetElementBorderWidth(Tk_Style style, Tk_StyledElement element,
- char *recordPtr, Tk_Window tkwin)
+ void *recordPtr, Tk_Window tkwin)
}
declare 264 {
void Tk_DrawElement(Tk_Style style, Tk_StyledElement element,
- char *recordPtr, Tk_Window tkwin, Drawable d, int x, int y,
+ void *recordPtr, Tk_Window tkwin, Drawable d, int x, int y,
int width, int height, int state)
}
@@ -1068,10 +1068,73 @@ declare 272 {
declare 273 {
void Tk_CreateOldPhotoImageFormat(const Tk_PhotoImageFormat *formatPtr)
}
+
+# TIP#580
+declare 274 {
+ int Tk_AlwaysShowSelection(Tk_Window tkwin)
+}
+declare 275 {
+ unsigned Tk_GetButtonMask(unsigned button)
+}
+declare 276 {
+ int Tk_GetDoublePixelsFromObj(Tcl_Interp *interp, Tk_Window tkwin,
+ Tcl_Obj *objPtr, double *doublePtr)
+}
+declare 277 {
+ Tcl_Obj *Tk_NewWindowObj(Tk_Window tkwin)
+}
+declare 278 {
+ void Tk_SendVirtualEvent(Tk_Window tkwin, const char *eventName,
+ Tcl_Obj *detail)
+}
+declare 279 {
+ Tcl_Obj *Tk_FontGetDescription(Tk_Font tkfont)
+}
+
+# TIP#529
+declare 280 {
+ void Tk_CreatePhotoImageFormatVersion3(
+ const Tk_PhotoImageFormatVersion3 *formatPtr)
+}
+
+# TIP#606
+declare 281 {
+ void Tk_DrawHighlightBorder(Tk_Window tkwin, GC fgGC, GC bgGC,
+ int highlightWidth, Drawable drawable)
+}
+declare 282 {
+ void Tk_SetMainMenubar(Tcl_Interp *interp, Tk_Window tkwin, const char *menuName)
+}
+declare 283 {
+ void Tk_SetWindowMenubar(Tcl_Interp *interp, Tk_Window tkwin,
+ const char *oldMenuName, const char *menuName)
+}
+declare 284 {
+ void Tk_ClipDrawableToRect(Display *display, Drawable d, int x,
+ int y, int width, int height)
+}
+declare 285 {
+ Tcl_Obj *Tk_GetSystemDefault(Tk_Window tkwin,
+ const char *dbName, const char *className)
+}
+declare 286 {
+ int Tk_UseWindow(Tcl_Interp *interp, Tk_Window tkwin, const char *string)
+}
+declare 287 {
+ void Tk_MakeContainer(Tk_Window tkwin)
+}
+declare 288 {
+ Tk_Window Tk_GetOtherWindow(Tk_Window tkwin)
+}
+declare 289 {
+ void Tk_Get3DBorderColors(Tk_3DBorder border, XColor *bgColorPtr, XColor *darkColorPtr,
+ XColor *lightColorPtr)
+}
declare 290 {
- void TkUnusedStubEntry(void)
+ Window Tk_MakeWindow(Tk_Window tkwin, Window parent)
}
+
# Define the platform specific public Tk interface. These functions are
# only available on the designated platform.
@@ -1102,37 +1165,24 @@ declare 5 win {
################################
# Aqua specific functions
-
-declare 0 aqua {
- void Tk_MacOSXSetEmbedHandler(
- Tk_MacOSXEmbedRegisterWinProc *registerWinProcPtr,
- Tk_MacOSXEmbedGetGrafPortProc *getPortProcPtr,
- Tk_MacOSXEmbedMakeContainerExistProc *containerExistProcPtr,
- Tk_MacOSXEmbedGetClipProc *getClipProc,
- Tk_MacOSXEmbedGetOffsetInParentProc *getOffsetProc)
-}
-declare 1 aqua {
- void Tk_MacOSXTurnOffMenus(void)
-}
-declare 2 aqua {
- void Tk_MacOSXTkOwnsCursor(int tkOwnsIt)
-}
-declare 3 aqua {
- void TkMacOSXInitMenus(Tcl_Interp *interp)
-}
+# Stub removed because the function no longer exists.
+#declare 3 aqua {
+# void TkMacOSXInitMenus(Tcl_Interp *interp)
+#}
declare 4 aqua {
void TkMacOSXInitAppleEvents(Tcl_Interp *interp)
}
declare 5 aqua {
- void TkGenWMConfigureEvent(Tk_Window tkwin, int x, int y, int width,
+ void TkGenWMConfigureEvent_(Tk_Window tkwin, int x, int y, int width,
int height, int flags)
}
declare 6 aqua {
void TkMacOSXInvalClipRgns(Tk_Window tkwin)
}
-declare 7 aqua {
- void *TkMacOSXGetDrawablePort(Drawable drawable)
-}
+# Stub removed because it just returned NULL.
+#declare 7 aqua {
+# void *TkMacOSXGetDrawablePort(Drawable drawable)
+#}
declare 8 aqua {
void *TkMacOSXGetRootControl(Drawable drawable)
}
@@ -1153,7 +1203,7 @@ declare 13 aqua {
void *Tk_MacOSXGetNSWindowForDrawable(Drawable drawable)
}
declare 16 aqua {
- void TkGenWMConfigureEvent_(Tk_Window tkwin, int x, int y, int width,
+ void TkGenWMConfigureEvent(Tk_Window tkwin, int x, int y, int width,
int height, int flags)
}
@@ -1166,11 +1216,11 @@ export {
int exact)
}
export {
- TCL_NORETURN1 void Tk_MainEx(int argc, char **argv, Tcl_AppInitProc *appInitProc,
+ TCL_NORETURN1 void Tk_MainEx(Tcl_Size argc, char **argv, Tcl_AppInitProc *appInitProc,
Tcl_Interp *interp)
}
export {
- TCL_NORETURN1 void Tk_MainExW(int argc, wchar_t **argv,
+ TCL_NORETURN1 void Tk_MainExW(Tcl_Size argc, wchar_t **argv,
Tcl_AppInitProc *appInitProc, Tcl_Interp *interp);
}
diff --git a/generic/tk.h b/generic/tk.h
index ef54890..8401d14 100644
--- a/generic/tk.h
+++ b/generic/tk.h
@@ -4,10 +4,10 @@
* 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-1998 Sun Microsystems, Inc.
- * Copyright (c) 1998-2000 Ajuba Solutions.
+ * Copyright © 1989-1994 The Regents of the University of California.
+ * Copyright © 1994 The Australian National University.
+ * Copyright © 1994-1998 Sun Microsystems, Inc.
+ * Copyright © 1998-2000 Ajuba Solutions.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -17,17 +17,10 @@
#define _TK
#include <tcl.h>
-#if (TCL_MAJOR_VERSION != 8) || (TCL_MINOR_VERSION < 6)
-# error Tk 8.6 must be compiled with tcl.h from Tcl 8.6 or better
+#if (TCL_MAJOR_VERSION < 8) || (TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION < 6)
+# error Tk 8.7 must be compiled with tcl.h from Tcl 8.6 or better
#endif
-#ifndef CONST84
-# define CONST84 const
-# define CONST84_RETURN const
-#endif
-#ifndef CONST86
-# define CONST86 CONST84
-#endif
#ifndef EXTERN
# define EXTERN extern TCL_STORAGE_CLASS
#endif
@@ -59,8 +52,8 @@ extern "C" {
* and update the version numbers:
*
* library/tk.tcl (1 LOC patch)
- * unix/configure.in (2 LOC Major, 2 LOC minor, 1 LOC patch)
- * win/configure.in (as above)
+ * unix/configure.ac (2 LOC Major, 2 LOC minor, 1 LOC patch)
+ * win/configure.ac (as above)
* README (sections 0 and 1)
* macosx/Tk-Common.xcconfig (not patchlevel) 1 LOC
* win/README (not patchlevel)
@@ -72,13 +65,18 @@ extern "C" {
* the version of Tcl that this release of Tk is compiled against.
*/
-#define TK_MAJOR_VERSION 8
-#define TK_MINOR_VERSION 6
-#define TK_RELEASE_LEVEL TCL_FINAL_RELEASE
-#define TK_RELEASE_SERIAL 14
+#ifndef TK_MAJOR_VERSION
+# define TK_MAJOR_VERSION 8
+#endif
+#if TK_MAJOR_VERSION != 8
+# error "This header-file is for Tk 8 only"
+#endif
+#define TK_MINOR_VERSION 7
+#define TK_RELEASE_LEVEL TCL_BETA_RELEASE
+#define TK_RELEASE_SERIAL 1
-#define TK_VERSION "8.6"
-#define TK_PATCH_LEVEL "8.6.14"
+#define TK_VERSION "8.7"
+#define TK_PATCH_LEVEL "8.7b1"
/*
* A special definition used to allow this header file to be included from
@@ -101,14 +99,15 @@ extern "C" {
# include <X11/X.h>
# endif
#endif
-#if defined(STDC_HEADERS) || defined(__STDC__) || defined(__C99__FUNC__) \
- || defined(__cplusplus) || defined(_MSC_VER) || defined(__ICC)
-# include <stddef.h>
-#endif
+#include <stddef.h>
#ifdef BUILD_tk
#undef TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS DLLEXPORT
+#else
+# ifndef TCL_STORAGE_CLASS
+# define TCL_STORAGE_CLASS DLLIMPORT
+# endif
#endif
/*
@@ -125,14 +124,14 @@ extern "C" {
* Dummy types that are used by clients:
*/
-#define Tk_ImageModel Tk_ImageMaster
+#define Tk_ImageMaster Tk_ImageModel
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_ImageModel_ *Tk_ImageModel;
typedef struct Tk_OptionTable_ *Tk_OptionTable;
typedef struct Tk_PostscriptInfo_ *Tk_PostscriptInfo;
typedef struct Tk_TextLayout_ *Tk_TextLayout;
@@ -147,6 +146,15 @@ typedef struct Tk_StyledElement_ *Tk_StyledElement;
*/
typedef const char *Tk_Uid;
+
+#if (TCL_MAJOR_VERSION < 9) && (TCL_MINOR_VERSION < 7)
+# ifndef Tcl_Size
+# define Tcl_Size int
+# endif
+# define TCL_SIZE_MAX INT_MAX
+# define TCL_SIZE_MODIFIER ""
+# define TCL_ENCODING_PROFILE_TCL8 0x01000000
+#endif
/*
*----------------------------------------------------------------------
@@ -174,7 +182,8 @@ typedef enum {
TK_OPTION_WINDOW,
TK_OPTION_END,
TK_OPTION_CUSTOM,
- TK_OPTION_STYLE
+ TK_OPTION_STYLE,
+ TK_OPTION_INDEX
} Tk_OptionType;
/*
@@ -195,20 +204,20 @@ typedef struct Tk_OptionSpec {
const char *defValue; /* Default value for option if not specified
* in command line, the option database, or
* the system. */
- int objOffset; /* Where in record to store a Tcl_Obj * that
+ Tcl_Size objOffset; /* Where in record to store a Tcl_Obj * that
* holds the value of this option, specified
* as an offset in bytes from the start of the
- * record. Use the Tk_Offset macro to generate
- * values for this. -1 means don't store the
- * Tcl_Obj in the record. */
- int internalOffset; /* Where in record to store the internal
+ * record. Use the offsetof macro to generate
+ * values for this. TCL_INDEX_NONE means don't
+ * store the Tcl_Obj in the record. */
+ Tcl_Size internalOffset; /* Where in record to store the internal
* representation of the value of this option,
* such as an int or XColor *. This field is
* specified as an offset in bytes from the
- * start of the record. Use the Tk_Offset
- * macro to generate values for it. -1 means
- * don't store the internal representation in
- * the record. */
+ * start of the record. Use the offsetof
+ * macro to generate values for it.
+ * TCL_INDEX_NONE means don't store the
+ * internal representation in the record. */
int flags; /* Any combination of the values defined
* below. */
const void *clientData; /* An alternate place to put option-specific
@@ -228,8 +237,14 @@ typedef struct Tk_OptionSpec {
* Tk_ConfigSpec structures, so be sure to coordinate any changes carefully.
*/
-#define TK_OPTION_NULL_OK (1 << 0)
#define TK_OPTION_DONT_SET_DEFAULT (1 << 3)
+#if TCL_MAJOR_VERSION > 8
+# define TK_OPTION_NULL_OK TCL_NULL_OK
+#else
+# define TK_OPTION_NULL_OK (1 << 0)
+#endif
+#define TK_OPTION_VAR(type) ((sizeof(type) < 2 * sizeof(int)) ? ((int)(sizeof(type)&(sizeof(int)-1))<<6) : (3<<6))
+#define TK_OPTION_ENUM_VAR TK_OPTION_VAR(Tk_OptionType)
/*
* The following structure and function types are used by TK_OPTION_CUSTOM
@@ -237,14 +252,14 @@ typedef struct Tk_OptionSpec {
* option config code to handle a custom option.
*/
-typedef int (Tk_CustomOptionSetProc) (ClientData clientData,
+typedef int (Tk_CustomOptionSetProc) (void *clientData,
Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj **value, char *widgRec,
- int offset, char *saveInternalPtr, int flags);
-typedef Tcl_Obj *(Tk_CustomOptionGetProc) (ClientData clientData,
- Tk_Window tkwin, char *widgRec, int offset);
-typedef void (Tk_CustomOptionRestoreProc) (ClientData clientData,
+ Tcl_Size offset, char *saveInternalPtr, int flags);
+typedef Tcl_Obj *(Tk_CustomOptionGetProc) (void *clientData,
+ Tk_Window tkwin, char *widgRec, Tcl_Size offset);
+typedef void (Tk_CustomOptionRestoreProc) (void *clientData,
Tk_Window tkwin, char *internalPtr, char *saveInternalPtr);
-typedef void (Tk_CustomOptionFreeProc) (ClientData clientData, Tk_Window tkwin,
+typedef void (Tk_CustomOptionFreeProc) (void *clientData, Tk_Window tkwin,
char *internalPtr);
typedef struct Tk_ObjCustomOption {
@@ -262,7 +277,7 @@ typedef struct Tk_ObjCustomOption {
Tk_CustomOptionFreeProc *freeProc;
/* Function to use to free the internal
* representation of an option. */
- ClientData clientData; /* Arbitrary one-word value passed to the
+ void *clientData; /* Arbitrary one-word value passed to the
* handling procs. */
} Tk_ObjCustomOption;
@@ -271,10 +286,8 @@ typedef struct Tk_ObjCustomOption {
* Computes number of bytes from beginning of structure to a given field.
*/
-#define Tk_Offset(type, field) ((int) offsetof(type, field))
-/* Workaround for platforms missing offsetof(), e.g. VC++ 6.0 */
-#ifndef offsetof
-# define offsetof(type, field) ((size_t) ((char *) &((type *) 0)->field))
+#if !defined(TK_NO_DEPRECATED) && (TK_MAJOR_VERSION < 9) && !defined(BUILD_tk)
+# define Tk_Offset(type, field) ((int) offsetof(type, field))
#endif
/*
@@ -292,16 +305,20 @@ typedef struct Tk_SavedOption {
Tcl_Obj *valuePtr; /* The old value of the option, in the form of
* a Tcl object; may be NULL if the value was
* not saved as an object. */
+#if TCL_MAJOR_VERSION < 9
double internalForm; /* The old value of the option, in some
* internal representation such as an int or
* (XColor *). Valid only if the field
- * optionPtr->specPtr->objOffset is < 0. The
+ * optionPtr->specPtr->objOffset is -1. The
* space must be large enough to accommodate a
- * double, a long, or a pointer; right now it
- * looks like a double (i.e., 8 bytes) is big
- * enough. Also, using a double guarantees
- * that the field is properly aligned for
- * storing large values. */
+ * long double, a double, a long, or a pointer;
+ * right now it looks like a long double (i.e., 16
+ * bytes) is big enough. Also, using a long double
+ * guarantees that the field is properly aligned
+ * for storing large values. */
+#else
+ long double internalForm;
+#endif
} Tk_SavedOption;
#ifdef TCL_MEM_DEBUG
@@ -311,11 +328,11 @@ typedef struct Tk_SavedOption {
#endif
typedef struct Tk_SavedOptions {
- char *recordPtr; /* The data structure in which to restore
+ void *recordPtr; /* The data structure in which to restore
* configuration options. */
Tk_Window tkwin; /* Window associated with recordPtr; needed to
* restore certain options. */
- int numItems; /* The number of valid items in items field. */
+ Tcl_Size numItems; /* The number of valid items in items field. */
Tk_SavedOption items[TK_NUM_SAVED_OPTIONS];
/* Items used to hold old values. */
struct Tk_SavedOptions *nextPtr;
@@ -339,10 +356,10 @@ typedef struct Tk_SavedOptions {
#ifndef __NO_OLD_CONFIG
-typedef int (Tk_OptionParseProc) (ClientData clientData, Tcl_Interp *interp,
- Tk_Window tkwin, CONST84 char *value, char *widgRec, int offset);
-typedef CONST86 char *(Tk_OptionPrintProc) (ClientData clientData,
- Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr);
+typedef int (Tk_OptionParseProc) (void *clientData, Tcl_Interp *interp,
+ Tk_Window tkwin, const char *value, char *widgRec, Tcl_Size offset);
+typedef const char *(Tk_OptionPrintProc) (void *clientData,
+ Tk_Window tkwin, char *widgRec, Tcl_Size offset, Tcl_FreeProc **freeProcPtr);
typedef struct Tk_CustomOption {
Tk_OptionParseProc *parseProc;
@@ -351,7 +368,7 @@ typedef struct Tk_CustomOption {
Tk_OptionPrintProc *printProc;
/* Procedure to return a printable string
* describing an existing option. */
- ClientData clientData; /* Arbitrary one-word value used by option
+ void *clientData; /* Arbitrary one-word value used by option
* parser: passed to parseProc and
* printProc. */
} Tk_CustomOption;
@@ -367,19 +384,19 @@ 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. */
- CONST86 char *argvName; /* Switch used to specify option in argv. NULL
+ const char *argvName; /* Switch used to specify option in argv. NULL
* means this spec is part of a group. */
Tk_Uid dbName; /* Name for option in option database. */
Tk_Uid dbClass; /* Class for option in database. */
Tk_Uid defValue; /* Default value for option if not specified
* in command line or database. */
- int offset; /* Where in widget record to store value; use
- * Tk_Offset macro to generate values for
+ Tcl_Size offset; /* Where in widget record to store value; use
+ * offsetof macro to generate values for
* this. */
int specFlags; /* Any combination of the values defined
* below; other bits are used internally by
* tkConfig.c. */
- CONST86 Tk_CustomOption *customPtr;
+ const 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
@@ -415,11 +432,17 @@ typedef enum {
* (internal-use-only flags are defined there).
*/
-#define TK_CONFIG_NULL_OK (1 << 0)
#define TK_CONFIG_COLOR_ONLY (1 << 1)
#define TK_CONFIG_MONO_ONLY (1 << 2)
#define TK_CONFIG_DONT_SET_DEFAULT (1 << 3)
-#define TK_CONFIG_OPTION_SPECIFIED (1 << 4)
+#ifndef TK_NO_DEPRECATED
+# define TK_CONFIG_OPTION_SPECIFIED (1 << 4)
+#endif /* !TK_NO_DEPRECATED */
+#if TCL_MAJOR_VERSION > 8
+# define TK_CONFIG_NULL_OK TCL_NULL_OK
+#else
+# define TK_CONFIG_NULL_OK (1 << 0)
+#endif
#define TK_CONFIG_USER_BIT 0x100
#endif /* __NO_OLD_CONFIG */
@@ -428,14 +451,14 @@ typedef enum {
*/
typedef struct {
- CONST86 char *key; /* The key string that flags the option in the
+ const char *key; /* The key string that flags the option in the
* argv array. */
int type; /* Indicates option type; see below. */
- char *src; /* Value to be used in setting dst; usage
+ void *src; /* Value to be used in setting dst; usage
* depends on type. */
- char *dst; /* Address of value to be modified; usage
+ void *dst; /* Address of value to be modified; usage
* depends on type. */
- CONST86 char *help; /* Documentation message describing this
+ const char *help; /* Documentation message describing this
* option. */
} Tk_ArgvInfo;
@@ -520,6 +543,7 @@ typedef enum {
*/
typedef enum {
+ TK_ANCHOR_NULL = -1,
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
@@ -530,6 +554,7 @@ typedef enum {
*/
typedef enum {
+ TK_JUSTIFY_NULL = -1,
TK_JUSTIFY_LEFT, TK_JUSTIFY_RIGHT, TK_JUSTIFY_CENTER
} Tk_Justify;
@@ -575,12 +600,12 @@ typedef struct Tk_FontMetrics {
*/
typedef Window (Tk_ClassCreateProc) (Tk_Window tkwin, Window parent,
- ClientData instanceData);
-typedef void (Tk_ClassWorldChangedProc) (ClientData instanceData);
+ void *instanceData);
+typedef void (Tk_ClassWorldChangedProc) (void *instanceData);
typedef void (Tk_ClassModalProc) (Tk_Window tkwin, XEvent *eventPtr);
typedef struct Tk_ClassProcs {
- unsigned int size;
+ Tcl_Size size;
Tk_ClassWorldChangedProc *worldChangedProc;
/* Procedure to invoke when the widget needs
* to respond in some way to a change in the
@@ -605,12 +630,12 @@ typedef struct Tk_ClassProcs {
*
* #define Tk_GetField(name, who, which) \
* (((who) == NULL) ? NULL :
- * (((who)->size <= Tk_Offset(name, which)) ? NULL :(name)->which))
+ * (((size_t)(who)->size <= offsetof(name, which)) ? NULL :(name)->which))
*/
#define Tk_GetClassProc(procs, which) \
(((procs) == NULL) ? NULL : \
- (((procs)->size <= Tk_Offset(Tk_ClassProcs, which)) ? NULL:(procs)->which))
+ (((size_t)(procs)->size <= offsetof(Tk_ClassProcs, which)) ? NULL:(procs)->which))
/*
* Each geometry manager (the packer, the placer, etc.) is represented by a
@@ -618,9 +643,9 @@ typedef struct Tk_ClassProcs {
* the geometry manager to carry out certain functions.
*/
-#define Tk_GeomLostContentProc Tk_GeomLostSlaveProc
-typedef void (Tk_GeomRequestProc) (ClientData clientData, Tk_Window tkwin);
-typedef void (Tk_GeomLostContentProc) (ClientData clientData, Tk_Window tkwin);
+#define Tk_GeomLostSlaveProc Tk_GeomLostContentProc
+typedef void (Tk_GeomRequestProc) (void *clientData, Tk_Window tkwin);
+typedef void (Tk_GeomLostContentProc) (void *clientData, Tk_Window tkwin);
typedef struct Tk_GeomMgr {
const char *name; /* Name of the geometry manager (command used
@@ -629,7 +654,7 @@ typedef struct Tk_GeomMgr {
Tk_GeomRequestProc *requestProc;
/* Procedure to invoke when a content's
* requested geometry changes. */
- Tk_GeomLostContentProc *lostSlaveProc;
+ Tk_GeomLostContentProc *lostContentProc;
/* Procedure to invoke when content is taken
* away from one geometry manager by another.
* NULL means geometry manager doesn't care
@@ -657,8 +682,10 @@ typedef struct Tk_GeomMgr {
#define ActivateNotify (MappingNotify + 2)
#define DeactivateNotify (MappingNotify + 3)
#define MouseWheelEvent (MappingNotify + 4)
-#define TK_LASTEVENT (MappingNotify + 5)
+#define TouchpadScroll (MappingNotify + 5)
+#define TK_LASTEVENT (MappingNotify + 6)
+#define TouchpadScrollMask (1L << 27)
#define MouseWheelMask (1L << 28)
#define ActivateMask (1L << 29)
#define VirtualEventMask (1L << 30)
@@ -752,9 +779,10 @@ typedef XActivateDeactivateEvent XDeactivateEvent;
(((Tk_FakeWin *) (tkwin))->flags & TK_WM_MANAGEABLE)
#define Tk_ReqWidth(tkwin) (((Tk_FakeWin *) (tkwin))->reqWidth)
#define Tk_ReqHeight(tkwin) (((Tk_FakeWin *) (tkwin))->reqHeight)
-/* Tk_InternalBorderWidth is deprecated */
+#ifndef TK_NO_DEPRECATED
#define Tk_InternalBorderWidth(tkwin) \
(((Tk_FakeWin *) (tkwin))->internalBorderLeft)
+#endif /* !TK_NO_DEPRECATED */
#define Tk_InternalBorderLeft(tkwin) \
(((Tk_FakeWin *) (tkwin))->internalBorderLeft)
#define Tk_InternalBorderRight(tkwin) \
@@ -799,31 +827,35 @@ typedef struct Tk_FakeWin {
unsigned long dummy7; /* dirtyAtts */
unsigned int flags;
char *dummy8; /* handlerList */
-#ifdef TK_USE_INPUT_METHODS
+#if defined(TK_USE_INPUT_METHODS) || (TCL_MAJOR_VERSION > 8)
XIC dummy9; /* inputContext */
#endif /* TK_USE_INPUT_METHODS */
- ClientData *dummy10; /* tagPtr */
- int dummy11; /* numTags */
- int dummy12; /* optionLevel */
+ void **dummy10; /* tagPtr */
+ Tcl_Size dummy11; /* numTags */
+ Tcl_Size dummy12; /* optionLevel */
char *dummy13; /* selHandlerList */
char *dummy14; /* geomMgrPtr */
- ClientData dummy15; /* geomData */
+ void *dummy15; /* geomData */
int reqWidth, reqHeight;
int internalBorderLeft;
char *dummy16; /* wmInfoPtr */
char *dummy17; /* classProcPtr */
- ClientData dummy18; /* instanceData */
+ void *dummy18; /* instanceData */
char *dummy19; /* privatePtr */
int internalBorderRight;
int internalBorderTop;
int internalBorderBottom;
int minReqWidth;
int minReqHeight;
-#ifdef TK_USE_INPUT_METHODS
+#if defined(TK_USE_INPUT_METHODS) || (TCL_MAJOR_VERSION > 8)
int dummy20;
#endif /* TK_USE_INPUT_METHODS */
char *dummy21; /* geomMgrName */
Tk_Window dummy22; /* maintainerPtr */
+#if !defined(TK_USE_INPUT_METHODS) && (TCL_MAJOR_VERSION < 9)
+ XIC dummy9; /* inputContext */
+ int dummy20;
+#endif /* TK_USE_INPUT_METHODS */
} Tk_FakeWin;
/*
@@ -931,7 +963,7 @@ typedef enum {
} Tk_State;
typedef struct Tk_SmoothMethod {
- CONST86 char *name;
+ const char *name;
int (*coordProc) (Tk_Canvas canvas, double *pointPtr, int numPoints,
int numSteps, XPoint xPoints[], double dblPoints[]);
void (*postscriptProc) (Tcl_Interp *interp, Tk_Canvas canvas,
@@ -947,7 +979,7 @@ typedef struct Tk_SmoothMethod {
#define TK_TAG_SPACE 3
typedef struct Tk_Item {
- int id; /* Unique identifier for this item (also
+ Tcl_Size 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
@@ -957,9 +989,9 @@ typedef struct Tk_Item {
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
+ Tcl_Size tagSpace; /* Total amount of tag space available at
* tagPtr. */
- int numTags; /* Number of tag slots actually used at
+ Tcl_Size numTags; /* Number of tag slots actually used at
* *tagPtr. */
struct Tk_ItemType *typePtr;/* Table of procedures that implement this
* type of item. */
@@ -1003,21 +1035,29 @@ typedef struct Tk_Item {
* lines, circles, etc.) that can form part of a canvas widget.
*/
-#ifdef USE_OLD_CANVAS
+#if defined(USE_OLD_CANVAS) && TCL_MAJOR_VERSION < 9
typedef int (Tk_ItemCreateProc)(Tcl_Interp *interp, Tk_Canvas canvas,
- Tk_Item *itemPtr, int argc, char **argv);
+ Tk_Item *itemPtr, Tcl_Size argc, char **argv);
typedef int (Tk_ItemConfigureProc)(Tcl_Interp *interp, Tk_Canvas canvas,
- Tk_Item *itemPtr, int argc, char **argv, int flags);
+ Tk_Item *itemPtr, Tcl_Size argc, char **argv, int flags);
typedef int (Tk_ItemCoordProc)(Tcl_Interp *interp, Tk_Canvas canvas,
- Tk_Item *itemPtr, int argc, char **argv);
+ Tk_Item *itemPtr, Tcl_Size argc, char **argv);
+typedef void (Tk_ItemInsertProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
+ int beforeThis, char *string);
+typedef int (Tk_ItemIndexProc)(Tcl_Interp *interp, Tk_Canvas canvas,
+ Tk_Item *itemPtr, char *indexString, int *indexPtr);
#else
typedef int (Tk_ItemCreateProc)(Tcl_Interp *interp, Tk_Canvas canvas,
- Tk_Item *itemPtr, int objc, Tcl_Obj *const objv[]);
+ Tk_Item *itemPtr, Tcl_Size objc, Tcl_Obj *const objv[]);
typedef int (Tk_ItemConfigureProc)(Tcl_Interp *interp, Tk_Canvas canvas,
- Tk_Item *itemPtr, int objc, Tcl_Obj *const objv[],
+ Tk_Item *itemPtr, Tcl_Size objc, Tcl_Obj *const objv[],
int flags);
typedef int (Tk_ItemCoordProc)(Tcl_Interp *interp, Tk_Canvas canvas,
- Tk_Item *itemPtr, int objc, Tcl_Obj *const objv[]);
+ Tk_Item *itemPtr, Tcl_Size objc, Tcl_Obj *const objv[]);
+typedef void (Tk_ItemInsertProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
+ Tcl_Size beforeThis, Tcl_Obj *string);
+typedef int (Tk_ItemIndexProc)(Tcl_Interp *interp, Tk_Canvas canvas,
+ Tk_Item *itemPtr, Tcl_Obj *indexString, Tcl_Size *indexPtr);
#endif /* USE_OLD_CANVAS */
typedef void (Tk_ItemDeleteProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
Display *display);
@@ -1030,43 +1070,31 @@ typedef int (Tk_ItemAreaProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
double *rectPtr);
typedef int (Tk_ItemPostscriptProc)(Tcl_Interp *interp, Tk_Canvas canvas,
Tk_Item *itemPtr, int prepass);
+typedef void (Tk_ItemRotateProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
+ double originX, double originY, double angleRadians);
typedef void (Tk_ItemScaleProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
double originX, double originY, double scaleX,
double scaleY);
typedef void (Tk_ItemTranslateProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
double deltaX, double deltaY);
-#ifdef USE_OLD_CANVAS
-typedef int (Tk_ItemIndexProc)(Tcl_Interp *interp, Tk_Canvas canvas,
- Tk_Item *itemPtr, char *indexString, int *indexPtr);
-#else
-typedef int (Tk_ItemIndexProc)(Tcl_Interp *interp, Tk_Canvas canvas,
- Tk_Item *itemPtr, Tcl_Obj *indexString, int *indexPtr);
-#endif /* USE_OLD_CANVAS */
typedef void (Tk_ItemCursorProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
- int index);
-typedef int (Tk_ItemSelectionProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
- int offset, char *buffer, int maxBytes);
-#ifdef USE_OLD_CANVAS
-typedef void (Tk_ItemInsertProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
- int beforeThis, char *string);
-#else
-typedef void (Tk_ItemInsertProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
- int beforeThis, Tcl_Obj *string);
-#endif /* USE_OLD_CANVAS */
+ Tcl_Size index);
+typedef Tcl_Size (Tk_ItemSelectionProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
+ Tcl_Size offset, char *buffer, Tcl_Size maxBytes);
typedef void (Tk_ItemDCharsProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
- int first, int last);
+ Tcl_Size first, Tcl_Size last);
#ifndef __NO_OLD_CONFIG
typedef struct Tk_ItemType {
- CONST86 char *name; /* The name of this type of item, such as
+ const char *name; /* The name of this type of item, such as
* "line". */
- int itemSize; /* Total amount of space needed for item's
+ Tcl_Size itemSize; /* Total amount of space needed for item's
* record. */
Tk_ItemCreateProc *createProc;
/* Procedure to create a new item of this
* type. */
- CONST86 Tk_ConfigSpec *configSpecs; /* Pointer to array of configuration specs for
+ const Tk_ConfigSpec *configSpecs; /* Pointer to array of configuration specs for
* this type. Used for returning configuration
* info. */
Tk_ItemConfigureProc *configProc;
@@ -1109,7 +1137,9 @@ typedef struct Tk_ItemType {
/* Procedure to delete characters from an
* item. */
struct Tk_ItemType *nextPtr;/* Used to link types together into a list. */
- char *reserved1; /* Reserved for future extension. */
+ Tk_ItemRotateProc *rotateProc;
+ /* Procedure to rotate an item's coordinates
+ * about a point. */
int reserved2; /* Carefully compatible with */
char *reserved3; /* Jan Nijtmans dash patch */
char *reserved4;
@@ -1120,7 +1150,8 @@ typedef struct Tk_ItemType {
* point-level manipulation like the line and polygon items.
*/
-#define TK_MOVABLE_POINTS 2
+#define TK_ALWAYS_REDRAW 1 /* item should be redrawn always*/
+#define TK_MOVABLE_POINTS 2 /* item supports point-level manipulation */
#endif /* __NO_OLD_CONFIG */
@@ -1142,14 +1173,14 @@ typedef struct Tk_CanvasTextInfo {
Tk_Item *selItemPtr; /* Pointer to selected item. NULL means
* selection isn't in this canvas. Writable by
* items. */
- int selectFirst; /* Character index of first selected
+ Tcl_Size selectFirst; /* Character index of first selected
* character. Writable by items. */
- int selectLast; /* Character index of last selected character.
+ Tcl_Size selectLast; /* Character index of last selected character.
* Writable by items. */
Tk_Item *anchorItemPtr; /* Item corresponding to "selectAnchor": not
* necessarily selItemPtr. Read-only to
* items. */
- int selectAnchor; /* Character index of fixed end of selection
+ Tcl_Size selectAnchor; /* Character index of fixed end of selection
* (i.e. "select to" operation will use this
* as one end of the selection). Writable by
* items. */
@@ -1231,24 +1262,24 @@ typedef struct Tk_Outline {
*/
typedef struct Tk_ImageType Tk_ImageType;
-#ifdef USE_OLD_IMAGE
-typedef int (Tk_ImageCreateProc) (Tcl_Interp *interp, char *name, int argc,
- char **argv, Tk_ImageType *typePtr, Tk_ImageMaster model,
- ClientData *clientDataPtr);
+#if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9 && defined(USE_OLD_IMAGE)
+typedef int (Tk_ImageCreateProc) (Tcl_Interp *interp, char *name, Tcl_Size argc,
+ char **argv, Tk_ImageType *typePtr, Tk_ImageModel model,
+ void **clientDataPtr);
#else
-typedef int (Tk_ImageCreateProc) (Tcl_Interp *interp, CONST86 char *name, int objc,
- Tcl_Obj *const objv[], CONST86 Tk_ImageType *typePtr, Tk_ImageMaster model,
- ClientData *clientDataPtr);
+typedef int (Tk_ImageCreateProc) (Tcl_Interp *interp, const char *name, Tcl_Size objc,
+ Tcl_Obj *const objv[], const Tk_ImageType *typePtr, Tk_ImageModel model,
+ void **clientDataPtr);
#endif /* USE_OLD_IMAGE */
-typedef ClientData (Tk_ImageGetProc) (Tk_Window tkwin, ClientData clientData);
-typedef void (Tk_ImageDisplayProc) (ClientData clientData, Display *display,
+typedef void *(Tk_ImageGetProc) (Tk_Window tkwin, void *clientData);
+typedef void (Tk_ImageDisplayProc) (void *clientData, Display *display,
Drawable drawable, int imageX, int imageY, int width, int height,
int drawableX, int drawableY);
-typedef void (Tk_ImageFreeProc) (ClientData clientData, Display *display);
-typedef void (Tk_ImageDeleteProc) (ClientData clientData);
-typedef void (Tk_ImageChangedProc) (ClientData clientData, int x, int y,
+typedef void (Tk_ImageFreeProc) (void *clientData, Display *display);
+typedef void (Tk_ImageDeleteProc) (void *clientData);
+typedef void (Tk_ImageChangedProc) (void *clientData, int x, int y,
int width, int height, int imageWidth, int imageHeight);
-typedef int (Tk_ImagePostscriptProc) (ClientData clientData,
+typedef int (Tk_ImagePostscriptProc) (void *clientData,
Tcl_Interp *interp, Tk_Window tkwin, Tk_PostscriptInfo psinfo,
int x, int y, int width, int height, int prepass);
@@ -1261,7 +1292,7 @@ typedef int (Tk_ImagePostscriptProc) (ClientData clientData,
*/
struct Tk_ImageType {
- CONST86 char *name; /* Name of image type. */
+ const char *name; /* Name of image type. */
Tk_ImageCreateProc *createProc;
/* Procedure to call to create a new image of
* this type. */
@@ -1367,13 +1398,43 @@ typedef int (Tk_ImageStringWriteProc) (Tcl_Interp *interp, Tcl_Obj *format,
#endif /* USE_OLD_IMAGE */
/*
+ * The following alternate definitions are used with the Tk8.7 file format
+ * supporting a metadata dict, internal dstring and close file flag
+ */
+
+typedef struct Tk_PhotoImageFormatVersion3 Tk_PhotoImageFormatVersion3;
+typedef int (Tk_ImageFileMatchProcVersion3) (Tcl_Interp *interp,
+ Tcl_Channel chan, const char *fileName, Tcl_Obj *format,
+ Tcl_Obj *metadataIn, int *widthPtr, int *heightPtr,
+ Tcl_Obj *metadataOut);
+typedef int (Tk_ImageStringMatchProcVersion3) (Tcl_Interp *interp,
+ Tcl_Obj *dataObj, Tcl_Obj *format, Tcl_Obj *metadataIn, int *widthPtr,
+ int *heightPtr, Tcl_Obj *metadataOut);
+typedef int (Tk_ImageFileReadProcVersion3) (Tcl_Interp *interp,
+ Tcl_Channel chan,
+ const char *fileName, Tcl_Obj *format, Tcl_Obj *metadataIn,
+ Tk_PhotoHandle imageHandle,
+ int destX, int destY, int width, int height, int srcX, int srcY,
+ Tcl_Obj *metadataOut);
+typedef int (Tk_ImageStringReadProcVersion3) (Tcl_Interp *interp,
+ Tcl_Obj *dataObj, Tcl_Obj *format, Tcl_Obj *metadataIn,
+ Tk_PhotoHandle imageHandle, int destX, int destY, int width, int height,
+ int srcX, int srcY, Tcl_Obj *metadataOut);
+typedef int (Tk_ImageFileWriteProcVersion3) (Tcl_Interp *interp,
+ const char *fileName, Tcl_Obj *format, Tcl_Obj *metadataIn,
+ Tk_PhotoImageBlock *blockPtr);
+typedef int (Tk_ImageStringWriteProcVersion3) (Tcl_Interp *interp,
+ Tcl_Obj *format, Tcl_Obj *metadataIn, 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 {
- CONST86 char *name; /* Name of image file format */
+ const char *name; /* Name of image file format */
Tk_ImageFileMatchProc *fileMatchProc;
/* Procedure to call to determine whether an
* image file matches this format. */
@@ -1398,6 +1459,38 @@ struct Tk_PhotoImageFormat {
* currently known. Filled in by Tk, not by
* image format handler. */
};
+
+/*
+ * The following structure is the same plus added support for the metadata
+ * structure.
+ */
+
+struct Tk_PhotoImageFormatVersion3 {
+ const char *name; /* Name of image file format */
+ Tk_ImageFileMatchProcVersion3 *fileMatchProc;
+ /* Procedure to call to determine whether an
+ * image file matches this format. */
+ Tk_ImageStringMatchProcVersion3 *stringMatchProc;
+ /* Procedure to call to determine whether the
+ * data in a string matches this format. */
+ Tk_ImageFileReadProcVersion3 *fileReadProc;
+ /* Procedure to call to read data from an
+ * image file into a photo image. */
+ Tk_ImageStringReadProcVersion3 *stringReadProc;
+ /* Procedure to call to read data from a
+ * string into a photo image. */
+ Tk_ImageFileWriteProcVersion3 *fileWriteProc;
+ /* Procedure to call to write data from a
+ * photo image to a file. */
+ Tk_ImageStringWriteProcVersion3 *stringWriteProc;
+ /* Procedure to call to obtain a string
+ * representation of the data in a photo
+ * image.*/
+ struct Tk_PhotoImageFormatVersion3 *nextPtr;
+ /* Next in list of all photo image formats
+ * currently known. Filled in by Tk, not by
+ * image format handler. */
+};
/*
*----------------------------------------------------------------------
@@ -1419,16 +1512,16 @@ struct Tk_PhotoImageFormat {
* declare widget elements.
*/
-typedef void (Tk_GetElementSizeProc) (ClientData clientData, char *recordPtr,
+typedef void (Tk_GetElementSizeProc) (void *clientData, char *recordPtr,
const Tk_OptionSpec **optionsPtr, Tk_Window tkwin, int width,
int height, int inner, int *widthPtr, int *heightPtr);
-typedef void (Tk_GetElementBoxProc) (ClientData clientData, char *recordPtr,
+typedef void (Tk_GetElementBoxProc) (void *clientData, char *recordPtr,
const Tk_OptionSpec **optionsPtr, Tk_Window tkwin, int x, int y,
int width, int height, int inner, int *xPtr, int *yPtr, int *widthPtr,
int *heightPtr);
-typedef int (Tk_GetElementBorderWidthProc) (ClientData clientData,
+typedef int (Tk_GetElementBorderWidthProc) (void *clientData,
char *recordPtr, const Tk_OptionSpec **optionsPtr, Tk_Window tkwin);
-typedef void (Tk_DrawElementProc) (ClientData clientData, char *recordPtr,
+typedef void (Tk_DrawElementProc) (void *clientData, char *recordPtr,
const Tk_OptionSpec **optionsPtr, Tk_Window tkwin, Drawable d, int x,
int y, int width, int height, int state);
@@ -1471,12 +1564,12 @@ typedef struct Tk_ElementSpec {
*----------------------------------------------------------------------
*
* 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.
+ * types that used to be in Tk but have moved to Tcl.
*
*----------------------------------------------------------------------
*/
+#if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
#define TK_READABLE TCL_READABLE
#define TK_WRITABLE TCL_WRITABLE
#define TK_EXCEPTION TCL_EXCEPTION
@@ -1511,6 +1604,11 @@ typedef struct Tk_ElementSpec {
#define Tk_Preserve Tcl_Preserve
#define Tk_Release Tcl_Release
+/* Related to USE_OLD_IMAGE: */
+
+#define Tk_InitImageArgs(interp, argc, argv) /**/
+#endif
+
/* Removed Tk_Main, use macro instead */
#if defined(_WIN32) || defined(__CYGWIN__)
#define Tk_Main(argc, argv, proc) Tk_MainEx(argc, argv, proc, \
@@ -1528,8 +1626,6 @@ EXTERN const char * Tk_PkgInitStubsCheck(Tcl_Interp *interp,
#define Tk_InitStubs(interp, version, exact) \
Tk_PkgInitStubsCheck(interp, version, exact)
#endif /* USE_TK_STUBS */
-
-#define Tk_InitImageArgs(interp, argc, argv) /**/
/*
*----------------------------------------------------------------------
@@ -1539,17 +1635,17 @@ EXTERN const char * Tk_PkgInitStubsCheck(Tcl_Interp *interp,
*----------------------------------------------------------------------
*/
-typedef int (Tk_ErrorProc) (ClientData clientData, XErrorEvent *errEventPtr);
-typedef void (Tk_EventProc) (ClientData clientData, XEvent *eventPtr);
-typedef int (Tk_GenericProc) (ClientData clientData, XEvent *eventPtr);
+typedef int (Tk_ErrorProc) (void *clientData, XErrorEvent *errEventPtr);
+typedef void (Tk_EventProc) (void *clientData, XEvent *eventPtr);
+typedef int (Tk_GenericProc) (void *clientData, XEvent *eventPtr);
typedef int (Tk_ClientMessageProc) (Tk_Window tkwin, XEvent *eventPtr);
-typedef int (Tk_GetSelProc) (ClientData clientData, Tcl_Interp *interp,
- CONST86 char *portion);
-typedef void (Tk_LostSelProc) (ClientData clientData);
-typedef Tk_RestrictAction (Tk_RestrictProc) (ClientData clientData,
+typedef int (Tk_GetSelProc) (void *clientData, Tcl_Interp *interp,
+ const char *portion);
+typedef void (Tk_LostSelProc) (void *clientData);
+typedef Tk_RestrictAction (Tk_RestrictProc) (void *clientData,
XEvent *eventPtr);
-typedef int (Tk_SelectionProc) (ClientData clientData, int offset,
- char *buffer, int maxBytes);
+typedef Tcl_Size (Tk_SelectionProc) (void *clientData, Tcl_Size offset,
+ char *buffer, Tcl_Size maxBytes);
/*
*----------------------------------------------------------------------
@@ -1572,12 +1668,13 @@ typedef int (Tk_SelectionProc) (ClientData clientData, int offset,
*----------------------------------------------------------------------
*
* Allow users to say that they don't want to alter their source to add extra
- * arguments to Tk_PhotoPutBlock() et al; DO NOT DEFINE THIS WHEN BUILDING TK.
+ * arguments to Tk_PhotoPutBlock() et al.
*
* This goes after the inclusion of the stubbed-decls so that the declarations
* of what is actually there can be correct.
*/
+#if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
#ifdef USE_COMPOSITELESS_PHOTO_PUT_BLOCK
# ifdef Tk_PhotoPutBlock
# undef Tk_PhotoPutBlock
@@ -1610,6 +1707,7 @@ typedef int (Tk_SelectionProc) (ClientData clientData, int offset,
# endif
# define Tk_PhotoSetSize Tk_PhotoSetSize_Panic
#endif /* USE_PANIC_ON_PHOTO_ALLOC_FAILURE */
+#endif /* !TK_NO_DEPRECATED */
#undef TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS DLLIMPORT
diff --git a/generic/tk3d.c b/generic/tk3d.c
index 65980e6..be7ba9b 100644
--- a/generic/tk3d.c
+++ b/generic/tk3d.c
@@ -4,8 +4,8 @@
* 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.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 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.
@@ -19,7 +19,7 @@
* by Tk_GetReliefFromObj.
*/
-static const char *const reliefStrings[] = {
+const char *const tkReliefStrings[] = {
"flat", "groove", "raised", "ridge", "solid", "sunken", NULL
};
@@ -46,12 +46,14 @@ static void ShiftLine(XPoint *p1Ptr, XPoint *p2Ptr,
* is set.
*/
-const Tcl_ObjType tkBorderObjType = {
- "border", /* name */
+const TkObjType tkBorderObjType = {
+ {"border", /* name */
FreeBorderObjProc, /* freeIntRepProc */
DupBorderObjProc, /* dupIntRepProc */
NULL, /* updateStringProc */
- NULL /* setFromAnyProc */
+ NULL, /* setFromAnyProc */
+ TCL_OBJTYPE_V0},
+ 0
};
/*
@@ -87,7 +89,7 @@ Tk_Alloc3DBorderFromObj(
{
TkBorder *borderPtr;
- if (objPtr->typePtr != &tkBorderObjType) {
+ if (objPtr->typePtr != &tkBorderObjType.objType) {
InitBorderObj(objPtr);
}
borderPtr = (TkBorder *)objPtr->internalRep.twoPtrValue.ptr1;
@@ -623,7 +625,7 @@ Tk_GetReliefFromObj(
* from. */
int *resultPtr) /* Where to place the answer. */
{
- return Tcl_GetIndexFromObjStruct(interp, objPtr, reliefStrings,
+ return Tcl_GetIndexFromObjStruct(interp, objPtr, tkReliefStrings,
sizeof(char *), "relief", 0, resultPtr);
}
@@ -678,7 +680,7 @@ Tk_GetRelief(
Tcl_SetObjResult(interp,
Tcl_ObjPrintf("bad relief \"%.50s\": must be %s",
name, "flat, groove, raised, ridge, solid, or sunken"));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "RELIEF", NULL);
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "RELIEF", (char *)NULL);
}
return TCL_ERROR;
}
@@ -755,7 +757,7 @@ Tk_Draw3DPolygon(
XPoint *pointPtr, /* Array of points describing polygon. All
* points must be absolute
* (CoordModeOrigin). */
- int numPoints, /* Number of points at *pointPtr. */
+ Tcl_Size 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. */
@@ -768,7 +770,8 @@ Tk_Draw3DPolygon(
XPoint *p1Ptr, *p2Ptr;
TkBorder *borderPtr = (TkBorder *) border;
GC gc;
- int i, lightOnLeft, dx, dy, parallel, pointsSeen;
+ Tcl_Size i;
+ int lightOnLeft, dx, dy, parallel, pointsSeen;
Display *display = Tk_Display(tkwin);
if (borderPtr->lightGC == NULL) {
@@ -841,9 +844,9 @@ Tk_Draw3DPolygon(
*/
pointsSeen = 0;
- for (i = -2, p1Ptr = &pointPtr[numPoints-2], p2Ptr = p1Ptr+1;
- i < numPoints; i++, p1Ptr = p2Ptr, p2Ptr++) {
- if ((i == -1) || (i == numPoints-1)) {
+ for (i = 0, p1Ptr = &pointPtr[numPoints-2], p2Ptr = p1Ptr+1;
+ i < numPoints + 2; i++, p1Ptr = p2Ptr, p2Ptr++) {
+ if ((i == 1) || (i == numPoints + 1)) {
p2Ptr = pointPtr;
}
if ((p2Ptr->x == p1Ptr->x) && (p2Ptr->y == p1Ptr->y)) {
@@ -1024,7 +1027,7 @@ Tk_Fill3DPolygon(
XPoint *pointPtr, /* Array of points describing polygon. All
* points must be absolute
* (CoordModeOrigin). */
- int numPoints, /* Number of points at *pointPtr. */
+ Tcl_Size 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. */
@@ -1036,7 +1039,7 @@ Tk_Fill3DPolygon(
TkBorder *borderPtr = (TkBorder *) border;
XFillPolygon(Tk_Display(tkwin), drawable, borderPtr->bgGC,
- pointPtr, numPoints, Complex, CoordModeOrigin);
+ pointPtr, (int)numPoints, Complex, CoordModeOrigin);
if (leftRelief != TK_RELIEF_FLAT) {
Tk_Draw3DPolygon(tkwin, drawable, border, pointPtr, numPoints,
borderWidth, leftRelief);
@@ -1249,7 +1252,7 @@ Tk_Get3DBorderFromObj(
Tcl_HashEntry *hashPtr;
TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
- if (objPtr->typePtr != &tkBorderObjType) {
+ if (objPtr->typePtr != &tkBorderObjType.objType) {
InitBorderObj(objPtr);
}
@@ -1341,7 +1344,7 @@ InitBorderObj(
if ((typePtr != NULL) && (typePtr->freeIntRepProc != NULL)) {
typePtr->freeIntRepProc(objPtr);
}
- objPtr->typePtr = &tkBorderObjType;
+ objPtr->typePtr = &tkBorderObjType.objType;
objPtr->internalRep.twoPtrValue.ptr1 = NULL;
}
@@ -1386,14 +1389,48 @@ TkDebugBorder(
Tcl_Obj *objPtr = Tcl_NewObj();
Tcl_ListObjAppendElement(NULL, objPtr,
- Tcl_NewIntObj(borderPtr->resourceRefCount));
+ Tcl_NewWideIntObj(borderPtr->resourceRefCount));
Tcl_ListObjAppendElement(NULL, objPtr,
- Tcl_NewIntObj(borderPtr->objRefCount));
+ Tcl_NewWideIntObj(borderPtr->objRefCount));
Tcl_ListObjAppendElement(NULL, resultPtr, objPtr);
}
}
return resultPtr;
}
+
+/*
+ *--------------------------------------------------------------
+ *
+ * Tk_Get3BorderColors --
+ *
+ * Given a Tk_3DBorder determine its 3 colors.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * None.
+ *
+ *--------------------------------------------------------------
+ */
+
+void
+Tk_Get3DBorderColors(
+ Tk_3DBorder border,
+ XColor *bgColorPtr,
+ XColor *darkColorPtr,
+ XColor *lightColorPtr)
+{
+ if (bgColorPtr) {
+ *bgColorPtr = *((TkBorder *)border)->bgColorPtr;
+ }
+ if (darkColorPtr) {
+ *darkColorPtr = *((TkBorder *) border)->darkColorPtr;
+ }
+ if (lightColorPtr) {
+ *lightColorPtr = *((TkBorder *) border)->lightColorPtr;
+ }
+}
/*
* Local Variables:
diff --git a/generic/tk3d.h b/generic/tk3d.h
index b9deb01..6a93199 100644
--- a/generic/tk3d.h
+++ b/generic/tk3d.h
@@ -3,7 +3,7 @@
*
* Declarations of types and functions shared by the 3d border module.
*
- * Copyright (c) 1996-1997 Sun Microsystems, Inc.
+ * Copyright © 1996-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.
@@ -28,7 +28,7 @@ typedef struct TkBorder {
* the border will be used. */
Colormap colormap; /* Colormap out of which pixels are
* allocated. */
- int resourceRefCount; /* Number of active uses of this color (each
+ Tcl_Size resourceRefCount; /* Number of active uses of this color (each
* active use corresponds to a call to
* Tk_Alloc3DBorderFromObj or Tk_Get3DBorder).
* If this count is 0, then this structure is
@@ -37,7 +37,7 @@ typedef struct TkBorder {
* because there are objects referring to it.
* The structure is freed when objRefCount and
* resourceRefCount are both 0. */
- int objRefCount; /* The number of Tcl objects that reference
+ Tcl_Size objRefCount; /* The number of Tcl objects that reference
* this structure. */
XColor *bgColorPtr; /* Background color (intensity between
* lightColorPtr and darkColorPtr). */
diff --git a/generic/tkArgv.c b/generic/tkArgv.c
index 6bfcedc..134b081 100644
--- a/generic/tkArgv.c
+++ b/generic/tkArgv.c
@@ -4,8 +4,8 @@
* This file contains a function that handles table-based argv-argc
* parsing.
*
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 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.
@@ -83,7 +83,6 @@ Tk_ParseArgv(
* than srcIndex). */
int argc; /* # arguments in argv still to process. */
size_t length; /* Number of characters in current argument. */
- char *endPtr; /* Used for identifying junk in arguments. */
int i;
if (flags & TK_ARGV_DONT_SKIP_FIRST_ARG) {
@@ -143,7 +142,7 @@ Tk_ParseArgv(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"ambiguous option \"%s\"", curArg));
Tcl_SetErrorCode(interp, "TK", "ARG", "AMBIGUOUS", curArg,
- NULL);
+ (char *)NULL);
return TCL_ERROR;
}
matchPtr = infoPtr;
@@ -159,7 +158,7 @@ Tk_ParseArgv(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"unrecognized argument \"%s\"", curArg));
Tcl_SetErrorCode(interp, "TK", "ARG", "UNRECOGNIZED", curArg,
- NULL);
+ (char *)NULL);
return TCL_ERROR;
}
argv[dstIndex] = curArg;
@@ -175,18 +174,13 @@ Tk_ParseArgv(
infoPtr = matchPtr;
switch (infoPtr->type) {
case TK_ARGV_CONSTANT:
- *((int *) infoPtr->dst) = PTR2INT(infoPtr->src);
+ *((int *) infoPtr->dst) = (int)PTR2INT(infoPtr->src);
break;
case TK_ARGV_INT:
if (argc == 0) {
goto missingArg;
}
- *((int *) infoPtr->dst) = strtol(argv[srcIndex], &endPtr, 0);
- if ((endPtr == argv[srcIndex]) || (*endPtr != 0)) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "expected %s argument for \"%s\" but got \"%s\"",
- "integer", infoPtr->key, argv[srcIndex]));
- Tcl_SetErrorCode(interp, "TK", "ARG", "INTEGER", curArg,NULL);
+ if (Tcl_GetInt(interp, argv[srcIndex], (int *) infoPtr->dst) != TCL_OK) {
return TCL_ERROR;
}
srcIndex++;
@@ -215,12 +209,7 @@ Tk_ParseArgv(
if (argc == 0) {
goto missingArg;
}
- *((double *) infoPtr->dst) = strtod(argv[srcIndex], &endPtr);
- if ((endPtr == argv[srcIndex]) || (*endPtr != 0)) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "expected %s argument for \"%s\" but got \"%s\"",
- "floating-point", infoPtr->key, argv[srcIndex]));
- Tcl_SetErrorCode(interp, "TK", "ARG", "FLOAT", curArg, NULL);
+ if (Tcl_GetDouble(interp, argv[srcIndex], ((double *) infoPtr->dst)) != TCL_OK) {
return TCL_ERROR;
}
srcIndex++;
@@ -228,9 +217,9 @@ Tk_ParseArgv(
break;
case TK_ARGV_FUNC: {
typedef int (ArgvFunc)(char *, const char *, const char *);
- ArgvFunc *handlerProc = (ArgvFunc *) infoPtr->src;
+ ArgvFunc *handlerProc = (ArgvFunc *)infoPtr->src;
- if (handlerProc(infoPtr->dst, infoPtr->key, argv[srcIndex])) {
+ if (handlerProc((char *)infoPtr->dst, infoPtr->key, argv[srcIndex])) {
srcIndex++;
argc--;
}
@@ -239,9 +228,9 @@ Tk_ParseArgv(
case TK_ARGV_GENFUNC: {
typedef int (ArgvGenFunc)(char *, Tcl_Interp *, const char *, int,
const char **);
- ArgvGenFunc *handlerProc = (ArgvGenFunc *) infoPtr->src;
+ ArgvGenFunc *handlerProc = (ArgvGenFunc *)infoPtr->src;
- argc = handlerProc(infoPtr->dst, interp, infoPtr->key, argc,
+ argc = handlerProc((char *)infoPtr->dst, interp, infoPtr->key, argc,
argv+srcIndex);
if (argc < 0) {
return TCL_ERROR;
@@ -250,17 +239,17 @@ Tk_ParseArgv(
}
case TK_ARGV_HELP:
PrintUsage(interp, argTable, flags);
- Tcl_SetErrorCode(interp, "TK", "ARG", "HELP", NULL);
+ Tcl_SetErrorCode(interp, "TK", "ARG", "HELP", (char *)NULL);
return TCL_ERROR;
case TK_ARGV_CONST_OPTION:
- Tk_AddOption(tkwin, infoPtr->dst, infoPtr->src,
+ Tk_AddOption(tkwin, (char *)infoPtr->dst, (char *)infoPtr->src,
TK_INTERACTIVE_PRIO);
break;
case TK_ARGV_OPTION_VALUE:
if (argc < 1) {
goto missingArg;
}
- Tk_AddOption(tkwin, infoPtr->dst, argv[srcIndex],
+ Tk_AddOption(tkwin, (char *)infoPtr->dst, argv[srcIndex],
TK_INTERACTIVE_PRIO);
srcIndex++;
argc--;
@@ -271,7 +260,7 @@ Tk_ParseArgv(
"\"%s\" option requires two following arguments",
curArg));
Tcl_SetErrorCode(interp, "TK", "ARG", "NAME_VALUE", curArg,
- NULL);
+ (char *)NULL);
return TCL_ERROR;
}
Tk_AddOption(tkwin, argv[srcIndex], argv[srcIndex+1],
@@ -282,7 +271,7 @@ Tk_ParseArgv(
default:
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad argument type %d in Tk_ArgvInfo", infoPtr->type));
- Tcl_SetErrorCode(interp, "TK", "API_ABUSE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "API_ABUSE", (char *)NULL);
return TCL_ERROR;
}
}
@@ -306,7 +295,7 @@ Tk_ParseArgv(
missingArg:
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"\"%s\" option requires an additional argument", curArg));
- Tcl_SetErrorCode(interp, "TK", "ARG", "MISSING", curArg, NULL);
+ Tcl_SetErrorCode(interp, "TK", "ARG", "MISSING", curArg, (char *)NULL);
return TCL_ERROR;
}
@@ -363,7 +352,7 @@ PrintUsage(
}
}
- message = Tcl_NewStringObj("Command-specific options:", -1);
+ message = Tcl_NewStringObj("Command-specific options:", TCL_INDEX_NONE);
for (i = 0; ; i++) {
for (infoPtr = i ? defaultTable : argTable;
infoPtr->type != TK_ARGV_END; infoPtr++) {
@@ -376,7 +365,7 @@ PrintUsage(
while (numSpaces-- > 0) {
Tcl_AppendToObj(message, " ", 1);
}
- Tcl_AppendToObj(message, infoPtr->help, -1);
+ Tcl_AppendToObj(message, infoPtr->help, TCL_INDEX_NONE);
switch (infoPtr->type) {
case TK_ARGV_INT:
Tcl_AppendPrintfToObj(message, "\n\t\tDefault value: %d",
@@ -403,7 +392,7 @@ PrintUsage(
if ((flags & TK_ARGV_NO_DEFAULTS) || (i > 0)) {
break;
}
- Tcl_AppendToObj(message, "\nGeneric options for all commands:", -1);
+ Tcl_AppendToObj(message, "\nGeneric options for all commands:", TCL_INDEX_NONE);
}
Tcl_SetObjResult(interp, message);
}
diff --git a/generic/tkArray.h b/generic/tkArray.h
index ec5cb81..dbb43ba 100644
--- a/generic/tkArray.h
+++ b/generic/tkArray.h
@@ -5,7 +5,7 @@
* Random access to any item is very fast. New items can be either appended
* or prepended. An array may be traversed in the forward or backward direction.
*
- * Copyright (c) 2018-2019 Gregor Cramer.
+ * Copyright © 2018-2019 Gregor Cramer.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
diff --git a/generic/tkAtom.c b/generic/tkAtom.c
index 475f9d2..0f86b0b 100644
--- a/generic/tkAtom.c
+++ b/generic/tkAtom.c
@@ -6,8 +6,8 @@
* 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.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 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.
@@ -156,7 +156,7 @@ Tk_GetAtomName(
}
name = (const char *)Tcl_GetHashKey(&dispPtr->nameTable, hPtr);
hPtr = Tcl_CreateHashEntry(&dispPtr->atomTable, INT2PTR(atom), &isNew);
- Tcl_SetHashValue(hPtr, name);
+ Tcl_SetHashValue(hPtr, (char *)name);
}
return (const char *)Tcl_GetHashValue(hPtr);
}
@@ -202,7 +202,7 @@ AtomInit(
Tcl_SetHashValue(hPtr, INT2PTR(atom));
name = (const char *)Tcl_GetHashKey(&dispPtr->nameTable, hPtr);
hPtr = Tcl_CreateHashEntry(&dispPtr->atomTable, INT2PTR(atom), &isNew);
- Tcl_SetHashValue(hPtr, name);
+ Tcl_SetHashValue(hPtr, (char *)name);
}
}
diff --git a/generic/tkBind.c b/generic/tkBind.c
index 5a42826..cc97fde 100644
--- a/generic/tkBind.c
+++ b/generic/tkBind.c
@@ -4,10 +4,10 @@
* This file provides functions 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-1997 Sun Microsystems, Inc.
- * Copyright (c) 1998 Scriptics Corporation.
- * Copyright (c) 2018-2019 Gregor Cramer.
+ * Copyright © 1989-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1998 Scriptics Corporation.
+ * Copyright © 2018-2019 Gregor Cramer.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -54,21 +54,21 @@
* equivalent sequences. However it is logical to give <Double-1> higher precedence
* since it is more specific. Indeed <Double-1> includes time and space requirements,
* which is not the case for <1><1>.
- * This can be achieved by setting PREFER_MOST_SPECIALIZED_EVENT to 1.
+ * This is achieved by setting PREFER_MOST_SPECIALIZED_EVENT to 1.
*/
#ifndef PREFER_MOST_SPECIALIZED_EVENT
-# define PREFER_MOST_SPECIALIZED_EVENT 0
+# define PREFER_MOST_SPECIALIZED_EVENT 1
#endif
/*
* Traditionally motion events can be combined with buttons in this way: <B1-B2-Motion>.
- * However it should be allowed to express this as <Motion-1-2> in addition. This can be
- * achieved by setting SUPPORT_ADDITIONAL_MOTION_SYNTAX to 1.
+ * However it should be allowed to express this as <Motion-1-2> in addition. This is achieved
+ * by setting SUPPORT_ADDITIONAL_MOTION_SYNTAX to 1.
*/
#ifndef SUPPORT_ADDITIONAL_MOTION_SYNTAX
-# define SUPPORT_ADDITIONAL_MOTION_SYNTAX 0 /* set to 1 if wanted */
+# define SUPPORT_ADDITIONAL_MOTION_SYNTAX 1
#endif
/*
@@ -424,7 +424,9 @@ static const ModInfo modArray[] = {
{"Shift", ShiftMask, 0},
{"Lock", LockMask, 0},
{"Meta", META_MASK, 0},
+#ifndef TK_NO_DEPRECATED
{"M", META_MASK, 0},
+#endif
{"Alt", ALT_MASK, 0},
{"Extended", EXTENDED_MASK, 0},
{"B1", Button1Mask, 0},
@@ -437,15 +439,35 @@ static const ModInfo modArray[] = {
{"Button4", Button4Mask, 0},
{"B5", Button5Mask, 0},
{"Button5", Button5Mask, 0},
+ {"B6", Button6Mask, 0},
+ {"Button6", Button6Mask, 0},
+ {"B7", Button7Mask, 0},
+ {"Button7", Button7Mask, 0},
+ {"B8", Button8Mask, 0},
+ {"Button8", Button8Mask, 0},
+ {"B9", Button9Mask, 0},
+ {"Button9", Button9Mask, 0},
{"Mod1", Mod1Mask, 0},
{"M1", Mod1Mask, 0},
+#ifdef MAC_OSX_TK
{"Command", Mod1Mask, 0},
+#elif defined (_WIN32)
+ {"Command", ControlMask, 0},
+#else
+ {"Command", META_MASK, 0},
+#endif
{"Mod2", Mod2Mask, 0},
{"M2", Mod2Mask, 0},
+#ifdef MAC_OSX_TK
{"Option", Mod2Mask, 0},
+#else
+ {"Option", ALT_MASK, 0},
+#endif
{"Mod3", Mod3Mask, 0},
{"M3", Mod3Mask, 0},
+ {"Num", Mod3Mask, 0},
{"Mod4", Mod4Mask, 0},
+ {"Fn", Mod4Mask, 0},
{"M4", Mod4Mask, 0},
{"Mod5", Mod5Mask, 0},
{"M5", Mod5Mask, 0},
@@ -478,10 +500,14 @@ typedef struct {
static const EventInfo eventArray[] = {
{"Key", KeyPress, KeyPressMask},
+#ifndef TK_NO_DEPRECATED
{"KeyPress", KeyPress, KeyPressMask},
+#endif
{"KeyRelease", KeyRelease, KeyPressMask|KeyReleaseMask},
{"Button", ButtonPress, ButtonPressMask},
+#ifndef TK_NO_DEPRECATED
{"ButtonPress", ButtonPress, ButtonPressMask},
+#endif
{"ButtonRelease", ButtonRelease, ButtonPressMask|ButtonReleaseMask},
{"Motion", MotionNotify, ButtonPressMask|PointerMotionMask},
{"Enter", EnterNotify, EnterWindowMask},
@@ -502,6 +528,7 @@ static const EventInfo eventArray[] = {
{"Activate", ActivateNotify, ActivateMask},
{"Deactivate", DeactivateNotify, ActivateMask},
{"MouseWheel", MouseWheelEvent, MouseWheelMask},
+ {"TouchpadScroll", TouchpadScroll, TouchpadScrollMask},
{"CirculateRequest", CirculateRequest, SubstructureRedirectMask},
{"ConfigureRequest", ConfigureRequest, SubstructureRedirectMask},
{"Create", CreateNotify, SubstructureNotifyMask},
@@ -606,7 +633,8 @@ static const int flagArray[TK_LASTEVENT] = {
/* VirtualEvent */ VIRTUAL,
/* Activate */ ACTIVATE,
/* Deactivate */ ACTIVATE,
- /* MouseWheel */ WHEEL
+ /* MouseWheel */ WHEEL,
+ /* TouchpadScroll */ WHEEL
};
/*
@@ -706,7 +734,7 @@ static int GetVirtualEvent(Tcl_Interp *interp, VirtualEventTable *vetPtr,
Tcl_Obj *virtName);
static Tk_Uid GetVirtualEventUid(Tcl_Interp *interp, char *virtString);
static int HandleEventGenerate(Tcl_Interp *interp, Tk_Window main,
- int objc, Tcl_Obj *const objv[]);
+ Tcl_Size objc, Tcl_Obj *const objv[]);
static void InitVirtualEventTable(VirtualEventTable *vetPtr);
static PatSeq * MatchPatterns(TkDisplay *dispPtr, Tk_BindingTable bindPtr, PSList *psList,
PSList *psSuccList, unsigned patIndex, const Event *eventPtr,
@@ -715,7 +743,6 @@ static int NameToWindow(Tcl_Interp *interp, Tk_Window main,
Tcl_Obj *objPtr, Tk_Window *tkwinPtr);
static unsigned ParseEventDescription(Tcl_Interp *interp, const char **eventStringPtr,
TkPattern *patPtr, unsigned *eventMaskPtr);
-static void DoWarp(void *clientData);
static PSList * GetLookupForEvent(LookupTables* lookupPtr, const Event *eventPtr,
Tcl_Obj *object, int onlyConsiderDetailedEvents);
static void ClearLookupTable(LookupTables *lookupTables, void *object);
@@ -737,7 +764,7 @@ void TkpDumpPSList(const PSList *psList);
static int BindCount = 0; /* Can be set or queried from Tcl through 'event debug' subcommand. Otherwise not used. */
#endif
-static unsigned Max(unsigned a, unsigned b) { return a < b ? b : a; }
+static Tcl_Size Max(Tcl_Size a, Tcl_Size b) { return a < b ? b : a; }
static int Abs(int n) { return n < 0 ? -n : n; }
static int IsOdd(int n) { return n & 1; }
@@ -777,8 +804,10 @@ static unsigned
GetButtonNumber(
const char *field)
{
+ unsigned button;
assert(field);
- return (field[0] >= '1' && field[0] <= '5' && field[1] == '\0') ? field[0] - '0' : 0;
+ button = (field[0] >= '1' && field[0] <= '9' && field[1] == '\0') ? (unsigned)(field[0] - '0') : 0;
+ return (button > 3) ? (button + 4) : button;
}
static Time
@@ -977,7 +1006,11 @@ ButtonNumberFromState(
if (state & Button2Mask) { return 2; }
if (state & Button3Mask) { return 3; }
if (state & Button4Mask) { return 4; }
- return 5;
+ if (state & Button5Mask) { return 5; }
+ if (state & Button6Mask) { return 6; }
+ if (state & Button7Mask) { return 7; }
+ if (state & Button8Mask) { return 8; }
+ return 9;
}
static void
@@ -1265,49 +1298,49 @@ TkBindInit(
assert(NoSymbol == 0L);
/* This must be a union, not a struct, otherwise comparison with NULL will not work. */
- assert(Tk_Offset(Detail, name) == Tk_Offset(Detail, info));
+ assert(offsetof(Detail, name) == offsetof(Detail, info));
/* We use some constraints about X*Event. */
- assert(Tk_Offset(XButtonEvent, time) == Tk_Offset(XMotionEvent, time));
- assert(Tk_Offset(XButtonEvent, x_root) == Tk_Offset(XMotionEvent, x_root));
- assert(Tk_Offset(XButtonEvent, y_root) == Tk_Offset(XMotionEvent, y_root));
- assert(Tk_Offset(XCreateWindowEvent, border_width) == Tk_Offset(XConfigureEvent, border_width));
- assert(Tk_Offset(XCreateWindowEvent, width) == Tk_Offset(XConfigureEvent, width));
- assert(Tk_Offset(XCreateWindowEvent, window) == Tk_Offset(XCirculateRequestEvent, window));
- assert(Tk_Offset(XCreateWindowEvent, window) == Tk_Offset(XConfigureEvent, window));
- assert(Tk_Offset(XCreateWindowEvent, window) == Tk_Offset(XGravityEvent, window));
- assert(Tk_Offset(XCreateWindowEvent, window) == Tk_Offset(XMapEvent, window));
- assert(Tk_Offset(XCreateWindowEvent, window) == Tk_Offset(XReparentEvent, window));
- assert(Tk_Offset(XCreateWindowEvent, window) == Tk_Offset(XUnmapEvent, window));
- assert(Tk_Offset(XCreateWindowEvent, x) == Tk_Offset(XConfigureEvent, x));
- assert(Tk_Offset(XCreateWindowEvent, x) == Tk_Offset(XGravityEvent, x));
- assert(Tk_Offset(XCreateWindowEvent, y) == Tk_Offset(XConfigureEvent, y));
- assert(Tk_Offset(XCreateWindowEvent, y) == Tk_Offset(XGravityEvent, y));
- assert(Tk_Offset(XCrossingEvent, time) == Tk_Offset(XEnterWindowEvent, time));
- assert(Tk_Offset(XCrossingEvent, time) == Tk_Offset(XLeaveWindowEvent, time));
- assert(Tk_Offset(XCrossingEvent, time) == Tk_Offset(XKeyEvent, time));
- assert(Tk_Offset(XKeyEvent, root) == Tk_Offset(XButtonEvent, root));
- assert(Tk_Offset(XKeyEvent, root) == Tk_Offset(XCrossingEvent, root));
- assert(Tk_Offset(XKeyEvent, root) == Tk_Offset(XMotionEvent, root));
- assert(Tk_Offset(XKeyEvent, state) == Tk_Offset(XButtonEvent, state));
- assert(Tk_Offset(XKeyEvent, state) == Tk_Offset(XMotionEvent, state));
- assert(Tk_Offset(XKeyEvent, subwindow) == Tk_Offset(XButtonEvent, subwindow));
- assert(Tk_Offset(XKeyEvent, subwindow) == Tk_Offset(XCrossingEvent, subwindow));
- assert(Tk_Offset(XKeyEvent, subwindow) == Tk_Offset(XMotionEvent, subwindow));
- assert(Tk_Offset(XKeyEvent, time) == Tk_Offset(XButtonEvent, time));
- assert(Tk_Offset(XKeyEvent, time) == Tk_Offset(XMotionEvent, time));
- assert(Tk_Offset(XKeyEvent, x) == Tk_Offset(XButtonEvent, x));
- assert(Tk_Offset(XKeyEvent, x) == Tk_Offset(XCrossingEvent, x));
- assert(Tk_Offset(XKeyEvent, x) == Tk_Offset(XMotionEvent, x));
- assert(Tk_Offset(XKeyEvent, x_root) == Tk_Offset(XButtonEvent, x_root));
- assert(Tk_Offset(XKeyEvent, x_root) == Tk_Offset(XCrossingEvent, x_root));
- assert(Tk_Offset(XKeyEvent, x_root) == Tk_Offset(XMotionEvent, x_root));
- assert(Tk_Offset(XKeyEvent, y) == Tk_Offset(XButtonEvent, y));
- assert(Tk_Offset(XKeyEvent, y) == Tk_Offset(XCrossingEvent, y));
- assert(Tk_Offset(XKeyEvent, y) == Tk_Offset(XMotionEvent, y));
- assert(Tk_Offset(XKeyEvent, y_root) == Tk_Offset(XButtonEvent, y_root));
- assert(Tk_Offset(XKeyEvent, y_root) == Tk_Offset(XCrossingEvent, y_root));
- assert(Tk_Offset(XKeyEvent, y_root) == Tk_Offset(XMotionEvent, y_root));
+ assert(offsetof(XButtonEvent, time) == offsetof(XMotionEvent, time));
+ assert(offsetof(XButtonEvent, x_root) == offsetof(XMotionEvent, x_root));
+ assert(offsetof(XButtonEvent, y_root) == offsetof(XMotionEvent, y_root));
+ assert(offsetof(XCreateWindowEvent, border_width) == offsetof(XConfigureEvent, border_width));
+ assert(offsetof(XCreateWindowEvent, width) == offsetof(XConfigureEvent, width));
+ assert(offsetof(XCreateWindowEvent, window) == offsetof(XCirculateRequestEvent, window));
+ assert(offsetof(XCreateWindowEvent, window) == offsetof(XConfigureEvent, window));
+ assert(offsetof(XCreateWindowEvent, window) == offsetof(XGravityEvent, window));
+ assert(offsetof(XCreateWindowEvent, window) == offsetof(XMapEvent, window));
+ assert(offsetof(XCreateWindowEvent, window) == offsetof(XReparentEvent, window));
+ assert(offsetof(XCreateWindowEvent, window) == offsetof(XUnmapEvent, window));
+ assert(offsetof(XCreateWindowEvent, x) == offsetof(XConfigureEvent, x));
+ assert(offsetof(XCreateWindowEvent, x) == offsetof(XGravityEvent, x));
+ assert(offsetof(XCreateWindowEvent, y) == offsetof(XConfigureEvent, y));
+ assert(offsetof(XCreateWindowEvent, y) == offsetof(XGravityEvent, y));
+ assert(offsetof(XCrossingEvent, time) == offsetof(XEnterWindowEvent, time));
+ assert(offsetof(XCrossingEvent, time) == offsetof(XLeaveWindowEvent, time));
+ assert(offsetof(XCrossingEvent, time) == offsetof(XKeyEvent, time));
+ assert(offsetof(XKeyEvent, root) == offsetof(XButtonEvent, root));
+ assert(offsetof(XKeyEvent, root) == offsetof(XCrossingEvent, root));
+ assert(offsetof(XKeyEvent, root) == offsetof(XMotionEvent, root));
+ assert(offsetof(XKeyEvent, state) == offsetof(XButtonEvent, state));
+ assert(offsetof(XKeyEvent, state) == offsetof(XMotionEvent, state));
+ assert(offsetof(XKeyEvent, subwindow) == offsetof(XButtonEvent, subwindow));
+ assert(offsetof(XKeyEvent, subwindow) == offsetof(XCrossingEvent, subwindow));
+ assert(offsetof(XKeyEvent, subwindow) == offsetof(XMotionEvent, subwindow));
+ assert(offsetof(XKeyEvent, time) == offsetof(XButtonEvent, time));
+ assert(offsetof(XKeyEvent, time) == offsetof(XMotionEvent, time));
+ assert(offsetof(XKeyEvent, x) == offsetof(XButtonEvent, x));
+ assert(offsetof(XKeyEvent, x) == offsetof(XCrossingEvent, x));
+ assert(offsetof(XKeyEvent, x) == offsetof(XMotionEvent, x));
+ assert(offsetof(XKeyEvent, x_root) == offsetof(XButtonEvent, x_root));
+ assert(offsetof(XKeyEvent, x_root) == offsetof(XCrossingEvent, x_root));
+ assert(offsetof(XKeyEvent, x_root) == offsetof(XMotionEvent, x_root));
+ assert(offsetof(XKeyEvent, y) == offsetof(XButtonEvent, y));
+ assert(offsetof(XKeyEvent, y) == offsetof(XCrossingEvent, y));
+ assert(offsetof(XKeyEvent, y) == offsetof(XMotionEvent, y));
+ assert(offsetof(XKeyEvent, y_root) == offsetof(XButtonEvent, y_root));
+ assert(offsetof(XKeyEvent, y_root) == offsetof(XCrossingEvent, y_root));
+ assert(offsetof(XKeyEvent, y_root) == offsetof(XMotionEvent, y_root));
/*
* Initialize the static data structures used by the binding package. They
@@ -2137,7 +2170,7 @@ Tk_BindEvent(
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 *objArr. */
+ Tcl_Size numObjects, /* Number of objects at *objArr. */
void **objArr) /* Array of one or more objects to check for a matching binding. */
{
Tcl_Interp *interp;
@@ -2159,9 +2192,9 @@ Tk_BindEvent(
unsigned scriptCount;
int oldScreen;
unsigned flags;
- unsigned arraySize;
+ Tcl_Size arraySize;
unsigned newArraySize;
- unsigned i, k;
+ Tcl_Size i, k;
assert(bindPtr);
assert(eventPtr);
@@ -2219,7 +2252,7 @@ Tk_BindEvent(
bindInfoPtr->lastEventTime = eventPtr->xkey.time;
}
/* Modifier keys should not influence button events. */
- for (i = 0; i < (unsigned) dispPtr->numModKeyCodes; ++i) {
+ for (i = 0; i < dispPtr->numModKeyCodes; ++i) {
if (dispPtr->modKeyCodes[i] == eventPtr->xkey.keycode) {
reset = 0;
}
@@ -2345,7 +2378,7 @@ Tk_BindEvent(
memset(matchPtrArr, 0, numObjects*sizeof(matchPtrArr[0]));
if (!PromArr_IsEmpty(bindPtr->promArr)) {
- for (k = 0; k < (unsigned) numObjects; ++k) {
+ for (k = 0; k < numObjects; ++k) {
psl[1] = PromArr_Last(bindPtr->promArr);
psl[0] = psl[1] - 1;
@@ -2377,7 +2410,7 @@ Tk_BindEvent(
* 2. Look for bindings without detail.
*/
- for (k = 0; k < (unsigned) numObjects; ++k) {
+ for (k = 0; k < numObjects; ++k) {
PSList *psSuccList = PromArr_First(bindPtr->promArr);
PatSeq *bestPtr;
@@ -2391,7 +2424,7 @@ Tk_BindEvent(
if (!PSList_IsEmpty(psSuccList)) {
/* We have promoted sequences, adjust array size. */
- arraySize = Max(1u, arraySize);
+ arraySize = Max(1, arraySize);
}
bestPtr = psPtr[0] ? psPtr[0] : psPtr[1];
@@ -2462,7 +2495,7 @@ Tk_BindEvent(
for (psEntry = PSList_First(psList); psEntry; psEntry = psNext) {
const TkPattern *patPtr;
- assert(i + 1 < psEntry->psPtr->numPats);
+ assert(i + 1 < (Tcl_Size)psEntry->psPtr->numPats);
psNext = PSList_Next(psEntry);
patPtr = &psEntry->psPtr->pats[i + 1];
@@ -2567,7 +2600,7 @@ Tk_BindEvent(
Tcl_Preserve(bindInfoPtr);
for (p = Tcl_DStringValue(&scripts), end = p + Tcl_DStringLength(&scripts); p < end; ) {
- size_t len = strlen(p);
+ Tcl_Size len = strlen(p);
int code;
if (!bindInfoPtr->deleted) {
@@ -2747,7 +2780,9 @@ IsPSInPSList(
PSEntry *psEntry;
TK_DLIST_FOREACH(psEntry, psList) {
- if (psEntry->psPtr == psPtr) { return 1; }
+ if (psEntry->psPtr == psPtr) {
+ return 1;
+ }
}
return 0;
}
@@ -2772,7 +2807,8 @@ MatchPatterns(
PatSeq *bestPhysPtr;
unsigned bestModMask;
const PSModMaskArr *bestModMaskArr = NULL;
- int i, isModKeyOnly = 0;
+ int isModKeyOnly = 0;
+ Tcl_Size i;
assert(dispPtr);
assert(bindPtr);
@@ -2799,12 +2835,12 @@ MatchPatterns(
* it from the keyboard. See bug [16ef161925].
*/
if (IsKeyEventType(curEvent->xev.type)) {
- for (i = 0; i < dispPtr->numModKeyCodes; ++i) {
- if (dispPtr->modKeyCodes[i] == curEvent->xev.xkey.keycode) {
- isModKeyOnly = 1;
- break;
- }
- }
+ for (i = 0; i < dispPtr->numModKeyCodes; ++i) {
+ if (dispPtr->modKeyCodes[i] == curEvent->xev.xkey.keycode) {
+ isModKeyOnly = 1;
+ break;
+ }
+ }
}
for (psEntry = PSList_First(psList); psEntry; psEntry = PSList_Next(psEntry)) {
@@ -2821,11 +2857,11 @@ MatchPatterns(
: VirtPatIsBound(bindPtr, psPtr, object, physPtrPtr)) {
TkPattern *patPtr = psPtr->pats + patIndex;
- /* Ignore modifier key events, and KeyRelease events if the current event
- * is of a different type (e.g. a Button event)
- */
- psEntry->keepIt = isModKeyOnly || \
- ((patPtr->eventType != (unsigned) curEvent->xev.type) && curEvent->xev.type == KeyRelease);
+ /* Ignore modifier key events, and KeyRelease events if the current event
+ * is of a different type (e.g. a Button event)
+ */
+ psEntry->keepIt = isModKeyOnly || \
+ ((patPtr->eventType != (unsigned) curEvent->xev.type) && curEvent->xev.type == KeyRelease);
if (patPtr->eventType == (unsigned) curEvent->xev.type
&& (curEvent->xev.type != CreateNotify
@@ -2841,7 +2877,7 @@ MatchPatterns(
unsigned curModMask = ResolveModifiers(dispPtr, bindPtr->curModMask);
psEntry->expired = 1; /* Remove it from promotion list. */
- psEntry->keepIt = 0; /* Don't keep matching patterns. */
+ psEntry->keepIt = 0; /* Don't keep matching patterns. */
if (IsSubsetOf(modMask, curModMask)) {
unsigned count = patPtr->info ? curEvent->countDetailed : curEvent->countAny;
@@ -2908,7 +2944,7 @@ MatchPatterns(
psEntry->keepIt = 1; /* Don't remove it from promotion list. */
}
} else {
- /*
+ /*
* Pattern sequence is already present in the success list.
*/
@@ -2982,8 +3018,8 @@ ExpandPercents(
while (1) {
char numStorage[TCL_INTEGER_SPACE];
const char *string;
- Tcl_WideInt number; /* signed */
- Tcl_WideUInt unumber; /* unsigned */
+ long long number; /* signed */
+ unsigned long long unumber; /* unsigned */
/*
* Find everything up to the next % character and append it to the
@@ -2993,7 +3029,7 @@ ExpandPercents(
for (string = before; *string && *string != '%'; ++string)
;
if (string != before) {
- Tcl_DStringAppend(dsPtr, before, string - before);
+ Tcl_DStringAppend(dsPtr, before, (Tcl_Size)(string - before));
before = string;
}
if (!*before) {
@@ -3244,8 +3280,8 @@ ExpandPercents(
}
{ /* local scope */
int cvtFlags;
- unsigned spaceNeeded = Tcl_ScanElement(string, &cvtFlags);
- unsigned length = Tcl_DStringLength(dsPtr);
+ Tcl_Size spaceNeeded = Tcl_ScanElement(string, &cvtFlags);
+ Tcl_Size length = Tcl_DStringLength(dsPtr);
Tcl_DStringSetLength(dsPtr, length + spaceNeeded);
spaceNeeded = Tcl_ConvertElement(
@@ -3847,7 +3883,7 @@ static int
HandleEventGenerate(
Tcl_Interp *interp, /* Interp for errors return and name lookup. */
Tk_Window mainWin, /* Main window associated with interp. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
union { XEvent general; XVirtualEvent virt; } event;
@@ -3867,7 +3903,7 @@ HandleEventGenerate(
unsigned count;
unsigned flags;
int number;
- unsigned i;
+ Tcl_Size i;
static const char *const fieldStrings[] = {
"-when", "-above", "-borderwidth", "-button",
@@ -3904,7 +3940,7 @@ HandleEventGenerate(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"window id \"%s\" doesn't exist in this application",
Tcl_GetString(objv[0])));
- Tcl_SetErrorCode(interp, "TK", "LOOKUP", "WINDOW", Tcl_GetString(objv[0]), NULL);
+ Tcl_SetErrorCode(interp, "TK", "LOOKUP", "WINDOW", Tcl_GetString(objv[0]), (char *)NULL);
return TCL_ERROR;
}
@@ -3917,13 +3953,13 @@ HandleEventGenerate(
}
if (count != 1u) {
Tcl_SetObjResult(interp,
- Tcl_NewStringObj("Double, Triple, or Quadruple modifier not allowed", -1));
- Tcl_SetErrorCode(interp, "TK", "EVENT", "BAD_MODIFIER", NULL);
+ Tcl_NewStringObj("Double, Triple, or Quadruple modifier not allowed", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "EVENT", "BAD_MODIFIER", (char *)NULL);
return TCL_ERROR;
}
if (*p) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj("only one event specification allowed", -1));
- Tcl_SetErrorCode(interp, "TK", "EVENT", "MULTIPLE", NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("only one event specification allowed", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "EVENT", "MULTIPLE", (char *)NULL);
return TCL_ERROR;
}
@@ -3977,10 +4013,10 @@ HandleEventGenerate(
warp = 0;
pos = TCL_QUEUE_TAIL;
- for (i = 2; i < (unsigned) objc; i += 2) {
+ for (i = 2; i < objc; i += 2) {
Tcl_Obj *optionPtr, *valuePtr;
#if defined(_MSC_VER)
- /* Work around MSVC compiler optimization bug, see [d93c8175fd]. */
+ /* Work around MSVC compiler optimization bug, see [d93c8175fd]. */
volatile int badOpt = 0;
#else
int badOpt = 0;
@@ -4004,7 +4040,7 @@ HandleEventGenerate(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"value for \"%s\" missing", Tcl_GetString(optionPtr)));
- Tcl_SetErrorCode(interp, "TK", "EVENT", "MISSING_VALUE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "EVENT", "MISSING_VALUE", (char *)NULL);
return TCL_ERROR;
}
@@ -4049,6 +4085,9 @@ HandleEventGenerate(
return TCL_ERROR;
}
if (flags & BUTTON) {
+ if (number >= Button4) {
+ number += (Button8 - Button4);
+ }
event.general.xbutton.button = number;
} else {
badOpt = 1;
@@ -4139,14 +4178,14 @@ HandleEventGenerate(
keysym = TkStringToKeysym(value);
if (keysym == NoSymbol) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf("unknown keysym \"%s\"", value));
- Tcl_SetErrorCode(interp, "TK", "LOOKUP", "KEYSYM", value, NULL);
+ Tcl_SetErrorCode(interp, "TK", "LOOKUP", "KEYSYM", value, (char *)NULL);
return TCL_ERROR;
}
TkpSetKeycodeAndState(tkwin, keysym, &event.general);
if (event.general.xkey.keycode == 0) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf("no keycode for keysym \"%s\"", value));
- Tcl_SetErrorCode(interp, "TK", "LOOKUP", "KEYCODE", value, NULL);
+ Tcl_SetErrorCode(interp, "TK", "LOOKUP", "KEYCODE", value, (char *)NULL);
return TCL_ERROR;
}
if (!(flags & KEY)) {
@@ -4381,7 +4420,7 @@ HandleEventGenerate(
if (badOpt) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"%s event doesn't accept \"%s\" option", name, Tcl_GetString(optionPtr)));
- Tcl_SetErrorCode(interp, "TK", "EVENT", "BAD_OPTION", NULL);
+ Tcl_SetErrorCode(interp, "TK", "EVENT", "BAD_OPTION", (char *)NULL);
return TCL_ERROR;
}
}
@@ -4424,9 +4463,18 @@ HandleEventGenerate(
dispPtr->warpX = event.general.xmotion.x;
dispPtr->warpY = event.general.xmotion.y;
- if (!(dispPtr->flags & TK_DISPLAY_IN_WARP)) {
- Tcl_DoWhenIdle(DoWarp, dispPtr);
- dispPtr->flags |= TK_DISPLAY_IN_WARP;
+ /*
+ * Warping with respect to a window will be done when Tk_handleEvent
+ * below will run the event handlers and in particular TkPointerEvent.
+ * This allows to make grabs and warping work together robustly, that
+ * is without depending on a precise sequence of events.
+ * Warping with respect to the whole screen (i.e. dispPtr->warpWindow
+ * is NULL) is run directly here.
+ */
+
+ if (!dispPtr->warpWindow) {
+ TkpWarpPointer(dispPtr);
+ XForceScreenSaver(dispPtr->display, ScreenSaverReset);
}
}
@@ -4498,7 +4546,7 @@ NameToWindow(
if (!tkwin) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad window name/identifier \"%s\"", name));
- Tcl_SetErrorCode(interp, "TK", "LOOKUP", "WINDOW_ID", name, NULL);
+ Tcl_SetErrorCode(interp, "TK", "LOOKUP", "WINDOW_ID", name, (char *)NULL);
return 0;
}
}
@@ -4511,9 +4559,9 @@ NameToWindow(
/*
*-------------------------------------------------------------------------
*
- * DoWarp --
+ * TkDoWarpWrtWin --
*
- * Perform warping of mouse pointer. Executed as an idle handler only.
+ * Perform warping of mouse pointer with respect to a window.
*
* Results:
* None
@@ -4524,33 +4572,34 @@ NameToWindow(
*-------------------------------------------------------------------------
*/
-static void
-DoWarp(
- void *clientData)
+void
+TkDoWarpWrtWin(
+ TkDisplay *dispPtr)
{
- TkDisplay *dispPtr = (TkDisplay *)clientData;
-
- assert(clientData);
+ assert(dispPtr);
/*
- * DoWarp was scheduled only if the window was mapped. It needs to be
- * still mapped at the time the present idle callback is executed. Also
- * one needs to guard against window destruction in the meantime.
- * Finally, the case warpWindow == NULL is special in that it means
- * the whole screen.
+ * A NULL warpWindow means warping with respect to the whole screen.
+ * We want to warp here only if we're warping with respect to a window.
*/
- if (!dispPtr->warpWindow ||
- (Tk_IsMapped(dispPtr->warpWindow) && Tk_WindowId(dispPtr->warpWindow) != None)) {
- TkpWarpPointer(dispPtr);
- XForceScreenSaver(dispPtr->display, ScreenSaverReset);
- }
-
if (dispPtr->warpWindow) {
+
+ /*
+ * Warping with respect to a window can only be done if the window is
+ * mapped. This was checked in HandleEvent. The window needs to be
+ * still mapped at the time the present code is executed. Also
+ * one needs to guard against window destruction in the meantime,
+ * which could have happened as a side effect of an event handler.
+ */
+
+ if (Tk_IsMapped(dispPtr->warpWindow) && Tk_WindowId(dispPtr->warpWindow) != None) {
+ TkpWarpPointer(dispPtr);
+ XForceScreenSaver(dispPtr->display, ScreenSaverReset);
+ }
Tcl_Release(dispPtr->warpWindow);
dispPtr->warpWindow = NULL;
}
- dispPtr->flags &= ~TK_DISPLAY_IN_WARP;
}
/*
@@ -4591,7 +4640,7 @@ GetVirtualEventUid(
|| virtString[length - 2] != '>'
|| virtString[length - 1] != '>') {
Tcl_SetObjResult(interp, Tcl_ObjPrintf("virtual event \"%s\" is badly formed", virtString));
- Tcl_SetErrorCode(interp, "TK", "EVENT", "VIRTUAL", "MALFORMED", NULL);
+ Tcl_SetErrorCode(interp, "TK", "EVENT", "VIRTUAL", "MALFORMED", (char *)NULL);
return NULL;
}
virtString[length - 2] = '\0';
@@ -4683,8 +4732,8 @@ FindSequence(
if (eventMask & VirtualEventMask) {
if (!allowVirtual) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "virtual event not allowed in definition of another virtual event", -1));
- Tcl_SetErrorCode(interp, "TK", "EVENT", "VIRTUAL", "INNER", NULL);
+ "virtual event not allowed in definition of another virtual event", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "EVENT", "VIRTUAL", "INNER", (char *)NULL);
ckfree(psPtr);
return NULL;
}
@@ -4707,14 +4756,14 @@ FindSequence(
*/
if (numPats == 0) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj("no events specified in binding", -1));
- Tcl_SetErrorCode(interp, "TK", "EVENT", "NO_EVENTS", NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("no events specified in binding", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "EVENT", "NO_EVENTS", (char *)NULL);
ckfree(psPtr);
return NULL;
}
if (numPats > 1u && virtualFound) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj("virtual events may not be composed", -1));
- Tcl_SetErrorCode(interp, "TK", "EVENT", "VIRTUAL", "COMPOSITION", NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("virtual events may not be composed", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "EVENT", "VIRTUAL", "COMPOSITION", (char *)NULL);
ckfree(psPtr);
return NULL;
}
@@ -4814,7 +4863,7 @@ FinalizeParseEventDescription(
if (errorObj) {
Tcl_SetObjResult(interp, errorObj);
- Tcl_SetErrorCode(interp, "TK", "EVENT", errCode, NULL);
+ Tcl_SetErrorCode(interp, "TK", "EVENT", errCode, (char *)NULL);
}
patPtr->count = count;
return count;
@@ -4897,13 +4946,13 @@ ParseEventDescription(
return FinalizeParseEventDescription(
interp,
patPtr, 0,
- Tcl_NewStringObj("virtual event \"<<>>\" is badly formed", -1), "MALFORMED");
+ Tcl_NewStringObj("virtual event \"<<>>\" is badly formed", TCL_INDEX_NONE), "MALFORMED");
}
if (!p || p[1] != '>') {
return FinalizeParseEventDescription(
interp,
patPtr, 0,
- Tcl_NewStringObj("missing \">\" in virtual binding", -1), "MALFORMED");
+ Tcl_NewStringObj("missing \">\" in virtual binding", TCL_INDEX_NONE), "MALFORMED");
}
size = p - field;
@@ -4956,7 +5005,6 @@ ParseEventDescription(
eventFlags = 0;
if ((hPtr = Tcl_FindHashEntry(&eventTable, field))) {
const EventInfo *eiPtr = (const EventInfo *)Tcl_GetHashValue(hPtr);
-
patPtr->eventType = eiPtr->type;
eventFlags = flagArray[eiPtr->type];
eventMask = eiPtr->eventMask;
@@ -5002,7 +5050,7 @@ ParseEventDescription(
"NON_BUTTON");
}
#if SUPPORT_ADDITIONAL_MOTION_SYNTAX
- patPtr->modMask |= TkGetButtonMask(button);
+ patPtr->modMask |= Tk_GetButtonMask(button);
p = SkipFieldDelims(p);
while (*p && *p != '>') {
p = SkipFieldDelims(GetField(p, field, sizeof(field)));
@@ -5012,7 +5060,7 @@ ParseEventDescription(
patPtr, 0,
Tcl_ObjPrintf("bad button number \"%s\"", field), "BUTTON");
}
- patPtr->modMask |= TkGetButtonMask(button);
+ patPtr->modMask |= Tk_GetButtonMask(button);
}
patPtr->info = ButtonNumberFromState(patPtr->modMask);
#endif
@@ -5027,11 +5075,10 @@ ParseEventDescription(
return FinalizeParseEventDescription(
interp,
patPtr, 0,
- Tcl_NewStringObj("no event type or button # or keysym", -1), "UNMODIFIABLE");
+ Tcl_NewStringObj("no event type or button # or keysym", TCL_INDEX_NONE), "UNMODIFIABLE");
} else if (patPtr->eventType == MotionNotify) {
patPtr->info = ButtonNumberFromState(patPtr->modMask);
}
-
p = SkipFieldDelims(p);
if (*p != '>') {
@@ -5041,14 +5088,14 @@ ParseEventDescription(
return FinalizeParseEventDescription(
interp,
patPtr, 0,
- Tcl_NewStringObj("extra characters after detail in binding", -1),
+ Tcl_NewStringObj("extra characters after detail in binding", TCL_INDEX_NONE),
"PAST_DETAIL");
}
}
return FinalizeParseEventDescription(
interp,
patPtr, 0,
- Tcl_NewStringObj("missing \">\" in binding", -1), "MALFORMED");
+ Tcl_NewStringObj("missing \">\" in binding", TCL_INDEX_NONE), "MALFORMED");
}
++p;
}
@@ -5175,7 +5222,7 @@ GetPatternObj(
assert(patPtr->eventType < TK_LASTEVENT);
assert(((size_t) eventArrayIndex[patPtr->eventType]) < SIZE_OF_ARRAY(eventArray));
- Tcl_AppendToObj(patternObj, eventArray[eventArrayIndex[patPtr->eventType]].name, -1);
+ Tcl_AppendToObj(patternObj, eventArray[eventArrayIndex[patPtr->eventType]].name, TCL_INDEX_NONE);
if (patPtr->info) {
switch (patPtr->eventType) {
@@ -5184,22 +5231,22 @@ GetPatternObj(
const char *string = TkKeysymToString(patPtr->info);
if (string) {
Tcl_AppendToObj(patternObj, "-", 1);
- Tcl_AppendToObj(patternObj, string, -1);
+ Tcl_AppendToObj(patternObj, string, TCL_INDEX_NONE);
}
break;
}
case ButtonPress:
case ButtonRelease:
- assert(patPtr->info <= Button5);
- Tcl_AppendPrintfToObj(patternObj, "-%u", (unsigned) patPtr->info);
+ assert(patPtr->info <= 13);
+ Tcl_AppendPrintfToObj(patternObj, "-%u", (unsigned) ((patPtr->info > 7) ? (patPtr->info - 4) : patPtr->info));
break;
#if PRINT_SHORT_MOTION_SYNTAX
case MotionNotify: {
unsigned mask = patPtr->modMask;
while (mask & ALL_BUTTONS) {
unsigned button = ButtonNumberFromState(mask);
- Tcl_AppendPrintfToObj(patternObj, "-%u", button);
- mask &= ~TkGetButtonMask(button);
+ Tcl_AppendPrintfToObj(patternObj, "-%u", (button > 7) ? (button - 4) : button);
+ mask &= ~Tk_GetButtonMask(button);
}
break;
}
@@ -5236,14 +5283,48 @@ TkStringToKeysym(
const char *name) /* Name of a keysym. */
{
#ifdef REDO_KEYSYM_LOOKUP
- Tcl_HashEntry *hPtr = Tcl_FindHashEntry(&keySymTable, name);
-
+ Tcl_HashEntry *hPtr;
+#endif /* REDO_KEYSYM_LOOKUP */
+ int keysym;
+
+ size_t len = TkUtfToUniChar(name, &keysym);
+ if (name[len] == '\0') {
+ if (!Tcl_UniCharIsPrint(keysym)) {
+ /* This form not supported */
+ } else if ((unsigned)(keysym - 0x21) <= 0x5D) {
+ return (KeySym)keysym;
+ } else if ((unsigned)(keysym - 0xA1) <= 0x5E) {
+ return (KeySym)keysym;
+ } else if (keysym == 0x20AC) {
+ return 0x20AC;
+ } else {
+ return (KeySym)keysym + 0x1000000;
+ }
+ }
+#ifdef REDO_KEYSYM_LOOKUP
+ if ((name[0] == 'U') && ((unsigned)(name[1] - '0') <= 9)) {
+ char *p = (char *)name + 1;
+ keysym = strtol(p, &p, 16);
+ if ((p >= name + 5) && (p <= name + 9) && !*p && (keysym >= 0x20)
+ && ((unsigned)(keysym - 0x7F) > 0x20)) {
+ if ((unsigned)(keysym - 0x21) <= 0x5D) {
+ return keysym;
+ } else if ((unsigned)(keysym - 0xA1) <= 0x5E) {
+ return keysym;
+ } else if (keysym == 0x20AC) {
+ return keysym;
+ }
+ return keysym + 0x1000000;
+ }
+ }
+#endif
+#ifdef REDO_KEYSYM_LOOKUP
+ hPtr = Tcl_FindHashEntry(&keySymTable, name);
if (hPtr) {
return (KeySym) Tcl_GetHashValue(hPtr);
}
- assert(name);
- if (strlen(name) == 1u) {
- KeySym keysym = (KeySym) (unsigned char) name[0];
+ if (((unsigned)(name[0]-1) < 0x7F) && !name[1]) {
+ keysym = (unsigned char) name[0];
if (TkKeysymToString(keysym)) {
return keysym;
@@ -5276,16 +5357,37 @@ TkKeysymToString(
KeySym keysym)
{
#ifdef REDO_KEYSYM_LOOKUP
- Tcl_HashEntry *hPtr = Tcl_FindHashEntry(&nameTable, (char *)keysym);
+ Tcl_HashEntry *hPtr;
+#endif
+
+ if ((unsigned)(keysym - 0x21) <= 0x5D) {
+ keysym += 0x1000000;
+ } else if ((unsigned)(keysym - 0xA1) <= 0x5E) {
+ keysym += 0x1000000;
+ } else if (keysym == 0x20AC) {
+ keysym += 0x1000000;
+ }
+ if ((keysym >= 0x1000020) && (keysym <= 0x110FFFF)
+ && ((unsigned)(keysym - 0x100007F) > 0x20)) {
+ char buf[10];
+ if (Tcl_UniCharIsPrint(keysym-0x1000000)) {
+ buf[TkUniCharToUtf(keysym - 0x1000000, buf)] = '\0';
+ } else if (keysym >= 0x1010000) {
+ snprintf(buf, sizeof(buf), "U%08X", (int)(keysym - 0x1000000));
+ } else {
+ snprintf(buf, sizeof(buf), "U%04X", (int)(keysym - 0x1000000));
+ }
+ return Tk_GetUid(buf);
+ }
+
+#ifdef REDO_KEYSYM_LOOKUP
+ hPtr = Tcl_FindHashEntry(&nameTable, INT2PTR(keysym));
if (hPtr) {
return (const char *)Tcl_GetHashValue(hPtr);
}
#endif /* REDO_KEYSYM_LOOKUP */
- if (keysym > (KeySym)0x1008FFFF) {
- return NULL;
- }
return XKeysymToString(keysym);
}
@@ -5321,35 +5423,6 @@ TkpGetBindingXEvent(
/*
*----------------------------------------------------------------------
*
- * TkpCancelWarp --
- *
- * This function cancels an outstanding pointer warp and
- * is called during tear down of the display.
- *
- * Results:
- * None.
- *
- * Side effects:
- * None.
- *
- *----------------------------------------------------------------------
- */
-
-void
-TkpCancelWarp(
- TkDisplay *dispPtr)
-{
- assert(dispPtr);
-
- if (dispPtr->flags & TK_DISPLAY_IN_WARP) {
- Tcl_CancelIdleCall(DoWarp, dispPtr);
- dispPtr->flags &= ~TK_DISPLAY_IN_WARP;
- }
-}
-
-/*
- *----------------------------------------------------------------------
- *
* TkpDumpPS --
*
* Dump given pattern sequence to stdout.
diff --git a/generic/tkBitmap.c b/generic/tkBitmap.c
index ad118d3..edd36ad 100644
--- a/generic/tkBitmap.c
+++ b/generic/tkBitmap.c
@@ -5,8 +5,8 @@
* 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-1998 Sun Microsystems, Inc.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994-1998 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -125,12 +125,14 @@ static void InitBitmapObj(Tcl_Obj *objPtr);
* field of the Tcl_Obj points to a TkBitmap object.
*/
-const Tcl_ObjType tkBitmapObjType = {
- "bitmap", /* name */
+const TkObjType tkBitmapObjType = {
+ {"bitmap", /* name */
FreeBitmapObjProc, /* freeIntRepProc */
DupBitmapObjProc, /* dupIntRepProc */
NULL, /* updateStringProc */
- NULL /* setFromAnyProc */
+ NULL, /* setFromAnyProc */
+ TCL_OBJTYPE_V0},
+ 0
};
/*
@@ -168,7 +170,7 @@ Tk_AllocBitmapFromObj(
{
TkBitmap *bitmapPtr;
- if (objPtr->typePtr != &tkBitmapObjType) {
+ if (objPtr->typePtr != &tkBitmapObjType.objType) {
InitBitmapObj(objPtr);
}
bitmapPtr = (TkBitmap *)objPtr->internalRep.twoPtrValue.ptr1;
@@ -348,8 +350,8 @@ GetBitmap(
if (Tcl_IsSafe(interp)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"can't specify bitmap with '@' in a safe interpreter",
- -1));
- Tcl_SetErrorCode(interp, "TK", "SAFE", "BITMAP_FILE", NULL);
+ TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "SAFE", "BITMAP_FILE", (char *)NULL);
goto error;
}
@@ -371,7 +373,7 @@ GetBitmap(
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"error reading bitmap file \"%s\"", string));
- Tcl_SetErrorCode(interp, "TK", "BITMAP", "FILE_ERROR", NULL);
+ Tcl_SetErrorCode(interp, "TK", "BITMAP", "FILE_ERROR", (char *)NULL);
}
Tcl_DStringFree(&buffer);
goto error;
@@ -394,7 +396,7 @@ GetBitmap(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bitmap \"%s\" not defined", string));
Tcl_SetErrorCode(interp, "TK", "LOOKUP", "BITMAP", string,
- NULL);
+ (char *)NULL);
}
goto error;
}
@@ -498,7 +500,7 @@ Tk_DefineBitmap(
if (!isNew) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bitmap \"%s\" is already defined", name));
- Tcl_SetErrorCode(interp, "TK", "BITMAP", "EXISTS", NULL);
+ Tcl_SetErrorCode(interp, "TK", "BITMAP", "EXISTS", (char *)NULL);
return TCL_ERROR;
}
predefPtr = (TkPredefBitmap *)ckalloc(sizeof(TkPredefBitmap));
@@ -540,7 +542,7 @@ Tk_NameOfBitmap(
Tcl_Panic("Tk_NameOfBitmap received unknown bitmap argument");
}
- idHashPtr = Tcl_FindHashEntry(&dispPtr->bitmapIdTable, (char *) bitmap);
+ idHashPtr = Tcl_FindHashEntry(&dispPtr->bitmapIdTable, bitmap);
if (idHashPtr == NULL) {
goto unknown;
}
@@ -582,7 +584,7 @@ Tk_SizeOfBitmap(
Tcl_Panic("Tk_SizeOfBitmap received unknown bitmap argument");
}
- idHashPtr = Tcl_FindHashEntry(&dispPtr->bitmapIdTable, (char *) bitmap);
+ idHashPtr = Tcl_FindHashEntry(&dispPtr->bitmapIdTable, bitmap);
if (idHashPtr == NULL) {
goto unknownBitmap;
}
@@ -670,7 +672,7 @@ Tk_FreeBitmap(
Tcl_Panic("Tk_FreeBitmap called before Tk_GetBitmap");
}
- idHashPtr = Tcl_FindHashEntry(&dispPtr->bitmapIdTable, (char *) bitmap);
+ idHashPtr = Tcl_FindHashEntry(&dispPtr->bitmapIdTable, bitmap);
if (idHashPtr == NULL) {
Tcl_Panic("Tk_FreeBitmap received unknown bitmap argument");
}
@@ -909,7 +911,7 @@ GetBitmapFromObj(
Tcl_HashEntry *hashPtr;
TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
- if (objPtr->typePtr != &tkBitmapObjType) {
+ if (objPtr->typePtr != &tkBitmapObjType.objType) {
InitBitmapObj(objPtr);
}
@@ -984,7 +986,7 @@ InitBitmapObj(
if ((typePtr != NULL) && (typePtr->freeIntRepProc != NULL)) {
typePtr->freeIntRepProc(objPtr);
}
- objPtr->typePtr = &tkBitmapObjType;
+ objPtr->typePtr = &tkBitmapObjType.objType;
objPtr->internalRep.twoPtrValue.ptr1 = NULL;
}
@@ -1159,9 +1161,9 @@ TkDebugBitmap(
for ( ; (bitmapPtr != NULL); bitmapPtr = bitmapPtr->nextPtr) {
objPtr = Tcl_NewObj();
Tcl_ListObjAppendElement(NULL, objPtr,
- Tcl_NewIntObj(bitmapPtr->resourceRefCount));
+ Tcl_NewWideIntObj(bitmapPtr->resourceRefCount));
Tcl_ListObjAppendElement(NULL, objPtr,
- Tcl_NewIntObj(bitmapPtr->objRefCount));
+ Tcl_NewWideIntObj(bitmapPtr->objRefCount));
Tcl_ListObjAppendElement(NULL, resultPtr, objPtr);
}
}
diff --git a/generic/tkBusy.c b/generic/tkBusy.c
index 00ba73e..ffa1cb8 100644
--- a/generic/tkBusy.c
+++ b/generic/tkBusy.c
@@ -27,7 +27,7 @@
static const Tk_OptionSpec busyOptionSpecs[] = {
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_BUSY_CURSOR, -1, Tk_Offset(Busy, cursor),
+ DEF_BUSY_CURSOR, TCL_INDEX_NONE, offsetof(Busy, cursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0}
};
@@ -36,14 +36,14 @@ static const Tk_OptionSpec busyOptionSpecs[] = {
* Forward declarations of functions defined in this file.
*/
-static void BusyEventProc(ClientData clientData,
+static void BusyEventProc(void *clientData,
XEvent *eventPtr);
-static void BusyGeometryProc(ClientData clientData,
+static void BusyGeometryProc(void *clientData,
Tk_Window tkwin);
-static void BusyCustodyProc(ClientData clientData,
+static void BusyCustodyProc(void *clientData,
Tk_Window tkwin);
static int ConfigureBusy(Tcl_Interp *interp, Busy *busyPtr,
- int objc, Tcl_Obj *const objv[]);
+ Tcl_Size objc, Tcl_Obj *const objv[]);
static Busy * CreateBusy(Tcl_Interp *interp, Tk_Window tkRef);
static Tcl_FreeProc DestroyBusy;
static void DoConfigureNotify(Tk_FakeWin *winPtr);
@@ -53,14 +53,14 @@ static Busy * GetBusy(Tcl_Interp *interp,
Tcl_Obj *const windowObj);
static int HoldBusy(Tcl_HashTable *busyTablePtr,
Tcl_Interp *interp, Tcl_Obj *const windowObj,
- int configObjc, Tcl_Obj *const configObjv[]);
+ Tcl_Size configObjc, Tcl_Obj *const configObjv[]);
static void MakeTransparentWindowExist(Tk_Window tkwin,
Window parent);
static inline Tk_Window NextChild(Tk_Window tkwin);
-static void RefWinEventProc(ClientData clientData,
+static void RefWinEventProc(void *clientData,
XEvent *eventPtr);
static inline void SetWindowInstanceData(Tk_Window tkwin,
- ClientData instanceData);
+ void *instanceData);
/*
* The "busy" geometry manager definition.
@@ -100,7 +100,7 @@ NextChild(
static inline void
SetWindowInstanceData(
Tk_Window tkwin,
- ClientData instanceData)
+ void *instanceData)
{
struct TkWindow *winPtr = (struct TkWindow *) tkwin;
@@ -128,7 +128,7 @@ SetWindowInstanceData(
static void
BusyCustodyProc(
- ClientData clientData, /* Information about the busy window. */
+ void *clientData, /* Information about the busy window. */
TCL_UNUSED(Tk_Window)) /* Not used. */
{
Busy *busyPtr = (Busy *)clientData;
@@ -250,7 +250,7 @@ DoConfigureNotify(
static void
RefWinEventProc(
- ClientData clientData, /* Busy window record */
+ void *clientData, /* Busy window record */
XEvent *eventPtr) /* Event which triggered call to routine */
{
Busy *busyPtr = (Busy *)clientData;
@@ -333,7 +333,11 @@ RefWinEventProc(
static void
DestroyBusy(
- char *data) /* Busy window structure record */
+#if TCL_MAJOR_VERSION > 8
+ void *data) /* Busy window structure record */
+#else
+ char *data)
+#endif
{
Busy *busyPtr = (Busy *)data;
@@ -344,7 +348,7 @@ DestroyBusy(
RefWinEventProc, busyPtr);
if (busyPtr->tkBusy != NULL) {
- Tk_FreeConfigOptions((char *)data, busyPtr->optionTable, busyPtr->tkBusy);
+ Tk_FreeConfigOptions(data, busyPtr->optionTable, busyPtr->tkBusy);
Tk_DeleteEventHandler(busyPtr->tkBusy, StructureNotifyMask,
BusyEventProc, busyPtr);
Tk_ManageGeometry(busyPtr->tkBusy, NULL, busyPtr);
@@ -376,7 +380,7 @@ DestroyBusy(
static void
BusyEventProc(
- ClientData clientData, /* Busy window record */
+ void *clientData, /* Busy window record */
XEvent *eventPtr) /* Event which triggered call to routine */
{
Busy *busyPtr = (Busy *)clientData;
@@ -574,7 +578,7 @@ CreateBusy(
busyPtr->cursor = NULL;
Tk_SetClass(tkBusy, "Busy");
busyPtr->optionTable = Tk_CreateOptionTable(interp, busyOptionSpecs);
- if (Tk_InitOptions(interp, (char *) busyPtr, busyPtr->optionTable,
+ if (Tk_InitOptions(interp, busyPtr, busyPtr->optionTable,
tkBusy) != TCL_OK) {
Tk_DestroyWindow(tkBusy);
return NULL;
@@ -636,12 +640,12 @@ static int
ConfigureBusy(
Tcl_Interp *interp,
Busy *busyPtr,
- int objc,
+ Tcl_Size objc,
Tcl_Obj *const objv[])
{
Tk_Cursor oldCursor = busyPtr->cursor;
- if (Tk_SetOptions(interp, (char *) busyPtr, busyPtr->optionTable, objc,
+ if (Tk_SetOptions(interp, busyPtr, busyPtr->optionTable, objc,
objv, busyPtr->tkBusy, NULL, NULL) != TCL_OK) {
return TCL_ERROR;
}
@@ -690,12 +694,12 @@ GetBusy(
if (!tkwin || (TkGetWindowFromObj(interp, tkwin, windowObj, &tkwin) != TCL_OK)) {
return NULL;
}
- hPtr = Tcl_FindHashEntry(busyTablePtr, (char *) tkwin);
+ hPtr = Tcl_FindHashEntry(busyTablePtr, tkwin);
if (hPtr == NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't find busy window \"%s\"", Tcl_GetString(windowObj)));
Tcl_SetErrorCode(interp, "TK", "LOOKUP", "BUSY",
- Tcl_GetString(windowObj), NULL);
+ Tcl_GetString(windowObj), (char *)NULL);
return NULL;
}
return (Busy *)Tcl_GetHashValue(hPtr);
@@ -727,7 +731,7 @@ HoldBusy(
Tcl_HashTable *busyTablePtr,/* Busy hash table. */
Tcl_Interp *interp, /* Interpreter to report errors to. */
Tcl_Obj *const windowObj, /* Window name. */
- int configObjc, /* Option pairs. */
+ Tcl_Size configObjc, /* Option pairs. */
Tcl_Obj *const configObjv[])
{
Tk_Window tkwin;
@@ -765,6 +769,9 @@ HoldBusy(
} else {
TkpHideBusyWindow(busyPtr);
}
+ if (result == TCL_OK) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(Tk_PathName(busyPtr->tkBusy), TCL_INDEX_NONE));
+ }
return result;
}
@@ -787,9 +794,9 @@ HoldBusy(
int
Tk_BusyObjCmd(
- ClientData clientData, /* Main window associated with interpreter. */
+ void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tk_Window tkwin = (Tk_Window)clientData;
@@ -798,15 +805,16 @@ Tk_BusyObjCmd(
Tcl_Obj *objPtr;
int index, result = TCL_OK;
static const char *const optionStrings[] = {
- "cget", "configure", "current", "forget", "hold", "status", NULL
+ "busywindow", "cget", "configure", "current", "forget", "hold",
+ "status", NULL
};
enum options {
- BUSY_CGET, BUSY_CONFIGURE, BUSY_CURRENT, BUSY_FORGET, BUSY_HOLD,
- BUSY_STATUS
+ BUSY_BUSYWINDOW, BUSY_CGET, BUSY_CONFIGURE, BUSY_CURRENT, BUSY_FORGET,
+ BUSY_HOLD, BUSY_STATUS
};
if (objc < 2) {
- Tcl_WrongNumArgs(interp, 1, objv, "options ?arg arg ...?");
+ Tcl_WrongNumArgs(interp, 1, objv, "options ?arg ...?");
return TCL_ERROR;
}
@@ -816,7 +824,7 @@ Tk_BusyObjCmd(
if (Tcl_GetString(objv[1])[0] == '.') {
if (objc%2 == 1) {
- Tcl_WrongNumArgs(interp, 1, objv, "window ?option value ...?");
+ Tcl_WrongNumArgs(interp, 1, objv, "window ?-option value ...?");
return TCL_ERROR;
}
return HoldBusy(busyTablePtr, interp, objv[1], objc-2, objv+2);
@@ -827,6 +835,19 @@ Tk_BusyObjCmd(
return TCL_ERROR;
}
switch ((enum options) index) {
+ case BUSY_BUSYWINDOW:
+ if (objc != 3) {
+ Tcl_WrongNumArgs(interp, 2, objv, "window");
+ return TCL_ERROR;
+ }
+ busyPtr = GetBusy(interp, busyTablePtr, objv[2]);
+ if (busyPtr == NULL) {
+ Tcl_ResetResult(interp);
+ return TCL_OK;
+ }
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(Tk_PathName(busyPtr->tkBusy), TCL_INDEX_NONE));
+ return TCL_OK;
+
case BUSY_CGET:
if (objc != 4) {
Tcl_WrongNumArgs(interp, 2, objv, "window option");
@@ -837,7 +858,7 @@ Tk_BusyObjCmd(
return TCL_ERROR;
}
Tcl_Preserve(busyPtr);
- objPtr = Tk_GetOptionValue(interp, (char *) busyPtr,
+ objPtr = Tk_GetOptionValue(interp, busyPtr,
busyPtr->optionTable, objv[3], busyPtr->tkBusy);
if (objPtr == NULL) {
result = TCL_ERROR;
@@ -849,7 +870,7 @@ Tk_BusyObjCmd(
case BUSY_CONFIGURE:
if (objc < 3) {
- Tcl_WrongNumArgs(interp, 2, objv, "window ?option? ?value ...?");
+ Tcl_WrongNumArgs(interp, 2, objv, "window ?-option value ...?");
return TCL_ERROR;
}
busyPtr = GetBusy(interp, busyTablePtr, objv[2]);
@@ -858,7 +879,7 @@ Tk_BusyObjCmd(
}
Tcl_Preserve(busyPtr);
if (objc <= 4) {
- objPtr = Tk_GetOptionInfo(interp, (char *)busyPtr,
+ objPtr = Tk_GetOptionInfo(interp, busyPtr,
busyPtr->optionTable, (objc == 4) ? objv[3] : NULL,
busyPtr->tkBusy);
if (objPtr == NULL) {
@@ -884,7 +905,7 @@ Tk_BusyObjCmd(
if (pattern == NULL ||
Tcl_StringCaseMatch(Tk_PathName(busyPtr->tkRef), pattern, 0)) {
Tcl_ListObjAppendElement(interp, objPtr,
- TkNewWindowObj(busyPtr->tkRef));
+ Tk_NewWindowObj(busyPtr->tkRef));
}
}
Tcl_SetObjResult(interp, objPtr);
@@ -906,7 +927,7 @@ Tk_BusyObjCmd(
case BUSY_HOLD:
if (objc < 3 || objc%2 != 1) {
- Tcl_WrongNumArgs(interp, 2, objv, "window ?option value ...?");
+ Tcl_WrongNumArgs(interp, 2, objv, "window ?-option value ...?");
return TCL_ERROR;
}
return HoldBusy(busyTablePtr, interp, objv[2], objc-3, objv+3);
diff --git a/generic/tkButton.c b/generic/tkButton.c
index afb9973..9d033e4 100644
--- a/generic/tkButton.c
+++ b/generic/tkButton.c
@@ -5,8 +5,8 @@
* toolkit. The widgets implemented include buttons, checkbuttons,
* radiobuttons, and labels.
*
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1998 Sun Microsystems, Inc.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994-1998 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -61,413 +61,413 @@ char tkDefLabelPady[TCL_INTEGER_SPACE] = DEF_LABCHKRAD_PADY;
static const Tk_OptionSpec labelOptionSpecs[] = {
{TK_OPTION_BORDER, "-activebackground", "activeBackground", "Foreground",
- DEF_BUTTON_ACTIVE_BG_COLOR, -1, Tk_Offset(TkButton, activeBorder),
+ DEF_BUTTON_ACTIVE_BG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, activeBorder),
0, DEF_BUTTON_ACTIVE_BG_MONO, 0},
{TK_OPTION_COLOR, "-activeforeground", "activeForeground", "Background",
- DEF_BUTTON_ACTIVE_FG_COLOR, -1, Tk_Offset(TkButton, activeFg),
+ DEF_BUTTON_ACTIVE_FG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, activeFg),
TK_OPTION_NULL_OK, DEF_BUTTON_ACTIVE_FG_MONO, 0},
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
- DEF_BUTTON_ANCHOR, -1, Tk_Offset(TkButton, anchor), 0, 0, 0},
+ DEF_BUTTON_ANCHOR, TCL_INDEX_NONE, offsetof(TkButton, anchor), TK_OPTION_ENUM_VAR, 0, 0},
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_BUTTON_BG_COLOR, -1, Tk_Offset(TkButton, normalBorder),
+ DEF_BUTTON_BG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, normalBorder),
0, DEF_BUTTON_BG_MONO, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL,
- NULL, 0, -1, 0, "-background", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_BITMAP, "-bitmap", "bitmap", "Bitmap",
- DEF_BUTTON_BITMAP, -1, Tk_Offset(TkButton, bitmap),
+ DEF_BUTTON_BITMAP, TCL_INDEX_NONE, offsetof(TkButton, bitmap),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- tkDefButtonBorderWidth, Tk_Offset(TkButton, borderWidthPtr),
- Tk_Offset(TkButton, borderWidth), 0, 0, 0},
+ tkDefButtonBorderWidth, offsetof(TkButton, borderWidthPtr),
+ offsetof(TkButton, borderWidth), 0, 0, 0},
{TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound",
- DEF_BUTTON_COMPOUND, -1, Tk_Offset(TkButton, compound),
+ DEF_BUTTON_COMPOUND, TCL_INDEX_NONE, offsetof(TkButton, compound),
0, tkCompoundStrings, 0},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_BUTTON_CURSOR, -1, Tk_Offset(TkButton, cursor),
+ DEF_BUTTON_CURSOR, TCL_INDEX_NONE, offsetof(TkButton, cursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_COLOR, "-disabledforeground", "disabledForeground",
"DisabledForeground", DEF_BUTTON_DISABLED_FG_COLOR,
- -1, Tk_Offset(TkButton, disabledFg), TK_OPTION_NULL_OK,
+ TCL_INDEX_NONE, offsetof(TkButton, disabledFg), TK_OPTION_NULL_OK,
DEF_BUTTON_DISABLED_FG_MONO, 0},
{TK_OPTION_SYNONYM, "-fg", "foreground", NULL,
- NULL, 0, -1, 0, "-foreground", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_BUTTON_FONT, -1, Tk_Offset(TkButton, tkfont), 0, 0, 0},
+ DEF_BUTTON_FONT, TCL_INDEX_NONE, offsetof(TkButton, tkfont), 0, 0, 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_LABEL_FG, -1, Tk_Offset(TkButton, normalFg), 0, 0, 0},
+ DEF_LABEL_FG, TCL_INDEX_NONE, offsetof(TkButton, normalFg), 0, 0, 0},
{TK_OPTION_STRING, "-height", "height", "Height",
- DEF_BUTTON_HEIGHT, Tk_Offset(TkButton, heightPtr), -1, 0, 0, 0},
+ DEF_BUTTON_HEIGHT, offsetof(TkButton, heightPtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_BORDER, "-highlightbackground", "highlightBackground",
"HighlightBackground", DEF_BUTTON_HIGHLIGHT_BG_COLOR,
- -1, Tk_Offset(TkButton, highlightBorder), 0,
+ TCL_INDEX_NONE, offsetof(TkButton, highlightBorder), 0,
DEF_BUTTON_HIGHLIGHT_BG_MONO, 0},
{TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_BUTTON_HIGHLIGHT, -1, Tk_Offset(TkButton, highlightColorPtr),
+ DEF_BUTTON_HIGHLIGHT, TCL_INDEX_NONE, offsetof(TkButton, highlightColorPtr),
0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
"HighlightThickness", tkDefLabelHighlightWidth,
- Tk_Offset(TkButton, highlightWidthPtr),
- Tk_Offset(TkButton, highlightWidth), 0, 0, 0},
+ offsetof(TkButton, highlightWidthPtr),
+ offsetof(TkButton, highlightWidth), 0, 0, 0},
{TK_OPTION_STRING, "-image", "image", "Image",
- DEF_BUTTON_IMAGE, Tk_Offset(TkButton, imagePtr), -1,
+ DEF_BUTTON_IMAGE, offsetof(TkButton, imagePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
- DEF_BUTTON_JUSTIFY, -1, Tk_Offset(TkButton, justify), 0, 0, 0},
+ DEF_BUTTON_JUSTIFY, TCL_INDEX_NONE, offsetof(TkButton, justify), TK_OPTION_ENUM_VAR, 0, 0},
{TK_OPTION_PIXELS, "-padx", "padX", "Pad",
- tkDefLabelPadx, Tk_Offset(TkButton, padXPtr),
- Tk_Offset(TkButton, padX), 0, 0, 0},
+ tkDefLabelPadx, offsetof(TkButton, padXPtr),
+ offsetof(TkButton, padX), 0, 0, 0},
{TK_OPTION_PIXELS, "-pady", "padY", "Pad",
- tkDefLabelPady, Tk_Offset(TkButton, padYPtr),
- Tk_Offset(TkButton, padY), 0, 0, 0},
+ tkDefLabelPady, offsetof(TkButton, padYPtr),
+ offsetof(TkButton, padY), 0, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_LABCHKRAD_RELIEF, -1, Tk_Offset(TkButton, relief), 0, 0, 0},
+ DEF_LABCHKRAD_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, relief), 0, 0, 0},
{TK_OPTION_STRING_TABLE, "-state", "state", "State",
- DEF_BUTTON_STATE, -1, Tk_Offset(TkButton, state),
+ DEF_BUTTON_STATE, TCL_INDEX_NONE, offsetof(TkButton, state),
TK_OPTION_ENUM_VAR, tkStateStrings, 0},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_LABEL_TAKE_FOCUS, Tk_Offset(TkButton, takeFocusPtr), -1,
+ DEF_LABEL_TAKE_FOCUS, offsetof(TkButton, takeFocusPtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-text", "text", "Text",
- DEF_BUTTON_TEXT, Tk_Offset(TkButton, textPtr), -1, 0, 0, 0},
+ DEF_BUTTON_TEXT, offsetof(TkButton, textPtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_STRING, "-textvariable", "textVariable", "Variable",
- DEF_BUTTON_TEXT_VARIABLE, Tk_Offset(TkButton, textVarNamePtr), -1,
+ DEF_BUTTON_TEXT_VARIABLE, offsetof(TkButton, textVarNamePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
- {TK_OPTION_INT, "-underline", "underline", "Underline",
- DEF_BUTTON_UNDERLINE, -1, Tk_Offset(TkButton, underline), 0, 0, 0},
+ {TK_OPTION_INDEX, "-underline", "underline", "Underline",
+ TK_OPTION_UNDERLINE_DEF(TkButton, underline), 0},
{TK_OPTION_STRING, "-width", "width", "Width",
- DEF_BUTTON_WIDTH, Tk_Offset(TkButton, widthPtr), -1, 0, 0, 0},
+ DEF_BUTTON_WIDTH, offsetof(TkButton, widthPtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength",
- DEF_BUTTON_WRAP_LENGTH, Tk_Offset(TkButton, wrapLengthPtr),
- Tk_Offset(TkButton, wrapLength), 0, 0, 0},
+ DEF_BUTTON_WRAP_LENGTH, offsetof(TkButton, wrapLengthPtr),
+ offsetof(TkButton, wrapLength), 0, 0, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0}
};
static const Tk_OptionSpec buttonOptionSpecs[] = {
{TK_OPTION_BORDER, "-activebackground", "activeBackground", "Foreground",
- DEF_BUTTON_ACTIVE_BG_COLOR, -1, Tk_Offset(TkButton, activeBorder),
+ DEF_BUTTON_ACTIVE_BG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, activeBorder),
0, DEF_BUTTON_ACTIVE_BG_MONO, 0},
{TK_OPTION_COLOR, "-activeforeground", "activeForeground", "Background",
- DEF_BUTTON_ACTIVE_FG_COLOR, -1, Tk_Offset(TkButton, activeFg),
+ DEF_BUTTON_ACTIVE_FG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, activeFg),
TK_OPTION_NULL_OK, DEF_BUTTON_ACTIVE_FG_MONO, 0},
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
- DEF_BUTTON_ANCHOR, -1, Tk_Offset(TkButton, anchor), 0, 0, 0},
+ DEF_BUTTON_ANCHOR, TCL_INDEX_NONE, offsetof(TkButton, anchor), TK_OPTION_ENUM_VAR, 0, 0},
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_BUTTON_BG_COLOR, -1, Tk_Offset(TkButton, normalBorder),
+ DEF_BUTTON_BG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, normalBorder),
0, DEF_BUTTON_BG_MONO, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL,
- NULL, 0, -1, 0, "-background", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_BITMAP, "-bitmap", "bitmap", "Bitmap",
- DEF_BUTTON_BITMAP, -1, Tk_Offset(TkButton, bitmap),
+ DEF_BUTTON_BITMAP, TCL_INDEX_NONE, offsetof(TkButton, bitmap),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- tkDefButtonBorderWidth, Tk_Offset(TkButton, borderWidthPtr),
- Tk_Offset(TkButton, borderWidth), 0, 0, 0},
+ tkDefButtonBorderWidth, offsetof(TkButton, borderWidthPtr),
+ offsetof(TkButton, borderWidth), 0, 0, 0},
{TK_OPTION_STRING, "-command", "command", "Command",
- DEF_BUTTON_COMMAND, Tk_Offset(TkButton, commandPtr), -1,
+ DEF_BUTTON_COMMAND, offsetof(TkButton, commandPtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound",
- DEF_BUTTON_COMPOUND, -1, Tk_Offset(TkButton, compound),
+ DEF_BUTTON_COMPOUND, TCL_INDEX_NONE, offsetof(TkButton, compound),
0, tkCompoundStrings, 0},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_BUTTON_CURSOR, -1, Tk_Offset(TkButton, cursor),
+ DEF_BUTTON_CURSOR, TCL_INDEX_NONE, offsetof(TkButton, cursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING_TABLE, "-default", "default", "Default",
- DEF_BUTTON_DEFAULT, -1, Tk_Offset(TkButton, defaultState),
+ DEF_BUTTON_DEFAULT, TCL_INDEX_NONE, offsetof(TkButton, defaultState),
TK_OPTION_ENUM_VAR, tkStateStrings, 0},
{TK_OPTION_COLOR, "-disabledforeground", "disabledForeground",
"DisabledForeground", DEF_BUTTON_DISABLED_FG_COLOR,
- -1, Tk_Offset(TkButton, disabledFg), TK_OPTION_NULL_OK,
+ TCL_INDEX_NONE, offsetof(TkButton, disabledFg), TK_OPTION_NULL_OK,
DEF_BUTTON_DISABLED_FG_MONO, 0},
{TK_OPTION_SYNONYM, "-fg", "foreground", NULL,
- NULL, 0, -1, 0, "-foreground", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_BUTTON_FONT, -1, Tk_Offset(TkButton, tkfont), 0, 0, 0},
+ DEF_BUTTON_FONT, TCL_INDEX_NONE, offsetof(TkButton, tkfont), 0, 0, 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_BUTTON_FG, -1, Tk_Offset(TkButton, normalFg), 0, 0, 0},
+ DEF_BUTTON_FG, TCL_INDEX_NONE, offsetof(TkButton, normalFg), 0, 0, 0},
{TK_OPTION_STRING, "-height", "height", "Height",
- DEF_BUTTON_HEIGHT, Tk_Offset(TkButton, heightPtr), -1, 0, 0, 0},
+ DEF_BUTTON_HEIGHT, offsetof(TkButton, heightPtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_BORDER, "-highlightbackground", "highlightBackground",
"HighlightBackground", DEF_BUTTON_HIGHLIGHT_BG_COLOR,
- -1, Tk_Offset(TkButton, highlightBorder), 0,
+ TCL_INDEX_NONE, offsetof(TkButton, highlightBorder), 0,
DEF_BUTTON_HIGHLIGHT_BG_MONO, 0},
{TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_BUTTON_HIGHLIGHT, -1, Tk_Offset(TkButton, highlightColorPtr),
+ DEF_BUTTON_HIGHLIGHT, TCL_INDEX_NONE, offsetof(TkButton, highlightColorPtr),
0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
"HighlightThickness", tkDefButtonHighlightWidth,
- Tk_Offset(TkButton, highlightWidthPtr),
- Tk_Offset(TkButton, highlightWidth), 0, 0, 0},
+ offsetof(TkButton, highlightWidthPtr),
+ offsetof(TkButton, highlightWidth), 0, 0, 0},
{TK_OPTION_STRING, "-image", "image", "Image",
- DEF_BUTTON_IMAGE, Tk_Offset(TkButton, imagePtr), -1,
+ DEF_BUTTON_IMAGE, offsetof(TkButton, imagePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
- DEF_BUTTON_JUSTIFY, -1, Tk_Offset(TkButton, justify), 0, 0, 0},
+ DEF_BUTTON_JUSTIFY, TCL_INDEX_NONE, offsetof(TkButton, justify), TK_OPTION_ENUM_VAR, 0, 0},
{TK_OPTION_RELIEF, "-overrelief", "overRelief", "OverRelief",
- DEF_BUTTON_OVER_RELIEF, -1, Tk_Offset(TkButton, overRelief),
+ DEF_BUTTON_OVER_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, overRelief),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-padx", "padX", "Pad",
- tkDefButtonPadx, Tk_Offset(TkButton, padXPtr),
- Tk_Offset(TkButton, padX), 0, 0, 0},
+ tkDefButtonPadx, offsetof(TkButton, padXPtr),
+ offsetof(TkButton, padX), 0, 0, 0},
{TK_OPTION_PIXELS, "-pady", "padY", "Pad",
- tkDefButtonPady, Tk_Offset(TkButton, padYPtr),
- Tk_Offset(TkButton, padY), 0, 0, 0},
+ tkDefButtonPady, offsetof(TkButton, padYPtr),
+ offsetof(TkButton, padY), 0, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_BUTTON_RELIEF, -1, Tk_Offset(TkButton, relief),
+ DEF_BUTTON_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, relief),
0, 0, 0},
{TK_OPTION_INT, "-repeatdelay", "repeatDelay", "RepeatDelay",
- DEF_BUTTON_REPEAT_DELAY, -1, Tk_Offset(TkButton, repeatDelay),
+ DEF_BUTTON_REPEAT_DELAY, TCL_INDEX_NONE, offsetof(TkButton, repeatDelay),
0, 0, 0},
{TK_OPTION_INT, "-repeatinterval", "repeatInterval", "RepeatInterval",
- DEF_BUTTON_REPEAT_INTERVAL, -1, Tk_Offset(TkButton, repeatInterval),
+ DEF_BUTTON_REPEAT_INTERVAL, TCL_INDEX_NONE, offsetof(TkButton, repeatInterval),
0, 0, 0},
{TK_OPTION_STRING_TABLE, "-state", "state", "State",
- DEF_BUTTON_STATE, -1, Tk_Offset(TkButton, state),
+ DEF_BUTTON_STATE, TCL_INDEX_NONE, offsetof(TkButton, state),
TK_OPTION_ENUM_VAR, tkStateStrings, 0},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_BUTTON_TAKE_FOCUS, Tk_Offset(TkButton, takeFocusPtr), -1,
+ DEF_BUTTON_TAKE_FOCUS, offsetof(TkButton, takeFocusPtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-text", "text", "Text",
- DEF_BUTTON_TEXT, Tk_Offset(TkButton, textPtr), -1, 0, 0, 0},
+ DEF_BUTTON_TEXT, offsetof(TkButton, textPtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_STRING, "-textvariable", "textVariable", "Variable",
- DEF_BUTTON_TEXT_VARIABLE, Tk_Offset(TkButton, textVarNamePtr), -1,
+ DEF_BUTTON_TEXT_VARIABLE, offsetof(TkButton, textVarNamePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
- {TK_OPTION_INT, "-underline", "underline", "Underline",
- DEF_BUTTON_UNDERLINE, -1, Tk_Offset(TkButton, underline), 0, 0, 0},
+ {TK_OPTION_INDEX, "-underline", "underline", "Underline",
+ TK_OPTION_UNDERLINE_DEF(TkButton, underline), 0},
{TK_OPTION_STRING, "-width", "width", "Width",
- DEF_BUTTON_WIDTH, Tk_Offset(TkButton, widthPtr), -1, 0, 0, 0},
+ DEF_BUTTON_WIDTH, offsetof(TkButton, widthPtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength",
- DEF_BUTTON_WRAP_LENGTH, Tk_Offset(TkButton, wrapLengthPtr),
- Tk_Offset(TkButton, wrapLength), 0, 0, 0},
- {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0}
+ DEF_BUTTON_WRAP_LENGTH, offsetof(TkButton, wrapLengthPtr),
+ offsetof(TkButton, wrapLength), 0, 0, 0},
+ {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0}
};
static const Tk_OptionSpec checkbuttonOptionSpecs[] = {
{TK_OPTION_BORDER, "-activebackground", "activeBackground", "Foreground",
- DEF_BUTTON_ACTIVE_BG_COLOR, -1, Tk_Offset(TkButton, activeBorder),
+ DEF_BUTTON_ACTIVE_BG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, activeBorder),
0, DEF_BUTTON_ACTIVE_BG_MONO, 0},
{TK_OPTION_COLOR, "-activeforeground", "activeForeground", "Background",
- DEF_CHKRAD_ACTIVE_FG_COLOR, -1, Tk_Offset(TkButton, activeFg),
+ DEF_CHKRAD_ACTIVE_FG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, activeFg),
TK_OPTION_NULL_OK, DEF_BUTTON_ACTIVE_FG_MONO, 0},
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
- DEF_BUTTON_ANCHOR, -1, Tk_Offset(TkButton, anchor), 0, 0, 0},
+ DEF_BUTTON_ANCHOR, TCL_INDEX_NONE, offsetof(TkButton, anchor), TK_OPTION_ENUM_VAR, 0, 0},
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_BUTTON_BG_COLOR, -1, Tk_Offset(TkButton, normalBorder),
+ DEF_BUTTON_BG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, normalBorder),
0, DEF_BUTTON_BG_MONO, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL,
- NULL, 0, -1, 0, "-background", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_BITMAP, "-bitmap", "bitmap", "Bitmap",
- DEF_BUTTON_BITMAP, -1, Tk_Offset(TkButton, bitmap),
+ DEF_BUTTON_BITMAP, TCL_INDEX_NONE, offsetof(TkButton, bitmap),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- tkDefButtonBorderWidth, Tk_Offset(TkButton, borderWidthPtr),
- Tk_Offset(TkButton, borderWidth), 0, 0, 0},
+ tkDefButtonBorderWidth, offsetof(TkButton, borderWidthPtr),
+ offsetof(TkButton, borderWidth), 0, 0, 0},
{TK_OPTION_STRING, "-command", "command", "Command",
- DEF_BUTTON_COMMAND, Tk_Offset(TkButton, commandPtr), -1,
+ DEF_BUTTON_COMMAND, offsetof(TkButton, commandPtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound",
- DEF_BUTTON_COMPOUND, -1, Tk_Offset(TkButton, compound),
+ DEF_BUTTON_COMPOUND, TCL_INDEX_NONE, offsetof(TkButton, compound),
0, tkCompoundStrings, 0},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_BUTTON_CURSOR, -1, Tk_Offset(TkButton, cursor),
+ DEF_BUTTON_CURSOR, TCL_INDEX_NONE, offsetof(TkButton, cursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_COLOR, "-disabledforeground", "disabledForeground",
"DisabledForeground", DEF_BUTTON_DISABLED_FG_COLOR,
- -1, Tk_Offset(TkButton, disabledFg), TK_OPTION_NULL_OK,
+ TCL_INDEX_NONE, offsetof(TkButton, disabledFg), TK_OPTION_NULL_OK,
DEF_BUTTON_DISABLED_FG_MONO, 0},
{TK_OPTION_SYNONYM, "-fg", "foreground", NULL,
- NULL, 0, -1, 0, "-foreground", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_BUTTON_FONT, -1, Tk_Offset(TkButton, tkfont), 0, 0, 0},
+ DEF_BUTTON_FONT, TCL_INDEX_NONE, offsetof(TkButton, tkfont), 0, 0, 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_CHKRAD_FG, -1, Tk_Offset(TkButton, normalFg), 0, 0, 0},
+ DEF_CHKRAD_FG, TCL_INDEX_NONE, offsetof(TkButton, normalFg), 0, 0, 0},
{TK_OPTION_STRING, "-height", "height", "Height",
- DEF_BUTTON_HEIGHT, Tk_Offset(TkButton, heightPtr), -1, 0, 0, 0},
+ DEF_BUTTON_HEIGHT, offsetof(TkButton, heightPtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_BORDER, "-highlightbackground", "highlightBackground",
"HighlightBackground", DEF_BUTTON_HIGHLIGHT_BG_COLOR,
- -1, Tk_Offset(TkButton, highlightBorder), 0,
+ TCL_INDEX_NONE, offsetof(TkButton, highlightBorder), 0,
DEF_BUTTON_HIGHLIGHT_BG_MONO, 0},
{TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_BUTTON_HIGHLIGHT, -1, Tk_Offset(TkButton, highlightColorPtr),
+ DEF_BUTTON_HIGHLIGHT, TCL_INDEX_NONE, offsetof(TkButton, highlightColorPtr),
0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
"HighlightThickness", tkDefButtonHighlightWidth,
- Tk_Offset(TkButton, highlightWidthPtr),
- Tk_Offset(TkButton, highlightWidth), 0, 0, 0},
+ offsetof(TkButton, highlightWidthPtr),
+ offsetof(TkButton, highlightWidth), 0, 0, 0},
{TK_OPTION_STRING, "-image", "image", "Image",
- DEF_BUTTON_IMAGE, Tk_Offset(TkButton, imagePtr), -1,
+ DEF_BUTTON_IMAGE, offsetof(TkButton, imagePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_BOOLEAN, "-indicatoron", "indicatorOn", "IndicatorOn",
- DEF_BUTTON_INDICATOR, -1, Tk_Offset(TkButton, indicatorOn), 0, 0, 0},
+ DEF_BUTTON_INDICATOR, TCL_INDEX_NONE, offsetof(TkButton, indicatorOn), 0, 0, 0},
{TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
- DEF_BUTTON_JUSTIFY, -1, Tk_Offset(TkButton, justify), 0, 0, 0},
+ DEF_BUTTON_JUSTIFY, TCL_INDEX_NONE, offsetof(TkButton, justify), TK_OPTION_ENUM_VAR, 0, 0},
{TK_OPTION_RELIEF, "-offrelief", "offRelief", "OffRelief",
- DEF_BUTTON_RELIEF, -1, Tk_Offset(TkButton, offRelief), 0, 0, 0},
+ DEF_BUTTON_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, offRelief), 0, 0, 0},
{TK_OPTION_STRING, "-offvalue", "offValue", "Value",
- DEF_BUTTON_OFF_VALUE, Tk_Offset(TkButton, offValuePtr), -1, 0, 0, 0},
+ DEF_BUTTON_OFF_VALUE, offsetof(TkButton, offValuePtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_STRING, "-onvalue", "onValue", "Value",
- DEF_BUTTON_ON_VALUE, Tk_Offset(TkButton, onValuePtr), -1, 0, 0, 0},
+ DEF_BUTTON_ON_VALUE, offsetof(TkButton, onValuePtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_RELIEF, "-overrelief", "overRelief", "OverRelief",
- DEF_BUTTON_OVER_RELIEF, -1, Tk_Offset(TkButton, overRelief),
+ DEF_BUTTON_OVER_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, overRelief),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-padx", "padX", "Pad",
- tkDefLabelPadx, Tk_Offset(TkButton, padXPtr),
- Tk_Offset(TkButton, padX), 0, 0, 0},
+ tkDefLabelPadx, offsetof(TkButton, padXPtr),
+ offsetof(TkButton, padX), 0, 0, 0},
{TK_OPTION_PIXELS, "-pady", "padY", "Pad",
- tkDefLabelPady, Tk_Offset(TkButton, padYPtr),
- Tk_Offset(TkButton, padY), 0, 0, 0},
+ tkDefLabelPady, offsetof(TkButton, padYPtr),
+ offsetof(TkButton, padY), 0, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_LABCHKRAD_RELIEF, -1, Tk_Offset(TkButton, relief), 0, 0, 0},
+ DEF_LABCHKRAD_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, relief), 0, 0, 0},
{TK_OPTION_BORDER, "-selectcolor", "selectColor", "Background",
- DEF_BUTTON_SELECT_COLOR, -1, Tk_Offset(TkButton, selectBorder),
+ DEF_BUTTON_SELECT_COLOR, TCL_INDEX_NONE, offsetof(TkButton, selectBorder),
TK_OPTION_NULL_OK, DEF_BUTTON_SELECT_MONO, 0},
{TK_OPTION_STRING, "-selectimage", "selectImage", "SelectImage",
- DEF_BUTTON_SELECT_IMAGE, Tk_Offset(TkButton, selectImagePtr), -1,
+ DEF_BUTTON_SELECT_IMAGE, offsetof(TkButton, selectImagePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING_TABLE, "-state", "state", "State",
- DEF_BUTTON_STATE, -1, Tk_Offset(TkButton, state),
+ DEF_BUTTON_STATE, TCL_INDEX_NONE, offsetof(TkButton, state),
TK_OPTION_ENUM_VAR, tkStateStrings, 0},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_BUTTON_TAKE_FOCUS, Tk_Offset(TkButton, takeFocusPtr), -1,
+ DEF_BUTTON_TAKE_FOCUS, offsetof(TkButton, takeFocusPtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-text", "text", "Text",
- DEF_BUTTON_TEXT, Tk_Offset(TkButton, textPtr), -1, 0, 0, 0},
+ DEF_BUTTON_TEXT, offsetof(TkButton, textPtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_STRING, "-textvariable", "textVariable", "Variable",
- DEF_BUTTON_TEXT_VARIABLE, Tk_Offset(TkButton, textVarNamePtr), -1,
+ DEF_BUTTON_TEXT_VARIABLE, offsetof(TkButton, textVarNamePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-tristateimage", "tristateImage", "TristateImage",
- DEF_BUTTON_IMAGE, Tk_Offset(TkButton, tristateImagePtr), -1,
+ DEF_BUTTON_IMAGE, offsetof(TkButton, tristateImagePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-tristatevalue", "tristateValue", "TristateValue",
- DEF_BUTTON_TRISTATE_VALUE, Tk_Offset(TkButton, tristateValuePtr), -1, 0, 0, 0},
- {TK_OPTION_INT, "-underline", "underline", "Underline",
- DEF_BUTTON_UNDERLINE, -1, Tk_Offset(TkButton, underline), 0, 0, 0},
+ DEF_BUTTON_TRISTATE_VALUE, offsetof(TkButton, tristateValuePtr), TCL_INDEX_NONE, 0, 0, 0},
+ {TK_OPTION_INDEX, "-underline", "underline", "Underline",
+ TK_OPTION_UNDERLINE_DEF(TkButton, underline), 0},
{TK_OPTION_STRING, "-variable", "variable", "Variable",
- DEF_CHECKBUTTON_VARIABLE, Tk_Offset(TkButton, selVarNamePtr), -1,
+ DEF_CHECKBUTTON_VARIABLE, offsetof(TkButton, selVarNamePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-width", "width", "Width",
- DEF_BUTTON_WIDTH, Tk_Offset(TkButton, widthPtr), -1, 0, 0, 0},
+ DEF_BUTTON_WIDTH, offsetof(TkButton, widthPtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength",
- DEF_BUTTON_WRAP_LENGTH, Tk_Offset(TkButton, wrapLengthPtr),
- Tk_Offset(TkButton, wrapLength), 0, 0, 0},
- {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0}
+ DEF_BUTTON_WRAP_LENGTH, offsetof(TkButton, wrapLengthPtr),
+ offsetof(TkButton, wrapLength), 0, 0, 0},
+ {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0}
};
static const Tk_OptionSpec radiobuttonOptionSpecs[] = {
{TK_OPTION_BORDER, "-activebackground", "activeBackground", "Foreground",
- DEF_BUTTON_ACTIVE_BG_COLOR, -1, Tk_Offset(TkButton, activeBorder),
+ DEF_BUTTON_ACTIVE_BG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, activeBorder),
0, DEF_BUTTON_ACTIVE_BG_MONO, 0},
{TK_OPTION_COLOR, "-activeforeground", "activeForeground", "Background",
- DEF_CHKRAD_ACTIVE_FG_COLOR, -1, Tk_Offset(TkButton, activeFg),
+ DEF_CHKRAD_ACTIVE_FG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, activeFg),
TK_OPTION_NULL_OK, DEF_BUTTON_ACTIVE_FG_MONO, 0},
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
- DEF_BUTTON_ANCHOR, -1, Tk_Offset(TkButton, anchor), 0, 0, 0},
+ DEF_BUTTON_ANCHOR, TCL_INDEX_NONE, offsetof(TkButton, anchor), TK_OPTION_ENUM_VAR, 0, 0},
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_BUTTON_BG_COLOR, -1, Tk_Offset(TkButton, normalBorder),
+ DEF_BUTTON_BG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, normalBorder),
0, DEF_BUTTON_BG_MONO, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL,
- NULL, 0, -1, 0, "-background", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_BITMAP, "-bitmap", "bitmap", "Bitmap",
- DEF_BUTTON_BITMAP, -1, Tk_Offset(TkButton, bitmap),
+ DEF_BUTTON_BITMAP, TCL_INDEX_NONE, offsetof(TkButton, bitmap),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- tkDefButtonBorderWidth, Tk_Offset(TkButton, borderWidthPtr),
- Tk_Offset(TkButton, borderWidth), 0, 0, 0},
+ tkDefButtonBorderWidth, offsetof(TkButton, borderWidthPtr),
+ offsetof(TkButton, borderWidth), 0, 0, 0},
{TK_OPTION_STRING, "-command", "command", "Command",
- DEF_BUTTON_COMMAND, Tk_Offset(TkButton, commandPtr), -1,
+ DEF_BUTTON_COMMAND, offsetof(TkButton, commandPtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound",
- DEF_BUTTON_COMPOUND, -1, Tk_Offset(TkButton, compound),
+ DEF_BUTTON_COMPOUND, TCL_INDEX_NONE, offsetof(TkButton, compound),
0, tkCompoundStrings, 0},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_BUTTON_CURSOR, -1, Tk_Offset(TkButton, cursor),
+ DEF_BUTTON_CURSOR, TCL_INDEX_NONE, offsetof(TkButton, cursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_COLOR, "-disabledforeground", "disabledForeground",
"DisabledForeground", DEF_BUTTON_DISABLED_FG_COLOR,
- -1, Tk_Offset(TkButton, disabledFg), TK_OPTION_NULL_OK,
+ TCL_INDEX_NONE, offsetof(TkButton, disabledFg), TK_OPTION_NULL_OK,
DEF_BUTTON_DISABLED_FG_MONO, 0},
{TK_OPTION_SYNONYM, "-fg", "foreground", NULL,
- NULL, 0, -1, 0, "-foreground", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_BUTTON_FONT, -1, Tk_Offset(TkButton, tkfont), 0, 0, 0},
+ DEF_BUTTON_FONT, TCL_INDEX_NONE, offsetof(TkButton, tkfont), 0, 0, 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_CHKRAD_FG, -1, Tk_Offset(TkButton, normalFg), 0, 0, 0},
+ DEF_CHKRAD_FG, TCL_INDEX_NONE, offsetof(TkButton, normalFg), 0, 0, 0},
{TK_OPTION_STRING, "-height", "height", "Height",
- DEF_BUTTON_HEIGHT, Tk_Offset(TkButton, heightPtr), -1, 0, 0, 0},
+ DEF_BUTTON_HEIGHT, offsetof(TkButton, heightPtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_BORDER, "-highlightbackground", "highlightBackground",
"HighlightBackground", DEF_BUTTON_HIGHLIGHT_BG_COLOR,
- -1, Tk_Offset(TkButton, highlightBorder), 0,
+ TCL_INDEX_NONE, offsetof(TkButton, highlightBorder), 0,
DEF_BUTTON_HIGHLIGHT_BG_MONO, 0},
{TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_BUTTON_HIGHLIGHT, -1, Tk_Offset(TkButton, highlightColorPtr),
+ DEF_BUTTON_HIGHLIGHT, TCL_INDEX_NONE, offsetof(TkButton, highlightColorPtr),
0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
"HighlightThickness", tkDefButtonHighlightWidth,
- Tk_Offset(TkButton, highlightWidthPtr),
- Tk_Offset(TkButton, highlightWidth), 0, 0, 0},
+ offsetof(TkButton, highlightWidthPtr),
+ offsetof(TkButton, highlightWidth), 0, 0, 0},
{TK_OPTION_STRING, "-image", "image", "Image",
- DEF_BUTTON_IMAGE, Tk_Offset(TkButton, imagePtr), -1,
+ DEF_BUTTON_IMAGE, offsetof(TkButton, imagePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_BOOLEAN, "-indicatoron", "indicatorOn", "IndicatorOn",
- DEF_BUTTON_INDICATOR, -1, Tk_Offset(TkButton, indicatorOn),
+ DEF_BUTTON_INDICATOR, TCL_INDEX_NONE, offsetof(TkButton, indicatorOn),
0, 0, 0},
{TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
- DEF_BUTTON_JUSTIFY, -1, Tk_Offset(TkButton, justify), 0, 0, 0},
+ DEF_BUTTON_JUSTIFY, TCL_INDEX_NONE, offsetof(TkButton, justify), TK_OPTION_ENUM_VAR, 0, 0},
{TK_OPTION_RELIEF, "-offrelief", "offRelief", "OffRelief",
- DEF_BUTTON_RELIEF, -1, Tk_Offset(TkButton, offRelief), 0, 0, 0},
+ DEF_BUTTON_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, offRelief), 0, 0, 0},
{TK_OPTION_RELIEF, "-overrelief", "overRelief", "OverRelief",
- DEF_BUTTON_OVER_RELIEF, -1, Tk_Offset(TkButton, overRelief),
+ DEF_BUTTON_OVER_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, overRelief),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-padx", "padX", "Pad",
- tkDefLabelPadx, Tk_Offset(TkButton, padXPtr),
- Tk_Offset(TkButton, padX), 0, 0, 0},
+ tkDefLabelPadx, offsetof(TkButton, padXPtr),
+ offsetof(TkButton, padX), 0, 0, 0},
{TK_OPTION_PIXELS, "-pady", "padY", "Pad",
- tkDefLabelPady, Tk_Offset(TkButton, padYPtr),
- Tk_Offset(TkButton, padY), 0, 0, 0},
+ tkDefLabelPady, offsetof(TkButton, padYPtr),
+ offsetof(TkButton, padY), 0, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_LABCHKRAD_RELIEF, -1, Tk_Offset(TkButton, relief), 0, 0, 0},
+ DEF_LABCHKRAD_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, relief), 0, 0, 0},
{TK_OPTION_BORDER, "-selectcolor", "selectColor", "Background",
- DEF_BUTTON_SELECT_COLOR, -1, Tk_Offset(TkButton, selectBorder),
+ DEF_BUTTON_SELECT_COLOR, TCL_INDEX_NONE, offsetof(TkButton, selectBorder),
TK_OPTION_NULL_OK, DEF_BUTTON_SELECT_MONO, 0},
{TK_OPTION_STRING, "-selectimage", "selectImage", "SelectImage",
- DEF_BUTTON_SELECT_IMAGE, Tk_Offset(TkButton, selectImagePtr), -1,
+ DEF_BUTTON_SELECT_IMAGE, offsetof(TkButton, selectImagePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING_TABLE, "-state", "state", "State",
- DEF_BUTTON_STATE, -1, Tk_Offset(TkButton, state),
+ DEF_BUTTON_STATE, TCL_INDEX_NONE, offsetof(TkButton, state),
TK_OPTION_ENUM_VAR, tkStateStrings, 0},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_BUTTON_TAKE_FOCUS, Tk_Offset(TkButton, takeFocusPtr), -1,
+ DEF_BUTTON_TAKE_FOCUS, offsetof(TkButton, takeFocusPtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-text", "text", "Text",
- DEF_BUTTON_TEXT, Tk_Offset(TkButton, textPtr), -1, 0, 0, 0},
+ DEF_BUTTON_TEXT, offsetof(TkButton, textPtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_STRING, "-textvariable", "textVariable", "Variable",
- DEF_BUTTON_TEXT_VARIABLE, Tk_Offset(TkButton, textVarNamePtr), -1,
+ DEF_BUTTON_TEXT_VARIABLE, offsetof(TkButton, textVarNamePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-tristateimage", "tristateImage", "TristateImage",
- DEF_BUTTON_IMAGE, Tk_Offset(TkButton, tristateImagePtr), -1,
+ DEF_BUTTON_IMAGE, offsetof(TkButton, tristateImagePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-tristatevalue", "tristateValue", "TristateValue",
- DEF_BUTTON_TRISTATE_VALUE, Tk_Offset(TkButton, tristateValuePtr), -1, 0, 0, 0},
- {TK_OPTION_INT, "-underline", "underline", "Underline",
- DEF_BUTTON_UNDERLINE, -1, Tk_Offset(TkButton, underline), 0, 0, 0},
+ DEF_BUTTON_TRISTATE_VALUE, offsetof(TkButton, tristateValuePtr), TCL_INDEX_NONE, 0, 0, 0},
+ {TK_OPTION_INDEX, "-underline", "underline", "Underline",
+ TK_OPTION_UNDERLINE_DEF(TkButton, underline), 0},
{TK_OPTION_STRING, "-value", "value", "Value",
- DEF_BUTTON_VALUE, Tk_Offset(TkButton, onValuePtr), -1, 0, 0, 0},
+ DEF_BUTTON_VALUE, offsetof(TkButton, onValuePtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_STRING, "-variable", "variable", "Variable",
- DEF_RADIOBUTTON_VARIABLE, Tk_Offset(TkButton, selVarNamePtr), -1,
+ DEF_RADIOBUTTON_VARIABLE, offsetof(TkButton, selVarNamePtr), TCL_INDEX_NONE,
0, 0, 0},
{TK_OPTION_STRING, "-width", "width", "Width",
- DEF_BUTTON_WIDTH, Tk_Offset(TkButton, widthPtr), -1, 0, 0, 0},
+ DEF_BUTTON_WIDTH, offsetof(TkButton, widthPtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength",
- DEF_BUTTON_WRAP_LENGTH, Tk_Offset(TkButton, wrapLengthPtr),
- Tk_Offset(TkButton, wrapLength), 0, 0, 0},
- {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0}
+ DEF_BUTTON_WRAP_LENGTH, offsetof(TkButton, wrapLengthPtr),
+ offsetof(TkButton, wrapLength), 0, 0, 0},
+ {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0}
};
/*
@@ -512,32 +512,30 @@ static const enum command map[][8] = {
* Forward declarations for functions defined later in this file:
*/
-static void ButtonCmdDeletedProc(ClientData clientData);
-static int ButtonCreate(ClientData clientData,
- Tcl_Interp *interp, int objc,
+static void ButtonCmdDeletedProc(void *clientData);
+static int ButtonCreate(void *clientData,
+ Tcl_Interp *interp, Tcl_Size objc,
Tcl_Obj *const objv[], int type);
-static void ButtonEventProc(ClientData clientData,
+static void ButtonEventProc(void *clientData,
XEvent *eventPtr);
-static void ButtonImageProc(ClientData clientData,
+static void ButtonImageProc(void *clientData,
int x, int y, int width, int height,
int imgWidth, int imgHeight);
-static void ButtonSelectImageProc(ClientData clientData,
+static void ButtonSelectImageProc(void *clientData,
int x, int y, int width, int height,
int imgWidth, int imgHeight);
-static void ButtonTristateImageProc(ClientData clientData,
+static void ButtonTristateImageProc(void *clientData,
int x, int y, int width, int height,
int imgWidth, int imgHeight);
-static char * ButtonTextVarProc(ClientData clientData,
+static char * ButtonTextVarProc(void *clientData,
Tcl_Interp *interp, const char *name1,
const char *name2, int flags);
-static char * ButtonVarProc(ClientData clientData,
+static char * ButtonVarProc(void *clientData,
Tcl_Interp *interp, const char *name1,
const char *name2, int flags);
-static int ButtonWidgetObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
+static Tcl_ObjCmdProc ButtonWidgetObjCmd;
static int ConfigureButton(Tcl_Interp *interp, TkButton *butPtr,
- int objc, Tcl_Obj *const objv[]);
+ Tcl_Size objc, Tcl_Obj *const objv[]);
static void DestroyButton(TkButton *butPtr);
/*
@@ -561,7 +559,7 @@ static void DestroyButton(TkButton *butPtr);
int
Tk_ButtonObjCmd(
- ClientData clientData, /* Either NULL or pointer to option table. */
+ void *clientData, /* Either NULL or pointer to option table. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument values. */
@@ -571,7 +569,7 @@ Tk_ButtonObjCmd(
int
Tk_CheckbuttonObjCmd(
- ClientData clientData, /* Either NULL or pointer to option table. */
+ void *clientData, /* Either NULL or pointer to option table. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument values. */
@@ -581,7 +579,7 @@ Tk_CheckbuttonObjCmd(
int
Tk_LabelObjCmd(
- ClientData clientData, /* Either NULL or pointer to option table. */
+ void *clientData, /* Either NULL or pointer to option table. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument values. */
@@ -591,7 +589,7 @@ Tk_LabelObjCmd(
int
Tk_RadiobuttonObjCmd(
- ClientData clientData, /* Either NULL or pointer to option table. */
+ void *clientData, /* Either NULL or pointer to option table. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument values. */
@@ -621,7 +619,7 @@ static int
ButtonCreate(
TCL_UNUSED(void *), /* NULL. */
Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[], /* Argument values. */
int type) /* Type of button to create: TYPE_LABEL,
* TYPE_BUTTON, TYPE_CHECK_BUTTON, or
@@ -648,7 +646,7 @@ ButtonCreate(
*/
tkwin = Tk_CreateWindowFromPath(interp, Tk_MainWindow(interp),
- Tcl_GetString(objv[1]), NULL);
+ Tcl_GetString(objv[1]), (char *)NULL);
if (tkwin == NULL) {
return TCL_ERROR;
}
@@ -677,7 +675,7 @@ ButtonCreate(
butPtr->type = type;
butPtr->optionTable = optionTable;
butPtr->textPtr = NULL;
- butPtr->underline = -1;
+ butPtr->underline = INT_MIN;
butPtr->textVarNamePtr = NULL;
butPtr->bitmap = None;
butPtr->imagePtr = NULL;
@@ -740,7 +738,7 @@ ButtonCreate(
ExposureMask|StructureNotifyMask|FocusChangeMask,
ButtonEventProc, butPtr);
- if (Tk_InitOptions(interp, (char *) butPtr, optionTable, tkwin)
+ if (Tk_InitOptions(interp, butPtr, optionTable, tkwin)
!= TCL_OK) {
Tk_DestroyWindow(butPtr->tkwin);
return TCL_ERROR;
@@ -750,7 +748,7 @@ ButtonCreate(
return TCL_ERROR;
}
- Tcl_SetObjResult(interp, TkNewWindowObj(butPtr->tkwin));
+ Tcl_SetObjResult(interp, Tk_NewWindowObj(butPtr->tkwin));
return TCL_OK;
}
@@ -774,7 +772,7 @@ ButtonCreate(
static int
ButtonWidgetObjCmd(
- ClientData clientData, /* Information about button widget. */
+ void *clientData, /* Information about button widget. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument values. */
@@ -785,7 +783,7 @@ ButtonWidgetObjCmd(
Tcl_Obj *objPtr;
if (objc < 2) {
- Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?");
+ Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?");
return TCL_ERROR;
}
result = Tcl_GetIndexFromObjStruct(interp, objv[1], commandNames[butPtr->type],
@@ -801,7 +799,7 @@ ButtonWidgetObjCmd(
Tcl_WrongNumArgs(interp, 1, objv, "cget option");
goto error;
}
- objPtr = Tk_GetOptionValue(interp, (char *) butPtr,
+ objPtr = Tk_GetOptionValue(interp, butPtr,
butPtr->optionTable, objv[2], butPtr->tkwin);
if (objPtr == NULL) {
goto error;
@@ -811,7 +809,7 @@ ButtonWidgetObjCmd(
case COMMAND_CONFIGURE:
if (objc <= 3) {
- objPtr = Tk_GetOptionInfo(interp, (char *) butPtr,
+ objPtr = Tk_GetOptionInfo(interp, butPtr,
butPtr->optionTable, (objc == 3) ? objv[2] : NULL,
butPtr->tkwin);
if (objPtr == NULL) {
@@ -998,7 +996,7 @@ DestroyButton(
NULL, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
ButtonVarProc, butPtr);
}
- Tk_FreeConfigOptions((char *) butPtr, butPtr->optionTable,
+ Tk_FreeConfigOptions(butPtr, butPtr->optionTable,
butPtr->tkwin);
butPtr->tkwin = NULL;
Tcl_EventuallyFree(butPtr, TCL_DYNAMIC);
@@ -1029,7 +1027,7 @@ ConfigureButton(
Tcl_Interp *interp, /* Used for error reporting. */
TkButton *butPtr, /* Information about widget; may or may
* not already have values for some fields. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument values. */
{
Tk_SavedOptions savedOptions;
@@ -1065,7 +1063,7 @@ ConfigureButton(
* First pass: set options to new values.
*/
- if (Tk_SetOptions(interp, (char *) butPtr,
+ if (Tk_SetOptions(interp, butPtr,
butPtr->optionTable, objc, objv,
butPtr->tkwin, &savedOptions, NULL) != TCL_OK) {
continue;
@@ -1099,17 +1097,45 @@ ConfigureButton(
} else {
Tk_SetBackgroundFromBorder(butPtr->tkwin, butPtr->normalBorder);
}
+ if (butPtr->wrapLength < 0) {
+ butPtr->wrapLength = 0;
+ if (butPtr->wrapLengthPtr) {
+ Tcl_DecrRefCount(butPtr->wrapLengthPtr);
+ }
+ butPtr->wrapLengthPtr = Tcl_NewIntObj(0);
+ Tcl_IncrRefCount(butPtr->wrapLengthPtr);
+ }
if (butPtr->borderWidth < 0) {
butPtr->borderWidth = 0;
+ if (butPtr->borderWidthPtr) {
+ Tcl_DecrRefCount(butPtr->borderWidthPtr);
+ }
+ butPtr->borderWidthPtr = Tcl_NewIntObj(0);
+ Tcl_IncrRefCount(butPtr->borderWidthPtr);
}
if (butPtr->highlightWidth < 0) {
butPtr->highlightWidth = 0;
+ if (butPtr->highlightWidthPtr) {
+ Tcl_DecrRefCount(butPtr->highlightWidthPtr);
+ }
+ butPtr->highlightWidthPtr = Tcl_NewIntObj(0);
+ Tcl_IncrRefCount(butPtr->highlightWidthPtr);
}
if (butPtr->padX < 0) {
butPtr->padX = 0;
+ if (butPtr->padXPtr) {
+ Tcl_DecrRefCount(butPtr->padXPtr);
+ }
+ butPtr->padXPtr = Tcl_NewIntObj(0);
+ Tcl_IncrRefCount(butPtr->padXPtr);
}
if (butPtr->padY < 0) {
butPtr->padY = 0;
+ if (butPtr->padYPtr) {
+ Tcl_DecrRefCount(butPtr->padYPtr);
+ }
+ butPtr->padYPtr = Tcl_NewIntObj(0);
+ Tcl_IncrRefCount(butPtr->padYPtr);
}
if (butPtr->type >= TYPE_CHECK_BUTTON) {
@@ -1117,7 +1143,7 @@ ConfigureButton(
if (butPtr->selVarNamePtr == NULL) {
butPtr->selVarNamePtr = Tcl_NewStringObj(
- Tk_Name(butPtr->tkwin), -1);
+ Tk_Name(butPtr->tkwin), TCL_INDEX_NONE);
Tcl_IncrRefCount(butPtr->selVarNamePtr);
}
namePtr = butPtr->selVarNamePtr;
@@ -1131,13 +1157,13 @@ ConfigureButton(
valuePtr = Tcl_ObjGetVar2(interp, namePtr, NULL, TCL_GLOBAL_ONLY);
butPtr->flags &= ~SELECTED;
- butPtr->flags &= ~TRISTATED;
+ butPtr->flags &= ~TRISTATED;
if (valuePtr != NULL) {
const char *value = Tcl_GetString(valuePtr);
if (strcmp(value, Tcl_GetString(butPtr->onValuePtr)) == 0) {
butPtr->flags |= SELECTED;
} else if (strcmp(value,
- Tcl_GetString(butPtr->tristateValuePtr)) == 0) {
+ Tcl_GetString(butPtr->tristateValuePtr)) == 0) {
butPtr->flags |= TRISTATED;
/*
@@ -1150,7 +1176,7 @@ ConfigureButton(
Tcl_GetString(butPtr->offValuePtr)) == 0) {
butPtr->flags &= ~TRISTATED;
}
- }
+ }
} else {
if (Tcl_ObjSetVar2(interp, namePtr, NULL,
(butPtr->type == TYPE_CHECK_BUTTON)
@@ -1260,13 +1286,13 @@ ConfigureButton(
if (Tk_GetPixelsFromObj(interp, butPtr->tkwin, butPtr->widthPtr,
&butPtr->width) != TCL_OK) {
widthError:
- Tcl_AddErrorInfo(interp, "\n (processing -width option)");
+ Tcl_AddErrorInfo(interp, "\n (processing \"-width\" option)");
continue;
}
if (Tk_GetPixelsFromObj(interp, butPtr->tkwin, butPtr->heightPtr,
&butPtr->height) != TCL_OK) {
heightError:
- Tcl_AddErrorInfo(interp, "\n (processing -height option)");
+ Tcl_AddErrorInfo(interp, "\n (processing \"-height\" option)");
continue;
}
} else {
@@ -1334,7 +1360,7 @@ ConfigureButton(
void
TkButtonWorldChanged(
- ClientData instanceData) /* Information about widget. */
+ void *instanceData) /* Information about widget. */
{
XGCValues gcValues;
GC newGC;
@@ -1447,7 +1473,7 @@ TkButtonWorldChanged(
static void
ButtonEventProc(
- ClientData clientData, /* Information about window. */
+ void *clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
TkButton *butPtr = (TkButton *)clientData;
@@ -1465,6 +1491,7 @@ ButtonEventProc(
} else if (eventPtr->type == FocusIn) {
if (eventPtr->xfocus.detail != NotifyInferior) {
butPtr->flags |= GOT_FOCUS;
+ Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->highlightWidthPtr, &butPtr->highlightWidth);
if (butPtr->highlightWidth > 0) {
goto redraw;
}
@@ -1472,6 +1499,7 @@ ButtonEventProc(
} else if (eventPtr->type == FocusOut) {
if (eventPtr->xfocus.detail != NotifyInferior) {
butPtr->flags &= ~GOT_FOCUS;
+ Tk_GetPixelsFromObj(NULL, butPtr->tkwin, butPtr->highlightWidthPtr, &butPtr->highlightWidth);
if (butPtr->highlightWidth > 0) {
goto redraw;
}
@@ -1506,7 +1534,7 @@ ButtonEventProc(
static void
ButtonCmdDeletedProc(
- ClientData clientData) /* Pointer to widget record for widget. */
+ void *clientData) /* Pointer to widget record for widget. */
{
TkButton *butPtr = (TkButton *)clientData;
@@ -1596,10 +1624,10 @@ TkInvokeButton(
static char *
ButtonVarProc(
- ClientData clientData, /* Information about button. */
+ void *clientData, /* Information about button. */
Tcl_Interp *interp, /* Interpreter containing variable. */
- const char *name1, /* Name of variable. */
- const char *name2, /* Second part of variable name. */
+ TCL_UNUSED(const char *), /* Name of variable. */
+ TCL_UNUSED(const char *), /* Second part of variable name. */
int flags) /* Information about what happened. */
{
TkButton *butPtr = (TkButton *)clientData;
@@ -1658,7 +1686,7 @@ ButtonVarProc(
return NULL;
}
butPtr->flags |= SELECTED;
- butPtr->flags &= ~TRISTATED;
+ butPtr->flags &= ~TRISTATED;
} else if (butPtr->offValuePtr
&& strcmp(value, Tcl_GetString(butPtr->offValuePtr)) == 0) {
if (!(butPtr->flags & (SELECTED | TRISTATED))) {
@@ -1666,11 +1694,11 @@ ButtonVarProc(
}
butPtr->flags &= ~(SELECTED | TRISTATED);
} else if (strcmp(value, Tcl_GetString(butPtr->tristateValuePtr)) == 0) {
- if (butPtr->flags & TRISTATED) {
- return NULL;
- }
- butPtr->flags |= TRISTATED;
- butPtr->flags &= ~SELECTED;
+ if (butPtr->flags & TRISTATED) {
+ return NULL;
+ }
+ butPtr->flags |= TRISTATED;
+ butPtr->flags &= ~SELECTED;
} else if (butPtr->flags & (SELECTED | TRISTATED)) {
butPtr->flags &= ~(SELECTED | TRISTATED);
} else {
@@ -1705,7 +1733,7 @@ ButtonVarProc(
static char *
ButtonTextVarProc(
- ClientData clientData, /* Information about button. */
+ void *clientData, /* Information about button. */
Tcl_Interp *interp, /* Interpreter containing variable. */
const char *name1, /* Not used. */
const char *name2, /* Not used. */
@@ -1713,6 +1741,8 @@ ButtonTextVarProc(
{
TkButton *butPtr = (TkButton *)clientData;
Tcl_Obj *valuePtr;
+ (void)name1;
+ (void)name2;
if (butPtr->flags & BUTTON_DELETED) {
return NULL;
@@ -1799,7 +1829,7 @@ ButtonTextVarProc(
static void
ButtonImageProc(
- ClientData clientData, /* Pointer to widget record. */
+ void *clientData, /* Pointer to widget record. */
int x, int y, /* Upper left pixel (within image) that must
* be redisplayed. */
int width, int height, /* Dimensions of area to redisplay (might be
@@ -1807,6 +1837,12 @@ ButtonImageProc(
int imgWidth, int imgHeight)/* New dimensions of image. */
{
TkButton *butPtr = (TkButton *)clientData;
+ (void)x;
+ (void)y;
+ (void)width;
+ (void)height;
+ (void)imgWidth;
+ (void)imgHeight;
if (butPtr->tkwin != NULL) {
TkpComputeButtonGeometry(butPtr);
@@ -1837,7 +1873,7 @@ ButtonImageProc(
static void
ButtonSelectImageProc(
- ClientData clientData, /* Pointer to widget record. */
+ void *clientData, /* Pointer to widget record. */
int x, int y, /* Upper left pixel (within image) that must
* be redisplayed. */
int width, int height, /* Dimensions of area to redisplay (might be
@@ -1845,6 +1881,12 @@ ButtonSelectImageProc(
int imgWidth, int imgHeight)/* New dimensions of image. */
{
TkButton *butPtr = (TkButton *)clientData;
+ (void)x;
+ (void)y;
+ (void)width;
+ (void)height;
+ (void)imgWidth;
+ (void)imgHeight;
#ifdef MAC_OSX_TK
if (butPtr->tkwin != NULL) {
@@ -1884,7 +1926,7 @@ ButtonSelectImageProc(
static void
ButtonTristateImageProc(
- ClientData clientData, /* Pointer to widget record. */
+ void *clientData, /* Pointer to widget record. */
int x, int y, /* Upper left pixel (within image) that must
* be redisplayed. */
int width, int height, /* Dimensions of area to redisplay (might be
@@ -1892,6 +1934,12 @@ ButtonTristateImageProc(
int imgWidth, int imgHeight)/* New dimensions of image. */
{
TkButton *butPtr = (TkButton *)clientData;
+ (void)x;
+ (void)y;
+ (void)width;
+ (void)height;
+ (void)imgWidth;
+ (void)imgHeight;
#ifdef MAC_OSX_TK
if (butPtr->tkwin != NULL) {
diff --git a/generic/tkButton.h b/generic/tkButton.h
index 73b5718..52e861a 100644
--- a/generic/tkButton.h
+++ b/generic/tkButton.h
@@ -4,7 +4,7 @@
* Declarations of types and functions used to implement button-like
* widgets.
*
- * Copyright (c) 1996-1998 Sun Microsystems, Inc.
+ * Copyright © 1996-1998 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -67,7 +67,7 @@ typedef struct {
Tcl_Obj *textPtr; /* Value of -text option: specifies text to
* display in button. */
int underline; /* Value of -underline option: specifies index
- * of character to underline. < 0 means don't
+ * of character to underline. INT_MIN means don't
* underline anything. */
Tcl_Obj *textVarNamePtr; /* Value of -textvariable option: specifies
* name of variable or NULL. If non-NULL,
@@ -308,14 +308,14 @@ MODULE_SCOPE char tkDefLabelPady[TCL_INTEGER_SPACE];
#ifndef TkpButtonSetDefaults
MODULE_SCOPE void TkpButtonSetDefaults(void);
#endif
-MODULE_SCOPE void TkButtonWorldChanged(ClientData instanceData);
+MODULE_SCOPE void TkButtonWorldChanged(void *instanceData);
MODULE_SCOPE void TkpComputeButtonGeometry(TkButton *butPtr);
MODULE_SCOPE TkButton *TkpCreateButton(Tk_Window tkwin);
#ifndef TkpDestroyButton
MODULE_SCOPE void TkpDestroyButton(TkButton *butPtr);
#endif
#ifndef TkpDisplayButton
-MODULE_SCOPE void TkpDisplayButton(ClientData clientData);
+MODULE_SCOPE void TkpDisplayButton(void *clientData);
#endif
MODULE_SCOPE int TkInvokeButton(TkButton *butPtr);
diff --git a/generic/tkCanvArc.c b/generic/tkCanvArc.c
index ccfe116..da40b99 100644
--- a/generic/tkCanvArc.c
+++ b/generic/tkCanvArc.c
@@ -3,8 +3,8 @@
*
* This file implements arc items for canvas widgets.
*
- * Copyright (c) 1992-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1992-1994 The Regents of the University of California.
+ * Copyright © 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.
@@ -14,6 +14,8 @@
#include "tkCanvas.h"
#include "default.h"
+#include "float.h"
+
/*
* The structure below defines the record for each arc item.
*/
@@ -63,6 +65,12 @@ typedef struct ArcItem {
* start (see ComputeArcOutline). */
double center2[2]; /* Coordinates of center of arc outline at
* start+extent (see ComputeArcOutline). */
+ double height; /* Distance from the arc's chord to its
+ * mid-point. */
+ double startPoint[2]; /* Start point of arc used when specifying
+ * height. */
+ double endPoint[2]; /* End point of arc used when specifying
+ * height. */
} ArcItem;
/*
@@ -78,11 +86,11 @@ typedef struct ArcItem {
* Information used for parsing configuration specs:
*/
-static int StyleParseProc(ClientData clientData, Tcl_Interp *interp,
+static int StyleParseProc(void *clientData, Tcl_Interp *interp,
Tk_Window tkwin, const char *value,
- char *widgRec, int offset);
-static const char * StylePrintProc(ClientData clientData, Tk_Window tkwin,
- char *widgRec, int offset, Tcl_FreeProc **freeProcPtr);
+ char *widgRec, Tcl_Size offset);
+static const char * StylePrintProc(void *clientData, Tk_Window tkwin,
+ char *widgRec, Tcl_Size offset, Tcl_FreeProc **freeProcPtr);
static const Tk_CustomOption stateOption = {
TkStateParseProc, TkStatePrintProc, INT2PTR(2)
@@ -105,65 +113,67 @@ static const Tk_CustomOption pixelOption = {
static const Tk_ConfigSpec configSpecs[] = {
{TK_CONFIG_CUSTOM, "-activedash", NULL, NULL,
- NULL, Tk_Offset(ArcItem, outline.activeDash),
+ NULL, offsetof(ArcItem, outline.activeDash),
TK_CONFIG_NULL_OK, &dashOption},
{TK_CONFIG_COLOR, "-activefill", NULL, NULL,
- NULL, Tk_Offset(ArcItem, activeFillColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ArcItem, activeFillColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_COLOR, "-activeoutline", NULL, NULL,
- NULL, Tk_Offset(ArcItem, outline.activeColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ArcItem, outline.activeColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-activeoutlinestipple", NULL, NULL,
- NULL, Tk_Offset(ArcItem, outline.activeStipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ArcItem, outline.activeStipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-activestipple", NULL, NULL,
- NULL, Tk_Offset(ArcItem, activeFillStipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ArcItem, activeFillStipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-activewidth", NULL, NULL,
- "0.0", Tk_Offset(ArcItem, outline.activeWidth),
+ "0.0", offsetof(ArcItem, outline.activeWidth),
TK_CONFIG_DONT_SET_DEFAULT, &pixelOption},
{TK_CONFIG_CUSTOM, "-dash", NULL, NULL,
- NULL, Tk_Offset(ArcItem, outline.dash),
+ NULL, offsetof(ArcItem, outline.dash),
TK_CONFIG_NULL_OK, &dashOption},
{TK_CONFIG_PIXELS, "-dashoffset", NULL, NULL,
- "0", Tk_Offset(ArcItem, outline.offset), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "0", offsetof(ArcItem, outline.offset), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_CUSTOM, "-disableddash", NULL, NULL,
- NULL, Tk_Offset(ArcItem, outline.disabledDash),
+ NULL, offsetof(ArcItem, outline.disabledDash),
TK_CONFIG_NULL_OK, &dashOption},
{TK_CONFIG_COLOR, "-disabledfill", NULL, NULL,
- NULL, Tk_Offset(ArcItem, disabledFillColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ArcItem, disabledFillColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_COLOR, "-disabledoutline", NULL, NULL,
- NULL, Tk_Offset(ArcItem, outline.disabledColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ArcItem, outline.disabledColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-disabledoutlinestipple", NULL, NULL,
- NULL, Tk_Offset(ArcItem, outline.disabledStipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ArcItem, outline.disabledStipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-disabledstipple", NULL, NULL,
- NULL, Tk_Offset(ArcItem, disabledFillStipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ArcItem, disabledFillStipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-disabledwidth", NULL, NULL,
- "0.0", Tk_Offset(ArcItem, outline.disabledWidth),
+ "0.0", offsetof(ArcItem, outline.disabledWidth),
TK_CONFIG_DONT_SET_DEFAULT, &pixelOption},
{TK_CONFIG_DOUBLE, "-extent", NULL, NULL,
- "90", Tk_Offset(ArcItem, extent), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "90", offsetof(ArcItem, extent), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_COLOR, "-fill", NULL, NULL,
- NULL, Tk_Offset(ArcItem, fillColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ArcItem, fillColor), TK_CONFIG_NULL_OK, NULL},
+ {TK_CONFIG_DOUBLE, "-height", NULL, NULL,
+ 0, offsetof(ArcItem, height), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_CUSTOM, "-offset", NULL, NULL,
- "0,0", Tk_Offset(ArcItem, tsoffset),
+ "0,0", offsetof(ArcItem, tsoffset),
TK_CONFIG_DONT_SET_DEFAULT, &offsetOption},
{TK_CONFIG_COLOR, "-outline", NULL, NULL,
- DEF_CANVITEM_OUTLINE, Tk_Offset(ArcItem, outline.color), TK_CONFIG_NULL_OK, NULL},
+ DEF_CANVITEM_OUTLINE, offsetof(ArcItem, outline.color), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-outlineoffset", NULL, NULL,
- "0,0", Tk_Offset(ArcItem, outline.tsoffset),
+ "0,0", offsetof(ArcItem, outline.tsoffset),
TK_CONFIG_DONT_SET_DEFAULT, &offsetOption},
{TK_CONFIG_BITMAP, "-outlinestipple", NULL, NULL,
- NULL, Tk_Offset(ArcItem, outline.stipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ArcItem, outline.stipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_DOUBLE, "-start", NULL, NULL,
- "0", Tk_Offset(ArcItem, start), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "0", offsetof(ArcItem, start), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_CUSTOM, "-state", NULL, NULL,
- NULL, Tk_Offset(Tk_Item, state), TK_CONFIG_NULL_OK, &stateOption},
+ NULL, offsetof(Tk_Item, state), TK_CONFIG_NULL_OK, &stateOption},
{TK_CONFIG_BITMAP, "-stipple", NULL, NULL,
- NULL, Tk_Offset(ArcItem, fillStipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ArcItem, fillStipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-style", NULL, NULL,
- NULL, Tk_Offset(ArcItem, style), TK_CONFIG_DONT_SET_DEFAULT,
+ NULL, offsetof(ArcItem, style), TK_CONFIG_DONT_SET_DEFAULT,
&styleOption},
{TK_CONFIG_CUSTOM, "-tags", NULL, NULL,
NULL, 0, TK_CONFIG_NULL_OK, &tagsOption},
{TK_CONFIG_CUSTOM, "-width", NULL, NULL,
- "1.0", Tk_Offset(ArcItem, outline.width), TK_CONFIG_DONT_SET_DEFAULT,
+ "1.0", offsetof(ArcItem, outline.width), TK_CONFIG_DONT_SET_DEFAULT,
&pixelOption},
{TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}
};
@@ -174,18 +184,19 @@ static const Tk_ConfigSpec configSpecs[] = {
static void ComputeArcBbox(Tk_Canvas canvas, ArcItem *arcPtr);
static int ConfigureArc(Tcl_Interp *interp,
- Tk_Canvas canvas, Tk_Item *itemPtr, int objc,
+ Tk_Canvas canvas, Tk_Item *itemPtr, Tcl_Size objc,
Tcl_Obj *const objv[], int flags);
+static void ComputeArcParametersFromHeight(ArcItem *arcPtr);
static int CreateArc(Tcl_Interp *interp,
Tk_Canvas canvas, struct Tk_Item *itemPtr,
- int objc, Tcl_Obj *const objv[]);
+ Tcl_Size objc, Tcl_Obj *const objv[]);
static void DeleteArc(Tk_Canvas canvas,
Tk_Item *itemPtr, Display *display);
static void DisplayArc(Tk_Canvas canvas,
Tk_Item *itemPtr, Display *display, Drawable dst,
int x, int y, int width, int height);
static int ArcCoords(Tcl_Interp *interp, Tk_Canvas canvas,
- Tk_Item *itemPtr, int objc, Tcl_Obj *const objv[]);
+ Tk_Item *itemPtr, Tcl_Size objc, Tcl_Obj *const objv[]);
static int ArcToArea(Tk_Canvas canvas,
Tk_Item *itemPtr, double *rectPtr);
static double ArcToPoint(Tk_Canvas canvas,
@@ -206,6 +217,8 @@ static int HorizLineToArc(double x1, double x2,
static int VertLineToArc(double x, double y1,
double y2, double rx, double ry,
double start, double extent);
+static void RotateArc(Tk_Canvas canvas, Tk_Item *itemPtr,
+ double originX, double originY, double angleRad);
/*
* The structures below defines the arc item types by means of functions that
@@ -233,7 +246,8 @@ Tk_ItemType tkArcType = {
NULL, /* insertProc */
NULL, /* dTextProc */
NULL, /* nextPtr */
- NULL, 0, NULL, NULL
+ RotateArc, /* rotateProc */
+ 0, NULL, NULL
};
/*
@@ -261,11 +275,11 @@ CreateArc(
Tk_Canvas canvas, /* Canvas to hold new item. */
Tk_Item *itemPtr, /* Record to hold new item; header has been
* initialized by caller. */
- int objc, /* Number of arguments in objv. */
+ Tcl_Size objc, /* Number of arguments in objv. */
Tcl_Obj *const objv[]) /* Arguments describing arc. */
{
ArcItem *arcPtr = (ArcItem *) itemPtr;
- int i;
+ Tcl_Size i;
if (objc == 0) {
Tcl_Panic("canvas did not pass any coords");
@@ -292,6 +306,7 @@ CreateArc(
arcPtr->disabledFillStipple = None;
arcPtr->style = PIESLICE_STYLE;
arcPtr->fillGC = NULL;
+ arcPtr->height = 0;
/*
* Process the arguments to fill in the item record.
@@ -339,7 +354,7 @@ ArcCoords(
Tk_Canvas canvas, /* Canvas containing item. */
Tk_Item *itemPtr, /* Item whose coordinates are to be read or
* modified. */
- int objc, /* Number of coordinates supplied in objv. */
+ Tcl_Size objc, /* Number of coordinates supplied in objv. */
Tcl_Obj *const objv[]) /* Array of coordinates: x1, y1, x2, y2, ... */
{
ArcItem *arcPtr = (ArcItem *) itemPtr;
@@ -359,9 +374,9 @@ ArcCoords(
return TCL_ERROR;
} else if (objc != 4) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "wrong # coordinates: expected 4, got %d", objc));
+ "wrong # coordinates: expected 4, got %" TCL_SIZE_MODIFIER "d", objc));
Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "ARC",
- NULL);
+ (char *)NULL);
return TCL_ERROR;
}
}
@@ -375,11 +390,22 @@ ArcCoords(
&arcPtr->bbox[3]) != TCL_OK)) {
return TCL_ERROR;
}
+
+ /*
+ * Store bbox as start and end points so they can be used if either
+ * radius or height is specified.
+ */
+
+ arcPtr->startPoint[0] = arcPtr->bbox[0];
+ arcPtr->startPoint[1] = arcPtr->bbox[1];
+ arcPtr->endPoint[0] = arcPtr->bbox[2];
+ arcPtr->endPoint[1] = arcPtr->bbox[3];
+
ComputeArcBbox(canvas, arcPtr);
} else {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "wrong # coordinates: expected 0 or 4, got %d", objc));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "ARC", NULL);
+ "wrong # coordinates: expected 0 or 4, got %" TCL_SIZE_MODIFIER "d", objc));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "ARC", (char *)NULL);
return TCL_ERROR;
}
return TCL_OK;
@@ -409,7 +435,7 @@ ConfigureArc(
Tcl_Interp *interp, /* Used for error reporting. */
Tk_Canvas canvas, /* Canvas containing itemPtr. */
Tk_Item *itemPtr, /* Arc item to reconfigure. */
- int objc, /* Number of elements in objv. */
+ Tcl_Size objc, /* Number of elements in objv. */
Tcl_Obj *const objv[], /* Arguments describing things to configure. */
int flags) /* Flags to pass to Tk_ConfigureWidget. */
{
@@ -448,6 +474,22 @@ ConfigureArc(
itemPtr->redraw_flags &= ~TK_ITEM_STATE_DEPENDANT;
}
+ /*
+ * Override the start and extent if the height is given.
+ */
+
+ ComputeArcParametersFromHeight(arcPtr);
+
+ ComputeArcBbox(canvas, arcPtr);
+
+ 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;
+
tsoffset = &arcPtr->outline.tsoffset;
flags = tsoffset->flags;
if (flags & TK_OFFSET_LEFT) {
@@ -465,15 +507,7 @@ ConfigureArc(
tsoffset->yoffset = (int) (arcPtr->bbox[2] + 0.5);
}
- 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;
-
- mask = Tk_ConfigOutlineGC(&gcValues, canvas, itemPtr, &(arcPtr->outline));
+ mask = (unsigned long)Tk_ConfigOutlineGC(&gcValues, canvas, itemPtr, &(arcPtr->outline));
if (mask) {
gcValues.cap_style = CapButt;
mask |= GCCapStyle;
@@ -560,6 +594,103 @@ ConfigureArc(
/*
*--------------------------------------------------------------
*
+ * ComputeArcParametersFromHeight --
+ *
+ * This function calculates the arc parameters given start-point,
+ * end-point and height (!= 0).
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * The height parameter is set to 0 on exit.
+ *
+ *--------------------------------------------------------------
+ */
+
+static void
+ComputeArcParametersFromHeight(
+ ArcItem* arcPtr)
+{
+ double chordLen, chordDir[2], chordCen[2], arcCen[2], d, radToDeg, radius;
+
+ /*
+ * Do nothing if no height has been specified.
+ */
+
+ if (arcPtr->height == 0)
+ return;
+
+ /*
+ * Calculate the chord length, return early if it is too small.
+ */
+
+ chordLen = hypot(arcPtr->endPoint[1] - arcPtr->startPoint[1],
+ arcPtr->startPoint[0] - arcPtr->endPoint[0]);
+
+ if (chordLen < DBL_EPSILON) {
+ arcPtr->start = arcPtr->extent = arcPtr->height = 0;
+ return;
+ }
+
+ chordDir[0] = (arcPtr->endPoint[0] - arcPtr->startPoint[0]) / chordLen;
+ chordDir[1] = (arcPtr->endPoint[1] - arcPtr->startPoint[1]) / chordLen;
+ chordCen[0] = (arcPtr->startPoint[0] + arcPtr->endPoint[0]) / 2;
+ chordCen[1] = (arcPtr->startPoint[1] + arcPtr->endPoint[1]) / 2;
+
+ /*
+ * Calculate the radius (assumes height != 0).
+ */
+
+ radius = (4*pow(arcPtr->height, 2) + pow(chordLen, 2))
+ / (8 * arcPtr->height);
+
+ /*
+ * The arc centre.
+ */
+
+ d = radius - arcPtr->height;
+ arcCen[0] = chordCen[0] - d * chordDir[1];
+ arcCen[1] = chordCen[1] + d * chordDir[0];
+
+ /*
+ * The arc start and span. Angles are negated because the coordinate
+ * system is left-handed.
+ */
+
+ radToDeg = 45 / atan(1);
+ arcPtr->start = atan2(arcCen[1] - arcPtr->startPoint[1],
+ arcPtr->startPoint[0] - arcCen[0]) * radToDeg;
+ arcPtr->extent = -2 * asin(chordLen / (2 * radius)) * radToDeg;
+
+ /*
+ * Handle spans > 180.
+ */
+
+ if (fabs(2 * arcPtr->height) > chordLen) {
+ arcPtr->extent = arcPtr->extent > 0 ? (360 - arcPtr->extent)
+ : -(360 + arcPtr->extent);
+ }
+
+ /*
+ * Create the bounding box.
+ */
+
+ arcPtr->bbox[0] = arcCen[0] - radius;
+ arcPtr->bbox[1] = arcCen[1] - radius;
+ arcPtr->bbox[2] = arcCen[0] + radius;
+ arcPtr->bbox[3] = arcCen[1] + radius;
+
+ /*
+ * Set the height to 0 so that itemcget -height returns 0.
+ */
+
+ arcPtr->height = 0;
+}
+
+/*
+ *--------------------------------------------------------------
+ *
* DeleteArc --
*
* This function is called to clean up the data structure associated with
@@ -1379,6 +1510,60 @@ ScaleArc(
/*
*--------------------------------------------------------------
*
+ * RotateArc --
+ *
+ * This function is called to rotate an arc by a given amount.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * The position of the arc is rotated by angleRad radians about (originX,
+ * originY), and the bounding box is updated in the generic part of the
+ * item structure.
+ *
+ *--------------------------------------------------------------
+ */
+
+static void
+RotateArc(
+ Tk_Canvas canvas,
+ Tk_Item *itemPtr,
+ double originX,
+ double originY,
+ double angleRad)
+{
+ ArcItem *arcPtr = (ArcItem *) itemPtr;
+ double newX, newY, oldX, oldY;
+
+ /*
+ * Compute the centre of the box, then rotate that about the origin.
+ */
+
+ newX = oldX = (arcPtr->bbox[0] + arcPtr->bbox[2]) / 2.0;
+ newY = oldY = (arcPtr->bbox[1] + arcPtr->bbox[3]) / 2.0;
+ TkRotatePoint(originX, originY, sin(angleRad), cos(angleRad),
+ &newX, &newY);
+
+ /*
+ * Apply the translation to the box.
+ */
+
+ arcPtr->bbox[0] += newX - oldX;
+ arcPtr->bbox[1] += newY - oldY;
+ arcPtr->bbox[2] += newX - oldX;
+ arcPtr->bbox[3] += newY - oldY;
+
+ /*
+ * TODO: update the arc endpoints?
+ */
+
+ ComputeArcBbox(canvas, arcPtr);
+}
+
+/*
+ *--------------------------------------------------------------
+ *
* TranslateArc --
*
* This function is called to move an arc by a given amount.
@@ -1891,32 +2076,28 @@ ArcToPostscript(
(arcPtr->bbox[2] - arcPtr->bbox[0])/2, (y1 - y2)/2);
if (arcPtr->style != CHORD_STYLE) {
- Tcl_AppendToObj(psObj, "0 0 moveto ", -1);
+ Tcl_AppendToObj(psObj, "0 0 moveto ", TCL_INDEX_NONE);
}
Tcl_AppendPrintfToObj(psObj,
"0 0 1 %.15g %.15g arc closepath\nsetmatrix\n",
ang1, ang2);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsColor(interp, canvas, fillColor) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsColor(interp, canvas, fillColor);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (fillStipple != None) {
- Tcl_AppendToObj(psObj, "clip ", -1);
+ Tcl_AppendToObj(psObj, "clip ", TCL_INDEX_NONE);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsStipple(interp, canvas, fillStipple) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsStipple(interp, canvas, fillStipple);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (arcPtr->outline.gc != NULL) {
- Tcl_AppendToObj(psObj, "grestore gsave\n", -1);
+ Tcl_AppendToObj(psObj, "grestore gsave\n", TCL_INDEX_NONE);
}
} else {
- Tcl_AppendToObj(psObj, "fill\n", -1);
+ Tcl_AppendToObj(psObj, "fill\n", TCL_INDEX_NONE);
}
}
@@ -1935,13 +2116,11 @@ ArcToPostscript(
ang1, ang2);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsOutline(canvas, itemPtr, &arcPtr->outline) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsOutline(canvas, itemPtr, &arcPtr->outline);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (arcPtr->style != ARC_STYLE) {
- Tcl_AppendToObj(psObj, "grestore gsave\n", -1);
+ Tcl_AppendToObj(psObj, "grestore gsave\n", TCL_INDEX_NONE);
Tcl_ResetResult(interp);
if (arcPtr->style == CHORD_STYLE) {
@@ -1950,44 +2129,36 @@ ArcToPostscript(
} else {
Tk_CanvasPsPath(interp, canvas, arcPtr->outlinePtr,
PIE_OUTLINE1_PTS);
- if (Tk_CanvasPsColor(interp, canvas, color) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsColor(interp, canvas, color);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (stipple != None) {
- Tcl_AppendToObj(psObj, "clip ", -1);
+ Tcl_AppendToObj(psObj, "clip ", TCL_INDEX_NONE);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsStipple(interp, canvas, stipple) !=TCL_OK){
- goto error;
- }
+ Tk_CanvasPsStipple(interp, canvas, stipple);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
} else {
- Tcl_AppendToObj(psObj, "fill\n", -1);
+ Tcl_AppendToObj(psObj, "fill\n", TCL_INDEX_NONE);
}
- Tcl_AppendToObj(psObj, "grestore gsave\n", -1);
+ Tcl_AppendToObj(psObj, "grestore gsave\n", TCL_INDEX_NONE);
Tcl_ResetResult(interp);
Tk_CanvasPsPath(interp, canvas,
arcPtr->outlinePtr + 2*PIE_OUTLINE1_PTS,
PIE_OUTLINE2_PTS);
}
- if (Tk_CanvasPsColor(interp, canvas, color) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsColor(interp, canvas, color);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (stipple != None) {
- Tcl_AppendToObj(psObj, "clip ", -1);
+ Tcl_AppendToObj(psObj, "clip ", TCL_INDEX_NONE);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsStipple(interp, canvas, stipple) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsStipple(interp, canvas, stipple);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
} else {
- Tcl_AppendToObj(psObj, "fill\n", -1);
+ Tcl_AppendToObj(psObj, "fill\n", TCL_INDEX_NONE);
}
}
}
@@ -2000,11 +2171,6 @@ ArcToPostscript(
Tcl_AppendObjToObj(Tcl_GetObjResult(interp), psObj);
Tcl_DecrRefCount(psObj);
return TCL_OK;
-
- error:
- Tcl_DiscardInterpState(interpState);
- Tcl_DecrRefCount(psObj);
- return TCL_ERROR;
}
/*
@@ -2032,7 +2198,7 @@ StyleParseProc(
TCL_UNUSED(Tk_Window), /* Window containing canvas widget. */
const char *value, /* Value of option. */
char *widgRec, /* Pointer to record for item. */
- int offset) /* Offset into item. */
+ Tcl_Size offset) /* Offset into item. */
{
int c;
size_t length;
@@ -2062,7 +2228,7 @@ StyleParseProc(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad -style option \"%s\": must be arc, chord, or pieslice",
value));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "ARC_STYLE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "ARC_STYLE", (char *)NULL);
*stylePtr = PIESLICE_STYLE;
return TCL_ERROR;
}
@@ -2093,7 +2259,7 @@ StylePrintProc(
TCL_UNUSED(void *), /* Ignored. */
TCL_UNUSED(Tk_Window), /* Ignored. */
char *widgRec, /* Pointer to record for item. */
- int offset, /* Offset into item. */
+ Tcl_Size offset, /* Offset into item. */
TCL_UNUSED(Tcl_FreeProc **)) /* Pointer to variable to fill in with
* information about how to reclaim storage
* for return string. */
diff --git a/generic/tkCanvBmap.c b/generic/tkCanvBmap.c
index 01d875c..1bbf566 100644
--- a/generic/tkCanvBmap.c
+++ b/generic/tkCanvBmap.c
@@ -3,8 +3,8 @@
*
* This file implements bitmap items for canvas widgets.
*
- * Copyright (c) 1992-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1992-1994 The Regents of the University of California.
+ * Copyright © 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.
@@ -50,30 +50,30 @@ static const Tk_CustomOption tagsOption = {
static const Tk_ConfigSpec configSpecs[] = {
{TK_CONFIG_COLOR, "-activebackground", NULL, NULL,
- NULL, Tk_Offset(BitmapItem, activeBgColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(BitmapItem, activeBgColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-activebitmap", NULL, NULL,
- NULL, Tk_Offset(BitmapItem, activeBitmap), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(BitmapItem, activeBitmap), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_COLOR, "-activeforeground", NULL, NULL,
- NULL, Tk_Offset(BitmapItem, activeFgColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(BitmapItem, activeFgColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_ANCHOR, "-anchor", NULL, NULL,
- "center", Tk_Offset(BitmapItem, anchor), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "center", offsetof(BitmapItem, anchor), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_COLOR, "-background", NULL, NULL,
- NULL, Tk_Offset(BitmapItem, bgColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(BitmapItem, bgColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-bitmap", NULL, NULL,
- NULL, Tk_Offset(BitmapItem, bitmap), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(BitmapItem, bitmap), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_COLOR, "-disabledbackground", NULL, NULL,
- NULL, Tk_Offset(BitmapItem, disabledBgColor),
+ NULL, offsetof(BitmapItem, disabledBgColor),
TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-disabledbitmap", NULL, NULL,
- NULL, Tk_Offset(BitmapItem, disabledBitmap),
+ NULL, offsetof(BitmapItem, disabledBitmap),
TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_COLOR, "-disabledforeground", NULL, NULL,
- NULL, Tk_Offset(BitmapItem, disabledFgColor),
+ NULL, offsetof(BitmapItem, disabledFgColor),
TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_COLOR, "-foreground", NULL, NULL,
- DEF_CANVBMAP_FG, Tk_Offset(BitmapItem, fgColor), 0, NULL},
+ DEF_CANVBMAP_FG, offsetof(BitmapItem, fgColor), 0, NULL},
{TK_CONFIG_CUSTOM, "-state", NULL, NULL,
- NULL, Tk_Offset(Tk_Item, state), TK_CONFIG_NULL_OK,
+ NULL, offsetof(Tk_Item, state), TK_CONFIG_NULL_OK,
&stateOption},
{TK_CONFIG_CUSTOM, "-tags", NULL, NULL,
NULL, 0, TK_CONFIG_NULL_OK, &tagsOption},
@@ -85,7 +85,7 @@ static const Tk_ConfigSpec configSpecs[] = {
*/
static int BitmapCoords(Tcl_Interp *interp,
- Tk_Canvas canvas, Tk_Item *itemPtr, int objc,
+ Tk_Canvas canvas, Tk_Item *itemPtr, Tcl_Size objc,
Tcl_Obj *const objv[]);
static int BitmapToArea(Tk_Canvas canvas,
Tk_Item *itemPtr, double *rectPtr);
@@ -96,16 +96,18 @@ static int BitmapToPostscript(Tcl_Interp *interp,
static void ComputeBitmapBbox(Tk_Canvas canvas,
BitmapItem *bmapPtr);
static int ConfigureBitmap(Tcl_Interp *interp,
- Tk_Canvas canvas, Tk_Item *itemPtr, int objc,
+ Tk_Canvas canvas, Tk_Item *itemPtr, Tcl_Size objc,
Tcl_Obj *const objv[], int flags);
static int TkcCreateBitmap(Tcl_Interp *interp,
Tk_Canvas canvas, struct Tk_Item *itemPtr,
- int objc, Tcl_Obj *const objv[]);
+ Tcl_Size objc, Tcl_Obj *const objv[]);
static void DeleteBitmap(Tk_Canvas canvas,
Tk_Item *itemPtr, Display *display);
static void DisplayBitmap(Tk_Canvas canvas,
Tk_Item *itemPtr, Display *display, Drawable dst,
int x, int y, int width, int height);
+static void RotateBitmap(Tk_Canvas canvas, Tk_Item *itemPtr,
+ double originX, double originY, double angleRad);
static void ScaleBitmap(Tk_Canvas canvas,
Tk_Item *itemPtr, double originX, double originY,
double scaleX, double scaleY);
@@ -138,7 +140,8 @@ Tk_ItemType tkBitmapType = {
NULL, /* insertProc */
NULL, /* dTextProc */
NULL, /* nextPtr */
- NULL, 0, NULL, NULL
+ RotateBitmap, /* rotateProc */
+ 0, NULL, NULL
};
/*
@@ -166,11 +169,11 @@ TkcCreateBitmap(
Tk_Canvas canvas, /* Canvas to hold new item. */
Tk_Item *itemPtr, /* Record to hold new item; header has been
* initialized by caller. */
- int objc, /* Number of arguments in objv. */
+ Tcl_Size objc, /* Number of arguments in objv. */
Tcl_Obj *const objv[]) /* Arguments describing rectangle. */
{
BitmapItem *bmapPtr = (BitmapItem *) itemPtr;
- int i;
+ Tcl_Size i;
if (objc == 0) {
Tcl_Panic("canvas did not pass any coords");
@@ -242,7 +245,7 @@ BitmapCoords(
Tk_Canvas canvas, /* Canvas containing item. */
Tk_Item *itemPtr, /* Item whose coordinates are to be read or
* modified. */
- int objc, /* Number of coordinates supplied in objv. */
+ Tcl_Size objc, /* Number of coordinates supplied in objv. */
Tcl_Obj *const objv[]) /* Array of coordinates: x1, y1, x2, y2, ... */
{
BitmapItem *bmapPtr = (BitmapItem *) itemPtr;
@@ -260,9 +263,9 @@ BitmapCoords(
return TCL_ERROR;
} else if (objc != 2) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "wrong # coordinates: expected 2, got %d", objc));
+ "wrong # coordinates: expected 2, got %" TCL_SIZE_MODIFIER "d", objc));
Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "BITMAP",
- NULL);
+ (char *)NULL);
return TCL_ERROR;
}
}
@@ -275,8 +278,8 @@ BitmapCoords(
ComputeBitmapBbox(canvas, bmapPtr);
} else {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "wrong # coordinates: expected 0 or 2, got %d", objc));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "BITMAP", NULL);
+ "wrong # coordinates: expected 0 or 2, got %" TCL_SIZE_MODIFIER "d", objc));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "BITMAP", (char *)NULL);
return TCL_ERROR;
}
return TCL_OK;
@@ -305,7 +308,7 @@ ConfigureBitmap(
Tcl_Interp *interp, /* Used for error reporting. */
Tk_Canvas canvas, /* Canvas containing itemPtr. */
Tk_Item *itemPtr, /* Bitmap item to reconfigure. */
- int objc, /* Number of elements in objv. */
+ Tcl_Size objc, /* Number of elements in objv. */
Tcl_Obj *const objv[], /* Arguments describing things to configure. */
int flags) /* Flags to pass to Tk_ConfigureWidget. */
{
@@ -414,7 +417,7 @@ ConfigureBitmap(
static void
DeleteBitmap(
- Tk_Canvas canvas, /* Info about overall canvas widget. */
+ TCL_UNUSED(Tk_Canvas), /* Info about overall canvas widget. */
Tk_Item *itemPtr, /* Item that is being deleted. */
Display *display) /* Display containing window for canvas. */
{
@@ -470,7 +473,6 @@ DeleteBitmap(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static void
ComputeBitmapBbox(
Tk_Canvas canvas, /* Canvas that contains item. */
@@ -537,7 +539,7 @@ ComputeBitmapBbox(
break;
case TK_ANCHOR_NW:
break;
- case TK_ANCHOR_CENTER:
+ default:
x -= width/2;
y -= height/2;
break;
@@ -668,10 +670,9 @@ DisplayBitmap(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static double
BitmapToPoint(
- Tk_Canvas canvas, /* Canvas containing item. */
+ TCL_UNUSED(Tk_Canvas), /* Canvas containing item. */
Tk_Item *itemPtr, /* Item to check against point. */
double *coordPtr) /* Pointer to x and y coordinates. */
{
@@ -725,10 +726,9 @@ BitmapToPoint(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static int
BitmapToArea(
- Tk_Canvas canvas, /* Canvas containing item. */
+ TCL_UNUSED(Tk_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
@@ -791,6 +791,39 @@ ScaleBitmap(
/*
*--------------------------------------------------------------
*
+ * RotateBitmap --
+ *
+ * This function is called to rotate a bitmap's origin by a given amount.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * The position of the bitmap is rotated by angleRad radians about
+ * (originX, originY), and the bounding box is updated in the generic
+ * part of the item structure.
+ *
+ *--------------------------------------------------------------
+ */
+
+static void
+RotateBitmap(
+ Tk_Canvas canvas,
+ Tk_Item *itemPtr,
+ double originX,
+ double originY,
+ double angleRad)
+{
+ BitmapItem *bmapPtr = (BitmapItem *) itemPtr;
+
+ TkRotatePoint(originX, originY, sin(angleRad), cos(angleRad),
+ &bmapPtr->x, &bmapPtr->y);
+ ComputeBitmapBbox(canvas, bmapPtr);
+}
+
+/*
+ *--------------------------------------------------------------
+ *
* TranslateBitmap --
*
* This function is called to move an item by a given amount.
@@ -843,7 +876,7 @@ BitmapToPostscript(
Tcl_Interp *interp, /* Leave Postscript or error message here. */
Tk_Canvas canvas, /* Information about overall canvas. */
Tk_Item *itemPtr, /* Item for which Postscript is wanted. */
- int prepass) /* 1 means this is a prepass to collect font
+ TCL_UNUSED(int)) /* 1 means this is a prepass to collect font
* information; 0 means final Postscript is
* being created. */
{
@@ -908,7 +941,7 @@ BitmapToPostscript(
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;
+ default: x -= width/2.0; y -= height/2.0; break;
}
/*
@@ -929,12 +962,10 @@ BitmapToPostscript(
x, y, width, height, -width);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsColor(interp, canvas, bgColor) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsColor(interp, canvas, bgColor);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
- Tcl_AppendToObj(psObj, "fill\n", -1);
+ Tcl_AppendToObj(psObj, "fill\n", TCL_INDEX_NONE);
}
/*
@@ -946,16 +977,14 @@ BitmapToPostscript(
if (fgColor != NULL) {
Tcl_ResetResult(interp);
- if (Tk_CanvasPsColor(interp, canvas, fgColor) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsColor(interp, canvas, fgColor);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (width > 60000) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"can't generate Postscript for bitmaps more than 60000"
- " pixels wide", -1));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "PS", "MEMLIMIT", NULL);
+ " pixels wide", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "PS", "MEMLIMIT", (char *)NULL);
goto error;
}
@@ -977,13 +1006,11 @@ BitmapToPostscript(
(double) rowsThisTime, width, rowsThisTime);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsBitmap(interp, canvas, bitmap,
- 0, curRow, width, rowsThisTime) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsBitmap(interp, canvas, bitmap, 0, curRow, width,
+ rowsThisTime);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
- Tcl_AppendToObj(psObj, "\n} imagemask\n", -1);
+ Tcl_AppendToObj(psObj, "\n} imagemask\n", TCL_INDEX_NONE);
}
}
diff --git a/generic/tkCanvImg.c b/generic/tkCanvImg.c
index 19d1516..5f67ec6 100644
--- a/generic/tkCanvImg.c
+++ b/generic/tkCanvImg.c
@@ -3,8 +3,8 @@
*
* This file implements image items for canvas widgets.
*
- * Copyright (c) 1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1994 The Regents of the University of California.
+ * Copyright © 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.
@@ -52,15 +52,15 @@ static const Tk_CustomOption tagsOption = {
static const Tk_ConfigSpec configSpecs[] = {
{TK_CONFIG_STRING, "-activeimage", NULL, NULL,
- NULL, Tk_Offset(ImageItem, activeImageString), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ImageItem, activeImageString), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_ANCHOR, "-anchor", NULL, NULL,
- "center", Tk_Offset(ImageItem, anchor), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "center", offsetof(ImageItem, anchor), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_STRING, "-disabledimage", NULL, NULL,
- NULL, Tk_Offset(ImageItem, disabledImageString), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ImageItem, disabledImageString), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_STRING, "-image", NULL, NULL,
- NULL, Tk_Offset(ImageItem, imageString), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ImageItem, imageString), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-state", NULL, NULL,
- NULL, Tk_Offset(Tk_Item, state), TK_CONFIG_NULL_OK, &stateOption},
+ NULL, offsetof(Tk_Item, state), TK_CONFIG_NULL_OK, &stateOption},
{TK_CONFIG_CUSTOM, "-tags", NULL, NULL,
NULL, 0, TK_CONFIG_NULL_OK, &tagsOption},
{TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}
@@ -70,11 +70,11 @@ static const Tk_ConfigSpec configSpecs[] = {
* Prototypes for functions defined in this file:
*/
-static void ImageChangedProc(ClientData clientData,
+static void ImageChangedProc(void *clientData,
int x, int y, int width, int height, int imgWidth,
int imgHeight);
static int ImageCoords(Tcl_Interp *interp,
- Tk_Canvas canvas, Tk_Item *itemPtr, int objc,
+ Tk_Canvas canvas, Tk_Item *itemPtr, Tcl_Size objc,
Tcl_Obj *const objv[]);
static int ImageToArea(Tk_Canvas canvas,
Tk_Item *itemPtr, double *rectPtr);
@@ -84,16 +84,18 @@ static int ImageToPostscript(Tcl_Interp *interp,
Tk_Canvas canvas, Tk_Item *itemPtr, int prepass);
static void ComputeImageBbox(Tk_Canvas canvas, ImageItem *imgPtr);
static int ConfigureImage(Tcl_Interp *interp,
- Tk_Canvas canvas, Tk_Item *itemPtr, int objc,
+ Tk_Canvas canvas, Tk_Item *itemPtr, Tcl_Size objc,
Tcl_Obj *const objv[], int flags);
static int CreateImage(Tcl_Interp *interp,
Tk_Canvas canvas, struct Tk_Item *itemPtr,
- int objc, Tcl_Obj *const objv[]);
+ Tcl_Size objc, Tcl_Obj *const objv[]);
static void DeleteImage(Tk_Canvas canvas,
Tk_Item *itemPtr, Display *display);
static void DisplayImage(Tk_Canvas canvas,
Tk_Item *itemPtr, Display *display, Drawable dst,
int x, int y, int width, int height);
+static void RotateImage(Tk_Canvas canvas, Tk_Item *itemPtr,
+ double originX, double originY, double angleRad);
static void ScaleImage(Tk_Canvas canvas,
Tk_Item *itemPtr, double originX, double originY,
double scaleX, double scaleY);
@@ -126,7 +128,8 @@ Tk_ItemType tkImageType = {
NULL, /* insertProc */
NULL, /* dTextProc */
NULL, /* nextPtr */
- NULL, 0, NULL, NULL
+ RotateImage, /* rotateProc */
+ 0, NULL, NULL
};
/*
@@ -154,11 +157,11 @@ CreateImage(
Tk_Canvas canvas, /* Canvas to hold new item. */
Tk_Item *itemPtr, /* Record to hold new item; header has been
* initialized by caller. */
- int objc, /* Number of arguments in objv. */
+ Tcl_Size objc, /* Number of arguments in objv. */
Tcl_Obj *const objv[]) /* Arguments describing rectangle. */
{
ImageItem *imgPtr = (ImageItem *) itemPtr;
- int i;
+ Tcl_Size i;
if (objc == 0) {
Tcl_Panic("canvas did not pass any coords");
@@ -226,7 +229,7 @@ ImageCoords(
Tk_Canvas canvas, /* Canvas containing item. */
Tk_Item *itemPtr, /* Item whose coordinates are to be read or
* modified. */
- int objc, /* Number of coordinates supplied in objv. */
+ Tcl_Size objc, /* Number of coordinates supplied in objv. */
Tcl_Obj *const objv[]) /* Array of coordinates: x1, y1, x2, y2, ... */
{
ImageItem *imgPtr = (ImageItem *) itemPtr;
@@ -244,9 +247,9 @@ ImageCoords(
return TCL_ERROR;
} else if (objc != 2) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "wrong # coordinates: expected 2, got %d", objc));
+ "wrong # coordinates: expected 2, got %" TCL_SIZE_MODIFIER "d", objc));
Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "IMAGE",
- NULL);
+ (char *)NULL);
return TCL_ERROR;
}
}
@@ -259,8 +262,8 @@ ImageCoords(
ComputeImageBbox(canvas, imgPtr);
} else {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "wrong # coordinates: expected 0 or 2, got %d", objc));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "IMAGE", NULL);
+ "wrong # coordinates: expected 0 or 2, got %" TCL_SIZE_MODIFIER "d", objc));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "IMAGE", (char *)NULL);
return TCL_ERROR;
}
return TCL_OK;
@@ -289,7 +292,7 @@ ConfigureImage(
Tcl_Interp *interp, /* Used for error reporting. */
Tk_Canvas canvas, /* Canvas containing itemPtr. */
Tk_Item *itemPtr, /* Image item to reconfigure. */
- int objc, /* Number of elements in objv. */
+ Tcl_Size objc, /* Number of elements in objv. */
Tcl_Obj *const objv[], /* Arguments describing things to configure. */
int flags) /* Flags to pass to Tk_ConfigureWidget. */
{
@@ -377,9 +380,9 @@ ConfigureImage(
static void
DeleteImage(
- Tk_Canvas canvas, /* Info about overall canvas widget. */
+ TCL_UNUSED(Tk_Canvas), /* Info about overall canvas widget. */
Tk_Item *itemPtr, /* Item that is being deleted. */
- Display *display) /* Display containing window for canvas. */
+ TCL_UNUSED(Display *)) /* Display containing window for canvas. */
{
ImageItem *imgPtr = (ImageItem *) itemPtr;
@@ -421,7 +424,6 @@ DeleteImage(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static void
ComputeImageBbox(
Tk_Canvas canvas, /* Canvas that contains item. */
@@ -487,7 +489,7 @@ ComputeImageBbox(
break;
case TK_ANCHOR_NW:
break;
- case TK_ANCHOR_CENTER:
+ default:
x -= width/2;
y -= height/2;
break;
@@ -534,6 +536,7 @@ DisplayImage(
short drawableX, drawableY;
Tk_Image image;
Tk_State state = itemPtr->state;
+ (void)display;
if (state == TK_STATE_NULL) {
state = Canvas(canvas)->canvas_state;
@@ -586,7 +589,7 @@ DisplayImage(
static double
ImageToPoint(
- Tk_Canvas canvas, /* Canvas containing item. */
+ TCL_UNUSED(Tk_Canvas), /* Canvas containing item. */
Tk_Item *itemPtr, /* Item to check against point. */
double *coordPtr) /* Pointer to x and y coordinates. */
{
@@ -642,7 +645,7 @@ ImageToPoint(
static int
ImageToArea(
- Tk_Canvas canvas, /* Canvas containing item. */
+ TCL_UNUSED(Tk_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
@@ -719,7 +722,7 @@ ImageToPostscript(
* Image item without actual image specified.
*/
- return TCL_OK;
+ return TCL_OK;
}
Tk_SizeOfImage(image, &width, &height);
@@ -740,7 +743,7 @@ ImageToPostscript(
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;
+ default: x -= width/2.0; y -= height/2.0; break;
}
if (!prepass) {
@@ -761,6 +764,40 @@ ImageToPostscript(
/*
*--------------------------------------------------------------
*
+ * RotateImage --
+ *
+ * This function is called to rotate an image's origin by a given amount.
+ * This does *not* rotate the contents of the image.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * The position of the image anchor is rotated by angleRad radians about
+ * (originX, originY), and the bounding box is updated in the generic
+ * part of the item structure.
+ *
+ *--------------------------------------------------------------
+ */
+
+static void
+RotateImage(
+ Tk_Canvas canvas,
+ Tk_Item *itemPtr,
+ double originX,
+ double originY,
+ double angleRad)
+{
+ ImageItem *imgPtr = (ImageItem *) itemPtr;
+
+ TkRotatePoint(originX, originY, sin(angleRad), cos(angleRad),
+ &imgPtr->x, &imgPtr->y);
+ ComputeImageBbox(canvas, imgPtr);
+}
+
+/*
+ *--------------------------------------------------------------
+ *
* ScaleImage --
*
* This function is invoked to rescale an item.
@@ -844,14 +881,14 @@ TranslateImage(
static void
ImageChangedProc(
- ClientData clientData, /* Pointer to canvas item for image. */
+ void *clientData, /* Pointer to canvas item for image. */
int x, int y, /* Upper left pixel (within image) that must
* be redisplayed. */
int width, int height, /* Dimensions of area to redisplay (may be <=
* 0). */
int imgWidth, int imgHeight)/* New dimensions of image. */
{
- ImageItem *imgPtr = clientData;
+ ImageItem *imgPtr = (ImageItem *)clientData;
/*
* If the image's size changed and it's not anchored at its northwest
diff --git a/generic/tkCanvLine.c b/generic/tkCanvLine.c
index 408ef7c..a0e6b54 100644
--- a/generic/tkCanvLine.c
+++ b/generic/tkCanvLine.c
@@ -3,9 +3,9 @@
*
* This file implements line items for canvas widgets.
*
- * Copyright (c) 1991-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
- * Copyright (c) 1998-1999 Scriptics Corporation.
+ * Copyright © 1991-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1998-1999 Scriptics Corporation.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -33,7 +33,7 @@ typedef struct LineItem {
Tk_Outline outline; /* Outline structure */
Tk_Canvas canvas; /* Canvas containing item. Needed for parsing
* arrow shapes. */
- int numPoints; /* Number of points in line (always >= 0). */
+ Tcl_Size numPoints; /* Number of points in line (always >= 0). */
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
@@ -83,12 +83,12 @@ static int ArrowheadPostscript(Tcl_Interp *interp,
double *arrowPtr, Tcl_Obj *psObj);
static void ComputeLineBbox(Tk_Canvas canvas, LineItem *linePtr);
static int ConfigureLine(Tcl_Interp *interp,
- Tk_Canvas canvas, Tk_Item *itemPtr, int objc,
+ Tk_Canvas canvas, Tk_Item *itemPtr, Tcl_Size objc,
Tcl_Obj *const objv[], int flags);
static int ConfigureArrows(Tk_Canvas canvas, LineItem *linePtr);
static int CreateLine(Tcl_Interp *interp,
Tk_Canvas canvas, struct Tk_Item *itemPtr,
- int objc, Tcl_Obj *const objv[]);
+ Tcl_Size objc, Tcl_Obj *const objv[]);
static void DeleteLine(Tk_Canvas canvas,
Tk_Item *itemPtr, Display *display);
static void DisplayLine(Tk_Canvas canvas,
@@ -96,32 +96,34 @@ static void DisplayLine(Tk_Canvas canvas,
int x, int y, int width, int height);
static int GetLineIndex(Tcl_Interp *interp,
Tk_Canvas canvas, Tk_Item *itemPtr,
- Tcl_Obj *obj, int *indexPtr);
+ Tcl_Obj *obj, Tcl_Size *indexPtr);
static int LineCoords(Tcl_Interp *interp,
Tk_Canvas canvas, Tk_Item *itemPtr,
- int objc, Tcl_Obj *const objv[]);
+ Tcl_Size objc, Tcl_Obj *const objv[]);
static void LineDeleteCoords(Tk_Canvas canvas,
- Tk_Item *itemPtr, int first, int last);
+ Tk_Item *itemPtr, Tcl_Size first, Tcl_Size last);
static void LineInsert(Tk_Canvas canvas,
- Tk_Item *itemPtr, int beforeThis, Tcl_Obj *obj);
+ Tk_Item *itemPtr, Tcl_Size beforeThis, Tcl_Obj *obj);
static int LineToArea(Tk_Canvas canvas,
Tk_Item *itemPtr, double *rectPtr);
static double LineToPoint(Tk_Canvas canvas,
Tk_Item *itemPtr, double *coordPtr);
static int LineToPostscript(Tcl_Interp *interp,
Tk_Canvas canvas, Tk_Item *itemPtr, int prepass);
-static int ArrowParseProc(ClientData clientData,
+static int ArrowParseProc(void *clientData,
Tcl_Interp *interp, Tk_Window tkwin,
- const char *value, char *recordPtr, int offset);
-static const char * ArrowPrintProc(ClientData clientData,
- Tk_Window tkwin, char *recordPtr, int offset,
+ const char *value, char *recordPtr, Tcl_Size offset);
+static const char * ArrowPrintProc(void *clientData,
+ Tk_Window tkwin, char *recordPtr, Tcl_Size offset,
Tcl_FreeProc **freeProcPtr);
-static int ParseArrowShape(ClientData clientData,
+static int ParseArrowShape(void *clientData,
Tcl_Interp *interp, Tk_Window tkwin,
- const char *value, char *recordPtr, int offset);
-static const char * PrintArrowShape(ClientData clientData,
- Tk_Window tkwin, char *recordPtr, int offset,
+ const char *value, char *recordPtr, Tcl_Size offset);
+static const char * PrintArrowShape(void *clientData,
+ Tk_Window tkwin, char *recordPtr, Tcl_Size offset,
Tcl_FreeProc **freeProcPtr);
+static void RotateLine(Tk_Canvas canvas, Tk_Item *itemPtr,
+ double originX, double originY, double angleRad);
static void ScaleLine(Tk_Canvas canvas,
Tk_Item *itemPtr, double originX, double originY,
double scaleX, double scaleY);
@@ -162,58 +164,58 @@ static const Tk_CustomOption pixelOption = {
static const Tk_ConfigSpec configSpecs[] = {
{TK_CONFIG_CUSTOM, "-activedash", NULL, NULL,
- NULL, Tk_Offset(LineItem, outline.activeDash),
+ NULL, offsetof(LineItem, outline.activeDash),
TK_CONFIG_NULL_OK, &dashOption},
{TK_CONFIG_COLOR, "-activefill", NULL, NULL,
- NULL, Tk_Offset(LineItem, outline.activeColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(LineItem, outline.activeColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-activestipple", NULL, NULL,
- NULL, Tk_Offset(LineItem, outline.activeStipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(LineItem, outline.activeStipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-activewidth", NULL, NULL,
- "0.0", Tk_Offset(LineItem, outline.activeWidth),
+ "0.0", offsetof(LineItem, outline.activeWidth),
TK_CONFIG_DONT_SET_DEFAULT, &pixelOption},
{TK_CONFIG_CUSTOM, "-arrow", NULL, NULL,
- "none", Tk_Offset(LineItem, arrow),
+ "none", offsetof(LineItem, arrow),
TK_CONFIG_DONT_SET_DEFAULT, &arrowOption},
{TK_CONFIG_CUSTOM, "-arrowshape", NULL, NULL,
- "8 10 3", Tk_Offset(LineItem, arrowShapeA),
+ "8 10 3", offsetof(LineItem, arrowShapeA),
TK_CONFIG_DONT_SET_DEFAULT, &arrowShapeOption},
{TK_CONFIG_CAP_STYLE, "-capstyle", NULL, NULL,
- "butt", Tk_Offset(LineItem, capStyle), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "butt", offsetof(LineItem, capStyle), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_COLOR, "-fill", NULL, NULL,
- DEF_CANVITEM_OUTLINE, Tk_Offset(LineItem, outline.color), TK_CONFIG_NULL_OK, NULL},
+ DEF_CANVITEM_OUTLINE, offsetof(LineItem, outline.color), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-dash", NULL, NULL,
- NULL, Tk_Offset(LineItem, outline.dash),
+ NULL, offsetof(LineItem, outline.dash),
TK_CONFIG_NULL_OK, &dashOption},
{TK_CONFIG_PIXELS, "-dashoffset", NULL, NULL,
- "0", Tk_Offset(LineItem, outline.offset), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "0", offsetof(LineItem, outline.offset), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_CUSTOM, "-disableddash", NULL, NULL,
- NULL, Tk_Offset(LineItem, outline.disabledDash),
+ NULL, offsetof(LineItem, outline.disabledDash),
TK_CONFIG_NULL_OK, &dashOption},
{TK_CONFIG_COLOR, "-disabledfill", NULL, NULL,
- NULL, Tk_Offset(LineItem, outline.disabledColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(LineItem, outline.disabledColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-disabledstipple", NULL, NULL,
- NULL, Tk_Offset(LineItem, outline.disabledStipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(LineItem, outline.disabledStipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-disabledwidth", NULL, NULL,
- "0.0", Tk_Offset(LineItem, outline.disabledWidth),
+ "0.0", offsetof(LineItem, outline.disabledWidth),
TK_CONFIG_DONT_SET_DEFAULT, &pixelOption},
{TK_CONFIG_JOIN_STYLE, "-joinstyle", NULL, NULL,
- "round", Tk_Offset(LineItem, joinStyle), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "round", offsetof(LineItem, joinStyle), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_CUSTOM, "-offset", NULL, NULL,
- "0,0", Tk_Offset(LineItem, outline.tsoffset),
+ "0,0", offsetof(LineItem, outline.tsoffset),
TK_CONFIG_DONT_SET_DEFAULT, &offsetOption},
{TK_CONFIG_CUSTOM, "-smooth", NULL, NULL,
- "0", Tk_Offset(LineItem, smooth),
+ "0", offsetof(LineItem, smooth),
TK_CONFIG_DONT_SET_DEFAULT, &smoothOption},
{TK_CONFIG_INT, "-splinesteps", NULL, NULL,
- "12", Tk_Offset(LineItem, splineSteps), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "12", offsetof(LineItem, splineSteps), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_CUSTOM, "-state", NULL, NULL,
- NULL, Tk_Offset(Tk_Item, state), TK_CONFIG_NULL_OK, &stateOption},
+ NULL, offsetof(Tk_Item, state), TK_CONFIG_NULL_OK, &stateOption},
{TK_CONFIG_BITMAP, "-stipple", NULL, NULL,
- NULL, Tk_Offset(LineItem, outline.stipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(LineItem, outline.stipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-tags", NULL, NULL,
NULL, 0, TK_CONFIG_NULL_OK, &tagsOption},
{TK_CONFIG_CUSTOM, "-width", NULL, NULL,
- "1.0", Tk_Offset(LineItem, outline.width),
+ "1.0", offsetof(LineItem, outline.width),
TK_CONFIG_DONT_SET_DEFAULT, &pixelOption},
{TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}
};
@@ -244,7 +246,8 @@ Tk_ItemType tkLineType = {
LineInsert, /* insertProc */
LineDeleteCoords, /* dTextProc */
NULL, /* nextPtr */
- NULL, 0, NULL, NULL
+ RotateLine, /* rotateProc */
+ 0, NULL, NULL
};
/*
@@ -280,11 +283,11 @@ CreateLine(
Tk_Canvas canvas, /* Canvas to hold new item. */
Tk_Item *itemPtr, /* Record to hold new item; header has been
* initialized by caller. */
- int objc, /* Number of arguments in objv. */
+ Tcl_Size objc, /* Number of arguments in objv. */
Tcl_Obj *const objv[]) /* Arguments describing line. */
{
LineItem *linePtr = (LineItem *) itemPtr;
- int i;
+ Tcl_Size i;
if (objc == 0) {
Tcl_Panic("canvas did not pass any coords");
@@ -359,15 +362,15 @@ LineCoords(
Tk_Canvas canvas, /* Canvas containing item. */
Tk_Item *itemPtr, /* Item whose coordinates are to be read or
* modified. */
- int objc, /* Number of coordinates supplied in objv. */
+ Tcl_Size objc, /* Number of coordinates supplied in objv. */
Tcl_Obj *const objv[]) /* Array of coordinates: x1, y1, x2, y2, ... */
{
LineItem *linePtr = (LineItem *) itemPtr;
- int i, numPoints;
+ Tcl_Size i, numPoints;
double *coordPtr;
if (objc == 0) {
- int numCoords;
+ Tcl_Size numCoords;
Tcl_Obj *subobj, *obj = Tcl_NewObj();
numCoords = 2*linePtr->numPoints;
@@ -397,14 +400,14 @@ LineCoords(
}
if (objc & 1) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "wrong # coordinates: expected an even number, got %d",
+ "wrong # coordinates: expected an even number, got %" TCL_SIZE_MODIFIER "d",
objc));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "LINE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "LINE", (char *)NULL);
return TCL_ERROR;
} else if (objc < 4) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "wrong # coordinates: expected at least 4, got %d", objc));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "LINE", NULL);
+ "wrong # coordinates: expected at least 4, got %" TCL_SIZE_MODIFIER "d", objc));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "LINE", (char *)NULL);
return TCL_ERROR;
}
@@ -469,7 +472,7 @@ ConfigureLine(
Tcl_Interp *interp, /* Used for error reporting. */
Tk_Canvas canvas, /* Canvas containing itemPtr. */
Tk_Item *itemPtr, /* Line item to reconfigure. */
- int objc, /* Number of elements in objv. */
+ Tcl_Size objc, /* Number of elements in objv. */
Tcl_Obj *const objv[], /* Arguments describing things to configure. */
int flags) /* Flags to pass to Tk_ConfigureWidget. */
{
@@ -482,7 +485,7 @@ ConfigureLine(
tkwin = Tk_CanvasTkwin(canvas);
if (TCL_OK != Tk_ConfigureWidget(interp, tkwin, configSpecs, objc,
- (const char **) objv, (char *) linePtr, flags|TK_CONFIG_OBJS)) {
+ (const char **)objv, (char *)linePtr, flags|TK_CONFIG_OBJS)) {
return TCL_ERROR;
}
@@ -650,7 +653,8 @@ ComputeLineBbox(
LineItem *linePtr) /* Item whose bbos is to be recomputed. */
{
double *coordPtr;
- int i, intWidth;
+ Tcl_Size i;
+ int intWidth;
double width;
Tk_State state = linePtr->header.state;
Tk_TSOffset *tsoffset;
@@ -839,7 +843,7 @@ DisplayLine(
TCL_UNUSED(int),
TCL_UNUSED(int))
{
- LineItem *linePtr = (LineItem *) itemPtr;
+ LineItem *linePtr = (LineItem *)itemPtr;
XPoint staticPoints[MAX_STATIC_POINTS*3];
XPoint *pointPtr;
double linewidth;
@@ -956,12 +960,12 @@ static void
LineInsert(
Tk_Canvas canvas, /* Canvas containing text item. */
Tk_Item *itemPtr, /* Line item to be modified. */
- int beforeThis, /* Index before which new coordinates are to
+ Tcl_Size beforeThis, /* Index before which new coordinates are to
* be inserted. */
Tcl_Obj *obj) /* New coordinates to be inserted. */
{
LineItem *linePtr = (LineItem *) itemPtr;
- int length, oriNumPoints, objc, nbInsPoints, i;
+ Tcl_Size length, oriNumPoints, objc, nbInsPoints, i;
double *newCoordPtr, *coordPtr;
Tk_State state = itemPtr->state;
Tcl_Obj **objv;
@@ -1010,11 +1014,11 @@ LineInsert(
}
}
- for (i=beforeThis; i<length; i++) {
+ for (i=(int)beforeThis; i<length; i++) {
newCoordPtr[i+objc] = linePtr->coordPtr[i];
}
if (linePtr->coordPtr) {
- ckfree(linePtr->coordPtr);
+ ckfree(linePtr->coordPtr);
}
linePtr->coordPtr = newCoordPtr;
length += objc ;
@@ -1043,7 +1047,6 @@ LineInsert(
objc += 4;
if (linePtr->smooth) {
-
if (!strcmp(linePtr->smooth->name, "true")) {
/*
* Quadratic Bezier splines. A second point must be included at
@@ -1058,7 +1061,7 @@ LineInsert(
* of the line, include a third point.
*/
- if (beforeThis == -4) {
+ if (beforeThis == (Tcl_Size)-4) {
objc += 2;
}
if (beforeThis + 4 == length - (objc - 8)) {
@@ -1079,7 +1082,7 @@ LineInsert(
itemPtr->redraw_flags &= ~TK_ITEM_DONT_REDRAW;
} else {
- beforeThis -= beforeThis % 6;
+ beforeThis -= (int)beforeThis % 6;
objc += 4;
}
@@ -1093,16 +1096,16 @@ LineInsert(
}
if (itemPtr->redraw_flags & TK_ITEM_DONT_REDRAW) {
- if (beforeThis < 0) {
+ if ((int)beforeThis < 0) {
beforeThis = 0;
}
- if (beforeThis + objc > length) {
- objc = length - beforeThis;
+ if ((int)beforeThis + objc > length) {
+ objc = length - (int)beforeThis;
}
itemPtr->x1 = itemPtr->x2 = (int) linePtr->coordPtr[beforeThis];
itemPtr->y1 = itemPtr->y2 = (int) linePtr->coordPtr[beforeThis+1];
- if ((linePtr->firstArrowPtr != NULL) && (beforeThis < 2)) {
+ if ((linePtr->firstArrowPtr != NULL) && ((int)beforeThis < 2)) {
/*
* Include old first arrow.
*/
@@ -1112,7 +1115,7 @@ LineInsert(
TkIncludePoint(itemPtr, coordPtr);
}
}
- if ((linePtr->lastArrowPtr != NULL) && (beforeThis+objc >= length)) {
+ if ((linePtr->lastArrowPtr != NULL) && ((int)beforeThis+objc >= length)) {
/*
* Include old last arrow.
*/
@@ -1146,7 +1149,7 @@ LineInsert(
double width;
int intWidth;
- if ((linePtr->firstArrowPtr != NULL) && (beforeThis < 2)) {
+ if ((linePtr->firstArrowPtr != NULL) && ((int)beforeThis < 2)) {
/*
* Include new first arrow.
*/
@@ -1156,7 +1159,7 @@ LineInsert(
TkIncludePoint(itemPtr, coordPtr);
}
}
- if ((linePtr->lastArrowPtr != NULL) && (beforeThis+objc >= length)) {
+ if ((linePtr->lastArrowPtr != NULL) && ((int)beforeThis+objc >= length)) {
/*
* Include new last arrow.
*/
@@ -1212,8 +1215,8 @@ static void
LineDeleteCoords(
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. */
+ Tcl_Size first, /* Index of first character to delete. */
+ Tcl_Size last) /* Index of last character to delete. */
{
LineItem *linePtr = (LineItem *) itemPtr;
int count, i, first1, last1, nbDelPoints;
@@ -1230,13 +1233,13 @@ LineDeleteCoords(
first &= -2; /* If odd, make it even. */
last &= -2;
- if (first < 0) {
+ if ((int)first < 0) {
first = 0;
}
- if (last >= length) {
+ if ((int)last >= length) {
last = length - 2;
}
- if (first > last) {
+ if ((int)first > (int)last) {
return;
}
@@ -1808,7 +1811,7 @@ ScaleLine(
{
LineItem *linePtr = (LineItem *) itemPtr;
double *coordPtr;
- int i;
+ Tcl_Size i;
/*
* Delete any arrowheads before scaling all the points (so that the
@@ -1861,36 +1864,52 @@ ScaleLine(
static int
GetLineIndex(
Tcl_Interp *interp, /* Used for error reporting. */
- Tk_Canvas canvas, /* Canvas containing item. */
+ TCL_UNUSED(Tk_Canvas), /* Canvas containing item. */
Tk_Item *itemPtr, /* Item for which the index is being
* specified. */
Tcl_Obj *obj, /* Specification of a particular coord in
* itemPtr's line. */
- int *indexPtr) /* Where to store converted index. */
+ Tcl_Size *indexPtr) /* Where to store converted index. */
{
+ Tcl_Size idx, length;
LineItem *linePtr = (LineItem *) itemPtr;
- const char *string = Tcl_GetString(obj);
+ char *string;
- if (string[0] == 'e') {
- if (strncmp(string, "end", obj->length) == 0) {
- *indexPtr = 2*linePtr->numPoints;
+ if (TCL_OK == TkGetIntForIndex(obj, 2*linePtr->numPoints - 1, 1, &idx)) {
+ if (idx < 0) {
+ idx = 0;
+ } else if (idx > (2*(Tcl_Size)linePtr->numPoints)) {
+ idx = 2*linePtr->numPoints;
} else {
- goto badIndex;
+ idx &= (Tcl_Size)-2; /* If index is odd, make it even. */
}
- } else if (string[0] == '@') {
- int i;
+ *indexPtr = idx;
+ return TCL_OK;
+ }
+
+ string = Tcl_GetStringFromObj(obj, &length);
+
+ if (string[0] == '@') {
+ Tcl_Size i;
double x, y, bestDist, dist, *coordPtr;
- char *end;
- const char *p;
+ char savechar;
+ char *p, *sep;
p = string+1;
- x = strtod(p, &end);
- if ((end == p) || (*end != ',')) {
+ sep = strchr(p, ',');
+ if (!sep) {
+ goto badIndex;
+ }
+ savechar = *sep;
+ *sep = '\0';
+ i = Tcl_GetDouble(NULL, p, &x);
+ *sep = savechar;
+ if (i != TCL_OK) {
goto badIndex;
}
- p = end+1;
- y = strtod(p, &end);
- if ((end == p) || (*end != 0)) {
+ p = sep+1;
+ i = Tcl_GetDouble(NULL, p, &y);
+ if (i != TCL_OK) {
goto badIndex;
}
bestDist = 1.0e36;
@@ -1905,28 +1924,12 @@ GetLineIndex(
coordPtr += 2;
}
} else {
- if (Tcl_GetIntFromObj(interp, obj, indexPtr) != TCL_OK) {
- goto badIndex;
- }
- *indexPtr &= -2; /* If index is odd, make it even. */
- if (*indexPtr < 0){
- *indexPtr = 0;
- } else if (*indexPtr > (2*linePtr->numPoints)) {
- *indexPtr = (2*linePtr->numPoints);
- }
+ badIndex:
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad index \"%s\"", string));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "ITEM_INDEX", "LINE", (char *)NULL);
+ return TCL_ERROR;
}
return TCL_OK;
-
- /*
- * Some of the paths here leave messages in interp->result, so we have to
- * clear it out before storing our own message.
- */
-
- badIndex:
- Tcl_ResetResult(interp);
- Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad index \"%s\"", string));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "ITEM_INDEX", "LINE", NULL);
- return TCL_ERROR;
}
/*
@@ -1955,7 +1958,7 @@ TranslateLine(
{
LineItem *linePtr = (LineItem *) itemPtr;
double *coordPtr;
- int i;
+ Tcl_Size i;
for (i = 0, coordPtr = linePtr->coordPtr; i < linePtr->numPoints;
i++, coordPtr += 2) {
@@ -1982,6 +1985,56 @@ TranslateLine(
/*
*--------------------------------------------------------------
*
+ * RotateLine --
+ *
+ * This function is called to rotate a line by a given amount about a
+ * point.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * The position of the line is rotated by angleRad about (originX,
+ * originY), and the bounding box is updated in the generic part of the
+ * item structure.
+ *
+ *--------------------------------------------------------------
+ */
+
+static void
+RotateLine(
+ Tk_Canvas canvas, /* Canvas containing item. */
+ Tk_Item *itemPtr, /* Item that is being moved. */
+ double originX, double originY,
+ double angleRad) /* Amount by which item is to be rotated. */
+{
+ LineItem *linePtr = (LineItem *) itemPtr;
+ double *coordPtr;
+ Tcl_Size i;
+ double s = sin(angleRad), c = cos(angleRad);
+
+ for (i = 0, coordPtr = linePtr->coordPtr; i < linePtr->numPoints;
+ i++, coordPtr += 2) {
+ TkRotatePoint(originX, originY, s, c, &coordPtr[0], &coordPtr[1]);
+ }
+ if (linePtr->firstArrowPtr != NULL) {
+ for (i = 0, coordPtr = linePtr->firstArrowPtr; i < PTS_IN_ARROW;
+ i++, coordPtr += 2) {
+ TkRotatePoint(originX, originY, s, c, &coordPtr[0], &coordPtr[1]);
+ }
+ }
+ if (linePtr->lastArrowPtr != NULL) {
+ for (i = 0, coordPtr = linePtr->lastArrowPtr; i < PTS_IN_ARROW;
+ i++, coordPtr += 2) {
+ TkRotatePoint(originX, originY, s, c, &coordPtr[0], &coordPtr[1]);
+ }
+ }
+ ComputeLineBbox(canvas, linePtr);
+}
+
+/*
+ *--------------------------------------------------------------
+ *
* ParseArrowShape --
*
* This function is called back during option parsing to parse arrow
@@ -2006,15 +2059,15 @@ ParseArrowShape(
const 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
+ Tcl_Size offset) /* Offset of shape information in widget
* record. */
{
LineItem *linePtr = (LineItem *) recordPtr;
double a, b, c;
- int argc;
+ Tcl_Size argc;
const char **argv = NULL;
- if (offset != Tk_Offset(LineItem, arrowShapeA)) {
+ if ((size_t)offset != offsetof(LineItem, arrowShapeA)) {
Tcl_Panic("ParseArrowShape received bogus offset");
}
@@ -2042,7 +2095,7 @@ ParseArrowShape(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad arrow shape \"%s\": must be list with three numbers",
value));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "ARROW_SHAPE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "ARROW_SHAPE", (char *)NULL);
if (argv != NULL) {
ckfree(argv);
}
@@ -2072,7 +2125,7 @@ PrintArrowShape(
TCL_UNUSED(Tk_Window), /* Window associated with linePtr's widget. */
char *recordPtr, /* Pointer to item record containing current
* shape information. */
- TCL_UNUSED(int), /* Offset of arrow information in record. */
+ TCL_UNUSED(Tcl_Size), /* Offset of arrow information in record. */
Tcl_FreeProc **freeProcPtr) /* Store address of function to call to free
* string here. */
{
@@ -2110,7 +2163,7 @@ ArrowParseProc(
TCL_UNUSED(Tk_Window), /* Window containing canvas widget. */
const char *value, /* Value of option. */
char *widgRec, /* Pointer to record for item. */
- int offset) /* Offset into item. */
+ Tcl_Size offset) /* Offset into item. */
{
int c;
size_t length;
@@ -2144,7 +2197,7 @@ ArrowParseProc(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad arrow spec \"%s\": must be none, first, last, or both",
value));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "ARROW", NULL);
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "ARROW", (char *)NULL);
*arrowPtr = ARROWS_NONE;
return TCL_ERROR;
}
@@ -2175,7 +2228,7 @@ ArrowPrintProc(
TCL_UNUSED(void *), /* Ignored. */
TCL_UNUSED(Tk_Window), /* Window containing canvas widget. */
char *widgRec, /* Pointer to record for item. */
- int offset, /* Offset into item. */
+ Tcl_Size offset, /* Offset into item. */
TCL_UNUSED(Tcl_FreeProc **)) /* Pointer to variable to fill in with
* information about how to reclaim storage
* for return string. */
@@ -2433,28 +2486,24 @@ LineToPostscript(
*/
if (linePtr->numPoints == 1) {
- Tcl_AppendToObj(psObj, "matrix currentmatrix\n", -1);
+ Tcl_AppendToObj(psObj, "matrix currentmatrix\n", TCL_INDEX_NONE);
Tcl_AppendPrintfToObj(psObj, "%.15g %.15g translate %.15g %.15g",
linePtr->coordPtr[0], Tk_CanvasPsY(canvas, linePtr->coordPtr[1]),
width/2.0, width/2.0);
Tcl_AppendToObj(psObj,
- " scale 1 0 moveto 0 0 1 0 360 arc\nsetmatrix\n", -1);
+ " scale 1 0 moveto 0 0 1 0 360 arc\nsetmatrix\n", TCL_INDEX_NONE);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsColor(interp, canvas, color) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsColor(interp, canvas, color);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (stipple != None) {
- Tcl_AppendToObj(psObj, "clip ", -1);
+ Tcl_AppendToObj(psObj, "clip ", TCL_INDEX_NONE);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsStipple(interp, canvas, stipple) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsStipple(interp, canvas, stipple);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
} else {
- Tcl_AppendToObj(psObj, "fill\n", -1);
+ Tcl_AppendToObj(psObj, "fill\n", TCL_INDEX_NONE);
}
goto done;
}
@@ -2520,9 +2569,7 @@ LineToPostscript(
Tcl_AppendPrintfToObj(psObj, "%d setlinejoin\n", style);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsOutline(canvas, itemPtr, &linePtr->outline) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsOutline(canvas, itemPtr, &linePtr->outline);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
/*
@@ -2531,21 +2578,17 @@ LineToPostscript(
if (linePtr->firstArrowPtr != NULL) {
if (stipple != None) {
- Tcl_AppendToObj(psObj, "grestore gsave\n", -1);
- }
- if (ArrowheadPostscript(interp, canvas, linePtr,
- linePtr->firstArrowPtr, psObj) != TCL_OK) {
- goto error;
+ Tcl_AppendToObj(psObj, "grestore gsave\n", TCL_INDEX_NONE);
}
+ ArrowheadPostscript(interp, canvas, linePtr,
+ linePtr->firstArrowPtr, psObj);
}
if (linePtr->lastArrowPtr != NULL) {
if (stipple != None) {
- Tcl_AppendToObj(psObj, "grestore gsave\n", -1);
- }
- if (ArrowheadPostscript(interp, canvas, linePtr,
- linePtr->lastArrowPtr, psObj) != TCL_OK) {
- goto error;
+ Tcl_AppendToObj(psObj, "grestore gsave\n", TCL_INDEX_NONE);
}
+ ArrowheadPostscript(interp, canvas, linePtr,
+ linePtr->lastArrowPtr, psObj);
}
/*
@@ -2557,11 +2600,6 @@ LineToPostscript(
Tcl_AppendObjToObj(Tcl_GetObjResult(interp), psObj);
Tcl_DecrRefCount(psObj);
return TCL_OK;
-
- error:
- Tcl_DiscardInterpState(interpState);
- Tcl_DecrRefCount(psObj);
- return TCL_ERROR;
}
/*
@@ -2618,15 +2656,13 @@ ArrowheadPostscript(
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (stipple != None) {
- Tcl_AppendToObj(psObj, "clip ", -1);
+ Tcl_AppendToObj(psObj, "clip ", TCL_INDEX_NONE);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsStipple(interp, canvas, stipple) != TCL_OK) {
- return TCL_ERROR;
- }
+ Tk_CanvasPsStipple(interp, canvas, stipple);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
} else {
- Tcl_AppendToObj(psObj, "fill\n", -1);
+ Tcl_AppendToObj(psObj, "fill\n", TCL_INDEX_NONE);
}
return TCL_OK;
}
diff --git a/generic/tkCanvPoly.c b/generic/tkCanvPoly.c
index aeca8a7..400e4c5 100644
--- a/generic/tkCanvPoly.c
+++ b/generic/tkCanvPoly.c
@@ -3,9 +3,9 @@
*
* 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.
- * Copyright (c) 1998-2000 Ajuba Solutions.
+ * Copyright © 1991-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1998-2000 Ajuba Solutions.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -77,70 +77,69 @@ static const Tk_CustomOption pixelOption = {
static const Tk_ConfigSpec configSpecs[] = {
{TK_CONFIG_CUSTOM, "-activedash", NULL, NULL,
- NULL, Tk_Offset(PolygonItem, outline.activeDash),
+ NULL, offsetof(PolygonItem, outline.activeDash),
TK_CONFIG_NULL_OK, &dashOption},
{TK_CONFIG_COLOR, "-activefill", NULL, NULL,
- NULL, Tk_Offset(PolygonItem, activeFillColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(PolygonItem, activeFillColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_COLOR, "-activeoutline", NULL, NULL,
- NULL, Tk_Offset(PolygonItem, outline.activeColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(PolygonItem, outline.activeColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-activeoutlinestipple", NULL, NULL,
- NULL, Tk_Offset(PolygonItem, outline.activeStipple),
+ NULL, offsetof(PolygonItem, outline.activeStipple),
TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-activestipple", NULL, NULL,
- NULL, Tk_Offset(PolygonItem, activeFillStipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(PolygonItem, activeFillStipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-activewidth", NULL, NULL,
- "0.0", Tk_Offset(PolygonItem, outline.activeWidth),
+ "0.0", offsetof(PolygonItem, outline.activeWidth),
TK_CONFIG_DONT_SET_DEFAULT, &pixelOption},
{TK_CONFIG_CUSTOM, "-dash", NULL, NULL,
- NULL, Tk_Offset(PolygonItem, outline.dash),
+ NULL, offsetof(PolygonItem, outline.dash),
TK_CONFIG_NULL_OK, &dashOption},
{TK_CONFIG_PIXELS, "-dashoffset", NULL, NULL,
- "0", Tk_Offset(PolygonItem, outline.offset),
+ "0", offsetof(PolygonItem, outline.offset),
TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_CUSTOM, "-disableddash", NULL, NULL,
- NULL, Tk_Offset(PolygonItem, outline.disabledDash),
+ NULL, offsetof(PolygonItem, outline.disabledDash),
TK_CONFIG_NULL_OK, &dashOption},
{TK_CONFIG_COLOR, "-disabledfill", NULL, NULL,
- NULL, Tk_Offset(PolygonItem, disabledFillColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(PolygonItem, disabledFillColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_COLOR, "-disabledoutline", NULL, NULL,
- NULL, Tk_Offset(PolygonItem, outline.disabledColor),
+ NULL, offsetof(PolygonItem, outline.disabledColor),
TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-disabledoutlinestipple", NULL, NULL,
- NULL, Tk_Offset(PolygonItem, outline.disabledStipple),
+ NULL, offsetof(PolygonItem, outline.disabledStipple),
TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-disabledstipple", NULL, NULL,
- NULL, Tk_Offset(PolygonItem, disabledFillStipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(PolygonItem, disabledFillStipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-disabledwidth", NULL, NULL,
- "0.0", Tk_Offset(PolygonItem, outline.disabledWidth),
+ "0.0", offsetof(PolygonItem, outline.disabledWidth),
TK_CONFIG_DONT_SET_DEFAULT, &pixelOption},
- /* Remark: Default for -fill should be NULL, see [2860519]. Will be fixed in Tk 8.7 */
{TK_CONFIG_COLOR, "-fill", NULL, NULL,
- DEF_CANVITEM_OUTLINE, Tk_Offset(PolygonItem, fillColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(PolygonItem, fillColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_JOIN_STYLE, "-joinstyle", NULL, NULL,
- "round", Tk_Offset(PolygonItem, joinStyle), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "round", offsetof(PolygonItem, joinStyle), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_CUSTOM, "-offset", NULL, NULL,
- "0,0", Tk_Offset(PolygonItem, tsoffset),
+ "0,0", offsetof(PolygonItem, tsoffset),
TK_CONFIG_NULL_OK, &offsetOption},
{TK_CONFIG_COLOR, "-outline", NULL, NULL,
- NULL, Tk_Offset(PolygonItem, outline.color), TK_CONFIG_NULL_OK, NULL},
+ DEF_CANVITEM_OUTLINE, offsetof(PolygonItem, outline.color), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-outlineoffset", NULL, NULL,
- "0,0", Tk_Offset(PolygonItem, outline.tsoffset),
+ "0,0", offsetof(PolygonItem, outline.tsoffset),
TK_CONFIG_NULL_OK, &offsetOption},
{TK_CONFIG_BITMAP, "-outlinestipple", NULL, NULL,
- NULL, Tk_Offset(PolygonItem, outline.stipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(PolygonItem, outline.stipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-smooth", NULL, NULL,
- "0", Tk_Offset(PolygonItem, smooth),
+ "0", offsetof(PolygonItem, smooth),
TK_CONFIG_DONT_SET_DEFAULT, &smoothOption},
{TK_CONFIG_INT, "-splinesteps", NULL, NULL,
- "12", Tk_Offset(PolygonItem, splineSteps), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "12", offsetof(PolygonItem, splineSteps), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_CUSTOM, "-state", NULL, NULL,
- NULL, Tk_Offset(Tk_Item, state), TK_CONFIG_NULL_OK, &stateOption},
+ NULL, offsetof(Tk_Item, state), TK_CONFIG_NULL_OK, &stateOption},
{TK_CONFIG_BITMAP, "-stipple", NULL, NULL,
- NULL, Tk_Offset(PolygonItem, fillStipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(PolygonItem, fillStipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-tags", NULL, NULL,
NULL, 0, TK_CONFIG_NULL_OK, &tagsOption},
{TK_CONFIG_CUSTOM, "-width", NULL, NULL,
- "1.0", Tk_Offset(PolygonItem, outline.width),
+ "1.0", offsetof(PolygonItem, outline.width),
TK_CONFIG_DONT_SET_DEFAULT, &pixelOption},
{TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}
};
@@ -152,11 +151,11 @@ static const Tk_ConfigSpec configSpecs[] = {
static void ComputePolygonBbox(Tk_Canvas canvas,
PolygonItem *polyPtr);
static int ConfigurePolygon(Tcl_Interp *interp,
- Tk_Canvas canvas, Tk_Item *itemPtr, int objc,
+ Tk_Canvas canvas, Tk_Item *itemPtr, Tcl_Size objc,
Tcl_Obj *const objv[], int flags);
static int CreatePolygon(Tcl_Interp *interp,
Tk_Canvas canvas, struct Tk_Item *itemPtr,
- int objc, Tcl_Obj *const objv[]);
+ Tcl_Size objc, Tcl_Obj *const objv[]);
static void DeletePolygon(Tk_Canvas canvas,
Tk_Item *itemPtr, Display *display);
static void DisplayPolygon(Tk_Canvas canvas,
@@ -164,20 +163,22 @@ static void DisplayPolygon(Tk_Canvas canvas,
int x, int y, int width, int height);
static int GetPolygonIndex(Tcl_Interp *interp,
Tk_Canvas canvas, Tk_Item *itemPtr,
- Tcl_Obj *obj, int *indexPtr);
+ Tcl_Obj *obj, Tcl_Size *indexPtr);
static int PolygonCoords(Tcl_Interp *interp,
Tk_Canvas canvas, Tk_Item *itemPtr,
- int objc, Tcl_Obj *const objv[]);
+ Tcl_Size objc, Tcl_Obj *const objv[]);
static void PolygonDeleteCoords(Tk_Canvas canvas,
- Tk_Item *itemPtr, int first, int last);
+ Tk_Item *itemPtr, Tcl_Size first, Tcl_Size last);
static void PolygonInsert(Tk_Canvas canvas,
- Tk_Item *itemPtr, int beforeThis, Tcl_Obj *obj);
+ Tk_Item *itemPtr, Tcl_Size beforeThis, Tcl_Obj *obj);
static int PolygonToArea(Tk_Canvas canvas,
Tk_Item *itemPtr, double *rectPtr);
static double PolygonToPoint(Tk_Canvas canvas,
Tk_Item *itemPtr, double *pointPtr);
static int PolygonToPostscript(Tcl_Interp *interp,
Tk_Canvas canvas, Tk_Item *itemPtr, int prepass);
+static void RotatePolygon(Tk_Canvas canvas, Tk_Item *itemPtr,
+ double originX, double originY, double angleRad);
static void ScalePolygon(Tk_Canvas canvas,
Tk_Item *itemPtr, double originX, double originY,
double scaleX, double scaleY);
@@ -210,7 +211,8 @@ Tk_ItemType tkPolygonType = {
PolygonInsert, /* insertProc */
PolygonDeleteCoords, /* dTextProc */
NULL, /* nextPtr */
- NULL, 0, NULL, NULL
+ RotatePolygon, /* rotateProc */
+ 0, NULL, NULL
};
/*
@@ -246,11 +248,11 @@ CreatePolygon(
Tk_Canvas canvas, /* Canvas to hold new item. */
Tk_Item *itemPtr, /* Record to hold new item; header has been
* initialized by caller. */
- int objc, /* Number of arguments in objv. */
+ Tcl_Size objc, /* Number of arguments in objv. */
Tcl_Obj *const objv[]) /* Arguments describing polygon. */
{
PolygonItem *polyPtr = (PolygonItem *) itemPtr;
- int i;
+ Tcl_Size i;
if (objc == 0) {
Tcl_Panic("canvas did not pass any coords");
@@ -330,11 +332,12 @@ PolygonCoords(
Tk_Canvas canvas, /* Canvas containing item. */
Tk_Item *itemPtr, /* Item whose coordinates are to be read or
* modified. */
- int objc, /* Number of coordinates supplied in objv. */
+ Tcl_Size objc, /* Number of coordinates supplied in objv. */
Tcl_Obj *const objv[]) /* Array of coordinates: x1, y1, x2, y2, ... */
{
PolygonItem *polyPtr = (PolygonItem *) itemPtr;
- int i, numPoints;
+ int i;
+ int numPoints;
if (objc == 0) {
/*
@@ -359,9 +362,9 @@ PolygonCoords(
}
if (objc & 1) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "wrong # coordinates: expected an even number, got %d",
+ "wrong # coordinates: expected an even number, got %" TCL_SIZE_MODIFIER "d",
objc));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "POLYGON", NULL);
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "POLYGON", (char *)NULL);
return TCL_ERROR;
}
@@ -428,7 +431,7 @@ ConfigurePolygon(
Tcl_Interp *interp, /* Interpreter for error reporting. */
Tk_Canvas canvas, /* Canvas containing itemPtr. */
Tk_Item *itemPtr, /* Polygon item to reconfigure. */
- int objc, /* Number of elements in objv. */
+ Tcl_Size objc, /* Number of elements in objv. */
Tcl_Obj *const objv[], /* Arguments describing things to configure. */
int flags) /* Flags to pass to Tk_ConfigureWidget. */
{
@@ -1014,12 +1017,13 @@ static void
PolygonInsert(
Tk_Canvas canvas, /* Canvas containing text item. */
Tk_Item *itemPtr, /* Line item to be modified. */
- int beforeThis, /* Index before which new coordinates are to
+ Tcl_Size beforeThis, /* Index before which new coordinates are to
* be inserted. */
Tcl_Obj *obj) /* New coordinates to be inserted. */
{
PolygonItem *polyPtr = (PolygonItem *) itemPtr;
- int length, oriNumPoints, objc, nbInsPoints, i;
+ int length, oriNumPoints, nbInsPoints, i;
+ Tcl_Size objc;
Tcl_Obj **objv;
double *newCoordPtr;
Tk_State state = itemPtr->state;
@@ -1035,14 +1039,14 @@ PolygonInsert(
oriNumPoints = polyPtr->numPoints - polyPtr->autoClosed;
length = 2*(polyPtr->numPoints - polyPtr->autoClosed);
nbInsPoints = objc / 2;
- while (beforeThis > length) {
+ while ((int)beforeThis > length) {
beforeThis -= length;
}
- while (beforeThis < 0) {
+ while ((int)beforeThis < 0) {
beforeThis += length;
}
newCoordPtr = (double *)ckalloc(sizeof(double) * (length + 2 + objc));
- for (i=0; i<beforeThis; i++) {
+ for (i=0; i<(int)beforeThis; i++) {
newCoordPtr[i] = polyPtr->coordPtr[i];
}
for (i=0; i<objc; i++) {
@@ -1053,7 +1057,7 @@ PolygonInsert(
}
}
- for (i=beforeThis; i<length; i++) {
+ for (i=(int)beforeThis; i<length; i++) {
newCoordPtr[i+objc] = polyPtr->coordPtr[i];
}
if (polyPtr->coordPtr) {
@@ -1136,7 +1140,7 @@ PolygonInsert(
itemPtr->redraw_flags &= ~TK_ITEM_DONT_REDRAW;
} else {
- beforeThis -= abs(beforeThis) % 6;
+ beforeThis -= abs((int)beforeThis) % 6;
objc += 4;
}
@@ -1154,7 +1158,7 @@ PolygonInsert(
* Be careful; beforeThis could now be negative
*/
- for (i=beforeThis; i<beforeThis+objc; i+=2) {
+ for (i=(int)beforeThis; i<(int)beforeThis+objc; i+=2) {
j = i;
if (j < 0) {
j += length;
@@ -1206,23 +1210,23 @@ static void
PolygonDeleteCoords(
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. */
+ Tcl_Size first, /* Index of first character to delete. */
+ Tcl_Size last) /* Index of last character to delete. */
{
PolygonItem *polyPtr = (PolygonItem *) itemPtr;
int count, i;
int length = 2*(polyPtr->numPoints - polyPtr->autoClosed);
- while (first >= length) {
+ while ((int)first >= length) {
first -= length;
}
- while (first < 0) {
+ while ((int)first < 0) {
first += length;
}
- while (last >= length) {
+ while ((int)last >= length) {
last -= length;
}
- while (last < 0) {
+ while ((int)last < 0) {
last += length;
}
@@ -1249,7 +1253,7 @@ PolygonDeleteCoords(
polyPtr->coordPtr[i-count] = polyPtr->coordPtr[i];
}
} else {
- for (i=last; i<=first; i++) {
+ for (i=last; i<=(int)first; i++) {
polyPtr->coordPtr[i-last] = polyPtr->coordPtr[i];
}
}
@@ -1709,30 +1713,43 @@ GetPolygonIndex(
* specified. */
Tcl_Obj *obj, /* Specification of a particular coord in
* itemPtr's line. */
- int *indexPtr) /* Where to store converted index. */
+ Tcl_Size *indexPtr) /* Where to store converted index. */
{
+ Tcl_Size length, idx;
PolygonItem *polyPtr = (PolygonItem *) itemPtr;
- const char *string = Tcl_GetString(obj);
-
- if (string[0] == 'e') {
- if (strncmp(string, "end", obj->length) != 0) {
- goto badIndex;
+ const char *string;
+ Tcl_Size count = 2*(polyPtr->numPoints - polyPtr->autoClosed);
+
+ if (TCL_OK == TkGetIntForIndex(obj, (INT_MAX - 1) - ((INT_MAX) % count), 1, &idx)) {
+ if (idx < 0) {
+ idx = 0;
+ } else if (idx >= INT_MAX - ((INT_MAX) % count)) {
+ idx = count;
+ } else {
+ idx = (idx & (Tcl_Size)-2) % count;
}
- *indexPtr = 2*(polyPtr->numPoints - polyPtr->autoClosed);
- } else if (string[0] == '@') {
+ *indexPtr = idx;
+ return TCL_OK;
+ }
+
+ string = Tcl_GetStringFromObj(obj, &length);
+
+ if (string[0] == '@') {
int i;
double x, y, bestDist, dist, *coordPtr;
- char *end;
+ char *rest;
const char *p;
p = string+1;
- x = strtod(p, &end);
- if ((end == p) || (*end != ',')) {
+ rest = strchr((char *)p, ',');
+ *rest = '\0';
+ if (Tcl_GetDouble(NULL, p, &x) != TCL_OK) {
+ *rest = ',';
goto badIndex;
}
- p = end+1;
- y = strtod(p, &end);
- if ((end == p) || (*end != 0)) {
+ *rest = ',';
+ p = rest+1;
+ if (Tcl_GetDouble(NULL, p, &y) != TCL_OK) {
goto badIndex;
}
bestDist = 1.0e36;
@@ -1747,31 +1764,50 @@ GetPolygonIndex(
coordPtr += 2;
}
} else {
- int count = 2*(polyPtr->numPoints - polyPtr->autoClosed);
-
- if (Tcl_GetIntFromObj(interp, obj, indexPtr) != TCL_OK) {
- goto badIndex;
- }
- *indexPtr &= -2; /* if odd, make it even */
- if (!count) {
- *indexPtr = 0;
- } else if (*indexPtr > 0) {
- *indexPtr = ((*indexPtr - 2) % count) + 2;
- } else {
- *indexPtr = -((-(*indexPtr)) % count);
- }
+ badIndex:
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad index \"%s\"", string));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "ITEM_INDEX", "POLY", (char *)NULL);
+ return TCL_ERROR;
}
return TCL_OK;
+}
+
+/*
+ *--------------------------------------------------------------
+ *
+ * RotatePolygon --
+ *
+ * This function is called to rotate a polygon by a given amount about a
+ * point.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * The position of the polygon is rotated by angleRad about (originX,
+ * originY), and the bounding box is updated in the generic part of the
+ * item structure.
+ *
+ *--------------------------------------------------------------
+ */
- /*
- * Some of the paths here leave messages in interp->result, so we have to
- * clear it out before storing our own message.
- */
+static void
+RotatePolygon(
+ Tk_Canvas canvas, /* Canvas containing item. */
+ Tk_Item *itemPtr, /* Item that is being moved. */
+ double originX, double originY,
+ double angleRad) /* Amount by which item is to be rotated. */
+{
+ PolygonItem *polyPtr = (PolygonItem *) itemPtr;
+ double *coordPtr;
+ int i;
+ double s = sin(angleRad), c = cos(angleRad);
- badIndex:
- Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad index \"%s\"", string));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "ITEM_INDEX", "POLY", NULL);
- return TCL_ERROR;
+ for (i = 0, coordPtr = polyPtr->coordPtr; i < polyPtr->numPoints;
+ i++, coordPtr += 2) {
+ TkRotatePoint(originX, originY, s, c, &coordPtr[0], &coordPtr[1]);
+ }
+ ComputePolygonBbox(canvas, polyPtr);
}
/*
@@ -1928,21 +1964,17 @@ PolygonToPostscript(
*/
Tcl_ResetResult(interp);
- if (Tk_CanvasPsColor(interp, canvas, color) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsColor(interp, canvas, color);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (stipple != None) {
- Tcl_AppendToObj(psObj, "clip ", -1);
+ Tcl_AppendToObj(psObj, "clip ", TCL_INDEX_NONE);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsStipple(interp, canvas, stipple) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsStipple(interp, canvas, stipple);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
} else {
- Tcl_AppendToObj(psObj, "fill\n", -1);
+ Tcl_AppendToObj(psObj, "fill\n", TCL_INDEX_NONE);
}
goto done;
}
@@ -1960,25 +1992,21 @@ PolygonToPostscript(
polyPtr->smooth->postscriptProc(interp, canvas, polyPtr->coordPtr,
polyPtr->numPoints, polyPtr->splineSteps);
}
- if (Tk_CanvasPsColor(interp, canvas, fillColor) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsColor(interp, canvas, fillColor);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (fillStipple != None) {
- Tcl_AppendToObj(psObj, "eoclip ", -1);
+ Tcl_AppendToObj(psObj, "eoclip ", TCL_INDEX_NONE);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsStipple(interp, canvas, fillStipple) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsStipple(interp, canvas, fillStipple);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (color != NULL) {
- Tcl_AppendToObj(psObj, "grestore gsave\n", -1);
+ Tcl_AppendToObj(psObj, "grestore gsave\n", TCL_INDEX_NONE);
}
} else {
- Tcl_AppendToObj(psObj, "eofill\n", -1);
+ Tcl_AppendToObj(psObj, "eofill\n", TCL_INDEX_NONE);
}
}
@@ -2007,9 +2035,7 @@ PolygonToPostscript(
Tcl_AppendPrintfToObj(psObj, "%d setlinejoin 1 setlinecap\n", style);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsOutline(canvas, itemPtr, &polyPtr->outline) != TCL_OK){
- goto error;
- }
+ Tk_CanvasPsOutline(canvas, itemPtr, &polyPtr->outline);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
}
@@ -2022,11 +2048,6 @@ PolygonToPostscript(
Tcl_AppendObjToObj(Tcl_GetObjResult(interp), psObj);
Tcl_DecrRefCount(psObj);
return TCL_OK;
-
- error:
- Tcl_DiscardInterpState(interpState);
- Tcl_DecrRefCount(psObj);
- return TCL_ERROR;
}
/*
diff --git a/generic/tkCanvPs.c b/generic/tkCanvPs.c
index fc3a772..d0e5e13 100644
--- a/generic/tkCanvPs.c
+++ b/generic/tkCanvPs.c
@@ -5,8 +5,8 @@
* the "postscript" widget command plus a few utility functions used for
* generating Postscript.
*
- * Copyright (c) 1991-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1991-1994 The Regents of the University of California.
+ * Copyright © 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.
@@ -94,37 +94,37 @@ typedef struct TkPostscriptInfo {
static const Tk_ConfigSpec configSpecs[] = {
{TK_CONFIG_STRING, "-colormap", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, colorVar), 0, NULL},
+ "", offsetof(TkPostscriptInfo, colorVar), 0, NULL},
{TK_CONFIG_STRING, "-colormode", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, colorMode), 0, NULL},
+ "", offsetof(TkPostscriptInfo, colorMode), 0, NULL},
{TK_CONFIG_STRING, "-file", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, fileName), 0, NULL},
+ "", offsetof(TkPostscriptInfo, fileName), 0, NULL},
{TK_CONFIG_STRING, "-channel", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, channelName), 0, NULL},
+ "", offsetof(TkPostscriptInfo, channelName), 0, NULL},
{TK_CONFIG_STRING, "-fontmap", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, fontVar), 0, NULL},
+ "", offsetof(TkPostscriptInfo, fontVar), 0, NULL},
{TK_CONFIG_PIXELS, "-height", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, height), 0, NULL},
+ "", offsetof(TkPostscriptInfo, height), 0, NULL},
{TK_CONFIG_ANCHOR, "-pageanchor", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, pageAnchor), 0, NULL},
+ "", offsetof(TkPostscriptInfo, pageAnchor), 0, NULL},
{TK_CONFIG_STRING, "-pageheight", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, pageHeightString), 0, NULL},
+ "", offsetof(TkPostscriptInfo, pageHeightString), 0, NULL},
{TK_CONFIG_STRING, "-pagewidth", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, pageWidthString), 0, NULL},
+ "", offsetof(TkPostscriptInfo, pageWidthString), 0, NULL},
{TK_CONFIG_STRING, "-pagex", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, pageXString), 0, NULL},
+ "", offsetof(TkPostscriptInfo, pageXString), 0, NULL},
{TK_CONFIG_STRING, "-pagey", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, pageYString), 0, NULL},
+ "", offsetof(TkPostscriptInfo, pageYString), 0, NULL},
{TK_CONFIG_BOOLEAN, "-prolog", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, prolog), 0, NULL},
+ "", offsetof(TkPostscriptInfo, prolog), 0, NULL},
{TK_CONFIG_BOOLEAN, "-rotate", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, rotate), 0, NULL},
+ "", offsetof(TkPostscriptInfo, rotate), 0, NULL},
{TK_CONFIG_PIXELS, "-width", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, width), 0, NULL},
+ "", offsetof(TkPostscriptInfo, width), 0, NULL},
{TK_CONFIG_PIXELS, "-x", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, x), 0, NULL},
+ "", offsetof(TkPostscriptInfo, x), 0, NULL},
{TK_CONFIG_PIXELS, "-y", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, y), 0, NULL},
+ "", offsetof(TkPostscriptInfo, y), 0, NULL},
{TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}
};
@@ -142,7 +142,7 @@ static inline Tcl_Obj * GetPostscriptBuffer(Tcl_Interp *interp);
/*
*--------------------------------------------------------------
*
- * TkCanvPostscriptCmd --
+ * TkCanvPostscriptObjCmd --
*
* This function is invoked to process the "postscript" options of the
* widget command for canvas widgets. See the user documentation for
@@ -157,14 +157,13 @@ static inline Tcl_Obj * GetPostscriptBuffer(Tcl_Interp *interp);
*--------------------------------------------------------------
*/
- /* ARGSUSED */
int
-TkCanvPostscriptCmd(
+TkCanvPostscriptObjCmd(
TkCanvas *canvasPtr, /* Information about canvas widget. */
Tcl_Interp *interp, /* Current interpreter. */
- int argc, /* Number of arguments. */
- const char **argv) /* Argument strings. Caller has already parsed
- * this command enough to know that argv[1] is
+ Tcl_Size objc, /* Number of arguments. */
+ Tcl_Obj *const objv[]) /* Argument strings. Caller has already parsed
+ * this command enough to know that objv[1] is
* "postscript". */
{
TkPostscriptInfo psInfo, *psInfoPtr = &psInfo;
@@ -193,7 +192,7 @@ TkCanvPostscriptCmd(
* such.
*/
- result = Tcl_EvalEx(interp, "::tk::ensure_psenc_is_loaded", -1, TCL_EVAL_GLOBAL);
+ result = Tcl_EvalEx(interp, "::tk::ensure_psenc_is_loaded", TCL_INDEX_NONE, TCL_EVAL_GLOBAL);
if (result != TCL_OK) {
return result;
}
@@ -237,8 +236,8 @@ TkCanvPostscriptCmd(
psInfo.prolog = 1;
psInfo.tkwin = tkwin;
Tcl_InitHashTable(&psInfo.fontTable, TCL_STRING_KEYS);
- result = Tk_ConfigureWidget(interp, tkwin, configSpecs, argc-2, argv+2,
- (char *) &psInfo, TK_CONFIG_ARGV_ONLY);
+ result = Tk_ConfigureWidget(interp, tkwin, configSpecs, objc-2, (const char **)objv+2,
+ (char *) &psInfo, TK_CONFIG_ARGV_ONLY|TK_CONFIG_OBJS);
if (result != TCL_OK) {
goto cleanup;
}
@@ -286,16 +285,14 @@ TkCanvPostscriptCmd(
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;
+ default:
+ deltaX = -psInfo.width/2;
+ break;
}
switch (psInfo.pageAnchor) {
case TK_ANCHOR_NW:
@@ -303,16 +300,14 @@ TkCanvPostscriptCmd(
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;
+ default:
+ deltaY = -psInfo.height/2;
+ break;
}
if (psInfo.colorMode == NULL) {
@@ -329,7 +324,7 @@ TkCanvPostscriptCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad color mode \"%s\": must be monochrome, gray, or color",
psInfo.colorMode));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "PS", "COLORMODE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "PS", "COLORMODE", (char *)NULL);
result = TCL_ERROR;
goto cleanup;
}
@@ -342,8 +337,8 @@ TkCanvPostscriptCmd(
if (psInfo.channelName != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "can't specify both -file and -channel", -1));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "PS", "USAGE", NULL);
+ "can't specify both -file and -channel", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "PS", "USAGE", (char *)NULL);
result = TCL_ERROR;
goto cleanup;
}
@@ -355,8 +350,8 @@ TkCanvPostscriptCmd(
if (Tcl_IsSafe(interp)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "can't specify -file in a safe interpreter", -1));
- Tcl_SetErrorCode(interp, "TK", "SAFE", "PS_FILE", NULL);
+ "can't specify -file in a safe interpreter", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "SAFE", "PS_FILE", (char *)NULL);
result = TCL_ERROR;
goto cleanup;
}
@@ -389,7 +384,7 @@ TkCanvPostscriptCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"channel \"%s\" wasn't opened for writing",
psInfo.channelName));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "PS", "UNWRITABLE",NULL);
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "PS", "UNWRITABLE", (char *)NULL);
result = TCL_ERROR;
goto cleanup;
}
@@ -436,7 +431,7 @@ TkCanvPostscriptCmd(
if (psInfo.prolog) {
Tcl_AppendToObj(psObj,
"%!PS-Adobe-3.0 EPSF-3.0\n"
- "%%Creator: Tk Canvas Widget\n", -1);
+ "%%Creator: Tk Canvas Widget\n", TCL_INDEX_NONE);
#ifdef HAVE_PW_GECOS
if (!Tcl_IsSafe(interp)) {
@@ -482,7 +477,7 @@ TkCanvPostscriptCmd(
Tcl_GetHashKey(&psInfo.fontTable, hPtr));
p = "%%%%+ font %s\n";
}
- Tcl_AppendToObj(psObj, "%%EndComments\n\n", -1);
+ Tcl_AppendToObj(psObj, "%%EndComments\n\n", TCL_INDEX_NONE);
/*
* Insert the prolog
@@ -491,7 +486,7 @@ TkCanvPostscriptCmd(
Tcl_AppendObjToObj(psObj, preambleObj);
if (psInfo.chan != NULL) {
- if (Tcl_WriteObj(psInfo.chan, psObj) == -1) {
+ if (Tcl_WriteObj(psInfo.chan, psObj) == TCL_IO_FAILURE) {
channelWriteFailed:
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"problem writing postscript data to channel: %s",
@@ -515,7 +510,7 @@ TkCanvPostscriptCmd(
"%%%%IncludeResource: font %s\n",
(char *) Tcl_GetHashKey(&psInfo.fontTable, hPtr));
}
- Tcl_AppendToObj(psObj, "%%EndSetup\n\n", -1);
+ Tcl_AppendToObj(psObj, "%%EndSetup\n\n", TCL_INDEX_NONE);
/*
* Page setup: move to page positioning point, rotate if needed, set
@@ -523,11 +518,11 @@ TkCanvPostscriptCmd(
* region.
*/
- Tcl_AppendToObj(psObj, "%%Page: 1 1\nsave\n", -1);
+ Tcl_AppendToObj(psObj, "%%Page: 1 1\nsave\n", TCL_INDEX_NONE);
Tcl_AppendPrintfToObj(psObj,
"%.1f %.1f translate\n", psInfo.pageX, psInfo.pageY);
if (psInfo.rotate) {
- Tcl_AppendToObj(psObj, "90 rotate\n", -1);
+ Tcl_AppendToObj(psObj, "90 rotate\n", TCL_INDEX_NONE);
}
Tcl_AppendPrintfToObj(psObj,
"%.4g %.4g scale\n", psInfo.scale, psInfo.scale);
@@ -545,7 +540,7 @@ TkCanvPostscriptCmd(
psInfo.x, Tk_PostscriptY((double)psInfo.y2,
(Tk_PostscriptInfo)psInfoPtr));
if (psInfo.chan != NULL) {
- if (Tcl_WriteObj(psInfo.chan, psObj) == -1) {
+ if (Tcl_WriteObj(psInfo.chan, psObj) == TCL_IO_FAILURE) {
goto channelWriteFailed;
}
Tcl_DecrRefCount(psObj);
@@ -577,17 +572,17 @@ TkCanvPostscriptCmd(
if (result != TCL_OK) {
Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf(
"\n (generating Postscript for item %d)",
- itemPtr->id));
+ (int)itemPtr->id));
goto cleanup;
}
- Tcl_AppendToObj(psObj, "gsave\n", -1);
+ Tcl_AppendToObj(psObj, "gsave\n", TCL_INDEX_NONE);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
- Tcl_AppendToObj(psObj, "grestore\n", -1);
+ Tcl_AppendToObj(psObj, "grestore\n", TCL_INDEX_NONE);
Tcl_ResetResult(interp);
if (psInfo.chan != NULL) {
- if (Tcl_WriteObj(psInfo.chan, psObj) == -1) {
+ if (Tcl_WriteObj(psInfo.chan, psObj) == TCL_IO_FAILURE) {
goto channelWriteFailed;
}
Tcl_DecrRefCount(psObj);
@@ -605,10 +600,10 @@ TkCanvPostscriptCmd(
"restore showpage\n\n"
"%%Trailer\n"
"end\n"
- "%%EOF\n", -1);
+ "%%EOF\n", TCL_INDEX_NONE);
if (psInfo.chan != NULL) {
- if (Tcl_WriteObj(psInfo.chan, psObj) == -1) {
+ if (Tcl_WriteObj(psInfo.chan, psObj) == TCL_IO_FAILURE) {
goto channelWriteFailed;
}
}
@@ -788,7 +783,7 @@ Tk_PostscriptFont(
if (psInfoPtr->fontVar != NULL) {
const char *name = Tk_NameOfFont(tkfont);
Tcl_Obj **objv;
- int objc;
+ Tcl_Size objc;
double size;
Tcl_Obj *list = Tcl_GetVar2Ex(interp, psInfoPtr->fontVar, name, 0);
@@ -803,7 +798,7 @@ Tk_PostscriptFont(
"bad font map entry for \"%s\": \"%s\"",
name, Tcl_GetString(list)));
Tcl_SetErrorCode(interp, "TK", "CANVAS", "PS", "FONTMAP",
- NULL);
+ (char *)NULL);
return TCL_ERROR;
}
@@ -912,11 +907,11 @@ PostscriptBitmap(
* syntactically correct.
*/
- Tcl_AppendToObj(psObj, "<>", -1);
+ Tcl_AppendToObj(psObj, "<>", TCL_INDEX_NONE);
return;
}
- Tcl_AppendToObj(psObj, "<", -1);
+ Tcl_AppendToObj(psObj, "<", TCL_INDEX_NONE);
mask = 0x80;
value = 0;
charsInLine = 0;
@@ -934,7 +929,7 @@ PostscriptBitmap(
value = 0;
charsInLine += 2;
if (charsInLine >= 60) {
- Tcl_AppendToObj(psObj, "\n", -1);
+ Tcl_AppendToObj(psObj, "\n", TCL_INDEX_NONE);
charsInLine = 0;
}
}
@@ -946,7 +941,7 @@ PostscriptBitmap(
charsInLine += 2;
}
}
- Tcl_AppendToObj(psObj, ">", -1);
+ Tcl_AppendToObj(psObj, ">", TCL_INDEX_NONE);
XDestroyImage(imagePtr);
}
@@ -1007,7 +1002,7 @@ Tk_PostscriptStipple(
psObj = GetPostscriptBuffer(interp);
Tcl_AppendPrintfToObj(psObj, "%d %d ", width, height);
PostscriptBitmap(tkwin, bitmap, 0, 0, width, height, psObj);
- Tcl_AppendToObj(psObj, " StippleFill\n", -1);
+ Tcl_AppendToObj(psObj, " StippleFill\n", TCL_INDEX_NONE);
return TCL_OK;
}
@@ -1064,7 +1059,7 @@ Tk_PostscriptPath(
* generated. */
double *coordPtr, /* Pointer to first in array of 2*numPoints
* coordinates giving points for path. */
- int numPoints) /* Number of points at *coordPtr. */
+ Tcl_Size numPoints) /* Number of points at *coordPtr. */
{
TkPostscriptInfo *psInfoPtr = (TkPostscriptInfo *) psInfo;
Tcl_Obj *psObj;
@@ -1109,50 +1104,54 @@ GetPostscriptPoints(
char *string, /* String describing a screen distance. */
double *doublePtr) /* Place to store converted result. */
{
- char *end;
+ const char *rest;
double d;
+ Tcl_DString ds;
- d = strtod(string, &end);
- if (end == string) {
- goto error;
+ if (Tcl_GetDouble(NULL, string, &d) == TCL_OK) {
+ *doublePtr = d;
+ return TCL_OK;
+ }
+ rest = string + strlen(string);
+ while ((rest > string) && isspace(UCHAR(rest[-1]))) {
+ --rest; /* skip all spaces at the end */
}
- while ((*end != '\0') && isspace(UCHAR(*end))) {
- end++;
+ if (rest > string) {
+ --rest; /* point to the character just before the last space */
+ }
+ if (rest == string) {
+ error:
+ if (interp != NULL) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "bad distance \"%s\"", string));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "PS", "POINTS", (char *)NULL);
+ }
+ return TCL_ERROR;
+ }
+ Tcl_DStringInit(&ds);
+ Tcl_DStringAppend(&ds, string, rest-string);
+ if (Tcl_GetDouble(NULL, Tcl_DStringValue(&ds), &d) != TCL_OK) {
+ Tcl_DStringFree(&ds);
+ goto error;
}
- switch (*end) {
+ Tcl_DStringFree(&ds);
+ switch (*rest) {
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;
-
- error:
- Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad distance \"%s\"", string));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "PS", "POINTS", NULL);
- return TCL_ERROR;
}
/*
@@ -1201,11 +1200,13 @@ GetPostscriptPoints(
#if defined(_WIN32) || defined(MAC_OSX_TK)
static void
TkImageGetColor(
- TkColormapData *cdata, /* Colormap data */
+ TkColormapData *cdata,
unsigned long pixel, /* Pixel value to look up */
double *red, double *green, double *blue)
/* Color data to return */
{
+ (void)cdata;
+
*red = (double) GetRValue(pixel) / 255.0;
*green = (double) GetGValue(pixel) / 255.0;
*blue = (double) GetBValue(pixel) / 255.0;
@@ -1261,7 +1262,7 @@ TkPostscriptImage(
Tk_Window tkwin,
Tk_PostscriptInfo psInfo, /* postscript info */
XImage *ximage, /* Image to draw */
- int x, int y, /* First pixel to output */
+ int x, TCL_UNUSED(int), /* First pixel to output */
int width, int height) /* Width and height of area */
{
TkPostscriptInfo *psInfoPtr = (TkPostscriptInfo *) psInfo;
@@ -1288,7 +1289,7 @@ TkPostscriptImage(
*/
ncolors = visual->map_entries;
- cdata.colors = ckalloc(sizeof(XColor) * ncolors);
+ cdata.colors = (XColor *)ckalloc(sizeof(XColor) * ncolors);
cdata.ncolors = ncolors;
if (visual->c_class == DirectColor || visual->c_class == TrueColor) {
@@ -1362,7 +1363,7 @@ TkPostscriptImage(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't generate Postscript for images more than %d pixels wide",
maxWidth));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "PS", "MEMLIMIT", NULL);
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "PS", "MEMLIMIT", (char *)NULL);
ckfree(cdata.colors);
return TCL_ERROR;
}
@@ -1408,7 +1409,7 @@ TkPostscriptImage(
lineLen += 2;
if (lineLen > 60) {
lineLen = 0;
- Tcl_AppendToObj(psObj, "\n", -1);
+ Tcl_AppendToObj(psObj, "\n", TCL_INDEX_NONE);
}
mask = 0x80;
data = 0x00;
@@ -1436,7 +1437,7 @@ TkPostscriptImage(
lineLen += 2;
if (lineLen > 60) {
lineLen = 0;
- Tcl_AppendToObj(psObj, "\n", -1);
+ Tcl_AppendToObj(psObj, "\n", TCL_INDEX_NONE);
}
}
break;
@@ -1456,7 +1457,7 @@ TkPostscriptImage(
lineLen += 6;
if (lineLen > 60) {
lineLen = 0;
- Tcl_AppendToObj(psObj, "\n", -1);
+ Tcl_AppendToObj(psObj, "\n", TCL_INDEX_NONE);
}
}
break;
@@ -1464,9 +1465,9 @@ TkPostscriptImage(
}
switch (level) {
case 0: case 1:
- Tcl_AppendToObj(psObj, ">\n} image\n", -1); break;
+ Tcl_AppendToObj(psObj, ">\n} image\n", TCL_INDEX_NONE); break;
default:
- Tcl_AppendToObj(psObj, ">\n} false 3 colorimage\n", -1); break;
+ Tcl_AppendToObj(psObj, ">\n} false 3 colorimage\n", TCL_INDEX_NONE); break;
}
Tcl_AppendPrintfToObj(psObj, "0 %d translate\n", rows);
}
@@ -1548,7 +1549,7 @@ Tk_PostscriptPhoto(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't generate Postscript for images more than %d pixels wide",
maxWidth));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "PS", "MEMLIMIT", NULL);
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "PS", "MEMLIMIT", (char *)NULL);
return TCL_ERROR;
}
@@ -1559,17 +1560,17 @@ Tk_PostscriptPhoto(
psObj = GetPostscriptBuffer(interp);
switch (colorLevel) {
case 0:
- Tcl_AppendToObj(psObj, "/DeviceGray setcolorspace\n\n", -1);
+ Tcl_AppendToObj(psObj, "/DeviceGray setcolorspace\n\n", TCL_INDEX_NONE);
decode = "1 0";
bpc = 1;
break;
case 1:
- Tcl_AppendToObj(psObj, "/DeviceGray setcolorspace\n\n", -1);
+ Tcl_AppendToObj(psObj, "/DeviceGray setcolorspace\n\n", TCL_INDEX_NONE);
decode = "0 1";
bpc = 8;
break;
default:
- Tcl_AppendToObj(psObj, "/DeviceRGB setcolorspace\n\n", -1);
+ Tcl_AppendToObj(psObj, "/DeviceRGB setcolorspace\n\n", TCL_INDEX_NONE);
decode = "0 1 0 1 0 1";
bpc = 8;
break;
@@ -1645,7 +1646,7 @@ Tk_PostscriptPhoto(
lineLen += 2;
if (lineLen >= 60) {
lineLen = 0;
- Tcl_AppendToObj(psObj, "\n", -1);
+ Tcl_AppendToObj(psObj, "\n", TCL_INDEX_NONE);
}
mask = 0x80;
data = 0x00;
@@ -1684,7 +1685,7 @@ Tk_PostscriptPhoto(
lineLen += 2;
if (lineLen >= 60) {
lineLen = 0;
- Tcl_AppendToObj(psObj, "\n", -1);
+ Tcl_AppendToObj(psObj, "\n", TCL_INDEX_NONE);
}
mask = 0x80;
data = 0x00;
@@ -1710,7 +1711,7 @@ Tk_PostscriptPhoto(
lineLen += 2;
if (lineLen >= 60) {
lineLen = 0;
- Tcl_AppendToObj(psObj, "\n", -1);
+ Tcl_AppendToObj(psObj, "\n", TCL_INDEX_NONE);
}
}
@@ -1732,7 +1733,7 @@ Tk_PostscriptPhoto(
lineLen += 2;
if (lineLen >= 60) {
lineLen = 0;
- Tcl_AppendToObj(psObj, "\n", -1);
+ Tcl_AppendToObj(psObj, "\n", TCL_INDEX_NONE);
}
}
break;
@@ -1750,7 +1751,7 @@ Tk_PostscriptPhoto(
lineLen += 2;
if (lineLen >= 60) {
lineLen = 0;
- Tcl_AppendToObj(psObj, "\n", -1);
+ Tcl_AppendToObj(psObj, "\n", TCL_INDEX_NONE);
}
}
@@ -1770,7 +1771,7 @@ Tk_PostscriptPhoto(
lineLen += 6;
if (lineLen >= 60) {
lineLen = 0;
- Tcl_AppendToObj(psObj, "\n", -1);
+ Tcl_AppendToObj(psObj, "\n", TCL_INDEX_NONE);
}
}
break;
@@ -1781,7 +1782,7 @@ Tk_PostscriptPhoto(
* The end-of-data marker.
*/
- Tcl_AppendToObj(psObj, ">\n", -1);
+ Tcl_AppendToObj(psObj, ">\n", TCL_INDEX_NONE);
return TCL_OK;
}
diff --git a/generic/tkCanvText.c b/generic/tkCanvText.c
index 8536eab..6ab7911 100644
--- a/generic/tkCanvText.c
+++ b/generic/tkCanvText.c
@@ -3,8 +3,8 @@
*
* This file implements text items for canvas widgets.
*
- * Copyright (c) 1991-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1991-1994 The Regents of the University of California.
+ * Copyright © 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.
@@ -14,6 +14,10 @@
#include "tkCanvas.h"
#include "default.h"
+#ifdef _WIN32
+#include "tkWinInt.h"
+#endif
+
/*
* The structure below defines the record for each text item.
*/
@@ -32,7 +36,7 @@ typedef struct TextItem {
*/
double x, y; /* Positioning point for text. */
- int insertPos; /* Character index of character just before
+ Tcl_Size insertPos; /* Character index of character just before
* which the insertion cursor is displayed. */
/*
@@ -53,7 +57,7 @@ typedef struct TextItem {
int width; /* Width of lines for word-wrap, pixels. Zero
* means no word-wrap. */
int underline; /* Index of character to put underline beneath
- * or -1 for no underlining. */
+ * or INT_MIN for no underlining. */
double angle; /* What angle, in degrees, to draw the text
* at. */
@@ -62,8 +66,8 @@ typedef struct TextItem {
* configuration settings above.
*/
- int numChars; /* Length of text in characters. */
- int numBytes; /* Length of text in bytes. */
+ Tcl_Size numChars; /* Length of text in characters. */
+ Tcl_Size numBytes; /* Length of text in bytes. */
Tk_TextLayout textLayout; /* Cached text layout information. */
int actualWidth; /* Width of text as computed. Used to make
* selections of wrapped text display
@@ -93,40 +97,123 @@ static const Tk_CustomOption offsetOption = {
TkOffsetParseProc, TkOffsetPrintProc, INT2PTR(TK_OFFSET_RELATIVE)
};
+static int
+UnderlineParseProc(
+ TCL_UNUSED(void *), /* Not used.*/
+ Tcl_Interp *interp, /* Used for reporting errors. */
+ TCL_UNUSED(Tk_Window), /* Window containing canvas widget. */
+ const char *value, /* Value of option. */
+ char *widgRec, /* Pointer to record for item. */
+ Tcl_Size offset) /* Offset into item (ignored). */
+{
+ int *underlinePtr = (int *) (widgRec + offset);
+ Tcl_Obj obj;
+ int code;
+ Tcl_Size underline;
+
+ if (value == NULL || *value == 0) {
+ *underlinePtr = INT_MIN; /* No underline */
+ return TCL_OK;
+ }
+
+ obj.refCount = 1;
+ obj.bytes = (char *)value;
+ obj.length = strlen(value);
+ obj.typePtr = NULL;
+ code = TkGetIntForIndex(&obj, TCL_INDEX_NONE, 0, &underline);
+ if (code == TCL_OK) {
+ if (underline < INT_MIN) {
+ underline = INT_MIN;
+ } else if (underline > INT_MAX) {
+ underline = INT_MAX;
+ }
+ *underlinePtr = (int)underline;
+
+ } else {
+ Tcl_AppendResult(interp, "bad index \"", value,
+ "\": must be integer?[+-]integer?, end?[+-]integer?, or \"\"", (char *)NULL);
+ }
+ return code;
+}
+
+static const char *
+UnderlinePrintProc(
+ TCL_UNUSED(void *),
+ TCL_UNUSED(Tk_Window), /* Window containing canvas widget. */
+ char *widgRec, /* Pointer to record for item. */
+ Tcl_Size offset, /* Pointer to record for item. */
+ Tcl_FreeProc **freeProcPtr) /* Pointer to variable to fill in with
+ * information about how to reclaim storage
+ * for return string. */
+{
+ int underline = *(int *)(widgRec + offset);
+ char *p;
+
+ if (underline == INT_MIN) {
+#if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
+ p = (char *)"-1";
+#else
+ p = (char *)"";
+#endif
+ *freeProcPtr = TCL_STATIC;
+ return p;
+ } else if (underline == INT_MAX) {
+ p = (char *)"end+1";
+ *freeProcPtr = TCL_STATIC;
+ return p;
+ } else if (underline == -1) {
+ p = (char *)"end";
+ *freeProcPtr = TCL_STATIC;
+ return p;
+ }
+ p = (char *)ckalloc(32);
+ if (underline < 0) {
+ snprintf(p, 32, "end%d", 1 + underline);
+ } else {
+ snprintf(p, 32, "%d", underline);
+ }
+ *freeProcPtr = TCL_DYNAMIC;
+ return p;
+}
+
+static const Tk_CustomOption underlineOption = {
+ UnderlineParseProc, UnderlinePrintProc, NULL
+};
+
static const Tk_ConfigSpec configSpecs[] = {
{TK_CONFIG_COLOR, "-activefill", NULL, NULL,
- NULL, Tk_Offset(TextItem, activeColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(TextItem, activeColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-activestipple", NULL, NULL,
- NULL, Tk_Offset(TextItem, activeStipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(TextItem, activeStipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_ANCHOR, "-anchor", NULL, NULL,
- "center", Tk_Offset(TextItem, anchor), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "center", offsetof(TextItem, anchor), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_DOUBLE, "-angle", NULL, NULL,
- "0.0", Tk_Offset(TextItem, angle), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "0.0", offsetof(TextItem, angle), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_COLOR, "-disabledfill", NULL, NULL,
- NULL, Tk_Offset(TextItem, disabledColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(TextItem, disabledColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-disabledstipple", NULL, NULL,
- NULL, Tk_Offset(TextItem, disabledStipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(TextItem, disabledStipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_COLOR, "-fill", NULL, NULL,
- DEF_CANVITEM_OUTLINE, Tk_Offset(TextItem, color), TK_CONFIG_NULL_OK, NULL},
+ DEF_CANVITEM_OUTLINE, offsetof(TextItem, color), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_FONT, "-font", NULL, NULL,
- DEF_CANVTEXT_FONT, Tk_Offset(TextItem, tkfont), 0, NULL},
+ DEF_CANVTEXT_FONT, offsetof(TextItem, tkfont), 0, NULL},
{TK_CONFIG_JUSTIFY, "-justify", NULL, NULL,
- "left", Tk_Offset(TextItem, justify), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "left", offsetof(TextItem, justify), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_CUSTOM, "-offset", NULL, NULL,
- "0,0", Tk_Offset(TextItem, tsoffset),
+ "0,0", offsetof(TextItem, tsoffset),
TK_CONFIG_DONT_SET_DEFAULT, &offsetOption},
{TK_CONFIG_CUSTOM, "-state", NULL, NULL,
- NULL, Tk_Offset(Tk_Item, state), TK_CONFIG_NULL_OK, &stateOption},
+ NULL, offsetof(Tk_Item, state), TK_CONFIG_NULL_OK, &stateOption},
{TK_CONFIG_BITMAP, "-stipple", NULL, NULL,
- NULL, Tk_Offset(TextItem, stipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(TextItem, stipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-tags", NULL, NULL,
NULL, 0, TK_CONFIG_NULL_OK, &tagsOption},
{TK_CONFIG_STRING, "-text", NULL, NULL,
- "", Tk_Offset(TextItem, text), 0, NULL},
- {TK_CONFIG_INT, "-underline", NULL, NULL,
- "-1", Tk_Offset(TextItem, underline), 0, NULL},
+ "", offsetof(TextItem, text), 0, NULL},
+ {TK_CONFIG_CUSTOM, "-underline", NULL, NULL, NULL,
+ offsetof(TextItem, underline), TK_CONFIG_NULL_OK, &underlineOption},
{TK_CONFIG_PIXELS, "-width", NULL, NULL,
- "0", Tk_Offset(TextItem, width), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "0", offsetof(TextItem, width), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}
};
@@ -136,40 +223,42 @@ static const Tk_ConfigSpec configSpecs[] = {
static void ComputeTextBbox(Tk_Canvas canvas, TextItem *textPtr);
static int ConfigureText(Tcl_Interp *interp,
- Tk_Canvas canvas, Tk_Item *itemPtr, int argc,
+ Tk_Canvas canvas, Tk_Item *itemPtr, Tcl_Size argc,
Tcl_Obj *const objv[], int flags);
static int CreateText(Tcl_Interp *interp,
Tk_Canvas canvas, struct Tk_Item *itemPtr,
- int objc, Tcl_Obj *const objv[]);
+ Tcl_Size objc, Tcl_Obj *const objv[]);
static void DeleteText(Tk_Canvas canvas,
Tk_Item *itemPtr, Display *display);
static void DisplayCanvText(Tk_Canvas canvas,
Tk_Item *itemPtr, Display *display, Drawable dst,
int x, int y, int width, int height);
-static int GetSelText(Tk_Canvas canvas,
- Tk_Item *itemPtr, int offset, char *buffer,
- int maxBytes);
+static Tcl_Size GetSelText(Tk_Canvas canvas,
+ Tk_Item *itemPtr, Tcl_Size offset, char *buffer,
+ Tcl_Size maxBytes);
static int GetTextIndex(Tcl_Interp *interp,
Tk_Canvas canvas, Tk_Item *itemPtr,
- Tcl_Obj *obj, int *indexPtr);
+ Tcl_Obj *obj, Tcl_Size *indexPtr);
static void ScaleText(Tk_Canvas canvas,
Tk_Item *itemPtr, double originX, double originY,
double scaleX, double scaleY);
static void SetTextCursor(Tk_Canvas canvas,
- Tk_Item *itemPtr, int index);
+ Tk_Item *itemPtr, Tcl_Size index);
static int TextCoords(Tcl_Interp *interp,
Tk_Canvas canvas, Tk_Item *itemPtr,
- int objc, Tcl_Obj *const objv[]);
+ Tcl_Size objc, Tcl_Obj *const objv[]);
static void TextDeleteChars(Tk_Canvas canvas,
- Tk_Item *itemPtr, int first, int last);
+ Tk_Item *itemPtr, Tcl_Size first, Tcl_Size last);
static void TextInsert(Tk_Canvas canvas,
- Tk_Item *itemPtr, int beforeThis, Tcl_Obj *obj);
+ Tk_Item *itemPtr, Tcl_Size beforeThis, Tcl_Obj *obj);
static int TextToArea(Tk_Canvas canvas,
Tk_Item *itemPtr, double *rectPtr);
static double TextToPoint(Tk_Canvas canvas,
Tk_Item *itemPtr, double *pointPtr);
static int TextToPostscript(Tcl_Interp *interp,
Tk_Canvas canvas, Tk_Item *itemPtr, int prepass);
+static void RotateText(Tk_Canvas canvas, Tk_Item *itemPtr,
+ double originX, double originY, double angleRad);
static void TranslateText(Tk_Canvas canvas,
Tk_Item *itemPtr, double deltaX, double deltaY);
@@ -199,7 +288,8 @@ Tk_ItemType tkTextType = {
TextInsert, /* insertProc */
TextDeleteChars, /* dTextProc */
NULL, /* nextPtr */
- NULL, 0, NULL, NULL
+ RotateText, /* rotateProc */
+ 0, NULL, NULL
};
#define ROUND(d) ((int) floor((d) + 0.5))
@@ -228,11 +318,11 @@ CreateText(
Tk_Canvas canvas, /* Canvas to hold new item. */
Tk_Item *itemPtr, /* Record to hold new item; header has been
* initialized by caller. */
- int objc, /* Number of arguments in objv. */
+ Tcl_Size objc, /* Number of arguments in objv. */
Tcl_Obj *const objv[]) /* Arguments describing rectangle. */
{
TextItem *textPtr = (TextItem *) itemPtr;
- int i;
+ Tcl_Size i;
if (objc == 0) {
Tcl_Panic("canvas did not pass any coords");
@@ -261,7 +351,7 @@ CreateText(
textPtr->disabledStipple = None;
textPtr->text = NULL;
textPtr->width = 0;
- textPtr->underline = -1;
+ textPtr->underline = INT_MIN;
textPtr->angle = 0.0;
textPtr->numChars = 0;
@@ -325,7 +415,7 @@ TextCoords(
Tk_Canvas canvas, /* Canvas containing item. */
Tk_Item *itemPtr, /* Item whose coordinates are to be read or
* modified. */
- int objc, /* Number of coordinates supplied in objv. */
+ Tcl_Size objc, /* Number of coordinates supplied in objv. */
Tcl_Obj *const objv[]) /* Array of coordinates: x1, y1, x2, y2, ... */
{
TextItem *textPtr = (TextItem *) itemPtr;
@@ -341,8 +431,8 @@ TextCoords(
return TCL_OK;
} else if (objc > 2) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "wrong # coordinates: expected 0 or 2, got %d", objc));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "TEXT", NULL);
+ "wrong # coordinates: expected 0 or 2, got %" TCL_SIZE_MODIFIER "d", objc));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "TEXT", (char *)NULL);
return TCL_ERROR;
}
@@ -352,8 +442,8 @@ TextCoords(
return TCL_ERROR;
} else if (objc != 2) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "wrong # coordinates: expected 2, got %d", objc));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "TEXT", NULL);
+ "wrong # coordinates: expected 2, got %" TCL_SIZE_MODIFIER "d", objc));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "TEXT", (char *)NULL);
return TCL_ERROR;
}
}
@@ -391,7 +481,7 @@ ConfigureText(
Tcl_Interp *interp, /* Interpreter for error reporting. */
Tk_Canvas canvas, /* Canvas containing itemPtr. */
Tk_Item *itemPtr, /* Rectangle item to reconfigure. */
- int objc, /* Number of elements in objv. */
+ Tcl_Size objc, /* Number of elements in objv. */
Tcl_Obj *const objv[], /* Arguments describing things to configure. */
int flags) /* Flags to pass to Tk_ConfigureWidget. */
{
@@ -504,7 +594,7 @@ ConfigureText(
*/
textPtr->numBytes = strlen(textPtr->text);
- textPtr->numChars = Tcl_NumUtfChars(textPtr->text, textPtr->numBytes);
+ textPtr->numChars = TkNumUtfChars(textPtr->text, textPtr->numBytes);
if (textInfoPtr->selItemPtr == itemPtr) {
if (textInfoPtr->selectFirst >= textPtr->numChars) {
@@ -788,7 +878,7 @@ DisplayCanvText(
{
TextItem *textPtr;
Tk_CanvasTextInfo *textInfoPtr;
- int selFirstChar, selLastChar;
+ Tcl_Size selFirstChar, selLastChar;
short drawableX, drawableY;
Pixmap stipple;
Tk_State state = itemPtr->state;
@@ -824,7 +914,7 @@ DisplayCanvText(
Tk_CanvasSetOffset(canvas, textPtr->gc, &textPtr->tsoffset);
}
- selFirstChar = -1;
+ selFirstChar = TCL_INDEX_NONE;
selLastChar = 0;
Tk_CanvasDrawableCoords(canvas, textPtr->drawOrigin[0],
textPtr->drawOrigin[1], &drawableX, &drawableY);
@@ -946,7 +1036,7 @@ DisplayCanvText(
* anti-aliasing colors would blend together.
*/
- if ((selFirstChar >= 0) && (textPtr->selTextGC != textPtr->gc)) {
+ if ((selFirstChar != TCL_INDEX_NONE) && (textPtr->selTextGC != textPtr->gc)) {
if (0 < selFirstChar) {
TkDrawAngledTextLayout(display, drawable, textPtr->gc,
textPtr->textLayout, drawableX, drawableY, textPtr->angle,
@@ -995,13 +1085,13 @@ static void
TextInsert(
Tk_Canvas canvas, /* Canvas containing text item. */
Tk_Item *itemPtr, /* Text item to be modified. */
- int index, /* Character index before which string is to
+ Tcl_Size index, /* Character index before which string is to
* be inserted. */
Tcl_Obj *obj) /* New characters to be inserted. */
{
TextItem *textPtr = (TextItem *) itemPtr;
int byteIndex, charsAdded;
- int byteCount;
+ Tcl_Size byteCount;
char *newStr, *text;
const char *string;
Tk_CanvasTextInfo *textInfoPtr = textPtr->textInfoPtr;
@@ -1016,7 +1106,7 @@ TextInsert(
if (index > textPtr->numChars) {
index = textPtr->numChars;
}
- byteIndex = TkUtfAtIndex(text, index) - text;
+ byteIndex = Tcl_UtfAtIndex(text, index) - text;
byteCount = strlen(string);
if (byteCount == 0) {
return;
@@ -1029,7 +1119,7 @@ TextInsert(
ckfree(text);
textPtr->text = newStr;
- charsAdded = Tcl_NumUtfChars(string, byteCount);
+ charsAdded = TkNumUtfChars(string, byteCount);
textPtr->numChars += charsAdded;
textPtr->numBytes += byteCount;
@@ -1077,9 +1167,9 @@ static void
TextDeleteChars(
Tk_Canvas canvas, /* Canvas containing itemPtr. */
Tk_Item *itemPtr, /* Item in which to delete characters. */
- int first, /* Character index of first character to
+ Tcl_Size first, /* Character index of first character to
* delete. */
- int last) /* Character index of last character to delete
+ Tcl_Size last) /* Character index of last character to delete
* (inclusive). */
{
TextItem *textPtr = (TextItem *) itemPtr;
@@ -1244,6 +1334,39 @@ TextToArea(
/*
*--------------------------------------------------------------
*
+ * RotateText --
+ *
+ * This function is called to rotate a text item by a given amount about a
+ * point. Note that this does *not* rotate the text of the item.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * The position of the text anchor is rotated by angleRad about (originX,
+ * originY), and the bounding box is updated in the generic part of the
+ * item structure.
+ *
+ *--------------------------------------------------------------
+ */
+
+static void
+RotateText(
+ Tk_Canvas canvas, /* Canvas containing item. */
+ Tk_Item *itemPtr, /* Item that is being rotated. */
+ double originX, double originY,
+ double angleRad) /* Amount by which item is to be rotated. */
+{
+ TextItem *textPtr = (TextItem *) itemPtr;
+
+ TkRotatePoint(originX, originY, sin(angleRad), cos(angleRad),
+ &textPtr->x, &textPtr->y);
+ ComputeTextBbox(canvas, textPtr);
+}
+
+/*
+ *--------------------------------------------------------------
+ *
* ScaleText --
*
* This function is invoked to rescale a text item.
@@ -1333,28 +1456,37 @@ GetTextIndex(
* specified. */
Tcl_Obj *obj, /* Specification of a particular character in
* itemPtr's text. */
- int *indexPtr) /* Where to store converted character
+ Tcl_Size *indexPtr) /* Where to store converted character
* index. */
{
TextItem *textPtr = (TextItem *) itemPtr;
- int length;
+ Tcl_Size length, idx;
int c;
Tk_CanvasTextInfo *textInfoPtr = textPtr->textInfoPtr;
- const char *string = Tcl_GetStringFromObj(obj, &length);
+ const char *string;
+ if (TCL_OK == TkGetIntForIndex(obj, textPtr->numChars - 1, 1, &idx)) {
+ if (idx < 0) {
+ idx = 0;
+ } else if (idx > textPtr->numChars) {
+ idx = textPtr->numChars;
+ }
+ *indexPtr = idx;
+ return TCL_OK;
+ }
+
+ string = Tcl_GetStringFromObj(obj, &length);
c = string[0];
- if ((c == 'e') && (strncmp(string, "end", length) == 0)) {
- *indexPtr = textPtr->numChars;
- } else if ((c == 'i')
+ if ((c == 'i')
&& (strncmp(string, "insert", length) == 0)) {
*indexPtr = textPtr->insertPos;
} else if ((c == 's') && (length >= 5)
&& (strncmp(string, "sel.first", length) == 0)) {
if (textInfoPtr->selItemPtr != itemPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "selection isn't in item", -1));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "UNSELECTED", NULL);
+ "selection isn't in item", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "UNSELECTED", (char *)NULL);
return TCL_ERROR;
}
*indexPtr = textInfoPtr->selectFirst;
@@ -1362,26 +1494,31 @@ GetTextIndex(
&& (strncmp(string, "sel.last", length) == 0)) {
if (textInfoPtr->selItemPtr != itemPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "selection isn't in item", -1));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "UNSELECTED", NULL);
+ "selection isn't in item", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "UNSELECTED", (char *)NULL);
return TCL_ERROR;
}
*indexPtr = textInfoPtr->selectLast;
} else if (c == '@') {
int x, y;
double tmp, cs = textPtr->cosine, s = textPtr->sine;
- char *end;
+ char *rest;
const char *p;
p = string+1;
- tmp = strtod(p, &end);
- if ((end == p) || (*end != ',')) {
+ rest = strchr((char *)p, ',');
+ if (!rest) {
goto badIndex;
}
+ *rest = '\0';
+ if (Tcl_GetDouble(NULL, p, &tmp) != TCL_OK) {
+ *rest = ',';
+ goto badIndex;
+ }
+ *rest = ',';
x = (int) ((tmp < 0) ? tmp - 0.5 : tmp + 0.5);
- p = end+1;
- tmp = strtod(p, &end);
- if ((end == p) || (*end != 0)) {
+ p = rest+1;
+ if (Tcl_GetDouble(NULL, p, &tmp) != TCL_OK) {
goto badIndex;
}
y = (int) ((tmp < 0) ? tmp - 0.5 : tmp + 0.5);
@@ -1389,21 +1526,10 @@ GetTextIndex(
y -= (int) textPtr->drawOrigin[1];
*indexPtr = Tk_PointToChar(textPtr->textLayout,
(int) (x*cs - y*s), (int) (y*cs + x*s));
- } else if (Tcl_GetIntFromObj(NULL, obj, indexPtr) == TCL_OK) {
- if (*indexPtr < 0) {
- *indexPtr = 0;
- } else if (*indexPtr > textPtr->numChars) {
- *indexPtr = textPtr->numChars;
- }
} else {
- /*
- * Some of the paths here leave messages in the interp's result, so we
- * have to clear it out before storing our own message.
- */
-
badIndex:
Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad index \"%s\"", string));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "ITEM_INDEX", "TEXT", NULL);
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "ITEM_INDEX", "TEXT", (char *)NULL);
return TCL_ERROR;
}
return TCL_OK;
@@ -1430,7 +1556,7 @@ SetTextCursor(
TCL_UNUSED(Tk_Canvas), /* Record describing canvas widget. */
Tk_Item *itemPtr, /* Text item in which cursor position is to be
* set. */
- int index) /* Character index of character just before
+ Tcl_Size index) /* Character index of character just before
* which cursor is to be positioned. */
{
TextItem *textPtr = (TextItem *) itemPtr;
@@ -1464,19 +1590,19 @@ SetTextCursor(
*--------------------------------------------------------------
*/
-static int
+static Tcl_Size
GetSelText(
TCL_UNUSED(Tk_Canvas), /* Canvas containing selection. */
Tk_Item *itemPtr, /* Text item containing selection. */
- int offset, /* Byte offset within selection of first
+ Tcl_Size offset, /* Byte 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,
+ Tcl_Size maxBytes) /* Maximum number of bytes to place at buffer,
* not including terminating NULL
* character. */
{
TextItem *textPtr = (TextItem *) itemPtr;
- int byteCount;
+ Tcl_Size byteCount;
char *text;
const char *selStart, *selEnd;
Tk_CanvasTextInfo *textInfoPtr = textPtr->textInfoPtr;
@@ -1489,14 +1615,14 @@ GetSelText(
selStart = TkUtfAtIndex(text, textInfoPtr->selectFirst);
selEnd = TkUtfAtIndex(selStart,
textInfoPtr->selectLast + 1 - textInfoPtr->selectFirst);
+ if (selEnd <= selStart + offset) {
+ return 0;
+ }
byteCount = selEnd - selStart - offset;
if (byteCount > maxBytes) {
byteCount = maxBytes;
}
- if (byteCount <= 0) {
- return 0;
- }
- memcpy(buffer, selStart + offset, (size_t) byteCount);
+ memcpy(buffer, selStart + offset, byteCount);
buffer[byteCount] = '\0';
return byteCount;
}
@@ -1585,9 +1711,7 @@ TextToPostscript(
}
Tcl_ResetResult(interp);
- if (Tk_CanvasPsColor(interp, canvas, color) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsColor(interp, canvas, color);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (stipple != None) {
diff --git a/generic/tkCanvUtil.c b/generic/tkCanvUtil.c
index 310df53..252bfb8 100644
--- a/generic/tkCanvUtil.c
+++ b/generic/tkCanvUtil.c
@@ -4,7 +4,7 @@
* This file contains a collection of utility functions used by the
* implementations of various canvas item types.
*
- * Copyright (c) 1994 Sun Microsystems, Inc.
+ * Copyright © 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.
@@ -46,7 +46,7 @@ static const Tk_SmoothMethod tkRawSmoothMethod = {
* Function forward-declarations.
*/
-static void SmoothMethodCleanupProc(ClientData clientData,
+static void SmoothMethodCleanupProc(void *clientData,
Tcl_Interp *interp);
static SmoothAssocData *InitSmoothMethods(Tcl_Interp *interp);
static int DashConvert(char *l, const char *p, int n,
@@ -235,7 +235,7 @@ Tk_CanvasWindowCoords(
int
Tk_CanvasGetCoord(
- Tcl_Interp *interp, /* Interpreter for error reporting. */
+ TCL_UNUSED(Tcl_Interp *), /* Interpreter for error reporting. */
Tk_Canvas canvas, /* Canvas to which coordinate applies. */
const char *string, /* Describes coordinate (any screen coordinate
* form may be used here). */
@@ -271,7 +271,7 @@ Tk_CanvasGetCoord(
int
Tk_CanvasGetCoordFromObj(
- Tcl_Interp *interp, /* Interpreter for error reporting. */
+ TCL_UNUSED(Tcl_Interp *), /* Interpreter for error reporting. */
Tk_Canvas canvas, /* Canvas to which coordinate applies. */
Tcl_Obj *obj, /* Describes coordinate (any screen coordinate
* form may be used here). */
@@ -403,15 +403,15 @@ Tk_CanvasGetTextInfo(
int
Tk_CanvasTagsParseProc(
- ClientData clientData, /* Not used.*/
+ TCL_UNUSED(void *),
Tcl_Interp *interp, /* Used for reporting errors. */
- Tk_Window tkwin, /* Window containing canvas widget. */
+ TCL_UNUSED(Tk_Window), /* Window containing canvas widget. */
const char *value, /* Value of option (list of tag names). */
char *widgRec, /* Pointer to record for item. */
- int offset) /* Offset into item (ignored). */
+ TCL_UNUSED(Tcl_Size)) /* Offset into item (ignored). */
{
Tk_Item *itemPtr = (Tk_Item *) widgRec;
- int argc, i;
+ Tcl_Size argc, i;
const char **argv;
Tk_Uid *newPtr;
@@ -429,7 +429,7 @@ Tk_CanvasTagsParseProc(
if (itemPtr->tagSpace < argc) {
newPtr = (Tk_Uid *)ckalloc(argc * sizeof(Tk_Uid));
- for (i = itemPtr->numTags - 1; i >= 0; i--) {
+ for (i = itemPtr->numTags - 1; i != TCL_INDEX_NONE; i--) {
newPtr[i] = itemPtr->tagPtr[i];
}
if (itemPtr->tagPtr != itemPtr->staticTagSpace) {
@@ -470,10 +470,10 @@ Tk_CanvasTagsParseProc(
const char *
Tk_CanvasTagsPrintProc(
- ClientData clientData, /* Ignored. */
- Tk_Window tkwin, /* Window containing canvas widget. */
+ TCL_UNUSED(void *),
+ TCL_UNUSED(Tk_Window), /* Window containing canvas widget. */
char *widgRec, /* Pointer to record for item. */
- int offset, /* Ignored. */
+ TCL_UNUSED(Tcl_Size), /* Ignored. */
Tcl_FreeProc **freeProcPtr) /* Pointer to variable to fill in with
* information about how to reclaim storage
* for return string. */
@@ -512,12 +512,12 @@ Tk_CanvasTagsPrintProc(
int
TkCanvasDashParseProc(
- ClientData clientData, /* Not used.*/
+ TCL_UNUSED(void *),
Tcl_Interp *interp, /* Used for reporting errors. */
- Tk_Window tkwin, /* Window containing canvas widget. */
+ TCL_UNUSED(Tk_Window), /* Window containing canvas widget. */
const char *value, /* Value of option. */
char *widgRec, /* Pointer to record for item. */
- int offset) /* Offset into item. */
+ Tcl_Size offset) /* Offset into item. */
{
return Tk_GetDash(interp, value, (Tk_Dash *) (widgRec+offset));
}
@@ -546,10 +546,10 @@ TkCanvasDashParseProc(
const char *
TkCanvasDashPrintProc(
- ClientData clientData, /* Ignored. */
- Tk_Window tkwin, /* Window containing canvas widget. */
+ TCL_UNUSED(void *),
+ TCL_UNUSED(Tk_Window), /* Window containing canvas widget. */
char *widgRec, /* Pointer to record for item. */
- int offset, /* Offset in record for item. */
+ Tcl_Size offset, /* Offset in record for item. */
Tcl_FreeProc **freeProcPtr) /* Pointer to variable to fill in with
* information about how to reclaim storage
* for return string. */
@@ -561,7 +561,7 @@ TkCanvasDashPrintProc(
if (i < 0) {
i = -i;
*freeProcPtr = TCL_DYNAMIC;
- buffer = ckalloc(i + 1);
+ buffer = (char *)ckalloc((Tcl_Size)i + 1);
p = (i > (int)sizeof(char *)) ? dash->pattern.pt : dash->pattern.array;
memcpy(buffer, p, (unsigned int) i);
buffer[i] = 0;
@@ -570,13 +570,13 @@ TkCanvasDashPrintProc(
*freeProcPtr = NULL;
return "";
}
- buffer = ckalloc(4 * i);
+ buffer = (char *)ckalloc(4 * (Tcl_Size)i);
*freeProcPtr = TCL_DYNAMIC;
p = (i > (int)sizeof(char *)) ? dash->pattern.pt : dash->pattern.array;
- snprintf(buffer, 4 * i, "%d", *p++ & 0xff);
+ snprintf(buffer, 4 * (size_t)i, "%d", *p++ & 0xff);
while (--i) {
- snprintf(buffer + strlen(buffer), 4 * i - strlen(buffer), " %d", *p++ & 0xff);
+ snprintf(buffer + strlen(buffer), 4 * (size_t)i - strlen(buffer), " %d", *p++ & 0xff);
}
return buffer;
}
@@ -606,12 +606,12 @@ InitSmoothMethods(
{
SmoothAssocData *methods, *ptr;
- methods = ckalloc(sizeof(SmoothAssocData));
+ methods = (SmoothAssocData *)ckalloc(sizeof(SmoothAssocData));
methods->smooth.name = tkRawSmoothMethod.name;
methods->smooth.coordProc = tkRawSmoothMethod.coordProc;
methods->smooth.postscriptProc = tkRawSmoothMethod.postscriptProc;
- ptr = methods->nextPtr = ckalloc(sizeof(SmoothAssocData));
+ ptr = methods->nextPtr = (SmoothAssocData *)ckalloc(sizeof(SmoothAssocData));
ptr->smooth.name = tkBezierSmoothMethod.name;
ptr->smooth.coordProc = tkBezierSmoothMethod.coordProc;
ptr->smooth.postscriptProc = tkBezierSmoothMethod.postscriptProc;
@@ -645,7 +645,7 @@ Tk_CreateSmoothMethod(
const Tk_SmoothMethod *smooth)
{
SmoothAssocData *methods, *typePtr2, *prevPtr, *ptr;
- methods = Tcl_GetAssocData(interp, "smoothMethod", NULL);
+ methods = (SmoothAssocData *)Tcl_GetAssocData(interp, "smoothMethod", NULL);
/*
* Initialize if we were not previously initialized.
@@ -671,7 +671,7 @@ Tk_CreateSmoothMethod(
break;
}
}
- ptr = ckalloc(sizeof(SmoothAssocData));
+ ptr = (SmoothAssocData *)ckalloc(sizeof(SmoothAssocData));
ptr->smooth.name = smooth->name;
ptr->smooth.coordProc = smooth->coordProc;
ptr->smooth.postscriptProc = smooth->postscriptProc;
@@ -698,11 +698,11 @@ Tk_CreateSmoothMethod(
static void
SmoothMethodCleanupProc(
- ClientData clientData, /* Points to "smoothMethod" AssocData for the
+ void *clientData, /* Points to "smoothMethod" AssocData for the
* interpreter. */
- Tcl_Interp *interp) /* Interpreter that is being deleted. */
+ TCL_UNUSED(Tcl_Interp *)) /* Interpreter that is being deleted. */
{
- SmoothAssocData *ptr, *methods = clientData;
+ SmoothAssocData *ptr, *methods = (SmoothAssocData *)clientData;
while (methods != NULL) {
ptr = methods;
@@ -730,12 +730,12 @@ SmoothMethodCleanupProc(
int
TkSmoothParseProc(
- ClientData clientData, /* Ignored. */
+ TCL_UNUSED(void *),
Tcl_Interp *interp, /* Used for reporting errors. */
- Tk_Window tkwin, /* Window containing canvas widget. */
+ TCL_UNUSED(Tk_Window), /* Window containing canvas widget. */
const char *value, /* Value of option. */
char *widgRec, /* Pointer to record for item. */
- int offset) /* Offset into item. */
+ Tcl_Size offset) /* Offset into item. */
{
const Tk_SmoothMethod **smoothPtr =
(const Tk_SmoothMethod **) (widgRec + offset);
@@ -749,7 +749,7 @@ TkSmoothParseProc(
return TCL_OK;
}
length = strlen(value);
- methods = Tcl_GetAssocData(interp, "smoothMethod", NULL);
+ methods = (SmoothAssocData *)Tcl_GetAssocData(interp, "smoothMethod", NULL);
/*
* Not initialized yet; fix that now.
@@ -777,7 +777,7 @@ TkSmoothParseProc(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"ambiguous smooth method \"%s\"", value));
Tcl_SetErrorCode(interp, "TK", "LOOKUP", "SMOOTH", value,
- NULL);
+ (char *)NULL);
return TCL_ERROR;
}
smooth = &methods->smooth;
@@ -822,11 +822,11 @@ TkSmoothParseProc(
const char *
TkSmoothPrintProc(
- ClientData clientData, /* Ignored. */
- Tk_Window tkwin, /* Window containing canvas widget. */
+ TCL_UNUSED(void *),
+ TCL_UNUSED(Tk_Window), /* Window containing canvas widget. */
char *widgRec, /* Pointer to record for item. */
- int offset, /* Offset into item. */
- Tcl_FreeProc **freeProcPtr) /* Pointer to variable to fill in with
+ Tcl_Size offset, /* Offset into item. */
+ TCL_UNUSED(Tcl_FreeProc **)) /* Pointer to variable to fill in with
* information about how to reclaim storage
* for return string. */
{
@@ -860,7 +860,8 @@ Tk_GetDash(
Tk_Dash *dash) /* Pointer to record in which to store dash
* information. */
{
- int argc, i;
+ Tcl_Size argc;
+ int i;
const char **largv, **argv = NULL;
char *pt;
@@ -879,9 +880,9 @@ Tk_GetDash(
if (i <= 0) {
goto badDashList;
}
- i = strlen(value);
+ i = (int)strlen(value);
if (i > (int) sizeof(char *)) {
- dash->pattern.pt = pt = ckalloc(strlen(value));
+ dash->pattern.pt = pt = (char *)ckalloc(strlen(value));
} else {
pt = dash->pattern.array;
}
@@ -899,7 +900,7 @@ Tk_GetDash(
ckfree(dash->pattern.pt);
}
if (argc > (int) sizeof(char *)) {
- dash->pattern.pt = pt = ckalloc(argc);
+ dash->pattern.pt = pt = (char *)ckalloc(argc);
} else {
pt = dash->pattern.array;
}
@@ -911,7 +912,7 @@ Tk_GetDash(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"expected integer in the range 1..255 but got \"%s\"",
*largv));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "DASH", NULL);
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "DASH", (char *)NULL);
goto syntaxError;
}
*pt++ = i;
@@ -932,7 +933,7 @@ Tk_GetDash(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad dash list \"%s\": must be a list of integers or a format like \"-..\"",
value));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "DASH", NULL);
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "DASH", (char *)NULL);
syntaxError:
if (argv != NULL) {
ckfree(argv);
@@ -1230,7 +1231,7 @@ Tk_ChangeOutlineGC(
int i = -dash->number;
p = (i > (int)sizeof(char *)) ? dash->pattern.pt : dash->pattern.array;
- q = ckalloc(2 * i);
+ q = (char *)ckalloc(2 * i);
i = DashConvert(q, p, i, width);
XSetDashes(Canvas(canvas)->display, outline->gc, outline->offset, q,i);
ckfree(q);
@@ -1269,7 +1270,6 @@ Tk_ChangeOutlineGC(
}
return 0;
}
-
/*
*--------------------------------------------------------------
@@ -1434,7 +1434,7 @@ Tk_CanvasPsOutline(
ptr = ((unsigned) ABS(dash->number) > sizeof(char *)) ?
dash->pattern.pt : dash->pattern.array;
- Tcl_AppendToObj(psObj, "[", -1);
+ Tcl_AppendToObj(psObj, "[", TCL_INDEX_NONE);
if (dash->number > 0) {
Tcl_Obj *converted;
char *p = ptr;
@@ -1445,14 +1445,14 @@ Tk_CanvasPsOutline(
}
Tcl_AppendObjToObj(psObj, converted);
if (dash->number & 1) {
- Tcl_AppendToObj(psObj, " ", -1);
+ Tcl_AppendToObj(psObj, " ", TCL_INDEX_NONE);
Tcl_AppendObjToObj(psObj, converted);
}
Tcl_DecrRefCount(converted);
Tcl_AppendPrintfToObj(psObj, "] %d setdash\n", outline->offset);
} else if (dash->number < 0) {
if (dash->number < -5) {
- lptr = ckalloc(1 - 2*dash->number);
+ lptr = (char *)ckalloc(1 - 2*dash->number);
}
i = DashConvert(lptr, ptr, -dash->number, width);
if (i > 0) {
@@ -1464,30 +1464,22 @@ Tk_CanvasPsOutline(
}
Tcl_AppendPrintfToObj(psObj, "] %d setdash\n", outline->offset);
} else {
- Tcl_AppendToObj(psObj, "] 0 setdash\n", -1);
+ Tcl_AppendToObj(psObj, "] 0 setdash\n", TCL_INDEX_NONE);
}
if (lptr != pattern) {
ckfree(lptr);
}
} else {
- Tcl_AppendToObj(psObj, "] 0 setdash\n", -1);
- }
-
- if (Tk_CanvasPsColor(interp, canvas, color) != TCL_OK) {
- return TCL_ERROR;
+ Tcl_AppendToObj(psObj, "] 0 setdash\n", TCL_INDEX_NONE);
}
- /*
- * Note that psObj might hold an invalid reference now.
- */
+ Tk_CanvasPsColor(interp, canvas, color);
if (stipple != None) {
- Tcl_AppendToObj(GetPostscriptBuffer(interp), "StrokeClip ", -1);
- if (Tk_CanvasPsStipple(interp, canvas, stipple) != TCL_OK) {
- return TCL_ERROR;
- }
+ Tcl_AppendToObj(GetPostscriptBuffer(interp), "StrokeClip ", TCL_INDEX_NONE);
+ Tk_CanvasPsStipple(interp, canvas, stipple);
} else {
- Tcl_AppendToObj(GetPostscriptBuffer(interp), "stroke\n", -1);
+ Tcl_AppendToObj(GetPostscriptBuffer(interp), "stroke\n", TCL_INDEX_NONE);
}
return TCL_OK;
@@ -1653,7 +1645,7 @@ TkCanvTranslatePath(
int numVertex, /* Number of vertices specified by
* coordArr[] */
double *coordArr, /* X and Y coordinates for each vertex */
- int closedPath, /* True if this is a closed polygon */
+ TCL_UNUSED(int), /* True if this is a closed polygon */
XPoint *outArr) /* Write results here, if not NULL */
{
int numOutput = 0; /* Number of output coordinates */
@@ -1724,7 +1716,7 @@ TkCanvTranslatePath(
if (numVertex*12 <= (int) (sizeof(staticSpace) / sizeof(double))) {
tempArr = staticSpace;
} else {
- tempArr = ckalloc(numVertex * 12 * sizeof(double));
+ tempArr = (double *)ckalloc(numVertex * 12 * sizeof(double));
}
for (i=0; i<numVertex*2; i++){
tempArr[i] = coordArr[i];
@@ -1869,6 +1861,43 @@ TkCanvTranslatePath(
}
/*
+ *--------------------------------------------------------------
+ *
+ * TkRotatePoint --
+ *
+ * Rotate a point about another point. The angle should be converted into
+ * its sine and cosine before calling this function.
+ *
+ * Results:
+ * None
+ *
+ * Side effects:
+ * The point in (*xPtr,*yPtr) is updated to be rotated about
+ * (originX,originY) by the amount given by the sine and cosine of the
+ * angle to rotate.
+ *
+ *--------------------------------------------------------------
+ */
+
+void
+TkRotatePoint(
+ double originX, double originY, /* The point about which to rotate. */
+ double sine, double cosine, /* How much to rotate? */
+ double *xPtr, double *yPtr) /* The point to be rotated. (INOUT) */
+{
+ double x = *xPtr - originX;
+ double y = *yPtr - originY;
+
+ /*
+ * Beware! The canvas coordinate space is flipped vertically, so rotations
+ * go the "wrong" way with respect to mathematics.
+ */
+
+ *xPtr = originX + x * cosine + y * sine;
+ *yPtr = originY - x * sine + y * cosine;
+}
+
+/*
* Local Variables:
* mode: c
* c-basic-offset: 4
diff --git a/generic/tkCanvWind.c b/generic/tkCanvWind.c
index 4be98e2..358c697 100644
--- a/generic/tkCanvWind.c
+++ b/generic/tkCanvWind.c
@@ -3,8 +3,8 @@
*
* 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.
+ * Copyright © 1992-1994 The Regents of the University of California.
+ * Copyright © 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.
@@ -46,17 +46,17 @@ static const Tk_CustomOption tagsOption = {
static const Tk_ConfigSpec configSpecs[] = {
{TK_CONFIG_ANCHOR, "-anchor", NULL, NULL,
- "center", Tk_Offset(WindowItem, anchor), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "center", offsetof(WindowItem, anchor), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_PIXELS, "-height", NULL, NULL,
- "0", Tk_Offset(WindowItem, height), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "0", offsetof(WindowItem, height), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_CUSTOM, "-state", NULL, NULL,
- NULL, Tk_Offset(Tk_Item, state), TK_CONFIG_NULL_OK, &stateOption},
+ NULL, offsetof(Tk_Item, state), TK_CONFIG_NULL_OK, &stateOption},
{TK_CONFIG_CUSTOM, "-tags", NULL, NULL,
NULL, 0, TK_CONFIG_NULL_OK, &tagsOption},
{TK_CONFIG_PIXELS, "-width", NULL, NULL,
- "0", Tk_Offset(WindowItem, width), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "0", offsetof(WindowItem, width), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_WINDOW, "-window", NULL, NULL,
- NULL, Tk_Offset(WindowItem, tkwin), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(WindowItem, tkwin), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}
};
@@ -67,29 +67,31 @@ static const Tk_ConfigSpec configSpecs[] = {
static void ComputeWindowBbox(Tk_Canvas canvas,
WindowItem *winItemPtr);
static int ConfigureWinItem(Tcl_Interp *interp,
- Tk_Canvas canvas, Tk_Item *itemPtr, int objc,
+ Tk_Canvas canvas, Tk_Item *itemPtr, Tcl_Size objc,
Tcl_Obj *const objv[], int flags);
static int CreateWinItem(Tcl_Interp *interp,
Tk_Canvas canvas, struct Tk_Item *itemPtr,
- int objc, Tcl_Obj *const objv[]);
+ Tcl_Size objc, Tcl_Obj *const objv[]);
static void DeleteWinItem(Tk_Canvas canvas,
Tk_Item *itemPtr, Display *display);
static void DisplayWinItem(Tk_Canvas canvas,
Tk_Item *itemPtr, Display *display, Drawable dst,
int x, int y, int width, int height);
+static void RotateWinItem(Tk_Canvas canvas, Tk_Item *itemPtr,
+ double originX, double originY, double angleRad);
static void ScaleWinItem(Tk_Canvas canvas,
Tk_Item *itemPtr, double originX, double originY,
double scaleX, double scaleY);
static void TranslateWinItem(Tk_Canvas canvas,
Tk_Item *itemPtr, double deltaX, double deltaY);
static int WinItemCoords(Tcl_Interp *interp,
- Tk_Canvas canvas, Tk_Item *itemPtr, int objc,
+ Tk_Canvas canvas, Tk_Item *itemPtr, Tcl_Size objc,
Tcl_Obj *const objv[]);
-static void WinItemLostContentProc(ClientData clientData,
+static void WinItemLostContentProc(void *clientData,
Tk_Window tkwin);
-static void WinItemRequestProc(ClientData clientData,
+static void WinItemRequestProc(void *clientData,
Tk_Window tkwin);
-static void WinItemStructureProc(ClientData clientData,
+static void WinItemStructureProc(void *clientData,
XEvent *eventPtr);
static int WinItemToArea(Tk_Canvas canvas,
Tk_Item *itemPtr, double *rectPtr);
@@ -98,7 +100,7 @@ static int WinItemToPostscript(Tcl_Interp *interp,
static double WinItemToPoint(Tk_Canvas canvas,
Tk_Item *itemPtr, double *pointPtr);
#ifdef X_GetImage
-static int xerrorhandler(ClientData clientData, XErrorEvent *e);
+static int xerrorhandler(void *clientData, XErrorEvent *e);
#endif
static int CanvasPsWindow(Tcl_Interp *interp,
Tk_Window tkwin, Tk_Canvas canvas, double x,
@@ -118,7 +120,7 @@ Tk_ItemType tkWindowType = {
WinItemCoords, /* coordProc */
DeleteWinItem, /* deleteProc */
DisplayWinItem, /* displayProc */
- 1|TK_CONFIG_OBJS, /* flags */
+ TK_ALWAYS_REDRAW|TK_CONFIG_OBJS, /* flags */
WinItemToPoint, /* pointProc */
WinItemToArea, /* areaProc */
WinItemToPostscript, /* postscriptProc */
@@ -130,7 +132,8 @@ Tk_ItemType tkWindowType = {
NULL, /* insertProc */
NULL, /* dTextProc */
NULL, /* nextPtr */
- NULL, 0, NULL, NULL
+ RotateWinItem, /* rotateProc */
+ 0, NULL, NULL
};
/*
@@ -141,7 +144,7 @@ Tk_ItemType tkWindowType = {
static const Tk_GeomMgr canvasGeomType = {
"canvas", /* name */
WinItemRequestProc, /* requestProc */
- WinItemLostContentProc, /* lostSlaveProc */
+ WinItemLostContentProc, /* lostContentProc */
};
/*
@@ -169,11 +172,11 @@ CreateWinItem(
Tk_Canvas canvas, /* Canvas to hold new item. */
Tk_Item *itemPtr, /* Record to hold new item; header has been
* initialized by caller. */
- int objc, /* Number of arguments in objv. */
+ Tcl_Size objc, /* Number of arguments in objv. */
Tcl_Obj *const objv[]) /* Arguments describing window. */
{
WindowItem *winItemPtr = (WindowItem *) itemPtr;
- int i;
+ Tcl_Size i;
if (objc == 0) {
Tcl_Panic("canvas did not pass any coords");
@@ -207,7 +210,7 @@ CreateWinItem(
if (WinItemCoords(interp, canvas, itemPtr, i, objv) != TCL_OK) {
goto error;
}
- if (ConfigureWinItem(interp, canvas, itemPtr, objc-i, objv+i, 0)
+ if (ConfigureWinItem(interp, canvas, itemPtr, objc - i, objv + i, 0)
== TCL_OK) {
return TCL_OK;
}
@@ -240,7 +243,7 @@ WinItemCoords(
Tk_Canvas canvas, /* Canvas containing item. */
Tk_Item *itemPtr, /* Item whose coordinates are to be read or
* modified. */
- int objc, /* Number of coordinates supplied in objv. */
+ Tcl_Size objc, /* Number of coordinates supplied in objv. */
Tcl_Obj *const objv[]) /* Array of coordinates: x1, y1, x2, y2, ... */
{
WindowItem *winItemPtr = (WindowItem *) itemPtr;
@@ -258,9 +261,9 @@ WinItemCoords(
return TCL_ERROR;
} else if (objc != 2) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "wrong # coordinates: expected 2, got %d", objc));
+ "wrong # coordinates: expected 2, got %" TCL_SIZE_MODIFIER "d", objc));
Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "WINDOW",
- NULL);
+ (char *)NULL);
return TCL_ERROR;
}
}
@@ -272,8 +275,8 @@ WinItemCoords(
ComputeWindowBbox(canvas, winItemPtr);
} else {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "wrong # coordinates: expected 0 or 2, got %d", objc));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "WINDOW", NULL);
+ "wrong # coordinates: expected 0 or 2, got %" TCL_SIZE_MODIFIER "d", objc));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS", "WINDOW", (char *)NULL);
return TCL_ERROR;
}
return TCL_OK;
@@ -302,7 +305,7 @@ ConfigureWinItem(
Tcl_Interp *interp, /* Used for error reporting. */
Tk_Canvas canvas, /* Canvas containing itemPtr. */
Tk_Item *itemPtr, /* Window item to reconfigure. */
- int objc, /* Number of elements in objv. */
+ Tcl_Size objc, /* Number of elements in objv. */
Tcl_Obj *const objv[], /* Arguments describing things to configure. */
int flags) /* Flags to pass to Tk_ConfigureWidget. */
{
@@ -375,7 +378,7 @@ ConfigureWinItem(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't use %s in a window item of this canvas",
Tk_PathName(winItemPtr->tkwin)));
- Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "HIERARCHY", NULL);
+ Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "HIERARCHY", (char *)NULL);
winItemPtr->tkwin = NULL;
return TCL_ERROR;
}
@@ -401,7 +404,7 @@ static void
DeleteWinItem(
Tk_Canvas canvas, /* Overall info about widget. */
Tk_Item *itemPtr, /* Item that is being deleted. */
- Display *display) /* Display containing window for canvas. */
+ TCL_UNUSED(Display *)) /* Display containing window for canvas. */
{
WindowItem *winItemPtr = (WindowItem *) itemPtr;
Tk_Window canvasTkwin = Tk_CanvasTkwin(canvas);
@@ -514,7 +517,7 @@ ComputeWindowBbox(
break;
case TK_ANCHOR_NW:
break;
- case TK_ANCHOR_CENTER:
+ default:
x -= width/2;
y -= height/2;
break;
@@ -556,11 +559,12 @@ static void
DisplayWinItem(
Tk_Canvas canvas, /* Canvas that contains item. */
Tk_Item *itemPtr, /* Item to be displayed. */
- Display *display, /* Display on which to draw item. */
+ TCL_UNUSED(Display *), /* Display on which to draw item. */
Drawable drawable, /* Pixmap or window in which to draw item. */
- int regionX, int regionY, int regionWidth, int regionHeight)
- /* Describes region of canvas that must be
- * redisplayed (not used). */
+ TCL_UNUSED(int), /* Describes region of canvas that must be */
+ TCL_UNUSED(int), /* redisplayed (not used). */
+ TCL_UNUSED(int),
+ TCL_UNUSED(int))
{
WindowItem *winItemPtr = (WindowItem *) itemPtr;
int width, height;
@@ -659,7 +663,7 @@ DisplayWinItem(
static double
WinItemToPoint(
- Tk_Canvas canvas, /* Canvas containing item. */
+ TCL_UNUSED(Tk_Canvas), /* Canvas containing item. */
Tk_Item *itemPtr, /* Item to check against point. */
double *pointPtr) /* Pointer to x and y coordinates. */
{
@@ -715,7 +719,7 @@ WinItemToPoint(
static int
WinItemToArea(
- Tk_Canvas canvas, /* Canvas containing item. */
+ TCL_UNUSED(Tk_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
@@ -758,8 +762,8 @@ WinItemToArea(
#ifdef X_GetImage
static int
xerrorhandler(
- ClientData clientData,
- XErrorEvent *e)
+ TCL_UNUSED(void *),
+ TCL_UNUSED(XErrorEvent *))
{
return 0;
}
@@ -799,7 +803,7 @@ WinItemToPostscript(
Tk_Window tkwin = winItemPtr->tkwin;
if (prepass || winItemPtr->tkwin == NULL) {
- return TCL_OK;
+ return TCL_OK;
}
width = Tk_Width(tkwin);
@@ -822,7 +826,7 @@ WinItemToPostscript(
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;
+ default: x -= width/2.0; y -= height/2.0; break;
}
return CanvasPsWindow(interp, tkwin, canvas, x, y, width, height);
@@ -871,7 +875,7 @@ CanvasPsWindow(
"1.000 1.000 1.000 setrgbcolor AdjustColor\nfill\ngrestore\n",
height, width, height, width);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
- Tcl_AppendToObj(psObj, "\nrestore\nend\n\n\n", -1);
+ Tcl_AppendToObj(psObj, "\nrestore\nend\n\n\n", TCL_INDEX_NONE);
goto done;
}
@@ -925,6 +929,40 @@ CanvasPsWindow(
/*
*--------------------------------------------------------------
*
+ * RotateWinItem --
+ *
+ * This function is called to rotate a window item by a given amount
+ * about a point. Note that this does *not* rotate the window of the
+ * item.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * The position of the window anchor is rotated by angleRad about (originX,
+ * originY), and the bounding box is updated in the generic part of the
+ * item structure.
+ *
+ *--------------------------------------------------------------
+ */
+
+static void
+RotateWinItem(
+ Tk_Canvas canvas, /* Canvas containing item. */
+ Tk_Item *itemPtr, /* Item that is being rotated. */
+ double originX, double originY,
+ double angleRad) /* Amount by which item is to be rotated. */
+{
+ WindowItem *winItemPtr = (WindowItem *) itemPtr;
+
+ TkRotatePoint(originX, originY, sin(angleRad), cos(angleRad),
+ &winItemPtr->x, &winItemPtr->y);
+ ComputeWindowBbox(canvas, winItemPtr);
+}
+
+/*
+ *--------------------------------------------------------------
+ *
* ScaleWinItem --
*
* This function is invoked to rescale a window item.
@@ -1014,10 +1052,10 @@ TranslateWinItem(
static void
WinItemStructureProc(
- ClientData clientData, /* Pointer to record describing window item. */
+ void *clientData, /* Pointer to record describing window item. */
XEvent *eventPtr) /* Describes what just happened. */
{
- WindowItem *winItemPtr = clientData;
+ WindowItem *winItemPtr = (WindowItem *)clientData;
if (eventPtr->type == DestroyNotify) {
winItemPtr->tkwin = NULL;
@@ -1044,10 +1082,10 @@ WinItemStructureProc(
static void
WinItemRequestProc(
- ClientData clientData, /* Pointer to record for window item. */
- Tk_Window tkwin) /* Window that changed its desired size. */
+ void *clientData, /* Pointer to record for window item. */
+ TCL_UNUSED(Tk_Window)) /* Window that changed its desired size. */
{
- WindowItem *winItemPtr = clientData;
+ WindowItem *winItemPtr = (WindowItem *)clientData;
ComputeWindowBbox(winItemPtr->canvas, winItemPtr);
@@ -1077,14 +1115,13 @@ WinItemRequestProc(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static void
WinItemLostContentProc(
- ClientData clientData, /* WindowItem structure for content window that
+ void *clientData, /* WindowItem structure for content window window that
* was stolen away. */
- Tk_Window tkwin) /* Tk's handle for the content window. */
+ TCL_UNUSED(Tk_Window)) /* Tk's handle for the content window. */
{
- WindowItem *winItemPtr = clientData;
+ WindowItem *winItemPtr = (WindowItem *)clientData;
Tk_Window canvasTkwin = Tk_CanvasTkwin(winItemPtr->canvas);
Tk_DeleteEventHandler(winItemPtr->tkwin, StructureNotifyMask,
diff --git a/generic/tkCanvas.c b/generic/tkCanvas.c
index ccd3cac..38a297d 100644
--- a/generic/tkCanvas.c
+++ b/generic/tkCanvas.c
@@ -5,49 +5,29 @@
* 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-1997 Sun Microsystems, Inc.
- * Copyright (c) 1998-1999 Scriptics Corporation.
+ * Copyright © 1991-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1998-1999 Scriptics Corporation.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
-/* #define USE_OLD_TAG_SEARCH 1 */
-
-#include "default.h"
#include "tkInt.h"
#include "tkCanvas.h"
-#ifdef TK_NO_DOUBLE_BUFFERING
+#include "default.h"
+#include "tkPort.h"
#ifdef MAC_OSX_TK
#include "tkMacOSXInt.h"
#endif
-#endif /* TK_NO_DOUBLE_BUFFERING */
+#ifdef _WIN32
+#include "tkWinInt.h"
+#endif
/*
* See tkCanvas.h for key data structures used to implement canvases.
*/
-#ifdef USE_OLD_TAG_SEARCH
-/*
- * The structure defined below is used to keep track of a tag search in
- * progress. No 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 *currentPtr; /* Pointer to last item returned. */
- Tk_Item *lastPtr; /* The item right before the currentPtr is
- * tracked so if the currentPtr is deleted we
- * don't have to start from the beginning. */
- int searchOver; /* Non-zero means NextItem should always
- * return NULL. */
-} TagSearch;
-
-#else /* USE_OLD_TAG_SEARCH */
/*
* The structure defined below is used to keep track of a tag search in
* progress. No field should be accessed by anyone other than TagSearchScan,
@@ -74,7 +54,7 @@ typedef struct TagSearch {
int searchOver; /* Non-zero means NextItem should always
* return NULL. */
int type; /* Search type (see #defs below) */
- int id; /* Item id for searches by id */
+ Tcl_Size id; /* Item id for searches by id */
const char *string; /* Tag expression string */
int stringIndex; /* Current position in string scan */
int stringLength; /* Length of tag expression string */
@@ -94,8 +74,6 @@ typedef struct TagSearch {
#define SEARCH_TYPE_TAG 3 /* Looking for an item by simple tag */
#define SEARCH_TYPE_EXPR 4 /* Compound search */
-#endif /* USE_OLD_TAG_SEARCH */
-
/*
* Custom option for handling "-state" and "-offset"
*/
@@ -115,92 +93,92 @@ static const Tk_CustomOption offsetOption = {
static const Tk_ConfigSpec configSpecs[] = {
{TK_CONFIG_BORDER, "-background", "background", "Background",
- DEF_CANVAS_BG_COLOR, Tk_Offset(TkCanvas, bgBorder),
+ DEF_CANVAS_BG_COLOR, offsetof(TkCanvas, bgBorder),
TK_CONFIG_COLOR_ONLY, NULL},
{TK_CONFIG_BORDER, "-background", "background", "Background",
- DEF_CANVAS_BG_MONO, Tk_Offset(TkCanvas, bgBorder),
+ DEF_CANVAS_BG_MONO, offsetof(TkCanvas, bgBorder),
TK_CONFIG_MONO_ONLY, NULL},
{TK_CONFIG_SYNONYM, "-bd", "borderWidth", NULL, NULL, 0, 0, NULL},
{TK_CONFIG_SYNONYM, "-bg", "background", NULL, NULL, 0, 0, NULL},
{TK_CONFIG_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_CANVAS_BORDER_WIDTH, Tk_Offset(TkCanvas, borderWidth), 0, NULL},
+ DEF_CANVAS_BORDER_WIDTH, offsetof(TkCanvas, borderWidth), 0, NULL},
{TK_CONFIG_DOUBLE, "-closeenough", "closeEnough", "CloseEnough",
- DEF_CANVAS_CLOSE_ENOUGH, Tk_Offset(TkCanvas, closeEnough), 0, NULL},
+ DEF_CANVAS_CLOSE_ENOUGH, offsetof(TkCanvas, closeEnough), 0, NULL},
{TK_CONFIG_BOOLEAN, "-confine", "confine", "Confine",
- DEF_CANVAS_CONFINE, Tk_Offset(TkCanvas, confine), 0, NULL},
+ DEF_CANVAS_CONFINE, offsetof(TkCanvas, confine), 0, NULL},
{TK_CONFIG_ACTIVE_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_CANVAS_CURSOR, Tk_Offset(TkCanvas, cursor), TK_CONFIG_NULL_OK, NULL},
+ DEF_CANVAS_CURSOR, offsetof(TkCanvas, cursor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_PIXELS, "-height", "height", "Height",
- DEF_CANVAS_HEIGHT, Tk_Offset(TkCanvas, height), 0, NULL},
+ DEF_CANVAS_HEIGHT, offsetof(TkCanvas, height), 0, NULL},
{TK_CONFIG_COLOR, "-highlightbackground", "highlightBackground",
"HighlightBackground", DEF_CANVAS_HIGHLIGHT_BG,
- Tk_Offset(TkCanvas, highlightBgColorPtr), 0, NULL},
+ offsetof(TkCanvas, highlightBgColorPtr), 0, NULL},
{TK_CONFIG_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_CANVAS_HIGHLIGHT, Tk_Offset(TkCanvas, highlightColorPtr), 0, NULL},
+ DEF_CANVAS_HIGHLIGHT, offsetof(TkCanvas, highlightColorPtr), 0, NULL},
{TK_CONFIG_PIXELS, "-highlightthickness", "highlightThickness",
"HighlightThickness",
- DEF_CANVAS_HIGHLIGHT_WIDTH, Tk_Offset(TkCanvas, highlightWidth), 0, NULL},
+ DEF_CANVAS_HIGHLIGHT_WIDTH, offsetof(TkCanvas, highlightWidth), 0, NULL},
{TK_CONFIG_BORDER, "-insertbackground", "insertBackground", "Foreground",
- DEF_CANVAS_INSERT_BG, Tk_Offset(TkCanvas, textInfo.insertBorder), 0, NULL},
+ DEF_CANVAS_INSERT_BG, offsetof(TkCanvas, textInfo.insertBorder), 0, NULL},
{TK_CONFIG_PIXELS, "-insertborderwidth", "insertBorderWidth", "BorderWidth",
DEF_CANVAS_INSERT_BD_COLOR,
- Tk_Offset(TkCanvas, textInfo.insertBorderWidth), TK_CONFIG_COLOR_ONLY, NULL},
+ offsetof(TkCanvas, textInfo.insertBorderWidth), TK_CONFIG_COLOR_ONLY, NULL},
{TK_CONFIG_PIXELS, "-insertborderwidth", "insertBorderWidth", "BorderWidth",
DEF_CANVAS_INSERT_BD_MONO,
- Tk_Offset(TkCanvas, textInfo.insertBorderWidth), TK_CONFIG_MONO_ONLY, NULL},
+ offsetof(TkCanvas, textInfo.insertBorderWidth), TK_CONFIG_MONO_ONLY, NULL},
{TK_CONFIG_INT, "-insertofftime", "insertOffTime", "OffTime",
- DEF_CANVAS_INSERT_OFF_TIME, Tk_Offset(TkCanvas, insertOffTime), 0, NULL},
+ DEF_CANVAS_INSERT_OFF_TIME, offsetof(TkCanvas, insertOffTime), 0, NULL},
{TK_CONFIG_INT, "-insertontime", "insertOnTime", "OnTime",
- DEF_CANVAS_INSERT_ON_TIME, Tk_Offset(TkCanvas, insertOnTime), 0, NULL},
+ DEF_CANVAS_INSERT_ON_TIME, offsetof(TkCanvas, insertOnTime), 0, NULL},
{TK_CONFIG_PIXELS, "-insertwidth", "insertWidth", "InsertWidth",
- DEF_CANVAS_INSERT_WIDTH, Tk_Offset(TkCanvas, textInfo.insertWidth), 0, NULL},
+ DEF_CANVAS_INSERT_WIDTH, offsetof(TkCanvas, textInfo.insertWidth), 0, NULL},
{TK_CONFIG_CUSTOM, "-offset", "offset", "Offset", "0,0",
- Tk_Offset(TkCanvas, tsoffset),TK_CONFIG_DONT_SET_DEFAULT,
+ offsetof(TkCanvas, tsoffset),TK_CONFIG_DONT_SET_DEFAULT,
&offsetOption},
{TK_CONFIG_RELIEF, "-relief", "relief", "Relief",
- DEF_CANVAS_RELIEF, Tk_Offset(TkCanvas, relief), 0, NULL},
+ DEF_CANVAS_RELIEF, offsetof(TkCanvas, relief), 0, NULL},
{TK_CONFIG_STRING, "-scrollregion", "scrollRegion", "ScrollRegion",
- DEF_CANVAS_SCROLL_REGION, Tk_Offset(TkCanvas, regionString),
+ DEF_CANVAS_SCROLL_REGION, offsetof(TkCanvas, regionString),
TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BORDER, "-selectbackground", "selectBackground", "Foreground",
- DEF_CANVAS_SELECT_COLOR, Tk_Offset(TkCanvas, textInfo.selBorder),
+ DEF_CANVAS_SELECT_COLOR, offsetof(TkCanvas, textInfo.selBorder),
TK_CONFIG_COLOR_ONLY, NULL},
{TK_CONFIG_BORDER, "-selectbackground", "selectBackground", "Foreground",
- DEF_CANVAS_SELECT_MONO, Tk_Offset(TkCanvas, textInfo.selBorder),
+ DEF_CANVAS_SELECT_MONO, offsetof(TkCanvas, textInfo.selBorder),
TK_CONFIG_MONO_ONLY, NULL},
{TK_CONFIG_PIXELS, "-selectborderwidth", "selectBorderWidth", "BorderWidth",
DEF_CANVAS_SELECT_BD_COLOR,
- Tk_Offset(TkCanvas, textInfo.selBorderWidth), TK_CONFIG_COLOR_ONLY, NULL},
+ offsetof(TkCanvas, textInfo.selBorderWidth), TK_CONFIG_COLOR_ONLY, NULL},
{TK_CONFIG_PIXELS, "-selectborderwidth", "selectBorderWidth", "BorderWidth",
- DEF_CANVAS_SELECT_BD_MONO, Tk_Offset(TkCanvas, textInfo.selBorderWidth),
+ DEF_CANVAS_SELECT_BD_MONO, offsetof(TkCanvas, textInfo.selBorderWidth),
TK_CONFIG_MONO_ONLY, NULL},
{TK_CONFIG_COLOR, "-selectforeground", "selectForeground", "Background",
- DEF_CANVAS_SELECT_FG_COLOR, Tk_Offset(TkCanvas, textInfo.selFgColorPtr),
+ DEF_CANVAS_SELECT_FG_COLOR, offsetof(TkCanvas, textInfo.selFgColorPtr),
TK_CONFIG_COLOR_ONLY|TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_COLOR, "-selectforeground", "selectForeground", "Background",
- DEF_CANVAS_SELECT_FG_MONO, Tk_Offset(TkCanvas, textInfo.selFgColorPtr),
+ DEF_CANVAS_SELECT_FG_MONO, offsetof(TkCanvas, textInfo.selFgColorPtr),
TK_CONFIG_MONO_ONLY|TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-state", "state", "State",
- "normal", Tk_Offset(TkCanvas, canvas_state), TK_CONFIG_DONT_SET_DEFAULT,
+ "normal", offsetof(TkCanvas, canvas_state), TK_CONFIG_DONT_SET_DEFAULT,
&stateOption},
{TK_CONFIG_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_CANVAS_TAKE_FOCUS, Tk_Offset(TkCanvas, takeFocus),
+ DEF_CANVAS_TAKE_FOCUS, offsetof(TkCanvas, takeFocus),
TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_PIXELS, "-width", "width", "Width",
- DEF_CANVAS_WIDTH, Tk_Offset(TkCanvas, width), 0, NULL},
+ DEF_CANVAS_WIDTH, offsetof(TkCanvas, width), 0, NULL},
{TK_CONFIG_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand",
- DEF_CANVAS_X_SCROLL_CMD, Tk_Offset(TkCanvas, xScrollCmd),
+ DEF_CANVAS_X_SCROLL_CMD, offsetof(TkCanvas, xScrollCmd),
TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_PIXELS, "-xscrollincrement", "xScrollIncrement",
"ScrollIncrement",
- DEF_CANVAS_X_SCROLL_INCREMENT, Tk_Offset(TkCanvas, xScrollIncrement),
+ DEF_CANVAS_X_SCROLL_INCREMENT, offsetof(TkCanvas, xScrollIncrement),
0, NULL},
{TK_CONFIG_STRING, "-yscrollcommand", "yScrollCommand", "ScrollCommand",
- DEF_CANVAS_Y_SCROLL_CMD, Tk_Offset(TkCanvas, yScrollCmd),
+ DEF_CANVAS_Y_SCROLL_CMD, offsetof(TkCanvas, yScrollCmd),
TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_PIXELS, "-yscrollincrement", "yScrollIncrement",
"ScrollIncrement",
- DEF_CANVAS_Y_SCROLL_INCREMENT, Tk_Offset(TkCanvas, yScrollIncrement),
+ DEF_CANVAS_Y_SCROLL_INCREMENT, offsetof(TkCanvas, yScrollIncrement),
0, NULL},
{TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}
};
@@ -215,7 +193,6 @@ static Tk_ItemType *typeList = NULL;
* yet. */
TCL_DECLARE_MUTEX(typeListMutex)
-#ifndef USE_OLD_TAG_SEARCH
/*
* Uids for operands in compiled advanced tag search expressions.
* Initialization is done by GetStaticUids()
@@ -236,70 +213,60 @@ typedef struct {
static Tcl_ThreadDataKey dataKey;
static SearchUids * GetStaticUids(void);
-#endif /* USE_OLD_TAG_SEARCH */
/*
* Prototypes for functions defined later in this file:
*/
-static void CanvasBindProc(ClientData clientData,
+static void CanvasBindProc(void *clientData,
XEvent *eventPtr);
-static void CanvasBlinkProc(ClientData clientData);
-static void CanvasCmdDeletedProc(ClientData clientData);
+static void CanvasBlinkProc(void *clientData);
+static void CanvasCmdDeletedProc(void *clientData);
static void CanvasDoEvent(TkCanvas *canvasPtr, XEvent *eventPtr);
-static void CanvasEventProc(ClientData clientData,
+static void CanvasEventProc(void *clientData,
XEvent *eventPtr);
-static int CanvasFetchSelection(ClientData clientData, int offset,
- char *buffer, int maxBytes);
+static Tcl_Size CanvasFetchSelection(void *clientData, Tcl_Size offset,
+ char *buffer, Tcl_Size maxBytes);
static Tk_Item * CanvasFindClosest(TkCanvas *canvasPtr,
double coords[2]);
static void CanvasFocusProc(TkCanvas *canvasPtr, int gotFocus);
-static void CanvasLostSelection(ClientData clientData);
+static void CanvasLostSelection(void *clientData);
static void CanvasSelectTo(TkCanvas *canvasPtr,
- Tk_Item *itemPtr, int index);
+ Tk_Item *itemPtr, Tcl_Size index);
static void CanvasSetOrigin(TkCanvas *canvasPtr,
int xOrigin, int yOrigin);
static void CanvasUpdateScrollbars(TkCanvas *canvasPtr);
-static int CanvasWidgetCmd(ClientData clientData,
+static int CanvasWidgetCmd(void *clientData,
Tcl_Interp *interp, int objc,
Tcl_Obj *const *objv);
-static void CanvasWorldChanged(ClientData instanceData);
+static void CanvasWorldChanged(void *instanceData);
static int ConfigureCanvas(Tcl_Interp *interp,
- TkCanvas *canvasPtr, int objc,
+ TkCanvas *canvasPtr, Tcl_Size objc,
Tcl_Obj *const *objv, int flags);
+static void DefaultRotateImplementation(TkCanvas *canvasPtr,
+ Tk_Item *itemPtr, double x, double y,
+ double angleRadians);
static Tcl_FreeProc DestroyCanvas;
-static void DisplayCanvas(ClientData clientData);
+static int DrawCanvas(Tcl_Interp *interp, void *clientData, Tk_PhotoHandle photohandle, int subsample, int zoom);
+static void DisplayCanvas(void *clientData);
static void DoItem(Tcl_Obj *accumObj,
Tk_Item *itemPtr, Tk_Uid tag);
static void EventuallyRedrawItem(TkCanvas *canvasPtr,
Tk_Item *itemPtr);
-#ifdef USE_OLD_TAG_SEARCH
-static int FindItems(Tcl_Interp *interp, TkCanvas *canvasPtr,
- int argc, Tcl_Obj *const *argv,
- Tcl_Obj *newTagObj, int first);
-#else /* USE_OLD_TAG_SEARCH */
static int FindItems(Tcl_Interp *interp, TkCanvas *canvasPtr,
- int objc, Tcl_Obj *const *objv,
- Tcl_Obj *newTagObj, int first,
+ Tcl_Size objc, Tcl_Obj *const *objv,
+ Tcl_Obj *newTagObj, Tcl_Size first,
TagSearch **searchPtrPtr);
-#endif /* USE_OLD_TAG_SEARCH */
static int FindArea(Tcl_Interp *interp, TkCanvas *canvasPtr,
Tcl_Obj *const *objv, Tk_Uid uid, int enclosed);
static double GridAlign(double coord, double spacing);
-static const char** TkGetStringsFromObjs(int objc, Tcl_Obj *const *objv);
+#if !defined(TK_NO_DEPRECATED) && (TK_MAJOR_VERSION < 9)
+static const char** TkGetStringsFromObjs(Tcl_Size objc, Tcl_Obj *const *objv);
+#endif
static void InitCanvas(void);
-#ifdef USE_OLD_TAG_SEARCH
-static Tk_Item * NextItem(TagSearch *searchPtr);
-#endif /* USE_OLD_TAG_SEARCH */
static void PickCurrentItem(TkCanvas *canvasPtr, XEvent *eventPtr);
static Tcl_Obj * ScrollFractions(int screen1,
int screen2, int object1, int object2);
-#ifdef USE_OLD_TAG_SEARCH
-static void RelinkItems(TkCanvas *canvasPtr,
- Tcl_Obj *tag, Tk_Item *prevPtr);
-static Tk_Item * StartTagSearch(TkCanvas *canvasPtr,
- Tcl_Obj *tag, TagSearch *searchPtr);
-#else /* USE_OLD_TAG_SEARCH */
static int RelinkItems(TkCanvas *canvasPtr, Tcl_Obj *tag,
Tk_Item *prevPtr, TagSearch **searchPtrPtr);
static void TagSearchExprInit(TagSearchExpr **exprPtrPtr);
@@ -313,7 +280,6 @@ static int TagSearchEvalExpr(TagSearchExpr *expr,
Tk_Item *itemPtr);
static Tk_Item * TagSearchFirst(TagSearch *searchPtr);
static Tk_Item * TagSearchNext(TagSearch *searchPtr);
-#endif /* USE_OLD_TAG_SEARCH */
/*
* The structure below defines canvas class behavior by means of functions
@@ -331,17 +297,6 @@ static const Tk_ClassProcs canvasClass = {
* Macros that significantly simplify all code that finds items.
*/
-#ifdef USE_OLD_TAG_SEARCH
-#define FIRST_CANVAS_ITEM_MATCHING(objPtr,searchPtrPtr,errorExitClause) \
- itemPtr = StartTagSearch(canvasPtr,(objPtr),&search)
-#define FOR_EVERY_CANVAS_ITEM_MATCHING(objPtr,searchPtrPtr,errorExitClause) \
- for (itemPtr = StartTagSearch(canvasPtr, (objPtr), &search); \
- itemPtr != NULL; itemPtr = NextItem(&search))
-#define FIND_ITEMS(objPtr, n) \
- FindItems(interp, canvasPtr, objc, objv, (objPtr), (n))
-#define RELINK_ITEMS(objPtr, itemPtr) \
- RelinkItems(canvasPtr, (objPtr), (itemPtr))
-#else /* USE_OLD_TAG_SEARCH */
#define FIRST_CANVAS_ITEM_MATCHING(objPtr,searchPtrPtr,errorExitClause) \
if ((result=TagSearchScan(canvasPtr,(objPtr),(searchPtrPtr))) != TCL_OK){ \
errorExitClause; \
@@ -357,7 +312,6 @@ static const Tk_ClassProcs canvasClass = {
FindItems(interp, canvasPtr, objc, objv, (objPtr), (n), &searchPtr)
#define RELINK_ITEMS(objPtr, itemPtr) \
result = RelinkItems(canvasPtr, (objPtr), (itemPtr), &searchPtr)
-#endif /* USE_OLD_TAG_SEARCH */
/*
* ----------------------------------------------------------------------
@@ -381,7 +335,7 @@ static inline int
ItemConfigure(
TkCanvas *canvasPtr,
Tk_Item *itemPtr,
- int objc,
+ Tcl_Size objc,
Tcl_Obj *const objv[])
{
Tcl_Interp *interp = canvasPtr->interp;
@@ -391,6 +345,9 @@ ItemConfigure(
result = itemPtr->typePtr->configProc(interp, (Tk_Canvas) canvasPtr,
itemPtr, objc, objv, TK_CONFIG_ARGV_ONLY);
} else {
+#if defined(TK_NO_DEPRECATED) || (TK_MAJOR_VERSION > 8)
+ Tcl_Panic("Flag TK_CONFIG_OBJS is mandatory");
+#else
const char **args = TkGetStringsFromObjs(objc, objv);
result = itemPtr->typePtr->configProc(interp, (Tk_Canvas) canvasPtr,
@@ -398,6 +355,7 @@ ItemConfigure(
if (args != NULL) {
ckfree(args);
}
+#endif
}
return result;
}
@@ -409,7 +367,7 @@ ItemConfigInfo(
Tcl_Obj *fieldName)
{
return Tk_ConfigureInfo(canvasPtr->interp, canvasPtr->tkwin,
- itemPtr->typePtr->configSpecs, (char *) itemPtr,
+ itemPtr->typePtr->configSpecs, itemPtr,
(fieldName ? Tcl_GetString(fieldName) : NULL), 0);
}
@@ -420,7 +378,7 @@ ItemConfigValue(
Tcl_Obj *fieldName)
{
return Tk_ConfigureValue(canvasPtr->interp, canvasPtr->tkwin,
- itemPtr->typePtr->configSpecs, (char *) itemPtr,
+ itemPtr->typePtr->configSpecs, itemPtr,
Tcl_GetString(fieldName), 0);
}
@@ -428,7 +386,7 @@ static inline int
ItemCoords(
TkCanvas *canvasPtr,
Tk_Item *itemPtr,
- int objc,
+ Tcl_Size objc,
Tcl_Obj *const objv[])
{
Tcl_Interp *interp = canvasPtr->interp;
@@ -440,6 +398,9 @@ ItemCoords(
result = itemPtr->typePtr->coordProc(interp, (Tk_Canvas) canvasPtr,
itemPtr, objc, objv);
} else {
+#if defined(TK_NO_DEPRECATED) || (TK_MAJOR_VERSION > 8)
+ Tcl_Panic("Flag TK_CONFIG_OBJS is mandatory");
+#else
const char **args = TkGetStringsFromObjs(objc, objv);
result = itemPtr->typePtr->coordProc(interp, (Tk_Canvas) canvasPtr,
@@ -447,6 +408,7 @@ ItemCoords(
if (args != NULL) {
ckfree(args);
}
+#endif
}
return result;
}
@@ -456,7 +418,7 @@ ItemCreate(
TkCanvas *canvasPtr,
Tk_Item *itemPtr, /* Warning: incomplete! typePtr field must be
* set by this point. */
- int objc,
+ Tcl_Size objc,
Tcl_Obj *const objv[])
{
Tcl_Interp *interp = canvasPtr->interp;
@@ -466,6 +428,9 @@ ItemCreate(
result = itemPtr->typePtr->createProc(interp, (Tk_Canvas) canvasPtr,
itemPtr, objc-3, objv+3);
} else {
+#if defined(TK_NO_DEPRECATED) || (TK_MAJOR_VERSION > 8)
+ Tcl_Panic("Flag TK_CONFIG_OBJS is mandatory");
+#else
const char **args = TkGetStringsFromObjs(objc-3, objv+3);
result = itemPtr->typePtr->createProc(interp, (Tk_Canvas) canvasPtr,
@@ -473,6 +438,7 @@ ItemCreate(
if (args != NULL) {
ckfree(args);
}
+#endif
}
return result;
}
@@ -522,7 +488,7 @@ ItemIndex(
TkCanvas *canvasPtr,
Tk_Item *itemPtr,
Tcl_Obj *objPtr,
- int *indexPtr)
+ Tcl_Size *indexPtr)
{
Tcl_Interp *interp = canvasPtr->interp;
@@ -532,8 +498,13 @@ ItemIndex(
return itemPtr->typePtr->indexProc(interp, (Tk_Canvas) canvasPtr,
itemPtr, objPtr, indexPtr);
} else {
+#if defined(TK_NO_DEPRECATED)
+ Tcl_AppendResult(interp, "Flag TK_CONFIG_OBJS is mandatory", (char *)NULL);
+ return TCL_ERROR;
+#else
return itemPtr->typePtr->indexProc(interp, (Tk_Canvas) canvasPtr,
itemPtr, (Tcl_Obj *) Tcl_GetString(objPtr), indexPtr);
+#endif
}
}
@@ -548,8 +519,12 @@ ItemInsert(
itemPtr->typePtr->insertProc((Tk_Canvas) canvasPtr, itemPtr,
beforeThis, toInsert);
} else {
+#if defined(TK_NO_DEPRECATED) || (TK_MAJOR_VERSION > 8)
+ Tcl_Panic("Flag TK_CONFIG_OBJS is mandatory");
+#else
itemPtr->typePtr->insertProc((Tk_Canvas) canvasPtr, itemPtr,
beforeThis, (Tcl_Obj *) Tcl_GetString(toInsert));
+#endif
}
}
@@ -587,20 +562,20 @@ ItemScale(
xOrigin, yOrigin, xScale, yScale);
}
-static inline int
+static inline Tcl_Size
ItemSelection(
TkCanvas *canvasPtr,
Tk_Item *itemPtr,
int offset,
char *buffer,
- int maxBytes)
+ Tcl_Size maxBytes)
{
if (itemPtr == NULL || itemPtr->typePtr->selectionProc == NULL) {
- return -1;
+ return TCL_INDEX_NONE;
}
return itemPtr->typePtr->selectionProc((Tk_Canvas) canvasPtr, itemPtr,
- offset, buffer, maxBytes);
+ offset, buffer, (int)maxBytes);
}
static inline void
@@ -613,6 +588,103 @@ ItemTranslate(
itemPtr->typePtr->translateProc((Tk_Canvas) canvasPtr, itemPtr,
xDelta, yDelta);
}
+
+static inline void
+ItemRotate(
+ TkCanvas *canvasPtr,
+ Tk_Item *itemPtr,
+ double x,
+ double y,
+ double angleRadians)
+{
+ if (itemPtr->typePtr->rotateProc != NULL) {
+ itemPtr->typePtr->rotateProc((Tk_Canvas) canvasPtr,
+ itemPtr, x, y, angleRadians);
+ } else {
+ DefaultRotateImplementation(canvasPtr, itemPtr, x, y, angleRadians);
+ }
+}
+
+/*
+ *--------------------------------------------------------------
+ *
+ * DefaultRotateImplementation --
+ *
+ * The default implementation of the rotation operation, used when items
+ * do not provide their own version.
+ *
+ *--------------------------------------------------------------
+ */
+
+static void
+DefaultRotateImplementation(
+ TkCanvas *canvasPtr,
+ Tk_Item *itemPtr,
+ double x,
+ double y,
+ double angleRadians)
+{
+ Tcl_Size i, objc;
+ int ok = 1;
+ Tcl_Obj **objv, **newObjv;
+ double *coordv;
+ double s = sin(angleRadians);
+ double c = cos(angleRadians);
+ Tcl_Interp *interp = canvasPtr->interp;
+
+ /*
+ * Get the coordinates out of the item.
+ */
+
+ if (ItemCoords(canvasPtr, itemPtr, 0, NULL) == TCL_OK &&
+ Tcl_ListObjGetElements(NULL, Tcl_GetObjResult(interp),
+ &objc, &objv) == TCL_OK) {
+ coordv = (double *) ckalloc(sizeof(double) * objc);
+ for (i=0 ; i<objc ; i++) {
+ if (Tcl_GetDoubleFromObj(NULL, objv[i], &coordv[i]) != TCL_OK) {
+ ok = 0;
+ break;
+ }
+ }
+ if (ok) {
+ /*
+ * Apply the rotation.
+ */
+
+ for (i=0 ; i<objc ; i+=2) {
+ double px = coordv[i+0] - x;
+ double py = coordv[i+1] - y;
+ double nx = px * c - py * s;
+ double ny = px * s + py * c;
+
+ coordv[i+0] = nx + x;
+ coordv[i+1] = ny + y;
+ }
+
+ /*
+ * Write the coordinates back into the item.
+ */
+
+ newObjv = (Tcl_Obj **) ckalloc(sizeof(Tcl_Obj *) * objc);
+ for (i=0 ; i<objc ; i++) {
+ newObjv[i] = Tcl_NewDoubleObj(coordv[i]);
+ Tcl_IncrRefCount(newObjv[i]);
+ }
+ ItemCoords(canvasPtr, itemPtr, objc, newObjv);
+ for (i=0 ; i<objc ; i++) {
+ Tcl_DecrRefCount(newObjv[i]);
+ }
+ ckfree(newObjv);
+ }
+ ckfree(coordv);
+ }
+
+ /*
+ * The interpreter result was (probably) modified above; reset it.
+ */
+
+ Tcl_ResetResult(interp);
+}
/*
*--------------------------------------------------------------
@@ -633,7 +705,7 @@ ItemTranslate(
int
Tk_CanvasObjCmd(
- ClientData clientData, /* Main window associated with interpreter. */
+ void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -686,8 +758,8 @@ Tk_CanvasObjCmd(
canvasPtr->textInfo.selBorderWidth = 0;
canvasPtr->textInfo.selFgColorPtr = NULL;
canvasPtr->textInfo.selItemPtr = NULL;
- canvasPtr->textInfo.selectFirst = -1;
- canvasPtr->textInfo.selectLast = -1;
+ canvasPtr->textInfo.selectFirst = TCL_INDEX_NONE;
+ canvasPtr->textInfo.selectLast = TCL_INDEX_NONE;
canvasPtr->textInfo.anchorItemPtr = NULL;
canvasPtr->textInfo.selectAnchor = 0;
canvasPtr->textInfo.insertBorder = NULL;
@@ -735,9 +807,7 @@ Tk_CanvasObjCmd(
canvasPtr->tsoffset.flags = 0;
canvasPtr->tsoffset.xoffset = 0;
canvasPtr->tsoffset.yoffset = 0;
-#ifndef USE_OLD_TAG_SEARCH
canvasPtr->bindTagExprs = NULL;
-#endif
Tcl_InitHashTable(&canvasPtr->idTable, TCL_ONE_WORD_KEYS);
Tk_SetClass(canvasPtr->tkwin, "Canvas");
@@ -755,7 +825,7 @@ Tk_CanvasObjCmd(
goto error;
}
- Tcl_SetObjResult(interp, TkNewWindowObj(canvasPtr->tkwin));
+ Tcl_SetObjResult(interp, Tk_NewWindowObj(canvasPtr->tkwin));
return TCL_OK;
error:
@@ -783,7 +853,7 @@ Tk_CanvasObjCmd(
static int
CanvasWidgetCmd(
- ClientData clientData, /* Information about canvas widget. */
+ void *clientData, /* Information about canvas widget. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -792,50 +862,47 @@ CanvasWidgetCmd(
int c, result;
Tk_Item *itemPtr = NULL; /* Initialization needed only to prevent
* compiler warning. */
-#ifdef USE_OLD_TAG_SEARCH
- TagSearch search;
-#else /* USE_OLD_TAG_SEARCH */
TagSearch *searchPtr = NULL;/* Allocated by first TagSearchScan, freed by
* TagSearchDestroy */
-#endif /* USE_OLD_TAG_SEARCH */
- int index;
- static const char *const optionStrings[] = {
+ int idx;
+ static const char *const canvasOptionStrings[] = {
"addtag", "bbox", "bind", "canvasx",
"canvasy", "cget", "configure", "coords",
"create", "dchars", "delete", "dtag",
"find", "focus", "gettags", "icursor",
- "imove", "index", "insert", "itemcget",
- "itemconfigure",
+ "image", "imove", "index", "insert",
+ "itemcget", "itemconfigure",
"lower", "move", "moveto", "postscript",
- "raise", "rchars", "scale", "scan",
- "select", "type", "xview", "yview",
- NULL
+ "raise", "rchars", "rotate", "scale",
+ "scan", "select", "type", "xview",
+ "yview", NULL
};
- enum options {
+ enum canvasOptionStringsEnum {
CANV_ADDTAG, CANV_BBOX, CANV_BIND, CANV_CANVASX,
CANV_CANVASY, CANV_CGET, CANV_CONFIGURE, CANV_COORDS,
CANV_CREATE, CANV_DCHARS, CANV_DELETE, CANV_DTAG,
CANV_FIND, CANV_FOCUS, CANV_GETTAGS, CANV_ICURSOR,
- CANV_IMOVE, CANV_INDEX, CANV_INSERT, CANV_ITEMCGET,
- CANV_ITEMCONFIGURE,
+ CANV_IMAGE, CANV_IMOVE, CANV_INDEX, CANV_INSERT,
+ CANV_ITEMCGET, CANV_ITEMCONFIGURE,
CANV_LOWER, CANV_MOVE, CANV_MOVETO, CANV_POSTSCRIPT,
- CANV_RAISE, CANV_RCHARS, CANV_SCALE, CANV_SCAN,
- CANV_SELECT, CANV_TYPE, CANV_XVIEW, CANV_YVIEW
+ CANV_RAISE, CANV_RCHARS, CANV_ROTATE, CANV_SCALE,
+ CANV_SCAN, CANV_SELECT, CANV_TYPE, CANV_XVIEW,
+ CANV_YVIEW
};
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?");
return TCL_ERROR;
}
- if (Tcl_GetIndexFromObj(interp, objv[1], optionStrings, "option", 0,
- &index) != TCL_OK) {
+ if (Tcl_GetIndexFromObj(interp, objv[1], canvasOptionStrings, "option", 0,
+ &idx) != TCL_OK) {
return TCL_ERROR;
}
Tcl_Preserve(canvasPtr);
result = TCL_OK;
- switch ((enum options)index) {
+ switch ((enum canvasOptionStringsEnum)idx) {
case CANV_ADDTAG:
if (objc < 4) {
Tcl_WrongNumArgs(interp, 2, objv, "tag searchCommand ?arg ...?");
@@ -846,7 +913,8 @@ CanvasWidgetCmd(
break;
case CANV_BBOX: {
- int i, gotAny;
+ int gotAny;
+ Tcl_Size i;
int x1 = 0, y1 = 0, x2 = 0, y2 = 0; /* Initializations needed only
* to prevent overcautious
* compiler warnings. */
@@ -888,10 +956,10 @@ CanvasWidgetCmd(
if (gotAny) {
Tcl_Obj *resultObjs[4];
- resultObjs[0] = Tcl_NewIntObj(x1);
- resultObjs[1] = Tcl_NewIntObj(y1);
- resultObjs[2] = Tcl_NewIntObj(x2);
- resultObjs[3] = Tcl_NewIntObj(y2);
+ resultObjs[0] = Tcl_NewWideIntObj(x1);
+ resultObjs[1] = Tcl_NewWideIntObj(y1);
+ resultObjs[2] = Tcl_NewWideIntObj(x2);
+ resultObjs[3] = Tcl_NewWideIntObj(y2);
Tcl_SetObjResult(interp, Tcl_NewListObj(4, resultObjs));
}
break;
@@ -911,35 +979,6 @@ CanvasWidgetCmd(
*/
object = NULL;
-#ifdef USE_OLD_TAG_SEARCH
- if (isdigit(UCHAR(Tcl_GetString(objv[2])[0]))) {
- int id;
- char *end;
- Tcl_HashEntry *entryPtr;
-
- id = strtoul(Tcl_GetString(objv[2]), &end, 0);
- if (*end != 0) {
- goto bindByTag;
- }
- entryPtr = Tcl_FindHashEntry(&canvasPtr->idTable, (char *) id);
- if (entryPtr != NULL) {
- itemPtr = Tcl_GetHashValue(entryPtr);
- object = itemPtr;
- }
-
- if (object == NULL) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "item \"%s\" doesn't exist", Tcl_GetString(objv[2])));
- Tcl_SetErrorCode(interp, "TK", "LOOKUP", "CANVAS_ITEM",
- Tcl_GetString(objv[2]), NULL);
- result = TCL_ERROR;
- goto done;
- }
- } else {
- bindByTag:
- object = Tk_GetUid(Tcl_GetString(objv[2]));
- }
-#else /* USE_OLD_TAG_SEARCH */
result = TagSearchScan(canvasPtr, objv[2], &searchPtr);
if (result != TCL_OK) {
goto done;
@@ -958,14 +997,13 @@ CanvasWidgetCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"item \"%s\" doesn't exist", Tcl_GetString(objv[2])));
Tcl_SetErrorCode(interp, "TK", "LOOKUP", "CANVAS_ITEM",
- Tcl_GetString(objv[2]), NULL);
+ Tcl_GetString(objv[2]), (char *)NULL);
result = TCL_ERROR;
goto done;
}
} else {
- object = (void *)searchPtr->expr->uid;
+ object = (char *)searchPtr->expr->uid;
}
-#endif /* USE_OLD_TAG_SEARCH */
/*
* Make a binding table if the canvas doesn't already have one.
@@ -985,7 +1023,6 @@ CanvasWidgetCmd(
object, Tcl_GetString(objv[3]));
goto done;
}
-#ifndef USE_OLD_TAG_SEARCH
if (searchPtr->type == SEARCH_TYPE_EXPR) {
/*
* If new tag expression, then insert in linked list.
@@ -1016,7 +1053,6 @@ CanvasWidgetCmd(
searchPtr->expr = NULL;
}
}
-#endif /* not USE_OLD_TAG_SEARCH */
if (argv4[0] == '+') {
argv4++;
append = 1;
@@ -1036,8 +1072,8 @@ CanvasWidgetCmd(
object, Tcl_GetString(objv[3]));
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"requested illegal events; only key, button, motion,"
- " enter, leave, and virtual events may be used", -1));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "BAD_EVENTS", NULL);
+ " enter, leave, and virtual events may be used", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "BAD_EVENTS", (char *)NULL);
result = TCL_ERROR;
goto done;
}
@@ -1061,7 +1097,7 @@ CanvasWidgetCmd(
}
Tcl_ResetResult(interp);
} else {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(command, -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(command, TCL_INDEX_NONE));
}
} else {
Tk_GetAllBindings(interp, canvasPtr->bindingTable, object);
@@ -1129,15 +1165,15 @@ CanvasWidgetCmd(
goto done;
}
result = Tk_ConfigureValue(interp, canvasPtr->tkwin, configSpecs,
- (char *) canvasPtr, Tcl_GetString(objv[2]), 0);
+ canvasPtr, Tcl_GetString(objv[2]), 0);
break;
case CANV_CONFIGURE:
if (objc == 2) {
result = Tk_ConfigureInfo(interp, canvasPtr->tkwin, configSpecs,
- (char *) canvasPtr, NULL, 0);
+ canvasPtr, NULL, 0);
} else if (objc == 3) {
result = Tk_ConfigureInfo(interp, canvasPtr->tkwin, configSpecs,
- (char *) canvasPtr, Tcl_GetString(objv[2]), 0);
+ canvasPtr, Tcl_GetString(objv[2]), 0);
} else {
result = ConfigureCanvas(interp, canvasPtr, objc-2, objv+2,
TK_CONFIG_ARGV_ONLY);
@@ -1185,6 +1221,7 @@ CanvasWidgetCmd(
tmpObj = Tcl_NewListObj(2, objv+4);
FOR_EVERY_CANVAS_ITEM_MATCHING(objv[2], &searchPtr, goto doneImove) {
+ Tcl_Size index;
int x1, x2, y1, y2;
int dontRedraw1, dontRedraw2;
@@ -1240,15 +1277,14 @@ CanvasWidgetCmd(
int isNew = 0;
Tcl_HashEntry *entryPtr;
const char *arg;
- size_t length;
+ Tcl_Size length;
if (objc < 3) {
Tcl_WrongNumArgs(interp, 2, objv, "type coords ?arg ...?");
result = TCL_ERROR;
goto done;
}
- arg = Tcl_GetString(objv[2]);
- length = objv[2]->length;
+ arg = Tcl_GetStringFromObj(objv[2], &length);
c = arg[0];
/*
@@ -1280,7 +1316,7 @@ CanvasWidgetCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"unknown or ambiguous item type \"%s\"", arg));
Tcl_SetErrorCode(interp, "TK", "LOOKUP", "CANVAS_ITEM_TYPE", arg,
- NULL);
+ (char *)NULL);
result = TCL_ERROR;
goto done;
}
@@ -1326,11 +1362,11 @@ CanvasWidgetCmd(
itemPtr->redraw_flags |= FORCE_REDRAW;
EventuallyRedrawItem(canvasPtr, itemPtr);
canvasPtr->flags |= REPICK_NEEDED;
- Tcl_SetObjResult(interp, Tcl_NewIntObj(itemPtr->id));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(itemPtr->id));
break;
}
case CANV_DCHARS: {
- int first, last;
+ Tcl_Size first, last;
int x1, x2, y1, y2;
if ((objc != 4) && (objc != 5)) {
@@ -1377,7 +1413,7 @@ CanvasWidgetCmd(
break;
}
case CANV_DELETE: {
- int i;
+ Tcl_Size i;
Tcl_HashEntry *entryPtr;
for (i = 2; i < objc; i++) {
@@ -1433,7 +1469,7 @@ CanvasWidgetCmd(
}
case CANV_DTAG: {
Tk_Uid tag;
- int i;
+ Tcl_Size i;
if ((objc != 3) && (objc != 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "tagOrId ?tagToDelete?");
@@ -1446,7 +1482,7 @@ CanvasWidgetCmd(
tag = Tk_GetUid(Tcl_GetString(objv[2]));
}
FOR_EVERY_CANVAS_ITEM_MATCHING(objv[2], &searchPtr, goto done) {
- for (i = itemPtr->numTags-1; i >= 0; i--) {
+ for (i = itemPtr->numTags-1; i != TCL_INDEX_NONE; i--) {
if (itemPtr->tagPtr[i] == tag) {
/*
@@ -1485,7 +1521,7 @@ CanvasWidgetCmd(
itemPtr = canvasPtr->textInfo.focusItemPtr;
if (objc == 2) {
if (itemPtr != NULL) {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(itemPtr->id));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(itemPtr->id));
}
goto done;
}
@@ -1520,14 +1556,15 @@ CanvasWidgetCmd(
int i;
Tcl_Obj *resultObj = Tcl_NewObj();
- for (i = 0; i < itemPtr->numTags; i++) {
+ for (i = 0; i < (int)itemPtr->numTags; i++) {
Tcl_ListObjAppendElement(NULL, resultObj,
- Tcl_NewStringObj(itemPtr->tagPtr[i], -1));
+ Tcl_NewStringObj(itemPtr->tagPtr[i], TCL_INDEX_NONE));
}
Tcl_SetObjResult(interp, resultObj);
}
break;
case CANV_ICURSOR: {
+ Tcl_Size index;
if (objc != 4) {
Tcl_WrongNumArgs(interp, 2, objv, "tagOrId index");
@@ -1552,6 +1589,7 @@ CanvasWidgetCmd(
break;
}
case CANV_INDEX: {
+ Tcl_Size index;
if (objc != 4) {
Tcl_WrongNumArgs(interp, 2, objv, "tagOrId string");
@@ -1567,7 +1605,7 @@ CanvasWidgetCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't find an indexable item \"%s\"",
Tcl_GetString(objv[2])));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "INDEXABLE_ITEM", NULL);
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "INDEXABLE_ITEM", (char *)NULL);
result = TCL_ERROR;
goto done;
}
@@ -1575,11 +1613,11 @@ CanvasWidgetCmd(
if (result != TCL_OK) {
goto done;
}
- Tcl_SetObjResult(interp, Tcl_NewIntObj(index));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(index));
break;
}
case CANV_INSERT: {
- int beforeThis;
+ Tcl_Size beforeThis;
int x1, x2, y1, y2;
if (objc != 5) {
@@ -1667,11 +1705,6 @@ CanvasWidgetCmd(
} else {
FIRST_CANVAS_ITEM_MATCHING(objv[3], &searchPtr, goto done);
if (itemPtr == NULL) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "tagOrId \"%s\" doesn't match any items",
- Tcl_GetString(objv[3])));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "ITEM", NULL);
- result = TCL_ERROR;
goto done;
}
itemPtr = itemPtr->prevPtr;
@@ -1765,12 +1798,7 @@ CanvasWidgetCmd(
break;
}
case CANV_POSTSCRIPT: {
- const char **args = TkGetStringsFromObjs(objc, objv);
-
- result = TkCanvPostscriptCmd(canvasPtr, interp, objc, args);
- if (args != NULL) {
- ckfree(args);
- }
+ result = TkCanvPostscriptObjCmd(canvasPtr, interp, objc, objv);
break;
}
case CANV_RAISE: {
@@ -1794,11 +1822,6 @@ CanvasWidgetCmd(
prevPtr = itemPtr;
}
if (prevPtr == NULL) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "tagOrId \"%s\" doesn't match any items",
- Tcl_GetString(objv[3])));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "ITEM", NULL);
- result = TCL_ERROR;
goto done;
}
}
@@ -1806,7 +1829,7 @@ CanvasWidgetCmd(
break;
}
case CANV_RCHARS: {
- int first, last;
+ Tcl_Size first, last;
int x1, x2, y1, y2;
int dontRedraw1, dontRedraw2;
@@ -1857,6 +1880,30 @@ CanvasWidgetCmd(
}
break;
}
+ case CANV_ROTATE: {
+ double x, y, angle;
+ Tk_Canvas canvas = (Tk_Canvas) canvasPtr;
+
+ if (objc != 6) {
+ Tcl_WrongNumArgs(interp, 2, objv, "tagOrId x y angle");
+ result = TCL_ERROR;
+ goto done;
+ }
+ if (Tk_CanvasGetCoordFromObj(interp, canvas, objv[3], &x) != TCL_OK ||
+ Tk_CanvasGetCoordFromObj(interp, canvas, objv[4], &y) != TCL_OK ||
+ Tcl_GetDoubleFromObj(interp, objv[5], &angle) != TCL_OK) {
+ result = TCL_ERROR;
+ goto done;
+ }
+ angle = angle * 3.1415927 / 180.0;
+ FOR_EVERY_CANVAS_ITEM_MATCHING(objv[2], &searchPtr, goto done) {
+ EventuallyRedrawItem(canvasPtr, itemPtr);
+ ItemRotate(canvasPtr, itemPtr, x, y, angle);
+ EventuallyRedrawItem(canvasPtr, itemPtr);
+ canvasPtr->flags |= REPICK_NEEDED;
+ }
+ break;
+ }
case CANV_SCALE: {
double xOrigin, yOrigin, xScale, yScale;
@@ -1877,8 +1924,8 @@ CanvasWidgetCmd(
}
if ((xScale == 0.0) || (yScale == 0.0)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "scale factor cannot be zero", -1));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "BAD_SCALE", NULL);
+ "scale factor cannot be zero", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "BAD_SCALE", (char *)NULL);
result = TCL_ERROR;
goto done;
}
@@ -1893,17 +1940,17 @@ CanvasWidgetCmd(
case CANV_SCAN: {
int x, y, gain = 10;
static const char *const optionStrings[] = {
- "mark", "dragto", NULL
+ "dragto", "mark", NULL
};
if (objc < 5) {
Tcl_WrongNumArgs(interp, 2, objv, "mark|dragto x y ?dragGain?");
result = TCL_ERROR;
} else if (Tcl_GetIndexFromObj(interp, objv[2], optionStrings,
- "scan option", 0, &index) != TCL_OK) {
+ "scan option", 0, &idx) != TCL_OK) {
result = TCL_ERROR;
- } else if ((objc != 5) && (objc != 5+index)) {
- Tcl_WrongNumArgs(interp, 3, objv, index?"x y ?gain?":"x y");
+ } else if ((objc != 5) && (objc + idx != 6)) {
+ Tcl_WrongNumArgs(interp, 3, objv, idx?"x y":"x y ?gain?");
result = TCL_ERROR;
} else if ((Tcl_GetIntFromObj(interp, objv[3], &x) != TCL_OK)
|| (Tcl_GetIntFromObj(interp, objv[4], &y) != TCL_OK)){
@@ -1911,7 +1958,7 @@ CanvasWidgetCmd(
} else if ((objc == 6) &&
(Tcl_GetIntFromObj(interp, objv[5], &gain) != TCL_OK)) {
result = TCL_ERROR;
- } else if (!index) {
+ } else if (idx) {
canvasPtr->scanX = x;
canvasPtr->scanXOrigin = canvasPtr->xOrigin;
canvasPtr->scanY = y;
@@ -1935,6 +1982,7 @@ CanvasWidgetCmd(
break;
}
case CANV_SELECT: {
+ Tcl_Size index;
int optionindex;
static const char *const optionStrings[] = {
"adjust", "clear", "from", "item", "to", NULL
@@ -1960,7 +2008,7 @@ CanvasWidgetCmd(
"can't find an indexable and selectable item \"%s\"",
Tcl_GetString(objv[3])));
Tcl_SetErrorCode(interp, "TK", "CANVAS", "SELECTABLE_ITEM",
- NULL);
+ (char *)NULL);
result = TCL_ERROR;
goto done;
}
@@ -1984,8 +2032,8 @@ CanvasWidgetCmd(
goto done;
}
if (canvasPtr->textInfo.selItemPtr == itemPtr) {
- if (index < (canvasPtr->textInfo.selectFirst
- + canvasPtr->textInfo.selectLast)/2) {
+ if (index + 1 <= ((canvasPtr->textInfo.selectFirst
+ + canvasPtr->textInfo.selectLast)/2)) {
canvasPtr->textInfo.selectAnchor =
canvasPtr->textInfo.selectLast + 1;
} else {
@@ -2021,7 +2069,7 @@ CanvasWidgetCmd(
}
if (canvasPtr->textInfo.selItemPtr != NULL) {
Tcl_SetObjResult(interp,
- Tcl_NewIntObj(canvasPtr->textInfo.selItemPtr->id));
+ Tcl_NewWideIntObj(canvasPtr->textInfo.selItemPtr->id));
}
break;
case CANV_TO:
@@ -2044,7 +2092,7 @@ CanvasWidgetCmd(
FIRST_CANVAS_ITEM_MATCHING(objv[2], &searchPtr, goto done);
if (itemPtr != NULL) {
Tcl_SetObjResult(interp,
- Tcl_NewStringObj(itemPtr->typePtr->name, -1));
+ Tcl_NewStringObj(itemPtr->typePtr->name, TCL_INDEX_NONE));
}
break;
case CANV_XVIEW: {
@@ -2052,7 +2100,6 @@ CanvasWidgetCmd(
int newX = 0; /* Initialization needed only to prevent gcc
* warnings. */
double fraction;
- const char **args;
if (objc == 2) {
Tcl_SetObjResult(interp, ScrollFractions(
@@ -2063,11 +2110,7 @@ CanvasWidgetCmd(
break;
}
- args = TkGetStringsFromObjs(objc, objv);
type = Tk_GetScrollInfoObj(interp, objc, objv, &fraction, &count);
- if (args != NULL) {
- ckfree(args);
- }
switch (type) {
case TK_SCROLL_MOVETO:
newX = canvasPtr->scrollX1 - canvasPtr->inset
@@ -2098,7 +2141,6 @@ CanvasWidgetCmd(
int newY = 0; /* Initialization needed only to prevent gcc
* warnings. */
double fraction;
- const char **args;
if (objc == 2) {
Tcl_SetObjResult(interp, ScrollFractions(
@@ -2109,11 +2151,7 @@ CanvasWidgetCmd(
break;
}
- args = TkGetStringsFromObjs(objc, objv);
type = Tk_GetScrollInfoObj(interp, objc, objv, &fraction, &count);
- if (args != NULL) {
- ckfree(args);
- }
switch (type) {
case TK_SCROLL_MOVETO:
newY = canvasPtr->scrollY1 - canvasPtr->inset + (int) (
@@ -2138,12 +2176,50 @@ CanvasWidgetCmd(
CanvasSetOrigin(canvasPtr, canvasPtr->xOrigin, newY);
break;
}
+ case CANV_IMAGE: {
+ Tk_PhotoHandle photohandle;
+ int subsample = 1, zoom = 1;
+
+ if (objc < 3 || objc > 5) {
+ Tcl_WrongNumArgs(interp, 2, objv, "imagename ?subsample? ?zoom?");
+ result = TCL_ERROR;
+ goto done;
+ }
+
+ if ((photohandle = Tk_FindPhoto(interp, Tcl_GetString(objv[2]) )) == 0) {
+ result = TCL_ERROR;
+ goto done;
+ }
+
+ /*
+ * If we are given a subsample or a zoom then grab them.
+ */
+
+ if (objc >= 4 && Tcl_GetIntFromObj(interp, objv[3], &subsample) != TCL_OK) {
+ result = TCL_ERROR;
+ goto done;
+ }
+ if (objc >= 5 && Tcl_GetIntFromObj(interp, objv[4], &zoom) != TCL_OK) {
+ result = TCL_ERROR;
+ goto done;
+ }
+
+ /*
+ * Set the image size to zero, which allows the DrawCanvas() function
+ * to expand the image automatically when it copies the pixmap into it.
+ */
+
+ if (Tk_PhotoSetSize(interp, photohandle, 0, 0) != TCL_OK) {
+ result = TCL_ERROR;
+ goto done;
+ }
+
+ result = DrawCanvas(interp, clientData, photohandle, subsample, zoom);
+ }
}
done:
-#ifndef USE_OLD_TAG_SEARCH
TagSearchDestroy(searchPtr);
-#endif /* not USE_OLD_TAG_SEARCH */
Tcl_Release(canvasPtr);
return result;
}
@@ -2168,13 +2244,15 @@ CanvasWidgetCmd(
static void
DestroyCanvas(
- char *memPtr) /* Info about canvas widget. */
+#if TCL_MAJOR_VERSION > 8
+ void *memPtr) /* Info about canvas widget. */
+#else
+ char *memPtr)
+#endif
{
TkCanvas *canvasPtr = (TkCanvas *)memPtr;
Tk_Item *itemPtr;
-#ifndef USE_OLD_TAG_SEARCH
TagSearchExpr *expr, *next;
-#endif
/*
* Free up all of the items in the canvas.
@@ -2199,19 +2277,17 @@ DestroyCanvas(
if (canvasPtr->pixmapGC != NULL) {
Tk_FreeGC(canvasPtr->display, canvasPtr->pixmapGC);
}
-#ifndef USE_OLD_TAG_SEARCH
expr = canvasPtr->bindTagExprs;
while (expr) {
next = expr->next;
TagSearchExprDestroy(expr);
expr = next;
}
-#endif /* USE_OLD_TAG_SEARCH */
Tcl_DeleteTimerHandler(canvasPtr->insertBlinkHandler);
if (canvasPtr->bindingTable != NULL) {
Tk_DeleteBindingTable(canvasPtr->bindingTable);
}
- Tk_FreeOptions(configSpecs, (char *) canvasPtr, canvasPtr->display, 0);
+ Tk_FreeOptions(configSpecs, canvasPtr, canvasPtr->display, 0);
canvasPtr->tkwin = NULL;
ckfree(canvasPtr);
}
@@ -2241,7 +2317,7 @@ ConfigureCanvas(
Tcl_Interp *interp, /* Used for error reporting. */
TkCanvas *canvasPtr, /* Information about widget; may or may not
* already have values for some fields. */
- int objc, /* Number of valid entries in objv. */
+ Tcl_Size objc, /* Number of valid entries in objv. */
Tcl_Obj *const objv[], /* Argument objects. */
int flags) /* Flags to pass to Tk_ConfigureWidget. */
{
@@ -2323,7 +2399,7 @@ ConfigureCanvas(
canvasPtr->scrollX2 = 0;
canvasPtr->scrollY2 = 0;
if (canvasPtr->regionString != NULL) {
- int argc2;
+ Tcl_Size argc2;
const char **argv2;
if (Tcl_SplitList(canvasPtr->interp, canvasPtr->regionString,
@@ -2333,7 +2409,7 @@ ConfigureCanvas(
if (argc2 != 4) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad scrollRegion \"%s\"", canvasPtr->regionString));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "SCROLL_REGION", NULL);
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "SCROLL_REGION", (char *)NULL);
badRegion:
ckfree(canvasPtr->regionString);
ckfree(argv2);
@@ -2405,7 +2481,7 @@ ConfigureCanvas(
static void
CanvasWorldChanged(
- ClientData instanceData) /* Information about widget. */
+ void *instanceData) /* Information about widget. */
{
TkCanvas *canvasPtr = (TkCanvas *)instanceData;
Tk_Item *itemPtr;
@@ -2426,6 +2502,537 @@ CanvasWorldChanged(
/*
*----------------------------------------------------------------------
*
+ * DecomposeMaskToShiftAndBits --
+ *
+ * Given a 32 bit pixel mask, we find the position of the lowest bit and the
+ * width of the mask bits.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+* None.
+ *
+ *----------------------------------------------------------------------
+ */
+static void
+DecomposeMaskToShiftAndBits(
+ unsigned int mask, /* The pixel mask to examine */
+ int *shift, /* Where to put the shift count (position of lowest bit) */
+ int *bits) /* Where to put the bit count (width of the pixel mask) */
+{
+ int i;
+
+ *shift = 0;
+ *bits = 0;
+
+ /*
+ * Find the lowest '1' bit in the mask.
+ */
+
+ for (i = 0; i < 32; ++i) {
+ if (mask & 1 << i)
+ break;
+ }
+ if (i < 32) {
+ *shift = i;
+
+ /*
+ * Now find the next '0' bit and the width of the mask.
+ */
+
+ for ( ; i < 32; ++i) {
+ if ((mask & 1 << i) == 0)
+ break;
+ else
+ ++*bits;
+ }
+
+ /*
+ * Limit to the top 8 bits if the mask was wider than 8.
+ */
+
+ if (*bits > 8) {
+ *shift += *bits - 8;
+ *bits = 8;
+ }
+ }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * DrawCanvas --
+ *
+ * This function draws the contents of a canvas into the given Photo image.
+ * This function is called from the widget "image" subcommand.
+ * The canvas does not need to be mapped (one of it's ancestors must be)
+ * in order for this function to work.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Canvas contents from within the -scrollregion or widget size are rendered
+ * into the Photo. Any errors are left in the result.
+ *
+ *----------------------------------------------------------------------
+ */
+
+#define OVERDRAW_PIXELS 32 /* How much larger we make the pixmap
+ * that the canvas objects are drawn into */
+
+#ifdef WORDS_BIGENDIAN
+#define IS_BIG_ENDIAN 1
+#else
+#define IS_BIG_ENDIAN 0
+#endif
+
+#define BYTE_SWAP16(n) ((((unsigned short)n)>>8) | (((unsigned short)n)<<8))
+#define BYTE_SWAP32(n) (((n>>24)&0x000000FF) | ((n<<8)&0x00FF0000) | ((n>>8)&0x0000FF00) | ((n<<24)&0xFF000000))
+
+static int
+DrawCanvas(
+ Tcl_Interp *interp, /* As passed to the widget command, and we will leave errors here */
+ void *clientData,
+ Tk_PhotoHandle photohandle, /* The photo we are rendering into */
+ int subsample, /* If either subsample or zoom are not 1 then we call Tk_PhotoPutZoomedBlock() */
+ int zoom)
+{
+ TkCanvas *canvasPtr = (TkCanvas *)clientData;
+ Tk_Window tkwin;
+ Display *displayPtr;
+ Tk_PhotoImageBlock blockPtr = {0,0,0,0,0,{0,0,0,0}};
+ Window wid;
+ Tk_Item *itemPtr;
+ Pixmap pixmap = 0;
+ XImage *ximagePtr = NULL;
+ Visual *visualPtr;
+ GC xgc = 0;
+ XGCValues xgcValues;
+ int canvasX1, canvasY1, canvasX2, canvasY2, cWidth, cHeight,
+ pixmapX1, pixmapY1, pixmapX2, pixmapY2, pmWidth, pmHeight,
+ bitsPerPixel, bytesPerPixel, x, y, result = TCL_OK,
+ rshift, gshift, bshift, rbits, gbits, bbits;
+
+#ifdef DEBUG_DRAWCANVAS
+ char buffer[128];
+#endif
+
+ if ((tkwin = canvasPtr->tkwin) == NULL) {
+ Tcl_AppendResult(interp, "canvas tkwin is NULL!", (char *)NULL);
+ result = TCL_ERROR;
+ goto done;
+ }
+
+ /*
+ * If this canvas is unmapped, then we won't have a window id, so we will
+ * try the ancestors of the canvas until we find a window that has a
+ * valid window id. The Tk_GetPixmap() call requires a valid window id.
+ */
+
+ do {
+
+ if ((displayPtr = Tk_Display(tkwin)) == NULL) {
+ Tcl_AppendResult(interp, "canvas (or parent) display is NULL!", (char *)NULL);
+ result = TCL_ERROR;
+ goto done;
+ }
+
+ if ((wid = Tk_WindowId(tkwin)) != 0) {
+ continue;
+ }
+
+ if ((tkwin = Tk_Parent(tkwin)) == NULL) {
+ Tcl_AppendResult(interp, "canvas has no parent with a valid window id! Is the toplevel window mapped?", (char *)NULL);
+ result = TCL_ERROR;
+ goto done;
+ }
+
+ } while (wid == 0);
+
+ bitsPerPixel = Tk_Depth(tkwin);
+ visualPtr = Tk_Visual(tkwin);
+
+ if (subsample == 0) {
+ Tcl_AppendResult(interp, "subsample cannot be zero", (char *)NULL);
+ result = TCL_ERROR;
+ goto done;
+ }
+
+ /*
+ * Scan through the item list, registering the bounding box for all items
+ * that didn't do that for the final coordinates yet. This can be
+ * determined by the FORCE_REDRAW flag.
+ */
+
+ for (itemPtr = canvasPtr -> firstItemPtr; itemPtr != NULL;
+ itemPtr = itemPtr -> nextPtr) {
+ if (itemPtr -> redraw_flags & FORCE_REDRAW) {
+ itemPtr -> redraw_flags &= ~FORCE_REDRAW;
+ EventuallyRedrawItem(canvasPtr, itemPtr);
+ itemPtr -> redraw_flags &= ~FORCE_REDRAW;
+ }
+ }
+
+ /*
+ * The DisplayCanvas() function works out the region that needs redrawing,
+ * but we don't do this. We grab the whole scrollregion or canvas window
+ * area. If we have a defined -scrollregion we use that as the drawing
+ * region, otherwise use the canvas window height and width with an origin
+ * of 0,0.
+ */
+ if (canvasPtr->scrollX1 != 0 || canvasPtr->scrollY1 != 0 ||
+ canvasPtr->scrollX2 != 0 || canvasPtr->scrollY2 != 0) {
+
+ canvasX1 = canvasPtr->scrollX1;
+ canvasY1 = canvasPtr->scrollY1;
+ canvasX2 = canvasPtr->scrollX2;
+ canvasY2 = canvasPtr->scrollY2;
+ cWidth = canvasX2 - canvasX1 + 1;
+ cHeight = canvasY2 - canvasY1 + 1;
+
+ } else {
+
+ cWidth = Tk_Width(tkwin);
+ cHeight = Tk_Height(tkwin);
+ canvasX1 = 0;
+ canvasY1 = 0;
+ canvasX2 = canvasX1 + cWidth - 1;
+ canvasY2 = canvasY1 + cHeight - 1;
+ }
+
+ /*
+ * Allocate a pixmap to draw into. We add OVERDRAW_PIXELS in the same way
+ * that DisplayCanvas() does to avoid problems on some systems when objects
+ * are being drawn too close to the edge.
+ */
+
+ pixmapX1 = canvasX1 - OVERDRAW_PIXELS;
+ pixmapY1 = canvasY1 - OVERDRAW_PIXELS;
+ pixmapX2 = canvasX2 + OVERDRAW_PIXELS;
+ pixmapY2 = canvasY2 + OVERDRAW_PIXELS;
+ pmWidth = pixmapX2 - pixmapX1 + 1;
+ pmHeight = pixmapY2 - pixmapY1 + 1;
+ if ((pixmap = Tk_GetPixmap(displayPtr, Tk_WindowId(tkwin), pmWidth, pmHeight,
+ bitsPerPixel)) == 0) {
+ Tcl_AppendResult(interp, "failed to create drawing Pixmap", (char *)NULL);
+ result = TCL_ERROR;
+ goto done;
+ }
+
+ /*
+ * Before we can draw the canvas objects into the pixmap it's background
+ * should be filled with canvas background colour.
+ */
+
+ xgcValues.function = GXcopy;
+ xgcValues.foreground = Tk_3DBorderColor(canvasPtr->bgBorder)->pixel;
+ xgc = XCreateGC(displayPtr, pixmap, GCFunction|GCForeground, &xgcValues);
+ XFillRectangle(displayPtr,pixmap,xgc,0,0,pmWidth,pmHeight);
+
+ /*
+ * Draw all the cavas items into the pixmap
+ */
+
+ canvasPtr->drawableXOrigin = pixmapX1;
+ canvasPtr->drawableYOrigin = pixmapY1;
+ for (itemPtr = canvasPtr->firstItemPtr; itemPtr != NULL;
+ itemPtr = itemPtr->nextPtr) {
+ if ((itemPtr->x1 >= pixmapX2) || (itemPtr->y1 >= pixmapY2) ||
+ (itemPtr->x2 < pixmapX1) || (itemPtr->y2 < pixmapY1)) {
+ if (!AlwaysRedraw(itemPtr)) {
+ continue;
+ }
+ }
+ if (itemPtr->state == TK_STATE_HIDDEN ||
+ (itemPtr->state == TK_STATE_NULL && canvasPtr->canvas_state
+ == TK_STATE_HIDDEN)) {
+ continue;
+ }
+ ItemDisplay(canvasPtr, itemPtr, pixmap, pixmapX1, pixmapY1, pmWidth,
+ pmHeight);
+ }
+
+ /*
+ * Copy the Pixmap into an ZPixmap format XImage so we can copy it across
+ * to the photo image. This seems to be the only way to get Pixmap image
+ * data out of an image. Note we have to account for the OVERDRAW_PIXELS
+ * border width.
+ */
+
+ if ((ximagePtr = XGetImage(displayPtr, pixmap, -pixmapX1, -pixmapY1, cWidth,
+ cHeight, AllPlanes, ZPixmap)) == NULL) {
+ Tcl_AppendResult(interp, "failed to copy Pixmap to XImage", (char *)NULL);
+ result = TCL_ERROR;
+ goto done;
+ }
+
+#ifdef DEBUG_DRAWCANVAS
+ Tcl_AppendResult(interp, "ximagePtr {", (char *)NULL);
+ snprintf(buffer,sizeof(buffer),"%d",ximagePtr->width); Tcl_AppendResult(interp, " width ", buffer, (char *)NULL);
+ snprintf(buffer,sizeof(buffer),"%d",ximagePtr->height); Tcl_AppendResult(interp, " height ", buffer, (char *)NULL);
+ snprintf(buffer,sizeof(buffer),"%d",ximagePtr->xoffset); Tcl_AppendResult(interp, " xoffset ", buffer, (char *)NULL);
+ snprintf(buffer,sizeof(buffer),"%d",ximagePtr->format); Tcl_AppendResult(interp, " format ", buffer, (char *)NULL);
+ Tcl_AppendResult(interp, " ximagePtr->data", (char *)NULL);
+ if (ximagePtr->data != NULL) {
+ int ix, iy;
+
+ Tcl_AppendResult(interp, " {", (char *)NULL);
+ for (iy = 0; iy < ximagePtr->height; ++ iy) {
+ Tcl_AppendResult(interp, " {", (char *)NULL);
+ for (ix = 0; ix < ximagePtr->bytes_per_line; ++ ix) {
+ if (ix > 0) {
+ if (ix % 4 == 0)
+ Tcl_AppendResult(interp, "-", (char *)NULL);
+ else
+ Tcl_AppendResult(interp, " ", (char *)NULL);
+ }
+ snprintf(buffer,sizeof(buffer),"%2.2x",ximagePtr->data[ximagePtr->bytes_per_line * iy + ix]&0xFF);
+ Tcl_AppendResult(interp, buffer, (char *)NULL);
+ }
+ Tcl_AppendResult(interp, " }", (char *)NULL);
+ }
+ Tcl_AppendResult(interp, " }", (char *)NULL);
+ } else
+ snprintf(buffer,sizeof(buffer)," NULL");
+ snprintf(buffer,sizeof(buffer),"%d",ximagePtr->byte_order); Tcl_AppendResult(interp, " byte_order ", buffer, (char *)NULL);
+ snprintf(buffer,sizeof(buffer),"%d",ximagePtr->bitmap_unit); Tcl_AppendResult(interp, " bitmap_unit ", buffer, (char *)NULL);
+ snprintf(buffer,sizeof(buffer),"%d",ximagePtr->bitmap_bit_order); Tcl_AppendResult(interp, " bitmap_bit_order ", buffer, (char *)NULL);
+ snprintf(buffer,sizeof(buffer),"%d",ximagePtr->bitmap_pad); Tcl_AppendResult(interp, " bitmap_pad ", buffer, (char *)NULL);
+ snprintf(buffer,sizeof(buffer),"%d",ximagePtr->depth); Tcl_AppendResult(interp, " depth ", buffer, (char *)NULL);
+ snprintf(buffer,sizeof(buffer),"%d",ximagePtr->bytes_per_line); Tcl_AppendResult(interp, " bytes_per_line ", buffer, (char *)NULL);
+ snprintf(buffer,sizeof(buffer),"%d",ximagePtr->bits_per_pixel); Tcl_AppendResult(interp, " bits_per_pixel ", buffer, (char *)NULL);
+ snprintf(buffer,sizeof(buffer),"0x%8.8lx",ximagePtr->red_mask); Tcl_AppendResult(interp, " red_mask ", buffer, (char *)NULL);
+ snprintf(buffer,sizeof(buffer),"0x%8.8lx",ximagePtr->green_mask); Tcl_AppendResult(interp, " green_mask ", buffer, (char *)NULL);
+ snprintf(buffer,sizeof(buffer),"0x%8.8lx",ximagePtr->blue_mask); Tcl_AppendResult(interp, " blue_mask ", buffer, (char *)NULL);
+ Tcl_AppendResult(interp, " }", (char *)NULL);
+
+ Tcl_AppendResult(interp, "\nvisualPtr {", (char *)NULL);
+ snprintf(buffer,sizeof(buffer),"0x%8.8lx",visualPtr->red_mask); Tcl_AppendResult(interp, " red_mask ", buffer, (char *)NULL);
+ snprintf(buffer,sizeof(buffer),"0x%8.8lx",visualPtr->green_mask); Tcl_AppendResult(interp, " green_mask ", buffer, (char *)NULL);
+ snprintf(buffer,sizeof(buffer),"0x%8.8lx",visualPtr->blue_mask); Tcl_AppendResult(interp, " blue_mask ", buffer, (char *)NULL);
+ Tcl_AppendResult(interp, " }", (char *)NULL);
+
+#endif
+
+ /*
+ * Fill in the PhotoImageBlock structure abd allocate a block of memory
+ * for the converted image data. Note we allocate an alpha channel even
+ * though we don't use one, because this layout helps Tk_PhotoPutBlock()
+ * use memcpy() instead of the slow pixel or line copy.
+ */
+
+ blockPtr.width = cWidth;
+ blockPtr.height = cHeight;
+ blockPtr.pixelSize = 4;
+ blockPtr.pitch = blockPtr.pixelSize * blockPtr.width;
+
+#ifdef TK_XGETIMAGE_USES_ABGR32
+ blockPtr.offset[0] = 1;
+ blockPtr.offset[1] = 2;
+ blockPtr.offset[2] = 3;
+ blockPtr.offset[3] = 0;
+#else
+ blockPtr.offset[0] = 0;
+ blockPtr.offset[1] = 1;
+ blockPtr.offset[2] = 2;
+ blockPtr.offset[3] = 3;
+#endif
+
+ blockPtr.pixelPtr = (unsigned char *)ckalloc(blockPtr.pixelSize * blockPtr.height * blockPtr.width);
+
+ /*
+ * Now convert the image data pixel by pixel from XImage to 32bit RGBA
+ * format suitable for Tk_PhotoPutBlock().
+ */
+
+ DecomposeMaskToShiftAndBits(visualPtr->red_mask,&rshift,&rbits);
+ DecomposeMaskToShiftAndBits(visualPtr->green_mask,&gshift,&gbits);
+ DecomposeMaskToShiftAndBits(visualPtr->blue_mask,&bshift,&bbits);
+
+#ifdef DEBUG_DRAWCANVAS
+ snprintf(buffer,sizeof(buffer),"%d",rshift); Tcl_AppendResult(interp, "\nbits { rshift ", buffer, (char *)NULL);
+ snprintf(buffer,sizeof(buffer),"%d",gshift); Tcl_AppendResult(interp, " gshift ", buffer, (char *)NULL);
+ snprintf(buffer,sizeof(buffer),"%d",bshift); Tcl_AppendResult(interp, " bshift ", buffer, (char *)NULL);
+ snprintf(buffer,sizeof(buffer),"%d",rbits); Tcl_AppendResult(interp, " rbits ", buffer, (char *)NULL);
+ snprintf(buffer,sizeof(buffer),"%d",gbits); Tcl_AppendResult(interp, " gbits ", buffer, (char *)NULL);
+ snprintf(buffer,sizeof(buffer),"%d",bbits); Tcl_AppendResult(interp, " bbits ", buffer, " }", (char *)NULL);
+ Tcl_AppendResult(interp, "\nConverted_image {", (char *)NULL);
+#endif
+
+ /* Ok, had to use ximagePtr->bits_per_pixel here and in the switch (...)
+ * below to get this to work on Windows. X11 correctly sets the bitmap
+ *_pad and bitmap_unit fields to 32, but on Windows they are 0 and 8
+ * respectively!
+ */
+
+ bytesPerPixel = ximagePtr->bits_per_pixel/8;
+ for (y = 0; y < blockPtr.height; ++y) {
+
+#ifdef DEBUG_DRAWCANVAS
+ Tcl_AppendResult(interp, " {", (char *)NULL);
+#endif
+
+ for(x = 0; x < blockPtr.width; ++x) {
+ unsigned int pixel = 0;
+ int pixel_offset = blockPtr.pitch * y + blockPtr.pixelSize * x;
+ switch (ximagePtr->bits_per_pixel) {
+
+ /*
+ * Get an 8 bit pixel from the XImage.
+ */
+
+ case 8 :
+ pixel = *((unsigned char *)(ximagePtr->data + bytesPerPixel * x
+ + ximagePtr->bytes_per_line * y));
+ break;
+
+ /*
+ * Get a 16 bit pixel from the XImage, and correct the
+ * byte order as necessary.
+ */
+
+ case 16 :
+ pixel = *((unsigned short *)(ximagePtr->data + bytesPerPixel * x
+ + ximagePtr->bytes_per_line * y));
+ if ((IS_BIG_ENDIAN && ximagePtr->byte_order == LSBFirst)
+ || (!IS_BIG_ENDIAN && ximagePtr->byte_order == MSBFirst))
+ pixel = BYTE_SWAP16(pixel);
+ break;
+
+ /*
+ * Grab a 32 bit pixel from the XImage, and correct the
+ * byte order as necessary.
+ */
+
+ case 32 :
+ pixel = *((unsigned int *)(ximagePtr->data + bytesPerPixel * x
+ + ximagePtr->bytes_per_line * y));
+ if ((IS_BIG_ENDIAN && ximagePtr->byte_order == LSBFirst)
+ || (!IS_BIG_ENDIAN && ximagePtr->byte_order == MSBFirst))
+ pixel = BYTE_SWAP32(pixel);
+ break;
+ }
+
+ /*
+ * We have a pixel with the correct byte order, so pull out the
+ * colours and place them in the photo block. Perhaps we could
+ * just not bother with the alpha byte because we are using
+ * TK_PHOTO_COMPOSITE_SET later?
+ * ***Windows: We have to swap the red and blue values. The
+ * XImage storage is B - G - R - A which becomes a 32bit ARGB
+ * quad. However the visual mask is a 32bit ABGR quad. And
+ * Tk_PhotoPutBlock() wants R-G-B-A which is a 32bit ABGR quad.
+ * If the visual mask was correct there would be no need to
+ * swap anything here.
+ */
+
+#ifdef _WIN32
+#define R_OFFSET blockPtr.offset[2]
+#define G_OFFSET blockPtr.offset[1]
+#define B_OFFSET blockPtr.offset[0]
+#define A_OFFSET blockPtr.offset[3]
+#else
+#define R_OFFSET blockPtr.offset[0]
+#define G_OFFSET blockPtr.offset[1]
+#define B_OFFSET blockPtr.offset[2]
+#define A_OFFSET blockPtr.offset[3]
+#endif
+#ifdef TK_XGETIMAGE_USES_ABGR32
+#define COPY_PIXEL (ximagePtr->bits_per_pixel == 32)
+#else
+#define COPY_PIXEL 0
+#endif
+
+ if (COPY_PIXEL) {
+ /*
+ * This platform packs pixels in RGBA byte order, as expected
+ * by Tk_PhotoPutBlock() so we can just copy the pixel as an int.
+ */
+ *((unsigned int *) (blockPtr.pixelPtr + pixel_offset)) = pixel;
+ } else {
+ blockPtr.pixelPtr[pixel_offset + R_OFFSET] =
+ (unsigned char)((pixel & visualPtr->red_mask) >> rshift);
+ blockPtr.pixelPtr[pixel_offset + G_OFFSET] =
+ (unsigned char)((pixel & visualPtr->green_mask) >> gshift);
+ blockPtr.pixelPtr[pixel_offset + B_OFFSET] =
+ (unsigned char)((pixel & visualPtr->blue_mask) >> bshift);
+ blockPtr.pixelPtr[pixel_offset + A_OFFSET] = 0xFF;
+ }
+
+#ifdef DEBUG_DRAWCANVAS
+ fprintf(stderr, "Converted pixel %x to %hhx %hhx %hhx %hhx \n",
+ pixel,
+ blockPtr.pixelPtr[pixel_offset + 0],
+ blockPtr.pixelPtr[pixel_offset + 1],
+ blockPtr.pixelPtr[pixel_offset + 2],
+ blockPtr.pixelPtr[pixel_offset + 3]);
+ {
+ int ix;
+ if (x > 0)
+ Tcl_AppendResult(interp, "-", (char *)NULL);
+ for (ix = 0; ix < 4; ++ix) {
+ if (ix > 0)
+ Tcl_AppendResult(interp, " ", (char *)NULL);
+ snprintf(buffer,sizeof(buffer),"%2.2x",
+ blockPtr.pixelPtr[blockPtr.pitch * y
+ + blockPtr.pixelSize * x + ix]&0xFF);
+ Tcl_AppendResult(interp, buffer, (char *)NULL);
+ }
+ }
+#endif
+
+ }
+
+#ifdef DEBUG_DRAWCANVAS
+ Tcl_AppendResult(interp, " }", (char *)NULL);
+#endif
+
+ }
+
+#ifdef DEBUG_DRAWCANVAS
+ Tcl_AppendResult(interp, " }", (char *)NULL);
+#endif
+
+ /*
+ * Now put the copied pixmap into the photo.
+ * If either zoom or subsample are not 1, we use the zoom function.
+ */
+
+ if (subsample != 1 || zoom != 1) {
+ if ((result = Tk_PhotoPutZoomedBlock(interp, photohandle, &blockPtr,
+ 0, 0, cWidth * zoom / subsample, cHeight * zoom / subsample,
+ zoom, zoom, subsample, subsample, TK_PHOTO_COMPOSITE_SET))
+ != TCL_OK) {
+ goto done;
+ }
+ } else {
+ if ((result = Tk_PhotoPutBlock(interp, photohandle, &blockPtr, 0, 0,
+ cWidth, cHeight, TK_PHOTO_COMPOSITE_SET)) != TCL_OK) {
+ goto done;
+ }
+ }
+
+ /*
+ * Clean up anything we have allocated and exit.
+ */
+
+done:
+ if (blockPtr.pixelPtr)
+ ckfree(blockPtr.pixelPtr);
+ if (pixmap)
+ Tk_FreePixmap(Tk_Display(tkwin), pixmap);
+ if (ximagePtr)
+ XDestroyImage(ximagePtr);
+ if (xgc)
+ XFreeGC(displayPtr,xgc);
+ return result;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* DisplayCanvas --
*
* This function redraws the contents of a canvas window. It is invoked
@@ -2443,7 +3050,7 @@ CanvasWorldChanged(
static void
DisplayCanvas(
- ClientData clientData) /* Information about widget. */
+ void *clientData) /* Information about widget. */
{
TkCanvas *canvasPtr = (TkCanvas *)clientData;
Tk_Window tkwin = canvasPtr->tkwin;
@@ -2576,7 +3183,7 @@ DisplayCanvas(
canvasPtr->drawableXOrigin = canvasPtr->xOrigin;
canvasPtr->drawableYOrigin = canvasPtr->yOrigin;
pixmap = Tk_WindowId(tkwin);
- TkpClipDrawableToRect(Tk_Display(tkwin), pixmap,
+ Tk_ClipDrawableToRect(Tk_Display(tkwin), pixmap,
screenX1 - canvasPtr->xOrigin, screenY1 - canvasPtr->yOrigin,
width, height);
#endif /* TK_NO_DOUBLE_BUFFERING */
@@ -2635,7 +3242,7 @@ DisplayCanvas(
screenX1 - canvasPtr->xOrigin, screenY1 - canvasPtr->yOrigin);
Tk_FreePixmap(Tk_Display(tkwin), pixmap);
#else
- TkpClipDrawableToRect(Tk_Display(tkwin), pixmap, 0, 0, -1, -1);
+ Tk_ClipDrawableToRect(Tk_Display(tkwin), pixmap, 0, 0, -1, -1);
#endif /* TK_NO_DOUBLE_BUFFERING */
}
@@ -2654,7 +3261,7 @@ DisplayCanvas(
Tk_Height(tkwin) - 2*canvasPtr->highlightWidth,
canvasPtr->borderWidth, canvasPtr->relief);
}
- if (canvasPtr->highlightWidth != 0) {
+ if (canvasPtr->highlightWidth > 0) {
GC fgGC, bgGC;
bgGC = Tk_GCForColor(canvasPtr->highlightBgColorPtr,
@@ -2662,10 +3269,10 @@ DisplayCanvas(
if (canvasPtr->textInfo.gotFocus) {
fgGC = Tk_GCForColor(canvasPtr->highlightColorPtr,
Tk_WindowId(tkwin));
- TkpDrawHighlightBorder(tkwin, fgGC, bgGC,
+ Tk_DrawHighlightBorder(tkwin, fgGC, bgGC,
canvasPtr->highlightWidth, Tk_WindowId(tkwin));
} else {
- TkpDrawHighlightBorder(tkwin, bgGC, bgGC,
+ Tk_DrawHighlightBorder(tkwin, bgGC, bgGC,
canvasPtr->highlightWidth, Tk_WindowId(tkwin));
}
}
@@ -2700,7 +3307,7 @@ DisplayCanvas(
static void
CanvasEventProc(
- ClientData clientData, /* Information about window. */
+ void *clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
TkCanvas *canvasPtr = (TkCanvas *)clientData;
@@ -2791,7 +3398,7 @@ CanvasEventProc(
static void
CanvasCmdDeletedProc(
- ClientData clientData) /* Pointer to widget record for widget. */
+ void *clientData) /* Pointer to widget record for widget. */
{
TkCanvas *canvasPtr = (TkCanvas *)clientData;
Tk_Window tkwin = canvasPtr->tkwin;
@@ -3061,208 +3668,6 @@ InitCanvas(void)
Tcl_MutexUnlock(&typeListMutex);
}
-#ifdef USE_OLD_TAG_SEARCH
-/*
- *--------------------------------------------------------------
- *
- * StartTagSearch --
- *
- * This function 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(
- TkCanvas *canvasPtr, /* Canvas whose items are to be searched. */
- Tcl_Obj *tagObj, /* Object giving tag value. */
- TagSearch *searchPtr) /* Record describing tag search; will be
- * initialized here. */
-{
- int id;
- Tk_Item *itemPtr, *lastPtr;
- Tk_Uid *tagPtr;
- Tk_Uid uid;
- char *tag = Tcl_GetString(tagObj);
- int count;
- TkWindow *tkwin = (TkWindow *) canvasPtr->tkwin;
- TkDisplay *dispPtr = tkwin->dispPtr;
-
- /*
- * 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;
- Tcl_HashEntry *entryPtr;
-
- dispPtr->numIdSearches++;
- id = strtoul(tag, &end, 0);
- if (*end == 0) {
- itemPtr = canvasPtr->hotPtr;
- lastPtr = canvasPtr->hotPrevPtr;
- if ((itemPtr == NULL) || (itemPtr->id != id) || (lastPtr == NULL)
- || (lastPtr->nextPtr != itemPtr)) {
- dispPtr->numSlowSearches++;
- entryPtr = Tcl_FindHashEntry(&canvasPtr->idTable, (char*) id);
- if (entryPtr != NULL) {
- itemPtr = Tcl_GetHashValue(entryPtr);
- lastPtr = itemPtr->prevPtr;
- } else {
- lastPtr = itemPtr = NULL;
- }
- }
- searchPtr->lastPtr = lastPtr;
- searchPtr->searchOver = 1;
- canvasPtr->hotPtr = itemPtr;
- canvasPtr->hotPrevPtr = lastPtr;
- return itemPtr;
- }
- }
-
- searchPtr->tag = uid = Tk_GetUid(tag);
- if (uid == Tk_GetUid("all")) {
- /*
- * All items match.
- */
-
- searchPtr->tag = NULL;
- searchPtr->lastPtr = NULL;
- searchPtr->currentPtr = canvasPtr->firstItemPtr;
- return canvasPtr->firstItemPtr;
- }
-
- /*
- * None of the above. Search for an item with a matching tag.
- */
-
- for (lastPtr = NULL, itemPtr = canvasPtr->firstItemPtr; itemPtr != NULL;
- lastPtr = itemPtr, itemPtr = itemPtr->nextPtr) {
- for (tagPtr = itemPtr->tagPtr, count = itemPtr->numTags;
- count > 0; tagPtr++, count--) {
- if (*tagPtr == uid) {
- searchPtr->lastPtr = lastPtr;
- searchPtr->currentPtr = itemPtr;
- return itemPtr;
- }
- }
- }
- searchPtr->lastPtr = lastPtr;
- searchPtr->searchOver = 1;
- return NULL;
-}
-
-/*
- *--------------------------------------------------------------
- *
- * NextItem --
- *
- * This function 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 function will
- * return the next item.
- *
- * Side effects:
- * None.
- *
- *--------------------------------------------------------------
- */
-
-static Tk_Item *
-NextItem(
- TagSearch *searchPtr) /* Record describing search in progress. */
-{
- Tk_Item *itemPtr, *lastPtr;
- 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.
- */
-
- lastPtr = searchPtr->lastPtr;
- if (lastPtr == NULL) {
- itemPtr = searchPtr->canvasPtr->firstItemPtr;
- } else {
- itemPtr = lastPtr->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 lastPtr; just return its new successor (i.e. do nothing
- * here).
- */
- } else {
- lastPtr = itemPtr;
- itemPtr = lastPtr->nextPtr;
- }
-
- /*
- * Handle special case of "all" search by returning next item.
- */
-
- uid = searchPtr->tag;
- if (uid == NULL) {
- searchPtr->lastPtr = lastPtr;
- searchPtr->currentPtr = itemPtr;
- return itemPtr;
- }
-
- /*
- * Look for an item with a particular tag.
- */
-
- for ( ; itemPtr != NULL; lastPtr = itemPtr, itemPtr = itemPtr->nextPtr) {
- for (tagPtr = itemPtr->tagPtr, count = itemPtr->numTags;
- count > 0; tagPtr++, count--) {
- if (*tagPtr == uid) {
- searchPtr->lastPtr = lastPtr;
- searchPtr->currentPtr = itemPtr;
- return itemPtr;
- }
- }
- }
- searchPtr->lastPtr = lastPtr;
- searchPtr->searchOver = 1;
- return NULL;
-}
-
-#else /* !USE_OLD_TAG_SEARCH */
/*
*----------------------------------------------------------------------
*
@@ -3631,9 +4036,9 @@ TagSearchScanExpr(
case '!': /* Negate next tag or subexpr */
if (looking_for_tag > 1) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "too many '!' in tag search expression", -1));
+ "too many '!' in tag search expression", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "CANVAS", "SEARCH",
- "COMPLEXITY", NULL);
+ "COMPLEXITY", (char *)NULL);
return TCL_ERROR;
}
looking_for_tag++;
@@ -3681,17 +4086,17 @@ TagSearchScanExpr(
}
if (!found_endquote) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "missing endquote in tag search expression", -1));
+ "missing endquote in tag search expression", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "CANVAS", "SEARCH",
- "ENDQUOTE", NULL);
+ "ENDQUOTE", (char *)NULL);
return TCL_ERROR;
}
if (!(tag - searchPtr->rewritebuffer)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"null quoted tag string in tag search expression",
- -1));
+ TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "CANVAS", "SEARCH",
- "EMPTY", NULL);
+ "EMPTY", (char *)NULL);
return TCL_ERROR;
}
*tag++ = '\0';
@@ -3706,9 +4111,9 @@ TagSearchScanExpr(
case '^':
case ')':
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "unexpected operator in tag search expression", -1));
+ "unexpected operator in tag search expression", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "CANVAS", "SEARCH",
- "UNEXPECTED", NULL);
+ "UNEXPECTED", (char *)NULL);
return TCL_ERROR;
default: /* Unquoted tag string */
@@ -3770,9 +4175,9 @@ TagSearchScanExpr(
c = searchPtr->string[searchPtr->stringIndex++];
if (c != '&') {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "singleton '&' in tag search expression", -1));
+ "singleton '&' in tag search expression", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "CANVAS", "SEARCH",
- "INCOMPLETE_OP", NULL);
+ "INCOMPLETE_OP", (char *)NULL);
return TCL_ERROR;
}
expr->uids[expr->index++] = searchUids->andUid;
@@ -3783,9 +4188,9 @@ TagSearchScanExpr(
c = searchPtr->string[searchPtr->stringIndex++];
if (c != '|') {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "singleton '|' in tag search expression", -1));
+ "singleton '|' in tag search expression", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "CANVAS", "SEARCH",
- "INCOMPLETE_OP", NULL);
+ "INCOMPLETE_OP", (char *)NULL);
return TCL_ERROR;
}
expr->uids[expr->index++] = searchUids->orUid;
@@ -3804,9 +4209,9 @@ TagSearchScanExpr(
default: /* syntax error */
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"invalid boolean operator in tag search expression",
- -1));
+ TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "CANVAS", "SEARCH", "BAD_OP",
- NULL);
+ (char *)NULL);
return TCL_ERROR;
}
}
@@ -3817,8 +4222,8 @@ TagSearchScanExpr(
return TCL_OK;
}
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "missing tag in tag search expression", -1));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "SEARCH", "NO_TAG", NULL);
+ "missing tag in tag search expression", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "SEARCH", "NO_TAG", (char *)NULL);
return TCL_ERROR;
}
@@ -3873,7 +4278,7 @@ TagSearchEvalExpr(
* set result 1 if tag is found in item's tags
*/
- for (tagPtr = itemPtr->tagPtr, count = itemPtr->numTags;
+ for (tagPtr = itemPtr->tagPtr, count = (int)itemPtr->numTags;
count > 0; tagPtr++, count--) {
if (*tagPtr == uid) {
result = 1;
@@ -3893,7 +4298,7 @@ TagSearchEvalExpr(
* set result 1 if tag is found in item's tags.
*/
- for (tagPtr = itemPtr->tagPtr, count = itemPtr->numTags;
+ for (tagPtr = itemPtr->tagPtr, count = (int)itemPtr->numTags;
count > 0; tagPtr++, count--) {
if (*tagPtr == uid) {
result = 1;
@@ -4059,7 +4464,7 @@ TagSearchFirst(
uid = searchPtr->expr->uid;
for (lastPtr = NULL, itemPtr = searchPtr->canvasPtr->firstItemPtr;
itemPtr != NULL; lastPtr=itemPtr, itemPtr=itemPtr->nextPtr) {
- for (tagPtr = itemPtr->tagPtr, count = itemPtr->numTags;
+ for (tagPtr = itemPtr->tagPtr, count = (int)itemPtr->numTags;
count > 0; tagPtr++, count--) {
if (*tagPtr == uid) {
searchPtr->lastPtr = lastPtr;
@@ -4161,7 +4566,7 @@ TagSearchNext(
uid = searchPtr->expr->uid;
for (; itemPtr != NULL; lastPtr = itemPtr, itemPtr = itemPtr->nextPtr) {
- for (tagPtr = itemPtr->tagPtr, count = itemPtr->numTags;
+ for (tagPtr = itemPtr->tagPtr, count = (int)itemPtr->numTags;
count > 0; tagPtr++, count--) {
if (*tagPtr == uid) {
searchPtr->lastPtr = lastPtr;
@@ -4191,7 +4596,6 @@ TagSearchNext(
searchPtr->searchOver = 1;
return NULL;
}
-#endif /* USE_OLD_TAG_SEARCH */
/*
*--------------------------------------------------------------
@@ -4228,11 +4632,11 @@ DoItem(
*/
if (tag == NULL) {
- Tcl_ListObjAppendElement(NULL, accumObj, Tcl_NewIntObj(itemPtr->id));
+ Tcl_ListObjAppendElement(NULL, accumObj, Tcl_NewWideIntObj(itemPtr->id));
return;
}
- for (tagPtr = itemPtr->tagPtr, count = itemPtr->numTags;
+ for (tagPtr = itemPtr->tagPtr, count = (int)itemPtr->numTags;
count > 0; tagPtr++, count--) {
if (tag == *tagPtr) {
return;
@@ -4292,7 +4696,7 @@ static int
FindItems(
Tcl_Interp *interp, /* Interpreter for error reporting. */
TkCanvas *canvasPtr, /* Canvas whose items are to be searched. */
- int objc, /* Number of entries in argv. Must be greater
+ Tcl_Size objc, /* Number of entries in argv. Must be greater
* than zero. */
Tcl_Obj *const *objv, /* Arguments that describe what items to
* search for (see user doc on "find" and
@@ -4301,17 +4705,12 @@ FindItems(
* found items; if NULL, then ids of found
* items are returned in the interp's
* result. */
- int first /* For error messages: gives number of
+ Tcl_Size first /* For error messages: gives number of
* elements of objv which are already
* handled. */
-#ifndef USE_OLD_TAG_SEARCH
,TagSearch **searchPtrPtr /* From CanvasWidgetCmd local vars*/
-#endif /* not USE_OLD_TAG_SEARCH */
)
{
-#ifdef USE_OLD_TAG_SEARCH
- TagSearch search;
-#endif /* USE_OLD_TAG_SEARCH */
Tk_Item *itemPtr;
Tk_Uid uid;
int index, result;
@@ -4628,16 +5027,6 @@ FindArea(
*--------------------------------------------------------------
*/
-#ifdef USE_OLD_TAG_SEARCH
-static void
-RelinkItems(
- TkCanvas *canvasPtr, /* Canvas to be modified. */
- Tcl_Obj *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). */
-#else /* USE_OLD_TAG_SEARCH */
static int
RelinkItems(
TkCanvas *canvasPtr, /* Canvas to be modified. */
@@ -4647,12 +5036,8 @@ RelinkItems(
* after this item (NULL means put at
* beginning of list). */
TagSearch **searchPtrPtr) /* From CanvasWidgetCmd local vars */
-#endif /* USE_OLD_TAG_SEARCH */
{
Tk_Item *itemPtr;
-#ifdef USE_OLD_TAG_SEARCH
- TagSearch search;
-#endif /* USE_OLD_TAG_SEARCH */
Tk_Item *firstMovePtr, *lastMovePtr;
int result;
@@ -4704,11 +5089,7 @@ RelinkItems(
*/
if (firstMovePtr == NULL) {
-#ifdef USE_OLD_TAG_SEARCH
- return;
-#else /* USE_OLD_TAG_SEARCH */
return TCL_OK;
-#endif /* USE_OLD_TAG_SEARCH */
}
if (prevPtr == NULL) {
if (canvasPtr->firstItemPtr != NULL) {
@@ -4729,9 +5110,7 @@ RelinkItems(
if (canvasPtr->lastItemPtr == prevPtr) {
canvasPtr->lastItemPtr = lastMovePtr;
}
-#ifndef USE_OLD_TAG_SEARCH
return TCL_OK;
-#endif /* not USE_OLD_TAG_SEARCH */
}
/*
@@ -4754,7 +5133,7 @@ RelinkItems(
static void
CanvasBindProc(
- ClientData clientData, /* Pointer to canvas structure. */
+ void *clientData, /* Pointer to canvas structure. */
XEvent *eventPtr) /* Pointer to X event that just happened. */
{
TkCanvas *canvasPtr = (TkCanvas *)clientData;
@@ -4771,7 +5150,7 @@ CanvasBindProc(
switch (eventPtr->type) {
case ButtonPress:
case ButtonRelease:
- mask = TkGetButtonMask(eventPtr->xbutton.button);
+ mask = Tk_GetButtonMask(eventPtr->xbutton.button);
/*
* For button press events, repick the current item using the button
@@ -4856,9 +5235,7 @@ PickCurrentItem(
double coords[2];
unsigned int buttonDown;
Tk_Item *prevItemPtr;
-#ifndef USE_OLD_TAG_SEARCH
SearchUids *searchUids = GetStaticUids();
-#endif
/*
* Check whether or not a button is down. If so, we'll log entry and exit
@@ -4957,7 +5334,7 @@ PickCurrentItem(
&& !(canvasPtr->flags & LEFT_GRABBED_ITEM)) {
XEvent event;
Tk_Item *itemPtr = canvasPtr->currentItemPtr;
- int i;
+ Tcl_Size i;
event = canvasPtr->pickEvent;
event.type = LeaveNotify;
@@ -4987,12 +5364,8 @@ PickCurrentItem(
*/
if ((itemPtr == canvasPtr->currentItemPtr) && !buttonDown) {
- for (i = itemPtr->numTags-1; i >= 0; i--) {
-#ifdef USE_OLD_TAG_SEARCH
- if (itemPtr->tagPtr[i] == Tk_GetUid("current"))
-#else /* USE_OLD_TAG_SEARCH */
+ for (i = itemPtr->numTags-1; i != TCL_INDEX_NONE; i--) {
if (itemPtr->tagPtr[i] == searchUids->currentUid)
-#endif /* USE_OLD_TAG_SEARCH */
/* then */ {
memmove((void *)(itemPtr->tagPtr + i),
itemPtr->tagPtr + i + 1,
@@ -5031,11 +5404,7 @@ PickCurrentItem(
if (canvasPtr->currentItemPtr != NULL) {
XEvent event;
-#ifdef USE_OLD_TAG_SEARCH
- DoItem(NULL, canvasPtr->currentItemPtr, Tk_GetUid("current"));
-#else /* USE_OLD_TAG_SEARCH */
DoItem(NULL, canvasPtr->currentItemPtr, searchUids->currentUid);
-#endif /* USE_OLD_TAG_SEARCH */
if ((canvasPtr->currentItemPtr->redraw_flags & TK_ITEM_STATE_DEPENDANT
&& prevItemPtr != canvasPtr->currentItemPtr)) {
ItemConfigure(canvasPtr, canvasPtr->currentItemPtr, 0, NULL);
@@ -5131,13 +5500,11 @@ CanvasDoEvent(
#define NUM_STATIC 3
void *staticObjects[NUM_STATIC];
void **objectPtr;
- int numObjects, i;
+ Tcl_Size numObjects, i;
Tk_Item *itemPtr;
-#ifndef USE_OLD_TAG_SEARCH
TagSearchExpr *expr;
- int numExprs;
+ Tcl_Size numExprs;
SearchUids *searchUids = GetStaticUids();
-#endif /* not USE_OLD_TAG_SEARCH */
if (canvasPtr->bindingTable == NULL) {
return;
@@ -5151,16 +5518,6 @@ CanvasDoEvent(
return;
}
-#ifdef USE_OLD_TAG_SEARCH
- /*
- * 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;
-#else /* USE_OLD_TAG_SEARCH */
/*
* Set up an array with all the relevant objects for processing this
* event. The relevant objects are:
@@ -5189,23 +5546,17 @@ CanvasDoEvent(
}
numObjects = itemPtr->numTags + numExprs + 2;
-#endif /* not USE_OLD_TAG_SEARCH */
if (numObjects <= NUM_STATIC) {
objectPtr = staticObjects;
} else {
objectPtr = (void **)ckalloc(numObjects * sizeof(void *));
}
-#ifdef USE_OLD_TAG_SEARCH
- objectPtr[0] = (void *)Tk_GetUid("all");
-#else /* USE_OLD_TAG_SEARCH */
- objectPtr[0] = (void *)searchUids->allUid;
-#endif /* USE_OLD_TAG_SEARCH */
- for (i = itemPtr->numTags - 1; i >= 0; i--) {
- objectPtr[i+1] = (void *)itemPtr->tagPtr[i];
+ objectPtr[0] = (char *)searchUids->allUid;
+ for (i = itemPtr->numTags - 1; i != TCL_INDEX_NONE; i--) {
+ objectPtr[i+1] = (char *)itemPtr->tagPtr[i];
}
objectPtr[itemPtr->numTags + 1] = itemPtr;
-#ifndef USE_OLD_TAG_SEARCH
/*
* Copy uids of matching expressions into object array
*/
@@ -5218,7 +5569,6 @@ CanvasDoEvent(
}
expr = expr->next;
}
-#endif /* not USE_OLD_TAG_SEARCH */
/*
* Invoke the binding system, then free up the object array if it was
@@ -5254,7 +5604,7 @@ CanvasDoEvent(
static void
CanvasBlinkProc(
- ClientData clientData) /* Pointer to record describing entry. */
+ void *clientData) /* Pointer to record describing entry. */
{
TkCanvas *canvasPtr = (TkCanvas *)clientData;
@@ -5341,10 +5691,10 @@ static void
CanvasSelectTo(
TkCanvas *canvasPtr, /* Information about widget. */
Tk_Item *itemPtr, /* Item that is to hold selection. */
- int index) /* Index of element that is to become the
+ Tcl_Size index) /* Index of element that is to become the
* "other" end of the selection. */
{
- int oldFirst, oldLast;
+ Tcl_Size oldFirst, oldLast;
Tk_Item *oldSelPtr;
oldFirst = canvasPtr->textInfo.selectFirst;
@@ -5371,7 +5721,7 @@ CanvasSelectTo(
canvasPtr->textInfo.selectFirst = canvasPtr->textInfo.selectAnchor;
canvasPtr->textInfo.selectLast = index;
} else {
- canvasPtr->textInfo.selectFirst = index;
+ canvasPtr->textInfo.selectFirst = ((int)index < 0) ? TCL_INDEX_NONE : index;
canvasPtr->textInfo.selectLast = canvasPtr->textInfo.selectAnchor - 1;
}
if ((canvasPtr->textInfo.selectFirst != oldFirst)
@@ -5402,13 +5752,13 @@ CanvasSelectTo(
*--------------------------------------------------------------
*/
-static int
+static Tcl_Size
CanvasFetchSelection(
- ClientData clientData, /* Information about canvas widget. */
- int offset, /* Offset within selection of first character
+ void *clientData, /* Information about canvas widget. */
+ Tcl_Size 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,
+ Tcl_Size maxBytes) /* Maximum number of bytes to place at buffer,
* not including terminating NULL
* character. */
{
@@ -5438,7 +5788,7 @@ CanvasFetchSelection(
static void
CanvasLostSelection(
- ClientData clientData) /* Information about entry widget. */
+ void *clientData) /* Information about entry widget. */
{
TkCanvas *canvasPtr = (TkCanvas *)clientData;
@@ -5591,10 +5941,10 @@ CanvasUpdateScrollbars(
xOrigin + width - inset, scrollX1, scrollX2);
Tcl_DStringInit(&buf);
- Tcl_DStringAppend(&buf, xScrollCmd, -1);
- Tcl_DStringAppend(&buf, " ", -1);
- Tcl_DStringAppend(&buf, Tcl_GetString(fractions), -1);
- result = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, TCL_EVAL_GLOBAL);
+ Tcl_DStringAppend(&buf, xScrollCmd, TCL_INDEX_NONE);
+ Tcl_DStringAppend(&buf, " ", TCL_INDEX_NONE);
+ Tcl_DStringAppend(&buf, Tcl_GetString(fractions), TCL_INDEX_NONE);
+ result = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), TCL_INDEX_NONE, TCL_EVAL_GLOBAL);
Tcl_DStringFree(&buf);
Tcl_DecrRefCount(fractions);
if (result != TCL_OK) {
@@ -5609,10 +5959,10 @@ CanvasUpdateScrollbars(
yOrigin + height - inset, scrollY1, scrollY2);
Tcl_DStringInit(&buf);
- Tcl_DStringAppend(&buf, yScrollCmd, -1);
- Tcl_DStringAppend(&buf, " ", -1);
- Tcl_DStringAppend(&buf, Tcl_GetString(fractions), -1);
- result = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, TCL_EVAL_GLOBAL);
+ Tcl_DStringAppend(&buf, yScrollCmd, TCL_INDEX_NONE);
+ Tcl_DStringAppend(&buf, " ", TCL_INDEX_NONE);
+ Tcl_DStringAppend(&buf, Tcl_GetString(fractions), TCL_INDEX_NONE);
+ result = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), TCL_INDEX_NONE, TCL_EVAL_GLOBAL);
Tcl_DStringFree(&buf);
Tcl_DecrRefCount(fractions);
if (result != TCL_OK) {
@@ -5769,12 +6119,13 @@ CanvasSetOrigin(
*----------------------------------------------------------------------
*/
+#if !defined(TK_NO_DEPRECATED) && (TK_MAJOR_VERSION < 9)
static const char **
TkGetStringsFromObjs(
- int objc,
+ Tcl_Size objc,
Tcl_Obj *const objv[])
{
- int i;
+ Tcl_Size i;
const char **argv;
if (objc <= 0) {
@@ -5787,6 +6138,7 @@ TkGetStringsFromObjs(
argv[objc] = 0;
return argv;
}
+#endif
/*
*--------------------------------------------------------------
@@ -5970,7 +6322,7 @@ Tk_CanvasPsPath(
* generated. */
double *coordPtr, /* Pointer to first in array of 2*numPoints
* coordinates giving points for path. */
- int numPoints) /* Number of points at *coordPtr. */
+ Tcl_Size numPoints) /* Number of points at *coordPtr. */
{
Tk_PostscriptPath(interp, Canvas(canvas)->psInfo, coordPtr, numPoints);
}
diff --git a/generic/tkCanvas.h b/generic/tkCanvas.h
index 75e1f92..4adde33 100644
--- a/generic/tkCanvas.h
+++ b/generic/tkCanvas.h
@@ -3,9 +3,9 @@
*
* 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.
- * Copyright (c) 1998 Scriptics Corporation.
+ * Copyright © 1991-1994 The Regents of the University of California.
+ * Copyright © 1994-1995 Sun Microsystems, Inc.
+ * Copyright © 1998 Scriptics Corporation.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -147,7 +147,7 @@ typedef struct TkCanvas {
* currentItem is based. Must be saved so that
* if the currentItem is deleted, can pick
* another. */
- int state; /* Last known modifier state. Used to defer
+ unsigned int state; /* Last known modifier state. Used to defer
* picking a new current object while buttons
* are down. */
@@ -214,7 +214,7 @@ typedef struct TkCanvas {
* when converting coordinates. */
int flags; /* Various flags; see below for
* definitions. */
- int nextId; /* Number to use as id for next item created
+ Tcl_Size nextId; /* Number to use as id for next item created
* in widget. */
Tk_PostscriptInfo psInfo; /* Pointer to information used for generating
* Postscript for the canvas. NULL means no
@@ -290,8 +290,8 @@ typedef struct TkCanvas {
* to the outside world:
*/
-MODULE_SCOPE int TkCanvPostscriptCmd(TkCanvas *canvasPtr,
- Tcl_Interp *interp, int argc, const char **argv);
+MODULE_SCOPE int TkCanvPostscriptObjCmd(TkCanvas *canvasPtr,
+ Tcl_Interp *interp, Tcl_Size argc, Tcl_Obj *const objv[]);
MODULE_SCOPE int TkCanvTranslatePath(TkCanvas *canvPtr,
int numVertex, double *coordPtr, int closed,
XPoint *outPtr);
diff --git a/generic/tkClipboard.c b/generic/tkClipboard.c
index e800da9..3bbfe12 100644
--- a/generic/tkClipboard.c
+++ b/generic/tkClipboard.c
@@ -5,8 +5,8 @@
* 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-1997 Sun Microsystems, Inc.
+ * Copyright © 1994 The Regents of the University of California.
+ * Copyright © 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.
@@ -19,14 +19,14 @@
* Prototypes for functions used only in this file:
*/
-static int ClipboardAppHandler(ClientData clientData,
- int offset, char *buffer, int maxBytes);
-static int ClipboardHandler(ClientData clientData,
- int offset, char *buffer, int maxBytes);
-static int ClipboardWindowHandler(ClientData clientData,
- int offset, char *buffer, int maxBytes);
-static void ClipboardLostSel(ClientData clientData);
-static int ClipboardGetProc(ClientData clientData,
+static Tcl_Size ClipboardAppHandler(void *clientData,
+ Tcl_Size offset, char *buffer, Tcl_Size maxBytes);
+static Tcl_Size ClipboardHandler(void *clientData,
+ Tcl_Size offset, char *buffer, Tcl_Size maxBytes);
+static Tcl_Size ClipboardWindowHandler(void *clientData,
+ Tcl_Size offset, char *buffer, Tcl_Size maxBytes);
+static void ClipboardLostSel(void *clientData);
+static int ClipboardGetProc(void *clientData,
Tcl_Interp *interp, const char *portion);
/*
@@ -48,20 +48,20 @@ static int ClipboardGetProc(ClientData clientData,
*----------------------------------------------------------------------
*/
-static int
+static Tcl_Size
ClipboardHandler(
- ClientData clientData, /* Information about data to fetch. */
- int offset, /* Return selection bytes starting at this
+ void *clientData, /* Information about data to fetch. */
+ Tcl_Size offset, /* Return selection bytes starting at this
* offset. */
char *buffer, /* Place to store converted selection. */
- int maxBytes) /* Maximum # of bytes to store at buffer. */
+ Tcl_Size maxBytes) /* Maximum # of bytes to store at buffer. */
{
TkClipboardTarget *targetPtr = (TkClipboardTarget *)clientData;
TkClipboardBuffer *cbPtr;
char *srcPtr, *destPtr;
- size_t count = 0;
- int scanned = 0;
- size_t length, freeCount;
+ Tcl_Size count = 0;
+ Tcl_Size scanned = 0;
+ Tcl_Size length, freeCount;
/*
* Skip to buffer containing offset byte
@@ -102,7 +102,7 @@ ClipboardHandler(
srcPtr = cbPtr->buffer;
length = cbPtr->length;
}
- return (int)count;
+ return count;
}
/*
@@ -126,16 +126,16 @@ ClipboardHandler(
*----------------------------------------------------------------------
*/
-static int
+static Tcl_Size
ClipboardAppHandler(
- ClientData clientData, /* Pointer to TkDisplay structure. */
- int offset, /* Return selection bytes starting at this
+ void *clientData, /* Pointer to TkDisplay structure. */
+ Tcl_Size offset, /* Return selection bytes starting at this
* offset. */
char *buffer, /* Place to store converted selection. */
- int maxBytes) /* Maximum # of bytes to store at buffer. */
+ Tcl_Size maxBytes) /* Maximum # of bytes to store at buffer. */
{
TkDisplay *dispPtr = (TkDisplay *)clientData;
- int length;
+ Tcl_Size length;
const char *p;
p = dispPtr->clipboardAppPtr->winPtr->nameUid;
@@ -171,13 +171,13 @@ ClipboardAppHandler(
*----------------------------------------------------------------------
*/
-static int
+static Tcl_Size
ClipboardWindowHandler(
TCL_UNUSED(void *), /* Not used. */
- TCL_UNUSED(int), /* Return selection bytes starting at this
+ TCL_UNUSED(Tcl_Size), /* Return selection bytes starting at this
* offset. */
char *buffer, /* Place to store converted selection. */
- TCL_UNUSED(int)) /* Maximum # of bytes to store at buffer. */
+ TCL_UNUSED(Tcl_Size)) /* Maximum # of bytes to store at buffer. */
{
buffer[0] = '.';
buffer[1] = 0;
@@ -204,7 +204,7 @@ ClipboardWindowHandler(
static void
ClipboardLostSel(
- ClientData clientData) /* Pointer to TkDisplay structure. */
+ void *clientData) /* Pointer to TkDisplay structure. */
{
TkDisplay *dispPtr = (TkDisplay *)clientData;
@@ -373,7 +373,7 @@ Tk_ClipboardAppend(
Tk_GetAtomName(tkwin, format),
Tk_GetAtomName(tkwin, targetPtr->format),
Tk_GetAtomName(tkwin, type)));
- Tcl_SetErrorCode(interp, "TK", "CLIPBOARD", "FORMAT_MISMATCH", NULL);
+ Tcl_SetErrorCode(interp, "TK", "CLIPBOARD", "FORMAT_MISMATCH", (char *)NULL);
return TCL_ERROR;
}
@@ -418,7 +418,7 @@ Tk_ClipboardAppend(
int
Tk_ClipboardObjCmd(
- ClientData clientData, /* Main window associated with interpreter. */
+ void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
@@ -450,7 +450,8 @@ Tk_ClipboardObjCmd(
"-displayof", "-format", "-type", NULL
};
enum appendOptions { APPEND_DISPLAYOF, APPEND_FORMAT, APPEND_TYPE };
- int subIndex, length;
+ int subIndex;
+ Tcl_Size length;
for (i = 2; i < objc - 1; i++) {
string = Tcl_GetStringFromObj(objv[i], &length);
@@ -479,7 +480,7 @@ Tk_ClipboardObjCmd(
if (i >= objc) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"value for \"%s\" missing", string));
- Tcl_SetErrorCode(interp, "TK", "CLIPBOARD", "VALUE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "CLIPBOARD", "VALUE", (char *)NULL);
return TCL_ERROR;
}
switch ((enum appendOptions) subIndex) {
@@ -569,7 +570,7 @@ Tk_ClipboardObjCmd(
if (i >= objc) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"value for \"%s\" missing", string));
- Tcl_SetErrorCode(interp, "TK", "CLIPBOARD", "VALUE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "CLIPBOARD", "VALUE", (char *)NULL);
return TCL_ERROR;
}
switch ((enum getOptions) subIndex) {
@@ -702,7 +703,7 @@ TkClipInit(
static int
ClipboardGetProc(
- ClientData clientData, /* Dynamic string holding partially assembled
+ void *clientData, /* Dynamic string holding partially assembled
* selection. */
TCL_UNUSED(Tcl_Interp *), /* Interpreter used for error reporting (not
* used). */
@@ -711,8 +712,8 @@ ClipboardGetProc(
Tcl_Encoding utf8 = Tcl_GetEncoding(NULL, "utf-8");
Tcl_DString ds;
- Tcl_ExternalToUtfDString(utf8, portion, -1, &ds);
- Tcl_DStringAppend((Tcl_DString *) clientData, Tcl_DStringValue(&ds), Tcl_DStringLength(&ds));
+ const char *str = Tcl_ExternalToUtfDString(utf8, portion, TCL_INDEX_NONE, &ds);
+ Tcl_DStringAppend((Tcl_DString *) clientData, str, Tcl_DStringLength(&ds));
Tcl_DStringFree(&ds);
Tcl_FreeEncoding(utf8);
return TCL_OK;
diff --git a/generic/tkCmds.c b/generic/tkCmds.c
index a642137..aaa6be4 100644
--- a/generic/tkCmds.c
+++ b/generic/tkCmds.c
@@ -4,9 +4,9 @@
* 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-1997 Sun Microsystems, Inc.
- * Copyright (c) 2000 Scriptics Corporation.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 2000 Scriptics Corporation.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -27,26 +27,26 @@
*/
static TkWindow * GetTopHierarchy(Tk_Window tkwin);
-static char * WaitVariableProc(ClientData clientData,
+static char * WaitVariableProc(void *clientData,
Tcl_Interp *interp, const char *name1,
const char *name2, int flags);
-static void WaitVisibilityProc(ClientData clientData,
+static void WaitVisibilityProc(void *clientData,
XEvent *eventPtr);
-static void WaitWindowProc(ClientData clientData,
+static void WaitWindowProc(void *clientData,
XEvent *eventPtr);
-static int AppnameCmd(ClientData dummy, Tcl_Interp *interp,
- int objc, Tcl_Obj *const *objv);
-static int CaretCmd(ClientData dummy, Tcl_Interp *interp,
- int objc, Tcl_Obj *const *objv);
-static int InactiveCmd(ClientData dummy, Tcl_Interp *interp,
- int objc, Tcl_Obj *const *objv);
-static int ScalingCmd(ClientData dummy, Tcl_Interp *interp,
- int objc, Tcl_Obj *const *objv);
-static int UseinputmethodsCmd(ClientData dummy,
- Tcl_Interp *interp, int objc,
+static int AppnameCmd(void *dummy, Tcl_Interp *interp,
+ Tcl_Size objc, Tcl_Obj *const *objv);
+static int CaretCmd(void *dummy, Tcl_Interp *interp,
+ Tcl_Size objc, Tcl_Obj *const *objv);
+static int InactiveCmd(void *dummy, Tcl_Interp *interp,
+ Tcl_Size objc, Tcl_Obj *const *objv);
+static int ScalingCmd(void *dummy, Tcl_Interp *interp,
+ Tcl_Size objc, Tcl_Obj *const *objv);
+static int UseinputmethodsCmd(void *dummy,
+ Tcl_Interp *interp, Tcl_Size objc,
Tcl_Obj *const *objv);
-static int WindowingsystemCmd(ClientData dummy,
- Tcl_Interp *interp, int objc,
+static int WindowingsystemCmd(void *dummy,
+ Tcl_Interp *interp, Tcl_Size objc,
Tcl_Obj *const *objv);
#if defined(_WIN32) || defined(MAC_OSX_TK)
@@ -60,6 +60,7 @@ MODULE_SCOPE const TkEnsemble tkFontchooserEnsemble[];
*/
static const TkEnsemble tkCmdMap[] = {
+ {"fontchooser", NULL, tkFontchooserEnsemble},
{"appname", AppnameCmd, NULL },
{"busy", Tk_BusyObjCmd, NULL },
{"caret", CaretCmd, NULL },
@@ -67,7 +68,6 @@ static const TkEnsemble tkCmdMap[] = {
{"scaling", ScalingCmd, NULL },
{"useinputmethods", UseinputmethodsCmd, NULL },
{"windowingsystem", WindowingsystemCmd, NULL },
- {"fontchooser", NULL, tkFontchooserEnsemble},
{NULL, NULL, NULL}
};
@@ -90,7 +90,7 @@ static const TkEnsemble tkCmdMap[] = {
int
Tk_BellObjCmd(
- ClientData clientData, /* Main window associated with interpreter. */
+ void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -100,7 +100,8 @@ Tk_BellObjCmd(
};
enum options { TK_BELL_DISPLAYOF, TK_BELL_NICE };
Tk_Window tkwin = (Tk_Window)clientData;
- int i, index, nice = 0;
+ int i;
+ int index, nice = 0;
Tk_ErrorHandler handler;
if (objc > 4) {
@@ -158,14 +159,14 @@ Tk_BellObjCmd(
int
Tk_BindObjCmd(
- ClientData clientData, /* Main window associated with interpreter. */
+ void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tk_Window tkwin = (Tk_Window)clientData;
TkWindow *winPtr;
- ClientData object;
+ void *object;
const char *string;
if ((objc < 2) || (objc > 4)) {
@@ -185,10 +186,10 @@ Tk_BindObjCmd(
if (winPtr == NULL) {
return TCL_ERROR;
}
- object = (ClientData) winPtr->pathName;
+ object = winPtr->pathName;
} else {
winPtr = (TkWindow *)clientData;
- object = (ClientData) Tk_GetUid(string);
+ object = (void *) Tk_GetUid(string);
}
/*
@@ -236,7 +237,7 @@ Tk_BindObjCmd(
Tcl_ResetResult(interp);
return TCL_OK;
}
- Tcl_SetObjResult(interp, Tcl_NewStringObj(command, -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(command, TCL_INDEX_NONE));
} else {
Tk_GetAllBindings(interp, winPtr->mainPtr->bindingTable, object);
}
@@ -267,10 +268,10 @@ TkBindEventProc(
XEvent *eventPtr) /* Information about event. */
{
#define MAX_OBJS 20
- ClientData objects[MAX_OBJS], *objPtr;
+ void *objects[MAX_OBJS], **objPtr;
TkWindow *topLevPtr;
- int i, count;
- const char *p;
+ Tcl_Size i, count;
+ char *p;
Tcl_HashEntry *hPtr;
if ((winPtr->mainPtr == NULL) || (winPtr->mainPtr->bindingTable == NULL)) {
@@ -288,7 +289,7 @@ TkBindEventProc(
objPtr = (void **)ckalloc(winPtr->numTags * sizeof(void *));
}
for (i = 0; i < winPtr->numTags; i++) {
- p = (const char *)winPtr->tagPtr[i];
+ p = (char *)winPtr->tagPtr[i];
if (*p == '.') {
hPtr = Tcl_FindHashEntry(&winPtr->mainPtr->nameTable, p);
if (hPtr != NULL) {
@@ -297,12 +298,12 @@ TkBindEventProc(
p = NULL;
}
}
- objPtr[i] = (ClientData) p;
+ objPtr[i] = p;
}
count = winPtr->numTags;
} else {
- objPtr[0] = (ClientData) winPtr->pathName;
- objPtr[1] = (ClientData) winPtr->classUid;
+ objPtr[0] = winPtr->pathName;
+ objPtr[1] = (void *)winPtr->classUid;
for (topLevPtr = winPtr;
(topLevPtr != NULL) && !(topLevPtr->flags & TK_TOP_HIERARCHY);
topLevPtr = topLevPtr->parentPtr) {
@@ -310,11 +311,11 @@ TkBindEventProc(
}
if ((winPtr != topLevPtr) && (topLevPtr != NULL)) {
count = 4;
- objPtr[2] = (ClientData) topLevPtr->pathName;
+ objPtr[2] = topLevPtr->pathName;
} else {
count = 3;
}
- objPtr[count-1] = (ClientData) Tk_GetUid("all");
+ objPtr[count-1] = (void *) Tk_GetUid("all");
}
Tk_BindEvent(winPtr->mainPtr->bindingTable, eventPtr, (Tk_Window) winPtr,
count, objPtr);
@@ -342,14 +343,14 @@ TkBindEventProc(
int
Tk_BindtagsObjCmd(
- ClientData clientData, /* Main window associated with interpreter. */
+ void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tk_Window tkwin = (Tk_Window)clientData;
TkWindow *winPtr, *winPtr2;
- int i, length;
+ Tcl_Size i, length;
const char *p;
Tcl_Obj *listPtr, **tags;
@@ -366,23 +367,23 @@ Tk_BindtagsObjCmd(
listPtr = Tcl_NewObj();
if (winPtr->numTags == 0) {
Tcl_ListObjAppendElement(NULL, listPtr,
- Tcl_NewStringObj(winPtr->pathName, -1));
+ Tcl_NewStringObj(winPtr->pathName, TCL_INDEX_NONE));
Tcl_ListObjAppendElement(NULL, listPtr,
- Tcl_NewStringObj(winPtr->classUid, -1));
+ Tcl_NewStringObj(winPtr->classUid, TCL_INDEX_NONE));
winPtr2 = winPtr;
while ((winPtr2 != NULL) && !(Tk_TopWinHierarchy(winPtr2))) {
winPtr2 = winPtr2->parentPtr;
}
if ((winPtr != winPtr2) && (winPtr2 != NULL)) {
Tcl_ListObjAppendElement(NULL, listPtr,
- Tcl_NewStringObj(winPtr2->pathName, -1));
+ Tcl_NewStringObj(winPtr2->pathName, TCL_INDEX_NONE));
}
Tcl_ListObjAppendElement(NULL, listPtr,
- Tcl_NewStringObj("all", -1));
+ Tcl_NewStringObj("all", TCL_INDEX_NONE));
} else {
for (i = 0; i < winPtr->numTags; i++) {
Tcl_ListObjAppendElement(NULL, listPtr,
- Tcl_NewStringObj((char *) winPtr->tagPtr[i], -1));
+ Tcl_NewStringObj((const char *)winPtr->tagPtr[i], TCL_INDEX_NONE));
}
}
Tcl_SetObjResult(interp, listPtr);
@@ -414,9 +415,9 @@ Tk_BindtagsObjCmd(
copy = (char *)ckalloc(strlen(p) + 1);
strcpy(copy, p);
- winPtr->tagPtr[i] = (ClientData) copy;
+ winPtr->tagPtr[i] = copy;
} else {
- winPtr->tagPtr[i] = (ClientData) Tk_GetUid(p);
+ winPtr->tagPtr[i] = (void *)Tk_GetUid(p);
}
}
return TCL_OK;
@@ -444,7 +445,7 @@ void
TkFreeBindingTags(
TkWindow *winPtr) /* Window whose tags are to be released. */
{
- int i;
+ Tcl_Size i;
const char *p;
for (i = 0; i < winPtr->numTags; i++) {
@@ -482,7 +483,7 @@ TkFreeBindingTags(
int
Tk_DestroyObjCmd(
- ClientData clientData, /* Main window associated with interpreter. */
+ void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -529,7 +530,7 @@ Tk_DestroyObjCmd(
int
Tk_LowerObjCmd(
- ClientData clientData, /* Main window associated with interpreter. */
+ void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -563,7 +564,7 @@ Tk_LowerObjCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't lower \"%s\" to bottom", Tcl_GetString(objv[1])));
}
- Tcl_SetErrorCode(interp, "TK", "RESTACK", "LOWER", NULL);
+ Tcl_SetErrorCode(interp, "TK", "RESTACK", "LOWER", (char *)NULL);
return TCL_ERROR;
}
return TCL_OK;
@@ -588,7 +589,7 @@ Tk_LowerObjCmd(
int
Tk_RaiseObjCmd(
- ClientData clientData, /* Main window associated with interpreter. */
+ void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -622,7 +623,7 @@ Tk_RaiseObjCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't raise \"%s\" to top", Tcl_GetString(objv[1])));
}
- Tcl_SetErrorCode(interp, "TK", "RESTACK", "RAISE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "RESTACK", "RAISE", (char *)NULL);
return TCL_ERROR;
}
return TCL_OK;
@@ -647,11 +648,15 @@ Tk_RaiseObjCmd(
int
TkInitTkCmd(
Tcl_Interp *interp,
- ClientData clientData)
+ void *clientData)
{
- TkMakeEnsemble(interp, "::", "tk", clientData, tkCmdMap);
+ /* If the interp is safe, leave out "fontchooser" */
+ int isSafe = Tcl_IsSafe(interp);
+ TkMakeEnsemble(interp, "::", "tk", clientData, tkCmdMap + isSafe);
#if defined(_WIN32) || defined(MAC_OSX_TK)
- TkInitFontchooser(interp, clientData);
+ if (!isSafe) {
+ TkInitFontchooser(interp, clientData);
+ }
#endif
return TCL_OK;
}
@@ -676,9 +681,9 @@ TkInitTkCmd(
int
AppnameCmd(
- ClientData clientData, /* Main window associated with interpreter. */
+ void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tk_Window tkwin = (Tk_Window)clientData;
@@ -687,30 +692,29 @@ AppnameCmd(
if (Tcl_IsSafe(interp)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "appname not accessible in a safe interpreter", -1));
- Tcl_SetErrorCode(interp, "TK", "SAFE", "APPLICATION", NULL);
+ "appname not accessible in a safe interpreter", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "SAFE", "APPLICATION", (char *)NULL);
return TCL_ERROR;
}
winPtr = (TkWindow *) tkwin;
- if (objc > 2) {
- Tcl_WrongNumArgs(interp, 1, objv, "?newName?");
- return TCL_ERROR;
- }
if (objc == 2) {
string = Tcl_GetString(objv[1]);
winPtr->nameUid = Tk_GetUid(Tk_SetAppName(tkwin, string));
+ } else if (objc != 1) {
+ Tcl_WrongNumArgs(interp, 1, objv, "?newName?");
+ return TCL_ERROR;
}
- Tcl_SetObjResult(interp, Tcl_NewStringObj(winPtr->nameUid, -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(winPtr->nameUid, TCL_INDEX_NONE));
return TCL_OK;
}
int
CaretCmd(
- ClientData clientData, /* Main window associated with interpreter. */
+ void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tk_Window tkwin = (Tk_Window)clientData;
@@ -744,15 +748,15 @@ CaretCmd(
Tcl_ListObjAppendElement(interp, objPtr,
Tcl_NewStringObj("-height", 7));
Tcl_ListObjAppendElement(interp, objPtr,
- Tcl_NewIntObj(caretPtr->height));
+ Tcl_NewWideIntObj(caretPtr->height));
Tcl_ListObjAppendElement(interp, objPtr,
Tcl_NewStringObj("-x", 2));
Tcl_ListObjAppendElement(interp, objPtr,
- Tcl_NewIntObj(caretPtr->x));
+ Tcl_NewWideIntObj(caretPtr->x));
Tcl_ListObjAppendElement(interp, objPtr,
Tcl_NewStringObj("-y", 2));
Tcl_ListObjAppendElement(interp, objPtr,
- Tcl_NewIntObj(caretPtr->y));
+ Tcl_NewWideIntObj(caretPtr->y));
Tcl_SetObjResult(interp, objPtr);
} else if (objc == 3) {
int value;
@@ -772,9 +776,9 @@ CaretCmd(
} else /* if (index == TK_CARET_HEIGHT) -- last case */ {
value = caretPtr->height;
}
- Tcl_SetObjResult(interp, Tcl_NewIntObj(value));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(value));
} else {
- int i;
+ Tcl_Size i;
int value, x = 0, y = 0, height = -1;
for (i = 2; i < objc; i += 2) {
@@ -801,35 +805,37 @@ CaretCmd(
int
ScalingCmd(
- ClientData clientData, /* Main window associated with interpreter. */
+ void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tk_Window tkwin = (Tk_Window)clientData;
Screen *screenPtr;
- int skip, width, height;
- double d;
+ Tcl_Size skip;
+ int width, height, intPct;
+ double d, dblPct;
skip = TkGetDisplayOf(interp, objc - 1, objv + 1, &tkwin);
if (skip < 0) {
return TCL_ERROR;
}
screenPtr = Tk_Screen(tkwin);
- if (objc - skip == 1) {
+ if (objc == 1 + skip) {
d = 25.4 / 72;
d *= WidthOfScreen(screenPtr);
d /= WidthMMOfScreen(screenPtr);
Tcl_SetObjResult(interp, Tcl_NewDoubleObj(d));
} else if (Tcl_IsSafe(interp)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "setting the scaling not accessible in a safe interpreter", -1));
- Tcl_SetErrorCode(interp, "TK", "SAFE", "SCALING", NULL);
+ "setting the scaling not accessible in a safe interpreter", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "SAFE", "SCALING", (char *)NULL);
return TCL_ERROR;
- } else if (objc - skip == 2) {
+ } else if (objc == 2 + skip) {
if (Tcl_GetDoubleFromObj(interp, objv[1+skip], &d) != TCL_OK) {
return TCL_ERROR;
}
+ dblPct = d * 75;
d = (25.4 / 72) / d;
width = (int) (d * WidthOfScreen(screenPtr) + 0.5);
if (width <= 0) {
@@ -841,6 +847,28 @@ ScalingCmd(
}
WidthMMOfScreen(screenPtr) = width;
HeightMMOfScreen(screenPtr) = height;
+
+ /*
+ * Keep the variables ::tk::scalingPct and ::tk::svgFmt
+ * in sync with the new value of the scaling factor
+ */
+
+ for (intPct = 100; 1; intPct += 25) {
+ if (dblPct < intPct + 12.5) {
+ break;
+ }
+ }
+ Tcl_SetVar2Ex(interp, "::tk::scalingPct", NULL, Tcl_NewIntObj(intPct),
+ TCL_GLOBAL_ONLY);
+
+ Tcl_SetVar2Ex(interp, "::tk::svgFmt", NULL,
+ Tcl_NewStringObj("svg", TCL_INDEX_NONE), TCL_GLOBAL_ONLY);
+ Tcl_SetVar2Ex(interp, "::tk::svgFmt", NULL,
+ Tcl_NewStringObj("-scale", TCL_INDEX_NONE),
+ TCL_GLOBAL_ONLY | TCL_APPEND_VALUE | TCL_LIST_ELEMENT);
+ Tcl_SetVar2Ex(interp, "::tk::svgFmt", NULL,
+ Tcl_NewDoubleObj(intPct / 100.0),
+ TCL_GLOBAL_ONLY | TCL_APPEND_VALUE | TCL_LIST_ELEMENT);
} else {
Tcl_WrongNumArgs(interp, 1, objv, "?-displayof window? ?factor?");
return TCL_ERROR;
@@ -850,33 +878,28 @@ ScalingCmd(
int
UseinputmethodsCmd(
- ClientData clientData, /* Main window associated with interpreter. */
+ void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tk_Window tkwin = (Tk_Window)clientData;
TkDisplay *dispPtr;
- int skip;
+ Tcl_Size skip;
if (Tcl_IsSafe(interp)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "useinputmethods not accessible in a safe interpreter", -1));
- Tcl_SetErrorCode(interp, "TK", "SAFE", "INPUT_METHODS", NULL);
+ "useinputmethods not accessible in a safe interpreter", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "SAFE", "INPUT_METHODS", (char *)NULL);
return TCL_ERROR;
}
- skip = TkGetDisplayOf(interp, objc-1, objv+1, &tkwin);
+ skip = TkGetDisplayOf(interp, objc - 1, objv + 1, &tkwin);
if (skip < 0) {
return TCL_ERROR;
}
dispPtr = ((TkWindow *) tkwin)->dispPtr;
- if ((objc - skip) == 2) {
- /*
- * In the case where TK_USE_INPUT_METHODS is not defined, this
- * will be ignored and we will always return 0. That will indicate
- * to the user that input methods are just not available.
- */
+ if (objc == 2 + skip) {
int boolVal;
@@ -884,14 +907,12 @@ UseinputmethodsCmd(
&boolVal) != TCL_OK) {
return TCL_ERROR;
}
-#ifdef TK_USE_INPUT_METHODS
- if (boolVal) {
+ if (boolVal && (dispPtr->inputMethod != NULL)) {
dispPtr->flags |= TK_DISPLAY_USE_IM;
} else {
dispPtr->flags &= ~TK_DISPLAY_USE_IM;
}
-#endif /* TK_USE_INPUT_METHODS */
- } else if ((objc - skip) != 1) {
+ } else if (objc != 1 + skip) {
Tcl_WrongNumArgs(interp, 1, objv,
"?-displayof window? ?boolean?");
return TCL_ERROR;
@@ -903,9 +924,9 @@ UseinputmethodsCmd(
int
WindowingsystemCmd(
- TCL_UNUSED(void *), /* Main window associated with interpreter. */
+ TCL_UNUSED(void *), /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
const char *windowingsystem;
@@ -921,30 +942,30 @@ WindowingsystemCmd(
#else
windowingsystem = "x11";
#endif
- Tcl_SetObjResult(interp, Tcl_NewStringObj(windowingsystem, -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(windowingsystem, TCL_INDEX_NONE));
return TCL_OK;
}
int
InactiveCmd(
- ClientData clientData, /* Main window associated with interpreter. */
+ void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tk_Window tkwin = (Tk_Window)clientData;
- int skip = TkGetDisplayOf(interp, objc - 1, objv + 1, &tkwin);
+ Tcl_Size skip = TkGetDisplayOf(interp, objc - 1, objv + 1, &tkwin);
if (skip < 0) {
return TCL_ERROR;
}
- if (objc - skip == 1) {
+ if (objc == 1 + skip) {
Tcl_WideInt inactive;
inactive = (Tcl_IsSafe(interp) ? -1 :
Tk_GetUserInactiveTime(Tk_Display(tkwin)));
Tcl_SetObjResult(interp, Tcl_NewWideIntObj(inactive));
- } else if (objc - skip == 2) {
+ } else if (objc == 2 + skip) {
const char *string;
string = Tcl_GetString(objv[objc-1]);
@@ -952,14 +973,14 @@ InactiveCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad option \"%s\": must be reset", string));
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "INDEX", "option",
- string, NULL);
+ string, (char *)NULL);
return TCL_ERROR;
}
if (Tcl_IsSafe(interp)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"resetting the user inactivity timer "
- "is not allowed in a safe interpreter", -1));
- Tcl_SetErrorCode(interp, "TK", "SAFE", "INACTIVITY_TIMER", NULL);
+ "is not allowed in a safe interpreter", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "SAFE", "INACTIVITY_TIMER", (char *)NULL);
return TCL_ERROR;
}
Tk_ResetUserInactiveTime(Tk_Display(tkwin));
@@ -990,7 +1011,7 @@ InactiveCmd(
int
Tk_TkwaitObjCmd(
- ClientData clientData, /* Main window associated with interpreter. */
+ void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -1063,7 +1084,7 @@ Tk_TkwaitObjCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"window \"%s\" was deleted before its visibility changed",
Tcl_GetString(objv[2])));
- Tcl_SetErrorCode(interp, "TK", "WAIT", "PREMATURE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "WAIT", "PREMATURE", (char *)NULL);
return TCL_ERROR;
}
Tk_DeleteEventHandler(window,
@@ -1118,11 +1139,11 @@ Tk_TkwaitObjCmd(
static char *
WaitVariableProc(
- ClientData clientData, /* Pointer to integer to set to 1. */
+ void *clientData, /* Pointer to integer to set to 1. */
Tcl_Interp *interp, /* Interpreter containing variable. */
const char *name1, /* Name of variable. */
- TCL_UNUSED(const char *), /* Second part of variable name. */
- TCL_UNUSED(int)) /* Information about what happened. */
+ TCL_UNUSED(const char *), /* Second part of variable name. */
+ TCL_UNUSED(int)) /* Information about what happened. */
{
int *donePtr = (int *)clientData;
@@ -1134,7 +1155,7 @@ WaitVariableProc(
static void
WaitVisibilityProc(
- ClientData clientData, /* Pointer to integer to set to 1. */
+ void *clientData, /* Pointer to integer to set to 1. */
XEvent *eventPtr) /* Information about event (not used). */
{
int *donePtr = (int *)clientData;
@@ -1148,7 +1169,7 @@ WaitVisibilityProc(
static void
WaitWindowProc(
- ClientData clientData, /* Pointer to integer to set to 1. */
+ void *clientData, /* Pointer to integer to set to 1. */
XEvent *eventPtr) /* Information about event. */
{
int *donePtr = (int *)clientData;
@@ -1177,7 +1198,7 @@ WaitWindowProc(
int
Tk_UpdateObjCmd(
- TCL_UNUSED(void *), /* Main window associated with interpreter. */
+ TCL_UNUSED(void *), /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -1275,12 +1296,13 @@ Tk_UpdateObjCmd(
int
Tk_WinfoObjCmd(
- ClientData clientData, /* Main window associated with interpreter. */
+ void *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, c_class, skip;
+ int index, x, y, width, height, useX, useY, c_class;
+ int skip;
const char *string;
TkWindow *winPtr;
Tk_Window tkwin = (Tk_Window)clientData;
@@ -1358,7 +1380,7 @@ Tk_WinfoObjCmd(
switch ((enum options) index) {
case WIN_CELLS:
Tcl_SetObjResult(interp,
- Tcl_NewIntObj(Tk_Visual(tkwin)->map_entries));
+ Tcl_NewWideIntObj(Tk_Visual(tkwin)->map_entries));
break;
case WIN_CHILDREN: {
Tcl_Obj *strPtr, *resultPtr = Tcl_NewObj();
@@ -1366,7 +1388,7 @@ Tk_WinfoObjCmd(
winPtr = winPtr->childList;
for ( ; winPtr != NULL; winPtr = winPtr->nextPtr) {
if (!(winPtr->flags & TK_ANONYMOUS_WINDOW)) {
- strPtr = Tcl_NewStringObj(winPtr->pathName, -1);
+ strPtr = Tcl_NewStringObj(winPtr->pathName, TCL_INDEX_NONE);
Tcl_ListObjAppendElement(NULL, resultPtr, strPtr);
}
}
@@ -1374,28 +1396,28 @@ Tk_WinfoObjCmd(
break;
}
case WIN_CLASS:
- Tcl_SetObjResult(interp, Tcl_NewStringObj(Tk_Class(tkwin), -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(Tk_Class(tkwin), TCL_INDEX_NONE));
break;
case WIN_COLORMAPFULL:
Tcl_SetObjResult(interp,
Tcl_NewBooleanObj(TkpCmapStressed(tkwin,Tk_Colormap(tkwin))));
break;
case WIN_DEPTH:
- Tcl_SetObjResult(interp, Tcl_NewIntObj(Tk_Depth(tkwin)));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(Tk_Depth(tkwin)));
break;
case WIN_GEOMETRY:
Tcl_SetObjResult(interp, Tcl_ObjPrintf("%dx%d+%d+%d",
Tk_Width(tkwin), Tk_Height(tkwin), Tk_X(tkwin), Tk_Y(tkwin)));
break;
case WIN_HEIGHT:
- Tcl_SetObjResult(interp, Tcl_NewIntObj(Tk_Height(tkwin)));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(Tk_Height(tkwin)));
break;
case WIN_ID: {
char buf[TCL_INTEGER_SPACE];
Tk_MakeWindowExist(tkwin);
TkpPrintWindowId(buf, Tk_WindowId(tkwin));
- Tcl_SetObjResult(interp, Tcl_NewStringObj(buf, -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(buf, TCL_INDEX_NONE));
break;
}
case WIN_ISMAPPED:
@@ -1404,16 +1426,16 @@ Tk_WinfoObjCmd(
case WIN_MANAGER:
if (winPtr->geomMgrPtr != NULL) {
Tcl_SetObjResult(interp,
- Tcl_NewStringObj(winPtr->geomMgrPtr->name, -1));
+ Tcl_NewStringObj(winPtr->geomMgrPtr->name, TCL_INDEX_NONE));
}
break;
case WIN_NAME:
- Tcl_SetObjResult(interp, Tcl_NewStringObj(Tk_Name(tkwin), -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(Tk_Name(tkwin), TCL_INDEX_NONE));
break;
case WIN_PARENT:
if (winPtr->parentPtr != NULL) {
Tcl_SetObjResult(interp,
- Tcl_NewStringObj(winPtr->parentPtr->pathName, -1));
+ Tcl_NewStringObj(winPtr->parentPtr->pathName, TCL_INDEX_NONE));
}
break;
case WIN_POINTERX:
@@ -1439,28 +1461,28 @@ Tk_WinfoObjCmd(
if (useX & useY) {
Tcl_Obj *xyObj[2];
- xyObj[0] = Tcl_NewIntObj(x);
- xyObj[1] = Tcl_NewIntObj(y);
+ xyObj[0] = Tcl_NewWideIntObj(x);
+ xyObj[1] = Tcl_NewWideIntObj(y);
Tcl_SetObjResult(interp, Tcl_NewListObj(2, xyObj));
} else if (useX) {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(x));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(x));
} else {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(y));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(y));
}
break;
case WIN_REQHEIGHT:
- Tcl_SetObjResult(interp, Tcl_NewIntObj(Tk_ReqHeight(tkwin)));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(Tk_ReqHeight(tkwin)));
break;
case WIN_REQWIDTH:
- Tcl_SetObjResult(interp, Tcl_NewIntObj(Tk_ReqWidth(tkwin)));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(Tk_ReqWidth(tkwin)));
break;
case WIN_ROOTX:
Tk_GetRootCoords(tkwin, &x, &y);
- Tcl_SetObjResult(interp, Tcl_NewIntObj(x));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(x));
break;
case WIN_ROOTY:
Tk_GetRootCoords(tkwin, &x, &y);
- Tcl_SetObjResult(interp, Tcl_NewIntObj(y));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(y));
break;
case WIN_SCREEN:
Tcl_SetObjResult(interp, Tcl_ObjPrintf("%s.%d",
@@ -1468,27 +1490,27 @@ Tk_WinfoObjCmd(
break;
case WIN_SCREENCELLS:
Tcl_SetObjResult(interp,
- Tcl_NewIntObj(CellsOfScreen(Tk_Screen(tkwin))));
+ Tcl_NewWideIntObj(CellsOfScreen(Tk_Screen(tkwin))));
break;
case WIN_SCREENDEPTH:
Tcl_SetObjResult(interp,
- Tcl_NewIntObj(DefaultDepthOfScreen(Tk_Screen(tkwin))));
+ Tcl_NewWideIntObj(DefaultDepthOfScreen(Tk_Screen(tkwin))));
break;
case WIN_SCREENHEIGHT:
Tcl_SetObjResult(interp,
- Tcl_NewIntObj(HeightOfScreen(Tk_Screen(tkwin))));
+ Tcl_NewWideIntObj(HeightOfScreen(Tk_Screen(tkwin))));
break;
case WIN_SCREENWIDTH:
Tcl_SetObjResult(interp,
- Tcl_NewIntObj(WidthOfScreen(Tk_Screen(tkwin))));
+ Tcl_NewWideIntObj(WidthOfScreen(Tk_Screen(tkwin))));
break;
case WIN_SCREENMMHEIGHT:
Tcl_SetObjResult(interp,
- Tcl_NewIntObj(HeightMMOfScreen(Tk_Screen(tkwin))));
+ Tcl_NewWideIntObj(HeightMMOfScreen(Tk_Screen(tkwin))));
break;
case WIN_SCREENMMWIDTH:
Tcl_SetObjResult(interp,
- Tcl_NewIntObj(WidthMMOfScreen(Tk_Screen(tkwin))));
+ Tcl_NewWideIntObj(WidthMMOfScreen(Tk_Screen(tkwin))));
break;
case WIN_SCREENVISUAL:
c_class = DefaultVisualOfScreen(Tk_Screen(tkwin))->c_class;
@@ -1499,7 +1521,7 @@ Tk_WinfoObjCmd(
case WIN_TOPLEVEL:
winPtr = GetTopHierarchy(tkwin);
if (winPtr != NULL) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(winPtr->pathName, -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(winPtr->pathName, TCL_INDEX_NONE));
}
break;
case WIN_VIEWABLE: {
@@ -1526,7 +1548,7 @@ Tk_WinfoObjCmd(
if (string == NULL) {
string = "unknown";
}
- Tcl_SetObjResult(interp, Tcl_NewStringObj(string, -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(string, TCL_INDEX_NONE));
break;
case WIN_VISUALID:
Tcl_SetObjResult(interp, Tcl_ObjPrintf("0x%x", (unsigned)
@@ -1534,28 +1556,28 @@ Tk_WinfoObjCmd(
break;
case WIN_VROOTHEIGHT:
Tk_GetVRootGeometry(tkwin, &x, &y, &width, &height);
- Tcl_SetObjResult(interp, Tcl_NewIntObj(height));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(height));
break;
case WIN_VROOTWIDTH:
Tk_GetVRootGeometry(tkwin, &x, &y, &width, &height);
- Tcl_SetObjResult(interp, Tcl_NewIntObj(width));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(width));
break;
case WIN_VROOTX:
Tk_GetVRootGeometry(tkwin, &x, &y, &width, &height);
- Tcl_SetObjResult(interp, Tcl_NewIntObj(x));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(x));
break;
case WIN_VROOTY:
Tk_GetVRootGeometry(tkwin, &x, &y, &width, &height);
- Tcl_SetObjResult(interp, Tcl_NewIntObj(y));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(y));
break;
case WIN_WIDTH:
- Tcl_SetObjResult(interp, Tcl_NewIntObj(Tk_Width(tkwin)));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(Tk_Width(tkwin)));
break;
case WIN_X:
- Tcl_SetObjResult(interp, Tcl_NewIntObj(Tk_X(tkwin)));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(Tk_X(tkwin)));
break;
case WIN_Y:
- Tcl_SetObjResult(interp, Tcl_NewIntObj(Tk_Y(tkwin)));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(Tk_Y(tkwin)));
break;
/*
@@ -1567,7 +1589,7 @@ Tk_WinfoObjCmd(
if (skip < 0) {
return TCL_ERROR;
}
- if (objc - skip != 3) {
+ if (objc != 3 + skip) {
Tcl_WrongNumArgs(interp, 2, objv, "?-displayof window? name");
return TCL_ERROR;
}
@@ -1584,7 +1606,7 @@ Tk_WinfoObjCmd(
if (skip < 0) {
return TCL_ERROR;
}
- if (objc - skip != 3) {
+ if (objc != 3 + skip) {
Tcl_WrongNumArgs(interp, 2, objv, "?-displayof window? id");
return TCL_ERROR;
}
@@ -1597,10 +1619,10 @@ Tk_WinfoObjCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"no atom exists with id \"%s\"", Tcl_GetString(objv[2])));
Tcl_SetErrorCode(interp, "TK", "LOOKUP", "ATOM",
- Tcl_GetString(objv[2]), NULL);
+ Tcl_GetString(objv[2]), (char *)NULL);
return TCL_ERROR;
}
- Tcl_SetObjResult(interp, Tcl_NewStringObj(name, -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(name, TCL_INDEX_NONE));
break;
}
case WIN_CONTAINING:
@@ -1608,7 +1630,7 @@ Tk_WinfoObjCmd(
if (skip < 0) {
return TCL_ERROR;
}
- if (objc - skip != 4) {
+ if (objc != 4 + skip) {
Tcl_WrongNumArgs(interp, 2, objv,
"?-displayof window? rootX rootY");
return TCL_ERROR;
@@ -1624,7 +1646,7 @@ Tk_WinfoObjCmd(
}
tkwin = Tk_CoordsToWindow(x, y, tkwin);
if (tkwin != NULL) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(Tk_PathName(tkwin),-1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(Tk_PathName(tkwin), TCL_INDEX_NONE));
}
break;
case WIN_INTERPS:
@@ -1632,7 +1654,7 @@ Tk_WinfoObjCmd(
if (skip < 0) {
return TCL_ERROR;
}
- if (objc - skip != 2) {
+ if (objc != 2 + skip) {
Tcl_WrongNumArgs(interp, 2, objv, "?-displayof window?");
return TCL_ERROR;
}
@@ -1644,7 +1666,7 @@ Tk_WinfoObjCmd(
if (skip < 0) {
return TCL_ERROR;
}
- if (objc - skip != 3) {
+ if (objc != 3 + skip) {
Tcl_WrongNumArgs(interp, 2, objv, "?-displayof window? id");
return TCL_ERROR;
}
@@ -1658,7 +1680,7 @@ Tk_WinfoObjCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"window id \"%s\" doesn't exist in this application",
string));
- Tcl_SetErrorCode(interp, "TK", "LOOKUP", "WINDOW", string, NULL);
+ Tcl_SetErrorCode(interp, "TK", "LOOKUP", "WINDOW", string, (char *)NULL);
return TCL_ERROR;
}
@@ -1670,7 +1692,7 @@ Tk_WinfoObjCmd(
tkwin = (Tk_Window) winPtr;
if (Tk_PathName(tkwin) != NULL) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(Tk_PathName(tkwin),-1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(Tk_PathName(tkwin), TCL_INDEX_NONE));
}
break;
}
@@ -1730,7 +1752,7 @@ Tk_WinfoObjCmd(
if (Tk_GetPixels(interp, tkwin, string, &pixels) != TCL_OK) {
return TCL_ERROR;
}
- Tcl_SetObjResult(interp, Tcl_NewIntObj(pixels));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(pixels));
break;
}
case WIN_RGB: {
@@ -1795,8 +1817,8 @@ Tk_WinfoObjCmd(
&templ, &count);
if (visInfoPtr == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "can't find any visuals for screen", -1));
- Tcl_SetErrorCode(interp, "TK", "VISUAL", "NONE", NULL);
+ "can't find any visuals for screen", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "VISUAL", "NONE", (char *)NULL);
return TCL_ERROR;
}
resultPtr = Tcl_NewObj();
@@ -1812,11 +1834,11 @@ Tk_WinfoObjCmd(
(unsigned long) visInfoPtr[i].visualid);
strcat(buf, visualIdString);
}
- strPtr = Tcl_NewStringObj(buf, -1);
+ strPtr = Tcl_NewStringObj(buf, TCL_INDEX_NONE);
Tcl_ListObjAppendElement(NULL, resultPtr, strPtr);
}
Tcl_SetObjResult(interp, resultPtr);
- XFree((char *) visInfoPtr);
+ XFree(visInfoPtr);
break;
}
}
@@ -1837,12 +1859,12 @@ Tk_WinfoObjCmd(
* 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.
+ * Otherwise, the return value is TCL_INDEX_NONE 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.
+ * window specified on the command line. If the return value was
+ * TCL_INDEX_NONE, an error message is left in interp's result object.
*
* Side effects:
* None.
@@ -1850,10 +1872,10 @@ Tk_WinfoObjCmd(
*----------------------------------------------------------------------
*/
-int
+Tcl_Size
TkGetDisplayOf(
Tcl_Interp *interp, /* Interpreter for error reporting. */
- int objc, /* Number of arguments. */
+ Tcl_Size 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. */
@@ -1865,23 +1887,23 @@ TkGetDisplayOf(
* present. */
{
const char *string;
- int length;
+ Tcl_Size length;
- if (objc < 1) {
+ if (objc + 1 < 2) {
return 0;
}
string = Tcl_GetStringFromObj(objv[0], &length);
if ((length >= 2) &&
(strncmp(string, "-displayof", length) == 0)) {
- if (objc < 2) {
+ if (objc < 2) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "value for \"-displayof\" missing", -1));
- Tcl_SetErrorCode(interp, "TK", "NO_VALUE", "DISPLAYOF", NULL);
- return -1;
+ "value for \"-displayof\" missing", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "NO_VALUE", "DISPLAYOF", (char *)NULL);
+ return TCL_INDEX_NONE;
}
*tkwinPtr = Tk_NameToWindow(interp, Tcl_GetString(objv[1]), *tkwinPtr);
if (*tkwinPtr == NULL) {
- return -1;
+ return TCL_INDEX_NONE;
}
return 2;
}
@@ -1910,8 +1932,8 @@ int
TkDeadAppObjCmd(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
- TCL_UNUSED(int), /* Number of arguments. */
- Tcl_Obj *const objv[]) /* Argument strings. */
+ TCL_UNUSED(int), /* Number of arguments. */
+ Tcl_Obj *const objv[]) /* Argument strings. */
{
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't invoke \"%s\" command: application has been destroyed",
@@ -1940,7 +1962,7 @@ TkDeadAppObjCmd(
static TkWindow *
GetTopHierarchy(
Tk_Window tkwin) /* Window for which the top-of-hierarchy
- * ancestor should be deterined. */
+ * ancestor should be determined. */
{
TkWindow *winPtr = (TkWindow *) tkwin;
diff --git a/generic/tkColor.c b/generic/tkColor.c
index bc4c30c..baff5e7 100644
--- a/generic/tkColor.c
+++ b/generic/tkColor.c
@@ -5,8 +5,8 @@
* 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-1997 Sun Microsystems, Inc.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 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.
@@ -56,12 +56,14 @@ static void InitColorObj(Tcl_Obj *objPtr);
* of the Tcl_Obj points to a TkColor object.
*/
-const Tcl_ObjType tkColorObjType = {
- "color", /* name */
+const TkObjType tkColorObjType = {
+ {"color", /* name */
FreeColorObjProc, /* freeIntRepProc */
DupColorObjProc, /* dupIntRepProc */
NULL, /* updateStringProc */
- NULL /* setFromAnyProc */
+ NULL, /* setFromAnyProc */
+ TCL_OBJTYPE_V1(TkLengthOne)},
+ 0
};
/*
@@ -99,7 +101,7 @@ Tk_AllocColorFromObj(
{
TkColor *tkColPtr;
- if (objPtr->typePtr != &tkColorObjType) {
+ if (objPtr->typePtr != &tkColorObjType.objType) {
InitColorObj(objPtr);
}
tkColPtr = (TkColor *) objPtr->internalRep.twoPtrValue.ptr1;
@@ -661,7 +663,7 @@ Tk_GetColorFromObj(
Tcl_HashEntry *hashPtr;
TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
- if (objPtr->typePtr != &tkColorObjType) {
+ if (objPtr->typePtr != &tkColorObjType.objType) {
InitColorObj(objPtr);
}
@@ -749,7 +751,7 @@ InitColorObj(
if ((typePtr != NULL) && (typePtr->freeIntRepProc != NULL)) {
typePtr->freeIntRepProc(objPtr);
}
- objPtr->typePtr = &tkColorObjType;
+ objPtr->typePtr = &tkColorObjType.objType;
objPtr->internalRep.twoPtrValue.ptr1 = NULL;
}
@@ -822,9 +824,9 @@ TkDebugColor(
Tcl_Obj *objPtr = Tcl_NewObj();
Tcl_ListObjAppendElement(NULL, objPtr,
- Tcl_NewIntObj(tkColPtr->resourceRefCount));
+ Tcl_NewWideIntObj((Tcl_WideInt)tkColPtr->resourceRefCount));
Tcl_ListObjAppendElement(NULL, objPtr,
- Tcl_NewIntObj(tkColPtr->objRefCount));
+ Tcl_NewWideIntObj((Tcl_WideInt)tkColPtr->objRefCount));
Tcl_ListObjAppendElement(NULL, resultPtr, objPtr);
}
}
diff --git a/generic/tkColor.h b/generic/tkColor.h
index 46993e8..d4a1fa7 100644
--- a/generic/tkColor.h
+++ b/generic/tkColor.h
@@ -3,7 +3,7 @@
*
* Declarations of data types and functions used by the Tk color module.
*
- * Copyright (c) 1996-1997 Sun Microsystems, Inc.
+ * Copyright © 1996-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.
@@ -38,7 +38,7 @@ typedef struct TkColor {
Colormap colormap; /* Colormap from which this entry was
* allocated. */
Visual *visual; /* Visual associated with colormap. */
- int resourceRefCount; /* Number of active uses of this color (each
+ Tcl_Size resourceRefCount; /* Number of active uses of this color (each
* active use corresponds to a call to
* Tk_AllocColorFromObj or Tk_GetColor). If
* this count is 0, then this TkColor
@@ -48,7 +48,7 @@ typedef struct TkColor {
* referring to it. The structure is freed
* when resourceRefCount and objRefCount are
* both 0. */
- int objRefCount; /* The number of Tcl objects that reference
+ Tcl_Size objRefCount; /* The number of Tcl objects that reference
* this structure. */
int type; /* TK_COLOR_BY_NAME or TK_COLOR_BY_VALUE. */
Tcl_HashEntry *hashPtr; /* Pointer to hash table entry for this
diff --git a/generic/tkConfig.c b/generic/tkConfig.c
index 3c0bb51..3336467 100644
--- a/generic/tkConfig.c
+++ b/generic/tkConfig.c
@@ -4,7 +4,7 @@
* This file contains functions that manage configuration options for
* widgets and other things.
*
- * Copyright (c) 1997-1998 Sun Microsystems, Inc.
+ * Copyright © 1997-1998 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -31,13 +31,13 @@
#endif
/*
- * The following encoding is used in TYPE_FLAGS:
+ * The following encoding is used in TK_OPTION_VAR:
*
- * if sizeof(type) == sizeof(int) => TYPE_FLAGS(type) = 0
- * if sizeof(type) == 1 => TYPE_FLAGS(type) = 64
- * if sizeof(type) == 2 => TYPE_FLAGS(type) = 128
+ * if sizeof(type) == sizeof(int) => TK_OPTION_VAR(type) = 0
+ * if sizeof(type) == 1 => TK_OPTION_VAR(type) = 64
+ * if sizeof(type) == 2 => TK_OPTION_VAR(type) = 128
+ * if sizeof(type) == sizeof(long long) => TK_OPTION_VAR(type) = 192
*/
-#define TYPE_FLAGS(type) (((int)(sizeof(type)&(sizeof(int)-1))<<6))
#define TYPE_MASK (((((int)sizeof(int)-1))|3)<<6)
/*
@@ -105,7 +105,7 @@ typedef struct TkOption {
*/
typedef struct OptionTable {
- int refCount; /* Counts the number of uses of this table
+ size_t refCount; /* Counts the number of uses of this table
* (the number of times Tk_CreateOptionTable
* has returned it). This can be greater than
* 1 if it is shared along several option
@@ -117,7 +117,7 @@ typedef struct OptionTable {
* templates, this points to the table
* corresponding to the next template in the
* chain. */
- int numOptions; /* The number of items in the options array
+ size_t numOptions; /* The number of items in the options array
* below. */
Option options[1]; /* Information about the individual options in
* the table. This must be the last field in
@@ -129,14 +129,14 @@ typedef struct OptionTable {
* Forward declarations for functions defined later in this file:
*/
-static int DoObjConfig(Tcl_Interp *interp, char *recordPtr,
+static int DoObjConfig(Tcl_Interp *interp, void *recordPtr,
Option *optionPtr, Tcl_Obj *valuePtr,
Tk_Window tkwin, Tk_SavedOption *savePtr);
static void FreeResources(Option *optionPtr, Tcl_Obj *objPtr,
- char *internalPtr, Tk_Window tkwin);
-static Tcl_Obj * GetConfigList(char *recordPtr,
+ void *internalPtr, Tk_Window tkwin);
+static Tcl_Obj * GetConfigList(void *recordPtr,
Option *optionPtr, Tk_Window tkwin);
-static Tcl_Obj * GetObjectForOption(char *recordPtr,
+static Tcl_Obj * GetObjectForOption(void *recordPtr,
Option *optionPtr, Tk_Window tkwin);
static Option * GetOption(const char *name, OptionTable *tablePtr);
static Option * GetOptionFromObj(Tcl_Interp *interp,
@@ -152,12 +152,14 @@ static void DupOptionInternalRep(Tcl_Obj *, Tcl_Obj *);
* the internalPtr2 field points to the entry that matched.
*/
-static const Tcl_ObjType optionObjType = {
- "option", /* name */
+static const TkObjType optionObjType = {
+ {"option", /* name */
FreeOptionInternalRep, /* freeIntRepProc */
DupOptionInternalRep, /* dupIntRepProc */
NULL, /* updateStringProc */
- NULL /* setFromAnyProc */
+ NULL, /* setFromAnyProc */
+ TCL_OBJTYPE_V0},
+ 0
};
/*
@@ -191,7 +193,7 @@ Tk_CreateOptionTable(
OptionTable *tablePtr;
const Tk_OptionSpec *specPtr, *specPtr2;
Option *optionPtr;
- int numOptions, i;
+ size_t numOptions, i;
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
@@ -213,7 +215,7 @@ Tk_CreateOptionTable(
* reuse the existing table.
*/
- hashEntryPtr = Tcl_CreateHashEntry(&tsdPtr->hashTable, (char *) templatePtr,
+ hashEntryPtr = Tcl_CreateHashEntry(&tsdPtr->hashTable, (char *)templatePtr,
&newEntry);
if (!newEntry) {
tablePtr = (OptionTable *)Tcl_GetHashValue(hashEntryPtr);
@@ -260,7 +262,7 @@ Tk_CreateOptionTable(
Tcl_Panic("Tk_CreateOptionTable couldn't find synonym");
}
if (strcmp(specPtr2->optionName,
- (char *) specPtr->clientData) == 0) {
+ (char *)specPtr->clientData) == 0) {
optionPtr->extra.synonymPtr = tablePtr->options + i;
break;
}
@@ -273,14 +275,14 @@ Tk_CreateOptionTable(
optionPtr->dbClassUID = Tk_GetUid(specPtr->dbClass);
}
if (specPtr->defValue != NULL) {
- optionPtr->defaultPtr = Tcl_NewStringObj(specPtr->defValue,-1);
+ optionPtr->defaultPtr = Tcl_NewStringObj(specPtr->defValue, TCL_INDEX_NONE);
Tcl_IncrRefCount(optionPtr->defaultPtr);
}
if (((specPtr->type == TK_OPTION_COLOR)
|| (specPtr->type == TK_OPTION_BORDER))
&& (specPtr->clientData != NULL)) {
optionPtr->extra.monoColorPtr =
- Tcl_NewStringObj((const char *)specPtr->clientData, -1);
+ Tcl_NewStringObj((const char *)specPtr->clientData, TCL_INDEX_NONE);
Tcl_IncrRefCount(optionPtr->extra.monoColorPtr);
}
@@ -293,7 +295,7 @@ Tk_CreateOptionTable(
}
}
if (((specPtr->type == TK_OPTION_STRING)
- && (specPtr->internalOffset >= 0))
+ && (specPtr->internalOffset != TCL_INDEX_NONE))
|| (specPtr->type == TK_OPTION_COLOR)
|| (specPtr->type == TK_OPTION_FONT)
|| (specPtr->type == TK_OPTION_BITMAP)
@@ -344,7 +346,7 @@ Tk_DeleteOptionTable(
{
OptionTable *tablePtr = (OptionTable *) optionTable;
Option *optionPtr;
- int count;
+ size_t count;
if (tablePtr->refCount-- > 1) {
return;
@@ -395,7 +397,7 @@ int
Tk_InitOptions(
Tcl_Interp *interp, /* Interpreter for error reporting. NULL means
* don't leave an error message. */
- char *recordPtr, /* Pointer to the record to configure. Note:
+ void *recordPtr, /* Pointer to the record to configure. Note:
* the caller should have properly initialized
* the record with NULL pointers for each
* option value. */
@@ -410,7 +412,7 @@ Tk_InitOptions(
{
OptionTable *tablePtr = (OptionTable *) optionTable;
Option *optionPtr;
- int count;
+ size_t count;
Tk_Uid value;
Tcl_Obj *valuePtr;
enum {
@@ -458,7 +460,7 @@ Tk_InitOptions(
value = Tk_GetOption(tkwin, optionPtr->dbNameUID,
optionPtr->dbClassUID);
if (value != NULL) {
- valuePtr = Tcl_NewStringObj(value, -1);
+ valuePtr = Tcl_NewStringObj(value, TCL_INDEX_NONE);
source = OPTION_DATABASE;
}
}
@@ -469,7 +471,7 @@ Tk_InitOptions(
if ((valuePtr == NULL)
&& (optionPtr->dbNameUID != NULL)) {
- valuePtr = TkpGetSystemDefault(tkwin, optionPtr->dbNameUID,
+ valuePtr = Tk_GetSystemDefault(tkwin, optionPtr->dbNameUID,
optionPtr->dbClassUID);
if (valuePtr != NULL) {
source = SYSTEM_DEFAULT;
@@ -566,7 +568,7 @@ DoObjConfig(
Tcl_Interp *interp, /* Interpreter for error reporting. If NULL,
* then no message is left if an error
* occurs. */
- char *recordPtr, /* The record to modify to hold the new option
+ void *recordPtr, /* The record to modify to hold the new option
* value. */
Option *optionPtr, /* Pointer to information about the option. */
Tcl_Obj *valuePtr, /* New value for option. */
@@ -582,10 +584,10 @@ DoObjConfig(
* free the old value). */
{
Tcl_Obj **slotPtrPtr, *oldPtr;
- char *internalPtr; /* Points to location in record where internal
+ void *internalPtr; /* Points to location in record where internal
* representation of value should be stored,
* or NULL. */
- char *oldInternalPtr; /* Points to location in which to save old
+ void *oldInternalPtr; /* Points to location in which to save old
* internal representation of value. */
Tk_SavedOption internal; /* Used to save the old internal
* representation of the value if
@@ -598,8 +600,8 @@ DoObjConfig(
*/
specPtr = optionPtr->specPtr;
- if (specPtr->objOffset >= 0) {
- slotPtrPtr = (Tcl_Obj **) (recordPtr + specPtr->objOffset);
+ if (specPtr->objOffset != TCL_INDEX_NONE) {
+ slotPtrPtr = (Tcl_Obj **) ((char *)recordPtr + specPtr->objOffset);
oldPtr = *slotPtrPtr;
} else {
slotPtrPtr = NULL;
@@ -611,41 +613,111 @@ DoObjConfig(
* object and internal forms, if they exist.
*/
- if (specPtr->internalOffset >= 0) {
- internalPtr = recordPtr + specPtr->internalOffset;
+ if (specPtr->internalOffset != TCL_INDEX_NONE) {
+ internalPtr = (char *)recordPtr + specPtr->internalOffset;
} else {
internalPtr = NULL;
}
if (savedOptionPtr != NULL) {
savedOptionPtr->optionPtr = optionPtr;
savedOptionPtr->valuePtr = oldPtr;
- oldInternalPtr = (char *) &savedOptionPtr->internalForm;
+ oldInternalPtr = (char *)&savedOptionPtr->internalForm;
} else {
- oldInternalPtr = (char *) &internal.internalForm;
+ oldInternalPtr = (char *)&internal.internalForm;
}
- nullOK = (optionPtr->specPtr->flags & (TK_OPTION_NULL_OK|32 /* TCL_NULL_OK */));
+ nullOK = (optionPtr->specPtr->flags & (TK_OPTION_NULL_OK|TCL_NULL_OK|1));
switch (optionPtr->specPtr->type) {
case TK_OPTION_BOOLEAN: {
int newBool;
- if (Tcl_GetBooleanFromObj(interp, valuePtr, &newBool) != TCL_OK) {
+ if (nullOK && ObjectIsEmpty(valuePtr)) {
+ valuePtr = NULL;
+ newBool = -1;
+ } else if (Tcl_GetBooleanFromObj(nullOK ? NULL : interp, valuePtr, &newBool) != TCL_OK) {
+ if (nullOK && interp) {
+ Tcl_AppendResult(interp, "expected boolean value or \"\" but got \"",
+ Tcl_GetString(valuePtr), "\"", NULL);
+ }
return TCL_ERROR;
}
if (internalPtr != NULL) {
- *((int *) oldInternalPtr) = *((int *) internalPtr);
- *((int *) internalPtr) = newBool;
+ if (optionPtr->specPtr->flags & TYPE_MASK) {
+ if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(char)) {
+ *((char *)oldInternalPtr) = *((char *)internalPtr);
+ *((char *)internalPtr) = (char)newBool;
+ } else if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(short)) {
+ *((short *)oldInternalPtr) = *((short *)internalPtr);
+ *((short *)internalPtr) = (short)newBool;
+ } else {
+ Tcl_Panic("Invalid flags for %s", "TK_OPTION_BOOLEAN");
+ }
+ } else {
+ *((int *)oldInternalPtr) = *((int *)internalPtr);
+ *((int *)internalPtr) = newBool;
+ }
}
break;
}
case TK_OPTION_INT: {
int newInt;
- if (Tcl_GetIntFromObj(interp, valuePtr, &newInt) != TCL_OK) {
+ if ((optionPtr->specPtr->flags & TYPE_MASK) == 0) {
+ if (nullOK && ObjectIsEmpty(valuePtr)) {
+ valuePtr = NULL;
+ newInt = INT_MIN;
+ } else if (Tcl_GetIntFromObj(nullOK ? NULL : interp, valuePtr, &newInt) != TCL_OK) {
+ invalidIntValue:
+ if (nullOK && interp) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "expected integer or \"\" but got \"%.50s\"", Tcl_GetString(valuePtr)));
+ Tcl_SetErrorCode(interp, "TCL", "VALUE", "NUMBER", (char *)NULL);
+ }
+ return TCL_ERROR;
+ }
+ if (internalPtr != NULL) {
+ *((int *)oldInternalPtr) = *((int *)internalPtr);
+ *((int *)internalPtr) = newInt;
+ }
+ } else if ((optionPtr->specPtr->flags & TYPE_MASK) == TYPE_MASK) {
+ Tcl_WideInt newWideInt;
+ if (nullOK && ObjectIsEmpty(valuePtr)) {
+ valuePtr = NULL;
+ newWideInt = (sizeof(long) > sizeof(int)) ? LONG_MIN : LLONG_MIN;
+ } else if (Tcl_GetWideIntFromObj(nullOK ? NULL : interp, valuePtr, &newWideInt) != TCL_OK) {
+ goto invalidIntValue;
+ }
+ if (internalPtr != NULL) {
+ if (sizeof(long) > sizeof(int)) {
+ *((long *)oldInternalPtr) = *((long *)internalPtr);
+ *((long *)internalPtr) = (long)newWideInt;
+ } else {
+ *((long long *)oldInternalPtr) = *((long long *)internalPtr);
+ *((long long *)internalPtr) = (long long)newWideInt;
+ }
+ }
+ } else {
+ Tcl_Panic("Invalid flags for %s", "TK_OPTION_INT");
+ }
+ break;
+ }
+ case TK_OPTION_INDEX: {
+ Tcl_Size newIndex;
+
+ if (TkGetIntForIndex(valuePtr, TCL_INDEX_NONE, 0, &newIndex) != TCL_OK) {
+ if (interp) {
+ Tcl_AppendResult(interp, "bad index \"", Tcl_GetString(valuePtr),
+ "\": must be integer?[+-]integer?, end?[+-]integer?, or \"\"", NULL);
+ }
return TCL_ERROR;
}
+ if (newIndex < INT_MIN) {
+ newIndex = INT_MIN;
+ } else if (newIndex > INT_MAX) {
+ newIndex = INT_MAX;
+ }
if (internalPtr != NULL) {
- *((int *) oldInternalPtr) = *((int *) internalPtr);
- *((int *) internalPtr) = newInt;
+ *((int *)oldInternalPtr) = *((int *)internalPtr);
+ *((int *)internalPtr) = (int)newIndex;
}
break;
}
@@ -654,23 +726,35 @@ DoObjConfig(
if (nullOK && ObjectIsEmpty(valuePtr)) {
valuePtr = NULL;
- newDbl = 0;
+#if defined(NAN)
+ newDbl = NAN;
+#else
+ newDbl = 0.0;
+#endif
} else {
- if (Tcl_GetDoubleFromObj(interp, valuePtr, &newDbl) != TCL_OK) {
+ if (Tcl_GetDoubleFromObj(nullOK ? NULL : interp, valuePtr, &newDbl) != TCL_OK) {
+ if (nullOK && interp) {
+ Tcl_Obj *msg = Tcl_NewStringObj("expected floating-point number or \"\" but got \"", TCL_INDEX_NONE);
+
+ Tcl_AppendLimitedToObj(msg, Tcl_GetString(valuePtr), TCL_INDEX_NONE, 50, "");
+ Tcl_AppendToObj(msg, "\"", TCL_INDEX_NONE);
+ Tcl_SetObjResult(interp, msg);
+ Tcl_SetErrorCode(interp, "TCL", "VALUE", "NUMBER", (char *)NULL);
+ }
return TCL_ERROR;
}
}
if (internalPtr != NULL) {
- *((double *) oldInternalPtr) = *((double *) internalPtr);
- *((double *) internalPtr) = newDbl;
+ *((double *)oldInternalPtr) = *((double *)internalPtr);
+ *((double *)internalPtr) = newDbl;
}
break;
}
case TK_OPTION_STRING: {
char *newStr;
const char *value;
- int length;
+ Tcl_Size length;
if (nullOK && ObjectIsEmpty(valuePtr)) {
valuePtr = NULL;
@@ -683,8 +767,8 @@ DoObjConfig(
} else {
newStr = NULL;
}
- *((char **) oldInternalPtr) = *((char **) internalPtr);
- *((char **) internalPtr) = newStr;
+ *((char **)oldInternalPtr) = *((char **)internalPtr);
+ *((char **)internalPtr) = newStr;
}
break;
}
@@ -697,24 +781,28 @@ DoObjConfig(
} else {
if (Tcl_GetIndexFromObjStruct(interp, valuePtr,
optionPtr->specPtr->clientData, sizeof(char *),
- optionPtr->specPtr->optionName+1, 0, &newValue) != TCL_OK) {
+ optionPtr->specPtr->optionName+1, (nullOK ? TCL_NULL_OK : 0), &newValue) != TCL_OK) {
return TCL_ERROR;
}
+ if (slotPtrPtr != NULL && valuePtr != NULL) {
+ valuePtr = Tcl_DuplicateObj(valuePtr);
+ Tcl_InvalidateStringRep(valuePtr);
+ }
}
if (internalPtr != NULL) {
if (optionPtr->specPtr->flags & TYPE_MASK) {
- if ((optionPtr->specPtr->flags & TYPE_MASK) == TYPE_FLAGS(char)) {
- *((char *) oldInternalPtr) = *((char *) internalPtr);
- *((char *) internalPtr) = newValue;
- } else if ((optionPtr->specPtr->flags & TYPE_MASK) == TYPE_FLAGS(short)) {
- *((short *) oldInternalPtr) = *((short *) internalPtr);
- *((short *) internalPtr) = newValue;
+ if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(char)) {
+ *((char *)oldInternalPtr) = *((char *)internalPtr);
+ *((char *)internalPtr) = (char)newValue;
+ } else if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(short)) {
+ *((short *)oldInternalPtr) = *((short *)internalPtr);
+ *((short *)internalPtr) = (short)newValue;
} else {
Tcl_Panic("Invalid flags for %s", "TK_OPTION_STRING_TABLE");
}
} else {
- *((int *) oldInternalPtr) = *((int *) internalPtr);
- *((int *) internalPtr) = newValue;
+ *((int *)oldInternalPtr) = *((int *)internalPtr);
+ *((int *)internalPtr) = newValue;
}
}
break;
@@ -732,8 +820,8 @@ DoObjConfig(
}
}
if (internalPtr != NULL) {
- *((XColor **) oldInternalPtr) = *((XColor **) internalPtr);
- *((XColor **) internalPtr) = newPtr;
+ *((XColor **)oldInternalPtr) = *((XColor **)internalPtr);
+ *((XColor **)internalPtr) = newPtr;
}
break;
}
@@ -750,8 +838,8 @@ DoObjConfig(
}
}
if (internalPtr != NULL) {
- *((Tk_Font *) oldInternalPtr) = *((Tk_Font *) internalPtr);
- *((Tk_Font *) internalPtr) = newFont;
+ *((Tk_Font *)oldInternalPtr) = *((Tk_Font *)internalPtr);
+ *((Tk_Font *)internalPtr) = newFont;
}
break;
}
@@ -768,8 +856,8 @@ DoObjConfig(
}
}
if (internalPtr != NULL) {
- *((Tk_Style *) oldInternalPtr) = *((Tk_Style *) internalPtr);
- *((Tk_Style *) internalPtr) = newStyle;
+ *((Tk_Style *)oldInternalPtr) = *((Tk_Style *)internalPtr);
+ *((Tk_Style *)internalPtr) = newStyle;
}
break;
}
@@ -786,8 +874,8 @@ DoObjConfig(
}
}
if (internalPtr != NULL) {
- *((Pixmap *) oldInternalPtr) = *((Pixmap *) internalPtr);
- *((Pixmap *) internalPtr) = newBitmap;
+ *((Pixmap *)oldInternalPtr) = *((Pixmap *)internalPtr);
+ *((Pixmap *)internalPtr) = newBitmap;
}
break;
}
@@ -804,8 +892,8 @@ DoObjConfig(
}
}
if (internalPtr != NULL) {
- *((Tk_3DBorder *) oldInternalPtr) = *((Tk_3DBorder *) internalPtr);
- *((Tk_3DBorder *) internalPtr) = newBorder;
+ *((Tk_3DBorder *)oldInternalPtr) = *((Tk_3DBorder *)internalPtr);
+ *((Tk_3DBorder *)internalPtr) = newBorder;
}
break;
}
@@ -815,14 +903,29 @@ DoObjConfig(
if (nullOK && ObjectIsEmpty(valuePtr)) {
valuePtr = NULL;
newRelief = TK_RELIEF_NULL;
- } else {
- if (Tk_GetReliefFromObj(interp, valuePtr, &newRelief) != TCL_OK) {
- return TCL_ERROR;
- }
+ } else if (Tcl_GetIndexFromObj(interp, valuePtr, tkReliefStrings,
+ "relief", (nullOK ? TCL_NULL_OK : 0), &newRelief) != TCL_OK) {
+ return TCL_ERROR;
}
if (internalPtr != NULL) {
- *((int *) oldInternalPtr) = *((int *) internalPtr);
- *((int *) internalPtr) = newRelief;
+ if (optionPtr->specPtr->flags & TYPE_MASK) {
+ if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(char)) {
+ *((char *)oldInternalPtr) = *((char *)internalPtr);
+ *((char *)internalPtr) = (char)newRelief;
+ } else if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(short)) {
+ *((short *)oldInternalPtr) = *((short *)internalPtr);
+ *((short *)internalPtr) = (short)newRelief;
+ } else {
+ Tcl_Panic("Invalid flags for %s", "TK_OPTION_RELIEF");
+ }
+ } else {
+ *((int *)oldInternalPtr) = *((int *)internalPtr);
+ *((int *)internalPtr) = newRelief;
+ }
+ }
+ if (slotPtrPtr != NULL && valuePtr != NULL) {
+ valuePtr = Tcl_DuplicateObj(valuePtr);
+ Tcl_InvalidateStringRep(valuePtr);
}
break;
}
@@ -846,26 +949,66 @@ DoObjConfig(
break;
}
case TK_OPTION_JUSTIFY: {
- Tk_Justify newJustify;
+ int newJustify;
- if (Tk_GetJustifyFromObj(interp, valuePtr, &newJustify) != TCL_OK) {
+ if (nullOK && ObjectIsEmpty(valuePtr)) {
+ valuePtr = NULL;
+ newJustify = -1;
+ } else if (Tcl_GetIndexFromObj(interp, valuePtr, tkJustifyStrings,
+ "justification", (nullOK ? TCL_NULL_OK : 0), &newJustify) != TCL_OK) {
return TCL_ERROR;
}
if (internalPtr != NULL) {
- *((Tk_Justify *) oldInternalPtr) = *((Tk_Justify *) internalPtr);
- *((Tk_Justify *) internalPtr) = newJustify;
+ if (optionPtr->specPtr->flags & TYPE_MASK) {
+ if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(char)) {
+ *((char *)oldInternalPtr) = *((char *)internalPtr);
+ *((char *)internalPtr) = (char)newJustify;
+ } else if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(short)) {
+ *((short *)oldInternalPtr) = *((short *)internalPtr);
+ *((short *)internalPtr) = (short)newJustify;
+ } else {
+ Tcl_Panic("Invalid flags for %s", "TK_OPTION_JUSTIFY");
+ }
+ } else {
+ *((int *)oldInternalPtr) = *((int *)internalPtr);
+ *((int *)internalPtr) = newJustify;
+ }
+ }
+ if (slotPtrPtr != NULL && valuePtr != NULL) {
+ valuePtr = Tcl_DuplicateObj(valuePtr);
+ Tcl_InvalidateStringRep(valuePtr);
}
break;
}
case TK_OPTION_ANCHOR: {
- Tk_Anchor newAnchor;
+ int newAnchor;
- if (Tk_GetAnchorFromObj(interp, valuePtr, &newAnchor) != TCL_OK) {
+ if (nullOK && ObjectIsEmpty(valuePtr)) {
+ valuePtr = NULL;
+ newAnchor = -1;
+ } else if (Tcl_GetIndexFromObj(interp, valuePtr, tkAnchorStrings,
+ "anchor", (nullOK ? TCL_NULL_OK : 0), &newAnchor) != TCL_OK) {
return TCL_ERROR;
}
if (internalPtr != NULL) {
- *((Tk_Anchor *) oldInternalPtr) = *((Tk_Anchor *) internalPtr);
- *((Tk_Anchor *) internalPtr) = newAnchor;
+ if (optionPtr->specPtr->flags & TYPE_MASK) {
+ if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(char)) {
+ *((char *)oldInternalPtr) = *((char *)internalPtr);
+ *((char *)internalPtr) = (char)newAnchor;
+ } else if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(short)) {
+ *((short *)oldInternalPtr) = *((short *)internalPtr);
+ *((short *)internalPtr) = (short)newAnchor;
+ } else {
+ Tcl_Panic("Invalid flags for %s", "TK_OPTION_JUSTIFY");
+ }
+ } else {
+ *((int *)oldInternalPtr) = *((int *)internalPtr);
+ *((int *)internalPtr) = newAnchor;
+ }
+ }
+ if (slotPtrPtr != NULL && valuePtr != NULL) {
+ valuePtr = Tcl_DuplicateObj(valuePtr);
+ Tcl_InvalidateStringRep(valuePtr);
}
break;
}
@@ -874,14 +1017,19 @@ DoObjConfig(
if (nullOK && ObjectIsEmpty(valuePtr)) {
valuePtr = NULL;
- newPixels = 0;
- } else if (Tk_GetPixelsFromObj(interp, tkwin, valuePtr,
+ newPixels = INT_MIN;
+ } else if (Tk_GetPixelsFromObj(nullOK ? NULL : interp, tkwin, valuePtr,
&newPixels) != TCL_OK) {
+ if (nullOK) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "expected screen distance or \"\" but got \"%.50s\"", Tcl_GetString(valuePtr)));
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "PIXELS", (char *)NULL);
+ }
return TCL_ERROR;
}
if (internalPtr != NULL) {
- *((int *) oldInternalPtr) = *((int *) internalPtr);
- *((int *) internalPtr) = newPixels;
+ *((int *)oldInternalPtr) = *((int *)internalPtr);
+ *((int *)internalPtr) = newPixels;
}
break;
}
@@ -896,8 +1044,8 @@ DoObjConfig(
return TCL_ERROR;
}
if (internalPtr != NULL) {
- *((Tk_Window *) oldInternalPtr) = *((Tk_Window *) internalPtr);
- *((Tk_Window *) internalPtr) = newWin;
+ *((Tk_Window *)oldInternalPtr) = *((Tk_Window *)internalPtr);
+ *((Tk_Window *)internalPtr) = newWin;
}
break;
}
@@ -905,7 +1053,7 @@ DoObjConfig(
const Tk_ObjCustomOption *custom = optionPtr->extra.custom;
if (custom->setProc(custom->clientData, interp, tkwin,
- &valuePtr, recordPtr, optionPtr->specPtr->internalOffset,
+ &valuePtr, (char *)recordPtr, optionPtr->specPtr->internalOffset,
(char *)oldInternalPtr, optionPtr->specPtr->flags) != TCL_OK) {
return TCL_ERROR;
}
@@ -916,7 +1064,7 @@ DoObjConfig(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad config table: unknown type %d",
optionPtr->specPtr->type));
- Tcl_SetErrorCode(interp, "TK", "BAD_CONFIG", NULL);
+ Tcl_SetErrorCode(interp, "TK", "BAD_CONFIG", (char *)NULL);
return TCL_ERROR;
}
@@ -1001,7 +1149,7 @@ GetOption(
Option *bestPtr, *optionPtr;
OptionTable *tablePtr2;
const char *p1, *p2;
- int count;
+ size_t count;
/*
* Search through all of the option tables in the chain to find the best
@@ -1093,7 +1241,7 @@ GetOptionFromObj(
* First, check to see if the object already has the answer cached.
*/
- if (objPtr->typePtr == &optionObjType) {
+ if (objPtr->typePtr == &optionObjType.objType) {
if (objPtr->internalRep.twoPtrValue.ptr1 == (void *) tablePtr) {
return (Option *) objPtr->internalRep.twoPtrValue.ptr2;
}
@@ -1115,7 +1263,7 @@ GetOptionFromObj(
}
objPtr->internalRep.twoPtrValue.ptr1 = (void *) tablePtr;
objPtr->internalRep.twoPtrValue.ptr2 = (void *) bestPtr;
- objPtr->typePtr = &optionObjType;
+ objPtr->typePtr = &optionObjType.objType;
tablePtr->refCount++;
return bestPtr;
@@ -1123,7 +1271,7 @@ GetOptionFromObj(
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"unknown option \"%s\"", name));
- Tcl_SetErrorCode(interp, "TK", "LOOKUP", "OPTION", name, NULL);
+ Tcl_SetErrorCode(interp, "TK", "LOOKUP", "OPTION", name, (char *)NULL);
}
return NULL;
}
@@ -1249,9 +1397,9 @@ int
Tk_SetOptions(
Tcl_Interp *interp, /* Interpreter for error reporting. If NULL,
* then no error message is returned.*/
- char *recordPtr, /* The record to configure. */
+ void *recordPtr, /* The record to configure. */
Tk_OptionTable optionTable, /* Describes valid options. */
- int objc, /* The number of elements in objv. */
+ Tcl_Size objc, /* The number of elements in objv. */
Tcl_Obj *const objv[], /* Contains one or more name-value pairs. */
Tk_Window tkwin, /* Window associated with the thing being
* configured; needed for some options (such
@@ -1299,7 +1447,7 @@ Tk_SetOptions(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"value for \"%s\" missing",
Tcl_GetString(*objv)));
- Tcl_SetErrorCode(interp, "TK", "VALUE_MISSING", NULL);
+ Tcl_SetErrorCode(interp, "TK", "VALUE_MISSING", (char *)NULL);
goto error;
}
}
@@ -1367,12 +1515,12 @@ Tk_RestoreSavedOptions(
Tk_SavedOptions *savePtr) /* Holds saved option information; must have
* been passed to Tk_SetOptions. */
{
- int i;
+ Tcl_Size i;
Option *optionPtr;
Tcl_Obj *newPtr; /* New object value of option, which we
* replace with old value and free. Taken from
* record. */
- char *internalPtr; /* Points to internal value of option in
+ void *internalPtr; /* Points to internal value of option in
* record. */
const Tk_OptionSpec *specPtr;
@@ -1397,12 +1545,12 @@ Tk_RestoreSavedOptions(
*/
if (specPtr->objOffset >= 0) {
- newPtr = *((Tcl_Obj **) (savePtr->recordPtr + specPtr->objOffset));
+ newPtr = *((Tcl_Obj **) ((char *)savePtr->recordPtr + specPtr->objOffset));
} else {
newPtr = NULL;
}
if (specPtr->internalOffset >= 0) {
- internalPtr = savePtr->recordPtr + specPtr->internalOffset;
+ internalPtr = (char *)savePtr->recordPtr + specPtr->internalOffset;
} else {
internalPtr = NULL;
}
@@ -1417,78 +1565,135 @@ Tk_RestoreSavedOptions(
* Now restore the old value of the option.
*/
- if (specPtr->objOffset >= 0) {
- *((Tcl_Obj **) (savePtr->recordPtr + specPtr->objOffset))
+ if (specPtr->objOffset != TCL_INDEX_NONE) {
+ *((Tcl_Obj **) ((char *)savePtr->recordPtr + specPtr->objOffset))
= savePtr->items[i].valuePtr;
}
- if (specPtr->internalOffset >= 0) {
- char *ptr = (char *) &savePtr->items[i].internalForm;
+ if (specPtr->internalOffset != TCL_INDEX_NONE) {
+ char *ptr = (char *)&savePtr->items[i].internalForm;
CLANG_ASSERT(internalPtr);
switch (specPtr->type) {
case TK_OPTION_BOOLEAN:
+ if (optionPtr->specPtr->flags & TYPE_MASK) {
+ if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(char)) {
+ *((char *)internalPtr) = *((char *)ptr);
+ } else if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(short)) {
+ *((short *)internalPtr) = *((short *)ptr);
+ } else {
+ Tcl_Panic("Invalid flags for %s", "TK_OPTION_BOOLEAN");
+ }
+ } else {
+ *((int *)internalPtr) = *((int *)ptr);
+ }
+ break;
case TK_OPTION_INT:
- *((int *) internalPtr) = *((int *) ptr);
+ if (optionPtr->specPtr->flags & TYPE_MASK) {
+ if ((optionPtr->specPtr->flags & TYPE_MASK) == TYPE_MASK) {
+ if (sizeof(long) > sizeof(int)) {
+ *((long *)internalPtr) = *((long *)ptr);
+ } else {
+ *((long long *)internalPtr) = *((long long *)ptr);
+ }
+ } else {
+ Tcl_Panic("Invalid flags for %s", "TK_OPTION_INT");
+ }
+ } else {
+ *((int *)internalPtr) = *((int *)ptr);
+ }
+ break;
+ case TK_OPTION_INDEX:
+ *((int *)internalPtr) = *((int *)ptr);
break;
case TK_OPTION_DOUBLE:
- *((double *) internalPtr) = *((double *) ptr);
+ *((double *)internalPtr) = *((double *)ptr);
break;
case TK_OPTION_STRING:
- *((char **) internalPtr) = *((char **) ptr);
+ *((char **)internalPtr) = *((char **)ptr);
break;
case TK_OPTION_STRING_TABLE:
if (optionPtr->specPtr->flags & TYPE_MASK) {
- if ((optionPtr->specPtr->flags & TYPE_MASK) == TYPE_FLAGS(char)) {
- *((char *) internalPtr) = *((char *) ptr);
- } else if ((optionPtr->specPtr->flags & TYPE_MASK) == TYPE_FLAGS(short)) {
- *((short *) internalPtr) = *((short *) ptr);
+ if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(char)) {
+ *((char *)internalPtr) = *((char *)ptr);
+ } else if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(short)) {
+ *((short *)internalPtr) = *((short *)ptr);
} else {
Tcl_Panic("Invalid flags for %s", "TK_OPTION_STRING_TABLE");
}
} else {
- *((int *) internalPtr) = *((int *) ptr);
+ *((int *)internalPtr) = *((int *)ptr);
}
break;
case TK_OPTION_COLOR:
- *((XColor **) internalPtr) = *((XColor **) ptr);
+ *((XColor **)internalPtr) = *((XColor **)ptr);
break;
case TK_OPTION_FONT:
- *((Tk_Font *) internalPtr) = *((Tk_Font *) ptr);
+ *((Tk_Font *)internalPtr) = *((Tk_Font *)ptr);
break;
case TK_OPTION_STYLE:
- *((Tk_Style *) internalPtr) = *((Tk_Style *) ptr);
+ *((Tk_Style *)internalPtr) = *((Tk_Style *)ptr);
break;
case TK_OPTION_BITMAP:
- *((Pixmap *) internalPtr) = *((Pixmap *) ptr);
+ *((Pixmap *)internalPtr) = *((Pixmap *)ptr);
break;
case TK_OPTION_BORDER:
- *((Tk_3DBorder *) internalPtr) = *((Tk_3DBorder *) ptr);
+ *((Tk_3DBorder *)internalPtr) = *((Tk_3DBorder *)ptr);
break;
case TK_OPTION_RELIEF:
- *((int *) internalPtr) = *((int *) ptr);
+ if (optionPtr->specPtr->flags & TYPE_MASK) {
+ if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(char)) {
+ *((char *)internalPtr) = *((char *)ptr);
+ } else if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(short)) {
+ *((short *)internalPtr) = *((short *)ptr);
+ } else {
+ Tcl_Panic("Invalid flags for %s", "TK_OPTION_RELIEF");
+ }
+ } else {
+ *((int *)internalPtr) = *((int *)ptr);
+ }
break;
case TK_OPTION_CURSOR:
*((Tk_Cursor *) internalPtr) = *((Tk_Cursor *) ptr);
Tk_DefineCursor(savePtr->tkwin, *((Tk_Cursor *) internalPtr));
break;
case TK_OPTION_JUSTIFY:
- *((Tk_Justify *) internalPtr) = *((Tk_Justify *) ptr);
+ if (optionPtr->specPtr->flags & TYPE_MASK) {
+ if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(char)) {
+ *((char *)internalPtr) = *((char *)ptr);
+ } else if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(short)) {
+ *((short *)internalPtr) = *((short *)ptr);
+ } else {
+ Tcl_Panic("Invalid flags for %s", "TK_OPTION_JUSTIFY");
+ }
+ } else {
+ *((int *)internalPtr) = *((int *)ptr);
+ }
break;
case TK_OPTION_ANCHOR:
- *((Tk_Anchor *) internalPtr) = *((Tk_Anchor *) ptr);
+ if (optionPtr->specPtr->flags & TYPE_MASK) {
+ if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(char)) {
+ *((char *)internalPtr) = *((char *)ptr);
+ } else if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(short)) {
+ *((short *)internalPtr) = *((short *)ptr);
+ } else {
+ Tcl_Panic("Invalid flags for %s", "TK_OPTION_ANCHOR");
+ }
+ } else {
+ *((int *)internalPtr) = *((int *)ptr);
+ }
break;
case TK_OPTION_PIXELS:
- *((int *) internalPtr) = *((int *) ptr);
+ *((int *)internalPtr) = *((int *)ptr);
break;
case TK_OPTION_WINDOW:
- *((Tk_Window *) internalPtr) = *((Tk_Window *) ptr);
+ *((Tk_Window *)internalPtr) = *((Tk_Window *)ptr);
break;
case TK_OPTION_CUSTOM: {
const Tk_ObjCustomOption *custom = optionPtr->extra.custom;
if (custom->restoreProc != NULL) {
custom->restoreProc(custom->clientData, savePtr->tkwin,
- internalPtr, ptr);
+ (char *)internalPtr, ptr);
}
break;
}
@@ -1522,7 +1727,7 @@ Tk_FreeSavedOptions(
Tk_SavedOptions *savePtr) /* Contains options saved in a previous call
* to Tk_SetOptions. */
{
- int count;
+ size_t count;
Tk_SavedOption *savedOptionPtr;
if (savePtr->nextPtr != NULL) {
@@ -1533,7 +1738,7 @@ Tk_FreeSavedOptions(
savedOptionPtr = &savePtr->items[count-1];
if (savedOptionPtr->optionPtr->flags & OPTION_NEEDS_FREEING) {
FreeResources(savedOptionPtr->optionPtr, savedOptionPtr->valuePtr,
- (char *) &savedOptionPtr->internalForm, savePtr->tkwin);
+ (char *)&savedOptionPtr->internalForm, savePtr->tkwin);
}
if (savedOptionPtr->valuePtr != NULL) {
Tcl_DecrRefCount(savedOptionPtr->valuePtr);
@@ -1560,7 +1765,7 @@ Tk_FreeSavedOptions(
void
Tk_FreeConfigOptions(
- char *recordPtr, /* Record whose fields contain current values
+ void *recordPtr, /* Record whose fields contain current values
* for options. */
Tk_OptionTable optionTable, /* Describes legal options. */
Tk_Window tkwin) /* Window associated with recordPtr; needed
@@ -1568,9 +1773,9 @@ Tk_FreeConfigOptions(
{
OptionTable *tablePtr;
Option *optionPtr;
- int count;
+ size_t count;
Tcl_Obj **oldPtrPtr, *oldPtr;
- char *oldInternalPtr;
+ void *oldInternalPtr;
const Tk_OptionSpec *specPtr;
for (tablePtr = (OptionTable *) optionTable; tablePtr != NULL;
@@ -1581,15 +1786,15 @@ Tk_FreeConfigOptions(
if (specPtr->type == TK_OPTION_SYNONYM) {
continue;
}
- if (specPtr->objOffset >= 0) {
- oldPtrPtr = (Tcl_Obj **) (recordPtr + specPtr->objOffset);
+ if (specPtr->objOffset != TCL_INDEX_NONE) {
+ oldPtrPtr = (Tcl_Obj **) ((char *)recordPtr + specPtr->objOffset);
oldPtr = *oldPtrPtr;
*oldPtrPtr = NULL;
} else {
oldPtr = NULL;
}
- if (specPtr->internalOffset >= 0) {
- oldInternalPtr = recordPtr + specPtr->internalOffset;
+ if (specPtr->internalOffset != TCL_INDEX_NONE) {
+ oldInternalPtr = (char *)recordPtr + specPtr->internalOffset;
} else {
oldInternalPtr = NULL;
}
@@ -1626,10 +1831,10 @@ FreeResources(
Option *optionPtr, /* Description of the configuration option. */
Tcl_Obj *objPtr, /* The current value of the option, specified
* as an object. */
- char *internalPtr, /* A pointer to an internal representation for
+ void *internalPtr, /* A pointer to an internal representation for
* the option's value, such as an int or
* (XColor *). Only valid if
- * optionPtr->specPtr->internalOffset >= 0. */
+ * optionPtr->specPtr->internalOffset != -1. */
Tk_Window tkwin) /* The window in which this option is used. */
{
int internalFormExists;
@@ -1640,21 +1845,21 @@ FreeResources(
* form, then use the object form.
*/
- internalFormExists = optionPtr->specPtr->internalOffset >= 0;
+ internalFormExists = optionPtr->specPtr->internalOffset != TCL_INDEX_NONE;
switch (optionPtr->specPtr->type) {
case TK_OPTION_STRING:
if (internalFormExists) {
- if (*((char **) internalPtr) != NULL) {
- ckfree(*((char **) internalPtr));
- *((char **) internalPtr) = NULL;
+ if (*((char **)internalPtr) != NULL) {
+ ckfree(*((char **)internalPtr));
+ *((char **)internalPtr) = NULL;
}
}
break;
case TK_OPTION_COLOR:
if (internalFormExists) {
- if (*((XColor **) internalPtr) != NULL) {
- Tk_FreeColor(*((XColor **) internalPtr));
- *((XColor **) internalPtr) = NULL;
+ if (*((XColor **)internalPtr) != NULL) {
+ Tk_FreeColor(*((XColor **)internalPtr));
+ *((XColor **)internalPtr) = NULL;
}
} else if (objPtr != NULL) {
Tk_FreeColorFromObj(tkwin, objPtr);
@@ -1662,23 +1867,23 @@ FreeResources(
break;
case TK_OPTION_FONT:
if (internalFormExists) {
- Tk_FreeFont(*((Tk_Font *) internalPtr));
- *((Tk_Font *) internalPtr) = NULL;
+ Tk_FreeFont(*((Tk_Font *)internalPtr));
+ *((Tk_Font *)internalPtr) = NULL;
} else if (objPtr != NULL) {
Tk_FreeFontFromObj(tkwin, objPtr);
}
break;
case TK_OPTION_STYLE:
if (internalFormExists) {
- Tk_FreeStyle(*((Tk_Style *) internalPtr));
- *((Tk_Style *) internalPtr) = NULL;
+ Tk_FreeStyle(*((Tk_Style *)internalPtr));
+ *((Tk_Style *)internalPtr) = NULL;
}
break;
case TK_OPTION_BITMAP:
if (internalFormExists) {
- if (*((Pixmap *) internalPtr) != None) {
- Tk_FreeBitmap(Tk_Display(tkwin), *((Pixmap *) internalPtr));
- *((Pixmap *) internalPtr) = None;
+ if (*((Pixmap *)internalPtr) != None) {
+ Tk_FreeBitmap(Tk_Display(tkwin), *((Pixmap *)internalPtr));
+ *((Pixmap *)internalPtr) = None;
}
} else if (objPtr != NULL) {
Tk_FreeBitmapFromObj(tkwin, objPtr);
@@ -1686,9 +1891,9 @@ FreeResources(
break;
case TK_OPTION_BORDER:
if (internalFormExists) {
- if (*((Tk_3DBorder *) internalPtr) != NULL) {
- Tk_Free3DBorder(*((Tk_3DBorder *) internalPtr));
- *((Tk_3DBorder *) internalPtr) = NULL;
+ if (*((Tk_3DBorder *)internalPtr) != NULL) {
+ Tk_Free3DBorder(*((Tk_3DBorder *)internalPtr));
+ *((Tk_3DBorder *)internalPtr) = NULL;
}
} else if (objPtr != NULL) {
Tk_Free3DBorderFromObj(tkwin, objPtr);
@@ -1707,7 +1912,7 @@ FreeResources(
case TK_OPTION_CUSTOM: {
const Tk_ObjCustomOption *custom = optionPtr->extra.custom;
if (internalFormExists && custom->freeProc != NULL) {
- custom->freeProc(custom->clientData, tkwin, internalPtr);
+ custom->freeProc(custom->clientData, tkwin, (char *)internalPtr);
}
break;
}
@@ -1746,7 +1951,7 @@ Tcl_Obj *
Tk_GetOptionInfo(
Tcl_Interp *interp, /* Interpreter for error reporting. If NULL,
* then no error message is created. */
- char *recordPtr, /* Record whose fields contain current values
+ void *recordPtr, /* Record whose fields contain current values
* for options. */
Tk_OptionTable optionTable, /* Describes all the legal options. */
Tcl_Obj *namePtr, /* If non-NULL, the string value selects a
@@ -1760,7 +1965,7 @@ Tk_GetOptionInfo(
Tcl_Obj *resultPtr;
OptionTable *tablePtr = (OptionTable *) optionTable;
Option *optionPtr;
- int count;
+ size_t count;
/*
* If information is only wanted for a single configuration spec, then
@@ -1814,7 +2019,7 @@ Tk_GetOptionInfo(
static Tcl_Obj *
GetConfigList(
- char *recordPtr, /* Pointer to record holding current values of
+ void *recordPtr, /* Pointer to record holding current values of
* configuration options. */
Option *optionPtr, /* Pointer to information describing a
* particular option. */
@@ -1824,24 +2029,24 @@ GetConfigList(
listPtr = Tcl_NewListObj(0, NULL);
Tcl_ListObjAppendElement(NULL, listPtr,
- Tcl_NewStringObj(optionPtr->specPtr->optionName, -1));
+ Tcl_NewStringObj(optionPtr->specPtr->optionName, TCL_INDEX_NONE));
if (optionPtr->specPtr->type == TK_OPTION_SYNONYM) {
elementPtr = Tcl_NewStringObj(
- optionPtr->extra.synonymPtr->specPtr->optionName, -1);
+ optionPtr->extra.synonymPtr->specPtr->optionName, TCL_INDEX_NONE);
Tcl_ListObjAppendElement(NULL, listPtr, elementPtr);
} else {
if (optionPtr->dbNameUID == NULL) {
elementPtr = Tcl_NewObj();
} else {
- elementPtr = Tcl_NewStringObj(optionPtr->dbNameUID, -1);
+ elementPtr = Tcl_NewStringObj(optionPtr->dbNameUID, TCL_INDEX_NONE);
}
Tcl_ListObjAppendElement(NULL, listPtr, elementPtr);
if (optionPtr->dbClassUID == NULL) {
elementPtr = Tcl_NewObj();
} else {
- elementPtr = Tcl_NewStringObj(optionPtr->dbClassUID, -1);
+ elementPtr = Tcl_NewStringObj(optionPtr->dbClassUID, TCL_INDEX_NONE);
}
Tcl_ListObjAppendElement(NULL, listPtr, elementPtr);
@@ -1857,8 +2062,8 @@ GetConfigList(
}
Tcl_ListObjAppendElement(NULL, listPtr, elementPtr);
- if (optionPtr->specPtr->objOffset >= 0) {
- elementPtr = *((Tcl_Obj **) (recordPtr
+ if (optionPtr->specPtr->objOffset != TCL_INDEX_NONE) {
+ elementPtr = *((Tcl_Obj **) ((char *)recordPtr
+ optionPtr->specPtr->objOffset));
if (elementPtr == NULL) {
elementPtr = Tcl_NewObj();
@@ -1892,7 +2097,7 @@ GetConfigList(
static Tcl_Obj *
GetObjectForOption(
- char *recordPtr, /* Pointer to record holding current values of
+ void *recordPtr, /* Pointer to record holding current values of
* configuration options. */
Option *optionPtr, /* Pointer to information describing an option
* whose internal value is stored in
@@ -1900,29 +2105,82 @@ GetObjectForOption(
Tk_Window tkwin) /* Window corresponding to recordPtr. */
{
Tcl_Obj *objPtr = NULL;
- char *internalPtr; /* Points to internal value of option in record. */
+ void *internalPtr; /* Points to internal value of option in record. */
- if (optionPtr->specPtr->internalOffset >= 0) {
- internalPtr = recordPtr + optionPtr->specPtr->internalOffset;
+ if (optionPtr->specPtr->internalOffset != TCL_INDEX_NONE) {
+ internalPtr = (char *)recordPtr + optionPtr->specPtr->internalOffset;
switch (optionPtr->specPtr->type) {
- case TK_OPTION_BOOLEAN:
- objPtr = Tcl_NewIntObj(*((int *)internalPtr));
+ case TK_OPTION_BOOLEAN: {
+ int value;
+ if (optionPtr->specPtr->flags & TYPE_MASK) {
+ if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(char)) {
+ value = *((signed char *)internalPtr);
+ } else if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(short)) {
+ value = *((short *)internalPtr);
+ } else {
+ Tcl_Panic("Invalid flags for %s", "TK_OPTION_BOOLEAN");
+ }
+ } else {
+ value = *((int *)internalPtr);
+ }
+ if (value != -1) {
+ objPtr = Tcl_NewBooleanObj(value);
+ }
+ break;
+ }
+ case TK_OPTION_INT: {
+ Tcl_WideInt value;
+ int nullOK = (optionPtr->specPtr->flags & (TK_OPTION_NULL_OK|TCL_NULL_OK|1));
+ if (optionPtr->specPtr->flags & TYPE_MASK) {
+ if ((optionPtr->specPtr->flags & TYPE_MASK) == TYPE_MASK) {
+ if (sizeof(long) > sizeof(int)) {
+ value = *((long *)internalPtr);
+ if (nullOK && (value == LONG_MIN)) {break;}
+ } else {
+ value = *((long long *)internalPtr);
+ if (nullOK && (value == LLONG_MIN)) {break;}
+ }
+ } else {
+ Tcl_Panic("Invalid flags for %s", "TK_OPTION_INT");
+ }
+ } else {
+ value = *((int *)internalPtr);
+ if (nullOK && (value == INT_MIN)) {break;}
+ }
+ objPtr = Tcl_NewWideIntObj(value);
break;
- case TK_OPTION_INT:
- objPtr = Tcl_NewIntObj(*((int *)internalPtr));
+ }
+ case TK_OPTION_INDEX:
+ if (!(optionPtr->specPtr->flags & (TK_OPTION_NULL_OK|TCL_NULL_OK|1)) || *((int *)internalPtr) != INT_MIN) {
+ if (*((int *)internalPtr) == INT_MIN) {
+ objPtr = TkNewIndexObj(TCL_INDEX_NONE);
+ } else if (*((int *)internalPtr) == INT_MAX) {
+ objPtr = Tcl_NewStringObj("end+1", TCL_INDEX_NONE);
+ } else if (*((int *)internalPtr) == -1) {
+ objPtr = Tcl_NewStringObj("end", TCL_INDEX_NONE);
+ } else if (*((int *)internalPtr) < 0) {
+ char buf[32];
+ snprintf(buf, 32, "end%d", 1 + *((int *)internalPtr));
+ objPtr = Tcl_NewStringObj(buf, TCL_INDEX_NONE);
+ } else {
+ objPtr = Tcl_NewWideIntObj(*((int *)internalPtr));
+ }
+ }
break;
case TK_OPTION_DOUBLE:
- objPtr = Tcl_NewDoubleObj(*((double *)internalPtr));
+ if (!(optionPtr->specPtr->flags & (TK_OPTION_NULL_OK|TCL_NULL_OK|1)) || !isnan(*((double *)internalPtr))) {
+ objPtr = Tcl_NewDoubleObj(*((double *)internalPtr));
+ }
break;
case TK_OPTION_STRING:
- objPtr = Tcl_NewStringObj(*((char **)internalPtr), -1);
+ objPtr = Tcl_NewStringObj(*((char **)internalPtr), TCL_INDEX_NONE);
break;
case TK_OPTION_STRING_TABLE: {
int value = 0;
if (optionPtr->specPtr->flags & TYPE_MASK) {
- if ((optionPtr->specPtr->flags & TYPE_MASK) == TYPE_FLAGS(char)) {
+ if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(char)) {
value = *((signed char *)internalPtr);
- } else if ((optionPtr->specPtr->flags & TYPE_MASK) == TYPE_FLAGS(short)) {
+ } else if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(short)) {
value = *((short *)internalPtr);
} else {
Tcl_Panic("Invalid flags for %s", "TK_OPTION_STRING_TABLE");
@@ -1931,8 +2189,8 @@ GetObjectForOption(
value = *((int *)internalPtr);
}
if (value >= 0) {
- objPtr = Tcl_NewStringObj(((char **) optionPtr->specPtr->clientData)[
- value], -1);
+ objPtr = Tcl_NewStringObj(((char **)optionPtr->specPtr->clientData)[
+ value], TCL_INDEX_NONE);
}
break;
}
@@ -1940,7 +2198,7 @@ GetObjectForOption(
XColor *colorPtr = *((XColor **)internalPtr);
if (colorPtr != NULL) {
- objPtr = Tcl_NewStringObj(Tk_NameOfColor(colorPtr), -1);
+ objPtr = Tcl_NewStringObj(Tk_NameOfColor(colorPtr), TCL_INDEX_NONE);
}
break;
}
@@ -1948,7 +2206,7 @@ GetObjectForOption(
Tk_Font tkfont = *((Tk_Font *)internalPtr);
if (tkfont != NULL) {
- objPtr = Tcl_NewStringObj(Tk_NameOfFont(tkfont), -1);
+ objPtr = Tcl_NewStringObj(Tk_NameOfFont(tkfont), TCL_INDEX_NONE);
}
break;
}
@@ -1956,7 +2214,7 @@ GetObjectForOption(
Tk_Style style = *((Tk_Style *)internalPtr);
if (style != NULL) {
- objPtr = Tcl_NewStringObj(Tk_NameOfStyle(style), -1);
+ objPtr = Tcl_NewStringObj(Tk_NameOfStyle(style), TCL_INDEX_NONE);
}
break;
}
@@ -1965,7 +2223,7 @@ GetObjectForOption(
if (pixmap != None) {
objPtr = Tcl_NewStringObj(
- Tk_NameOfBitmap(Tk_Display(tkwin), pixmap), -1);
+ Tk_NameOfBitmap(Tk_Display(tkwin), pixmap), TCL_INDEX_NONE);
}
break;
}
@@ -1973,45 +2231,90 @@ GetObjectForOption(
Tk_3DBorder border = *((Tk_3DBorder *)internalPtr);
if (border != NULL) {
- objPtr = Tcl_NewStringObj(Tk_NameOf3DBorder(border), -1);
+ objPtr = Tcl_NewStringObj(Tk_NameOf3DBorder(border), TCL_INDEX_NONE);
}
break;
}
- case TK_OPTION_RELIEF:
- objPtr = Tcl_NewStringObj(Tk_NameOfRelief(*((int *)internalPtr)), -1);
+ case TK_OPTION_RELIEF: {
+ int value;
+ if (optionPtr->specPtr->flags & TYPE_MASK) {
+ if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(char)) {
+ value = *((signed char *)internalPtr);
+ } else if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(short)) {
+ value = *((short *)internalPtr);
+ } else {
+ Tcl_Panic("Invalid flags for %s", "TK_OPTION_RELIEF");
+ }
+ } else {
+ value = *((int *)internalPtr);
+ }
+ if (value != TK_RELIEF_NULL) {
+ objPtr = Tcl_NewStringObj(Tk_NameOfRelief(value), TCL_INDEX_NONE);
+ }
break;
+ }
case TK_OPTION_CURSOR: {
Tk_Cursor cursor = *((Tk_Cursor *)internalPtr);
if (cursor != NULL) {
objPtr = Tcl_NewStringObj(
- Tk_NameOfCursor(Tk_Display(tkwin), cursor), -1);
+ Tk_NameOfCursor(Tk_Display(tkwin), cursor), TCL_INDEX_NONE);
}
break;
}
- case TK_OPTION_JUSTIFY:
- objPtr = Tcl_NewStringObj(Tk_NameOfJustify(
- *((Tk_Justify *)internalPtr)), -1);
+ case TK_OPTION_JUSTIFY: {
+ Tk_Justify value;
+ if (optionPtr->specPtr->flags & TYPE_MASK) {
+ if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(char)) {
+ value = (Tk_Justify)*((signed char *)internalPtr);
+ } else if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(short)) {
+ value = (Tk_Justify)*((short *)internalPtr);
+ } else {
+ Tcl_Panic("Invalid flags for %s", "TK_OPTION_JUSTIFY");
+ }
+ } else {
+ value = (Tk_Justify)*((int *)internalPtr);
+ }
+ if (value != TK_JUSTIFY_NULL) {
+ objPtr = Tcl_NewStringObj(Tk_NameOfJustify(value), TCL_INDEX_NONE);
+ }
break;
- case TK_OPTION_ANCHOR:
- objPtr = Tcl_NewStringObj(Tk_NameOfAnchor(
- *((Tk_Anchor *)internalPtr)), -1);
+ }
+ case TK_OPTION_ANCHOR: {
+ Tk_Anchor value;
+ if (optionPtr->specPtr->flags & TYPE_MASK) {
+ if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(char)) {
+ value = (Tk_Anchor)*((signed char *)internalPtr);
+ } else if ((optionPtr->specPtr->flags & TYPE_MASK) == TK_OPTION_VAR(short)) {
+ value = (Tk_Anchor)*((short *)internalPtr);
+ } else {
+ Tcl_Panic("Invalid flags for %s", "TK_OPTION_ANCHOR");
+ }
+ } else {
+ value = (Tk_Anchor)*((int *)internalPtr);
+ }
+ if (value != TK_ANCHOR_NULL) {
+ objPtr = Tcl_NewStringObj(Tk_NameOfAnchor(value), TCL_INDEX_NONE);
+ }
break;
+ }
case TK_OPTION_PIXELS:
- objPtr = Tcl_NewIntObj(*((int *)internalPtr));
+ if (!(optionPtr->specPtr->flags & (TK_OPTION_NULL_OK|TCL_NULL_OK|1)) || *((int *)internalPtr) != INT_MIN) {
+ objPtr = Tcl_NewWideIntObj(*((int *)internalPtr));
+ }
break;
case TK_OPTION_WINDOW: {
tkwin = *((Tk_Window *)internalPtr);
if (tkwin != NULL) {
- objPtr = Tcl_NewStringObj(Tk_PathName(tkwin), -1);
+ objPtr = Tcl_NewStringObj(Tk_PathName(tkwin), TCL_INDEX_NONE);
}
break;
}
case TK_OPTION_CUSTOM: {
const Tk_ObjCustomOption *custom = optionPtr->extra.custom;
- objPtr = custom->getProc(custom->clientData, tkwin, recordPtr,
+ objPtr = custom->getProc(custom->clientData, tkwin, (char *)recordPtr,
optionPtr->specPtr->internalOffset);
break;
}
@@ -2049,7 +2352,7 @@ Tk_GetOptionValue(
Tcl_Interp *interp, /* Interpreter for error reporting. If NULL
* then no messages are provided for
* errors. */
- char *recordPtr, /* Record whose fields contain current values
+ void *recordPtr, /* Record whose fields contain current values
* for options. */
Tk_OptionTable optionTable, /* Describes legal options. */
Tcl_Obj *namePtr, /* Gives the command-line name for the option
@@ -2067,8 +2370,8 @@ Tk_GetOptionValue(
if (optionPtr->specPtr->type == TK_OPTION_SYNONYM) {
optionPtr = optionPtr->extra.synonymPtr;
}
- if (optionPtr->specPtr->objOffset >= 0) {
- resultPtr = *((Tcl_Obj **) (recordPtr+optionPtr->specPtr->objOffset));
+ if (optionPtr->specPtr->objOffset != TCL_INDEX_NONE) {
+ resultPtr = *((Tcl_Obj **) ((char *)recordPtr+optionPtr->specPtr->objOffset));
if (resultPtr == NULL) {
/*
* This option has a null value and is represented by a null
@@ -2138,11 +2441,11 @@ TkDebugConfig(
if (tablePtr == (OptionTable *) Tcl_GetHashValue(hashEntryPtr)) {
for ( ; tablePtr != NULL; tablePtr = tablePtr->nextPtr) {
Tcl_ListObjAppendElement(NULL, objPtr,
- Tcl_NewIntObj(tablePtr->refCount));
+ Tcl_NewWideIntObj((Tcl_WideInt)tablePtr->refCount));
Tcl_ListObjAppendElement(NULL, objPtr,
- Tcl_NewIntObj(tablePtr->numOptions));
+ Tcl_NewWideIntObj((Tcl_WideInt)tablePtr->numOptions));
Tcl_ListObjAppendElement(NULL, objPtr, Tcl_NewStringObj(
- tablePtr->options[0].specPtr->optionName, -1));
+ tablePtr->options[0].specPtr->optionName, TCL_INDEX_NONE));
}
break;
}
diff --git a/generic/tkConsole.c b/generic/tkConsole.c
index 875d034..8302b38 100644
--- a/generic/tkConsole.c
+++ b/generic/tkConsole.c
@@ -5,7 +5,7 @@
* 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.
+ * Copyright © 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.
@@ -24,7 +24,7 @@
typedef struct ConsoleInfo {
Tcl_Interp *consoleInterp; /* Interpreter displaying the console. */
Tcl_Interp *interp; /* Interpreter controlled by console. */
- int refCount;
+ size_t refCount;
} ConsoleInfo;
/*
@@ -43,23 +43,21 @@ typedef struct ChannelData {
* Prototypes for local procedures defined in this file:
*/
-static int ConsoleClose(ClientData instanceData, Tcl_Interp *interp);
-static int Console2Close(ClientData instanceData, Tcl_Interp *interp, int flags);
-static void ConsoleDeleteProc(ClientData clientData);
-static void ConsoleEventProc(ClientData clientData, XEvent *eventPtr);
-static int ConsoleHandle(ClientData instanceData, int direction,
- ClientData *handlePtr);
-static int ConsoleInput(ClientData instanceData, char *buf, int toRead,
+static int ConsoleClose(void *instanceData, Tcl_Interp *interp);
+static int Console2Close(void *instanceData, Tcl_Interp *interp, int flags);
+static void ConsoleDeleteProc(void *clientData);
+static void ConsoleEventProc(void *clientData, XEvent *eventPtr);
+static int ConsoleHandle(void *instanceData, int direction,
+ void **handlePtr);
+static int ConsoleInput(void *instanceData, char *buf, int toRead,
int *errorCode);
-static int ConsoleObjCmd(ClientData clientData, Tcl_Interp *interp,
- int objc, Tcl_Obj *const objv[]);
-static int ConsoleOutput(ClientData instanceData, const char *buf,
+static Tcl_ObjCmdProc ConsoleObjCmd;
+static int ConsoleOutput(void *instanceData, const char *buf,
int toWrite, int *errorCode);
-static void ConsoleWatch(ClientData instanceData, int mask);
-static void DeleteConsoleInterp(ClientData clientData);
-static void InterpDeleteProc(ClientData clientData, Tcl_Interp *interp);
-static int InterpreterObjCmd(ClientData clientData, Tcl_Interp *interp,
- int objc, Tcl_Obj *const objv[]);
+static void ConsoleWatch(void *instanceData, int mask);
+static void DeleteConsoleInterp(void *clientData);
+static void InterpDeleteProc(void *clientData, Tcl_Interp *interp);
+static Tcl_ObjCmdProc InterpreterObjCmd;
/*
* This structure describes the channel type structure for file based IO:
@@ -68,7 +66,7 @@ static int InterpreterObjCmd(ClientData clientData, Tcl_Interp *interp,
static const Tcl_ChannelType consoleChannelType = {
"console", /* Type name. */
TCL_CHANNEL_VERSION_5, /* v5 channel */
- ConsoleClose, /* Close proc. */
+ (Tcl_DriverCloseProc *)ConsoleClose, /* Close proc. */
ConsoleInput, /* Input proc. */
ConsoleOutput, /* Output proc. */
NULL, /* Seek proc. */
@@ -224,8 +222,8 @@ Tk_InitConsoleChannels(
* Ensure that we are getting a compatible version of Tcl.
*/
- if (Tcl_InitStubs(interp, "8.6", 0) == NULL) {
- return;
+ if (Tcl_InitStubs(interp, "8.6-", 0) == NULL) {
+ return;
}
consoleInitPtr = (int *)Tcl_GetThreadData(&consoleInitKey, (int) sizeof(int));
@@ -444,7 +442,7 @@ Tk_CreateConsoleWindow(
Tcl_Preserve(consoleInterp);
result = Tcl_EvalEx(consoleInterp, "source -encoding utf-8 $tk_library/console.tcl",
- -1, TCL_EVAL_GLOBAL);
+ TCL_INDEX_NONE, TCL_EVAL_GLOBAL);
if (result == TCL_ERROR) {
Tcl_SetReturnOptions(interp,
Tcl_GetReturnOptions(consoleInterp, result));
@@ -493,7 +491,7 @@ Tk_CreateConsoleWindow(
static int
ConsoleOutput(
- ClientData instanceData, /* Indicates which device to use. */
+ void *instanceData, /* Indicates which device to use. */
const char *buf, /* The data buffer. */
int toWrite, /* How many bytes to write? */
int *errorCode) /* Where to store error code. */
@@ -517,19 +515,18 @@ ConsoleOutput(
* Assumption is utf-8 Tcl_Encoding is reliably present.
*/
- const char *bytes
- = Tcl_ExternalToUtfDString(utf8, buf, toWrite, &ds);
- int numBytes = Tcl_DStringLength(&ds);
- Tcl_Obj *cmd = Tcl_NewStringObj("tk::ConsoleOutput", -1);
+ const char *bytes = Tcl_ExternalToUtfDString(utf8, buf, toWrite, &ds);
+ Tcl_Size numBytes = Tcl_DStringLength(&ds);
+ Tcl_Obj *cmd = Tcl_NewStringObj("tk::ConsoleOutput", TCL_INDEX_NONE);
Tcl_FreeEncoding(utf8);
if (data->type == TCL_STDERR) {
Tcl_ListObjAppendElement(NULL, cmd,
- Tcl_NewStringObj("stderr", -1));
+ Tcl_NewStringObj("stderr", TCL_INDEX_NONE));
} else {
Tcl_ListObjAppendElement(NULL, cmd,
- Tcl_NewStringObj("stdout", -1));
+ Tcl_NewStringObj("stdout", TCL_INDEX_NONE));
}
Tcl_ListObjAppendElement(NULL, cmd,
Tcl_NewStringObj(bytes, numBytes));
@@ -588,7 +585,7 @@ ConsoleInput(
static int
ConsoleClose(
- ClientData instanceData,
+ void *instanceData,
TCL_UNUSED(Tcl_Interp *))
{
ChannelData *data = (ChannelData *)instanceData;
@@ -609,7 +606,7 @@ ConsoleClose(
static int
Console2Close(
- ClientData instanceData, /* Unused. */
+ void *instanceData, /* Unused. */
Tcl_Interp *interp, /* Unused. */
int flags)
{
@@ -693,7 +690,7 @@ ConsoleHandle(
static int
ConsoleObjCmd(
- ClientData clientData, /* Access to the console interp */
+ void *clientData, /* Access to the console interp */
Tcl_Interp *interp, /* Current interpreter */
int objc, /* Number of arguments */
Tcl_Obj *const objv[]) /* Argument objects */
@@ -728,21 +725,21 @@ ConsoleObjCmd(
Tcl_WrongNumArgs(interp, 2, objv, NULL);
return TCL_ERROR;
}
- cmd = Tcl_NewStringObj("wm withdraw .", -1);
+ cmd = Tcl_NewStringObj("wm withdraw .", TCL_INDEX_NONE);
break;
case CON_SHOW:
if (objc != 2) {
Tcl_WrongNumArgs(interp, 2, objv, NULL);
return TCL_ERROR;
}
- cmd = Tcl_NewStringObj("wm deiconify .", -1);
+ cmd = Tcl_NewStringObj("wm deiconify .", TCL_INDEX_NONE);
break;
case CON_TITLE:
if (objc > 3) {
Tcl_WrongNumArgs(interp, 2, objv, "?title?");
return TCL_ERROR;
}
- cmd = Tcl_NewStringObj("wm title .", -1);
+ cmd = Tcl_NewStringObj("wm title .", TCL_INDEX_NONE);
if (objc == 3) {
Tcl_ListObjAppendElement(NULL, cmd, objv[2]);
}
@@ -761,7 +758,7 @@ ConsoleObjCmd(
Tcl_Release(consoleInterp);
} else {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "no active console interp", -1));
+ "no active console interp", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "CONSOLE", "NONE", NULL);
result = TCL_ERROR;
}
@@ -785,7 +782,7 @@ ConsoleObjCmd(
static int
InterpreterObjCmd(
- ClientData clientData, /* */
+ void *clientData, /* */
Tcl_Interp *interp, /* Current interpreter */
int objc, /* Number of arguments */
Tcl_Obj *const objv[]) /* Argument objects */
@@ -812,7 +809,7 @@ InterpreterObjCmd(
if ((otherInterp == NULL) || Tcl_InterpDeleted(otherInterp)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "no active parent interp", -1));
+ "no active parent interp", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "CONSOLE", "NO_INTERP", NULL);
return TCL_ERROR;
}
@@ -859,7 +856,7 @@ InterpreterObjCmd(
static void
DeleteConsoleInterp(
- ClientData clientData)
+ void *clientData)
{
Tcl_Interp *interp = (Tcl_Interp *)clientData;
@@ -885,7 +882,7 @@ DeleteConsoleInterp(
static void
InterpDeleteProc(
- ClientData clientData,
+ void *clientData,
Tcl_Interp *interp)
{
ConsoleInfo *info = (ConsoleInfo *)clientData;
@@ -918,7 +915,7 @@ InterpDeleteProc(
static void
ConsoleDeleteProc(
- ClientData clientData)
+ void *clientData)
{
ConsoleInfo *info = (ConsoleInfo *)clientData;
@@ -951,7 +948,7 @@ ConsoleDeleteProc(
static void
ConsoleEventProc(
- ClientData clientData,
+ void *clientData,
XEvent *eventPtr)
{
if (eventPtr->type == DestroyNotify) {
@@ -959,7 +956,7 @@ ConsoleEventProc(
Tcl_Interp *consoleInterp = info->consoleInterp;
if (consoleInterp && !Tcl_InterpDeleted(consoleInterp)) {
- Tcl_EvalEx(consoleInterp, "tk::ConsoleExit", -1, TCL_EVAL_GLOBAL);
+ Tcl_EvalEx(consoleInterp, "tk::ConsoleExit", TCL_INDEX_NONE, TCL_EVAL_GLOBAL);
}
if (info->refCount-- <= 1) {
diff --git a/generic/tkCursor.c b/generic/tkCursor.c
index 50c6803..1bed0c4 100644
--- a/generic/tkCursor.c
+++ b/generic/tkCursor.c
@@ -5,8 +5,8 @@
* 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-1997 Sun Microsystems, Inc.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 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.
@@ -59,12 +59,14 @@ static void InitCursorObj(Tcl_Obj *objPtr);
* option is set.
*/
-Tcl_ObjType const tkCursorObjType = {
- "cursor", /* name */
+const TkObjType tkCursorObjType = {
+ {"cursor", /* name */
FreeCursorObjProc, /* freeIntRepProc */
DupCursorObjProc, /* dupIntRepProc */
NULL, /* updateStringProc */
- NULL /* setFromAnyProc */
+ NULL, /* setFromAnyProc */
+ TCL_OBJTYPE_V1(TkLengthOne)},
+ 0
};
/*
@@ -101,7 +103,7 @@ Tk_AllocCursorFromObj(
{
TkCursor *cursorPtr;
- if (objPtr->typePtr != &tkCursorObjType) {
+ if (objPtr->typePtr != &tkCursorObjType.objType) {
InitCursorObj(objPtr);
}
cursorPtr = (TkCursor *)objPtr->internalRep.twoPtrValue.ptr1;
@@ -429,10 +431,10 @@ Tk_NameOfCursor(
if (!dispPtr->cursorInit) {
printid:
- snprintf(dispPtr->cursorString, sizeof(dispPtr->cursorString), "cursor id 0x%" TCL_Z_MODIFIER "x", (size_t)cursor);
+ snprintf(dispPtr->cursorString, sizeof(dispPtr->cursorString), "cursor id 0x%" TCL_Z_MODIFIER "x", PTR2INT(cursor));
return dispPtr->cursorString;
}
- idHashPtr = Tcl_FindHashEntry(&dispPtr->cursorIdTable, (char *) cursor);
+ idHashPtr = Tcl_FindHashEntry(&dispPtr->cursorIdTable, cursor);
if (idHashPtr == NULL) {
goto printid;
}
@@ -521,7 +523,7 @@ Tk_FreeCursor(
Tcl_Panic("Tk_FreeCursor called before Tk_GetCursor");
}
- idHashPtr = Tcl_FindHashEntry(&dispPtr->cursorIdTable, (char *) cursor);
+ idHashPtr = Tcl_FindHashEntry(&dispPtr->cursorIdTable, cursor);
if (idHashPtr == NULL) {
Tcl_Panic("Tk_FreeCursor received unknown cursor argument");
}
@@ -698,7 +700,7 @@ GetCursorFromObj(
Tcl_HashEntry *hashPtr;
TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
- if (objPtr->typePtr != &tkCursorObjType) {
+ if (objPtr->typePtr != &tkCursorObjType.objType) {
InitCursorObj(objPtr);
}
@@ -775,7 +777,7 @@ InitCursorObj(
if ((typePtr != NULL) && (typePtr->freeIntRepProc != NULL)) {
typePtr->freeIntRepProc(objPtr);
}
- objPtr->typePtr = &tkCursorObjType;
+ objPtr->typePtr = &tkCursorObjType.objType;
objPtr->internalRep.twoPtrValue.ptr1 = NULL;
}
@@ -866,9 +868,9 @@ TkDebugCursor(
for ( ; (cursorPtr != NULL); cursorPtr = cursorPtr->nextPtr) {
objPtr = Tcl_NewObj();
Tcl_ListObjAppendElement(NULL, objPtr,
- Tcl_NewIntObj(cursorPtr->resourceRefCount));
+ Tcl_NewWideIntObj(cursorPtr->resourceRefCount));
Tcl_ListObjAppendElement(NULL, objPtr,
- Tcl_NewIntObj(cursorPtr->objRefCount));
+ Tcl_NewWideIntObj(cursorPtr->objRefCount));
Tcl_ListObjAppendElement(NULL, resultPtr, objPtr);
}
}
diff --git a/generic/tkDList.h b/generic/tkDList.h
index 3a8840c..f6c70d9 100644
--- a/generic/tkDList.h
+++ b/generic/tkDList.h
@@ -7,7 +7,7 @@
* before or after an existing element or at the head/tail of the list.
* A list may be traversed in the forward or backward direction.
*
- * Copyright (c) 2018 Gregor Cramer.
+ * Copyright © 2018 Gregor Cramer.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
diff --git a/generic/tkDecls.h b/generic/tkDecls.h
index 86196ef..bdad3d1 100644
--- a/generic/tkDecls.h
+++ b/generic/tkDecls.h
@@ -3,7 +3,7 @@
*
* Declarations of functions in the platform independent public Tcl API.
*
- * Copyright (c) 1998-1999 Scriptics Corporation.
+ * Copyright © 1998-1999 Scriptics Corporation.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -17,6 +17,14 @@
#define TCL_STORAGE_CLASS DLLEXPORT
#endif
+#if !defined(BUILD_tk)
+# define TK_DEPRECATED(msg) EXTERN TCL_DEPRECATED_API(msg)
+#elif defined(TK_NO_DEPRECATED)
+# define TK_DEPRECATED(msg) MODULE_SCOPE
+#else
+# define TK_DEPRECATED(msg) EXTERN
+#endif
+
/*
* WARNING: This file is automatically generated by the tools/genStubs.tcl
* script. Any modifications to the function declarations below should be made
@@ -56,7 +64,7 @@ EXTERN void Tk_AddOption(Tk_Window tkwin, const char *name,
/* 6 */
EXTERN void Tk_BindEvent(Tk_BindingTable bindingTable,
XEvent *eventPtr, Tk_Window tkwin,
- int numObjects, ClientData *objectPtr);
+ Tcl_Size numObjects, void **objectPtr);
/* 7 */
EXTERN void Tk_CanvasDrawableCoords(Tk_Canvas canvas, double x,
double y, short *drawableXPtr,
@@ -82,7 +90,7 @@ EXTERN int Tk_CanvasPsFont(Tcl_Interp *interp, Tk_Canvas canvas,
Tk_Font font);
/* 14 */
EXTERN void Tk_CanvasPsPath(Tcl_Interp *interp, Tk_Canvas canvas,
- double *coordPtr, int numPoints);
+ double *coordPtr, Tcl_Size numPoints);
/* 15 */
EXTERN int Tk_CanvasPsStipple(Tcl_Interp *interp,
Tk_Canvas canvas, Pixmap bitmap);
@@ -91,13 +99,14 @@ EXTERN double Tk_CanvasPsY(Tk_Canvas canvas, double y);
/* 17 */
EXTERN void Tk_CanvasSetStippleOrigin(Tk_Canvas canvas, GC gc);
/* 18 */
-EXTERN int Tk_CanvasTagsParseProc(ClientData clientData,
+EXTERN int Tk_CanvasTagsParseProc(void *clientData,
Tcl_Interp *interp, Tk_Window tkwin,
- const char *value, char *widgRec, int offset);
+ const char *value, char *widgRec,
+ Tcl_Size offset);
/* 19 */
-EXTERN CONST86 char * Tk_CanvasTagsPrintProc(ClientData clientData,
- Tk_Window tkwin, char *widgRec, int offset,
- Tcl_FreeProc **freeProcPtr);
+EXTERN const char * Tk_CanvasTagsPrintProc(void *clientData,
+ Tk_Window tkwin, char *widgRec,
+ Tcl_Size offset, Tcl_FreeProc **freeProcPtr);
/* 20 */
EXTERN Tk_Window Tk_CanvasTkwin(Tk_Canvas canvas);
/* 21 */
@@ -109,7 +118,7 @@ EXTERN void Tk_ChangeWindowAttributes(Tk_Window tkwin,
unsigned long valueMask,
XSetWindowAttributes *attsPtr);
/* 23 */
-EXTERN int Tk_CharBbox(Tk_TextLayout layout, int index,
+EXTERN int Tk_CharBbox(Tk_TextLayout layout, Tcl_Size index,
int *xPtr, int *yPtr, int *widthPtr,
int *heightPtr);
/* 24 */
@@ -123,25 +132,25 @@ EXTERN int Tk_ClipboardClear(Tcl_Interp *interp,
Tk_Window tkwin);
/* 27 */
EXTERN int Tk_ConfigureInfo(Tcl_Interp *interp, Tk_Window tkwin,
- const Tk_ConfigSpec *specs, char *widgRec,
+ const Tk_ConfigSpec *specs, void *widgRec,
const char *argvName, int flags);
/* 28 */
EXTERN int Tk_ConfigureValue(Tcl_Interp *interp,
Tk_Window tkwin, const Tk_ConfigSpec *specs,
- char *widgRec, const char *argvName,
+ void *widgRec, const char *argvName,
int flags);
/* 29 */
EXTERN int Tk_ConfigureWidget(Tcl_Interp *interp,
Tk_Window tkwin, const Tk_ConfigSpec *specs,
- int argc, CONST84 char **argv, char *widgRec,
- int flags);
+ Tcl_Size argc, const char **argv,
+ void *widgRec, int flags);
/* 30 */
EXTERN void Tk_ConfigureWindow(Tk_Window tkwin,
unsigned int valueMask,
XWindowChanges *valuePtr);
/* 31 */
EXTERN Tk_TextLayout Tk_ComputeTextLayout(Tk_Font font, const char *str,
- int numChars, int wrapLength,
+ Tcl_Size numChars, int wrapLength,
Tk_Justify justify, int flags, int *widthPtr,
int *heightPtr);
/* 32 */
@@ -149,23 +158,22 @@ EXTERN Tk_Window Tk_CoordsToWindow(int rootX, int rootY,
Tk_Window tkwin);
/* 33 */
EXTERN unsigned long Tk_CreateBinding(Tcl_Interp *interp,
- Tk_BindingTable bindingTable,
- ClientData object, const char *eventStr,
- const char *script, int append);
+ Tk_BindingTable bindingTable, void *object,
+ const char *eventStr, const char *script,
+ int append);
/* 34 */
EXTERN Tk_BindingTable Tk_CreateBindingTable(Tcl_Interp *interp);
/* 35 */
EXTERN Tk_ErrorHandler Tk_CreateErrorHandler(Display *display, int errNum,
int request, int minorCode,
- Tk_ErrorProc *errorProc,
- ClientData clientData);
+ Tk_ErrorProc *errorProc, void *clientData);
/* 36 */
EXTERN void Tk_CreateEventHandler(Tk_Window token,
unsigned long mask, Tk_EventProc *proc,
- ClientData clientData);
+ void *clientData);
/* 37 */
EXTERN void Tk_CreateGenericHandler(Tk_GenericProc *proc,
- ClientData clientData);
+ void *clientData);
/* 38 */
EXTERN void Tk_CreateImageType(const Tk_ImageType *typePtr);
/* 39 */
@@ -176,7 +184,7 @@ EXTERN void Tk_CreatePhotoImageFormat(
/* 41 */
EXTERN void Tk_CreateSelHandler(Tk_Window tkwin, Atom selection,
Atom target, Tk_SelectionProc *proc,
- ClientData clientData, Atom format);
+ void *clientData, Atom format);
/* 42 */
EXTERN Tk_Window Tk_CreateWindow(Tcl_Interp *interp, Tk_Window parent,
const char *name, const char *screenName);
@@ -191,11 +199,11 @@ EXTERN int Tk_DefineBitmap(Tcl_Interp *interp, const char *name,
EXTERN void Tk_DefineCursor(Tk_Window window, Tk_Cursor cursor);
/* 46 */
EXTERN void Tk_DeleteAllBindings(Tk_BindingTable bindingTable,
- ClientData object);
+ void *object);
/* 47 */
EXTERN int Tk_DeleteBinding(Tcl_Interp *interp,
- Tk_BindingTable bindingTable,
- ClientData object, const char *eventStr);
+ Tk_BindingTable bindingTable, void *object,
+ const char *eventStr);
/* 48 */
EXTERN void Tk_DeleteBindingTable(Tk_BindingTable bindingTable);
/* 49 */
@@ -203,10 +211,10 @@ EXTERN void Tk_DeleteErrorHandler(Tk_ErrorHandler handler);
/* 50 */
EXTERN void Tk_DeleteEventHandler(Tk_Window token,
unsigned long mask, Tk_EventProc *proc,
- ClientData clientData);
+ void *clientData);
/* 51 */
EXTERN void Tk_DeleteGenericHandler(Tk_GenericProc *proc,
- ClientData clientData);
+ void *clientData);
/* 52 */
EXTERN void Tk_DeleteImage(Tcl_Interp *interp, const char *name);
/* 53 */
@@ -215,14 +223,14 @@ EXTERN void Tk_DeleteSelHandler(Tk_Window tkwin, Atom selection,
/* 54 */
EXTERN void Tk_DestroyWindow(Tk_Window tkwin);
/* 55 */
-EXTERN CONST84_RETURN char * Tk_DisplayName(Tk_Window tkwin);
+EXTERN const char * Tk_DisplayName(Tk_Window tkwin);
/* 56 */
EXTERN int Tk_DistanceToTextLayout(Tk_TextLayout layout, int x,
int y);
/* 57 */
EXTERN void Tk_Draw3DPolygon(Tk_Window tkwin, Drawable drawable,
Tk_3DBorder border, XPoint *pointPtr,
- int numPoints, int borderWidth,
+ Tcl_Size numPoints, int borderWidth,
int leftRelief);
/* 58 */
EXTERN void Tk_Draw3DRectangle(Tk_Window tkwin,
@@ -232,7 +240,7 @@ EXTERN void Tk_Draw3DRectangle(Tk_Window tkwin,
/* 59 */
EXTERN void Tk_DrawChars(Display *display, Drawable drawable,
GC gc, Tk_Font tkfont, const char *source,
- int numBytes, int x, int y);
+ Tcl_Size numBytes, int x, int y);
/* 60 */
EXTERN void Tk_DrawFocusHighlight(Tk_Window tkwin, GC gc,
int width, Drawable drawable);
@@ -240,11 +248,11 @@ EXTERN void Tk_DrawFocusHighlight(Tk_Window tkwin, GC gc,
EXTERN void Tk_DrawTextLayout(Display *display,
Drawable drawable, GC gc,
Tk_TextLayout layout, int x, int y,
- int firstChar, int lastChar);
+ Tcl_Size firstChar, Tcl_Size lastChar);
/* 62 */
EXTERN void Tk_Fill3DPolygon(Tk_Window tkwin, Drawable drawable,
Tk_3DBorder border, XPoint *pointPtr,
- int numPoints, int borderWidth,
+ Tcl_Size numPoints, int borderWidth,
int leftRelief);
/* 63 */
EXTERN void Tk_Fill3DRectangle(Tk_Window tkwin,
@@ -274,14 +282,15 @@ EXTERN void Tk_FreeGC(Display *display, GC gc);
EXTERN void Tk_FreeImage(Tk_Image image);
/* 74 */
EXTERN void Tk_FreeOptions(const Tk_ConfigSpec *specs,
- char *widgRec, Display *display,
+ void *widgRec, Display *display,
int needFlags);
/* 75 */
EXTERN void Tk_FreePixmap(Display *display, Pixmap pixmap);
/* 76 */
EXTERN void Tk_FreeTextLayout(Tk_TextLayout textLayout);
/* 77 */
-EXTERN void Tk_FreeXId(Display *display, XID xid);
+TK_DEPRECATED("function does nothing, call can be removed")
+void Tk_FreeXId(Display *display, XID xid);
/* 78 */
EXTERN GC Tk_GCForColor(XColor *colorPtr, Drawable drawable);
/* 79 */
@@ -292,17 +301,16 @@ EXTERN Tk_3DBorder Tk_Get3DBorder(Tcl_Interp *interp, Tk_Window tkwin,
Tk_Uid colorName);
/* 81 */
EXTERN void Tk_GetAllBindings(Tcl_Interp *interp,
- Tk_BindingTable bindingTable,
- ClientData object);
+ Tk_BindingTable bindingTable, void *object);
/* 82 */
EXTERN int Tk_GetAnchor(Tcl_Interp *interp, const char *str,
Tk_Anchor *anchorPtr);
/* 83 */
-EXTERN CONST84_RETURN char * Tk_GetAtomName(Tk_Window tkwin, Atom atom);
+EXTERN const char * Tk_GetAtomName(Tk_Window tkwin, Atom atom);
/* 84 */
-EXTERN CONST84_RETURN char * Tk_GetBinding(Tcl_Interp *interp,
- Tk_BindingTable bindingTable,
- ClientData object, const char *eventStr);
+EXTERN const char * Tk_GetBinding(Tcl_Interp *interp,
+ Tk_BindingTable bindingTable, void *object,
+ const char *eventStr);
/* 85 */
EXTERN Pixmap Tk_GetBitmap(Tcl_Interp *interp, Tk_Window tkwin,
const char *str);
@@ -344,11 +352,11 @@ EXTERN GC Tk_GetGC(Tk_Window tkwin, unsigned long valueMask,
EXTERN Tk_Image Tk_GetImage(Tcl_Interp *interp, Tk_Window tkwin,
const char *name,
Tk_ImageChangedProc *changeProc,
- ClientData clientData);
+ void *clientData);
/* 98 */
-EXTERN ClientData Tk_GetImageMasterData(Tcl_Interp *interp,
+EXTERN void * Tk_GetImageModelData(Tcl_Interp *interp,
const char *name,
- CONST86 Tk_ImageType **typePtrPtr);
+ const Tk_ImageType **typePtrPtr);
/* 99 */
EXTERN Tk_ItemType * Tk_GetItemTypes(void);
/* 100 */
@@ -375,8 +383,8 @@ EXTERN int Tk_GetRelief(Tcl_Interp *interp, const char *name,
EXTERN void Tk_GetRootCoords(Tk_Window tkwin, int *xPtr,
int *yPtr);
/* 108 */
-EXTERN int Tk_GetScrollInfo(Tcl_Interp *interp, int argc,
- CONST84 char **argv, double *dblPtr,
+EXTERN int Tk_GetScrollInfo(Tcl_Interp *interp, Tcl_Size argc,
+ const char **argv, double *dblPtr,
int *intPtr);
/* 109 */
EXTERN int Tk_GetScreenMM(Tcl_Interp *interp, Tk_Window tkwin,
@@ -384,7 +392,7 @@ EXTERN int Tk_GetScreenMM(Tcl_Interp *interp, Tk_Window tkwin,
/* 110 */
EXTERN int Tk_GetSelection(Tcl_Interp *interp, Tk_Window tkwin,
Atom selection, Atom target,
- Tk_GetSelProc *proc, ClientData clientData);
+ Tk_GetSelProc *proc, void *clientData);
/* 111 */
EXTERN Tk_Uid Tk_GetUid(const char *str);
/* 112 */
@@ -402,7 +410,7 @@ EXTERN void Tk_HandleEvent(XEvent *eventPtr);
/* 116 */
EXTERN Tk_Window Tk_IdToWindow(Display *display, Window window);
/* 117 */
-EXTERN void Tk_ImageChanged(Tk_ImageMaster model, int x, int y,
+EXTERN void Tk_ImageChanged(Tk_ImageModel model, int x, int y,
int width, int height, int imageWidth,
int imageHeight);
/* 118 */
@@ -422,13 +430,12 @@ EXTERN Tk_Window Tk_MainWindow(Tcl_Interp *interp);
EXTERN void Tk_MakeWindowExist(Tk_Window tkwin);
/* 124 */
EXTERN void Tk_ManageGeometry(Tk_Window tkwin,
- const Tk_GeomMgr *mgrPtr,
- ClientData clientData);
+ const Tk_GeomMgr *mgrPtr, void *clientData);
/* 125 */
EXTERN void Tk_MapWindow(Tk_Window tkwin);
/* 126 */
EXTERN int Tk_MeasureChars(Tk_Font tkfont, const char *source,
- int numBytes, int maxPixels, int flags,
+ Tcl_Size numBytes, int maxPixels, int flags,
int *lengthPtr);
/* 127 */
EXTERN void Tk_MoveResizeWindow(Tk_Window tkwin, int x, int y,
@@ -438,44 +445,45 @@ EXTERN void Tk_MoveWindow(Tk_Window tkwin, int x, int y);
/* 129 */
EXTERN void Tk_MoveToplevelWindow(Tk_Window tkwin, int x, int y);
/* 130 */
-EXTERN CONST84_RETURN char * Tk_NameOf3DBorder(Tk_3DBorder border);
+EXTERN const char * Tk_NameOf3DBorder(Tk_3DBorder border);
/* 131 */
-EXTERN CONST84_RETURN char * Tk_NameOfAnchor(Tk_Anchor anchor);
+EXTERN const char * Tk_NameOfAnchor(Tk_Anchor anchor);
/* 132 */
-EXTERN CONST84_RETURN char * Tk_NameOfBitmap(Display *display, Pixmap bitmap);
+EXTERN const char * Tk_NameOfBitmap(Display *display, Pixmap bitmap);
/* 133 */
-EXTERN CONST84_RETURN char * Tk_NameOfCapStyle(int cap);
+EXTERN const char * Tk_NameOfCapStyle(int cap);
/* 134 */
-EXTERN CONST84_RETURN char * Tk_NameOfColor(XColor *colorPtr);
+EXTERN const char * Tk_NameOfColor(XColor *colorPtr);
/* 135 */
-EXTERN CONST84_RETURN char * Tk_NameOfCursor(Display *display,
- Tk_Cursor cursor);
+EXTERN const char * Tk_NameOfCursor(Display *display, Tk_Cursor cursor);
/* 136 */
-EXTERN CONST84_RETURN char * Tk_NameOfFont(Tk_Font font);
+EXTERN const char * Tk_NameOfFont(Tk_Font font);
/* 137 */
-EXTERN CONST84_RETURN char * Tk_NameOfImage(Tk_ImageMaster model);
+EXTERN const char * Tk_NameOfImage(Tk_ImageModel model);
/* 138 */
-EXTERN CONST84_RETURN char * Tk_NameOfJoinStyle(int join);
+EXTERN const char * Tk_NameOfJoinStyle(int join);
/* 139 */
-EXTERN CONST84_RETURN char * Tk_NameOfJustify(Tk_Justify justify);
+EXTERN const char * Tk_NameOfJustify(Tk_Justify justify);
/* 140 */
-EXTERN CONST84_RETURN char * Tk_NameOfRelief(int relief);
+EXTERN const char * Tk_NameOfRelief(int relief);
/* 141 */
EXTERN Tk_Window Tk_NameToWindow(Tcl_Interp *interp,
const char *pathName, Tk_Window tkwin);
/* 142 */
EXTERN void Tk_OwnSelection(Tk_Window tkwin, Atom selection,
- Tk_LostSelProc *proc, ClientData clientData);
+ Tk_LostSelProc *proc, void *clientData);
/* 143 */
EXTERN int Tk_ParseArgv(Tcl_Interp *interp, Tk_Window tkwin,
- int *argcPtr, CONST84 char **argv,
+ int *argcPtr, const char **argv,
const Tk_ArgvInfo *argTable, int flags);
/* 144 */
-EXTERN void Tk_PhotoPutBlock_NoComposite(Tk_PhotoHandle handle,
+TK_DEPRECATED("function signature changed")
+void Tk_PhotoPutBlock_NoComposite(Tk_PhotoHandle handle,
Tk_PhotoImageBlock *blockPtr, int x, int y,
int width, int height);
/* 145 */
-EXTERN void Tk_PhotoPutZoomedBlock_NoComposite(
+TK_DEPRECATED("function signature changed")
+void Tk_PhotoPutZoomedBlock_NoComposite(
Tk_PhotoHandle handle,
Tk_PhotoImageBlock *blockPtr, int x, int y,
int width, int height, int zoomX, int zoomY,
@@ -486,13 +494,15 @@ EXTERN int Tk_PhotoGetImage(Tk_PhotoHandle handle,
/* 147 */
EXTERN void Tk_PhotoBlank(Tk_PhotoHandle handle);
/* 148 */
-EXTERN void Tk_PhotoExpand_Panic(Tk_PhotoHandle handle,
+TK_DEPRECATED("function signature changed")
+void Tk_PhotoExpand_Panic(Tk_PhotoHandle handle,
int width, int height);
/* 149 */
EXTERN void Tk_PhotoGetSize(Tk_PhotoHandle handle, int *widthPtr,
int *heightPtr);
/* 150 */
-EXTERN void Tk_PhotoSetSize_Panic(Tk_PhotoHandle handle,
+TK_DEPRECATED("function signature changed")
+void Tk_PhotoSetSize_Panic(Tk_PhotoHandle handle,
int width, int height);
/* 151 */
EXTERN int Tk_PointToChar(Tk_TextLayout layout, int x, int y);
@@ -517,8 +527,8 @@ EXTERN void Tk_ResizeWindow(Tk_Window tkwin, int width,
EXTERN int Tk_RestackWindow(Tk_Window tkwin, int aboveBelow,
Tk_Window other);
/* 158 */
-EXTERN Tk_RestrictProc * Tk_RestrictEvents(Tk_RestrictProc *proc,
- ClientData arg, ClientData *prevArgPtr);
+EXTERN Tk_RestrictProc * Tk_RestrictEvents(Tk_RestrictProc *proc, void *arg,
+ void **prevArgPtr);
/* 159 */
EXTERN int Tk_SafeInit(Tcl_Interp *interp);
/* 160 */
@@ -566,14 +576,14 @@ EXTERN void Tk_TextLayoutToPostscript(Tcl_Interp *interp,
Tk_TextLayout layout);
/* 176 */
EXTERN int Tk_TextWidth(Tk_Font font, const char *str,
- int numBytes);
+ Tcl_Size numBytes);
/* 177 */
EXTERN void Tk_UndefineCursor(Tk_Window window);
/* 178 */
EXTERN void Tk_UnderlineChars(Display *display,
Drawable drawable, GC gc, Tk_Font tkfont,
const char *source, int x, int y,
- int firstByte, int lastByte);
+ Tcl_Size firstByte, Tcl_Size lastByte);
/* 179 */
EXTERN void Tk_UnderlineTextLayout(Display *display,
Drawable drawable, GC gc,
@@ -620,7 +630,7 @@ EXTERN void Tk_FreeBitmapFromObj(Tk_Window tkwin,
/* 194 */
EXTERN void Tk_FreeColorFromObj(Tk_Window tkwin, Tcl_Obj *objPtr);
/* 195 */
-EXTERN void Tk_FreeConfigOptions(char *recordPtr,
+EXTERN void Tk_FreeConfigOptions(void *recordPtr,
Tk_OptionTable optionToken, Tk_Window tkwin);
/* 196 */
EXTERN void Tk_FreeSavedOptions(Tk_SavedOptions *savePtr);
@@ -642,12 +652,12 @@ EXTERN XColor * Tk_GetColorFromObj(Tk_Window tkwin, Tcl_Obj *objPtr);
/* 203 */
EXTERN Tk_Cursor Tk_GetCursorFromObj(Tk_Window tkwin, Tcl_Obj *objPtr);
/* 204 */
-EXTERN Tcl_Obj * Tk_GetOptionInfo(Tcl_Interp *interp, char *recordPtr,
+EXTERN Tcl_Obj * Tk_GetOptionInfo(Tcl_Interp *interp, void *recordPtr,
Tk_OptionTable optionTable, Tcl_Obj *namePtr,
Tk_Window tkwin);
/* 205 */
EXTERN Tcl_Obj * Tk_GetOptionValue(Tcl_Interp *interp,
- char *recordPtr, Tk_OptionTable optionTable,
+ void *recordPtr, Tk_OptionTable optionTable,
Tcl_Obj *namePtr, Tk_Window tkwin);
/* 206 */
EXTERN int Tk_GetJustifyFromObj(Tcl_Interp *interp,
@@ -663,21 +673,21 @@ EXTERN int Tk_GetPixelsFromObj(Tcl_Interp *interp,
EXTERN int Tk_GetReliefFromObj(Tcl_Interp *interp,
Tcl_Obj *objPtr, int *resultPtr);
/* 210 */
-EXTERN int Tk_GetScrollInfoObj(Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[], double *dblPtr,
- int *intPtr);
+EXTERN int Tk_GetScrollInfoObj(Tcl_Interp *interp,
+ Tcl_Size objc, Tcl_Obj *const objv[],
+ double *dblPtr, int *intPtr);
/* 211 */
-EXTERN int Tk_InitOptions(Tcl_Interp *interp, char *recordPtr,
+EXTERN int Tk_InitOptions(Tcl_Interp *interp, void *recordPtr,
Tk_OptionTable optionToken, Tk_Window tkwin);
/* 212 */
-EXTERN TCL_NORETURN1 void Tk_MainEx(int argc, char **argv,
+EXTERN TCL_NORETURN1 void Tk_MainEx(Tcl_Size argc, char **argv,
Tcl_AppInitProc *appInitProc,
Tcl_Interp *interp);
/* 213 */
EXTERN void Tk_RestoreSavedOptions(Tk_SavedOptions *savePtr);
/* 214 */
-EXTERN int Tk_SetOptions(Tcl_Interp *interp, char *recordPtr,
- Tk_OptionTable optionTable, int objc,
+EXTERN int Tk_SetOptions(Tcl_Interp *interp, void *recordPtr,
+ Tk_OptionTable optionTable, Tcl_Size objc,
Tcl_Obj *const objv[], Tk_Window tkwin,
Tk_SavedOptions *savePtr, int *maskPtr);
/* 215 */
@@ -741,7 +751,7 @@ EXTERN int Tk_PostscriptImage(Tk_Image image,
/* 235 */
EXTERN void Tk_PostscriptPath(Tcl_Interp *interp,
Tk_PostscriptInfo psInfo, double *coordPtr,
- int numPoints);
+ Tcl_Size numPoints);
/* 236 */
EXTERN int Tk_PostscriptStipple(Tcl_Interp *interp,
Tk_Window tkwin, Tk_PostscriptInfo psInfo,
@@ -765,7 +775,7 @@ EXTERN Tk_Window Tk_CreateAnonymousWindow(Tcl_Interp *interp,
/* 242 */
EXTERN void Tk_SetClassProcs(Tk_Window tkwin,
const Tk_ClassProcs *procs,
- ClientData instanceData);
+ void *instanceData);
/* 243 */
EXTERN void Tk_SetInternalBorderEx(Tk_Window tkwin, int left,
int right, int top, int bottom);
@@ -776,11 +786,13 @@ EXTERN void Tk_SetMinimumRequestSize(Tk_Window tkwin,
EXTERN void Tk_SetCaretPos(Tk_Window tkwin, int x, int y,
int height);
/* 246 */
-EXTERN void Tk_PhotoPutBlock_Panic(Tk_PhotoHandle handle,
+TK_DEPRECATED("function signature changed")
+void Tk_PhotoPutBlock_Panic(Tk_PhotoHandle handle,
Tk_PhotoImageBlock *blockPtr, int x, int y,
int width, int height, int compRule);
/* 247 */
-EXTERN void Tk_PhotoPutZoomedBlock_Panic(Tk_PhotoHandle handle,
+TK_DEPRECATED("function signature changed")
+void Tk_PhotoPutZoomedBlock_Panic(Tk_PhotoHandle handle,
Tk_PhotoImageBlock *blockPtr, int x, int y,
int width, int height, int zoomX, int zoomY,
int subsampleX, int subsampleY, int compRule);
@@ -799,7 +811,7 @@ EXTERN int Tk_RegisterStyledElement(Tk_StyleEngine engine,
EXTERN int Tk_GetElementId(const char *name);
/* 253 */
EXTERN Tk_Style Tk_CreateStyle(const char *name,
- Tk_StyleEngine engine, ClientData clientData);
+ Tk_StyleEngine engine, void *clientData);
/* 254 */
EXTERN Tk_Style Tk_GetStyle(Tcl_Interp *interp, const char *name);
/* 255 */
@@ -814,26 +826,27 @@ EXTERN Tk_Style Tk_GetStyleFromObj(Tcl_Obj *objPtr);
/* 259 */
EXTERN void Tk_FreeStyleFromObj(Tcl_Obj *objPtr);
/* 260 */
-EXTERN Tk_StyledElement Tk_GetStyledElement(Tk_Style style, int elementId,
+EXTERN Tk_StyledElement Tk_GetStyledElement(Tk_Style style,
+ Tcl_Size elementId,
Tk_OptionTable optionTable);
/* 261 */
EXTERN void Tk_GetElementSize(Tk_Style style,
- Tk_StyledElement element, char *recordPtr,
+ Tk_StyledElement element, void *recordPtr,
Tk_Window tkwin, int width, int height,
int inner, int *widthPtr, int *heightPtr);
/* 262 */
EXTERN void Tk_GetElementBox(Tk_Style style,
- Tk_StyledElement element, char *recordPtr,
+ Tk_StyledElement element, void *recordPtr,
Tk_Window tkwin, int x, int y, int width,
int height, int inner, int *xPtr, int *yPtr,
int *widthPtr, int *heightPtr);
/* 263 */
EXTERN int Tk_GetElementBorderWidth(Tk_Style style,
- Tk_StyledElement element, char *recordPtr,
+ Tk_StyledElement element, void *recordPtr,
Tk_Window tkwin);
/* 264 */
EXTERN void Tk_DrawElement(Tk_Style style,
- Tk_StyledElement element, char *recordPtr,
+ Tk_StyledElement element, void *recordPtr,
Tk_Window tkwin, Drawable d, int x, int y,
int width, int height, int state);
/* 265 */
@@ -864,24 +877,54 @@ EXTERN void Tk_CreateOldImageType(const Tk_ImageType *typePtr);
/* 273 */
EXTERN void Tk_CreateOldPhotoImageFormat(
const Tk_PhotoImageFormat *formatPtr);
-/* Slot 274 is reserved */
-/* Slot 275 is reserved */
-/* Slot 276 is reserved */
-/* Slot 277 is reserved */
-/* Slot 278 is reserved */
-/* Slot 279 is reserved */
-/* Slot 280 is reserved */
-/* Slot 281 is reserved */
-/* Slot 282 is reserved */
-/* Slot 283 is reserved */
-/* Slot 284 is reserved */
-/* Slot 285 is reserved */
-/* Slot 286 is reserved */
-/* Slot 287 is reserved */
-/* Slot 288 is reserved */
-/* Slot 289 is reserved */
+/* 274 */
+EXTERN int Tk_AlwaysShowSelection(Tk_Window tkwin);
+/* 275 */
+EXTERN unsigned Tk_GetButtonMask(unsigned button);
+/* 276 */
+EXTERN int Tk_GetDoublePixelsFromObj(Tcl_Interp *interp,
+ Tk_Window tkwin, Tcl_Obj *objPtr,
+ double *doublePtr);
+/* 277 */
+EXTERN Tcl_Obj * Tk_NewWindowObj(Tk_Window tkwin);
+/* 278 */
+EXTERN void Tk_SendVirtualEvent(Tk_Window tkwin,
+ const char *eventName, Tcl_Obj *detail);
+/* 279 */
+EXTERN Tcl_Obj * Tk_FontGetDescription(Tk_Font tkfont);
+/* 280 */
+EXTERN void Tk_CreatePhotoImageFormatVersion3(
+ const Tk_PhotoImageFormatVersion3 *formatPtr);
+/* 281 */
+EXTERN void Tk_DrawHighlightBorder(Tk_Window tkwin, GC fgGC,
+ GC bgGC, int highlightWidth,
+ Drawable drawable);
+/* 282 */
+EXTERN void Tk_SetMainMenubar(Tcl_Interp *interp,
+ Tk_Window tkwin, const char *menuName);
+/* 283 */
+EXTERN void Tk_SetWindowMenubar(Tcl_Interp *interp,
+ Tk_Window tkwin, const char *oldMenuName,
+ const char *menuName);
+/* 284 */
+EXTERN void Tk_ClipDrawableToRect(Display *display, Drawable d,
+ int x, int y, int width, int height);
+/* 285 */
+EXTERN Tcl_Obj * Tk_GetSystemDefault(Tk_Window tkwin,
+ const char *dbName, const char *className);
+/* 286 */
+EXTERN int Tk_UseWindow(Tcl_Interp *interp, Tk_Window tkwin,
+ const char *string);
+/* 287 */
+EXTERN void Tk_MakeContainer(Tk_Window tkwin);
+/* 288 */
+EXTERN Tk_Window Tk_GetOtherWindow(Tk_Window tkwin);
+/* 289 */
+EXTERN void Tk_Get3DBorderColors(Tk_3DBorder border,
+ XColor *bgColorPtr, XColor *darkColorPtr,
+ XColor *lightColorPtr);
/* 290 */
-EXTERN void TkUnusedStubEntry(void);
+EXTERN Window Tk_MakeWindow(Tk_Window tkwin, Window parent);
typedef struct {
const struct TkPlatStubs *tkPlatStubs;
@@ -900,7 +943,7 @@ typedef struct TkStubs {
void (*tk_3DHorizontalBevel) (Tk_Window tkwin, Drawable drawable, Tk_3DBorder border, int x, int y, int width, int height, int leftIn, int rightIn, int topBevel, int relief); /* 3 */
void (*tk_3DVerticalBevel) (Tk_Window tkwin, Drawable drawable, Tk_3DBorder border, int x, int y, int width, int height, int leftBevel, int relief); /* 4 */
void (*tk_AddOption) (Tk_Window tkwin, const char *name, const char *value, int priority); /* 5 */
- void (*tk_BindEvent) (Tk_BindingTable bindingTable, XEvent *eventPtr, Tk_Window tkwin, int numObjects, ClientData *objectPtr); /* 6 */
+ void (*tk_BindEvent) (Tk_BindingTable bindingTable, XEvent *eventPtr, Tk_Window tkwin, Tcl_Size numObjects, void **objectPtr); /* 6 */
void (*tk_CanvasDrawableCoords) (Tk_Canvas canvas, double x, double y, short *drawableXPtr, short *drawableYPtr); /* 7 */
void (*tk_CanvasEventuallyRedraw) (Tk_Canvas canvas, int x1, int y1, int x2, int y2); /* 8 */
int (*tk_CanvasGetCoord) (Tcl_Interp *interp, Tk_Canvas canvas, const char *str, double *doublePtr); /* 9 */
@@ -908,55 +951,55 @@ typedef struct TkStubs {
int (*tk_CanvasPsBitmap) (Tcl_Interp *interp, Tk_Canvas canvas, Pixmap bitmap, int x, int y, int width, int height); /* 11 */
int (*tk_CanvasPsColor) (Tcl_Interp *interp, Tk_Canvas canvas, XColor *colorPtr); /* 12 */
int (*tk_CanvasPsFont) (Tcl_Interp *interp, Tk_Canvas canvas, Tk_Font font); /* 13 */
- void (*tk_CanvasPsPath) (Tcl_Interp *interp, Tk_Canvas canvas, double *coordPtr, int numPoints); /* 14 */
+ void (*tk_CanvasPsPath) (Tcl_Interp *interp, Tk_Canvas canvas, double *coordPtr, Tcl_Size numPoints); /* 14 */
int (*tk_CanvasPsStipple) (Tcl_Interp *interp, Tk_Canvas canvas, Pixmap bitmap); /* 15 */
double (*tk_CanvasPsY) (Tk_Canvas canvas, double y); /* 16 */
void (*tk_CanvasSetStippleOrigin) (Tk_Canvas canvas, GC gc); /* 17 */
- int (*tk_CanvasTagsParseProc) (ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, int offset); /* 18 */
- CONST86 char * (*tk_CanvasTagsPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); /* 19 */
+ int (*tk_CanvasTagsParseProc) (void *clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, Tcl_Size offset); /* 18 */
+ const char * (*tk_CanvasTagsPrintProc) (void *clientData, Tk_Window tkwin, char *widgRec, Tcl_Size offset, Tcl_FreeProc **freeProcPtr); /* 19 */
Tk_Window (*tk_CanvasTkwin) (Tk_Canvas canvas); /* 20 */
void (*tk_CanvasWindowCoords) (Tk_Canvas canvas, double x, double y, short *screenXPtr, short *screenYPtr); /* 21 */
void (*tk_ChangeWindowAttributes) (Tk_Window tkwin, unsigned long valueMask, XSetWindowAttributes *attsPtr); /* 22 */
- int (*tk_CharBbox) (Tk_TextLayout layout, int index, int *xPtr, int *yPtr, int *widthPtr, int *heightPtr); /* 23 */
+ int (*tk_CharBbox) (Tk_TextLayout layout, Tcl_Size index, int *xPtr, int *yPtr, int *widthPtr, int *heightPtr); /* 23 */
void (*tk_ClearSelection) (Tk_Window tkwin, Atom selection); /* 24 */
int (*tk_ClipboardAppend) (Tcl_Interp *interp, Tk_Window tkwin, Atom target, Atom format, const char *buffer); /* 25 */
int (*tk_ClipboardClear) (Tcl_Interp *interp, Tk_Window tkwin); /* 26 */
- int (*tk_ConfigureInfo) (Tcl_Interp *interp, Tk_Window tkwin, const Tk_ConfigSpec *specs, char *widgRec, const char *argvName, int flags); /* 27 */
- int (*tk_ConfigureValue) (Tcl_Interp *interp, Tk_Window tkwin, const Tk_ConfigSpec *specs, char *widgRec, const char *argvName, int flags); /* 28 */
- int (*tk_ConfigureWidget) (Tcl_Interp *interp, Tk_Window tkwin, const Tk_ConfigSpec *specs, int argc, CONST84 char **argv, char *widgRec, int flags); /* 29 */
+ int (*tk_ConfigureInfo) (Tcl_Interp *interp, Tk_Window tkwin, const Tk_ConfigSpec *specs, void *widgRec, const char *argvName, int flags); /* 27 */
+ int (*tk_ConfigureValue) (Tcl_Interp *interp, Tk_Window tkwin, const Tk_ConfigSpec *specs, void *widgRec, const char *argvName, int flags); /* 28 */
+ int (*tk_ConfigureWidget) (Tcl_Interp *interp, Tk_Window tkwin, const Tk_ConfigSpec *specs, Tcl_Size argc, const char **argv, void *widgRec, int flags); /* 29 */
void (*tk_ConfigureWindow) (Tk_Window tkwin, unsigned int valueMask, XWindowChanges *valuePtr); /* 30 */
- Tk_TextLayout (*tk_ComputeTextLayout) (Tk_Font font, const char *str, int numChars, int wrapLength, Tk_Justify justify, int flags, int *widthPtr, int *heightPtr); /* 31 */
+ Tk_TextLayout (*tk_ComputeTextLayout) (Tk_Font font, const char *str, Tcl_Size numChars, int wrapLength, Tk_Justify justify, int flags, int *widthPtr, int *heightPtr); /* 31 */
Tk_Window (*tk_CoordsToWindow) (int rootX, int rootY, Tk_Window tkwin); /* 32 */
- unsigned long (*tk_CreateBinding) (Tcl_Interp *interp, Tk_BindingTable bindingTable, ClientData object, const char *eventStr, const char *script, int append); /* 33 */
+ unsigned long (*tk_CreateBinding) (Tcl_Interp *interp, Tk_BindingTable bindingTable, void *object, const char *eventStr, const char *script, int append); /* 33 */
Tk_BindingTable (*tk_CreateBindingTable) (Tcl_Interp *interp); /* 34 */
- Tk_ErrorHandler (*tk_CreateErrorHandler) (Display *display, int errNum, int request, int minorCode, Tk_ErrorProc *errorProc, ClientData clientData); /* 35 */
- void (*tk_CreateEventHandler) (Tk_Window token, unsigned long mask, Tk_EventProc *proc, ClientData clientData); /* 36 */
- void (*tk_CreateGenericHandler) (Tk_GenericProc *proc, ClientData clientData); /* 37 */
+ Tk_ErrorHandler (*tk_CreateErrorHandler) (Display *display, int errNum, int request, int minorCode, Tk_ErrorProc *errorProc, void *clientData); /* 35 */
+ void (*tk_CreateEventHandler) (Tk_Window token, unsigned long mask, Tk_EventProc *proc, void *clientData); /* 36 */
+ void (*tk_CreateGenericHandler) (Tk_GenericProc *proc, void *clientData); /* 37 */
void (*tk_CreateImageType) (const Tk_ImageType *typePtr); /* 38 */
void (*tk_CreateItemType) (Tk_ItemType *typePtr); /* 39 */
void (*tk_CreatePhotoImageFormat) (const Tk_PhotoImageFormat *formatPtr); /* 40 */
- void (*tk_CreateSelHandler) (Tk_Window tkwin, Atom selection, Atom target, Tk_SelectionProc *proc, ClientData clientData, Atom format); /* 41 */
+ void (*tk_CreateSelHandler) (Tk_Window tkwin, Atom selection, Atom target, Tk_SelectionProc *proc, void *clientData, Atom format); /* 41 */
Tk_Window (*tk_CreateWindow) (Tcl_Interp *interp, Tk_Window parent, const char *name, const char *screenName); /* 42 */
Tk_Window (*tk_CreateWindowFromPath) (Tcl_Interp *interp, Tk_Window tkwin, const char *pathName, const char *screenName); /* 43 */
int (*tk_DefineBitmap) (Tcl_Interp *interp, const char *name, const void *source, int width, int height); /* 44 */
void (*tk_DefineCursor) (Tk_Window window, Tk_Cursor cursor); /* 45 */
- void (*tk_DeleteAllBindings) (Tk_BindingTable bindingTable, ClientData object); /* 46 */
- int (*tk_DeleteBinding) (Tcl_Interp *interp, Tk_BindingTable bindingTable, ClientData object, const char *eventStr); /* 47 */
+ void (*tk_DeleteAllBindings) (Tk_BindingTable bindingTable, void *object); /* 46 */
+ int (*tk_DeleteBinding) (Tcl_Interp *interp, Tk_BindingTable bindingTable, void *object, const char *eventStr); /* 47 */
void (*tk_DeleteBindingTable) (Tk_BindingTable bindingTable); /* 48 */
void (*tk_DeleteErrorHandler) (Tk_ErrorHandler handler); /* 49 */
- void (*tk_DeleteEventHandler) (Tk_Window token, unsigned long mask, Tk_EventProc *proc, ClientData clientData); /* 50 */
- void (*tk_DeleteGenericHandler) (Tk_GenericProc *proc, ClientData clientData); /* 51 */
+ void (*tk_DeleteEventHandler) (Tk_Window token, unsigned long mask, Tk_EventProc *proc, void *clientData); /* 50 */
+ void (*tk_DeleteGenericHandler) (Tk_GenericProc *proc, void *clientData); /* 51 */
void (*tk_DeleteImage) (Tcl_Interp *interp, const char *name); /* 52 */
void (*tk_DeleteSelHandler) (Tk_Window tkwin, Atom selection, Atom target); /* 53 */
void (*tk_DestroyWindow) (Tk_Window tkwin); /* 54 */
- CONST84_RETURN char * (*tk_DisplayName) (Tk_Window tkwin); /* 55 */
+ const char * (*tk_DisplayName) (Tk_Window tkwin); /* 55 */
int (*tk_DistanceToTextLayout) (Tk_TextLayout layout, int x, int y); /* 56 */
- void (*tk_Draw3DPolygon) (Tk_Window tkwin, Drawable drawable, Tk_3DBorder border, XPoint *pointPtr, int numPoints, int borderWidth, int leftRelief); /* 57 */
+ void (*tk_Draw3DPolygon) (Tk_Window tkwin, Drawable drawable, Tk_3DBorder border, XPoint *pointPtr, Tcl_Size numPoints, int borderWidth, int leftRelief); /* 57 */
void (*tk_Draw3DRectangle) (Tk_Window tkwin, Drawable drawable, Tk_3DBorder border, int x, int y, int width, int height, int borderWidth, int relief); /* 58 */
- void (*tk_DrawChars) (Display *display, Drawable drawable, GC gc, Tk_Font tkfont, const char *source, int numBytes, int x, int y); /* 59 */
+ void (*tk_DrawChars) (Display *display, Drawable drawable, GC gc, Tk_Font tkfont, const char *source, Tcl_Size numBytes, int x, int y); /* 59 */
void (*tk_DrawFocusHighlight) (Tk_Window tkwin, GC gc, int width, Drawable drawable); /* 60 */
- void (*tk_DrawTextLayout) (Display *display, Drawable drawable, GC gc, Tk_TextLayout layout, int x, int y, int firstChar, int lastChar); /* 61 */
- void (*tk_Fill3DPolygon) (Tk_Window tkwin, Drawable drawable, Tk_3DBorder border, XPoint *pointPtr, int numPoints, int borderWidth, int leftRelief); /* 62 */
+ void (*tk_DrawTextLayout) (Display *display, Drawable drawable, GC gc, Tk_TextLayout layout, int x, int y, Tcl_Size firstChar, Tcl_Size lastChar); /* 61 */
+ void (*tk_Fill3DPolygon) (Tk_Window tkwin, Drawable drawable, Tk_3DBorder border, XPoint *pointPtr, Tcl_Size numPoints, int borderWidth, int leftRelief); /* 62 */
void (*tk_Fill3DRectangle) (Tk_Window tkwin, Drawable drawable, Tk_3DBorder border, int x, int y, int width, int height, int borderWidth, int relief); /* 63 */
Tk_PhotoHandle (*tk_FindPhoto) (Tcl_Interp *interp, const char *imageName); /* 64 */
Font (*tk_FontId) (Tk_Font font); /* 65 */
@@ -968,17 +1011,17 @@ typedef struct TkStubs {
void (*tk_FreeFont) (Tk_Font f); /* 71 */
void (*tk_FreeGC) (Display *display, GC gc); /* 72 */
void (*tk_FreeImage) (Tk_Image image); /* 73 */
- void (*tk_FreeOptions) (const Tk_ConfigSpec *specs, char *widgRec, Display *display, int needFlags); /* 74 */
+ void (*tk_FreeOptions) (const Tk_ConfigSpec *specs, void *widgRec, Display *display, int needFlags); /* 74 */
void (*tk_FreePixmap) (Display *display, Pixmap pixmap); /* 75 */
void (*tk_FreeTextLayout) (Tk_TextLayout textLayout); /* 76 */
- void (*tk_FreeXId) (Display *display, XID xid); /* 77 */
+ TCL_DEPRECATED_API("function does nothing, call can be removed") void (*tk_FreeXId) (Display *display, XID xid); /* 77 */
GC (*tk_GCForColor) (XColor *colorPtr, Drawable drawable); /* 78 */
void (*tk_GeometryRequest) (Tk_Window tkwin, int reqWidth, int reqHeight); /* 79 */
Tk_3DBorder (*tk_Get3DBorder) (Tcl_Interp *interp, Tk_Window tkwin, Tk_Uid colorName); /* 80 */
- void (*tk_GetAllBindings) (Tcl_Interp *interp, Tk_BindingTable bindingTable, ClientData object); /* 81 */
+ void (*tk_GetAllBindings) (Tcl_Interp *interp, Tk_BindingTable bindingTable, void *object); /* 81 */
int (*tk_GetAnchor) (Tcl_Interp *interp, const char *str, Tk_Anchor *anchorPtr); /* 82 */
- CONST84_RETURN char * (*tk_GetAtomName) (Tk_Window tkwin, Atom atom); /* 83 */
- CONST84_RETURN char * (*tk_GetBinding) (Tcl_Interp *interp, Tk_BindingTable bindingTable, ClientData object, const char *eventStr); /* 84 */
+ const char * (*tk_GetAtomName) (Tk_Window tkwin, Atom atom); /* 83 */
+ const char * (*tk_GetBinding) (Tcl_Interp *interp, Tk_BindingTable bindingTable, void *object, const char *eventStr); /* 84 */
Pixmap (*tk_GetBitmap) (Tcl_Interp *interp, Tk_Window tkwin, const char *str); /* 85 */
Pixmap (*tk_GetBitmapFromData) (Tcl_Interp *interp, Tk_Window tkwin, const void *source, int width, int height); /* 86 */
int (*tk_GetCapStyle) (Tcl_Interp *interp, const char *str, int *capPtr); /* 87 */
@@ -991,8 +1034,8 @@ typedef struct TkStubs {
Tk_Font (*tk_GetFontFromObj) (Tk_Window tkwin, Tcl_Obj *objPtr); /* 94 */
void (*tk_GetFontMetrics) (Tk_Font font, Tk_FontMetrics *fmPtr); /* 95 */
GC (*tk_GetGC) (Tk_Window tkwin, unsigned long valueMask, XGCValues *valuePtr); /* 96 */
- Tk_Image (*tk_GetImage) (Tcl_Interp *interp, Tk_Window tkwin, const char *name, Tk_ImageChangedProc *changeProc, ClientData clientData); /* 97 */
- ClientData (*tk_GetImageMasterData) (Tcl_Interp *interp, const char *name, CONST86 Tk_ImageType **typePtrPtr); /* 98 */
+ Tk_Image (*tk_GetImage) (Tcl_Interp *interp, Tk_Window tkwin, const char *name, Tk_ImageChangedProc *changeProc, void *clientData); /* 97 */
+ void * (*tk_GetImageModelData) (Tcl_Interp *interp, const char *name, const Tk_ImageType **typePtrPtr); /* 98 */
Tk_ItemType * (*tk_GetItemTypes) (void); /* 99 */
int (*tk_GetJoinStyle) (Tcl_Interp *interp, const char *str, int *joinPtr); /* 100 */
int (*tk_GetJustify) (Tcl_Interp *interp, const char *str, Tk_Justify *justifyPtr); /* 101 */
@@ -1002,49 +1045,49 @@ typedef struct TkStubs {
Pixmap (*tk_GetPixmap) (Display *display, Drawable d, int width, int height, int depth); /* 105 */
int (*tk_GetRelief) (Tcl_Interp *interp, const char *name, int *reliefPtr); /* 106 */
void (*tk_GetRootCoords) (Tk_Window tkwin, int *xPtr, int *yPtr); /* 107 */
- int (*tk_GetScrollInfo) (Tcl_Interp *interp, int argc, CONST84 char **argv, double *dblPtr, int *intPtr); /* 108 */
+ int (*tk_GetScrollInfo) (Tcl_Interp *interp, Tcl_Size argc, const char **argv, double *dblPtr, int *intPtr); /* 108 */
int (*tk_GetScreenMM) (Tcl_Interp *interp, Tk_Window tkwin, const char *str, double *doublePtr); /* 109 */
- int (*tk_GetSelection) (Tcl_Interp *interp, Tk_Window tkwin, Atom selection, Atom target, Tk_GetSelProc *proc, ClientData clientData); /* 110 */
+ int (*tk_GetSelection) (Tcl_Interp *interp, Tk_Window tkwin, Atom selection, Atom target, Tk_GetSelProc *proc, void *clientData); /* 110 */
Tk_Uid (*tk_GetUid) (const char *str); /* 111 */
Visual * (*tk_GetVisual) (Tcl_Interp *interp, Tk_Window tkwin, const char *str, int *depthPtr, Colormap *colormapPtr); /* 112 */
void (*tk_GetVRootGeometry) (Tk_Window tkwin, int *xPtr, int *yPtr, int *widthPtr, int *heightPtr); /* 113 */
int (*tk_Grab) (Tcl_Interp *interp, Tk_Window tkwin, int grabGlobal); /* 114 */
void (*tk_HandleEvent) (XEvent *eventPtr); /* 115 */
Tk_Window (*tk_IdToWindow) (Display *display, Window window); /* 116 */
- void (*tk_ImageChanged) (Tk_ImageMaster model, int x, int y, int width, int height, int imageWidth, int imageHeight); /* 117 */
+ void (*tk_ImageChanged) (Tk_ImageModel model, int x, int y, int width, int height, int imageWidth, int imageHeight); /* 117 */
int (*tk_Init) (Tcl_Interp *interp); /* 118 */
Atom (*tk_InternAtom) (Tk_Window tkwin, const char *name); /* 119 */
int (*tk_IntersectTextLayout) (Tk_TextLayout layout, int x, int y, int width, int height); /* 120 */
void (*tk_MaintainGeometry) (Tk_Window window, Tk_Window container, int x, int y, int width, int height); /* 121 */
Tk_Window (*tk_MainWindow) (Tcl_Interp *interp); /* 122 */
void (*tk_MakeWindowExist) (Tk_Window tkwin); /* 123 */
- void (*tk_ManageGeometry) (Tk_Window tkwin, const Tk_GeomMgr *mgrPtr, ClientData clientData); /* 124 */
+ void (*tk_ManageGeometry) (Tk_Window tkwin, const Tk_GeomMgr *mgrPtr, void *clientData); /* 124 */
void (*tk_MapWindow) (Tk_Window tkwin); /* 125 */
- int (*tk_MeasureChars) (Tk_Font tkfont, const char *source, int numBytes, int maxPixels, int flags, int *lengthPtr); /* 126 */
+ int (*tk_MeasureChars) (Tk_Font tkfont, const char *source, Tcl_Size numBytes, int maxPixels, int flags, int *lengthPtr); /* 126 */
void (*tk_MoveResizeWindow) (Tk_Window tkwin, int x, int y, int width, int height); /* 127 */
void (*tk_MoveWindow) (Tk_Window tkwin, int x, int y); /* 128 */
void (*tk_MoveToplevelWindow) (Tk_Window tkwin, int x, int y); /* 129 */
- CONST84_RETURN char * (*tk_NameOf3DBorder) (Tk_3DBorder border); /* 130 */
- CONST84_RETURN char * (*tk_NameOfAnchor) (Tk_Anchor anchor); /* 131 */
- CONST84_RETURN char * (*tk_NameOfBitmap) (Display *display, Pixmap bitmap); /* 132 */
- CONST84_RETURN char * (*tk_NameOfCapStyle) (int cap); /* 133 */
- CONST84_RETURN char * (*tk_NameOfColor) (XColor *colorPtr); /* 134 */
- CONST84_RETURN char * (*tk_NameOfCursor) (Display *display, Tk_Cursor cursor); /* 135 */
- CONST84_RETURN char * (*tk_NameOfFont) (Tk_Font font); /* 136 */
- CONST84_RETURN char * (*tk_NameOfImage) (Tk_ImageMaster model); /* 137 */
- CONST84_RETURN char * (*tk_NameOfJoinStyle) (int join); /* 138 */
- CONST84_RETURN char * (*tk_NameOfJustify) (Tk_Justify justify); /* 139 */
- CONST84_RETURN char * (*tk_NameOfRelief) (int relief); /* 140 */
+ const char * (*tk_NameOf3DBorder) (Tk_3DBorder border); /* 130 */
+ const char * (*tk_NameOfAnchor) (Tk_Anchor anchor); /* 131 */
+ const char * (*tk_NameOfBitmap) (Display *display, Pixmap bitmap); /* 132 */
+ const char * (*tk_NameOfCapStyle) (int cap); /* 133 */
+ const char * (*tk_NameOfColor) (XColor *colorPtr); /* 134 */
+ const char * (*tk_NameOfCursor) (Display *display, Tk_Cursor cursor); /* 135 */
+ const char * (*tk_NameOfFont) (Tk_Font font); /* 136 */
+ const char * (*tk_NameOfImage) (Tk_ImageModel model); /* 137 */
+ const char * (*tk_NameOfJoinStyle) (int join); /* 138 */
+ const char * (*tk_NameOfJustify) (Tk_Justify justify); /* 139 */
+ const char * (*tk_NameOfRelief) (int relief); /* 140 */
Tk_Window (*tk_NameToWindow) (Tcl_Interp *interp, const char *pathName, Tk_Window tkwin); /* 141 */
- void (*tk_OwnSelection) (Tk_Window tkwin, Atom selection, Tk_LostSelProc *proc, ClientData clientData); /* 142 */
- int (*tk_ParseArgv) (Tcl_Interp *interp, Tk_Window tkwin, int *argcPtr, CONST84 char **argv, const Tk_ArgvInfo *argTable, int flags); /* 143 */
- void (*tk_PhotoPutBlock_NoComposite) (Tk_PhotoHandle handle, Tk_PhotoImageBlock *blockPtr, int x, int y, int width, int height); /* 144 */
- void (*tk_PhotoPutZoomedBlock_NoComposite) (Tk_PhotoHandle handle, Tk_PhotoImageBlock *blockPtr, int x, int y, int width, int height, int zoomX, int zoomY, int subsampleX, int subsampleY); /* 145 */
+ void (*tk_OwnSelection) (Tk_Window tkwin, Atom selection, Tk_LostSelProc *proc, void *clientData); /* 142 */
+ int (*tk_ParseArgv) (Tcl_Interp *interp, Tk_Window tkwin, int *argcPtr, const char **argv, const Tk_ArgvInfo *argTable, int flags); /* 143 */
+ TCL_DEPRECATED_API("function signature changed") void (*tk_PhotoPutBlock_NoComposite) (Tk_PhotoHandle handle, Tk_PhotoImageBlock *blockPtr, int x, int y, int width, int height); /* 144 */
+ TCL_DEPRECATED_API("function signature changed") void (*tk_PhotoPutZoomedBlock_NoComposite) (Tk_PhotoHandle handle, Tk_PhotoImageBlock *blockPtr, int x, int y, int width, int height, int zoomX, int zoomY, int subsampleX, int subsampleY); /* 145 */
int (*tk_PhotoGetImage) (Tk_PhotoHandle handle, Tk_PhotoImageBlock *blockPtr); /* 146 */
void (*tk_PhotoBlank) (Tk_PhotoHandle handle); /* 147 */
- void (*tk_PhotoExpand_Panic) (Tk_PhotoHandle handle, int width, int height); /* 148 */
+ TCL_DEPRECATED_API("function signature changed") void (*tk_PhotoExpand_Panic) (Tk_PhotoHandle handle, int width, int height); /* 148 */
void (*tk_PhotoGetSize) (Tk_PhotoHandle handle, int *widthPtr, int *heightPtr); /* 149 */
- void (*tk_PhotoSetSize_Panic) (Tk_PhotoHandle handle, int width, int height); /* 150 */
+ TCL_DEPRECATED_API("function signature changed") void (*tk_PhotoSetSize_Panic) (Tk_PhotoHandle handle, int width, int height); /* 150 */
int (*tk_PointToChar) (Tk_TextLayout layout, int x, int y); /* 151 */
int (*tk_PostscriptFontName) (Tk_Font tkfont, Tcl_DString *dsPtr); /* 152 */
void (*tk_PreserveColormap) (Display *display, Colormap colormap); /* 153 */
@@ -1052,7 +1095,7 @@ typedef struct TkStubs {
void (*tk_RedrawImage) (Tk_Image image, int imageX, int imageY, int width, int height, Drawable drawable, int drawableX, int drawableY); /* 155 */
void (*tk_ResizeWindow) (Tk_Window tkwin, int width, int height); /* 156 */
int (*tk_RestackWindow) (Tk_Window tkwin, int aboveBelow, Tk_Window other); /* 157 */
- Tk_RestrictProc * (*tk_RestrictEvents) (Tk_RestrictProc *proc, ClientData arg, ClientData *prevArgPtr); /* 158 */
+ Tk_RestrictProc * (*tk_RestrictEvents) (Tk_RestrictProc *proc, void *arg, void **prevArgPtr); /* 158 */
int (*tk_SafeInit) (Tcl_Interp *interp); /* 159 */
const char * (*tk_SetAppName) (Tk_Window tkwin, const char *name); /* 160 */
void (*tk_SetBackgroundFromBorder) (Tk_Window tkwin, Tk_3DBorder border); /* 161 */
@@ -1070,9 +1113,9 @@ typedef struct TkStubs {
void (*tk_SizeOfImage) (Tk_Image image, int *widthPtr, int *heightPtr); /* 173 */
int (*tk_StrictMotif) (Tk_Window tkwin); /* 174 */
void (*tk_TextLayoutToPostscript) (Tcl_Interp *interp, Tk_TextLayout layout); /* 175 */
- int (*tk_TextWidth) (Tk_Font font, const char *str, int numBytes); /* 176 */
+ int (*tk_TextWidth) (Tk_Font font, const char *str, Tcl_Size numBytes); /* 176 */
void (*tk_UndefineCursor) (Tk_Window window); /* 177 */
- void (*tk_UnderlineChars) (Display *display, Drawable drawable, GC gc, Tk_Font tkfont, const char *source, int x, int y, int firstByte, int lastByte); /* 178 */
+ void (*tk_UnderlineChars) (Display *display, Drawable drawable, GC gc, Tk_Font tkfont, const char *source, int x, int y, Tcl_Size firstByte, Tcl_Size lastByte); /* 178 */
void (*tk_UnderlineTextLayout) (Display *display, Drawable drawable, GC gc, Tk_TextLayout layout, int x, int y, int underline); /* 179 */
void (*tk_Ungrab) (Tk_Window tkwin); /* 180 */
void (*tk_UnmaintainGeometry) (Tk_Window window, Tk_Window container); /* 181 */
@@ -1089,7 +1132,7 @@ typedef struct TkStubs {
void (*tk_Free3DBorderFromObj) (Tk_Window tkwin, Tcl_Obj *objPtr); /* 192 */
void (*tk_FreeBitmapFromObj) (Tk_Window tkwin, Tcl_Obj *objPtr); /* 193 */
void (*tk_FreeColorFromObj) (Tk_Window tkwin, Tcl_Obj *objPtr); /* 194 */
- void (*tk_FreeConfigOptions) (char *recordPtr, Tk_OptionTable optionToken, Tk_Window tkwin); /* 195 */
+ void (*tk_FreeConfigOptions) (void *recordPtr, Tk_OptionTable optionToken, Tk_Window tkwin); /* 195 */
void (*tk_FreeSavedOptions) (Tk_SavedOptions *savePtr); /* 196 */
void (*tk_FreeCursorFromObj) (Tk_Window tkwin, Tcl_Obj *objPtr); /* 197 */
void (*tk_FreeFontFromObj) (Tk_Window tkwin, Tcl_Obj *objPtr); /* 198 */
@@ -1098,17 +1141,17 @@ typedef struct TkStubs {
Pixmap (*tk_GetBitmapFromObj) (Tk_Window tkwin, Tcl_Obj *objPtr); /* 201 */
XColor * (*tk_GetColorFromObj) (Tk_Window tkwin, Tcl_Obj *objPtr); /* 202 */
Tk_Cursor (*tk_GetCursorFromObj) (Tk_Window tkwin, Tcl_Obj *objPtr); /* 203 */
- Tcl_Obj * (*tk_GetOptionInfo) (Tcl_Interp *interp, char *recordPtr, Tk_OptionTable optionTable, Tcl_Obj *namePtr, Tk_Window tkwin); /* 204 */
- Tcl_Obj * (*tk_GetOptionValue) (Tcl_Interp *interp, char *recordPtr, Tk_OptionTable optionTable, Tcl_Obj *namePtr, Tk_Window tkwin); /* 205 */
+ Tcl_Obj * (*tk_GetOptionInfo) (Tcl_Interp *interp, void *recordPtr, Tk_OptionTable optionTable, Tcl_Obj *namePtr, Tk_Window tkwin); /* 204 */
+ Tcl_Obj * (*tk_GetOptionValue) (Tcl_Interp *interp, void *recordPtr, Tk_OptionTable optionTable, Tcl_Obj *namePtr, Tk_Window tkwin); /* 205 */
int (*tk_GetJustifyFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, Tk_Justify *justifyPtr); /* 206 */
int (*tk_GetMMFromObj) (Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr, double *doublePtr); /* 207 */
int (*tk_GetPixelsFromObj) (Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr, int *intPtr); /* 208 */
int (*tk_GetReliefFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, int *resultPtr); /* 209 */
- int (*tk_GetScrollInfoObj) (Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], double *dblPtr, int *intPtr); /* 210 */
- int (*tk_InitOptions) (Tcl_Interp *interp, char *recordPtr, Tk_OptionTable optionToken, Tk_Window tkwin); /* 211 */
- TCL_NORETURN1 void (*tk_MainEx) (int argc, char **argv, Tcl_AppInitProc *appInitProc, Tcl_Interp *interp); /* 212 */
+ int (*tk_GetScrollInfoObj) (Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[], double *dblPtr, int *intPtr); /* 210 */
+ int (*tk_InitOptions) (Tcl_Interp *interp, void *recordPtr, Tk_OptionTable optionToken, Tk_Window tkwin); /* 211 */
+ TCL_DEPRECATED_API("Don't use this function in a stub-enabled extension") TCL_NORETURN1 void (*tk_MainEx) (Tcl_Size argc, char **argv, Tcl_AppInitProc *appInitProc, Tcl_Interp *interp); /* 212 */
void (*tk_RestoreSavedOptions) (Tk_SavedOptions *savePtr); /* 213 */
- int (*tk_SetOptions) (Tcl_Interp *interp, char *recordPtr, Tk_OptionTable optionTable, int objc, Tcl_Obj *const objv[], Tk_Window tkwin, Tk_SavedOptions *savePtr, int *maskPtr); /* 214 */
+ int (*tk_SetOptions) (Tcl_Interp *interp, void *recordPtr, Tk_OptionTable optionTable, Tcl_Size objc, Tcl_Obj *const objv[], Tk_Window tkwin, Tk_SavedOptions *savePtr, int *maskPtr); /* 214 */
void (*tk_InitConsoleChannels) (Tcl_Interp *interp); /* 215 */
int (*tk_CreateConsoleWindow) (Tcl_Interp *interp); /* 216 */
void (*tk_CreateSmoothMethod) (Tcl_Interp *interp, const Tk_SmoothMethod *method); /* 217 */
@@ -1129,36 +1172,36 @@ typedef struct TkStubs {
int (*tk_PostscriptColor) (Tcl_Interp *interp, Tk_PostscriptInfo psInfo, XColor *colorPtr); /* 232 */
int (*tk_PostscriptFont) (Tcl_Interp *interp, Tk_PostscriptInfo psInfo, Tk_Font font); /* 233 */
int (*tk_PostscriptImage) (Tk_Image image, Tcl_Interp *interp, Tk_Window tkwin, Tk_PostscriptInfo psinfo, int x, int y, int width, int height, int prepass); /* 234 */
- void (*tk_PostscriptPath) (Tcl_Interp *interp, Tk_PostscriptInfo psInfo, double *coordPtr, int numPoints); /* 235 */
+ void (*tk_PostscriptPath) (Tcl_Interp *interp, Tk_PostscriptInfo psInfo, double *coordPtr, Tcl_Size numPoints); /* 235 */
int (*tk_PostscriptStipple) (Tcl_Interp *interp, Tk_Window tkwin, Tk_PostscriptInfo psInfo, Pixmap bitmap); /* 236 */
double (*tk_PostscriptY) (double y, Tk_PostscriptInfo psInfo); /* 237 */
int (*tk_PostscriptPhoto) (Tcl_Interp *interp, Tk_PhotoImageBlock *blockPtr, Tk_PostscriptInfo psInfo, int width, int height); /* 238 */
void (*tk_CreateClientMessageHandler) (Tk_ClientMessageProc *proc); /* 239 */
void (*tk_DeleteClientMessageHandler) (Tk_ClientMessageProc *proc); /* 240 */
Tk_Window (*tk_CreateAnonymousWindow) (Tcl_Interp *interp, Tk_Window parent, const char *screenName); /* 241 */
- void (*tk_SetClassProcs) (Tk_Window tkwin, const Tk_ClassProcs *procs, ClientData instanceData); /* 242 */
+ void (*tk_SetClassProcs) (Tk_Window tkwin, const Tk_ClassProcs *procs, void *instanceData); /* 242 */
void (*tk_SetInternalBorderEx) (Tk_Window tkwin, int left, int right, int top, int bottom); /* 243 */
void (*tk_SetMinimumRequestSize) (Tk_Window tkwin, int minWidth, int minHeight); /* 244 */
void (*tk_SetCaretPos) (Tk_Window tkwin, int x, int y, int height); /* 245 */
- void (*tk_PhotoPutBlock_Panic) (Tk_PhotoHandle handle, Tk_PhotoImageBlock *blockPtr, int x, int y, int width, int height, int compRule); /* 246 */
- void (*tk_PhotoPutZoomedBlock_Panic) (Tk_PhotoHandle handle, Tk_PhotoImageBlock *blockPtr, int x, int y, int width, int height, int zoomX, int zoomY, int subsampleX, int subsampleY, int compRule); /* 247 */
+ TCL_DEPRECATED_API("function signature changed") void (*tk_PhotoPutBlock_Panic) (Tk_PhotoHandle handle, Tk_PhotoImageBlock *blockPtr, int x, int y, int width, int height, int compRule); /* 246 */
+ TCL_DEPRECATED_API("function signature changed") void (*tk_PhotoPutZoomedBlock_Panic) (Tk_PhotoHandle handle, Tk_PhotoImageBlock *blockPtr, int x, int y, int width, int height, int zoomX, int zoomY, int subsampleX, int subsampleY, int compRule); /* 247 */
int (*tk_CollapseMotionEvents) (Display *display, int collapse); /* 248 */
Tk_StyleEngine (*tk_RegisterStyleEngine) (const char *name, Tk_StyleEngine parent); /* 249 */
Tk_StyleEngine (*tk_GetStyleEngine) (const char *name); /* 250 */
int (*tk_RegisterStyledElement) (Tk_StyleEngine engine, Tk_ElementSpec *templatePtr); /* 251 */
int (*tk_GetElementId) (const char *name); /* 252 */
- Tk_Style (*tk_CreateStyle) (const char *name, Tk_StyleEngine engine, ClientData clientData); /* 253 */
+ Tk_Style (*tk_CreateStyle) (const char *name, Tk_StyleEngine engine, void *clientData); /* 253 */
Tk_Style (*tk_GetStyle) (Tcl_Interp *interp, const char *name); /* 254 */
void (*tk_FreeStyle) (Tk_Style style); /* 255 */
const char * (*tk_NameOfStyle) (Tk_Style style); /* 256 */
Tk_Style (*tk_AllocStyleFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr); /* 257 */
Tk_Style (*tk_GetStyleFromObj) (Tcl_Obj *objPtr); /* 258 */
void (*tk_FreeStyleFromObj) (Tcl_Obj *objPtr); /* 259 */
- Tk_StyledElement (*tk_GetStyledElement) (Tk_Style style, int elementId, Tk_OptionTable optionTable); /* 260 */
- void (*tk_GetElementSize) (Tk_Style style, Tk_StyledElement element, char *recordPtr, Tk_Window tkwin, int width, int height, int inner, int *widthPtr, int *heightPtr); /* 261 */
- void (*tk_GetElementBox) (Tk_Style style, Tk_StyledElement element, char *recordPtr, Tk_Window tkwin, int x, int y, int width, int height, int inner, int *xPtr, int *yPtr, int *widthPtr, int *heightPtr); /* 262 */
- int (*tk_GetElementBorderWidth) (Tk_Style style, Tk_StyledElement element, char *recordPtr, Tk_Window tkwin); /* 263 */
- void (*tk_DrawElement) (Tk_Style style, Tk_StyledElement element, char *recordPtr, Tk_Window tkwin, Drawable d, int x, int y, int width, int height, int state); /* 264 */
+ Tk_StyledElement (*tk_GetStyledElement) (Tk_Style style, Tcl_Size elementId, Tk_OptionTable optionTable); /* 260 */
+ void (*tk_GetElementSize) (Tk_Style style, Tk_StyledElement element, void *recordPtr, Tk_Window tkwin, int width, int height, int inner, int *widthPtr, int *heightPtr); /* 261 */
+ void (*tk_GetElementBox) (Tk_Style style, Tk_StyledElement element, void *recordPtr, Tk_Window tkwin, int x, int y, int width, int height, int inner, int *xPtr, int *yPtr, int *widthPtr, int *heightPtr); /* 262 */
+ int (*tk_GetElementBorderWidth) (Tk_Style style, Tk_StyledElement element, void *recordPtr, Tk_Window tkwin); /* 263 */
+ void (*tk_DrawElement) (Tk_Style style, Tk_StyledElement element, void *recordPtr, Tk_Window tkwin, Drawable d, int x, int y, int width, int height, int state); /* 264 */
int (*tk_PhotoExpand) (Tcl_Interp *interp, Tk_PhotoHandle handle, int width, int height); /* 265 */
int (*tk_PhotoPutBlock) (Tcl_Interp *interp, Tk_PhotoHandle handle, Tk_PhotoImageBlock *blockPtr, int x, int y, int width, int height, int compRule); /* 266 */
int (*tk_PhotoPutZoomedBlock) (Tcl_Interp *interp, Tk_PhotoHandle handle, Tk_PhotoImageBlock *blockPtr, int x, int y, int width, int height, int zoomX, int zoomY, int subsampleX, int subsampleY, int compRule); /* 267 */
@@ -1168,23 +1211,23 @@ typedef struct TkStubs {
Tcl_Interp * (*tk_Interp) (Tk_Window tkwin); /* 271 */
void (*tk_CreateOldImageType) (const Tk_ImageType *typePtr); /* 272 */
void (*tk_CreateOldPhotoImageFormat) (const Tk_PhotoImageFormat *formatPtr); /* 273 */
- void (*reserved274)(void);
- void (*reserved275)(void);
- void (*reserved276)(void);
- void (*reserved277)(void);
- void (*reserved278)(void);
- void (*reserved279)(void);
- void (*reserved280)(void);
- void (*reserved281)(void);
- void (*reserved282)(void);
- void (*reserved283)(void);
- void (*reserved284)(void);
- void (*reserved285)(void);
- void (*reserved286)(void);
- void (*reserved287)(void);
- void (*reserved288)(void);
- void (*reserved289)(void);
- void (*tkUnusedStubEntry) (void); /* 290 */
+ int (*tk_AlwaysShowSelection) (Tk_Window tkwin); /* 274 */
+ unsigned (*tk_GetButtonMask) (unsigned button); /* 275 */
+ int (*tk_GetDoublePixelsFromObj) (Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr, double *doublePtr); /* 276 */
+ Tcl_Obj * (*tk_NewWindowObj) (Tk_Window tkwin); /* 277 */
+ void (*tk_SendVirtualEvent) (Tk_Window tkwin, const char *eventName, Tcl_Obj *detail); /* 278 */
+ Tcl_Obj * (*tk_FontGetDescription) (Tk_Font tkfont); /* 279 */
+ void (*tk_CreatePhotoImageFormatVersion3) (const Tk_PhotoImageFormatVersion3 *formatPtr); /* 280 */
+ void (*tk_DrawHighlightBorder) (Tk_Window tkwin, GC fgGC, GC bgGC, int highlightWidth, Drawable drawable); /* 281 */
+ void (*tk_SetMainMenubar) (Tcl_Interp *interp, Tk_Window tkwin, const char *menuName); /* 282 */
+ void (*tk_SetWindowMenubar) (Tcl_Interp *interp, Tk_Window tkwin, const char *oldMenuName, const char *menuName); /* 283 */
+ void (*tk_ClipDrawableToRect) (Display *display, Drawable d, int x, int y, int width, int height); /* 284 */
+ Tcl_Obj * (*tk_GetSystemDefault) (Tk_Window tkwin, const char *dbName, const char *className); /* 285 */
+ int (*tk_UseWindow) (Tcl_Interp *interp, Tk_Window tkwin, const char *string); /* 286 */
+ void (*tk_MakeContainer) (Tk_Window tkwin); /* 287 */
+ Tk_Window (*tk_GetOtherWindow) (Tk_Window tkwin); /* 288 */
+ void (*tk_Get3DBorderColors) (Tk_3DBorder border, XColor *bgColorPtr, XColor *darkColorPtr, XColor *lightColorPtr); /* 289 */
+ Window (*tk_MakeWindow) (Tk_Window tkwin, Window parent); /* 290 */
} TkStubs;
extern const TkStubs *tkStubsPtr;
@@ -1395,8 +1438,8 @@ extern const TkStubs *tkStubsPtr;
(tkStubsPtr->tk_GetGC) /* 96 */
#define Tk_GetImage \
(tkStubsPtr->tk_GetImage) /* 97 */
-#define Tk_GetImageMasterData \
- (tkStubsPtr->tk_GetImageMasterData) /* 98 */
+#define Tk_GetImageModelData \
+ (tkStubsPtr->tk_GetImageModelData) /* 98 */
#define Tk_GetItemTypes \
(tkStubsPtr->tk_GetItemTypes) /* 99 */
#define Tk_GetJoinStyle \
@@ -1745,24 +1788,40 @@ extern const TkStubs *tkStubsPtr;
(tkStubsPtr->tk_CreateOldImageType) /* 272 */
#define Tk_CreateOldPhotoImageFormat \
(tkStubsPtr->tk_CreateOldPhotoImageFormat) /* 273 */
-/* Slot 274 is reserved */
-/* Slot 275 is reserved */
-/* Slot 276 is reserved */
-/* Slot 277 is reserved */
-/* Slot 278 is reserved */
-/* Slot 279 is reserved */
-/* Slot 280 is reserved */
-/* Slot 281 is reserved */
-/* Slot 282 is reserved */
-/* Slot 283 is reserved */
-/* Slot 284 is reserved */
-/* Slot 285 is reserved */
-/* Slot 286 is reserved */
-/* Slot 287 is reserved */
-/* Slot 288 is reserved */
-/* Slot 289 is reserved */
-#define TkUnusedStubEntry \
- (tkStubsPtr->tkUnusedStubEntry) /* 290 */
+#define Tk_AlwaysShowSelection \
+ (tkStubsPtr->tk_AlwaysShowSelection) /* 274 */
+#define Tk_GetButtonMask \
+ (tkStubsPtr->tk_GetButtonMask) /* 275 */
+#define Tk_GetDoublePixelsFromObj \
+ (tkStubsPtr->tk_GetDoublePixelsFromObj) /* 276 */
+#define Tk_NewWindowObj \
+ (tkStubsPtr->tk_NewWindowObj) /* 277 */
+#define Tk_SendVirtualEvent \
+ (tkStubsPtr->tk_SendVirtualEvent) /* 278 */
+#define Tk_FontGetDescription \
+ (tkStubsPtr->tk_FontGetDescription) /* 279 */
+#define Tk_CreatePhotoImageFormatVersion3 \
+ (tkStubsPtr->tk_CreatePhotoImageFormatVersion3) /* 280 */
+#define Tk_DrawHighlightBorder \
+ (tkStubsPtr->tk_DrawHighlightBorder) /* 281 */
+#define Tk_SetMainMenubar \
+ (tkStubsPtr->tk_SetMainMenubar) /* 282 */
+#define Tk_SetWindowMenubar \
+ (tkStubsPtr->tk_SetWindowMenubar) /* 283 */
+#define Tk_ClipDrawableToRect \
+ (tkStubsPtr->tk_ClipDrawableToRect) /* 284 */
+#define Tk_GetSystemDefault \
+ (tkStubsPtr->tk_GetSystemDefault) /* 285 */
+#define Tk_UseWindow \
+ (tkStubsPtr->tk_UseWindow) /* 286 */
+#define Tk_MakeContainer \
+ (tkStubsPtr->tk_MakeContainer) /* 287 */
+#define Tk_GetOtherWindow \
+ (tkStubsPtr->tk_GetOtherWindow) /* 288 */
+#define Tk_Get3DBorderColors \
+ (tkStubsPtr->tk_Get3DBorderColors) /* 289 */
+#define Tk_MakeWindow \
+ (tkStubsPtr->tk_MakeWindow) /* 290 */
#endif /* defined(USE_TK_STUBS) */
@@ -1773,15 +1832,35 @@ extern const TkStubs *tkStubsPtr;
#undef Tk_Init
#undef Tk_SafeInit
#undef Tk_CreateConsoleWindow
-#define Tk_GetImageModelData Tk_GetImageMasterData
+
+#undef Tk_FreeXId
+#define Tk_FreeXId(display,xid)
+#undef Tk_GetStyleFromObj
+#undef Tk_FreeStyleFromObj
+#define Tk_GetStyleFromObj(obj) Tk_AllocStyleFromObj(NULL, obj)
+#define Tk_FreeStyleFromObj(obj) /* no-op */
+#define Tk_GetImageMasterData Tk_GetImageModelData
+
+#ifndef MAC_OSX_TK
+# undef Tk_ClipDrawableToRect
+#endif
#if defined(_WIN32) && defined(UNICODE)
# define Tk_MainEx Tk_MainExW
- EXTERN void Tk_MainExW(int argc, wchar_t **argv,
+ EXTERN void Tk_MainExW(Tcl_Size argc, wchar_t **argv,
Tcl_AppInitProc *appInitProc, Tcl_Interp *interp);
#endif
-#undef Tk_FreeStyleFromObj
-#define Tk_FreeStyleFromObj(objPtr) ((void)(objPtr))
+
+
+#if defined(TK_NO_DEPRECATED) || TCL_MAJOR_VERSION > 8
+#undef Tk_PhotoPutBlock_NoComposite
+#undef Tk_PhotoPutZoomedBlock_NoComposite
+#undef Tk_PhotoExpand_Panic
+#undef Tk_PhotoPutBlock_Panic
+#undef Tk_PhotoPutZoomedBlock_Panic
+#undef Tk_PhotoSetSize_Panic
+#undef Tk_CreateOldPhotoImageFormat
+#endif /* TK_NO_DEPRECATED */
#undef TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS DLLIMPORT
diff --git a/generic/tkEntry.c b/generic/tkEntry.c
index 3c38c5c..7ee455e 100644
--- a/generic/tkEntry.c
+++ b/generic/tkEntry.c
@@ -6,10 +6,10 @@
* spinbox expands on the entry by adding up/down buttons that control
* the value of the entry widget.
*
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
- * Copyright (c) 2000 Ajuba Solutions.
- * Copyright (c) 2002 ActiveState Corporation.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 2000 Ajuba Solutions.
+ * Copyright © 2002 ActiveState Corporation.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -67,102 +67,108 @@ enum validateType {
static const Tk_OptionSpec entryOptSpec[] = {
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_ENTRY_BG_COLOR, -1, Tk_Offset(Entry, normalBorder),
+ DEF_ENTRY_BG_COLOR, TCL_INDEX_NONE, offsetof(Entry, normalBorder),
0, DEF_ENTRY_BG_MONO, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL,
- NULL, 0, -1, 0, "-background", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_ENTRY_BORDER_WIDTH, -1, Tk_Offset(Entry, borderWidth), 0, 0, 0},
+ DEF_ENTRY_BORDER_WIDTH, TCL_INDEX_NONE, offsetof(Entry, borderWidth), 0, 0, 0},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_ENTRY_CURSOR, -1, Tk_Offset(Entry, cursor),
+ DEF_ENTRY_CURSOR, TCL_INDEX_NONE, offsetof(Entry, cursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_BORDER, "-disabledbackground", "disabledBackground",
- "DisabledBackground", DEF_ENTRY_DISABLED_BG_COLOR, -1,
- Tk_Offset(Entry, disabledBorder), TK_OPTION_NULL_OK,
+ "DisabledBackground", DEF_ENTRY_DISABLED_BG_COLOR, TCL_INDEX_NONE,
+ offsetof(Entry, disabledBorder), TK_OPTION_NULL_OK,
DEF_ENTRY_DISABLED_BG_MONO, 0},
{TK_OPTION_COLOR, "-disabledforeground", "disabledForeground",
- "DisabledForeground", DEF_ENTRY_DISABLED_FG, -1,
- Tk_Offset(Entry, dfgColorPtr), TK_OPTION_NULL_OK, 0, 0},
+ "DisabledForeground", DEF_ENTRY_DISABLED_FG, TCL_INDEX_NONE,
+ offsetof(Entry, dfgColorPtr), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_BOOLEAN, "-exportselection", "exportSelection",
- "ExportSelection", DEF_ENTRY_EXPORT_SELECTION, -1,
- Tk_Offset(Entry, exportSelection), 0, 0, 0},
+ "ExportSelection", DEF_ENTRY_EXPORT_SELECTION, TCL_INDEX_NONE,
+ offsetof(Entry, exportSelection), 0, 0, 0},
{TK_OPTION_SYNONYM, "-fg", "foreground", NULL,
- NULL, 0, -1, 0, "-foreground", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_ENTRY_FONT, -1, Tk_Offset(Entry, tkfont), 0, 0, 0},
+ DEF_ENTRY_FONT, TCL_INDEX_NONE, offsetof(Entry, tkfont), 0, 0, 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_ENTRY_FG, -1, Tk_Offset(Entry, fgColorPtr), 0, 0, 0},
+ DEF_ENTRY_FG, TCL_INDEX_NONE, offsetof(Entry, fgColorPtr), 0, 0, 0},
{TK_OPTION_COLOR, "-highlightbackground", "highlightBackground",
"HighlightBackground", DEF_ENTRY_HIGHLIGHT_BG,
- -1, Tk_Offset(Entry, highlightBgColorPtr), 0, 0, 0},
+ TCL_INDEX_NONE, offsetof(Entry, highlightBgColorPtr), 0, 0, 0},
{TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_ENTRY_HIGHLIGHT, -1, Tk_Offset(Entry, highlightColorPtr), 0, 0, 0},
+ DEF_ENTRY_HIGHLIGHT, TCL_INDEX_NONE, offsetof(Entry, highlightColorPtr), 0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
- "HighlightThickness", DEF_ENTRY_HIGHLIGHT_WIDTH, -1,
- Tk_Offset(Entry, highlightWidth), 0, 0, 0},
+ "HighlightThickness", DEF_ENTRY_HIGHLIGHT_WIDTH, TCL_INDEX_NONE,
+ offsetof(Entry, highlightWidth), 0, 0, 0},
{TK_OPTION_BORDER, "-insertbackground", "insertBackground", "Foreground",
- DEF_ENTRY_INSERT_BG, -1, Tk_Offset(Entry, insertBorder), 0, 0, 0},
+ DEF_ENTRY_INSERT_BG, TCL_INDEX_NONE, offsetof(Entry, insertBorder), 0, 0, 0},
{TK_OPTION_PIXELS, "-insertborderwidth", "insertBorderWidth",
- "BorderWidth", DEF_ENTRY_INSERT_BD_COLOR, -1,
- Tk_Offset(Entry, insertBorderWidth), 0,
+ "BorderWidth", DEF_ENTRY_INSERT_BD_COLOR, TCL_INDEX_NONE,
+ offsetof(Entry, insertBorderWidth), 0,
DEF_ENTRY_INSERT_BD_MONO, 0},
{TK_OPTION_INT, "-insertofftime", "insertOffTime", "OffTime",
- DEF_ENTRY_INSERT_OFF_TIME, -1, Tk_Offset(Entry, insertOffTime),
+ DEF_ENTRY_INSERT_OFF_TIME, TCL_INDEX_NONE, offsetof(Entry, insertOffTime),
0, 0, 0},
{TK_OPTION_INT, "-insertontime", "insertOnTime", "OnTime",
- DEF_ENTRY_INSERT_ON_TIME, -1, Tk_Offset(Entry, insertOnTime), 0, 0, 0},
+ DEF_ENTRY_INSERT_ON_TIME, TCL_INDEX_NONE, offsetof(Entry, insertOnTime), 0, 0, 0},
{TK_OPTION_PIXELS, "-insertwidth", "insertWidth", "InsertWidth",
- DEF_ENTRY_INSERT_WIDTH, -1, Tk_Offset(Entry, insertWidth), 0, 0, 0},
+ DEF_ENTRY_INSERT_WIDTH, TCL_INDEX_NONE, offsetof(Entry, insertWidth), 0, 0, 0},
{TK_OPTION_STRING, "-invalidcommand", "invalidCommand", "InvalidCommand",
- DEF_ENTRY_INVALIDCMD, -1, Tk_Offset(Entry, invalidCmd),
+ DEF_ENTRY_INVALIDCMD, TCL_INDEX_NONE, offsetof(Entry, invalidCmd),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_SYNONYM, "-invcmd", NULL, NULL,
- NULL, 0, -1, 0, "-invalidcommand", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-invalidcommand", 0},
{TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
- DEF_ENTRY_JUSTIFY, -1, Tk_Offset(Entry, justify), 0, 0, 0},
+ DEF_ENTRY_JUSTIFY, TCL_INDEX_NONE, offsetof(Entry, justify), TK_OPTION_ENUM_VAR, 0, 0},
+ {TK_OPTION_STRING, "-placeholder", "placeHolder", "PlaceHolder",
+ DEF_ENTRY_PLACEHOLDER, TCL_INDEX_NONE, offsetof(Entry, placeholderString),
+ TK_OPTION_NULL_OK, 0, 0},
+ {TK_OPTION_COLOR, "-placeholderforeground", "placeholderForeground",
+ "PlaceholderForeground", DEF_ENTRY_PLACEHOLDERFG, TCL_INDEX_NONE,
+ offsetof(Entry, placeholderColorPtr), 0, 0, 0},
{TK_OPTION_BORDER, "-readonlybackground", "readonlyBackground",
- "ReadonlyBackground", DEF_ENTRY_READONLY_BG_COLOR, -1,
- Tk_Offset(Entry, readonlyBorder), TK_OPTION_NULL_OK,
+ "ReadonlyBackground", DEF_ENTRY_READONLY_BG_COLOR, TCL_INDEX_NONE,
+ offsetof(Entry, readonlyBorder), TK_OPTION_NULL_OK,
DEF_ENTRY_READONLY_BG_MONO, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_ENTRY_RELIEF, -1, Tk_Offset(Entry, relief), 0, 0, 0},
+ DEF_ENTRY_RELIEF, TCL_INDEX_NONE, offsetof(Entry, relief), 0, 0, 0},
{TK_OPTION_BORDER, "-selectbackground", "selectBackground", "Foreground",
- DEF_ENTRY_SELECT_COLOR, -1, Tk_Offset(Entry, selBorder),
+ DEF_ENTRY_SELECT_COLOR, TCL_INDEX_NONE, offsetof(Entry, selBorder),
0, DEF_ENTRY_SELECT_MONO, 0},
{TK_OPTION_PIXELS, "-selectborderwidth", "selectBorderWidth",
- "BorderWidth", DEF_ENTRY_SELECT_BD_COLOR, -1,
- Tk_Offset(Entry, selBorderWidth),
+ "BorderWidth", DEF_ENTRY_SELECT_BD_COLOR, TCL_INDEX_NONE,
+ offsetof(Entry, selBorderWidth),
0, DEF_ENTRY_SELECT_BD_MONO, 0},
{TK_OPTION_COLOR, "-selectforeground", "selectForeground", "Background",
- DEF_ENTRY_SELECT_FG_COLOR, -1, Tk_Offset(Entry, selFgColorPtr),
+ DEF_ENTRY_SELECT_FG_COLOR, TCL_INDEX_NONE, offsetof(Entry, selFgColorPtr),
TK_OPTION_NULL_OK, DEF_ENTRY_SELECT_FG_MONO, 0},
{TK_OPTION_STRING, "-show", "show", "Show",
- DEF_ENTRY_SHOW, -1, Tk_Offset(Entry, showChar),
+ DEF_ENTRY_SHOW, TCL_INDEX_NONE, offsetof(Entry, showChar),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING_TABLE, "-state", "state", "State",
- DEF_ENTRY_STATE, -1, Tk_Offset(Entry, state),
+ DEF_ENTRY_STATE, TCL_INDEX_NONE, offsetof(Entry, state),
0, stateStrings, 0},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_ENTRY_TAKE_FOCUS, -1, Tk_Offset(Entry, takeFocus),
+ DEF_ENTRY_TAKE_FOCUS, TCL_INDEX_NONE, offsetof(Entry, takeFocus),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-textvariable", "textVariable", "Variable",
- DEF_ENTRY_TEXT_VARIABLE, -1, Tk_Offset(Entry, textVarName),
+ DEF_ENTRY_TEXT_VARIABLE, TCL_INDEX_NONE, offsetof(Entry, textVarName),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING_TABLE, "-validate", "validate", "Validate",
- DEF_ENTRY_VALIDATE, -1, Tk_Offset(Entry, validate),
+ DEF_ENTRY_VALIDATE, TCL_INDEX_NONE, offsetof(Entry, validate),
0, validateStrings, 0},
{TK_OPTION_STRING, "-validatecommand", "validateCommand","ValidateCommand",
- NULL, -1, Tk_Offset(Entry, validateCmd), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(Entry, validateCmd), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_SYNONYM, "-vcmd", NULL, NULL,
- NULL, 0, -1, 0, "-validatecommand", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-validatecommand", 0},
{TK_OPTION_INT, "-width", "width", "Width",
- DEF_ENTRY_WIDTH, -1, Tk_Offset(Entry, prefWidth), 0, 0, 0},
+ DEF_ENTRY_WIDTH, TCL_INDEX_NONE, offsetof(Entry, prefWidth), 0, 0, 0},
{TK_OPTION_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand",
- DEF_ENTRY_SCROLL_COMMAND, -1, Tk_Offset(Entry, scrollCmd),
+ DEF_ENTRY_SCROLL_COMMAND, TCL_INDEX_NONE, offsetof(Entry, scrollCmd),
TK_OPTION_NULL_OK, 0, 0},
- {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0}
+ {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0}
};
/*
@@ -174,9 +180,9 @@ static const Tk_OptionSpec entryOptSpec[] = {
#define DEF_SPINBOX_CMD ""
-#define DEF_SPINBOX_FROM "0"
-#define DEF_SPINBOX_TO "0"
-#define DEF_SPINBOX_INCREMENT "1"
+#define DEF_SPINBOX_FROM "0.0"
+#define DEF_SPINBOX_TO "0.0"
+#define DEF_SPINBOX_INCREMENT "1.0"
#define DEF_SPINBOX_FORMAT ""
#define DEF_SPINBOX_VALUES ""
@@ -184,135 +190,141 @@ static const Tk_OptionSpec entryOptSpec[] = {
static const Tk_OptionSpec sbOptSpec[] = {
{TK_OPTION_BORDER, "-activebackground", "activeBackground", "Background",
- DEF_BUTTON_ACTIVE_BG_COLOR, -1, Tk_Offset(Spinbox, activeBorder),
+ DEF_BUTTON_ACTIVE_BG_COLOR, TCL_INDEX_NONE, offsetof(Spinbox, activeBorder),
0, DEF_BUTTON_ACTIVE_BG_MONO, 0},
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_ENTRY_BG_COLOR, -1, Tk_Offset(Entry, normalBorder),
+ DEF_ENTRY_BG_COLOR, TCL_INDEX_NONE, offsetof(Entry, normalBorder),
0, DEF_ENTRY_BG_MONO, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL,
- NULL, 0, -1, 0, "-background", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_ENTRY_BORDER_WIDTH, -1, Tk_Offset(Entry, borderWidth), 0, 0, 0},
+ DEF_ENTRY_BORDER_WIDTH, TCL_INDEX_NONE, offsetof(Entry, borderWidth), 0, 0, 0},
{TK_OPTION_BORDER, "-buttonbackground", "buttonBackground", "Background",
- DEF_BUTTON_BG_COLOR, -1, Tk_Offset(Spinbox, buttonBorder),
+ DEF_BUTTON_BG_COLOR, TCL_INDEX_NONE, offsetof(Spinbox, buttonBorder),
0, DEF_BUTTON_BG_MONO, 0},
{TK_OPTION_CURSOR, "-buttoncursor", "buttonCursor", "Cursor",
- DEF_BUTTON_CURSOR, -1, Tk_Offset(Spinbox, bCursor),
+ DEF_BUTTON_CURSOR, TCL_INDEX_NONE, offsetof(Spinbox, bCursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_RELIEF, "-buttondownrelief", "buttonDownRelief", "Relief",
- DEF_BUTTON_RELIEF, -1, Tk_Offset(Spinbox, bdRelief), 0, 0, 0},
+ DEF_BUTTON_RELIEF, TCL_INDEX_NONE, offsetof(Spinbox, bdRelief), 0, 0, 0},
{TK_OPTION_RELIEF, "-buttonuprelief", "buttonUpRelief", "Relief",
- DEF_BUTTON_RELIEF, -1, Tk_Offset(Spinbox, buRelief), 0, 0, 0},
+ DEF_BUTTON_RELIEF, TCL_INDEX_NONE, offsetof(Spinbox, buRelief), 0, 0, 0},
{TK_OPTION_STRING, "-command", "command", "Command",
- DEF_SPINBOX_CMD, -1, Tk_Offset(Spinbox, command),
+ DEF_SPINBOX_CMD, TCL_INDEX_NONE, offsetof(Spinbox, command),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_ENTRY_CURSOR, -1, Tk_Offset(Entry, cursor),
+ DEF_ENTRY_CURSOR, TCL_INDEX_NONE, offsetof(Entry, cursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_BORDER, "-disabledbackground", "disabledBackground",
- "DisabledBackground", DEF_ENTRY_DISABLED_BG_COLOR, -1,
- Tk_Offset(Entry, disabledBorder), TK_OPTION_NULL_OK,
+ "DisabledBackground", DEF_ENTRY_DISABLED_BG_COLOR, TCL_INDEX_NONE,
+ offsetof(Entry, disabledBorder), TK_OPTION_NULL_OK,
DEF_ENTRY_DISABLED_BG_MONO, 0},
{TK_OPTION_COLOR, "-disabledforeground", "disabledForeground",
- "DisabledForeground", DEF_ENTRY_DISABLED_FG, -1,
- Tk_Offset(Entry, dfgColorPtr), TK_OPTION_NULL_OK, 0, 0},
+ "DisabledForeground", DEF_ENTRY_DISABLED_FG, TCL_INDEX_NONE,
+ offsetof(Entry, dfgColorPtr), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_BOOLEAN, "-exportselection", "exportSelection",
- "ExportSelection", DEF_ENTRY_EXPORT_SELECTION, -1,
- Tk_Offset(Entry, exportSelection), 0, 0, 0},
+ "ExportSelection", DEF_ENTRY_EXPORT_SELECTION, TCL_INDEX_NONE,
+ offsetof(Entry, exportSelection), 0, 0, 0},
{TK_OPTION_SYNONYM, "-fg", "foreground", NULL,
- NULL, 0, -1, 0, "-foreground", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_ENTRY_FONT, -1, Tk_Offset(Entry, tkfont), 0, 0, 0},
+ DEF_ENTRY_FONT, TCL_INDEX_NONE, offsetof(Entry, tkfont), 0, 0, 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_ENTRY_FG, -1, Tk_Offset(Entry, fgColorPtr), 0, 0, 0},
+ DEF_ENTRY_FG, TCL_INDEX_NONE, offsetof(Entry, fgColorPtr), 0, 0, 0},
{TK_OPTION_STRING, "-format", "format", "Format",
- DEF_SPINBOX_FORMAT, -1, Tk_Offset(Spinbox, reqFormat),
+ DEF_SPINBOX_FORMAT, TCL_INDEX_NONE, offsetof(Spinbox, reqFormat),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_DOUBLE, "-from", "from", "From",
- DEF_SPINBOX_FROM, -1, Tk_Offset(Spinbox, fromValue), 0, 0, 0},
+ DEF_SPINBOX_FROM, TCL_INDEX_NONE, offsetof(Spinbox, fromValue), 0, 0, 0},
{TK_OPTION_COLOR, "-highlightbackground", "highlightBackground",
"HighlightBackground", DEF_ENTRY_HIGHLIGHT_BG,
- -1, Tk_Offset(Entry, highlightBgColorPtr), 0, 0, 0},
+ TCL_INDEX_NONE, offsetof(Entry, highlightBgColorPtr), 0, 0, 0},
{TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_ENTRY_HIGHLIGHT, -1, Tk_Offset(Entry, highlightColorPtr), 0, 0, 0},
+ DEF_ENTRY_HIGHLIGHT, TCL_INDEX_NONE, offsetof(Entry, highlightColorPtr), 0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
- "HighlightThickness", DEF_ENTRY_HIGHLIGHT_WIDTH, -1,
- Tk_Offset(Entry, highlightWidth), 0, 0, 0},
+ "HighlightThickness", DEF_ENTRY_HIGHLIGHT_WIDTH, TCL_INDEX_NONE,
+ offsetof(Entry, highlightWidth), 0, 0, 0},
{TK_OPTION_DOUBLE, "-increment", "increment", "Increment",
- DEF_SPINBOX_INCREMENT, -1, Tk_Offset(Spinbox, increment), 0, 0, 0},
+ DEF_SPINBOX_INCREMENT, TCL_INDEX_NONE, offsetof(Spinbox, increment), 0, 0, 0},
{TK_OPTION_BORDER, "-insertbackground", "insertBackground", "Foreground",
- DEF_ENTRY_INSERT_BG, -1, Tk_Offset(Entry, insertBorder), 0, 0, 0},
+ DEF_ENTRY_INSERT_BG, TCL_INDEX_NONE, offsetof(Entry, insertBorder), 0, 0, 0},
{TK_OPTION_PIXELS, "-insertborderwidth", "insertBorderWidth",
- "BorderWidth", DEF_ENTRY_INSERT_BD_COLOR, -1,
- Tk_Offset(Entry, insertBorderWidth), 0,
+ "BorderWidth", DEF_ENTRY_INSERT_BD_COLOR, TCL_INDEX_NONE,
+ offsetof(Entry, insertBorderWidth), 0,
DEF_ENTRY_INSERT_BD_MONO, 0},
{TK_OPTION_INT, "-insertofftime", "insertOffTime", "OffTime",
- DEF_ENTRY_INSERT_OFF_TIME, -1, Tk_Offset(Entry, insertOffTime),
+ DEF_ENTRY_INSERT_OFF_TIME, TCL_INDEX_NONE, offsetof(Entry, insertOffTime),
0, 0, 0},
{TK_OPTION_INT, "-insertontime", "insertOnTime", "OnTime",
- DEF_ENTRY_INSERT_ON_TIME, -1, Tk_Offset(Entry, insertOnTime), 0, 0, 0},
+ DEF_ENTRY_INSERT_ON_TIME, TCL_INDEX_NONE, offsetof(Entry, insertOnTime), 0, 0, 0},
{TK_OPTION_PIXELS, "-insertwidth", "insertWidth", "InsertWidth",
- DEF_ENTRY_INSERT_WIDTH, -1, Tk_Offset(Entry, insertWidth), 0, 0, 0},
+ DEF_ENTRY_INSERT_WIDTH, TCL_INDEX_NONE, offsetof(Entry, insertWidth), 0, 0, 0},
{TK_OPTION_STRING, "-invalidcommand", "invalidCommand", "InvalidCommand",
- DEF_ENTRY_INVALIDCMD, -1, Tk_Offset(Entry, invalidCmd),
+ DEF_ENTRY_INVALIDCMD, TCL_INDEX_NONE, offsetof(Entry, invalidCmd),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_SYNONYM, "-invcmd", NULL, NULL,
- NULL, 0, -1, 0, "-invalidcommand", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-invalidcommand", 0},
{TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
- DEF_ENTRY_JUSTIFY, -1, Tk_Offset(Entry, justify), 0, 0, 0},
+ DEF_ENTRY_JUSTIFY, TCL_INDEX_NONE, offsetof(Entry, justify), TK_OPTION_ENUM_VAR, 0, 0},
+ {TK_OPTION_STRING, "-placeholder", "placeHolder", "PlaceHolder",
+ DEF_ENTRY_PLACEHOLDER, TCL_INDEX_NONE, offsetof(Entry, placeholderString),
+ TK_OPTION_NULL_OK, 0, 0},
+ {TK_OPTION_COLOR, "-placeholderforeground", "placeholderForeground",
+ "PlaceholderForeground", DEF_ENTRY_PLACEHOLDERFG, TCL_INDEX_NONE,
+ offsetof(Entry, placeholderColorPtr), 0, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_ENTRY_RELIEF, -1, Tk_Offset(Entry, relief), 0, 0, 0},
+ DEF_ENTRY_RELIEF, TCL_INDEX_NONE, offsetof(Entry, relief), 0, 0, 0},
{TK_OPTION_BORDER, "-readonlybackground", "readonlyBackground",
- "ReadonlyBackground", DEF_ENTRY_READONLY_BG_COLOR, -1,
- Tk_Offset(Entry, readonlyBorder), TK_OPTION_NULL_OK,
+ "ReadonlyBackground", DEF_ENTRY_READONLY_BG_COLOR, TCL_INDEX_NONE,
+ offsetof(Entry, readonlyBorder), TK_OPTION_NULL_OK,
DEF_ENTRY_READONLY_BG_MONO, 0},
{TK_OPTION_INT, "-repeatdelay", "repeatDelay", "RepeatDelay",
- DEF_SPINBOX_REPEAT_DELAY, -1, Tk_Offset(Spinbox, repeatDelay),
+ DEF_SPINBOX_REPEAT_DELAY, TCL_INDEX_NONE, offsetof(Spinbox, repeatDelay),
0, 0, 0},
{TK_OPTION_INT, "-repeatinterval", "repeatInterval", "RepeatInterval",
- DEF_SPINBOX_REPEAT_INTERVAL, -1, Tk_Offset(Spinbox, repeatInterval),
+ DEF_SPINBOX_REPEAT_INTERVAL, TCL_INDEX_NONE, offsetof(Spinbox, repeatInterval),
0, 0, 0},
{TK_OPTION_BORDER, "-selectbackground", "selectBackground", "Foreground",
- DEF_ENTRY_SELECT_COLOR, -1, Tk_Offset(Entry, selBorder),
+ DEF_ENTRY_SELECT_COLOR, TCL_INDEX_NONE, offsetof(Entry, selBorder),
0, DEF_ENTRY_SELECT_MONO, 0},
{TK_OPTION_PIXELS, "-selectborderwidth", "selectBorderWidth",
- "BorderWidth", DEF_ENTRY_SELECT_BD_COLOR, -1,
- Tk_Offset(Entry, selBorderWidth),
+ "BorderWidth", DEF_ENTRY_SELECT_BD_COLOR, TCL_INDEX_NONE,
+ offsetof(Entry, selBorderWidth),
0, DEF_ENTRY_SELECT_BD_MONO, 0},
{TK_OPTION_COLOR, "-selectforeground", "selectForeground", "Background",
- DEF_ENTRY_SELECT_FG_COLOR, -1, Tk_Offset(Entry, selFgColorPtr),
+ DEF_ENTRY_SELECT_FG_COLOR, TCL_INDEX_NONE, offsetof(Entry, selFgColorPtr),
TK_OPTION_NULL_OK, DEF_ENTRY_SELECT_FG_MONO, 0},
{TK_OPTION_STRING_TABLE, "-state", "state", "State",
- DEF_ENTRY_STATE, -1, Tk_Offset(Entry, state),
+ DEF_ENTRY_STATE, TCL_INDEX_NONE, offsetof(Entry, state),
0, stateStrings, 0},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_ENTRY_TAKE_FOCUS, -1, Tk_Offset(Entry, takeFocus),
+ DEF_ENTRY_TAKE_FOCUS, TCL_INDEX_NONE, offsetof(Entry, takeFocus),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-textvariable", "textVariable", "Variable",
- DEF_ENTRY_TEXT_VARIABLE, -1, Tk_Offset(Entry, textVarName),
+ DEF_ENTRY_TEXT_VARIABLE, TCL_INDEX_NONE, offsetof(Entry, textVarName),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_DOUBLE, "-to", "to", "To",
- DEF_SPINBOX_TO, -1, Tk_Offset(Spinbox, toValue), 0, 0, 0},
+ DEF_SPINBOX_TO, TCL_INDEX_NONE, offsetof(Spinbox, toValue), 0, 0, 0},
{TK_OPTION_STRING_TABLE, "-validate", "validate", "Validate",
- DEF_ENTRY_VALIDATE, -1, Tk_Offset(Entry, validate),
+ DEF_ENTRY_VALIDATE, TCL_INDEX_NONE, offsetof(Entry, validate),
0, validateStrings, 0},
{TK_OPTION_STRING, "-validatecommand", "validateCommand","ValidateCommand",
- NULL, -1, Tk_Offset(Entry, validateCmd), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(Entry, validateCmd), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-values", "values", "Values",
- DEF_SPINBOX_VALUES, -1, Tk_Offset(Spinbox, valueStr),
+ DEF_SPINBOX_VALUES, TCL_INDEX_NONE, offsetof(Spinbox, valueStr),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_SYNONYM, "-vcmd", NULL, NULL,
- NULL, 0, -1, 0, "-validatecommand", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-validatecommand", 0},
{TK_OPTION_INT, "-width", "width", "Width",
- DEF_ENTRY_WIDTH, -1, Tk_Offset(Entry, prefWidth), 0, 0, 0},
+ DEF_ENTRY_WIDTH, TCL_INDEX_NONE, offsetof(Entry, prefWidth), 0, 0, 0},
{TK_OPTION_BOOLEAN, "-wrap", "wrap", "Wrap",
- DEF_SPINBOX_WRAP, -1, Tk_Offset(Spinbox, wrap), 0, 0, 0},
+ DEF_SPINBOX_WRAP, TCL_INDEX_NONE, offsetof(Spinbox, wrap), 0, 0, 0},
{TK_OPTION_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand",
- DEF_ENTRY_SCROLL_COMMAND, -1, Tk_Offset(Entry, scrollCmd),
+ DEF_ENTRY_SCROLL_COMMAND, TCL_INDEX_NONE, offsetof(Entry, scrollCmd),
TK_OPTION_NULL_OK, 0, 0},
- {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0}
+ {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0}
};
/*
@@ -379,7 +391,7 @@ enum sbselCmd {
*/
static const char *const selElementNames[] = {
- "none", "buttondown", "buttonup", NULL, "entry"
+ "buttondown", "buttonup", "none", NULL, "entry"
};
/*
@@ -394,8 +406,8 @@ static const char *const selElementNames[] = {
*/
static int ConfigureEntry(Tcl_Interp *interp, Entry *entryPtr,
- int objc, Tcl_Obj *const objv[]);
-static int DeleteChars(Entry *entryPtr, int index, int count);
+ Tcl_Size objc, Tcl_Obj *const objv[]);
+static int DeleteChars(Entry *entryPtr, Tcl_Size index, Tcl_Size count);
static Tcl_FreeProc DestroyEntry;
static void DisplayEntry(void *clientData);
static void EntryBlinkProc(void *clientData);
@@ -404,42 +416,38 @@ static void EntryComputeGeometry(Entry *entryPtr);
static void EntryEventProc(void *clientData,
XEvent *eventPtr);
static void EntryFocusProc(Entry *entryPtr, int gotFocus);
-static int EntryFetchSelection(void *clientData, int offset,
- char *buffer, int maxBytes);
+static Tcl_Size EntryFetchSelection(void *clientData, Tcl_Size offset,
+ char *buffer, Tcl_Size maxBytes);
static void EntryLostSelection(void *clientData);
static void EventuallyRedraw(Entry *entryPtr);
static void EntryScanTo(Entry *entryPtr, int y);
static void EntrySetValue(Entry *entryPtr, const char *value);
-static void EntrySelectTo(Entry *entryPtr, int index);
+static void EntrySelectTo(Entry *entryPtr, Tcl_Size index);
static char * EntryTextVarProc(void *clientData,
Tcl_Interp *interp, const char *name1,
const char *name2, int flags);
static void EntryUpdateScrollbar(Entry *entryPtr);
static int EntryValidate(Entry *entryPtr, char *cmd);
static int EntryValidateChange(Entry *entryPtr, const char *change,
- const char *newStr, int index, int type);
+ const char *newStr, Tcl_Size index, int type);
static void ExpandPercents(Entry *entryPtr, const char *before,
- const char *change, const char *newStr, int index,
+ const char *change, const char *newStr, Tcl_Size index,
int type, Tcl_DString *dsPtr);
static int EntryValueChanged(Entry *entryPtr,
const char *newValue);
static void EntryVisibleRange(Entry *entryPtr,
double *firstPtr, double *lastPtr);
-static int EntryWidgetObjCmd(void *clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
+static Tcl_ObjCmdProc EntryWidgetObjCmd;
static void EntryWorldChanged(void *instanceData);
static int GetEntryIndex(Tcl_Interp *interp, Entry *entryPtr,
- Tcl_Obj *indexObj, int *indexPtr);
-static int InsertChars(Entry *entryPtr, int index, const char *string);
+ Tcl_Obj *indexObj, Tcl_Size *indexPtr);
+static int InsertChars(Entry *entryPtr, Tcl_Size index, const char *string);
/*
* These forward declarations are the spinbox specific ones:
*/
-static int SpinboxWidgetObjCmd(void *clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
+static Tcl_ObjCmdProc SpinboxWidgetObjCmd;
static int GetSpinboxElement(Spinbox *sbPtr, int x, int y);
static int SpinboxInvoke(Tcl_Interp *interp, Spinbox *sbPtr,
int element);
@@ -525,8 +533,8 @@ Tk_EntryObjCmd(
tmp = (char *)ckalloc(1);
tmp[0] = '\0';
entryPtr->string = tmp;
- entryPtr->selectFirst = -1;
- entryPtr->selectLast = -1;
+ entryPtr->selectFirst = TCL_INDEX_NONE;
+ entryPtr->selectLast = TCL_INDEX_NONE;
entryPtr->cursor = NULL;
entryPtr->exportSelection = 1;
@@ -541,6 +549,8 @@ Tk_EntryObjCmd(
entryPtr->avgWidth = 1;
entryPtr->validate = VALIDATE_NONE;
+ entryPtr->placeholderGC = NULL;
+
/*
* Keep a hold of the associated tkwin until we destroy the entry,
* otherwise Tk might free it while we still need it.
@@ -556,14 +566,14 @@ Tk_EntryObjCmd(
Tk_CreateSelHandler(entryPtr->tkwin, XA_PRIMARY, XA_STRING,
EntryFetchSelection, entryPtr, XA_STRING);
- if ((Tk_InitOptions(interp, (char *) entryPtr, optionTable, tkwin)
+ if ((Tk_InitOptions(interp, entryPtr, optionTable, tkwin)
!= TCL_OK) ||
(ConfigureEntry(interp, entryPtr, objc-2, objv+2) != TCL_OK)) {
Tk_DestroyWindow(entryPtr->tkwin);
return TCL_ERROR;
}
- Tcl_SetObjResult(interp, TkNewWindowObj(entryPtr->tkwin));
+ Tcl_SetObjResult(interp, Tk_NewWindowObj(entryPtr->tkwin));
return TCL_OK;
}
@@ -615,7 +625,7 @@ EntryWidgetObjCmd(
Tcl_Preserve(entryPtr);
switch ((enum entryCmd) cmdIndex) {
case COMMAND_BBOX: {
- int index;
+ Tcl_Size index;
int x, y, width, height;
Tcl_Obj *bbox[4];
@@ -627,14 +637,14 @@ EntryWidgetObjCmd(
&index) != TCL_OK) {
goto error;
}
- if ((index == entryPtr->numChars) && (index > 0)) {
+ if ((index == entryPtr->numChars) && (index + 1 > 1)) {
index--;
}
Tk_CharBbox(entryPtr->textLayout, index, &x, &y, &width, &height);
- bbox[0] = Tcl_NewIntObj(x + entryPtr->layoutX);
- bbox[1] = Tcl_NewIntObj(y + entryPtr->layoutY);
- bbox[2] = Tcl_NewIntObj(width);
- bbox[3] = Tcl_NewIntObj(height);
+ bbox[0] = Tcl_NewWideIntObj(x + entryPtr->layoutX);
+ bbox[1] = Tcl_NewWideIntObj(y + entryPtr->layoutY);
+ bbox[2] = Tcl_NewWideIntObj(width);
+ bbox[3] = Tcl_NewWideIntObj(height);
Tcl_SetObjResult(interp, Tcl_NewListObj(4, bbox));
break;
}
@@ -645,7 +655,7 @@ EntryWidgetObjCmd(
goto error;
}
- objPtr = Tk_GetOptionValue(interp, (char *) entryPtr,
+ objPtr = Tk_GetOptionValue(interp, entryPtr,
entryPtr->optionTable, objv[2], entryPtr->tkwin);
if (objPtr == NULL) {
goto error;
@@ -655,7 +665,7 @@ EntryWidgetObjCmd(
case COMMAND_CONFIGURE:
if (objc <= 3) {
- objPtr = Tk_GetOptionInfo(interp, (char *) entryPtr,
+ objPtr = Tk_GetOptionInfo(interp, entryPtr,
entryPtr->optionTable,
(objc == 3) ? objv[2] : NULL,
entryPtr->tkwin);
@@ -669,7 +679,7 @@ EntryWidgetObjCmd(
break;
case COMMAND_DELETE: {
- int first, last;
+ Tcl_Size first, last;
int code;
if ((objc < 3) || (objc > 4)) {
@@ -700,7 +710,7 @@ EntryWidgetObjCmd(
Tcl_WrongNumArgs(interp, 2, objv, NULL);
goto error;
}
- Tcl_SetObjResult(interp, Tcl_NewStringObj(entryPtr->string, -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(entryPtr->string, TCL_INDEX_NONE));
break;
case COMMAND_ICURSOR:
@@ -716,7 +726,7 @@ EntryWidgetObjCmd(
break;
case COMMAND_INDEX: {
- int index;
+ Tcl_Size index;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "string");
@@ -726,12 +736,12 @@ EntryWidgetObjCmd(
&index) != TCL_OK) {
goto error;
}
- Tcl_SetObjResult(interp, Tcl_NewIntObj(index));
+ Tcl_SetObjResult(interp, TkNewIndexObj(index));
break;
}
case COMMAND_INSERT: {
- int index;
+ Tcl_Size index;
int code;
if (objc != 4) {
@@ -773,7 +783,7 @@ EntryWidgetObjCmd(
EntryScanTo(entryPtr, x);
} else {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "bad scan option \"%s\": must be mark or dragto",
+ "bad scan option \"%s\": must be dragto or mark",
minorCmd));
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "INDEX", "scan option",
minorCmd, NULL);
@@ -783,7 +793,7 @@ EntryWidgetObjCmd(
}
case COMMAND_SELECTION: {
- int index, index2;
+ Tcl_Size index, index2;
if (objc < 3) {
Tcl_WrongNumArgs(interp, 2, objv, "option ?index?");
@@ -821,8 +831,8 @@ EntryWidgetObjCmd(
objv[3], &index) != TCL_OK) {
goto error;
}
- if (entryPtr->selectFirst >= 0) {
- int half1, half2;
+ if (entryPtr->selectFirst != TCL_INDEX_NONE) {
+ Tcl_Size half1, half2;
half1 = (entryPtr->selectFirst + entryPtr->selectLast)/2;
half2 = (entryPtr->selectFirst + entryPtr->selectLast + 1)/2;
@@ -845,9 +855,9 @@ EntryWidgetObjCmd(
Tcl_WrongNumArgs(interp, 3, objv, NULL);
goto error;
}
- if (entryPtr->selectFirst >= 0) {
- entryPtr->selectFirst = -1;
- entryPtr->selectLast = -1;
+ if (entryPtr->selectFirst != TCL_INDEX_NONE) {
+ entryPtr->selectFirst = TCL_INDEX_NONE;
+ entryPtr->selectLast = TCL_INDEX_NONE;
EventuallyRedraw(entryPtr);
}
goto done;
@@ -870,7 +880,7 @@ EntryWidgetObjCmd(
goto error;
}
Tcl_SetObjResult(interp,
- Tcl_NewBooleanObj(entryPtr->selectFirst >= 0));
+ Tcl_NewBooleanObj(entryPtr->selectFirst != TCL_INDEX_NONE));
goto done;
case SELECTION_RANGE:
@@ -887,8 +897,8 @@ EntryWidgetObjCmd(
goto error;
}
if (index >= index2) {
- entryPtr->selectFirst = -1;
- entryPtr->selectLast = -1;
+ entryPtr->selectFirst = TCL_INDEX_NONE;
+ entryPtr->selectLast = TCL_INDEX_NONE;
} else {
entryPtr->selectFirst = index;
entryPtr->selectLast = index2;
@@ -937,7 +947,7 @@ EntryWidgetObjCmd(
}
case COMMAND_XVIEW: {
- int index;
+ Tcl_Size index;
if (objc == 2) {
double first, last;
@@ -984,7 +994,7 @@ EntryWidgetObjCmd(
if (index >= entryPtr->numChars) {
index = entryPtr->numChars - 1;
}
- if (index < 0) {
+ if ((int)index < 0) {
index = 0;
}
entryPtr->leftIndex = index;
@@ -1024,7 +1034,11 @@ EntryWidgetObjCmd(
static void
DestroyEntry(
- char *memPtr) /* Info about entry widget. */
+#if TCL_MAJOR_VERSION > 8
+ void *memPtr) /* Info about entry widget. */
+#else
+ char *memPtr)
+#endif
{
Entry *entryPtr = (Entry *)memPtr;
@@ -1033,7 +1047,7 @@ DestroyEntry(
* Tk_FreeOptions handle all the standard option-related stuff.
*/
- ckfree((char *)entryPtr->string);
+ ckfree((void *)entryPtr->string);
if (entryPtr->textVarName != NULL) {
Tcl_UntraceVar2(entryPtr->interp, entryPtr->textVarName,
NULL, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
@@ -1048,7 +1062,7 @@ DestroyEntry(
}
Tcl_DeleteTimerHandler(entryPtr->insertBlinkHandler);
if (entryPtr->displayString != entryPtr->string) {
- ckfree((char *)entryPtr->displayString);
+ ckfree((void *)entryPtr->displayString);
}
if (entryPtr->type == TK_SPINBOX) {
Spinbox *sbPtr = (Spinbox *) entryPtr;
@@ -1062,7 +1076,7 @@ DestroyEntry(
}
}
Tk_FreeTextLayout(entryPtr->textLayout);
- Tk_FreeConfigOptions((char *) entryPtr, entryPtr->optionTable,
+ Tk_FreeConfigOptions(entryPtr, entryPtr->optionTable,
entryPtr->tkwin);
Tcl_Release(entryPtr->tkwin);
entryPtr->tkwin = NULL;
@@ -1095,7 +1109,7 @@ ConfigureEntry(
Tcl_Interp *interp, /* Used for error reporting. */
Entry *entryPtr, /* Information about widget; may or may not
* already have values for some fields. */
- int objc, /* Number of valid entries in argv. */
+ Tcl_Size objc, /* Number of valid entries in argv. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tk_SavedOptions savedOptions;
@@ -1145,7 +1159,7 @@ ConfigureEntry(
* First pass: set options to new values.
*/
- if (Tk_SetOptions(interp, (char *) entryPtr,
+ if (Tk_SetOptions(interp, entryPtr,
entryPtr->optionTable, objc, objv,
entryPtr->tkwin, &savedOptions, NULL) != TCL_OK) {
continue;
@@ -1185,13 +1199,15 @@ ConfigureEntry(
if (entryPtr->type == TK_SPINBOX) {
if (sbPtr->fromValue > sbPtr->toValue) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "-to value must be greater than -from value",
- -1));
- Tcl_SetErrorCode(interp, "TK", "SPINBOX", "RANGE_SANITY",
- NULL);
- continue;
- }
+ /*
+ * Swap -from and -to values.
+ */
+
+ double tmpFromTo = sbPtr->fromValue;
+
+ sbPtr->fromValue = sbPtr->toValue;
+ sbPtr->toValue = tmpFromTo;
+ }
if (sbPtr->reqFormat && (oldFormat != sbPtr->reqFormat)) {
/*
@@ -1249,9 +1265,9 @@ ConfigureEntry(
sbPtr->listObj = NULL;
if (sbPtr->valueStr != NULL) {
Tcl_Obj *newObjPtr;
- int nelems;
+ Tcl_Size nelems;
- newObjPtr = Tcl_NewStringObj(sbPtr->valueStr, -1);
+ newObjPtr = Tcl_NewStringObj(sbPtr->valueStr, TCL_INDEX_NONE);
if (Tcl_ListObjLength(interp, newObjPtr, &nelems)
!= TCL_OK) {
valuesChanged = -1;
@@ -1286,7 +1302,7 @@ ConfigureEntry(
if (entryPtr->exportSelection && (!oldExport)
&& (!Tcl_IsSafe(entryPtr->interp))
- && (entryPtr->selectFirst != -1)
+ && (entryPtr->selectFirst != TCL_INDEX_NONE)
&& !(entryPtr->flags & GOT_SELECTION)) {
Tk_OwnSelection(entryPtr->tkwin, XA_PRIMARY, EntryLostSelection,
entryPtr);
@@ -1300,7 +1316,7 @@ ConfigureEntry(
Tk_SetInternalBorder(entryPtr->tkwin,
entryPtr->borderWidth + entryPtr->highlightWidth);
- if (entryPtr->highlightWidth <= 0) {
+ if (entryPtr->highlightWidth < 0) {
entryPtr->highlightWidth = 0;
}
entryPtr->inset = entryPtr->highlightWidth
@@ -1380,7 +1396,7 @@ ConfigureEntry(
}
snprintf(sbPtr->formatBuf, formatSpace, sbPtr->valueFormat, dvalue);
- /*
+ /*
* No check for error return here as well, because any possible
* error will be trapped below when attempting tracing.
*/
@@ -1495,8 +1511,20 @@ EntryWorldChanged(
}
entryPtr->textGC = gc;
+ if (entryPtr->placeholderColorPtr != NULL) {
+ gcValues.foreground = entryPtr->placeholderColorPtr->pixel;
+ }
+ mask = GCForeground | GCFont | GCGraphicsExposures;
+ gc = Tk_GetGC(entryPtr->tkwin, mask, &gcValues);
+ if (entryPtr->placeholderGC != NULL) {
+ Tk_FreeGC(entryPtr->display, entryPtr->placeholderGC);
+ }
+ entryPtr->placeholderGC = gc;
+
if (entryPtr->selFgColorPtr != NULL) {
gcValues.foreground = entryPtr->selFgColorPtr->pixel;
+ } else {
+ gcValues.foreground = colorPtr->pixel;
}
gcValues.font = Tk_FontId(entryPtr->tkfont);
mask = GCForeground | GCFont;
@@ -1653,7 +1681,7 @@ DisplayEntry(
* Hide the selection whenever we don't have the focus, unless we
* always want to show selection.
*/
- if (TkpAlwaysShowSelection(entryPtr->tkwin)) {
+ if (Tk_AlwaysShowSelection(entryPtr->tkwin)) {
showSelection = 1;
} else {
showSelection = (entryPtr->flags & GOT_FOCUS);
@@ -1721,7 +1749,7 @@ DisplayEntry(
cursorX -= (entryPtr->insertWidth == 1) ? 1 : (entryPtr->insertWidth)/2;
Tk_SetCaretPos(entryPtr->tkwin, cursorX, baseY - fm.ascent,
fm.ascent + fm.descent);
- if (entryPtr->insertPos >= entryPtr->leftIndex && cursorX < xBound) {
+ if ((entryPtr->insertPos >= entryPtr->leftIndex) && cursorX < xBound) {
if (entryPtr->flags & CURSOR_ON) {
Tk_Fill3DRectangle(tkwin, pixmap, entryPtr->insertBorder,
cursorX, baseY - fm.ascent, entryPtr->insertWidth,
@@ -1735,43 +1763,56 @@ DisplayEntry(
}
}
- if (showSelection && (entryPtr->state != STATE_DISABLED)
- && (entryPtr->selTextGC != entryPtr->textGC)
- && (entryPtr->selectFirst < entryPtr->selectLast)) {
+ if ((entryPtr->numChars == 0) && (entryPtr->placeholderChars != 0)) {
- /*
- * Draw the selected and unselected portions separately.
- */
+ /*
+ * Draw the placeholder text.
+ */
- int selFirst;
+ Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->placeholderGC,
+ entryPtr->placeholderLayout, entryPtr->placeholderX, entryPtr->layoutY,
+ entryPtr->placeholderLeftIndex, entryPtr->placeholderChars);
- if (entryPtr->selectFirst < entryPtr->leftIndex) {
- selFirst = entryPtr->leftIndex;
- } else {
- selFirst = entryPtr->selectFirst;
- }
- if (entryPtr->leftIndex < selFirst) {
- Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->textGC,
- entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY,
- entryPtr->leftIndex, selFirst);
- }
- Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->selTextGC,
- entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY,
- selFirst, entryPtr->selectLast);
- if (entryPtr->selectLast < entryPtr->numChars) {
- Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->textGC,
- entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY,
- entryPtr->selectLast, entryPtr->numChars);
- }
} else {
- /*
- * Draw the entire visible text
- */
+ if (showSelection && (entryPtr->state != STATE_DISABLED)
+ && (entryPtr->selTextGC != entryPtr->textGC)
+ && (entryPtr->selectFirst < entryPtr->selectLast)) {
+
+ /*
+ * Draw the selected and unselected portions separately.
+ */
+
+ Tcl_Size selFirst;
+
+ if (entryPtr->selectFirst < entryPtr->leftIndex) {
+ selFirst = entryPtr->leftIndex;
+ } else {
+ selFirst = entryPtr->selectFirst;
+ }
+ if (entryPtr->leftIndex < selFirst) {
+ Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->textGC,
+ entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY,
+ entryPtr->leftIndex, selFirst);
+ }
+ Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->selTextGC,
+ entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY,
+ selFirst, entryPtr->selectLast);
+ if (entryPtr->selectLast < entryPtr->numChars) {
+ Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->textGC,
+ entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY,
+ entryPtr->selectLast, entryPtr->numChars);
+ }
+ } else {
+
+ /*
+ * Draw the entire visible text
+ */
- Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->textGC,
- entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY,
- entryPtr->leftIndex, entryPtr->numChars);
+ Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->textGC,
+ entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY,
+ entryPtr->leftIndex, entryPtr->numChars);
+ }
}
if (entryPtr->type == TK_SPINBOX) {
@@ -1883,9 +1924,9 @@ DisplayEntry(
bgGC = Tk_GCForColor(entryPtr->highlightBgColorPtr, pixmap);
if (entryPtr->flags & GOT_FOCUS) {
fgGC = Tk_GCForColor(entryPtr->highlightColorPtr, pixmap);
- TkpDrawHighlightBorder(tkwin, fgGC, bgGC, xBound, pixmap);
+ Tk_DrawHighlightBorder(tkwin, fgGC, bgGC, xBound, pixmap);
} else {
- TkpDrawHighlightBorder(tkwin, bgGC, bgGC, xBound, pixmap);
+ Tk_DrawHighlightBorder(tkwin, bgGC, bgGC, xBound, pixmap);
}
}
}
@@ -1929,13 +1970,13 @@ EntryComputeGeometry(
Entry *entryPtr) /* Widget record for entry. */
{
int totalLength, overflow, rightX;
- int maxOffScreen;
+ Tcl_Size maxOffScreen;
int height, width, i;
Tk_FontMetrics fm;
char *p;
if (entryPtr->displayString != entryPtr->string) {
- ckfree((char *)entryPtr->displayString);
+ ckfree((void *)entryPtr->displayString);
entryPtr->displayString = entryPtr->string;
entryPtr->numDisplayBytes = entryPtr->numBytes;
}
@@ -1964,13 +2005,65 @@ EntryComputeGeometry(
p = (char *)ckalloc(entryPtr->numDisplayBytes + 1);
entryPtr->displayString = p;
- for (i = entryPtr->numChars; --i >= 0; ) {
+ for (i = entryPtr->numChars; i-- > 0; ) {
memcpy(p, buf, size);
p += size;
}
*p = '\0';
}
+ /* Recompute layout of placeholder text.
+ * Only the placeholderX and placeholderLeftIndex value is needed.
+ * We use the same font so we can use the layoutY value from below.
+ */
+
+ Tk_FreeTextLayout(entryPtr->placeholderLayout);
+ if (entryPtr->placeholderString) {
+ entryPtr->placeholderChars = strlen(entryPtr->placeholderString);
+ entryPtr->placeholderLayout = Tk_ComputeTextLayout(entryPtr->tkfont,
+ entryPtr->placeholderString, entryPtr->placeholderChars, 0,
+ entryPtr->justify, TK_IGNORE_NEWLINES, &totalLength, NULL);
+ overflow = totalLength -
+ (Tk_Width(entryPtr->tkwin) - 2*entryPtr->inset - entryPtr->xWidth);
+ if (overflow <= 0) {
+ entryPtr->placeholderLeftIndex = 0;
+ if (entryPtr->justify == TK_JUSTIFY_LEFT) {
+ entryPtr->placeholderX = entryPtr->inset;
+ } else if (entryPtr->justify == TK_JUSTIFY_RIGHT) {
+ entryPtr->placeholderX = Tk_Width(entryPtr->tkwin) - entryPtr->inset
+ - entryPtr->xWidth - totalLength;
+ } else {
+ entryPtr->placeholderX = (Tk_Width(entryPtr->tkwin)
+ - entryPtr->xWidth - totalLength)/2;
+ }
+ } 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
+ * placeholderLeftIndex be any greater than that.
+ */
+
+ maxOffScreen = Tk_PointToChar(entryPtr->placeholderLayout, overflow, 0);
+ Tk_CharBbox(entryPtr->placeholderLayout, maxOffScreen,
+ &rightX, NULL, NULL, NULL);
+ if (rightX < overflow) {
+ maxOffScreen++;
+ }
+ entryPtr->placeholderLeftIndex = maxOffScreen;
+ Tk_CharBbox(entryPtr->placeholderLayout, entryPtr->placeholderLeftIndex, &rightX,
+ NULL, NULL, NULL);
+ entryPtr->placeholderX = entryPtr->inset -rightX;
+ }
+ } else {
+ entryPtr->placeholderChars = 0;
+ entryPtr->placeholderLayout = Tk_ComputeTextLayout(entryPtr->tkfont,
+ entryPtr->placeholderString, 0, 0,
+ entryPtr->justify, TK_IGNORE_NEWLINES, NULL, NULL);
+ entryPtr->placeholderX = entryPtr->inset;
+ }
+
Tk_FreeTextLayout(entryPtr->textLayout);
entryPtr->textLayout = Tk_ComputeTextLayout(entryPtr->tkfont,
entryPtr->displayString, entryPtr->numChars, 0,
@@ -2061,14 +2154,12 @@ EntryComputeGeometry(
static int
InsertChars(
Entry *entryPtr, /* Entry that is to get the new elements. */
- int index, /* Add the new elements before this character
+ Tcl_Size index, /* Add the new elements before this character
* index. */
const char *value) /* New characters to add (NULL-terminated
* string). */
{
- ptrdiff_t byteIndex;
- size_t byteCount, newByteCount;
- int oldChars, charsAdded;
+ size_t byteIndex, byteCount, newByteCount, oldChars, charsAdded;
const char *string;
char *newStr;
@@ -2093,22 +2184,20 @@ InsertChars(
return TCL_OK;
}
- ckfree((char *)string);
+ ckfree((void *)string);
entryPtr->string = newStr;
/*
- * ??? Is this construction still needed with Tcl_NumUtfChars ???
- *
* The following construction is used because inserting improperly formed
* UTF-8 sequences between other improperly formed UTF-8 sequences could
* result in actually forming valid UTF-8 sequences; the number of
- * characters added may not be Tcl_NumUtfChars(string, -1), because of
+ * characters added may not be Tcl_NumUtfChars(string, TCL_INDEX_NONE), because of
* context. The actual number of characters added is how many characters
* are in the string now minus the number that used to be there.
*/
oldChars = entryPtr->numChars;
- entryPtr->numChars = Tcl_NumUtfChars(newStr, -1);
+ entryPtr->numChars = TkNumUtfChars(newStr, TCL_INDEX_NONE);
charsAdded = entryPtr->numChars - oldChars;
entryPtr->numBytes += byteCount;
@@ -2164,8 +2253,8 @@ InsertChars(
static int
DeleteChars(
Entry *entryPtr, /* Entry widget to modify. */
- int index, /* Index of first character to delete. */
- int count) /* How many characters to delete. */
+ Tcl_Size index, /* Index of first character to delete. */
+ Tcl_Size count) /* How many characters to delete. */
{
int byteIndex, byteCount, newByteCount;
const char *string;
@@ -2174,7 +2263,7 @@ DeleteChars(
if (index + count > entryPtr->numChars) {
count = entryPtr->numChars - index;
}
- if (count <= 0) {
+ if ((int)count <= 0) {
return TCL_OK;
}
@@ -2201,7 +2290,7 @@ DeleteChars(
}
ckfree(toDelete);
- ckfree((char *)entryPtr->string);
+ ckfree((void *)entryPtr->string);
entryPtr->string = newStr;
entryPtr->numChars -= count;
entryPtr->numBytes -= byteCount;
@@ -2232,8 +2321,8 @@ DeleteChars(
}
}
if (entryPtr->selectLast <= entryPtr->selectFirst) {
- entryPtr->selectFirst = -1;
- entryPtr->selectLast = -1;
+ entryPtr->selectFirst = TCL_INDEX_NONE;
+ entryPtr->selectLast = TCL_INDEX_NONE;
}
if (entryPtr->selectAnchor >= index) {
if (entryPtr->selectAnchor >= index + count) {
@@ -2380,7 +2469,7 @@ EntrySetValue(
malloced = 1;
entryPtr->flags |= VALIDATE_VAR;
- (void) EntryValidateChange(entryPtr, NULL, value, -1,
+ (void) EntryValidateChange(entryPtr, NULL, value, TCL_INDEX_NONE,
VALIDATE_FORCED);
entryPtr->flags &= ~VALIDATE_VAR;
@@ -2391,13 +2480,13 @@ EntrySetValue(
if (entryPtr->flags & VALIDATE_ABORT) {
entryPtr->flags &= ~VALIDATE_ABORT;
- ckfree((char *)value);
+ ckfree((void *)value);
return;
}
}
oldSource = entryPtr->string;
- ckfree((char *)entryPtr->string);
+ ckfree((void *)entryPtr->string);
if (malloced) {
entryPtr->string = value;
@@ -2408,17 +2497,17 @@ EntrySetValue(
entryPtr->string = tmp;
}
entryPtr->numBytes = valueLen;
- entryPtr->numChars = Tcl_NumUtfChars(value, valueLen);
+ entryPtr->numChars = TkNumUtfChars(value, valueLen);
if (entryPtr->displayString == oldSource) {
entryPtr->displayString = entryPtr->string;
entryPtr->numDisplayBytes = entryPtr->numBytes;
}
- if (entryPtr->selectFirst >= 0) {
+ if (entryPtr->selectFirst != TCL_INDEX_NONE) {
if (entryPtr->selectFirst >= entryPtr->numChars) {
- entryPtr->selectFirst = -1;
- entryPtr->selectLast = -1;
+ entryPtr->selectFirst = TCL_INDEX_NONE;
+ entryPtr->selectLast = TCL_INDEX_NONE;
} else if (entryPtr->selectLast > entryPtr->numChars) {
entryPtr->selectLast = entryPtr->numChars;
}
@@ -2583,10 +2672,22 @@ GetEntryIndex(
Entry *entryPtr, /* Entry for which the index is being
* specified. */
Tcl_Obj *indexObj, /* Specifies character in entryPtr. */
- int *indexPtr) /* Where to store converted character index */
+ Tcl_Size *indexPtr) /* Where to store converted character index */
{
- const char *string = Tcl_GetString(indexObj);
- size_t length = indexObj->length;
+ Tcl_Size length, idx;
+ const char *string;
+
+ if (TCL_OK == TkGetIntForIndex(indexObj, entryPtr->numChars - 1, 1, &idx)) {
+ if (idx < 0) {
+ idx = 0;
+ } else if (idx > entryPtr->numChars) {
+ idx = entryPtr->numChars;
+ }
+ *indexPtr = idx;
+ return TCL_OK;
+ }
+
+ string = Tcl_GetStringFromObj(indexObj, &length);
switch (string[0]) {
case 'a':
@@ -2595,12 +2696,6 @@ GetEntryIndex(
}
*indexPtr = entryPtr->selectAnchor;
break;
- case 'e':
- if (strncmp(string, "end", length) != 0) {
- goto badIndex;
- }
- *indexPtr = entryPtr->numChars;
- break;
case 'i':
if (strncmp(string, "insert", length) != 0) {
goto badIndex;
@@ -2661,24 +2756,15 @@ GetEntryIndex(
break;
}
default:
- if (Tcl_GetIntFromObj(NULL, indexObj, indexPtr) != TCL_OK) {
- goto badIndex;
- }
- if (*indexPtr < 0){
- *indexPtr = 0;
- } else if (*indexPtr > entryPtr->numChars) {
- *indexPtr = entryPtr->numChars;
- }
+ badIndex:
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad %s index \"%s\"",
+ (entryPtr->type == TK_ENTRY) ? "entry" : "spinbox", string));
+ Tcl_SetErrorCode(interp, "TK",
+ (entryPtr->type == TK_ENTRY) ? "ENTRY" : "SPINBOX",
+ "BAD_INDEX", NULL);
+ return TCL_ERROR;
}
return TCL_OK;
-
- badIndex:
- Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad %s index \"%s\"",
- (entryPtr->type == TK_ENTRY) ? "entry" : "spinbox", string));
- Tcl_SetErrorCode(interp, "TK",
- (entryPtr->type == TK_ENTRY) ? "ENTRY" : "SPINBOX",
- "BAD_INDEX", NULL);
- return TCL_ERROR;
}
/*
@@ -2703,7 +2789,7 @@ EntryScanTo(
Entry *entryPtr, /* Information about widget. */
int x) /* X-coordinate to use for scan operation. */
{
- int newLeftIndex;
+ Tcl_Size newLeftIndex;
/*
* Compute new leftIndex for entry by amplifying the difference between
@@ -2759,10 +2845,10 @@ EntryScanTo(
static void
EntrySelectTo(
Entry *entryPtr, /* Information about widget. */
- int index) /* Character index of element that is to
+ Tcl_Size index) /* Character index of element that is to
* become the "other" end of the selection. */
{
- int newFirst, newLast;
+ Tcl_Size newFirst, newLast;
/*
* Grab the selection if we don't own it already.
@@ -2789,7 +2875,7 @@ EntrySelectTo(
newFirst = index;
newLast = entryPtr->selectAnchor;
if (newLast < 0) {
- newFirst = newLast = -1;
+ newFirst = newLast = TCL_INDEX_NONE;
}
}
if ((entryPtr->selectFirst == newFirst)
@@ -2822,17 +2908,17 @@ EntrySelectTo(
*----------------------------------------------------------------------
*/
-static int
+static Tcl_Size
EntryFetchSelection(
void *clientData, /* Information about entry widget. */
- int offset, /* Byte offset within selection of first
+ Tcl_Size offset, /* Byte 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,
+ Tcl_Size maxBytes) /* Maximum number of bytes to place at buffer,
* not including terminating NUL character. */
{
Entry *entryPtr = (Entry *)clientData;
- int byteCount;
+ Tcl_Size byteCount;
const char *string;
const char *selStart, *selEnd;
@@ -2844,13 +2930,13 @@ EntryFetchSelection(
selStart = TkUtfAtIndex(string, entryPtr->selectFirst);
selEnd = TkUtfAtIndex(selStart,
entryPtr->selectLast - entryPtr->selectFirst);
+ if (selEnd <= selStart + offset) {
+ return 0;
+ }
byteCount = selEnd - selStart - offset;
if (byteCount > maxBytes) {
byteCount = maxBytes;
}
- if (byteCount <= 0) {
- return 0;
- }
memcpy(buffer, selStart + offset, byteCount);
buffer[byteCount] = '\0';
return byteCount;
@@ -2889,11 +2975,11 @@ EntryLostSelection(
* This is controlled by ::tk::AlwaysShowSelection.
*/
- if (TkpAlwaysShowSelection(entryPtr->tkwin)
- && (entryPtr->selectFirst >= 0) && entryPtr->exportSelection
+ if (Tk_AlwaysShowSelection(entryPtr->tkwin)
+ && (entryPtr->selectFirst != TCL_INDEX_NONE) && entryPtr->exportSelection
&& (!Tcl_IsSafe(entryPtr->interp))) {
- entryPtr->selectFirst = -1;
- entryPtr->selectLast = -1;
+ entryPtr->selectFirst = TCL_INDEX_NONE;
+ entryPtr->selectLast = TCL_INDEX_NONE;
EventuallyRedraw(entryPtr);
}
}
@@ -2972,7 +3058,7 @@ EntryVisibleRange(
charsInWindow = Tk_PointToChar(entryPtr->textLayout,
Tk_Width(entryPtr->tkwin) - entryPtr->inset
- entryPtr->xWidth - entryPtr->layoutX - 1, 0);
- if (charsInWindow < entryPtr->numChars) {
+ if (charsInWindow < (int)entryPtr->numChars) {
charsInWindow++;
}
charsInWindow -= entryPtr->leftIndex;
@@ -3026,12 +3112,12 @@ EntryUpdateScrollbar(
Tcl_PrintDouble(NULL, first, firstStr);
Tcl_PrintDouble(NULL, last, lastStr);
Tcl_DStringInit(&buf);
- Tcl_DStringAppend(&buf, entryPtr->scrollCmd, -1);
- Tcl_DStringAppend(&buf, " ", -1);
- Tcl_DStringAppend(&buf, firstStr, -1);
- Tcl_DStringAppend(&buf, " ", -1);
- Tcl_DStringAppend(&buf, lastStr, -1);
- code = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, TCL_EVAL_GLOBAL);
+ Tcl_DStringAppend(&buf, entryPtr->scrollCmd, TCL_INDEX_NONE);
+ Tcl_DStringAppend(&buf, " ", TCL_INDEX_NONE);
+ Tcl_DStringAppend(&buf, firstStr, TCL_INDEX_NONE);
+ Tcl_DStringAppend(&buf, " ", TCL_INDEX_NONE);
+ Tcl_DStringAppend(&buf, lastStr, TCL_INDEX_NONE);
+ code = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), TCL_INDEX_NONE, TCL_EVAL_GLOBAL);
Tcl_DStringFree(&buf);
if (code != TCL_OK) {
Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf(
@@ -3118,7 +3204,7 @@ EntryFocusProc(
if (entryPtr->validate == VALIDATE_ALL ||
entryPtr->validate == VALIDATE_FOCUS ||
entryPtr->validate == VALIDATE_FOCUSIN) {
- EntryValidateChange(entryPtr, NULL, entryPtr->string, -1,
+ EntryValidateChange(entryPtr, NULL, entryPtr->string, TCL_INDEX_NONE,
VALIDATE_FOCUSIN);
}
} else {
@@ -3127,7 +3213,7 @@ EntryFocusProc(
if (entryPtr->validate == VALIDATE_ALL ||
entryPtr->validate == VALIDATE_FOCUS ||
entryPtr->validate == VALIDATE_FOCUSOUT) {
- EntryValidateChange(entryPtr, NULL, entryPtr->string, -1,
+ EntryValidateChange(entryPtr, NULL, entryPtr->string, TCL_INDEX_NONE,
VALIDATE_FOCUSOUT);
}
}
@@ -3183,7 +3269,7 @@ EntryTextVarProc(
entryPtr->textVarName,
TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
EntryTextVarProc, probe);
- if (probe == (void *)entryPtr) {
+ if (probe == entryPtr) {
break;
}
} while (probe);
@@ -3249,7 +3335,7 @@ EntryValidate(
Tcl_Interp *interp = entryPtr->interp;
int code, isOK;
- code = Tcl_EvalEx(interp, cmd, -1, TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT);
+ code = Tcl_EvalEx(interp, cmd, TCL_INDEX_NONE, TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT);
/*
* We accept TCL_OK and TCL_RETURN as valid return codes from the command
@@ -3306,7 +3392,7 @@ EntryValidateChange(
const char *change, /* Characters to be added/deleted
* (NUL-terminated string). */
const char *newValue, /* Potential new value of entry string */
- int index, /* index of insert/delete, -1 otherwise */
+ Tcl_Size index, /* index of insert/delete, TCL_INDEX_NONE otherwise */
int type) /* forced, delete, insert, focusin or
* focusout */
{
@@ -3397,7 +3483,7 @@ EntryValidateChange(
change, newValue, index, type, &script);
Tcl_DStringAppend(&script, "", 1);
p = Tcl_DStringValue(&script);
- result = Tcl_EvalEx(entryPtr->interp, p, -1,
+ result = Tcl_EvalEx(entryPtr->interp, p, TCL_INDEX_NONE,
TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT);
if (result != TCL_OK) {
Tcl_AddErrorInfo(entryPtr->interp,
@@ -3452,7 +3538,7 @@ ExpandPercents(
const char *change, /* Characters to added/deleted (NUL-terminated
* string). */
const char *newValue, /* Potential new value of entry string */
- int index, /* index of insert/delete */
+ Tcl_Size index, /* index of insert/delete */
int type, /* INSERT or DELETE */
Tcl_DString *dsPtr) /* Dynamic string in which to append new
* command. */
@@ -3481,7 +3567,7 @@ ExpandPercents(
string = Tcl_UtfFindFirst(before, '%');
if (string == NULL) {
- Tcl_DStringAppend(dsPtr, before, -1);
+ Tcl_DStringAppend(dsPtr, before, TCL_INDEX_NONE);
break;
} else if (string != before) {
Tcl_DStringAppend(dsPtr, before, string-before);
@@ -3541,7 +3627,7 @@ ExpandPercents(
string = numStorage;
break;
case 'i': /* index of insert/delete */
- snprintf(numStorage, sizeof(numStorage), "%d", index);
+ snprintf(numStorage, sizeof(numStorage), "%d", (int)index);
string = numStorage;
break;
case 'P': /* 'Peeked' new value of the string */
@@ -3581,10 +3667,10 @@ ExpandPercents(
}
}
- spaceNeeded = Tcl_ScanCountedElement(string, -1, &cvtFlags);
+ spaceNeeded = Tcl_ScanCountedElement(string, TCL_INDEX_NONE, &cvtFlags);
length = Tcl_DStringLength(dsPtr);
Tcl_DStringSetLength(dsPtr, length + spaceNeeded);
- spaceNeeded = Tcl_ConvertCountedElement(string, -1,
+ spaceNeeded = Tcl_ConvertCountedElement(string, TCL_INDEX_NONE,
Tcl_DStringValue(dsPtr) + length,
cvtFlags | TCL_DONT_USE_BRACES);
Tcl_DStringSetLength(dsPtr, length + spaceNeeded);
@@ -3661,8 +3747,8 @@ Tk_SpinboxObjCmd(
tmp = (char *)ckalloc(1);
tmp[0] = '\0';
entryPtr->string = tmp;
- entryPtr->selectFirst = -1;
- entryPtr->selectLast = -1;
+ entryPtr->selectFirst = TCL_INDEX_NONE;
+ entryPtr->selectLast = TCL_INDEX_NONE;
entryPtr->cursor = NULL;
entryPtr->exportSelection = 1;
@@ -3689,6 +3775,8 @@ Tk_SpinboxObjCmd(
sbPtr->bdRelief = TK_RELIEF_FLAT;
sbPtr->buRelief = TK_RELIEF_FLAT;
+ entryPtr->placeholderGC = NULL;
+
/*
* Keep a hold of the associated tkwin until we destroy the spinbox,
* otherwise Tk might free it while we still need it.
@@ -3704,7 +3792,7 @@ Tk_SpinboxObjCmd(
Tk_CreateSelHandler(entryPtr->tkwin, XA_PRIMARY, XA_STRING,
EntryFetchSelection, entryPtr, XA_STRING);
- if (Tk_InitOptions(interp, (char *) sbPtr, optionTable, tkwin)
+ if (Tk_InitOptions(interp, sbPtr, optionTable, tkwin)
!= TCL_OK) {
Tk_DestroyWindow(entryPtr->tkwin);
return TCL_ERROR;
@@ -3713,7 +3801,7 @@ Tk_SpinboxObjCmd(
goto error;
}
- Tcl_SetObjResult(interp, TkNewWindowObj(entryPtr->tkwin));
+ Tcl_SetObjResult(interp, Tk_NewWindowObj(entryPtr->tkwin));
return TCL_OK;
error:
@@ -3770,7 +3858,7 @@ SpinboxWidgetObjCmd(
Tcl_Preserve(entryPtr);
switch ((enum sbCmd) cmdIndex) {
case SB_CMD_BBOX: {
- int index;
+ Tcl_Size index;
int x, y, width, height;
Tcl_Obj *bbox[4];
@@ -3786,10 +3874,10 @@ SpinboxWidgetObjCmd(
index--;
}
Tk_CharBbox(entryPtr->textLayout, index, &x, &y, &width, &height);
- bbox[0] = Tcl_NewIntObj(x + entryPtr->layoutX);
- bbox[1] = Tcl_NewIntObj(y + entryPtr->layoutY);
- bbox[2] = Tcl_NewIntObj(width);
- bbox[3] = Tcl_NewIntObj(height);
+ bbox[0] = Tcl_NewWideIntObj(x + entryPtr->layoutX);
+ bbox[1] = Tcl_NewWideIntObj(y + entryPtr->layoutY);
+ bbox[2] = Tcl_NewWideIntObj(width);
+ bbox[3] = Tcl_NewWideIntObj(height);
Tcl_SetObjResult(interp, Tcl_NewListObj(4, bbox));
break;
}
@@ -3800,7 +3888,7 @@ SpinboxWidgetObjCmd(
goto error;
}
- objPtr = Tk_GetOptionValue(interp, (char *) entryPtr,
+ objPtr = Tk_GetOptionValue(interp, entryPtr,
entryPtr->optionTable, objv[2], entryPtr->tkwin);
if (objPtr == NULL) {
goto error;
@@ -3810,7 +3898,7 @@ SpinboxWidgetObjCmd(
case SB_CMD_CONFIGURE:
if (objc <= 3) {
- objPtr = Tk_GetOptionInfo(interp, (char *) entryPtr,
+ objPtr = Tk_GetOptionInfo(interp, entryPtr,
entryPtr->optionTable, (objc == 3) ? objv[2] : NULL,
entryPtr->tkwin);
if (objPtr == NULL) {
@@ -3823,7 +3911,7 @@ SpinboxWidgetObjCmd(
break;
case SB_CMD_DELETE: {
- int first, last;
+ Tcl_Size first, last;
int code;
if ((objc < 3) || (objc > 4)) {
@@ -3856,7 +3944,7 @@ SpinboxWidgetObjCmd(
Tcl_WrongNumArgs(interp, 2, objv, NULL);
goto error;
}
- Tcl_SetObjResult(interp, Tcl_NewStringObj(entryPtr->string, -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(entryPtr->string, TCL_INDEX_NONE));
break;
case SB_CMD_ICURSOR:
@@ -3885,13 +3973,13 @@ SpinboxWidgetObjCmd(
elem = GetSpinboxElement(sbPtr, x, y);
if (elem != SEL_NONE) {
Tcl_SetObjResult(interp,
- Tcl_NewStringObj(selElementNames[elem], -1));
+ Tcl_NewStringObj(selElementNames[elem], TCL_INDEX_NONE));
}
break;
}
case SB_CMD_INDEX: {
- int index;
+ Tcl_Size index;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "string");
@@ -3901,12 +3989,12 @@ SpinboxWidgetObjCmd(
&index) != TCL_OK) {
goto error;
}
- Tcl_SetObjResult(interp, Tcl_NewIntObj(index));
+ Tcl_SetObjResult(interp, TkNewIndexObj(index));
break;
}
case SB_CMD_INSERT: {
- int index;
+ Tcl_Size index;
int code;
if (objc != 4) {
@@ -3965,7 +4053,7 @@ SpinboxWidgetObjCmd(
EntryScanTo(entryPtr, x);
} else {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "bad scan option \"%s\": must be mark or dragto",
+ "bad scan option \"%s\": must be dragto or mark",
minorCmd));
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "INDEX", "scan option",
minorCmd, NULL);
@@ -3975,7 +4063,7 @@ SpinboxWidgetObjCmd(
}
case SB_CMD_SELECTION: {
- int index, index2;
+ Tcl_Size index, index2;
if (objc < 3) {
Tcl_WrongNumArgs(interp, 2, objv, "option ?index?");
@@ -4013,8 +4101,8 @@ SpinboxWidgetObjCmd(
objv[3], &index) != TCL_OK) {
goto error;
}
- if (entryPtr->selectFirst >= 0) {
- int half1, half2;
+ if (entryPtr->selectFirst != TCL_INDEX_NONE) {
+ Tcl_Size half1, half2;
half1 = (entryPtr->selectFirst + entryPtr->selectLast)/2;
half2 = (entryPtr->selectFirst + entryPtr->selectLast + 1)/2;
@@ -4037,9 +4125,9 @@ SpinboxWidgetObjCmd(
Tcl_WrongNumArgs(interp, 3, objv, NULL);
goto error;
}
- if (entryPtr->selectFirst >= 0) {
- entryPtr->selectFirst = -1;
- entryPtr->selectLast = -1;
+ if (entryPtr->selectFirst != TCL_INDEX_NONE) {
+ entryPtr->selectFirst = TCL_INDEX_NONE;
+ entryPtr->selectLast = TCL_INDEX_NONE;
EventuallyRedraw(entryPtr);
}
goto done;
@@ -4062,7 +4150,7 @@ SpinboxWidgetObjCmd(
goto error;
}
Tcl_SetObjResult(interp, Tcl_NewBooleanObj(
- entryPtr->selectFirst >= 0));
+ entryPtr->selectFirst != TCL_INDEX_NONE));
goto done;
case SB_SEL_RANGE:
@@ -4079,8 +4167,8 @@ SpinboxWidgetObjCmd(
goto error;
}
if (index >= index2) {
- entryPtr->selectFirst = -1;
- entryPtr->selectLast = -1;
+ entryPtr->selectFirst = TCL_INDEX_NONE;
+ entryPtr->selectLast = TCL_INDEX_NONE;
} else {
entryPtr->selectFirst = index;
entryPtr->selectLast = index2;
@@ -4114,7 +4202,7 @@ SpinboxWidgetObjCmd(
}
if (objc == 3) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- selElementNames[sbPtr->selElement], -1));
+ selElementNames[sbPtr->selElement], TCL_INDEX_NONE));
} else {
int lastElement = sbPtr->selElement;
@@ -4145,7 +4233,7 @@ SpinboxWidgetObjCmd(
goto error;
}
}
- Tcl_SetObjResult(interp, Tcl_NewStringObj(entryPtr->string, -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(entryPtr->string, TCL_INDEX_NONE));
break;
}
@@ -4159,7 +4247,7 @@ SpinboxWidgetObjCmd(
selIndex = entryPtr->validate;
entryPtr->validate = VALIDATE_ALL;
code = EntryValidateChange(entryPtr, NULL, entryPtr->string,
- -1, VALIDATE_FORCED);
+ TCL_INDEX_NONE, VALIDATE_FORCED);
if (entryPtr->validate != VALIDATE_NONE) {
entryPtr->validate = selIndex;
}
@@ -4169,7 +4257,7 @@ SpinboxWidgetObjCmd(
}
case SB_CMD_XVIEW: {
- int index;
+ Tcl_Size index;
if (objc == 2) {
double first, last;
@@ -4193,7 +4281,7 @@ SpinboxWidgetObjCmd(
switch (Tk_GetScrollInfoObj(interp, objc, objv, &fraction,
&count)) {
case TK_SCROLL_MOVETO:
- index = (int) ((fraction * entryPtr->numChars) + 0.5);
+ index = ((fraction * entryPtr->numChars) + 0.5);
break;
case TK_SCROLL_PAGES: {
int charsPerPage;
@@ -4332,8 +4420,8 @@ SpinboxInvoke(
* there. If not, move to the first element of the list.
*/
- int i, listc;
- int elemLen, length = entryPtr->numChars;
+ Tcl_Size i, listc;
+ Tcl_Size elemLen, length = entryPtr->numChars;
const char *bytes;
Tcl_Obj **listv;
@@ -4426,7 +4514,7 @@ SpinboxInvoke(
VALIDATE_BUTTON, &script);
Tcl_DStringAppend(&script, "", 1);
- code = Tcl_EvalEx(interp, Tcl_DStringValue(&script), -1,
+ code = Tcl_EvalEx(interp, Tcl_DStringValue(&script), TCL_INDEX_NONE,
TCL_EVAL_GLOBAL | TCL_EVAL_DIRECT);
Tcl_DStringFree(&script);
diff --git a/generic/tkEntry.h b/generic/tkEntry.h
index 8d863cf..fbebdaa 100644
--- a/generic/tkEntry.h
+++ b/generic/tkEntry.h
@@ -6,7 +6,7 @@
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * Copyright (c) 2002 Apple Inc.
+ * Copyright © 2002 Apple Inc.
*/
#ifndef _TKENTRY
@@ -45,18 +45,18 @@ typedef struct {
const char *string; /* Pointer to storage for string;
* NULL-terminated; malloc-ed. */
- int insertPos; /* Character index before which next typed
+ Tcl_Size insertPos; /* Character index before which next typed
* character will be inserted. */
/*
* Information about what's selected, if any.
*/
- int selectFirst; /* Character index of first selected character
+ Tcl_Size selectFirst; /* Character index of first selected character
* (-1 means nothing selected. */
- int selectLast; /* Character index just after last selected
+ Tcl_Size selectLast; /* Character index just after last selected
* character (-1 means nothing selected. */
- int selectAnchor; /* Fixed end of selection (i.e. "select to"
+ Tcl_Size selectAnchor; /* Fixed end of selection (i.e. "select to"
* operation will use this as one end of the
* selection). */
@@ -129,6 +129,19 @@ typedef struct {
* only used by the Entry widget. */
/*
+ * Fields used in displaying help text if entry value is empty
+ */
+
+ Tk_TextLayout placeholderLayout;/* Cached placeholder text layout information. */
+ char *placeholderString; /* String value of placeholder. */
+ Tcl_Size placeholderChars; /* Number of chars in placeholder. */
+ XColor *placeholderColorPtr;/* Color value of placeholder foreground. */
+ GC placeholderGC; /* For drawing placeholder text. */
+ int placeholderX; /* Origin for layout. */
+ int placeholderLeftIndex; /* Character index of left-most character
+ * visible in window. */
+
+ /*
* Fields whose values are derived from the current values of the
* configuration settings above.
*/
@@ -138,13 +151,13 @@ typedef struct {
* malloced memory with the same character
* length as string but whose characters are
* all equal to showChar. */
- int numBytes; /* Length of string in bytes. */
- int numChars; /* Length of string in characters. Both string
+ Tcl_Size numBytes; /* Length of string in bytes. */
+ Tcl_Size numChars; /* Length of string in characters. Both string
* and displayString have the same character
* length, but may have different byte lengths
* due to being made from different UTF-8
* characters. */
- int numDisplayBytes; /* Length of displayString in bytes. */
+ Tcl_Size numDisplayBytes; /* Length of displayString in bytes. */
int inset; /* Number of pixels on the left and right
* sides that are taken up by XPAD,
* borderWidth (if any), and highlightWidth
@@ -153,7 +166,7 @@ typedef struct {
int layoutX, layoutY; /* Origin for layout. */
int leftX; /* X position at which character at leftIndex
* is drawn (varies depending on justify). */
- int leftIndex; /* Character index of left-most character
+ Tcl_Size leftIndex; /* Character index of left-most character
* visible in window. */
Tcl_TimerToken insertBlinkHandler;
/* Timer handler used to blink cursor on and
@@ -283,7 +296,7 @@ enum state {
*/
enum selelement {
- SEL_NONE, SEL_BUTTONDOWN, SEL_BUTTONUP, SEL_NULL, SEL_ENTRY
+ SEL_BUTTONDOWN, SEL_BUTTONUP, SEL_NONE, SEL_NULL, SEL_ENTRY
};
/*
diff --git a/generic/tkError.c b/generic/tkError.c
index eadeffe..bffcbe5 100644
--- a/generic/tkError.c
+++ b/generic/tkError.c
@@ -6,8 +6,8 @@
* 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.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 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.
@@ -80,7 +80,7 @@ Tk_CreateErrorHandler(
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. */
+ void *clientData) /* Arbitrary value to pass to errorProc. */
{
TkErrorHandler *errorPtr;
TkDisplay *dispPtr;
@@ -164,11 +164,10 @@ Tk_DeleteErrorHandler(
* there are many handlers that stay around forever).
*/
- dispPtr->deleteCount += 1;
- if (dispPtr->deleteCount >= 10) {
+ if (dispPtr->deleteCount++ >= 9) {
TkErrorHandler *prevPtr;
TkErrorHandler *nextPtr;
- int lastSerial = LastKnownRequestProcessed(dispPtr->display);
+ unsigned long lastSerial = LastKnownRequestProcessed(dispPtr->display);
/*
* Last chance to catch errors for this handler: if no event/error
@@ -176,7 +175,7 @@ Tk_DeleteErrorHandler(
* we need a round trip with the X server now.
*/
- if (errorPtr->lastRequest > (unsigned long) lastSerial) {
+ if (errorPtr->lastRequest > lastSerial) {
XSync(dispPtr->display, False);
}
dispPtr->deleteCount = 0;
@@ -184,7 +183,7 @@ Tk_DeleteErrorHandler(
for (prevPtr = NULL; errorPtr != NULL; errorPtr = nextPtr) {
nextPtr = errorPtr->nextPtr;
if ((errorPtr->lastRequest != (unsigned long) -1)
- && (errorPtr->lastRequest <= (unsigned long) lastSerial)) {
+ && (errorPtr->lastRequest <= lastSerial)) {
if (prevPtr == NULL) {
dispPtr->errorPtr = nextPtr;
} else {
diff --git a/generic/tkEvent.c b/generic/tkEvent.c
index 9c3b1b3..1231a97 100644
--- a/generic/tkEvent.c
+++ b/generic/tkEvent.c
@@ -4,10 +4,10 @@
* 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.
- * Copyright (c) 1998-2000 Ajuba Solutions.
- * Copyright (c) 2004 George Peter Staplin
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994-1995 Sun Microsystems, Inc.
+ * Copyright © 1998-2000 Ajuba Solutions.
+ * Copyright © 2004 George Peter Staplin
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -15,6 +15,14 @@
#include "tkInt.h"
+#ifdef _WIN32
+#include "tkWinInt.h"
+#elif defined(MAC_OSX_TK)
+#include "tkMacOSXInt.h"
+#else
+#include "tkUnixInt.h"
+#endif
+
/*
* There's a potential problem if a handler is deleted while it's current
* (i.e. its function is executing), since Tk_HandleEvent will need to read
@@ -43,7 +51,7 @@ typedef struct InProgress {
typedef struct GenericHandler {
Tk_GenericProc *proc; /* Function to dispatch on all X events. */
- ClientData clientData; /* Client data to pass to function. */
+ void *clientData; /* Client data to pass to function. */
int deleteFlag; /* Flag to set when this handler is
* deleted. */
struct GenericHandler *nextPtr;
@@ -115,7 +123,8 @@ static const unsigned long eventMasks[TK_LASTEVENT] = {
VirtualEventMask, /* VirtualEvents */
ActivateMask, /* ActivateNotify */
ActivateMask, /* DeactivateNotify */
- MouseWheelMask /* MouseWheelEvent */
+ MouseWheelMask, /* MouseWheelEvent */
+ TouchpadScrollMask /* TouchpadScroll */
};
/*
@@ -125,7 +134,7 @@ static const unsigned long eventMasks[TK_LASTEVENT] = {
typedef struct ExitHandler {
Tcl_ExitProc *proc; /* Function to call when process exits. */
- ClientData clientData; /* One word of information to pass to proc. */
+ void *clientData; /* One word of information to pass to proc. */
struct ExitHandler *nextPtr;/* Next in list of all exit handlers for this
* application, or NULL for end of list. */
} ExitHandler;
@@ -165,7 +174,7 @@ typedef struct {
Tk_RestrictProc *restrictProc;
/* Function to call. NULL means no
* restrictProc is currently in effect. */
- ClientData restrictArg; /* Argument to pass to restrictProc. */
+ void *restrictArg; /* Argument to pass to restrictProc. */
ExitHandler *firstExitPtr; /* First in list of all exit handlers for this
* thread. */
int inExit; /* True when this thread is exiting. This is
@@ -189,7 +198,7 @@ TCL_DECLARE_MUTEX(exitMutex)
*/
static void CleanUpTkEvent(XEvent *eventPtr);
-static void DelayedMotionProc(ClientData clientData);
+static void DelayedMotionProc(void *clientData);
static unsigned long GetEventMaskFromXEvent(XEvent *eventPtr);
static TkWindow * GetTkWindowFromXEvent(XEvent *eventPtr);
static void InvokeClientMessageHandlers(ThreadSpecificData *tsdPtr,
@@ -202,12 +211,10 @@ static int InvokeMouseHandlers(TkWindow *winPtr,
unsigned long mask, XEvent *eventPtr);
static Window ParentXId(Display *display, Window w);
static int RefreshKeyboardMappingIfNeeded(XEvent *eventPtr);
-static int TkXErrorHandler(ClientData clientData,
+static int TkXErrorHandler(void *clientData,
XErrorEvent *errEventPtr);
static int WindowEventProc(Tcl_Event *evPtr, int flags);
-#ifdef TK_USE_INPUT_METHODS
static void CreateXIC(TkWindow *winPtr);
-#endif /* TK_USE_INPUT_METHODS */
/*
*----------------------------------------------------------------------
@@ -315,7 +322,6 @@ InvokeMouseHandlers(
*----------------------------------------------------------------------
*/
-#ifdef TK_USE_INPUT_METHODS
static void
CreateXIC(
TkWindow *winPtr)
@@ -362,7 +368,6 @@ CreateXIC(
XSelectInput(winPtr->display, winPtr->window, winPtr->atts.event_mask);
}
}
-#endif
/*
*----------------------------------------------------------------------
@@ -509,9 +514,12 @@ RefreshKeyboardMappingIfNeeded(
/*
*----------------------------------------------------------------------
*
- * TkGetButtonMask --
+ * Tk_GetButtonMask --
*
- * Return the proper Button${n}Mask for the button.
+ * Return the proper Button${n}Mask for the button. Don't care about
+ * Button4 - Button7, because those are not actually buttons: Those
+ * are used for the horizontal or vertical mouse wheels. Button4Mask
+ * and higher is actually used for Button 8 and higher.
*
* Results:
* A button mask.
@@ -523,14 +531,15 @@ RefreshKeyboardMappingIfNeeded(
*/
static const unsigned buttonMasks[] = {
- 0, Button1Mask, Button2Mask, Button3Mask, Button4Mask, Button5Mask
+ 0, Button1Mask, Button2Mask, Button3Mask, 0, 0, 0, 0, Button4Mask, \
+ Button5Mask, Button6Mask, Button7Mask, Button8Mask, Button9Mask
};
unsigned
-TkGetButtonMask(
+Tk_GetButtonMask(
unsigned button)
{
- return (button > Button5) ? 0 : buttonMasks[button];
+ return (button > Button9) ? 0 : buttonMasks[button];
}
/*
@@ -683,7 +692,7 @@ Tk_CreateEventHandler(
* handler. */
unsigned long mask, /* Events for which proc should be called. */
Tk_EventProc *proc, /* Function to call for each selected event */
- ClientData clientData) /* Arbitrary data to pass to proc. */
+ void *clientData) /* Arbitrary data to pass to proc. */
{
TkEventHandler *handlerPtr;
TkWindow *winPtr = (TkWindow *)token;
@@ -773,7 +782,7 @@ Tk_DeleteEventHandler(
Tk_Window token, /* Same as corresponding arguments passed */
unsigned long mask, /* previously to Tk_CreateEventHandler. */
Tk_EventProc *proc,
- ClientData clientData)
+ void *clientData)
{
TkEventHandler *handlerPtr;
InProgress *ipPtr;
@@ -848,7 +857,7 @@ Tk_DeleteEventHandler(
void
Tk_CreateGenericHandler(
Tk_GenericProc *proc, /* Function to call on every event. */
- ClientData clientData) /* One-word value to pass to proc. */
+ void *clientData) /* One-word value to pass to proc. */
{
GenericHandler *handlerPtr;
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
@@ -889,7 +898,7 @@ Tk_CreateGenericHandler(
void
Tk_DeleteGenericHandler(
Tk_GenericProc *proc,
- ClientData clientData)
+ void *clientData)
{
GenericHandler * handler;
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
@@ -1034,7 +1043,7 @@ TkEventInit(void)
static int
TkXErrorHandler(
- ClientData clientData, /* Pointer to flag we set. */
+ void *clientData, /* Pointer to flag we set. */
TCL_UNUSED(XErrorEvent *)) /* X error info. */
{
int *error = (int *)clientData;
@@ -1132,11 +1141,22 @@ Tk_HandleEvent(
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
-#if !defined(MAC_OSX_TK) && !defined(_WIN32)
- if (((eventPtr->type == ButtonPress) || (eventPtr->type == ButtonRelease))
- && ((eventPtr->xbutton.button - 6) < 2)) {
- eventPtr->xbutton.button -= 2;
- eventPtr->xbutton.state ^= ShiftMask;
+
+#if !defined(_WIN32) && !defined(MAC_OSX_TK)
+ if ((eventPtr->type == ButtonRelease) || (eventPtr->type == ButtonPress)) {
+ if ((eventPtr->xbutton.button >= Button4) && (eventPtr->xbutton.button < Button8)) {
+ if (eventPtr->type == ButtonRelease) {
+ return;
+ } else { /* eventPtr->type == ButtonPress */
+ int but = eventPtr->xbutton.button;
+ eventPtr->type = MouseWheelEvent;
+ eventPtr->xany.send_event = -1;
+ eventPtr->xkey.keycode = (but & 1) ? -120 : 120;
+ if (but > Button5) {
+ eventPtr->xkey.state |= ShiftMask;
+ }
+ }
+ }
}
#endif
@@ -1206,7 +1226,6 @@ Tk_HandleEvent(
* ever active for X11.
*/
-#ifdef TK_USE_INPUT_METHODS
/*
* If the XIC has been invalidated, it must be recreated.
*/
@@ -1228,7 +1247,6 @@ Tk_HandleEvent(
XSetICFocus(winPtr->inputContext);
}
}
-#endif /*TK_USE_INPUT_METHODS*/
/*
* For events where it hasn't already been done, update the current time
@@ -1437,8 +1455,8 @@ TkCurrentTime(
Tk_RestrictProc *
Tk_RestrictEvents(
Tk_RestrictProc *proc, /* Function to call for each incoming event */
- ClientData arg, /* Arbitrary argument to pass to proc. */
- ClientData *prevArgPtr) /* Place to store information about previous
+ void *arg, /* Arbitrary argument to pass to proc. */
+ void **prevArgPtr) /* Place to store information about previous
* argument. */
{
Tk_RestrictProc *prev;
@@ -1796,7 +1814,7 @@ CleanUpTkEvent(
static void
DelayedMotionProc(
- ClientData clientData) /* Pointer to display containing a delayed
+ void *clientData) /* Pointer to display containing a delayed
* motion event to be serviced. */
{
TkDisplay *dispPtr = (TkDisplay *)clientData;
@@ -1827,7 +1845,7 @@ DelayedMotionProc(
void
TkCreateExitHandler(
Tcl_ExitProc *proc, /* Function to invoke. */
- ClientData clientData) /* Arbitrary value to pass to proc. */
+ void *clientData) /* Arbitrary value to pass to proc. */
{
ExitHandler *exitPtr;
@@ -1882,7 +1900,7 @@ TkCreateExitHandler(
void
TkDeleteExitHandler(
Tcl_ExitProc *proc, /* Function that was previously registered. */
- ClientData clientData) /* Arbitrary value to pass to proc. */
+ void *clientData) /* Arbitrary value to pass to proc. */
{
ExitHandler *exitPtr, *prevPtr;
@@ -1924,7 +1942,7 @@ TkDeleteExitHandler(
void
TkCreateThreadExitHandler(
Tcl_ExitProc *proc, /* Function to invoke. */
- ClientData clientData) /* Arbitrary value to pass to proc. */
+ void *clientData) /* Arbitrary value to pass to proc. */
{
ExitHandler *exitPtr;
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
@@ -1965,7 +1983,7 @@ TkCreateThreadExitHandler(
void
TkDeleteThreadExitHandler(
Tcl_ExitProc *proc, /* Function that was previously registered. */
- ClientData clientData) /* Arbitrary value to pass to proc. */
+ void *clientData) /* Arbitrary value to pass to proc. */
{
ExitHandler *exitPtr, *prevPtr;
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
diff --git a/generic/tkFileFilter.c b/generic/tkFileFilter.c
index c8dbc52..cac1c78 100644
--- a/generic/tkFileFilter.c
+++ b/generic/tkFileFilter.c
@@ -4,7 +4,7 @@
* Process the -filetypes option for the file dialogs on Windows and the
* Mac.
*
- * Copyright (c) 1996 Sun Microsystems, Inc.
+ * Copyright © 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.
@@ -79,9 +79,8 @@ TkGetFileFilters(
Tcl_Obj *types, /* Value of the -filetypes option. */
int isWindows) /* True if we are running on Windows. */
{
- int listObjc;
+ Tcl_Size i, listObjc;
Tcl_Obj ** listObjv = NULL;
- int i;
if (types == NULL) {
return TCL_OK;
@@ -110,7 +109,7 @@ TkGetFileFilters(
* third is the Mac OSType ID, but we don't care about them here.
*/
- int count;
+ Tcl_Size count;
FileFilter *filterPtr;
Tcl_Obj **typeInfo;
@@ -233,7 +232,8 @@ AddClause(
* two platforms */
{
Tcl_Obj **globList = NULL, **ostypeList = NULL;
- int globCount, ostypeCount, i, code = TCL_OK;
+ Tcl_Size globCount, ostypeCount, i;
+ int code = TCL_OK;
FileFilterClause *clausePtr;
Tcl_Encoding macRoman = NULL;
@@ -262,7 +262,7 @@ AddClause(
*/
for (i=0; i<ostypeCount; i++) {
- int len;
+ Tcl_Size len;
const char *strType = Tcl_GetStringFromObj(ostypeList[i], &len);
/*
@@ -286,7 +286,7 @@ AddClause(
* be 4 macRoman characters long
*/
- Tcl_UtfToExternalDString(macRoman, strType, len, &osTypeDS);
+ (void)Tcl_UtfToExternalDString(macRoman, strType, len, &osTypeDS);
len = Tcl_DStringLength(&osTypeDS);
Tcl_DStringFree(&osTypeDS);
}
@@ -305,7 +305,7 @@ AddClause(
* Add the clause into the list of clauses
*/
- clausePtr = ckalloc(sizeof(FileFilterClause));
+ clausePtr = (FileFilterClause *)ckalloc(sizeof(FileFilterClause));
clausePtr->patterns = NULL;
clausePtr->patternsTail = NULL;
clausePtr->macTypes = NULL;
@@ -321,8 +321,8 @@ AddClause(
if (globCount > 0 && globList != NULL) {
for (i=0; i<globCount; i++) {
- GlobPattern *globPtr = ckalloc(sizeof(GlobPattern));
- int len;
+ GlobPattern *globPtr = (GlobPattern *)ckalloc(sizeof(GlobPattern));
+ Tcl_Size len;
const char *str = Tcl_GetStringFromObj(globList[i], &len);
len = (len + 1) * sizeof(char);
@@ -331,12 +331,12 @@ AddClause(
* Prepend a "*" to patterns that do not have a leading "*"
*/
- globPtr->pattern = ckalloc(len + 1);
+ globPtr->pattern = (char *)ckalloc(len + 1);
globPtr->pattern[0] = '*';
strcpy(globPtr->pattern+1, str);
} else if (isWindows) {
if (strcmp(str, "*") == 0) {
- globPtr->pattern = ckalloc(4);
+ globPtr->pattern = (char *)ckalloc(4);
strcpy(globPtr->pattern, "*.*");
} else if (strcmp(str, "") == 0) {
/*
@@ -345,14 +345,14 @@ AddClause(
* TODO: "*." actually matches with all files on Win95
*/
- globPtr->pattern = ckalloc(3);
+ globPtr->pattern = (char *)ckalloc(3);
strcpy(globPtr->pattern, "*.");
} else {
- globPtr->pattern = ckalloc(len);
+ globPtr->pattern = (char *)ckalloc(len);
strcpy(globPtr->pattern, str);
}
} else {
- globPtr->pattern = ckalloc(len);
+ globPtr->pattern = (char *)ckalloc(len);
strcpy(globPtr->pattern, str);
}
@@ -375,8 +375,8 @@ AddClause(
}
for (i=0; i<ostypeCount; i++) {
Tcl_DString osTypeDS;
- int len;
- MacFileType *mfPtr = ckalloc(sizeof(MacFileType));
+ Tcl_Size len;
+ MacFileType *mfPtr = (MacFileType *)ckalloc(sizeof(MacFileType));
const char *strType = Tcl_GetStringFromObj(ostypeList[i], &len);
char *string;
@@ -385,8 +385,7 @@ AddClause(
* macRoman characters long
*/
- Tcl_UtfToExternalDString(macRoman, strType, len, &osTypeDS);
- string = Tcl_DStringValue(&osTypeDS);
+ string = Tcl_UtfToExternalDString(macRoman, strType, len, &osTypeDS);
mfPtr->type = (OSType) string[0] << 24 | (OSType) string[1] << 16 |
(OSType) string[2] << 8 | (OSType) string[3];
Tcl_DStringFree(&osTypeDS);
@@ -445,11 +444,11 @@ GetFilter(
}
}
- filterPtr = ckalloc(sizeof(FileFilter));
+ filterPtr = (FileFilter *)ckalloc(sizeof(FileFilter));
filterPtr->clauses = NULL;
filterPtr->clausesTail = NULL;
len = strlen(name) + 1;
- filterPtr->name = ckalloc(len);
+ filterPtr->name = (char *)ckalloc(len);
memcpy(filterPtr->name, name, len);
if (flistPtr->filters == NULL) {
diff --git a/generic/tkFileFilter.h b/generic/tkFileFilter.h
index 131e423..07d4d33 100644
--- a/generic/tkFileFilter.h
+++ b/generic/tkFileFilter.h
@@ -4,7 +4,7 @@
* Declarations for the file filter processing routines needed by the
* file selection dialogs.
*
- * Copyright (c) 1996 Sun Microsystems, Inc.
+ * Copyright © 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.
@@ -13,6 +13,10 @@
#ifndef _TK_FILE_FILTER
#define _TK_FILE_FILTER
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#define OSType long
typedef struct GlobPattern {
@@ -75,4 +79,8 @@ MODULE_SCOPE int TkGetFileFilters(Tcl_Interp *interp,
FileFilterList *flistPtr, Tcl_Obj *valuePtr,
int isWindows);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _TK_FILE_FILTER */
diff --git a/generic/tkFocus.c b/generic/tkFocus.c
index c2808e4..9ea7321 100644
--- a/generic/tkFocus.c
+++ b/generic/tkFocus.c
@@ -3,8 +3,8 @@
*
* This file contains functions 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.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 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.
@@ -82,7 +82,7 @@ typedef struct TkDisplayFocusInfo {
static DisplayFocusInfo*FindDisplayFocusInfo(TkMainInfo *mainPtr,
TkDisplay *dispPtr);
-static void FocusMapProc(ClientData clientData, XEvent *eventPtr);
+static void FocusMapProc(void *clientData, XEvent *eventPtr);
static void GenerateFocusEvents(TkWindow *sourcePtr,
TkWindow *destPtr);
@@ -105,7 +105,7 @@ static void GenerateFocusEvents(TkWindow *sourcePtr,
int
Tk_FocusObjCmd(
- ClientData clientData, /* Main window associated with interpreter. */
+ void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -128,7 +128,7 @@ Tk_FocusObjCmd(
Tk_Window focusWin = (Tk_Window) TkGetFocusWin(winPtr);
if (focusWin != NULL) {
- Tcl_SetObjResult(interp, TkNewWindowObj(focusWin));
+ Tcl_SetObjResult(interp, Tk_NewWindowObj(focusWin));
}
return TCL_OK;
}
@@ -179,7 +179,7 @@ Tk_FocusObjCmd(
}
newPtr = TkGetFocusWin(newPtr);
if (newPtr != NULL) {
- Tcl_SetObjResult(interp, TkNewWindowObj((Tk_Window) newPtr));
+ Tcl_SetObjResult(interp, Tk_NewWindowObj((Tk_Window) newPtr));
}
break;
case 1: /* -force */
@@ -212,12 +212,12 @@ Tk_FocusObjCmd(
for (tlFocusPtr = newPtr->mainPtr->tlFocusPtr; tlFocusPtr != NULL;
tlFocusPtr = tlFocusPtr->nextPtr) {
if (tlFocusPtr->topLevelPtr == topLevelPtr) {
- Tcl_SetObjResult(interp, TkNewWindowObj((Tk_Window)
+ Tcl_SetObjResult(interp, Tk_NewWindowObj((Tk_Window)
tlFocusPtr->focusWinPtr));
return TCL_OK;
}
}
- Tcl_SetObjResult(interp, TkNewWindowObj((Tk_Window) topLevelPtr));
+ Tcl_SetObjResult(interp, Tk_NewWindowObj((Tk_Window) topLevelPtr));
return TCL_OK;
}
break;
@@ -630,8 +630,8 @@ TkSetFocusWin(
}
tlFocusPtr->focusWinPtr = winPtr;
- if (topLevelPtr->flags & TK_EMBEDDED &&
- (displayFocusPtr->focusWinPtr == NULL)) {
+ if ((topLevelPtr->flags & TK_EMBEDDED) &&
+ (displayFocusPtr->focusWinPtr == NULL)) {
/*
* We are assigning focus to an embedded toplevel. The platform
@@ -971,7 +971,7 @@ GenerateFocusEvents(
static void
FocusMapProc(
- ClientData clientData, /* Toplevel window. */
+ void *clientData, /* Toplevel window. */
XEvent *eventPtr) /* Information about event. */
{
TkWindow *winPtr = (TkWindow *)clientData;
diff --git a/generic/tkFont.c b/generic/tkFont.c
index b1586aa..bb0b34f 100644
--- a/generic/tkFont.c
+++ b/generic/tkFont.c
@@ -4,8 +4,8 @@
* This file maintains a database of fonts for the Tk toolkit. It also
* provides several utility functions for measuring and displaying text.
*
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1998 Sun Microsystems, Inc.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994-1998 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -48,7 +48,7 @@ typedef struct TkFontInfo {
*/
typedef struct NamedFont {
- int refCount; /* Number of users of named font. */
+ size_t 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. */
@@ -73,9 +73,9 @@ typedef struct LayoutChunk {
const char *start; /* Pointer to simple string to be displayed.
* This is a pointer into the TkTextLayout's
* string. */
- int numBytes; /* The number of bytes in this chunk. */
- int numChars; /* The number of characters in this chunk. */
- int numDisplayChars; /* The number of characters to display when
+ Tcl_Size numBytes; /* The number of bytes in this chunk. */
+ Tcl_Size numChars; /* The number of characters in this chunk. */
+ Tcl_Size 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
@@ -98,7 +98,7 @@ typedef struct TextLayout {
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
+ Tcl_Size numChunks; /* Number of chunks actually used in following
* array. */
LayoutChunk chunks[TKFLEXARRAY];/* Array of chunks. The actual size will be
* maxChunks. THIS FIELD MUST BE THE LAST IN
@@ -328,7 +328,7 @@ static const char *const globalFontClass[] = {
static int ConfigAttributesObj(Tcl_Interp *interp,
- Tk_Window tkwin, int objc, Tcl_Obj *const objv[],
+ Tk_Window tkwin, Tcl_Size objc, Tcl_Obj *const objv[],
TkFontAttributes *faPtr);
static void DupFontObjProc(Tcl_Obj *srcObjPtr, Tcl_Obj *dupObjPtr);
static int FieldSpecified(const char *field);
@@ -337,13 +337,13 @@ static void FreeFontObjProc(Tcl_Obj *objPtr);
static int GetAttributeInfoObj(Tcl_Interp *interp,
const TkFontAttributes *faPtr, Tcl_Obj *objPtr);
static LayoutChunk * NewChunk(TextLayout **layoutPtrPtr, int *maxPtr,
- const char *start, int numChars, int curX,
+ const char *start, Tcl_Size numChars, int curX,
int newX, int y);
static int ParseFontNameObj(Tcl_Interp *interp, Tk_Window tkwin,
Tcl_Obj *objPtr, TkFontAttributes *faPtr);
static void RecomputeWidgets(TkWindow *winPtr);
static int SetFontFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr);
-static void TheWorldHasChanged(ClientData clientData);
+static void TheWorldHasChanged(void *clientData);
static void UpdateDependentFonts(TkFontInfo *fiPtr,
Tk_Window tkwin, Tcl_HashEntry *namedHashPtr);
@@ -353,12 +353,14 @@ static void UpdateDependentFonts(TkFontInfo *fiPtr,
* font object points to the TkFont structure for the font, or NULL.
*/
-const Tcl_ObjType tkFontObjType = {
- "font", /* name */
+const TkObjType tkFontObjType = {
+ {"font", /* name */
FreeFontObjProc, /* freeIntRepProc */
DupFontObjProc, /* dupIntRepProc */
NULL, /* updateStringProc */
- SetFontFromAny /* setFromAnyProc */
+ NULL, /* setFromAnyProc */
+ TCL_OBJTYPE_V0},
+ 0
};
/*
@@ -475,7 +477,7 @@ TkFontPkgFree(
int
Tk_FontObjCmd(
- ClientData clientData, /* Main window associated with interpreter. */
+ void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -564,7 +566,7 @@ Tk_FontObjCmd(
if (objc < 3 || n < objc) {
Tcl_WrongNumArgs(interp, 2, objv,
- "font ?-displayof window? ?option? ?--? ?char?");
+ "font ?-displayof window? ?-option? ?--? ?char?");
return TCL_ERROR;
}
@@ -574,14 +576,14 @@ Tk_FontObjCmd(
if (charPtr != NULL) {
const char *string = Tcl_GetString(charPtr);
- int len = TkUtfToUniChar(string, &uniChar);
+ size_t len = TkUtfToUniChar(string, &uniChar);
- if (len != charPtr->length) {
+ if (len != (size_t)charPtr->length) {
resultPtr = Tcl_NewStringObj(
- "expected a single character but got \"", -1);
+ "expected a single character but got \"", TCL_INDEX_NONE);
Tcl_AppendLimitedToObj(resultPtr, string,
- -1, 40, "...");
- Tcl_AppendToObj(resultPtr, "\"", -1);
+ TCL_INDEX_NONE, 40, "...");
+ Tcl_AppendToObj(resultPtr, "\"", TCL_INDEX_NONE);
Tcl_SetObjResult(interp, resultPtr);
Tcl_SetErrorCode(interp, "TK", "VALUE", "FONT_SAMPLE", NULL);
return TCL_ERROR;
@@ -685,7 +687,7 @@ Tk_FontObjCmd(
if (TkCreateNamedFont(interp, tkwin, name, &fa) != TCL_OK) {
return TCL_ERROR;
}
- Tcl_SetObjResult(interp, Tcl_NewStringObj(name, -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(name, TCL_INDEX_NONE));
break;
}
case FONT_DELETE: {
@@ -723,7 +725,7 @@ Tk_FontObjCmd(
case FONT_MEASURE: {
const char *string;
Tk_Font tkfont;
- int length = 0;
+ Tcl_Size length = 0;
int skip = 0;
if (objc > 4) {
@@ -742,7 +744,7 @@ Tk_FontObjCmd(
return TCL_ERROR;
}
string = Tcl_GetStringFromObj(objv[3 + skip], &length);
- Tcl_SetObjResult(interp, Tcl_NewIntObj(
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(
Tk_TextWidth(tkfont, string, length)));
Tk_FreeFont(tkfont);
break;
@@ -752,7 +754,7 @@ Tk_FontObjCmd(
int skip, i;
const TkFontMetrics *fmPtr;
static const char *const switches[] = {
- "-ascent", "-descent", "-linespace", "-fixed", NULL
+ "-ascent", "-descent", "-fixed", "-linespace", NULL
};
skip = TkGetDisplayOf(interp, objc - 3, objv + 3, &tkwin);
@@ -761,7 +763,7 @@ Tk_FontObjCmd(
}
if ((objc < 3) || (objc > 4 + skip)) {
Tcl_WrongNumArgs(interp, 2, objv,
- "font ?-displayof window? ?option?");
+ "font ?-displayof window? ?-option?");
return TCL_ERROR;
}
tkfont = Tk_AllocFontFromObj(interp, tkwin, objv[2]);
@@ -786,10 +788,10 @@ Tk_FontObjCmd(
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;
+ case 2: i = fmPtr->fixed; break;
+ case 3: i = fmPtr->ascent + fmPtr->descent; break;
}
- Tcl_SetObjResult(interp, Tcl_NewIntObj(i));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(i));
}
Tk_FreeFont(tkfont);
break;
@@ -813,7 +815,7 @@ Tk_FontObjCmd(
namedHashPtr);
Tcl_ListObjAppendElement(NULL, resultPtr,
- Tcl_NewStringObj(string, -1));
+ Tcl_NewStringObj(string, TCL_INDEX_NONE));
}
namedHashPtr = Tcl_NextHashEntry(&search);
}
@@ -881,7 +883,7 @@ UpdateDependentFonts(
static void
TheWorldHasChanged(
- ClientData clientData) /* Info about application's fonts. */
+ void *clientData) /* Info about application's fonts. */
{
TkFontInfo *fiPtr = (TkFontInfo *)clientData;
@@ -939,8 +941,8 @@ RecomputeWidgets(
* Broadcast font change virtually for mega-widget layout managers.
* Do this after the font change has been propagated to core widgets.
*/
- TkSendVirtualEvent((Tk_Window)winPtr, "TkWorldChanged",
- Tcl_NewStringObj("FontChanged",-1));
+ Tk_SendVirtualEvent((Tk_Window)winPtr, "TkWorldChanged",
+ Tcl_NewStringObj("FontChanged",-1));
}
/*
@@ -1084,7 +1086,7 @@ Tk_GetFont(
Tk_Font tkfont;
Tcl_Obj *strPtr;
- strPtr = Tcl_NewStringObj(string, -1);
+ strPtr = Tcl_NewStringObj(string, TCL_INDEX_NONE);
Tcl_IncrRefCount(strPtr);
tkfont = Tk_AllocFontFromObj(interp, tkwin, strPtr);
Tcl_DecrRefCount(strPtr);
@@ -1126,7 +1128,7 @@ Tk_AllocFontFromObj(
int isNew, descent;
NamedFont *nfPtr;
- if (objPtr->typePtr != &tkFontObjType
+ if (objPtr->typePtr != &tkFontObjType.objType
|| objPtr->internalRep.twoPtrValue.ptr2 != fiPtr) {
SetFontFromAny(interp, objPtr);
}
@@ -1224,7 +1226,7 @@ Tk_AllocFontFromObj(
}
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"failed to allocate font due to internal system font engine"
- " problem", -1));
+ " problem", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "FONT", "INTERNAL_PROBLEM", NULL);
return NULL;
}
@@ -1311,7 +1313,7 @@ Tk_GetFontFromObj(
TkFont *fontPtr;
Tcl_HashEntry *hashPtr;
- if (objPtr->typePtr != &tkFontObjType
+ if (objPtr->typePtr != &tkFontObjType.objType
|| objPtr->internalRep.twoPtrValue.ptr2 != fiPtr) {
SetFontFromAny(NULL, objPtr);
}
@@ -1392,7 +1394,7 @@ SetFontFromAny(
if ((typePtr != NULL) && (typePtr->freeIntRepProc != NULL)) {
typePtr->freeIntRepProc(objPtr);
}
- objPtr->typePtr = &tkFontObjType;
+ objPtr->typePtr = &tkFontObjType.objType;
objPtr->internalRep.twoPtrValue.ptr1 = NULL;
objPtr->internalRep.twoPtrValue.ptr2 = NULL;
@@ -1733,7 +1735,7 @@ Tk_PostscriptFontName(
* to do.
*/
- Tcl_DStringAppend(dsPtr, family, -1);
+ Tcl_DStringAppend(dsPtr, family, TCL_INDEX_NONE);
src = dest = Tcl_DStringValue(dsPtr) + len;
upper = 1;
@@ -1743,15 +1745,11 @@ Tk_PostscriptFontName(
upper = 1;
}
src += TkUtfToUniChar(src, &ch);
- if (ch <= 0xffff) {
- if (upper) {
- ch = Tcl_UniCharToUpper(ch);
- upper = 0;
- } else {
- ch = Tcl_UniCharToLower(ch);
- }
- } else {
+ if (upper) {
+ ch = Tcl_UniCharToUpper(ch);
upper = 0;
+ } else {
+ ch = Tcl_UniCharToLower(ch);
}
dest += TkUniCharToUtf(ch, dest);
}
@@ -1760,13 +1758,13 @@ Tk_PostscriptFontName(
family = Tcl_DStringValue(dsPtr) + len;
}
if (family != Tcl_DStringValue(dsPtr) + len) {
- Tcl_DStringAppend(dsPtr, family, -1);
+ Tcl_DStringAppend(dsPtr, family, TCL_INDEX_NONE);
family = Tcl_DStringValue(dsPtr) + len;
}
if (strcasecmp(family, "NewCenturySchoolbook") == 0) {
Tcl_DStringSetLength(dsPtr, len);
- Tcl_DStringAppend(dsPtr, "NewCenturySchlbk", -1);
+ Tcl_DStringAppend(dsPtr, "NewCenturySchlbk", TCL_INDEX_NONE);
family = Tcl_DStringValue(dsPtr) + len;
}
@@ -1816,15 +1814,15 @@ Tk_PostscriptFontName(
if ((strcmp(family, "Times") == 0)
|| (strcmp(family, "NewCenturySchlbk") == 0)
|| (strcmp(family, "Palatino") == 0)) {
- Tcl_DStringAppend(dsPtr, "-Roman", -1);
+ Tcl_DStringAppend(dsPtr, "-Roman", TCL_INDEX_NONE);
}
} else {
- Tcl_DStringAppend(dsPtr, "-", -1);
+ Tcl_DStringAppend(dsPtr, "-", TCL_INDEX_NONE);
if (weightString != NULL) {
- Tcl_DStringAppend(dsPtr, weightString, -1);
+ Tcl_DStringAppend(dsPtr, weightString, TCL_INDEX_NONE);
}
if (slantString != NULL) {
- Tcl_DStringAppend(dsPtr, slantString, -1);
+ Tcl_DStringAppend(dsPtr, slantString, TCL_INDEX_NONE);
}
}
@@ -1853,8 +1851,8 @@ int
Tk_TextWidth(
Tk_Font tkfont, /* Font in which text will be measured. */
const char *string, /* String whose width will be computed. */
- int numBytes) /* Number of bytes to consider from string, or
- * < 0 for strlen(). */
+ Tcl_Size numBytes) /* Number of bytes to consider from string, or
+ * TCL_INDEX_NONE for strlen(). */
{
int width;
@@ -1900,8 +1898,8 @@ Tk_UnderlineChars(
* underlined or overstruck. */
int x, int y, /* Coordinates at which first character of
* string is drawn. */
- int firstByte, /* Index of first byte of first character. */
- int lastByte) /* Index of first byte after the last
+ Tcl_Size firstByte, /* Index of first byte of first character. */
+ Tcl_Size lastByte) /* Index of first byte after the last
* character. */
{
TkUnderlineCharsInContext(display, drawable, gc, tkfont, string,
@@ -1919,11 +1917,11 @@ TkUnderlineCharsInContext(
* dimensions, etc. */
const char *string, /* String containing characters to be
* underlined or overstruck. */
- int numBytes, /* Number of bytes in string. */
+ Tcl_Size numBytes, /* Number of bytes in string. */
int x, int y, /* Coordinates at which the first character of
* the whole string would be drawn. */
- int firstByte, /* Index of first byte of first character. */
- int lastByte) /* Index of first byte after the last
+ Tcl_Size firstByte, /* Index of first byte of first character. */
+ Tcl_Size lastByte) /* Index of first byte after the last
* character. */
{
TkFont *fontPtr = (TkFont *) tkfont;
@@ -1973,8 +1971,8 @@ Tk_ComputeTextLayout(
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(). */
+ Tcl_Size numChars, /* Number of characters to consider from
+ * string, or TCL_INDEX_NONE for strlen(). */
int wrapLength, /* Longest permissible line length, in pixels.
* <= 0 means no automatic wrapping: just let
* lines get as long as needed. */
@@ -1989,7 +1987,7 @@ Tk_ComputeTextLayout(
{
TkFont *fontPtr = (TkFont *) tkfont;
const char *start, *endp, *special;
- int n;
+ Tcl_Size n;
int y, bytesThisChunk, maxChunks, curLine, layoutHeight;
int baseline, height, curX, newX, maxWidth, *lineLengths;
TextLayout *layoutPtr;
@@ -2014,7 +2012,7 @@ Tk_ComputeTextLayout(
height = fmPtr->ascent + fmPtr->descent;
if (numChars < 0) {
- numChars = Tcl_NumUtfChars(string, -1);
+ numChars = TkNumUtfChars(string, TCL_INDEX_NONE);
}
if (wrapLength == 0) {
wrapLength = -1;
@@ -2022,7 +2020,7 @@ Tk_ComputeTextLayout(
maxChunks = 1;
- layoutPtr = (TextLayout *)ckalloc(Tk_Offset(TextLayout, chunks)
+ layoutPtr = (TextLayout *)ckalloc(offsetof(TextLayout, chunks)
+ maxChunks * sizeof(LayoutChunk));
layoutPtr->tkfont = tkfont;
layoutPtr->string = string;
@@ -2154,7 +2152,7 @@ Tk_ComputeTextLayout(
bytesThisChunk = Tk_MeasureChars(tkfont, end, bytesThisChunk,
-1, 0, &chunkPtr->totalWidth);
chunkPtr->numBytes += bytesThisChunk;
- chunkPtr->numChars += Tcl_NumUtfChars(end, bytesThisChunk);
+ chunkPtr->numChars += TkNumUtfChars(end, bytesThisChunk);
chunkPtr->totalWidth += curX;
}
}
@@ -2313,10 +2311,10 @@ Tk_DrawTextLayout(
* Tk_ComputeTextLayout(). */
int x, int y, /* Upper-left hand corner of rectangle in
* which to draw (pixels). */
- int firstChar, /* The index of the first character to draw
+ Tcl_Size firstChar, /* The index of the first character to draw
* from the given text item. 0 specifies the
* beginning. */
- int lastChar) /* The index just after the last character to
+ Tcl_Size lastChar) /* The index just after the last character to
* draw from the given text item. A number < 0
* means to draw all characters. */
{
@@ -2326,7 +2324,7 @@ Tk_DrawTextLayout(
#else
TextLayout *layoutPtr = (TextLayout *) layout;
int i, drawX;
- int numDisplayChars;
+ Tcl_Size numDisplayChars;
const char *firstByte, *lastByte;
LayoutChunk *chunkPtr;
@@ -2385,10 +2383,10 @@ TkDrawAngledTextLayout(
int x, int y, /* Upper-left hand corner of rectangle in
* which to draw (pixels). */
double angle,
- int firstChar, /* The index of the first character to draw
+ Tcl_Size firstChar, /* The index of the first character to draw
* from the given text item. 0 specifies the
* beginning. */
- int lastChar) /* The index just after the last character to
+ Tcl_Size lastChar) /* The index just after the last character to
* draw from the given text item. A number < 0
* means to draw all characters. */
{
@@ -2493,7 +2491,7 @@ Tk_UnderlineTextLayout(
int x, int 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. */
+ * or INT_MIN for no underline. */
{
int xx, yy, width, height;
@@ -2520,7 +2518,7 @@ TkUnderlineAngledTextLayout(
* which to draw (pixels). */
double angle,
int underline) /* Index of the single character to underline,
- * or -1 for no underline. */
+ * or INT_MIN for no underline. */
{
int xx, yy, width, height;
@@ -2676,7 +2674,7 @@ Tk_PointToChar(
}
n = Tk_MeasureChars((Tk_Font) fontPtr, chunkPtr->start,
chunkPtr->numBytes, x - chunkPtr->x, 0, &dummy);
- return numChars + Tcl_NumUtfChars(chunkPtr->start, n);
+ return numChars + TkNumUtfChars(chunkPtr->start, n);
}
numChars += chunkPtr->numChars;
lastPtr = chunkPtr;
@@ -2747,8 +2745,8 @@ int
Tk_CharBbox(
Tk_TextLayout layout, /* Layout information, from a previous call to
* Tk_ComputeTextLayout(). */
- int index, /* The index of the character whose bbox is
- * desired. */
+ Tcl_Size index, /* The index of the character whose bbox is
+ * desired. Negative means count backwards. */
int *xPtr, int *yPtr, /* Filled with the upper-left hand corner, in
* pixels, of the bounding box for the
* character specified by index, if
@@ -2759,17 +2757,21 @@ Tk_CharBbox(
* index, if non-NULL. */
{
TextLayout *layoutPtr = (TextLayout *) layout;
- LayoutChunk *chunkPtr;
+ LayoutChunk *chunkPtr = layoutPtr->chunks;
int i, x = 0, w;
Tk_Font tkfont;
TkFont *fontPtr;
const char *end;
if (index < 0) {
- return 0;
+ for (i = 0; i < layoutPtr->numChunks; i++) {
+ index += (chunkPtr + i)->numChars;
+ }
+ if (index < 0) {
+ return 0;
+ }
}
- chunkPtr = layoutPtr->chunks;
tkfont = layoutPtr->tkfont;
fontPtr = (TkFont *) tkfont;
@@ -3309,20 +3311,20 @@ Tk_TextLayoutToPostscript(
int baseline = chunkPtr->y;
Tcl_Obj *psObj = Tcl_NewObj();
int i, j;
- int len;
+ Tcl_Size len;
const char *p, *glyphname;
char uindex[5], c, *ps;
int ch;
- Tcl_AppendToObj(psObj, "[(", -1);
+ Tcl_AppendToObj(psObj, "[(", TCL_INDEX_NONE);
for (i = 0; i < layoutPtr->numChunks; i++, chunkPtr++) {
if (baseline != chunkPtr->y) {
- Tcl_AppendToObj(psObj, ")]\n[(", -1);
+ Tcl_AppendToObj(psObj, ")]\n[(", TCL_INDEX_NONE);
baseline = chunkPtr->y;
}
if (chunkPtr->numDisplayChars <= 0) {
if (chunkPtr->start[0] == '\t') {
- Tcl_AppendToObj(psObj, "\\t", -1);
+ Tcl_AppendToObj(psObj, "\\t", TCL_INDEX_NONE);
}
continue;
}
@@ -3375,10 +3377,10 @@ Tk_TextLayoutToPostscript(
ps[len-1] = '/';
} else {
- Tcl_AppendToObj(psObj, ")/", -1);
+ Tcl_AppendToObj(psObj, ")/", TCL_INDEX_NONE);
}
- Tcl_AppendToObj(psObj, glyphname, -1);
- Tcl_AppendToObj(psObj, "(", -1);
+ Tcl_AppendToObj(psObj, glyphname, TCL_INDEX_NONE);
+ Tcl_AppendToObj(psObj, "(", TCL_INDEX_NONE);
} else {
/*
* No known mapping for the character into the space of
@@ -3393,7 +3395,7 @@ noMapping: ;
}
}
}
- Tcl_AppendToObj(psObj, ")]\n", -1);
+ Tcl_AppendToObj(psObj, ")]\n", TCL_INDEX_NONE);
Tcl_AppendObjToObj(Tcl_GetObjResult(interp), psObj);
Tcl_DecrRefCount(psObj);
}
@@ -3423,13 +3425,13 @@ static int
ConfigAttributesObj(
Tcl_Interp *interp, /* Interp for error return. */
TCL_UNUSED(Tk_Window), /* For display on which font will be used. */
- int objc, /* Number of elements in argv. */
+ Tcl_Size 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;
+ Tcl_Size i;
int n, index;
Tcl_Obj *optionPtr, *valuePtr;
const char *value;
@@ -3559,20 +3561,20 @@ GetAttributeInfoObj(
case FONT_SIZE:
if (faPtr->size >= 0.0) {
- valuePtr = Tcl_NewIntObj((int)(faPtr->size + 0.5));
+ valuePtr = Tcl_NewWideIntObj((Tcl_WideInt)(faPtr->size + 0.5));
} else {
- valuePtr = Tcl_NewIntObj(-(int)(-faPtr->size + 0.5));
+ valuePtr = Tcl_NewWideIntObj(-(Tcl_WideInt)(-faPtr->size + 0.5));
}
break;
case FONT_WEIGHT:
str = TkFindStateString(weightMap, faPtr->weight);
- valuePtr = Tcl_NewStringObj(str, -1);
+ valuePtr = Tcl_NewStringObj(str, TCL_INDEX_NONE);
break;
case FONT_SLANT:
str = TkFindStateString(slantMap, faPtr->slant);
- valuePtr = Tcl_NewStringObj(str, -1);
+ valuePtr = Tcl_NewStringObj(str, TCL_INDEX_NONE);
break;
case FONT_UNDERLINE:
@@ -3588,7 +3590,7 @@ GetAttributeInfoObj(
return TCL_OK;
}
Tcl_ListObjAppendElement(NULL, resultPtr,
- Tcl_NewStringObj(fontOpt[i], -1));
+ Tcl_NewStringObj(fontOpt[i], TCL_INDEX_NONE));
Tcl_ListObjAppendElement(NULL, resultPtr, valuePtr);
}
Tcl_SetObjResult(interp, resultPtr);
@@ -3598,6 +3600,57 @@ GetAttributeInfoObj(
/*
*---------------------------------------------------------------------------
*
+ * Tk_FontGetDescription --
+ *
+ * Return information about the font description as a Tcl list. One
+ * possible result is "{{DejaVu Sans} -16 bold underline}".
+ *
+ * Results:
+ * The list of descriptions.
+ *
+ * Side effects:
+ * None.
+ *
+ *---------------------------------------------------------------------------
+ */
+
+Tcl_Obj *
+Tk_FontGetDescription(
+ Tk_Font tkfont) /* Font whose description is desired. */
+{
+ const TkFontAttributes *faPtr = GetFontAttributes(tkfont);
+ Tcl_Obj *resultPtr = Tcl_NewObj();
+ const char *str;
+
+ str = faPtr->family;
+ Tcl_ListObjAppendElement(NULL, resultPtr, Tcl_NewStringObj(str, str ? -1 : 0));
+ if (faPtr->size >= 0.0) {
+ Tcl_ListObjAppendElement(NULL, resultPtr, Tcl_NewWideIntObj((int)(faPtr->size + 0.5)));
+ } else {
+ Tcl_ListObjAppendElement(NULL, resultPtr, Tcl_NewWideIntObj(-(int)(-faPtr->size + 0.5)));
+ }
+ if (faPtr->weight != TK_FW_NORMAL) {
+ str = TkFindStateString(weightMap, faPtr->weight);
+ Tcl_ListObjAppendElement(NULL, resultPtr, Tcl_NewStringObj(str, TCL_INDEX_NONE));
+ }
+ if (faPtr->slant != TK_FS_ROMAN) {
+ str = TkFindStateString(slantMap, faPtr->slant);
+ Tcl_ListObjAppendElement(NULL, resultPtr, Tcl_NewStringObj(str, TCL_INDEX_NONE));
+ }
+ if (faPtr->underline) {
+ str = TkFindStateString(underlineMap, faPtr->underline);
+ Tcl_ListObjAppendElement(NULL, resultPtr, Tcl_NewStringObj(str, TCL_INDEX_NONE));
+ }
+ if (faPtr->overstrike) {
+ str = TkFindStateString(overstrikeMap, faPtr->overstrike);
+ Tcl_ListObjAppendElement(NULL, resultPtr, Tcl_NewStringObj(str, TCL_INDEX_NONE));
+ }
+ return resultPtr;
+}
+
+/*
+ *---------------------------------------------------------------------------
+ *
* ParseFontNameObj --
*
* Converts a object into a set of font attributes that can be used to
@@ -3632,7 +3685,7 @@ ParseFontNameObj(
{
const char *dash;
int result, n;
- int objc, i;
+ Tcl_Size objc, i;
Tcl_Obj **objv;
const char *string;
@@ -3785,7 +3838,7 @@ NewChunk(
TextLayout **layoutPtrPtr,
int *maxPtr,
const char *start,
- int numBytes,
+ Tcl_Size numBytes,
int curX,
int newX,
int y)
@@ -3799,13 +3852,13 @@ NewChunk(
maxChunks = *maxPtr;
if (layoutPtr->numChunks == maxChunks) {
maxChunks *= 2;
- s = Tk_Offset(TextLayout, chunks) + (maxChunks * sizeof(LayoutChunk));
+ s = offsetof(TextLayout, chunks) + (maxChunks * sizeof(LayoutChunk));
layoutPtr = (TextLayout *)ckrealloc(layoutPtr, s);
*layoutPtrPtr = layoutPtr;
*maxPtr = maxChunks;
}
- numChars = Tcl_NumUtfChars(start, numBytes);
+ numChars = TkNumUtfChars(start, numBytes);
chunkPtr = &layoutPtr->chunks[layoutPtr->numChunks];
chunkPtr->start = start;
chunkPtr->numBytes = numBytes;
@@ -3872,7 +3925,7 @@ TkFontParseXLFD(
}
Tcl_DStringInit(&ds);
- Tcl_DStringAppend(&ds, str, -1);
+ Tcl_DStringAppend(&ds, str, TCL_INDEX_NONE);
src = Tcl_DStringValue(&ds);
field[0] = src;
@@ -4270,9 +4323,9 @@ TkDebugFont(
for ( ; (fontPtr != NULL); fontPtr = fontPtr->nextPtr) {
objPtr = Tcl_NewObj();
Tcl_ListObjAppendElement(NULL, objPtr,
- Tcl_NewIntObj(fontPtr->resourceRefCount));
+ Tcl_NewWideIntObj(fontPtr->resourceRefCount));
Tcl_ListObjAppendElement(NULL, objPtr,
- Tcl_NewIntObj(fontPtr->objRefCount));
+ Tcl_NewWideIntObj(fontPtr->objRefCount));
Tcl_ListObjAppendElement(NULL, resultPtr, objPtr);
}
}
@@ -4307,7 +4360,7 @@ TkFontGetFirstTextLayout(
{
TextLayout *layoutPtr = (TextLayout *) layout;
LayoutChunk *chunkPtr;
- int numBytesInChunk;
+ Tcl_Size numBytesInChunk;
if ((layoutPtr == NULL) || (layoutPtr->numChunks == 0)
|| (layoutPtr->chunks->numDisplayChars <= 0)) {
diff --git a/generic/tkFont.h b/generic/tkFont.h
index de479bf..3ac34db 100644
--- a/generic/tkFont.h
+++ b/generic/tkFont.h
@@ -5,7 +5,7 @@
* parts of the font package. This information is not visible outside of
* the font package.
*
- * Copyright (c) 1996-1997 Sun Microsystems, Inc.
+ * Copyright © 1996-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.
@@ -14,6 +14,10 @@
#ifndef _TKFONT
#define _TKFONT
+#ifdef __cplusplus
+extern "C" {
+#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
@@ -85,7 +89,7 @@ typedef struct TkFont {
* Fields used and maintained exclusively by generic code.
*/
- int resourceRefCount; /* Number of active uses of this font (each
+ Tcl_Size resourceRefCount; /* Number of active uses of this font (each
* active use corresponds to a call to
* Tk_AllocFontFromTable or Tk_GetFont). If
* this count is 0, then this TkFont structure
@@ -95,7 +99,7 @@ typedef struct TkFont {
* The structure is freed when
* resourceRefCount and objRefCount are both
* 0. */
- int objRefCount; /* The number of Tcl objects that reference
+ Tcl_Size objRefCount; /* The number of Tcl objects that reference
* this structure. */
Tcl_HashEntry *cacheHashPtr;/* Entry in font cache for this structure,
* used when deleting it. */
@@ -221,4 +225,8 @@ MODULE_SCOPE void TkpGetFontFamilies(Tcl_Interp *interp,
Tk_Window tkwin);
MODULE_SCOPE TkFont * TkpGetNativeFont(Tk_Window tkwin, const char *name);
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _TKFONT */
diff --git a/generic/tkFrame.c b/generic/tkFrame.c
index c5e50b6..1d93976 100644
--- a/generic/tkFrame.c
+++ b/generic/tkFrame.c
@@ -5,8 +5,8 @@
* 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-1997 Sun Microsystems, Inc.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 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.
@@ -94,6 +94,16 @@ typedef struct {
* pixels of extra space to leave above and
* below child area. */
int padY; /* Integer value corresponding to padYPtr. */
+ Tcl_Obj *bgimgPtr; /* Value of -backgroundimage option: specifies
+ * image to display on window's background, or
+ * NULL if none. */
+ Tk_Image bgimg; /* Derived from bgimgPtr by calling
+ * Tk_GetImage, or NULL if bgimgPtr is
+ * NULL. */
+ int tile; /* Whether to tile the bgimg. */
+#ifndef TK_NO_DOUBLE_BUFFERING
+ GC copyGC; /* GC for copying when double-buffering. */
+#endif /* TK_NO_DOUBLE_BUFFERING */
} Frame;
/*
@@ -174,80 +184,94 @@ static const char *const labelAnchorStrings[] = {
static const Tk_OptionSpec commonOptSpec[] = {
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_FRAME_BG_COLOR, -1, Tk_Offset(Frame, border),
+ DEF_FRAME_BG_COLOR, TCL_INDEX_NONE, offsetof(Frame, border),
TK_OPTION_NULL_OK, DEF_FRAME_BG_MONO, 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL,
- NULL, 0, -1, 0, "-background", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_STRING, "-colormap", "colormap", "Colormap",
- DEF_FRAME_COLORMAP, -1, Tk_Offset(Frame, colormapName),
+ DEF_FRAME_COLORMAP, TCL_INDEX_NONE, offsetof(Frame, colormapName),
TK_OPTION_NULL_OK, 0, 0},
/*
* Having -container is useless in a labelframe since a container has
* no border. It should be deprecated.
*/
{TK_OPTION_BOOLEAN, "-container", "container", "Container",
- DEF_FRAME_CONTAINER, -1, Tk_Offset(Frame, isContainer), 0, 0, 0},
+ DEF_FRAME_CONTAINER, TCL_INDEX_NONE, offsetof(Frame, isContainer), 0, 0, 0},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_FRAME_CURSOR, -1, Tk_Offset(Frame, cursor),
+ DEF_FRAME_CURSOR, TCL_INDEX_NONE, offsetof(Frame, cursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-height", "height", "Height",
- DEF_FRAME_HEIGHT, -1, Tk_Offset(Frame, height), 0, 0, 0},
+ DEF_FRAME_HEIGHT, TCL_INDEX_NONE, offsetof(Frame, height), 0, 0, 0},
{TK_OPTION_COLOR, "-highlightbackground", "highlightBackground",
- "HighlightBackground", DEF_FRAME_HIGHLIGHT_BG, -1,
- Tk_Offset(Frame, highlightBgColorPtr), 0, 0, 0},
+ "HighlightBackground", DEF_FRAME_HIGHLIGHT_BG, TCL_INDEX_NONE,
+ offsetof(Frame, highlightBgColorPtr), 0, 0, 0},
{TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_FRAME_HIGHLIGHT, -1, Tk_Offset(Frame, highlightColorPtr),
+ DEF_FRAME_HIGHLIGHT, TCL_INDEX_NONE, offsetof(Frame, highlightColorPtr),
0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
- "HighlightThickness", DEF_FRAME_HIGHLIGHT_WIDTH, -1,
- Tk_Offset(Frame, highlightWidth), 0, 0, 0},
+ "HighlightThickness", DEF_FRAME_HIGHLIGHT_WIDTH, TCL_INDEX_NONE,
+ offsetof(Frame, highlightWidth), 0, 0, 0},
{TK_OPTION_PIXELS, "-padx", "padX", "Pad",
- DEF_FRAME_PADX, Tk_Offset(Frame, padXPtr),
- Tk_Offset(Frame, padX), 0, 0, 0},
+ DEF_FRAME_PADX, offsetof(Frame, padXPtr),
+ offsetof(Frame, padX), 0, 0, 0},
{TK_OPTION_PIXELS, "-pady", "padY", "Pad",
- DEF_FRAME_PADY, Tk_Offset(Frame, padYPtr),
- Tk_Offset(Frame, padY), 0, 0, 0},
+ DEF_FRAME_PADY, offsetof(Frame, padYPtr),
+ offsetof(Frame, padY), 0, 0, 0},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_FRAME_TAKE_FOCUS, -1, Tk_Offset(Frame, takeFocus),
+ DEF_FRAME_TAKE_FOCUS, TCL_INDEX_NONE, offsetof(Frame, takeFocus),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-visual", "visual", "Visual",
- DEF_FRAME_VISUAL, -1, Tk_Offset(Frame, visualName),
+ DEF_FRAME_VISUAL, TCL_INDEX_NONE, offsetof(Frame, visualName),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-width", "width", "Width",
- DEF_FRAME_WIDTH, -1, Tk_Offset(Frame, width), 0, 0, 0},
+ DEF_FRAME_WIDTH, TCL_INDEX_NONE, offsetof(Frame, width), 0, 0, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0}
};
static const Tk_OptionSpec frameOptSpec[] = {
+ {TK_OPTION_STRING, "-backgroundimage", "backgroundImage", "BackgroundImage",
+ DEF_FRAME_BG_IMAGE, offsetof(Frame, bgimgPtr), TCL_INDEX_NONE,
+ TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
+ {TK_OPTION_SYNONYM, "-bgimg", NULL, NULL,
+ NULL, 0, TCL_INDEX_NONE, 0, "-backgroundimage", 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_FRAME_BORDER_WIDTH, -1, Tk_Offset(Frame, borderWidth), 0, 0, 0},
+ DEF_FRAME_BORDER_WIDTH, TCL_INDEX_NONE, offsetof(Frame, borderWidth), 0, 0, 0},
{TK_OPTION_STRING, "-class", "class", "Class",
- DEF_FRAME_CLASS, -1, Tk_Offset(Frame, className), 0, 0, 0},
+ DEF_FRAME_CLASS, TCL_INDEX_NONE, offsetof(Frame, className), 0, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_FRAME_RELIEF, -1, Tk_Offset(Frame, relief), 0, 0, 0},
+ DEF_FRAME_RELIEF, TCL_INDEX_NONE, offsetof(Frame, relief), 0, 0, 0},
+ {TK_OPTION_BOOLEAN, "-tile", "tile", "Tile",
+ DEF_FRAME_BG_TILE, TCL_INDEX_NONE, offsetof(Frame, tile), 0, 0, 0},
{TK_OPTION_END, NULL, NULL, NULL,
NULL, 0, 0, 0, commonOptSpec, 0}
};
static const Tk_OptionSpec toplevelOptSpec[] = {
+ {TK_OPTION_STRING, "-backgroundimage", "backgroundImage", "BackgroundImage",
+ DEF_FRAME_BG_IMAGE, offsetof(Frame, bgimgPtr), TCL_INDEX_NONE,
+ TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
+ {TK_OPTION_SYNONYM, "-bgimg", NULL, NULL,
+ NULL, 0, TCL_INDEX_NONE, 0, "-backgroundimage", 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_FRAME_BORDER_WIDTH, -1, Tk_Offset(Frame, borderWidth), 0, 0, 0},
+ DEF_FRAME_BORDER_WIDTH, TCL_INDEX_NONE, offsetof(Frame, borderWidth), 0, 0, 0},
{TK_OPTION_STRING, "-class", "class", "Class",
- DEF_TOPLEVEL_CLASS, -1, Tk_Offset(Frame, className), 0, 0, 0},
+ DEF_TOPLEVEL_CLASS, TCL_INDEX_NONE, offsetof(Frame, className), 0, 0, 0},
{TK_OPTION_STRING, "-menu", "menu", "Menu",
- DEF_TOPLEVEL_MENU, -1, Tk_Offset(Frame, menuName),
+ DEF_TOPLEVEL_MENU, TCL_INDEX_NONE, offsetof(Frame, menuName),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_FRAME_RELIEF, -1, Tk_Offset(Frame, relief), 0, 0, 0},
+ DEF_FRAME_RELIEF, TCL_INDEX_NONE, offsetof(Frame, relief), 0, 0, 0},
{TK_OPTION_STRING, "-screen", "screen", "Screen",
- DEF_TOPLEVEL_SCREEN, -1, Tk_Offset(Frame, screenName),
+ DEF_TOPLEVEL_SCREEN, TCL_INDEX_NONE, offsetof(Frame, screenName),
TK_OPTION_NULL_OK, 0, 0},
+ {TK_OPTION_BOOLEAN, "-tile", "tile", "Tile",
+ DEF_FRAME_BG_TILE, TCL_INDEX_NONE, offsetof(Frame, tile), 0, 0, 0},
{TK_OPTION_STRING, "-use", "use", "Use",
- DEF_TOPLEVEL_USE, -1, Tk_Offset(Frame, useThis),
+ DEF_TOPLEVEL_USE, TCL_INDEX_NONE, offsetof(Frame, useThis),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_END, NULL, NULL, NULL,
NULL, 0, 0, 0, commonOptSpec, 0}
@@ -255,27 +279,27 @@ static const Tk_OptionSpec toplevelOptSpec[] = {
static const Tk_OptionSpec labelframeOptSpec[] = {
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_LABELFRAME_BORDER_WIDTH, -1, Tk_Offset(Frame, borderWidth),
+ DEF_LABELFRAME_BORDER_WIDTH, TCL_INDEX_NONE, offsetof(Frame, borderWidth),
0, 0, 0},
{TK_OPTION_STRING, "-class", "class", "Class",
- DEF_LABELFRAME_CLASS, -1, Tk_Offset(Frame, className), 0, 0, 0},
+ DEF_LABELFRAME_CLASS, TCL_INDEX_NONE, offsetof(Frame, className), 0, 0, 0},
{TK_OPTION_SYNONYM, "-fg", "foreground", NULL,
- NULL, 0, -1, 0, "-foreground", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_LABELFRAME_FONT, -1, Tk_Offset(Labelframe, tkfont), 0, 0, 0},
+ DEF_LABELFRAME_FONT, TCL_INDEX_NONE, offsetof(Labelframe, tkfont), 0, 0, 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_LABELFRAME_FG, -1, Tk_Offset(Labelframe, textColorPtr), 0, 0, 0},
+ DEF_LABELFRAME_FG, TCL_INDEX_NONE, offsetof(Labelframe, textColorPtr), 0, 0, 0},
{TK_OPTION_STRING_TABLE, "-labelanchor", "labelAnchor", "LabelAnchor",
- DEF_LABELFRAME_LABELANCHOR, -1, Tk_Offset(Labelframe, labelAnchor),
+ DEF_LABELFRAME_LABELANCHOR, TCL_INDEX_NONE, offsetof(Labelframe, labelAnchor),
0, labelAnchorStrings, 0},
{TK_OPTION_WINDOW, "-labelwidget", "labelWidget", "LabelWidget",
- NULL, -1, Tk_Offset(Labelframe, labelWin), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(Labelframe, labelWin), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_LABELFRAME_RELIEF, -1, Tk_Offset(Frame, relief), 0, 0, 0},
+ DEF_LABELFRAME_RELIEF, TCL_INDEX_NONE, offsetof(Frame, relief), 0, 0, 0},
{TK_OPTION_STRING, "-text", "text", "Text",
- DEF_LABELFRAME_TEXT, Tk_Offset(Labelframe, textPtr), -1,
+ DEF_LABELFRAME_TEXT, offsetof(Labelframe, textPtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_END, NULL, NULL, NULL,
NULL, 0, 0, 0, commonOptSpec, 0}
@@ -304,13 +328,19 @@ static const Tk_OptionSpec *const optionSpecs[] = {
static void ComputeFrameGeometry(Frame *framePtr);
static int ConfigureFrame(Tcl_Interp *interp, Frame *framePtr,
- int objc, Tcl_Obj *const objv[]);
+ Tcl_Size objc, Tcl_Obj *const objv[]);
static int CreateFrame(void *clientData, Tcl_Interp *interp,
- int objc, Tcl_Obj *const objv[],
+ Tcl_Size objc, Tcl_Obj *const objv[],
enum FrameType type, const char *appName);
static Tcl_FreeProc DestroyFrame;
static void DestroyFramePartly(Frame *framePtr);
static void DisplayFrame(void *clientData);
+static void DrawFrameBackground(Tk_Window tkwin, Pixmap pixmap,
+ int highlightWidth, int borderWidth,
+ Tk_Image bgimg, int bgtile);
+static void FrameBgImageProc(void *clientData,
+ int x, int y, int width, int height,
+ int imgWidth, int imgHeight);
static void FrameCmdDeletedProc(void *clientData);
static void FrameEventProc(void *clientData,
XEvent *eventPtr);
@@ -320,9 +350,7 @@ static void FrameRequestProc(void *clientData,
Tk_Window tkwin);
static void FrameStructureProc(void *clientData,
XEvent *eventPtr);
-static int FrameWidgetObjCmd(void *clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
+static Tcl_ObjCmdProc FrameWidgetObjCmd;
static void FrameWorldChanged(void *instanceData);
static void MapFrame(void *clientData);
@@ -421,7 +449,7 @@ int
TkCreateFrame(
void *clientData, /* Either NULL or pointer to option table. */
Tcl_Interp *interp, /* Current interpreter. */
- int argc, /* Number of arguments. */
+ Tcl_Size argc, /* Number of arguments. */
const char *const *argv, /* Argument strings. */
int toplevel, /* Non-zero means create a toplevel window,
* zero means create a frame. */
@@ -430,11 +458,12 @@ TkCreateFrame(
* Gives the base name to use for the new
* application. */
{
- int result, i;
+ int result;
+ Tcl_Size i;
Tcl_Obj **objv = (Tcl_Obj **)ckalloc((argc+1) * sizeof(Tcl_Obj **));
for (i=0; i<argc; i++) {
- objv[i] = Tcl_NewStringObj(argv[i], -1);
+ objv[i] = Tcl_NewStringObj(argv[i], TCL_INDEX_NONE);
Tcl_IncrRefCount(objv[i]);
}
objv[argc] = NULL;
@@ -459,7 +488,7 @@ TkListCreateFrame(
* Gives the base name to use for the new
* application. */
{
- int objc;
+ Tcl_Size objc;
Tcl_Obj **objv;
if (TCL_OK != Tcl_ListObjGetElements(interp, listObj, &objc, &objv)) {
@@ -474,7 +503,7 @@ static int
CreateFrame(
TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[], /* Argument objects. */
enum FrameType type, /* What widget type to create. */
const char *appName) /* Should only be non-NULL if there are no
@@ -488,8 +517,8 @@ CreateFrame(
Tk_Window newWin;
const char *className, *screenName, *visualName, *colormapName;
const char *arg, *useOption;
- int i, depth;
- int length;
+ int depth;
+ Tcl_Size i, length;
unsigned int mask;
Colormap colormap;
Visual *visual;
@@ -548,8 +577,8 @@ CreateFrame(
* 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.
+ * 3. Must call Tk_UseWindow before setting non-default visual
+ * information, since Tk_UseWindow changes the defaults.
*/
if (screenName == NULL) {
@@ -603,7 +632,7 @@ CreateFrame(
useOption = Tk_GetOption(newWin, "use", "Use");
}
if ((useOption != NULL) && (*useOption != 0)
- && (TkpUseWindow(interp, newWin, useOption) != TCL_OK)) {
+ && (Tk_UseWindow(interp, newWin, useOption) != TCL_OK)) {
goto error;
}
if (visualName == NULL) {
@@ -683,7 +712,7 @@ CreateFrame(
mask |= ActivateMask;
}
Tk_CreateEventHandler(newWin, mask, FrameEventProc, framePtr);
- if ((Tk_InitOptions(interp, (char *) framePtr, optionTable, newWin)
+ if ((Tk_InitOptions(interp, framePtr, optionTable, newWin)
!= TCL_OK) ||
(ConfigureFrame(interp, framePtr, objc-2, objv+2) != TCL_OK)) {
goto error;
@@ -692,16 +721,16 @@ CreateFrame(
if (framePtr->useThis != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"windows cannot have both the -use and the -container"
- " option set", -1));
+ " option set", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "FRAME", "CONTAINMENT", NULL);
goto error;
}
- TkpMakeContainer(framePtr->tkwin);
+ Tk_MakeContainer(framePtr->tkwin);
}
if (type == TYPE_TOPLEVEL) {
Tcl_DoWhenIdle(MapFrame, framePtr);
}
- Tcl_SetObjResult(interp, TkNewWindowObj(newWin));
+ Tcl_SetObjResult(interp, Tk_NewWindowObj(newWin));
return TCL_OK;
error:
@@ -744,8 +773,8 @@ FrameWidgetObjCmd(
};
Frame *framePtr = (Frame *)clientData;
int result = TCL_OK, index;
- int c, i;
- int length;
+ int c;
+ Tcl_Size i, length;
Tcl_Obj *objPtr;
if (objc < 2) {
@@ -764,7 +793,7 @@ FrameWidgetObjCmd(
result = TCL_ERROR;
goto done;
}
- objPtr = Tk_GetOptionValue(interp, (char *) framePtr,
+ objPtr = Tk_GetOptionValue(interp, framePtr,
framePtr->optionTable, objv[2], framePtr->tkwin);
if (objPtr == NULL) {
result = TCL_ERROR;
@@ -774,7 +803,7 @@ FrameWidgetObjCmd(
break;
case FRAME_CONFIGURE:
if (objc <= 3) {
- objPtr = Tk_GetOptionInfo(interp, (char *) framePtr,
+ objPtr = Tk_GetOptionInfo(interp, framePtr,
framePtr->optionTable, (objc == 3) ? objv[2] : NULL,
framePtr->tkwin);
if (objPtr == NULL) {
@@ -812,7 +841,7 @@ FrameWidgetObjCmd(
if (c == 'u') {
const char *string = Tcl_GetString(objv[i+1]);
- if (TkpUseWindow(interp, framePtr->tkwin,
+ if (Tk_UseWindow(interp, framePtr->tkwin,
string) != TCL_OK) {
result = TCL_ERROR;
goto done;
@@ -859,7 +888,11 @@ FrameWidgetObjCmd(
static void
DestroyFrame(
- char *memPtr) /* Info about frame widget. */
+#if TCL_MAJOR_VERSION > 8
+ void *memPtr) /* Info about frame widget. */
+#else
+ char *memPtr)
+#endif
{
Frame *framePtr = (Frame *)memPtr;
Labelframe *labelframePtr = (Labelframe *)memPtr;
@@ -870,9 +903,17 @@ DestroyFrame(
Tk_FreeGC(framePtr->display, labelframePtr->textGC);
}
}
+#ifndef TK_NO_DOUBLE_BUFFERING
+ if (framePtr->copyGC != NULL) {
+ Tk_FreeGC(framePtr->display, framePtr->copyGC);
+ }
+#endif /* TK_NO_DOUBLE_BUFFERING */
if (framePtr->colormap != None) {
Tk_FreeColormap(framePtr->display, framePtr->colormap);
}
+ if (framePtr->bgimg) {
+ Tk_FreeImage(framePtr->bgimg);
+ }
ckfree(framePtr);
}
@@ -911,7 +952,7 @@ DestroyFramePartly(
labelframePtr->labelWin = NULL;
}
- Tk_FreeConfigOptions((char *) framePtr, framePtr->optionTable,
+ Tk_FreeConfigOptions(framePtr, framePtr->optionTable,
framePtr->tkwin);
}
@@ -940,13 +981,14 @@ ConfigureFrame(
Tcl_Interp *interp, /* Used for error reporting. */
Frame *framePtr, /* Information about widget; may or may not
* already have values for some fields. */
- int objc, /* Number of valid entries in objv. */
+ Tcl_Size objc, /* Number of valid entries in objv. */
Tcl_Obj *const objv[]) /* Arguments. */
{
Tk_SavedOptions savedOptions;
char *oldMenuName;
Tk_Window oldWindow = NULL;
Labelframe *labelframePtr = (Labelframe *) framePtr;
+ Tk_Image image = NULL;
/*
* Need the old menubar name for the menu code to delete it.
@@ -962,7 +1004,7 @@ ConfigureFrame(
if (framePtr->type == TYPE_LABELFRAME) {
oldWindow = labelframePtr->labelWin;
}
- if (Tk_SetOptions(interp, (char *) framePtr,
+ if (Tk_SetOptions(interp, framePtr,
framePtr->optionTable, objc, objv,
framePtr->tkwin, &savedOptions, NULL) != TCL_OK) {
if (oldMenuName != NULL) {
@@ -970,6 +1012,20 @@ ConfigureFrame(
}
return TCL_ERROR;
}
+
+ if (framePtr->bgimgPtr) {
+ image = Tk_GetImage(interp, framePtr->tkwin,
+ Tcl_GetString(framePtr->bgimgPtr), FrameBgImageProc, framePtr);
+ if (image == NULL) {
+ Tk_RestoreSavedOptions(&savedOptions);
+ return TCL_ERROR;
+ }
+ }
+ if (framePtr->bgimg) {
+ Tk_FreeImage(framePtr->bgimg);
+ }
+ framePtr->bgimg = image;
+
Tk_FreeSavedOptions(&savedOptions);
/*
@@ -981,7 +1037,7 @@ ConfigureFrame(
|| ((oldMenuName != NULL) && (framePtr->menuName != NULL)
&& strcmp(oldMenuName, framePtr->menuName) != 0))
&& framePtr->type == TYPE_TOPLEVEL) {
- TkSetWindowMenuBar(interp, framePtr->tkwin, oldMenuName,
+ Tk_SetWindowMenubar(interp, framePtr->tkwin, oldMenuName,
framePtr->menuName);
}
@@ -1111,6 +1167,15 @@ FrameWorldChanged(
anyWindowLabel = (framePtr->type == TYPE_LABELFRAME) &&
(labelframePtr->labelWin != NULL);
+#ifndef TK_NO_DOUBLE_BUFFERING
+ gcValues.graphics_exposures = False;
+ gc = Tk_GetGC(tkwin, GCGraphicsExposures, &gcValues);
+ if (framePtr->copyGC != NULL) {
+ Tk_FreeGC(framePtr->display, framePtr->copyGC);
+ }
+ framePtr->copyGC = gc;
+#endif /* TK_NO_DOUBLE_BUFFERING */
+
if (framePtr->type == TYPE_LABELFRAME) {
/*
* The textGC is needed even in the labelWin case, so it's always
@@ -1138,7 +1203,7 @@ FrameWorldChanged(
Tk_FreeTextLayout(labelframePtr->textLayout);
labelframePtr->textLayout =
Tk_ComputeTextLayout(labelframePtr->tkfont,
- labelText, -1, 0, TK_JUSTIFY_CENTER, 0,
+ labelText, TCL_INDEX_NONE, 0, TK_JUSTIFY_CENTER, 0,
&labelframePtr->labelReqWidth,
&labelframePtr->labelReqHeight);
labelframePtr->labelReqWidth += 2 * LABELSPACING;
@@ -1439,10 +1504,10 @@ DisplayFrame(
if (framePtr->flags & GOT_FOCUS) {
fgGC = Tk_GCForColor(framePtr->highlightColorPtr,
Tk_WindowId(tkwin));
- TkpDrawHighlightBorder(tkwin, fgGC, bgGC, hlWidth,
+ Tk_DrawHighlightBorder(tkwin, fgGC, bgGC, hlWidth,
Tk_WindowId(tkwin));
} else {
- TkpDrawHighlightBorder(tkwin, bgGC, bgGC, hlWidth,
+ Tk_DrawHighlightBorder(tkwin, bgGC, bgGC, hlWidth,
Tk_WindowId(tkwin));
}
}
@@ -1455,6 +1520,24 @@ DisplayFrame(
return;
}
+#ifndef TK_NO_DOUBLE_BUFFERING
+ /*
+ * In order to avoid screen flashes, this function redraws the frame into
+ * off-screen memory, then copies it back on-screen in a single operation.
+ * This means there's no point in time where the on-screen image has been
+ * cleared.
+ * Also, ensure that the pixmap size is at least 1x1 pixels to prevent
+ * crashes, see [610aa08858].
+ */
+
+ pixmap = Tk_GetPixmap(framePtr->display, Tk_WindowId(tkwin),
+ (Tk_Width(tkwin) > 0 ? Tk_Width(tkwin) : 1),
+ (Tk_Height(tkwin) > 0 ? Tk_Height(tkwin) : 1),
+ Tk_Depth(tkwin));
+#else
+ pixmap = Tk_WindowId(tkwin);
+#endif /* TK_NO_DOUBLE_BUFFERING */
+
if (framePtr->type != TYPE_LABELFRAME) {
/*
* Pass to platform specific draw function. In general, it just draws
@@ -1462,8 +1545,12 @@ DisplayFrame(
*/
noLabel:
- TkpDrawFrame(tkwin, framePtr->border, hlWidth,
+ TkpDrawFrameEx(tkwin, pixmap, framePtr->border, hlWidth,
framePtr->borderWidth, framePtr->relief);
+ if (framePtr->bgimg) {
+ DrawFrameBackground(tkwin, pixmap, hlWidth, framePtr->borderWidth,
+ framePtr->bgimg, framePtr->tile);
+ }
} else {
Labelframe *labelframePtr = (Labelframe *) framePtr;
@@ -1472,20 +1559,6 @@ DisplayFrame(
goto noLabel;
}
-#ifndef TK_NO_DOUBLE_BUFFERING
- /*
- * In order to avoid screen flashes, this function redraws the frame
- * into off-screen memory, then copies it back on-screen in a single
- * operation. This means there's no point in time where the on-screen
- * image has been cleared.
- */
-
- pixmap = Tk_GetPixmap(framePtr->display, Tk_WindowId(tkwin),
- Tk_Width(tkwin), Tk_Height(tkwin), Tk_Depth(tkwin));
-#else
- pixmap = Tk_WindowId(tkwin);
-#endif /* TK_NO_DOUBLE_BUFFERING */
-
/*
* Clear the pixmap.
*/
@@ -1594,22 +1667,54 @@ DisplayFrame(
labelframePtr->labelBox.height);
}
}
+ }
#ifndef TK_NO_DOUBLE_BUFFERING
- /*
- * Everything's been redisplayed; now copy the pixmap onto the screen
- * and free up the pixmap.
- */
+ /*
+ * Everything's been redisplayed; now copy the pixmap onto the screen and
+ * free up the pixmap.
+ */
- XCopyArea(framePtr->display, pixmap, Tk_WindowId(tkwin),
- labelframePtr->textGC, hlWidth, hlWidth,
- (unsigned) (Tk_Width(tkwin) - 2 * hlWidth),
- (unsigned) (Tk_Height(tkwin) - 2 * hlWidth),
- hlWidth, hlWidth);
- Tk_FreePixmap(framePtr->display, pixmap);
+ XCopyArea(framePtr->display, pixmap, Tk_WindowId(tkwin),
+ framePtr->copyGC, hlWidth, hlWidth,
+ (unsigned) (Tk_Width(tkwin) - 2 * hlWidth),
+ (unsigned) (Tk_Height(tkwin) - 2 * hlWidth),
+ hlWidth, hlWidth);
+ Tk_FreePixmap(framePtr->display, pixmap);
#endif /* TK_NO_DOUBLE_BUFFERING */
- }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkpDrawFrame --
+ *
+ * This procedure draws the rectangular frame area.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Draws inside the tkwin area.
+ *
+ *----------------------------------------------------------------------
+ */
+void
+TkpDrawFrame(
+ Tk_Window tkwin,
+ Tk_3DBorder border,
+ int highlightWidth,
+ int borderWidth,
+ int relief)
+{
+ /*
+ * Legacy shim to allow for external callers. Internal ones use
+ * non-exposed TkpDrawFrameEx directly so they can use double-buffering.
+ */
+
+ TkpDrawFrameEx(tkwin, Tk_WindowId(tkwin), border,
+ highlightWidth, borderWidth, relief);
}
/*
@@ -1645,7 +1750,7 @@ FrameEventProc(
goto redraw;
} else if (eventPtr->type == DestroyNotify) {
if (framePtr->menuName != NULL) {
- TkSetWindowMenuBar(framePtr->interp, framePtr->tkwin,
+ Tk_SetWindowMenubar(framePtr->interp, framePtr->tkwin,
framePtr->menuName, NULL);
ckfree(framePtr->menuName);
framePtr->menuName = NULL;
@@ -1694,7 +1799,7 @@ FrameEventProc(
}
}
} else if (eventPtr->type == ActivateNotify) {
- TkpSetMainMenubar(framePtr->interp, framePtr->tkwin,
+ Tk_SetMainMenubar(framePtr->interp, framePtr->tkwin,
framePtr->menuName);
}
return;
@@ -1732,7 +1837,7 @@ FrameCmdDeletedProc(
Tk_Window tkwin = framePtr->tkwin;
if (framePtr->menuName != NULL) {
- TkSetWindowMenuBar(framePtr->interp, framePtr->tkwin,
+ Tk_SetWindowMenubar(framePtr->interp, framePtr->tkwin,
framePtr->menuName, NULL);
ckfree(framePtr->menuName);
framePtr->menuName = NULL;
@@ -1929,7 +2034,7 @@ FrameRequestProc(
static void
FrameLostContentProc(
- void *clientData, /* Frame structure for content window that was
+ void *clientData, /* Frame structure for content window window that was
* stolen away. */
TCL_UNUSED(Tk_Window)) /* Tk's handle for the content window window. */
{
@@ -1964,7 +2069,7 @@ TkMapTopFrame(
framePtr->type = TYPE_TOPLEVEL;
Tcl_DoWhenIdle(MapFrame, framePtr);
if (framePtr->menuName != NULL) {
- TkSetWindowMenuBar(framePtr->interp, framePtr->tkwin, NULL,
+ Tk_SetWindowMenubar(framePtr->interp, framePtr->tkwin, NULL,
framePtr->menuName);
}
} else if (!Tk_IsTopLevel(tkwin) && framePtr->type == TYPE_TOPLEVEL) {
@@ -2029,6 +2134,129 @@ TkToplevelWindowForCommand(
}
/*
+ *----------------------------------------------------------------------
+ *
+ * FrameBgImageProc --
+ *
+ * This function is invoked by the image code whenever the manager for an
+ * image does something that affects the size or contents of an image
+ * displayed on a frame's background.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Arranges for the button to get redisplayed.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+FrameBgImageProc(
+ void *clientData, /* Pointer to widget record. */
+ TCL_UNUSED(int), /* Upper left pixel (within image) that must */
+ TCL_UNUSED(int), /* be redisplayed. */
+ TCL_UNUSED(int), /* Dimensions of area to redisplay (might be */
+ TCL_UNUSED(int), /* <= 0). */
+ TCL_UNUSED(int), /* New dimensions of image. */
+ TCL_UNUSED(int))
+{
+ Frame *framePtr = (Frame *)clientData;
+
+ /*
+ * Changing the background image never alters the dimensions of the frame.
+ */
+
+ if (framePtr->tkwin && Tk_IsMapped(framePtr->tkwin) &&
+ !(framePtr->flags & REDRAW_PENDING)) {
+ Tcl_DoWhenIdle(DisplayFrame, framePtr);
+ framePtr->flags |= REDRAW_PENDING;
+ }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * DrawFrameBackground --
+ *
+ * This function draws the background image of a rectangular frame area.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Draws inside the tkwin area.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+DrawFrameBackground(
+ Tk_Window tkwin,
+ Pixmap pixmap,
+ int highlightWidth,
+ int borderWidth,
+ Tk_Image bgimg,
+ int bgtile)
+{
+ int width, height; /* Area to paint on. */
+ int imageWidth, imageHeight; /* Dimensions of image. */
+ const int bw = highlightWidth + borderWidth;
+
+ Tk_SizeOfImage(bgimg, &imageWidth, &imageHeight);
+ width = Tk_Width(tkwin) - 2*bw;
+ height = Tk_Height(tkwin) - 2*bw;
+
+ if (bgtile) {
+ /*
+ * Draw the image tiled in the widget (inside the border).
+ */
+
+ int x, y;
+
+ for (x = bw; x - bw < width; x += imageWidth) {
+ int w = imageWidth;
+ if (x - bw + imageWidth > width) {
+ w = (width + bw) - x;
+ }
+ for (y = bw; y < height + bw; y += imageHeight) {
+ int h = imageHeight;
+ if (y - bw + imageHeight > height) {
+ h = (height + bw) - y;
+ }
+ Tk_RedrawImage(bgimg, 0, 0, w, h, pixmap, x, y);
+ }
+ }
+ } else {
+ /*
+ * Draw the image centred in the widget (inside the border).
+ */
+
+ int x, y, xOff, yOff, w, h;
+
+ if (width > imageWidth) {
+ x = 0;
+ xOff = (Tk_Width(tkwin) - imageWidth) / 2;
+ w = imageWidth;
+ } else {
+ x = (imageWidth - width) / 2;
+ xOff = bw;
+ w = width;
+ }
+ if (height > imageHeight) {
+ y = 0;
+ yOff = (Tk_Height(tkwin) - imageHeight) / 2;
+ h = imageHeight;
+ } else {
+ y = (imageHeight - height) / 2;
+ yOff = bw;
+ h = height;
+ }
+ Tk_RedrawImage(bgimg, x, y, w, h, pixmap, xOff, yOff);
+ }
+}
+
+/*
* Local Variables:
* mode: c
* c-basic-offset: 4
diff --git a/generic/tkGC.c b/generic/tkGC.c
index 8744ec4..591e887 100644
--- a/generic/tkGC.c
+++ b/generic/tkGC.c
@@ -4,8 +4,8 @@
* 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.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 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.
@@ -23,7 +23,7 @@
typedef struct {
GC gc; /* Graphics context. */
Display *display; /* Display to which gc belongs. */
- int refCount; /* Number of active uses of gc. */
+ size_t refCount; /* Number of active uses of gc. */
Tcl_HashEntry *valueHashPtr;/* Entry in valueTable (needed when deleting
* this structure). */
} TkGC;
@@ -307,7 +307,7 @@ Tk_FreeGC(
return;
}
- idHashPtr = Tcl_FindHashEntry(&dispPtr->gcIdTable, (char *) gc);
+ idHashPtr = Tcl_FindHashEntry(&dispPtr->gcIdTable, gc);
if (idHashPtr == NULL) {
Tcl_Panic("Tk_FreeGC received unknown gc argument");
}
diff --git a/generic/tkGeometry.c b/generic/tkGeometry.c
index 6e61361..b34e3ba 100644
--- a/generic/tkGeometry.c
+++ b/generic/tkGeometry.c
@@ -4,8 +4,8 @@
* 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.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 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.
@@ -53,10 +53,10 @@ typedef struct MaintainContainer {
* Prototypes for static procedures in this file:
*/
-static void MaintainCheckProc(ClientData clientData);
-static void MaintainContainerProc(ClientData clientData,
+static void MaintainCheckProc(void *clientData);
+static void MaintainContainerProc(void *clientData,
XEvent *eventPtr);
-static void MaintainContentProc(ClientData clientData,
+static void MaintainContentProc(void *clientData,
XEvent *eventPtr);
/*
@@ -75,7 +75,7 @@ static void MaintainContentProc(ClientData clientData,
* 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.
+ * from the new one, it is notified by calling its lostContentProc.
*
*--------------------------------------------------------------
*/
@@ -87,7 +87,7 @@ Tk_ManageGeometry(
const Tk_GeomMgr *mgrPtr, /* Static structure describing the geometry
* manager. This structure must never go
* away. */
- ClientData clientData) /* Arbitrary one-word argument to pass to
+ void *clientData) /* Arbitrary one-word argument to pass to
* geometry manager procedures. */
{
TkWindow *winPtr = (TkWindow *) tkwin;
@@ -95,8 +95,8 @@ Tk_ManageGeometry(
if ((winPtr->geomMgrPtr != NULL) && (mgrPtr != NULL)
&& ((winPtr->geomMgrPtr != mgrPtr)
|| (winPtr->geomData != clientData))
- && (winPtr->geomMgrPtr->lostSlaveProc != NULL)) {
- winPtr->geomMgrPtr->lostSlaveProc(winPtr->geomData, tkwin);
+ && (winPtr->geomMgrPtr->lostContentProc != NULL)) {
+ winPtr->geomMgrPtr->lostContentProc(winPtr->geomData, tkwin);
}
winPtr->geomMgrPtr = mgrPtr;
@@ -333,10 +333,10 @@ TkSetGeometryContainer(
if (winPtr->geomMgrName != NULL) {
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "cannot use geometry manager %s inside %s which already"
- " has slaves managed by %s",
+ "cannot use geometry manager %s inside %s because"
+ " %s is already managing it's content windows",
name, Tk_PathName(tkwin), winPtr->geomMgrName));
- Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "FIGHT", NULL);
+ Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "FIGHT", (char *)NULL);
}
return TCL_ERROR;
}
@@ -654,7 +654,7 @@ Tk_UnmaintainGeometry(
static void
MaintainContainerProc(
- ClientData clientData, /* Pointer to MaintainContainer structure for the
+ void *clientData, /* Pointer to MaintainContainer structure for the
* container window. */
XEvent *eventPtr) /* Describes what just happened. */
{
@@ -708,7 +708,7 @@ MaintainContainerProc(
static void
MaintainContentProc(
- ClientData clientData, /* Pointer to MaintainContent structure for
+ void *clientData, /* Pointer to MaintainContent structure for
* container-window pair. */
XEvent *eventPtr) /* Describes what just happened. */
{
@@ -741,7 +741,7 @@ MaintainContentProc(
static void
MaintainCheckProc(
- ClientData clientData) /* Pointer to MaintainContainer structure for the
+ void *clientData) /* Pointer to MaintainContainer structure for the
* container window. */
{
MaintainContainer *containerPtr = (MaintainContainer *)clientData;
diff --git a/generic/tkGet.c b/generic/tkGet.c
index 65a16ae..f109582 100644
--- a/generic/tkGet.c
+++ b/generic/tkGet.c
@@ -6,8 +6,8 @@
* functions, like Tk_GetDirection and Tk_GetUid. The more complex
* functions like Tk_GetColor are in separate files.
*
- * Copyright (c) 1991-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1991-1994 The Regents of the University of California.
+ * Copyright © 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.
@@ -28,17 +28,17 @@ typedef struct {
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;
-static void FreeUidThreadExitProc(ClientData clientData);
+static void FreeUidThreadExitProc(void *clientData);
/*
* The following tables defines the string values for reliefs, which are
* used by Tk_GetAnchorFromObj and Tk_GetJustifyFromObj.
*/
-static const char *const anchorStrings[] = {
+const char *const tkAnchorStrings[] = {
"n", "ne", "e", "se", "s", "sw", "w", "nw", "center", NULL
};
-static const char *const justifyStrings[] = {
+const char *const tkJustifyStrings[] = {
"left", "right", "center", NULL
};
@@ -71,7 +71,7 @@ Tk_GetAnchorFromObj(
{
int index, code;
- code = Tcl_GetIndexFromObj(interp, objPtr, anchorStrings, "anchor", 0,
+ code = Tcl_GetIndexFromObj(interp, objPtr, tkAnchorStrings, "anchor", 0,
&index);
if (code == TCL_OK) {
*anchorPtr = (Tk_Anchor) index;
@@ -155,7 +155,7 @@ Tk_GetAnchor(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad anchor position \"%s\": must be"
" n, ne, e, se, s, sw, w, nw, or center", string));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "ANCHOR", NULL);
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "ANCHOR", (char *)NULL);
return TCL_ERROR;
}
@@ -190,6 +190,7 @@ Tk_NameOfAnchor(
case TK_ANCHOR_W: return "w";
case TK_ANCHOR_NW: return "nw";
case TK_ANCHOR_CENTER: return "center";
+ case TK_ANCHOR_NULL: return "";
}
return "unknown anchor position";
}
@@ -242,7 +243,7 @@ Tk_GetJoinStyle(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad join style \"%s\": must be bevel, miter, or round",
string));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "JOIN", NULL);
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "JOIN", (char *)NULL);
return TCL_ERROR;
}
@@ -323,7 +324,7 @@ Tk_GetCapStyle(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad cap style \"%s\": must be butt, projecting, or round",
string));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "CAP", NULL);
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "CAP", (char *)NULL);
return TCL_ERROR;
}
@@ -385,7 +386,7 @@ Tk_GetJustifyFromObj(
{
int index, code;
- code = Tcl_GetIndexFromObj(interp, objPtr, justifyStrings,
+ code = Tcl_GetIndexFromObj(interp, objPtr, tkJustifyStrings,
"justification", 0, &index);
if (code == TCL_OK) {
*justifyPtr = (Tk_Justify) index;
@@ -441,7 +442,7 @@ Tk_GetJustify(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad justification \"%s\": must be left, right, or center",
string));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "JUSTIFY", NULL);
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "JUSTIFY", (char *)NULL);
return TCL_ERROR;
}
@@ -471,7 +472,7 @@ Tk_NameOfJustify(
case TK_JUSTIFY_LEFT: return "left";
case TK_JUSTIFY_RIGHT: return "right";
case TK_JUSTIFY_CENTER: return "center";
- default: break;
+ case TK_JUSTIFY_NULL: return "";
}
return "unknown justification style";
}
@@ -531,7 +532,7 @@ Tk_GetUid(
{
int dummy;
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
- Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
Tcl_HashTable *tablePtr = &tsdPtr->uidTable;
if (!tsdPtr->initialized) {
@@ -572,53 +573,63 @@ Tk_GetScreenMM(
const char *string, /* String describing a screen distance. */
double *doublePtr) /* Place to store converted result. */
{
- char *end;
+ const char *rest;
double d;
-
- d = strtod(string, &end);
- if (end == string) {
- goto error;
- }
- while ((*end != '\0') && isspace(UCHAR(*end))) {
- end++;
- }
- switch (*end) {
- case 0:
+ Tcl_DString ds;
+
+ if (Tcl_GetDouble(NULL, string, &d) == TCL_OK) {
+ if (!tkwin) {
+ if (interp != NULL) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("bad screen", -1));
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "SCREEN_DISTANCE", (char *)NULL);
+ }
+ return TCL_ERROR;
+ }
d /= WidthOfScreen(Tk_Screen(tkwin));
d *= WidthMMOfScreen(Tk_Screen(tkwin));
- break;
+ *doublePtr = d;
+ return TCL_OK;
+ }
+ rest = string + strlen(string);
+ while ((rest > string) && isspace(UCHAR(rest[-1]))) {
+ --rest; /* skip all spaces at the end */
+ }
+ if (rest > string) {
+ --rest; /* point to the character just before the last space */
+ }
+ if (rest == string) {
+ error:
+ if (interp != NULL) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "expected screen distance or \"\" but got \"%.50s\"", string));
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "PIXELS", (char *)NULL);
+ }
+ return TCL_ERROR;
+ }
+ Tcl_DStringInit(&ds);
+ Tcl_DStringAppend(&ds, string, rest-string);
+ if (Tcl_GetDouble(NULL, Tcl_DStringValue(&ds), &d) != TCL_OK) {
+ Tcl_DStringFree(&ds);
+ goto error;
+ }
+ Tcl_DStringFree(&ds);
+ switch (*rest) {
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;
-
- error:
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "bad screen distance \"%s\"", string));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "SCREEN_DISTANCE", NULL);
- return TCL_ERROR;
}
/*
@@ -692,61 +703,66 @@ TkGetDoublePixels(
const char *string, /* String describing a number of pixels. */
double *doublePtr) /* Place to store converted result. */
{
- char *end;
+ const char *rest;
double d;
+ Tcl_DString ds;
+ if (Tcl_GetDouble(NULL, string, &d) == TCL_OK) {
+ *doublePtr = d;
+ return TCL_OK;
+ }
if (!tkwin) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad screen"));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "FRACTIONAL_PIXELS", NULL);
+ if (interp != NULL) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("bad screen", -1));
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "FRACTIONAL_PIXELS", (char *)NULL);
+ }
return TCL_ERROR;
}
- d = strtod((char *) string, &end);
- if (end == string) {
- goto error;
+ rest = string + strlen(string);
+ while ((rest > string) && isspace(UCHAR(rest[-1]))) {
+ --rest; /* skip all spaces at the end */
}
- while ((*end != '\0') && isspace(UCHAR(*end))) {
- end++;
+ if (rest > string) {
+ --rest; /* point to the character just before the last space */
}
- switch (*end) {
- case 0:
- break;
+ if (rest == string) {
+ error:
+ if (interp != NULL) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "expected screen distance but got \"%.50s\"", string));
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "PIXELS", (char *)NULL);
+ }
+ return TCL_ERROR;
+ }
+ Tcl_DStringInit(&ds);
+ Tcl_DStringAppend(&ds, string, rest-string);
+ if (Tcl_GetDouble(NULL, Tcl_DStringValue(&ds), &d) != TCL_OK) {
+ Tcl_DStringFree(&ds);
+ goto error;
+ }
+ Tcl_DStringFree(&ds);
+ switch (*rest) {
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;
- }
*doublePtr = d;
return TCL_OK;
-
- error:
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "bad screen distance \"%s\"", string));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "FRACTIONAL_PIXELS", NULL);
- return TCL_ERROR;
}
/*
diff --git a/generic/tkGrab.c b/generic/tkGrab.c
index 2232ba5..5a25dea 100644
--- a/generic/tkGrab.c
+++ b/generic/tkGrab.c
@@ -3,8 +3,8 @@
*
* This file provides functions that implement grabs for Tk.
*
- * Copyright (c) 1992-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1992-1994 The Regents of the University of California.
+ * Copyright © 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.
@@ -170,7 +170,7 @@ static void ReleaseButtonGrab(TkDisplay *dispPtr);
int
Tk_GrabObjCmd(
- ClientData clientData, /* Main window associated with interpreter. */
+ void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -180,7 +180,7 @@ Tk_GrabObjCmd(
TkDisplay *dispPtr;
const char *arg;
int index;
- int len;
+ Tcl_Size len;
static const char *const optionStrings[] = {
"current", "release", "set", "status", NULL
};
@@ -272,7 +272,7 @@ Tk_GrabObjCmd(
}
dispPtr = ((TkWindow *) tkwin)->dispPtr;
if (dispPtr->eventualGrabWinPtr != NULL) {
- Tcl_SetObjResult(interp, TkNewWindowObj((Tk_Window)
+ Tcl_SetObjResult(interp, Tk_NewWindowObj((Tk_Window)
dispPtr->eventualGrabWinPtr));
}
} else {
@@ -281,7 +281,7 @@ Tk_GrabObjCmd(
for (dispPtr = TkGetDisplayList(); dispPtr != NULL;
dispPtr = dispPtr->nextPtr) {
if (dispPtr->eventualGrabWinPtr != NULL) {
- Tcl_ListObjAppendElement(NULL, resultObj, TkNewWindowObj(
+ Tcl_ListObjAppendElement(NULL, resultObj, Tk_NewWindowObj(
(Tk_Window) dispPtr->eventualGrabWinPtr));
}
}
@@ -357,7 +357,7 @@ Tk_GrabObjCmd(
} else {
statusString = "local";
}
- Tcl_SetObjResult(interp, Tcl_NewStringObj(statusString, -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(statusString, TCL_INDEX_NONE));
break;
}
}
@@ -523,20 +523,20 @@ Tk_Grab(
grabError:
if (grabResult == GrabNotViewable) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "grab failed: window not viewable", -1));
+ "grab failed: window not viewable", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "GRAB", "UNVIEWABLE", NULL);
} else if (grabResult == AlreadyGrabbed) {
alreadyGrabbed:
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "grab failed: another application has grab", -1));
+ "grab failed: another application has grab", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "GRAB", "GRABBED", NULL);
} else if (grabResult == GrabFrozen) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "grab failed: keyboard or pointer frozen", -1));
+ "grab failed: keyboard or pointer frozen", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "GRAB", "FROZEN", NULL);
} else if (grabResult == GrabInvalidTime) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "grab failed: invalid time", -1));
+ "grab failed: invalid time", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "GRAB", "BAD_TIME", NULL);
} else {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
@@ -668,6 +668,9 @@ ReleaseButtonGrab(
* This function is called for each pointer-related event, before the
* event has been processed. It does various things to make grabs work
* correctly.
+ * Also, this function takes care of warping the mouse pointer with
+ * respect to a given window, both when there is a grab in effect and
+ * when there is none.
*
* Results:
* If the return value is 1 it means the event should be processed (event
@@ -679,6 +682,7 @@ ReleaseButtonGrab(
* 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.
+ * The mouse pointer may be moved.
*
*----------------------------------------------------------------------
*/
@@ -775,10 +779,24 @@ TkPointerEvent(
return 1;
}
+ if ((eventPtr->type == MotionNotify) && !appGrabbed) {
+
+ /*
+ * Warp the mouse pointer with respect to window dispPtr->warpWindow
+ * if such a window was set in HandleEventGenerate.
+ */
+
+ TkDoWarpWrtWin(dispPtr);
+ }
+
if (!appGrabbed) {
return 1;
}
+ /*
+ * From this point on, there is a grab in effect.
+ */
+
if (eventPtr->type == MotionNotify) {
/*
* When grabs are active, X reports motion events relative to the
@@ -801,6 +819,13 @@ TkPointerEvent(
Tk_QueueWindowEvent(eventPtr, TCL_QUEUE_HEAD);
return 0;
}
+
+ /*
+ * Warp the mouse pointer with respect to window dispPtr->warpWindow
+ * if such a window was set in HandleEventGenerate.
+ */
+
+ TkDoWarpWrtWin(dispPtr);
return 1;
}
@@ -873,7 +898,7 @@ TkPointerEvent(
} else {
if (eventPtr->xbutton.button != AnyButton &&
((eventPtr->xbutton.state & ALL_BUTTONS)
- == TkGetButtonMask(eventPtr->xbutton.button))) {
+ == Tk_GetButtonMask(eventPtr->xbutton.button))) {
ReleaseButtonGrab(dispPtr); /* Note 4. */
}
}
@@ -1243,7 +1268,7 @@ EatGrabEvents(
{
Tk_RestrictProc *prevProc;
GrabInfo info;
- ClientData prevArg;
+ void *prevArg;
info.display = dispPtr->display;
info.serial = serial;
@@ -1276,7 +1301,7 @@ EatGrabEvents(
static Tk_RestrictAction
GrabRestrictProc(
- ClientData arg,
+ void *arg,
XEvent *eventPtr)
{
GrabInfo *info = (GrabInfo *)arg;
diff --git a/generic/tkGrid.c b/generic/tkGrid.c
index b58acdc..50068b5 100644
--- a/generic/tkGrid.c
+++ b/generic/tkGrid.c
@@ -3,7 +3,7 @@
*
* Grid based geometry manager.
*
- * Copyright (c) 1996-1997 Sun Microsystems, Inc.
+ * Copyright © 1996-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.
@@ -255,45 +255,45 @@ typedef struct UniformGroup {
static void AdjustForSticky(Gridder *contentPtr, int *xPtr,
int *yPtr, int *widthPtr, int *heightPtr);
-static int AdjustOffsets(int width, int elements,
+static int AdjustOffsets(int width, Tcl_Size elements,
SlotInfo *slotPtr);
-static void ArrangeGrid(ClientData clientData);
-static int CheckSlotData(Gridder *containerPtr, int slot,
+static void ArrangeGrid(void *clientData);
+static int CheckSlotData(Gridder *containerPtr, Tcl_Size slot,
int slotType, int checkOnly);
static int ConfigureContent(Tcl_Interp *interp, Tk_Window tkwin,
- int objc, Tcl_Obj *const objv[]);
+ Tcl_Size objc, Tcl_Obj *const objv[]);
static Tcl_FreeProc DestroyGrid;
static Gridder * GetGrid(Tk_Window tkwin);
static int GridAnchorCommand(Tk_Window tkwin, Tcl_Interp *interp,
- int objc, Tcl_Obj *const objv[]);
+ Tcl_Size objc, Tcl_Obj *const objv[]);
static int GridBboxCommand(Tk_Window tkwin, Tcl_Interp *interp,
- int objc, Tcl_Obj *const objv[]);
+ Tcl_Size objc, Tcl_Obj *const objv[]);
static int GridForgetRemoveCommand(Tk_Window tkwin,
- Tcl_Interp *interp, int objc,
+ Tcl_Interp *interp, Tcl_Size objc,
Tcl_Obj *const objv[]);
static int GridInfoCommand(Tk_Window tkwin, Tcl_Interp *interp,
- int objc, Tcl_Obj *const objv[]);
+ Tcl_Size objc, Tcl_Obj *const objv[]);
static int GridLocationCommand(Tk_Window tkwin,
- Tcl_Interp *interp, int objc,
+ Tcl_Interp *interp, Tcl_Size objc,
Tcl_Obj *const objv[]);
static int GridPropagateCommand(Tk_Window tkwin,
- Tcl_Interp *interp, int objc,
+ Tcl_Interp *interp, Tcl_Size objc,
Tcl_Obj *const objv[]);
static int GridRowColumnConfigureCommand(Tk_Window tkwin,
- Tcl_Interp *interp, int objc,
+ Tcl_Interp *interp, Tcl_Size objc,
Tcl_Obj *const objv[]);
static int GridSizeCommand(Tk_Window tkwin, Tcl_Interp *interp,
- int objc, Tcl_Obj *const objv[]);
+ Tcl_Size objc, Tcl_Obj *const objv[]);
static int GridContentCommand(Tk_Window tkwin, Tcl_Interp *interp,
- int objc, Tcl_Obj *const objv[]);
-static void GridStructureProc(ClientData clientData,
+ Tcl_Size objc, Tcl_Obj *const objv[]);
+static void GridStructureProc(void *clientData,
XEvent *eventPtr);
-static void GridLostContentProc(ClientData clientData,
+static void GridLostContentProc(void *clientData,
Tk_Window tkwin);
-static void GridReqProc(ClientData clientData, Tk_Window tkwin);
+static void GridReqProc(void *clientData, Tk_Window tkwin);
static void InitContainerData(Gridder *containerPtr);
-static Tcl_Obj * NewPairObj(int, int);
-static Tcl_Obj * NewQuadObj(int, int, int, int);
+static Tcl_Obj * NewPairObj(Tcl_WideInt, Tcl_WideInt);
+static Tcl_Obj * NewQuadObj(Tcl_WideInt, Tcl_WideInt, Tcl_WideInt, Tcl_WideInt);
static int ResolveConstraints(Gridder *gridPtr, int rowOrColumn,
int maxOffset);
static void SetGridSize(Gridder *gridPtr);
@@ -308,7 +308,7 @@ static void Unlink(Gridder *gridPtr);
static const Tk_GeomMgr gridMgrType = {
"grid", /* name */
GridReqProc, /* requestProc */
- GridLostContentProc, /* lostSlaveProc */
+ GridLostContentProc, /* lostContentProc */
};
/*
@@ -330,7 +330,7 @@ static const Tk_GeomMgr gridMgrType = {
int
Tk_GridObjCmd(
- ClientData clientData, /* Main window associated with interpreter. */
+ void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -341,6 +341,11 @@ Tk_GridObjCmd(
"content", "forget", "info", "location", "propagate",
"remove", "rowconfigure", "size", "slaves", NULL
};
+ static const char *const optionStringsNoDep[] = {
+ "anchor", "bbox", "columnconfigure", "configure",
+ "content", "forget", "info", "location", "propagate",
+ "remove", "rowconfigure", "size", NULL
+ };
enum options {
GRID_ANCHOR, GRID_BBOX, GRID_COLUMNCONFIGURE, GRID_CONFIGURE,
GRID_CONTENT, GRID_FORGET, GRID_INFO, GRID_LOCATION, GRID_PROPAGATE,
@@ -361,8 +366,16 @@ Tk_GridObjCmd(
return TCL_ERROR;
}
- if (Tcl_GetIndexFromObjStruct(interp, objv[1], optionStrings,
+ if (Tcl_GetIndexFromObjStruct(NULL, objv[1], optionStrings,
sizeof(char *), "option", 0, &index) != TCL_OK) {
+ /*
+ * Call it again without the deprecated ones to get a proper error
+ * message. This works well since there can't be any ambiguity between
+ * deprecated and new options.
+ */
+
+ Tcl_GetIndexFromObjStruct(interp, objv[1], optionStringsNoDep,
+ sizeof(char *), "option", 0, &index);
return TCL_ERROR;
}
@@ -403,7 +416,7 @@ Tk_GridObjCmd(
}
/* This should not happen */
- Tcl_SetObjResult(interp, Tcl_NewStringObj("internal error in grid", -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("internal error in grid", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "API_ABUSE", NULL);
return TCL_ERROR;
}
@@ -429,7 +442,7 @@ static int
GridAnchorCommand(
Tk_Window tkwin, /* Main window of the application. */
Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tk_Window container;
@@ -498,7 +511,7 @@ static int
GridBboxCommand(
Tk_Window tkwin, /* Main window of the application. */
Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tk_Window container;
@@ -511,7 +524,7 @@ GridBboxCommand(
int width, height; /* size of the bounding box */
if (objc!=3 && objc != 5 && objc != 7) {
- Tcl_WrongNumArgs(interp, 2, objv, "master ?column row ?column row??");
+ Tcl_WrongNumArgs(interp, 2, objv, "window ?column row ?column row??");
return TCL_ERROR;
}
@@ -628,12 +641,12 @@ static int
GridForgetRemoveCommand(
Tk_Window tkwin, /* Main window of the application. */
Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tk_Window content;
Gridder *contentPtr;
- int i;
+ Tcl_Size i;
const char *string = Tcl_GetString(objv[1]);
char c = string[0];
@@ -681,7 +694,7 @@ GridForgetRemoveCommand(
}
if (contentPtr->containerPtr != NULL) {
contentPtr->in = Tcl_NewStringObj(
- Tk_PathName(contentPtr->containerPtr->tkwin), -1);
+ Tk_PathName(contentPtr->containerPtr->tkwin), TCL_INDEX_NONE);
Tcl_IncrRefCount(contentPtr->in);
}
}
@@ -718,7 +731,7 @@ static int
GridInfoCommand(
Tk_Window tkwin, /* Main window of the application. */
Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Gridder *contentPtr;
@@ -739,21 +752,21 @@ GridInfoCommand(
}
infoObj = Tcl_NewObj();
- Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-in", -1),
- TkNewWindowObj(contentPtr->containerPtr->tkwin));
- Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-column", -1),
- Tcl_NewIntObj(contentPtr->column));
- Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-row", -1),
- Tcl_NewIntObj(contentPtr->row));
- Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-columnspan", -1),
- Tcl_NewIntObj(contentPtr->numCols));
- Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-rowspan", -1),
- Tcl_NewIntObj(contentPtr->numRows));
+ Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-in", TCL_INDEX_NONE),
+ Tk_NewWindowObj(contentPtr->containerPtr->tkwin));
+ Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-column", TCL_INDEX_NONE),
+ Tcl_NewWideIntObj(contentPtr->column));
+ Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-row", TCL_INDEX_NONE),
+ Tcl_NewWideIntObj(contentPtr->row));
+ Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-columnspan", TCL_INDEX_NONE),
+ Tcl_NewWideIntObj(contentPtr->numCols));
+ Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-rowspan", TCL_INDEX_NONE),
+ Tcl_NewWideIntObj(contentPtr->numRows));
TkAppendPadAmount(infoObj, "-ipadx", contentPtr->iPadX/2, contentPtr->iPadX);
TkAppendPadAmount(infoObj, "-ipady", contentPtr->iPadY/2, contentPtr->iPadY);
TkAppendPadAmount(infoObj, "-padx", contentPtr->padLeft, contentPtr->padX);
TkAppendPadAmount(infoObj, "-pady", contentPtr->padTop, contentPtr->padY);
- Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-sticky", -1),
+ Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-sticky", TCL_INDEX_NONE),
StickyToObj(contentPtr->sticky));
Tcl_SetObjResult(interp, infoObj);
return TCL_OK;
@@ -780,7 +793,7 @@ static int
GridLocationCommand(
Tk_Window tkwin, /* Main window of the application. */
Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tk_Window container;
@@ -792,7 +805,7 @@ GridLocationCommand(
int endX, endY; /* End of grid. */
if (objc != 5) {
- Tcl_WrongNumArgs(interp, 2, objv, "master x y");
+ Tcl_WrongNumArgs(interp, 2, objv, "window x y");
return TCL_ERROR;
}
@@ -809,7 +822,7 @@ GridLocationCommand(
containerPtr = GetGrid(container);
if (containerPtr->containerDataPtr == NULL) {
- Tcl_SetObjResult(interp, NewPairObj(-1, -1));
+ Tcl_SetObjResult(interp, NewPairObj(-1, TCL_INDEX_NONE));
return TCL_OK;
}
gridPtr = containerPtr->containerDataPtr;
@@ -873,7 +886,7 @@ static int
GridPropagateCommand(
Tk_Window tkwin, /* Main window of the application. */
Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tk_Window container;
@@ -961,7 +974,7 @@ static int
GridRowColumnConfigureCommand(
Tk_Window tkwin, /* Main window of the application. */
Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tk_Window container, content;
@@ -970,10 +983,10 @@ GridRowColumnConfigureCommand(
int slot; /* the column or row number */
int slotType; /* COLUMN or ROW */
int size; /* the configuration value */
- int lObjc; /* Number of items in index list */
+ Tcl_Size lObjc; /* Number of items in index list */
Tcl_Obj **lObjv; /* array of indices */
int ok; /* temporary TCL result code */
- int i, j, first, last;
+ Tcl_Size i, j, first, last;
const char *string;
static const char *const optionStrings[] = {
"-minsize", "-pad", "-uniform", "-weight", NULL
@@ -985,7 +998,7 @@ GridRowColumnConfigureCommand(
Tcl_Obj *listCopy;
if (((objc % 2 != 0) && (objc > 6)) || (objc < 4)) {
- Tcl_WrongNumArgs(interp, 2, objv, "master index ?-option value ...?");
+ Tcl_WrongNumArgs(interp, 2, objv, "window index ?-option value ...?");
return TCL_ERROR;
}
@@ -1017,7 +1030,7 @@ GridRowColumnConfigureCommand(
if ((objc == 4) || (objc == 5)) {
if (lObjc != 1) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "must specify a single element on retrieval", -1));
+ "must specify a single element on retrieval", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "GRID", "USAGE", NULL);
Tcl_DecrRefCount(listCopy);
return TCL_ERROR;
@@ -1055,18 +1068,18 @@ GridRowColumnConfigureCommand(
}
Tcl_ListObjAppendElement(interp, res,
- Tcl_NewStringObj("-minsize", -1));
- Tcl_ListObjAppendElement(interp, res, Tcl_NewIntObj(minsize));
+ Tcl_NewStringObj("-minsize", TCL_INDEX_NONE));
+ Tcl_ListObjAppendElement(interp, res, Tcl_NewWideIntObj(minsize));
Tcl_ListObjAppendElement(interp, res,
- Tcl_NewStringObj("-pad", -1));
- Tcl_ListObjAppendElement(interp, res, Tcl_NewIntObj(pad));
+ Tcl_NewStringObj("-pad", TCL_INDEX_NONE));
+ Tcl_ListObjAppendElement(interp, res, Tcl_NewWideIntObj(pad));
Tcl_ListObjAppendElement(interp, res,
- Tcl_NewStringObj("-uniform", -1));
+ Tcl_NewStringObj("-uniform", TCL_INDEX_NONE));
Tcl_ListObjAppendElement(interp, res,
- Tcl_NewStringObj(uniform == NULL ? "" : uniform, -1));
+ Tcl_NewStringObj(uniform == NULL ? "" : uniform, TCL_INDEX_NONE));
Tcl_ListObjAppendElement(interp, res,
- Tcl_NewStringObj("-weight", -1));
- Tcl_ListObjAppendElement(interp, res, Tcl_NewIntObj(weight));
+ Tcl_NewStringObj("-weight", TCL_INDEX_NONE));
+ Tcl_ListObjAppendElement(interp, res, Tcl_NewWideIntObj(weight));
Tcl_SetObjResult(interp, res);
Tcl_DecrRefCount(listCopy);
return TCL_OK;
@@ -1083,18 +1096,18 @@ GridRowColumnConfigureCommand(
return TCL_ERROR;
}
if (index == ROWCOL_MINSIZE) {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(
(ok == TCL_OK) ? slotPtr[slot].minSize : 0));
} else if (index == ROWCOL_WEIGHT) {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(
(ok == TCL_OK) ? slotPtr[slot].weight : 0));
} else if (index == ROWCOL_UNIFORM) {
Tk_Uid value = (ok == TCL_OK) ? slotPtr[slot].uniform : "";
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- (value == NULL) ? "" : value, -1));
+ (value == NULL) ? "" : value, TCL_INDEX_NONE));
} else if (index == ROWCOL_PAD) {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(
(ok == TCL_OK) ? slotPtr[slot].pad : 0));
}
Tcl_DecrRefCount(listCopy);
@@ -1131,7 +1144,7 @@ GridRowColumnConfigureCommand(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"the window \"%s\" is not managed by \"%s\"",
Tcl_GetString(lObjv[j]), Tcl_GetString(objv[2])));
- Tcl_SetErrorCode(interp, "TK", "GRID", "NOT_MASTER", NULL);
+ Tcl_SetErrorCode(interp, "TK", "GRID", "NOT_MANAGED", NULL);
Tcl_DecrRefCount(listCopy);
return TCL_ERROR;
}
@@ -1294,7 +1307,7 @@ static int
GridSizeCommand(
Tk_Window tkwin, /* Main window of the application. */
Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tk_Window container;
@@ -1345,7 +1358,7 @@ static int
GridContentCommand(
Tk_Window tkwin, /* Main window of the application. */
Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tk_Window container;
@@ -1401,7 +1414,7 @@ GridContentCommand(
contentPtr->row+contentPtr->numRows-1 < row)) {
continue;
}
- Tcl_ListObjAppendElement(interp,res, TkNewWindowObj(contentPtr->tkwin));
+ Tcl_ListObjAppendElement(interp,res, Tk_NewWindowObj(contentPtr->tkwin));
}
Tcl_SetObjResult(interp, res);
return TCL_OK;
@@ -1427,7 +1440,7 @@ GridContentCommand(
static void
GridReqProc(
- ClientData clientData, /* Grid's information about window that got
+ void *clientData, /* Grid's information about window that got
* new preferred geometry. */
TCL_UNUSED(Tk_Window)) /* Other Tk-related information about the
* window. */
@@ -1460,7 +1473,7 @@ GridReqProc(
static void
GridLostContentProc(
- ClientData clientData, /* Grid structure for content window that was
+ void *clientData, /* Grid structure for content window that was
* stolen away. */
TCL_UNUSED(Tk_Window)) /* Tk's handle for the content window. */
{
@@ -1496,10 +1509,10 @@ GridLostContentProc(
static int
AdjustOffsets(
int size, /* The total layout size (in pixels). */
- int slots, /* Number of slots. */
+ Tcl_Size slots, /* Number of slots. */
SlotInfo *slotPtr) /* Pointer to slot array. */
{
- int slot; /* Current slot. */
+ Tcl_Size slot; /* Current slot. */
int diff; /* Extra pixels needed to add to the layout. */
int totalWeight; /* Sum of the weights for all the slots. */
int weight; /* Sum of the weights so far. */
@@ -1719,7 +1732,7 @@ AdjustForSticky(
static void
ArrangeGrid(
- ClientData clientData) /* Structure describing container whose content
+ void *clientData) /* Structure describing container whose content
* are to be re-layed out. */
{
Gridder *containerPtr = (Gridder *)clientData;
@@ -2581,7 +2594,7 @@ SetContentRow(
lastRow = ((newRow >= 0) ? newRow : 0) + newNumRows;
if (lastRow >= MAX_ELEMENT) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj("row out of bounds", -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("row out of bounds", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "GRID", "BAD_ROW", NULL);
return TCL_ERROR;
}
@@ -2614,11 +2627,11 @@ SetContentRow(
static int
CheckSlotData(
Gridder *containerPtr, /* The geometry container for this grid. */
- int slot, /* Which slot to look at. */
+ Tcl_Size 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) */
+ Tcl_Size numSlot; /* Number of slots already allocated (Space) */
int end; /* Last used constraint. */
/*
@@ -2777,11 +2790,15 @@ Unlink(
/*
* If we have emptied this container from content it means we are no longer
* handling it and should mark it as free.
+ *
+ * Send the event "NoManagedChild" to the container to inform it about there
+ * being no managed children inside it.
*/
if ((containerPtr->contentPtr == NULL) && (containerPtr->flags & ALLOCED_CONTAINER)) {
TkFreeGeometryContainer(containerPtr->tkwin, "grid");
containerPtr->flags &= ~ALLOCED_CONTAINER;
+ Tk_SendVirtualEvent(containerPtr->tkwin, "NoManagedChild", NULL);
}
}
@@ -2807,7 +2824,11 @@ Unlink(
static void
DestroyGrid(
- char *memPtr) /* Info about window that is now dead. */
+#if TCL_MAJOR_VERSION > 8
+ void *memPtr) /* Info about window that is now dead. */
+#else
+ char *memPtr)
+#endif
{
Gridder *gridPtr = (Gridder *)memPtr;
@@ -2849,7 +2870,7 @@ DestroyGrid(
static void
GridStructureProc(
- ClientData clientData, /* Our information about window referred to by
+ void *clientData, /* Our information about window referred to by
* eventPtr. */
XEvent *eventPtr) /* Describes what just happened. */
{
@@ -2885,7 +2906,7 @@ GridStructureProc(
contentPtr->nextPtr = NULL;
}
Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->gridHashTable,
- (char *)gridPtr->tkwin));
+ gridPtr->tkwin));
if (gridPtr->flags & REQUESTED_RELAYOUT) {
Tcl_CancelIdleCall(ArrangeGrid, gridPtr);
}
@@ -2932,7 +2953,7 @@ ConfigureContent(
Tcl_Interp *interp, /* Interpreter for error reporting. */
Tk_Window tkwin, /* Any window in application containing
* content. Used to look up content names. */
- int objc, /* Number of elements in argv. */
+ Tcl_Size objc, /* Number of elements in argv. */
Tcl_Obj *const objv[]) /* Argument objects: contains one or more
* window names followed by any number of
* "option value" pairs. Caller must make sure
@@ -2969,7 +2990,7 @@ ConfigureContent(
firstChar = 0;
for (numWindows=0, i=0; i < objc; i++) {
- int length;
+ Tcl_Size length;
char prevChar = firstChar;
string = Tcl_GetStringFromObj(objv[i], &length);
@@ -3030,7 +3051,7 @@ ConfigureContent(
if ((firstChar == REL_HORIZ) && ((numWindows == 0) ||
(prevChar == REL_SKIP) || (prevChar == REL_VERT))) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "must specify window before shortcut '-'", -1));
+ "must specify window before shortcut '-'", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "GRID", "SHORTCUT_USAGE", NULL);
return TCL_ERROR;
}
@@ -3050,7 +3071,7 @@ ConfigureContent(
if ((objc - numWindows) & 1) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "extra option or option with no value", -1));
+ "extra option or option with no value", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "GRID", "BAD_PARAMETER", NULL);
return TCL_ERROR;
}
@@ -3203,7 +3224,7 @@ ConfigureContent(
}
if (other == content) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "window can't be managed in itself", -1));
+ "window can't be managed in itself", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "SELF", NULL);
return TCL_ERROR;
}
@@ -3347,7 +3368,7 @@ ConfigureContent(
}
if (Tk_TopWinHierarchy(ancestor)) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "can't put %s inside %s", Tcl_GetString(objv[j]),
+ "can't put \"%s\" inside \"%s\"", Tcl_GetString(objv[j]),
Tk_PathName(containerPtr->tkwin)));
Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "HIERARCHY", NULL);
Unlink(contentPtr);
@@ -3363,7 +3384,7 @@ ConfigureContent(
container = (TkWindow *)TkGetContainer(container)) {
if (container == (TkWindow *)content) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "can't put %s inside %s, would cause management loop",
+ "can't put \"%s\" inside \"%s\": would cause management loop",
Tcl_GetString(objv[j]), Tk_PathName(containerPtr->tkwin)));
Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "LOOP", NULL);
Unlink(contentPtr);
@@ -3448,7 +3469,7 @@ ConfigureContent(
if (containerPtr == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "can't use '^', cant find master", -1));
+ "can't use '^', can't find container window", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "GRID", "SHORTCUT_USAGE", NULL);
return TCL_ERROR;
}
@@ -3502,7 +3523,7 @@ ConfigureContent(
}
if (!match) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "can't find slave to extend with \"^\"", -1));
+ "can't find content to extend with \"^\"", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "GRID", "SHORTCUT_USAGE", NULL);
return TCL_ERROR;
}
@@ -3510,7 +3531,7 @@ ConfigureContent(
if (containerPtr == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "can't determine master window", -1));
+ "can't determine container window", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "GRID", "SHORTCUT_USAGE", NULL);
return TCL_ERROR;
}
@@ -3519,11 +3540,15 @@ ConfigureContent(
/*
* If we have emptied this container from content it means we are no longer
* handling it and should mark it as free.
+ *
+ * Send the event "NoManagedChild" to the container to inform it about there
+ * being no managed children inside it.
*/
if (containerPtr->contentPtr == NULL && containerPtr->flags & ALLOCED_CONTAINER) {
TkFreeGeometryContainer(containerPtr->tkwin, "grid");
containerPtr->flags &= ~ALLOCED_CONTAINER;
+ Tk_SendVirtualEvent(containerPtr->tkwin, "NoManagedChild", NULL);
}
return TCL_OK;
@@ -3634,12 +3659,12 @@ StringToSticky(
static Tcl_Obj *
NewPairObj(
- int val1, int val2)
+ Tcl_WideInt val1, Tcl_WideInt val2)
{
Tcl_Obj *ary[2];
- ary[0] = Tcl_NewIntObj(val1);
- ary[1] = Tcl_NewIntObj(val2);
+ ary[0] = Tcl_NewWideIntObj(val1);
+ ary[1] = Tcl_NewWideIntObj(val2);
return Tcl_NewListObj(2, ary);
}
@@ -3661,14 +3686,14 @@ NewPairObj(
static Tcl_Obj *
NewQuadObj(
- int val1, int val2, int val3, int val4)
+ Tcl_WideInt val1, Tcl_WideInt val2, Tcl_WideInt val3, Tcl_WideInt val4)
{
Tcl_Obj *ary[4];
- ary[0] = Tcl_NewIntObj(val1);
- ary[1] = Tcl_NewIntObj(val2);
- ary[2] = Tcl_NewIntObj(val3);
- ary[3] = Tcl_NewIntObj(val4);
+ ary[0] = Tcl_NewWideIntObj(val1);
+ ary[1] = Tcl_NewWideIntObj(val2);
+ ary[2] = Tcl_NewWideIntObj(val3);
+ ary[3] = Tcl_NewWideIntObj(val4);
return Tcl_NewListObj(4, ary);
}
diff --git a/generic/tkIcu.c b/generic/tkIcu.c
new file mode 100644
index 0000000..503c98d
--- /dev/null
+++ b/generic/tkIcu.c
@@ -0,0 +1,322 @@
+/*
+ * tkIcu.c --
+ *
+ * tkIcu.c implements various Tk commands which can find
+ * grapheme cluster and workchar bounderies in Unicode strings.
+ *
+ * Copyright © 2021 Jan Nijtmans
+ *
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ */
+
+#include "tkInt.h"
+
+/*
+ * Runtime linking of libicu.
+ */
+typedef enum UBreakIteratorTypex {
+ UBRK_CHARACTERX = 0,
+ UBRK_WORDX = 1
+} UBreakIteratorTypex;
+
+typedef enum UErrorCodex {
+ U_ZERO_ERRORZ = 0 /**< No error, no warning. */
+} UErrorCodex;
+
+typedef void *(*fn_icu_open)(UBreakIteratorTypex, const char *,
+ const uint16_t *, int32_t, UErrorCodex *);
+typedef void (*fn_icu_close)(void *);
+typedef int32_t (*fn_icu_preceding)(void *, int32_t);
+typedef int32_t (*fn_icu_following)(void *, int32_t);
+typedef int32_t (*fn_icu_previous)(void *);
+typedef int32_t (*fn_icu_next)(void *);
+typedef void (*fn_icu_setText)(void *, const void *, int32_t, UErrorCodex *);
+
+static struct {
+ size_t nopen;
+ Tcl_LoadHandle lib;
+ fn_icu_open open;
+ fn_icu_close close;
+ fn_icu_preceding preceding;
+ fn_icu_following following;
+ fn_icu_previous previous;
+ fn_icu_next next;
+ fn_icu_setText setText;
+} icu_fns = {
+ 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
+};
+
+#define FLAG_WORD 1
+#define FLAG_FOLLOWING 4
+#define FLAG_SPACE 8
+
+#define icu_open icu_fns.open
+#define icu_close icu_fns.close
+#define icu_preceding icu_fns.preceding
+#define icu_following icu_fns.following
+#define icu_previous icu_fns.previous
+#define icu_next icu_fns.next
+#define icu_setText icu_fns.setText
+
+TCL_DECLARE_MUTEX(icu_mutex);
+
+static int
+startEndOfCmd(
+ void *clientData,
+ Tcl_Interp *interp,
+ int objc,
+ Tcl_Obj *const objv[])
+{
+ Tcl_DString ds;
+ Tcl_Size len;
+ const char *str;
+ UErrorCodex errorCode = U_ZERO_ERRORZ;
+ void *it;
+ Tcl_Size idx;
+ int flags = PTR2INT(clientData);
+ const uint16_t *ustr;
+ const char *locale = NULL;
+
+ if ((unsigned)(objc - 3) > 1) {
+ Tcl_WrongNumArgs(interp, 1 , objv, "str start ?locale?");
+ return TCL_ERROR;
+ }
+ if (objc > 3) {
+ locale = Tcl_GetString(objv[3]);
+ if (!*locale) {
+ locale = NULL;
+ }
+ }
+ Tcl_DStringInit(&ds);
+ str = Tcl_GetStringFromObj(objv[1], &len);
+ Tcl_UtfToChar16DString(str, len, &ds);
+ len = Tcl_DStringLength(&ds)/2;
+ Tcl_Size ulen = TkGetCharLength(objv[1]);
+ if (TkGetIntForIndex(objv[2], ulen-1, 0, &idx) != TCL_OK) {
+ Tcl_DStringFree(&ds);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad index \"%s\": must be integer?[+-]integer?, end?[+-]integer?, or \"\"", Tcl_GetString(objv[2])));
+ Tcl_SetErrorCode(interp, "TK", "ICU", "INDEX", (char *)NULL);
+ return TCL_ERROR;
+ }
+ it = icu_open((UBreakIteratorTypex)(flags&3), locale,
+ NULL, -1, &errorCode);
+ if (it != NULL) {
+ errorCode = U_ZERO_ERRORZ;
+ ustr = (const uint16_t *)Tcl_DStringValue(&ds);
+ icu_setText(it, ustr, len, &errorCode);
+ }
+ if (it == NULL || errorCode != U_ZERO_ERRORZ) {
+ Tcl_DStringFree(&ds);
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("cannot open ICU iterator, errorcode: %d", (int)errorCode));
+ Tcl_SetErrorCode(interp, "TK", "ICU", "CANNOTOPEN", (char *)NULL);
+ return TCL_ERROR;
+ }
+ if (idx > 0 && len != ulen) {
+ /* The string contains codepoints > \uFFFF. Determine UTF-16 index */
+ Tcl_Size newIdx = 0;
+ for (Tcl_Size i = 0; i < idx; i++) {
+ newIdx += 1 + (((newIdx < (Tcl_Size)len-1) && (ustr[newIdx]&0xFC00) == 0xD800) && ((ustr[newIdx+1]&0xFC00) == 0xDC00));
+ }
+ idx = newIdx;
+ }
+ if (flags & FLAG_FOLLOWING) {
+ if ((idx < 0) && (flags & FLAG_WORD)) {
+ idx = 0;
+ }
+ idx = icu_following(it, idx);
+ if ((flags & FLAG_WORD) && idx >= len) {
+ idx = -1;
+ }
+ } else if (idx > 0) {
+ if (!(flags & FLAG_WORD)) {
+ idx += 1 + (((ustr[idx]&0xFC00) == 0xD800) && ((ustr[idx+1]&0xFC00) == 0xDC00));
+ }
+ idx = icu_preceding(it, idx);
+ if (idx == 0 && (flags & FLAG_WORD)) {
+ flags &= ~FLAG_WORD; /* If 0 is reached here, don't do a further search */
+ }
+ }
+ if ((flags & FLAG_WORD) && (idx != TCL_INDEX_NONE)) {
+ if (!(flags & FLAG_SPACE) == ((idx >= len) || Tcl_UniCharIsSpace(ustr[idx]))) {
+ if (flags & FLAG_FOLLOWING) {
+ idx = icu_next(it);
+ if (idx >= len) {
+ idx = TCL_INDEX_NONE;
+ }
+ } else {
+ idx = icu_previous(it);
+ }
+ } else if (idx == 0 && !(flags & FLAG_FOLLOWING)) {
+ idx = TCL_INDEX_NONE;
+ }
+ }
+ icu_close(it);
+ Tcl_DStringFree(&ds);
+ if (idx != TCL_INDEX_NONE) {
+ if (idx > 0 && len != ulen) {
+ /* The string contains codepoints > \uFFFF. Determine UTF-32 index */
+ Tcl_Size newIdx = 1;
+ for (Tcl_Size i = 1; i < idx; i++) {
+ if (((ustr[i-1]&0xFC00) != 0xD800) || ((ustr[i]&0xFC00) != 0xDC00)) newIdx++;
+ }
+ idx = newIdx;
+ }
+ Tcl_SetObjResult(interp, TkNewIndexObj(idx));
+ }
+ return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * SysNotifyDeleteCmd --
+ *
+ * Delete notification and clean up.
+ *
+ * Results:
+ * Window destroyed.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+icuCleanup(
+ TCL_UNUSED(void *))
+{
+ Tcl_MutexLock(&icu_mutex);
+ if (icu_fns.nopen-- <= 1) {
+ if (icu_fns.lib != NULL) {
+ Tcl_FSUnloadFile(NULL, icu_fns.lib);
+ }
+ memset(&icu_fns, 0, sizeof(icu_fns));
+ }
+ Tcl_MutexUnlock(&icu_mutex);
+}
+
+void
+Icu_Init(
+ Tcl_Interp *interp)
+{
+ Tcl_MutexLock(&icu_mutex);
+ char symbol[24];
+ char icuversion[4] = "_80"; /* Highest ICU version + 1 */
+
+ if (icu_fns.nopen == 0) {
+ int i = 0;
+ Tcl_Obj *nameobj;
+ static const char *iculibs[] = {
+#if defined(_WIN32)
+ "icuuc??.dll", /* When running under Windows, user-provided */
+ NULL,
+ "cygicuuc??.dll", /* When running under Cygwin */
+#elif defined(__CYGWIN__)
+ "cygicuuc??.dll",
+#elif defined(MAC_OSX_TCL)
+ "libicuuc.??.dylib",
+#else
+ "libicuuc.so.??",
+#endif
+ NULL
+ };
+
+ /* Going back down to ICU version 60 */
+ while ((icu_fns.lib == NULL) && (icuversion[1] >= '6')) {
+ if (--icuversion[2] < '0') {
+ icuversion[1]--; icuversion[2] = '9';
+ }
+#if defined(_WIN32) && !defined(STATIC_BUILD)
+ if (tclStubsPtr->tcl_CreateFileHandler) {
+ /* Running on Cygwin, so try to load the cygwin icu dll */
+ i = 2;
+ } else
+#endif
+ i = 0;
+ while (iculibs[i] != NULL) {
+ Tcl_ResetResult(interp);
+ nameobj = Tcl_NewStringObj(iculibs[i], TCL_INDEX_NONE);
+ char *nameStr = Tcl_GetString(nameobj);
+ char *p = strchr(nameStr, '?');
+ if (p != NULL) {
+ memcpy(p, icuversion+1, 2);
+ }
+ Tcl_IncrRefCount(nameobj);
+ if (Tcl_LoadFile(interp, nameobj, NULL, 0, NULL, &icu_fns.lib)
+ == TCL_OK) {
+ if (p == NULL) {
+ icuversion[0] = '\0';
+ }
+ Tcl_DecrRefCount(nameobj);
+ break;
+ }
+ Tcl_DecrRefCount(nameobj);
+ ++i;
+ }
+ }
+#if defined(_WIN32)
+ if (icu_fns.lib == NULL) {
+ Tcl_ResetResult(interp);
+ nameobj = Tcl_NewStringObj("icu.dll", TCL_INDEX_NONE);
+ Tcl_IncrRefCount(nameobj);
+ if (Tcl_LoadFile(interp, nameobj, NULL, 0, NULL, &icu_fns.lib)
+ == TCL_OK) {
+ icuversion[0] = '\0';
+ }
+ Tcl_DecrRefCount(nameobj);
+ }
+ if (icu_fns.lib == NULL) {
+ Tcl_ResetResult(interp);
+ nameobj = Tcl_NewStringObj("icuuc.dll", TCL_INDEX_NONE);
+ Tcl_IncrRefCount(nameobj);
+ if (Tcl_LoadFile(interp, nameobj, NULL, 0, NULL, &icu_fns.lib)
+ == TCL_OK) {
+ icuversion[0] = '\0';
+ }
+ Tcl_DecrRefCount(nameobj);
+ }
+#endif
+ if (icu_fns.lib != NULL) {
+#define ICU_SYM(name) \
+ strcpy(symbol, "ubrk_" #name ); \
+ strcat(symbol, icuversion); \
+ icu_fns.name = (fn_icu_ ## name) \
+ Tcl_FindSymbol(NULL, icu_fns.lib, symbol)
+ ICU_SYM(open);
+ ICU_SYM(close);
+ ICU_SYM(preceding);
+ ICU_SYM(following);
+ ICU_SYM(previous);
+ ICU_SYM(next);
+ ICU_SYM(setText);
+#undef ICU_SYM
+ }
+ }
+ Tcl_MutexUnlock(&icu_mutex);
+
+ if (icu_fns.lib != NULL) {
+ Tcl_CreateObjCommand(interp, "::tk::startOfCluster", startEndOfCmd,
+ INT2PTR(0), icuCleanup);
+ Tcl_CreateObjCommand(interp, "::tk::startOfNextWord", startEndOfCmd,
+ INT2PTR(FLAG_WORD|FLAG_FOLLOWING), icuCleanup);
+ Tcl_CreateObjCommand(interp, "::tk::startOfPreviousWord", startEndOfCmd,
+ INT2PTR(FLAG_WORD), icuCleanup);
+ Tcl_CreateObjCommand(interp, "::tk::endOfCluster", startEndOfCmd,
+ INT2PTR(FLAG_FOLLOWING), icuCleanup);
+ Tcl_CreateObjCommand(interp, "::tk::endOfWord", startEndOfCmd,
+ INT2PTR(FLAG_WORD|FLAG_FOLLOWING|FLAG_SPACE), icuCleanup);
+ icu_fns.nopen += 5;
+ }
+}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * coding: utf-8
+ * End:
+ */
+
diff --git a/generic/tkImage.c b/generic/tkImage.c
index 50c3c66..701c765 100644
--- a/generic/tkImage.c
+++ b/generic/tkImage.c
@@ -4,8 +4,8 @@
* 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-1997 Sun Microsystems, Inc.
+ * Copyright © 1994 The Regents of the University of California.
+ * Copyright © 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.
@@ -33,12 +33,12 @@ typedef struct Image {
struct ImageModel *modelPtr;
/* Model for this image (identifiers image
* manager, for example). */
- ClientData instanceData; /* One word argument to pass to image manager
+ void *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. */
+ void *widgetClientData;/* Argument to pass to changeProc. */
struct Image *nextPtr; /* Next in list of all image instances
* associated with the same name. */
struct Image *prevPtr; /* Previous in list of all image instances
@@ -55,7 +55,7 @@ typedef struct ImageModel {
Tk_ImageType *typePtr; /* Information about image type. NULL means
* that no image manager owns this image: the
* image was deleted. */
- ClientData modelData; /* One-word argument to pass to image mgr when
+ void *modelData; /* One-word argument to pass to image mgr when
* dealing with the model, as opposed to
* instances. */
int width, height; /* Last known dimensions for image. */
@@ -87,7 +87,7 @@ static Tcl_ThreadDataKey dataKey;
* Prototypes for local functions:
*/
-static void ImageTypeThreadExitProc(ClientData clientData);
+static void ImageTypeThreadExitProc(void *clientData);
static Tcl_FreeProc DeleteImage;
static void EventuallyDeleteImage(ImageModel *modelPtr,
int forgetImageHashNow);
@@ -208,7 +208,7 @@ Tk_CreateImageType(
int
Tk_ImageObjCmd(
- ClientData clientData, /* Main window associated with interpreter. */
+ void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
@@ -233,7 +233,7 @@ Tk_ImageObjCmd(
const char *arg, *name;
Tcl_Obj *resultObj;
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
- Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "option ?args?");
@@ -280,7 +280,7 @@ Tk_ImageObjCmd(
if (typePtr == NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"image type \"%s\" doesn't exist", arg));
- Tcl_SetErrorCode(interp, "TK", "LOOKUP", "IMAGE_TYPE", arg, NULL);
+ Tcl_SetErrorCode(interp, "TK", "LOOKUP", "IMAGE_TYPE", arg, (char *)NULL);
return TCL_ERROR;
}
@@ -313,7 +313,7 @@ Tk_ImageObjCmd(
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"images may not be named the same as the main window",
-1));
- Tcl_SetErrorCode(interp, "TK", "IMAGE", "SMASH_MAIN", NULL);
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "SMASH_MAIN", (char *)NULL);
return TCL_ERROR;
}
}
@@ -375,8 +375,8 @@ Tk_ImageObjCmd(
}
Tcl_Preserve(modelPtr);
if (oldimage) {
- typedef int (OldCreateProc)(Tcl_Interp*, char*, int, char**,
- Tk_ImageType*, Tk_ImageModel, ClientData*);
+ typedef int (OldCreateProc)(Tcl_Interp*, char*, Tcl_Size, char**,
+ Tk_ImageType*, Tk_ImageModel, void **);
i = ((OldCreateProc*)typePtr->createProc)(interp,
(char*)name, objc, (char**)args, typePtr,
(Tk_ImageModel)modelPtr, &modelPtr->modelData);
@@ -403,7 +403,7 @@ Tk_ImageObjCmd(
modelPtr->modelData);
}
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- (const char *)Tcl_GetHashKey(&winPtr->mainPtr->imageTable, hPtr), -1));
+ (const char *)Tcl_GetHashKey(&winPtr->mainPtr->imageTable, hPtr), TCL_INDEX_NONE));
break;
}
case IMAGE_DELETE:
@@ -433,7 +433,7 @@ Tk_ImageObjCmd(
continue;
}
Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj(
- (const char *)Tcl_GetHashKey(&winPtr->mainPtr->imageTable, hPtr), -1));
+ (const char *)Tcl_GetHashKey(&winPtr->mainPtr->imageTable, hPtr), TCL_INDEX_NONE));
}
Tcl_SetObjResult(interp, resultObj);
break;
@@ -446,12 +446,12 @@ Tk_ImageObjCmd(
for (typePtr = tsdPtr->imageTypeList; typePtr != NULL;
typePtr = typePtr->nextPtr) {
Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj(
- typePtr->name, -1));
+ typePtr->name, TCL_INDEX_NONE));
}
for (typePtr = tsdPtr->oldImageTypeList; typePtr != NULL;
typePtr = typePtr->nextPtr) {
Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj(
- typePtr->name, -1));
+ typePtr->name, TCL_INDEX_NONE));
}
Tcl_SetObjResult(interp, resultObj);
break;
@@ -487,7 +487,7 @@ Tk_ImageObjCmd(
switch ((enum options) index) {
case IMAGE_HEIGHT:
- Tcl_SetObjResult(interp, Tcl_NewIntObj(modelPtr->height));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(modelPtr->height));
break;
case IMAGE_INUSE:
Tcl_SetObjResult(interp, Tcl_NewBooleanObj(
@@ -496,11 +496,11 @@ Tk_ImageObjCmd(
case IMAGE_TYPE:
if (modelPtr->typePtr != NULL) {
Tcl_SetObjResult(interp,
- Tcl_NewStringObj(modelPtr->typePtr->name, -1));
+ Tcl_NewStringObj(modelPtr->typePtr->name, TCL_INDEX_NONE));
}
break;
case IMAGE_WIDTH:
- Tcl_SetObjResult(interp, Tcl_NewIntObj(modelPtr->width));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(modelPtr->width));
break;
default:
Tcl_Panic("can't happen");
@@ -511,7 +511,7 @@ Tk_ImageObjCmd(
alreadyDeleted:
Tcl_SetObjResult(interp, Tcl_ObjPrintf("image \"%s\" doesn't exist",arg));
- Tcl_SetErrorCode(interp, "TK", "LOOKUP", "IMAGE", arg, NULL);
+ Tcl_SetErrorCode(interp, "TK", "LOOKUP", "IMAGE", arg, (char *)NULL);
return TCL_ERROR;
}
@@ -620,7 +620,7 @@ Tk_GetImage(
Tk_ImageChangedProc *changeProc,
/* Function to invoke when redisplay is needed
* because image's pixels or size changed. */
- ClientData clientData) /* One-word argument to pass to damageProc. */
+ void *clientData) /* One-word argument to pass to damageProc. */
{
Tcl_HashEntry *hPtr;
ImageModel *modelPtr;
@@ -657,7 +657,7 @@ Tk_GetImage(
if (interp) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"image \"%s\" doesn't exist", name));
- Tcl_SetErrorCode(interp, "TK", "LOOKUP", "IMAGE", name, NULL);
+ Tcl_SetErrorCode(interp, "TK", "LOOKUP", "IMAGE", name, (char *)NULL);
}
return NULL;
}
@@ -974,7 +974,11 @@ Tk_DeleteImage(
static void
DeleteImage(
- char *blockPtr) /* Pointer to main data structure for image. */
+#if TCL_MAJOR_VERSION > 8
+ void *blockPtr) /* Pointer to main data structure for image. */
+#else
+ char *blockPtr)
+#endif
{
Image *imagePtr;
Tk_ImageType *typePtr;
@@ -1089,7 +1093,7 @@ TkDeleteAllImages(
*----------------------------------------------------------------------
*/
-ClientData
+void *
Tk_GetImageModelData(
Tcl_Interp *interp, /* Interpreter in which the image was
* created. */
diff --git a/generic/tkImgBmap.c b/generic/tkImgBmap.c
index f02b560..49de20a 100644
--- a/generic/tkImgBmap.c
+++ b/generic/tkImgBmap.c
@@ -3,9 +3,9 @@
*
* 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.
- * Copyright (c) 1999 Scriptics Corporation.
+ * Copyright © 1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1999 Scriptics Corporation.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -18,7 +18,7 @@
* image:
*/
-typedef struct BitmapModel {
+typedef struct {
Tk_ImageModel tkModel; /* Tk's token for image model. NULL means the
* image is being deleted. */
Tcl_Interp *interp; /* Interpreter for application that is using
@@ -49,7 +49,7 @@ typedef struct BitmapModel {
*/
typedef struct BitmapInstance {
- int refCount; /* Number of instances that share this data
+ size_t refCount; /* Number of instances that share this data
* structure. */
BitmapModel *modelPtr; /* Pointer to model for image. */
Tk_Window tkwin; /* Window in which the instances will be
@@ -75,7 +75,7 @@ typedef struct BitmapInstance {
static int GetByte(Tcl_Channel chan);
static int ImgBmapCreate(Tcl_Interp *interp,
- const char *name, int objc, Tcl_Obj *const objv[],
+ const char *name, Tcl_Size objc, Tcl_Obj *const objv[],
const Tk_ImageType *typePtr, Tk_ImageModel model,
void **clientDataPtr);
static void *ImgBmapGet(Tk_Window tkwin, void *clientData);
@@ -108,17 +108,17 @@ Tk_ImageType tkBitmapImageType = {
static const Tk_ConfigSpec configSpecs[] = {
{TK_CONFIG_UID, "-background", NULL, NULL,
- "", Tk_Offset(BitmapModel, bgUid), 0, NULL},
+ "", offsetof(BitmapModel, bgUid), 0, NULL},
{TK_CONFIG_STRING, "-data", NULL, NULL,
- NULL, Tk_Offset(BitmapModel, dataString), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(BitmapModel, dataString), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_STRING, "-file", NULL, NULL,
- NULL, Tk_Offset(BitmapModel, fileString), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(BitmapModel, fileString), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_UID, "-foreground", NULL, NULL,
- "#000000", Tk_Offset(BitmapModel, fgUid), 0, NULL},
+ "#000000", offsetof(BitmapModel, fgUid), 0, NULL},
{TK_CONFIG_STRING, "-maskdata", NULL, NULL,
- NULL, Tk_Offset(BitmapModel, maskDataString), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(BitmapModel, maskDataString), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_STRING, "-maskfile", NULL, NULL,
- NULL, Tk_Offset(BitmapModel, maskFileString), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(BitmapModel, maskFileString), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}
};
@@ -150,7 +150,7 @@ static int ImgBmapCmd(void *clientData, Tcl_Interp *interp,
static void ImgBmapCmdDeletedProc(void *clientData);
static void ImgBmapConfigureInstance(BitmapInstance *instancePtr);
static int ImgBmapConfigureModel(BitmapModel *modelPtr,
- int objc, Tcl_Obj *const objv[], int flags);
+ Tcl_Size objc, Tcl_Obj *const objv[], int flags);
static int NextBitmapWord(ParseInfo *parseInfoPtr);
/*
@@ -174,7 +174,7 @@ ImgBmapCreate(
Tcl_Interp *interp, /* Interpreter for application containing
* image. */
const char *name, /* Name to use for image. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[], /* Argument objects for options (doesn't
* include image name or type). */
TCL_UNUSED(const Tk_ImageType *),/* Pointer to our type record (not used). */
@@ -231,7 +231,7 @@ static int
ImgBmapConfigureModel(
BitmapModel *modelPtr, /* Pointer to data structure describing
* overall bitmap image to (reconfigure). */
- int objc, /* Number of entries in objv. */
+ Tcl_Size objc, /* Number of entries in objv. */
Tcl_Obj *const objv[], /* Pairs of configuration options for image. */
int flags) /* Flags to pass to Tk_ConfigureWidget, such
* as TK_CONFIG_ARGV_ONLY. */
@@ -269,7 +269,7 @@ ImgBmapConfigureModel(
|| (modelPtr->maskDataString != NULL)) {
if (modelPtr->data == NULL) {
Tcl_SetObjResult(modelPtr->interp, Tcl_NewStringObj(
- "can't have mask without bitmap", -1));
+ "can't have mask without bitmap", TCL_INDEX_NONE));
Tcl_SetErrorCode(modelPtr->interp, "TK", "IMAGE", "BITMAP",
"NO_BITMAP", NULL);
return TCL_ERROR;
@@ -285,7 +285,7 @@ ImgBmapConfigureModel(
ckfree(modelPtr->maskData);
modelPtr->maskData = NULL;
Tcl_SetObjResult(modelPtr->interp, Tcl_NewStringObj(
- "bitmap and mask have different sizes", -1));
+ "bitmap and mask have different sizes", TCL_INDEX_NONE));
Tcl_SetErrorCode(modelPtr->interp, "TK", "IMAGE", "BITMAP",
"MASK_SIZE", NULL);
return TCL_ERROR;
@@ -591,7 +591,7 @@ TkGetBitmapData(
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"format error in bitmap data; looks like it's an"
- " obsolete X10 bitmap file", -1));
+ " obsolete X10 bitmap file", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "BITMAP", "OBSOLETE",
NULL);
}
@@ -636,7 +636,7 @@ TkGetBitmapData(
error:
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "format error in bitmap data", -1));
+ "format error in bitmap data", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "BITMAP", "FORMAT", NULL);
}
@@ -764,14 +764,14 @@ ImgBmapCmd(
return TCL_ERROR;
}
return Tk_ConfigureValue(interp, Tk_MainWindow(interp), configSpecs,
- (char *)modelPtr, Tcl_GetString(objv[2]), 0);
+ modelPtr, Tcl_GetString(objv[2]), 0);
case 1: /* configure */
if (objc == 2) {
return Tk_ConfigureInfo(interp, Tk_MainWindow(interp),
- configSpecs, (char *)modelPtr, NULL, 0);
+ configSpecs, modelPtr, NULL, 0);
} else if (objc == 3) {
return Tk_ConfigureInfo(interp, Tk_MainWindow(interp),
- configSpecs, (char *)modelPtr,
+ configSpecs, modelPtr,
Tcl_GetString(objv[2]), 0);
} else {
return ImgBmapConfigureModel(modelPtr, objc-2, objv+2,
@@ -1013,7 +1013,7 @@ ImgBmapDelete(
if (modelPtr->maskData != NULL) {
ckfree(modelPtr->maskData);
}
- Tk_FreeOptions(configSpecs, (char *)modelPtr, NULL, 0);
+ Tk_FreeOptions(configSpecs, modelPtr, NULL, 0);
ckfree(modelPtr);
}
@@ -1151,10 +1151,10 @@ ImgBmapPsImagemask(
Tcl_AppendPrintfToObj(psObj, " %02x",
bit_reverse[0xff & data[i*nBytePerRow + j]]);
}
- Tcl_AppendToObj(psObj, "\n", -1);
+ Tcl_AppendToObj(psObj, "\n", TCL_INDEX_NONE);
}
- Tcl_AppendToObj(psObj, ">} imagemask \n", -1);
+ Tcl_AppendToObj(psObj, ">} imagemask \n", TCL_INDEX_NONE);
}
/*
@@ -1209,7 +1209,7 @@ ImgBmapPostscript(
if (modelPtr->width*modelPtr->height > 60000) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"unable to generate postscript for bitmaps larger than 60000"
- " pixels", -1));
+ " pixels", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "CANVAS", "PS", "MEMLIMIT", NULL);
return TCL_ERROR;
}
@@ -1259,7 +1259,7 @@ ImgBmapPostscript(
if (modelPtr->maskData == NULL) {
Tcl_AppendToObj(psObj,
"0 0 moveto 1 0 rlineto 0 1 rlineto -1 0 rlineto "
- "closepath fill\n", -1);
+ "closepath fill\n", TCL_INDEX_NONE);
} else {
ImgBmapPsImagemask(psObj, modelPtr->width, modelPtr->height,
modelPtr->maskData);
diff --git a/generic/tkImgGIF.c b/generic/tkImgGIF.c
index 33bf004..32b01e4 100644
--- a/generic/tkImgGIF.c
+++ b/generic/tkImgGIF.c
@@ -8,10 +8,10 @@
* 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.
- * Copyright (c) 1997 Australian National University
- * Copyright (c) 2005-2010 Donal K. Fellows
+ * Copyright © Reed Wade (wade@cs.utk.edu), University of Tennessee
+ * Copyright © 1995-1997 Sun Microsystems, Inc.
+ * Copyright © 1997 Australian National University
+ * Copyright © 2005-2010 Donal K. Fellows
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -47,6 +47,18 @@
#define GIF_DONE (GIF_SPECIAL+4)
/*
+ * structure to hold the data of a Graphic Control Extension block.
+ */
+
+typedef struct {
+ int blockPresent; /* if 1, the block was read and is in scope */
+ int transparent; /* Transparency index */
+ int delayTime; /* update delay time in 10ms */
+ int disposalMethod; /* disposal method 0-3 */
+ int userInteraction; /* user interaction 0/1 */
+} GIFGraphicControlExtensionBlock;
+
+/*
* 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.
*/
@@ -55,7 +67,7 @@ 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) */
- int length; /* Total amount of bytes in data */
+ Tcl_Size length; /* Total amount of bytes in data */
} MFile;
/*
@@ -111,35 +123,44 @@ typedef struct {
* serializing in the GIF format.
*/
-typedef int (WriteBytesFunc) (void *clientData, const char *bytes,
- int byteCount);
+typedef Tcl_Size (WriteBytesFunc) (void *clientData, const char *bytes,
+ Tcl_Size byteCount);
/*
* The format record for the GIF file format:
*/
-static int FileMatchGIF(Tcl_Channel chan, const char *fileName,
- Tcl_Obj *format, int *widthPtr, int *heightPtr,
- Tcl_Interp *interp);
+static int FileMatchGIF(Tcl_Interp *interp, Tcl_Channel chan,
+ const char *fileName, Tcl_Obj *format,
+ Tcl_Obj *metadataInObj, int *widthPtr,
+ int *heightPtr, Tcl_Obj *metadataOutObj);
static int FileReadGIF(Tcl_Interp *interp, Tcl_Channel chan,
const char *fileName, Tcl_Obj *format,
- Tk_PhotoHandle imageHandle, int destX, int destY,
- int width, int height, int srcX, int srcY);
-static int StringMatchGIF(Tcl_Obj *dataObj, Tcl_Obj *format,
- int *widthPtr, int *heightPtr, Tcl_Interp *interp);
+ Tcl_Obj *metadataInObj, Tk_PhotoHandle imageHandle,
+ int destX, int destY, int width, int height,
+ int srcX, int srcY, Tcl_Obj *metadataOutObj);
+static int StringMatchGIF(Tcl_Interp *interp, Tcl_Obj *dataObj,
+ Tcl_Obj *format, Tcl_Obj *metadataInObj,
+ int *widthPtr, int *heightPtr,
+ Tcl_Obj *metadataOutObj);
static int StringReadGIF(Tcl_Interp *interp, Tcl_Obj *dataObj,
- Tcl_Obj *format, Tk_PhotoHandle imageHandle,
+ Tcl_Obj *format, Tcl_Obj *metadataInObj,
+ Tk_PhotoHandle imageHandle,
int destX, int destY, int width, int height,
- int srcX, int srcY);
+ int srcX, int srcY, Tcl_Obj *metadataOutObj);
static int FileWriteGIF(Tcl_Interp *interp, const char *filename,
- Tcl_Obj *format, Tk_PhotoImageBlock *blockPtr);
+ Tcl_Obj *format, Tcl_Obj *metadataInObj,
+ Tk_PhotoImageBlock *blockPtr);
static int StringWriteGIF(Tcl_Interp *interp, Tcl_Obj *format,
+ Tcl_Obj *metadataInObj,
Tk_PhotoImageBlock *blockPtr);
-static int CommonWriteGIF(Tcl_Interp *interp, void *clientData,
+static int CommonWriteGIF(Tcl_Interp *interp,
+ void *clientData,
WriteBytesFunc *writeProc, Tcl_Obj *format,
+ Tcl_Obj *metadataInObj,
Tk_PhotoImageBlock *blockPtr);
-Tk_PhotoImageFormat tkImgFmtGIF = {
+Tk_PhotoImageFormatVersion3 tkImgFmtGIF = {
"gif", /* name */
FileMatchGIF, /* fileMatchProc */
StringMatchGIF, /* stringMatchProc */
@@ -165,9 +186,13 @@ Tk_PhotoImageFormat tkImgFmtGIF = {
* Prototypes for local functions defined in this file:
*/
+static int ReadOneByte(Tcl_Interp *interp,
+ GIFImageConfig *gifConfPtr, Tcl_Channel chan);
static int DoExtension(GIFImageConfig *gifConfPtr,
Tcl_Channel chan, int label, unsigned char *buffer,
- int *transparent);
+ GIFGraphicControlExtensionBlock
+ *gifGraphicControlExtensionBlock,
+ Tcl_Obj *metadataOutObj);
static int GetCode(Tcl_Channel chan, int code_size, int flag,
GIFImageConfig *gifConfPtr);
static int GetDataBlock(GIFImageConfig *gifConfPtr,
@@ -187,14 +212,14 @@ static int ReadImage(GIFImageConfig *gifConfPtr,
* these are for the BASE64 image reader code only
*/
-static int Fread(GIFImageConfig *gifConfPtr, unsigned char *dst,
- size_t size, size_t count, Tcl_Channel chan);
-static int Mread(unsigned char *dst, size_t size, size_t count,
+static Tcl_Size Fread(GIFImageConfig *gifConfPtr, unsigned char *dst,
+ Tcl_Size size, Tcl_Size count, Tcl_Channel chan);
+static Tcl_Size Mread(unsigned char *dst, Tcl_Size size, Tcl_Size count,
MFile *handle);
static int Mgetc(MFile *handle);
static int char64(int c);
static void mInit(unsigned char *string, MFile *handle,
- int length);
+ Tcl_Size length);
/*
* Types, defines and variables needed to write and compress a GIF.
@@ -345,13 +370,15 @@ static void FlushChar(GIFState_t *statePtr);
static int
FileMatchGIF(
+ TCL_UNUSED(Tcl_Interp *), /* not used */
Tcl_Channel chan, /* The image file, open for reading. */
- const char *fileName, /* The name of the image file. */
- Tcl_Obj *format, /* User-specified format object, or NULL. */
+ TCL_UNUSED(const char *), /* The name of the image file. */
+ TCL_UNUSED(Tcl_Obj *), /* User-specified format object, or NULL. */
+ TCL_UNUSED(Tcl_Obj *), /* metadata input, may be NULL */
int *widthPtr, int *heightPtr,
/* The dimensions of the image are returned
* here if the file is a valid raw GIF file. */
- TCL_UNUSED(Tcl_Interp *))
+ TCL_UNUSED(Tcl_Obj *)) /* metadata return dict, may be NULL */
{
GIFImageConfig gifConf;
@@ -384,28 +411,33 @@ FileReadGIF(
Tcl_Channel chan, /* The image file, open for reading. */
const char *fileName, /* The name of the image file. */
Tcl_Obj *format, /* User-specified format object, or NULL. */
+ TCL_UNUSED(Tcl_Obj *), /* metadata input, may be NULL */
Tk_PhotoHandle imageHandle, /* The photo image to write into. */
int destX, int destY, /* Coordinates of top-left pixel in photo
* image to be written to. */
int width, int height, /* Dimensions of block of photo image to be
* written to. */
- int srcX, int srcY) /* Coordinates of top-left pixel to be used in
+ int srcX, int srcY, /* Coordinates of top-left pixel to be used in
* image being read. */
+ Tcl_Obj *metadataOutObj) /* metadata return dict, may be NULL */
{
int fileWidth, fileHeight, imageWidth, imageHeight;
unsigned int nBytes;
- int index = 0, argc = 0, i, result = TCL_ERROR;
+ int index = 0, result = TCL_ERROR;
+ Tcl_Size argc = 0, i;
Tcl_Obj **objv;
unsigned char buf[100];
unsigned char *trashBuffer = NULL;
int bitPixel;
+ int gifLabel;
unsigned char colorMap[MAXCOLORMAPSIZE][4];
- int transparent = -1;
+ GIFGraphicControlExtensionBlock gifGraphicControlExtensionBlock;
static const char *const optionStrings[] = {
"-index", NULL
};
GIFImageConfig gifConf, *gifConfPtr = &gifConf;
+ gifGraphicControlExtensionBlock.blockPresent = 0;
/*
* Decode the magic used to convey when we're sourcing data from a string
* source and not a file.
@@ -479,7 +511,7 @@ FileReadGIF(
if (BitSet(buf[0], LOCALCOLORMAP)) { /* Global Colormap */
if (!ReadColorMap(gifConfPtr, chan, bitPixel, colorMap)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "error reading color map", -1));
+ "error reading color map", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "COLOR_MAP", NULL);
return TCL_ERROR;
}
@@ -507,26 +539,24 @@ FileReadGIF(
}
/*
+ * -------------------------------------------------------------------------
+ * From here on, go to error to not leave memory leaks
+ * -------------------------------------------------------------------------
+ */
+
+ /*
* Search for the frame from the GIF to display.
*/
while (1) {
- if (Fread(gifConfPtr, buf, 1, 1, chan) != 1) {
- /*
- * Premature end of image.
- */
-
- Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "premature end of image data for this index", -1));
- Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "PREMATURE_END",
- NULL);
+ if (-1 == (gifLabel = ReadOneByte( interp, gifConfPtr, chan ) ) ) {
goto error;
}
- switch (buf[0]) {
+ switch (gifLabel) {
case GIF_TERMINATOR:
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "no image data for this index", -1));
+ "no image data for this index", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "NO_DATA", NULL);
goto error;
@@ -535,18 +565,15 @@ FileReadGIF(
* This is a GIF extension.
*/
- if (Fread(gifConfPtr, buf, 1, 1, chan) != 1) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "error reading extension function code in GIF image",
- -1));
- Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "BAD_EXT",
- NULL);
+ if (-1 == (gifLabel = ReadOneByte( interp, gifConfPtr, chan ) ) ) {
goto error;
}
- if (DoExtension(gifConfPtr, chan, buf[0],
- gifConfPtr->workingBuffer, &transparent) < 0) {
+ if (DoExtension(gifConfPtr, chan, gifLabel,
+ gifConfPtr->workingBuffer, &gifGraphicControlExtensionBlock,
+ metadataOutObj)
+ < 0) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "error reading extension in GIF image", -1));
+ "error reading extension in GIF image", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "BAD_EXT",
NULL);
goto error;
@@ -587,7 +614,7 @@ FileReadGIF(
if (BitSet(buf[8], LOCALCOLORMAP)) {
if (!ReadColorMap(gifConfPtr, chan, bitPixel, colorMap)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "error reading color map", -1));
+ "error reading color map", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF",
"COLOR_MAP", NULL);
goto error;
@@ -635,7 +662,7 @@ FileReadGIF(
* This extension starts a new scope, so Graphic control Extension
* data should be cleared
*/
- transparent = -1;
+ gifGraphicControlExtensionBlock.blockPresent = 0;
continue;
}
@@ -650,7 +677,7 @@ FileReadGIF(
if (BitSet(buf[8], LOCALCOLORMAP)) {
if (!ReadColorMap(gifConfPtr, chan, bitPixel, colorMap)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "error reading color map", -1));
+ "error reading color map", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "COLOR_MAP", NULL);
goto error;
}
@@ -685,7 +712,10 @@ FileReadGIF(
if ((width > 0) && (height > 0)) {
unsigned char* pixelPtr;
Tk_PhotoImageBlock block;
-
+ int transparent = -1;
+ if (gifGraphicControlExtensionBlock.blockPresent) {
+ transparent = gifGraphicControlExtensionBlock.transparent;
+ }
/*
* Read the data and put it into the photo buffer for display by the
* general image machinery.
@@ -728,14 +758,133 @@ FileReadGIF(
}
/*
+ * Update the metadata dictionary with current image data
+ */
+
+ if (NULL != metadataOutObj) {
+
+ /*
+ * Save the update box, if not the whole image
+ */
+
+ if ( width != fileWidth || height != fileHeight) {
+ Tcl_Obj *itemList[4];
+ itemList[0] = Tcl_NewIntObj(destX);
+ itemList[1] = Tcl_NewIntObj(destY);
+ itemList[2] = Tcl_NewIntObj(width);
+ itemList[3] = Tcl_NewIntObj(height);
+ if ( TCL_OK != Tcl_DictObjPut(interp, metadataOutObj,
+ Tcl_NewStringObj("update region",-1),
+ Tcl_NewListObj(4, itemList) )) {
+ result = TCL_ERROR;
+ goto error;
+ }
+ }
+
+ /*
+ * Copy the Graphic Control Extension Block data to the metadata
+ * dictionary
+ */
+
+ if (gifGraphicControlExtensionBlock.blockPresent) {
+ if ( gifGraphicControlExtensionBlock.delayTime != 0) {
+ if ( TCL_OK != Tcl_DictObjPut(interp, metadataOutObj,
+ Tcl_NewStringObj("delay time",-1),
+ Tcl_NewIntObj(gifGraphicControlExtensionBlock.delayTime)
+ )) {
+ result = TCL_ERROR;
+ goto error;
+ }
+ }
+ switch ( gifGraphicControlExtensionBlock.disposalMethod ) {
+ case 1: /* Do not dispose */
+ if ( TCL_OK != Tcl_DictObjPut(interp, metadataOutObj,
+ Tcl_NewStringObj("disposal method",-1),
+ Tcl_NewStringObj("do not dispose",-1))) {
+ result = TCL_ERROR;
+ goto error;
+ }
+ break;
+ case 2: /* Restore to background color */
+ if ( TCL_OK != Tcl_DictObjPut(interp, metadataOutObj,
+ Tcl_NewStringObj("disposal method",-1),
+ Tcl_NewStringObj("restore to background color",-1))) {
+ result = TCL_ERROR;
+ goto error;
+ }
+ break;
+ case 3: /* Restore to previous */
+ if ( TCL_OK != Tcl_DictObjPut(interp, metadataOutObj,
+ Tcl_NewStringObj("disposal method",-1),
+ Tcl_NewStringObj("restore to previous",-1))) {
+ result = TCL_ERROR;
+ goto error;
+ }
+ break;
+ }
+ if ( gifGraphicControlExtensionBlock.userInteraction != 0) {
+ if ( TCL_OK != Tcl_DictObjPut(interp, metadataOutObj,
+ Tcl_NewStringObj("user interaction",-1),
+ Tcl_NewBooleanObj(1))) {
+ result = TCL_ERROR;
+ goto error;
+ }
+ }
+ }
+ }
+
+ /*
* We've successfully read the GIF frame (or there was nothing to read,
* which suits as well). We're done.
*/
- Tcl_SetObjResult(interp, Tcl_NewStringObj(tkImgFmtGIF.name, -1));
+ while (1) {
+ if (-1 == (gifLabel = ReadOneByte( interp, gifConfPtr, chan ) ) ) {
+ goto error;
+ }
+ switch (gifLabel) {
+ case GIF_TERMINATOR:
+ break;
+
+ case GIF_EXTENSION:
+ /*
+ * This is a GIF extension.
+ */
+
+ if (-1 == (gifLabel = ReadOneByte( interp, gifConfPtr, chan ) ) ) {
+ goto error;
+ }
+ if (DoExtension(gifConfPtr, chan, gifLabel,
+ gifConfPtr->workingBuffer, &gifGraphicControlExtensionBlock,
+ metadataOutObj)
+ < 0) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "error reading extension in GIF image", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "BAD_EXT",
+ NULL);
+ goto error;
+ }
+ continue;
+ case GIF_START:
+ /*
+ * There should not be a second image block - bail out without error
+ */
+ break;
+ default:
+ /*
+ * Not a valid start character; ignore it.
+ */
+
+ continue;
+ }
+ break;
+ }
+
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(tkImgFmtGIF.name, TCL_INDEX_NONE));
result = TCL_OK;
- error:
+error:
+
/*
* If a trash buffer has been allocated, free it now.
*/
@@ -746,6 +895,45 @@ FileReadGIF(
return result;
}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * Read one Byte --
+ *
+ * Read one byte (label byte) from the image stream.
+ *
+ * Results:
+ * The return value is 1 if the first characters in the data are like GIF
+ * data, and 0 otherwise.
+ *
+ * Side effects:
+ * The access position in the source is incremented.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+ReadOneByte(
+ Tcl_Interp *interp, /* Interpreter to use for reporting errors. */
+ GIFImageConfig *gifConfPtr,
+ Tcl_Channel chan /* The image file, open for reading. */
+ )
+{
+ unsigned char buf[2];
+ if (Fread(gifConfPtr, buf, 1, 1, chan) != 1) {
+ /*
+ * Premature end of image.
+ */
+
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "premature end of image data", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "PREMATURE_END", NULL);
+ return -1;
+ }
+ return buf[0];
+}
+
/*
*----------------------------------------------------------------------
*
@@ -764,16 +952,19 @@ FileReadGIF(
*----------------------------------------------------------------------
*/
+
static int
StringMatchGIF(
+ TCL_UNUSED(Tcl_Interp *), /* not used */
Tcl_Obj *dataObj, /* the object containing the image data */
- Tcl_Obj *format, /* the image format object, or NULL */
+ TCL_UNUSED(Tcl_Obj *), /* the image format object, or NULL */
+ TCL_UNUSED(Tcl_Obj *), /* metadata input, may be NULL */
int *widthPtr, /* where to put the string width */
int *heightPtr, /* where to put the string height */
- Tcl_Interp *interp) /* not used */
+ TCL_UNUSED(Tcl_Obj *)) /* metadata return dict, may be NULL */
{
unsigned char *data, header[10];
- int got, length;
+ Tcl_Size got, length;
MFile handle;
data = Tcl_GetByteArrayFromObj(dataObj, &length);
@@ -836,13 +1027,15 @@ StringReadGIF(
Tcl_Interp *interp, /* interpreter for reporting errors in */
Tcl_Obj *dataObj, /* object containing the image */
Tcl_Obj *format, /* format object, or NULL */
+ Tcl_Obj *metadataInObj, /* metadata input, may be NULL */
Tk_PhotoHandle imageHandle, /* the image to write this data into */
int destX, int destY, /* The rectangular region of the */
int width, int height, /* image to copy */
- int srcX, int srcY)
+ int srcX, int srcY,
+ Tcl_Obj *metadataOutObj) /* metadata return dict, may be NULL */
{
MFile handle, *hdlPtr = &handle;
- int length;
+ Tcl_Size length;
const char *xferFormat;
unsigned char *data = Tcl_GetByteArrayFromObj(dataObj, &length);
@@ -868,7 +1061,8 @@ StringReadGIF(
*/
return FileReadGIF(interp, (Tcl_Channel) hdlPtr, xferFormat, format,
- imageHandle, destX, destY, width, height, srcX, srcY);
+ metadataInObj, imageHandle, destX, destY, width, height, srcX, srcY,
+ metadataOutObj);
}
/*
@@ -947,15 +1141,43 @@ ReadColorMap(
return 1;
}
+/*
+*----------------------------------------------------------------------
+*
+* DoExtension --
+*
+* Process a GIF extension block
+*
+* Results:
+* -1 to trigger an extension read error
+* >= 0 ok
+*
+* Side effects:
+* The gifGraphicControlExtensionBlock is set if present in current
+* extensions
+* The data of the following extensions are saved to the metadata dict:
+* - Application extension
+* - Comment extension in key "comment"
+* Plain text extensions are currently ignored.
+*
+*----------------------------------------------------------------------
+*/
+
static int
DoExtension(
GIFImageConfig *gifConfPtr,
Tcl_Channel chan,
int label,
- unsigned char *buf,
- int *transparent)
+ unsigned char *buf, /* defined as 280 byte working buffer */
+ GIFGraphicControlExtensionBlock *gifGraphicControlExtensionBlock,
+ Tcl_Obj *metadataOutObj)
{
int count;
+ /* Prepare extension name
+ * Maximum string size: "comment" + Code(3) + trailing zero
+ */
+ char extensionStreamName[8];
+ extensionStreamName[0] = '\0';
switch (label) {
case 0x01: /* Plain Text Extension */
@@ -963,37 +1185,77 @@ DoExtension(
* This extension starts a new scope, so Graphic control Extension
* data should be cleared
*/
- *transparent = -1;
- break;
-
- case 0xff: /* Application Extension */
+ gifGraphicControlExtensionBlock->blockPresent = 0;
+ /* this extension is ignored, skip below */
break;
-
- case 0xfe: /* Comment Extension */
- do {
- count = GetDataBlock(gifConfPtr, chan, buf);
- } while (count > 0);
- return count;
-
case 0xf9: /* Graphic Control Extension */
count = GetDataBlock(gifConfPtr, chan, buf);
if (count < 0) {
- return 1;
+ return -1;
}
- if ((buf[0] & 0x1) != 0) {
- *transparent = buf[3];
+ gifGraphicControlExtensionBlock->blockPresent=1;
+ /* save disposal method */
+ gifGraphicControlExtensionBlock->disposalMethod
+ = ((buf[0] & 0x1C) >> 2);
+ /* save disposal method */
+ gifGraphicControlExtensionBlock->userInteraction = ((buf[0] & 2) >> 1);
+ /* save delay time */
+ gifGraphicControlExtensionBlock->delayTime
+ = LM_to_uint(buf[1], buf[2]);
+ /* save transparent index if given */
+ if ((buf[0] & 0x1) == 0) {
+ gifGraphicControlExtensionBlock->transparent = -1;
+ } else {
+ gifGraphicControlExtensionBlock->transparent = buf[3];
}
-
- do {
+ break;
+ case 0xfe: /* Comment Extension */
+ strcpy(extensionStreamName,"comment");
+ /* copy the extension data below */
+ break;
+ }
+ /* Add extension to dict */
+ if (NULL != metadataOutObj
+ && extensionStreamName[0] != '\0' ) {
+ Tcl_Obj *ValueObj = NULL;
+ int length = 0;
+ for (;;) {
count = GetDataBlock(gifConfPtr, chan, buf);
- } while (count > 0);
- return count;
+ switch (count) {
+ case -1: /* error */
+ return -1;
+ case 0: /* end of data */
+ if (length > 0) {
+ if ( TCL_OK != Tcl_DictObjPut(NULL, metadataOutObj,
+ Tcl_NewByteArrayObj(
+ (unsigned char *)extensionStreamName,
+ strlen(extensionStreamName)), ValueObj)) {
+ return -1;
+ }
+ }
+ /* return success */
+ return 0;
+ default: /* block received */
+ if (length == 0) {
+ /* first block */
+ ValueObj = Tcl_NewByteArrayObj(buf, count);
+ length = count;
+ } else {
+ /* consecutive block */
+ unsigned char *bytePtr;
+ bytePtr = Tcl_SetByteArrayLength(ValueObj, length+count);
+ memcpy(bytePtr+length,buf,count);
+ length += count;
+ }
+ break;
+ }
+ } /* for */
}
-
+ /* skip eventual remaining data block bytes */
do {
count = GetDataBlock(gifConfPtr, chan, buf);
} while (count > 0);
- return count;
+ return count; /* this may be -1 for error or 0 */
}
static int
@@ -1024,7 +1286,7 @@ GetDataBlock(
* transparency, etc.
*
* This code is based on the code found in the ImageMagick GIF decoder,
- * which is (c) 2000 ImageMagick Studio.
+ * which is © 2000 ImageMagick Studio.
*
* Some thoughts on our implementation:
* It sure would be nice if ReadImage didn't take 11 parameters! I think
@@ -1078,7 +1340,7 @@ ReadImage(
}
if (initialCodeSize > MAX_LWZ_BITS) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj("malformed image", -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("malformed image", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "MALFORMED", NULL);
return TCL_ERROR;
}
@@ -1198,24 +1460,24 @@ ReadImage(
}
firstCode = append[code];
- /*
- * Push the head of the code onto the stack.
- */
+ /*
+ * Push the head of the code onto the stack.
+ */
- *top++ = firstCode;
+ *top++ = firstCode;
- if (maxCode < (1 << MAX_LWZ_BITS)) {
+ if (maxCode < (1 << MAX_LWZ_BITS)) {
/*
* If there's still room in our codes table, add a new entry.
* Otherwise don't, and keep using the current table.
- * See DEFERRED CLEAR CODE IN LZW COMPRESSION in the GIF89a
- * specification.
+ * See DEFERRED CLEAR CODE IN LZW COMPRESSION in the GIF89a
+ * specification.
*/
prefix[maxCode] = oldCode;
append[maxCode] = firstCode;
maxCode++;
- }
+ }
/*
* maxCode tells us the maximum code value we can accept. If
@@ -1414,7 +1676,7 @@ static void
mInit(
unsigned char *string, /* string containing initial mmencoded data */
MFile *handle, /* mmdecode "file" handle */
- int length) /* Number of bytes in string */
+ Tcl_Size length) /* Number of bytes in string */
{
handle->data = string;
handle->state = 0;
@@ -1440,15 +1702,15 @@ mInit(
*----------------------------------------------------------------------
*/
-static int
+static Tcl_Size
Mread(
unsigned char *dst, /* where to put the result */
- size_t chunkSize, /* size of each transfer */
- size_t numChunks, /* number of chunks */
+ Tcl_Size chunkSize, /* size of each transfer */
+ Tcl_Size numChunks, /* number of chunks */
MFile *handle) /* mmdecode "file" handle */
{
- int i, c;
- int count = chunkSize * numChunks;
+ int c;
+ Tcl_Size i, count = chunkSize * numChunks;
for (i=0; i<count && (c=Mgetc(handle)) != GIF_DONE; i++) {
*dst++ = c;
@@ -1589,13 +1851,17 @@ char64(
*----------------------------------------------------------------------
*/
-static int
+static Tcl_Size
Fread(
GIFImageConfig *gifConfPtr,
unsigned char *dst, /* where to put the result */
- size_t hunk, size_t count, /* how many */
+ Tcl_Size hunk, Tcl_Size count, /* how many */
Tcl_Channel chan)
{
+ if (hunk < 0 || count < 0) {
+ return -1;
+ }
+
if (gifConfPtr->fromData == INLINE_DATA_BASE64) {
return Mread(dst, hunk, count, (MFile *) chan);
}
@@ -1603,7 +1869,7 @@ Fread(
if (gifConfPtr->fromData == INLINE_DATA_BINARY) {
MFile *handle = (MFile *) chan;
- if ((handle->length <= 0) || ((size_t)handle->length < hunk * count)) {
+ if ((handle->length <= 0) || (handle->length < hunk*count)) {
return -1;
}
memcpy(dst, handle->data, hunk * count);
@@ -1652,6 +1918,7 @@ FileWriteGIF(
Tcl_Interp *interp, /* Interpreter to use for reporting errors. */
const char *filename,
Tcl_Obj *format,
+ Tcl_Obj *metadataInObj,
Tk_PhotoImageBlock *blockPtr)
{
Tcl_Channel chan = NULL;
@@ -1667,7 +1934,8 @@ FileWriteGIF(
return TCL_ERROR;
}
- result = CommonWriteGIF(interp, chan, WriteToChannel, format, blockPtr);
+ result = CommonWriteGIF(interp, chan, WriteToChannel, format, metadataInObj,
+ blockPtr);
if (Tcl_Close(interp, chan) == TCL_ERROR) {
return TCL_ERROR;
@@ -1680,6 +1948,7 @@ StringWriteGIF(
Tcl_Interp *interp, /* Interpreter to use for reporting errors and
* returning the GIF data. */
Tcl_Obj *format,
+ Tcl_Obj *metadataInObj,
Tk_PhotoImageBlock *blockPtr)
{
int result;
@@ -1687,7 +1956,7 @@ StringWriteGIF(
Tcl_IncrRefCount(objPtr);
result = CommonWriteGIF(interp, objPtr, WriteToByteArray, format,
- blockPtr);
+ metadataInObj, blockPtr);
if (result == TCL_OK) {
Tcl_SetObjResult(interp, objPtr);
}
@@ -1695,22 +1964,22 @@ StringWriteGIF(
return result;
}
-static int
+static Tcl_Size
WriteToChannel(
void *clientData,
const char *bytes,
- int byteCount)
+ Tcl_Size byteCount)
{
Tcl_Channel handle = (Tcl_Channel)clientData;
return Tcl_Write(handle, bytes, byteCount);
}
-static int
+static Tcl_Size
WriteToByteArray(
void *clientData,
const char *bytes,
- int byteCount)
+ Tcl_Size byteCount)
{
Tcl_Obj *objPtr = (Tcl_Obj *)clientData;
Tcl_Obj *tmpObj = Tcl_NewByteArrayObj((unsigned char *) bytes, byteCount);
@@ -1726,7 +1995,8 @@ CommonWriteGIF(
Tcl_Interp *interp,
void *handle,
WriteBytesFunc *writeProc,
- Tcl_Obj *format,
+ TCL_UNUSED(Tcl_Obj *),
+ Tcl_Obj *metadataInObj,
Tk_PhotoImageBlock *blockPtr)
{
GifWriterState state;
@@ -1767,7 +2037,7 @@ CommonWriteGIF(
state.pixelPitch = blockPtr->pitch;
SaveMap(&state, blockPtr);
if (state.num >= MAXCOLORMAPSIZE) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj("too many colors", -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("too many colors", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "GIF", "COLORFUL", NULL);
return TCL_ERROR;
}
@@ -1856,6 +2126,50 @@ CommonWriteGIF(
c = 0;
writeProc(handle, (char *) &c, 1);
+ /*
+ * Check for metadata keys to add to file
+ */
+ if (NULL != metadataInObj) {
+ Tcl_Obj *itemData;
+
+ /*
+ * Check and code comment block
+ */
+
+ if (TCL_ERROR == Tcl_DictObjGet(interp, metadataInObj,
+ Tcl_NewStringObj("comment",-1),
+ &itemData)) {
+ return TCL_ERROR;
+ }
+ if (itemData != NULL) {
+ Tcl_Size length;
+ unsigned char *comment;
+ comment = Tcl_GetByteArrayFromObj(itemData, &length);
+ if (length > 0) {
+ /* write comment header */
+ writeProc(handle, (char *) "\x21\xfe", 2);
+ /* write comment blocks */
+ for (;length > 0;) {
+ int blockLength;
+ unsigned char blockLengthChar;
+ if (length > 255) {
+ length -=255;
+ blockLength = 255;
+ } else {
+ blockLength = length;
+ length = 0;
+ }
+ blockLengthChar = (unsigned char) blockLength;
+ writeProc(handle, (char *) &blockLengthChar, 1);
+ writeProc(handle, (char *) comment, blockLength);
+ comment += blockLength;
+ }
+ /* Block terminator */
+ c = 0;
+ writeProc(handle, (char *) &c, 1);
+ }
+ }
+ }
c = GIF_TERMINATOR;
writeProc(handle, (char *) &c, 1);
diff --git a/generic/tkImgListFormat.c b/generic/tkImgListFormat.c
new file mode 100644
index 0000000..d2a674d
--- /dev/null
+++ b/generic/tkImgListFormat.c
@@ -0,0 +1,1138 @@
+/*
+ * tkImgListFormat.c --
+ *
+ * Implements the default image data format. I.e. the format used for
+ * [imageName data] and [imageName put] if no other format is specified.
+ *
+ * The default format consits of a list of scan lines (rows) with each
+ * list element being itself a list of pixels (or columns). For details,
+ * see the manpage photo.n
+ *
+ * This image format cannot read/write files, it is meant for string
+ * data only.
+ *
+ *
+ * Copyright © 1994 The Australian National University.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 2002-2003 Donal K. Fellows
+ * Copyright © 2003 ActiveState Corporation.
+ *
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ *
+ * Authors:
+ * Paul Mackerras (paulus@cs.anu.edu.au),
+ * Department of Computer Science,
+ * Australian National University.
+ *
+ * Simon Bachmann (simonbachmann@bluewin.ch)
+ */
+
+
+#include "tkImgPhoto.h"
+
+#ifdef _WIN32
+#include "tkWinInt.h"
+#endif
+
+/*
+ * Message to generate when an attempt to allocate memory for an image fails.
+ */
+
+#define TK_PHOTO_ALLOC_FAILURE_MESSAGE \
+ "not enough free memory for image buffer"
+
+
+/*
+ * Color name length limit: do not attempt to parse as color strings that are
+ * longer than this limit
+ */
+
+#define TK_PHOTO_MAX_COLOR_LENGTH 99
+
+/*
+ * Symbols for the different formats of a color string.
+ */
+
+enum ColorFormatType {
+ COLORFORMAT_TKCOLOR,
+ COLORFORMAT_EMPTYSTRING,
+ COLORFORMAT_LIST,
+ COLORFORMAT_RGB1,
+ COLORFORMAT_RGB2,
+ COLORFORMAT_RGBA1,
+ COLORFORMAT_RGBA2
+};
+
+/*
+ * Names for the color format types above.
+ * Order must match the one in enum ColorFormatType
+ */
+
+static const char *const colorFormatNames[] = {
+ "tkcolor",
+ "emptystring",
+ "list",
+ "rgb-short",
+ "rgb",
+ "rgba-short",
+ "rgba",
+ NULL
+};
+
+/*
+ * The following data structure is used to return information from
+ * ParseFormatOptions:
+ */
+
+struct FormatOptions {
+ int options; /* Individual bits indicate which options were
+ * specified - see below. */
+ Tcl_Obj *formatName; /* Name specified without an option. */
+ enum ColorFormatType colorFormat;
+ /* The color format type given with the
+ * -colorformat option */
+};
+
+/*
+ * Bit definitions for use with ParseFormatOptions: each bit is set in the
+ * allowedOptions parameter on a call to ParseFormatOptions if that option
+ * is allowed for the current photo image subcommand. On return, the bit is
+ * set in the options field of the FormatOptions structure if that option
+ * was specified.
+ *
+ * OPT_COLORFORMAT: Set if -alpha option allowed/specified.
+ */
+
+#define OPT_COLORFORMAT 1
+
+/*
+ * List of format option names. The order here must match the order of
+ * declarations of the FMT_OPT_* constants above.
+ */
+
+static const char *const formatOptionNames[] = {
+ "-colorformat",
+ NULL
+};
+
+/*
+ * Forward declarations
+ */
+
+static int ParseFormatOptions(Tcl_Interp *interp, int allowedOptions,
+ Tcl_Size objc, Tcl_Obj *const objv[], Tcl_Size *indexPtr,
+ struct FormatOptions *optPtr);
+static Tcl_Obj *GetBadOptMsg(const char *badValue, int allowedOpts);
+static int StringMatchDef(Tcl_Obj *data, Tcl_Obj *formatString,
+ int *widthPtr, int *heightPtr, Tcl_Interp *interp);
+static int StringReadDef(Tcl_Interp *interp, Tcl_Obj *data,
+ Tcl_Obj *formatString, Tk_PhotoHandle imageHandle,
+ int destX, int destY, int width, int height,
+ int srcX, int srcY);
+static int StringWriteDef(Tcl_Interp *interp,
+ Tcl_Obj *formatString,
+ Tk_PhotoImageBlock *blockPtr);
+static int ParseColor(Tcl_Interp *interp, Tcl_Obj *specObj,
+ Display *display, Colormap colormap, unsigned char *redPtr,
+ unsigned char *greenPtr, unsigned char *bluePtr,
+ unsigned char *alphaPtr);
+static int ParseColorAsList(const char *colorString, unsigned char *redPtr,
+ unsigned char *greenPtr, unsigned char *bluePtr,
+ unsigned char *alphaPtr);
+static int ParseColorAsHex(Tcl_Interp *interp, const char *colorString,
+ int colorStrLen, Display *display, Colormap colormap,
+ unsigned char *redPtr, unsigned char *greenPtr,
+ unsigned char *bluePtr, unsigned char *alphaPtr);
+static int ParseColorAsStandard(Tcl_Interp *interp,
+ const char *colorString, int colorStrLen,
+ Display *display, Colormap colormap,
+ unsigned char *redPtr, unsigned char *greenPtr,
+ unsigned char *bluePtr, unsigned char *alphaPtr);
+
+/*
+ * The format record for the default image handler
+ */
+
+Tk_PhotoImageFormat tkImgFmtDefault = {
+ "default", /* name */
+ NULL, /* fileMatchProc: format doesn't support file ops */
+ StringMatchDef, /* stringMatchProc */
+ NULL, /* fileReadProc: format doesn't support file read */
+ StringReadDef, /* stringReadProc */
+ NULL, /* fileWriteProc: format doesn't support file write */
+ StringWriteDef, /* stringWriteProc */
+ NULL /* nextPtr */
+};
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * ParseFormatOptions --
+ *
+ * Parse the options passed to the image format handler.
+ *
+ * Results:
+ * On success, the structure pointed to by optPtr is filled with the
+ * values passed or with the defaults and TCL_OK returned.
+ * If an error occurs, leaves an error message in interp and returns
+ * TCL_ERROR.
+ *
+ * Side effects:
+ * The value in *indexPtr is updated to the index of the fist
+ * element in argv[] that does not look like an option/value, or to
+ * argc if parsing reached the end of argv[].
+ *
+ *----------------------------------------------------------------------
+ */
+static int
+ParseFormatOptions(
+ Tcl_Interp *interp, /* For error messages */
+ int allowedOptions, /* Bitfield specifying which options are
+ * to be considered allowed */
+ Tcl_Size objc, /* Number of elements in argv[] */
+ Tcl_Obj *const objv[], /* The arguments to parse */
+ Tcl_Size *indexPtr, /* Index giving the first element to
+ * parse. The value is updated to the
+ * index where parsing ended */
+ struct FormatOptions *optPtr) /* Parsed option values are written to
+ * this struct */
+
+{
+ Tcl_Size optIndex, index;
+ int first, typeIndex;
+ const char *option;
+
+ first = 1;
+
+ /*
+ * Fill in default values
+ */
+ optPtr->options = 0;
+ optPtr->formatName = NULL;
+ optPtr->colorFormat = COLORFORMAT_RGB2;
+ for (index = *indexPtr; index < objc; *indexPtr = ++index) {
+ int optionExists;
+
+ /*
+ * The first value can be the format handler's name. It goes to
+ * optPtr->name.
+ */
+ option = Tcl_GetString(objv[index]);
+ if (option[0] != '-') {
+ if (first) {
+ optPtr->formatName = objv[index];
+ first = 0;
+ continue;
+ } else {
+ break;
+ }
+ }
+ first = 0;
+
+ /*
+ * Check if option is known and allowed
+ */
+
+ optionExists = 1;
+ if (Tcl_GetIndexFromObj(NULL, objv[index], formatOptionNames,
+ "format option", 0, &optIndex) != TCL_OK) {
+ optionExists = 0;
+ }
+ if (!optionExists || !((1 << optIndex) & allowedOptions)) {
+ Tcl_SetObjResult(interp, GetBadOptMsg(Tcl_GetString(objv[index]),
+ allowedOptions));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_OPTION", NULL);
+ return TCL_ERROR;
+ }
+
+ /*
+ * Option-specific checks
+ */
+
+ switch (1 << optIndex) {
+ case OPT_COLORFORMAT:
+ *indexPtr = ++index;
+ if (index >= objc) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("the \"%s\" option "
+ "requires a value", Tcl_GetString(objv[index - 1])));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
+ "MISSING_VALUE", NULL);
+ return TCL_ERROR;
+ }
+ if (Tcl_GetIndexFromObj(NULL, objv[index], colorFormatNames, "",
+ TCL_EXACT, &typeIndex) != TCL_OK
+ || (typeIndex != COLORFORMAT_LIST
+ && typeIndex != COLORFORMAT_RGB2
+ && typeIndex != COLORFORMAT_RGBA2) ) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad color format "
+ "\"%s\": must be rgb, rgba, or list",
+ Tcl_GetString(objv[index])));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
+ "BAD_COLOR_FORMAT", NULL);
+ return TCL_ERROR;
+ }
+ optPtr->colorFormat = (enum ColorFormatType)typeIndex;
+ break;
+ default:
+ Tcl_Panic("ParseFormatOptions: unexpected switch fallthrough");
+ }
+
+ /*
+ * Add option to bitfield in optPtr
+ */
+ optPtr->options |= (1 << optIndex);
+ }
+
+ return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GetBadOptMsg --
+ *
+ * Build a Tcl_Obj containing an error message in the form "bad option
+ * "xx": must be y, or z", based on the bits set in allowedOpts.
+ *
+ * Results:
+ * A Tcl Object containig the error message.
+ *
+ * Side effects:
+ * None
+ *----------------------------------------------------------------------
+ */
+static Tcl_Obj *
+GetBadOptMsg(
+ const char *badValue, /* the erroneous option */
+ int allowedOpts) /* bitfield specifying the allowed options */
+{
+ int i, bit;
+ Tcl_Obj *resObj = Tcl_ObjPrintf("bad format option \"%s\": ", badValue);
+
+ if (allowedOpts == 0) {
+ Tcl_AppendToObj(resObj, "no options allowed", TCL_INDEX_NONE);
+ } else {
+ Tcl_AppendToObj(resObj, "must be ", TCL_INDEX_NONE);
+ bit = 1;
+ for (i = 0; formatOptionNames[i] != NULL; i++) {
+ if (allowedOpts & bit) {
+ if (allowedOpts & (bit -1)) {
+ /*
+ * not the first option
+ */
+ if (allowedOpts & ~((bit << 1) - 1)) {
+ /*
+ * not the last option
+ */
+ Tcl_AppendToObj(resObj, ", ", TCL_INDEX_NONE);
+ } else {
+ Tcl_AppendToObj(resObj, ", or ", TCL_INDEX_NONE);
+ }
+ }
+ Tcl_AppendToObj(resObj, formatOptionNames[i], TCL_INDEX_NONE);
+ }
+ bit <<=1;
+ }
+ }
+ return resObj;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * StringMatchDef --
+ *
+ * Default string match function. Test if image data in string form
+ * appears to be in the default list-of-list-of-pixel-data format
+ * accepted by the "<img> put" command.
+ *
+ * Results:
+ * If thte data is in the default format, writes the size of the image
+ * to widthPtr and heightPtr and returns 1. Otherwise, leaves an error
+ * message in interp (if not NULL) and returns 0.
+ * Note that this function does not parse all data points. A return
+ * value of 1 does not guarantee that the data can be read without
+ * errors.
+ *
+ * Side effects:
+ * None
+ *----------------------------------------------------------------------
+ */
+static int
+StringMatchDef(
+ Tcl_Obj *data, /* The data to check */
+ TCL_UNUSED(Tcl_Obj *), /* Value of the -format option, not used here */
+ int *widthPtr, /* Width of image is written to this location */
+ int *heightPtr, /* Height of image is written to this location */
+ Tcl_Interp *interp) /* Error messages are left in this interpreter */
+{
+ Tcl_Size y, rowCount, colCount, curColCount;
+ unsigned char dummy;
+ Tcl_Obj **rowListPtr, *pixelData;
+
+ /*
+ * See if data can be parsed as a list, if every element is itself a valid
+ * list and all sublists have the same length.
+ */
+
+ if (Tcl_ListObjGetElements(interp, data, &rowCount, &rowListPtr)
+ != TCL_OK) {
+ return 0;
+ }
+ if (rowCount == 0) {
+ /*
+ * empty list is valid data
+ */
+
+ *widthPtr = 0;
+ *heightPtr = 0;
+ return 1;
+ }
+ colCount = -1;
+ for (y = 0; y < rowCount; y++) {
+ if (Tcl_ListObjLength(interp, rowListPtr[y], &curColCount) != TCL_OK) {
+ return 0;
+ }
+ if (colCount < 0) {
+ colCount = curColCount;
+ } else if (curColCount != colCount) {
+ if (interp != NULL) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("invalid row # %" TCL_SIZE_MODIFIER "d: "
+ "all rows must have the same number of elements", y));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
+ "INVALID_DATA", NULL);
+ }
+ return 0;
+ }
+ }
+
+ /*
+ * Data in base64 encoding (or even binary data), might actually pass
+ * these tests. To avoid parsing it as list of lists format, check one
+ * pixel for validity.
+ */
+ if (Tcl_ListObjIndex(interp, rowListPtr[0], 0, &pixelData) != TCL_OK) {
+ return 0;
+ }
+ (void)Tcl_GetString(pixelData);
+ if (pixelData->length > TK_PHOTO_MAX_COLOR_LENGTH) {
+ return 0;
+ }
+ if (ParseColor(interp, pixelData, Tk_Display(Tk_MainWindow(interp)),
+ Tk_Colormap(Tk_MainWindow(interp)), &dummy, &dummy, &dummy, &dummy)
+ != TCL_OK) {
+ return 0;
+ }
+
+ /*
+ * Looks like we have valid data for this format.
+ * We do not check any pixel values - that's the job of ImgStringRead()
+ */
+
+ *widthPtr = colCount;
+ *heightPtr = rowCount;
+
+ return 1;
+
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * StringReadDef --
+ *
+ * String read function for default format. (see manpage for details on
+ * the format).
+ *
+ * Results:
+ * A standard Tcl result.
+ *
+ * Side effects:
+ * If the data has valid format, write it to the image identified by
+ * imageHandle.
+ * If the image data cannot be parsed, an error message is left in
+ * interp.
+ *
+ *----------------------------------------------------------------------
+*/
+
+static int
+StringReadDef(
+ Tcl_Interp *interp, /* leave error messages here */
+ Tcl_Obj *data, /* the data to parse */
+ Tcl_Obj *formatString, /* value of the -format option */
+ Tk_PhotoHandle imageHandle, /* write data to this image */
+ int destX, int destY, /* start writing data at this point
+ * in destination image*/
+ int width, int height, /* dimensions of area to write to */
+ int srcX, int srcY) /* start reading source data at these
+ * coordinates */
+{
+ Tcl_Obj **rowListPtr, **colListPtr;
+ Tcl_Obj **objv;
+ Tcl_Size objc, rowCount, colCount, curColCount;
+ unsigned char *curPixelPtr;
+ int x, y;
+ Tk_PhotoImageBlock srcBlock;
+ Display *display;
+ Colormap colormap;
+ struct FormatOptions opts;
+ Tcl_Size optIndex;
+
+ /*
+ * Parse format suboptions
+ * We don't use any format suboptions, but we still need to provide useful
+ * error messages if suboptions were specified.
+ */
+
+ memset(&opts, 0, sizeof(opts));
+ if (formatString != NULL) {
+ if (Tcl_ListObjGetElements(interp, formatString, &objc, &objv)
+ != TCL_OK) {
+ return TCL_ERROR;
+ }
+ optIndex = 0;
+ if (ParseFormatOptions(interp, 0, objc, objv, &optIndex, &opts)
+ != TCL_OK) {
+ return TCL_ERROR;
+ }
+ if (optIndex < objc) {
+ Tcl_SetObjResult(interp,
+ GetBadOptMsg(Tcl_GetString(objv[optIndex]), 0));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_OPTION", NULL);
+ return TCL_ERROR;
+ }
+ }
+
+ /*
+ * Check input data
+ */
+
+ if (Tcl_ListObjGetElements(interp, data, &rowCount, &rowListPtr)
+ != TCL_OK ) {
+ return TCL_ERROR;
+ }
+ if ( rowCount > 0 && Tcl_ListObjLength(interp, rowListPtr[0], &colCount)
+ != TCL_OK) {
+ return TCL_ERROR;
+ }
+ if (width <= 0 || height <= 0 || rowCount == 0 || colCount == 0) {
+ /*
+ * No changes with zero sized input or zero sized output region
+ */
+
+ return TCL_OK;
+ }
+ if (srcX < 0 || srcY < 0 || srcX >= rowCount || srcY >= colCount) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("source coordinates out of range"));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "COORDINATES", NULL);
+ return TCL_ERROR;
+ }
+
+ /*
+ * Memory allocation overflow protection.
+ * May not be able to trigger/ demo / test this.
+ */
+
+ if (colCount > (int)(UINT_MAX / 4 / rowCount)) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "photo image dimensions exceed Tcl memory limits"));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
+ "OVERFLOW", NULL);
+ return TCL_OK;
+ }
+
+ /*
+ * Read data and put it to imageHandle
+ */
+
+ srcBlock.width = colCount - srcX;
+ srcBlock.height = rowCount - srcY;
+ srcBlock.pixelSize = 4;
+ srcBlock.pitch = srcBlock.width * 4;
+ srcBlock.offset[0] = 0;
+ srcBlock.offset[1] = 1;
+ srcBlock.offset[2] = 2;
+ srcBlock.offset[3] = 3;
+ srcBlock.pixelPtr = (unsigned char *)attemptckalloc(srcBlock.pitch * srcBlock.height);
+ if (srcBlock.pixelPtr == NULL) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(TK_PHOTO_ALLOC_FAILURE_MESSAGE));
+ Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL);
+ return TCL_ERROR;
+ }
+ curPixelPtr = srcBlock.pixelPtr;
+ display = Tk_Display(Tk_MainWindow(interp));
+ colormap = Tk_Colormap(Tk_MainWindow(interp));
+ for (y = srcY; y < rowCount; y++) {
+ /*
+ * We don't test the length of row, as that's been done in
+ * ImgStringMatch()
+ */
+
+ if (Tcl_ListObjGetElements(interp, rowListPtr[y], &curColCount,
+ &colListPtr) != TCL_OK) {
+ goto errorExit;
+ }
+ for (x = srcX; x < colCount; x++) {
+ if (ParseColor(interp, colListPtr[x], display, colormap,
+ curPixelPtr, curPixelPtr + 1, curPixelPtr + 2,
+ curPixelPtr + 3) != TCL_OK) {
+ goto errorExit;
+ }
+ curPixelPtr += 4;
+ }
+ }
+
+ /*
+ * Write image data to destHandle
+ */
+ if (Tk_PhotoPutBlock(interp, imageHandle, &srcBlock, destX, destY,
+ width, height, TK_PHOTO_COMPOSITE_SET) != TCL_OK) {
+ goto errorExit;
+ }
+
+ ckfree(srcBlock.pixelPtr);
+
+ return TCL_OK;
+
+ errorExit:
+ ckfree(srcBlock.pixelPtr);
+
+ return TCL_ERROR;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * StringWriteDef --
+ *
+ * String write function for default image data format. See the user
+ * documentation for details.
+ *
+ * Results:
+ * The converted data is set as the result of interp. Returns a standard
+ * Tcl result.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+StringWriteDef(
+ Tcl_Interp *interp, /* For the result and errors */
+ Tcl_Obj *formatString, /* The value of the -format option */
+ Tk_PhotoImageBlock *blockPtr) /* The image data to convert */
+{
+ int greenOffset, blueOffset, alphaOffset, hasAlpha;
+ Tcl_Obj *result, **objv = NULL;
+ Tcl_Size objc, allowedOpts, optIndex;
+ struct FormatOptions opts;
+
+ /*
+ * Parse format suboptions
+ */
+ if (Tcl_ListObjGetElements(interp, formatString, &objc, &objv)
+ != TCL_OK) {
+ return TCL_ERROR;
+ }
+ allowedOpts = OPT_COLORFORMAT;
+ optIndex = 0;
+ if (ParseFormatOptions(interp, allowedOpts, objc, objv, &optIndex, &opts)
+ != TCL_OK) {
+ return TCL_ERROR;
+ }
+ if (optIndex < objc) {
+ Tcl_SetObjResult(interp,
+ GetBadOptMsg(Tcl_GetString(objv[optIndex]), allowedOpts));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_OPTION", NULL);
+ return TCL_ERROR;
+ }
+
+ greenOffset = blockPtr->offset[1] - blockPtr->offset[0];
+ blueOffset = blockPtr->offset[2] - blockPtr->offset[0];
+
+ /*
+ * A negative alpha offset signals that the image is fully opaque.
+ * That's not really documented anywhere, but it's the way it is!
+ */
+
+ if (blockPtr->offset[3] < 0) {
+ hasAlpha = 0;
+ alphaOffset = 0;
+ } else {
+ hasAlpha = 1;
+ alphaOffset = blockPtr->offset[3] - blockPtr->offset[0];
+ }
+
+ if ((blockPtr->width > 0) && (blockPtr->height > 0)) {
+ int row, col;
+ Tcl_DString data, line;
+ char colorBuf[11];
+ unsigned char *pixelPtr;
+ unsigned char alphaVal = 255;
+
+ Tcl_DStringInit(&data);
+ for (row=0; row<blockPtr->height; row++) {
+ pixelPtr = blockPtr->pixelPtr + blockPtr->offset[0]
+ + row * blockPtr->pitch;
+ Tcl_DStringInit(&line);
+ for (col=0; col<blockPtr->width; col++) {
+ if (hasAlpha) {
+ alphaVal = pixelPtr[alphaOffset];
+ }
+
+ /*
+ * We don't build lines as a list for #RGBA and #RGB. Since
+ * these color formats look like comments, the first element
+ * of the list would get quoted with an additional {} .
+ * While this is not a problem if the data is used as
+ * a list, it would cause problems if someone decides to parse
+ * it as a string (and it looks kinda strange)
+ */
+
+ switch (opts.colorFormat) {
+ case COLORFORMAT_RGB2:
+ snprintf(colorBuf, sizeof(colorBuf), "#%02x%02x%02x ", pixelPtr[0],
+ pixelPtr[greenOffset], pixelPtr[blueOffset]);
+ Tcl_DStringAppend(&line, colorBuf, TCL_INDEX_NONE);
+ break;
+ case COLORFORMAT_RGBA2:
+ snprintf(colorBuf, sizeof(colorBuf), "#%02x%02x%02x%02x ",
+ pixelPtr[0], pixelPtr[greenOffset],
+ pixelPtr[blueOffset], alphaVal);
+ Tcl_DStringAppend(&line, colorBuf, TCL_INDEX_NONE);
+ break;
+ case COLORFORMAT_LIST:
+ Tcl_DStringStartSublist(&line);
+ snprintf(colorBuf, sizeof(colorBuf), "%d", pixelPtr[0]);
+ Tcl_DStringAppendElement(&line, colorBuf);
+ snprintf(colorBuf, sizeof(colorBuf), "%d", pixelPtr[greenOffset]);
+ Tcl_DStringAppendElement(&line, colorBuf);
+ snprintf(colorBuf, sizeof(colorBuf), "%d", pixelPtr[blueOffset]);
+ Tcl_DStringAppendElement(&line, colorBuf);
+ snprintf(colorBuf, sizeof(colorBuf), "%d", alphaVal);
+ Tcl_DStringAppendElement(&line, colorBuf);
+ Tcl_DStringEndSublist(&line);
+ break;
+ default:
+ Tcl_Panic("unexpected switch fallthrough");
+ }
+ pixelPtr += blockPtr->pixelSize;
+ }
+ if (opts.colorFormat != COLORFORMAT_LIST) {
+ /*
+ * For the #XXX formats, we need to remove the last
+ * whitespace.
+ */
+
+ *(Tcl_DStringValue(&line) + Tcl_DStringLength(&line) - 1)
+ = '\0';
+ }
+ Tcl_DStringAppendElement(&data, Tcl_DStringValue(&line));
+ Tcl_DStringFree(&line);
+ }
+ result = Tcl_NewStringObj(Tcl_DStringValue(&data), TCL_INDEX_NONE);
+ Tcl_DStringFree(&data);
+ } else {
+ result = Tcl_NewObj();
+ }
+
+ Tcl_SetObjResult(interp, result);
+ return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * ParseColor --
+ *
+ * This function extracts color and alpha values from a string. It
+ * understands standard Tk color formats, alpha suffixes and the color
+ * formats specific to photo images, which include alpha data.
+ *
+ * Results:
+ * On success, writes red, green, blue and alpha values to the
+ * corresponding pointers. If the color spec contains no alpha
+ * information, 255 is taken as transparency value.
+ * If the input cannot be parsed, leaves an error message in
+ * interp. Returns a standard Tcl result.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+static int
+ParseColor(
+ Tcl_Interp *interp, /* error messages go there */
+ Tcl_Obj *specObj, /* the color data to parse */
+ Display *display, /* display of main window, needed to parse
+ * standard Tk colors */
+ Colormap colormap, /* colormap of current display */
+ unsigned char *redPtr, /* the result is written to these pointers */
+ unsigned char *greenPtr,
+ unsigned char *bluePtr,
+ unsigned char *alphaPtr)
+{
+ const char *specString;
+ Tcl_Size length;
+
+ /*
+ * Find out which color format we have
+ */
+
+ specString = Tcl_GetStringFromObj(specObj, &length);
+
+ if (length == 0) {
+ /* Empty string */
+ *redPtr = *greenPtr = *bluePtr = *alphaPtr = 0;
+ return TCL_OK;
+ }
+ if (length > TK_PHOTO_MAX_COLOR_LENGTH) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("invalid color"));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
+ "INVALID_COLOR", NULL);
+ return TCL_ERROR;
+ }
+ if (specString[0] == '#') {
+ return ParseColorAsHex(interp, specString, length, display,
+ colormap, redPtr, greenPtr, bluePtr, alphaPtr);
+ }
+ if (ParseColorAsList(specString,
+ redPtr, greenPtr, bluePtr, alphaPtr) == TCL_OK) {
+ return TCL_OK;
+ }
+
+ /*
+ * Parsing the color as standard Tk color always is the last option tried
+ * because TkParseColor() is very slow with values it cannot parse.
+ */
+
+ Tcl_ResetResult(interp);
+ return ParseColorAsStandard(interp, specString, length, display,
+ colormap, redPtr, greenPtr, bluePtr, alphaPtr);
+
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * ParseColorAsList --
+ *
+ * This function extracts color and alpha values from a list of 3 or 4
+ * integers (the list color format).
+ *
+ * Results:
+ * On success, writes red, green, blue and alpha values to the
+ * corresponding pointers. If the color spec contains no alpha
+ * information, 255 is taken as transparency value.
+ * Returns a standard Tcl result.
+ *
+ * Side effects:
+ * None
+ *
+ *----------------------------------------------------------------------
+ */
+static int
+ParseColorAsList(
+ const char *colorString, /* the color data to parse */
+ unsigned char *redPtr, /* the result is written to these pointers */
+ unsigned char *greenPtr,
+ unsigned char *bluePtr,
+ unsigned char *alphaPtr)
+{
+ /*
+ * This is kinda ugly. The code would be certainly nicer if it
+ * used Tcl_ListObjGetElements() and Tcl_GetIntFromObj(). But with
+ * strtol() it's *much* faster.
+ */
+
+ const char *curPos;
+ int values[4];
+ int i;
+
+ curPos = colorString;
+ i = 0;
+
+ /*
+ * strtol can give false positives with a sequence of space chars.
+ * To avoid that, advance the pointer to the next non-blank char.
+ */
+
+ while(isspace(UCHAR(*curPos))) {
+ ++curPos;
+ }
+ while (i < 4 && *curPos != '\0') {
+ values[i] = strtol(curPos, (char **)&curPos, 0);
+ if (values[i] < 0 || values[i] > 255) {
+ return TCL_ERROR;
+ }
+ while(isspace(UCHAR(*curPos))) {
+ ++curPos;
+ }
+ ++i;
+ }
+
+ if (i < 3 || *curPos != '\0') {
+ return TCL_ERROR;
+ }
+ if (i < 4) {
+ values[3] = 255;
+ }
+
+ *redPtr = (unsigned char) values[0];
+ *greenPtr = (unsigned char) values[1];
+ *bluePtr = (unsigned char) values[2];
+ *alphaPtr = (unsigned char) values[3];
+
+ return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * ParseColorAsHex --
+ *
+ * This function extracts color and alpha values from a string
+ * starting with '#', followed by hex digits. It undestands both
+ * the #RGBA form and the #RBG (with optional suffix)
+ *
+ * Results:
+ * On success, writes red, green, blue and alpha values to the
+ * corresponding pointers. If the color spec contains no alpha
+ * information, 255 is taken as transparency value.
+ * Returns a standard Tcl result.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+static int
+ParseColorAsHex(
+ Tcl_Interp *interp, /* error messages are left here */
+ const char *colorString, /* the color data to parse */
+ int colorStrLen, /* length of the color string */
+ Display *display, /* display of main window */
+ Colormap colormap, /* colormap of current display */
+ unsigned char *redPtr, /* the result is written to these pointers */
+ unsigned char *greenPtr,
+ unsigned char *bluePtr,
+ unsigned char *alphaPtr)
+{
+ int i;
+ unsigned long int colorValue = 0;
+
+ if (colorStrLen - 1 != 4 && colorStrLen - 1 != 8) {
+ return ParseColorAsStandard(interp, colorString, colorStrLen,
+ display, colormap, redPtr, greenPtr, bluePtr, alphaPtr);
+ }
+ for (i = 1; i < colorStrLen; i++) {
+ if (!isxdigit(UCHAR(colorString[i]))) {
+ /*
+ * There still is a chance that this is a Tk color with
+ * an alpha suffix
+ */
+
+ return ParseColorAsStandard(interp, colorString, colorStrLen,
+ display, colormap, redPtr, greenPtr, bluePtr, alphaPtr);
+ }
+ }
+
+ colorValue = strtoul(colorString + 1, NULL, 16);
+ switch (colorStrLen - 1) {
+ case 4:
+ /* #RGBA format */
+ *redPtr = (unsigned char) ((colorValue >> 12) * 0x11);
+ *greenPtr = (unsigned char) (((colorValue >> 8) & 0xf) * 0x11);
+ *bluePtr = (unsigned char) (((colorValue >> 4) & 0xf) * 0x11);
+ *alphaPtr = (unsigned char) ((colorValue & 0xf) * 0x11);
+ return TCL_OK;
+ case 8:
+ /* #RRGGBBAA format */
+ *redPtr = (unsigned char) (colorValue >> 24);
+ *greenPtr = (unsigned char) ((colorValue >> 16) & 0xff);
+ *bluePtr = (unsigned char) ((colorValue >> 8) & 0xff);
+ *alphaPtr = (unsigned char) (colorValue & 0xff);
+ return TCL_OK;
+ default:
+ Tcl_Panic("unexpected switch fallthrough");
+ }
+
+ /* Shouldn't get here */
+ return TCL_ERROR;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * ParseColorAsStandard --
+ *
+ * This function tries to split a color stirng in a color and a
+ * suffix part and to extract color and alpha values from them. The
+ * color part is treated as regular Tk color.
+ *
+ * Results:
+ * On success, writes red, green, blue and alpha values to the
+ * corresponding pointers. If the color spec contains no alpha
+ * information, 255 is taken as transparency value.
+ * Returns a standard Tcl result.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+static int
+ParseColorAsStandard(
+ Tcl_Interp *interp, /* error messages are left here */
+ const char *specString, /* the color data to parse */
+ int specStrLen, /* length of the color string */
+ Display *display, /* display of main window */
+ Colormap colormap, /* colormap of current display */
+ unsigned char *redPtr, /* the result is written to these pointers */
+ unsigned char *greenPtr,
+ unsigned char *bluePtr,
+ unsigned char *alphaPtr)
+{
+ XColor parsedColor;
+ const char *suffixString, *colorString;
+ char colorBuffer[TK_PHOTO_MAX_COLOR_LENGTH + 1];
+ double fracAlpha;
+ unsigned int suffixAlpha = 0;
+ int i;
+
+ /*
+ * Split color data string in color and suffix parts
+ */
+
+ if ((suffixString = strrchr(specString, '@')) == NULL
+ && ((suffixString = strrchr(specString, '#')) == NULL
+ || suffixString == specString)) {
+ suffixString = specString + specStrLen;
+ colorString = specString;
+ } else {
+ strncpy(colorBuffer, specString, suffixString - specString);
+ colorBuffer[suffixString - specString] = '\0';
+ colorString = (const char*)colorBuffer;
+ }
+
+ /*
+ * Try to parse as standard Tk color.
+ *
+ * We don't use Tk_GetColor() et al. here, as those functions
+ * migth return a color that does not exaxtly match the given name
+ * if the colormap is full. Also, we don't really want the color to be
+ * added to the colormap.
+ */
+
+ if ( ! TkParseColor(display, colormap, colorString, &parsedColor)) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "invalid color name \"%s\"", specString));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
+ "INVALID_COLOR", NULL);
+ return TCL_ERROR;
+ }
+
+ /*
+ * parse the Suffix
+ */
+
+ switch (suffixString[0]) {
+ case '\0':
+ suffixAlpha = 255;
+ break;
+ case '@':
+ if (Tcl_GetDouble(NULL, suffixString + 1, &fracAlpha) != TCL_OK) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("invalid alpha "
+ "suffix \"%s\": expected floating-point value",
+ suffixString));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
+ "INVALID COLOR", NULL);
+ return TCL_ERROR;
+ }
+ if (fracAlpha < 0 || fracAlpha > 1) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("invalid alpha suffix"
+ " \"%s\": value must be in the range from 0 to 1",
+ suffixString));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
+ "INVALID_COLOR", NULL);
+ return TCL_ERROR;
+ }
+ suffixAlpha = (unsigned int) floor(fracAlpha * 255 + 0.5);
+ break;
+ case '#':
+ if (strlen(suffixString + 1) < 1 || strlen(suffixString + 1)> 2) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "invalid alpha suffix \"%s\"", suffixString));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
+ "INVALID_COLOR", NULL);
+ return TCL_ERROR;
+ }
+ for (i = 1; i <= (int)strlen(suffixString + 1); i++) {
+ if ( ! isxdigit(UCHAR(suffixString[i]))) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "invalid alpha suffix \"%s\": expected hex digit",
+ suffixString));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
+ "INVALID_COLOR", NULL);
+ return TCL_ERROR;
+ }
+ }
+ if (strlen(suffixString + 1) == 1) {
+ sscanf(suffixString, "#%1x", &suffixAlpha);
+ suffixAlpha *= 0x11;
+ } else {
+ sscanf(suffixString, "#%2x", &suffixAlpha);
+ }
+ break;
+ default:
+ Tcl_Panic("unexpected switch fallthrough");
+ }
+
+ *redPtr = (unsigned char) (parsedColor.red >> 8);
+ *greenPtr = (unsigned char) (parsedColor.green >> 8);
+ *bluePtr = (unsigned char) (parsedColor.blue >> 8);
+ *alphaPtr = (unsigned char) suffixAlpha;
+
+ return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkDebugStringMatchDef --
+ *
+ * Debugging function for StringMatchDef. Basically just an alias for
+ * that function, intended to expose it directly to tests, as
+ * StirngMatchDef cannot be sufficiently tested otherwise.
+ *
+ * Results:
+ * See StringMatchDef.
+ *
+ * Side effects:
+ * None
+ *----------------------------------------------------------------------
+ */
+int
+TkDebugPhotoStringMatchDef(
+ Tcl_Interp *interp, /* Error messages are left in this interpreter */
+ Tcl_Obj *data, /* The data to check */
+ Tcl_Obj *formatString, /* Value of the -format option, not used here */
+ int *widthPtr, /* Width of image is written to this location */
+ int *heightPtr) /* Height of image is written to this location */
+{
+ return StringMatchDef(data, formatString, widthPtr, heightPtr, interp);
+}
+
+
+/* Local Variables: */
+/* mode: c */
+/* fill-column: 78 */
+/* c-basic-offset: 4 */
+/* tab-width: 8 */
+/* indent-tabs-mode: nil */
+/* End: */
diff --git a/generic/tkImgPNG.c b/generic/tkImgPNG.c
index 99ba37a..a49ed15 100644
--- a/generic/tkImgPNG.c
+++ b/generic/tkImgPNG.c
@@ -3,8 +3,8 @@
*
* A Tk photo image file handler for PNG files.
*
- * Copyright (c) 2006-2008 Muonics, Inc.
- * Copyright (c) 2008 Donal K. Fellows
+ * Copyright © 2006-2008 Muonics, Inc.
+ * Copyright © 2008 Donal K. Fellows
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -126,7 +126,7 @@ typedef struct {
Tcl_Channel channel; /* Channel for from-file reads. */
Tcl_Obj *objDataPtr;
unsigned char *strDataBuf; /* Raw source data for from-string reads. */
- int strDataLen; /* Length of source data. */
+ Tcl_Size strDataLen; /* Length of source data. */
unsigned char *base64Data; /* base64 encoded string data. */
unsigned char base64Bits; /* Remaining bits from last base64 read. */
unsigned char base64State; /* Current state of base64 decoder. */
@@ -175,6 +175,15 @@ typedef struct {
Tcl_Obj *thisLineObj; /* Current line of pixels to process. */
int lineSize; /* Number of bytes in a PNG line. */
int phaseSize; /* Number of bytes/line in current phase. */
+
+
+ /*
+ * Physical size: pHYS chunks.
+ */
+
+ double DPI;
+ double aspect;
+
} PNGImage;
/*
@@ -199,32 +208,36 @@ static int DecodePNG(Tcl_Interp *interp, PNGImage *pngPtr,
int destX, int destY, int width, int height,
int srcX, int srcY);
static int EncodePNG(Tcl_Interp *interp,
- Tk_PhotoImageBlock *blockPtr, PNGImage *pngPtr);
-static int FileMatchPNG(Tcl_Channel chan, const char *fileName,
- Tcl_Obj *fmtObj, int *widthPtr, int *heightPtr,
- Tcl_Interp *interp);
+ Tk_PhotoImageBlock *blockPtr, PNGImage *pngPtr,
+ Tcl_Obj *metadataInObj);
+static int FileMatchPNG(Tcl_Interp *interp, Tcl_Channel chan,
+ const char *fileName, Tcl_Obj *fmtObj,
+ Tcl_Obj *metadataInObj, int *widthPtr,
+ int *heightPtr, Tcl_Obj *metadataOut);
static int FileReadPNG(Tcl_Interp *interp, Tcl_Channel chan,
const char *fileName, Tcl_Obj *fmtObj,
- Tk_PhotoHandle imageHandle, int destX, int destY,
- int width, int height, int srcX, int srcY);
+ Tcl_Obj *metadataInObj, Tk_PhotoHandle imageHandle,
+ int destX, int destY, int width, int height,
+ int srcX, int srcY, Tcl_Obj *metadataOutPtr);
static int FileWritePNG(Tcl_Interp *interp, const char *filename,
- Tcl_Obj *fmtObj, Tk_PhotoImageBlock *blockPtr);
+ Tcl_Obj *fmtObj, Tcl_Obj *metadataInObj,
+ Tk_PhotoImageBlock *blockPtr);
static int InitPNGImage(Tcl_Interp *interp, PNGImage *pngPtr,
Tcl_Channel chan, Tcl_Obj *objPtr, int dir);
static inline unsigned char Paeth(int a, int b, int c);
static int ParseFormat(Tcl_Interp *interp, Tcl_Obj *fmtObj,
PNGImage *pngPtr);
static int ReadBase64(Tcl_Interp *interp, PNGImage *pngPtr,
- unsigned char *destPtr, int destSz,
+ unsigned char *destPtr, Tcl_Size destSz,
unsigned long *crcPtr);
static int ReadByteArray(Tcl_Interp *interp, PNGImage *pngPtr,
- unsigned char *destPtr, int destSz,
+ unsigned char *destPtr, Tcl_Size destSz,
unsigned long *crcPtr);
static int ReadData(Tcl_Interp *interp, PNGImage *pngPtr,
- unsigned char *destPtr, int destSz,
+ unsigned char *destPtr, Tcl_Size destSz,
unsigned long *crcPtr);
static int ReadChunkHeader(Tcl_Interp *interp, PNGImage *pngPtr,
- int *sizePtr, unsigned long *typePtr,
+ Tcl_Size *sizePtr, unsigned long *typePtr,
unsigned long *crcPtr);
static int ReadIDAT(Tcl_Interp *interp, PNGImage *pngPtr,
int chunkSz, unsigned long crc);
@@ -237,26 +250,30 @@ static int ReadTRNS(Tcl_Interp *interp, PNGImage *pngPtr,
int chunkSz, unsigned long crc);
static int SkipChunk(Tcl_Interp *interp, PNGImage *pngPtr,
int chunkSz, unsigned long crc);
-static int StringMatchPNG(Tcl_Obj *dataObj, Tcl_Obj *fmtObj,
+static int StringMatchPNG(Tcl_Interp *interp, Tcl_Obj *pObjData,
+ Tcl_Obj *fmtObj, Tcl_Obj *metadataInObj,
int *widthPtr, int *heightPtr,
- Tcl_Interp *interp);
-static int StringReadPNG(Tcl_Interp *interp, Tcl_Obj *dataObj,
- Tcl_Obj *fmtObj, Tk_PhotoHandle imageHandle,
+ Tcl_Obj *metadataOutObj);
+static int StringReadPNG(Tcl_Interp *interp, Tcl_Obj *pObjData,
+ Tcl_Obj *fmtObj, Tcl_Obj *metadataInObj,
+ Tk_PhotoHandle imageHandle,
int destX, int destY, int width, int height,
- int srcX, int srcY);
+ int srcX, int srcY, Tcl_Obj *metadataOutObj);
+
static int StringWritePNG(Tcl_Interp *interp, Tcl_Obj *fmtObj,
+ Tcl_Obj *metadataInObj,
Tk_PhotoImageBlock *blockPtr);
static int UnfilterLine(Tcl_Interp *interp, PNGImage *pngPtr);
static inline int WriteByte(Tcl_Interp *interp, PNGImage *pngPtr,
unsigned char c, unsigned long *crcPtr);
static inline int WriteChunk(Tcl_Interp *interp, PNGImage *pngPtr,
unsigned long chunkType,
- const unsigned char *dataPtr, int dataSize);
+ const unsigned char *dataPtr, Tcl_Size dataSize);
static int WriteData(Tcl_Interp *interp, PNGImage *pngPtr,
- const unsigned char *srcPtr, int srcSz,
+ const unsigned char *srcPtr, Tcl_Size srcSz,
unsigned long *crcPtr);
static int WriteExtraChunks(Tcl_Interp *interp,
- PNGImage *pngPtr);
+ PNGImage *pngPtr, Tcl_Obj *metadataInObj);
static int WriteIHDR(Tcl_Interp *interp, PNGImage *pngPtr,
Tk_PhotoImageBlock *blockPtr);
static int WriteIDAT(Tcl_Interp *interp, PNGImage *pngPtr,
@@ -268,7 +285,7 @@ static inline int WriteInt32(Tcl_Interp *interp, PNGImage *pngPtr,
* The format record for the PNG file format:
*/
-Tk_PhotoImageFormat tkImgFmtPNG = {
+Tk_PhotoImageFormatVersion3 tkImgFmtPNG = {
"png", /* name */
FileMatchPNG, /* fileMatchProc */
StringMatchPNG, /* stringMatchProc */
@@ -337,7 +354,7 @@ InitPNGImage(
TCL_ZLIB_COMPRESS_DEFAULT, NULL, &pngPtr->stream) != TCL_OK) {
if (interp) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "zlib initialization failed", -1));
+ "zlib initialization failed", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "ZLIB_INIT", NULL);
}
if (objPtr) {
@@ -346,6 +363,13 @@ InitPNGImage(
return TCL_ERROR;
}
+ /*
+ * Initialize physical size pHYS values
+ */
+
+ pngPtr->DPI = -1;
+ pngPtr->aspect = -1;
+
return TCL_OK;
}
@@ -431,7 +455,7 @@ ReadBase64(
Tcl_Interp *interp,
PNGImage *pngPtr,
unsigned char *destPtr,
- int destSz,
+ Tcl_Size destSz,
unsigned long *crcPtr)
{
static const unsigned char from64[] = {
@@ -521,7 +545,7 @@ ReadBase64(
if (destSz) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "unexpected end of image data", -1));
+ "unexpected end of image data", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "EARLY_END", NULL);
return TCL_ERROR;
}
@@ -556,7 +580,7 @@ ReadByteArray(
Tcl_Interp *interp,
PNGImage *pngPtr,
unsigned char *destPtr,
- int destSz,
+ Tcl_Size destSz,
unsigned long *crcPtr)
{
/*
@@ -565,13 +589,13 @@ ReadByteArray(
if (pngPtr->strDataLen < destSz) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "unexpected end of image data", -1));
+ "unexpected end of image data", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "EARLY_END", NULL);
return TCL_ERROR;
}
while (destSz) {
- int blockSz = PNG_MIN(destSz, PNG_BLOCK_SZ);
+ Tcl_Size blockSz = PNG_MIN(destSz, PNG_BLOCK_SZ);
memcpy(destPtr, pngPtr->strDataBuf, blockSz);
@@ -614,7 +638,7 @@ ReadData(
Tcl_Interp *interp,
PNGImage *pngPtr,
unsigned char *destPtr,
- int destSz,
+ Tcl_Size destSz,
unsigned long *crcPtr)
{
if (pngPtr->base64Data) {
@@ -624,10 +648,10 @@ ReadData(
}
while (destSz) {
- int blockSz = PNG_MIN(destSz, PNG_BLOCK_SZ);
+ Tcl_Size blockSz = PNG_MIN(destSz, PNG_BLOCK_SZ);
blockSz = Tcl_Read(pngPtr->channel, (char *)destPtr, blockSz);
- if (blockSz == -1) {
+ if (blockSz == TCL_IO_FAILURE) {
/* TODO: failure info... */
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"channel read failed: %s", Tcl_PosixError(interp)));
@@ -653,7 +677,7 @@ ReadData(
if (destSz && Tcl_Eof(pngPtr->channel)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "unexpected end of file", -1));
+ "unexpected end of file", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "EOF", NULL);
return TCL_ERROR;
}
@@ -739,7 +763,7 @@ CheckCRC(
*/
if (calculated != chunked) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj("CRC check failed", -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("CRC check failed", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "CRC", NULL);
return TCL_ERROR;
}
@@ -859,7 +883,7 @@ static int
ReadChunkHeader(
Tcl_Interp *interp,
PNGImage *pngPtr,
- int *sizePtr,
+ Tcl_Size *sizePtr,
unsigned long *typePtr,
unsigned long *crcPtr)
{
@@ -934,6 +958,7 @@ ReadChunkHeader(
case CHUNK_IDAT:
case CHUNK_IEND:
case CHUNK_IHDR:
+ case CHUNK_pHYs:
case CHUNK_PLTE:
case CHUNK_tRNS:
break;
@@ -952,7 +977,6 @@ ReadChunkHeader(
case CHUNK_iTXt:
case CHUNK_oFFs:
case CHUNK_pCAL:
- case CHUNK_pHYs:
case CHUNK_sBIT:
case CHUNK_sCAL:
case CHUNK_sPLT:
@@ -1011,7 +1035,7 @@ ReadChunkHeader(
if ((pc[i] < 65) || (pc[i] > 122) ||
((pc[i] > 90) && (pc[i] < 97))) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "invalid chunk type", -1));
+ "invalid chunk type", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG",
"INVALID_CHUNK", NULL);
return TCL_ERROR;
@@ -1112,7 +1136,7 @@ CheckColor(
if ((8 != pngPtr->bitDepth) && (16 != pngPtr->bitDepth)) {
unsupportedDepth:
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "bit depth is not allowed for given color type", -1));
+ "bit depth is not allowed for given color type", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "BAD_DEPTH", NULL);
return TCL_ERROR;
}
@@ -1240,7 +1264,7 @@ ReadIHDR(
{
unsigned char sigBuf[PNG_SIG_SZ];
unsigned long chunkType;
- int chunkSz;
+ Tcl_Size chunkSz;
unsigned long crc;
unsigned long width, height;
int mismatch;
@@ -1277,7 +1301,7 @@ ReadIHDR(
if (mismatch) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "data stream does not have a PNG signature", -1));
+ "data stream does not have a PNG signature", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "NO_SIG", NULL);
return TCL_ERROR;
}
@@ -1295,14 +1319,14 @@ ReadIHDR(
if (chunkType != CHUNK_IHDR) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "expected IHDR chunk type", -1));
+ "expected IHDR chunk type", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "NO_IHDR", NULL);
return TCL_ERROR;
}
if (chunkSz != 13) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "invalid IHDR chunk size", -1));
+ "invalid IHDR chunk size", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "BAD_IHDR", NULL);
return TCL_ERROR;
}
@@ -1446,7 +1470,7 @@ ReadPLTE(
case PNG_COLOR_GRAY:
case PNG_COLOR_GRAYALPHA:
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "PLTE chunk type forbidden for grayscale", -1));
+ "PLTE chunk type forbidden for grayscale", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "PLTE_UNEXPECTED",
NULL);
return TCL_ERROR;
@@ -1463,7 +1487,7 @@ ReadPLTE(
if (!chunkSz || (chunkSz > PNG_PLTE_MAXSZ) || (chunkSz % 3)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "invalid palette chunk size", -1));
+ "invalid palette chunk size", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "BAD_PLTE", NULL);
return TCL_ERROR;
}
@@ -1540,7 +1564,7 @@ ReadTRNS(
if (chunkSz > PNG_TRNS_MAXSZ) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "invalid tRNS chunk size", -1));
+ "invalid tRNS chunk size", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "BAD_TRNS", NULL);
return TCL_ERROR;
}
@@ -1571,7 +1595,7 @@ ReadTRNS(
if (chunkSz > pngPtr->paletteLen) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "size of tRNS chunk is too large for the palette", -1));
+ "size of tRNS chunk is too large for the palette", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "TRNS_SIZE", NULL);
return TCL_ERROR;
}
@@ -1616,7 +1640,7 @@ ReadTRNS(
if (chunkSz != 6) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "invalid tRNS chunk size - must 6 bytes for RGB", -1));
+ "invalid tRNS chunk size - must 6 bytes for RGB", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "BAD_TRNS", NULL);
return TCL_ERROR;
}
@@ -1644,6 +1668,84 @@ ReadTRNS(
/*
*----------------------------------------------------------------------
*
+ * ReadPHYS --
+ *
+ * This function reads the PHYS (physical size) chunk data from
+ * the PNG file and populates the fields in the PNGImage
+ * structure.
+ *
+ * Results:
+ * TCL_OK, or TCL_ERROR if an I/O error occurs or the PHYS chunk is
+ * invalid.
+ *
+ * Side effects:
+ * The access position in f advances.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+ReadPHYS(
+ Tcl_Interp *interp,
+ PNGImage *pngPtr,
+ int chunkSz,
+ unsigned long crc)
+{
+ unsigned long PPUx, PPUy;
+ char unitSpecifier;
+
+ /*
+ * Check chunk size equal 9 bytes
+ */
+
+ if (chunkSz != 9) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "invalid physical chunk size", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "BAD_PHYS", NULL);
+ return TCL_ERROR;
+ }
+
+ /*
+ * Read the chunk data
+ * 4 bytes: Pixels per unit, x axis
+ * 4 bytes: Pixels per unit, y axis
+ * 1 byte: unit specifier
+ */
+
+ if (ReadInt32(interp, pngPtr, &PPUx, &crc) == TCL_ERROR) {
+ return TCL_ERROR;
+ }
+ if (ReadInt32(interp, pngPtr, &PPUy, &crc) == TCL_ERROR) {
+ return TCL_ERROR;
+ }
+ if (ReadData(interp, pngPtr, (unsigned char *)&unitSpecifier, 1, &crc) == TCL_ERROR) {
+ return TCL_ERROR;
+ }
+
+ if (CheckCRC(interp, pngPtr, crc) == TCL_ERROR) {
+ return TCL_ERROR;
+ }
+
+ if ( PPUx > 2147483647 || PPUy > 2147483647
+ || unitSpecifier > 1 ) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "invalid physical size value", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "BAD_PHYS", NULL);
+ return TCL_ERROR;
+ }
+
+ if (PPUx > 0) {
+ pngPtr->aspect = ((double) PPUy) / ((double) PPUx);
+ }
+ if (1 == unitSpecifier) {
+ pngPtr->DPI = ((double) PPUx) * 0.0254;
+ }
+ return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* Paeth --
*
* Utility function for applying the Paeth filter to a pixel. The Paeth
@@ -1709,9 +1811,9 @@ UnfilterLine(
PNGImage *pngPtr)
{
unsigned char *thisLine =
- Tcl_GetByteArrayFromObj(pngPtr->thisLineObj, (int *)NULL);
+ Tcl_GetByteArrayFromObj(pngPtr->thisLineObj, (Tcl_Size *)NULL);
unsigned char *lastLine =
- Tcl_GetByteArrayFromObj(pngPtr->lastLineObj, (int *)NULL);
+ Tcl_GetByteArrayFromObj(pngPtr->lastLineObj, (Tcl_Size *)NULL);
#define PNG_FILTER_NONE 0
#define PNG_FILTER_SUB 1
@@ -1841,7 +1943,7 @@ DecodeLine(
int colStep = 1; /* Column increment each pass */
int pixStep = 0; /* extra pixelPtr increment each pass */
unsigned char lastPixel[6];
- unsigned char *p = Tcl_GetByteArrayFromObj(pngPtr->thisLineObj, (int *)NULL);
+ unsigned char *p = Tcl_GetByteArrayFromObj(pngPtr->thisLineObj, (Tcl_Size *)NULL);
p++;
if (UnfilterLine(interp, pngPtr) == TCL_ERROR) {
@@ -2098,7 +2200,7 @@ ReadIDAT(
*/
while (chunkSz && !Tcl_ZlibStreamEof(pngPtr->stream)) {
- int len1, len2;
+ Tcl_Size len1, len2;
/*
* Read another block of input into the zlib stream if data remains.
@@ -2115,7 +2217,7 @@ ReadIDAT(
if (Tcl_ZlibStreamEof(pngPtr->stream)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "extra data after end of zlib stream", -1));
+ "extra data after end of zlib stream", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "EXTRA_DATA",
NULL);
return TCL_ERROR;
@@ -2154,7 +2256,7 @@ ReadIDAT(
}
Tcl_GetByteArrayFromObj(pngPtr->thisLineObj, &len2);
- if (len2 == pngPtr->phaseSize) {
+ if (len2 == (Tcl_Size)pngPtr->phaseSize) {
if (pngPtr->phase > 7) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"extra data after final scan line of final phase",
@@ -2207,7 +2309,7 @@ ReadIDAT(
if (chunkSz != 0) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "compressed data after stream finalize in PNG data", -1));
+ "compressed data after stream finalize in PNG data", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "EXTRA_DATA", NULL);
return TCL_ERROR;
}
@@ -2292,11 +2394,11 @@ ParseFormat(
PNGImage *pngPtr)
{
Tcl_Obj **objv = NULL;
- int objc = 0;
+ Tcl_Size objc = 0;
static const char *const fmtOptions[] = {
"-alpha", NULL
};
- enum fmtOptions {
+ enum fmtOptionsEnum {
OPT_ALPHA
};
@@ -2333,7 +2435,7 @@ ParseFormat(
objc--;
objv++;
- switch ((enum fmtOptions) optIndex) {
+ switch ((enum fmtOptionsEnum) optIndex) {
case OPT_ALPHA:
if (Tcl_GetDoubleFromObj(interp, objv[0],
&pngPtr->alpha) == TCL_ERROR) {
@@ -2342,7 +2444,7 @@ ParseFormat(
if ((pngPtr->alpha < 0.0) || (pngPtr->alpha > 1.0)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "-alpha value must be between 0.0 and 1.0", -1));
+ "-alpha value must be between 0.0 and 1.0", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "BAD_ALPHA",
NULL);
return TCL_ERROR;
@@ -2388,7 +2490,7 @@ DecodePNG(
{
unsigned long chunkType;
int result;
- int chunkSz;
+ Tcl_Size chunkSz;
unsigned long crc;
/*
@@ -2421,6 +2523,29 @@ DecodePNG(
return TCL_ERROR;
}
+ /*
+ * Physical header may be present here so try to parse it
+ */
+
+ if (CHUNK_pHYs == chunkType) {
+ /*
+ * Finish parsing the PHYS chunk.
+ */
+
+ if (ReadPHYS(interp, pngPtr, chunkSz, crc) == TCL_ERROR) {
+ return TCL_ERROR;
+ }
+
+ /*
+ * Begin the next chunk.
+ */
+
+ if (ReadChunkHeader(interp, pngPtr, &chunkSz, &chunkType,
+ &crc) == TCL_ERROR) {
+ return TCL_ERROR;
+ }
+ }
+
if (CHUNK_PLTE == chunkType) {
/*
* Finish parsing the PLTE chunk.
@@ -2440,7 +2565,7 @@ DecodePNG(
}
} else if (PNG_COLOR_PLTE == pngPtr->colorType) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "PLTE chunk required for indexed color", -1));
+ "PLTE chunk required for indexed color", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "NEED_PLTE", NULL);
return TCL_ERROR;
}
@@ -2472,13 +2597,36 @@ DecodePNG(
}
/*
+ * Physical header may be present here so try to parse it
+ */
+
+ if (CHUNK_pHYs == chunkType) {
+ /*
+ * Finish parsing the PHYS chunk.
+ */
+
+ if (ReadPHYS(interp, pngPtr, chunkSz, crc) == TCL_ERROR) {
+ return TCL_ERROR;
+ }
+
+ /*
+ * Begin the next chunk.
+ */
+
+ if (ReadChunkHeader(interp, pngPtr, &chunkSz, &chunkType,
+ &crc) == TCL_ERROR) {
+ return TCL_ERROR;
+ }
+ }
+
+ /*
* Other ancillary chunk types could appear here, but for now we're only
* interested in IDAT. The others should have been skipped.
*/
if (chunkType != CHUNK_IDAT) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "at least one IDAT chunk is required", -1));
+ "at least one IDAT chunk is required", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "NEED_IDAT", NULL);
return TCL_ERROR;
}
@@ -2529,8 +2677,8 @@ DecodePNG(
pngPtr->block.pixelPtr = (unsigned char *)attemptckalloc(pngPtr->blockLen);
if (!pngPtr->block.pixelPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "memory allocation failed", -1));
- Tcl_SetErrorCode(interp, "TK", "MALLOC", (char *)NULL);
+ "memory allocation failed", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL);
return TCL_ERROR;
}
@@ -2581,7 +2729,7 @@ DecodePNG(
if (!Tcl_ZlibStreamEof(pngPtr->stream)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "unfinalized data stream in PNG data", -1));
+ "unfinalized data stream in PNG data", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "EXTRA_DATA", NULL);
return TCL_ERROR;
}
@@ -2607,7 +2755,7 @@ DecodePNG(
if (chunkSz) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "IEND chunk contents must be empty", -1));
+ "IEND chunk contents must be empty", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "BAD_IEND", NULL);
return TCL_ERROR;
}
@@ -2628,7 +2776,7 @@ DecodePNG(
#if 0
if (ReadData(interp, pngPtr, &c, 1, NULL) != TCL_ERROR) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "extra data following IEND chunk", -1));
+ "extra data following IEND chunk", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "BAD_IEND", NULL);
return TCL_ERROR;
}
@@ -2672,12 +2820,15 @@ DecodePNG(
static int
FileMatchPNG(
- Tcl_Channel chan,
- const char *fileName,
- Tcl_Obj *fmtObj,
- int *widthPtr,
- int *heightPtr,
- Tcl_Interp *interp)
+ Tcl_Interp *interp, /* Interpreter to use for reporting errors. */
+ Tcl_Channel chan, /* The image file, open for reading. */
+ TCL_UNUSED(const char *), /* The name of the image file. */
+ TCL_UNUSED(Tcl_Obj *), /* User-specified format object, or NULL. */
+ TCL_UNUSED(Tcl_Obj *), /* metadata input, may be NULL */
+ int *widthPtr, int *heightPtr,
+ /* The dimensions of the image are returned
+ * here if the file is a valid raw GIF file. */
+ TCL_UNUSED(Tcl_Obj *)) /* metadata return dict, may be NULL */
{
PNGImage png;
int match = 0;
@@ -2718,15 +2869,17 @@ static int
FileReadPNG(
Tcl_Interp* interp, /* Interpreter to use for reporting errors. */
Tcl_Channel chan, /* The image file, open for reading. */
- const char* fileName, /* The name of the image file. */
+ TCL_UNUSED(const char*), /* The name of the image file. */
Tcl_Obj *fmtObj, /* User-specified format object, or NULL. */
+ TCL_UNUSED(Tcl_Obj*), /* metadata input, may be NULL */
Tk_PhotoHandle imageHandle, /* The photo image to write into. */
int destX, int destY, /* Coordinates of top-left pixel in photo
* image to be written to. */
int width, int height, /* Dimensions of block of photo image to be
* written to. */
- int srcX, int srcY) /* Coordinates of top-left pixel to be used in
+ int srcX, int srcY, /* Coordinates of top-left pixel to be used in
* image being read. */
+ Tcl_Obj* metadataOutObj) /* metadata return dict, may be NULL */
{
PNGImage png;
int result = TCL_ERROR;
@@ -2737,6 +2890,18 @@ FileReadPNG(
result = DecodePNG(interp, &png, fmtObj, imageHandle, destX, destY, width, height, srcX, srcY);
}
+ if (TCL_OK == result && metadataOutObj != NULL && png.DPI != -1) {
+ result = Tcl_DictObjPut(NULL, metadataOutObj,
+ Tcl_NewStringObj("DPI",-1),
+ Tcl_NewDoubleObj(png.DPI));
+ }
+
+ if (TCL_OK == result && metadataOutObj != NULL && png.aspect != -1) {
+ result = Tcl_DictObjPut(NULL, metadataOutObj,
+ Tcl_NewStringObj("aspect",-1),
+ Tcl_NewDoubleObj(png.aspect));
+ }
+
CleanupPNGImage(&png);
return result;
}
@@ -2761,11 +2926,13 @@ FileReadPNG(
static int
StringMatchPNG(
- Tcl_Obj *pObjData,
- Tcl_Obj *fmtObj,
- int *widthPtr,
- int *heightPtr,
- Tcl_Interp *interp)
+ Tcl_Interp *interp, /* Interpreter to use for reporting errors. */
+ Tcl_Obj *pObjData, /* the object containing the image data */
+ TCL_UNUSED(Tcl_Obj *), /* the image format object, or NULL */
+ TCL_UNUSED(Tcl_Obj *), /* metadata input, may be NULL */
+ int *widthPtr, /* where to put the string width */
+ int *heightPtr, /* where to put the string height */
+ TCL_UNUSED(Tcl_Obj *)) /* metadata return dict, may be NULL */
{
PNGImage png;
int match = 0;
@@ -2807,13 +2974,15 @@ StringReadPNG(
Tcl_Interp* interp, /* Interpreter to use for reporting errors. */
Tcl_Obj *pObjData,
Tcl_Obj *fmtObj, /* User-specified format object, or NULL. */
+ TCL_UNUSED(Tcl_Obj*), /* metadata input, may be NULL */
Tk_PhotoHandle imageHandle, /* The photo image to write into. */
int destX, int destY, /* Coordinates of top-left pixel in photo
* image to be written to. */
int width, int height, /* Dimensions of block of photo image to be
* written to. */
- int srcX, int srcY) /* Coordinates of top-left pixel to be used in
+ int srcX, int srcY, /* Coordinates of top-left pixel to be used in
* image being read. */
+ Tcl_Obj *metadataOutObj) /* metadata return dict, may be NULL */
{
PNGImage png;
int result = TCL_ERROR;
@@ -2825,6 +2994,18 @@ StringReadPNG(
result = DecodePNG(interp, &png, fmtObj, imageHandle, destX, destY, width, height, srcX, srcY);
}
+ if (TCL_OK == result && metadataOutObj != NULL && png.DPI != -1) {
+ result = Tcl_DictObjPut(NULL, metadataOutObj,
+ Tcl_NewStringObj("DPI",-1),
+ Tcl_NewDoubleObj(png.DPI));
+ }
+
+ if (TCL_OK == result && metadataOutObj != NULL && png.aspect != -1) {
+ result = Tcl_DictObjPut(NULL, metadataOutObj,
+ Tcl_NewStringObj("aspect",-1),
+ Tcl_NewDoubleObj(png.aspect));
+ }
+
CleanupPNGImage(&png);
return result;
}
@@ -2850,7 +3031,7 @@ WriteData(
Tcl_Interp *interp,
PNGImage *pngPtr,
const unsigned char *srcPtr,
- int srcSz,
+ Tcl_Size srcSz,
unsigned long *crcPtr)
{
if (!srcPtr || srcSz <= 0) {
@@ -2867,14 +3048,14 @@ WriteData(
*/
if (pngPtr->objDataPtr) {
- int objSz;
+ Tcl_Size objSz;
unsigned char *destPtr;
Tcl_GetByteArrayFromObj(pngPtr->objDataPtr, &objSz);
- if (objSz > INT_MAX - srcSz) {
+ if (objSz + srcSz > INT_MAX) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "image too large to store completely in byte array", -1));
+ "image too large to store completely in byte array", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "TOO_LARGE", NULL);
return TCL_ERROR;
}
@@ -2883,13 +3064,13 @@ WriteData(
if (!destPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "memory allocation failed", -1));
+ "memory allocation failed", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "MALLOC", NULL);
return TCL_ERROR;
}
memcpy(destPtr+objSz, srcPtr, srcSz);
- } else if (Tcl_Write(pngPtr->channel, (const char *) srcPtr, srcSz) == -1) {
+ } else if (Tcl_Write(pngPtr->channel, (const char *) srcPtr, srcSz) == TCL_IO_FAILURE) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"write to channel failed: %s", Tcl_PosixError(interp)));
return TCL_ERROR;
@@ -2911,6 +3092,34 @@ WriteByte(
/*
*----------------------------------------------------------------------
*
+ * LongToInt32 --
+ *
+ * This function transforms to a 32-bit integer value as
+ * four bytes in network byte order.
+ *
+ * Results:
+ * None
+ *
+ * Side effects:
+ * Buffer will be modified.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static inline void
+LongToInt32(
+ unsigned long l,
+ unsigned char *pc)
+{
+ pc[0] = (unsigned char) ((l & 0xff000000) >> 24);
+ pc[1] = (unsigned char) ((l & 0x00ff0000) >> 16);
+ pc[2] = (unsigned char) ((l & 0x0000ff00) >> 8);
+ pc[3] = (unsigned char) ((l & 0x000000ff) >> 0);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* WriteInt32 --
*
* This function writes a 32-bit integer value out to the PNG image as
@@ -2933,12 +3142,7 @@ WriteInt32(
unsigned long *crcPtr)
{
unsigned char pc[4];
-
- pc[0] = (unsigned char) ((l & 0xff000000) >> 24);
- pc[1] = (unsigned char) ((l & 0x00ff0000) >> 16);
- pc[2] = (unsigned char) ((l & 0x0000ff00) >> 8);
- pc[3] = (unsigned char) ((l & 0x000000ff) >> 0);
-
+ LongToInt32(l,pc);
return WriteData(interp, pngPtr, pc, 4, crcPtr);
}
@@ -2965,7 +3169,7 @@ WriteChunk(
PNGImage *pngPtr,
unsigned long chunkType,
const unsigned char *dataPtr,
- int dataSize)
+ Tcl_Size dataSize)
{
unsigned long crc = Tcl_ZlibCRC32(0, NULL, 0);
int result = TCL_OK;
@@ -3139,7 +3343,7 @@ WriteIDAT(
int rowNum, flush = TCL_ZLIB_NO_FLUSH, result;
Tcl_Obj *outputObj;
unsigned char *outputBytes;
- int outputSize;
+ Tcl_Size outputSize;
/*
* Filter and compress each row one at a time.
@@ -3208,7 +3412,7 @@ WriteIDAT(
if (Tcl_ZlibStreamPut(pngPtr->stream, pngPtr->thisLineObj,
flush) != TCL_OK) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "deflate() returned error", -1));
+ "deflate() returned error", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "DEFLATE", NULL);
return TCL_ERROR;
}
@@ -3230,7 +3434,7 @@ WriteIDAT(
*/
outputObj = Tcl_NewObj();
- (void) Tcl_ZlibStreamGet(pngPtr->stream, outputObj, -1);
+ (void) Tcl_ZlibStreamGet(pngPtr->stream, outputObj, TCL_INDEX_NONE);
outputBytes = Tcl_GetByteArrayFromObj(outputObj, &outputSize);
result = WriteChunk(interp, pngPtr, CHUNK_IDAT, outputBytes, outputSize);
Tcl_DecrRefCount(outputObj);
@@ -3257,7 +3461,8 @@ WriteIDAT(
static int
WriteExtraChunks(
Tcl_Interp *interp,
- PNGImage *pngPtr)
+ PNGImage *pngPtr,
+ Tcl_Obj *metadataInObj)
{
static const unsigned char sBIT_contents[] = {
8, 8, 8, 8
@@ -3299,8 +3504,8 @@ WriteExtraChunks(
Tcl_DStringInit(&buf);
Tcl_DStringAppend(&buf, "Software", 9);
- Tcl_DStringAppend(&buf, "Tk Toolkit v", -1);
- Tcl_DStringAppend(&buf, TK_PATCH_LEVEL, -1);
+ Tcl_DStringAppend(&buf, "Tk Toolkit v", TCL_INDEX_NONE);
+ Tcl_DStringAppend(&buf, TK_PATCH_LEVEL, TCL_INDEX_NONE);
if (WriteChunk(interp, pngPtr, CHUNK_tEXt,
(unsigned char *) Tcl_DStringValue(&buf),
Tcl_DStringLength(&buf)) != TCL_OK) {
@@ -3309,6 +3514,79 @@ WriteExtraChunks(
}
Tcl_DStringFree(&buf);
+ /*
+ * Add a pHYs chunk if there is metadata for DPI and/or aspect
+ * aspect = PPUy / PPUx
+ * DPI = PPUx * 0.0254
+ * The physical chunk consists of:
+ * - Points per meter in x direction (32 bit)
+ * - Points per meter in x direction (32 bit)
+ * - Unit specifier: 0: no unit (only aspect), 1: Points per meter
+ */
+
+ if (metadataInObj != NULL) {
+
+ Tcl_Obj *aspectObj, *DPIObj;
+ double aspectValue=-1, DPIValue=-1;
+ unsigned long PPUx = 65536, PPUy = 65536;
+ char unitSpecifier;
+
+ if (TCL_ERROR == Tcl_DictObjGet(interp, metadataInObj,
+ Tcl_NewStringObj("aspect",-1),
+ &aspectObj) ||
+ TCL_ERROR == Tcl_DictObjGet(interp, metadataInObj,
+ Tcl_NewStringObj("DPI",-1),
+ &DPIObj) ) {
+ return TCL_ERROR;
+ }
+ if (DPIObj != NULL) {
+ if (TCL_ERROR == Tcl_GetDoubleFromObj(interp, DPIObj, &DPIValue))
+ {
+ return TCL_ERROR;
+ }
+ PPUx = (unsigned long)floor(DPIValue / 0.0254+0.5);
+ if (aspectObj == NULL) {
+ PPUy = PPUx;
+ }
+ unitSpecifier = 1;
+ }
+ if (aspectObj != NULL) {
+ if (TCL_ERROR == Tcl_GetDoubleFromObj(interp, aspectObj,
+ &aspectValue)) {
+ return TCL_ERROR;
+ }
+
+ /*
+ * aspect = PPUy / PPUx
+ */
+
+ if (DPIObj == NULL) {
+ unitSpecifier = 0;
+ PPUx = 65536;
+ PPUy = (unsigned long)floor(65536.0 * aspectValue+0.5);
+ } else {
+ PPUy = (unsigned long)floor(DPIValue * aspectValue / 0.0254+0.5);
+ }
+ }
+ if (DPIObj != NULL || aspectObj != NULL) {
+ unsigned char buffer[9];
+
+ if ( PPUx > 2147483647 || PPUy > 2147483647 ) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "DPI or aspect out of range", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "PHYS", NULL);
+ return TCL_ERROR;
+ }
+
+ LongToInt32(PPUx, buffer);
+ LongToInt32(PPUy, buffer+4);
+ buffer[8] = unitSpecifier;
+ if (WriteChunk(interp, pngPtr, CHUNK_pHYs, buffer, 9)
+ != TCL_OK) {
+ return TCL_ERROR;
+ }
+ }
+ }
return TCL_OK;
}
@@ -3334,7 +3612,8 @@ static int
EncodePNG(
Tcl_Interp *interp,
Tk_PhotoImageBlock *blockPtr,
- PNGImage *pngPtr)
+ PNGImage *pngPtr,
+ Tcl_Obj *metadataInObj)
{
int greenOffset, blueOffset, alphaOffset;
@@ -3384,7 +3663,7 @@ EncodePNG(
if ((blockPtr->width > (INT_MAX - 1) / (pngPtr->bytesPerPixel)) ||
(blockPtr->height > INT_MAX / pngPtr->lineSize)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "image is too large to encode pixel data", -1));
+ "image is too large to encode pixel data", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "TOO_LARGE", NULL);
return TCL_ERROR;
}
@@ -3417,7 +3696,7 @@ EncodePNG(
* other programs more than us.
*/
- if (WriteExtraChunks(interp, pngPtr) == TCL_ERROR) {
+ if (WriteExtraChunks(interp, pngPtr, metadataInObj) == TCL_ERROR) {
return TCL_ERROR;
}
@@ -3458,7 +3737,8 @@ static int
FileWritePNG(
Tcl_Interp *interp,
const char *filename,
- Tcl_Obj *fmtObj,
+ TCL_UNUSED(Tcl_Obj *),
+ Tcl_Obj *metadataInObj,
Tk_PhotoImageBlock *blockPtr)
{
Tcl_Channel chan;
@@ -3494,7 +3774,7 @@ FileWritePNG(
* Write the raw PNG data out to the file.
*/
- result = EncodePNG(interp, blockPtr, &png);
+ result = EncodePNG(interp, blockPtr, &png, metadataInObj);
cleanup:
Tcl_Close(interp, chan);
@@ -3523,7 +3803,8 @@ FileWritePNG(
static int
StringWritePNG(
Tcl_Interp *interp,
- Tcl_Obj *fmtObj,
+ TCL_UNUSED(Tcl_Obj *),
+ Tcl_Obj *metadataInObj,
Tk_PhotoImageBlock *blockPtr)
{
Tcl_Obj *resultObj = Tcl_NewObj();
@@ -3544,7 +3825,7 @@ StringWritePNG(
* back to the interpreter if successful.
*/
- result = EncodePNG(interp, blockPtr, &png);
+ result = EncodePNG(interp, blockPtr, &png, metadataInObj);
if (TCL_OK == result) {
Tcl_SetObjResult(interp, png.objDataPtr);
diff --git a/generic/tkImgPPM.c b/generic/tkImgPPM.c
index 9d62a66..a9d0391 100644
--- a/generic/tkImgPPM.c
+++ b/generic/tkImgPPM.c
@@ -3,8 +3,8 @@
*
* A photo image file handler for PPM (Portable PixMap) files.
*
- * Copyright (c) 1994 The Australian National University.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1994 The Australian National University.
+ * Copyright © 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.
@@ -146,7 +146,7 @@ FileReadPPM(
{
int fileWidth, fileHeight, maxIntensity;
int nLines, h, type, bytesPerChannel = 1;
- int nBytes, count;
+ size_t nBytes, count;
unsigned char *pixelPtr;
Tk_PhotoImageBlock block;
@@ -205,7 +205,7 @@ FileReadPPM(
}
if (srcY > 0) {
- Tcl_Seek(chan, (Tcl_WideInt)(srcY * block.pitch), SEEK_CUR);
+ Tcl_Seek(chan, (long long)srcY * block.pitch, SEEK_CUR);
}
nLines = (MAX_MEMORY + block.pitch - 1) / block.pitch;
@@ -290,7 +290,8 @@ FileWritePPM(
Tk_PhotoImageBlock *blockPtr)
{
Tcl_Channel chan;
- int w, h, greenOffset, blueOffset, nBytes;
+ int w, h, greenOffset, blueOffset;
+ size_t nBytes;
unsigned char *pixelPtr, *pixLinePtr;
char header[16 + TCL_INTEGER_SPACE * 2];
@@ -306,7 +307,7 @@ FileWritePPM(
}
snprintf(header, sizeof(header), "P6\n%d %d\n255\n", blockPtr->width, blockPtr->height);
- Tcl_Write(chan, header, -1);
+ Tcl_Write(chan, header, TCL_INDEX_NONE);
pixLinePtr = blockPtr->pixelPtr + blockPtr->offset[0];
greenOffset = blockPtr->offset[1] - blockPtr->offset[0];
@@ -315,16 +316,16 @@ FileWritePPM(
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) {
+ if ((size_t)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) {
+ if (Tcl_Write(chan,(char *)&pixelPtr[0], 1) == TCL_IO_FAILURE ||
+ Tcl_Write(chan,(char *)&pixelPtr[greenOffset],1) == TCL_IO_FAILURE ||
+ Tcl_Write(chan,(char *)&pixelPtr[blueOffset],1) == TCL_IO_FAILURE) {
goto writeerror;
}
pixelPtr += blockPtr->pixelSize;
@@ -497,13 +498,13 @@ StringReadPPM(
&maxIntensity, &dataBuffer, &dataSize);
if (type == 0) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "couldn't read raw PPM header from string", -1));
+ "couldn't read raw PPM header from string", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PPM", "NO_HEADER", NULL);
return TCL_ERROR;
}
if ((fileWidth <= 0) || (fileHeight <= 0)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "PPM image data has dimension(s) <= 0", -1));
+ "PPM image data has dimension(s) <= 0", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PPM", "DIMENSIONS", NULL);
return TCL_ERROR;
}
@@ -555,7 +556,7 @@ StringReadPPM(
if (block.pitch*height > dataSize) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "truncated PPM data", -1));
+ "truncated PPM data", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PPM", "TRUNCATED", NULL);
return TCL_ERROR;
}
@@ -591,7 +592,7 @@ StringReadPPM(
if (dataSize < nBytes) {
ckfree(pixelPtr);
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "truncated PPM data", -1));
+ "truncated PPM data", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PPM", "TRUNCATED", NULL);
return TCL_ERROR;
}
@@ -762,7 +763,7 @@ ReadPPMStringHeader(
#define BUFFER_SIZE 1000
char buffer[BUFFER_SIZE], c;
int i, numFields, type = 0;
- int dataSize;
+ Tcl_Size dataSize;
unsigned char *dataBuffer;
dataBuffer = Tcl_GetByteArrayFromObj(dataPtr, &dataSize);
diff --git a/generic/tkImgPhInstance.c b/generic/tkImgPhInstance.c
index 6c1631b..98a2b41 100644
--- a/generic/tkImgPhInstance.c
+++ b/generic/tkImgPhInstance.c
@@ -5,10 +5,10 @@
* images are stored in full color (32 bits per pixel including alpha
* channel) and displayed using dithering if necessary.
*
- * Copyright (c) 1994 The Australian National University.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
- * Copyright (c) 2002-2008 Donal K. Fellows
- * Copyright (c) 2003 ActiveState Corporation.
+ * Copyright © 1994 The Australian National University.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 2002-2008 Donal K. Fellows
+ * Copyright © 2003 ActiveState Corporation.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -28,8 +28,15 @@
/*
* Declaration for internal Xlib function used here:
*/
-
+#if !defined(_WIN32) && !defined(__CYGWIN__) && !defined(MAC_OSX_TK)
+#ifdef __cplusplus
+extern "C" {
+#endif
extern int _XInitImageFuncPtrs(XImage *image);
+#ifdef __cplusplus
+}
+#endif
+#endif
/*
* Forward declarations
@@ -41,11 +48,11 @@ static void BlendComplexAlpha(XImage *bgImg, PhotoInstance *iPtr,
#endif
static int IsValidPalette(PhotoInstance *instancePtr,
const char *palette);
-static int CountBits(pixel mask);
+static int CountBits(unsigned mask);
static void GetColorTable(PhotoInstance *instancePtr);
static void FreeColorTable(ColorTable *colorPtr, int force);
static void AllocateColors(ColorTable *colorPtr);
-static void DisposeColorTable(ClientData clientData);
+static void DisposeColorTable(void *clientData);
static int ReclaimColors(ColorTableId *id, int numColors);
/*
@@ -81,7 +88,7 @@ void
TkImgPhotoConfigureInstance(
PhotoInstance *instancePtr) /* Instance to reconfigure. */
{
- PhotoModel *modelPtr = instancePtr->masterPtr;
+ PhotoModel *modelPtr = instancePtr->modelPtr;
XImage *imagePtr;
int bitsPerPixel;
ColorTable *colorTablePtr;
@@ -117,7 +124,7 @@ TkImgPhotoConfigureInstance(
*/
if (colorTablePtr != NULL) {
- colorTablePtr->liveRefCount -= 1;
+ colorTablePtr->liveRefCount--;
FreeColorTable(colorTablePtr, 0);
}
GetColorTable(instancePtr);
@@ -207,14 +214,14 @@ TkImgPhotoConfigureInstance(
*----------------------------------------------------------------------
*/
-ClientData
+void *
TkImgPhotoGet(
Tk_Window tkwin, /* Window in which the instance will be
* used. */
- ClientData modelData) /* Pointer to our model structure for the
+ void *modelData) /* Pointer to our model structure for the
* image. */
{
- PhotoModel *modelPtr = modelData;
+ PhotoModel *modelPtr = (PhotoModel *)modelData;
PhotoInstance *instancePtr;
Colormap colormap;
int mono, nRed, nGreen, nBlue, numVisuals;
@@ -287,8 +294,8 @@ TkImgPhotoGet(
* a new instance of the image.
*/
- instancePtr = ckalloc(sizeof(PhotoInstance));
- instancePtr->masterPtr = modelPtr;
+ instancePtr = (PhotoInstance *)ckalloc(sizeof(PhotoInstance));
+ instancePtr->modelPtr = modelPtr;
instancePtr->display = Tk_Display(tkwin);
instancePtr->colormap = Tk_Colormap(tkwin);
Tk_PreserveColormap(instancePtr->display, instancePtr->colormap);
@@ -359,7 +366,7 @@ TkImgPhotoGet(
nRed = 1 << visInfoPtr->depth;
break;
}
- XFree((char *) visInfoPtr);
+ XFree(visInfoPtr);
if (mono) {
snprintf(buf, sizeof(buf), "%d", nRed);
@@ -401,7 +408,7 @@ TkImgPhotoGet(
*/
if (instancePtr->nextPtr == NULL) {
- Tk_ImageChanged(modelPtr->tkMaster, 0, 0, 0, 0,
+ Tk_ImageChanged(modelPtr->tkModel, 0, 0, 0, 0,
modelPtr->width, modelPtr->height);
}
@@ -463,7 +470,7 @@ BlendComplexAlpha(
int x, y, line;
unsigned long pixel;
unsigned char r, g, b, alpha, unalpha, *modelPtr;
- unsigned char *alphaAr = iPtr->masterPtr->pix32;
+ unsigned char *alphaAr = iPtr->modelPtr->pix32;
/*
* This blending is an integer version of the Source-Over compositing rule
@@ -520,7 +527,7 @@ BlendComplexAlpha(
green_mlen = 8 - CountBits(green_mask >> green_shift);
blue_mlen = 8 - CountBits(blue_mask >> blue_shift);
for (y = 0; y < height; y++) {
- line = (y + yOffset) * iPtr->masterPtr->width;
+ line = (y + yOffset) * iPtr->modelPtr->width;
for (x = 0; x < width; x++) {
modelPtr = alphaAr + ((line + x + xOffset) * 4);
alpha = modelPtr[3];
@@ -563,7 +570,7 @@ BlendComplexAlpha(
#endif /* !_WIN32 */
for (y = 0; y < height; y++) {
- line = (y + yOffset) * iPtr->masterPtr->width;
+ line = (y + yOffset) * iPtr->modelPtr->width;
for (x = 0; x < width; x++) {
modelPtr = alphaAr + ((line + x + xOffset) * 4);
alpha = modelPtr[3];
@@ -623,7 +630,7 @@ BlendComplexAlpha(
void
TkImgPhotoDisplay(
- ClientData clientData, /* Pointer to PhotoInstance structure for
+ void *clientData, /* Pointer to PhotoInstance structure for
* instance to be displayed. */
Display *display, /* Display on which to draw image. */
Drawable drawable, /* Pixmap or window in which to draw image. */
@@ -634,7 +641,7 @@ TkImgPhotoDisplay(
int drawableX,int drawableY)/* Coordinates within drawable that correspond
* to imageX and imageY. */
{
- PhotoInstance *instancePtr = clientData;
+ PhotoInstance *instancePtr = (PhotoInstance *)clientData;
#ifndef TK_CAN_RENDER_RGBA
XVisualInfo visInfo = instancePtr->visualInfo;
#endif
@@ -655,7 +662,7 @@ TkImgPhotoDisplay(
* no need to call XGetImage or to do the Porter-Duff compositing by hand.
*/
- unsigned char *rgbaPixels = instancePtr->masterPtr->pix32;
+ unsigned char *rgbaPixels = instancePtr->modelPtr->pix32;
XImage *photo = XCreateImage(display, NULL, 32, ZPixmap, 0, (char*)rgbaPixels,
(unsigned int)instancePtr->width,
(unsigned int)instancePtr->height,
@@ -668,7 +675,7 @@ TkImgPhotoDisplay(
#else
- if ((instancePtr->masterPtr->flags & COMPLEX_ALPHA)
+ if ((instancePtr->modelPtr->flags & COMPLEX_ALPHA)
&& visInfo.depth >= 15
&& (visInfo.c_class == DirectColor || visInfo.c_class == TrueColor)) {
Tk_ErrorHandler handler;
@@ -716,7 +723,7 @@ TkImgPhotoDisplay(
fallBack:
TkSetRegion(display, instancePtr->gc,
- instancePtr->masterPtr->validRegion);
+ instancePtr->modelPtr->validRegion);
XSetClipOrigin(display, instancePtr->gc, drawableX - imageX,
drawableY - imageY);
XCopyArea(display, instancePtr->pixels, drawable, instancePtr->gc,
@@ -749,12 +756,12 @@ TkImgPhotoDisplay(
void
TkImgPhotoFree(
- ClientData clientData, /* Pointer to PhotoInstance structure for
+ void *clientData, /* Pointer to PhotoInstance structure for
* instance to be displayed. */
- Display *display) /* Display containing window that used
+ TCL_UNUSED(Display *)) /* Display containing window that used
* image. */
{
- PhotoInstance *instancePtr = clientData;
+ PhotoInstance *instancePtr = (PhotoInstance *)clientData;
ColorTable *colorPtr;
if (instancePtr->refCount-- > 1) {
@@ -770,7 +777,7 @@ TkImgPhotoFree(
colorPtr = instancePtr->colorTablePtr;
if (colorPtr != NULL) {
- colorPtr->liveRefCount -= 1;
+ colorPtr->liveRefCount--;
}
Tcl_DoWhenIdle(TkImgDisposeInstance, instancePtr);
@@ -804,7 +811,7 @@ TkImgPhotoInstanceSetSize(
XRectangle validBox;
Pixmap newPixmap;
- modelPtr = instancePtr->masterPtr;
+ modelPtr = instancePtr->modelPtr;
TkClipBox(modelPtr->validRegion, &validBox);
if ((instancePtr->width != modelPtr->width)
@@ -854,7 +861,7 @@ TkImgPhotoInstanceSetSize(
* such possibility.
*/
- newError = ckalloc(modelPtr->height * modelPtr->width
+ newError = (schar *)ckalloc(modelPtr->height * modelPtr->width
* 3 * sizeof(schar));
/*
@@ -892,8 +899,8 @@ TkImgPhotoInstanceSetSize(
if (modelPtr->width == instancePtr->width) {
offset = validBox.y * modelPtr->width * 3;
memcpy(newError + offset, instancePtr->error + offset,
- (size_t) (validBox.height
- * modelPtr->width * 3 * sizeof(schar)));
+ (size_t) validBox.height
+ * modelPtr->width * 3 * sizeof(schar));
} else if (validBox.width > 0 && validBox.height > 0) {
errDestPtr = newError +
@@ -1021,7 +1028,7 @@ IsValidPalette(
static int
CountBits(
- pixel mask) /* Value to count the 1 bits in. */
+ unsigned mask) /* Value to count the 1 bits in. */
{
int n;
@@ -1083,13 +1090,13 @@ GetColorTable(
* Re-use the existing entry.
*/
- colorPtr = Tcl_GetHashValue(entry);
+ colorPtr = (ColorTable *)Tcl_GetHashValue(entry);
} else {
/*
* No color table currently available; need to make one.
*/
- colorPtr = ckalloc(sizeof(ColorTable));
+ colorPtr = (ColorTable *)ckalloc(sizeof(ColorTable));
/*
* The following line of code should not normally be needed due to the
@@ -1153,8 +1160,7 @@ FreeColorTable(
* longer required by an instance. */
int force) /* Force free to happen immediately. */
{
- colorPtr->refCount--;
- if (colorPtr->refCount > 0) {
+ if (colorPtr->refCount-- > 1) {
return;
}
@@ -1251,7 +1257,7 @@ AllocateColors(
} else {
numColors = MAX(MAX(nRed, nGreen), nBlue);
}
- colors = ckalloc(numColors * sizeof(XColor));
+ colors = (XColor *)ckalloc(numColors * sizeof(XColor));
for (i = 0; i < numColors; ++i) {
if (igam == 1.0) {
@@ -1271,7 +1277,7 @@ AllocateColors(
*/
numColors = (mono) ? nRed: (nRed * nGreen * nBlue);
- colors = ckalloc(numColors * sizeof(XColor));
+ colors = (XColor *)ckalloc(numColors * sizeof(XColor));
if (!mono) {
/*
@@ -1315,7 +1321,7 @@ AllocateColors(
* Now try to allocate the colors we've calculated.
*/
- pixels = ckalloc(numColors * sizeof(unsigned long));
+ pixels = (unsigned long *)ckalloc(numColors * sizeof(unsigned long));
for (i = 0; i < numColors; ++i) {
if (!XAllocColor(colorPtr->id.display, colorPtr->id.colormap,
&colors[i])) {
@@ -1472,10 +1478,10 @@ AllocateColors(
static void
DisposeColorTable(
- ClientData clientData) /* Pointer to the ColorTable whose
+ void *clientData) /* Pointer to the ColorTable whose
* colors are to be released. */
{
- ColorTable *colorPtr = clientData;
+ ColorTable *colorPtr = (ColorTable *)clientData;
Tcl_HashEntry *entry;
if (colorPtr->pixelMap != NULL) {
@@ -1487,7 +1493,7 @@ DisposeColorTable(
ckfree(colorPtr->pixelMap);
}
- entry = Tcl_FindHashEntry(&imgPhotoColorHash, (char *) &colorPtr->id);
+ entry = Tcl_FindHashEntry(&imgPhotoColorHash, &colorPtr->id);
if (entry == NULL) {
Tcl_Panic("DisposeColorTable couldn't find hash entry");
}
@@ -1535,7 +1541,7 @@ ReclaimColors(
entry = Tcl_FirstHashEntry(&imgPhotoColorHash, &srch);
while (entry != NULL) {
- colorPtr = Tcl_GetHashValue(entry);
+ colorPtr = (ColorTable *)Tcl_GetHashValue(entry);
if ((colorPtr->id.display == id->display)
&& (colorPtr->id.colormap == id->colormap)
&& (colorPtr->liveRefCount == 0 )&& (colorPtr->numColors != 0)
@@ -1564,7 +1570,7 @@ ReclaimColors(
entry = Tcl_FirstHashEntry(&imgPhotoColorHash, &srch);
while ((entry != NULL) && (numColors > 0)) {
- colorPtr = Tcl_GetHashValue(entry);
+ colorPtr = (ColorTable *)Tcl_GetHashValue(entry);
if ((colorPtr->id.display == id->display)
&& (colorPtr->id.colormap == id->colormap)
&& (colorPtr->liveRefCount == 0) && (colorPtr->numColors != 0)
@@ -1606,10 +1612,10 @@ ReclaimColors(
void
TkImgDisposeInstance(
- ClientData clientData) /* Pointer to the instance whose resources are
+ void *clientData) /* Pointer to the instance whose resources are
* to be released. */
{
- PhotoInstance *instancePtr = clientData;
+ PhotoInstance *instancePtr = (PhotoInstance *)clientData;
PhotoInstance *prevPtr;
if (instancePtr->pixels != None) {
@@ -1628,10 +1634,10 @@ TkImgDisposeInstance(
FreeColorTable(instancePtr->colorTablePtr, 1);
}
- if (instancePtr->masterPtr->instancePtr == instancePtr) {
- instancePtr->masterPtr->instancePtr = instancePtr->nextPtr;
+ if (instancePtr->modelPtr->instancePtr == instancePtr) {
+ instancePtr->modelPtr->instancePtr = instancePtr->nextPtr;
} else {
- for (prevPtr = instancePtr->masterPtr->instancePtr;
+ for (prevPtr = instancePtr->modelPtr->instancePtr;
prevPtr->nextPtr != instancePtr; prevPtr = prevPtr->nextPtr) {
/* Empty loop body. */
}
@@ -1665,14 +1671,14 @@ TkImgDitherInstance(
* block to be dithered. */
int width, int height) /* Dimensions of the block to be dithered. */
{
- PhotoModel *modelPtr = instancePtr->masterPtr;
+ PhotoModel *modelPtr = instancePtr->modelPtr;
ColorTable *colorPtr = instancePtr->colorTablePtr;
XImage *imagePtr;
int nLines, bigEndian, i, c, x, y, xEnd, doDithering = 1;
int bitsPerPixel, bytesPerLine, lineLength;
unsigned char *srcLinePtr;
schar *errLinePtr;
- pixel firstBit, word, mask;
+ unsigned firstBit, word, mask;
/*
* Turn dithering off in certain cases where it is not needed (TrueColor,
@@ -1719,7 +1725,7 @@ TkImgDitherInstance(
* recovering from the failure.
*/
- imagePtr->data = ckalloc(imagePtr->bytes_per_line * nLines);
+ imagePtr->data = (char *)ckalloc(imagePtr->bytes_per_line * nLines);
bigEndian = imagePtr->bitmap_bit_order == MSBFirst;
firstBit = bigEndian? (1 << (imagePtr->bitmap_unit - 1)): 1;
@@ -1745,7 +1751,7 @@ TkImgDitherInstance(
unsigned char *srcPtr = srcLinePtr;
schar *errPtr = errLinePtr;
unsigned char *destBytePtr = dstLinePtr;
- pixel *destLongPtr = (pixel *) dstLinePtr;
+ unsigned *destLongPtr = (unsigned *) dstLinePtr;
if (colorPtr->flags & COLOR_WINDOW) {
/*
@@ -1836,7 +1842,7 @@ TkImgDitherInstance(
* sizes.
*/
- case NBBY * sizeof(pixel):
+ case NBBY * sizeof(unsigned):
*destLongPtr++ = i;
break;
#endif
@@ -1898,7 +1904,7 @@ TkImgDitherInstance(
* sizes.
*/
- case NBBY * sizeof(pixel):
+ case NBBY * sizeof(unsigned):
*destLongPtr++ = i;
break;
#endif
@@ -2008,8 +2014,8 @@ TkImgResetDither(
{
if (instancePtr->error) {
memset(instancePtr->error, 0,
- /*(size_t)*/ (instancePtr->masterPtr->width
- * instancePtr->masterPtr->height * 3 * sizeof(schar)));
+ (size_t) instancePtr->modelPtr->width
+ * instancePtr->modelPtr->height * 3 * sizeof(schar));
}
}
diff --git a/generic/tkImgPhoto.c b/generic/tkImgPhoto.c
index 5d5921b..0138e68 100644
--- a/generic/tkImgPhoto.c
+++ b/generic/tkImgPhoto.c
@@ -5,10 +5,10 @@
* full color (32 bits per pixel including alpha channel) and displayed
* using dithering if necessary.
*
- * Copyright (c) 1994 The Australian National University.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
- * Copyright (c) 2002-2003 Donal K. Fellows
- * Copyright (c) 2003 ActiveState Corporation.
+ * Copyright © 1994 The Australian National University.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 2002-2003 Donal K. Fellows
+ * Copyright © 2003 ActiveState Corporation.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -39,6 +39,7 @@ struct SubcommandOptions {
XColor *background; /* Value specified for -background option. */
int compositingRule; /* Value specified for -compositingrule
* option. */
+ Tcl_Obj *metadata; /* Value specified for -metadata option. */
};
/*
@@ -48,26 +49,32 @@ struct SubcommandOptions {
* set in the options field of the SubcommandOptions structure if that option
* was specified.
*
+ * OPT_ALPHA: Set if -alpha option allowed/specified.
* OPT_BACKGROUND: Set if -format option allowed/specified.
* OPT_COMPOSITE: Set if -compositingrule option allowed/spec'd.
* OPT_FORMAT: Set if -format option allowed/specified.
* OPT_FROM: Set if -from option allowed/specified.
* OPT_GRAYSCALE: Set if -grayscale option allowed/specified.
+ * OPT_METADATA: Set if -metadata 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_WITHALPHA: Set if -withalpha option allowed/specified.
* OPT_ZOOM: Set if -zoom option allowed/specified.
*/
-#define OPT_BACKGROUND 1
-#define OPT_COMPOSITE 2
-#define OPT_FORMAT 4
-#define OPT_FROM 8
-#define OPT_GRAYSCALE 0x10
-#define OPT_SHRINK 0x20
-#define OPT_SUBSAMPLE 0x40
-#define OPT_TO 0x80
-#define OPT_ZOOM 0x100
+#define OPT_ALPHA 1
+#define OPT_BACKGROUND 2
+#define OPT_COMPOSITE 4
+#define OPT_FORMAT 8
+#define OPT_FROM 0x10
+#define OPT_GRAYSCALE 0x20
+#define OPT_METADATA 0x40
+#define OPT_SHRINK 0x80
+#define OPT_SUBSAMPLE 0x100
+#define OPT_TO 0x200
+#define OPT_WITHALPHA 0x400
+#define OPT_ZOOM 0x800
/*
* List of option names. The order here must match the order of declarations
@@ -75,14 +82,17 @@ struct SubcommandOptions {
*/
static const char *const optionNames[] = {
+ "-alpha",
"-background",
"-compositingrule",
"-format",
"-from",
"-grayscale",
+ "-metadata",
"-shrink",
"-subsample",
"-to",
+ "-withalpha",
"-zoom",
NULL
};
@@ -100,7 +110,7 @@ static const char *const optionNames[] = {
*/
static int ImgPhotoCreate(Tcl_Interp *interp, const char *name,
- int objc, Tcl_Obj *const objv[],
+ Tcl_Size objc, Tcl_Obj *const objv[],
const Tk_ImageType *typePtr, Tk_ImageModel model,
void **clientDataPtr);
static void ImgPhotoDelete(void *clientData);
@@ -129,9 +139,14 @@ typedef struct {
Tk_PhotoImageFormat *formatList;
/* Pointer to the first in the list of known
* photo image formats.*/
+#if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
Tk_PhotoImageFormat *oldFormatList;
/* Pointer to the first in the list of known
* photo image formats.*/
+#endif
+ Tk_PhotoImageFormatVersion3 *formatListVersion3;
+ /* Pointer to the first in the list of known
+ * photo image formats in Version3 format.*/
int initialized; /* Set to 1 if we've initialized the
* structure. */
} ThreadSpecificData;
@@ -152,19 +167,21 @@ static Tcl_ThreadDataKey dataKey;
static const Tk_ConfigSpec configSpecs[] = {
{TK_CONFIG_STRING, "-data", NULL, NULL,
- NULL, -1, TK_CONFIG_NULL_OK, NULL},
+ NULL, TCL_INDEX_NONE, TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_STRING, "-file", NULL, NULL,
- NULL, Tk_Offset(PhotoModel, fileString), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(PhotoModel, fileString), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_STRING, "-format", NULL, NULL,
- NULL, -1, TK_CONFIG_NULL_OK, NULL},
+ NULL, TCL_INDEX_NONE, TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_DOUBLE, "-gamma", NULL, NULL,
- DEF_PHOTO_GAMMA, Tk_Offset(PhotoModel, gamma), 0, NULL},
+ DEF_PHOTO_GAMMA, offsetof(PhotoModel, gamma), 0, NULL},
{TK_CONFIG_INT, "-height", NULL, NULL,
- DEF_PHOTO_HEIGHT, Tk_Offset(PhotoModel, userHeight), 0, NULL},
+ DEF_PHOTO_HEIGHT, offsetof(PhotoModel, userHeight), 0, NULL},
+ {TK_CONFIG_STRING, "-metadata", NULL, NULL,
+ NULL, TCL_INDEX_NONE, TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_UID, "-palette", NULL, NULL,
- DEF_PHOTO_PALETTE, Tk_Offset(PhotoModel, palette), 0, NULL},
+ DEF_PHOTO_PALETTE, offsetof(PhotoModel, palette), 0, NULL},
{TK_CONFIG_INT, "-width", NULL, NULL,
- DEF_PHOTO_WIDTH, Tk_Offset(PhotoModel, userWidth), 0, NULL},
+ DEF_PHOTO_WIDTH, offsetof(PhotoModel, userWidth), 0, NULL},
{TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}
};
@@ -178,27 +195,30 @@ static int ImgPhotoCmd(void *clientData, Tcl_Interp *interp,
static int ParseSubcommandOptions(
struct SubcommandOptions *optPtr,
Tcl_Interp *interp, int allowedOptions,
- int *indexPtr, int objc, Tcl_Obj *const objv[]);
+ Tcl_Size *indexPtr, Tcl_Size objc, Tcl_Obj *const objv[]);
static void ImgPhotoCmdDeletedProc(void *clientData);
static int ImgPhotoConfigureModel(Tcl_Interp *interp,
- PhotoModel *modelPtr, int objc,
+ PhotoModel *modelPtr, Tcl_Size objc,
Tcl_Obj *const objv[], int flags);
static int ToggleComplexAlphaIfNeeded(PhotoModel *mPtr);
static int ImgPhotoSetSize(PhotoModel *modelPtr, int width,
int height);
-static int ImgStringWrite(Tcl_Interp *interp,
- Tcl_Obj *formatString,
- Tk_PhotoImageBlock *blockPtr);
static char * ImgGetPhoto(PhotoModel *modelPtr,
Tk_PhotoImageBlock *blockPtr,
struct SubcommandOptions *optPtr);
static int MatchFileFormat(Tcl_Interp *interp, Tcl_Channel chan,
const char *fileName, Tcl_Obj *formatString,
+ Tcl_Obj *metadataInObj,
+ Tcl_Obj *metadataOutObj,
Tk_PhotoImageFormat **imageFormatPtr,
+ Tk_PhotoImageFormatVersion3 **imageFormatVersion3Ptr,
int *widthPtr, int *heightPtr, int *oldformat);
static int MatchStringFormat(Tcl_Interp *interp, Tcl_Obj *data,
Tcl_Obj *formatString,
+ Tcl_Obj *metadataInObj,
+ Tcl_Obj *metadataOutObj,
Tk_PhotoImageFormat **imageFormatPtr,
+ Tk_PhotoImageFormatVersion3 **imageFormatVersion3Ptr,
int *widthPtr, int *heightPtr, int *oldformat);
static const char * GetExtension(const char *path);
@@ -223,26 +243,36 @@ PhotoFormatThreadExitProc(
TCL_UNUSED(void *)) /* not used */
{
Tk_PhotoImageFormat *freePtr;
+ Tk_PhotoImageFormatVersion3 *freePtrVersion3;
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+#if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
while (tsdPtr->oldFormatList != NULL) {
freePtr = tsdPtr->oldFormatList;
tsdPtr->oldFormatList = tsdPtr->oldFormatList->nextPtr;
ckfree(freePtr);
}
+#endif
while (tsdPtr->formatList != NULL) {
freePtr = tsdPtr->formatList;
tsdPtr->formatList = tsdPtr->formatList->nextPtr;
- ckfree((char *)freePtr->name);
+ ckfree((void *)freePtr->name);
ckfree(freePtr);
}
+ while (tsdPtr->formatListVersion3 != NULL) {
+ freePtrVersion3 = tsdPtr->formatListVersion3;
+ tsdPtr->formatListVersion3 = tsdPtr->formatListVersion3->nextPtr;
+ ckfree((void *)freePtrVersion3->name);
+ ckfree(freePtrVersion3);
+ }
}
/*
*----------------------------------------------------------------------
*
- * Tk_CreateOldPhotoImageFormat, Tk_CreatePhotoImageFormat --
+ * Tk_CreateOldPhotoImageFormat, Tk_CreatePhotoImageFormat,
+ * Tk_CreatePhotoImageFormatVersion3 --
*
* This function is invoked by an image file handler to register a new
* photo image format and the functions that handle the new format. The
@@ -258,6 +288,7 @@ PhotoFormatThreadExitProc(
*----------------------------------------------------------------------
*/
+#if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
void
Tk_CreateOldPhotoImageFormat(
const Tk_PhotoImageFormat *formatPtr)
@@ -278,6 +309,7 @@ Tk_CreateOldPhotoImageFormat(
copyPtr->nextPtr = tsdPtr->oldFormatList;
tsdPtr->oldFormatList = copyPtr;
}
+#endif
void
Tk_CreatePhotoImageFormat(
@@ -296,10 +328,13 @@ Tk_CreatePhotoImageFormat(
}
copyPtr = (Tk_PhotoImageFormat *)ckalloc(sizeof(Tk_PhotoImageFormat));
*copyPtr = *formatPtr;
+#if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
if (isupper((unsigned char) *formatPtr->name)) {
copyPtr->nextPtr = tsdPtr->oldFormatList;
tsdPtr->oldFormatList = copyPtr;
- } else {
+ } else
+#endif
+ {
/* for compatibility with aMSN: make a copy of formatPtr->name */
char *name = (char *)ckalloc(strlen(formatPtr->name) + 1);
strcpy(name, formatPtr->name);
@@ -308,6 +343,32 @@ Tk_CreatePhotoImageFormat(
tsdPtr->formatList = copyPtr;
}
}
+void
+Tk_CreatePhotoImageFormatVersion3(
+ const Tk_PhotoImageFormatVersion3 *formatPtr)
+ /* Structure describing the format. All of the
+ * fields except "nextPtr" must be filled in
+ * by caller. */
+{
+ Tk_PhotoImageFormatVersion3 *copyPtr;
+ char *name;
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+
+ if (!tsdPtr->initialized) {
+ tsdPtr->initialized = 1;
+ Tcl_CreateThreadExitHandler(PhotoFormatThreadExitProc, NULL);
+ }
+ copyPtr = (Tk_PhotoImageFormatVersion3 *)
+ ckalloc(sizeof(Tk_PhotoImageFormatVersion3));
+ *copyPtr = *formatPtr;
+ /* for compatibility with aMSN: make a copy of formatPtr->name */
+ name = (char *)ckalloc(strlen(formatPtr->name) + 1);
+ strcpy(name, formatPtr->name);
+ copyPtr->name = name;
+ copyPtr->nextPtr = tsdPtr->formatListVersion3;
+ tsdPtr->formatListVersion3 = copyPtr;
+}
/*
*----------------------------------------------------------------------
@@ -331,7 +392,7 @@ ImgPhotoCreate(
Tcl_Interp *interp, /* Interpreter for application containing
* image. */
const char *name, /* Name to use for image. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[], /* Argument objects for options (doesn't
* include image name or type). */
TCL_UNUSED(const Tk_ImageType *),/* Pointer to our type record (not used). */
@@ -348,7 +409,7 @@ ImgPhotoCreate(
modelPtr = (PhotoModel *)ckalloc(sizeof(PhotoModel));
memset(modelPtr, 0, sizeof(PhotoModel));
- modelPtr->tkMaster = model;
+ modelPtr->tkModel = model;
modelPtr->interp = interp;
modelPtr->imageCmd = Tcl_CreateObjCommand(interp, name, ImgPhotoCmd,
modelPtr, ImgPhotoCmdDeletedProc);
@@ -406,15 +467,14 @@ ImgPhotoCmd(
};
PhotoModel *modelPtr = (PhotoModel *)clientData;
- int result, x, y, width, height, dataWidth, dataHeight, listObjc;
- int index;
+ int result, x, y, width, height;
+ Tcl_Size index;
struct SubcommandOptions options;
- Tcl_Obj **listObjv, **srcObjv;
unsigned char *pixelPtr;
Tk_PhotoImageBlock block;
- Tk_Window tkwin;
Tk_PhotoImageFormat *imageFormat;
- int length;
+ Tk_PhotoImageFormatVersion3 *imageFormatVersion3;
+ Tcl_Size length;
int imageWidth, imageHeight, matched, oldformat = 0;
Tcl_Channel chan;
Tk_PhotoHandle srcHandle;
@@ -452,8 +512,7 @@ ImgPhotoCmd(
Tcl_WrongNumArgs(interp, 2, objv, "option");
return TCL_ERROR;
}
- arg = Tcl_GetString(objv[2]);
- length = objv[2]->length;
+ arg = Tcl_GetStringFromObj(objv[2], &length);
if (strncmp(arg,"-data", length) == 0) {
if (modelPtr->dataString) {
Tcl_SetObjResult(interp, modelPtr->dataString);
@@ -462,9 +521,13 @@ ImgPhotoCmd(
if (modelPtr->format) {
Tcl_SetObjResult(interp, modelPtr->format);
}
+ } else if (strncmp(arg, "-metadata", length) == 0) {
+ if (modelPtr->metadata) {
+ Tcl_SetObjResult(interp, modelPtr->metadata);
+ }
} else {
Tk_ConfigureValue(interp, Tk_MainWindow(interp), configSpecs,
- (char *)modelPtr, Tcl_GetString(objv[2]), 0);
+ modelPtr, Tcl_GetString(objv[2]), 0);
}
return TCL_OK;
}
@@ -478,7 +541,7 @@ ImgPhotoCmd(
Tcl_Obj *obj, *subobj;
result = Tk_ConfigureInfo(interp, Tk_MainWindow(interp),
- configSpecs, (char *)modelPtr, NULL, 0);
+ configSpecs, modelPtr, NULL, 0);
if (result != TCL_OK) {
return result;
}
@@ -497,14 +560,20 @@ ImgPhotoCmd(
Tcl_AppendStringsToObj(subobj, " {}", (char *)NULL);
}
Tcl_ListObjAppendElement(interp, obj, subobj);
+ subobj = Tcl_NewStringObj("-metadata {} {} {}", 18);
+ if (modelPtr->metadata) {
+ Tcl_ListObjAppendElement(NULL, subobj, modelPtr->metadata);
+ } else {
+ Tcl_AppendStringsToObj(subobj, " {}", (char *)NULL);
+ }
+ Tcl_ListObjAppendElement(interp, obj, subobj);
Tcl_ListObjAppendList(interp, obj, Tcl_GetObjResult(interp));
Tcl_SetObjResult(interp, obj);
return TCL_OK;
} else if (objc == 3) {
- const char *arg = Tcl_GetString(objv[2]);
+ const char *arg = Tcl_GetStringFromObj(objv[2], &length);
- length = objv[2]->length;
if (length > 1 && !strncmp(arg, "-data", length)) {
Tcl_AppendResult(interp, "-data {} {} {}", (char *)NULL);
if (modelPtr->dataString) {
@@ -532,9 +601,23 @@ ImgPhotoCmd(
Tcl_AppendResult(interp, " {}", (char *)NULL);
}
return TCL_OK;
+ } else if (length > 1 &&
+ !strncmp(arg, "-metadata", length)) {
+ Tcl_AppendResult(interp, "-metadata {} {} {}", (char *)NULL);
+ if (modelPtr->metadata) {
+ /*
+ * TODO: Modifying result is bad!
+ */
+
+ Tcl_ListObjAppendElement(NULL, Tcl_GetObjResult(interp),
+ modelPtr->metadata);
+ } else {
+ Tcl_AppendResult(interp, " {}", (char *)NULL);
+ }
+ return TCL_OK;
} else {
return Tk_ConfigureInfo(interp, Tk_MainWindow(interp),
- configSpecs, (char *) modelPtr, arg, 0);
+ configSpecs, modelPtr, arg, 0);
}
} else {
return ImgPhotoConfigureModel(interp, modelPtr, objc-2, objv+2,
@@ -658,38 +741,43 @@ ImgPhotoCmd(
if (ImgPhotoSetSize(modelPtr, options.toX2,
options.toY2) != TCL_OK) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1));
+ TK_PHOTO_ALLOC_FAILURE_MESSAGE, TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "MALLOC", (char *)NULL);
return TCL_ERROR;
}
}
if (block.pixelPtr || (options.options & OPT_SHRINK)) {
- Tk_ImageChanged(modelPtr->tkMaster, 0, 0, 0, 0,
+ Tk_ImageChanged(modelPtr->tkModel, 0, 0, 0, 0,
modelPtr->width, modelPtr->height);
}
return result;
case PHOTO_DATA: {
- char *data;
+ char *data = NULL;
+ Tcl_Obj *freeObj = NULL;
+ Tcl_Obj *metadataIn;
/*
* photo data command - first parse and check any options given.
*/
Tk_ImageStringWriteProc *stringWriteProc = NULL;
+ Tk_ImageStringWriteProcVersion3 *stringWriteProcVersion3 = NULL;
- index = 2;
+ index = 1;
memset(&options, 0, sizeof(options));
options.name = NULL;
options.format = NULL;
+ options.metadata = NULL;
options.fromX = 0;
options.fromY = 0;
if (ParseSubcommandOptions(&options, interp,
- OPT_FORMAT | OPT_FROM | OPT_GRAYSCALE | OPT_BACKGROUND,
+ OPT_FORMAT | OPT_FROM | OPT_GRAYSCALE | OPT_BACKGROUND
+ | OPT_METADATA,
&index, objc, objv) != TCL_OK) {
return TCL_ERROR;
}
- if ((options.name != NULL) || (index < objc)) {
+ if ((options.name == NULL) || (index < objc)) {
Tcl_WrongNumArgs(interp, 2, objv, "?-option value ...?");
if (options.background) {
Tk_FreeColor(options.background);
@@ -701,7 +789,7 @@ ImgPhotoCmd(
|| (options.fromX2 > modelPtr->width)
|| (options.fromY2 > modelPtr->height)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "coordinates for -from option extend outside image", -1));
+ "coordinates for -from option extend outside image", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", (char *)NULL);
if (options.background) {
Tk_FreeColor(options.background);
@@ -717,17 +805,45 @@ ImgPhotoCmd(
options.fromX2 = modelPtr->width;
options.fromY2 = modelPtr->height;
}
+ if (!(options.options & OPT_FORMAT)) {
+ options.format = Tcl_NewStringObj("default", TCL_INDEX_NONE);
+ freeObj = options.format;
+ }
+
+ /*
+ * Use argument metadata if specified, otherwise the master metadata
+ */
+
+ if (NULL != options.metadata) {
+ metadataIn = options.metadata;
+ } else {
+ metadataIn = modelPtr->metadata;
+ }
/*
* Search for an appropriate image string format handler.
*/
- if (options.options & OPT_FORMAT) {
- matched = 0;
- for (imageFormat = tsdPtr->formatList; imageFormat != NULL;
- imageFormat = imageFormat->nextPtr) {
+ matched = 0;
+ for (imageFormat = tsdPtr->formatList; imageFormat != NULL;
+ imageFormat = imageFormat->nextPtr) {
+ if ((strncasecmp(Tcl_GetString(options.format),
+ imageFormat->name, strlen(imageFormat->name)) == 0)) {
+ matched = 1;
+ if (imageFormat->stringWriteProc != NULL) {
+ stringWriteProc = imageFormat->stringWriteProc;
+ break;
+ }
+ }
+ }
+#if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
+ if (stringWriteProc == NULL) {
+ oldformat = 1;
+ for (imageFormat = tsdPtr->oldFormatList; imageFormat != NULL;
+ imageFormat = imageFormat->nextPtr) {
if ((strncasecmp(Tcl_GetString(options.format),
- imageFormat->name, strlen(imageFormat->name)) == 0)) {
+ imageFormat->name,
+ strlen(imageFormat->name)) == 0)) {
matched = 1;
if (imageFormat->stringWriteProc != NULL) {
stringWriteProc = imageFormat->stringWriteProc;
@@ -735,35 +851,33 @@ ImgPhotoCmd(
}
}
}
- if (stringWriteProc == NULL) {
- oldformat = 1;
- for (imageFormat = tsdPtr->oldFormatList; imageFormat != NULL;
- imageFormat = imageFormat->nextPtr) {
- if ((strncasecmp(Tcl_GetString(options.format),
- imageFormat->name,
- strlen(imageFormat->name)) == 0)) {
- matched = 1;
- if (imageFormat->stringWriteProc != NULL) {
- stringWriteProc = imageFormat->stringWriteProc;
- break;
- }
+ }
+#endif
+ if (stringWriteProc == NULL) {
+ oldformat = 0;
+ for (imageFormatVersion3 = tsdPtr->formatListVersion3;
+ imageFormatVersion3 != NULL;
+ imageFormatVersion3 = imageFormatVersion3->nextPtr) {
+ if ((strncasecmp(Tcl_GetString(options.format),
+ imageFormatVersion3->name,
+ strlen(imageFormatVersion3->name)) == 0)) {
+ matched = 1;
+ if (imageFormatVersion3->stringWriteProc != NULL) {
+ stringWriteProcVersion3 =
+ imageFormatVersion3->stringWriteProc;
+ break;
}
}
}
- if (stringWriteProc == NULL) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "image string format \"%s\" is %s",
- Tcl_GetString(options.format),
- (matched ? "not supported" : "unknown")));
- Tcl_SetErrorCode(interp, "TK", "LOOKUP", "PHOTO_FORMAT",
- Tcl_GetString(options.format), NULL);
- if (options.background) {
- Tk_FreeColor(options.background);
- }
- return TCL_ERROR;
- }
- } else {
- stringWriteProc = ImgStringWrite;
+ }
+ if (stringWriteProc == NULL && stringWriteProcVersion3 == NULL) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "image string format \"%s\" is %s",
+ Tcl_GetString(options.format),
+ (matched ? "not supported" : "unknown")));
+ Tcl_SetErrorCode(interp, "TK", "LOOKUP", "PHOTO_FORMAT",
+ Tcl_GetString(options.format), (char *)NULL);
+ goto dataErrorExit;
}
/*
@@ -772,7 +886,10 @@ ImgPhotoCmd(
data = ImgGetPhoto(modelPtr, &block, &options);
- if (oldformat) {
+ if (stringWriteProc == NULL) {
+ result = (stringWriteProcVersion3)(interp,
+ options.format, metadataIn, &block);
+ } else if (oldformat) {
Tcl_DString buffer;
typedef int (*OldStringWriteProc)(Tcl_Interp *interp,
Tcl_DString *dataPtr, const char *formatString,
@@ -799,7 +916,22 @@ ImgPhotoCmd(
if (data) {
ckfree(data);
}
+ if (freeObj != NULL) {
+ Tcl_DecrRefCount(freeObj);
+ }
return result;
+
+ dataErrorExit:
+ if (options.background) {
+ Tk_FreeColor(options.background);
+ }
+ if (data) {
+ ckfree(data);
+ }
+ if (freeObj != NULL) {
+ Tcl_DecrRefCount(freeObj);
+ }
+ return TCL_ERROR;
}
case PHOTO_GET: {
@@ -807,12 +939,24 @@ ImgPhotoCmd(
* photo get command - first parse and check parameters.
*/
- Tcl_Obj *channels[3];
+ Tcl_Obj *channels[4];
+ int i, channelCount = 3;
- if (objc != 4) {
- Tcl_WrongNumArgs(interp, 2, objv, "x y");
+ index = 3;
+ memset(&options, 0, sizeof(options));
+ options.name = NULL;
+ if (ParseSubcommandOptions(&options, interp, OPT_WITHALPHA,
+ &index, objc, objv) != TCL_OK) {
return TCL_ERROR;
}
+ if (options.name == NULL || index < objc) {
+ Tcl_WrongNumArgs(interp, 2, objv, "x y ?-withalpha?");
+ return TCL_ERROR;
+ }
+ if (options.options & OPT_WITHALPHA) {
+ channelCount = 4;
+ }
+
if ((Tcl_GetIntFromObj(interp, objv[2], &x) != TCL_OK)
|| (Tcl_GetIntFromObj(interp, objv[3], &y) != TCL_OK)) {
return TCL_ERROR;
@@ -832,22 +976,27 @@ ImgPhotoCmd(
*/
pixelPtr = modelPtr->pix32 + (y * modelPtr->width + x) * 4;
- channels[0] = Tcl_NewIntObj(pixelPtr[0]);
- channels[1] = Tcl_NewIntObj(pixelPtr[1]);
- channels[2] = Tcl_NewIntObj(pixelPtr[2]);
- Tcl_SetObjResult(interp, Tcl_NewListObj(3, channels));
+ for (i = 0; i < channelCount; i++) {
+ channels[i] = Tcl_NewWideIntObj(pixelPtr[i]);
+ }
+ Tcl_SetObjResult(interp, Tcl_NewListObj(channelCount, channels));
return TCL_OK;
}
- case PHOTO_PUT:
+ case PHOTO_PUT: {
+ Tcl_Obj *format, *data;
+
/*
- * photo put command - first parse the options and colors specified.
+ * photo put command - first parse the options.
*/
index = 2;
memset(&options, 0, sizeof(options));
options.name = NULL;
- if (ParseSubcommandOptions(&options, interp, OPT_TO|OPT_FORMAT,
+ options.format = NULL;
+ options.metadata = NULL;
+ if (ParseSubcommandOptions(&options, interp,
+ OPT_TO|OPT_FORMAT|OPT_METADATA,
&index, objc, objv) != TCL_OK) {
return TCL_ERROR;
}
@@ -856,174 +1005,65 @@ ImgPhotoCmd(
return TCL_ERROR;
}
- if (MatchStringFormat(interp, options.name ? objv[2]:NULL,
- options.format, &imageFormat, &imageWidth,
- &imageHeight, &oldformat) == TCL_OK) {
- Tcl_Obj *format, *data;
+ /*
+ * See if there's a format that can read the data
+ */
- if (!(options.options & OPT_TO) || (options.toX2 < 0)) {
- options.toX2 = options.toX + imageWidth;
- options.toY2 = options.toY + imageHeight;
- }
- if (imageWidth > options.toX2 - options.toX) {
- imageWidth = options.toX2 - options.toX;
- }
- if (imageHeight > options.toY2 - options.toY) {
- imageHeight = options.toY2 - options.toY;
- }
- format = options.format;
- data = objv[2];
- if (oldformat) {
- if (format) {
- format = (Tcl_Obj *) Tcl_GetString(format);
- }
- data = (Tcl_Obj *) Tcl_GetString(data);
- }
- if (imageFormat->stringReadProc(interp, data, format,
- (Tk_PhotoHandle) modelPtr, options.toX, options.toY,
- imageWidth, imageHeight, 0, 0) != TCL_OK) {
- return TCL_ERROR;
- }
- modelPtr->flags |= IMAGE_CHANGED;
- return TCL_OK;
- }
- if (options.options & OPT_FORMAT) {
- return TCL_ERROR;
- }
- Tcl_ResetResult(interp);
- if (Tcl_ListObjGetElements(interp, options.name,
- &dataHeight, &srcObjv) != TCL_OK) {
+ if (MatchStringFormat(interp, objv[2], options.format,
+ options.metadata, NULL, &imageFormat,
+ &imageFormatVersion3, &imageWidth, &imageHeight, &oldformat)
+ != TCL_OK) {
return TCL_ERROR;
}
- tkwin = Tk_MainWindow(interp);
- block.pixelPtr = NULL;
- dataWidth = 0;
- pixelPtr = NULL;
- for (y = 0; y < dataHeight; ++y) {
- if (Tcl_ListObjGetElements(interp, srcObjv[y],
- &listObjc, &listObjv) != TCL_OK) {
- break;
- }
-
- if (y == 0) {
- if (listObjc == 0) {
- /*
- * Lines must be non-empty...
- */
- break;
- }
- dataWidth = listObjc;
- /*
- * Memory allocation overflow protection.
- * May not be able to trigger/ demo / test this.
- */
-
- if (dataWidth > (int)((UINT_MAX/3) / dataHeight)) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "photo image dimensions exceed Tcl memory limits", -1));
- Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
- "OVERFLOW", NULL);
- break;
- }
-
- pixelPtr = ckalloc(dataWidth * dataHeight * 3);
- block.pixelPtr = pixelPtr;
- } else if (listObjc != dataWidth) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "all elements of color list must have the same"
- " number of elements", -1));
- Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
- "NON_RECTANGULAR", NULL);
- break;
- }
-
- for (x = 0; x < dataWidth; ++x) {
- const char *colorString = Tcl_GetString(listObjv[x]);
- XColor color;
- int tmpr, tmpg, tmpb;
-
- /*
- * We do not use Tk_GetColorFromObj() because we absolutely do
- * not want to invoke the fallback code.
- */
-
- if (colorString[0] == '#') {
- if (isxdigit(UCHAR(colorString[1])) &&
- isxdigit(UCHAR(colorString[2])) &&
- isxdigit(UCHAR(colorString[3]))) {
- if (colorString[4] == '\0') {
- /* Got #rgb */
- sscanf(colorString+1, "%1x%1x%1x",
- &tmpr, &tmpg, &tmpb);
- *pixelPtr++ = tmpr * 0x11;
- *pixelPtr++ = tmpg * 0x11;
- *pixelPtr++ = tmpb * 0x11;
- continue;
- } else if (isxdigit(UCHAR(colorString[4])) &&
- isxdigit(UCHAR(colorString[5])) &&
- isxdigit(UCHAR(colorString[6])) &&
- colorString[7] == '\0') {
- /* Got #rrggbb */
- sscanf(colorString+1, "%2x%2x%2x",
- &tmpr, &tmpg, &tmpb);
- *pixelPtr++ = tmpr;
- *pixelPtr++ = tmpg;
- *pixelPtr++ = tmpb;
- continue;
- }
- }
- }
-
- if (!TkParseColor(Tk_Display(tkwin), Tk_Colormap(tkwin),
- colorString, &color)) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "can't parse color \"%s\"", colorString));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "COLOR", NULL);
- break;
- }
- *pixelPtr++ = color.red >> 8;
- *pixelPtr++ = color.green >> 8;
- *pixelPtr++ = color.blue >> 8;
- }
- if (x < dataWidth) {
- break;
+ if (!(options.options & OPT_TO) || (options.toX2 < 0)) {
+ options.toX2 = options.toX + imageWidth;
+ options.toY2 = options.toY + imageHeight;
+ }
+ if (imageWidth > options.toX2 - options.toX) {
+ imageWidth = options.toX2 - options.toX;
+ }
+ if (imageHeight > options.toY2 - options.toY) {
+ imageHeight = options.toY2 - options.toY;
+ }
+ format = options.format;
+ data = objv[2];
+ if (oldformat) {
+ if (format) {
+ format = (Tcl_Obj *) Tcl_GetString(format);
}
+ data = (Tcl_Obj *) Tcl_GetString(data);
}
- if (y < dataHeight || dataHeight == 0 || dataWidth == 0) {
- if (block.pixelPtr != NULL) {
- ckfree(block.pixelPtr);
+
+ if (imageFormat != NULL) {
+ if (imageFormat->stringReadProc(interp, data, format,
+ (Tk_PhotoHandle) modelPtr, options.toX, options.toY,
+ options.toX2 - options.toX,
+ options.toY2 - options.toY, 0, 0) != TCL_OK) {
+ return TCL_ERROR;
}
- if (y < dataHeight) {
+ } else {
+ if (imageFormatVersion3->stringReadProc(interp, data, format,
+ options.metadata,
+ (Tk_PhotoHandle) modelPtr, options.toX, options.toY,
+ options.toX2 - options.toX,
+ options.toY2 - options.toY, 0, 0,
+ NULL)
+ != TCL_OK) {
return TCL_ERROR;
}
- return TCL_OK;
}
/*
- * Fill in default values for the -to option, then copy the block in
- * using Tk_PhotoPutBlock.
+ * SB: is the next line really needed? The stringReadProc
+ * writes image data with Tk_PhotoPutBlock(), which in turn
+ * takes care to notify the changed image and to set/unset the
+ * IMAGE_CHANGED bit.
*/
+ modelPtr->flags |= IMAGE_CHANGED;
- if (!(options.options & OPT_TO) || (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;
- block.offset[3] = 0;
- result = Tk_PhotoPutBlock(interp, modelPtr, &block,
- options.toX, options.toY, options.toX2 - options.toX,
- options.toY2 - options.toY,
- TK_PHOTO_COMPOSITE_SET);
- ckfree(block.pixelPtr);
- return result;
-
+ return TCL_OK;
+ }
case PHOTO_READ: {
Tcl_Obj *format;
@@ -1035,8 +1075,9 @@ ImgPhotoCmd(
memset(&options, 0, sizeof(options));
options.name = NULL;
options.format = NULL;
+ options.metadata = NULL;
if (ParseSubcommandOptions(&options, interp,
- OPT_FORMAT | OPT_FROM | OPT_TO | OPT_SHRINK,
+ OPT_FORMAT | OPT_FROM | OPT_TO | OPT_SHRINK | OPT_METADATA,
&index, objc, objv) != TCL_OK) {
return TCL_ERROR;
}
@@ -1051,7 +1092,7 @@ ImgPhotoCmd(
if (Tcl_IsSafe(interp)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "can't get image from a file in a safe interpreter", -1));
+ "can't get image from a file in a safe interpreter", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "SAFE", "PHOTO_FILE", (char *)NULL);
return TCL_ERROR;
}
@@ -1072,10 +1113,12 @@ ImgPhotoCmd(
}
if (MatchFileFormat(interp, chan,
- Tcl_GetString(options.name), options.format, &imageFormat,
- &imageWidth, &imageHeight, &oldformat) != TCL_OK) {
- Tcl_Close(NULL, chan);
- return TCL_ERROR;
+ Tcl_GetString(options.name), options.format,
+ options.metadata, NULL, &imageFormat,
+ &imageFormatVersion3, &imageWidth, &imageHeight, &oldformat)
+ != TCL_OK) {
+ result = TCL_ERROR;
+ goto readCleanup;
}
/*
@@ -1089,8 +1132,8 @@ ImgPhotoCmd(
"coordinates for -from option extend outside source image",
-1));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", (char *)NULL);
- Tcl_Close(NULL, chan);
- return TCL_ERROR;
+ result = TCL_ERROR;
+ goto readCleanup;
}
if (!(options.options & OPT_FROM) || (options.fromX2 < 0)) {
width = imageWidth - options.fromX;
@@ -1109,10 +1152,10 @@ ImgPhotoCmd(
options.toY + height) != TCL_OK) {
Tcl_ResetResult(interp);
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1));
+ TK_PHOTO_ALLOC_FAILURE_MESSAGE, TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "MALLOC", (char *)NULL);
- Tcl_Close(NULL, chan);
- return TCL_ERROR;
+ result = TCL_ERROR;
+ goto readCleanup;
}
}
@@ -1125,10 +1168,19 @@ ImgPhotoCmd(
if (oldformat && format) {
format = (Tcl_Obj *) Tcl_GetString(format);
}
- result = imageFormat->fileReadProc(interp, chan,
- Tcl_GetString(options.name),
- format, (Tk_PhotoHandle) modelPtr, options.toX,
- options.toY, width, height, options.fromX, options.fromY);
+ if (imageFormat != NULL) {
+ result = imageFormat->fileReadProc(interp, chan,
+ Tcl_GetString(options.name),
+ format, (Tk_PhotoHandle) modelPtr, options.toX,
+ options.toY, width, height, options.fromX, options.fromY);
+ } else {
+ result = imageFormatVersion3->fileReadProc(interp, chan,
+ Tcl_GetString(options.name),
+ format, options.metadata, (Tk_PhotoHandle) modelPtr,
+ options.toX, options.toY, width, height, options.fromX,
+ options.fromY, NULL);
+ }
+readCleanup:
if (chan != NULL) {
Tcl_Close(NULL, chan);
}
@@ -1164,7 +1216,7 @@ ImgPhotoCmd(
* Tell the core image code that part of the image has changed.
*/
- Tk_ImageChanged(modelPtr->tkMaster, x, y,
+ Tk_ImageChanged(modelPtr->tkModel, x, y,
(modelPtr->width - x), (modelPtr->height - y),
modelPtr->width, modelPtr->height);
}
@@ -1189,14 +1241,40 @@ ImgPhotoCmd(
switch ((enum transOptions) index) {
case PHOTO_TRANS_GET: {
- if (objc != 5) {
- Tcl_WrongNumArgs(interp, 3, objv, "x y");
+ int boolMode;
+
+ /*
+ * parse fixed args and option
+ */
+
+ if (objc > 6 || objc < 5) {
+ Tcl_WrongNumArgs(interp, 3, objv, "x y ?-option?");
return TCL_ERROR;
}
if ((Tcl_GetIntFromObj(interp, objv[3], &x) != TCL_OK)
|| (Tcl_GetIntFromObj(interp, objv[4], &y) != TCL_OK)) {
return TCL_ERROR;
}
+
+ index = 4;
+ memset(&options, 0, sizeof(options));
+ if (ParseSubcommandOptions(&options, interp,
+ OPT_ALPHA, &index, objc, objv) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ if (index < objc) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "unknown option \"%s\": must be -alpha",
+ Tcl_GetString(objv[index])));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_OPTION",
+ (char *)NULL);
+ return TCL_ERROR;
+ }
+ boolMode = 1;
+ if (options.options & OPT_ALPHA) {
+ boolMode = 0;
+ }
+
if ((x < 0) || (x >= modelPtr->width)
|| (y < 0) || (y >= modelPtr->height)) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
@@ -1207,26 +1285,55 @@ ImgPhotoCmd(
return TCL_ERROR;
}
+ /*
+ * Extract and return the desired value
+ */
pixelPtr = modelPtr->pix32 + (y * modelPtr->width + x) * 4;
-
- Tcl_SetObjResult(interp, Tcl_NewBooleanObj(pixelPtr[3] == 0));
+ if (boolMode) {
+ Tcl_SetObjResult(interp, Tcl_NewBooleanObj(pixelPtr[3] == 0));
+ } else {
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(pixelPtr[3]));
+ }
return TCL_OK;
}
case PHOTO_TRANS_SET: {
- int transFlag;
+ int newVal, boolMode;
XRectangle setBox;
+ TkRegion modRegion;
- if (objc != 6) {
- Tcl_WrongNumArgs(interp, 3, objv, "x y boolean");
+ /*
+ * Parse args and option, check for valid values
+ */
+
+ if (objc < 6 || objc > 7) {
+ Tcl_WrongNumArgs(interp, 3, objv, "x y newVal ?-option?");
return TCL_ERROR;
}
if ((Tcl_GetIntFromObj(interp, objv[3], &x) != TCL_OK)
- || (Tcl_GetIntFromObj(interp, objv[4], &y) != TCL_OK)
- || (Tcl_GetBooleanFromObj(interp, objv[5],
- &transFlag) != TCL_OK)) {
+ || (Tcl_GetIntFromObj(interp, objv[4], &y) != TCL_OK)) {
+ return TCL_ERROR;
+ }
+
+ index = 5;
+ memset(&options, 0, sizeof(options));
+ if (ParseSubcommandOptions(&options, interp,
+ OPT_ALPHA, &index, objc, objv) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ if (index < objc) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "unknown option \"%s\": must be -alpha",
+ Tcl_GetString(objv[index])));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_OPTION",
+ (char *)NULL);
return TCL_ERROR;
}
+ boolMode = 1;
+ if (options.options & OPT_ALPHA) {
+ boolMode = 0;
+ }
+
if ((x < 0) || (x >= modelPtr->width)
|| (y < 0) || (y >= modelPtr->height)) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
@@ -1237,45 +1344,60 @@ ImgPhotoCmd(
return TCL_ERROR;
}
+ if (boolMode) {
+ if (Tcl_GetBooleanFromObj(interp, objv[5], &newVal) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ } else {
+ if (Tcl_GetIntFromObj(interp, objv[5], &newVal) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ if (newVal < 0 || newVal > 255) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "invalid alpha value \"%d\": "
+ "must be integer between 0 and 255", newVal));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
+ "BAD_VALUE", (char *)NULL);
+ return TCL_ERROR;
+ }
+ }
+
+ /*
+ * Set new alpha value for the pixel
+ */
+
+ pixelPtr = modelPtr->pix32 + (y * modelPtr->width + x) * 4;
+ if (boolMode) {
+ pixelPtr[3] = newVal ? 0 : 255;
+ } else {
+ pixelPtr[3] = newVal;
+ }
+
+ /*
+ * Update the validRegion of the image
+ */
+
setBox.x = x;
setBox.y = y;
setBox.width = 1;
setBox.height = 1;
- pixelPtr = modelPtr->pix32 + (y * modelPtr->width + x) * 4;
-
- if (transFlag) {
- /*
- * Make pixel transparent.
- */
-
- TkRegion clearRegion = TkCreateRegion();
-
- TkUnionRectWithRegion(&setBox, clearRegion, clearRegion);
- TkSubtractRegion(modelPtr->validRegion, clearRegion,
+ modRegion = TkCreateRegion();
+ TkUnionRectWithRegion(&setBox, modRegion, modRegion);
+ if (pixelPtr[3]) {
+ TkUnionRectWithRegion(&setBox, modelPtr->validRegion,
modelPtr->validRegion);
- TkDestroyRegion(clearRegion);
-
- /*
- * Set the alpha value correctly.
- */
-
- pixelPtr[3] = 0;
} else {
- /*
- * Make pixel opaque.
- */
-
- TkUnionRectWithRegion(&setBox, modelPtr->validRegion,
+ TkSubtractRegion(modelPtr->validRegion, modRegion,
modelPtr->validRegion);
- pixelPtr[3] = 255;
}
+ TkDestroyRegion(modRegion);
/*
* Inform the generic image code that the image
* has (potentially) changed.
*/
- Tk_ImageChanged(modelPtr->tkMaster, x, y, 1, 1,
+ Tk_ImageChanged(modelPtr->tkModel, x, y, 1, 1,
modelPtr->width, modelPtr->height);
modelPtr->flags &= ~IMAGE_CHANGED;
return TCL_OK;
@@ -1288,7 +1410,7 @@ ImgPhotoCmd(
case PHOTO_WRITE: {
char *data;
const char *fmtString;
- Tcl_Obj *format;
+ Tcl_Obj *format, *metadataIn;
int usedExt;
/*
@@ -1297,7 +1419,7 @@ ImgPhotoCmd(
if (Tcl_IsSafe(interp)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "can't write image to a file in a safe interpreter", -1));
+ "can't write image to a file in a safe interpreter", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "SAFE", "PHOTO_FILE", (char *)NULL);
return TCL_ERROR;
}
@@ -1310,8 +1432,10 @@ ImgPhotoCmd(
memset(&options, 0, sizeof(options));
options.name = NULL;
options.format = NULL;
+ options.metadata = NULL;
if (ParseSubcommandOptions(&options, interp,
- OPT_FORMAT | OPT_FROM | OPT_GRAYSCALE | OPT_BACKGROUND,
+ OPT_FORMAT | OPT_FROM | OPT_GRAYSCALE | OPT_BACKGROUND
+ | OPT_METADATA,
&index, objc, objv) != TCL_OK) {
return TCL_ERROR;
}
@@ -1327,7 +1451,7 @@ ImgPhotoCmd(
|| (options.fromX2 > modelPtr->width)
|| (options.fromY2 > modelPtr->height)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "coordinates for -from option extend outside image", -1));
+ "coordinates for -from option extend outside image", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO", "BAD_FROM", (char *)NULL);
if (options.background) {
Tk_FreeColor(options.background);
@@ -1353,6 +1477,17 @@ ImgPhotoCmd(
usedExt = 0;
}
+
+ /*
+ * Use argument metadata if specified, otherwise the master metadata
+ */
+
+ if (NULL != options.metadata) {
+ metadataIn = options.metadata;
+ } else {
+ metadataIn = modelPtr->metadata;
+ }
+
/*
* Search for an appropriate image file format handler, and give an
* error if none is found.
@@ -1360,6 +1495,7 @@ ImgPhotoCmd(
matched = 0;
redoFormatLookup:
+ imageFormatVersion3 = NULL;
for (imageFormat = tsdPtr->formatList; imageFormat != NULL;
imageFormat = imageFormat->nextPtr) {
if ((fmtString == NULL)
@@ -1371,6 +1507,7 @@ ImgPhotoCmd(
}
}
}
+#if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
if (imageFormat == NULL) {
oldformat = 1;
for (imageFormat = tsdPtr->oldFormatList; imageFormat != NULL;
@@ -1385,6 +1522,22 @@ ImgPhotoCmd(
}
}
}
+#endif
+ if (imageFormat == NULL) {
+ oldformat = 0;
+ for (imageFormatVersion3 = tsdPtr->formatListVersion3;
+ imageFormatVersion3 != NULL;
+ imageFormatVersion3 = imageFormatVersion3->nextPtr) {
+ if ((fmtString == NULL)
+ || (strncasecmp(fmtString, imageFormatVersion3->name,
+ strlen(imageFormatVersion3->name)) == 0)) {
+ matched = 1;
+ if (imageFormatVersion3->fileWriteProc != NULL) {
+ break;
+ }
+ }
+ }
+ }
if (usedExt && !matched) {
/*
* If we didn't find one and we're using file extensions as the
@@ -1396,11 +1549,11 @@ ImgPhotoCmd(
fmtString = NULL;
goto redoFormatLookup;
}
- if (imageFormat == NULL) {
+ if (imageFormat == NULL && imageFormatVersion3 == NULL) {
if (fmtString == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"no available image file format has file writing"
- " capability", -1));
+ " capability", TCL_INDEX_NONE));
} else if (!matched) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"image file format \"%s\" is unknown", fmtString));
@@ -1426,8 +1579,14 @@ ImgPhotoCmd(
if (oldformat && format) {
format = (Tcl_Obj *) Tcl_GetString(options.format);
}
- result = imageFormat->fileWriteProc(interp,
- Tcl_GetString(options.name), format, &block);
+ if (imageFormat != NULL) {
+ result = imageFormat->fileWriteProc(interp,
+ Tcl_GetString(options.name), format, &block);
+ } else {
+ result = imageFormatVersion3->fileWriteProc(interp,
+ Tcl_GetString(options.name), format, metadataIn,
+ &block);
+ }
if (options.background) {
Tk_FreeColor(options.background);
}
@@ -1479,13 +1638,18 @@ GetExtension(
*
* This function is invoked to process one of the options which may be
* specified for the photo image subcommands, namely, -from, -to, -zoom,
- * -subsample, -format, -shrink, and -compositingrule.
+ * -subsample, -format, -shrink, -compositingrule, -alpha, -boolean,
+ * -withalpha and -metadata.
+ * Parsing starts at the index in *optIndexPtr and stops at the end of
+ * objv[] or at the first value that does not belong to an option.
*
* Results:
* A standard Tcl result.
*
* Side effects:
- * Fields in *optPtr get filled in.
+ * Fields in *optPtr get filled in. The value of optIndexPtr is updated
+ * to contain the index of the first element in argv[] that was not
+ * parsed, or argc if the end of objv[] was reached.
*
*----------------------------------------------------------------------
*/
@@ -1498,10 +1662,10 @@ ParseSubcommandOptions(
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
+ Tcl_Size *optIndexPtr, /* Points to a variable containing the current
* index in objv; this variable is updated by
* this function. */
- int objc, /* Number of arguments in objv[]. */
+ Tcl_Size objc, /* Number of arguments in objv[]. */
Tcl_Obj *const objv[]) /* Arguments to be parsed. */
{
static const char *const compositingRules[] = {
@@ -1509,7 +1673,7 @@ ParseSubcommandOptions(
* TK_PHOTO_COMPOSITE_* constants. */
NULL
};
- int index, length, argIndex;
+ Tcl_Size index, length, argIndex;
int c, bit, currentBit;
int values[4], numValues, maxValues;
const char *option, *expandedOption, *needed;
@@ -1593,6 +1757,17 @@ ParseSubcommandOptions(
}
*optIndexPtr = ++index;
optPtr->format = objv[index];
+ } else if (bit == OPT_METADATA) {
+ /*
+ * The -metadata option takes a single dict value. Note that
+ * parsing this is outside the scope of this function.
+ */
+
+ if (index + 1 >= objc) {
+ goto oneValueRequired;
+ }
+ *optIndexPtr = ++index;
+ optPtr->metadata = objv[index];
} else if (bit == OPT_COMPOSITE) {
/*
* The -compositingrule option takes a single value from a
@@ -1609,7 +1784,8 @@ ParseSubcommandOptions(
return TCL_ERROR;
}
*optIndexPtr = index;
- } else if ((bit != OPT_SHRINK) && (bit != OPT_GRAYSCALE)) {
+ } else if (bit == OPT_TO || bit == OPT_FROM
+ || bit == OPT_SUBSAMPLE || bit == OPT_ZOOM) {
const char *val;
maxValues = ((bit == OPT_FROM) || (bit == OPT_TO)) ? 4 : 2;
@@ -1742,12 +1918,12 @@ ParseSubcommandOptions(
if (allowedOptions & bit) {
if (allowedOptions & (bit - 1)) {
if (allowedOptions & ~((bit << 1) - 1)) {
- Tcl_AppendToObj(msgObj, ", ", -1);
+ Tcl_AppendToObj(msgObj, ", ", TCL_INDEX_NONE);
} else {
- Tcl_AppendToObj(msgObj, ", or ", -1);
+ Tcl_AppendToObj(msgObj, ", or ", TCL_INDEX_NONE);
}
}
- Tcl_AppendToObj(msgObj, *listPtr, -1);
+ Tcl_AppendToObj(msgObj, *listPtr, TCL_INDEX_NONE);
}
bit <<= 1;
}
@@ -1781,20 +1957,22 @@ ImgPhotoConfigureModel(
Tcl_Interp *interp, /* Interpreter to use for reporting errors. */
PhotoModel *modelPtr, /* Pointer to data structure describing
* overall photo image to (re)configure. */
- int objc, /* Number of entries in objv. */
+ Tcl_Size objc, /* Number of entries in objv. */
Tcl_Obj *const objv[], /* Pairs of configuration options for image. */
int flags) /* Flags to pass to Tk_ConfigureWidget, such
* as TK_CONFIG_ARGV_ONLY. */
{
PhotoInstance *instancePtr;
const char *oldFileString, *oldPaletteString;
- Tcl_Obj *oldData, *data = NULL, *oldFormat, *format = NULL;
+ Tcl_Obj *oldData, *data = NULL, *oldFormat, *format = NULL,
+ *metadataInObj = NULL, *metadataOutObj = NULL;
Tcl_Obj *tempdata, *tempformat;
- int i, length;
+ Tcl_Size i, length;
int result, imageWidth, imageHeight, oldformat;
double oldGamma;
Tcl_Channel chan;
Tk_PhotoImageFormat *imageFormat;
+ Tk_PhotoImageFormatVersion3 *imageFormatVersion3;
for (i = 0; i < objc; i++) {
const char *arg = Tcl_GetStringFromObj(objv[i], &length);
@@ -1805,7 +1983,7 @@ ImgPhotoConfigureModel(
data = objv[i];
} else {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "value for \"-data\" missing", -1));
+ "value for \"-data\" missing", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
"MISSING_VALUE", (char *)NULL);
return TCL_ERROR;
@@ -1816,11 +1994,22 @@ ImgPhotoConfigureModel(
format = objv[i];
} else {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "value for \"-format\" missing", -1));
+ "value for \"-format\" missing", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
"MISSING_VALUE", (char *)NULL);
return TCL_ERROR;
}
+ } else if ((arg[1] == 'm') &&
+ !strncmp(arg, "-metadata", length)) {
+ if (++i < objc) {
+ metadataInObj = objv[i];
+ } else {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "value for \"-metadata\" missing", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
+ "MISSING_VALUE", (char *)NULL);
+ return TCL_ERROR;
+ }
}
}
}
@@ -1858,7 +2047,7 @@ ImgPhotoConfigureModel(
}
/*
- * Regard the empty string for -file, -data or -format as the null value.
+ * Regard the empty string for -file, -data, -format or -metadata as the null value.
*/
if ((modelPtr->fileString != NULL) && (modelPtr->fileString[0] == 0)) {
@@ -1870,7 +2059,7 @@ ImgPhotoConfigureModel(
* Force into ByteArray format, which most (all) image handlers will
* use anyway. Empty length means ignore the -data option.
*/
- int bytesize;
+ Tcl_Size bytesize;
(void) Tcl_GetByteArrayFromObj(data, &bytesize);
if (bytesize) {
@@ -1900,6 +2089,32 @@ ImgPhotoConfigureModel(
}
modelPtr->format = format;
}
+ if (metadataInObj) {
+ /*
+ * Make -metadata a dict.
+ * Take also empty metadatas as this may be a sign to replace
+ * existing metadata.
+ */
+ Tcl_Size dictSize;
+
+ if (TCL_OK != Tcl_DictObjSize(interp,metadataInObj, &dictSize)) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "value for \"-metadata\" not a dict", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
+ "UNRECOGNIZED_DATA", (char *)NULL);
+ return TCL_ERROR;
+ }
+
+ if (dictSize > 0) {
+ Tcl_IncrRefCount(metadataInObj);
+ } else {
+ metadataInObj = NULL;
+ }
+ if (modelPtr->metadata) {
+ Tcl_DecrRefCount(modelPtr->metadata);
+ }
+ modelPtr->metadata = metadataInObj;
+ }
/*
* Set the image to the user-requested size, if any, and make sure storage
* is correctly allocated for this image.
@@ -1908,7 +2123,7 @@ ImgPhotoConfigureModel(
if (ImgPhotoSetSize(modelPtr, modelPtr->width,
modelPtr->height) != TCL_OK) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1));
+ TK_PHOTO_ALLOC_FAILURE_MESSAGE, TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "MALLOC", (char *)NULL);
goto errorExit;
}
@@ -1939,11 +2154,19 @@ ImgPhotoConfigureModel(
goto errorExit;
}
+ /*
+ * Flag that we want the metadata result dict
+ */
+
+ metadataOutObj = Tcl_NewDictObj();
+ Tcl_IncrRefCount(metadataOutObj);
+
if ((Tcl_SetChannelOption(interp, chan, "-translation", "binary")
!= TCL_OK) ||
(MatchFileFormat(interp, chan, modelPtr->fileString,
- modelPtr->format, &imageFormat, &imageWidth,
- &imageHeight, &oldformat) != TCL_OK)) {
+ modelPtr->format, modelPtr->metadata, metadataOutObj,
+ &imageFormat, &imageFormatVersion3,
+ &imageWidth, &imageHeight, &oldformat) != TCL_OK)) {
Tcl_Close(NULL, chan);
goto errorExit;
}
@@ -1951,7 +2174,7 @@ ImgPhotoConfigureModel(
if (result != TCL_OK) {
Tcl_Close(NULL, chan);
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1));
+ TK_PHOTO_ALLOC_FAILURE_MESSAGE, TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "MALLOC", (char *)NULL);
goto errorExit;
}
@@ -1959,9 +2182,19 @@ ImgPhotoConfigureModel(
if (oldformat && tempformat) {
tempformat = (Tcl_Obj *) Tcl_GetString(tempformat);
}
- result = imageFormat->fileReadProc(interp, chan,
- modelPtr->fileString, tempformat, (Tk_PhotoHandle) modelPtr,
- 0, 0, imageWidth, imageHeight, 0, 0);
+ if (imageFormat != NULL) {
+ result = imageFormat->fileReadProc(interp, chan,
+ modelPtr->fileString, tempformat,
+ (Tk_PhotoHandle) modelPtr,
+ 0, 0, imageWidth, imageHeight, 0, 0);
+ } else {
+ result = imageFormatVersion3->fileReadProc(interp, chan,
+ modelPtr->fileString, tempformat, modelPtr->metadata,
+ (Tk_PhotoHandle) modelPtr,
+ 0, 0, imageWidth, imageHeight, 0, 0,
+ metadataOutObj);
+ }
+
Tcl_Close(NULL, chan);
if (result != TCL_OK) {
goto errorExit;
@@ -1975,14 +2208,22 @@ ImgPhotoConfigureModel(
&& ((modelPtr->dataString != oldData)
|| (modelPtr->format != oldFormat))) {
+ /*
+ * Flag that we want the metadata result dict
+ */
+
+ metadataOutObj = Tcl_NewDictObj();
+ Tcl_IncrRefCount(metadataOutObj);
+
if (MatchStringFormat(interp, modelPtr->dataString,
- modelPtr->format, &imageFormat, &imageWidth,
+ modelPtr->format, modelPtr->metadata, metadataOutObj,
+ &imageFormat, &imageFormatVersion3, &imageWidth,
&imageHeight, &oldformat) != TCL_OK) {
goto errorExit;
}
if (ImgPhotoSetSize(modelPtr, imageWidth, imageHeight) != TCL_OK) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1));
+ TK_PHOTO_ALLOC_FAILURE_MESSAGE, TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "MALLOC", (char *)NULL);
goto errorExit;
}
@@ -1994,10 +2235,18 @@ ImgPhotoConfigureModel(
}
tempdata = (Tcl_Obj *) Tcl_GetString(tempdata);
}
- if (imageFormat->stringReadProc(interp, tempdata, tempformat,
- (Tk_PhotoHandle) modelPtr, 0, 0, imageWidth, imageHeight,
- 0, 0) != TCL_OK) {
- goto errorExit;
+ if (imageFormat != NULL) {
+ if (imageFormat->stringReadProc(interp, tempdata, tempformat,
+ (Tk_PhotoHandle) modelPtr, 0, 0, imageWidth, imageHeight,
+ 0, 0) != TCL_OK) {
+ goto errorExit;
+ }
+ } else {
+ if (imageFormatVersion3->stringReadProc(interp, tempdata, tempformat,
+ modelPtr->metadata, (Tk_PhotoHandle) modelPtr, 0, 0,
+ imageWidth, imageHeight, 0, 0, metadataOutObj) != TCL_OK) {
+ goto errorExit;
+ }
}
Tcl_ResetResult(interp);
@@ -2005,6 +2254,49 @@ ImgPhotoConfigureModel(
}
/*
+ * Merge driver returned metadata and master metadata
+ */
+ if (metadataOutObj != NULL) {
+ Tcl_Size dictSize;
+ if (TCL_OK != Tcl_DictObjSize(interp,metadataOutObj, &dictSize)) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "driver metadata not a dict", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
+ "UNRECOGNIZED_DATA", (char *)NULL);
+ goto errorExit;
+ }
+ if (dictSize > 0) {
+
+ /*
+ * We have driver return metadata
+ */
+
+ if (modelPtr->metadata == NULL) {
+ modelPtr->metadata = metadataOutObj;
+ metadataOutObj = NULL;
+ } else {
+ Tcl_DictSearch search;
+ Tcl_Obj *key, *value;
+ int done;
+
+ if (Tcl_IsShared(modelPtr->metadata)) {
+ Tcl_DecrRefCount(modelPtr->metadata);
+ modelPtr->metadata = Tcl_DuplicateObj(modelPtr->metadata);
+ Tcl_IncrRefCount(modelPtr->metadata);
+ }
+
+ if (Tcl_DictObjFirst(interp, metadataOutObj, &search, &key,
+ &value, &done) != TCL_OK) {
+ goto errorExit;
+ }
+ for (; !done ; Tcl_DictObjNext(&search, &key, &value, &done)) {
+ Tcl_DictObjPut(interp, modelPtr->metadata, key, value);
+ }
+ }
+ }
+ }
+
+ /*
* Enforce a reasonable value for gamma.
*/
@@ -2032,7 +2324,7 @@ ImgPhotoConfigureModel(
* Inform the generic image code that the image has (potentially) changed.
*/
- Tk_ImageChanged(modelPtr->tkMaster, 0, 0, modelPtr->width,
+ Tk_ImageChanged(modelPtr->tkModel, 0, 0, modelPtr->width,
modelPtr->height, modelPtr->width, modelPtr->height);
modelPtr->flags &= ~IMAGE_CHANGED;
@@ -2042,6 +2334,9 @@ ImgPhotoConfigureModel(
if (oldFormat != NULL) {
Tcl_DecrRefCount(oldFormat);
}
+ if (metadataOutObj != NULL) {
+ Tcl_DecrRefCount(metadataOutObj);
+ }
ToggleComplexAlphaIfNeeded(modelPtr);
@@ -2054,6 +2349,9 @@ ImgPhotoConfigureModel(
if (oldFormat != NULL) {
Tcl_DecrRefCount(oldFormat);
}
+ if (metadataOutObj != NULL) {
+ Tcl_DecrRefCount(metadataOutObj);
+ }
return TCL_ERROR;
}
@@ -2136,7 +2434,7 @@ ImgPhotoDelete(
Tcl_CancelIdleCall(TkImgDisposeInstance, instancePtr);
TkImgDisposeInstance(instancePtr);
}
- modelPtr->tkMaster = NULL;
+ modelPtr->tkModel = NULL;
if (modelPtr->imageCmd != NULL) {
Tcl_DeleteCommandFromToken(modelPtr->interp, modelPtr->imageCmd);
}
@@ -2152,7 +2450,10 @@ ImgPhotoDelete(
if (modelPtr->format != NULL) {
Tcl_DecrRefCount(modelPtr->format);
}
- Tk_FreeOptions(configSpecs, (char *) modelPtr, NULL, 0);
+ if (modelPtr->metadata != NULL) {
+ Tcl_DecrRefCount(modelPtr->metadata);
+ }
+ Tk_FreeOptions(configSpecs, modelPtr, NULL, 0);
ckfree(modelPtr);
}
@@ -2181,8 +2482,8 @@ ImgPhotoCmdDeletedProc(
PhotoModel *modelPtr = (PhotoModel *)clientData;
modelPtr->imageCmd = NULL;
- if (modelPtr->tkMaster != NULL) {
- Tk_DeleteImage(modelPtr->interp, Tk_NameOfImage(modelPtr->tkMaster));
+ if (modelPtr->tkModel != NULL) {
+ Tk_DeleteImage(modelPtr->interp, Tk_NameOfImage(modelPtr->tkModel));
}
}
@@ -2388,9 +2689,9 @@ ImgPhotoSetSize(
*
* 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.
+ * to the image format record is returned in *imageFormatPtr or
+ * *imageFormatVersion3Ptr, and the width and height of the image are
+ * returned in *widthPtr and *heightPtr.
*
* Side effects:
* None.
@@ -2404,9 +2705,16 @@ MatchFileFormat(
Tcl_Channel chan, /* The image file, open for reading. */
const char *fileName, /* The name of the image file. */
Tcl_Obj *formatObj, /* User-specified format string, or NULL. */
+ Tcl_Obj *metadataInObj, /* User-specified metadata, may be NULL */
+ Tcl_Obj *metadataOutObj, /* metadata to return, may be NULL */
Tk_PhotoImageFormat **imageFormatPtr,
/* A pointer to the photo image format record
- * is returned here. */
+ * is returned here. For formatVersion3, this is
+ * set to NULL */
+ Tk_PhotoImageFormatVersion3 **imageFormatVersion3Ptr,
+ /* A pointer to the photo image formatVersion3
+ * record is returned here. For non
+ * formatVersion3, this is set to NULL*/
int *widthPtr, int *heightPtr,
/* The dimensions of the image are returned
* here. */
@@ -2415,6 +2723,7 @@ MatchFileFormat(
int matched = 0;
int useoldformat = 0;
Tk_PhotoImageFormat *formatPtr;
+ Tk_PhotoImageFormatVersion3 *formatVersion3Ptr;
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
const char *formatString = NULL;
@@ -2460,7 +2769,8 @@ MatchFileFormat(
}
}
}
- if (formatPtr == NULL) {
+#if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
+if (formatPtr == NULL) {
useoldformat = 1;
for (formatPtr = tsdPtr->oldFormatList; formatPtr != NULL;
formatPtr = formatPtr->nextPtr) {
@@ -2494,28 +2804,99 @@ MatchFileFormat(
}
}
}
+#endif
- if (formatPtr == NULL) {
- if ((formatObj != NULL) && !matched) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "image file format \"%s\" is not supported",
- formatString));
- Tcl_SetErrorCode(interp, "TK", "LOOKUP", "PHOTO_FORMAT",
- formatString, (char *)NULL);
- } else {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "couldn't recognize data in image file \"%s\"",
- fileName));
- Tcl_SetErrorCode(interp, "TK", "PHOTO", "IMAGE",
- "UNRECOGNIZED_DATA", (char *)NULL);
+ /*
+ * For old and not version 3 format, exit now with success
+ */
+
+ if (formatPtr != NULL) {
+ *imageFormatPtr = formatPtr;
+ *imageFormatVersion3Ptr = NULL;
+ *oldformat = useoldformat;
+ (void) Tcl_Seek(chan, Tcl_LongAsWide(0L), SEEK_SET);
+ return TCL_OK;
+ }
+
+ /*
+ * Scan through the table of file format version 3 handlers to find one
+ * which can handle the image.
+ */
+
+ for (formatVersion3Ptr = tsdPtr->formatListVersion3;
+ formatVersion3Ptr != NULL;
+ formatVersion3Ptr = formatVersion3Ptr->nextPtr) {
+ if (formatObj != NULL) {
+ if (strncasecmp(formatString,
+ formatVersion3Ptr->name, strlen(formatVersion3Ptr->name))
+ != 0) {
+ continue;
+ }
+ matched = 1;
+ if (formatVersion3Ptr->fileMatchProc == NULL) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "-file option isn't supported for %s images",
+ formatString));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
+ "NOT_FILE_FORMAT", (char *)NULL);
+ return TCL_ERROR;
+ }
+ }
+ if (formatVersion3Ptr->fileMatchProc != NULL) {
+ (void) Tcl_Seek(chan, Tcl_LongAsWide(0L), SEEK_SET);
+
+ if (formatVersion3Ptr->fileMatchProc(interp, chan, fileName,
+ formatObj, metadataInObj, widthPtr, heightPtr,
+ metadataOutObj)) {
+ if (*widthPtr < 1) {
+ *widthPtr = 1;
+ }
+ if (*heightPtr < 1) {
+ *heightPtr = 1;
+ }
+ *imageFormatVersion3Ptr = formatVersion3Ptr;
+ *imageFormatPtr = NULL;
+ *oldformat = 0;
+ (void) Tcl_Seek(chan, Tcl_LongAsWide(0L), SEEK_SET);
+ return TCL_OK;
+ }
+
+ /*
+ * Check if driver has shared or changed the metadata Tcl object.
+ * In this case, release and recreate it.
+ */
+
+ if (metadataOutObj != NULL) {
+ Tcl_Size dictSize;
+ if (Tcl_IsShared(metadataOutObj)
+ || TCL_OK != Tcl_DictObjSize(interp,metadataOutObj, &dictSize)
+ || dictSize > 0) {
+ Tcl_DecrRefCount(metadataOutObj);
+ metadataOutObj = Tcl_NewDictObj();
+ Tcl_IncrRefCount(metadataOutObj);
+ }
+ }
}
- return TCL_ERROR;
}
- *imageFormatPtr = formatPtr;
- *oldformat = useoldformat;
- (void) Tcl_Seek(chan, Tcl_LongAsWide(0L), SEEK_SET);
- return TCL_OK;
+ /*
+ * No matching format found
+ */
+
+ if ((formatObj != NULL) && !matched) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "image file format \"%s\" is not supported",
+ formatString));
+ Tcl_SetErrorCode(interp, "TK", "LOOKUP", "PHOTO_FORMAT",
+ formatString, (char *)NULL);
+ } else {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "couldn't recognize data in image file \"%s\"",
+ fileName));
+ Tcl_SetErrorCode(interp, "TK", "PHOTO", "IMAGE",
+ "UNRECOGNIZED_DATA", (char *)NULL);
+ }
+ return TCL_ERROR;
}
/*
@@ -2530,9 +2911,9 @@ MatchFileFormat(
*
* 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.
+ * to the image format record is returned in *imageFormatPtr or
+ * *imageFormatVersion3Ptr, and the width and height of the image are
+ * returned in *widthPtr and *heightPtr.
*
* Side effects:
* None.
@@ -2545,16 +2926,24 @@ MatchStringFormat(
Tcl_Interp *interp, /* Interpreter to use for reporting errors. */
Tcl_Obj *data, /* Object containing the image data. */
Tcl_Obj *formatObj, /* User-specified format string, or NULL. */
+ Tcl_Obj *metadataInObj, /* User-specified metadata, may be NULL */
+ Tcl_Obj *metadataOutObj, /* metadata output dict, may be NULL */
Tk_PhotoImageFormat **imageFormatPtr,
/* A pointer to the photo image format record
- * is returned here. */
+ * is returned here. For formatVersion3, this is
+ * set to NULL*/
+ Tk_PhotoImageFormatVersion3 **imageFormatVersion3Ptr,
+ /* A pointer to the photo image formatVersion3
+ * record is returned here. For non
+ * formatVersion3, this is set to NULL*/
int *widthPtr, int *heightPtr,
/* The dimensions of the image are returned
* here. */
int *oldformat) /* Returns 1 if the old image API is used. */
{
int matched = 0, useoldformat = 0;
- Tk_PhotoImageFormat *formatPtr;
+ Tk_PhotoImageFormat *formatPtr, *defaultFormatPtr = NULL;
+ Tk_PhotoImageFormatVersion3 *formatVersion3Ptr = NULL;
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
const char *formatString = NULL;
@@ -2570,6 +2959,16 @@ MatchStringFormat(
for (formatPtr = tsdPtr->formatList; formatPtr != NULL;
formatPtr = formatPtr->nextPtr) {
+ /*
+ * To keep the behaviour of older versions (Tk <= 8.6), the default
+ * list-of-lists string format is checked last. Remember its position.
+ */
+
+ if (strncasecmp("default", formatPtr->name, strlen(formatPtr->name))
+ == 0) {
+ defaultFormatPtr = formatPtr;
+ }
+
if (formatObj != NULL) {
if (strncasecmp(formatString,
formatPtr->name, strlen(formatPtr->name)) != 0) {
@@ -2585,6 +2984,16 @@ MatchStringFormat(
return TCL_ERROR;
}
}
+
+ /*
+ * If this is the default format, and it was not passed as -format
+ * option, skip the stringMatchProc test. It'll be done later
+ */
+
+ if (formatObj == NULL && formatPtr == defaultFormatPtr) {
+ continue;
+ }
+
if ((formatPtr->stringMatchProc != NULL)
&& (formatPtr->stringReadProc != NULL)
&& formatPtr->stringMatchProc(data, formatObj,
@@ -2593,6 +3002,7 @@ MatchStringFormat(
}
}
+#if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
if (formatPtr == NULL) {
useoldformat = 1;
for (formatPtr = tsdPtr->oldFormatList; formatPtr != NULL;
@@ -2622,23 +3032,104 @@ MatchStringFormat(
}
}
}
+#endif
+
if (formatPtr == NULL) {
- if ((formatObj != NULL) && !matched) {
+ useoldformat = 0;
+ for (formatVersion3Ptr = tsdPtr->formatListVersion3;
+ formatVersion3Ptr != NULL;
+ formatVersion3Ptr = formatVersion3Ptr->nextPtr) {
+ if (formatObj != NULL) {
+ if (strncasecmp(formatString,
+ formatVersion3Ptr->name, strlen(formatVersion3Ptr->name)
+ ) != 0) {
+ continue;
+ }
+ matched = 1;
+ if (formatVersion3Ptr->stringMatchProc == NULL) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "-data option isn't supported for %s images",
+ formatString));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
+ "NOT_DATA_FORMAT", (char *)NULL);
+ return TCL_ERROR;
+ }
+ }
+ if ((formatVersion3Ptr->stringMatchProc != NULL)
+ && (formatVersion3Ptr->stringReadProc != NULL)
+ && formatVersion3Ptr->stringMatchProc(interp, data,
+ formatObj, metadataInObj, widthPtr, heightPtr,
+ metadataOutObj)) {
+ break;
+ }
+
+ /*
+ * Check if driver has shared or changed the metadata tcl object.
+ * In this case, release and recreate it.
+ */
+
+ if (metadataOutObj != NULL) {
+ Tcl_Size dictSize;
+ if (Tcl_IsShared(metadataOutObj)
+ || TCL_OK != Tcl_DictObjSize(interp,metadataOutObj, &dictSize)
+ || dictSize > 0) {
+ Tcl_DecrRefCount(metadataOutObj);
+ metadataOutObj = Tcl_NewDictObj();
+ Tcl_IncrRefCount(metadataOutObj);
+ }
+ }
+ }
+ }
+
+ if (formatPtr == NULL && formatVersion3Ptr == NULL) {
+ /*
+ * Try the default format as last resort (only if no -format option
+ * was passed).
+ */
+
+ if ( formatObj == NULL && defaultFormatPtr == NULL) {
+ Tcl_Panic("default image format handler not registered");
+ }
+ if ( formatObj == NULL
+ && defaultFormatPtr->stringMatchProc != NULL
+ && defaultFormatPtr->stringReadProc != NULL
+ && defaultFormatPtr->stringMatchProc(data, formatObj,
+ widthPtr, heightPtr, interp) != 0) {
+ useoldformat = 0;
+ formatPtr = defaultFormatPtr;
+ } else if ((formatObj != NULL) && !matched) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"image format \"%s\" is not supported", formatString));
Tcl_SetErrorCode(interp, "TK", "LOOKUP", "PHOTO_FORMAT",
formatString, (char *)NULL);
+ return TCL_ERROR;
} else {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "couldn't recognize image data", -1));
- Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
- "UNRECOGNIZED_DATA", (char *)NULL);
+
+ /*
+ * Some lower level routine (stringMatchProc) may have already set
+ * a specific error message, so just return this. Otherwise return
+ * a generic image data error.
+ */
+
+ if (Tcl_GetString(Tcl_GetObjResult(interp))[0] == '\0') {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "couldn't recognize image data", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
+ "UNRECOGNIZED_DATA", (char *)NULL);
+ }
+ return TCL_ERROR;
}
- return TCL_ERROR;
}
*imageFormatPtr = formatPtr;
+ *imageFormatVersion3Ptr = formatVersion3Ptr;
*oldformat = useoldformat;
+
+ /*
+ * Some stringMatchProc might have left error messages and error codes in
+ * interp. Clear them before return.
+ */
+ Tcl_ResetResult(interp);
return TCL_OK;
}
@@ -2670,7 +3161,7 @@ Tk_FindPhoto(
{
const Tk_ImageType *typePtr;
void *clientData =
- Tk_GetImageMasterData(interp, imageName, &typePtr);
+ Tk_GetImageModelData(interp, imageName, &typePtr);
if ((typePtr == NULL) || (typePtr->name != tkPhotoImageType.name)) {
return NULL;
@@ -2779,7 +3270,7 @@ Tk_PhotoPutBlock(
if (sourceBlock.pixelPtr == NULL) {
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1));
+ TK_PHOTO_ALLOC_FAILURE_MESSAGE, TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "MALLOC", (char *)NULL);
}
return TCL_ERROR;
@@ -2796,7 +3287,7 @@ Tk_PhotoPutBlock(
MAX(yEnd, modelPtr->height)) == TCL_ERROR) {
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1));
+ TK_PHOTO_ALLOC_FAILURE_MESSAGE, TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "MALLOC", (char *)NULL);
}
goto errorExit;
@@ -3100,7 +3591,7 @@ Tk_PhotoPutBlock(
* Tell the core image code that this image has changed.
*/
- Tk_ImageChanged(modelPtr->tkMaster, x, y, width, height,
+ Tk_ImageChanged(modelPtr->tkModel, x, y, width, height,
modelPtr->width, modelPtr->height);
if (memToFree) ckfree(memToFree);
@@ -3225,7 +3716,7 @@ Tk_PhotoPutZoomedBlock(
if (sourceBlock.pixelPtr == NULL) {
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1));
+ TK_PHOTO_ALLOC_FAILURE_MESSAGE, TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "MALLOC", (char *)NULL);
}
return TCL_ERROR;
@@ -3241,7 +3732,7 @@ Tk_PhotoPutZoomedBlock(
MAX(yEnd, modelPtr->height)) == TCL_ERROR) {
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1));
+ TK_PHOTO_ALLOC_FAILURE_MESSAGE, TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "MALLOC", (char *)NULL);
}
goto errorExit;
@@ -3456,7 +3947,7 @@ Tk_PhotoPutZoomedBlock(
* Tell the core image code that this image has changed.
*/
- Tk_ImageChanged(modelPtr->tkMaster, x, y, width, height, modelPtr->width,
+ Tk_ImageChanged(modelPtr->tkModel, x, y, width, height, modelPtr->width,
modelPtr->height);
if (memToFree) ckfree(memToFree);
@@ -3602,7 +4093,7 @@ Tk_PhotoBlank(
* Tell the core image code that this image has changed.
*/
- Tk_ImageChanged(modelPtr->tkMaster, 0, 0, modelPtr->width,
+ Tk_ImageChanged(modelPtr->tkModel, 0, 0, modelPtr->width,
modelPtr->height, modelPtr->width, modelPtr->height);
}
@@ -3646,12 +4137,12 @@ Tk_PhotoExpand(
MAX(height, modelPtr->height)) == TCL_ERROR) {
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1));
+ TK_PHOTO_ALLOC_FAILURE_MESSAGE, TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "MALLOC", (char *)NULL);
}
return TCL_ERROR;
}
- Tk_ImageChanged(modelPtr->tkMaster, 0, 0, 0, 0, modelPtr->width,
+ Tk_ImageChanged(modelPtr->tkModel, 0, 0, 0, 0, modelPtr->width,
modelPtr->height);
}
return TCL_OK;
@@ -3721,12 +4212,12 @@ Tk_PhotoSetSize(
((height > 0) ? height: modelPtr->height)) == TCL_ERROR) {
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- TK_PHOTO_ALLOC_FAILURE_MESSAGE, -1));
+ TK_PHOTO_ALLOC_FAILURE_MESSAGE, TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "MALLOC", (char *)NULL);
}
return TCL_ERROR;
}
- Tk_ImageChanged(modelPtr->tkMaster, 0, 0, 0, 0,
+ Tk_ImageChanged(modelPtr->tkModel, 0, 0, 0, 0,
modelPtr->width, modelPtr->height);
return TCL_OK;
}
@@ -3956,57 +4447,6 @@ ImgGetPhoto(
/*
*----------------------------------------------------------------------
*
- * ImgStringWrite --
- *
- * Default string write function. The data is formatted in the default
- * format as accepted by the "<img> put" command.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-ImgStringWrite(
- Tcl_Interp *interp,
- Tcl_Obj *formatString,
- Tk_PhotoImageBlock *blockPtr)
-{
- int greenOffset, blueOffset;
- Tcl_Obj *data;
-
- greenOffset = blockPtr->offset[1] - blockPtr->offset[0];
- blueOffset = blockPtr->offset[2] - blockPtr->offset[0];
-
- data = Tcl_NewObj();
- if ((blockPtr->width > 0) && (blockPtr->height > 0)) {
- int row, col;
-
- for (row=0; row<blockPtr->height; row++) {
- Tcl_Obj *line = Tcl_NewObj();
- unsigned char *pixelPtr = blockPtr->pixelPtr + blockPtr->offset[0]
- + row * blockPtr->pitch;
-
- for (col=0; col<blockPtr->width; col++) {
- Tcl_AppendPrintfToObj(line, "%s#%02x%02x%02x",
- col ? " " : "", *pixelPtr,
- pixelPtr[greenOffset], pixelPtr[blueOffset]);
- pixelPtr += blockPtr->pixelSize;
- }
- Tcl_ListObjAppendElement(NULL, data, line);
- }
- }
- Tcl_SetObjResult(interp, data);
- return TCL_OK;
-}
-
-/*
- *----------------------------------------------------------------------
- *
* Tk_PhotoGetImage --
*
* This function is called to obtain image data from a photo image. This
@@ -4094,7 +4534,7 @@ ImgPhotoPostscript(
*
*----------------------------------------------------------------------
*/
-
+#if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
void
Tk_PhotoPutBlock_NoComposite(
Tk_PhotoHandle handle,
@@ -4180,6 +4620,7 @@ Tk_PhotoSetSize_Panic(
Tcl_Panic(TK_PHOTO_ALLOC_FAILURE_MESSAGE);
}
}
+#endif /* TK_NO_DEPRECATED */
/*
* Local Variables:
diff --git a/generic/tkImgPhoto.h b/generic/tkImgPhoto.h
index 994fa40..a65b971 100644
--- a/generic/tkImgPhoto.h
+++ b/generic/tkImgPhoto.h
@@ -3,10 +3,10 @@
*
* Declarations for images of type "photo" for Tk.
*
- * Copyright (c) 1994 The Australian National University.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
- * Copyright (c) 2002-2008 Donal K. Fellows
- * Copyright (c) 2003 ActiveState Corporation.
+ * Copyright © 1994 The Australian National University.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 2002-2008 Donal K. Fellows
+ * Copyright © 2003 ActiveState Corporation.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -27,11 +27,11 @@
* Forward declarations of the structures we define.
*/
-#define PhotoModel PhotoMaster
+#define PhotoMaster PhotoModel
typedef struct ColorTableId ColorTableId;
typedef struct ColorTable ColorTable;
typedef struct PhotoInstance PhotoInstance;
-typedef struct PhotoMaster PhotoMaster;
+typedef struct PhotoModel PhotoModel;
/*
* A signed 8-bit integral type. If chars are unsigned and the compiler isn't
@@ -50,13 +50,6 @@ typedef struct PhotoMaster PhotoMaster;
#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.
*/
@@ -94,19 +87,26 @@ struct ColorTableId {
struct ColorTable {
ColorTableId id; /* Information used in selecting this color
* table. */
+#if TCL_MAJOR_VERSION > 8
+ size_t refCount; /* Number of instances using this map. */
+ size_t liveRefCount; /* Number of instances which are actually in
+ * use, using this map. */
int flags; /* See below. */
- int refCount; /* Number of instances using this map. */
- int liveRefCount; /* Number of instances which are actually in
+#else
+ int flags; /* See below. */
+ unsigned int refCount; /* Number of instances using this map. */
+ unsigned int liveRefCount; /* Number of instances which are actually in
* use, using this map. */
+#endif
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
+ unsigned 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 greenValues[256]; /* Ditto for green intensity. */
+ unsigned blueValues[256]; /* Ditto for blue intensity. */
unsigned long *pixelMap; /* Actual pixel values allocated. */
unsigned char colorQuant[3][256];
@@ -141,8 +141,8 @@ struct ColorTable {
* Definition of the data associated with each photo image model.
*/
-struct PhotoMaster {
- Tk_ImageMaster tkMaster; /* Tk's token for image model. NULL means the
+struct PhotoModel {
+ Tk_ImageModel tkModel; /* Tk's token for image model. NULL means the
* image is being deleted. */
Tcl_Interp *interp; /* Interpreter associated with the application
* using this image. */
@@ -159,6 +159,8 @@ struct PhotoMaster {
Tcl_Obj *dataString; /* Object to use as contents of image. */
Tcl_Obj *format; /* User-specified format of data in image file
* or string value. */
+ Tcl_Obj *metadata; /* User-specified metadata dict or read from
+ * image file */
unsigned char *pix32; /* Local storage for 32-bit image. */
int ditherX, ditherY; /* Location of first incorrectly dithered
* pixel in image. */
@@ -169,7 +171,7 @@ struct PhotoMaster {
};
/*
- * Bit definitions for the flags field of a PhotoMaster.
+ * Bit definitions for the flags field of a PhotoModel.
* COLOR_IMAGE: 1 means that the image has different color
* components.
* IMAGE_CHANGED: 1 means that the instances of this image need
@@ -196,13 +198,17 @@ struct PhotoMaster {
*/
struct PhotoInstance {
- PhotoMaster *masterPtr; /* Pointer to model for image. */
+ PhotoModel *modelPtr; /* Pointer to model for image. */
Display *display; /* Display for windows using this instance. */
Colormap colormap; /* The image may only be used in windows with
* this particular colormap. */
PhotoInstance *nextPtr; /* Pointer to the next instance in the list of
* instances associated with this model. */
- int refCount; /* Number of instances using this structure. */
+#if TCL_MAJOR_VERSION > 8
+ size_t refCount; /* Number of instances using this structure. */
+#else
+ unsigned int refCount; /* Number of instances using this structure. */
+#endif
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
@@ -241,16 +247,16 @@ struct PhotoInstance {
MODULE_SCOPE void TkImgPhotoConfigureInstance(
PhotoInstance *instancePtr);
-MODULE_SCOPE void TkImgDisposeInstance(ClientData clientData);
+MODULE_SCOPE void TkImgDisposeInstance(void *clientData);
MODULE_SCOPE void TkImgPhotoInstanceSetSize(PhotoInstance *instancePtr);
-MODULE_SCOPE ClientData TkImgPhotoGet(Tk_Window tkwin, ClientData clientData);
+MODULE_SCOPE void *TkImgPhotoGet(Tk_Window tkwin, void *clientData);
MODULE_SCOPE void TkImgDitherInstance(PhotoInstance *instancePtr, int x,
int y, int width, int height);
-MODULE_SCOPE void TkImgPhotoDisplay(ClientData clientData,
+MODULE_SCOPE void TkImgPhotoDisplay(void *clientData,
Display *display, Drawable drawable,
int imageX, int imageY, int width, int height,
int drawableX, int drawableY);
-MODULE_SCOPE void TkImgPhotoFree(ClientData clientData,
+MODULE_SCOPE void TkImgPhotoFree(void *clientData,
Display *display);
MODULE_SCOPE void TkImgResetDither(PhotoInstance *instancePtr);
diff --git a/generic/tkImgSVGnano.c b/generic/tkImgSVGnano.c
new file mode 100644
index 0000000..73bbbf8
--- /dev/null
+++ b/generic/tkImgSVGnano.c
@@ -0,0 +1,876 @@
+/*
+ * tkImgSVGnano.c
+ *
+ * A photo file handler for SVG files.
+ *
+ * Copyright © 2013-14 Mikko Mononen memon@inside.org
+ * Copyright © 2018 Christian Gollwitzer auriocus@gmx.de
+ * Copyright © 2018 Christian Werner https://www.androwish.org/
+ * Copyright © 2018 Rene Zaumseil r.zaumseil@freenet.de
+ *
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ *
+ * This handler is build using the original nanosvg library files from
+ * https://github.com/memononen/nanosvg
+ *
+ */
+
+#include "tkInt.h"
+#define NANOSVG_malloc ckalloc
+#define NANOSVG_realloc ckrealloc
+#define NANOSVG_free ckfree
+#define NANOSVG_SCOPE MODULE_SCOPE
+#define NANOSVG_ALL_COLOR_KEYWORDS
+#define NANOSVG_IMPLEMENTATION
+#include "nanosvg.h"
+#define NANOSVGRAST_IMPLEMENTATION
+#include "nanosvgrast.h"
+
+/* Additional parameters to nsvgRasterize() */
+
+typedef struct {
+ double scale;
+ int scaleToHeight;
+ int scaleToWidth;
+} RastOpts;
+
+/*
+ * Per interp cache of last NSVGimage which was matched to
+ * be immediately rasterized after the match. This helps to
+ * eliminate double parsing of the SVG file/string.
+ */
+
+typedef struct {
+ /* A poiner to remember if it is the same svn image (data)
+ * It is a Tcl_Channel if image created by -file option
+ * or a Tcl_Obj, if image is created with the -data option
+ */
+ void *dataOrChan;
+ Tcl_DString formatString;
+ NSVGimage *nsvgImage;
+ RastOpts ropts;
+} NSVGcache;
+
+static const void * MemMem(const void *haystack, size_t haysize,
+ const void *needle, size_t needlen);
+static int FileMatchSVG(Tcl_Channel chan, const char *fileName,
+ Tcl_Obj *format, int *widthPtr, int *heightPtr,
+ Tcl_Interp *interp);
+static int FileReadSVG(Tcl_Interp *interp, Tcl_Channel chan,
+ const char *fileName, Tcl_Obj *format,
+ Tk_PhotoHandle imageHandle, int destX, int destY,
+ int width, int height, int srcX, int srcY);
+static int StringMatchSVG(Tcl_Obj *dataObj, Tcl_Obj *format,
+ int *widthPtr, int *heightPtr, Tcl_Interp *interp);
+static int StringReadSVG(Tcl_Interp *interp, Tcl_Obj *dataObj,
+ Tcl_Obj *format, Tk_PhotoHandle imageHandle,
+ int destX, int destY, int width, int height,
+ int srcX, int srcY);
+static NSVGimage * ParseSVGWithOptions(Tcl_Interp *interp,
+ const char *input, Tcl_Size length, Tcl_Obj *format,
+ RastOpts *ropts);
+static int RasterizeSVG(Tcl_Interp *interp,
+ Tk_PhotoHandle imageHandle, NSVGimage *nsvgImage,
+ int destX, int destY, int width, int height,
+ int srcX, int srcY, RastOpts *ropts);
+static double GetScaleFromParameters(NSVGimage *nsvgImage,
+ RastOpts *ropts, int *widthPtr, int *heightPtr);
+static NSVGcache * GetCachePtr(Tcl_Interp *interp);
+static int CacheSVG(Tcl_Interp *interp, void *dataOrChan,
+ Tcl_Obj *formatObj, NSVGimage *nsvgImage,
+ RastOpts *ropts);
+static NSVGimage * GetCachedSVG(Tcl_Interp *interp, void *dataOrChan,
+ Tcl_Obj *formatObj, RastOpts *ropts);
+static void CleanCache(Tcl_Interp *interp);
+static void FreeCache(void *clientData, Tcl_Interp *interp);
+
+/*
+ * The format record for the SVG nano file format:
+ */
+
+Tk_PhotoImageFormat tkImgFmtSVGnano = {
+ "svg", /* name */
+ FileMatchSVG, /* fileMatchProc */
+ StringMatchSVG, /* stringMatchProc */
+ FileReadSVG, /* fileReadProc */
+ StringReadSVG, /* stringReadProc */
+ NULL, /* fileWriteProc */
+ NULL, /* stringWriteProc */
+ NULL
+};
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * MemMem --
+ *
+ * Like strstr() but operating on memory buffers with sizes.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static const void *
+MemMem(const void *haystack, size_t haylen,
+ const void *needle, size_t needlen)
+{
+ const void *hayend, *second, *p;
+ unsigned char first;
+
+ if ((needlen <= 0) || (haylen < needlen)) {
+ return NULL;
+ }
+ hayend = (const void *) ((char *) haystack + haylen - needlen);
+ first = ((char *) needle)[0];
+ second = (const void *) ((char *) needle + 1);
+ needlen -= 1;
+ while (haystack < hayend) {
+ p = memchr(haystack, first, (char *) hayend - (char *) haystack);
+ if (p == NULL) {
+ break;
+ }
+ if (needlen == 0) {
+ return p;
+ }
+ haystack = (const void *) ((char *) p + 1);
+ if (memcmp(second, haystack, needlen) == 0) {
+ return p;
+ }
+ }
+ return NULL;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * FileMatchSVG --
+ *
+ * This function is invoked by the photo image type to see if a file
+ * contains image data in SVG format.
+ *
+ * Results:
+ * The return value is >0 if the file can be successfully parsed,
+ * and 0 otherwise.
+ *
+ * Side effects:
+ * The file is saved in the internal cache for further use.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+FileMatchSVG(
+ Tcl_Channel chan,
+ TCL_UNUSED(const char *),
+ Tcl_Obj *formatObj,
+ int *widthPtr, int *heightPtr,
+ Tcl_Interp *interp)
+{
+ Tcl_Size length;
+ Tcl_Obj *dataObj = Tcl_NewObj();
+ const char *data;
+ RastOpts ropts;
+ NSVGimage *nsvgImage;
+
+ CleanCache(interp);
+ if (Tcl_ReadChars(chan, dataObj, 4096, 0) == TCL_IO_FAILURE) {
+ /* in case of an error reading the file */
+ Tcl_DecrRefCount(dataObj);
+ return 0;
+ }
+ data = Tcl_GetStringFromObj(dataObj, &length);
+ /* should have a '<svg' and a '>' in the first 4k */
+ if ((memchr(data, '>', length) == NULL) ||
+ (MemMem(data, length, "<svg", 4) == NULL)) {
+ Tcl_DecrRefCount(dataObj);
+ return 0;
+ }
+ if (!Tcl_Eof(chan) && (Tcl_ReadChars(chan, dataObj, TCL_INDEX_NONE, 1) == TCL_IO_FAILURE)) {
+ /* in case of an error reading the file */
+ Tcl_DecrRefCount(dataObj);
+ return 0;
+ }
+ data = Tcl_GetStringFromObj(dataObj, &length);
+ nsvgImage = ParseSVGWithOptions(interp, data, length, formatObj, &ropts);
+ Tcl_DecrRefCount(dataObj);
+ if (nsvgImage != NULL) {
+ GetScaleFromParameters(nsvgImage, &ropts, widthPtr, heightPtr);
+ if ((*widthPtr <= 0.0) || (*heightPtr <= 0.0)) {
+ nsvgDelete(nsvgImage);
+ return 0;
+ }
+ if (!CacheSVG(interp, chan, formatObj, nsvgImage, &ropts)) {
+ nsvgDelete(nsvgImage);
+ }
+ return 1;
+ }
+ return 0;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * FileReadSVG --
+ *
+ * This function is called by the photo image type to read SVG format
+ * data from a file and write it into a given photo image.
+ *
+ * Results:
+ * A standard TCL completion code. If TCL_ERROR is returned then an error
+ * message is left in the interp's result.
+ *
+ * Side effects:
+ * The access position in file f is changed, and new data is added to the
+ * image given by imageHandle.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+FileReadSVG(
+ Tcl_Interp *interp,
+ Tcl_Channel chan,
+ TCL_UNUSED(const char *),
+ Tcl_Obj *formatObj,
+ Tk_PhotoHandle imageHandle,
+ int destX, int destY,
+ int width, int height,
+ int srcX, int srcY)
+{
+ Tcl_Size length;
+ const char *data;
+ RastOpts ropts;
+ NSVGimage *nsvgImage = GetCachedSVG(interp, chan, formatObj, &ropts);
+
+ if (nsvgImage == NULL) {
+ Tcl_Obj *dataObj = Tcl_NewObj();
+
+ if (Tcl_ReadChars(chan, dataObj, TCL_INDEX_NONE, 0) == TCL_IO_FAILURE) {
+ /* in case of an error reading the file */
+ Tcl_DecrRefCount(dataObj);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("read error", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "READ_ERROR", NULL);
+ return TCL_ERROR;
+ }
+ data = Tcl_GetStringFromObj(dataObj, &length);
+ nsvgImage = ParseSVGWithOptions(interp, data, length, formatObj,
+ &ropts);
+ Tcl_DecrRefCount(dataObj);
+ if (nsvgImage == NULL) {
+ return TCL_ERROR;
+ }
+ }
+ return RasterizeSVG(interp, imageHandle, nsvgImage, destX, destY,
+ width, height, srcX, srcY, &ropts);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * StringMatchSVG --
+ *
+ * This function is invoked by the photo image type to see if a string
+ * contains image data in SVG format.
+ *
+ * Results:
+ * The return value is >0 if the file can be successfully parsed,
+ * and 0 otherwise.
+ *
+ * Side effects:
+ * The file is saved in the internal cache for further use.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+StringMatchSVG(
+ Tcl_Obj *dataObj,
+ Tcl_Obj *formatObj,
+ int *widthPtr, int *heightPtr,
+ Tcl_Interp *interp)
+{
+ Tcl_Size length, testLength;
+ const char *data;
+ RastOpts ropts;
+ NSVGimage *nsvgImage;
+
+ CleanCache(interp);
+ data = Tcl_GetStringFromObj(dataObj, &length);
+ /* should have a '<svg' and a '>' in the first 4k */
+ testLength = (length > 4096) ? 4096 : length;
+ if ((memchr(data, '>', testLength) == NULL) ||
+ (MemMem(data, testLength, "<svg", 4) == NULL)) {
+ return 0;
+ }
+ nsvgImage = ParseSVGWithOptions(interp, data, length, formatObj, &ropts);
+ if (nsvgImage != NULL) {
+ GetScaleFromParameters(nsvgImage, &ropts, widthPtr, heightPtr);
+ if ((*widthPtr <= 0.0) || (*heightPtr <= 0.0)) {
+ nsvgDelete(nsvgImage);
+ return 0;
+ }
+ if (!CacheSVG(interp, dataObj, formatObj, nsvgImage, &ropts)) {
+ nsvgDelete(nsvgImage);
+ }
+ return 1;
+ }
+ return 0;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * StringReadSVG --
+ *
+ * This function is called by the photo image type to read SVG format
+ * data from a string and write it into a given photo image.
+ *
+ * Results:
+ * A standard TCL completion code. If TCL_ERROR is returned then an error
+ * message is left in the interp's result.
+ *
+ * Side effects:
+ * New data is added to the image given by imageHandle.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+StringReadSVG(
+ Tcl_Interp *interp,
+ Tcl_Obj *dataObj,
+ Tcl_Obj *formatObj,
+ Tk_PhotoHandle imageHandle,
+ int destX, int destY,
+ int width, int height,
+ int srcX, int srcY)
+{
+ Tcl_Size length;
+ const char *data;
+ RastOpts ropts;
+ NSVGimage *nsvgImage = GetCachedSVG(interp, dataObj, formatObj, &ropts);
+
+ if (nsvgImage == NULL) {
+ data = Tcl_GetStringFromObj(dataObj, &length);
+ nsvgImage = ParseSVGWithOptions(interp, data, length, formatObj,
+ &ropts);
+ }
+ if (nsvgImage == NULL) {
+ return TCL_ERROR;
+ }
+ return RasterizeSVG(interp, imageHandle, nsvgImage, destX, destY,
+ width, height, srcX, srcY, &ropts);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * ParseSVGWithOptions --
+ *
+ * This function is called to parse the given input string as SVG.
+ *
+ * Results:
+ * Return a newly create NSVGimage on success, and NULL otherwise.
+ *
+ * Side effects:
+ *
+ *----------------------------------------------------------------------
+ */
+
+static NSVGimage *
+ParseSVGWithOptions(
+ Tcl_Interp *interp,
+ const char *input,
+ Tcl_Size length,
+ Tcl_Obj *formatObj,
+ RastOpts *ropts)
+{
+ Tcl_Obj **objv = NULL;
+ Tcl_Size objc = 0;
+ double dpi = 96.0;
+ char *inputCopy = NULL;
+ NSVGimage *nsvgImage;
+ int parameterScaleSeen = 0;
+ static const char *const fmtOptions[] = {
+ "-dpi", "-scale", "-scaletoheight", "-scaletowidth", NULL
+ };
+ enum fmtOptionsEnum {
+ OPT_DPI, OPT_SCALE, OPT_SCALE_TO_HEIGHT, OPT_SCALE_TO_WIDTH
+ };
+
+ /*
+ * The parser destroys the original input string,
+ * therefore first duplicate.
+ */
+
+ inputCopy = (char *)attemptckalloc(length+1);
+ if (inputCopy == NULL) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("cannot alloc data buffer", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "OUT_OF_MEMORY", NULL);
+ goto error;
+ }
+ memcpy(inputCopy, input, length);
+ inputCopy[length] = '\0';
+
+ /*
+ * Process elements of format specification as a list.
+ */
+
+ ropts->scale = 1.0;
+ ropts->scaleToHeight = 0;
+ ropts->scaleToWidth = 0;
+ if ((formatObj != NULL) &&
+ Tcl_ListObjGetElements(interp, formatObj, &objc, &objv) != TCL_OK) {
+ goto error;
+ }
+ for (; objc > 0 ; objc--, objv++) {
+ int optIndex;
+
+ /*
+ * Ignore the "svg" part of the format specification.
+ */
+
+ if (!strcasecmp(Tcl_GetString(objv[0]), "svg")) {
+ continue;
+ }
+
+ if (Tcl_GetIndexFromObjStruct(interp, objv[0], fmtOptions,
+ sizeof(char *), "option", 0, &optIndex) == TCL_ERROR) {
+ goto error;
+ }
+
+ if (objc < 2) {
+ ckfree(inputCopy);
+ inputCopy = NULL;
+ Tcl_WrongNumArgs(interp, 1, objv, "value");
+ goto error;
+ }
+
+ objc--;
+ objv++;
+
+ /*
+ * check that only one scale option is given
+ */
+ switch ((enum fmtOptionsEnum)optIndex) {
+ case OPT_SCALE:
+ case OPT_SCALE_TO_HEIGHT:
+ case OPT_SCALE_TO_WIDTH:
+ if ( parameterScaleSeen ) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "only one of -scale, -scaletoheight, -scaletowidth may be given", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "BAD_SCALE",
+ NULL);
+ goto error;
+ }
+ parameterScaleSeen = 1;
+ break;
+ default:
+ break;
+ }
+
+ /*
+ * Decode parameters
+ */
+ switch ((enum fmtOptionsEnum) optIndex) {
+ case OPT_DPI:
+ if (Tcl_GetDoubleFromObj(interp, objv[0], &dpi) == TCL_ERROR) {
+ goto error;
+ }
+ if (dpi < 0.0) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "-dpi value must be positive", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "BAD_DPI",
+ NULL);
+ goto error;
+ }
+ break;
+ case OPT_SCALE:
+ if (Tcl_GetDoubleFromObj(interp, objv[0], &ropts->scale) ==
+ TCL_ERROR) {
+ goto error;
+ }
+ if (ropts->scale <= 0.0) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "-scale value must be positive", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "BAD_SCALE",
+ NULL);
+ goto error;
+ }
+ break;
+ case OPT_SCALE_TO_HEIGHT:
+ if (Tcl_GetIntFromObj(interp, objv[0], &ropts->scaleToHeight) ==
+ TCL_ERROR) {
+ goto error;
+ }
+ if (ropts->scaleToHeight <= 0) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "-scaletoheight value must be positive", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "BAD_SCALE",
+ NULL);
+ goto error;
+ }
+ break;
+ case OPT_SCALE_TO_WIDTH:
+ if (Tcl_GetIntFromObj(interp, objv[0], &ropts->scaleToWidth) ==
+ TCL_ERROR) {
+ goto error;
+ }
+ if (ropts->scaleToWidth <= 0) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "-scaletowidth value must be positive", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "BAD_SCALE",
+ NULL);
+ goto error;
+ }
+ break;
+ }
+ }
+
+ nsvgImage = nsvgParse(inputCopy, "px", (float) dpi);
+ if (nsvgImage == NULL) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("cannot parse SVG image", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "PARSE_ERROR", NULL);
+ goto error;
+ }
+ ckfree(inputCopy);
+ return nsvgImage;
+
+error:
+ if (inputCopy != NULL) {
+ ckfree(inputCopy);
+ }
+ return NULL;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * RasterizeSVG --
+ *
+ * This function is called to rasterize the given nsvgImage and
+ * fill the imageHandle with data.
+ *
+ * Results:
+ * A standard TCL completion code. If TCL_ERROR is returned then an error
+ * message is left in the interp's result.
+ *
+ *
+ * Side effects:
+ * On error the given nsvgImage will be deleted.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+RasterizeSVG(
+ Tcl_Interp *interp,
+ Tk_PhotoHandle imageHandle,
+ NSVGimage *nsvgImage,
+ int destX, int destY,
+ int width, int height,
+ TCL_UNUSED(int),
+ TCL_UNUSED(int),
+ RastOpts *ropts)
+{
+ int w, h, c;
+ NSVGrasterizer *rast;
+ unsigned char *imgData;
+ Tk_PhotoImageBlock svgblock;
+ double scale;
+ Tcl_WideUInt wh;
+
+ scale = GetScaleFromParameters(nsvgImage, ropts, &w, &h);
+
+ rast = nsvgCreateRasterizer();
+ if (rast == NULL) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("cannot initialize rasterizer", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "RASTERIZER_ERROR",
+ NULL);
+ goto cleanAST;
+ }
+
+ /* Tk Ticket [822330269b] Check potential int overflow in following ckalloc */
+ wh = (Tcl_WideUInt)w * (Tcl_WideUInt)h;
+ if ( w < 0 || h < 0 || wh > INT_MAX / 4) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("image size overflow", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "IMAGE_SIZE_OVERFLOW", NULL);
+ goto cleanRAST;
+ }
+
+ imgData = (unsigned char *)attemptckalloc(wh * 4);
+ if (imgData == NULL) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("cannot alloc image buffer", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "OUT_OF_MEMORY", NULL);
+ goto cleanRAST;
+ }
+ nsvgRasterize(rast, nsvgImage, 0, 0,
+ (float) scale, imgData, w, h, w * 4);
+ /* transfer the data to a photo block */
+ svgblock.pixelPtr = imgData;
+ svgblock.width = w;
+ svgblock.height = h;
+ svgblock.pitch = w * 4;
+ svgblock.pixelSize = 4;
+ for (c = 0; c <= 3; c++) {
+ svgblock.offset[c] = c;
+ }
+ if (Tk_PhotoExpand(interp, imageHandle,
+ destX + width, destY + height) != TCL_OK) {
+ goto cleanRAST;
+ }
+ if (Tk_PhotoPutBlock(interp, imageHandle, &svgblock, destX, destY,
+ width, height, TK_PHOTO_COMPOSITE_SET) != TCL_OK) {
+ goto cleanimg;
+ }
+ ckfree(imgData);
+ nsvgDeleteRasterizer(rast);
+ nsvgDelete(nsvgImage);
+ return TCL_OK;
+
+cleanimg:
+ ckfree(imgData);
+
+cleanRAST:
+ nsvgDeleteRasterizer(rast);
+
+cleanAST:
+ nsvgDelete(nsvgImage);
+ return TCL_ERROR;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GetScaleFromParameters --
+ *
+ * Get the scale value from the already parsed parameters -scale,
+ * -scaletoheight and -scaletowidth.
+ *
+ * The image width and height is also returned.
+ *
+ * Results:
+ * The evaluated or configured scale value, or 0.0 on failure
+ *
+ * Side effects:
+ * heightPtr and widthPtr are set to height and width of the image.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static double
+GetScaleFromParameters(
+ NSVGimage *nsvgImage,
+ RastOpts *ropts,
+ int *widthPtr,
+ int *heightPtr)
+{
+ double scale;
+ int width, height;
+
+ if ((nsvgImage->width == 0.0) || (nsvgImage->height == 0.0)) {
+ width = height = 0;
+ scale = 1.0;
+ } else if (ropts->scaleToHeight > 0) {
+ /*
+ * Fixed height
+ */
+ height = ropts->scaleToHeight;
+ scale = height / nsvgImage->height;
+ width = (int) ceil(nsvgImage->width * scale);
+ } else if (ropts->scaleToWidth > 0) {
+ /*
+ * Fixed width
+ */
+ width = ropts->scaleToWidth;
+ scale = width / nsvgImage->width;
+ height = (int) ceil(nsvgImage->height * scale);
+ } else {
+ /*
+ * Scale factor
+ */
+ scale = ropts->scale;
+ width = (int) ceil(nsvgImage->width * scale);
+ height = (int) ceil(nsvgImage->height * scale);
+ }
+
+ *heightPtr = height;
+ *widthPtr = width;
+ return scale;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GetCachePtr --
+ *
+ * This function is called to get the per interpreter used
+ * svg image cache.
+ *
+ * Results:
+ * Return a pointer to the used cache.
+ *
+ * Side effects:
+ * Initialize the cache on the first call.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static NSVGcache *
+GetCachePtr(
+ Tcl_Interp *interp
+) {
+ NSVGcache *cachePtr = (NSVGcache *)Tcl_GetAssocData(interp, "tksvgnano", NULL);
+ if (cachePtr == NULL) {
+ cachePtr = (NSVGcache *)ckalloc(sizeof(NSVGcache));
+ cachePtr->dataOrChan = NULL;
+ Tcl_DStringInit(&cachePtr->formatString);
+ cachePtr->nsvgImage = NULL;
+ Tcl_SetAssocData(interp, "tksvgnano", FreeCache, cachePtr);
+ }
+ return cachePtr;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * CacheSVG --
+ *
+ * Add the given svg image informations to the cache for further usage.
+ *
+ * Results:
+ * Return 1 on success, and 0 otherwise.
+ *
+ * Side effects:
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+CacheSVG(
+ Tcl_Interp *interp,
+ void *dataOrChan,
+ Tcl_Obj *formatObj,
+ NSVGimage *nsvgImage,
+ RastOpts *ropts)
+{
+ Tcl_Size length;
+ const char *data;
+ NSVGcache *cachePtr = GetCachePtr(interp);
+
+ if (cachePtr != NULL) {
+ cachePtr->dataOrChan = dataOrChan;
+ if (formatObj != NULL) {
+ data = Tcl_GetStringFromObj(formatObj, &length);
+ Tcl_DStringAppend(&cachePtr->formatString, data, length);
+ }
+ cachePtr->nsvgImage = nsvgImage;
+ cachePtr->ropts = *ropts;
+ return 1;
+ }
+ return 0;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GetCachedSVG --
+ *
+ * Try to get the NSVGimage from the internal cache.
+ *
+ * Results:
+ * Return the found NSVGimage on success, and NULL otherwise.
+ *
+ * Side effects:
+ * Calls the CleanCache() function.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static NSVGimage *
+GetCachedSVG(
+ Tcl_Interp *interp,
+ void *dataOrChan,
+ Tcl_Obj *formatObj,
+ RastOpts *ropts)
+{
+ Tcl_Size length;
+ const char *data;
+ NSVGcache *cachePtr = GetCachePtr(interp);
+ NSVGimage *nsvgImage = NULL;
+
+ if ((cachePtr != NULL) && (cachePtr->nsvgImage != NULL) &&
+ (cachePtr->dataOrChan == dataOrChan)) {
+ if (formatObj != NULL) {
+ data = Tcl_GetStringFromObj(formatObj, &length);
+ if (strcmp(data, Tcl_DStringValue(&cachePtr->formatString)) == 0) {
+ nsvgImage = cachePtr->nsvgImage;
+ *ropts = cachePtr->ropts;
+ cachePtr->nsvgImage = NULL;
+ }
+ } else if (Tcl_DStringLength(&cachePtr->formatString) == 0) {
+ nsvgImage = cachePtr->nsvgImage;
+ *ropts = cachePtr->ropts;
+ cachePtr->nsvgImage = NULL;
+ }
+ }
+ CleanCache(interp);
+ return nsvgImage;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * CleanCache --
+ *
+ * Reset the cache and delete the saved image in it.
+ *
+ * Results:
+ *
+ * Side effects:
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+CleanCache(Tcl_Interp *interp)
+{
+ NSVGcache *cachePtr = GetCachePtr(interp);
+
+ if (cachePtr != NULL) {
+ cachePtr->dataOrChan = NULL;
+ Tcl_DStringSetLength(&cachePtr->formatString, 0);
+ if (cachePtr->nsvgImage != NULL) {
+ nsvgDelete(cachePtr->nsvgImage);
+ cachePtr->nsvgImage = NULL;
+ }
+ }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * FreeCache --
+ *
+ * This function is called to clean up the internal cache data.
+ *
+ * Results:
+ *
+ * Side effects:
+ * Existing image data in the cache and the cache will be deleted.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+FreeCache(void *clientData, TCL_UNUSED(Tcl_Interp *))
+{
+ NSVGcache *cachePtr = (NSVGcache *)clientData;
+
+ Tcl_DStringFree(&cachePtr->formatString);
+ if (cachePtr->nsvgImage != NULL) {
+ nsvgDelete(cachePtr->nsvgImage);
+ }
+ ckfree(cachePtr);
+}
+
diff --git a/generic/tkImgUtil.c b/generic/tkImgUtil.c
index 5487165..856fe25 100644
--- a/generic/tkImgUtil.c
+++ b/generic/tkImgUtil.c
@@ -3,7 +3,7 @@
*
* This file contains image related utility functions.
*
- * Copyright (c) 1995 Sun Microsystems, Inc.
+ * Copyright © 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.
@@ -11,7 +11,9 @@
#include "tkInt.h"
#include "xbytes.h"
-
+#ifdef _WIN32
+# include "tkWinInt.h"
+#endif
/*
*----------------------------------------------------------------------
@@ -55,7 +57,7 @@ TkAlignImageData(
dataWidth += (alignment - (dataWidth % alignment));
}
- data = ckalloc(dataWidth * image->height);
+ data = (char *)ckalloc(dataWidth * image->height);
destPtr = data;
for (i = 0; i < image->height; i++) {
diff --git a/generic/tkInt.decls b/generic/tkInt.decls
index 8106b83..7d75a42 100644
--- a/generic/tkInt.decls
+++ b/generic/tkInt.decls
@@ -4,8 +4,8 @@
# are exported by the Tk library. This file is used to generate the
# tkIntDecls.h, tkIntPlatDecls.h, tkIntStub.c, and tkPlatStub.c files.
#
-# Copyright (c) 1998-1999 by Scriptics Corporation.
-# Copyright (c) 2007 Daniel A. Steffen <das@users.sourceforge.net>
+# Copyright © 1998-1999 Scriptics Corporation.
+# Copyright © 2007 Daniel A. Steffen <das@users.sourceforge.net>
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -67,8 +67,8 @@ declare 12 {
int xHot, int yHot, XColor fg, XColor bg)
}
declare 13 {
- int TkCreateFrame(ClientData clientData, Tcl_Interp *interp,
- int argc, const char *const *argv, int toplevel, const char *appName)
+ int TkCreateFrame(void *clientData, Tcl_Interp *interp,
+ Tcl_Size argc, const char *const *argv, int toplevel, const char *appName)
}
declare 14 {
Tk_Window TkCreateMainWindow(Tcl_Interp *interp,
@@ -99,7 +99,7 @@ declare 21 {
const TkStateMap *mapPtr, const char *strKey)
}
declare 22 {
- CONST86 char *TkFindStateString(const TkStateMap *mapPtr, int numKey)
+ const char *TkFindStateString(const TkStateMap *mapPtr, int numKey)
}
declare 23 {
void TkFocusDeadWindow(TkWindow *winPtr)
@@ -145,7 +145,7 @@ declare 34 {
TkDisplay *TkGetDisplay(Display *display)
}
declare 35 {
- int TkGetDisplayOf(Tcl_Interp *interp, int objc, Tcl_Obj *const objv[],
+ Tcl_Size TkGetDisplayOf(Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[],
Tk_Window *tkwinPtr)
}
declare 36 {
@@ -182,7 +182,7 @@ declare 45 {
void TkInstallFrameMenu(Tk_Window tkwin)
}
declare 46 {
- CONST86 char *TkKeysymToString(KeySym keysym)
+ const char *TkKeysymToString(KeySym keysym)
}
declare 47 {
int TkLineToArea(double end1Ptr[], double end2Ptr[], double rectPtr[])
@@ -226,7 +226,7 @@ declare 58 {
declare 59 {
void TkpGetAppName(Tcl_Interp *interp, Tcl_DString *name)
}
-declare 60 {
+declare 60 {deprecated {renamed to Tk_GetOtherWindow}} {
TkWindow *TkpGetOtherWindow(TkWindow *winPtr)
}
declare 61 {
@@ -239,13 +239,13 @@ declare 63 {
void TkpInitializeMenuBindings(Tcl_Interp *interp,
Tk_BindingTable bindingTable)
}
-declare 64 {
+declare 64 {deprecated {renamed to Tk_MakeContainer}} {
void TkpMakeContainer(Tk_Window tkwin)
}
declare 65 {
void TkpMakeMenuWindow(Tk_Window tkwin, int transient)
}
-declare 66 {
+declare 66 {deprecated {renamed to Tk_MakeWindow}} {
Window TkpMakeWindow(TkWindow *winPtr, Window parent)
}
declare 67 {
@@ -269,10 +269,10 @@ declare 72 {
declare 73 {
void TkpRedirectKeyEvent(TkWindow *winPtr, XEvent *eventPtr)
}
-declare 74 {
+declare 74 {deprecated {renamed to Tk_SetMainMenubar}} {
void TkpSetMainMenubar(Tcl_Interp *interp, Tk_Window tkwin, const char *menuName)
}
-declare 75 {
+declare 75 {deprecated {renamed to Tk_UseWindow}} {
int TkpUseWindow(Tcl_Interp *interp, Tk_Window tkwin, const char *string)
}
#
@@ -288,7 +288,7 @@ declare 78 {
}
declare 79 {
int TkScrollWindow(Tk_Window tkwin, GC gc, int x, int y,
- int width, int height, int dx, int dy, TkRegion damageRgn)
+ int width, int height, int dx, int dy, Region damageRgn)
}
declare 80 {
void TkSelDeadWindow(TkWindow *winPtr)
@@ -306,9 +306,9 @@ declare 83 {
# Exported publically as Tk_SetClassProcs in 8.4a2
#declare 84 {
# void TkSetClassProcs(Tk_Window tkwin,
-# TkClassProcs *procs, ClientData instanceData)
+# TkClassProcs *procs, void *instanceData)
#}
-declare 85 {
+declare 85 {deprecated {renamed to Tk_SetWindowMenubar}} {
void TkSetWindowMenuBar(Tcl_Interp *interp, Tk_Window tkwin,
const char *oldMenuName, const char *menuName)
}
@@ -389,12 +389,12 @@ declare 108 {
Tcl_Obj *objPtr, Tk_Window *windowPtr)
}
declare 109 {
- CONST86 char *TkpGetString(TkWindow *winPtr, XEvent *eventPtr, Tcl_DString *dsPtr)
+ const char *TkpGetString(TkWindow *winPtr, XEvent *eventPtr, Tcl_DString *dsPtr)
}
declare 110 {
void TkpGetSubFonts(Tcl_Interp *interp, Tk_Font tkfont)
}
-declare 111 {
+declare 111 {deprecated {renamed to Tk_GetSystemDefault}} {
Tcl_Obj *TkpGetSystemDefault(Tk_Window tkwin,
const char *dbName, const char *className)
}
@@ -402,27 +402,27 @@ declare 112 {
void TkpMenuThreadInit(void)
}
declare 113 {
- int TkClipBox(TkRegion rgn, XRectangle *rect_return)
+ int XClipBox(Region rgn, XRectangle *rect_return)
}
declare 114 {
- TkRegion TkCreateRegion(void)
+ Region XCreateRegion(void)
}
declare 115 {
- int TkDestroyRegion(TkRegion rgn)
+ int XDestroyRegion(Region rgn)
}
declare 116 {
- int TkIntersectRegion(TkRegion sra, TkRegion srcb, TkRegion dr_return)
+ int XIntersectRegion(Region sra, Region srcb, Region dr_return)
}
declare 117 {
- int TkRectInRegion(TkRegion rgn, int x, int y, unsigned int width,
+ int XRectInRegion(Region rgn, int x, int y, unsigned int width,
unsigned int height)
}
declare 118 {
- int TkSetRegion(Display *display, GC gc, TkRegion rgn)
+ int XSetRegion(Display *display, GC gc, Region rgn)
}
declare 119 {
- int TkUnionRectWithRegion(XRectangle *rect,
- TkRegion src, TkRegion dr_return)
+ int XUnionRectWithRegion(XRectangle *rect,
+ Region src, Region dr_return)
}
declare 121 aqua {
Pixmap TkpCreateNativeBitmap(Display *display, const void *source)
@@ -434,7 +434,7 @@ declare 124 aqua {
Pixmap TkpGetNativeAppBitmap(Display *display,
const char *name, int *width, int *height)
}
-declare 135 {
+declare 135 {deprecated {renamed to Tk_DrawHighlightBorder}} {
void TkpDrawHighlightBorder(Tk_Window tkwin, GC fgGC, GC bgGC,
int highlightWidth, Drawable drawable)
}
@@ -452,7 +452,7 @@ declare 139 {
void TkpInitKeymapInfo(TkDisplay *dispPtr)
}
declare 140 {
- TkRegion TkPhotoGetValidRegion(Tk_PhotoHandle handle)
+ Region TkPhotoGetValidRegion(Tk_PhotoHandle handle)
}
declare 141 {
TkWindow **TkWmStackorderToplevel(TkWindow *parentPtr)
@@ -467,7 +467,7 @@ declare 144 {
void TkGCCleanup(TkDisplay *dispPtr)
}
declare 145 {
- int TkSubtractRegion(TkRegion sra, TkRegion srcb, TkRegion dr_return)
+ int XSubtractRegion(Region sra, Region srcb, Region dr_return)
}
declare 146 {
void TkStylePkgInit(TkMainInfo *mainPtr)
@@ -498,25 +498,25 @@ declare 152 {
int highlightWidth, int borderWidth, int relief)
}
declare 153 {
- void TkCreateThreadExitHandler(Tcl_ExitProc *proc, ClientData clientData)
+ void TkCreateThreadExitHandler(Tcl_ExitProc *proc, void *clientData)
}
declare 154 {
- void TkDeleteThreadExitHandler(Tcl_ExitProc *proc, ClientData clientData)
+ void TkDeleteThreadExitHandler(Tcl_ExitProc *proc, void *clientData)
}
# entries needed only by tktest:
declare 156 {
- int TkpTestembedCmd(ClientData clientData, Tcl_Interp *interp, int objc,
+ int TkpTestembedCmd(void *clientData, Tcl_Interp *interp, Tcl_Size objc,
Tcl_Obj *const objv[])
}
declare 157 {
- int TkpTesttextCmd(ClientData dummy, Tcl_Interp *interp, int objc,
+ int TkpTesttextCmd(void *dummy, Tcl_Interp *interp, Tcl_Size objc,
Tcl_Obj *const objv[])
}
declare 158 {
int TkSelGetSelection(Tcl_Interp *interp, Tk_Window tkwin,
Atom selection, Atom target, Tk_GetSelProc *proc,
- ClientData clientData)
+ void *clientData)
}
declare 159 {
int TkTextGetIndex(Tcl_Interp *interp, struct TkText *textPtr,
@@ -524,21 +524,21 @@ declare 159 {
}
declare 160 {
int TkTextIndexBackBytes(const struct TkText *textPtr,
- const struct TkTextIndex *srcPtr, int count,
+ const struct TkTextIndex *srcPtr, Tcl_Size count,
struct TkTextIndex *dstPtr)
}
declare 161 {
int TkTextIndexForwBytes(const struct TkText *textPtr,
- const struct TkTextIndex *srcPtr, int count,
+ const struct TkTextIndex *srcPtr, Tcl_Size count,
struct TkTextIndex *dstPtr)
}
declare 162 {
struct TkTextIndex *TkTextMakeByteIndex(TkTextBTree tree,
const struct TkText *textPtr, int lineIndex,
- int byteIndex, struct TkTextIndex *indexPtr)
+ Tcl_Size byteIndex, struct TkTextIndex *indexPtr)
}
declare 163 {
- int TkTextPrintIndex(const struct TkText *textPtr,
+ Tcl_Size TkTextPrintIndex(const struct TkText *textPtr,
const struct TkTextIndex *indexPtr, char *string)
}
declare 164 {
@@ -547,7 +547,7 @@ declare 164 {
}
declare 165 {
int TkTextXviewCmd(struct TkText *textPtr, Tcl_Interp *interp,
- int objc, Tcl_Obj *const objv[])
+ Tcl_Size objc, Tcl_Obj *const objv[])
}
declare 166 {
void TkTextChanged(struct TkSharedText *sharedTextPtr,
@@ -566,59 +566,59 @@ declare 168 {
}
# Next group of functions exposed due to [Bug 2768945].
declare 169 {
- int TkStateParseProc(ClientData clientData, Tcl_Interp *interp,
- Tk_Window tkwin, const char *value, char *widgRec, int offset)
+ int TkStateParseProc(void *clientData, Tcl_Interp *interp,
+ Tk_Window tkwin, const char *value, char *widgRec, Tcl_Size offset)
}
declare 170 {
- CONST86 char *TkStatePrintProc(ClientData clientData, Tk_Window tkwin,
- char *widgRec, int offset, Tcl_FreeProc **freeProcPtr)
+ const char *TkStatePrintProc(void *clientData, Tk_Window tkwin,
+ char *widgRec, Tcl_Size offset, Tcl_FreeProc **freeProcPtr)
}
declare 171 {
- int TkCanvasDashParseProc(ClientData clientData, Tcl_Interp *interp,
- Tk_Window tkwin, const char *value, char *widgRec, int offset)
+ int TkCanvasDashParseProc(void *clientData, Tcl_Interp *interp,
+ Tk_Window tkwin, const char *value, char *widgRec, Tcl_Size offset)
}
declare 172 {
- CONST86 char *TkCanvasDashPrintProc(ClientData clientData, Tk_Window tkwin,
- char *widgRec, int offset, Tcl_FreeProc **freeProcPtr)
+ const char *TkCanvasDashPrintProc(void *clientData, Tk_Window tkwin,
+ char *widgRec, Tcl_Size offset, Tcl_FreeProc **freeProcPtr)
}
declare 173 {
- int TkOffsetParseProc(ClientData clientData, Tcl_Interp *interp,
- Tk_Window tkwin, const char *value, char *widgRec, int offset)
+ int TkOffsetParseProc(void *clientData, Tcl_Interp *interp,
+ Tk_Window tkwin, const char *value, char *widgRec, Tcl_Size offset)
}
declare 174 {
- CONST86 char *TkOffsetPrintProc(ClientData clientData, Tk_Window tkwin,
- char *widgRec, int offset, Tcl_FreeProc **freeProcPtr)
+ const char *TkOffsetPrintProc(void *clientData, Tk_Window tkwin,
+ char *widgRec, Tcl_Size offset, Tcl_FreeProc **freeProcPtr)
}
declare 175 {
- int TkPixelParseProc(ClientData clientData, Tcl_Interp *interp,
- Tk_Window tkwin, const char *value, char *widgRec, int offset)
+ int TkPixelParseProc(void *clientData, Tcl_Interp *interp,
+ Tk_Window tkwin, const char *value, char *widgRec, Tcl_Size offset)
}
declare 176 {
- CONST86 char *TkPixelPrintProc(ClientData clientData, Tk_Window tkwin,
- char *widgRec, int offset, Tcl_FreeProc **freeProcPtr)
+ const char *TkPixelPrintProc(void *clientData, Tk_Window tkwin,
+ char *widgRec, Tcl_Size offset, Tcl_FreeProc **freeProcPtr)
}
declare 177 {
- int TkOrientParseProc(ClientData clientData, Tcl_Interp *interp,
- Tk_Window tkwin, const char *value, char *widgRec, int offset)
+ int TkOrientParseProc(void *clientData, Tcl_Interp *interp,
+ Tk_Window tkwin, const char *value, char *widgRec, Tcl_Size offset)
}
declare 178 {
- CONST86 char *TkOrientPrintProc(ClientData clientData, Tk_Window tkwin,
- char *widgRec, int offset, Tcl_FreeProc **freeProcPtr)
+ const char *TkOrientPrintProc(void *clientData, Tk_Window tkwin,
+ char *widgRec, Tcl_Size offset, Tcl_FreeProc **freeProcPtr)
}
declare 179 {
- int TkSmoothParseProc(ClientData clientData, Tcl_Interp *interp,
- Tk_Window tkwin, const char *value, char *widgRec, int offset)
+ int TkSmoothParseProc(void *clientData, Tcl_Interp *interp,
+ Tk_Window tkwin, const char *value, char *widgRec, Tcl_Size offset)
}
declare 180 {
- CONST86 char *TkSmoothPrintProc(ClientData clientData, Tk_Window tkwin,
- char *widgRec, int offset, Tcl_FreeProc **freeProcPtr)
+ const char *TkSmoothPrintProc(void *clientData, Tk_Window tkwin,
+ char *widgRec, Tcl_Size offset, Tcl_FreeProc **freeProcPtr)
}
# Angled text API, exposed for Emiliano Gavilán's RBC work.
declare 181 {
void TkDrawAngledTextLayout(Display *display, Drawable drawable, GC gc,
- Tk_TextLayout layout, int x, int y, double angle, int firstChar,
- int lastChar)
+ Tk_TextLayout layout, int x, int y, double angle, Tcl_Size firstChar,
+ Tcl_Size lastChar)
}
declare 182 {
void TkUnderlineAngledTextLayout(Display *display, Drawable drawable,
@@ -631,19 +631,22 @@ declare 183 {
}
declare 184 {
void TkDrawAngledChars(Display *display,Drawable drawable, GC gc,
- Tk_Font tkfont, const char *source, int numBytes, double x,
+ Tk_Font tkfont, const char *source, Tcl_Size numBytes, double x,
double y, double angle)
}
# Support for aqua's inability to draw outside [NSView drawRect:]
-declare 185 macosx {
+declare 185 {
void TkpRedrawWidget(Tk_Window tkwin)
}
-declare 186 macosx {
+declare 186 {
int TkpWillDrawWidget(Tk_Window tkwin)
}
+
+# Debugging / testing functions for photo images
declare 187 {
- void TkUnusedStubEntry(void)
+ int TkDebugPhotoStringMatchDef(Tcl_Interp *inter, Tcl_Obj *data,
+ Tcl_Obj *formatString, int *widthPtr, int *heightPtr)
}
@@ -692,7 +695,7 @@ declare 12 x11 {
}
# only needed by tktest:
declare 13 x11 {
- int TkpTestsendCmd(ClientData clientData, Tcl_Interp *interp, int objc,
+ int TkpTestsendCmd_(void *clientData, Tcl_Interp *interp, Tcl_Size objc,
Tcl_Obj *const objv[])
}
declare 38 x11 {
@@ -718,7 +721,7 @@ declare 44 x11 {
}
# only needed by tktest:
declare 45 x11 {
- int TkpTestsendCmd_(ClientData clientData, Tcl_Interp *interp, int objc,
+ int TkpTestsendCmd(void *clientData, Tcl_Interp *interp, Tcl_Size objc,
Tcl_Obj *const objv[])
}
@@ -810,7 +813,7 @@ declare 27 win {
void TkWinWmCleanup(HINSTANCE hInstance)
}
declare 28 win {
- void TkWinXCleanup(ClientData clientData)
+ void TkWinXCleanup(void *clientData)
}
declare 29 win {
void TkWinXInit(HINSTANCE hInstance)
@@ -875,7 +878,7 @@ declare 44 win {
}
# only needed by tktest:
declare 45 win {
- int TkpTestsendCmd(ClientData clientData, Tcl_Interp *interp, int objc,
+ int TkpTestsendCmd(void *clientData, Tcl_Interp *interp, Tcl_Size objc,
Tcl_Obj *const objv[])
}
declare 47 win {
@@ -915,9 +918,10 @@ declare 9 aqua {
declare 10 aqua {
int TkMacOSXDispatchMenuEvent(int menuID, int index)
}
-declare 11 aqua {
- void TkMacOSXInstallCursor(int resizeOverride)
-}
+# Now a static function
+# declare 11 aqua {
+# void TkMacOSXInstallCursor(int resizeOverride)
+# }
declare 12 aqua {
void TkMacOSXHandleTearoffMenu(void)
}
@@ -989,7 +993,7 @@ declare 34 aqua {
int TkMacOSXUseMenuID(short macID)
}
declare 35 aqua {
- TkRegion TkMacOSXVisableClipRgn(TkWindow *winPtr)
+ Region TkMacOSXVisableClipRgn(TkWindow *winPtr)
}
declare 36 aqua {
void TkMacOSXWinBounds(TkWindow *winPtr, void *geometry)
@@ -1023,10 +1027,10 @@ declare 46 aqua {
int TkpIsWindowFloating(void *window)
}
declare 47 aqua {
- Tk_Window TkMacOSXGetCapture(void)
+ Tk_Window TkpGetCapture(void)
}
declare 49 aqua {
- Tk_Window TkGetTransientMaster(TkWindow *winPtr)
+ Tk_Window TkMacOSXGetContainer(TkWindow *winPtr)
}
declare 50 aqua {
int TkGenerateButtonEvent(int x, int y, Window window, unsigned int state)
@@ -1500,385 +1504,566 @@ declare 137 win {
int sx, int sy, int dx, int dy,
unsigned int w, unsigned int h)
}
+declare 138 win {
+ Region XPolygonRegion(XPoint *pts, int n, int rule)
+}
+declare 139 win {
+ int XPointInRegion(Region rgn, int x, int y)
+}
+# For XIM
+declare 140 win {
+ XVaNestedList XVaCreateNestedList(int dummy, ...)
+}
+declare 141 win {
+ char *XSetICValues(XIC xic, ...)
+}
+declare 142 win {
+ char *XGetICValues(XIC xic, ...)
+}
+declare 143 win {
+ void XSetICFocus(XIC xic)
+}
+declare 147 win {
+ void XFreeFontSet(Display *display, XFontSet fontset)
+}
+declare 148 win {
+ int XCloseIM(XIM im)
+}
+declare 149 win {
+ Bool XRegisterIMInstantiateCallback(Display *dpy, struct _XrmHashBucketRec *rbd,
+ char *res_name, char *res_class, XIDProc callback, XPointer client_data)
+}
+declare 150 win {
+ Bool XUnregisterIMInstantiateCallback(Display *dpy, struct _XrmHashBucketRec *rbd,
+ char *res_name, char *res_class, XIDProc callback, XPointer client_data)
+}
+declare 151 win {
+ char *XSetLocaleModifiers(const char *modifier_list)
+}
+declare 152 win {
+ XIM XOpenIM(Display *dpy, struct _XrmHashBucketRec *rdb, char *res_name,
+ char *res_class)
+}
+declare 153 win {
+ char *XGetIMValues(XIM im, ...)
+}
+declare 154 win {
+ char *XSetIMValues(XIM im, ...)
+}
+declare 155 win {
+ XFontSet XCreateFontSet(Display *display, _Xconst char *base_font_name_list,
+ char ***missing_charset_list, int *missing_charset_count, char **def_string)
+}
+declare 156 win {
+ void XFreeStringList(char **list)
+}
+declare 157 win {
+ KeySym XkbKeycodeToKeysym(Display *d, unsigned int k, int g, int i)
+}
declare 158 win {
- void TkUnusedStubEntry(void)
+ Display *XkbOpenDisplay(const char *name, int *ev_rtrn, int *err_rtrn,
+ int *major_rtrn, int *minor_rtrn, int *reason)
}
################################
-# X functions for Aqua
+# X functions for MacOSX
-declare 0 aqua {
+declare 0 macosx {
int XSetDashes(Display *display, GC gc, int dash_offset,
_Xconst char *dash_list, int n)
}
-declare 1 aqua {
+declare 1 macosx {
XModifierKeymap *XGetModifierMapping(Display *d)
}
-declare 2 aqua {
+declare 2 macosx {
XImage *XCreateImage(Display *d, Visual *v, unsigned int ui1, int i1,
int i2, char *cp, unsigned int ui2, unsigned int ui3, int i3,
int i4)
}
-declare 3 aqua {
+declare 3 macosx {
XImage *XGetImage(Display *d, Drawable dr, int i1, int i2,
unsigned int ui1, unsigned int ui2, unsigned long ul, int i3)
}
-declare 4 aqua {
+declare 4 macosx {
char *XGetAtomName(Display *d, Atom a)
}
-declare 5 aqua {
+declare 5 macosx {
char *XKeysymToString(KeySym k)
}
-declare 6 aqua {
+declare 6 macosx {
Colormap XCreateColormap(Display *d, Window w, Visual *v, int i)
}
-declare 7 aqua {
+declare 7 macosx {
GContext XGContextFromGC(GC g)
}
-declare 8 aqua {
- KeySym XKeycodeToKeysym(Display *d, KeyCode k, int i)
+# second parameter was of type KeyCode
+declare 8 macosx {
+ KeySym XKeycodeToKeysym(Display *d, unsigned int k, int i)
}
-declare 9 aqua {
+declare 9 macosx {
KeySym XStringToKeysym(_Xconst char *c)
}
-declare 10 aqua {
+declare 10 macosx {
Window XRootWindow(Display *d, int i)
}
-declare 11 aqua {
+declare 11 macosx {
XErrorHandler XSetErrorHandler(XErrorHandler x)
}
-declare 12 aqua {
+declare 12 macosx {
Status XAllocColor(Display *d, Colormap c, XColor *xp)
}
-declare 13 aqua {
+declare 13 macosx {
int XBell(Display *d, int i)
}
-declare 14 aqua {
+declare 14 macosx {
int XChangeProperty(Display *d, Window w, Atom a1, Atom a2, int i1,
int i2, _Xconst unsigned char *c, int i3)
}
-declare 15 aqua {
+declare 15 macosx {
int XChangeWindowAttributes(Display *d, Window w, unsigned long ul,
XSetWindowAttributes *x)
}
-declare 16 aqua {
+declare 16 macosx {
int XConfigureWindow(Display *d, Window w, unsigned int i,
XWindowChanges *x)
}
-declare 17 aqua {
+declare 17 macosx {
int XCopyArea(Display *d, Drawable dr1, Drawable dr2, GC g, int i1,
int i2, unsigned int ui1, unsigned int ui2, int i3, int i4)
}
-declare 18 aqua {
+declare 18 macosx {
int XCopyPlane(Display *d, Drawable dr1, Drawable dr2, GC g, int i1,
int i2, unsigned int ui1,
unsigned int ui2, int i3, int i4, unsigned long ul)
}
-declare 19 aqua {
+declare 19 macosx {
Pixmap XCreateBitmapFromData(Display *display, Drawable d,
_Xconst char *data, unsigned int width, unsigned int height)
}
-declare 20 aqua {
+declare 20 macosx {
int XDefineCursor(Display *d, Window w, Cursor c)
}
-declare 21 aqua {
+declare 21 macosx {
int XDestroyWindow(Display *d, Window w)
}
-declare 22 aqua {
+declare 22 macosx {
int XDrawArc(Display *d, Drawable dr, GC g, int i1, int i2,
unsigned int ui1, unsigned int ui2, int i3, int i4)
}
-declare 23 aqua {
+declare 23 macosx {
int XDrawLines(Display *d, Drawable dr, GC g, XPoint *x, int i1, int i2)
}
-declare 24 aqua {
+declare 24 macosx {
int XDrawRectangle(Display *d, Drawable dr, GC g, int i1, int i2,
unsigned int ui1, unsigned int ui2)
}
-declare 25 aqua {
+declare 25 macosx {
int XFillArc(Display *d, Drawable dr, GC g, int i1, int i2,
unsigned int ui1, unsigned int ui2, int i3, int i4)
}
-declare 26 aqua {
+declare 26 macosx {
int XFillPolygon(Display *d, Drawable dr, GC g, XPoint *x,
int i1, int i2, int i3)
}
-declare 27 aqua {
+declare 27 macosx {
int XFillRectangles(Display *d, Drawable dr, GC g, XRectangle *x, int i)
}
-declare 28 aqua {
+declare 28 macosx {
int XFreeColormap(Display *d, Colormap c)
}
-declare 29 aqua {
+declare 29 macosx {
int XFreeColors(Display *d, Colormap c,
unsigned long *ulp, int i, unsigned long ul)
}
-declare 30 aqua {
+declare 30 macosx {
int XFreeModifiermap(XModifierKeymap *x)
}
-declare 31 aqua {
+declare 31 macosx {
Status XGetGeometry(Display *d, Drawable dr, Window *w, int *i1,
int *i2, unsigned int *ui1, unsigned int *ui2, unsigned int *ui3,
unsigned int *ui4)
}
-declare 32 aqua {
+declare 32 macosx {
int XGetWindowProperty(Display *d, Window w, Atom a1, long l1, long l2,
Bool b, Atom a2, Atom *ap, int *ip, unsigned long *ulp1,
unsigned long *ulp2, unsigned char **cpp)
}
-declare 33 aqua {
+declare 33 macosx {
int XGrabKeyboard(Display *d, Window w, Bool b, int i1, int i2, Time t)
}
-declare 34 aqua {
+declare 34 macosx {
int XGrabPointer(Display *d, Window w1, Bool b, unsigned int ui,
int i1, int i2, Window w2, Cursor c, Time t)
}
-declare 35 aqua {
+declare 35 macosx {
KeyCode XKeysymToKeycode(Display *d, KeySym k)
}
-declare 36 aqua {
+declare 36 macosx {
int XMapWindow(Display *d, Window w)
}
-declare 37 aqua {
+declare 37 macosx {
int XMoveResizeWindow(Display *d, Window w, int i1, int i2,
unsigned int ui1, unsigned int ui2)
}
-declare 38 aqua {
+declare 38 macosx {
int XMoveWindow(Display *d, Window w, int i1, int i2)
}
-declare 39 aqua {
+declare 39 macosx {
Bool XQueryPointer(Display *d, Window w1, Window *w2, Window *w3,
int *i1, int *i2, int *i3, int *i4, unsigned int *ui)
}
-declare 40 aqua {
+declare 40 macosx {
int XRaiseWindow(Display *d, Window w)
}
-declare 41 aqua {
+declare 41 macosx {
int XRefreshKeyboardMapping(XMappingEvent *x)
}
-declare 42 aqua {
+declare 42 macosx {
int XResizeWindow(Display *d, Window w, unsigned int ui1,
unsigned int ui2)
}
-declare 43 aqua {
+declare 43 macosx {
int XSelectInput(Display *d, Window w, long l)
}
-declare 44 aqua {
+declare 44 macosx {
Status XSendEvent(Display *d, Window w, Bool b, long l, XEvent *x)
}
-declare 45 aqua {
+declare 45 macosx {
int XSetIconName(Display *d, Window w, _Xconst char *c)
}
-declare 46 aqua {
+declare 46 macosx {
int XSetInputFocus(Display *d, Window w, int i, Time t)
}
-declare 47 aqua {
+declare 47 macosx {
int XSetSelectionOwner(Display *d, Atom a, Window w, Time t)
}
-declare 48 aqua {
+declare 48 macosx {
int XSetWindowBackground(Display *d, Window w, unsigned long ul)
}
-declare 49 aqua {
+declare 49 macosx {
int XSetWindowBackgroundPixmap(Display *d, Window w, Pixmap p)
}
-declare 50 aqua {
+declare 50 macosx {
int XSetWindowBorder(Display *d, Window w, unsigned long ul)
}
-declare 51 aqua {
+declare 51 macosx {
int XSetWindowBorderPixmap(Display *d, Window w, Pixmap p)
}
-declare 52 aqua {
+declare 52 macosx {
int XSetWindowBorderWidth(Display *d, Window w, unsigned int ui)
}
-declare 53 aqua {
+declare 53 macosx {
int XSetWindowColormap(Display *d, Window w, Colormap c)
}
-declare 54 aqua {
+declare 54 macosx {
int XUngrabKeyboard(Display *d, Time t)
}
-declare 55 aqua {
+declare 55 macosx {
int XUngrabPointer(Display *d, Time t)
}
-declare 56 aqua {
+declare 56 macosx {
int XUnmapWindow(Display *d, Window w)
}
-declare 57 aqua {
+declare 57 macosx {
int TkPutImage(unsigned long *colors, int ncolors, Display *display,
Drawable d, GC gc, XImage *image, int src_x, int src_y,
int dest_x, int dest_y, unsigned int width, unsigned int height)
}
-declare 58 aqua {
+declare 58 macosx {
Status XParseColor(Display *display, Colormap map,
_Xconst char *spec, XColor *colorPtr)
}
-declare 59 aqua {
+declare 59 macosx {
GC XCreateGC(Display *display, Drawable d,
unsigned long valuemask, XGCValues *values)
}
-declare 60 aqua {
+declare 60 macosx {
int XFreeGC(Display *display, GC gc)
}
-declare 61 aqua {
+declare 61 macosx {
Atom XInternAtom(Display *display, _Xconst char *atom_name,
Bool only_if_exists)
}
-declare 62 aqua {
+declare 62 macosx {
int XSetBackground(Display *display, GC gc, unsigned long foreground)
}
-declare 63 aqua {
+declare 63 macosx {
int XSetForeground(Display *display, GC gc, unsigned long foreground)
}
-declare 64 aqua {
+declare 64 macosx {
int XSetClipMask(Display *display, GC gc, Pixmap pixmap)
}
-declare 65 aqua {
+declare 65 macosx {
int XSetClipOrigin(Display *display, GC gc,
int clip_x_origin, int clip_y_origin)
}
-declare 66 aqua {
+declare 66 macosx {
int XSetTSOrigin(Display *display, GC gc,
int ts_x_origin, int ts_y_origin)
}
-declare 67 aqua {
+declare 67 macosx {
int XChangeGC(Display *d, GC gc, unsigned long mask, XGCValues *values)
}
-declare 68 aqua {
+declare 68 macosx {
int XSetFont(Display *display, GC gc, Font font)
}
-declare 69 aqua {
+declare 69 macosx {
int XSetArcMode(Display *display, GC gc, int arc_mode)
}
-declare 70 aqua {
+declare 70 macosx {
int XSetStipple(Display *display, GC gc, Pixmap stipple)
}
-declare 71 aqua {
+declare 71 macosx {
int XSetFillRule(Display *display, GC gc, int fill_rule)
}
-declare 72 aqua {
+declare 72 macosx {
int XSetFillStyle(Display *display, GC gc, int fill_style)
}
-declare 73 aqua {
+declare 73 macosx {
int XSetFunction(Display *display, GC gc, int function)
}
-declare 74 aqua {
+declare 74 macosx {
int XSetLineAttributes(Display *display, GC gc, unsigned int line_width,
int line_style, int cap_style, int join_style)
}
-declare 75 aqua {
+declare 75 macosx {
int _XInitImageFuncPtrs(XImage *image)
}
-declare 76 aqua {
+declare 76 macosx {
XIC XCreateIC(XIM xim, ...)
}
-declare 77 aqua {
+declare 77 macosx {
XVisualInfo *XGetVisualInfo(Display *display, long vinfo_mask,
XVisualInfo *vinfo_template, int *nitems_return)
}
-declare 78 aqua {
+declare 78 macosx {
void XSetWMClientMachine(Display *display, Window w,
XTextProperty *text_prop)
}
-declare 79 aqua {
+declare 79 macosx {
Status XStringListToTextProperty(char **list, int count,
XTextProperty *text_prop_return)
}
-declare 80 aqua {
+declare 80 macosx {
int XDrawSegments(Display *display, Drawable d, GC gc,
XSegment *segments, int nsegments)
}
-declare 81 aqua {
+declare 81 macosx {
int XForceScreenSaver(Display *display, int mode)
}
-declare 82 aqua {
+declare 82 macosx {
int XDrawLine(Display *d, Drawable dr, GC g, int x1, int y1,
int x2, int y2)
}
-declare 83 aqua {
+declare 83 macosx {
int XFillRectangle(Display *display, Drawable d, GC gc,
int x, int y, unsigned int width, unsigned int height)
}
-declare 84 aqua {
+declare 84 macosx {
int XClearWindow(Display *d, Window w)
}
-declare 85 aqua {
+declare 85 macosx {
int XDrawPoint(Display *display, Drawable d, GC gc, int x, int y)
}
-declare 86 aqua {
+declare 86 macosx {
int XDrawPoints(Display *display, Drawable d, GC gc, XPoint *points,
int npoints, int mode)
}
-declare 87 aqua {
+declare 87 macosx {
int XWarpPointer(Display *display, Window src_w, Window dest_w,
int src_x, int src_y, unsigned int src_width,
unsigned int src_height, int dest_x, int dest_y)
}
-declare 88 aqua {
+declare 88 macosx {
int XQueryColor(Display *display, Colormap colormap, XColor *def_in_out)
}
-declare 89 aqua {
+declare 89 macosx {
int XQueryColors(Display *display, Colormap colormap,
XColor *defs_in_out, int ncolors)
}
-declare 90 aqua {
+declare 90 macosx {
Status XQueryTree(Display *d, Window w1, Window *w2, Window *w3,
Window **w4, unsigned int *ui)
}
-declare 91 aqua {
+declare 91 macosx {
int XSync(Display *display, Bool discard)
}
-declare 106 aqua {
+declare 92 macosx {
+ Bool XTranslateCoordinates(Display *d, Window w1, Window w2, int i1,
+ int i2, int *i3, int *i4, Window *w3)
+}
+declare 93 macosx {
+ int XDeleteProperty(Display *d, Window w, Atom a)
+}
+declare 94 macosx {
+ int XFreeCursor(Display *d, Cursor c)
+}
+declare 95 macosx {
+ int XGetInputFocus(Display *d, Window *w, int *i)
+}
+declare 96 macosx {
+ int XmbLookupString(XIC xi, XKeyPressedEvent *xk, char *c, int i,
+ KeySym *k, Status *s)
+}
+declare 97 macosx {
+ int XNextEvent(Display *d, XEvent *x)
+}
+declare 98 macosx {
+ int XPutBackEvent(Display *d, XEvent *x)
+}
+declare 99 macosx {
+ int XSetCommand(Display *d, Window w, char **c, int i)
+}
+declare 100 macosx {
+ int XWindowEvent(Display *d, Window w, long l, XEvent *x)
+}
+declare 101 macosx {
+ Status XGetWindowAttributes(Display *d, Window w, XWindowAttributes *x)
+}
+declare 102 macosx {
+ Status XGetWMColormapWindows(Display *d, Window w, Window **wpp, int *ip)
+}
+declare 103 macosx {
+ Status XIconifyWindow(Display *d, Window w, int i)
+}
+declare 104 macosx {
+ Status XWithdrawWindow(Display *d, Window w, int i)
+}
+declare 105 macosx {
+ XHostAddress *XListHosts(Display *d, int *i, Bool *b)
+}
+declare 106 macosx {
int XSetClipRectangles(Display *display, GC gc, int clip_x_origin,
int clip_y_origin, XRectangle rectangles[], int n, int ordering)
}
-declare 107 aqua {
+declare 107 macosx {
int XFlush(Display *display)
}
-declare 108 aqua {
+declare 108 macosx {
int XGrabServer(Display *display)
}
-declare 109 aqua {
+declare 109 macosx {
int XUngrabServer(Display *display)
}
-declare 110 aqua {
+declare 110 macosx {
int XFree(void *data)
}
-declare 111 aqua {
+declare 111 macosx {
int XNoOp(Display *display)
}
-declare 112 aqua {
+declare 112 macosx {
XAfterFunction XSynchronize(Display *display, Bool onoff)
}
-declare 114 aqua {
+declare 113 macosx {
+ Status XLookupColor(Display *d, Colormap c1, _Xconst char *c2,
+ XColor *x1, XColor *x2)
+}
+declare 114 macosx {
VisualID XVisualIDFromVisual(Visual *visual)
}
-declare 120 aqua {
- int XOffsetRegion(void *rgn, int dx, int dy)
+declare 120 macosx {
+ int XOffsetRegion(Region rgn, int dx, int dy)
+}
+declare 121 macosx {
+ int XUnionRegion(Region srca, Region srcb, Region dr_return)
+}
+declare 122 macosx {
+ Window XCreateWindow(Display *display, Window parent, int x, int y,
+ unsigned int width, unsigned int height,
+ unsigned int border_width, int depth, unsigned int clazz,
+ Visual *visual, unsigned long value_mask,
+ XSetWindowAttributes *attributes)
}
-declare 129 aqua {
+declare 129 macosx {
int XLowerWindow(Display *d, Window w)
}
-declare 137 aqua {
+declare 130 macosx {
+ int XFillArcs(Display *d, Drawable dr, GC gc, XArc *a, int n)
+}
+declare 131 macosx {
+ int XDrawArcs(Display *d, Drawable dr, GC gc, XArc *a, int n)
+}
+declare 132 macosx {
+ int XDrawRectangles(Display *d, Drawable dr, GC gc, XRectangle *r, int n)
+}
+declare 136 macosx {
+ int XReparentWindow(Display *d, Window w, Window p, int x, int y)
+}
+declare 137 macosx {
int XPutImage(Display *d, Drawable dr, GC gc, XImage *im,
int sx, int sy, int dx, int dy,
unsigned int w, unsigned int h)
}
-declare 144 aqua {
+declare 138 macosx {
+ Region XPolygonRegion(XPoint *pts, int n, int rule)
+}
+declare 139 macosx {
+ int XPointInRegion(Region rgn, int x, int y)
+}
+declare 140 macosx {
+ XVaNestedList XVaCreateNestedList(int dummy, ...)
+}
+declare 141 macosx {
+ char *XSetICValues(XIC xic, ...)
+}
+declare 142 macosx {
+ char *XGetICValues(XIC xic, ...)
+}
+declare 143 macosx {
+ void XSetICFocus(XIC xic)
+}
+declare 144 macosx {
void XDestroyIC(XIC xic)
}
-declare 145 aqua {
+declare 145 macosx {
Cursor XCreatePixmapCursor(Display *d, Pixmap p1, Pixmap p2,
XColor *x1, XColor *x2, unsigned int ui1, unsigned int ui2)
}
-declare 146 aqua {
+declare 146 macosx {
Cursor XCreateGlyphCursor(Display *d, Font f1, Font f2,
unsigned int ui1, unsigned int ui2, XColor _Xconst *x1,
XColor _Xconst *x2)
}
-declare 157 aqua {
+declare 147 macosx {
+ void XFreeFontSet(Display *display, XFontSet fontset)
+}
+declare 148 macosx {
+ int XCloseIM(XIM im)
+}
+declare 149 macosx {
+ Bool XRegisterIMInstantiateCallback(Display *dpy, struct _XrmHashBucketRec *rbd,
+ char *res_name, char *res_class, XIDProc callback, XPointer client_data)
+}
+declare 150 macosx {
+ Bool XUnregisterIMInstantiateCallback(Display *dpy, struct _XrmHashBucketRec *rbd,
+ char *res_name, char *res_class, XIDProc callback, XPointer client_data)
+}
+declare 151 macosx {
+ char *XSetLocaleModifiers(const char *modifier_list)
+}
+declare 152 macosx {
+ XIM XOpenIM(Display *dpy, struct _XrmHashBucketRec *rdb, char *res_name,
+ char *res_class)
+}
+declare 153 macosx {
+ char *XGetIMValues(XIM im, ...)
+}
+declare 154 macosx {
+ char *XSetIMValues(XIM im, ...)
+}
+declare 155 macosx {
+ XFontSet XCreateFontSet(Display *display, _Xconst char *base_font_name_list,
+ char ***missing_charset_list, int *missing_charset_count, char **def_string)
+}
+declare 156 macosx {
+ void XFreeStringList(char **list)
+}
+declare 157 macosx {
KeySym XkbKeycodeToKeysym(Display *d, unsigned int k, int g, int i)
}
-declare 158 aqua {
- void TkUnusedStubEntry(void)
+declare 158 macosx {
+ Display *XkbOpenDisplay(const char *name, int *ev_rtrn, int *err_rtrn,
+ int *major_rtrn, int *minor_rtrn, int *reason)
}
# Local Variables:
diff --git a/generic/tkInt.h b/generic/tkInt.h
index 00a55be..5ee4791 100644
--- a/generic/tkInt.h
+++ b/generic/tkInt.h
@@ -4,9 +4,9 @@
* Declarations for things used internally by the Tk functions 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 Scriptics Corporation.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1998 Scriptics Corporation.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -19,21 +19,20 @@
#include "tkPort.h"
#endif
-#define TK_OPTION_ENUM_VAR ((int)(sizeof(Tk_OptionType)&(sizeof(int)-1))<<6)
-
/*
* Ensure WORDS_BIGENDIAN is defined correctly:
* Needs to happen here in addition to configure to work with fat compiles on
* Darwin (where configure runs only once for multiple architectures).
*/
-#include <stdio.h>
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_SYS_PARAM_H
# include <sys/param.h>
#endif
+#include <stdint.h>
+#include <stdlib.h>
#ifdef BYTE_ORDER
# ifdef BIG_ENDIAN
# if BYTE_ORDER == BIG_ENDIAN
@@ -76,14 +75,39 @@
# endif
#endif
-#if defined(_WIN32) && (TCL_MAJOR_VERSION < 9) && (TCL_MINOR_VERSION < 7)
-# if TCL_UTF_MAX > 3
-# define Tcl_WCharToUtfDString(a,b,c) Tcl_WinTCharToUtf((TCHAR *)(a),(b)*sizeof(WCHAR),c)
-# define Tcl_UtfToWCharDString(a,b,c) (WCHAR *)Tcl_WinUtfToTChar(a,b,c)
-# else
-# define Tcl_WCharToUtfDString ((char * (*)(const WCHAR *, int len, Tcl_DString *))Tcl_UniCharToUtfDString)
-# define Tcl_UtfToWCharDString ((WCHAR * (*)(const char *, int len, Tcl_DString *))Tcl_UtfToUniCharDString)
-# endif
+#if (TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION < 7)
+# define Tcl_WCharToUtfDString ((char * (*)(const WCHAR *, int, Tcl_DString *))Tcl_UniCharToUtfDString)
+# define Tcl_UtfToWCharDString ((WCHAR * (*)(const char *, int, Tcl_DString *))Tcl_UtfToUniCharDString)
+# define Tcl_Char16ToUtfDString Tcl_UniCharToUtfDString
+# define Tcl_UtfToChar16DString Tcl_UtfToUniCharDString
+# define TCL_COMBINE 0
+#endif
+
+/* Make available UTF-32 versions of the API, even though we compile with TCL_UTF_MAX=3 */
+#if TCL_MAJOR_VERSION > 8
+# define TkUtfToUniChar (tclStubsPtr->tcl_UtfToUniChar) /* 646 */
+# define TkUniCharToUtf (tclStubsPtr->tcl_UniCharToUtf) /* 324 (without TCL_COMBINE) */
+# define TkNumUtfChars (tclStubsPtr->tcl_NumUtfChars) /* 669 */
+# define TkGetCharLength (tclStubsPtr->tcl_GetCharLength) /* 670 */
+# define TkUtfAtIndex (tclStubsPtr->tcl_UtfAtIndex) /* 671 */
+#else
+ MODULE_SCOPE Tcl_Size TkUtfToUniChar(const char *, int *);
+ MODULE_SCOPE Tcl_Size TkUniCharToUtf(int, char *);
+# ifdef USE_TCL_STUBS
+# define TkNumUtfChars (((&tclStubsPtr->tcl_PkgProvideEx)[631]) ? \
+ ((Tcl_Size (*)(const char *, Tcl_Size))(void *)((&tclStubsPtr->tcl_PkgProvideEx)[669])) \
+ : (tclStubsPtr->tcl_NumUtfChars) /* 312 */)
+# define TkGetCharLength (((&tclStubsPtr->tcl_PkgProvideEx)[631]) ? \
+ ((Tcl_Size (*)(Tcl_Obj *))(void *)((&tclStubsPtr->tcl_PkgProvideEx)[670])) \
+ : (tclStubsPtr->tcl_GetCharLength) /* 380 */)
+# define TkUtfAtIndex (((&tclStubsPtr->tcl_PkgProvideEx)[631]) ? \
+ ((const char *(*)(const char *, Tcl_Size))(void *)((&tclStubsPtr->tcl_PkgProvideEx)[671])) \
+ : (tclStubsPtr->tcl_UtfAtIndex) /* 325 */)
+# else
+# define TkNumUtfChars TclNumUtfChars
+# define TkGetCharLength TclGetCharLength
+# define TkUtfAtIndex TclUtfAtIndex
+# endif
#endif
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
@@ -94,7 +118,7 @@
# define TKFLEXARRAY 1
#endif
-#ifndef Tcl_GetParent
+#if !defined(Tcl_GetParent) && (TCL_MAJOR_VERSION < 9) && (TCL_MINOR_VERSION < 7)
# define Tcl_GetParent Tcl_GetMaster
#endif
@@ -104,23 +128,29 @@
* to/from pointer from/to integer of different size".
*/
-#if !defined(INT2PTR) && !defined(PTR2INT)
-# if defined(HAVE_INTPTR_T) || defined(intptr_t)
-# define INT2PTR(p) ((void*)(intptr_t)(p))
-# define PTR2INT(p) ((int)(intptr_t)(p))
-# else
-# define INT2PTR(p) ((void*)(p))
-# define PTR2INT(p) ((int)(p))
-# endif
+#if !defined(INT2PTR)
+# define INT2PTR(p) ((void *)(ptrdiff_t)(p))
#endif
-#if !defined(UINT2PTR) && !defined(PTR2UINT)
-# if defined(HAVE_UINTPTR_T) || defined(uintptr_t)
-# define UINT2PTR(p) ((void*)(uintptr_t)(p))
-# define PTR2UINT(p) ((unsigned int)(uintptr_t)(p))
-# else
-# define UINT2PTR(p) ((void*)(p))
-# define PTR2UINT(p) ((unsigned int)(p))
-# endif
+#if !defined(PTR2INT)
+# define PTR2INT(p) ((ptrdiff_t)(p))
+#endif
+#if !defined(UINT2PTR)
+# define UINT2PTR(p) ((void *)(size_t)(p))
+#endif
+#if !defined(PTR2UINT)
+# define PTR2UINT(p) ((size_t)(p))
+#endif
+
+/*
+ * Fallback in case Tk is linked against a Tcl version not having TIP #585
+ * (TCL_INDEX_TEMP_TABLE) or TIP #613/#618 (TCL_NULL_OK)
+ */
+
+#ifndef TCL_NULL_OK
+# define TCL_NULL_OK 32
+#endif
+#if !defined(TCL_INDEX_TEMP_TABLE)
+# define TCL_INDEX_TEMP_TABLE 64
#endif
#ifndef TCL_Z_MODIFIER
@@ -132,6 +162,16 @@
# define TCL_Z_MODIFIER ""
# endif
#endif /* !TCL_Z_MODIFIER */
+#undef TCL_LL_MODIFIER
+#if defined(_WIN32) && (!defined(__USE_MINGW_ANSI_STDIO) || !__USE_MINGW_ANSI_STDIO)
+# define TCL_LL_MODIFIER "I64"
+#else
+# define TCL_LL_MODIFIER "ll"
+#endif
+
+#if !defined(TCL_SIZE_MODIFIER)
+# define TCL_SIZE_MODIFIER ""
+#endif
/*
* Opaque type declarations:
@@ -141,7 +181,7 @@ typedef struct TkColormap TkColormap;
typedef struct TkFontAttributes TkFontAttributes;
typedef struct TkGrabEvent TkGrabEvent;
typedef struct TkpCursor_ *TkpCursor;
-typedef struct TkRegion_ *TkRegion;
+#define TkRegion Region
typedef struct TkStressedCmap TkStressedCmap;
typedef struct TkBindInfo_ *TkBindInfo;
typedef struct Busy *TkBusy;
@@ -156,7 +196,7 @@ typedef struct TkCursor {
Tk_Cursor cursor; /* System specific identifier for cursor. */
Display *display; /* Display containing cursor. Needed for
* disposal and retrieval of cursors. */
- int resourceRefCount; /* Number of active uses of this cursor (each
+ Tcl_Size resourceRefCount; /* Number of active uses of this cursor (each
* active use corresponds to a call to
* Tk_AllocPreserveFromObj or Tk_Preserve). If
* this count is 0, then this structure is no
@@ -165,7 +205,7 @@ typedef struct TkCursor {
* there are objects referring to it. The
* structure is freed when resourceRefCount
* and objRefCount are both 0. */
- int objRefCount; /* Number of Tcl objects that reference this
+ Tcl_Size objRefCount; /* Number of Tcl objects that reference this
* structure.. */
Tcl_HashTable *otherTable; /* Second table (other than idTable) used to
* index this entry. */
@@ -200,6 +240,8 @@ typedef struct TkCaret {
* specific data, since each thread will have its own TkDisplay structure.
*/
+typedef enum TkLockUsage {LU_IGNORE, LU_CAPS, LU_SHIFT} TkLockUsage;
+
typedef struct TkDisplay {
Display *display; /* Xlib's info about display. */
struct TkDisplay *nextPtr; /* Next in list of all displays. */
@@ -241,10 +283,10 @@ typedef struct TkDisplay {
unsigned int altModMask; /* Has one bit set to indicate the modifier
* corresponding to the "Meta" key. If no such
* modifier, then this is zero. */
- enum {LU_IGNORE, LU_CAPS, LU_SHIFT} lockUsage;
+ TkLockUsage lockUsage;
/* Indicates how to interpret lock
* modifier. */
- int numModKeyCodes; /* Number of entries in modKeyCodes array
+ Tcl_Size 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
@@ -315,7 +357,7 @@ typedef struct TkDisplay {
/* First in list of error handlers for this
* display. NULL means no handlers exist at
* present. */
- int deleteCount; /* Counts # of handlers deleted since last
+ Tcl_Size deleteCount; /* Counts # of handlers deleted since last
* time inactive handlers were garbage-
* collected. When this number gets big,
* handlers get cleaned up. */
@@ -456,9 +498,9 @@ typedef struct TkDisplay {
*/
int placeInit; /* 0 means tables below need initializing. */
- Tcl_HashTable masterTable; /* Maps from Tk_Window toke to the Master
+ Tcl_HashTable containerTable; /* Maps from Tk_Window token to the Container
* structure for the window, if it exists. */
- Tcl_HashTable slaveTable; /* Maps from Tk_Window toke to the Slave
+ Tcl_HashTable contentTable; /* Maps from Tk_Window token to the Content
* structure for the window, if it exists. */
/*
@@ -530,14 +572,14 @@ typedef struct TkDisplay {
* Miscellaneous information:
*/
-#ifdef TK_USE_INPUT_METHODS
+#if defined(TK_USE_INPUT_METHODS) || (TCL_MAJOR_VERSION > 8)
XIM inputMethod; /* Input method for this display. */
XIMStyle inputStyle; /* Input style selected for this display. */
XFontSet inputXfs; /* XFontSet cached for over-the-spot XIM. */
#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
+ Tcl_Size 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. */
@@ -546,10 +588,17 @@ typedef struct TkDisplay {
* The following field were all added for Tk8.3
*/
+#if TCL_MAJOR_VERSION < 9
+#if !defined(TK_NO_DEPRECATED)
int mouseButtonState; /* Current mouse button state for this
* display. NOT USED as of 8.6.10 */
Window mouseButtonWindow; /* Window the button state was set in, added
* in Tk 8.4. */
+#else
+ int notused1;
+ XID notused2;
+#endif /* !TK_NO_DEPRECATED */
+#endif
Tk_Window warpWindow;
Tk_Window warpMainwin; /* For finding the root window for warping
* purposes. */
@@ -567,8 +616,11 @@ typedef struct TkDisplay {
int iconDataSize; /* Size of default iconphoto image data. */
unsigned char *iconDataPtr; /* Default iconphoto image data, if set. */
-#ifdef TK_USE_INPUT_METHODS
int ximGeneration; /* Used to invalidate XIC */
+#if !defined(TK_USE_INPUT_METHODS) && (TCL_MAJOR_VERSION < 9)
+ XIM inputMethod; /* Input method for this display. */
+ XIMStyle inputStyle; /* Input style selected for this display. */
+ XFontSet inputXfs; /* XFontSet cached for over-the-spot XIM. */
#endif /* TK_USE_INPUT_METHODS */
} TkDisplay;
@@ -580,15 +632,11 @@ typedef struct TkDisplay {
* Whether to use input methods for this display
* TK_DISPLAY_WM_TRACING: (default off)
* Whether we should do wm tracing on this display.
- * TK_DISPLAY_IN_WARP: (default off)
- * Indicates that we are in a pointer warp
*/
#define TK_DISPLAY_COLLAPSE_MOTION_EVENTS (1 << 0)
#define TK_DISPLAY_USE_IM (1 << 1)
#define TK_DISPLAY_WM_TRACING (1 << 3)
-#define TK_DISPLAY_IN_WARP (1 << 4)
-#define TK_DISPLAY_USE_XKB (1 << 5)
/*
* One of the following structures exists for each error handler created by a
@@ -613,7 +661,7 @@ typedef struct TkErrorHandler {
* codes). */
Tk_ErrorProc *errorProc; /* Function to invoke when a matching error
* occurs. NULL means just ignore errors. */
- ClientData clientData; /* Arbitrary value to pass to errorProc. */
+ void *clientData; /* Arbitrary value to pass to errorProc. */
struct TkErrorHandler *nextPtr;
/* Pointer to next older handler for this
* display, or NULL for end of list. */
@@ -628,7 +676,7 @@ typedef struct TkEventHandler {
unsigned long mask; /* Events for which to invoke proc. */
Tk_EventProc *proc; /* Function to invoke when an event in mask
* occurs. */
- ClientData clientData; /* Argument to pass to proc. */
+ void *clientData; /* Argument to pass to proc. */
struct TkEventHandler *nextPtr;
/* Next in list of handlers associated with
* window (NULL means end of list). */
@@ -641,7 +689,7 @@ typedef struct TkEventHandler {
*/
typedef struct TkMainInfo {
- int refCount; /* Number of windows whose "mainPtr" fields
+ Tcl_Size 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
@@ -652,7 +700,11 @@ typedef struct TkMainInfo {
Tcl_HashTable nameTable; /* Hash table mapping path names to TkWindow
* structs for all windows related to this
* main window. Managed by tkWindow.c. */
- long deletionEpoch; /* Incremented by window deletions. */
+#if TCL_MAJOR_VERSION > 8
+ size_t deletionEpoch; /* Incremented by window deletions. */
+#else
+ long deletionEpoch;
+#endif
Tk_BindingTable bindingTable;
/* Used in conjunction with "bind" command to
* bind events to Tcl commands. */
@@ -693,8 +745,16 @@ typedef struct TkMainInfo {
/* Saved Tcl [update] command, used to restore
* Tcl's version of [update] after Tk is shut
* down */
+#if TCL_MAJOR_VERSION > 8
+ Tcl_ObjCmdProc2 *tclUpdateObjProc2;
+ /* Saved Tcl [update] command, used to restore
+ * Tcl's version of [update] after Tk is shut
+ * down, in case it's a Tcl_ObjCmdProc2 */
+#endif
unsigned int ttkNbTabsStickBit;
/* Information used by ttk::notebook. */
+ int troughInnerX, troughInnerY, troughInnerWidth, troughInnerHeight;
+ /* Information used by ttk::scale. */
} TkMainInfo;
/*
@@ -795,7 +855,7 @@ typedef struct TkWindow {
TkEventHandler *handlerList;/* First in list of event handlers declared
* for this window, or NULL if none. */
-#ifdef TK_USE_INPUT_METHODS
+#if defined(TK_USE_INPUT_METHODS) || (TCL_MAJOR_VERSION > 8)
XIC inputContext; /* XIM input context. */
#endif /* TK_USE_INPUT_METHODS */
@@ -804,16 +864,16 @@ typedef struct TkWindow {
* in tkCmds.c):
*/
- ClientData *tagPtr; /* Points to array of tags used for bindings
+ void **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. */
+ Tcl_Size 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
+ Tcl_Size optionLevel; /* TCL_INDEX_NONE means no option information is currently
* cached for this window. Otherwise this
* gives the level in the option stack at
* which info is cached. */
@@ -832,7 +892,7 @@ typedef struct TkWindow {
const Tk_GeomMgr *geomMgrPtr;
/* Information about geometry manager for this
* window. */
- ClientData geomData; /* Argument for geometry manager functions. */
+ void *geomData; /* Argument for geometry manager functions. */
int reqWidth, reqHeight; /* Arguments from last call to
* Tk_GeometryRequest, or 0's if
* Tk_GeometryRequest hasn't been called. */
@@ -857,7 +917,7 @@ typedef struct TkWindow {
*/
const Tk_ClassProcs *classProcsPtr;
- ClientData instanceData;
+ void *instanceData;
/*
* Platform specific information private to each port.
@@ -876,7 +936,7 @@ typedef struct TkWindow {
int minReqWidth; /* Minimum requested width. */
int minReqHeight; /* Minimum requested height. */
-#ifdef TK_USE_INPUT_METHODS
+#if defined(TK_USE_INPUT_METHODS) || (TCL_MAJOR_VERSION > 8)
int ximGeneration; /* Used to invalidate XIC */
#endif /* TK_USE_INPUT_METHODS */
char *geomMgrName; /* Records the name of the geometry manager. */
@@ -884,6 +944,10 @@ typedef struct TkWindow {
/* The geometry container for this window. The
* value is NULL if the window has no container or
* if its container is its parent. */
+#if !defined(TK_USE_INPUT_METHODS) && (TCL_MAJOR_VERSION < 9)
+ XIC inputContext; /* XIM input context. */
+ int ximGeneration; /* Used to invalidate XIC */
+#endif /* TK_USE_INPUT_METHODS */
} TkWindow;
/*
@@ -892,6 +956,9 @@ typedef struct TkWindow {
MODULE_SCOPE const char *const tkStateStrings[];
MODULE_SCOPE const char *const tkCompoundStrings[];
+MODULE_SCOPE const char *const tkAnchorStrings[];
+MODULE_SCOPE const char *const tkReliefStrings[];
+MODULE_SCOPE const char *const tkJustifyStrings[];
/*
* Real definition of some events. Note that these events come from outside
@@ -901,8 +968,10 @@ MODULE_SCOPE const char *const tkCompoundStrings[];
typedef struct {
XKeyEvent keyEvent; /* The real event from X11. */
#ifdef _WIN32
- char trans_chars[XMaxTransChars];
- /* translated characters */
+# ifndef XMaxTransChars
+# define XMaxTransChars 7
+# endif
+ char trans_chars[XMaxTransChars]; /* translated characters */
unsigned char nbytes;
#elif !defined(MAC_OSX_TK)
char *charValuePtr; /* A pointer to a string that holds the key's
@@ -910,7 +979,7 @@ typedef struct {
* adding), or NULL if that has not been
* computed yet. If non-NULL, this string was
* allocated with ckalloc(). */
- int charValueLen; /* Length of string in charValuePtr when that
+ Tcl_Size charValueLen; /* Length of string in charValuePtr when that
* is non-NULL. */
KeySym keysym; /* Key symbol computed after input methods
* have been invoked */
@@ -925,14 +994,30 @@ typedef struct {
#define TK_MAKE_MENU_POPUP 1
#define TK_MAKE_MENU_DROPDOWN 2
+/* See TIP #494 */
+#ifndef TCL_IO_FAILURE
+# define TCL_IO_FAILURE (-1)
+#endif
+/* See TIP #537 */
+#ifndef TCL_INDEX_NONE
+# define TCL_INDEX_NONE (-1)
+#endif
+#ifndef TCL_INDEX_END
+# define TCL_INDEX_END ((Tcl_Size)-2)
+#endif
+
/*
* The following structure is used with TkMakeEnsemble to create ensemble
* commands and optionally to create sub-ensembles.
*/
+#if (TCL_MAJOR_VERSION < 9) && !defined(Tcl_ObjCmdProc2)
+#define Tcl_ObjCmdProc2 Tcl_ObjCmdProc
+#endif
+
typedef struct TkEnsemble {
const char *name;
- Tcl_ObjCmdProc *proc;
+ Tcl_ObjCmdProc2 *proc;
const struct TkEnsemble *subensemble;
} TkEnsemble;
@@ -956,7 +1041,7 @@ typedef struct TkpClipMask {
int type; /* TKP_CLIP_PIXMAP or TKP_CLIP_REGION. */
union {
Pixmap pixmap;
- TkRegion region;
+ Region region;
} value;
} TkpClipMask;
@@ -1006,28 +1091,64 @@ typedef struct TkpClipMask {
#define EXTENDED_MASK (AnyModifier<<3)
/*
+ * Buttons 8 and 9 are the Xbuttons (left and right side-buttons). On Windows/Mac, those
+ * are known as Buttons 4 and 5. At script level, they also get the numbers 4 and 5.
+ */
+
+#ifndef Button8
+# define Button8 8
+#endif
+#ifndef Button9
+# define Button9 9
+#endif
+
+#ifndef Button6Mask
+# define Button6Mask (1<<13)
+#endif
+#ifndef Button7Mask
+# define Button7Mask (1<<14)
+#endif
+#ifndef Button8Mask
+# define Button8Mask (AnyModifier<<4)
+#endif
+#ifndef Button9Mask
+# define Button9Mask (AnyModifier<<5)
+#endif
+
+/*
* Mask that selects any of the state bits corresponding to buttons, plus
* masks that select individual buttons' bits:
*/
#define ALL_BUTTONS \
- (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask)
+ (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask \
+ |Button6Mask|Button7Mask|Button8Mask|Button9Mask)
-MODULE_SCOPE unsigned TkGetButtonMask(unsigned);
-
/*
* Object types not declared in tkObj.c need to be mentioned here so they can
* be properly registered with Tcl:
*/
-MODULE_SCOPE const Tcl_ObjType tkBorderObjType;
-MODULE_SCOPE const Tcl_ObjType tkBitmapObjType;
-MODULE_SCOPE const Tcl_ObjType tkColorObjType;
-MODULE_SCOPE const Tcl_ObjType tkCursorObjType;
-MODULE_SCOPE const Tcl_ObjType tkFontObjType;
-MODULE_SCOPE const Tcl_ObjType tkStateKeyObjType;
-MODULE_SCOPE const Tcl_ObjType tkTextIndexType;
+typedef struct {
+ Tcl_ObjType objType;
+ size_t version;
+} TkObjType;
+
+#ifndef TCL_OBJTYPE_V0
+# define TCL_OBJTYPE_V0 /* just empty */
+#endif
+#ifndef TCL_OBJTYPE_V1
+# define TCL_OBJTYPE_V1(lengthProc) /* just empty */
+#endif
+
+MODULE_SCOPE const TkObjType tkBorderObjType;
+MODULE_SCOPE const TkObjType tkBitmapObjType;
+MODULE_SCOPE const TkObjType tkColorObjType;
+MODULE_SCOPE const TkObjType tkCursorObjType;
+MODULE_SCOPE const TkObjType tkFontObjType;
+MODULE_SCOPE const TkObjType tkStateKeyObjType;
+MODULE_SCOPE const TkObjType tkTextIndexType;
/*
* Miscellaneous variables shared among Tk modules but not exported to the
@@ -1036,10 +1157,12 @@ MODULE_SCOPE const Tcl_ObjType tkTextIndexType;
MODULE_SCOPE const Tk_SmoothMethod tkBezierSmoothMethod;
MODULE_SCOPE Tk_ImageType tkBitmapImageType;
-MODULE_SCOPE Tk_PhotoImageFormat tkImgFmtGIF;
+MODULE_SCOPE Tk_PhotoImageFormatVersion3 tkImgFmtGIF;
MODULE_SCOPE void (*tkHandleEventProc) (XEvent* eventPtr);
-MODULE_SCOPE Tk_PhotoImageFormat tkImgFmtPNG;
+MODULE_SCOPE Tk_PhotoImageFormat tkImgFmtDefault;
+MODULE_SCOPE Tk_PhotoImageFormatVersion3 tkImgFmtPNG;
MODULE_SCOPE Tk_PhotoImageFormat tkImgFmtPPM;
+MODULE_SCOPE Tk_PhotoImageFormat tkImgFmtSVGnano;
MODULE_SCOPE TkMainInfo *tkMainWindowList;
MODULE_SCOPE Tk_ImageType tkPhotoImageType;
MODULE_SCOPE Tcl_HashTable tkPredefBitmapTable;
@@ -1105,158 +1228,61 @@ MODULE_SCOPE void Ttk_TkDestroyedHandler(Tcl_Interp *interp);
* world:
*/
-MODULE_SCOPE int Tk_BellObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_BindObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_BindtagsObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_BusyObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_ButtonObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_CanvasObjCmd(ClientData clientData,
- Tcl_Interp *interp, int argc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_CheckbuttonObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_ClipboardObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_ChooseColorObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_ChooseDirectoryObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_DestroyObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_EntryObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_EventObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_FrameObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_FocusObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_FontObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_GetOpenFileObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_GetSaveFileObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_GrabObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_GridObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_ImageObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_LabelObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_LabelframeObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_ListboxObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_LowerObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_MenuObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_MenubuttonObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_MessageBoxObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_MessageObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_PanedWindowObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_OptionObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_PackObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_PlaceObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_RadiobuttonObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_RaiseObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_ScaleObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_ScrollbarObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_SelectionObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_SendObjCmd(ClientData clientData,
- Tcl_Interp *interp,int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_SpinboxObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_TextObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_TkwaitObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_ToplevelObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_UpdateObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_WinfoObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-MODULE_SCOPE int Tk_WmObjCmd(ClientData clientData, Tcl_Interp *interp,
- int objc, Tcl_Obj *const objv[]);
-
-MODULE_SCOPE int Tk_GetDoublePixelsFromObj(Tcl_Interp *interp,
- Tk_Window tkwin, Tcl_Obj *objPtr,
- double *doublePtr);
-#define TkSetGeometryContainer TkSetGeometryMaster
+MODULE_SCOPE Tcl_ObjCmdProc Tk_BellObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_BindObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_BindtagsObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc2 Tk_BusyObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_ButtonObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_CanvasObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_CheckbuttonObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_ClipboardObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_ChooseColorObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_ChooseDirectoryObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_DestroyObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_EntryObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_EventObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_FrameObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_FocusObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_FontObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_GetOpenFileObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_GetSaveFileObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_GrabObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_GridObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_ImageObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_LabelObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_LabelframeObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_ListboxObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_LowerObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_MenuObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_MenubuttonObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_MessageBoxObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_MessageObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_PanedWindowObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_OptionObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_PackObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_PlaceObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_RadiobuttonObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_RaiseObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_ScaleObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_ScrollbarObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_SelectionObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_SendObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_SpinboxObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_TextObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_TkwaitObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_ToplevelObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_UpdateObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_WinfoObjCmd;
+MODULE_SCOPE Tcl_ObjCmdProc Tk_WmObjCmd;
+
MODULE_SCOPE int TkSetGeometryContainer(Tcl_Interp *interp,
Tk_Window tkwin, const char *name);
-#define TkFreeGeometryContainer TkFreeGeometryMaster
MODULE_SCOPE void TkFreeGeometryContainer(Tk_Window tkwin,
const char *name);
MODULE_SCOPE void TkEventInit(void);
MODULE_SCOPE void TkRegisterObjTypes(void);
-MODULE_SCOPE int TkDeadAppObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]);
+MODULE_SCOPE Tcl_ObjCmdProc TkDeadAppObjCmd;
MODULE_SCOPE int TkCanvasGetCoordObj(Tcl_Interp *interp,
Tk_Canvas canvas, Tcl_Obj *obj,
double *doublePtr);
@@ -1270,10 +1296,10 @@ MODULE_SCOPE XEvent * TkpGetBindingXEvent(Tcl_Interp *interp);
MODULE_SCOPE void TkCreateExitHandler(Tcl_ExitProc *proc,
void *clientData);
MODULE_SCOPE void TkDeleteExitHandler(Tcl_ExitProc *proc,
- ClientData clientData);
+ void *clientData);
MODULE_SCOPE Tcl_ExitProc TkFinalize;
MODULE_SCOPE Tcl_ExitProc TkFinalizeThread;
-MODULE_SCOPE void TkpBuildRegionFromAlphaData(TkRegion region,
+MODULE_SCOPE void TkpBuildRegionFromAlphaData(Region region,
unsigned x, unsigned y, unsigned width,
unsigned height, unsigned char *dataPtr,
unsigned pixelStride, unsigned lineStride);
@@ -1284,49 +1310,65 @@ MODULE_SCOPE int TkParsePadAmount(Tcl_Interp *interp,
int *pad1Ptr, int *pad2Ptr);
MODULE_SCOPE void TkFocusSplit(TkWindow *winPtr);
MODULE_SCOPE void TkFocusJoin(TkWindow *winPtr);
-MODULE_SCOPE int TkpAlwaysShowSelection(Tk_Window tkwin);
MODULE_SCOPE void TkpDrawCharsInContext(Display * display,
Drawable drawable, GC gc, Tk_Font tkfont,
- const char *source, int numBytes, int rangeStart,
- int rangeLength, int x, int y);
+ const char *source, Tcl_Size numBytes, Tcl_Size rangeStart,
+ Tcl_Size rangeLength, int x, int y);
MODULE_SCOPE void TkpDrawAngledCharsInContext(Display * display,
Drawable drawable, GC gc, Tk_Font tkfont,
- const char *source, int numBytes, int rangeStart,
- int rangeLength, double x, double y, double angle);
+ const char *source, Tcl_Size numBytes, Tcl_Size rangeStart,
+ Tcl_Size rangeLength, double x, double y, double angle);
MODULE_SCOPE int TkpMeasureCharsInContext(Tk_Font tkfont,
- const char *source, int numBytes, int rangeStart,
- int rangeLength, int maxLength, int flags,
+ const char *source, Tcl_Size numBytes, Tcl_Size rangeStart,
+ Tcl_Size rangeLength, int maxLength, int flags,
int *lengthPtr);
MODULE_SCOPE void TkUnderlineCharsInContext(Display *display,
Drawable drawable, GC gc, Tk_Font tkfont,
- const char *string, int numBytes, int x, int y,
- int firstByte, int lastByte);
+ const char *string, Tcl_Size numBytes, int x, int y,
+ Tcl_Size firstByte, Tcl_Size lastByte);
MODULE_SCOPE void TkpGetFontAttrsForChar(Tk_Window tkwin, Tk_Font tkfont,
int c, struct TkFontAttributes *faPtr);
-MODULE_SCOPE Tcl_Obj * TkNewWindowObj(Tk_Window tkwin);
+MODULE_SCOPE void TkpDrawFrameEx(Tk_Window tkwin, Drawable drawable,
+ Tk_3DBorder border, int highlightWidth,
+ int borderWidth, int relief);
MODULE_SCOPE void TkpShowBusyWindow(TkBusy busy);
MODULE_SCOPE void TkpHideBusyWindow(TkBusy busy);
+MODULE_SCOPE Tcl_Size TkLengthOne(Tcl_Obj *);
MODULE_SCOPE void TkpMakeTransparentWindowExist(Tk_Window tkwin,
Window parent);
MODULE_SCOPE void TkpCreateBusy(Tk_FakeWin *winPtr, Tk_Window tkRef,
Window *parentPtr, Tk_Window tkParent,
TkBusy busy);
MODULE_SCOPE int TkBackgroundEvalObjv(Tcl_Interp *interp,
- int objc, Tcl_Obj *const *objv, int flags);
-MODULE_SCOPE void TkSendVirtualEvent(Tk_Window tgtWin,
- const char *eventName, Tcl_Obj *detail);
+ Tcl_Size objc, Tcl_Obj *const *objv, int flags);
MODULE_SCOPE Tcl_Command TkMakeEnsemble(Tcl_Interp *interp,
const char *nsname, const char *name,
- ClientData clientData, const TkEnsemble *map);
+ void *clientData, const TkEnsemble *map);
+MODULE_SCOPE double TkScalingLevel(Tk_Window tkwin);
MODULE_SCOPE int TkInitTkCmd(Tcl_Interp *interp,
- ClientData clientData);
+ void *clientData);
MODULE_SCOPE int TkInitFontchooser(Tcl_Interp *interp,
- ClientData clientData);
+ void *clientData);
+MODULE_SCOPE void TkInitEmbeddedConfigurationInformation(
+ Tcl_Interp *interp);
+MODULE_SCOPE void TkDoWarpWrtWin(TkDisplay *dispPtr);
MODULE_SCOPE void TkpWarpPointer(TkDisplay *dispPtr);
-MODULE_SCOPE void TkpCancelWarp(TkDisplay *dispPtr);
-MODULE_SCOPE int TkListCreateFrame(ClientData clientData,
+MODULE_SCOPE int TkListCreateFrame(void *clientData,
Tcl_Interp *interp, Tcl_Obj *listObj,
int toplevel, Tcl_Obj *nameObj);
+MODULE_SCOPE void TkRotatePoint(double originX, double originY,
+ double sine, double cosine, double *xPtr,
+ double *yPtr);
+MODULE_SCOPE int TkGetIntForIndex(Tcl_Obj *, Tcl_Size, int lastOK, Tcl_Size*);
+
+#if !defined(TK_NO_DEPRECATED) && (TCL_MAJOR_VERSION < 9)
+# define TkNewIndexObj(value) Tcl_NewWideIntObj((Tcl_WideInt)(value + 1) - 1)
+# define TK_OPTION_UNDERLINE_DEF(type, field) "-1", TCL_INDEX_NONE, offsetof(type, field), 0, NULL
+#else
+# define TkNewIndexObj(value) (((Tcl_Size)(value) == TCL_INDEX_NONE) ? Tcl_NewObj() : Tcl_NewWideIntObj((Tcl_WideInt)(value)))
+# define TK_OPTION_UNDERLINE_DEF(type, field) NULL, TCL_INDEX_NONE, offsetof(type, field), TK_OPTION_NULL_OK, NULL
+#endif
+
#ifdef _WIN32
#define TkParseColor XParseColor
@@ -1335,8 +1377,30 @@ MODULE_SCOPE Status TkParseColor (Display * display,
Colormap map, const char* spec,
XColor * colorPtr);
#endif
+#if !defined(_WIN32) && !defined(__CYGWIN__) /* UNIX and MacOSX */
+#undef TkPutImage
+#define TkPutImage(colors, ncolors, display, pixels, gc, image, srcx, srcy, destx, desty, width, height) \
+ XPutImage(display, pixels, gc, image, srcx, srcy, destx, desty, width, height);
+#else
+#undef XPutImage
+#define XPutImage(display, pixels, gc, image, srcx, srcy, destx, desty, width, height) \
+ TkPutImage(NULL, 0, display, pixels, gc, image, srcx, srcy, destx, desty, width, height);
+#endif
+
+/*
+ * These macros are just wrappers for the equivalent X Region calls.
+ */
+#define TkClipBox XClipBox
+#define TkCreateRegion XCreateRegion
+#define TkDestroyRegion XDestroyRegion
+#define TkIntersectRegion XIntersectRegion
+#define TkRectInRegion XRectInRegion
+#define TkSetRegion XSetRegion
+#define TkSubtractRegion XSubtractRegion
+#define TkUnionRectWithRegion XUnionRectWithRegion
+
#ifdef HAVE_XFT
-MODULE_SCOPE void TkUnixSetXftClipRegion(TkRegion clipRegion);
+MODULE_SCOPE void TkUnixSetXftClipRegion(Region clipRegion);
#endif
MODULE_SCOPE void TkpCopyRegion(TkRegion dst, TkRegion src);
@@ -1345,33 +1409,22 @@ MODULE_SCOPE void TkpCopyRegion(TkRegion dst, TkRegion src);
# define c_class class
#endif
-/* Tcl 8.6 has a different definition of Tcl_UniChar than other Tcl versions for TCL_UTF_MAX > 3 */
-#if TCL_UTF_MAX > (3 + (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 6))
-# define TkUtfToUniChar Tcl_UtfToUniChar
-# define TkUniCharToUtf Tcl_UniCharToUtf
-# define TkUtfPrev Tcl_UtfPrev
-# define TkUtfAtIndex Tcl_UtfAtIndex
-#else
- MODULE_SCOPE int TkUtfToUniChar(const char *, int *);
- MODULE_SCOPE int TkUniCharToUtf(int, char *);
- MODULE_SCOPE const char *TkUtfPrev(const char *, const char *);
- MODULE_SCOPE const char *TkUtfAtIndex(const char *src, int index);
+#if defined(_WIN32) && !defined(STATIC_BUILD) && TCL_MAJOR_VERSION < 9
+# define tcl_CreateFileHandler reserved9
#endif
+MODULE_SCOPE void Icu_Init(Tcl_Interp* interp);
+
/*
* Unsupported commands.
*/
-MODULE_SCOPE int TkUnsupported1ObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
+MODULE_SCOPE Tcl_ObjCmdProc TkUnsupported1ObjCmd;
/*
* For Tktest.
*/
-MODULE_SCOPE int SquareObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj * const objv[]);
+MODULE_SCOPE Tcl_ObjCmdProc SquareObjCmd;
MODULE_SCOPE int TkOldTestInit(Tcl_Interp *interp);
#if !(defined(_WIN32) || defined(MAC_OSX_TK))
#define TkplatformtestInit(x) TCL_OK
diff --git a/generic/tkIntDecls.h b/generic/tkIntDecls.h
index 60aec8e..d71885b 100644
--- a/generic/tkIntDecls.h
+++ b/generic/tkIntDecls.h
@@ -6,7 +6,7 @@
* interfaces are not guaranteed to remain the same between
* versions. Use at your own risk.
*
- * Copyright (c) 1998-1999 Scriptics Corporation.
+ * Copyright © 1998-1999 Scriptics Corporation.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -15,6 +15,8 @@
#ifndef _TKINTDECLS
#define _TKINTDECLS
+#include "X11/Xutil.h"
+
#ifdef BUILD_tk
#undef TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS DLLEXPORT
@@ -77,10 +79,9 @@ EXTERN TkCursor * TkCreateCursorFromData(Tk_Window tkwin,
int width, int height, int xHot, int yHot,
XColor fg, XColor bg);
/* 13 */
-EXTERN int TkCreateFrame(ClientData clientData,
- Tcl_Interp *interp, int argc,
- const char *const *argv, int toplevel,
- const char *appName);
+EXTERN int TkCreateFrame(void *clientData, Tcl_Interp *interp,
+ Tcl_Size argc, const char *const *argv,
+ int toplevel, const char *appName);
/* 14 */
EXTERN Tk_Window TkCreateMainWindow(Tcl_Interp *interp,
const char *screenName, const char *baseName);
@@ -104,7 +105,7 @@ EXTERN int TkFindStateNum(Tcl_Interp *interp,
const char *option, const TkStateMap *mapPtr,
const char *strKey);
/* 22 */
-EXTERN CONST86 char * TkFindStateString(const TkStateMap *mapPtr,
+EXTERN const char * TkFindStateString(const TkStateMap *mapPtr,
int numKey);
/* 23 */
EXTERN void TkFocusDeadWindow(TkWindow *winPtr);
@@ -139,7 +140,7 @@ EXTERN const char * TkGetDefaultScreenName(Tcl_Interp *interp,
/* 34 */
EXTERN TkDisplay * TkGetDisplay(Display *display);
/* 35 */
-EXTERN int TkGetDisplayOf(Tcl_Interp *interp, int objc,
+EXTERN Tcl_Size TkGetDisplayOf(Tcl_Interp *interp, Tcl_Size objc,
Tcl_Obj *const objv[], Tk_Window *tkwinPtr);
/* 36 */
EXTERN TkWindow * TkGetFocusWin(TkWindow *winPtr);
@@ -167,7 +168,7 @@ EXTERN void TkInOutEvents(XEvent *eventPtr, TkWindow *sourcePtr,
/* 45 */
EXTERN void TkInstallFrameMenu(Tk_Window tkwin);
/* 46 */
-EXTERN CONST86 char * TkKeysymToString(KeySym keysym);
+EXTERN const char * TkKeysymToString(KeySym keysym);
/* 47 */
EXTERN int TkLineToArea(double end1Ptr[], double end2Ptr[],
double rectPtr[]);
@@ -202,7 +203,8 @@ EXTERN void TkpDisplayWarning(const char *msg, const char *title);
/* 59 */
EXTERN void TkpGetAppName(Tcl_Interp *interp, Tcl_DString *name);
/* 60 */
-EXTERN TkWindow * TkpGetOtherWindow(TkWindow *winPtr);
+TK_DEPRECATED("renamed to Tk_GetOtherWindow")
+TkWindow * TkpGetOtherWindow(TkWindow *winPtr);
/* 61 */
EXTERN TkWindow * TkpGetWrapperWindow(TkWindow *winPtr);
/* 62 */
@@ -211,11 +213,13 @@ EXTERN int TkpInit(Tcl_Interp *interp);
EXTERN void TkpInitializeMenuBindings(Tcl_Interp *interp,
Tk_BindingTable bindingTable);
/* 64 */
-EXTERN void TkpMakeContainer(Tk_Window tkwin);
+TK_DEPRECATED("renamed to Tk_MakeContainer")
+void TkpMakeContainer(Tk_Window tkwin);
/* 65 */
EXTERN void TkpMakeMenuWindow(Tk_Window tkwin, int transient);
/* 66 */
-EXTERN Window TkpMakeWindow(TkWindow *winPtr, Window parent);
+TK_DEPRECATED("renamed to Tk_MakeWindow")
+Window TkpMakeWindow(TkWindow *winPtr, Window parent);
/* 67 */
EXTERN void TkpMenuNotifyToplevelCreate(Tcl_Interp *interp,
const char *menuName);
@@ -235,10 +239,12 @@ EXTERN int TkPositionInTree(TkWindow *winPtr, TkWindow *treePtr);
EXTERN void TkpRedirectKeyEvent(TkWindow *winPtr,
XEvent *eventPtr);
/* 74 */
-EXTERN void TkpSetMainMenubar(Tcl_Interp *interp,
+TK_DEPRECATED("renamed to Tk_SetMainMenubar")
+void TkpSetMainMenubar(Tcl_Interp *interp,
Tk_Window tkwin, const char *menuName);
/* 75 */
-EXTERN int TkpUseWindow(Tcl_Interp *interp, Tk_Window tkwin,
+TK_DEPRECATED("renamed to Tk_UseWindow")
+int TkpUseWindow(Tcl_Interp *interp, Tk_Window tkwin,
const char *string);
/* Slot 76 is reserved */
/* 77 */
@@ -254,7 +260,7 @@ EXTERN int TkReadBitmapFile(Display *display, Drawable d,
/* 79 */
EXTERN int TkScrollWindow(Tk_Window tkwin, GC gc, int x, int y,
int width, int height, int dx, int dy,
- TkRegion damageRgn);
+ Region damageRgn);
/* 80 */
EXTERN void TkSelDeadWindow(TkWindow *winPtr);
/* 81 */
@@ -265,7 +271,8 @@ EXTERN void TkSelInit(Tk_Window tkwin);
EXTERN void TkSelPropProc(XEvent *eventPtr);
/* Slot 84 is reserved */
/* 85 */
-EXTERN void TkSetWindowMenuBar(Tcl_Interp *interp,
+TK_DEPRECATED("renamed to Tk_SetWindowMenubar")
+void TkSetWindowMenuBar(Tcl_Interp *interp,
Tk_Window tkwin, const char *oldMenuName,
const char *menuName);
/* 86 */
@@ -324,32 +331,33 @@ EXTERN int TkGetWindowFromObj(Tcl_Interp *interp,
Tk_Window tkwin, Tcl_Obj *objPtr,
Tk_Window *windowPtr);
/* 109 */
-EXTERN CONST86 char * TkpGetString(TkWindow *winPtr, XEvent *eventPtr,
+EXTERN const char * TkpGetString(TkWindow *winPtr, XEvent *eventPtr,
Tcl_DString *dsPtr);
/* 110 */
EXTERN void TkpGetSubFonts(Tcl_Interp *interp, Tk_Font tkfont);
/* 111 */
-EXTERN Tcl_Obj * TkpGetSystemDefault(Tk_Window tkwin,
+TK_DEPRECATED("renamed to Tk_GetSystemDefault")
+Tcl_Obj * TkpGetSystemDefault(Tk_Window tkwin,
const char *dbName, const char *className);
/* 112 */
EXTERN void TkpMenuThreadInit(void);
/* 113 */
-EXTERN int TkClipBox(TkRegion rgn, XRectangle *rect_return);
+EXTERN int XClipBox(Region rgn, XRectangle *rect_return);
/* 114 */
-EXTERN TkRegion TkCreateRegion(void);
+EXTERN Region XCreateRegion(void);
/* 115 */
-EXTERN int TkDestroyRegion(TkRegion rgn);
+EXTERN int XDestroyRegion(Region rgn);
/* 116 */
-EXTERN int TkIntersectRegion(TkRegion sra, TkRegion srcb,
- TkRegion dr_return);
+EXTERN int XIntersectRegion(Region sra, Region srcb,
+ Region dr_return);
/* 117 */
-EXTERN int TkRectInRegion(TkRegion rgn, int x, int y,
+EXTERN int XRectInRegion(Region rgn, int x, int y,
unsigned int width, unsigned int height);
/* 118 */
-EXTERN int TkSetRegion(Display *display, GC gc, TkRegion rgn);
+EXTERN int XSetRegion(Display *display, GC gc, Region rgn);
/* 119 */
-EXTERN int TkUnionRectWithRegion(XRectangle *rect, TkRegion src,
- TkRegion dr_return);
+EXTERN int XUnionRectWithRegion(XRectangle *rect, Region src,
+ Region dr_return);
/* Slot 120 is reserved */
#ifdef MAC_OSX_TK /* AQUA */
/* 121 */
@@ -377,7 +385,8 @@ EXTERN Pixmap TkpGetNativeAppBitmap(Display *display,
/* Slot 133 is reserved */
/* Slot 134 is reserved */
/* 135 */
-EXTERN void TkpDrawHighlightBorder(Tk_Window tkwin, GC fgGC,
+TK_DEPRECATED("renamed to Tk_DrawHighlightBorder")
+void TkpDrawHighlightBorder(Tk_Window tkwin, GC fgGC,
GC bgGC, int highlightWidth,
Drawable drawable);
/* 136 */
@@ -390,7 +399,7 @@ EXTERN KeySym TkpGetKeySym(TkDisplay *dispPtr, XEvent *eventPtr);
/* 139 */
EXTERN void TkpInitKeymapInfo(TkDisplay *dispPtr);
/* 140 */
-EXTERN TkRegion TkPhotoGetValidRegion(Tk_PhotoHandle handle);
+EXTERN Region TkPhotoGetValidRegion(Tk_PhotoHandle handle);
/* 141 */
EXTERN TkWindow ** TkWmStackorderToplevel(TkWindow *parentPtr);
/* 142 */
@@ -400,8 +409,8 @@ EXTERN void TkClipCleanup(TkDisplay *dispPtr);
/* 144 */
EXTERN void TkGCCleanup(TkDisplay *dispPtr);
/* 145 */
-EXTERN int TkSubtractRegion(TkRegion sra, TkRegion srcb,
- TkRegion dr_return);
+EXTERN int XSubtractRegion(Region sra, Region srcb,
+ Region dr_return);
/* 146 */
EXTERN void TkStylePkgInit(TkMainInfo *mainPtr);
/* 147 */
@@ -426,40 +435,40 @@ EXTERN void TkpDrawFrame(Tk_Window tkwin, Tk_3DBorder border,
int relief);
/* 153 */
EXTERN void TkCreateThreadExitHandler(Tcl_ExitProc *proc,
- ClientData clientData);
+ void *clientData);
/* 154 */
EXTERN void TkDeleteThreadExitHandler(Tcl_ExitProc *proc,
- ClientData clientData);
+ void *clientData);
/* Slot 155 is reserved */
/* 156 */
-EXTERN int TkpTestembedCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
+EXTERN int TkpTestembedCmd(void *clientData, Tcl_Interp *interp,
+ Tcl_Size objc, Tcl_Obj *const objv[]);
/* 157 */
-EXTERN int TkpTesttextCmd(ClientData dummy, Tcl_Interp *interp,
- int objc, Tcl_Obj *const objv[]);
+EXTERN int TkpTesttextCmd(void *dummy, Tcl_Interp *interp,
+ Tcl_Size objc, Tcl_Obj *const objv[]);
/* 158 */
EXTERN int TkSelGetSelection(Tcl_Interp *interp,
Tk_Window tkwin, Atom selection, Atom target,
- Tk_GetSelProc *proc, ClientData clientData);
+ Tk_GetSelProc *proc, void *clientData);
/* 159 */
EXTERN int TkTextGetIndex(Tcl_Interp *interp,
struct TkText *textPtr, const char *string,
struct TkTextIndex *indexPtr);
/* 160 */
EXTERN int TkTextIndexBackBytes(const struct TkText *textPtr,
- const struct TkTextIndex *srcPtr, int count,
- struct TkTextIndex *dstPtr);
+ const struct TkTextIndex *srcPtr,
+ Tcl_Size count, struct TkTextIndex *dstPtr);
/* 161 */
EXTERN int TkTextIndexForwBytes(const struct TkText *textPtr,
- const struct TkTextIndex *srcPtr, int count,
- struct TkTextIndex *dstPtr);
+ const struct TkTextIndex *srcPtr,
+ Tcl_Size count, struct TkTextIndex *dstPtr);
/* 162 */
EXTERN struct TkTextIndex * TkTextMakeByteIndex(TkTextBTree tree,
const struct TkText *textPtr, int lineIndex,
- int byteIndex, struct TkTextIndex *indexPtr);
+ Tcl_Size byteIndex,
+ struct TkTextIndex *indexPtr);
/* 163 */
-EXTERN int TkTextPrintIndex(const struct TkText *textPtr,
+EXTERN Tcl_Size TkTextPrintIndex(const struct TkText *textPtr,
const struct TkTextIndex *indexPtr,
char *string);
/* 164 */
@@ -468,7 +477,7 @@ EXTERN struct TkTextSegment * TkTextSetMark(struct TkText *textPtr,
struct TkTextIndex *indexPtr);
/* 165 */
EXTERN int TkTextXviewCmd(struct TkText *textPtr,
- Tcl_Interp *interp, int objc,
+ Tcl_Interp *interp, Tcl_Size objc,
Tcl_Obj *const objv[]);
/* 166 */
EXTERN void TkTextChanged(struct TkSharedText *sharedTextPtr,
@@ -484,58 +493,65 @@ EXTERN void TkTextInsertDisplayProc(struct TkText *textPtr,
int y, int height, int baseline,
Display *display, Drawable dst, int screenY);
/* 169 */
-EXTERN int TkStateParseProc(ClientData clientData,
+EXTERN int TkStateParseProc(void *clientData,
Tcl_Interp *interp, Tk_Window tkwin,
- const char *value, char *widgRec, int offset);
+ const char *value, char *widgRec,
+ Tcl_Size offset);
/* 170 */
-EXTERN CONST86 char * TkStatePrintProc(ClientData clientData,
- Tk_Window tkwin, char *widgRec, int offset,
+EXTERN const char * TkStatePrintProc(void *clientData, Tk_Window tkwin,
+ char *widgRec, Tcl_Size offset,
Tcl_FreeProc **freeProcPtr);
/* 171 */
-EXTERN int TkCanvasDashParseProc(ClientData clientData,
+EXTERN int TkCanvasDashParseProc(void *clientData,
Tcl_Interp *interp, Tk_Window tkwin,
- const char *value, char *widgRec, int offset);
+ const char *value, char *widgRec,
+ Tcl_Size offset);
/* 172 */
-EXTERN CONST86 char * TkCanvasDashPrintProc(ClientData clientData,
- Tk_Window tkwin, char *widgRec, int offset,
- Tcl_FreeProc **freeProcPtr);
+EXTERN const char * TkCanvasDashPrintProc(void *clientData,
+ Tk_Window tkwin, char *widgRec,
+ Tcl_Size offset, Tcl_FreeProc **freeProcPtr);
/* 173 */
-EXTERN int TkOffsetParseProc(ClientData clientData,
+EXTERN int TkOffsetParseProc(void *clientData,
Tcl_Interp *interp, Tk_Window tkwin,
- const char *value, char *widgRec, int offset);
+ const char *value, char *widgRec,
+ Tcl_Size offset);
/* 174 */
-EXTERN CONST86 char * TkOffsetPrintProc(ClientData clientData,
- Tk_Window tkwin, char *widgRec, int offset,
+EXTERN const char * TkOffsetPrintProc(void *clientData, Tk_Window tkwin,
+ char *widgRec, Tcl_Size offset,
Tcl_FreeProc **freeProcPtr);
/* 175 */
-EXTERN int TkPixelParseProc(ClientData clientData,
+EXTERN int TkPixelParseProc(void *clientData,
Tcl_Interp *interp, Tk_Window tkwin,
- const char *value, char *widgRec, int offset);
+ const char *value, char *widgRec,
+ Tcl_Size offset);
/* 176 */
-EXTERN CONST86 char * TkPixelPrintProc(ClientData clientData,
- Tk_Window tkwin, char *widgRec, int offset,
+EXTERN const char * TkPixelPrintProc(void *clientData, Tk_Window tkwin,
+ char *widgRec, Tcl_Size offset,
Tcl_FreeProc **freeProcPtr);
/* 177 */
-EXTERN int TkOrientParseProc(ClientData clientData,
+EXTERN int TkOrientParseProc(void *clientData,
Tcl_Interp *interp, Tk_Window tkwin,
- const char *value, char *widgRec, int offset);
+ const char *value, char *widgRec,
+ Tcl_Size offset);
/* 178 */
-EXTERN CONST86 char * TkOrientPrintProc(ClientData clientData,
- Tk_Window tkwin, char *widgRec, int offset,
+EXTERN const char * TkOrientPrintProc(void *clientData, Tk_Window tkwin,
+ char *widgRec, Tcl_Size offset,
Tcl_FreeProc **freeProcPtr);
/* 179 */
-EXTERN int TkSmoothParseProc(ClientData clientData,
+EXTERN int TkSmoothParseProc(void *clientData,
Tcl_Interp *interp, Tk_Window tkwin,
- const char *value, char *widgRec, int offset);
+ const char *value, char *widgRec,
+ Tcl_Size offset);
/* 180 */
-EXTERN CONST86 char * TkSmoothPrintProc(ClientData clientData,
- Tk_Window tkwin, char *widgRec, int offset,
+EXTERN const char * TkSmoothPrintProc(void *clientData, Tk_Window tkwin,
+ char *widgRec, Tcl_Size offset,
Tcl_FreeProc **freeProcPtr);
/* 181 */
EXTERN void TkDrawAngledTextLayout(Display *display,
Drawable drawable, GC gc,
Tk_TextLayout layout, int x, int y,
- double angle, int firstChar, int lastChar);
+ double angle, Tcl_Size firstChar,
+ Tcl_Size lastChar);
/* 182 */
EXTERN void TkUnderlineAngledTextLayout(Display *display,
Drawable drawable, GC gc,
@@ -548,18 +564,16 @@ EXTERN int TkIntersectAngledTextLayout(Tk_TextLayout layout,
/* 184 */
EXTERN void TkDrawAngledChars(Display *display,
Drawable drawable, GC gc, Tk_Font tkfont,
- const char *source, int numBytes, double x,
- double y, double angle);
-#ifdef MAC_OSX_TCL /* MACOSX */
+ const char *source, Tcl_Size numBytes,
+ double x, double y, double angle);
/* 185 */
EXTERN void TkpRedrawWidget(Tk_Window tkwin);
-#endif /* MACOSX */
-#ifdef MAC_OSX_TCL /* MACOSX */
/* 186 */
EXTERN int TkpWillDrawWidget(Tk_Window tkwin);
-#endif /* MACOSX */
/* 187 */
-EXTERN void TkUnusedStubEntry(void);
+EXTERN int TkDebugPhotoStringMatchDef(Tcl_Interp *inter,
+ Tcl_Obj *data, Tcl_Obj *formatString,
+ int *widthPtr, int *heightPtr);
typedef struct TkIntStubs {
int magic;
@@ -578,7 +592,7 @@ typedef struct TkIntStubs {
void (*reserved10)(void);
void (*reserved11)(void);
TkCursor * (*tkCreateCursorFromData) (Tk_Window tkwin, const char *source, const char *mask, int width, int height, int xHot, int yHot, XColor fg, XColor bg); /* 12 */
- int (*tkCreateFrame) (ClientData clientData, Tcl_Interp *interp, int argc, const char *const *argv, int toplevel, const char *appName); /* 13 */
+ int (*tkCreateFrame) (void *clientData, Tcl_Interp *interp, Tcl_Size argc, const char *const *argv, int toplevel, const char *appName); /* 13 */
Tk_Window (*tkCreateMainWindow) (Tcl_Interp *interp, const char *screenName, const char *baseName); /* 14 */
Time (*tkCurrentTime) (TkDisplay *dispPtr); /* 15 */
void (*tkDeleteAllImages) (TkMainInfo *mainPtr); /* 16 */
@@ -587,7 +601,7 @@ typedef struct TkIntStubs {
void (*tkEventDeadWindow) (TkWindow *winPtr); /* 19 */
void (*tkFillPolygon) (Tk_Canvas canvas, double *coordPtr, int numPoints, Display *display, Drawable drawable, GC gc, GC outlineGC); /* 20 */
int (*tkFindStateNum) (Tcl_Interp *interp, const char *option, const TkStateMap *mapPtr, const char *strKey); /* 21 */
- CONST86 char * (*tkFindStateString) (const TkStateMap *mapPtr, int numKey); /* 22 */
+ const char * (*tkFindStateString) (const TkStateMap *mapPtr, int numKey); /* 22 */
void (*tkFocusDeadWindow) (TkWindow *winPtr); /* 23 */
int (*tkFocusFilterEvent) (TkWindow *winPtr, XEvent *eventPtr); /* 24 */
TkWindow * (*tkFocusKeyEvent) (TkWindow *winPtr, XEvent *eventPtr); /* 25 */
@@ -600,7 +614,7 @@ typedef struct TkIntStubs {
TkCursor * (*tkGetCursorByName) (Tcl_Interp *interp, Tk_Window tkwin, Tk_Uid string); /* 32 */
const char * (*tkGetDefaultScreenName) (Tcl_Interp *interp, const char *screenName); /* 33 */
TkDisplay * (*tkGetDisplay) (Display *display); /* 34 */
- int (*tkGetDisplayOf) (Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], Tk_Window *tkwinPtr); /* 35 */
+ Tcl_Size (*tkGetDisplayOf) (Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[], Tk_Window *tkwinPtr); /* 35 */
TkWindow * (*tkGetFocusWin) (TkWindow *winPtr); /* 36 */
int (*tkGetInterpNames) (Tcl_Interp *interp, Tk_Window tkwin); /* 37 */
int (*tkGetMiterPoints) (double p1[], double p2[], double p3[], double width, double m1[], double m2[]); /* 38 */
@@ -611,7 +625,7 @@ typedef struct TkIntStubs {
void (*tkIncludePoint) (Tk_Item *itemPtr, double *pointPtr); /* 43 */
void (*tkInOutEvents) (XEvent *eventPtr, TkWindow *sourcePtr, TkWindow *destPtr, int leaveType, int enterType, Tcl_QueuePosition position); /* 44 */
void (*tkInstallFrameMenu) (Tk_Window tkwin); /* 45 */
- CONST86 char * (*tkKeysymToString) (KeySym keysym); /* 46 */
+ const char * (*tkKeysymToString) (KeySym keysym); /* 46 */
int (*tkLineToArea) (double end1Ptr[], double end2Ptr[], double rectPtr[]); /* 47 */
double (*tkLineToPoint) (double end1Ptr[], double end2Ptr[], double pointPtr[]); /* 48 */
int (*tkMakeBezierCurve) (Tk_Canvas canvas, double *pointPtr, int numPoints, int numSteps, XPoint xPoints[], double dblPoints[]); /* 49 */
@@ -625,13 +639,13 @@ typedef struct TkIntStubs {
void (*tkpClaimFocus) (TkWindow *topLevelPtr, int force); /* 57 */
void (*tkpDisplayWarning) (const char *msg, const char *title); /* 58 */
void (*tkpGetAppName) (Tcl_Interp *interp, Tcl_DString *name); /* 59 */
- TkWindow * (*tkpGetOtherWindow) (TkWindow *winPtr); /* 60 */
+ TCL_DEPRECATED_API("renamed to Tk_GetOtherWindow") TkWindow * (*tkpGetOtherWindow) (TkWindow *winPtr); /* 60 */
TkWindow * (*tkpGetWrapperWindow) (TkWindow *winPtr); /* 61 */
int (*tkpInit) (Tcl_Interp *interp); /* 62 */
void (*tkpInitializeMenuBindings) (Tcl_Interp *interp, Tk_BindingTable bindingTable); /* 63 */
- void (*tkpMakeContainer) (Tk_Window tkwin); /* 64 */
+ TCL_DEPRECATED_API("renamed to Tk_MakeContainer") void (*tkpMakeContainer) (Tk_Window tkwin); /* 64 */
void (*tkpMakeMenuWindow) (Tk_Window tkwin, int transient); /* 65 */
- Window (*tkpMakeWindow) (TkWindow *winPtr, Window parent); /* 66 */
+ TCL_DEPRECATED_API("renamed to Tk_MakeWindow") Window (*tkpMakeWindow) (TkWindow *winPtr, Window parent); /* 66 */
void (*tkpMenuNotifyToplevelCreate) (Tcl_Interp *interp, const char *menuName); /* 67 */
TkDisplay * (*tkpOpenDisplay) (const char *display_name); /* 68 */
int (*tkPointerEvent) (XEvent *eventPtr, TkWindow *winPtr); /* 69 */
@@ -639,18 +653,18 @@ typedef struct TkIntStubs {
double (*tkPolygonToPoint) (double *polyPtr, int numPoints, double *pointPtr); /* 71 */
int (*tkPositionInTree) (TkWindow *winPtr, TkWindow *treePtr); /* 72 */
void (*tkpRedirectKeyEvent) (TkWindow *winPtr, XEvent *eventPtr); /* 73 */
- void (*tkpSetMainMenubar) (Tcl_Interp *interp, Tk_Window tkwin, const char *menuName); /* 74 */
- int (*tkpUseWindow) (Tcl_Interp *interp, Tk_Window tkwin, const char *string); /* 75 */
+ TCL_DEPRECATED_API("renamed to Tk_SetMainMenubar") void (*tkpSetMainMenubar) (Tcl_Interp *interp, Tk_Window tkwin, const char *menuName); /* 74 */
+ TCL_DEPRECATED_API("renamed to Tk_UseWindow") int (*tkpUseWindow) (Tcl_Interp *interp, Tk_Window tkwin, const char *string); /* 75 */
void (*reserved76)(void);
void (*tkQueueEventForAllChildren) (TkWindow *winPtr, XEvent *eventPtr); /* 77 */
int (*tkReadBitmapFile) (Display *display, Drawable d, const char *filename, unsigned int *width_return, unsigned int *height_return, Pixmap *bitmap_return, int *x_hot_return, int *y_hot_return); /* 78 */
- int (*tkScrollWindow) (Tk_Window tkwin, GC gc, int x, int y, int width, int height, int dx, int dy, TkRegion damageRgn); /* 79 */
+ int (*tkScrollWindow) (Tk_Window tkwin, GC gc, int x, int y, int width, int height, int dx, int dy, Region damageRgn); /* 79 */
void (*tkSelDeadWindow) (TkWindow *winPtr); /* 80 */
void (*tkSelEventProc) (Tk_Window tkwin, XEvent *eventPtr); /* 81 */
void (*tkSelInit) (Tk_Window tkwin); /* 82 */
void (*tkSelPropProc) (XEvent *eventPtr); /* 83 */
void (*reserved84)(void);
- void (*tkSetWindowMenuBar) (Tcl_Interp *interp, Tk_Window tkwin, const char *oldMenuName, const char *menuName); /* 85 */
+ TCL_DEPRECATED_API("renamed to Tk_SetWindowMenubar") void (*tkSetWindowMenuBar) (Tcl_Interp *interp, Tk_Window tkwin, const char *oldMenuName, const char *menuName); /* 85 */
KeySym (*tkStringToKeysym) (const char *name); /* 86 */
int (*tkThickPolyLineToArea) (double *coordPtr, int numPoints, double width, int capStyle, int joinStyle, double *rectPtr); /* 87 */
void (*tkWmAddToColormapWindows) (TkWindow *winPtr); /* 88 */
@@ -674,17 +688,17 @@ typedef struct TkIntStubs {
TkDisplay * (*tkGetDisplayList) (void); /* 106 */
TkMainInfo * (*tkGetMainInfoList) (void); /* 107 */
int (*tkGetWindowFromObj) (Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr, Tk_Window *windowPtr); /* 108 */
- CONST86 char * (*tkpGetString) (TkWindow *winPtr, XEvent *eventPtr, Tcl_DString *dsPtr); /* 109 */
+ const char * (*tkpGetString) (TkWindow *winPtr, XEvent *eventPtr, Tcl_DString *dsPtr); /* 109 */
void (*tkpGetSubFonts) (Tcl_Interp *interp, Tk_Font tkfont); /* 110 */
- Tcl_Obj * (*tkpGetSystemDefault) (Tk_Window tkwin, const char *dbName, const char *className); /* 111 */
+ TCL_DEPRECATED_API("renamed to Tk_GetSystemDefault") Tcl_Obj * (*tkpGetSystemDefault) (Tk_Window tkwin, const char *dbName, const char *className); /* 111 */
void (*tkpMenuThreadInit) (void); /* 112 */
- int (*tkClipBox) (TkRegion rgn, XRectangle *rect_return); /* 113 */
- TkRegion (*tkCreateRegion) (void); /* 114 */
- int (*tkDestroyRegion) (TkRegion rgn); /* 115 */
- int (*tkIntersectRegion) (TkRegion sra, TkRegion srcb, TkRegion dr_return); /* 116 */
- int (*tkRectInRegion) (TkRegion rgn, int x, int y, unsigned int width, unsigned int height); /* 117 */
- int (*tkSetRegion) (Display *display, GC gc, TkRegion rgn); /* 118 */
- int (*tkUnionRectWithRegion) (XRectangle *rect, TkRegion src, TkRegion dr_return); /* 119 */
+ int (*xClipBox) (Region rgn, XRectangle *rect_return); /* 113 */
+ Region (*xCreateRegion) (void); /* 114 */
+ int (*xDestroyRegion) (Region rgn); /* 115 */
+ int (*xIntersectRegion) (Region sra, Region srcb, Region dr_return); /* 116 */
+ int (*xRectInRegion) (Region rgn, int x, int y, unsigned int width, unsigned int height); /* 117 */
+ int (*xSetRegion) (Display *display, GC gc, Region rgn); /* 118 */
+ int (*xUnionRectWithRegion) (XRectangle *rect, Region src, Region dr_return); /* 119 */
void (*reserved120)(void);
#if !(defined(_WIN32) || defined(MAC_OSX_TK)) /* X11 */
void (*reserved121)(void);
@@ -733,17 +747,17 @@ typedef struct TkIntStubs {
void (*reserved132)(void);
void (*reserved133)(void);
void (*reserved134)(void);
- void (*tkpDrawHighlightBorder) (Tk_Window tkwin, GC fgGC, GC bgGC, int highlightWidth, Drawable drawable); /* 135 */
+ TCL_DEPRECATED_API("renamed to Tk_DrawHighlightBorder") void (*tkpDrawHighlightBorder) (Tk_Window tkwin, GC fgGC, GC bgGC, int highlightWidth, Drawable drawable); /* 135 */
void (*tkSetFocusWin) (TkWindow *winPtr, int force); /* 136 */
void (*tkpSetKeycodeAndState) (Tk_Window tkwin, KeySym keySym, XEvent *eventPtr); /* 137 */
KeySym (*tkpGetKeySym) (TkDisplay *dispPtr, XEvent *eventPtr); /* 138 */
void (*tkpInitKeymapInfo) (TkDisplay *dispPtr); /* 139 */
- TkRegion (*tkPhotoGetValidRegion) (Tk_PhotoHandle handle); /* 140 */
+ Region (*tkPhotoGetValidRegion) (Tk_PhotoHandle handle); /* 140 */
TkWindow ** (*tkWmStackorderToplevel) (TkWindow *parentPtr); /* 141 */
void (*tkFocusFree) (TkMainInfo *mainPtr); /* 142 */
void (*tkClipCleanup) (TkDisplay *dispPtr); /* 143 */
void (*tkGCCleanup) (TkDisplay *dispPtr); /* 144 */
- int (*tkSubtractRegion) (TkRegion sra, TkRegion srcb, TkRegion dr_return); /* 145 */
+ int (*xSubtractRegion) (Region sra, Region srcb, Region dr_return); /* 145 */
void (*tkStylePkgInit) (TkMainInfo *mainPtr); /* 146 */
void (*tkStylePkgFree) (TkMainInfo *mainPtr); /* 147 */
Tk_Window (*tkToplevelWindowForCommand) (Tcl_Interp *interp, const char *cmdName); /* 148 */
@@ -751,57 +765,41 @@ typedef struct TkIntStubs {
int (*tkMakeRawCurve) (Tk_Canvas canvas, double *pointPtr, int numPoints, int numSteps, XPoint xPoints[], double dblPoints[]); /* 150 */
void (*tkMakeRawCurvePostscript) (Tcl_Interp *interp, Tk_Canvas canvas, double *pointPtr, int numPoints); /* 151 */
void (*tkpDrawFrame) (Tk_Window tkwin, Tk_3DBorder border, int highlightWidth, int borderWidth, int relief); /* 152 */
- void (*tkCreateThreadExitHandler) (Tcl_ExitProc *proc, ClientData clientData); /* 153 */
- void (*tkDeleteThreadExitHandler) (Tcl_ExitProc *proc, ClientData clientData); /* 154 */
+ void (*tkCreateThreadExitHandler) (Tcl_ExitProc *proc, void *clientData); /* 153 */
+ void (*tkDeleteThreadExitHandler) (Tcl_ExitProc *proc, void *clientData); /* 154 */
void (*reserved155)(void);
- int (*tkpTestembedCmd) (ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); /* 156 */
- int (*tkpTesttextCmd) (ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); /* 157 */
- int (*tkSelGetSelection) (Tcl_Interp *interp, Tk_Window tkwin, Atom selection, Atom target, Tk_GetSelProc *proc, ClientData clientData); /* 158 */
+ int (*tkpTestembedCmd) (void *clientData, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[]); /* 156 */
+ int (*tkpTesttextCmd) (void *dummy, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[]); /* 157 */
+ int (*tkSelGetSelection) (Tcl_Interp *interp, Tk_Window tkwin, Atom selection, Atom target, Tk_GetSelProc *proc, void *clientData); /* 158 */
int (*tkTextGetIndex) (Tcl_Interp *interp, struct TkText *textPtr, const char *string, struct TkTextIndex *indexPtr); /* 159 */
- int (*tkTextIndexBackBytes) (const struct TkText *textPtr, const struct TkTextIndex *srcPtr, int count, struct TkTextIndex *dstPtr); /* 160 */
- int (*tkTextIndexForwBytes) (const struct TkText *textPtr, const struct TkTextIndex *srcPtr, int count, struct TkTextIndex *dstPtr); /* 161 */
- struct TkTextIndex * (*tkTextMakeByteIndex) (TkTextBTree tree, const struct TkText *textPtr, int lineIndex, int byteIndex, struct TkTextIndex *indexPtr); /* 162 */
- int (*tkTextPrintIndex) (const struct TkText *textPtr, const struct TkTextIndex *indexPtr, char *string); /* 163 */
+ int (*tkTextIndexBackBytes) (const struct TkText *textPtr, const struct TkTextIndex *srcPtr, Tcl_Size count, struct TkTextIndex *dstPtr); /* 160 */
+ int (*tkTextIndexForwBytes) (const struct TkText *textPtr, const struct TkTextIndex *srcPtr, Tcl_Size count, struct TkTextIndex *dstPtr); /* 161 */
+ struct TkTextIndex * (*tkTextMakeByteIndex) (TkTextBTree tree, const struct TkText *textPtr, int lineIndex, Tcl_Size byteIndex, struct TkTextIndex *indexPtr); /* 162 */
+ Tcl_Size (*tkTextPrintIndex) (const struct TkText *textPtr, const struct TkTextIndex *indexPtr, char *string); /* 163 */
struct TkTextSegment * (*tkTextSetMark) (struct TkText *textPtr, const char *name, struct TkTextIndex *indexPtr); /* 164 */
- int (*tkTextXviewCmd) (struct TkText *textPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); /* 165 */
+ int (*tkTextXviewCmd) (struct TkText *textPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[]); /* 165 */
void (*tkTextChanged) (struct TkSharedText *sharedTextPtr, struct TkText *textPtr, const struct TkTextIndex *index1Ptr, const struct TkTextIndex *index2Ptr); /* 166 */
int (*tkBTreeNumLines) (TkTextBTree tree, const struct TkText *textPtr); /* 167 */
void (*tkTextInsertDisplayProc) (struct TkText *textPtr, struct TkTextDispChunk *chunkPtr, int x, int y, int height, int baseline, Display *display, Drawable dst, int screenY); /* 168 */
- int (*tkStateParseProc) (ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, int offset); /* 169 */
- CONST86 char * (*tkStatePrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); /* 170 */
- int (*tkCanvasDashParseProc) (ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, int offset); /* 171 */
- CONST86 char * (*tkCanvasDashPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); /* 172 */
- int (*tkOffsetParseProc) (ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, int offset); /* 173 */
- CONST86 char * (*tkOffsetPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); /* 174 */
- int (*tkPixelParseProc) (ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, int offset); /* 175 */
- CONST86 char * (*tkPixelPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); /* 176 */
- int (*tkOrientParseProc) (ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, int offset); /* 177 */
- CONST86 char * (*tkOrientPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); /* 178 */
- int (*tkSmoothParseProc) (ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, int offset); /* 179 */
- CONST86 char * (*tkSmoothPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr); /* 180 */
- void (*tkDrawAngledTextLayout) (Display *display, Drawable drawable, GC gc, Tk_TextLayout layout, int x, int y, double angle, int firstChar, int lastChar); /* 181 */
+ int (*tkStateParseProc) (void *clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, Tcl_Size offset); /* 169 */
+ const char * (*tkStatePrintProc) (void *clientData, Tk_Window tkwin, char *widgRec, Tcl_Size offset, Tcl_FreeProc **freeProcPtr); /* 170 */
+ int (*tkCanvasDashParseProc) (void *clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, Tcl_Size offset); /* 171 */
+ const char * (*tkCanvasDashPrintProc) (void *clientData, Tk_Window tkwin, char *widgRec, Tcl_Size offset, Tcl_FreeProc **freeProcPtr); /* 172 */
+ int (*tkOffsetParseProc) (void *clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, Tcl_Size offset); /* 173 */
+ const char * (*tkOffsetPrintProc) (void *clientData, Tk_Window tkwin, char *widgRec, Tcl_Size offset, Tcl_FreeProc **freeProcPtr); /* 174 */
+ int (*tkPixelParseProc) (void *clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, Tcl_Size offset); /* 175 */
+ const char * (*tkPixelPrintProc) (void *clientData, Tk_Window tkwin, char *widgRec, Tcl_Size offset, Tcl_FreeProc **freeProcPtr); /* 176 */
+ int (*tkOrientParseProc) (void *clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, Tcl_Size offset); /* 177 */
+ const char * (*tkOrientPrintProc) (void *clientData, Tk_Window tkwin, char *widgRec, Tcl_Size offset, Tcl_FreeProc **freeProcPtr); /* 178 */
+ int (*tkSmoothParseProc) (void *clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, Tcl_Size offset); /* 179 */
+ const char * (*tkSmoothPrintProc) (void *clientData, Tk_Window tkwin, char *widgRec, Tcl_Size offset, Tcl_FreeProc **freeProcPtr); /* 180 */
+ void (*tkDrawAngledTextLayout) (Display *display, Drawable drawable, GC gc, Tk_TextLayout layout, int x, int y, double angle, Tcl_Size firstChar, Tcl_Size lastChar); /* 181 */
void (*tkUnderlineAngledTextLayout) (Display *display, Drawable drawable, GC gc, Tk_TextLayout layout, int x, int y, double angle, int underline); /* 182 */
int (*tkIntersectAngledTextLayout) (Tk_TextLayout layout, int x, int y, int width, int height, double angle); /* 183 */
- void (*tkDrawAngledChars) (Display *display, Drawable drawable, GC gc, Tk_Font tkfont, const char *source, int numBytes, double x, double y, double angle); /* 184 */
-#if !defined(_WIN32) && !defined(MAC_OSX_TCL) /* UNIX */
- void (*reserved185)(void);
-#endif /* UNIX */
-#if defined(_WIN32) /* WIN */
- void (*reserved185)(void);
-#endif /* WIN */
-#ifdef MAC_OSX_TCL /* MACOSX */
+ void (*tkDrawAngledChars) (Display *display, Drawable drawable, GC gc, Tk_Font tkfont, const char *source, Tcl_Size numBytes, double x, double y, double angle); /* 184 */
void (*tkpRedrawWidget) (Tk_Window tkwin); /* 185 */
-#endif /* MACOSX */
-#if !defined(_WIN32) && !defined(MAC_OSX_TCL) /* UNIX */
- void (*reserved186)(void);
-#endif /* UNIX */
-#if defined(_WIN32) /* WIN */
- void (*reserved186)(void);
-#endif /* WIN */
-#ifdef MAC_OSX_TCL /* MACOSX */
int (*tkpWillDrawWidget) (Tk_Window tkwin); /* 186 */
-#endif /* MACOSX */
- void (*tkUnusedStubEntry) (void); /* 187 */
+ int (*tkDebugPhotoStringMatchDef) (Tcl_Interp *inter, Tcl_Obj *data, Tcl_Obj *formatString, int *widthPtr, int *heightPtr); /* 187 */
} TkIntStubs;
extern const TkIntStubs *tkIntStubsPtr;
@@ -1037,20 +1035,20 @@ extern const TkIntStubs *tkIntStubsPtr;
(tkIntStubsPtr->tkpGetSystemDefault) /* 111 */
#define TkpMenuThreadInit \
(tkIntStubsPtr->tkpMenuThreadInit) /* 112 */
-#define TkClipBox \
- (tkIntStubsPtr->tkClipBox) /* 113 */
-#define TkCreateRegion \
- (tkIntStubsPtr->tkCreateRegion) /* 114 */
-#define TkDestroyRegion \
- (tkIntStubsPtr->tkDestroyRegion) /* 115 */
-#define TkIntersectRegion \
- (tkIntStubsPtr->tkIntersectRegion) /* 116 */
-#define TkRectInRegion \
- (tkIntStubsPtr->tkRectInRegion) /* 117 */
-#define TkSetRegion \
- (tkIntStubsPtr->tkSetRegion) /* 118 */
-#define TkUnionRectWithRegion \
- (tkIntStubsPtr->tkUnionRectWithRegion) /* 119 */
+#define XClipBox \
+ (tkIntStubsPtr->xClipBox) /* 113 */
+#define XCreateRegion \
+ (tkIntStubsPtr->xCreateRegion) /* 114 */
+#define XDestroyRegion \
+ (tkIntStubsPtr->xDestroyRegion) /* 115 */
+#define XIntersectRegion \
+ (tkIntStubsPtr->xIntersectRegion) /* 116 */
+#define XRectInRegion \
+ (tkIntStubsPtr->xRectInRegion) /* 117 */
+#define XSetRegion \
+ (tkIntStubsPtr->xSetRegion) /* 118 */
+#define XUnionRectWithRegion \
+ (tkIntStubsPtr->xUnionRectWithRegion) /* 119 */
/* Slot 120 is reserved */
#ifdef MAC_OSX_TK /* AQUA */
#define TkpCreateNativeBitmap \
@@ -1095,8 +1093,8 @@ extern const TkIntStubs *tkIntStubsPtr;
(tkIntStubsPtr->tkClipCleanup) /* 143 */
#define TkGCCleanup \
(tkIntStubsPtr->tkGCCleanup) /* 144 */
-#define TkSubtractRegion \
- (tkIntStubsPtr->tkSubtractRegion) /* 145 */
+#define XSubtractRegion \
+ (tkIntStubsPtr->xSubtractRegion) /* 145 */
#define TkStylePkgInit \
(tkIntStubsPtr->tkStylePkgInit) /* 146 */
#define TkStylePkgFree \
@@ -1174,16 +1172,12 @@ extern const TkIntStubs *tkIntStubsPtr;
(tkIntStubsPtr->tkIntersectAngledTextLayout) /* 183 */
#define TkDrawAngledChars \
(tkIntStubsPtr->tkDrawAngledChars) /* 184 */
-#ifdef MAC_OSX_TCL /* MACOSX */
#define TkpRedrawWidget \
(tkIntStubsPtr->tkpRedrawWidget) /* 185 */
-#endif /* MACOSX */
-#ifdef MAC_OSX_TCL /* MACOSX */
#define TkpWillDrawWidget \
(tkIntStubsPtr->tkpWillDrawWidget) /* 186 */
-#endif /* MACOSX */
-#define TkUnusedStubEntry \
- (tkIntStubsPtr->tkUnusedStubEntry) /* 187 */
+#define TkDebugPhotoStringMatchDef \
+ (tkIntStubsPtr->tkDebugPhotoStringMatchDef) /* 187 */
#endif /* defined(USE_TK_STUBS) */
@@ -1192,19 +1186,6 @@ extern const TkIntStubs *tkIntStubsPtr;
#undef TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS DLLIMPORT
-/*
- * On X11, these macros are just wrappers for the equivalent X Region calls.
- */
-#if !(defined(_WIN32) || defined(__CYGWIN__) || defined(MAC_OSX_TK)) /* X11 */
-
-#undef TkClipBox
-#undef TkCreateRegion
-#undef TkDestroyRegion
-#undef TkIntersectRegion
-#undef TkRectInRegion
-#undef TkSetRegion
-#undef TkSubtractRegion
-#undef TkUnionRectWithRegion
#undef TkpCmapStressed_
#undef TkpSync_
#undef TkUnixContainerId_
@@ -1213,29 +1194,31 @@ extern const TkIntStubs *tkIntStubsPtr;
#undef TkWmCleanup_
#undef TkSendCleanup_
#undef TkpTestsendCmd_
+#undef TkSetWindowMenuBar
+#undef TkpDrawHighlightBorder
+#undef TkpUseWindow
+#undef TkpSetMainMenubar
+#undef TkpGetOtherWindow
+#undef TkpGetSystemDefault
+#undef TkpMakeContainer
+#undef TkpMakeWindow
-#define TkClipBox(rgn, rect) XClipBox((Region) rgn, rect)
-#define TkCreateRegion() (TkRegion) XCreateRegion()
-#define TkDestroyRegion(rgn) XDestroyRegion((Region) rgn)
-#define TkIntersectRegion(a, b, r) XIntersectRegion((Region) a, \
- (Region) b, (Region) r)
-#define TkRectInRegion(r, x, y, w, h) XRectInRegion((Region) r, x, y, w, h)
-#define TkSetRegion(d, gc, rgn) XSetRegion(d, gc, (Region) rgn)
-#define TkSubtractRegion(a, b, r) XSubtractRegion((Region) a, \
- (Region) b, (Region) r)
-#define TkUnionRectWithRegion(rect, src, ret) XUnionRectWithRegion(rect, \
- (Region) src, (Region) ret)
-
-#endif /* UNIX */
+#if !defined(TK_NO_DEPRECATED) && (TCL_MAJOR_VERSION == 8)
+# define TkSetWindowMenuBar Tk_SetWindowMenubar
+# define TkpDrawHighlightBorder Tk_DrawHighlightBorder
+# define TkpUseWindow Tk_UseWindow
+# define TkpSetMainMenubar Tk_SetMainMenubar
+# define TkpGetOtherWindow ((TkWindow *(*)(TkWindow *))(void *)Tk_GetOtherWindow)
+# define TkpGetSystemDefault Tk_GetSystemDefault
+# define TkpMakeContainer Tk_MakeContainer
+# define TkpMakeWindow ((Window (*)(TkWindow *, Window))(void *)Tk_MakeWindow)
+#endif
-#if !defined(MAC_OSX_TK)
+#if !defined(MAC_OSX_TK) && !defined(USE_TK_STUBS)
# undef TkpWillDrawWidget
# undef TkpRedrawWidget
# define TkpWillDrawWidget(w) 0
# define TkpRedrawWidget(w)
#endif
-#undef TkUnusedStubEntry
-
#endif /* _TKINTDECLS */
-
diff --git a/generic/tkIntPlatDecls.h b/generic/tkIntPlatDecls.h
index 8bffa2c..e87272e 100644
--- a/generic/tkIntPlatDecls.h
+++ b/generic/tkIntPlatDecls.h
@@ -6,7 +6,7 @@
* interfaces are not guaranteed to remain the same between
* versions. Use at your own risk.
*
- * Copyright (c) 1998-1999 Scriptics Corporation.
+ * Copyright © 1998-1999 Scriptics Corporation.
* All rights reserved.
*/
@@ -103,7 +103,7 @@ EXTERN void TkWinSetWindowPos(HWND hwnd, HWND siblingHwnd,
/* 27 */
EXTERN void TkWinWmCleanup(HINSTANCE hInstance);
/* 28 */
-EXTERN void TkWinXCleanup(ClientData clientData);
+EXTERN void TkWinXCleanup(void *clientData);
/* 29 */
EXTERN void TkWinXInit(HINSTANCE hInstance);
/* 30 */
@@ -139,9 +139,8 @@ EXTERN void TkWmCleanup(TkDisplay *dispPtr);
/* 44 */
EXTERN void TkSendCleanup(TkDisplay *dispPtr);
/* 45 */
-EXTERN int TkpTestsendCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
+EXTERN int TkpTestsendCmd(void *clientData, Tcl_Interp *interp,
+ Tcl_Size objc, Tcl_Obj *const objv[]);
/* Slot 46 is reserved */
/* 47 */
EXTERN Tk_Window TkpGetCapture(void);
@@ -170,8 +169,7 @@ EXTERN unsigned int TkMacOSXButtonKeyState(void);
EXTERN void TkMacOSXClearMenubarActive(void);
/* 10 */
EXTERN int TkMacOSXDispatchMenuEvent(int menuID, int index);
-/* 11 */
-EXTERN void TkMacOSXInstallCursor(int resizeOverride);
+/* Slot 11 is reserved */
/* 12 */
EXTERN void TkMacOSXHandleTearoffMenu(void);
/* Slot 13 is reserved */
@@ -216,7 +214,7 @@ EXTERN void TkMacOSXUpdateClipRgn(TkWindow *winPtr);
/* 34 */
EXTERN int TkMacOSXUseMenuID(short macID);
/* 35 */
-EXTERN TkRegion TkMacOSXVisableClipRgn(TkWindow *winPtr);
+EXTERN Region TkMacOSXVisableClipRgn(TkWindow *winPtr);
/* 36 */
EXTERN void TkMacOSXWinBounds(TkWindow *winPtr, void *geometry);
/* 37 */
@@ -242,10 +240,10 @@ EXTERN void TkMacOSXPreprocessMenu(void);
/* 46 */
EXTERN int TkpIsWindowFloating(void *window);
/* 47 */
-EXTERN Tk_Window TkMacOSXGetCapture(void);
+EXTERN Tk_Window TkpGetCapture(void);
/* Slot 48 is reserved */
/* 49 */
-EXTERN Tk_Window TkGetTransientMaster(TkWindow *winPtr);
+EXTERN Tk_Window TkMacOSXGetContainer(TkWindow *winPtr);
/* 50 */
EXTERN int TkGenerateButtonEvent(int x, int y, Window window,
unsigned int state);
@@ -289,9 +287,8 @@ EXTERN void TkSendCleanup(TkDisplay *dispPtr);
/* 12 */
EXTERN int TkpWmSetState(TkWindow *winPtr, int state);
/* 13 */
-EXTERN int TkpTestsendCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
+EXTERN int TkpTestsendCmd_(void *clientData, Tcl_Interp *interp,
+ Tcl_Size objc, Tcl_Obj *const objv[]);
/* Slot 14 is reserved */
/* Slot 15 is reserved */
/* Slot 16 is reserved */
@@ -331,9 +328,8 @@ EXTERN void TkWmCleanup_(TkDisplay *dispPtr);
/* 44 */
EXTERN void TkSendCleanup_(TkDisplay *dispPtr);
/* 45 */
-EXTERN int TkpTestsendCmd_(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
+EXTERN int TkpTestsendCmd(void *clientData, Tcl_Interp *interp,
+ Tcl_Size objc, Tcl_Obj *const objv[]);
#endif /* X11 */
typedef struct TkIntPlatStubs {
@@ -369,7 +365,7 @@ typedef struct TkIntPlatStubs {
void (*tkWinSetMenu) (Tk_Window tkwin, HMENU hMenu); /* 25 */
void (*tkWinSetWindowPos) (HWND hwnd, HWND siblingHwnd, int pos); /* 26 */
void (*tkWinWmCleanup) (HINSTANCE hInstance); /* 27 */
- void (*tkWinXCleanup) (ClientData clientData); /* 28 */
+ void (*tkWinXCleanup) (void *clientData); /* 28 */
void (*tkWinXInit) (HINSTANCE hInstance); /* 29 */
void (*tkWinSetForegroundWindow) (TkWindow *winPtr); /* 30 */
void (*tkWinDialogDebug) (int debug); /* 31 */
@@ -386,7 +382,7 @@ typedef struct TkIntPlatStubs {
void (*tkUnixSetMenubar) (Tk_Window tkwin, Tk_Window menubar); /* 42 */
void (*tkWmCleanup) (TkDisplay *dispPtr); /* 43 */
void (*tkSendCleanup) (TkDisplay *dispPtr); /* 44 */
- int (*tkpTestsendCmd) (ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); /* 45 */
+ int (*tkpTestsendCmd) (void *clientData, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[]); /* 45 */
void (*reserved46)(void);
Tk_Window (*tkpGetCapture) (void); /* 47 */
#endif /* WIN */
@@ -402,7 +398,7 @@ typedef struct TkIntPlatStubs {
unsigned int (*tkMacOSXButtonKeyState) (void); /* 8 */
void (*tkMacOSXClearMenubarActive) (void); /* 9 */
int (*tkMacOSXDispatchMenuEvent) (int menuID, int index); /* 10 */
- void (*tkMacOSXInstallCursor) (int resizeOverride); /* 11 */
+ void (*reserved11)(void);
void (*tkMacOSXHandleTearoffMenu) (void); /* 12 */
void (*reserved13)(void);
int (*tkMacOSXDoHLEvent) (void *theEvent); /* 14 */
@@ -426,7 +422,7 @@ typedef struct TkIntPlatStubs {
void (*tkMacOSXUpdateClipRgn) (TkWindow *winPtr); /* 32 */
void (*reserved33)(void);
int (*tkMacOSXUseMenuID) (short macID); /* 34 */
- TkRegion (*tkMacOSXVisableClipRgn) (TkWindow *winPtr); /* 35 */
+ Region (*tkMacOSXVisableClipRgn) (TkWindow *winPtr); /* 35 */
void (*tkMacOSXWinBounds) (TkWindow *winPtr, void *geometry); /* 36 */
void (*tkMacOSXWindowOffset) (void *wRef, int *xOffset, int *yOffset); /* 37 */
int (*tkSetMacColor) (unsigned long pixel, void *macColor); /* 38 */
@@ -438,9 +434,9 @@ typedef struct TkIntPlatStubs {
MacDrawable * (*tkMacOSXGetHostToplevel) (TkWindow *winPtr); /* 44 */
void (*tkMacOSXPreprocessMenu) (void); /* 45 */
int (*tkpIsWindowFloating) (void *window); /* 46 */
- Tk_Window (*tkMacOSXGetCapture) (void); /* 47 */
+ Tk_Window (*tkpGetCapture) (void); /* 47 */
void (*reserved48)(void);
- Tk_Window (*tkGetTransientMaster) (TkWindow *winPtr); /* 49 */
+ Tk_Window (*tkMacOSXGetContainer) (TkWindow *winPtr); /* 49 */
int (*tkGenerateButtonEvent) (int x, int y, Window window, unsigned int state); /* 50 */
void (*tkGenWMDestroyEvent) (Tk_Window tkwin); /* 51 */
void (*tkMacOSXSetDrawingEnabled) (TkWindow *winPtr, int flag); /* 52 */
@@ -462,7 +458,7 @@ typedef struct TkIntPlatStubs {
void (*tkSendCleanup) (TkDisplay *dispPtr); /* 10 */
void (*reserved11)(void);
int (*tkpWmSetState) (TkWindow *winPtr, int state); /* 12 */
- int (*tkpTestsendCmd) (ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); /* 13 */
+ int (*tkpTestsendCmd_) (void *clientData, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[]); /* 13 */
void (*reserved14)(void);
void (*reserved15)(void);
void (*reserved16)(void);
@@ -494,7 +490,7 @@ typedef struct TkIntPlatStubs {
void (*tkUnixSetMenubar_) (Tk_Window tkwin, Tk_Window menubar); /* 42 */
void (*tkWmCleanup_) (TkDisplay *dispPtr); /* 43 */
void (*tkSendCleanup_) (TkDisplay *dispPtr); /* 44 */
- int (*tkpTestsendCmd_) (ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]); /* 45 */
+ int (*tkpTestsendCmd) (void *clientData, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[]); /* 45 */
#endif /* X11 */
} TkIntPlatStubs;
@@ -628,8 +624,7 @@ extern const TkIntPlatStubs *tkIntPlatStubsPtr;
(tkIntPlatStubsPtr->tkMacOSXClearMenubarActive) /* 9 */
#define TkMacOSXDispatchMenuEvent \
(tkIntPlatStubsPtr->tkMacOSXDispatchMenuEvent) /* 10 */
-#define TkMacOSXInstallCursor \
- (tkIntPlatStubsPtr->tkMacOSXInstallCursor) /* 11 */
+/* Slot 11 is reserved */
#define TkMacOSXHandleTearoffMenu \
(tkIntPlatStubsPtr->tkMacOSXHandleTearoffMenu) /* 12 */
/* Slot 13 is reserved */
@@ -693,11 +688,11 @@ extern const TkIntPlatStubs *tkIntPlatStubsPtr;
(tkIntPlatStubsPtr->tkMacOSXPreprocessMenu) /* 45 */
#define TkpIsWindowFloating \
(tkIntPlatStubsPtr->tkpIsWindowFloating) /* 46 */
-#define TkMacOSXGetCapture \
- (tkIntPlatStubsPtr->tkMacOSXGetCapture) /* 47 */
+#define TkpGetCapture \
+ (tkIntPlatStubsPtr->tkpGetCapture) /* 47 */
/* Slot 48 is reserved */
-#define TkGetTransientMaster \
- (tkIntPlatStubsPtr->tkGetTransientMaster) /* 49 */
+#define TkMacOSXGetContainer \
+ (tkIntPlatStubsPtr->tkMacOSXGetContainer) /* 49 */
#define TkGenerateButtonEvent \
(tkIntPlatStubsPtr->tkGenerateButtonEvent) /* 50 */
#define TkGenWMDestroyEvent \
@@ -736,8 +731,8 @@ extern const TkIntPlatStubs *tkIntPlatStubsPtr;
/* Slot 11 is reserved */
#define TkpWmSetState \
(tkIntPlatStubsPtr->tkpWmSetState) /* 12 */
-#define TkpTestsendCmd \
- (tkIntPlatStubsPtr->tkpTestsendCmd) /* 13 */
+#define TkpTestsendCmd_ \
+ (tkIntPlatStubsPtr->tkpTestsendCmd_) /* 13 */
/* Slot 14 is reserved */
/* Slot 15 is reserved */
/* Slot 16 is reserved */
@@ -776,8 +771,8 @@ extern const TkIntPlatStubs *tkIntPlatStubsPtr;
(tkIntPlatStubsPtr->tkWmCleanup_) /* 43 */
#define TkSendCleanup_ \
(tkIntPlatStubsPtr->tkSendCleanup_) /* 44 */
-#define TkpTestsendCmd_ \
- (tkIntPlatStubsPtr->tkpTestsendCmd_) /* 45 */
+#define TkpTestsendCmd \
+ (tkIntPlatStubsPtr->tkpTestsendCmd) /* 45 */
#endif /* X11 */
#endif /* defined(USE_TK_STUBS) */
@@ -793,12 +788,14 @@ extern const TkIntPlatStubs *tkIntPlatStubsPtr;
#undef TkSendCleanup_
#undef TkpTestsendCmd_
#undef TkGenerateActivateEvents_
-
-#define TkMacOSXGetContainer TkGetTransientMaster
+#undef TkMacOSXSetUpClippingRgn
#undef TkMacOSXIsCharacterMissing
#define TkMacOSXIsCharacterMissing(tkfont) ((void)tkfont, 0)
#undef TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS DLLIMPORT
+#undef TkWinGetPlatformId
+#define TkWinGetPlatformId() (2) /* VER_PLATFORM_WIN32_NT */
+
#endif /* _TKINTPLATDECLS */
diff --git a/generic/tkIntXlibDecls.h b/generic/tkIntXlibDecls.h
index 795edfb..b935f0a 100644
--- a/generic/tkIntXlibDecls.h
+++ b/generic/tkIntXlibDecls.h
@@ -6,7 +6,7 @@
* interfaces are not guaranteed to remain the same between
* versions. Use at your own risk.
*
- * Copyright (c) 1998-1999 Scriptics Corporation.
+ * Copyright © 1998-1999 Scriptics Corporation.
* All rights reserved.
*/
@@ -23,17 +23,23 @@
# include <tcl.h>
#endif
-/* Some (older) versions of X11/Xutil.h have a wrong signature of those
- two functions, so move them out of the way temporarily. */
-#define XOffsetRegion _XOffsetRegion
-#define XUnionRegion _XUnionRegion
+#ifndef EXTERN
+# define EXTERN extern TCL_STORAGE_CLASS
+#endif
+
#include "X11/Xutil.h"
-#undef XOffsetRegion
-#undef XUnionRegion
#ifdef BUILD_tk
-#undef TCL_STORAGE_CLASS
-#define TCL_STORAGE_CLASS DLLEXPORT
+# undef TCL_STORAGE_CLASS
+# define TCL_STORAGE_CLASS DLLEXPORT
+#else
+# ifndef TCL_STORAGE_CLASS
+# define TCL_STORAGE_CLASS DLLIMPORT
+# endif
+#endif
+
+#if defined(MAC_OSX_TK) && !defined(MAC_OSX_TCL)
+# define MAC_OSX_TCL 1
#endif
typedef int (*XAfterFunction) ( /* WARNING, this type not in Xlib spec */
@@ -416,30 +422,61 @@ EXTERN int XReparentWindow(Display *d, Window w, Window p,
EXTERN int XPutImage(Display *d, Drawable dr, GC gc, XImage *im,
int sx, int sy, int dx, int dy,
unsigned int w, unsigned int h);
-/* Slot 138 is reserved */
-/* Slot 139 is reserved */
-/* Slot 140 is reserved */
-/* Slot 141 is reserved */
-/* Slot 142 is reserved */
-/* Slot 143 is reserved */
+/* 138 */
+EXTERN Region XPolygonRegion(XPoint *pts, int n, int rule);
+/* 139 */
+EXTERN int XPointInRegion(Region rgn, int x, int y);
+/* 140 */
+EXTERN XVaNestedList XVaCreateNestedList(int dummy, ...);
+/* 141 */
+EXTERN char * XSetICValues(XIC xic, ...);
+/* 142 */
+EXTERN char * XGetICValues(XIC xic, ...);
+/* 143 */
+EXTERN void XSetICFocus(XIC xic);
/* Slot 144 is reserved */
/* Slot 145 is reserved */
/* Slot 146 is reserved */
-/* Slot 147 is reserved */
-/* Slot 148 is reserved */
-/* Slot 149 is reserved */
-/* Slot 150 is reserved */
-/* Slot 151 is reserved */
-/* Slot 152 is reserved */
-/* Slot 153 is reserved */
-/* Slot 154 is reserved */
-/* Slot 155 is reserved */
-/* Slot 156 is reserved */
-/* Slot 157 is reserved */
+/* 147 */
+EXTERN void XFreeFontSet(Display *display, XFontSet fontset);
+/* 148 */
+EXTERN int XCloseIM(XIM im);
+/* 149 */
+EXTERN Bool XRegisterIMInstantiateCallback(Display *dpy,
+ struct _XrmHashBucketRec *rbd,
+ char *res_name, char *res_class,
+ XIDProc callback, XPointer client_data);
+/* 150 */
+EXTERN Bool XUnregisterIMInstantiateCallback(Display *dpy,
+ struct _XrmHashBucketRec *rbd,
+ char *res_name, char *res_class,
+ XIDProc callback, XPointer client_data);
+/* 151 */
+EXTERN char * XSetLocaleModifiers(const char *modifier_list);
+/* 152 */
+EXTERN XIM XOpenIM(Display *dpy, struct _XrmHashBucketRec *rdb,
+ char *res_name, char *res_class);
+/* 153 */
+EXTERN char * XGetIMValues(XIM im, ...);
+/* 154 */
+EXTERN char * XSetIMValues(XIM im, ...);
+/* 155 */
+EXTERN XFontSet XCreateFontSet(Display *display,
+ _Xconst char *base_font_name_list,
+ char ***missing_charset_list,
+ int *missing_charset_count,
+ char **def_string);
+/* 156 */
+EXTERN void XFreeStringList(char **list);
+/* 157 */
+EXTERN KeySym XkbKeycodeToKeysym(Display *d, unsigned int k, int g,
+ int i);
/* 158 */
-EXTERN void TkUnusedStubEntry(void);
+EXTERN Display * XkbOpenDisplay(const char *name, int *ev_rtrn,
+ int *err_rtrn, int *major_rtrn,
+ int *minor_rtrn, int *reason);
#endif /* WIN */
-#ifdef MAC_OSX_TK /* AQUA */
+#ifdef MAC_OSX_TCL /* MACOSX */
/* 0 */
EXTERN int XSetDashes(Display *display, GC gc, int dash_offset,
_Xconst char *dash_list, int n);
@@ -463,7 +500,7 @@ EXTERN Colormap XCreateColormap(Display *d, Window w, Visual *v,
/* 7 */
EXTERN GContext XGContextFromGC(GC g);
/* 8 */
-EXTERN KeySym XKeycodeToKeysym(Display *d, KeyCode k, int i);
+EXTERN KeySym XKeycodeToKeysym(Display *d, unsigned int k, int i);
/* 9 */
EXTERN KeySym XStringToKeysym(_Xconst char *c);
/* 10 */
@@ -702,20 +739,39 @@ EXTERN Status XQueryTree(Display *d, Window w1, Window *w2,
Window *w3, Window **w4, unsigned int *ui);
/* 91 */
EXTERN int XSync(Display *display, Bool discard);
-/* Slot 92 is reserved */
-/* Slot 93 is reserved */
-/* Slot 94 is reserved */
-/* Slot 95 is reserved */
-/* Slot 96 is reserved */
-/* Slot 97 is reserved */
-/* Slot 98 is reserved */
-/* Slot 99 is reserved */
-/* Slot 100 is reserved */
-/* Slot 101 is reserved */
-/* Slot 102 is reserved */
-/* Slot 103 is reserved */
-/* Slot 104 is reserved */
-/* Slot 105 is reserved */
+/* 92 */
+EXTERN Bool XTranslateCoordinates(Display *d, Window w1,
+ Window w2, int i1, int i2, int *i3, int *i4,
+ Window *w3);
+/* 93 */
+EXTERN int XDeleteProperty(Display *d, Window w, Atom a);
+/* 94 */
+EXTERN int XFreeCursor(Display *d, Cursor c);
+/* 95 */
+EXTERN int XGetInputFocus(Display *d, Window *w, int *i);
+/* 96 */
+EXTERN int XmbLookupString(XIC xi, XKeyPressedEvent *xk,
+ char *c, int i, KeySym *k, Status *s);
+/* 97 */
+EXTERN int XNextEvent(Display *d, XEvent *x);
+/* 98 */
+EXTERN int XPutBackEvent(Display *d, XEvent *x);
+/* 99 */
+EXTERN int XSetCommand(Display *d, Window w, char **c, int i);
+/* 100 */
+EXTERN int XWindowEvent(Display *d, Window w, long l, XEvent *x);
+/* 101 */
+EXTERN Status XGetWindowAttributes(Display *d, Window w,
+ XWindowAttributes *x);
+/* 102 */
+EXTERN Status XGetWMColormapWindows(Display *d, Window w,
+ Window **wpp, int *ip);
+/* 103 */
+EXTERN Status XIconifyWindow(Display *d, Window w, int i);
+/* 104 */
+EXTERN Status XWithdrawWindow(Display *d, Window w, int i);
+/* 105 */
+EXTERN XHostAddress * XListHosts(Display *d, int *i, Bool *b);
/* 106 */
EXTERN int XSetClipRectangles(Display *display, GC gc,
int clip_x_origin, int clip_y_origin,
@@ -732,7 +788,9 @@ EXTERN int XFree(void *data);
EXTERN int XNoOp(Display *display);
/* 112 */
EXTERN XAfterFunction XSynchronize(Display *display, Bool onoff);
-/* Slot 113 is reserved */
+/* 113 */
+EXTERN Status XLookupColor(Display *d, Colormap c1,
+ _Xconst char *c2, XColor *x1, XColor *x2);
/* 114 */
EXTERN VisualID XVisualIDFromVisual(Visual *visual);
/* Slot 115 is reserved */
@@ -741,9 +799,18 @@ EXTERN VisualID XVisualIDFromVisual(Visual *visual);
/* Slot 118 is reserved */
/* Slot 119 is reserved */
/* 120 */
-EXTERN int XOffsetRegion(void *rgn, int dx, int dy);
-/* Slot 121 is reserved */
-/* Slot 122 is reserved */
+EXTERN int XOffsetRegion(Region rgn, int dx, int dy);
+/* 121 */
+EXTERN int XUnionRegion(Region srca, Region srcb,
+ Region dr_return);
+/* 122 */
+EXTERN Window XCreateWindow(Display *display, Window parent, int x,
+ int y, unsigned int width,
+ unsigned int height,
+ unsigned int border_width, int depth,
+ unsigned int clazz, Visual *visual,
+ unsigned long value_mask,
+ XSetWindowAttributes *attributes);
/* Slot 123 is reserved */
/* Slot 124 is reserved */
/* Slot 125 is reserved */
@@ -752,23 +819,37 @@ EXTERN int XOffsetRegion(void *rgn, int dx, int dy);
/* Slot 128 is reserved */
/* 129 */
EXTERN int XLowerWindow(Display *d, Window w);
-/* Slot 130 is reserved */
-/* Slot 131 is reserved */
-/* Slot 132 is reserved */
+/* 130 */
+EXTERN int XFillArcs(Display *d, Drawable dr, GC gc, XArc *a,
+ int n);
+/* 131 */
+EXTERN int XDrawArcs(Display *d, Drawable dr, GC gc, XArc *a,
+ int n);
+/* 132 */
+EXTERN int XDrawRectangles(Display *d, Drawable dr, GC gc,
+ XRectangle *r, int n);
/* Slot 133 is reserved */
/* Slot 134 is reserved */
/* Slot 135 is reserved */
-/* Slot 136 is reserved */
+/* 136 */
+EXTERN int XReparentWindow(Display *d, Window w, Window p,
+ int x, int y);
/* 137 */
EXTERN int XPutImage(Display *d, Drawable dr, GC gc, XImage *im,
int sx, int sy, int dx, int dy,
unsigned int w, unsigned int h);
-/* Slot 138 is reserved */
-/* Slot 139 is reserved */
-/* Slot 140 is reserved */
-/* Slot 141 is reserved */
-/* Slot 142 is reserved */
-/* Slot 143 is reserved */
+/* 138 */
+EXTERN Region XPolygonRegion(XPoint *pts, int n, int rule);
+/* 139 */
+EXTERN int XPointInRegion(Region rgn, int x, int y);
+/* 140 */
+EXTERN XVaNestedList XVaCreateNestedList(int dummy, ...);
+/* 141 */
+EXTERN char * XSetICValues(XIC xic, ...);
+/* 142 */
+EXTERN char * XGetICValues(XIC xic, ...);
+/* 143 */
+EXTERN void XSetICFocus(XIC xic);
/* 144 */
EXTERN void XDestroyIC(XIC xic);
/* 145 */
@@ -779,22 +860,45 @@ EXTERN Cursor XCreatePixmapCursor(Display *d, Pixmap p1, Pixmap p2,
EXTERN Cursor XCreateGlyphCursor(Display *d, Font f1, Font f2,
unsigned int ui1, unsigned int ui2,
XColor _Xconst *x1, XColor _Xconst *x2);
-/* Slot 147 is reserved */
-/* Slot 148 is reserved */
-/* Slot 149 is reserved */
-/* Slot 150 is reserved */
-/* Slot 151 is reserved */
-/* Slot 152 is reserved */
-/* Slot 153 is reserved */
-/* Slot 154 is reserved */
-/* Slot 155 is reserved */
-/* Slot 156 is reserved */
+/* 147 */
+EXTERN void XFreeFontSet(Display *display, XFontSet fontset);
+/* 148 */
+EXTERN int XCloseIM(XIM im);
+/* 149 */
+EXTERN Bool XRegisterIMInstantiateCallback(Display *dpy,
+ struct _XrmHashBucketRec *rbd,
+ char *res_name, char *res_class,
+ XIDProc callback, XPointer client_data);
+/* 150 */
+EXTERN Bool XUnregisterIMInstantiateCallback(Display *dpy,
+ struct _XrmHashBucketRec *rbd,
+ char *res_name, char *res_class,
+ XIDProc callback, XPointer client_data);
+/* 151 */
+EXTERN char * XSetLocaleModifiers(const char *modifier_list);
+/* 152 */
+EXTERN XIM XOpenIM(Display *dpy, struct _XrmHashBucketRec *rdb,
+ char *res_name, char *res_class);
+/* 153 */
+EXTERN char * XGetIMValues(XIM im, ...);
+/* 154 */
+EXTERN char * XSetIMValues(XIM im, ...);
+/* 155 */
+EXTERN XFontSet XCreateFontSet(Display *display,
+ _Xconst char *base_font_name_list,
+ char ***missing_charset_list,
+ int *missing_charset_count,
+ char **def_string);
+/* 156 */
+EXTERN void XFreeStringList(char **list);
/* 157 */
EXTERN KeySym XkbKeycodeToKeysym(Display *d, unsigned int k, int g,
int i);
/* 158 */
-EXTERN void TkUnusedStubEntry(void);
-#endif /* AQUA */
+EXTERN Display * XkbOpenDisplay(const char *name, int *ev_rtrn,
+ int *err_rtrn, int *major_rtrn,
+ int *minor_rtrn, int *reason);
+#endif /* MACOSX */
typedef struct TkIntXlibStubs {
int magic;
@@ -939,29 +1043,29 @@ typedef struct TkIntXlibStubs {
int (*xDrawPoints) (Display *d, Drawable dr, GC gc, XPoint *p, int n, int m); /* 135 */
int (*xReparentWindow) (Display *d, Window w, Window p, int x, int y); /* 136 */
int (*xPutImage) (Display *d, Drawable dr, GC gc, XImage *im, int sx, int sy, int dx, int dy, unsigned int w, unsigned int h); /* 137 */
- void (*reserved138)(void);
- void (*reserved139)(void);
- void (*reserved140)(void);
- void (*reserved141)(void);
- void (*reserved142)(void);
- void (*reserved143)(void);
+ Region (*xPolygonRegion) (XPoint *pts, int n, int rule); /* 138 */
+ int (*xPointInRegion) (Region rgn, int x, int y); /* 139 */
+ XVaNestedList (*xVaCreateNestedList) (int dummy, ...); /* 140 */
+ char * (*xSetICValues) (XIC xic, ...); /* 141 */
+ char * (*xGetICValues) (XIC xic, ...); /* 142 */
+ void (*xSetICFocus) (XIC xic); /* 143 */
void (*reserved144)(void);
void (*reserved145)(void);
void (*reserved146)(void);
- void (*reserved147)(void);
- void (*reserved148)(void);
- void (*reserved149)(void);
- void (*reserved150)(void);
- void (*reserved151)(void);
- void (*reserved152)(void);
- void (*reserved153)(void);
- void (*reserved154)(void);
- void (*reserved155)(void);
- void (*reserved156)(void);
- void (*reserved157)(void);
- void (*tkUnusedStubEntry) (void); /* 158 */
+ void (*xFreeFontSet) (Display *display, XFontSet fontset); /* 147 */
+ int (*xCloseIM) (XIM im); /* 148 */
+ Bool (*xRegisterIMInstantiateCallback) (Display *dpy, struct _XrmHashBucketRec *rbd, char *res_name, char *res_class, XIDProc callback, XPointer client_data); /* 149 */
+ Bool (*xUnregisterIMInstantiateCallback) (Display *dpy, struct _XrmHashBucketRec *rbd, char *res_name, char *res_class, XIDProc callback, XPointer client_data); /* 150 */
+ char * (*xSetLocaleModifiers) (const char *modifier_list); /* 151 */
+ XIM (*xOpenIM) (Display *dpy, struct _XrmHashBucketRec *rdb, char *res_name, char *res_class); /* 152 */
+ char * (*xGetIMValues) (XIM im, ...); /* 153 */
+ char * (*xSetIMValues) (XIM im, ...); /* 154 */
+ XFontSet (*xCreateFontSet) (Display *display, _Xconst char *base_font_name_list, char ***missing_charset_list, int *missing_charset_count, char **def_string); /* 155 */
+ void (*xFreeStringList) (char **list); /* 156 */
+ KeySym (*xkbKeycodeToKeysym) (Display *d, unsigned int k, int g, int i); /* 157 */
+ Display * (*xkbOpenDisplay) (const char *name, int *ev_rtrn, int *err_rtrn, int *major_rtrn, int *minor_rtrn, int *reason); /* 158 */
#endif /* WIN */
-#ifdef MAC_OSX_TK /* AQUA */
+#ifdef MAC_OSX_TCL /* MACOSX */
int (*xSetDashes) (Display *display, GC gc, int dash_offset, _Xconst char *dash_list, int n); /* 0 */
XModifierKeymap * (*xGetModifierMapping) (Display *d); /* 1 */
XImage * (*xCreateImage) (Display *d, Visual *v, unsigned int ui1, int i1, int i2, char *cp, unsigned int ui2, unsigned int ui3, int i3, int i4); /* 2 */
@@ -970,7 +1074,7 @@ typedef struct TkIntXlibStubs {
char * (*xKeysymToString) (KeySym k); /* 5 */
Colormap (*xCreateColormap) (Display *d, Window w, Visual *v, int i); /* 6 */
GContext (*xGContextFromGC) (GC g); /* 7 */
- KeySym (*xKeycodeToKeysym) (Display *d, KeyCode k, int i); /* 8 */
+ KeySym (*xKeycodeToKeysym) (Display *d, unsigned int k, int i); /* 8 */
KeySym (*xStringToKeysym) (_Xconst char *c); /* 9 */
Window (*xRootWindow) (Display *d, int i); /* 10 */
XErrorHandler (*xSetErrorHandler) (XErrorHandler x); /* 11 */
@@ -1054,20 +1158,20 @@ typedef struct TkIntXlibStubs {
int (*xQueryColors) (Display *display, Colormap colormap, XColor *defs_in_out, int ncolors); /* 89 */
Status (*xQueryTree) (Display *d, Window w1, Window *w2, Window *w3, Window **w4, unsigned int *ui); /* 90 */
int (*xSync) (Display *display, Bool discard); /* 91 */
- void (*reserved92)(void);
- void (*reserved93)(void);
- void (*reserved94)(void);
- void (*reserved95)(void);
- void (*reserved96)(void);
- void (*reserved97)(void);
- void (*reserved98)(void);
- void (*reserved99)(void);
- void (*reserved100)(void);
- void (*reserved101)(void);
- void (*reserved102)(void);
- void (*reserved103)(void);
- void (*reserved104)(void);
- void (*reserved105)(void);
+ Bool (*xTranslateCoordinates) (Display *d, Window w1, Window w2, int i1, int i2, int *i3, int *i4, Window *w3); /* 92 */
+ int (*xDeleteProperty) (Display *d, Window w, Atom a); /* 93 */
+ int (*xFreeCursor) (Display *d, Cursor c); /* 94 */
+ int (*xGetInputFocus) (Display *d, Window *w, int *i); /* 95 */
+ int (*xmbLookupString) (XIC xi, XKeyPressedEvent *xk, char *c, int i, KeySym *k, Status *s); /* 96 */
+ int (*xNextEvent) (Display *d, XEvent *x); /* 97 */
+ int (*xPutBackEvent) (Display *d, XEvent *x); /* 98 */
+ int (*xSetCommand) (Display *d, Window w, char **c, int i); /* 99 */
+ int (*xWindowEvent) (Display *d, Window w, long l, XEvent *x); /* 100 */
+ Status (*xGetWindowAttributes) (Display *d, Window w, XWindowAttributes *x); /* 101 */
+ Status (*xGetWMColormapWindows) (Display *d, Window w, Window **wpp, int *ip); /* 102 */
+ Status (*xIconifyWindow) (Display *d, Window w, int i); /* 103 */
+ Status (*xWithdrawWindow) (Display *d, Window w, int i); /* 104 */
+ XHostAddress * (*xListHosts) (Display *d, int *i, Bool *b); /* 105 */
int (*xSetClipRectangles) (Display *display, GC gc, int clip_x_origin, int clip_y_origin, XRectangle rectangles[], int n, int ordering); /* 106 */
int (*xFlush) (Display *display); /* 107 */
int (*xGrabServer) (Display *display); /* 108 */
@@ -1075,16 +1179,16 @@ typedef struct TkIntXlibStubs {
int (*xFree) (void *data); /* 110 */
int (*xNoOp) (Display *display); /* 111 */
XAfterFunction (*xSynchronize) (Display *display, Bool onoff); /* 112 */
- void (*reserved113)(void);
+ Status (*xLookupColor) (Display *d, Colormap c1, _Xconst char *c2, XColor *x1, XColor *x2); /* 113 */
VisualID (*xVisualIDFromVisual) (Visual *visual); /* 114 */
void (*reserved115)(void);
void (*reserved116)(void);
void (*reserved117)(void);
void (*reserved118)(void);
void (*reserved119)(void);
- int (*xOffsetRegion) (void *rgn, int dx, int dy); /* 120 */
- void (*reserved121)(void);
- void (*reserved122)(void);
+ int (*xOffsetRegion) (Region rgn, int dx, int dy); /* 120 */
+ int (*xUnionRegion) (Region srca, Region srcb, Region dr_return); /* 121 */
+ Window (*xCreateWindow) (Display *display, Window parent, int x, int y, unsigned int width, unsigned int height, unsigned int border_width, int depth, unsigned int clazz, Visual *visual, unsigned long value_mask, XSetWindowAttributes *attributes); /* 122 */
void (*reserved123)(void);
void (*reserved124)(void);
void (*reserved125)(void);
@@ -1092,36 +1196,36 @@ typedef struct TkIntXlibStubs {
void (*reserved127)(void);
void (*reserved128)(void);
int (*xLowerWindow) (Display *d, Window w); /* 129 */
- void (*reserved130)(void);
- void (*reserved131)(void);
- void (*reserved132)(void);
+ int (*xFillArcs) (Display *d, Drawable dr, GC gc, XArc *a, int n); /* 130 */
+ int (*xDrawArcs) (Display *d, Drawable dr, GC gc, XArc *a, int n); /* 131 */
+ int (*xDrawRectangles) (Display *d, Drawable dr, GC gc, XRectangle *r, int n); /* 132 */
void (*reserved133)(void);
void (*reserved134)(void);
void (*reserved135)(void);
- void (*reserved136)(void);
+ int (*xReparentWindow) (Display *d, Window w, Window p, int x, int y); /* 136 */
int (*xPutImage) (Display *d, Drawable dr, GC gc, XImage *im, int sx, int sy, int dx, int dy, unsigned int w, unsigned int h); /* 137 */
- void (*reserved138)(void);
- void (*reserved139)(void);
- void (*reserved140)(void);
- void (*reserved141)(void);
- void (*reserved142)(void);
- void (*reserved143)(void);
+ Region (*xPolygonRegion) (XPoint *pts, int n, int rule); /* 138 */
+ int (*xPointInRegion) (Region rgn, int x, int y); /* 139 */
+ XVaNestedList (*xVaCreateNestedList) (int dummy, ...); /* 140 */
+ char * (*xSetICValues) (XIC xic, ...); /* 141 */
+ char * (*xGetICValues) (XIC xic, ...); /* 142 */
+ void (*xSetICFocus) (XIC xic); /* 143 */
void (*xDestroyIC) (XIC xic); /* 144 */
Cursor (*xCreatePixmapCursor) (Display *d, Pixmap p1, Pixmap p2, XColor *x1, XColor *x2, unsigned int ui1, unsigned int ui2); /* 145 */
Cursor (*xCreateGlyphCursor) (Display *d, Font f1, Font f2, unsigned int ui1, unsigned int ui2, XColor _Xconst *x1, XColor _Xconst *x2); /* 146 */
- void (*reserved147)(void);
- void (*reserved148)(void);
- void (*reserved149)(void);
- void (*reserved150)(void);
- void (*reserved151)(void);
- void (*reserved152)(void);
- void (*reserved153)(void);
- void (*reserved154)(void);
- void (*reserved155)(void);
- void (*reserved156)(void);
+ void (*xFreeFontSet) (Display *display, XFontSet fontset); /* 147 */
+ int (*xCloseIM) (XIM im); /* 148 */
+ Bool (*xRegisterIMInstantiateCallback) (Display *dpy, struct _XrmHashBucketRec *rbd, char *res_name, char *res_class, XIDProc callback, XPointer client_data); /* 149 */
+ Bool (*xUnregisterIMInstantiateCallback) (Display *dpy, struct _XrmHashBucketRec *rbd, char *res_name, char *res_class, XIDProc callback, XPointer client_data); /* 150 */
+ char * (*xSetLocaleModifiers) (const char *modifier_list); /* 151 */
+ XIM (*xOpenIM) (Display *dpy, struct _XrmHashBucketRec *rdb, char *res_name, char *res_class); /* 152 */
+ char * (*xGetIMValues) (XIM im, ...); /* 153 */
+ char * (*xSetIMValues) (XIM im, ...); /* 154 */
+ XFontSet (*xCreateFontSet) (Display *display, _Xconst char *base_font_name_list, char ***missing_charset_list, int *missing_charset_count, char **def_string); /* 155 */
+ void (*xFreeStringList) (char **list); /* 156 */
KeySym (*xkbKeycodeToKeysym) (Display *d, unsigned int k, int g, int i); /* 157 */
- void (*tkUnusedStubEntry) (void); /* 158 */
-#endif /* AQUA */
+ Display * (*xkbOpenDisplay) (const char *name, int *ev_rtrn, int *err_rtrn, int *major_rtrn, int *minor_rtrn, int *reason); /* 158 */
+#endif /* MACOSX */
} TkIntXlibStubs;
extern const TkIntXlibStubs *tkIntXlibStubsPtr;
@@ -1402,30 +1506,47 @@ extern const TkIntXlibStubs *tkIntXlibStubsPtr;
(tkIntXlibStubsPtr->xReparentWindow) /* 136 */
#define XPutImage \
(tkIntXlibStubsPtr->xPutImage) /* 137 */
-/* Slot 138 is reserved */
-/* Slot 139 is reserved */
-/* Slot 140 is reserved */
-/* Slot 141 is reserved */
-/* Slot 142 is reserved */
-/* Slot 143 is reserved */
+#define XPolygonRegion \
+ (tkIntXlibStubsPtr->xPolygonRegion) /* 138 */
+#define XPointInRegion \
+ (tkIntXlibStubsPtr->xPointInRegion) /* 139 */
+#define XVaCreateNestedList \
+ (tkIntXlibStubsPtr->xVaCreateNestedList) /* 140 */
+#define XSetICValues \
+ (tkIntXlibStubsPtr->xSetICValues) /* 141 */
+#define XGetICValues \
+ (tkIntXlibStubsPtr->xGetICValues) /* 142 */
+#define XSetICFocus \
+ (tkIntXlibStubsPtr->xSetICFocus) /* 143 */
/* Slot 144 is reserved */
/* Slot 145 is reserved */
/* Slot 146 is reserved */
-/* Slot 147 is reserved */
-/* Slot 148 is reserved */
-/* Slot 149 is reserved */
-/* Slot 150 is reserved */
-/* Slot 151 is reserved */
-/* Slot 152 is reserved */
-/* Slot 153 is reserved */
-/* Slot 154 is reserved */
-/* Slot 155 is reserved */
-/* Slot 156 is reserved */
-/* Slot 157 is reserved */
-#define TkUnusedStubEntry \
- (tkIntXlibStubsPtr->tkUnusedStubEntry) /* 158 */
+#define XFreeFontSet \
+ (tkIntXlibStubsPtr->xFreeFontSet) /* 147 */
+#define XCloseIM \
+ (tkIntXlibStubsPtr->xCloseIM) /* 148 */
+#define XRegisterIMInstantiateCallback \
+ (tkIntXlibStubsPtr->xRegisterIMInstantiateCallback) /* 149 */
+#define XUnregisterIMInstantiateCallback \
+ (tkIntXlibStubsPtr->xUnregisterIMInstantiateCallback) /* 150 */
+#define XSetLocaleModifiers \
+ (tkIntXlibStubsPtr->xSetLocaleModifiers) /* 151 */
+#define XOpenIM \
+ (tkIntXlibStubsPtr->xOpenIM) /* 152 */
+#define XGetIMValues \
+ (tkIntXlibStubsPtr->xGetIMValues) /* 153 */
+#define XSetIMValues \
+ (tkIntXlibStubsPtr->xSetIMValues) /* 154 */
+#define XCreateFontSet \
+ (tkIntXlibStubsPtr->xCreateFontSet) /* 155 */
+#define XFreeStringList \
+ (tkIntXlibStubsPtr->xFreeStringList) /* 156 */
+#define XkbKeycodeToKeysym \
+ (tkIntXlibStubsPtr->xkbKeycodeToKeysym) /* 157 */
+#define XkbOpenDisplay \
+ (tkIntXlibStubsPtr->xkbOpenDisplay) /* 158 */
#endif /* WIN */
-#ifdef MAC_OSX_TK /* AQUA */
+#ifdef MAC_OSX_TCL /* MACOSX */
#define XSetDashes \
(tkIntXlibStubsPtr->xSetDashes) /* 0 */
#define XGetModifierMapping \
@@ -1610,20 +1731,34 @@ extern const TkIntXlibStubs *tkIntXlibStubsPtr;
(tkIntXlibStubsPtr->xQueryTree) /* 90 */
#define XSync \
(tkIntXlibStubsPtr->xSync) /* 91 */
-/* Slot 92 is reserved */
-/* Slot 93 is reserved */
-/* Slot 94 is reserved */
-/* Slot 95 is reserved */
-/* Slot 96 is reserved */
-/* Slot 97 is reserved */
-/* Slot 98 is reserved */
-/* Slot 99 is reserved */
-/* Slot 100 is reserved */
-/* Slot 101 is reserved */
-/* Slot 102 is reserved */
-/* Slot 103 is reserved */
-/* Slot 104 is reserved */
-/* Slot 105 is reserved */
+#define XTranslateCoordinates \
+ (tkIntXlibStubsPtr->xTranslateCoordinates) /* 92 */
+#define XDeleteProperty \
+ (tkIntXlibStubsPtr->xDeleteProperty) /* 93 */
+#define XFreeCursor \
+ (tkIntXlibStubsPtr->xFreeCursor) /* 94 */
+#define XGetInputFocus \
+ (tkIntXlibStubsPtr->xGetInputFocus) /* 95 */
+#define XmbLookupString \
+ (tkIntXlibStubsPtr->xmbLookupString) /* 96 */
+#define XNextEvent \
+ (tkIntXlibStubsPtr->xNextEvent) /* 97 */
+#define XPutBackEvent \
+ (tkIntXlibStubsPtr->xPutBackEvent) /* 98 */
+#define XSetCommand \
+ (tkIntXlibStubsPtr->xSetCommand) /* 99 */
+#define XWindowEvent \
+ (tkIntXlibStubsPtr->xWindowEvent) /* 100 */
+#define XGetWindowAttributes \
+ (tkIntXlibStubsPtr->xGetWindowAttributes) /* 101 */
+#define XGetWMColormapWindows \
+ (tkIntXlibStubsPtr->xGetWMColormapWindows) /* 102 */
+#define XIconifyWindow \
+ (tkIntXlibStubsPtr->xIconifyWindow) /* 103 */
+#define XWithdrawWindow \
+ (tkIntXlibStubsPtr->xWithdrawWindow) /* 104 */
+#define XListHosts \
+ (tkIntXlibStubsPtr->xListHosts) /* 105 */
#define XSetClipRectangles \
(tkIntXlibStubsPtr->xSetClipRectangles) /* 106 */
#define XFlush \
@@ -1638,7 +1773,8 @@ extern const TkIntXlibStubs *tkIntXlibStubsPtr;
(tkIntXlibStubsPtr->xNoOp) /* 111 */
#define XSynchronize \
(tkIntXlibStubsPtr->xSynchronize) /* 112 */
-/* Slot 113 is reserved */
+#define XLookupColor \
+ (tkIntXlibStubsPtr->xLookupColor) /* 113 */
#define XVisualIDFromVisual \
(tkIntXlibStubsPtr->xVisualIDFromVisual) /* 114 */
/* Slot 115 is reserved */
@@ -1648,8 +1784,10 @@ extern const TkIntXlibStubs *tkIntXlibStubsPtr;
/* Slot 119 is reserved */
#define XOffsetRegion \
(tkIntXlibStubsPtr->xOffsetRegion) /* 120 */
-/* Slot 121 is reserved */
-/* Slot 122 is reserved */
+#define XUnionRegion \
+ (tkIntXlibStubsPtr->xUnionRegion) /* 121 */
+#define XCreateWindow \
+ (tkIntXlibStubsPtr->xCreateWindow) /* 122 */
/* Slot 123 is reserved */
/* Slot 124 is reserved */
/* Slot 125 is reserved */
@@ -1658,50 +1796,72 @@ extern const TkIntXlibStubs *tkIntXlibStubsPtr;
/* Slot 128 is reserved */
#define XLowerWindow \
(tkIntXlibStubsPtr->xLowerWindow) /* 129 */
-/* Slot 130 is reserved */
-/* Slot 131 is reserved */
-/* Slot 132 is reserved */
+#define XFillArcs \
+ (tkIntXlibStubsPtr->xFillArcs) /* 130 */
+#define XDrawArcs \
+ (tkIntXlibStubsPtr->xDrawArcs) /* 131 */
+#define XDrawRectangles \
+ (tkIntXlibStubsPtr->xDrawRectangles) /* 132 */
/* Slot 133 is reserved */
/* Slot 134 is reserved */
/* Slot 135 is reserved */
-/* Slot 136 is reserved */
+#define XReparentWindow \
+ (tkIntXlibStubsPtr->xReparentWindow) /* 136 */
#define XPutImage \
(tkIntXlibStubsPtr->xPutImage) /* 137 */
-/* Slot 138 is reserved */
-/* Slot 139 is reserved */
-/* Slot 140 is reserved */
-/* Slot 141 is reserved */
-/* Slot 142 is reserved */
-/* Slot 143 is reserved */
+#define XPolygonRegion \
+ (tkIntXlibStubsPtr->xPolygonRegion) /* 138 */
+#define XPointInRegion \
+ (tkIntXlibStubsPtr->xPointInRegion) /* 139 */
+#define XVaCreateNestedList \
+ (tkIntXlibStubsPtr->xVaCreateNestedList) /* 140 */
+#define XSetICValues \
+ (tkIntXlibStubsPtr->xSetICValues) /* 141 */
+#define XGetICValues \
+ (tkIntXlibStubsPtr->xGetICValues) /* 142 */
+#define XSetICFocus \
+ (tkIntXlibStubsPtr->xSetICFocus) /* 143 */
#define XDestroyIC \
(tkIntXlibStubsPtr->xDestroyIC) /* 144 */
#define XCreatePixmapCursor \
(tkIntXlibStubsPtr->xCreatePixmapCursor) /* 145 */
#define XCreateGlyphCursor \
(tkIntXlibStubsPtr->xCreateGlyphCursor) /* 146 */
-/* Slot 147 is reserved */
-/* Slot 148 is reserved */
-/* Slot 149 is reserved */
-/* Slot 150 is reserved */
-/* Slot 151 is reserved */
-/* Slot 152 is reserved */
-/* Slot 153 is reserved */
-/* Slot 154 is reserved */
-/* Slot 155 is reserved */
-/* Slot 156 is reserved */
+#define XFreeFontSet \
+ (tkIntXlibStubsPtr->xFreeFontSet) /* 147 */
+#define XCloseIM \
+ (tkIntXlibStubsPtr->xCloseIM) /* 148 */
+#define XRegisterIMInstantiateCallback \
+ (tkIntXlibStubsPtr->xRegisterIMInstantiateCallback) /* 149 */
+#define XUnregisterIMInstantiateCallback \
+ (tkIntXlibStubsPtr->xUnregisterIMInstantiateCallback) /* 150 */
+#define XSetLocaleModifiers \
+ (tkIntXlibStubsPtr->xSetLocaleModifiers) /* 151 */
+#define XOpenIM \
+ (tkIntXlibStubsPtr->xOpenIM) /* 152 */
+#define XGetIMValues \
+ (tkIntXlibStubsPtr->xGetIMValues) /* 153 */
+#define XSetIMValues \
+ (tkIntXlibStubsPtr->xSetIMValues) /* 154 */
+#define XCreateFontSet \
+ (tkIntXlibStubsPtr->xCreateFontSet) /* 155 */
+#define XFreeStringList \
+ (tkIntXlibStubsPtr->xFreeStringList) /* 156 */
#define XkbKeycodeToKeysym \
(tkIntXlibStubsPtr->xkbKeycodeToKeysym) /* 157 */
-#define TkUnusedStubEntry \
- (tkIntXlibStubsPtr->tkUnusedStubEntry) /* 158 */
-#endif /* AQUA */
+#define XkbOpenDisplay \
+ (tkIntXlibStubsPtr->xkbOpenDisplay) /* 158 */
+#endif /* MACOSX */
#endif /* defined(USE_TK_STUBS) */
/* !END!: Do not edit above this line. */
+#if !defined(_WIN32) && !defined(__CYGWIN__) && !defined(MAC_OSX_TCL) /* X11, Except MacOS/Cygwin */
+EXTERN Display *XkbOpenDisplay(const char *, int *, int *, int *, int *, int *);
+#endif
+
#undef TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS DLLIMPORT
-#undef TkUnusedStubEntry
-
#endif /* _TKINTXLIBDECLS */
diff --git a/generic/tkListbox.c b/generic/tkListbox.c
index f97a9c8..4e4fa23 100644
--- a/generic/tkListbox.c
+++ b/generic/tkListbox.c
@@ -5,15 +5,15 @@
* 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.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 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.
*/
-#include "default.h"
#include "tkInt.h"
+#include "default.h"
#ifdef _WIN32
#include "tkWinInt.h"
@@ -50,7 +50,7 @@ typedef struct {
* available for listbox items. */
char *listVarName; /* List variable name */
Tcl_Obj *listObj; /* Pointer to the list object being used */
- int nElements; /* Holds the current count of elements */
+ Tcl_Size nElements; /* Holds the current count of elements */
Tcl_HashTable *selection; /* Tracks selection */
Tcl_HashTable *itemAttrTable;
/* Tracks item attributes */
@@ -115,7 +115,7 @@ typedef struct {
* is offset to the left by this many pixels
* (0 means no offset, positive means there is
* an offset). This is x scrolling information
- * is not linked to justification. */
+ * is not linked to justification. */
/*
* Information about what's selected or active, if any.
@@ -235,80 +235,80 @@ static const char *const activeStyleStrings[] = {
static const Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_STRING_TABLE, "-activestyle", "activeStyle", "ActiveStyle",
- DEF_LISTBOX_ACTIVE_STYLE, -1, Tk_Offset(Listbox, activeStyle),
+ DEF_LISTBOX_ACTIVE_STYLE, TCL_INDEX_NONE, offsetof(Listbox, activeStyle),
0, activeStyleStrings, 0},
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_LISTBOX_BG_COLOR, -1, Tk_Offset(Listbox, normalBorder),
+ DEF_LISTBOX_BG_COLOR, TCL_INDEX_NONE, offsetof(Listbox, normalBorder),
0, DEF_LISTBOX_BG_MONO, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL,
- NULL, 0, -1, 0, "-background", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_LISTBOX_BORDER_WIDTH, -1, Tk_Offset(Listbox, borderWidth),
+ DEF_LISTBOX_BORDER_WIDTH, TCL_INDEX_NONE, offsetof(Listbox, borderWidth),
0, 0, 0},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_LISTBOX_CURSOR, -1, Tk_Offset(Listbox, cursor),
+ DEF_LISTBOX_CURSOR, TCL_INDEX_NONE, offsetof(Listbox, cursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_COLOR, "-disabledforeground", "disabledForeground",
- "DisabledForeground", DEF_LISTBOX_DISABLED_FG, -1,
- Tk_Offset(Listbox, dfgColorPtr), TK_OPTION_NULL_OK, 0, 0},
+ "DisabledForeground", DEF_LISTBOX_DISABLED_FG, TCL_INDEX_NONE,
+ offsetof(Listbox, dfgColorPtr), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_BOOLEAN, "-exportselection", "exportSelection",
- "ExportSelection", DEF_LISTBOX_EXPORT_SELECTION, -1,
- Tk_Offset(Listbox, exportSelection), 0, 0, 0},
+ "ExportSelection", DEF_LISTBOX_EXPORT_SELECTION, TCL_INDEX_NONE,
+ offsetof(Listbox, exportSelection), 0, 0, 0},
{TK_OPTION_SYNONYM, "-fg", "foreground", NULL,
- NULL, 0, -1, 0, "-foreground", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_LISTBOX_FONT, -1, Tk_Offset(Listbox, tkfont), 0, 0, 0},
+ DEF_LISTBOX_FONT, TCL_INDEX_NONE, offsetof(Listbox, tkfont), 0, 0, 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_LISTBOX_FG, -1, Tk_Offset(Listbox, fgColorPtr), 0, 0, 0},
+ DEF_LISTBOX_FG, TCL_INDEX_NONE, offsetof(Listbox, fgColorPtr), 0, 0, 0},
{TK_OPTION_INT, "-height", "height", "Height",
- DEF_LISTBOX_HEIGHT, -1, Tk_Offset(Listbox, height), 0, 0, 0},
+ DEF_LISTBOX_HEIGHT, TCL_INDEX_NONE, offsetof(Listbox, height), 0, 0, 0},
{TK_OPTION_COLOR, "-highlightbackground", "highlightBackground",
- "HighlightBackground", DEF_LISTBOX_HIGHLIGHT_BG, -1,
- Tk_Offset(Listbox, highlightBgColorPtr), 0, 0, 0},
+ "HighlightBackground", DEF_LISTBOX_HIGHLIGHT_BG, TCL_INDEX_NONE,
+ offsetof(Listbox, highlightBgColorPtr), 0, 0, 0},
{TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_LISTBOX_HIGHLIGHT, -1, Tk_Offset(Listbox, highlightColorPtr),
+ DEF_LISTBOX_HIGHLIGHT, TCL_INDEX_NONE, offsetof(Listbox, highlightColorPtr),
0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
- "HighlightThickness", DEF_LISTBOX_HIGHLIGHT_WIDTH, -1,
- Tk_Offset(Listbox, highlightWidth), 0, 0, 0},
+ "HighlightThickness", DEF_LISTBOX_HIGHLIGHT_WIDTH, TCL_INDEX_NONE,
+ offsetof(Listbox, highlightWidth), 0, 0, 0},
{TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
- DEF_LISTBOX_JUSTIFY, -1, Tk_Offset(Listbox, justify), 0, 0, 0},
+ DEF_LISTBOX_JUSTIFY, TCL_INDEX_NONE, offsetof(Listbox, justify), TK_OPTION_ENUM_VAR, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_LISTBOX_RELIEF, -1, Tk_Offset(Listbox, relief), 0, 0, 0},
+ DEF_LISTBOX_RELIEF, TCL_INDEX_NONE, offsetof(Listbox, relief), 0, 0, 0},
{TK_OPTION_BORDER, "-selectbackground", "selectBackground", "Foreground",
- DEF_LISTBOX_SELECT_COLOR, -1, Tk_Offset(Listbox, selBorder),
+ DEF_LISTBOX_SELECT_COLOR, TCL_INDEX_NONE, offsetof(Listbox, selBorder),
0, DEF_LISTBOX_SELECT_MONO, 0},
{TK_OPTION_PIXELS, "-selectborderwidth", "selectBorderWidth",
- "BorderWidth", DEF_LISTBOX_SELECT_BD, -1,
- Tk_Offset(Listbox, selBorderWidth), 0, 0, 0},
+ "BorderWidth", DEF_LISTBOX_SELECT_BD, TCL_INDEX_NONE,
+ offsetof(Listbox, selBorderWidth), 0, 0, 0},
{TK_OPTION_COLOR, "-selectforeground", "selectForeground", "Background",
- DEF_LISTBOX_SELECT_FG_COLOR, -1, Tk_Offset(Listbox, selFgColorPtr),
+ DEF_LISTBOX_SELECT_FG_COLOR, TCL_INDEX_NONE, offsetof(Listbox, selFgColorPtr),
TK_OPTION_NULL_OK, DEF_LISTBOX_SELECT_FG_MONO, 0},
{TK_OPTION_STRING, "-selectmode", "selectMode", "SelectMode",
- DEF_LISTBOX_SELECT_MODE, -1, Tk_Offset(Listbox, selectMode),
+ DEF_LISTBOX_SELECT_MODE, TCL_INDEX_NONE, offsetof(Listbox, selectMode),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_BOOLEAN, "-setgrid", "setGrid", "SetGrid",
- DEF_LISTBOX_SET_GRID, -1, Tk_Offset(Listbox, setGrid), 0, 0, 0},
+ DEF_LISTBOX_SET_GRID, TCL_INDEX_NONE, offsetof(Listbox, setGrid), 0, 0, 0},
{TK_OPTION_STRING_TABLE, "-state", "state", "State",
- DEF_LISTBOX_STATE, -1, Tk_Offset(Listbox, state),
+ DEF_LISTBOX_STATE, TCL_INDEX_NONE, offsetof(Listbox, state),
0, &tkStateStrings[1], 0},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_LISTBOX_TAKE_FOCUS, -1, Tk_Offset(Listbox, takeFocus),
+ DEF_LISTBOX_TAKE_FOCUS, TCL_INDEX_NONE, offsetof(Listbox, takeFocus),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_INT, "-width", "width", "Width",
- DEF_LISTBOX_WIDTH, -1, Tk_Offset(Listbox, width), 0, 0, 0},
+ DEF_LISTBOX_WIDTH, TCL_INDEX_NONE, offsetof(Listbox, width), 0, 0, 0},
{TK_OPTION_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand",
- DEF_LISTBOX_SCROLL_COMMAND, -1, Tk_Offset(Listbox, xScrollCmd),
+ DEF_LISTBOX_SCROLL_COMMAND, TCL_INDEX_NONE, offsetof(Listbox, xScrollCmd),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-yscrollcommand", "yScrollCommand", "ScrollCommand",
- DEF_LISTBOX_SCROLL_COMMAND, -1, Tk_Offset(Listbox, yScrollCmd),
+ DEF_LISTBOX_SCROLL_COMMAND, TCL_INDEX_NONE, offsetof(Listbox, yScrollCmd),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-listvariable", "listVariable", "Variable",
- DEF_LISTBOX_LIST_VARIABLE, -1, Tk_Offset(Listbox, listVarName),
+ DEF_LISTBOX_LIST_VARIABLE, TCL_INDEX_NONE, offsetof(Listbox, listVarName),
TK_OPTION_NULL_OK, 0, 0},
- {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0}
+ {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0}
};
/*
@@ -318,22 +318,22 @@ static const Tk_OptionSpec optionSpecs[] = {
static const Tk_OptionSpec itemAttrOptionSpecs[] = {
{TK_OPTION_BORDER, "-background", NULL, NULL,
- NULL, -1, Tk_Offset(ItemAttr, border),
+ NULL, TCL_INDEX_NONE, offsetof(ItemAttr, border),
TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL,
- NULL, 0, -1, 0, "-background", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_SYNONYM, "-fg", "foreground", NULL,
- NULL, 0, -1, 0, "-foreground", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
{TK_OPTION_COLOR, "-foreground", NULL, NULL,
- NULL, -1, Tk_Offset(ItemAttr, fgColor),
+ NULL, TCL_INDEX_NONE, offsetof(ItemAttr, fgColor),
TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_BORDER, "-selectbackground", NULL, NULL,
- NULL, -1, Tk_Offset(ItemAttr, selBorder),
+ NULL, TCL_INDEX_NONE, offsetof(ItemAttr, selBorder),
TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_COLOR, "-selectforeground", NULL, NULL,
- NULL, -1, Tk_Offset(ItemAttr, selFgColor),
+ NULL, TCL_INDEX_NONE, offsetof(ItemAttr, selFgColor),
TK_OPTION_NULL_OK, NULL, 0},
- {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, NULL, 0}
+ {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, NULL, 0}
};
/*
@@ -363,17 +363,17 @@ enum selcommand {
};
static const char *const scanCommandNames[] = {
- "mark", "dragto", NULL
+ "dragto", "mark", NULL
};
enum scancommand {
- SCAN_MARK, SCAN_DRAGTO
+ SCAN_DRAGTO, SCAN_MARK
};
static const char *const indexNames[] = {
- "active", "anchor", "end", NULL
+ "active", "anchor", NULL
};
enum indices {
- INDEX_ACTIVE, INDEX_ANCHOR, INDEX_END
+ INDEX_ACTIVE, INDEX_ANCHOR
};
/*
@@ -383,56 +383,54 @@ enum indices {
static void ChangeListboxOffset(Listbox *listPtr, int offset);
static void ChangeListboxView(Listbox *listPtr, int index);
static int ConfigureListbox(Tcl_Interp *interp, Listbox *listPtr,
- int objc, Tcl_Obj *const objv[]);
+ Tcl_Size objc, Tcl_Obj *const objv[]);
static int ConfigureListboxItem(Tcl_Interp *interp,
- Listbox *listPtr, ItemAttr *attrs, int objc,
- Tcl_Obj *const objv[], int index);
+ Listbox *listPtr, ItemAttr *attrs, Tcl_Size objc,
+ Tcl_Obj *const objv[], Tcl_Size index);
static int ListboxDeleteSubCmd(Listbox *listPtr,
int first, int last);
static Tcl_FreeProc DestroyListbox;
-static void DestroyListboxOptionTables(ClientData clientData,
+static void DestroyListboxOptionTables(void *clientData,
Tcl_Interp *interp);
-static void DisplayListbox(ClientData clientData);
+static void DisplayListbox(void *clientData);
static int GetListboxIndex(Tcl_Interp *interp, Listbox *listPtr,
- Tcl_Obj *index, int endIsSize, int *indexPtr);
+ Tcl_Obj *index, int endIsSize, Tcl_Size *indexPtr);
static int ListboxInsertSubCmd(Listbox *listPtr,
- int index, int objc, Tcl_Obj *const objv[]);
-static void ListboxCmdDeletedProc(ClientData clientData);
+ Tcl_Size index, Tcl_Size objc, Tcl_Obj *const objv[]);
+static void ListboxCmdDeletedProc(void *clientData);
static void ListboxComputeGeometry(Listbox *listPtr,
int fontChanged, int maxIsStale, int updateGrid);
-static void ListboxEventProc(ClientData clientData,
+static void ListboxEventProc(void *clientData,
XEvent *eventPtr);
-static int ListboxFetchSelection(ClientData clientData,
- int offset, char *buffer, int maxBytes);
-static void ListboxLostSelection(ClientData clientData);
+static Tcl_Size ListboxFetchSelection(void *clientData,
+ Tcl_Size offset, char *buffer, Tcl_Size maxBytes);
+static void ListboxLostSelection(void *clientData);
static void GenerateListboxSelectEvent(Listbox *listPtr);
static void EventuallyRedrawRange(Listbox *listPtr,
- int first, int last);
+ Tcl_Size first, Tcl_Size last);
static void ListboxScanTo(Listbox *listPtr, int x, int y);
static int ListboxSelect(Listbox *listPtr,
int first, int last, int select);
static void ListboxUpdateHScrollbar(Listbox *listPtr);
static void ListboxUpdateVScrollbar(Listbox *listPtr);
-static int ListboxWidgetObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
+static Tcl_ObjCmdProc ListboxWidgetObjCmd;
static int ListboxBboxSubCmd(Tcl_Interp *interp,
Listbox *listPtr, int index);
static int ListboxSelectionSubCmd(Tcl_Interp *interp,
- Listbox *listPtr, int objc, Tcl_Obj *const objv[]);
+ Listbox *listPtr, Tcl_Size objc, Tcl_Obj *const objv[]);
static int ListboxXviewSubCmd(Tcl_Interp *interp,
- Listbox *listPtr, int objc, Tcl_Obj *const objv[]);
+ Listbox *listPtr, Tcl_Size objc, Tcl_Obj *const objv[]);
static int ListboxYviewSubCmd(Tcl_Interp *interp,
- Listbox *listPtr, int objc, Tcl_Obj *const objv[]);
+ Listbox *listPtr, Tcl_Size objc, Tcl_Obj *const objv[]);
static ItemAttr * ListboxGetItemAttributes(Tcl_Interp *interp,
Listbox *listPtr, int index);
-static void ListboxWorldChanged(ClientData instanceData);
+static void ListboxWorldChanged(void *instanceData);
static int NearestListboxElement(Listbox *listPtr, int y);
-static char * ListboxListVarProc(ClientData clientData,
+static char * ListboxListVarProc(void *clientData,
Tcl_Interp *interp, const char *name1,
const char *name2, int flags);
static void MigrateHashEntries(Tcl_HashTable *table,
- int first, int last, int offset);
+ Tcl_Size first, Tcl_Size last, Tcl_Size offset);
static int GetMaxOffset(Listbox *listPtr);
/*
@@ -466,7 +464,7 @@ static const Tk_ClassProcs listboxClass = {
int
Tk_ListboxObjCmd(
- ClientData clientData, /* NULL. */
+ TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -486,15 +484,15 @@ Tk_ListboxObjCmd(
return TCL_ERROR;
}
- optionTables = Tcl_GetAssocData(interp, "ListboxOptionTables", NULL);
+ optionTables = (ListboxOptionTables *)Tcl_GetAssocData(interp, "ListboxOptionTables", NULL);
if (optionTables == NULL) {
/*
* We haven't created the option tables for this widget class yet. Do
- * it now and save the a pointer to them as the ClientData for the
+ * it now and save the a pointer to them as the void *for the
* command, so future invocations will have access to it.
*/
- optionTables = ckalloc(sizeof(ListboxOptionTables));
+ optionTables = (ListboxOptionTables *)ckalloc(sizeof(ListboxOptionTables));
/*
* Set up an exit handler to free the optionTables struct.
@@ -519,7 +517,7 @@ Tk_ListboxObjCmd(
* already (e.g. resource pointers).
*/
- listPtr = ckalloc(sizeof(Listbox));
+ listPtr = (Listbox *)ckalloc(sizeof(Listbox));
memset(listPtr, 0, sizeof(Listbox));
listPtr->tkwin = tkwin;
@@ -530,9 +528,9 @@ Tk_ListboxObjCmd(
ListboxCmdDeletedProc);
listPtr->optionTable = optionTables->listboxOptionTable;
listPtr->itemAttrOptionTable = optionTables->itemAttrOptionTable;
- listPtr->selection = ckalloc(sizeof(Tcl_HashTable));
+ listPtr->selection = (Tcl_HashTable *)ckalloc(sizeof(Tcl_HashTable));
Tcl_InitHashTable(listPtr->selection, TCL_ONE_WORD_KEYS);
- listPtr->itemAttrTable = ckalloc(sizeof(Tcl_HashTable));
+ listPtr->itemAttrTable = (Tcl_HashTable *)ckalloc(sizeof(Tcl_HashTable));
Tcl_InitHashTable(listPtr->itemAttrTable, TCL_ONE_WORD_KEYS);
listPtr->relief = TK_RELIEF_RAISED;
listPtr->textGC = NULL;
@@ -560,7 +558,7 @@ Tk_ListboxObjCmd(
ListboxEventProc, listPtr);
Tk_CreateSelHandler(listPtr->tkwin, XA_PRIMARY, XA_STRING,
ListboxFetchSelection, listPtr, XA_STRING);
- if (Tk_InitOptions(interp, (char *)listPtr,
+ if (Tk_InitOptions(interp, listPtr,
optionTables->listboxOptionTable, tkwin) != TCL_OK) {
Tk_DestroyWindow(listPtr->tkwin);
return TCL_ERROR;
@@ -571,7 +569,7 @@ Tk_ListboxObjCmd(
return TCL_ERROR;
}
- Tcl_SetObjResult(interp, TkNewWindowObj(listPtr->tkwin));
+ Tcl_SetObjResult(interp, Tk_NewWindowObj(listPtr->tkwin));
return TCL_OK;
}
@@ -595,13 +593,14 @@ Tk_ListboxObjCmd(
static int
ListboxWidgetObjCmd(
- ClientData clientData, /* Information about listbox widget. */
+ void *clientData, /* Information about listbox widget. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Arguments as Tcl_Obj's. */
{
- Listbox *listPtr = clientData;
- int cmdIndex, index;
+ Listbox *listPtr = (Listbox *)clientData;
+ int cmdIndex;
+ Tcl_Size index;
int result = TCL_OK;
Tcl_Obj *objPtr;
@@ -675,7 +674,7 @@ ListboxWidgetObjCmd(
break;
}
- objPtr = Tk_GetOptionValue(interp, (char *) listPtr,
+ objPtr = Tk_GetOptionValue(interp, listPtr,
listPtr->optionTable, objv[2], listPtr->tkwin);
if (objPtr == NULL) {
result = TCL_ERROR;
@@ -687,7 +686,7 @@ ListboxWidgetObjCmd(
case COMMAND_CONFIGURE:
if (objc <= 3) {
- objPtr = Tk_GetOptionInfo(interp, (char *) listPtr,
+ objPtr = Tk_GetOptionInfo(interp, listPtr,
listPtr->optionTable,
(objc == 3) ? objv[2] : NULL, listPtr->tkwin);
if (objPtr == NULL) {
@@ -719,9 +718,9 @@ ListboxWidgetObjCmd(
*/
objPtr = Tcl_NewObj();
- for (i = 0; i < listPtr->nElements; i++) {
+ for (i = 0; i < (int)listPtr->nElements; i++) {
if (Tcl_FindHashEntry(listPtr->selection, KEY(i))) {
- Tcl_ListObjAppendElement(NULL, objPtr, Tcl_NewIntObj(i));
+ Tcl_ListObjAppendElement(NULL, objPtr, Tcl_NewWideIntObj(i));
}
}
Tcl_SetObjResult(interp, objPtr);
@@ -730,7 +729,7 @@ ListboxWidgetObjCmd(
}
case COMMAND_DELETE: {
- int first, last;
+ Tcl_Size first, last;
if ((objc < 3) || (objc > 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "firstIndex ?lastIndex?");
@@ -747,7 +746,7 @@ ListboxWidgetObjCmd(
break;
}
- if (first < listPtr->nElements) {
+ if (first < (int)listPtr->nElements) {
/*
* if a "last index" was given, get it now; otherwise, use the
* first index as the last index.
@@ -761,7 +760,7 @@ ListboxWidgetObjCmd(
} else {
last = first;
}
- if (last >= listPtr->nElements) {
+ if (last >= (int)listPtr->nElements) {
last = listPtr->nElements - 1;
}
result = ListboxDeleteSubCmd(listPtr, first, last);
@@ -772,7 +771,7 @@ ListboxWidgetObjCmd(
}
case COMMAND_GET: {
- int first, last, listLen;
+ Tcl_Size listLen, first, last;
Tcl_Obj **elemPtrs;
if (objc != 3 && objc != 4) {
@@ -791,11 +790,11 @@ ListboxWidgetObjCmd(
break;
}
}
- if (first >= listPtr->nElements) {
+ if (first >= (int)listPtr->nElements) {
result = TCL_OK;
break;
}
- if (last >= listPtr->nElements) {
+ if (last >= (int)listPtr->nElements) {
last = listPtr->nElements - 1;
}
if (first < 0) {
@@ -834,7 +833,7 @@ ListboxWidgetObjCmd(
if (result != TCL_OK) {
break;
}
- Tcl_SetObjResult(interp, Tcl_NewIntObj(index));
+ Tcl_SetObjResult(interp, TkNewIndexObj(index));
result = TCL_OK;
break;
@@ -871,11 +870,11 @@ ListboxWidgetObjCmd(
break;
}
- if (index < 0 || index >= listPtr->nElements) {
+ if (index < 0 || index >= (int)listPtr->nElements) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"item number \"%s\" out of range",
Tcl_GetString(objv[2])));
- Tcl_SetErrorCode(interp, "TK", "LISTBOX", "ITEM_INDEX", NULL);
+ Tcl_SetErrorCode(interp, "TK", "LISTBOX", "ITEM_INDEX", (char *)NULL);
result = TCL_ERROR;
break;
}
@@ -898,7 +897,7 @@ ListboxWidgetObjCmd(
if (objc < 3) {
Tcl_WrongNumArgs(interp, 2, objv,
- "index ?-option? ?value? ?-option value ...?");
+ "index ?-option value ...?");
result = TCL_ERROR;
break;
}
@@ -908,18 +907,18 @@ ListboxWidgetObjCmd(
break;
}
- if (index < 0 || index >= listPtr->nElements) {
+ if (index < 0 || index >= (int)listPtr->nElements) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"item number \"%s\" out of range",
Tcl_GetString(objv[2])));
- Tcl_SetErrorCode(interp, "TK", "LISTBOX", "ITEM_INDEX", NULL);
+ Tcl_SetErrorCode(interp, "TK", "LISTBOX", "ITEM_INDEX", (char *)NULL);
result = TCL_ERROR;
break;
}
attrPtr = ListboxGetItemAttributes(interp, listPtr, index);
if (objc <= 4) {
- objPtr = Tk_GetOptionInfo(interp, (char *) attrPtr,
+ objPtr = Tk_GetOptionInfo(interp, attrPtr,
listPtr->itemAttrOptionTable,
(objc == 4) ? objv[3] : NULL, listPtr->tkwin);
if (objPtr == NULL) {
@@ -949,7 +948,7 @@ ListboxWidgetObjCmd(
break;
}
index = NearestListboxElement(listPtr, y);
- Tcl_SetObjResult(interp, Tcl_NewIntObj(index));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(index));
result = TCL_OK;
break;
}
@@ -1001,7 +1000,7 @@ ListboxWidgetObjCmd(
if (result != TCL_OK) {
break;
}
- if (index >= listPtr->nElements) {
+ if (index >= (int)listPtr->nElements) {
index = listPtr->nElements - 1;
}
if (index < 0) {
@@ -1037,7 +1036,7 @@ ListboxWidgetObjCmd(
result = TCL_ERROR;
break;
}
- Tcl_SetObjResult(interp, Tcl_NewIntObj(listPtr->nElements));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(listPtr->nElements));
result = TCL_OK;
break;
case COMMAND_XVIEW:
@@ -1084,7 +1083,7 @@ ListboxBboxSubCmd(
lastVisibleIndex = listPtr->topIndex + listPtr->fullLines
+ listPtr->partialLine;
- if (listPtr->nElements < lastVisibleIndex) {
+ if ((int)listPtr->nElements < lastVisibleIndex) {
lastVisibleIndex = listPtr->nElements;
}
@@ -1095,7 +1094,8 @@ ListboxBboxSubCmd(
if ((listPtr->topIndex <= index) && (index < lastVisibleIndex)) {
Tcl_Obj *el, *results[4];
const char *stringRep;
- int pixelWidth, stringLen, x, y, result;
+ int pixelWidth, x, y, result;
+ Tcl_Size stringLen;
Tk_FontMetrics fm;
/*
@@ -1111,21 +1111,21 @@ ListboxBboxSubCmd(
Tk_GetFontMetrics(listPtr->tkfont, &fm);
pixelWidth = Tk_TextWidth(listPtr->tkfont, stringRep, stringLen);
- if (listPtr->justify == TK_JUSTIFY_LEFT) {
- x = (listPtr->inset + listPtr->selBorderWidth) - listPtr->xOffset;
- } else if (listPtr->justify == TK_JUSTIFY_RIGHT) {
- x = Tk_Width(tkwin) - (listPtr->inset + listPtr->selBorderWidth)
- - pixelWidth - listPtr->xOffset + GetMaxOffset(listPtr);
- } else {
- x = (Tk_Width(tkwin) - pixelWidth)/2
- - listPtr->xOffset + GetMaxOffset(listPtr)/2;
- }
+ if (listPtr->justify == TK_JUSTIFY_LEFT) {
+ x = (listPtr->inset + listPtr->selBorderWidth) - listPtr->xOffset;
+ } else if (listPtr->justify == TK_JUSTIFY_RIGHT) {
+ x = Tk_Width(tkwin) - (listPtr->inset + listPtr->selBorderWidth)
+ - pixelWidth - listPtr->xOffset + GetMaxOffset(listPtr);
+ } else {
+ x = (Tk_Width(tkwin) - pixelWidth)/2
+ - listPtr->xOffset + GetMaxOffset(listPtr)/2;
+ }
y = ((index - listPtr->topIndex)*listPtr->lineHeight)
+ listPtr->inset + listPtr->selBorderWidth;
- results[0] = Tcl_NewIntObj(x);
- results[1] = Tcl_NewIntObj(y);
- results[2] = Tcl_NewIntObj(pixelWidth);
- results[3] = Tcl_NewIntObj(fm.linespace);
+ results[0] = Tcl_NewWideIntObj(x);
+ results[1] = Tcl_NewWideIntObj(y);
+ results[2] = Tcl_NewWideIntObj(pixelWidth);
+ results[3] = Tcl_NewWideIntObj(fm.linespace);
Tcl_SetObjResult(interp, Tcl_NewListObj(4, results));
}
return TCL_OK;
@@ -1152,10 +1152,11 @@ static int
ListboxSelectionSubCmd(
Tcl_Interp *interp, /* Pointer to the calling Tcl interpreter */
Listbox *listPtr, /* Information about the listbox */
- int objc, /* Number of arguments in the objv array */
+ Tcl_Size objc, /* Number of arguments in the objv array */
Tcl_Obj *const objv[]) /* Array of arguments to the procedure */
{
- int selCmdIndex, first, last;
+ int selCmdIndex;
+ Tcl_Size first, last;
int result = TCL_OK;
if (objc != 4 && objc != 5) {
@@ -1194,7 +1195,7 @@ ListboxSelectionSubCmd(
Tcl_WrongNumArgs(interp, 3, objv, "index");
return TCL_ERROR;
}
- if (first >= listPtr->nElements) {
+ if (first >= (int)listPtr->nElements) {
first = listPtr->nElements - 1;
}
if (first < 0) {
@@ -1242,7 +1243,7 @@ static int
ListboxXviewSubCmd(
Tcl_Interp *interp, /* Pointer to the calling Tcl interpreter */
Listbox *listPtr, /* Information about the listbox */
- int objc, /* Number of arguments in the objv array */
+ Tcl_Size objc, /* Number of arguments in the objv array */
Tcl_Obj *const objv[]) /* Array of arguments to the procedure */
{
int index, count, windowWidth, windowUnits;
@@ -1320,10 +1321,11 @@ static int
ListboxYviewSubCmd(
Tcl_Interp *interp, /* Pointer to the calling Tcl interpreter */
Listbox *listPtr, /* Information about the listbox */
- int objc, /* Number of arguments in the objv array */
+ Tcl_Size objc, /* Number of arguments in the objv array */
Tcl_Obj *const objv[]) /* Array of arguments to the procedure */
{
- int index, count;
+ Tcl_Size index;
+ int count;
double fraction;
if (objc == 2) {
@@ -1352,7 +1354,7 @@ ListboxYviewSubCmd(
} else {
switch (Tk_GetScrollInfoObj(interp, objc, objv, &fraction, &count)) {
case TK_SCROLL_MOVETO:
- index = (int) (listPtr->nElements*fraction + 0.5);
+ index = (Tcl_Size)(listPtr->nElements*fraction + 0.5);
break;
case TK_SCROLL_PAGES:
if (listPtr->fullLines > 2) {
@@ -1402,16 +1404,16 @@ ListboxGetItemAttributes(
entry = Tcl_CreateHashEntry(listPtr->itemAttrTable, KEY(index), &isNew);
if (isNew) {
- attrs = ckalloc(sizeof(ItemAttr));
+ attrs = (ItemAttr *)ckalloc(sizeof(ItemAttr));
attrs->border = NULL;
attrs->selBorder = NULL;
attrs->fgColor = NULL;
attrs->selFgColor = NULL;
- Tk_InitOptions(interp, (char *)attrs, listPtr->itemAttrOptionTable,
+ Tk_InitOptions(interp, attrs, listPtr->itemAttrOptionTable,
listPtr->tkwin);
Tcl_SetHashValue(entry, attrs);
} else {
- attrs = Tcl_GetHashValue(entry);
+ attrs = (ItemAttr *)Tcl_GetHashValue(entry);
}
return attrs;
}
@@ -1436,7 +1438,11 @@ ListboxGetItemAttributes(
static void
DestroyListbox(
- char *memPtr) /* Info about listbox widget. */
+#if TCL_MAJOR_VERSION > 8
+ void *memPtr) /* Info about listbox widget. */
+#else
+ char *memPtr)
+#endif
{
Listbox *listPtr = (Listbox *)memPtr;
Tcl_HashEntry *entry;
@@ -1490,7 +1496,7 @@ DestroyListbox(
Tk_FreeBitmap(Tk_Display(listPtr->tkwin), listPtr->gray);
}
- Tk_FreeConfigOptions((char *) listPtr, listPtr->optionTable,
+ Tk_FreeConfigOptions(listPtr, listPtr->optionTable,
listPtr->tkwin);
Tcl_Release(listPtr->tkwin);
listPtr->tkwin = NULL;
@@ -1517,8 +1523,8 @@ DestroyListbox(
static void
DestroyListboxOptionTables(
- ClientData clientData, /* Pointer to the OptionTables struct */
- Tcl_Interp *interp) /* Pointer to the calling interp */
+ void *clientData, /* Pointer to the OptionTables struct */
+ TCL_UNUSED(Tcl_Interp *)) /* Pointer to the calling interp */
{
ckfree(clientData);
return;
@@ -1549,7 +1555,7 @@ ConfigureListbox(
Tcl_Interp *interp, /* Used for error reporting. */
Listbox *listPtr, /* Information about widget; may or may not
* already have values for some fields. */
- int objc, /* Number of valid entries in argv. */
+ Tcl_Size objc, /* Number of valid entries in argv. */
Tcl_Obj *const objv[]) /* Arguments. */
{
Tk_SavedOptions savedOptions;
@@ -1570,7 +1576,7 @@ ConfigureListbox(
* First pass: set options to new values.
*/
- if (Tk_SetOptions(interp, (char *) listPtr,
+ if (Tk_SetOptions(interp, listPtr,
listPtr->optionTable, objc, objv,
listPtr->tkwin, &savedOptions, NULL) != TCL_OK) {
continue;
@@ -1630,7 +1636,7 @@ ConfigureListbox(
if (listPtr->listVarName != NULL) {
Tcl_Obj *listVarObj = Tcl_GetVar2Ex(interp, listPtr->listVarName,
NULL, TCL_GLOBAL_ONLY);
- int dummy;
+ Tcl_Size dummy;
if (listVarObj == NULL) {
listVarObj = (oldListObj ? oldListObj : Tcl_NewObj());
@@ -1710,13 +1716,13 @@ ConfigureListboxItem(
Listbox *listPtr, /* Information about widget; may or may not
* already have values for some fields. */
ItemAttr *attrs, /* Information about the item to configure */
- int objc, /* Number of valid entries in argv. */
+ Tcl_Size objc, /* Number of valid entries in argv. */
Tcl_Obj *const objv[], /* Arguments. */
- int index) /* Index of the listbox item being configure */
+ Tcl_Size index) /* Index of the listbox item being configure */
{
Tk_SavedOptions savedOptions;
- if (Tk_SetOptions(interp, (char *)attrs,
+ if (Tk_SetOptions(interp, attrs,
listPtr->itemAttrOptionTable, objc, objv, listPtr->tkwin,
&savedOptions, NULL) != TCL_OK) {
Tk_RestoreSavedOptions(&savedOptions);
@@ -1753,12 +1759,12 @@ ConfigureListboxItem(
static void
ListboxWorldChanged(
- ClientData instanceData) /* Information about widget. */
+ void *instanceData) /* Information about widget. */
{
XGCValues gcValues;
GC gc;
unsigned long mask;
- Listbox *listPtr = instanceData;
+ Listbox *listPtr = (Listbox *)instanceData;
if (listPtr->state & STATE_NORMAL) {
gcValues.foreground = listPtr->fgColorPtr->pixel;
@@ -1827,12 +1833,13 @@ ListboxWorldChanged(
static void
DisplayListbox(
- ClientData clientData) /* Information about window. */
+ void *clientData) /* Information about window. */
{
- Listbox *listPtr = clientData;
+ Listbox *listPtr = (Listbox *)clientData;
Tk_Window tkwin = listPtr->tkwin;
GC gc;
- int i, limit, x, y, prevSelected, freeGC, stringLen;
+ int i, limit, x, y, prevSelected, freeGC;
+ Tcl_Size stringLen;
Tk_FontMetrics fm;
Tcl_Obj *curElement;
Tcl_HashEntry *entry;
@@ -1898,7 +1905,7 @@ DisplayListbox(
*/
limit = listPtr->topIndex + listPtr->fullLines + listPtr->partialLine - 1;
- if (limit >= listPtr->nElements) {
+ if (limit >= (int)listPtr->nElements) {
limit = listPtr->nElements-1;
}
left = right = 0;
@@ -1948,7 +1955,7 @@ DisplayListbox(
*/
if (entry != NULL) {
- attrs = Tcl_GetHashValue(entry);
+ attrs = (ItemAttr *)Tcl_GetHashValue(entry);
/*
* Default GC has the values from the widget at large.
@@ -2014,7 +2021,7 @@ DisplayListbox(
1, 1, 1, TK_RELIEF_RAISED);
}
/* Draw bottom bevel */
- if (i + 1 == listPtr->nElements ||
+ if (i + 1 == (int)listPtr->nElements ||
!Tcl_FindHashEntry(listPtr->selection, KEY(i + 1))) {
Tk_3DHorizontalBevel(tkwin, pixmap, selectedBg, x-left,
y + listPtr->lineHeight - listPtr->selBorderWidth,
@@ -2029,7 +2036,7 @@ DisplayListbox(
*/
if (entry != NULL) {
- attrs = Tcl_GetHashValue(entry);
+ attrs = (ItemAttr *)Tcl_GetHashValue(entry);
gcValues.foreground = listPtr->fgColorPtr->pixel;
gcValues.font = Tk_FontId(listPtr->tkfont);
gcValues.graphics_exposures = False;
@@ -2065,24 +2072,24 @@ DisplayListbox(
* Draw the actual text of this item.
*/
- Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i, &curElement);
- stringRep = Tcl_GetStringFromObj(curElement, &stringLen);
- textWidth = Tk_TextWidth(listPtr->tkfont, stringRep, stringLen);
+ Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i, &curElement);
+ stringRep = Tcl_GetStringFromObj(curElement, &stringLen);
+ textWidth = Tk_TextWidth(listPtr->tkfont, stringRep, stringLen);
Tk_GetFontMetrics(listPtr->tkfont, &fm);
y += fm.ascent + listPtr->selBorderWidth;
- if (listPtr->justify == TK_JUSTIFY_LEFT) {
- x = (listPtr->inset + listPtr->selBorderWidth) - listPtr->xOffset;
- } else if (listPtr->justify == TK_JUSTIFY_RIGHT) {
- x = Tk_Width(tkwin) - (listPtr->inset + listPtr->selBorderWidth)
- - textWidth - listPtr->xOffset + GetMaxOffset(listPtr);
- } else {
- x = (Tk_Width(tkwin) - textWidth)/2
- - listPtr->xOffset + GetMaxOffset(listPtr)/2;
- }
-
- Tk_DrawChars(listPtr->display, pixmap, gc, listPtr->tkfont,
+ if (listPtr->justify == TK_JUSTIFY_LEFT) {
+ x = (listPtr->inset + listPtr->selBorderWidth) - listPtr->xOffset;
+ } else if (listPtr->justify == TK_JUSTIFY_RIGHT) {
+ x = Tk_Width(tkwin) - (listPtr->inset + listPtr->selBorderWidth)
+ - textWidth - listPtr->xOffset + GetMaxOffset(listPtr);
+ } else {
+ x = (Tk_Width(tkwin) - textWidth)/2
+ - listPtr->xOffset + GetMaxOffset(listPtr)/2;
+ }
+
+ Tk_DrawChars(listPtr->display, pixmap, gc, listPtr->tkfont,
stringRep, stringLen, x, y);
/*
@@ -2179,10 +2186,10 @@ DisplayListbox(
bgGC = Tk_GCForColor(listPtr->highlightBgColorPtr, pixmap);
if (listPtr->flags & GOT_FOCUS) {
fgGC = Tk_GCForColor(listPtr->highlightColorPtr, pixmap);
- TkpDrawHighlightBorder(tkwin, fgGC, bgGC,
+ Tk_DrawHighlightBorder(tkwin, fgGC, bgGC,
listPtr->highlightWidth, pixmap);
} else {
- TkpDrawHighlightBorder(tkwin, bgGC, bgGC,
+ Tk_DrawHighlightBorder(tkwin, bgGC, bgGC,
listPtr->highlightWidth, pixmap);
}
}
@@ -2228,7 +2235,8 @@ ListboxComputeGeometry(
* Tk_UnsetGrid to update gridding for the
* window. */
{
- int width, height, pixelWidth, pixelHeight, textLength, i, result;
+ int width, height, pixelWidth, pixelHeight, i, result;
+ Tcl_Size textLength;
Tk_FontMetrics fm;
Tcl_Obj *element;
const char *text;
@@ -2239,7 +2247,7 @@ ListboxComputeGeometry(
listPtr->xScrollUnit = 1;
}
listPtr->maxWidth = 0;
- for (i = 0; i < listPtr->nElements; i++) {
+ for (i = 0; i < (int)listPtr->nElements; i++) {
/*
* Compute the pixel width of the current element.
*/
@@ -2272,7 +2280,7 @@ ListboxComputeGeometry(
+ 2*listPtr->selBorderWidth;
height = listPtr->height;
if (listPtr->height <= 0) {
- height = listPtr->nElements;
+ height = (int)listPtr->nElements;
if (height < 1) {
height = 1;
}
@@ -2310,12 +2318,13 @@ ListboxComputeGeometry(
static int
ListboxInsertSubCmd(
Listbox *listPtr, /* Listbox that is to get the new elements. */
- int index, /* Add the new elements before this
+ Tcl_Size index, /* Add the new elements before this
* element. */
- int objc, /* Number of new elements to add. */
+ Tcl_Size objc, /* Number of new elements to add. */
Tcl_Obj *const objv[]) /* New elements (one per entry). */
{
- int i, oldMaxWidth, pixelWidth, result, length;
+ int oldMaxWidth, pixelWidth, result;
+ Tcl_Size i, length;
Tcl_Obj *newListObj;
const char *stringRep;
@@ -2392,8 +2401,8 @@ ListboxInsertSubCmd(
}
if (index <= listPtr->active) {
listPtr->active += objc;
- if ((listPtr->active >= listPtr->nElements) &&
- (listPtr->nElements > 0)) {
+ if ((listPtr->active >= (int)listPtr->nElements) &&
+ ((int)listPtr->nElements > 0)) {
listPtr->active = listPtr->nElements-1;
}
}
@@ -2429,7 +2438,8 @@ ListboxDeleteSubCmd(
int first, /* Index of first element to delete. */
int last) /* Index of last element to delete. */
{
- int count, i, widthChanged, length, result, pixelWidth;
+ int count, i, widthChanged, result, pixelWidth;
+ Tcl_Size length;
Tcl_Obj *newListObj, *element;
const char *stringRep;
Tcl_HashEntry *entry;
@@ -2442,7 +2452,7 @@ ListboxDeleteSubCmd(
if (first < 0) {
first = 0;
}
- if (last >= listPtr->nElements) {
+ if (last >= (int)listPtr->nElements) {
last = listPtr->nElements-1;
}
count = last + 1 - first;
@@ -2555,7 +2565,7 @@ ListboxDeleteSubCmd(
listPtr->topIndex = first;
}
}
- if (listPtr->topIndex > (listPtr->nElements - listPtr->fullLines)) {
+ if (listPtr->topIndex > ((int)listPtr->nElements - listPtr->fullLines)) {
listPtr->topIndex = listPtr->nElements - listPtr->fullLines;
if (listPtr->topIndex < 0) {
listPtr->topIndex = 0;
@@ -2565,8 +2575,8 @@ ListboxDeleteSubCmd(
listPtr->active -= count;
} else if (listPtr->active >= first) {
listPtr->active = first;
- if ((listPtr->active >= listPtr->nElements) &&
- (listPtr->nElements > 0)) {
+ if ((listPtr->active >= (int)listPtr->nElements) &&
+ ((int)listPtr->nElements > 0)) {
listPtr->active = listPtr->nElements-1;
}
}
@@ -2599,10 +2609,10 @@ ListboxDeleteSubCmd(
static void
ListboxEventProc(
- ClientData clientData, /* Information about window. */
+ void *clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
- Listbox *listPtr = clientData;
+ Listbox *listPtr = (Listbox *)clientData;
if (eventPtr->type == Expose) {
EventuallyRedrawRange(listPtr,
@@ -2675,9 +2685,9 @@ ListboxEventProc(
static void
ListboxCmdDeletedProc(
- ClientData clientData) /* Pointer to widget record for widget. */
+ void *clientData) /* Pointer to widget record for widget. */
{
- Listbox *listPtr = clientData;
+ Listbox *listPtr = (Listbox *)clientData;
/*
* This procedure could be invoked either because the window was destroyed
@@ -2715,13 +2725,23 @@ GetListboxIndex(
Listbox *listPtr, /* Listbox for which the index is being
* specified. */
Tcl_Obj *indexObj, /* Specifies an element in the listbox. */
- int endIsSize, /* If 1, "end" refers to the number of entries
+ int lastOK, /* If 1, "end" refers to the number of entries
* in the listbox. If 0, "end" refers to 1
* less than the number of entries. */
- int *indexPtr) /* Where to store converted index. */
+ Tcl_Size *indexPtr) /* Where to store converted index. */
{
- int result, index;
- const char *stringRep;
+ int result;
+ Tcl_Size idx, index;
+ char *stringRep;
+
+ result = TkGetIntForIndex(indexObj, listPtr->nElements - 1, lastOK, &idx);
+ if (result == TCL_OK) {
+ if ((idx != TCL_INDEX_NONE) && (idx > listPtr->nElements)) {
+ idx = listPtr->nElements;
+ }
+ *indexPtr = idx;
+ return TCL_OK;
+ }
/*
* First see if the index is one of the named indices.
@@ -2738,14 +2758,6 @@ GetListboxIndex(
/* "anchor" index */
*indexPtr = listPtr->selectAnchor;
break;
- case INDEX_END:
- /* "end" index */
- if (endIsSize) {
- *indexPtr = listPtr->nElements;
- } else {
- *indexPtr = listPtr->nElements - 1;
- }
- break;
}
return TCL_OK;
}
@@ -2757,22 +2769,27 @@ GetListboxIndex(
stringRep = Tcl_GetString(indexObj);
if (stringRep[0] == '@') {
- /*
- * @x,y index
- */
+ /*
+ * @x,y index
+ */
int y;
- const char *start;
- char *end;
+ char *start;
+ char *rest;
start = stringRep + 1;
- y = strtol(start, &end, 0);
- if ((start == end) || (*end != ',')) {
+ rest = strchr(start, ',');
+ if (!rest) {
+ goto badIndex;
+ }
+ *rest = '\0';
+ if (Tcl_GetInt(NULL, start, &y) != TCL_OK) {
+ *rest = ',';
goto badIndex;
}
- start = end+1;
- y = strtol(start, &end, 0);
- if ((start == end) || (*end != '\0')) {
+ *rest = ',';
+ start = rest+1;
+ if (Tcl_GetInt(NULL, start, &y) != TCL_OK) {
goto badIndex;
}
*indexPtr = NearestListboxElement(listPtr, y);
@@ -2780,22 +2797,14 @@ GetListboxIndex(
}
/*
- * Maybe the index is just an integer.
- */
-
- if (Tcl_GetIntFromObj(interp, indexObj, indexPtr) == TCL_OK) {
- return TCL_OK;
- }
-
- /*
* Everything failed, nothing matched. Throw up an error message.
*/
badIndex:
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad listbox index \"%s\": must be active, anchor, end, @x,y,"
- " or a number", Tcl_GetString(indexObj)));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "LISTBOX_INDEX", NULL);
+ " or an index", Tcl_GetString(indexObj)));
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "LISTBOX_INDEX", (char *)NULL);
return TCL_ERROR;
}
@@ -2824,7 +2833,7 @@ ChangeListboxView(
int index) /* Index of element in listPtr that should now
* appear at the top of the listbox. */
{
- if (index >= (listPtr->nElements - listPtr->fullLines)) {
+ if (index >= ((int)listPtr->nElements - listPtr->fullLines)) {
index = listPtr->nElements - listPtr->fullLines;
}
if (index < 0) {
@@ -2983,7 +2992,7 @@ NearestListboxElement(
index = 0;
}
index += listPtr->topIndex;
- if (index >= listPtr->nElements) {
+ if (index >= (int)listPtr->nElements) {
index = listPtr->nElements-1;
}
return index;
@@ -3027,13 +3036,13 @@ ListboxSelect(
first = last;
last = i;
}
- if ((last < 0) || (first >= listPtr->nElements)) {
+ if ((last < 0) || (first >= (int)listPtr->nElements)) {
return TCL_OK;
}
if (first < 0) {
first = 0;
}
- if (last >= listPtr->nElements) {
+ if (last >= (int)listPtr->nElements) {
last = listPtr->nElements - 1;
}
oldCount = listPtr->numSelected;
@@ -3102,19 +3111,20 @@ ListboxSelect(
*----------------------------------------------------------------------
*/
-static int
+static Tcl_Size
ListboxFetchSelection(
- ClientData clientData, /* Information about listbox widget. */
- int offset, /* Offset within selection of first byte to be
+ void *clientData, /* Information about listbox widget. */
+ Tcl_Size 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,
+ Tcl_Size maxBytes) /* Maximum number of bytes to place at buffer,
* not including terminating NULL
* character. */
{
- Listbox *listPtr = clientData;
+ Listbox *listPtr = (Listbox *)clientData;
Tcl_DString selection;
- int length, count, needNewline, stringLen, i;
+ int count, needNewline, i;
+ Tcl_Size length, stringLen;
Tcl_Obj *curElement;
const char *stringRep;
Tcl_HashEntry *entry;
@@ -3129,7 +3139,7 @@ ListboxFetchSelection(
needNewline = 0;
Tcl_DStringInit(&selection);
- for (i = 0; i < listPtr->nElements; i++) {
+ for (i = 0; i < (int)listPtr->nElements; i++) {
entry = Tcl_FindHashEntry(listPtr->selection, KEY(i));
if (entry != NULL) {
if (needNewline) {
@@ -3152,14 +3162,14 @@ ListboxFetchSelection(
* Copy the requested portion of the selection to the buffer.
*/
- count = length - offset;
- if (count <= 0) {
+ if (length <= offset) {
count = 0;
} else {
- if (count > maxBytes) {
- count = maxBytes;
+ count = length - offset;
+ if (count > (int)maxBytes) {
+ count = (int)maxBytes;
}
- memcpy(buffer, Tcl_DStringValue(&selection) + offset, (size_t) count);
+ memcpy(buffer, Tcl_DStringValue(&selection) + offset, count);
}
buffer[count] = '\0';
Tcl_DStringFree(&selection);
@@ -3186,14 +3196,14 @@ ListboxFetchSelection(
static void
ListboxLostSelection(
- ClientData clientData) /* Information about listbox widget. */
+ void *clientData) /* Information about listbox widget. */
{
- Listbox *listPtr = clientData;
+ Listbox *listPtr = (Listbox *)clientData;
if ((listPtr->exportSelection) && (!Tcl_IsSafe(listPtr->interp))
&& (listPtr->nElements > 0)) {
ListboxSelect(listPtr, 0, listPtr->nElements-1, 0);
- GenerateListboxSelectEvent(listPtr);
+ GenerateListboxSelectEvent(listPtr);
}
}
@@ -3218,7 +3228,7 @@ static void
GenerateListboxSelectEvent(
Listbox *listPtr) /* Information about widget. */
{
- TkSendVirtualEvent(listPtr->tkwin, "ListboxSelect", NULL);
+ Tk_SendVirtualEvent(listPtr->tkwin, "ListboxSelect", NULL);
}
/*
@@ -3241,14 +3251,14 @@ GenerateListboxSelectEvent(
static void
EventuallyRedrawRange(
Listbox *listPtr, /* Information about widget. */
- int first, /* Index of first element in list that needs
+ TCL_UNUSED(Tcl_Size), /* Index of first element in list that needs
* to be redrawn. */
- int last) /* Index of last element in list that needs to
+ TCL_UNUSED(Tcl_Size)) /* Index of last element in list that needs to
* be redrawn. May be less than first; these
* just bracket a range. */
{
/*
- * We don't have to a redraw callback if one is already pending,
+ * We don't have to register a redraw callback if one is already pending,
* or if the window doesn't exist, or if the window isn't mapped.
*/
@@ -3316,12 +3326,12 @@ ListboxUpdateVScrollbar(
interp = listPtr->interp;
Tcl_Preserve(interp);
Tcl_DStringInit(&buf);
- Tcl_DStringAppend(&buf, listPtr->yScrollCmd, -1);
- Tcl_DStringAppend(&buf, " ", -1);
- Tcl_DStringAppend(&buf, firstStr, -1);
- Tcl_DStringAppend(&buf, " ", -1);
- Tcl_DStringAppend(&buf, lastStr, -1);
- result = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, TCL_EVAL_GLOBAL);
+ Tcl_DStringAppend(&buf, listPtr->yScrollCmd, TCL_INDEX_NONE);
+ Tcl_DStringAppend(&buf, " ", TCL_INDEX_NONE);
+ Tcl_DStringAppend(&buf, firstStr, TCL_INDEX_NONE);
+ Tcl_DStringAppend(&buf, " ", TCL_INDEX_NONE);
+ Tcl_DStringAppend(&buf, lastStr, TCL_INDEX_NONE);
+ result = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), TCL_INDEX_NONE, TCL_EVAL_GLOBAL);
Tcl_DStringFree(&buf);
if (result != TCL_OK) {
Tcl_AddErrorInfo(interp,
@@ -3388,12 +3398,12 @@ ListboxUpdateHScrollbar(
interp = listPtr->interp;
Tcl_Preserve(interp);
Tcl_DStringInit(&buf);
- Tcl_DStringAppend(&buf, listPtr->xScrollCmd, -1);
- Tcl_DStringAppend(&buf, " ", -1);
- Tcl_DStringAppend(&buf, firstStr, -1);
- Tcl_DStringAppend(&buf, " ", -1);
- Tcl_DStringAppend(&buf, lastStr, -1);
- result = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, TCL_EVAL_GLOBAL);
+ Tcl_DStringAppend(&buf, listPtr->xScrollCmd, TCL_INDEX_NONE);
+ Tcl_DStringAppend(&buf, " ", TCL_INDEX_NONE);
+ Tcl_DStringAppend(&buf, firstStr, TCL_INDEX_NONE);
+ Tcl_DStringAppend(&buf, " ", TCL_INDEX_NONE);
+ Tcl_DStringAppend(&buf, lastStr, TCL_INDEX_NONE);
+ result = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), TCL_INDEX_NONE, TCL_EVAL_GLOBAL);
Tcl_DStringFree(&buf);
if (result != TCL_OK) {
Tcl_AddErrorInfo(interp,
@@ -3421,15 +3431,15 @@ ListboxUpdateHScrollbar(
static char *
ListboxListVarProc(
- ClientData clientData, /* Information about button. */
+ void *clientData, /* Information about button. */
Tcl_Interp *interp, /* Interpreter containing variable. */
- const char *name1, /* Not used. */
- const char *name2, /* Not used. */
+ TCL_UNUSED(const char *),
+ TCL_UNUSED(const char *),
int flags) /* Information about what happened. */
{
- Listbox *listPtr = clientData;
+ Listbox *listPtr = (Listbox *)clientData;
Tcl_Obj *oldListObj, *varListObj;
- int oldLength, i;
+ Tcl_Size oldLength, i;
Tcl_HashEntry *entry;
/*
@@ -3438,27 +3448,27 @@ ListboxListVarProc(
if (flags & TCL_TRACE_UNSETS) {
- if (!Tcl_InterpDeleted(interp) && listPtr->listVarName) {
- ClientData probe = NULL;
-
- do {
- probe = Tcl_VarTraceInfo(interp,
- listPtr->listVarName,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- ListboxListVarProc, probe);
- if (probe == (ClientData)listPtr) {
- break;
- }
- } while (probe);
- if (probe) {
- /*
- * We were able to fetch the unset trace for our
- * listVarName, which means it is not unset and not
- * the cause of this unset trace. Instead some outdated
- * former variable must be, and we should ignore it.
- */
- return NULL;
- }
+ if (!Tcl_InterpDeleted(interp) && listPtr->listVarName) {
+ void *probe = NULL;
+
+ do {
+ probe = Tcl_VarTraceInfo(interp,
+ listPtr->listVarName,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ ListboxListVarProc, probe);
+ if (probe == (void *)listPtr) {
+ break;
+ }
+ } while (probe);
+ if (probe) {
+ /*
+ * We were able to fetch the unset trace for our
+ * listVarName, which means it is not unset and not
+ * the cause of this unset trace. Instead some outdated
+ * former variable must be, and we should ignore it.
+ */
+ return NULL;
+ }
Tcl_SetVar2Ex(interp, listPtr->listVarName, NULL,
listPtr->listObj, TCL_GLOBAL_ONLY);
Tcl_TraceVar2(interp, listPtr->listVarName,
@@ -3531,7 +3541,7 @@ ListboxListVarProc(
if (oldLength != listPtr->nElements) {
listPtr->flags |= UPDATE_V_SCROLLBAR;
- if (listPtr->topIndex > (listPtr->nElements - listPtr->fullLines)) {
+ if (listPtr->topIndex > ((int)listPtr->nElements - listPtr->fullLines)) {
listPtr->topIndex = listPtr->nElements - listPtr->fullLines;
if (listPtr->topIndex < 0) {
listPtr->topIndex = 0;
@@ -3575,13 +3585,14 @@ ListboxListVarProc(
static void
MigrateHashEntries(
Tcl_HashTable *table,
- int first,
- int last,
- int offset)
+ Tcl_Size first,
+ Tcl_Size last,
+ Tcl_Size offset)
{
- int i, isNew;
+ Tcl_Size i;
+ int isNew;
Tcl_HashEntry *entry;
- ClientData clientData;
+ void *clientData;
if (offset == 0) {
return;
@@ -3639,15 +3650,15 @@ static int GetMaxOffset(
int maxOffset;
maxOffset = listPtr->maxWidth -
- (Tk_Width(listPtr->tkwin) - 2*listPtr->inset -
- 2*listPtr->selBorderWidth) + listPtr->xScrollUnit - 1;
+ (Tk_Width(listPtr->tkwin) - 2*listPtr->inset -
+ 2*listPtr->selBorderWidth) + listPtr->xScrollUnit - 1;
if (maxOffset < 0) {
- /*
- * Listbox is larger in width than its largest width item.
- */
+ /*
+ * Listbox is larger in width than its largest width item.
+ */
- maxOffset = 0;
+ maxOffset = 0;
}
maxOffset -= maxOffset % listPtr->xScrollUnit;
diff --git a/generic/tkMacWinMenu.c b/generic/tkMacWinMenu.c
index 71ed414..848e09b 100644
--- a/generic/tkMacWinMenu.c
+++ b/generic/tkMacWinMenu.c
@@ -4,7 +4,7 @@
* 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 Sun Microsystems, Inc.
+ * Copyright © 1996-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.
@@ -43,7 +43,7 @@ PreprocessMenu(
TkMenu *menuPtr)
{
int index, result, finished;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
Tcl_Preserve(menuPtr);
@@ -129,7 +129,7 @@ int
TkPreprocessMenu(
TkMenu *menuPtr)
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
tsdPtr->postCommandGeneration++;
diff --git a/generic/tkMain.c b/generic/tkMain.c
index 3174499..07a7813 100644
--- a/generic/tkMain.c
+++ b/generic/tkMain.c
@@ -7,8 +7,8 @@
* 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-1997 Sun Microsystems, Inc.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 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.
@@ -17,7 +17,7 @@
#include "tkInt.h"
#if defined(_WIN32) && !defined(UNICODE) && !defined(STATIC_BUILD)
-MODULE_SCOPE void TkCygwinMainEx(int, char **, Tcl_AppInitProc *, Tcl_Interp *);
+MODULE_SCOPE void TkCygwinMainEx(Tcl_Size, char **, Tcl_AppInitProc *, Tcl_Interp *);
#endif
/*
@@ -40,7 +40,7 @@ extern "C" {
/* Little hack to eliminate the need for "tclInt.h" here:
Just copy a small portion of TclIntPlatStubs, just
enough to make it work. See [600b72bfbc] */
-typedef struct {
+typedef struct TclIntPlatStubs {
int magic;
void *hooks;
void (*dummy[16]) (void); /* dummy entries 0-15, not used */
@@ -104,7 +104,7 @@ static int WinIsTty(int fd) {
*/
#if !defined(STATIC_BUILD)
- if (tclStubsPtr->reserved9 && tclIntPlatStubsPtr->tclpIsAtty) {
+ if (tclStubsPtr->tcl_CreateFileHandler && tclIntPlatStubsPtr->tclpIsAtty) {
/* We are running on Cygwin */
return tclIntPlatStubsPtr->tclpIsAtty(fd);
}
@@ -165,7 +165,7 @@ static void StdinProc(void *clientData, int mask);
TCL_NORETURN1 void
Tk_MainEx(
- int argc, /* Number of arguments. */
+ Tcl_Size argc, /* Number of arguments. */
TCHAR **argv, /* Array of argument strings. */
Tcl_AppInitProc *appInitProc,
/* Application-specific initialization
@@ -189,7 +189,7 @@ Tk_MainEx(
* Ensure that we are getting a compatible version of Tcl.
*/
- if (Tcl_InitStubs(interp, "8.6", 0) == NULL) {
+ if (Tcl_InitStubs(interp, "8.6-", 0) == NULL) {
if (Tcl_InitStubs(interp, "8.1", 0) == NULL) {
abort();
} else {
@@ -199,7 +199,7 @@ Tk_MainEx(
#if defined(_WIN32) && !defined(UNICODE) && !defined(STATIC_BUILD)
- if (tclStubsPtr->reserved9) {
+ if (tclStubsPtr->tcl_CreateFileHandler) {
/* We are running win32 Tk under Cygwin, so let's check
* whether the env("DISPLAY") variable or the -display
* argument is set. If so, we really want to run the
@@ -209,7 +209,7 @@ Tk_MainEx(
TkCygwinMainEx(argc, argv, appInitProc, interp);
/* Only returns when Tk_MainEx() was not found */
} else {
- int j;
+ Tcl_Size j;
for (j = 1; j < argc; ++j) {
if (!strcmp(argv[j], "-display")) {
@@ -229,7 +229,7 @@ Tk_MainEx(
#if defined(_WIN32)
#if !defined(STATIC_BUILD)
/* If compiled for Win32 but running on Cygwin, don't use console */
- if (!tclStubsPtr->reserved9)
+ if (!tclStubsPtr->tcl_CreateFileHandler)
#endif
Tk_InitConsoleChannels(interp);
#endif
@@ -247,7 +247,9 @@ Tk_MainEx(
*/
if (NULL == Tcl_GetStartupScript(NULL)) {
+#if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
size_t length;
+#endif
/*
* Check whether first 3 args (argv[1] - argv[3]) look like
@@ -255,7 +257,7 @@ Tk_MainEx(
* or like
* FILENAME
* or like
- * -file FILENAME (ancient history support only)
+ * -file FILENAME (ancient history support only, removed with Tcl 9.0)
*/
/* mind argc is being adjusted as we proceed */
@@ -270,12 +272,14 @@ Tk_MainEx(
Tcl_SetStartupScript(NewNativeObj(argv[1]), NULL);
argc--;
i++;
+#if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
} else if ((argc >= 2) && (length = _tcslen(argv[1]))
&& (length > 1) && (0 == _tcsncmp(TEXT("-file"), argv[1], length))
&& ('-' != argv[2][0])) {
Tcl_SetStartupScript(NewNativeObj(argv[2]), NULL);
argc -= 2;
i += 2;
+#endif
}
}
@@ -287,7 +291,7 @@ Tk_MainEx(
}
Tcl_SetVar2Ex(interp, "argv0", NULL, appName, TCL_GLOBAL_ONLY);
- Tcl_SetVar2Ex(interp, "argc", NULL, Tcl_NewIntObj(argc), TCL_GLOBAL_ONLY);
+ Tcl_SetVar2Ex(interp, "argc", NULL, Tcl_NewWideIntObj(argc), TCL_GLOBAL_ONLY);
argvPtr = Tcl_NewListObj(0, NULL);
while (argc--) {
@@ -410,15 +414,14 @@ Tk_MainEx(
static void
StdinProc(
void *clientData, /* The state of interactive cmd line */
- int mask) /* Not used. */
+ TCL_UNUSED(int) /*mask*/)
{
char *cmd;
int code;
- int length;
+ Tcl_Size length;
InteractiveState *isPtr = (InteractiveState *)clientData;
Tcl_Channel chan = isPtr->input;
Tcl_Interp *interp = isPtr->interp;
- (void)mask;
length = Tcl_Gets(chan, &isPtr->line);
@@ -436,8 +439,8 @@ StdinProc(
return;
}
- Tcl_DStringAppend(&isPtr->command, Tcl_DStringValue(&isPtr->line), -1);
- cmd = Tcl_DStringAppend(&isPtr->command, "\n", -1);
+ Tcl_DStringAppend(&isPtr->command, Tcl_DStringValue(&isPtr->line), TCL_INDEX_NONE);
+ cmd = Tcl_DStringAppend(&isPtr->command, "\n", TCL_INDEX_NONE);
Tcl_DStringFree(&isPtr->line);
if (!Tcl_CommandComplete(cmd)) {
isPtr->gotPartial = 1;
diff --git a/generic/tkMenu.c b/generic/tkMenu.c
index fcf49a6..66d919f 100644
--- a/generic/tkMenu.c
+++ b/generic/tkMenu.c
@@ -6,8 +6,8 @@
* 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-1998 Sun Microsystems, Inc.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994-1998 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -101,126 +101,124 @@ TCL_DECLARE_MUTEX(menuMutex)
* to update code in TkpMenuInit that changes the font string entry.
*/
-static const char *const menuStateStrings[] = {"active", "normal", "disabled", NULL};
-
static const char *const menuEntryTypeStrings[] = {
"cascade", "checkbutton", "command", "radiobutton", "separator", NULL
};
static const Tk_OptionSpec tkBasicMenuEntryConfigSpecs[] = {
{TK_OPTION_BORDER, "-activebackground", NULL, NULL,
- DEF_MENU_ENTRY_ACTIVE_BG, Tk_Offset(TkMenuEntry, activeBorderPtr), -1,
+ DEF_MENU_ENTRY_ACTIVE_BG, offsetof(TkMenuEntry, activeBorderPtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_COLOR, "-activeforeground", NULL, NULL,
DEF_MENU_ENTRY_ACTIVE_FG,
- Tk_Offset(TkMenuEntry, activeFgPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, activeFgPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_STRING, "-accelerator", NULL, NULL,
DEF_MENU_ENTRY_ACCELERATOR,
- Tk_Offset(TkMenuEntry, accelPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, accelPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_BORDER, "-background", NULL, NULL,
DEF_MENU_ENTRY_BG,
- Tk_Offset(TkMenuEntry, borderPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, borderPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_BITMAP, "-bitmap", NULL, NULL,
DEF_MENU_ENTRY_BITMAP,
- Tk_Offset(TkMenuEntry, bitmapPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, bitmapPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_BOOLEAN, "-columnbreak", NULL, NULL,
DEF_MENU_ENTRY_COLUMN_BREAK,
- -1, Tk_Offset(TkMenuEntry, columnBreak), 0, NULL, 0},
+ TCL_INDEX_NONE, offsetof(TkMenuEntry, columnBreak), 0, NULL, 0},
{TK_OPTION_STRING, "-command", NULL, NULL,
DEF_MENU_ENTRY_COMMAND,
- Tk_Offset(TkMenuEntry, commandPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, commandPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound",
- DEF_MENU_ENTRY_COMPOUND, -1, Tk_Offset(TkMenuEntry, compound), 0,
+ DEF_MENU_ENTRY_COMPOUND, TCL_INDEX_NONE, offsetof(TkMenuEntry, compound), 0,
tkCompoundStrings, 0},
{TK_OPTION_FONT, "-font", NULL, NULL,
DEF_MENU_ENTRY_FONT,
- Tk_Offset(TkMenuEntry, fontPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, fontPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_COLOR, "-foreground", NULL, NULL,
DEF_MENU_ENTRY_FG,
- Tk_Offset(TkMenuEntry, fgPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, fgPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_BOOLEAN, "-hidemargin", NULL, NULL,
DEF_MENU_ENTRY_HIDE_MARGIN,
- -1, Tk_Offset(TkMenuEntry, hideMargin), 0, NULL, 0},
+ TCL_INDEX_NONE, offsetof(TkMenuEntry, hideMargin), 0, NULL, 0},
{TK_OPTION_STRING, "-image", NULL, NULL,
DEF_MENU_ENTRY_IMAGE,
- Tk_Offset(TkMenuEntry, imagePtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, imagePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_STRING, "-label", NULL, NULL,
DEF_MENU_ENTRY_LABEL,
- Tk_Offset(TkMenuEntry, labelPtr), -1, 0, NULL, 0},
+ offsetof(TkMenuEntry, labelPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_STRING_TABLE, "-state", NULL, NULL,
DEF_MENU_ENTRY_STATE,
- -1, Tk_Offset(TkMenuEntry, state),
- 0, menuStateStrings, 0},
- {TK_OPTION_INT, "-underline", NULL, NULL,
- DEF_MENU_ENTRY_UNDERLINE, -1, Tk_Offset(TkMenuEntry, underline), 0, NULL, 0},
+ TCL_INDEX_NONE, offsetof(TkMenuEntry, state),
+ 0, tkStateStrings, 0},
+ {TK_OPTION_INDEX, "-underline", NULL, NULL,
+ TK_OPTION_UNDERLINE_DEF(TkMenuEntry, underline), 0},
{TK_OPTION_END, NULL, NULL, NULL, 0, 0, 0, 0, NULL, 0}
};
static const Tk_OptionSpec tkSeparatorEntryConfigSpecs[] = {
{TK_OPTION_BORDER, "-background", NULL, NULL,
DEF_MENU_ENTRY_BG,
- Tk_Offset(TkMenuEntry, borderPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, borderPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_END, NULL, NULL, NULL, 0, 0, 0, 0, NULL, 0}
};
static const Tk_OptionSpec tkCheckButtonEntryConfigSpecs[] = {
{TK_OPTION_BOOLEAN, "-indicatoron", NULL, NULL,
DEF_MENU_ENTRY_INDICATOR,
- -1, Tk_Offset(TkMenuEntry, indicatorOn), 0, NULL, 0},
+ TCL_INDEX_NONE, offsetof(TkMenuEntry, indicatorOn), 0, NULL, 0},
{TK_OPTION_STRING, "-offvalue", NULL, NULL,
DEF_MENU_ENTRY_OFF_VALUE,
- Tk_Offset(TkMenuEntry, offValuePtr), -1, 0, NULL, 0},
+ offsetof(TkMenuEntry, offValuePtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_STRING, "-onvalue", NULL, NULL,
DEF_MENU_ENTRY_ON_VALUE,
- Tk_Offset(TkMenuEntry, onValuePtr), -1, 0, NULL, 0},
+ offsetof(TkMenuEntry, onValuePtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_COLOR, "-selectcolor", NULL, NULL,
DEF_MENU_ENTRY_SELECT,
- Tk_Offset(TkMenuEntry, indicatorFgPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, indicatorFgPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_STRING, "-selectimage", NULL, NULL,
DEF_MENU_ENTRY_SELECT_IMAGE,
- Tk_Offset(TkMenuEntry, selectImagePtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, selectImagePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_STRING, "-variable", NULL, NULL,
DEF_MENU_ENTRY_CHECK_VARIABLE,
- Tk_Offset(TkMenuEntry, namePtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, namePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_END, NULL, NULL, NULL,
- NULL, 0, -1, 0, tkBasicMenuEntryConfigSpecs, 0}
+ NULL, 0, TCL_INDEX_NONE, 0, tkBasicMenuEntryConfigSpecs, 0}
};
static const Tk_OptionSpec tkRadioButtonEntryConfigSpecs[] = {
{TK_OPTION_BOOLEAN, "-indicatoron", NULL, NULL,
DEF_MENU_ENTRY_INDICATOR,
- -1, Tk_Offset(TkMenuEntry, indicatorOn), 0, NULL, 0},
+ TCL_INDEX_NONE, offsetof(TkMenuEntry, indicatorOn), 0, NULL, 0},
{TK_OPTION_COLOR, "-selectcolor", NULL, NULL,
DEF_MENU_ENTRY_SELECT,
- Tk_Offset(TkMenuEntry, indicatorFgPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, indicatorFgPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_STRING, "-selectimage", NULL, NULL,
DEF_MENU_ENTRY_SELECT_IMAGE,
- Tk_Offset(TkMenuEntry, selectImagePtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, selectImagePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_STRING, "-value", NULL, NULL,
DEF_MENU_ENTRY_VALUE,
- Tk_Offset(TkMenuEntry, onValuePtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, onValuePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_STRING, "-variable", NULL, NULL,
DEF_MENU_ENTRY_RADIO_VARIABLE,
- Tk_Offset(TkMenuEntry, namePtr), -1, 0, NULL, 0},
+ offsetof(TkMenuEntry, namePtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_END, NULL, NULL, NULL,
- NULL, 0, -1, 0, tkBasicMenuEntryConfigSpecs, 0}
+ NULL, 0, TCL_INDEX_NONE, 0, tkBasicMenuEntryConfigSpecs, 0}
};
static const Tk_OptionSpec tkCascadeEntryConfigSpecs[] = {
{TK_OPTION_STRING, "-menu", NULL, NULL,
DEF_MENU_ENTRY_MENU,
- Tk_Offset(TkMenuEntry, namePtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, namePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_END, NULL, NULL, NULL,
- NULL, 0, -1, 0, tkBasicMenuEntryConfigSpecs, 0}
+ NULL, 0, TCL_INDEX_NONE, 0, tkBasicMenuEntryConfigSpecs, 0}
};
static const Tk_OptionSpec tkTearoffEntryConfigSpecs[] = {
{TK_OPTION_BORDER, "-background", NULL, NULL,
DEF_MENU_ENTRY_BG,
- Tk_Offset(TkMenuEntry, borderPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, borderPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_STRING_TABLE, "-state", NULL, NULL,
- DEF_MENU_ENTRY_STATE, -1, Tk_Offset(TkMenuEntry, state),
- 0, menuStateStrings, 0},
+ DEF_MENU_ENTRY_STATE, TCL_INDEX_NONE, offsetof(TkMenuEntry, state),
+ 0, tkStateStrings, 0},
{TK_OPTION_END, NULL, NULL, NULL, 0, 0, 0, 0, NULL, 0}
};
@@ -235,65 +233,68 @@ static const Tk_OptionSpec *specsArray[] = {
*/
static const char *const menuTypeStrings[] = {
- "normal", "tearoff", "menubar", NULL
+ "menubar", "normal", "tearoff", NULL
};
static const Tk_OptionSpec tkMenuConfigSpecs[] = {
{TK_OPTION_BORDER, "-activebackground", "activeBackground",
"Foreground", DEF_MENU_ACTIVE_BG_COLOR,
- Tk_Offset(TkMenu, activeBorderPtr), -1, 0,
- (ClientData) DEF_MENU_ACTIVE_BG_MONO, 0},
+ offsetof(TkMenu, activeBorderPtr), TCL_INDEX_NONE, 0,
+ DEF_MENU_ACTIVE_BG_MONO, 0},
{TK_OPTION_PIXELS, "-activeborderwidth", "activeBorderWidth",
"BorderWidth", DEF_MENU_ACTIVE_BORDER_WIDTH,
- Tk_Offset(TkMenu, activeBorderWidthPtr), -1, 0, NULL, 0},
+ offsetof(TkMenu, activeBorderWidthPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_COLOR, "-activeforeground", "activeForeground",
"Background", DEF_MENU_ACTIVE_FG_COLOR,
- Tk_Offset(TkMenu, activeFgPtr), -1, 0,
- (ClientData) DEF_MENU_ACTIVE_FG_MONO, 0},
+ offsetof(TkMenu, activeFgPtr), TCL_INDEX_NONE, 0,
+ DEF_MENU_ACTIVE_FG_MONO, 0},
+ {TK_OPTION_RELIEF, "-activerelief", "activeRelief", "Relief",
+ DEF_MENU_ACTIVE_RELIEF, offsetof(TkMenu, activeReliefPtr),
+ TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_MENU_BG_COLOR, Tk_Offset(TkMenu, borderPtr), -1, 0,
- (ClientData) DEF_MENU_BG_MONO, 0},
+ DEF_MENU_BG_COLOR, offsetof(TkMenu, borderPtr), TCL_INDEX_NONE, 0,
+ DEF_MENU_BG_MONO, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL,
- NULL, 0, -1, 0, "-background", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
DEF_MENU_BORDER_WIDTH,
- Tk_Offset(TkMenu, borderWidthPtr), -1, 0, NULL, 0},
+ offsetof(TkMenu, borderWidthPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
DEF_MENU_CURSOR,
- Tk_Offset(TkMenu, cursorPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenu, cursorPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_COLOR, "-disabledforeground", "disabledForeground",
"DisabledForeground", DEF_MENU_DISABLED_FG_COLOR,
- Tk_Offset(TkMenu, disabledFgPtr), -1, TK_OPTION_NULL_OK,
- (ClientData) DEF_MENU_DISABLED_FG_MONO, 0},
+ offsetof(TkMenu, disabledFgPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK,
+ DEF_MENU_DISABLED_FG_MONO, 0},
{TK_OPTION_SYNONYM, "-fg", NULL, NULL,
- NULL, 0, -1, 0, "-foreground", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_MENU_FONT, Tk_Offset(TkMenu, fontPtr), -1, 0, NULL, 0},
+ DEF_MENU_FONT, offsetof(TkMenu, fontPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_MENU_FG, Tk_Offset(TkMenu, fgPtr), -1, 0, NULL, 0},
+ DEF_MENU_FG, offsetof(TkMenu, fgPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_STRING, "-postcommand", "postCommand", "Command",
DEF_MENU_POST_COMMAND,
- Tk_Offset(TkMenu, postCommandPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenu, postCommandPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_MENU_RELIEF, Tk_Offset(TkMenu, reliefPtr), -1, 0, NULL, 0},
+ DEF_MENU_RELIEF, offsetof(TkMenu, reliefPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_COLOR, "-selectcolor", "selectColor", "Background",
- DEF_MENU_SELECT_COLOR, Tk_Offset(TkMenu, indicatorFgPtr), -1, 0,
- (ClientData) DEF_MENU_SELECT_MONO, 0},
+ DEF_MENU_SELECT_COLOR, offsetof(TkMenu, indicatorFgPtr), TCL_INDEX_NONE, 0,
+ DEF_MENU_SELECT_MONO, 0},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
DEF_MENU_TAKE_FOCUS,
- Tk_Offset(TkMenu, takeFocusPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenu, takeFocusPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_BOOLEAN, "-tearoff", "tearOff", "TearOff",
- DEF_MENU_TEAROFF, -1, Tk_Offset(TkMenu, tearoff), 0, NULL, 0},
+ DEF_MENU_TEAROFF, TCL_INDEX_NONE, offsetof(TkMenu, tearoff), 0, NULL, 0},
{TK_OPTION_STRING, "-tearoffcommand", "tearOffCommand",
"TearOffCommand", DEF_MENU_TEAROFF_CMD,
- Tk_Offset(TkMenu, tearoffCommandPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenu, tearoffCommandPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_STRING, "-title", "title", "Title",
- DEF_MENU_TITLE, Tk_Offset(TkMenu, titlePtr), -1,
+ DEF_MENU_TITLE, offsetof(TkMenu, titlePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_STRING_TABLE, "-type", "type", "Type",
- DEF_MENU_TYPE, Tk_Offset(TkMenu, menuTypePtr), -1,
+ DEF_MENU_TYPE, offsetof(TkMenu, menuTypePtr), TCL_INDEX_NONE,
0, menuTypeStrings, 0},
{TK_OPTION_END, NULL, NULL, NULL, 0, 0, 0, 0, NULL, 0}
};
@@ -305,12 +306,12 @@ static const Tk_OptionSpec tkMenuConfigSpecs[] = {
static const char *const menuOptions[] = {
"activate", "add", "cget", "clone", "configure", "delete", "entrycget",
- "entryconfigure", "index", "insert", "invoke", "post", "postcascade",
+ "entryconfigure", "id", "index", "insert", "invoke", "post", "postcascade",
"type", "unpost", "xposition", "yposition", NULL
};
enum options {
MENU_ACTIVATE, MENU_ADD, MENU_CGET, MENU_CLONE, MENU_CONFIGURE,
- MENU_DELETE, MENU_ENTRYCGET, MENU_ENTRYCONFIGURE, MENU_INDEX,
+ MENU_DELETE, MENU_ENTRYCGET, MENU_ENTRYCONFIGURE, MENU_ID, MENU_INDEX,
MENU_INSERT, MENU_INVOKE, MENU_POST, MENU_POSTCASCADE, MENU_TYPE,
MENU_UNPOST, MENU_XPOSITION, MENU_YPOSITION
};
@@ -322,41 +323,40 @@ enum options {
static int CloneMenu(TkMenu *menuPtr, Tcl_Obj *newMenuName,
Tcl_Obj *newMenuTypeString);
static int ConfigureMenu(Tcl_Interp *interp, TkMenu *menuPtr,
- int objc, Tcl_Obj *const objv[]);
-static int ConfigureMenuCloneEntries(Tcl_Interp *interp,
- TkMenu *menuPtr, int index,
- int objc, Tcl_Obj *const objv[]);
+ Tcl_Size objc, Tcl_Obj *const objv[]);
+static int ConfigureMenuCloneEntries(TkMenu *menuPtr, int index,
+ Tcl_Size objc, Tcl_Obj *const objv[]);
static int ConfigureMenuEntry(TkMenuEntry *mePtr,
- int objc, Tcl_Obj *const objv[]);
+ Tcl_Size objc, Tcl_Obj *const objv[]);
static void DeleteMenuCloneEntries(TkMenu *menuPtr,
int first, int last);
-static void DestroyMenuHashTable(ClientData clientData,
+static void DestroyMenuHashTable(void *clientData,
Tcl_Interp *interp);
static void DestroyMenuInstance(TkMenu *menuPtr);
static Tcl_FreeProc DestroyMenuEntry;
-static int GetIndexFromCoords(Tcl_Interp *interp,
+static Tcl_Size GetIndexFromCoords(Tcl_Interp *interp,
TkMenu *menuPtr, const char *string,
- int *indexPtr);
+ Tcl_Size *indexPtr);
static int MenuDoYPosition(Tcl_Interp *interp,
TkMenu *menuPtr, Tcl_Obj *objPtr);
static int MenuDoXPosition(Tcl_Interp *interp,
TkMenu *menuPtr, Tcl_Obj *objPtr);
static int MenuAddOrInsert(Tcl_Interp *interp,
- TkMenu *menuPtr, Tcl_Obj *indexPtr, int objc,
+ TkMenu *menuPtr, Tcl_Obj *indexPtr, Tcl_Size objc,
Tcl_Obj *const objv[]);
-static void MenuCmdDeletedProc(ClientData clientData);
-static TkMenuEntry * MenuNewEntry(TkMenu *menuPtr, int index, int type);
-static char * MenuVarProc(ClientData clientData,
+static void MenuCmdDeletedProc(void *clientData);
+static TkMenuEntry * MenuNewEntry(TkMenu *menuPtr, Tcl_Size index, int type);
+static char * MenuVarProc(void *clientData,
Tcl_Interp *interp, const char *name1,
const char *name2, int flags);
-static int MenuWidgetObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-static void MenuWorldChanged(ClientData instanceData);
+static Tcl_ObjCmdProc MenuWidgetObjCmd;
+static void MenuWorldChanged(void *instanceData);
static int PostProcessEntry(TkMenuEntry *mePtr);
static void RecursivelyDeleteMenu(TkMenu *menuPtr);
static void UnhookCascadeEntry(TkMenuEntry *mePtr);
-static void TkMenuCleanup(ClientData unused);
+static void MenuCleanup(void *unused);
+static int GetMenuIndex(Tcl_Interp *interp, TkMenu *menuPtr,
+ Tcl_Obj *objPtr, int lastOK, Tcl_Size *indexPtr);
/*
* The structure below is a list of procs that respond to certain window
@@ -390,7 +390,7 @@ static const Tk_ClassProcs menuClass = {
int
Tk_MenuObjCmd(
- ClientData clientData, /* Main window associated with interpreter. */
+ void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
@@ -399,7 +399,7 @@ Tk_MenuObjCmd(
Tk_Window newWin;
TkMenu *menuPtr;
TkMenuReferences *menuRefPtr;
- int i;
+ Tcl_Size i;
int index, toplevel;
const char *windowName;
static const char *const typeStringList[] = {"-type", NULL};
@@ -446,10 +446,12 @@ Tk_MenuObjCmd(
menuPtr->widgetCmd = Tcl_CreateObjCommand(interp,
Tk_PathName(menuPtr->tkwin), MenuWidgetObjCmd, menuPtr,
MenuCmdDeletedProc);
- menuPtr->active = -1;
+ menuPtr->active = TCL_INDEX_NONE;
menuPtr->cursorPtr = NULL;
- menuPtr->masterMenuPtr = menuPtr;
+ menuPtr->mainMenuPtr = menuPtr;
menuPtr->menuType = UNKNOWN_TYPE;
+ Tcl_InitHashTable(&menuPtr->items, TCL_STRING_KEYS);
+ menuPtr->serial = 0;
TkMenuInitializeDrawingFields(menuPtr);
Tk_SetClass(menuPtr->tkwin, "Menu");
@@ -457,7 +459,7 @@ Tk_MenuObjCmd(
Tk_CreateEventHandler(newWin,
ExposureMask|StructureNotifyMask|ActivateMask,
TkMenuEventProc, menuPtr);
- if (Tk_InitOptions(interp, (char *) menuPtr,
+ if (Tk_InitOptions(interp, menuPtr,
tsdPtr->menuOptionTable, menuPtr->tkwin)
!= TCL_OK) {
Tk_DestroyWindow(menuPtr->tkwin);
@@ -513,11 +515,11 @@ Tk_MenuObjCmd(
* creating exists.
*/
- if ((menuPtr->masterMenuPtr != menuPtr)
- || ((menuPtr->masterMenuPtr == menuPtr)
- && ((cascadeListPtr->menuPtr->masterMenuPtr
+ if ((menuPtr->mainMenuPtr != menuPtr)
+ || ((menuPtr->mainMenuPtr == menuPtr)
+ && ((cascadeListPtr->menuPtr->mainMenuPtr
== cascadeListPtr->menuPtr)))) {
- newObjv[0] = Tcl_NewStringObj("-menu", -1);
+ newObjv[0] = Tcl_NewStringObj("-menu", TCL_INDEX_NONE);
newObjv[1] = Tcl_NewStringObj(Tk_PathName(menuPtr->tkwin),-1);
Tcl_IncrRefCount(newObjv[0]);
Tcl_IncrRefCount(newObjv[1]);
@@ -525,9 +527,9 @@ Tk_MenuObjCmd(
Tcl_DecrRefCount(newObjv[0]);
Tcl_DecrRefCount(newObjv[1]);
} else {
- Tcl_Obj *normalPtr = Tcl_NewStringObj("normal", -1);
+ Tcl_Obj *normalPtr = Tcl_NewStringObj("normal", TCL_INDEX_NONE);
Tcl_Obj *windowNamePtr = Tcl_NewStringObj(
- Tk_PathName(cascadeListPtr->menuPtr->tkwin), -1);
+ Tk_PathName(cascadeListPtr->menuPtr->tkwin), TCL_INDEX_NONE);
Tcl_IncrRefCount(normalPtr);
Tcl_IncrRefCount(windowNamePtr);
@@ -541,7 +543,7 @@ Tk_MenuObjCmd(
* entry of the parent's instance.
*/
- newObjv[0] = Tcl_NewStringObj("-menu", -1);
+ newObjv[0] = Tcl_NewStringObj("-menu", TCL_INDEX_NONE);
newObjv[1] = newMenuName;
Tcl_IncrRefCount(newObjv[0]);
ConfigureMenuEntry(cascadeListPtr, 2, newObjv);
@@ -567,20 +569,20 @@ Tk_MenuObjCmd(
while (topLevelListPtr != NULL) {
/*
- * Need to get the next pointer first. TkSetWindowMenuBar changes
+ * Need to get the next pointer first. Tk_SetWindowMenubar changes
* the list, so that the next pointer is different after calling
* it.
*/
nextPtr = topLevelListPtr->nextPtr;
listtkwin = topLevelListPtr->tkwin;
- TkSetWindowMenuBar(menuPtr->interp, listtkwin,
+ Tk_SetWindowMenubar(menuPtr->interp, listtkwin,
Tk_PathName(menuPtr->tkwin), Tk_PathName(menuPtr->tkwin));
topLevelListPtr = nextPtr;
}
}
- Tcl_SetObjResult(interp, TkNewWindowObj(menuPtr->tkwin));
+ Tcl_SetObjResult(interp, Tk_NewWindowObj(menuPtr->tkwin));
return TCL_OK;
}
@@ -604,7 +606,7 @@ Tk_MenuObjCmd(
static int
MenuWidgetObjCmd(
- ClientData clientData, /* Information about menu widget. */
+ void *clientData, /* Information about menu widget. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
@@ -628,13 +630,13 @@ MenuWidgetObjCmd(
switch ((enum options) option) {
case MENU_ACTIVATE: {
- int index;
+ Tcl_Size index;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "index");
goto error;
}
- if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
+ if (GetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
goto error;
}
if (menuPtr->active == index) {
@@ -642,7 +644,7 @@ MenuWidgetObjCmd(
}
if ((index >= 0) && ((menuPtr->entries[index]->type==SEPARATOR_ENTRY)
|| (menuPtr->entries[index]->state == ENTRY_DISABLED))) {
- index = -1;
+ index = TCL_INDEX_NONE;
}
result = TkActivateMenuEntry(menuPtr, index);
break;
@@ -664,7 +666,7 @@ MenuWidgetObjCmd(
Tcl_WrongNumArgs(interp, 2, objv, "option");
goto error;
}
- resultPtr = Tk_GetOptionValue(interp, (char *) menuPtr,
+ resultPtr = Tk_GetOptionValue(interp, menuPtr,
tsdPtr->menuOptionTable, objv[2],
menuPtr->tkwin);
if (resultPtr == NULL) {
@@ -684,7 +686,7 @@ MenuWidgetObjCmd(
Tcl_Obj *resultPtr;
if (objc == 2) {
- resultPtr = Tk_GetOptionInfo(interp, (char *) menuPtr,
+ resultPtr = Tk_GetOptionInfo(interp, menuPtr,
tsdPtr->menuOptionTable, NULL,
menuPtr->tkwin);
if (resultPtr == NULL) {
@@ -694,7 +696,7 @@ MenuWidgetObjCmd(
Tcl_SetObjResult(interp, resultPtr);
}
} else if (objc == 3) {
- resultPtr = Tk_GetOptionInfo(interp, (char *) menuPtr,
+ resultPtr = Tk_GetOptionInfo(interp, menuPtr,
tsdPtr->menuOptionTable, objv[2],
menuPtr->tkwin);
if (resultPtr == NULL) {
@@ -712,7 +714,8 @@ MenuWidgetObjCmd(
break;
}
case MENU_DELETE: {
- int first, last;
+ Tcl_Size first, last;
+ Tcl_WideInt w;
if ((objc != 3) && (objc != 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "first ?last?");
@@ -725,16 +728,17 @@ MenuWidgetObjCmd(
*/
if (isdigit(UCHAR(Tcl_GetString(objv[2])[0]))
- && Tcl_GetIntFromObj(NULL, objv[2], &first) == TCL_OK) {
+ && Tcl_GetWideIntFromObj(NULL, objv[2], &w) == TCL_OK) {
+ first = w;
if (first >= menuPtr->numEntries) {
goto done;
}
- } else if (TkGetMenuIndex(interp,menuPtr,objv[2],0,&first) != TCL_OK){
+ } else if (GetMenuIndex(interp,menuPtr,objv[2],0,&first) != TCL_OK){
goto error;
}
if (objc == 3) {
last = first;
- } else if (TkGetMenuIndex(interp,menuPtr,objv[3],0,&last) != TCL_OK) {
+ } else if (GetMenuIndex(interp,menuPtr,objv[3],0,&last) != TCL_OK) {
goto error;
}
@@ -746,21 +750,21 @@ MenuWidgetObjCmd(
first = 1;
}
- if ((first == -1) || (last < first)) {
+ if ((first < 0) || (last < first)) {
goto done;
}
DeleteMenuCloneEntries(menuPtr, first, last);
break;
}
case MENU_ENTRYCGET: {
- int index;
+ Tcl_Size index;
Tcl_Obj *resultPtr;
if (objc != 4) {
Tcl_WrongNumArgs(interp, 2, objv, "index option");
goto error;
}
- if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
+ if (GetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
goto error;
}
if (index < 0) {
@@ -768,7 +772,7 @@ MenuWidgetObjCmd(
}
mePtr = menuPtr->entries[index];
Tcl_Preserve(mePtr);
- resultPtr = Tk_GetOptionValue(interp, (char *) mePtr,
+ resultPtr = Tk_GetOptionValue(interp, mePtr,
mePtr->optionTable, objv[3], menuPtr->tkwin);
Tcl_Release(mePtr);
if (resultPtr == NULL) {
@@ -778,14 +782,14 @@ MenuWidgetObjCmd(
break;
}
case MENU_ENTRYCONFIGURE: {
- int index;
+ Tcl_Size index;
Tcl_Obj *resultPtr;
if (objc < 3) {
Tcl_WrongNumArgs(interp, 2, objv, "index ?-option value ...?");
goto error;
}
- if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
+ if (GetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
goto error;
}
if (index < 0) {
@@ -794,7 +798,7 @@ MenuWidgetObjCmd(
mePtr = menuPtr->entries[index];
Tcl_Preserve(mePtr);
if (objc == 3) {
- resultPtr = Tk_GetOptionInfo(interp, (char *) mePtr,
+ resultPtr = Tk_GetOptionInfo(interp, mePtr,
mePtr->optionTable, NULL, menuPtr->tkwin);
if (resultPtr == NULL) {
result = TCL_ERROR;
@@ -803,7 +807,7 @@ MenuWidgetObjCmd(
Tcl_SetObjResult(interp, resultPtr);
}
} else if (objc == 4) {
- resultPtr = Tk_GetOptionInfo(interp, (char *) mePtr,
+ resultPtr = Tk_GetOptionInfo(interp, mePtr,
mePtr->optionTable, objv[3], menuPtr->tkwin);
if (resultPtr == NULL) {
result = TCL_ERROR;
@@ -812,26 +816,52 @@ MenuWidgetObjCmd(
Tcl_SetObjResult(interp, resultPtr);
}
} else {
- result = ConfigureMenuCloneEntries(interp, menuPtr, index,
+ result = ConfigureMenuCloneEntries(menuPtr, index,
objc-3, objv+3);
}
Tcl_Release(mePtr);
break;
}
+ case MENU_ID: {
+ Tcl_Size index;
+ const char *idStr;
+ Tcl_HashEntry *entryPtr;
+
+ if (objc != 3) {
+ Tcl_WrongNumArgs(interp, 2, objv, "index");
+ goto error;
+ }
+ if (GetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
+ goto error;
+ }
+ if (index < 0) {
+ goto done;
+ }
+ entryPtr = menuPtr->entries[index]->entryPtr;
+ if (entryPtr) {
+ idStr = (const char *)Tcl_GetHashKey(&menuPtr->items, entryPtr);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(idStr, TCL_INDEX_NONE));
+ }
+ break;
+ }
case MENU_INDEX: {
- int index;
+ Tcl_Size index;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "string");
goto error;
}
- if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
+ if (GetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
goto error;
}
if (index < 0) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj("none", -1));
+#if defined(TK_NO_DEPRECATED)
+ Tcl_SetObjResult(interp, Tcl_NewObj());
+#else
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("none", TCL_INDEX_NONE));
+#endif
} else {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(index));
+ Tcl_SetObjResult(interp, TkNewIndexObj(index));
}
break;
}
@@ -846,13 +876,13 @@ MenuWidgetObjCmd(
}
break;
case MENU_INVOKE: {
- int index;
+ Tcl_Size index;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "index");
goto error;
}
- if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
+ if (GetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
goto error;
}
if (index < 0) {
@@ -863,7 +893,7 @@ MenuWidgetObjCmd(
}
case MENU_POST: {
int x, y;
- int index = -1;
+ Tcl_Size index = TCL_INDEX_NONE;
if (objc != 4 && objc != 5) {
Tcl_WrongNumArgs(interp, 2, objv, "x y ?index?");
@@ -874,9 +904,9 @@ MenuWidgetObjCmd(
goto error;
}
if (objc == 5) {
- if (TkGetMenuIndex(interp, menuPtr, objv[4], 0, &index) != TCL_OK) {
- goto error;
- }
+ if (GetMenuIndex(interp, menuPtr, objv[4], 0, &index) != TCL_OK) {
+ goto error;
+ }
}
/*
@@ -888,9 +918,9 @@ MenuWidgetObjCmd(
*/
if (menuPtr->menuType == MENUBAR) {
- Tcl_AppendResult(interp, "a menubar menu cannot be posted", NULL);
- return TCL_ERROR;
- } else if (menuPtr->menuType != TEAROFF_MENU) {
+ Tcl_AppendResult(interp, "a menubar menu cannot be posted", NULL);
+ return TCL_ERROR;
+ } else if (menuPtr->menuType != TEAROFF_MENU) {
result = TkpPostMenu(interp, menuPtr, x, y, index);
} else {
result = TkpPostTearoffMenu(interp, menuPtr, x, y, index);
@@ -898,14 +928,14 @@ MenuWidgetObjCmd(
break;
}
case MENU_POSTCASCADE: {
- int index;
+ Tcl_Size index;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "index");
goto error;
}
- if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
+ if (GetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
goto error;
}
if ((index < 0) || (menuPtr->entries[index]->type != CASCADE_ENTRY)) {
@@ -916,14 +946,14 @@ MenuWidgetObjCmd(
break;
}
case MENU_TYPE: {
- int index;
+ Tcl_Size index;
const char *typeStr;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "index");
goto error;
}
- if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
+ if (GetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
goto error;
}
if (index < 0) {
@@ -934,7 +964,7 @@ MenuWidgetObjCmd(
} else {
typeStr = menuEntryTypeStrings[menuPtr->entries[index]->type];
}
- Tcl_SetObjResult(interp, Tcl_NewStringObj(typeStr, -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(typeStr, TCL_INDEX_NONE));
break;
}
case MENU_UNPOST:
@@ -995,8 +1025,8 @@ TkInvokeMenu(
* against freeing by the caller.
* Tk Bug [2d3a81c0].
*/
- int index) /* The zero based index of the item we are
- * invoking. */
+ Tcl_Size index) /* The zero based index of the item we are
+ * invoking. */
{
int result = TCL_OK;
TkMenuEntry *mePtr;
@@ -1014,9 +1044,9 @@ TkInvokeMenu(
Tcl_DString ds;
Tcl_DStringInit(&ds);
- Tcl_DStringAppend(&ds, "tk::TearOffMenu ", -1);
- Tcl_DStringAppend(&ds, Tk_PathName(menuPtr->tkwin), -1);
- result = Tcl_EvalEx(interp, Tcl_DStringValue(&ds), -1, TCL_EVAL_GLOBAL);
+ Tcl_DStringAppend(&ds, "tk::TearOffMenu ", TCL_INDEX_NONE);
+ Tcl_DStringAppend(&ds, Tk_PathName(menuPtr->tkwin), TCL_INDEX_NONE);
+ result = Tcl_EvalEx(interp, Tcl_DStringValue(&ds), TCL_INDEX_NONE, TCL_EVAL_GLOBAL);
Tcl_DStringFree(&ds);
} else if ((mePtr->type == CHECK_BUTTON_ENTRY)
&& (mePtr->namePtr != NULL)) {
@@ -1129,10 +1159,10 @@ DestroyMenuInstance(
for (; cascadePtr != NULL; cascadePtr = nextCascadePtr) {
nextCascadePtr = cascadePtr->nextCascadePtr;
- if (menuPtr->masterMenuPtr != menuPtr) {
- Tcl_Obj *menuNamePtr = Tcl_NewStringObj("-menu", -1);
+ if (menuPtr->mainMenuPtr != menuPtr) {
+ Tcl_Obj *menuNamePtr = Tcl_NewStringObj("-menu", TCL_INDEX_NONE);
- parentMainMenuPtr = cascadePtr->menuPtr->masterMenuPtr;
+ parentMainMenuPtr = cascadePtr->menuPtr->mainMenuPtr;
parentMainEntryPtr =
parentMainMenuPtr->entries[cascadePtr->index];
newObjv[0] = menuNamePtr;
@@ -1155,8 +1185,8 @@ DestroyMenuInstance(
}
}
- if (menuPtr->masterMenuPtr != menuPtr) {
- for (menuInstancePtr = menuPtr->masterMenuPtr;
+ if (menuPtr->mainMenuPtr != menuPtr) {
+ for (menuInstancePtr = menuPtr->mainMenuPtr;
menuInstancePtr != NULL;
menuInstancePtr = menuInstancePtr->nextInstancePtr) {
if (menuInstancePtr->nextInstancePtr == menuPtr) {
@@ -1176,13 +1206,25 @@ DestroyMenuInstance(
for (i = menuPtr->numEntries; --i >= 0; ) {
/*
+ * Clean up the hash entry for the menu item ID.
+ * This cannot be postponed until the entry is eventually freed,
+ * because the hash table may already have been deleted by then.
+ */
+
+ if (menuPtr->entries[i]->entryPtr) {
+ Tcl_DeleteHashEntry(menuPtr->entries[i]->entryPtr);
+ menuPtr->entries[i]->entryPtr = NULL;
+ }
+
+ /*
* As each menu entry is deleted from the end of the array of entries,
* decrement menuPtr->numEntries. Otherwise, the act of deleting menu
* entry i will dereference freed memory attempting to queue a redraw
* for menu entries (i+1)...numEntries.
*/
- Tcl_EventuallyFree(menuPtr->entries[i], DestroyMenuEntry);
+ Tcl_EventuallyFree(menuPtr->entries[i],
+ DestroyMenuEntry);
menuPtr->numEntries = i;
}
menuPtr->active = -1;
@@ -1190,8 +1232,9 @@ DestroyMenuInstance(
ckfree(menuPtr->entries);
menuPtr->entries = NULL;
}
+ Tcl_DeleteHashTable(&menuPtr->items);
TkMenuFreeDrawOptions(menuPtr);
- Tk_FreeConfigOptions((char *) menuPtr,
+ Tk_FreeConfigOptions(menuPtr,
tsdPtr->menuOptionTable, menuPtr->tkwin);
if (menuPtr->tkwin != NULL) {
Tk_Window tkwin = menuPtr->tkwin;
@@ -1254,7 +1297,7 @@ TkDestroyMenu(
topLevelListPtr = nextTopLevelPtr;
}
}
- if (menuPtr->masterMenuPtr == menuPtr) {
+ if (menuPtr->mainMenuPtr == menuPtr) {
while (menuPtr->nextInstancePtr != NULL) {
menuInstancePtr = menuPtr->nextInstancePtr;
menuPtr->nextInstancePtr = menuInstancePtr->nextInstancePtr;
@@ -1381,7 +1424,11 @@ UnhookCascadeEntry(
static void
DestroyMenuEntry(
- char *memPtr) /* Pointer to entry to be freed. */
+#if TCL_MAJOR_VERSION > 8
+ void *memPtr) /* Pointer to entry to be freed. */
+#else
+ char *memPtr)
+#endif
{
TkMenuEntry *mePtr = (TkMenuEntry *)memPtr;
TkMenu *menuPtr = mePtr->menuPtr;
@@ -1402,7 +1449,7 @@ DestroyMenuEntry(
*/
if (mePtr->type == CASCADE_ENTRY) {
- if (menuPtr->masterMenuPtr != menuPtr) {
+ if (menuPtr->mainMenuPtr != menuPtr) {
TkMenu *destroyThis = NULL;
TkMenuReferences *menuRefPtr = mePtr->childMenuRefPtr;
@@ -1422,7 +1469,7 @@ DestroyMenuEntry(
*/
if ((destroyThis != NULL)
- && (destroyThis->masterMenuPtr == destroyThis)) {
+ && (destroyThis->mainMenuPtr == destroyThis)) {
destroyThis = NULL;
}
}
@@ -1455,9 +1502,13 @@ DestroyMenuEntry(
TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
MenuVarProc, mePtr);
}
+ if (mePtr->entryPtr) {
+ Tcl_DeleteHashEntry(mePtr->entryPtr);
+ mePtr->entryPtr = NULL;
+ }
TkpDestroyMenuEntry(mePtr);
TkMenuEntryFreeDrawOptions(mePtr);
- Tk_FreeConfigOptions((char *) mePtr, mePtr->optionTable, menuPtr->tkwin);
+ Tk_FreeConfigOptions(mePtr, mePtr->optionTable, menuPtr->tkwin);
ckfree(mePtr);
}
@@ -1481,10 +1532,10 @@ DestroyMenuEntry(
static void
MenuWorldChanged(
- ClientData instanceData) /* Information about widget. */
+ void *instanceData) /* Information about widget. */
{
TkMenu *menuPtr = (TkMenu *)instanceData;
- int i;
+ Tcl_Size i;
TkMenuConfigureDrawOptions(menuPtr);
for (i = 0; i < menuPtr->numEntries; i++) {
@@ -1519,7 +1570,7 @@ ConfigureMenu(
Tcl_Interp *interp, /* Used for error reporting. */
TkMenu *menuPtr, /* Information about widget; may or may not
* already have values for some fields. */
- int objc, /* Number of valid entries in argv. */
+ Tcl_Size objc, /* Number of valid entries in argv. */
Tcl_Obj *const objv[]) /* Arguments. */
{
int i;
@@ -1528,14 +1579,14 @@ ConfigureMenu(
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
- for (menuListPtr = menuPtr->masterMenuPtr; menuListPtr != NULL;
+ for (menuListPtr = menuPtr->mainMenuPtr; menuListPtr != NULL;
menuListPtr = menuListPtr->nextInstancePtr) {
menuListPtr->errorStructPtr = (Tk_SavedOptions *)ckalloc(sizeof(Tk_SavedOptions));
- result = Tk_SetOptions(interp, (char *) menuListPtr,
+ result = Tk_SetOptions(interp, menuListPtr,
tsdPtr->menuOptionTable, objc, objv,
menuListPtr->tkwin, menuListPtr->errorStructPtr, NULL);
if (result != TCL_OK) {
- for (cleanupPtr = menuPtr->masterMenuPtr;
+ for (cleanupPtr = menuPtr->mainMenuPtr;
cleanupPtr != menuListPtr;
cleanupPtr = cleanupPtr->nextInstancePtr) {
Tk_RestoreSavedOptions(cleanupPtr->errorStructPtr);
@@ -1604,7 +1655,7 @@ ConfigureMenu(
if ((menuListPtr->numEntries == 0)
|| (menuListPtr->entries[0]->type != TEAROFF_ENTRY)) {
if (MenuNewEntry(menuListPtr, 0, TEAROFF_ENTRY) == NULL) {
- for (cleanupPtr = menuPtr->masterMenuPtr;
+ for (cleanupPtr = menuPtr->mainMenuPtr;
cleanupPtr != menuListPtr;
cleanupPtr = cleanupPtr->nextInstancePtr) {
Tk_RestoreSavedOptions(cleanupPtr->errorStructPtr);
@@ -1653,7 +1704,7 @@ ConfigureMenu(
TkEventuallyRecomputeMenu(menuListPtr);
}
- for (cleanupPtr = menuPtr->masterMenuPtr; cleanupPtr != NULL;
+ for (cleanupPtr = menuPtr->mainMenuPtr; cleanupPtr != NULL;
cleanupPtr = cleanupPtr->nextInstancePtr) {
Tk_FreeSavedOptions(cleanupPtr->errorStructPtr);
ckfree(cleanupPtr->errorStructPtr);
@@ -1701,12 +1752,12 @@ PostProcessEntry(
if (mePtr->labelPtr == NULL) {
mePtr->labelLength = 0;
} else {
- Tcl_GetStringFromObj(mePtr->labelPtr, &mePtr->labelLength);
+ (void)Tcl_GetStringFromObj(mePtr->labelPtr, &mePtr->labelLength);
}
if (mePtr->accelPtr == NULL) {
mePtr->accelLength = 0;
} else {
- Tcl_GetStringFromObj(mePtr->accelPtr, &mePtr->accelLength);
+ (void)Tcl_GetStringFromObj(mePtr->accelPtr, &mePtr->accelLength);
}
/*
@@ -1900,7 +1951,7 @@ static int
ConfigureMenuEntry(
TkMenuEntry *mePtr,/* Information about menu entry; may or may
* not already have values for some fields. */
- int objc, /* Number of valid entries in argv. */
+ Tcl_Size objc, /* Number of valid entries in argv. */
Tcl_Obj *const objv[]) /* Arguments. */
{
TkMenu *menuPtr = mePtr->menuPtr;
@@ -1924,7 +1975,7 @@ ConfigureMenuEntry(
result = TCL_OK;
if (menuPtr->tkwin != NULL) {
- if (Tk_SetOptions(menuPtr->interp, (char *) mePtr,
+ if (Tk_SetOptions(menuPtr->interp, mePtr,
mePtr->optionTable, objc, objv, menuPtr->tkwin,
&errorStruct, NULL) != TCL_OK) {
return TCL_ERROR;
@@ -1950,8 +2001,7 @@ ConfigureMenuEntry(
* Calls ConfigureMenuEntry for each menu in the clone chain.
*
* Results:
- * The return value is a standard Tcl result. If TCL_ERROR is returned,
- * then the interp's result contains an error message.
+ * The return value is a standard Tcl result.
*
* Side effects:
* Configuration information such as label and accelerator get set for
@@ -1962,10 +2012,9 @@ ConfigureMenuEntry(
static int
ConfigureMenuCloneEntries(
- Tcl_Interp *interp, /* Used for error reporting. */
TkMenu *menuPtr, /* Information about whole menu. */
int index, /* Index of mePtr within menuPtr's entries. */
- int objc, /* Number of valid entries in argv. */
+ Tcl_Size objc, /* Number of valid entries in argv. */
Tcl_Obj *const objv[]) /* Arguments. */
{
TkMenuEntry *mePtr;
@@ -1984,7 +2033,7 @@ ConfigureMenuCloneEntries(
* configure the entry to point to the new clone.
*/
- mePtr = menuPtr->masterMenuPtr->entries[index];
+ mePtr = menuPtr->mainMenuPtr->entries[index];
if (mePtr->type == CASCADE_ENTRY) {
oldCascadePtr = mePtr->namePtr;
if (oldCascadePtr != NULL) {
@@ -2029,7 +2078,7 @@ ConfigureMenuCloneEntries(
}
}
- for (menuListPtr = menuPtr->masterMenuPtr->nextInstancePtr;
+ for (menuListPtr = menuPtr->mainMenuPtr->nextInstancePtr;
menuListPtr != NULL;
menuListPtr = menuListPtr->nextInstancePtr) {
@@ -2054,9 +2103,9 @@ ConfigureMenuCloneEntries(
Tcl_Obj *newObjv[2];
Tcl_Obj *newCloneNamePtr;
Tcl_Obj *pathNamePtr = Tcl_NewStringObj(
- Tk_PathName(menuListPtr->tkwin), -1);
- Tcl_Obj *normalPtr = Tcl_NewStringObj("normal", -1);
- Tcl_Obj *menuObjPtr = Tcl_NewStringObj("-menu", -1);
+ Tk_PathName(menuListPtr->tkwin), TCL_INDEX_NONE);
+ Tcl_Obj *normalPtr = Tcl_NewStringObj("normal", TCL_INDEX_NONE);
+ Tcl_Obj *menuObjPtr = Tcl_NewStringObj("-menu", TCL_INDEX_NONE);
Tcl_IncrRefCount(pathNamePtr);
newCloneNamePtr = TkNewMenuName(menuPtr->interp,
@@ -2084,7 +2133,7 @@ ConfigureMenuCloneEntries(
/*
*--------------------------------------------------------------
*
- * TkGetMenuIndex --
+ * GetMenuIndex --
*
* Parse a textual index into a menu and return the numerical index of
* the indicated entry.
@@ -2102,7 +2151,7 @@ ConfigureMenuCloneEntries(
*/
int
-TkGetMenuIndex(
+GetMenuIndex(
Tcl_Interp *interp, /* For error messages. */
TkMenu *menuPtr, /* Menu for which the index is being
* specified. */
@@ -2110,27 +2159,44 @@ TkGetMenuIndex(
* manual entry for valid .*/
int lastOK, /* Non-zero means its OK to return index just
* *after* last entry. */
- int *indexPtr) /* Where to store converted index. */
+ Tcl_Size *indexPtr) /* Where to store converted index. */
{
- int i;
- const char *string = Tcl_GetString(objPtr);
+ Tcl_Size i;
+ const char *string;
+ Tcl_HashEntry *entryPtr;
+
+ if (TkGetIntForIndex(objPtr, menuPtr->numEntries - 1, lastOK, indexPtr) == TCL_OK) {
+ /* TCL_INDEX_NONE is only accepted if it does not result from a negative number */
+ if (*indexPtr >= 0 || Tcl_GetString(objPtr)[0] != '-') {
+ if (*indexPtr >= menuPtr->numEntries) {
+ *indexPtr = menuPtr->numEntries - ((lastOK) ? 0 : 1);
+ }
+ return TCL_OK;
+ }
+ }
+
+ string = Tcl_GetString(objPtr);
if ((string[0] == 'a') && (strcmp(string, "active") == 0)) {
*indexPtr = menuPtr->active;
return TCL_OK;
}
- if (((string[0] == 'l') && (strcmp(string, "last") == 0))
- || ((string[0] == 'e') && (strcmp(string, "end") == 0))) {
+ if ((string[0] == 'l') && (strcmp(string, "last") == 0)) {
*indexPtr = menuPtr->numEntries - ((lastOK) ? 0 : 1);
return TCL_OK;
}
- if ((string[0] == '\0') ||
- ((string[0] == 'n') && (strcmp(string, "none") == 0))) {
- *indexPtr = -1;
+ if (string[0] == 0) {
+ *indexPtr = TCL_INDEX_NONE;
+ return TCL_OK;
+ }
+#if !defined(TK_NO_DEPRECATED)
+ if ((string[0] == 'n') && (strcmp(string, "none") == 0)) {
+ *indexPtr = TCL_INDEX_NONE;
return TCL_OK;
}
+#endif
if (string[0] == '@') {
if (GetIndexFromCoords(interp, menuPtr, string, indexPtr)
@@ -2139,21 +2205,11 @@ TkGetMenuIndex(
}
}
- if (isdigit(UCHAR(string[0]))) {
- if (Tcl_GetIntFromObj(interp, objPtr, &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_ResetResult(interp);
+ entryPtr = Tcl_FindHashEntry(&menuPtr->items, string);
+ if (entryPtr) {
+ TkMenuEntry *mePtr = (TkMenuEntry *)Tcl_GetHashValue(entryPtr);
+ *indexPtr = mePtr->index;
+ return TCL_OK;
}
for (i = 0; i < menuPtr->numEntries; i++) {
@@ -2168,7 +2224,7 @@ TkGetMenuIndex(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad menu entry index \"%s\"", string));
- Tcl_SetErrorCode(interp, "TK", "MENU", "INDEX", NULL);
+ Tcl_SetErrorCode(interp, "TK", "MENU", "INDEX", (char *)NULL);
return TCL_ERROR;
}
@@ -2192,7 +2248,7 @@ TkGetMenuIndex(
static void
MenuCmdDeletedProc(
- ClientData clientData) /* Pointer to widget record for widget. */
+ void *clientData) /* Pointer to widget record for widget. */
{
TkMenu *menuPtr = (TkMenu *)clientData;
Tk_Window tkwin = menuPtr->tkwin;
@@ -2236,13 +2292,13 @@ MenuCmdDeletedProc(
static TkMenuEntry *
MenuNewEntry(
TkMenu *menuPtr, /* Menu that will hold the new entry. */
- int index, /* Where in the menu the new entry is to
+ Tcl_Size 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;
+ Tcl_Size i;
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
@@ -2270,7 +2326,7 @@ MenuNewEntry(
mePtr->menuPtr = menuPtr;
mePtr->labelPtr = NULL;
mePtr->labelLength = 0;
- mePtr->underline = -1;
+ mePtr->underline = INT_MIN;
mePtr->bitmapPtr = NULL;
mePtr->imagePtr = NULL;
mePtr->image = NULL;
@@ -2296,14 +2352,15 @@ MenuNewEntry(
mePtr->entryFlags = 0;
mePtr->index = index;
mePtr->nextCascadePtr = NULL;
- if (Tk_InitOptions(menuPtr->interp, (char *) mePtr,
+ if (Tk_InitOptions(menuPtr->interp, mePtr,
mePtr->optionTable, menuPtr->tkwin) != TCL_OK) {
ckfree(mePtr);
return NULL;
}
+ mePtr->entryPtr = NULL;
TkMenuInitializeEntryDrawingFields(mePtr);
if (TkpMenuNewEntry(mePtr) != TCL_OK) {
- Tk_FreeConfigOptions((char *) mePtr, mePtr->optionTable,
+ Tk_FreeConfigOptions(mePtr, mePtr->optionTable,
menuPtr->tkwin);
ckfree(mePtr);
return NULL;
@@ -2335,17 +2392,21 @@ MenuAddOrInsert(
TkMenu *menuPtr, /* Widget in which to create new entry. */
Tcl_Obj *indexPtr, /* Object describing index at which to insert.
* NULL means insert at end. */
- int objc, /* Number of elements in objv. */
+ Tcl_Size objc, /* Number of elements in objv. */
Tcl_Obj *const objv[]) /* Arguments to command: first arg is type of
* entry, others are config options. */
{
int type;
- int index;
+ Tcl_Size index;
TkMenuEntry *mePtr;
TkMenu *menuListPtr;
+ Tcl_HashEntry *entryPtr;
+ Tcl_Obj *idPtr = NULL;
+ int isNew;
+ int offs;
if (indexPtr != NULL) {
- if (TkGetMenuIndex(interp, menuPtr, indexPtr, 1, &index) != TCL_OK) {
+ if (GetMenuIndex(interp, menuPtr, indexPtr, 1, &index) != TCL_OK) {
return TCL_ERROR;
}
} else {
@@ -2353,8 +2414,8 @@ MenuAddOrInsert(
}
if (index < 0) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "bad index \"%s\"", Tcl_GetString(indexPtr)));
- Tcl_SetErrorCode(interp, "TK", "MENU", "INDEX", NULL);
+ "bad menu entry index \"%s\"", Tcl_GetString(indexPtr)));
+ Tcl_SetErrorCode(interp, "TK", "MENU", "INDEX", (char *)NULL);
return TCL_ERROR;
}
if (menuPtr->tearoff && (index == 0)) {
@@ -2369,26 +2430,42 @@ MenuAddOrInsert(
sizeof(char *), "menu entry type", 0, &type) != TCL_OK) {
return TCL_ERROR;
}
+ offs = 1;
/*
- * Now we have to add an entry for every instance related to this menu.
+ * Check for a user supplied id
*/
- for (menuListPtr = menuPtr->masterMenuPtr; menuListPtr != NULL;
+ if (objc % 2 == 0) {
+ idPtr = objv[offs];
+ if (Tcl_FindHashEntry(&menuPtr->items, Tcl_GetString(idPtr))) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "entry \"%s\" already exists", Tcl_GetString(idPtr)));
+ Tcl_SetErrorCode(interp, "TK", "MENU", "ENTRY_EXISTS", (char *)NULL);
+ return TCL_ERROR;
+ }
+ offs++;
+ }
+
+ /*
+ * Now we have to add an entry for every instance related to this menu.
+ */
+ for (menuListPtr = menuPtr->mainMenuPtr; menuListPtr != NULL;
menuListPtr = menuListPtr->nextInstancePtr) {
mePtr = MenuNewEntry(menuListPtr, index, type);
if (mePtr == NULL) {
return TCL_ERROR;
}
- if (ConfigureMenuEntry(mePtr, objc - 1, objv + 1) != TCL_OK) {
+ if (ConfigureMenuEntry(mePtr, objc - offs, objv + offs) != TCL_OK) {
TkMenu *errorMenuPtr;
- int i;
+ Tcl_Size i;
- for (errorMenuPtr = menuPtr->masterMenuPtr;
+ for (errorMenuPtr = menuPtr->mainMenuPtr;
errorMenuPtr != NULL;
errorMenuPtr = errorMenuPtr->nextInstancePtr) {
- Tcl_EventuallyFree(errorMenuPtr->entries[index], DestroyMenuEntry);
+ Tcl_EventuallyFree(errorMenuPtr->entries[index],
+ DestroyMenuEntry);
for (i = index; i < errorMenuPtr->numEntries - 1; i++) {
errorMenuPtr->entries[i] = errorMenuPtr->entries[i + 1];
errorMenuPtr->entries[i]->index = i;
@@ -2404,6 +2481,23 @@ MenuAddOrInsert(
return TCL_ERROR;
}
+ if (idPtr == NULL) {
+ char idbuf[16];
+ /* Generate an id for the new entry on the main menu */
+ do {
+ snprintf(idbuf, sizeof(idbuf), "e%03X", ++menuPtr->serial);
+ entryPtr = Tcl_CreateHashEntry(
+ &menuListPtr->items, idbuf, &isNew);
+ } while (!isNew);
+ idPtr = Tcl_NewStringObj(idbuf, TCL_INDEX_NONE);
+ } else {
+ /* Reuse the specified or previously generated id on all clones */
+ entryPtr = Tcl_CreateHashEntry(
+ &menuListPtr->items, Tcl_GetString(idPtr), &isNew);
+ }
+ Tcl_SetHashValue(entryPtr, mePtr);
+ mePtr->entryPtr = entryPtr;
+
/*
* 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
@@ -2417,12 +2511,12 @@ MenuAddOrInsert(
&& (mePtr->childMenuRefPtr != NULL)
&& (mePtr->childMenuRefPtr->menuPtr != NULL)) {
TkMenu *cascadeMenuPtr =
- mePtr->childMenuRefPtr->menuPtr->masterMenuPtr;
+ mePtr->childMenuRefPtr->menuPtr->mainMenuPtr;
Tcl_Obj *newCascadePtr, *newObjv[2];
- Tcl_Obj *menuNamePtr = Tcl_NewStringObj("-menu", -1);
+ Tcl_Obj *menuNamePtr = Tcl_NewStringObj("-menu", TCL_INDEX_NONE);
Tcl_Obj *windowNamePtr =
- Tcl_NewStringObj(Tk_PathName(menuListPtr->tkwin), -1);
- Tcl_Obj *normalPtr = Tcl_NewStringObj("normal", -1);
+ Tcl_NewStringObj(Tk_PathName(menuListPtr->tkwin), TCL_INDEX_NONE);
+ Tcl_Obj *normalPtr = Tcl_NewStringObj("normal", TCL_INDEX_NONE);
TkMenuReferences *menuRefPtr;
Tcl_IncrRefCount(windowNamePtr);
@@ -2449,6 +2543,8 @@ MenuAddOrInsert(
}
}
}
+
+ Tcl_SetObjResult(interp, idPtr);
return TCL_OK;
}
@@ -2472,10 +2568,10 @@ MenuAddOrInsert(
static char *
MenuVarProc(
- ClientData clientData, /* Information about menu entry. */
+ void *clientData, /* Information about menu entry. */
Tcl_Interp *interp, /* Interpreter containing variable. */
- const char *name1, /* First part of variable's name. */
- const char *name2, /* Second part of variable's name. */
+ TCL_UNUSED(const char *), /* First part of variable's name. */
+ TCL_UNUSED(const char *), /* Second part of variable's name. */
int flags) /* Describes what just happened. */
{
TkMenuEntry *mePtr = (TkMenuEntry *)clientData;
@@ -2505,26 +2601,26 @@ MenuVarProc(
*/
if (flags & TCL_TRACE_UNSETS) {
- ClientData probe = NULL;
+ void *probe = NULL;
mePtr->entryFlags &= ~ENTRY_SELECTED;
- do {
- probe = Tcl_VarTraceInfo(interp, name,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- MenuVarProc, probe);
- if (probe == (ClientData)mePtr) {
- break;
- }
- } while (probe);
- if (probe) {
- /*
- * We were able to fetch the unset trace for our
- * namePtr, which means it is not unset and not
- * the cause of this unset trace. Instead some outdated
- * former variable must be, and we should ignore it.
- */
+ do {
+ probe = Tcl_VarTraceInfo(interp, name,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ MenuVarProc, probe);
+ if (probe == (void *)mePtr) {
+ break;
+ }
+ } while (probe);
+ if (probe) {
+ /*
+ * We were able to fetch the unset trace for our
+ * namePtr, which means it is not unset and not
+ * the cause of this unset trace. Instead some outdated
+ * former variable must be, and we should ignore it.
+ */
return NULL;
- }
+ }
Tcl_TraceVar2(interp, name, NULL,
TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
MenuVarProc, clientData);
@@ -2584,8 +2680,8 @@ MenuVarProc(
int
TkActivateMenuEntry(
TkMenu *menuPtr, /* Menu in which to activate. */
- int index) /* Index of entry to activate, or -1 to
- * deactivate all entries. */
+ Tcl_Size index) /* Index of entry to activate, or
+ * TCL_INDEX_NONE to deactivate all entries. */
{
TkMenuEntry *mePtr;
int result = TCL_OK;
@@ -2685,7 +2781,7 @@ CloneMenu(
{
int returnResult;
int menuType;
- int i;
+ Tcl_Size i;
TkMenuReferences *menuRefPtr;
Tcl_Obj *menuDupCommandArray[4];
@@ -2698,11 +2794,11 @@ CloneMenu(
}
}
- menuDupCommandArray[0] = Tcl_NewStringObj("tk::MenuDup", -1);
- menuDupCommandArray[1] = Tcl_NewStringObj(Tk_PathName(menuPtr->tkwin), -1);
+ menuDupCommandArray[0] = Tcl_NewStringObj("tk::MenuDup", TCL_INDEX_NONE);
+ menuDupCommandArray[1] = Tcl_NewStringObj(Tk_PathName(menuPtr->tkwin), TCL_INDEX_NONE);
menuDupCommandArray[2] = newMenuNamePtr;
if (newMenuTypePtr == NULL) {
- menuDupCommandArray[3] = Tcl_NewStringObj("normal", -1);
+ menuDupCommandArray[3] = Tcl_NewStringObj("normal", TCL_INDEX_NONE);
} else {
menuDupCommandArray[3] = newMenuTypePtr;
}
@@ -2725,7 +2821,7 @@ CloneMenu(
&& (menuPtr->numEntries == menuRefPtr->menuPtr->numEntries)) {
TkMenu *newMenuPtr = menuRefPtr->menuPtr;
Tcl_Obj *newObjv[3];
- int numElements;
+ Tcl_Size numElements;
/*
* Now put this newly created menu into the parent menu's instance
@@ -2734,14 +2830,14 @@ CloneMenu(
if (menuPtr->nextInstancePtr == NULL) {
menuPtr->nextInstancePtr = newMenuPtr;
- newMenuPtr->masterMenuPtr = menuPtr->masterMenuPtr;
+ newMenuPtr->mainMenuPtr = menuPtr->mainMenuPtr;
} else {
- TkMenu *masterMenuPtr;
+ TkMenu *mainMenuPtr;
- masterMenuPtr = menuPtr->masterMenuPtr;
- newMenuPtr->nextInstancePtr = masterMenuPtr->nextInstancePtr;
- masterMenuPtr->nextInstancePtr = newMenuPtr;
- newMenuPtr->masterMenuPtr = masterMenuPtr;
+ mainMenuPtr = menuPtr->mainMenuPtr;
+ newMenuPtr->nextInstancePtr = mainMenuPtr->nextInstancePtr;
+ mainMenuPtr->nextInstancePtr = newMenuPtr;
+ newMenuPtr->mainMenuPtr = mainMenuPtr;
}
/*
@@ -2751,8 +2847,8 @@ CloneMenu(
* structure.
*/
- newObjv[0] = Tcl_NewStringObj("bindtags", -1);
- newObjv[1] = Tcl_NewStringObj(Tk_PathName(newMenuPtr->tkwin), -1);
+ newObjv[0] = Tcl_NewStringObj("bindtags", TCL_INDEX_NONE);
+ newObjv[1] = Tcl_NewStringObj(Tk_PathName(newMenuPtr->tkwin), TCL_INDEX_NONE);
Tcl_IncrRefCount(newObjv[0]);
Tcl_IncrRefCount(newObjv[1]);
if (Tk_BindtagsObjCmd(newMenuPtr->tkwin, newMenuPtr->interp, 2,
@@ -2771,7 +2867,7 @@ CloneMenu(
if (strcmp(windowName, Tk_PathName(newMenuPtr->tkwin))
== 0) {
Tcl_Obj *newElementPtr = Tcl_NewStringObj(
- Tk_PathName(newMenuPtr->masterMenuPtr->tkwin), -1);
+ Tk_PathName(newMenuPtr->mainMenuPtr->tkwin), TCL_INDEX_NONE);
/*
* The newElementPtr will have its refCount incremented
@@ -2819,7 +2915,7 @@ CloneMenu(
Tcl_IncrRefCount(newCascadePtr);
CloneMenu(oldCascadePtr, newCascadePtr, NULL);
- newObjv[0] = Tcl_NewStringObj("-menu", -1);
+ newObjv[0] = Tcl_NewStringObj("-menu", TCL_INDEX_NONE);
newObjv[1] = newCascadePtr;
Tcl_IncrRefCount(newObjv[0]);
ConfigureMenuEntry(newMenuPtr->entries[i], 2, newObjv);
@@ -2860,17 +2956,17 @@ MenuDoXPosition(
TkMenu *menuPtr,
Tcl_Obj *objPtr)
{
- int index;
+ Tcl_Size index;
TkRecomputeMenu(menuPtr);
- if (TkGetMenuIndex(interp, menuPtr, objPtr, 0, &index) != TCL_OK) {
+ if (GetMenuIndex(interp, menuPtr, objPtr, 0, &index) != TCL_OK) {
return TCL_ERROR;
}
Tcl_ResetResult(interp);
if (index < 0) {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(0));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(0));
} else {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(menuPtr->entries[index]->x));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(menuPtr->entries[index]->x));
}
return TCL_OK;
}
@@ -2897,17 +2993,17 @@ MenuDoYPosition(
TkMenu *menuPtr,
Tcl_Obj *objPtr)
{
- int index;
+ Tcl_Size index;
TkRecomputeMenu(menuPtr);
- if (TkGetMenuIndex(interp, menuPtr, objPtr, 0, &index) != TCL_OK) {
+ if (GetMenuIndex(interp, menuPtr, objPtr, 0, &index) != TCL_OK) {
goto error;
}
Tcl_ResetResult(interp);
if (index < 0) {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(0));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(0));
} else {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(menuPtr->entries[index]->y));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(menuPtr->entries[index]->y));
}
return TCL_OK;
@@ -2935,40 +3031,40 @@ MenuDoYPosition(
*----------------------------------------------------------------------
*/
-static int
+static Tcl_Size
GetIndexFromCoords(
Tcl_Interp *interp, /* Interpreter of menu. */
TkMenu *menuPtr, /* The menu we are searching. */
const char *string, /* The @string we are parsing. */
- int *indexPtr) /* The index of the item that matches. */
+ Tcl_Size *indexPtr) /* The index of the item that matches. */
{
int x, y;
- int i;
+ Tcl_Size i;
const char *p;
- char *end;
+ const char *rest;
int x2, borderwidth, max;
TkRecomputeMenu(menuPtr);
p = string + 1;
- y = strtol(p, &end, 0);
- if (end == p) {
- goto error;
- }
- Tk_GetPixelsFromObj(interp, menuPtr->tkwin,
- menuPtr->borderWidthPtr, &borderwidth);
- if (*end == ',') {
- x = y;
- p = end + 1;
- y = strtol(p, &end, 0);
- if ((end == p) || (*end != '\0')) {
+ Tk_GetPixelsFromObj(NULL, menuPtr->tkwin,
+ menuPtr->borderWidthPtr, &borderwidth);
+ rest = strchr(p, ',');
+ if (rest) {
+ Tcl_DString ds;
+ Tcl_DStringInit(&ds);
+ Tcl_DStringAppend(&ds, p, rest - p);
+
+ if (Tcl_GetInt(NULL, Tcl_DStringValue(&ds), &x) != TCL_OK) {
goto error;
}
} else {
- if (*end != '\0') {
- goto error;
- }
x = borderwidth;
+ rest = string;
}
+ p = rest + 1;
+ if (Tcl_GetInt(NULL, p, &y) != TCL_OK) {
+ goto error;
+ }
*indexPtr = -1;
@@ -3022,7 +3118,7 @@ static void
RecursivelyDeleteMenu(
TkMenu *menuPtr) /* The menubar instance we are deleting. */
{
- int i;
+ Tcl_Size i;
TkMenuEntry *mePtr;
/*
@@ -3085,7 +3181,7 @@ TkNewMenuName(
doDot = parentName[strlen(parentName) - 1] != '.';
- childPtr = Tcl_NewStringObj(Tk_PathName(menuPtr->tkwin), -1);
+ childPtr = Tcl_NewStringObj(Tk_PathName(menuPtr->tkwin), TCL_INDEX_NONE);
for (destString = Tcl_GetString(childPtr);
*destString != '\0'; destString++) {
if (*destString == '.') {
@@ -3097,7 +3193,7 @@ TkNewMenuName(
if (i == 0) {
resultPtr = Tcl_DuplicateObj(parentPtr);
if (doDot) {
- Tcl_AppendToObj(resultPtr, ".", -1);
+ Tcl_AppendToObj(resultPtr, ".", TCL_INDEX_NONE);
}
Tcl_AppendObjToObj(resultPtr, childPtr);
} else {
@@ -3106,10 +3202,10 @@ TkNewMenuName(
Tcl_DecrRefCount(resultPtr);
resultPtr = Tcl_DuplicateObj(parentPtr);
if (doDot) {
- Tcl_AppendToObj(resultPtr, ".", -1);
+ Tcl_AppendToObj(resultPtr, ".", TCL_INDEX_NONE);
}
Tcl_AppendObjToObj(resultPtr, childPtr);
- intPtr = Tcl_NewIntObj(i);
+ intPtr = Tcl_NewWideIntObj(i);
Tcl_AppendObjToObj(resultPtr, intPtr);
Tcl_DecrRefCount(intPtr);
}
@@ -3127,7 +3223,7 @@ TkNewMenuName(
/*
*----------------------------------------------------------------------
*
- * TkSetWindowMenuBar --
+ * Tk_SetWindowMenubar --
*
* Associates a menu with a window. Called by ConfigureFrame in in
* response to a "-menu .foo" configuration option for a top level.
@@ -3143,7 +3239,7 @@ TkNewMenuName(
*/
void
-TkSetWindowMenuBar(
+Tk_SetWindowMenubar(
Tcl_Interp *interp, /* The interpreter the toplevel lives in. */
Tk_Window tkwin, /* The toplevel window. */
const char *oldMenuName, /* The name of the menubar previously set in
@@ -3175,7 +3271,7 @@ TkSetWindowMenuBar(
menuPtr = menuRefPtr->menuPtr;
- for (instancePtr = menuPtr->masterMenuPtr;
+ for (instancePtr = menuPtr->mainMenuPtr;
instancePtr != NULL;
instancePtr = instancePtr->nextInstancePtr) {
if (instancePtr->menuType == MENUBAR
@@ -3234,7 +3330,7 @@ TkSetWindowMenuBar(
Tcl_Obj *newObjv[4];
Tcl_Obj *windowNamePtr = Tcl_NewStringObj(Tk_PathName(tkwin),
-1);
- Tcl_Obj *menubarPtr = Tcl_NewStringObj("menubar", -1);
+ Tcl_Obj *menubarPtr = Tcl_NewStringObj("menubar", TCL_INDEX_NONE);
/*
* Clone the menu and all of the cascades underneath it.
@@ -3250,7 +3346,7 @@ TkSetWindowMenuBar(
cloneMenuRefPtr = TkFindMenuReferencesObj(interp, cloneMenuPtr);
if ((cloneMenuRefPtr != NULL)
&& (cloneMenuRefPtr->menuPtr != NULL)) {
- Tcl_Obj *cursorPtr = Tcl_NewStringObj("-cursor", -1);
+ Tcl_Obj *cursorPtr = Tcl_NewStringObj("-cursor", TCL_INDEX_NONE);
Tcl_Obj *nullPtr = Tcl_NewObj();
cloneMenuRefPtr->menuPtr->parentTopLevelPtr = tkwin;
@@ -3285,7 +3381,7 @@ TkSetWindowMenuBar(
} else {
TkpSetWindowMenuBar(tkwin, NULL);
}
- TkpSetMainMenubar(interp, tkwin, menuName);
+ Tk_SetMainMenubar(interp, tkwin, menuName);
}
/*
@@ -3307,8 +3403,8 @@ TkSetWindowMenuBar(
static void
DestroyMenuHashTable(
- ClientData clientData, /* The menu hash table we are destroying. */
- Tcl_Interp *interp) /* The interpreter we are destroying. */
+ void *clientData, /* The menu hash table we are destroying. */
+ TCL_UNUSED(Tcl_Interp *)) /* The interpreter we are destroying. */
{
Tcl_DeleteHashTable((Tcl_HashTable *)clientData);
ckfree(clientData);
@@ -3518,10 +3614,10 @@ DeleteMenuCloneEntries(
int last) /* The zero-based last entry. */
{
TkMenu *menuListPtr;
- int numDeleted, i, j;
+ Tcl_Size numDeleted, i, j;
numDeleted = last + 1 - first;
- for (menuListPtr = menuPtr->masterMenuPtr; menuListPtr != NULL;
+ for (menuListPtr = menuPtr->mainMenuPtr; menuListPtr != NULL;
menuListPtr = menuListPtr->nextInstancePtr) {
for (i = last; i >= first; i--) {
Tcl_EventuallyFree(menuListPtr->entries[i], DestroyMenuEntry);
@@ -3536,10 +3632,10 @@ DeleteMenuCloneEntries(
ckfree(menuListPtr->entries);
menuListPtr->entries = NULL;
}
- if ((menuListPtr->active >= first)
- && (menuListPtr->active <= last)) {
+ if (((int)menuListPtr->active >= first)
+ && ((int)menuListPtr->active <= last)) {
menuListPtr->active = -1;
- } else if (menuListPtr->active > last) {
+ } else if ((int)menuListPtr->active > last) {
menuListPtr->active -= numDeleted;
}
TkEventuallyRecomputeMenu(menuListPtr);
@@ -3549,7 +3645,7 @@ DeleteMenuCloneEntries(
/*
*----------------------------------------------------------------------
*
- * TkMenuCleanup --
+ * MenuCleanup --
*
* Resets menusInitialized to allow Tk to be finalized and reused without
* the DLL being unloaded.
@@ -3564,8 +3660,8 @@ DeleteMenuCloneEntries(
*/
static void
-TkMenuCleanup(
- ClientData unused)
+MenuCleanup(
+ TCL_UNUSED(void *))
{
menusInitialized = 0;
}
@@ -3604,7 +3700,7 @@ TkMenuInit(void)
* Make sure we cleanup on finalize.
*/
- TkCreateExitHandler((Tcl_ExitProc *) TkMenuCleanup, NULL);
+ TkCreateExitHandler((Tcl_ExitProc *) MenuCleanup, NULL);
Tcl_MutexUnlock(&menuMutex);
}
if (!tsdPtr->menusInitialized) {
diff --git a/generic/tkMenu.h b/generic/tkMenu.h
index ccc365a..ffe6770 100644
--- a/generic/tkMenu.h
+++ b/generic/tkMenu.h
@@ -4,7 +4,7 @@
* Declarations shared among all of the files that implement menu
* widgets.
*
- * Copyright (c) 1996-1998 Sun Microsystems, Inc.
+ * Copyright © 1996-1998 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -64,11 +64,11 @@ typedef struct TkMenuEntry {
Tk_OptionTable optionTable; /* Option table for this menu entry. */
Tcl_Obj *labelPtr; /* Main text label displayed in entry (NULL if
* no label). */
- int labelLength; /* Number of non-NULL characters in label. */
+ Tcl_Size labelLength; /* Number of non-NULL characters in label. */
int state; /* State of button for display purposes:
* normal, active, or disabled. */
int underline; /* Value of -underline option: specifies index
- * of character to underline (<0 means don't
+ * of character to underline (-1 means don't
* underline anything). */
Tcl_Obj *underlinePtr; /* Index of character to underline. */
Tcl_Obj *bitmapPtr; /* Bitmap to display in menu entry, or NULL.
@@ -85,7 +85,7 @@ typedef struct TkMenuEntry {
Tcl_Obj *accelPtr; /* Accelerator string displayed at right of
* menu entry. NULL means no such accelerator.
* Malloc'ed. */
- int accelLength; /* Number of non-NULL characters in
+ Tcl_Size accelLength; /* Number of non-NULL characters in
* accelerator. */
int indicatorOn; /* True means draw indicator, false means
* don't draw it. This field is ignored unless
@@ -183,6 +183,7 @@ typedef struct TkMenuEntry {
int index; /* Need to know which index we are. This is
* zero-based. This is the top-left entry of
* the menu. */
+ Tcl_HashEntry *entryPtr; /* Back-pointer to hash table entry */
/*
* Bookeeping for main menus and cascade menus.
@@ -244,8 +245,8 @@ typedef struct TkMenuEntry {
*/
#define ENTRY_ACTIVE 0
-#define ENTRY_NORMAL 1
-#define ENTRY_DISABLED 2
+#define ENTRY_DISABLED 1
+#define ENTRY_NORMAL 2
/*
* A data structure of the following type is kept for each menu widget:
@@ -263,9 +264,9 @@ typedef struct TkMenu {
Tcl_Command widgetCmd; /* Token for menu's widget command. */
TkMenuEntry **entries; /* Array of pointers to all the entries in the
* menu. NULL means no entries. */
- int numEntries; /* Number of elements in entries. */
- int active; /* Index of active entry. -1 means nothing
- * active. */
+ Tcl_Size numEntries; /* Number of elements in entries. */
+ Tcl_Size active; /* Index of active entry. TCL_INDEX_NONE means
+ * nothing active. */
int menuType; /* MAIN_MENU, TEAROFF_MENU, or MENUBAR. See
* below for definitions. */
Tcl_Obj *menuTypePtr; /* Used to control whether created tkwin is a
@@ -351,7 +352,7 @@ typedef struct TkMenu {
struct TkMenu *nextInstancePtr;
/* The next instance of this menu in the
* chain. */
- struct TkMenu *masterMenuPtr;
+ struct TkMenu *mainMenuPtr;
/* A pointer to the original menu for this
* clone chain. Points back to this structure
* if this menu is a main menu. */
@@ -378,6 +379,9 @@ typedef struct TkMenu {
/* We actually have to allocate these because
* multiple menus get changed during one
* ConfigureMenu call. */
+ Tcl_Obj *activeReliefPtr; /* 3-d effect for active element. */
+ Tcl_HashTable items; /* Map: id -> entry */
+ int serial; /* Next item # for autogenerated ids */
} TkMenu;
/*
@@ -460,10 +464,9 @@ typedef struct TkMenuReferences {
*/
#define UNKNOWN_TYPE -1
-#define MAIN_MENU 0
-#define MASTER_MENU 0
-#define TEAROFF_MENU 1
-#define MENUBAR 2
+#define MENUBAR 0
+#define MAIN_MENU 1
+#define TEAROFF_MENU 2
/*
* Various geometry definitions:
@@ -478,7 +481,7 @@ typedef struct TkMenuReferences {
* the outside world:
*/
-MODULE_SCOPE int TkActivateMenuEntry(TkMenu *menuPtr, int index);
+MODULE_SCOPE int TkActivateMenuEntry(TkMenu *menuPtr, Tcl_Size index);
MODULE_SCOPE void TkBindMenu(Tk_Window tkwin, TkMenu *menuPtr);
MODULE_SCOPE TkMenuReferences*TkCreateMenuReferences(Tcl_Interp *interp,
const char *name);
@@ -491,24 +494,22 @@ MODULE_SCOPE TkMenuReferences*TkFindMenuReferencesObj(Tcl_Interp *interp,
Tcl_Obj *namePtr);
MODULE_SCOPE int TkFreeMenuReferences(TkMenuReferences *menuRefPtr);
MODULE_SCOPE Tcl_HashTable *TkGetMenuHashTable(Tcl_Interp *interp);
-MODULE_SCOPE int TkGetMenuIndex(Tcl_Interp *interp, TkMenu *menuPtr,
- Tcl_Obj *objPtr, int lastOK, int *indexPtr);
MODULE_SCOPE void TkMenuInitializeDrawingFields(TkMenu *menuPtr);
MODULE_SCOPE void TkMenuInitializeEntryDrawingFields(TkMenuEntry *mePtr);
MODULE_SCOPE int TkInvokeMenu(Tcl_Interp *interp, TkMenu *menuPtr,
- int index);
+ Tcl_Size index);
MODULE_SCOPE void TkMenuConfigureDrawOptions(TkMenu *menuPtr);
MODULE_SCOPE int TkMenuConfigureEntryDrawOptions(
- TkMenuEntry *mePtr, int index);
+ TkMenuEntry *mePtr, Tcl_Size index);
MODULE_SCOPE void TkMenuFreeDrawOptions(TkMenu *menuPtr);
MODULE_SCOPE void TkMenuEntryFreeDrawOptions(TkMenuEntry *mePtr);
-MODULE_SCOPE void TkMenuEventProc(ClientData clientData,
+MODULE_SCOPE void TkMenuEventProc(void *clientData,
XEvent *eventPtr);
-MODULE_SCOPE void TkMenuImageProc(ClientData clientData, int x, int y,
+MODULE_SCOPE void TkMenuImageProc(void *clientData, int x, int y,
int width, int height, int imgWidth,
int imgHeight);
MODULE_SCOPE void TkMenuInit(void);
-MODULE_SCOPE void TkMenuSelectImageProc(ClientData clientData, int x,
+MODULE_SCOPE void TkMenuSelectImageProc(void *clientData, int x,
int y, int width, int height, int imgWidth,
int imgHeight);
MODULE_SCOPE Tcl_Obj * TkNewMenuName(Tcl_Interp *interp,
@@ -540,9 +541,9 @@ MODULE_SCOPE void TkpMenuInit(void);
MODULE_SCOPE int TkpMenuNewEntry(TkMenuEntry *mePtr);
MODULE_SCOPE int TkpNewMenu(TkMenu *menuPtr);
MODULE_SCOPE int TkpPostMenu(Tcl_Interp *interp, TkMenu *menuPtr,
- int x, int y, int index);
+ int x, int y, Tcl_Size index);
MODULE_SCOPE int TkpPostTearoffMenu(Tcl_Interp *interp, TkMenu *menuPtr,
- int x, int y, int index);
+ int x, int y, Tcl_Size index);
MODULE_SCOPE void TkpSetWindowMenuBar(Tk_Window tkwin, TkMenu *menuPtr);
#endif /* _TKMENU */
diff --git a/generic/tkMenuDraw.c b/generic/tkMenuDraw.c
index 1ac4558..62ab105 100644
--- a/generic/tkMenuDraw.c
+++ b/generic/tkMenuDraw.c
@@ -4,7 +4,7 @@
* This module implements the platform-independent drawing and geometry
* calculations of menu widgets.
*
- * Copyright (c) 1996-1997 Sun Microsystems, Inc.
+ * Copyright © 1996-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.
@@ -19,8 +19,8 @@
static void AdjustMenuCoords(TkMenu *menuPtr, TkMenuEntry *mePtr,
int *xPtr, int *yPtr);
-static void ComputeMenuGeometry(ClientData clientData);
-static void DisplayMenu(ClientData clientData);
+static void ComputeMenuGeometry(void *clientData);
+static void DisplayMenu(void *clientData);
/*
*----------------------------------------------------------------------
@@ -298,7 +298,7 @@ TkMenuConfigureDrawOptions(
int
TkMenuConfigureEntryDrawOptions(
TkMenuEntry *mePtr,
- int index)
+ Tcl_Size index)
{
XGCValues gcValues;
GC newGC, newActiveGC, newDisabledGC, newIndicatorGC;
@@ -315,7 +315,7 @@ TkMenuConfigureEntryDrawOptions(
}
} else {
if (index == menuPtr->active) {
- TkActivateMenuEntry(menuPtr, -1);
+ TkActivateMenuEntry(menuPtr, TCL_INDEX_NONE);
}
}
@@ -487,7 +487,7 @@ TkEventuallyRedrawMenu(
TkMenuEntry *mePtr)/* Entry to redraw. NULL means redraw all the
* entries in the menu. */
{
- int i;
+ Tcl_Size i;
if (menuPtr->tkwin == NULL) {
return;
@@ -528,9 +528,9 @@ TkEventuallyRedrawMenu(
static void
ComputeMenuGeometry(
- ClientData clientData) /* Structure describing menu. */
+ void *clientData) /* Structure describing menu. */
{
- TkMenu *menuPtr = clientData;
+ TkMenu *menuPtr = (TkMenu *)clientData;
if (menuPtr->tkwin == NULL) {
return;
@@ -579,14 +579,15 @@ ComputeMenuGeometry(
void
TkMenuSelectImageProc(
- ClientData clientData, /* Pointer to widget record. */
- int x, int y, /* Upper left pixel (within image) that must
- * be redisplayed. */
- int width, int height, /* Dimensions of area to redisplay (may be
- * <=0). */
- int imgWidth, int imgHeight)/* New dimensions of image. */
+ void *clientData, /* Pointer to widget record. */
+ TCL_UNUSED(int), /* Upper left pixel (within image) that must */
+ TCL_UNUSED(int), /* be redisplayed. */
+ TCL_UNUSED(int), /* Dimensions of area to redisplay (may be */
+ TCL_UNUSED(int), /* <= 0). */
+ TCL_UNUSED(int),
+ TCL_UNUSED(int))/* New dimensions of image. */
{
- TkMenuEntry *mePtr = clientData;
+ TkMenuEntry *mePtr = (TkMenuEntry *)clientData;
if ((mePtr->entryFlags & ENTRY_SELECTED)
&& !(mePtr->menuPtr->menuFlags & REDRAW_PENDING)) {
@@ -613,12 +614,13 @@ TkMenuSelectImageProc(
static void
DisplayMenu(
- ClientData clientData) /* Information about widget. */
+ void *clientData) /* Information about widget. */
{
- TkMenu *menuPtr = clientData;
+ TkMenu *menuPtr = (TkMenu *)clientData;
TkMenuEntry *mePtr;
Tk_Window tkwin = menuPtr->tkwin;
- int index, strictMotif;
+ Tcl_Size index;
+ int strictMotif;
Tk_Font tkfont;
Tk_FontMetrics menuMetrics;
int width;
@@ -756,10 +758,10 @@ DisplayMenu(
void
TkMenuEventProc(
- ClientData clientData, /* Information about window. */
+ void *clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
- TkMenu *menuPtr = clientData;
+ TkMenu *menuPtr = (TkMenu *)clientData;
if ((eventPtr->type == Expose) && (eventPtr->xexpose.count == 0)) {
TkEventuallyRedrawMenu(menuPtr, NULL);
@@ -768,7 +770,7 @@ TkMenuEventProc(
TkEventuallyRedrawMenu(menuPtr, NULL);
} else if (eventPtr->type == ActivateNotify) {
if (menuPtr->menuType == TEAROFF_MENU) {
- TkpSetMainMenubar(menuPtr->interp, menuPtr->tkwin, NULL);
+ Tk_SetMainMenubar(menuPtr->interp, menuPtr->tkwin, NULL);
}
} else if (eventPtr->type == DestroyNotify) {
if (menuPtr->tkwin != NULL) {
@@ -817,14 +819,15 @@ TkMenuEventProc(
void
TkMenuImageProc(
- ClientData clientData, /* Pointer to widget record. */
- int x, int y, /* Upper left pixel (within image) that must
- * be redisplayed. */
- int width, int height, /* Dimensions of area to redisplay (may be
- * <=0). */
- int imgWidth, int imgHeight)/* New dimensions of image. */
+ void *clientData,/* Pointer to widget record. */
+ TCL_UNUSED(int), /* Upper left pixel (within image) that must */
+ TCL_UNUSED(int), /* * be redisplayed. */
+ TCL_UNUSED(int), /* Dimensions of area to redisplay (may be */
+ TCL_UNUSED(int), /* <=0). */
+ TCL_UNUSED(int), /* New dimensions of image. */
+ TCL_UNUSED(int))
{
- TkMenu *menuPtr = ((TkMenuEntry *) clientData)->menuPtr;
+ TkMenu *menuPtr = (TkMenu *)((TkMenuEntry *) clientData)->menuPtr;
if ((menuPtr->tkwin != NULL) && !(menuPtr->menuFlags & RESIZE_PENDING)) {
menuPtr->menuFlags |= RESIZE_PENDING;
@@ -911,7 +914,7 @@ TkPostSubmenu(
*/
subary[0] = menuPtr->postedCascade->namePtr;
- subary[1] = Tcl_NewStringObj("unpost", -1);
+ subary[1] = Tcl_NewStringObj("unpost", TCL_INDEX_NONE);
Tcl_IncrRefCount(subary[1]);
TkEventuallyRedrawMenu(menuPtr, NULL);
result = Tcl_EvalObjv(interp, 2, subary, 0);
@@ -940,9 +943,9 @@ TkPostSubmenu(
menuPtr->postedCascade = mePtr;
subary[0] = mePtr->namePtr;
- subary[1] = Tcl_NewStringObj("post", -1);
- subary[2] = Tcl_NewIntObj(x);
- subary[3] = Tcl_NewIntObj(y);
+ subary[1] = Tcl_NewStringObj("post", TCL_INDEX_NONE);
+ subary[2] = Tcl_NewWideIntObj(x);
+ subary[3] = Tcl_NewWideIntObj(y);
Tcl_IncrRefCount(subary[1]);
Tcl_IncrRefCount(subary[2]);
Tcl_IncrRefCount(subary[3]);
diff --git a/generic/tkMenubutton.c b/generic/tkMenubutton.c
index 9e17b36..0dd8396 100644
--- a/generic/tkMenubutton.c
+++ b/generic/tkMenubutton.c
@@ -4,8 +4,8 @@
* 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.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 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.
@@ -13,7 +13,6 @@
#include "tkInt.h"
#include "tkMenubutton.h"
-#include "default.h"
/*
* The structure below defines menubutton class behavior by means of
@@ -42,99 +41,98 @@ static const char *const directionStrings[] = {
static const Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_BORDER, "-activebackground", "activeBackground", "Foreground",
- DEF_MENUBUTTON_ACTIVE_BG_COLOR, -1,
- Tk_Offset(TkMenuButton, activeBorder), 0,
- (ClientData) DEF_MENUBUTTON_ACTIVE_BG_MONO, 0},
+ DEF_MENUBUTTON_ACTIVE_BG_COLOR, TCL_INDEX_NONE,
+ offsetof(TkMenuButton, activeBorder), 0,
+ DEF_MENUBUTTON_ACTIVE_BG_MONO, 0},
{TK_OPTION_COLOR, "-activeforeground", "activeForeground", "Background",
- DEF_MENUBUTTON_ACTIVE_FG_COLOR, -1,
- Tk_Offset(TkMenuButton, activeFg),
+ DEF_MENUBUTTON_ACTIVE_FG_COLOR, TCL_INDEX_NONE,
+ offsetof(TkMenuButton, activeFg),
0, DEF_MENUBUTTON_ACTIVE_FG_MONO, 0},
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
- DEF_MENUBUTTON_ANCHOR, -1,
- Tk_Offset(TkMenuButton, anchor), 0, 0, 0},
+ DEF_MENUBUTTON_ANCHOR, TCL_INDEX_NONE,
+ offsetof(TkMenuButton, anchor), TK_OPTION_ENUM_VAR, 0, 0},
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_MENUBUTTON_BG_COLOR, -1, Tk_Offset(TkMenuButton, normalBorder),
+ DEF_MENUBUTTON_BG_COLOR, TCL_INDEX_NONE, offsetof(TkMenuButton, normalBorder),
0, DEF_MENUBUTTON_BG_MONO, 0},
- {TK_OPTION_SYNONYM, "-bd", NULL, NULL, NULL, 0, -1,
+ {TK_OPTION_SYNONYM, "-bd", NULL, NULL, NULL, 0, TCL_INDEX_NONE,
0, "-borderwidth", 0},
- {TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, 0, -1,
+ {TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, 0, TCL_INDEX_NONE,
0, "-background", 0},
{TK_OPTION_BITMAP, "-bitmap", "bitmap", "Bitmap",
- DEF_MENUBUTTON_BITMAP, -1, Tk_Offset(TkMenuButton, bitmap),
+ DEF_MENUBUTTON_BITMAP, TCL_INDEX_NONE, offsetof(TkMenuButton, bitmap),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_MENUBUTTON_BORDER_WIDTH, -1,
- Tk_Offset(TkMenuButton, borderWidth), 0, 0, 0},
+ DEF_MENUBUTTON_BORDER_WIDTH, TCL_INDEX_NONE,
+ offsetof(TkMenuButton, borderWidth), 0, 0, 0},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_MENUBUTTON_CURSOR, -1, Tk_Offset(TkMenuButton, cursor),
+ DEF_MENUBUTTON_CURSOR, TCL_INDEX_NONE, offsetof(TkMenuButton, cursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING_TABLE, "-direction", "direction", "Direction",
- DEF_MENUBUTTON_DIRECTION, -1, Tk_Offset(TkMenuButton, direction),
+ DEF_MENUBUTTON_DIRECTION, TCL_INDEX_NONE, offsetof(TkMenuButton, direction),
TK_OPTION_ENUM_VAR, directionStrings, 0},
{TK_OPTION_COLOR, "-disabledforeground", "disabledForeground",
"DisabledForeground", DEF_MENUBUTTON_DISABLED_FG_COLOR,
- -1, Tk_Offset(TkMenuButton, disabledFg), TK_OPTION_NULL_OK,
- (ClientData) DEF_MENUBUTTON_DISABLED_FG_MONO, 0},
- {TK_OPTION_SYNONYM, "-fg", "foreground", NULL, NULL, 0, -1,
+ TCL_INDEX_NONE, offsetof(TkMenuButton, disabledFg), TK_OPTION_NULL_OK,
+ DEF_MENUBUTTON_DISABLED_FG_MONO, 0},
+ {TK_OPTION_SYNONYM, "-fg", "foreground", NULL, NULL, 0, TCL_INDEX_NONE,
0, "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_MENUBUTTON_FONT, -1, Tk_Offset(TkMenuButton, tkfont), 0, 0, 0},
+ DEF_MENUBUTTON_FONT, TCL_INDEX_NONE, offsetof(TkMenuButton, tkfont), 0, 0, 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_MENUBUTTON_FG, -1, Tk_Offset(TkMenuButton, normalFg), 0, 0, 0},
+ DEF_MENUBUTTON_FG, TCL_INDEX_NONE, offsetof(TkMenuButton, normalFg), 0, 0, 0},
{TK_OPTION_STRING, "-height", "height", "Height",
- DEF_MENUBUTTON_HEIGHT, -1, Tk_Offset(TkMenuButton, heightString),
+ DEF_MENUBUTTON_HEIGHT, TCL_INDEX_NONE, offsetof(TkMenuButton, heightString),
0, 0, 0},
{TK_OPTION_COLOR, "-highlightbackground", "highlightBackground",
"HighlightBackground", DEF_MENUBUTTON_HIGHLIGHT_BG_COLOR,
- -1, Tk_Offset(TkMenuButton, highlightBgColorPtr), 0, 0, 0},
+ TCL_INDEX_NONE, offsetof(TkMenuButton, highlightBgColorPtr), 0, 0, 0},
{TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_MENUBUTTON_HIGHLIGHT, -1,
- Tk_Offset(TkMenuButton, highlightColorPtr), 0, 0, 0},
+ DEF_MENUBUTTON_HIGHLIGHT, TCL_INDEX_NONE,
+ offsetof(TkMenuButton, highlightColorPtr), 0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
"HighlightThickness", DEF_MENUBUTTON_HIGHLIGHT_WIDTH,
- -1, Tk_Offset(TkMenuButton, highlightWidth), 0, 0, 0},
+ TCL_INDEX_NONE, offsetof(TkMenuButton, highlightWidth), 0, 0, 0},
{TK_OPTION_STRING, "-image", "image", "Image",
- DEF_MENUBUTTON_IMAGE, -1, Tk_Offset(TkMenuButton, imageString),
+ DEF_MENUBUTTON_IMAGE, TCL_INDEX_NONE, offsetof(TkMenuButton, imageString),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_BOOLEAN, "-indicatoron", "indicatorOn", "IndicatorOn",
- DEF_MENUBUTTON_INDICATOR, -1, Tk_Offset(TkMenuButton, indicatorOn),
+ DEF_MENUBUTTON_INDICATOR, TCL_INDEX_NONE, offsetof(TkMenuButton, indicatorOn),
0, 0, 0},
{TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
- DEF_MENUBUTTON_JUSTIFY, -1, Tk_Offset(TkMenuButton, justify), 0, 0, 0},
+ DEF_MENUBUTTON_JUSTIFY, TCL_INDEX_NONE, offsetof(TkMenuButton, justify), TK_OPTION_ENUM_VAR, 0, 0},
{TK_OPTION_STRING, "-menu", "menu", "Menu",
- DEF_MENUBUTTON_MENU, -1, Tk_Offset(TkMenuButton, menuName),
+ DEF_MENUBUTTON_MENU, TCL_INDEX_NONE, offsetof(TkMenuButton, menuName),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-padx", "padX", "Pad",
- DEF_MENUBUTTON_PADX, -1, Tk_Offset(TkMenuButton, padX),
+ DEF_MENUBUTTON_PADX, TCL_INDEX_NONE, offsetof(TkMenuButton, padX),
0, 0, 0},
{TK_OPTION_PIXELS, "-pady", "padY", "Pad",
- DEF_MENUBUTTON_PADY, -1, Tk_Offset(TkMenuButton, padY),
+ DEF_MENUBUTTON_PADY, TCL_INDEX_NONE, offsetof(TkMenuButton, padY),
0, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_MENUBUTTON_RELIEF, -1, Tk_Offset(TkMenuButton, relief),
+ DEF_MENUBUTTON_RELIEF, TCL_INDEX_NONE, offsetof(TkMenuButton, relief),
0, 0, 0},
{TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound",
- DEF_BUTTON_COMPOUND, -1, Tk_Offset(TkMenuButton, compound),
+ DEF_BUTTON_COMPOUND, TCL_INDEX_NONE, offsetof(TkMenuButton, compound),
0, tkCompoundStrings, 0},
{TK_OPTION_STRING_TABLE, "-state", "state", "State",
- DEF_MENUBUTTON_STATE, -1, Tk_Offset(TkMenuButton, state),
+ DEF_MENUBUTTON_STATE, TCL_INDEX_NONE, offsetof(TkMenuButton, state),
TK_OPTION_ENUM_VAR, tkStateStrings, 0},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_MENUBUTTON_TAKE_FOCUS, -1,
- Tk_Offset(TkMenuButton, takeFocus), TK_OPTION_NULL_OK, 0, 0},
+ DEF_MENUBUTTON_TAKE_FOCUS, TCL_INDEX_NONE,
+ offsetof(TkMenuButton, takeFocus), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-text", "text", "Text",
- DEF_MENUBUTTON_TEXT, -1, Tk_Offset(TkMenuButton, text), 0, 0, 0},
+ DEF_MENUBUTTON_TEXT, TCL_INDEX_NONE, offsetof(TkMenuButton, text), 0, 0, 0},
{TK_OPTION_STRING, "-textvariable", "textVariable", "Variable",
- DEF_MENUBUTTON_TEXT_VARIABLE, -1,
- Tk_Offset(TkMenuButton, textVarName), TK_OPTION_NULL_OK, 0, 0},
- {TK_OPTION_INT, "-underline", "underline", "Underline",
- DEF_MENUBUTTON_UNDERLINE, -1, Tk_Offset(TkMenuButton, underline),
- 0, 0, 0},
+ DEF_MENUBUTTON_TEXT_VARIABLE, TCL_INDEX_NONE,
+ offsetof(TkMenuButton, textVarName), TK_OPTION_NULL_OK, 0, 0},
+ {TK_OPTION_INDEX, "-underline", "underline", "Underline",
+ TK_OPTION_UNDERLINE_DEF(TkMenuButton, underline), 0},
{TK_OPTION_STRING, "-width", "width", "Width",
- DEF_MENUBUTTON_WIDTH, -1, Tk_Offset(TkMenuButton, widthString),
+ DEF_MENUBUTTON_WIDTH, TCL_INDEX_NONE, offsetof(TkMenuButton, widthString),
0, 0, 0},
{TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength",
- DEF_MENUBUTTON_WRAP_LENGTH, -1, Tk_Offset(TkMenuButton, wrapLength),
+ DEF_MENUBUTTON_WRAP_LENGTH, TCL_INDEX_NONE, offsetof(TkMenuButton, wrapLength),
0, 0, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0}
};
@@ -157,22 +155,20 @@ enum command {
* Forward declarations for functions defined later in this file:
*/
-static void MenuButtonCmdDeletedProc(ClientData clientData);
-static void MenuButtonEventProc(ClientData clientData,
+static void MenuButtonCmdDeletedProc(void *clientData);
+static void MenuButtonEventProc(void *clientData,
XEvent *eventPtr);
-static void MenuButtonImageProc(ClientData clientData,
+static void MenuButtonImageProc(void *clientData,
int x, int y, int width, int height, int imgWidth,
int imgHeight);
-static char * MenuButtonTextVarProc(ClientData clientData,
+static char * MenuButtonTextVarProc(void *clientData,
Tcl_Interp *interp, const char *name1,
const char *name2, int flags);
-static int MenuButtonWidgetObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
+static Tcl_ObjCmdProc MenuButtonWidgetObjCmd;
static int ConfigureMenuButton(Tcl_Interp *interp,
TkMenuButton *mbPtr, int objc,
Tcl_Obj *const objv[]);
-static void DestroyMenuButton(char *memPtr);
+static void DestroyMenuButton(void *memPtr);
/*
*--------------------------------------------------------------
@@ -194,7 +190,7 @@ static void DestroyMenuButton(char *memPtr);
int
Tk_MenubuttonObjCmd(
- ClientData clientData, /* NULL. */
+ void *dummy, /* NULL. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -202,6 +198,7 @@ Tk_MenubuttonObjCmd(
TkMenuButton *mbPtr;
Tk_OptionTable optionTable;
Tk_Window tkwin;
+ (void)dummy;
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "pathName ?-option value ...?");
@@ -243,7 +240,7 @@ Tk_MenubuttonObjCmd(
mbPtr->optionTable = optionTable;
mbPtr->menuName = NULL;
mbPtr->text = NULL;
- mbPtr->underline = -1;
+ mbPtr->underline = INT_MIN;
mbPtr->textVarName = NULL;
mbPtr->bitmap = None;
mbPtr->imageString = NULL;
@@ -290,7 +287,7 @@ Tk_MenubuttonObjCmd(
ExposureMask|StructureNotifyMask|FocusChangeMask,
MenuButtonEventProc, mbPtr);
- if (Tk_InitOptions(interp, (char *) mbPtr, optionTable, tkwin) != TCL_OK) {
+ if (Tk_InitOptions(interp, mbPtr, optionTable, tkwin) != TCL_OK) {
Tk_DestroyWindow(mbPtr->tkwin);
return TCL_ERROR;
}
@@ -300,7 +297,7 @@ Tk_MenubuttonObjCmd(
return TCL_ERROR;
}
- Tcl_SetObjResult(interp, TkNewWindowObj(mbPtr->tkwin));
+ Tcl_SetObjResult(interp, Tk_NewWindowObj(mbPtr->tkwin));
return TCL_OK;
}
@@ -324,12 +321,12 @@ Tk_MenubuttonObjCmd(
static int
MenuButtonWidgetObjCmd(
- ClientData clientData, /* Information about button widget. */
+ void *clientData, /* Information about button widget. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- TkMenuButton *mbPtr = clientData;
+ TkMenuButton *mbPtr = (TkMenuButton *)clientData;
int result, index;
Tcl_Obj *objPtr;
@@ -351,7 +348,7 @@ MenuButtonWidgetObjCmd(
goto error;
}
- objPtr = Tk_GetOptionValue(interp, (char *) mbPtr,
+ objPtr = Tk_GetOptionValue(interp, mbPtr,
mbPtr->optionTable, objv[2], mbPtr->tkwin);
if (objPtr == NULL) {
goto error;
@@ -361,7 +358,7 @@ MenuButtonWidgetObjCmd(
case COMMAND_CONFIGURE:
if (objc <= 3) {
- objPtr = Tk_GetOptionInfo(interp, (char *) mbPtr,
+ objPtr = Tk_GetOptionInfo(interp, mbPtr,
mbPtr->optionTable, (objc == 3) ? objv[2] : NULL,
mbPtr->tkwin);
if (objPtr == NULL) {
@@ -402,9 +399,9 @@ MenuButtonWidgetObjCmd(
static void
DestroyMenuButton(
- char *memPtr) /* Info about button widget. */
+ void *memPtr) /* Info about button widget. */
{
- TkMenuButton *mbPtr = (TkMenuButton *) memPtr;
+ TkMenuButton *mbPtr = (TkMenuButton *)memPtr;
TkpDestroyMenuButton(mbPtr);
if (mbPtr->flags & REDRAW_PENDING) {
@@ -443,7 +440,7 @@ DestroyMenuButton(
if (mbPtr->textLayout != NULL) {
Tk_FreeTextLayout(mbPtr->textLayout);
}
- Tk_FreeConfigOptions((char *) mbPtr, mbPtr->optionTable, mbPtr->tkwin);
+ Tk_FreeConfigOptions(mbPtr, mbPtr->optionTable, mbPtr->tkwin);
mbPtr->tkwin = NULL;
Tcl_EventuallyFree(mbPtr, TCL_DYNAMIC);
}
@@ -506,7 +503,7 @@ ConfigureMenuButton(
* First pass: set options to new values.
*/
- if (Tk_SetOptions(interp, (char *) mbPtr,
+ if (Tk_SetOptions(interp, mbPtr,
mbPtr->optionTable, objc, objv,
mbPtr->tkwin, &savedOptions, NULL) != TCL_OK) {
continue;
@@ -573,13 +570,13 @@ ConfigureMenuButton(
if (Tk_GetPixels(interp, mbPtr->tkwin, mbPtr->widthString,
&mbPtr->width) != TCL_OK) {
widthError:
- Tcl_AddErrorInfo(interp, "\n (processing -width option)");
+ Tcl_AddErrorInfo(interp, "\n (processing \"-width\" option)");
continue;
}
if (Tk_GetPixels(interp, mbPtr->tkwin, mbPtr->heightString,
&mbPtr->height) != TCL_OK) {
heightError:
- Tcl_AddErrorInfo(interp, "\n (processing -height option)");
+ Tcl_AddErrorInfo(interp, "\n (processing \"-height\" option)");
continue;
}
} else {
@@ -615,7 +612,7 @@ ConfigureMenuButton(
if (mbPtr->text != NULL) {
ckfree(mbPtr->text);
}
- mbPtr->text = ckalloc(strlen(value) + 1);
+ mbPtr->text = (char *)ckalloc(strlen(value) + 1);
strcpy(mbPtr->text, value);
}
Tcl_TraceVar2(interp, mbPtr->textVarName, NULL,
@@ -652,12 +649,12 @@ ConfigureMenuButton(
void
TkMenuButtonWorldChanged(
- ClientData instanceData) /* Information about widget. */
+ void *instanceData) /* Information about widget. */
{
XGCValues gcValues;
GC gc;
unsigned long mask;
- TkMenuButton *mbPtr = instanceData;
+ TkMenuButton *mbPtr = (TkMenuButton *)instanceData;
gcValues.font = Tk_FontId(mbPtr->tkfont);
gcValues.foreground = mbPtr->normalFg->pixel;
@@ -755,10 +752,10 @@ TkMenuButtonWorldChanged(
static void
MenuButtonEventProc(
- ClientData clientData, /* Information about window. */
+ void *clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
- TkMenuButton *mbPtr = clientData;
+ TkMenuButton *mbPtr = (TkMenuButton *)clientData;
if ((eventPtr->type == Expose) && (eventPtr->xexpose.count == 0)) {
goto redraw;
@@ -770,7 +767,7 @@ MenuButtonEventProc(
goto redraw;
} else if (eventPtr->type == DestroyNotify) {
- DestroyMenuButton((char *) mbPtr);
+ DestroyMenuButton(mbPtr);
} else if (eventPtr->type == FocusIn) {
if (eventPtr->xfocus.detail != NotifyInferior) {
mbPtr->flags |= GOT_FOCUS;
@@ -815,9 +812,9 @@ MenuButtonEventProc(
static void
MenuButtonCmdDeletedProc(
- ClientData clientData) /* Pointer to widget record for widget. */
+ void *clientData) /* Pointer to widget record for widget. */
{
- TkMenuButton *mbPtr = clientData;
+ TkMenuButton *mbPtr = (TkMenuButton *)clientData;
Tk_Window tkwin = mbPtr->tkwin;
/*
@@ -850,18 +847,19 @@ MenuButtonCmdDeletedProc(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static char *
MenuButtonTextVarProc(
- ClientData clientData, /* Information about button. */
+ void *clientData, /* Information about button. */
Tcl_Interp *interp, /* Interpreter containing variable. */
const char *name1, /* Name of variable. */
const char *name2, /* Second part of variable name. */
int flags) /* Information about what happened. */
{
- TkMenuButton *mbPtr = clientData;
+ TkMenuButton *mbPtr = (TkMenuButton *)clientData;
const char *value;
- unsigned len;
+ size_t len;
+ (void)name1;
+ (void)name2;
/*
* If the variable is unset, then immediately recreate it unless the whole
@@ -870,14 +868,14 @@ MenuButtonTextVarProc(
if (flags & TCL_TRACE_UNSETS) {
if (!Tcl_InterpDeleted(interp) && mbPtr->textVarName) {
- ClientData probe = NULL;
+ void *probe = NULL;
do {
probe = Tcl_VarTraceInfo(interp,
mbPtr->textVarName,
TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
MenuButtonTextVarProc, probe);
- if (probe == (ClientData)mbPtr) {
+ if (probe == (void *)mbPtr) {
break;
}
} while (probe);
@@ -906,8 +904,8 @@ MenuButtonTextVarProc(
if (mbPtr->text != NULL) {
ckfree(mbPtr->text);
}
- len = 1 + (unsigned) strlen(value);
- mbPtr->text = ckalloc(len);
+ len = 1 + strlen(value);
+ mbPtr->text = (char *)ckalloc(len);
memcpy(mbPtr->text, value, len);
TkpComputeMenuButtonGeometry(mbPtr);
@@ -939,14 +937,20 @@ MenuButtonTextVarProc(
static void
MenuButtonImageProc(
- ClientData clientData, /* Pointer to widget record. */
+ void *clientData, /* Pointer to widget record. */
int x, int y, /* Upper left pixel (within image) that must
* be redisplayed. */
int width, int height, /* Dimensions of area to redisplay (may be <=
* 0). */
int imgWidth, int imgHeight)/* New dimensions of image. */
{
- TkMenuButton *mbPtr = clientData;
+ TkMenuButton *mbPtr = (TkMenuButton *)clientData;
+ (void)x;
+ (void)y;
+ (void)width;
+ (void)height;
+ (void)imgWidth;
+ (void)imgHeight;
if (mbPtr->tkwin != NULL) {
TkpComputeMenuButtonGeometry(mbPtr);
diff --git a/generic/tkMenubutton.h b/generic/tkMenubutton.h
index 7c25509..16ed223 100644
--- a/generic/tkMenubutton.h
+++ b/generic/tkMenubutton.h
@@ -4,7 +4,7 @@
* Declarations of types and functions used to implement the menubutton
* widget.
*
- * Copyright (c) 1996-1997 Sun Microsystems, Inc.
+ * Copyright © 1996-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.
@@ -64,7 +64,7 @@ typedef struct {
char *text; /* Text to display in button (malloc'ed) or
* NULL. */
- int underline; /* Index of character to underline. */
+ int underline; /* Index of character to underline. INT_MIN means no underline */
char *textVarName; /* Name of variable (malloc'ed) or NULL. If
* non-NULL, button displays the contents of
* this variable. */
@@ -161,12 +161,12 @@ typedef struct {
* whether the menubutton should show both an
* image and text, and, if so, how. */
enum direction direction; /* Direction for where to pop the menu. Valid
- * directions are "above", "below", "left",
- * "right", and "flush". "flush" means that
- * the upper left corner of the menubutton is
- * where the menu pops up. "above" and "below"
+ * directions are "above", "below", "flush",
+ * "left", and "right". "above" and "below"
* will attempt to pop the menu completely
* above or below the menu respectively.
+ * "flush" means that the upper left corner
+ * of the menubutton is where the menu pops up.
* "left" and "right" will pop the menu left
* or right, and the active item will be next
* to the button. */
@@ -209,8 +209,8 @@ typedef struct {
MODULE_SCOPE void TkpComputeMenuButtonGeometry(TkMenuButton *mbPtr);
MODULE_SCOPE TkMenuButton *TkpCreateMenuButton(Tk_Window tkwin);
-MODULE_SCOPE void TkpDisplayMenuButton(ClientData clientData);
+MODULE_SCOPE void TkpDisplayMenuButton(void *clientData);
MODULE_SCOPE void TkpDestroyMenuButton(TkMenuButton *mbPtr);
-MODULE_SCOPE void TkMenuButtonWorldChanged(ClientData instanceData);
+MODULE_SCOPE void TkMenuButtonWorldChanged(void *instanceData);
#endif /* _TKMENUBUTTON */
diff --git a/generic/tkMessage.c b/generic/tkMessage.c
index 6f5d0ce..0dc912c 100644
--- a/generic/tkMessage.c
+++ b/generic/tkMessage.c
@@ -5,22 +5,29 @@
* 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-1997 Sun Microsystems, Inc.
- * Copyright (c) 1998-2000 Ajuba Solutions.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1998-2000 Ajuba Solutions.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
-#include "default.h"
#include "tkInt.h"
+#include "default.h"
/*
* A data structure of the following type is kept for each message widget
* managed by this file:
*/
+#ifdef TK_NO_DEPRECATED
+# undef DEF_MESSAGE_PADX
+# undef DEF_MESSAGE_PADY
+# define DEF_MESSAGE_PADX NULL
+# define DEF_MESSAGE_PADY NULL
+#endif
+
typedef struct {
Tk_Window tkwin; /* Window that embodies the message. NULL
* means that the window has been destroyed
@@ -39,7 +46,7 @@ typedef struct {
*/
char *string; /* String displayed in message. */
- int numChars; /* Number of characters in string, not
+ Tcl_Size numChars; /* Number of characters in string, not
* including terminating NULL. */
char *textVarName; /* Name of variable (malloc'ed) or NULL.
* If non-NULL, message displays the contents
@@ -47,21 +54,20 @@ typedef struct {
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. */
+ Tcl_Obj *borderWidthObj; /* Width of border. */
int relief; /* 3-D effect: TK_RELIEF_RAISED, etc. */
- int highlightWidth; /* Width in pixels of highlight to draw
+ Tcl_Obj *highlightWidthObj; /* Width in pixels of highlight to draw
* around widget when it has the focus.
- * <= 0 means don't draw a highlight. */
+ * 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. */
- Tcl_Obj *padXPtr, *padYPtr; /* Tcl_Obj rep's of padX, padY values. */
- int padX, padY; /* User-requested extra space around text. */
- int width; /* User-requested width, in pixels. 0 means
- * compute width using aspect ratio below. */
+ Tcl_Obj *padXObj, *padYObj; /* Tcl_Obj rep's of padX, padY values. */
+ Tcl_Obj *widthObj; /* User-requested width, in pixels. 0 means
+ * compute width using aspect ratio. */
int aspect; /* Desired aspect ratio for window
* (100*width/height). */
int msgWidth; /* Width in pixels needed to display
@@ -109,57 +115,57 @@ typedef struct {
static const Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", DEF_MESSAGE_ANCHOR,
- -1, Tk_Offset(Message, anchor), 0, 0, 0},
+ TCL_INDEX_NONE, offsetof(Message, anchor), TK_OPTION_ENUM_VAR, 0, 0},
{TK_OPTION_INT, "-aspect", "aspect", "Aspect", DEF_MESSAGE_ASPECT,
- -1, Tk_Offset(Message, aspect), 0, 0, 0},
+ TCL_INDEX_NONE, offsetof(Message, aspect), 0, 0, 0},
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_MESSAGE_BG_COLOR, -1, Tk_Offset(Message, border), 0,
- DEF_MESSAGE_BG_MONO, 0},
+ DEF_MESSAGE_BG_COLOR, TCL_INDEX_NONE, offsetof(Message, border), 0,
+ DEF_MESSAGE_BG_MONO, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL, NULL,
- 0, -1, 0, "-borderwidth", 0},
+ 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL,
- 0, -1, 0, "-background", 0},
+ 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_MESSAGE_BORDER_WIDTH, -1,
- Tk_Offset(Message, borderWidth), 0, 0, 0},
+ DEF_MESSAGE_BORDER_WIDTH, offsetof(Message, borderWidthObj),
+ TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_MESSAGE_CURSOR, -1, Tk_Offset(Message, cursor),
- TK_OPTION_NULL_OK, 0, 0},
+ DEF_MESSAGE_CURSOR, TCL_INDEX_NONE, offsetof(Message, cursor),
+ TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_SYNONYM, "-fg", NULL, NULL, NULL,
- 0, -1, 0, "-foreground", 0},
+ 0, TCL_INDEX_NONE, 0, "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_MESSAGE_FONT, -1, Tk_Offset(Message, tkfont), 0, 0, 0},
+ DEF_MESSAGE_FONT, TCL_INDEX_NONE, offsetof(Message, tkfont), 0, 0, 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_MESSAGE_FG, -1, Tk_Offset(Message, fgColorPtr), 0, 0, 0},
+ DEF_MESSAGE_FG, TCL_INDEX_NONE, offsetof(Message, fgColorPtr), 0, 0, 0},
{TK_OPTION_COLOR, "-highlightbackground", "highlightBackground",
- "HighlightBackground", DEF_MESSAGE_HIGHLIGHT_BG, -1,
- Tk_Offset(Message, highlightBgColorPtr), 0, 0, 0},
+ "HighlightBackground", DEF_MESSAGE_HIGHLIGHT_BG, TCL_INDEX_NONE,
+ offsetof(Message, highlightBgColorPtr), 0, 0, 0},
{TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_MESSAGE_HIGHLIGHT, -1, Tk_Offset(Message, highlightColorPtr),
- 0, 0, 0},
+ DEF_MESSAGE_HIGHLIGHT, TCL_INDEX_NONE, offsetof(Message, highlightColorPtr),
+ 0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
- "HighlightThickness", DEF_MESSAGE_HIGHLIGHT_WIDTH, -1,
- Tk_Offset(Message, highlightWidth), 0, 0, 0},
+ "HighlightThickness", DEF_MESSAGE_HIGHLIGHT_WIDTH, offsetof(Message, highlightWidthObj),
+ TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
- DEF_MESSAGE_JUSTIFY, -1, Tk_Offset(Message, justify), 0, 0, 0},
+ DEF_MESSAGE_JUSTIFY, TCL_INDEX_NONE, offsetof(Message, justify), TK_OPTION_ENUM_VAR, 0, 0},
{TK_OPTION_PIXELS, "-padx", "padX", "Pad",
- DEF_MESSAGE_PADX, Tk_Offset(Message, padXPtr),
- Tk_Offset(Message, padX), 0, 0, 0},
+ DEF_MESSAGE_PADX, offsetof(Message, padXObj),
+ TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-pady", "padY", "Pad",
- DEF_MESSAGE_PADY, Tk_Offset(Message, padYPtr),
- Tk_Offset(Message, padY), 0, 0, 0},
+ DEF_MESSAGE_PADY, offsetof(Message, padYObj),
+ TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_MESSAGE_RELIEF, -1, Tk_Offset(Message, relief), 0, 0, 0},
+ DEF_MESSAGE_RELIEF, TCL_INDEX_NONE, offsetof(Message, relief), 0, 0, 0},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_MESSAGE_TAKE_FOCUS, -1, Tk_Offset(Message, takeFocus),
+ DEF_MESSAGE_TAKE_FOCUS, TCL_INDEX_NONE, offsetof(Message, takeFocus),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-text", "text", "Text",
- DEF_MESSAGE_TEXT, -1, Tk_Offset(Message, string), 0, 0, 0},
+ DEF_MESSAGE_TEXT, TCL_INDEX_NONE, offsetof(Message, string), 0, 0, 0},
{TK_OPTION_STRING, "-textvariable", "textVariable", "Variable",
- DEF_MESSAGE_TEXT_VARIABLE, -1, Tk_Offset(Message, textVarName),
+ DEF_MESSAGE_TEXT_VARIABLE, TCL_INDEX_NONE, offsetof(Message, textVarName),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-width", "width", "Width",
- DEF_MESSAGE_WIDTH, -1, Tk_Offset(Message, width), 0, 0 ,0},
+ DEF_MESSAGE_WIDTH, offsetof(Message, widthObj), TCL_INDEX_NONE, 0, 0 ,0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0}
};
@@ -167,21 +173,19 @@ static const Tk_OptionSpec optionSpecs[] = {
* Forward declarations for functions defined later in this file:
*/
-static void MessageCmdDeletedProc(ClientData clientData);
-static void MessageEventProc(ClientData clientData,
+static void MessageCmdDeletedProc(void *clientData);
+static void MessageEventProc(void *clientData,
XEvent *eventPtr);
-static char * MessageTextVarProc(ClientData clientData,
+static char * MessageTextVarProc(void *clientData,
Tcl_Interp *interp, const char *name1,
const char *name2, int flags);
-static int MessageWidgetObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-static void MessageWorldChanged(ClientData instanceData);
+static Tcl_ObjCmdProc MessageWidgetObjCmd;
+static void MessageWorldChanged(void *instanceData);
static void ComputeMessageGeometry(Message *msgPtr);
static int ConfigureMessage(Tcl_Interp *interp, Message *msgPtr,
int objc, Tcl_Obj *const objv[], int flags);
-static void DestroyMessage(char *memPtr);
-static void DisplayMessage(ClientData clientData);
+static void DestroyMessage(void *memPtr);
+static void DisplayMessage(void *clientData);
/*
* The structure below defines message class behavior by means of functions
@@ -214,7 +218,7 @@ static const Tk_ClassProcs messageClass = {
int
Tk_MessageObjCmd(
- ClientData clientData, /* NULL. */
+ TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
@@ -241,8 +245,8 @@ Tk_MessageObjCmd(
optionTable = Tk_CreateOptionTable(interp, optionSpecs);
- msgPtr = ckalloc(sizeof(Message));
- memset(msgPtr, 0, (size_t) sizeof(Message));
+ msgPtr = (Message *)ckalloc(sizeof(Message));
+ memset(msgPtr, 0, sizeof(Message));
/*
* Set values for those fields that don't take a 0 or NULL value.
@@ -267,7 +271,7 @@ Tk_MessageObjCmd(
Tk_CreateEventHandler(msgPtr->tkwin,
ExposureMask|StructureNotifyMask|FocusChangeMask,
MessageEventProc, msgPtr);
- if (Tk_InitOptions(interp, (char *)msgPtr, optionTable, tkwin) != TCL_OK) {
+ if (Tk_InitOptions(interp, msgPtr, optionTable, tkwin) != TCL_OK) {
Tk_DestroyWindow(msgPtr->tkwin);
return TCL_ERROR;
}
@@ -277,7 +281,7 @@ Tk_MessageObjCmd(
return TCL_ERROR;
}
- Tcl_SetObjResult(interp, TkNewWindowObj(msgPtr->tkwin));
+ Tcl_SetObjResult(interp, Tk_NewWindowObj(msgPtr->tkwin));
return TCL_OK;
}
@@ -301,12 +305,12 @@ Tk_MessageObjCmd(
static int
MessageWidgetObjCmd(
- ClientData clientData, /* Information about message widget. */
+ void *clientData, /* Information about message widget. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
{
- Message *msgPtr = clientData;
+ Message *msgPtr = (Message *)clientData;
static const char *const optionStrings[] = { "cget", "configure", NULL };
enum options { MESSAGE_CGET, MESSAGE_CONFIGURE };
int index;
@@ -331,7 +335,7 @@ MessageWidgetObjCmd(
Tcl_WrongNumArgs(interp, 2, objv, "option");
result = TCL_ERROR;
} else {
- objPtr = Tk_GetOptionValue(interp, (char *) msgPtr,
+ objPtr = Tk_GetOptionValue(interp, msgPtr,
msgPtr->optionTable, objv[2], msgPtr->tkwin);
if (objPtr == NULL) {
result = TCL_ERROR;
@@ -343,7 +347,7 @@ MessageWidgetObjCmd(
break;
case MESSAGE_CONFIGURE:
if (objc <= 3) {
- objPtr = Tk_GetOptionInfo(interp, (char *) msgPtr,
+ objPtr = Tk_GetOptionInfo(interp, msgPtr,
msgPtr->optionTable, (objc == 3) ? objv[2] : NULL,
msgPtr->tkwin);
if (objPtr == NULL) {
@@ -382,7 +386,7 @@ MessageWidgetObjCmd(
static void
DestroyMessage(
- char *memPtr) /* Info about message widget. */
+ void *memPtr) /* Info about message widget. */
{
Message *msgPtr = (Message *) memPtr;
@@ -409,7 +413,7 @@ DestroyMessage(
TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
MessageTextVarProc, msgPtr);
}
- Tk_FreeConfigOptions((char *) msgPtr, msgPtr->optionTable, msgPtr->tkwin);
+ Tk_FreeConfigOptions(msgPtr, msgPtr->optionTable, msgPtr->tkwin);
msgPtr->tkwin = NULL;
ckfree(msgPtr);
}
@@ -441,9 +445,10 @@ ConfigureMessage(
* already have values for some fields. */
int objc, /* Number of valid entries in argv. */
Tcl_Obj *const objv[], /* Arguments. */
- int flags) /* Flags to pass to Tk_ConfigureWidget. */
+ TCL_UNUSED(int)) /* Flags to pass to Tk_ConfigureWidget. */
{
Tk_SavedOptions savedOptions;
+ int width, borderWidth, highlightWidth, padX, padY;
/*
* Eliminate any existing trace on a variable monitored by the message.
@@ -455,7 +460,7 @@ ConfigureMessage(
MessageTextVarProc, msgPtr);
}
- if (Tk_SetOptions(interp, (char *) msgPtr, msgPtr->optionTable, objc, objv,
+ if (Tk_SetOptions(interp, msgPtr, msgPtr->optionTable, objc, objv,
msgPtr->tkwin, &savedOptions, NULL) != TCL_OK) {
Tk_RestoreSavedOptions(&savedOptions);
return TCL_ERROR;
@@ -478,7 +483,7 @@ ConfigureMessage(
if (msgPtr->string != NULL) {
ckfree(msgPtr->string);
}
- msgPtr->string = strcpy(ckalloc(strlen(value) + 1), value);
+ msgPtr->string = strcpy((char *)ckalloc(strlen(value) + 1), value);
}
Tcl_TraceVar2(interp, msgPtr->textVarName, NULL,
TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
@@ -491,10 +496,55 @@ ConfigureMessage(
* be specified to Tk_ConfigureWidget.
*/
- msgPtr->numChars = Tcl_NumUtfChars(msgPtr->string, -1);
+ msgPtr->numChars = TkNumUtfChars(msgPtr->string, TCL_INDEX_NONE);
- if (msgPtr->highlightWidth < 0) {
- msgPtr->highlightWidth = 0;
+ Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->widthObj, &width);
+ if (width < 0) {
+ if (msgPtr->widthObj) {
+ Tcl_DecrRefCount(msgPtr->widthObj);
+ }
+ msgPtr->widthObj = Tcl_NewIntObj(0);
+ Tcl_IncrRefCount(msgPtr->widthObj);
+ }
+ Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->borderWidthObj, &borderWidth);
+ if (borderWidth < 0) {
+ if (msgPtr->borderWidthObj) {
+ Tcl_DecrRefCount(msgPtr->borderWidthObj);
+ }
+ msgPtr->borderWidthObj = Tcl_NewIntObj(0);
+ Tcl_IncrRefCount(msgPtr->borderWidthObj);
+ }
+ Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->highlightWidthObj, &highlightWidth);
+ if (highlightWidth < 0) {
+ if (msgPtr->highlightWidthObj) {
+ Tcl_DecrRefCount(msgPtr->highlightWidthObj);
+ }
+ msgPtr->highlightWidthObj = Tcl_NewIntObj(0);
+ Tcl_IncrRefCount(msgPtr->highlightWidthObj);
+ }
+ if (!msgPtr->padXObj) {
+ msgPtr->padXObj = Tcl_NewIntObj(-1);
+ Tcl_IncrRefCount(msgPtr->padXObj);
+ }
+ Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->padXObj, &padX);
+ if (padX < 0) {
+ if (strcmp(Tcl_GetString(msgPtr->padXObj), "-1")) {
+ Tcl_DecrRefCount(msgPtr->padXObj);
+ msgPtr->padXObj = Tcl_NewIntObj(-1);
+ Tcl_IncrRefCount(msgPtr->padXObj);
+ }
+ }
+ if (!msgPtr->padYObj) {
+ msgPtr->padYObj = Tcl_NewIntObj(-1);
+ Tcl_IncrRefCount(msgPtr->padYObj);
+ }
+ Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->padYObj, &padY);
+ if (padY < 0) {
+ if (strcmp(Tcl_GetString(msgPtr->padYObj), "-1")) {
+ Tcl_DecrRefCount(msgPtr->padYObj);
+ msgPtr->padYObj = Tcl_NewIntObj(-1);
+ Tcl_IncrRefCount(msgPtr->padYObj);
+ }
}
Tk_FreeSavedOptions(&savedOptions);
@@ -522,12 +572,11 @@ ConfigureMessage(
static void
MessageWorldChanged(
- ClientData instanceData) /* Information about widget. */
+ void *instanceData) /* Information about widget. */
{
XGCValues gcValues;
GC gc = NULL;
- Tk_FontMetrics fm;
- Message *msgPtr = instanceData;
+ Message *msgPtr = (Message *)instanceData;
if (msgPtr->border != NULL) {
Tk_SetBackgroundFromBorder(msgPtr->tkwin, msgPtr->border);
@@ -541,14 +590,6 @@ MessageWorldChanged(
}
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.
@@ -587,10 +628,24 @@ ComputeMessageGeometry(
int width, inc, height;
int thisWidth, thisHeight, maxWidth;
int aspect, lowerBound, upperBound, inset;
+ int borderWidth, highlightWidth, padX, padY;
+ Tk_FontMetrics fm;
Tk_FreeTextLayout(msgPtr->textLayout);
- inset = msgPtr->borderWidth + msgPtr->highlightWidth;
+ Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->borderWidthObj, &borderWidth);
+ Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->highlightWidthObj, &highlightWidth);
+ Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->padXObj, &padX);
+ Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->padYObj, &padY);
+ Tk_GetFontMetrics(msgPtr->tkfont, &fm);
+ if (padX < 0) {
+ padX = fm.ascent / 2;
+ }
+ if (padY < 0) {
+ padY = fm.ascent / 4;
+ }
+
+ inset = borderWidth + highlightWidth;
/*
* Compute acceptable bounds for the final aspect ratio.
@@ -611,8 +666,8 @@ ComputeMessageGeometry(
* explicit width then just use that.
*/
- if (msgPtr->width > 0) {
- width = msgPtr->width;
+ Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->widthObj, &width);
+ if (width > 0) {
inc = 0;
} else {
width = WidthOfScreen(Tk_Screen(msgPtr->tkwin))/2;
@@ -623,8 +678,8 @@ ComputeMessageGeometry(
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);
+ maxWidth = thisWidth + 2 * (inset + padX);
+ height = thisHeight + 2 * (inset + padY);
if (inc <= 2) {
break;
@@ -664,27 +719,41 @@ ComputeMessageGeometry(
static void
DisplayMessage(
- ClientData clientData) /* Information about window. */
+ void *clientData) /* Information about window. */
{
- Message *msgPtr = clientData;
+ Message *msgPtr = (Message *)clientData;
Tk_Window tkwin = msgPtr->tkwin;
int x, y;
- int borderWidth = msgPtr->highlightWidth;
+ int width, borderWidth, highlightWidth, padX, padY;
+ Tk_FontMetrics fm;
+ Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->borderWidthObj, &borderWidth);
+ Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->highlightWidthObj, &highlightWidth);
+ Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->padXObj, &padX);
+ Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->padYObj, &padY);
+ Tk_GetFontMetrics(msgPtr->tkfont, &fm);
+ if (padX < 0) {
+ padX = fm.ascent / 2;
+ }
+ if (padY < 0) {
+ padY = fm.ascent / 4;
+ }
+
+ width = highlightWidth;
msgPtr->flags &= ~REDRAW_PENDING;
if ((msgPtr->tkwin == NULL) || !Tk_IsMapped(tkwin)) {
return;
}
if (msgPtr->border != NULL) {
- borderWidth += msgPtr->borderWidth;
+ width += borderWidth;
}
if (msgPtr->relief == TK_RELIEF_FLAT) {
- borderWidth = msgPtr->highlightWidth;
+ width = highlightWidth;
}
Tk_Fill3DRectangle(tkwin, Tk_WindowId(tkwin), msgPtr->border,
- borderWidth, borderWidth,
- Tk_Width(tkwin) - 2 * borderWidth,
- Tk_Height(tkwin) - 2 * borderWidth,
+ width, width,
+ Tk_Width(tkwin) - 2 * width,
+ Tk_Height(tkwin) - 2 * width,
0, TK_RELIEF_FLAT);
/*
@@ -692,28 +761,28 @@ DisplayMessage(
* anchor option.
*/
- TkComputeAnchor(msgPtr->anchor, tkwin, msgPtr->padX, msgPtr->padY,
+ TkComputeAnchor(msgPtr->anchor, tkwin, padX, padY,
msgPtr->msgWidth, msgPtr->msgHeight, &x, &y);
Tk_DrawTextLayout(Tk_Display(tkwin), Tk_WindowId(tkwin), msgPtr->textGC,
msgPtr->textLayout, x, y, 0, -1);
- if (borderWidth > msgPtr->highlightWidth) {
+ if (width > highlightWidth) {
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);
+ highlightWidth, highlightWidth,
+ Tk_Width(tkwin) - 2 * highlightWidth,
+ Tk_Height(tkwin) - 2 * highlightWidth,
+ borderWidth, msgPtr->relief);
}
- if (msgPtr->highlightWidth != 0) {
+ if (highlightWidth > 0) {
GC fgGC, bgGC;
bgGC = Tk_GCForColor(msgPtr->highlightBgColorPtr, Tk_WindowId(tkwin));
if (msgPtr->flags & GOT_FOCUS) {
fgGC = Tk_GCForColor(msgPtr->highlightColorPtr,Tk_WindowId(tkwin));
- TkpDrawHighlightBorder(tkwin, fgGC, bgGC, msgPtr->highlightWidth,
+ Tk_DrawHighlightBorder(tkwin, fgGC, bgGC, highlightWidth,
Tk_WindowId(tkwin));
} else {
- TkpDrawHighlightBorder(tkwin, bgGC, bgGC, msgPtr->highlightWidth,
+ Tk_DrawHighlightBorder(tkwin, bgGC, bgGC, highlightWidth,
Tk_WindowId(tkwin));
}
}
@@ -739,10 +808,11 @@ DisplayMessage(
static void
MessageEventProc(
- ClientData clientData, /* Information about window. */
+ void *clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
- Message *msgPtr = clientData;
+ Message *msgPtr = (Message *)clientData;
+ int highlightWidth;
if (((eventPtr->type == Expose) && (eventPtr->xexpose.count == 0))
|| (eventPtr->type == ConfigureNotify)) {
@@ -752,14 +822,16 @@ MessageEventProc(
} else if (eventPtr->type == FocusIn) {
if (eventPtr->xfocus.detail != NotifyInferior) {
msgPtr->flags |= GOT_FOCUS;
- if (msgPtr->highlightWidth > 0) {
+ Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->highlightWidthObj, &highlightWidth);
+ if (highlightWidth > 0) {
goto redraw;
}
}
} else if (eventPtr->type == FocusOut) {
if (eventPtr->xfocus.detail != NotifyInferior) {
msgPtr->flags &= ~GOT_FOCUS;
- if (msgPtr->highlightWidth > 0) {
+ Tk_GetPixelsFromObj(NULL, msgPtr->tkwin, msgPtr->highlightWidthObj, &highlightWidth);
+ if (highlightWidth > 0) {
goto redraw;
}
}
@@ -793,9 +865,9 @@ MessageEventProc(
static void
MessageCmdDeletedProc(
- ClientData clientData) /* Pointer to widget record for widget. */
+ void *clientData) /* Pointer to widget record for widget. */
{
- Message *msgPtr = clientData;
+ Message *msgPtr = (Message *)clientData;
/*
* This function could be invoked either because the window was destroyed
@@ -826,16 +898,15 @@ MessageCmdDeletedProc(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static char *
MessageTextVarProc(
- ClientData clientData, /* Information about message. */
+ void *clientData, /* Information about message. */
Tcl_Interp *interp, /* Interpreter containing variable. */
- const char *name1, /* Name of variable. */
- const char *name2, /* Second part of variable name. */
+ TCL_UNUSED(const char *), /* Name of variable. */
+ TCL_UNUSED(const char *), /* Second part of variable name. */
int flags) /* Information about what happened. */
{
- Message *msgPtr = clientData;
+ Message *msgPtr = (Message *)clientData;
const char *value;
/*
@@ -844,27 +915,27 @@ MessageTextVarProc(
*/
if (flags & TCL_TRACE_UNSETS) {
- if (!Tcl_InterpDeleted(interp) && msgPtr->textVarName) {
- ClientData probe = NULL;
-
- do {
- probe = Tcl_VarTraceInfo(interp,
- msgPtr->textVarName,
- TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
- MessageTextVarProc, probe);
- if (probe == (ClientData)msgPtr) {
- break;
- }
- } while (probe);
- if (probe) {
- /*
- * We were able to fetch the unset trace for our
- * textVarName, which means it is not unset and not
- * the cause of this unset trace. Instead some outdated
- * former variable must be, and we should ignore it.
- */
- return NULL;
- }
+ if (!Tcl_InterpDeleted(interp) && msgPtr->textVarName) {
+ void *probe = NULL;
+
+ do {
+ probe = Tcl_VarTraceInfo(interp,
+ msgPtr->textVarName,
+ TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
+ MessageTextVarProc, probe);
+ if (probe == (void *)msgPtr) {
+ break;
+ }
+ } while (probe);
+ if (probe) {
+ /*
+ * We were able to fetch the unset trace for our
+ * textVarName, which means it is not unset and not
+ * the cause of this unset trace. Instead some outdated
+ * former variable must be, and we should ignore it.
+ */
+ return NULL;
+ }
Tcl_SetVar2(interp, msgPtr->textVarName, NULL, msgPtr->string,
TCL_GLOBAL_ONLY);
Tcl_TraceVar2(interp, msgPtr->textVarName, NULL,
@@ -881,8 +952,8 @@ MessageTextVarProc(
if (msgPtr->string != NULL) {
ckfree(msgPtr->string);
}
- msgPtr->numChars = Tcl_NumUtfChars(value, -1);
- msgPtr->string = ckalloc(strlen(value) + 1);
+ msgPtr->numChars = TkNumUtfChars(value, TCL_INDEX_NONE);
+ msgPtr->string = (char *)ckalloc(strlen(value) + 1);
strcpy(msgPtr->string, value);
ComputeMessageGeometry(msgPtr);
diff --git a/generic/tkObj.c b/generic/tkObj.c
index 596a1cc..d5c702a 100644
--- a/generic/tkObj.c
+++ b/generic/tkObj.c
@@ -3,7 +3,7 @@
*
* This file contains functions that implement the common Tk object types
*
- * Copyright (c) 1997 Sun Microsystems, Inc.
+ * Copyright © 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.
@@ -72,8 +72,12 @@ typedef struct MMRep {
typedef struct WindowRep {
Tk_Window tkwin; /* Cached window; NULL if not found. */
TkMainInfo *mainPtr; /* MainWindow associated with tkwin. */
- long epoch; /* Value of mainPtr->deletionEpoch at last
+#if TCL_MAJOR_VERSION > 8
+ size_t epoch; /* Value of mainPtr->deletionEpoch at last
* successful lookup. */
+#else
+ long epoch;
+#endif
} WindowRep;
/*
@@ -92,32 +96,72 @@ static int SetMMFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr);
static int SetPixelFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr);
static int SetWindowFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr);
+#if TCL_MAJOR_VERSION < 9
+#ifdef __cplusplus
+extern "C" {
+#endif
+#if defined(USE_TCL_STUBS)
+/* Little hack to eliminate the need for "tclInt.h" here:
+ Just copy a small portion of TclIntStubs, just
+ enough to make it work */
+typedef struct TclIntStubs {
+ int magic;
+ void *hooks;
+ void (*dummy[34]) (void); /* dummy entries 0-33, not used */
+ int (*tclGetIntForIndex) (Tcl_Interp *interp, Tcl_Obj *objPtr, int endValue, int *indexPtr); /* 34 */
+} TclIntStubs;
+extern const TclIntStubs *tclIntStubsPtr;
+
+# undef Tcl_GetIntForIndex
+# define Tcl_GetIntForIndex(interp, obj, max, ptr) ((tclIntStubsPtr->tclGetIntForIndex == NULL)? \
+ ((int (*)(Tcl_Interp*, Tcl_Obj *, int, int*))(void *)((&(tclStubsPtr->tcl_PkgProvideEx))[645]))((interp), (obj), (max), (ptr)): \
+ tclIntStubsPtr->tclGetIntForIndex((interp), (obj), (max), (ptr)))
+#elif TCL_MINOR_VERSION < 7
+extern int TclGetIntForIndex(Tcl_Interp*, Tcl_Obj *, int, int*);
+# define Tcl_GetIntForIndex(interp, obj, max, ptr) TclGetIntForIndex(interp, obj, max, ptr)
+#endif
+#ifdef __cplusplus
+}
+#endif
+#endif
+
/*
* The following structure defines the implementation of the "pixel" Tcl
* object, used for measuring distances. The pixel object remembers its
* initial display-independent settings.
*/
-static const Tcl_ObjType pixelObjType = {
- "pixel", /* name */
+static const TkObjType pixelObjType = {
+ {"pixel", /* name */
FreePixelInternalRep, /* freeIntRepProc */
DupPixelInternalRep, /* dupIntRepProc */
NULL, /* updateStringProc */
- SetPixelFromAny /* setFromAnyProc */
+ NULL, /* setFromAnyProc */
+ TCL_OBJTYPE_V1(TkLengthOne)},
+ 0
};
+Tcl_Size
+TkLengthOne(
+ TCL_UNUSED(Tcl_Obj *))
+{
+ return 1;
+}
+
/*
* The following structure defines the implementation of the "pixel" Tcl
* object, used for measuring distances. The pixel object remembers its
* initial display-independent settings.
*/
-static const Tcl_ObjType mmObjType = {
- "mm", /* name */
+static const TkObjType mmObjType = {
+ {"mm", /* name */
FreeMMInternalRep, /* freeIntRepProc */
DupMMInternalRep, /* dupIntRepProc */
UpdateStringOfMM, /* updateStringProc */
- SetMMFromAny /* setFromAnyProc */
+ NULL, /* setFromAnyProc */
+ TCL_OBJTYPE_V1(TkLengthOne)},
+ 0
};
/*
@@ -125,12 +169,14 @@ static const Tcl_ObjType mmObjType = {
* Tcl object.
*/
-static const Tcl_ObjType windowObjType = {
- "window", /* name */
+static const TkObjType windowObjType = {
+ {"window", /* name */
FreeWindowInternalRep, /* freeIntRepProc */
DupWindowInternalRep, /* dupIntRepProc */
NULL, /* updateStringProc */
- SetWindowFromAny /* setFromAnyProc */
+ NULL, /* setFromAnyProc */
+ TCL_OBJTYPE_V0},
+ 0
};
/*
@@ -167,6 +213,46 @@ GetTypeCache(void)
/*
*----------------------------------------------------------------------
*
+ * TkGetIntForIndex --
+ *
+ * Almost the same as Tcl_GetIntForIndex, but it retrieves an int. Accepts
+ * "" (empty string) as well.
+ *
+ * Results:
+ * The return value is a standard Tcl object result.
+ *
+ * Side effects:
+ * None
+ *
+ *----------------------------------------------------------------------
+ */
+
+int
+TkGetIntForIndex(
+ Tcl_Obj *indexObj,
+ Tcl_Size end,
+ int lastOK,
+ Tcl_Size *indexPtr)
+{
+ if (indexObj == NULL) {
+ *indexPtr = TCL_INDEX_NONE;
+ return TCL_OK;
+ }
+ if (Tcl_GetIntForIndex(NULL, indexObj, end + lastOK, indexPtr) != TCL_OK) {
+ const char *value = Tcl_GetString(indexObj);
+ if (!*value) {
+ /* empty string */
+ *indexPtr = (end == -1) ? -1 - TCL_SIZE_MAX : TCL_INDEX_NONE;
+ return TCL_OK;
+ }
+ return TCL_ERROR;
+ }
+ return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* GetPixelsFromObjEx --
*
* Attempt to return a pixel value from the Tcl object "objPtr". If the
@@ -201,7 +287,7 @@ GetPixelsFromObjEx(
1.0L, 10.0L, 25.4L, 0.3527777777777777777L /*25.4 / 72.0*/
};
- if (objPtr->typePtr != &pixelObjType) {
+ if (objPtr->typePtr != &pixelObjType.objType) {
if (Tcl_GetDoubleFromObj(NULL, objPtr, &d) == TCL_OK) {
if (dblPtr != NULL) {
@@ -213,7 +299,7 @@ GetPixelsFromObjEx(
}
retry:
- fresh = (objPtr->typePtr != &pixelObjType);
+ fresh = (objPtr->typePtr != &pixelObjType.objType);
if (fresh) {
result = SetPixelFromAny(interp, objPtr);
if (result != TCL_OK) {
@@ -320,7 +406,7 @@ Tk_GetDoublePixelsFromObj(
if (result != TCL_OK) {
return result;
}
- if (objPtr->typePtr == &pixelObjType && !SIMPLE_PIXELREP(objPtr)) {
+ if (objPtr->typePtr == &pixelObjType.objType && !SIMPLE_PIXELREP(objPtr)) {
PixelRep *pixelPtr = GET_COMPLEXPIXEL(objPtr);
if (pixelPtr->units >= 0) {
@@ -433,7 +519,7 @@ SetPixelFromAny(
{
ThreadSpecificData *typeCache = GetTypeCache();
const Tcl_ObjType *typePtr;
- const char *string;
+ char *string;
char *rest;
double d;
int i, units;
@@ -453,20 +539,27 @@ SetPixelFromAny(
} else if (Tcl_GetDoubleFromObj(NULL, objPtr, &d) == TCL_OK) {
units = -1;
} else {
+ char savechar;
string = Tcl_GetString(objPtr);
- d = strtod(string, &rest);
- if (rest == string) {
- goto error;
+ rest = string + strlen(string);
+ while ((rest > string) && isspace(UCHAR(rest[-1]))) {
+ --rest; /* skip all spaces at the end */
}
- while ((*rest != '\0') && isspace(UCHAR(*rest))) {
- rest++;
+ if (rest > string) {
+ --rest; /* point to the character just before the last space */
+ }
+ if (rest == string) {
+ error:
+ if (interp != NULL) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "expected screen distance but got \"%.50s\"", string));
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "PIXELS", (char *)NULL);
+ }
+ return TCL_ERROR;
}
switch (*rest) {
- case '\0':
- units = -1;
- break;
case 'm':
units = 0;
break;
@@ -482,7 +575,15 @@ SetPixelFromAny(
default:
goto error;
}
+ savechar = *rest;
+ *rest = '\0';
+ if (Tcl_GetDouble(NULL, string, &d) != TCL_OK) {
+ *rest = savechar;
+ goto error;
+ }
+ *rest = savechar;
}
+
/*
* Free the old internalRep before setting the new one.
*/
@@ -492,7 +593,7 @@ SetPixelFromAny(
typePtr->freeIntRepProc(objPtr);
}
- objPtr->typePtr = &pixelObjType;
+ objPtr->typePtr = &pixelObjType.objType;
i = (int) d;
if ((units < 0) && (i == d)) {
@@ -507,14 +608,6 @@ SetPixelFromAny(
SET_COMPLEXPIXEL(objPtr, pixelPtr);
}
return TCL_OK;
-
- error:
- if (interp != NULL) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "bad screen distance \"%.50s\"", string));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "PIXELS", NULL);
- }
- return TCL_ERROR;
}
/*
@@ -552,7 +645,7 @@ Tk_GetMMFromObj(
10.0L, 25.4L, 1.0L, 0.352777777777777777L /*25.4 / 72.0*/
};
- if (objPtr->typePtr != &mmObjType) {
+ if (objPtr->typePtr != &mmObjType.objType) {
result = SetMMFromAny(interp, objPtr);
if (result != TCL_OK) {
return result;
@@ -726,28 +819,29 @@ SetMMFromAny(
} else if (Tcl_GetDoubleFromObj(NULL, objPtr, &d) == TCL_OK) {
units = -1;
} else {
+ char savechar;
+
/*
* It wasn't a known int or double, so parse it.
*/
string = Tcl_GetString(objPtr);
- d = strtod(string, &rest);
+ rest = string + strlen(string);
+ while ((rest > string) && isspace(UCHAR(rest[-1]))) {
+ --rest; /* skip all spaces at the end */
+ }
+ if (rest > string) {
+ --rest; /* point to the character just before the last space */
+ }
if (rest == string) {
error:
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "bad screen distance \"%s\"", string));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "DISTANCE", NULL);
+ "expected screen distance but got \"%.50s\"", string));
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "PIXELS", (char *)NULL);
return TCL_ERROR;
}
- while ((*rest != '\0') && isspace(UCHAR(*rest))) {
- rest++;
- }
-
switch (*rest) {
- case '\0':
- units = -1;
- break;
case 'c':
units = 0;
break;
@@ -763,6 +857,13 @@ SetMMFromAny(
default:
goto error;
}
+ savechar = *rest;
+ *rest = '\0';
+ if (Tcl_GetDouble(NULL, string, &d) != TCL_OK) {
+ *rest = savechar;
+ goto error;
+ }
+ *rest = savechar;
}
/*
@@ -774,7 +875,7 @@ SetMMFromAny(
typePtr->freeIntRepProc(objPtr);
}
- objPtr->typePtr = &mmObjType;
+ objPtr->typePtr = &mmObjType.objType;
mmPtr = (MMRep *)ckalloc(sizeof(MMRep));
mmPtr->value = d;
@@ -818,7 +919,7 @@ TkGetWindowFromObj(
TkMainInfo *mainPtr = ((TkWindow *) tkwin)->mainPtr;
WindowRep *winPtr;
- if (objPtr->typePtr != &windowObjType) {
+ if (objPtr->typePtr != &windowObjType.objType) {
int result = SetWindowFromAny(interp, objPtr);
if (result != TCL_OK) {
return result;
@@ -893,7 +994,7 @@ SetWindowFromAny(
winPtr->epoch = 0;
objPtr->internalRep.twoPtrValue.ptr1 = winPtr;
- objPtr->typePtr = &windowObjType;
+ objPtr->typePtr = &windowObjType.objType;
return TCL_OK;
}
@@ -962,7 +1063,7 @@ FreeWindowInternalRep(
/*
*----------------------------------------------------------------------
*
- * TkNewWindowObj --
+ * Tk_NewWindowObj --
*
* This function allocates a new Tcl_Obj that refers to a particular
* Tk window.
@@ -977,10 +1078,10 @@ FreeWindowInternalRep(
*/
Tcl_Obj *
-TkNewWindowObj(
+Tk_NewWindowObj(
Tk_Window tkwin)
{
- Tcl_Obj *objPtr = Tcl_NewStringObj(Tk_PathName(tkwin), -1);
+ Tcl_Obj *objPtr = Tcl_NewStringObj(Tk_PathName(tkwin), TCL_INDEX_NONE);
TkMainInfo *mainPtr = ((TkWindow *) tkwin)->mainPtr;
WindowRep *winPtr;
@@ -1025,7 +1126,7 @@ TkParsePadAmount(
int *allPtr) /* Write the total padding here */
{
int firstInt, secondInt; /* The two components of the padding */
- int objc; /* The length of the list (should be 1 or 2) */
+ Tcl_Size objc; /* The length of the list (should be 1 or 2) */
Tcl_Obj **objv; /* The objects in the list */
/*
@@ -1033,12 +1134,12 @@ TkParsePadAmount(
* shimmered between a list and a pixel spec.
*/
- if (specObj->typePtr == &pixelObjType) {
+ if (specObj->typePtr == &pixelObjType.objType) {
if (Tk_GetPixelsFromObj(interp, tkwin, specObj, &firstInt) != TCL_OK){
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad pad value \"%s\": must be positive screen distance",
Tcl_GetString(specObj)));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "PADDING", "DIST", NULL);
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "PADDING", "DIST", (char *)NULL);
return TCL_ERROR;
}
secondInt = firstInt;
@@ -1055,8 +1156,8 @@ TkParsePadAmount(
}
if (objc != 1 && objc != 2) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "wrong number of parts to pad specification", -1));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "PADDING", "PARTS", NULL);
+ "wrong number of parts to pad specification", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "PADDING", "PARTS", (char *)NULL);
return TCL_ERROR;
}
@@ -1069,7 +1170,7 @@ TkParsePadAmount(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad pad value \"%s\": must be positive screen distance",
Tcl_GetString(objv[0])));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "PADDING", "DIST", NULL);
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "PADDING", "DIST", (char *)NULL);
return TCL_ERROR;
}
@@ -1085,7 +1186,7 @@ TkParsePadAmount(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad 2nd pad value \"%s\": must be positive screen distance",
Tcl_GetString(objv[1])));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "PADDING", "DIST", NULL);
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "PADDING", "DIST", (char *)NULL);
return TCL_ERROR;
}
@@ -1121,16 +1222,16 @@ TkParsePadAmount(
void
TkRegisterObjTypes(void)
{
- Tcl_RegisterObjType(&tkBorderObjType);
- Tcl_RegisterObjType(&tkBitmapObjType);
- Tcl_RegisterObjType(&tkColorObjType);
- Tcl_RegisterObjType(&tkCursorObjType);
- Tcl_RegisterObjType(&tkFontObjType);
- Tcl_RegisterObjType(&mmObjType);
- Tcl_RegisterObjType(&pixelObjType);
- Tcl_RegisterObjType(&tkStateKeyObjType);
- Tcl_RegisterObjType(&windowObjType);
- Tcl_RegisterObjType(&tkTextIndexType);
+ Tcl_RegisterObjType(&tkBorderObjType.objType);
+ Tcl_RegisterObjType(&tkBitmapObjType.objType);
+ Tcl_RegisterObjType(&tkColorObjType.objType);
+ Tcl_RegisterObjType(&tkCursorObjType.objType);
+ Tcl_RegisterObjType(&tkFontObjType.objType);
+ Tcl_RegisterObjType(&mmObjType.objType);
+ Tcl_RegisterObjType(&pixelObjType.objType);
+ Tcl_RegisterObjType(&tkStateKeyObjType.objType);
+ Tcl_RegisterObjType(&windowObjType.objType);
+ Tcl_RegisterObjType(&tkTextIndexType.objType);
}
/*
diff --git a/generic/tkOldConfig.c b/generic/tkOldConfig.c
index 08c95f2..23259ec 100644
--- a/generic/tkOldConfig.c
+++ b/generic/tkOldConfig.c
@@ -5,8 +5,8 @@
* FOR BACKWARD COMPATIBILITY; THE NEW CONFIGURATION PACKAGE SHOULD BE
* USED FOR NEW PROJECTS.
*
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 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.
@@ -14,6 +14,16 @@
#include "tkInt.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!
+ */
+
+#ifndef TK_CONFIG_OPTION_SPECIFIED
+# define TK_CONFIG_OPTION_SPECIFIED (1 << 4)
+#endif
+
#ifdef _WIN32
#include "tkWinInt.h"
#endif
@@ -24,18 +34,18 @@
static int DoConfig(Tcl_Interp *interp, Tk_Window tkwin,
Tk_ConfigSpec *specPtr, Tk_Uid value,
- int valueIsUid, char *widgRec);
+ int valueIsUid, void *widgRec);
static Tk_ConfigSpec * FindConfigSpec(Tcl_Interp *interp,
Tk_ConfigSpec *specs, const char *argvName,
int needFlags, int hateFlags);
static char * FormatConfigInfo(Tcl_Interp *interp, Tk_Window tkwin,
- const Tk_ConfigSpec *specPtr, char *widgRec);
+ const Tk_ConfigSpec *specPtr, void *widgRec);
static const char * FormatConfigValue(Tcl_Interp *interp, Tk_Window tkwin,
- const Tk_ConfigSpec *specPtr, char *widgRec,
+ const Tk_ConfigSpec *specPtr, void *widgRec,
char *buffer, Tcl_FreeProc **freeProcPtr);
static Tk_ConfigSpec * GetCachedSpecs(Tcl_Interp *interp,
const Tk_ConfigSpec *staticSpecs);
-static void DeleteSpecCacheTable(ClientData clientData,
+static void DeleteSpecCacheTable(void *clientData,
Tcl_Interp *interp);
/*
@@ -66,9 +76,9 @@ Tk_ConfigureWidget(
Tk_Window tkwin, /* Window containing widget (needed to set up
* X resources). */
const Tk_ConfigSpec *specs, /* Describes legal options. */
- int argc, /* Number of elements in argv. */
+ Tcl_Size argc, /* Number of elements in argv. */
const char **argv, /* Command-line options. */
- char *widgRec, /* Record whose fields are to be modified.
+ void *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
@@ -88,8 +98,8 @@ Tk_ConfigureWidget(
* we're on our way out of the application
*/
- Tcl_SetObjResult(interp, Tcl_NewStringObj("NULL main window", -1));
- Tcl_SetErrorCode(interp, "TK", "NO_MAIN_WINDOW", NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("NULL main window", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "NO_MAIN_WINDOW", (char *)NULL);
return TCL_ERROR;
}
@@ -121,7 +131,11 @@ Tk_ConfigureWidget(
if (flags & TK_CONFIG_OBJS) {
arg = Tcl_GetString((Tcl_Obj *) *argv);
} else {
+#if defined(TK_NO_DEPRECATED) || (TK_MAJOR_VERSION > 8)
+ Tcl_Panic("Flag TK_CONFIG_OBJS is mandatory");
+#else
arg = *argv;
+#endif
}
specPtr = FindConfigSpec(interp, staticSpecs, arg, needFlags, hateFlags);
if (specPtr == NULL) {
@@ -135,13 +149,17 @@ Tk_ConfigureWidget(
if (argc < 2) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"value for \"%s\" missing", arg));
- Tcl_SetErrorCode(interp, "TK", "VALUE_MISSING", NULL);
+ Tcl_SetErrorCode(interp, "TK", "VALUE_MISSING", (char *)NULL);
return TCL_ERROR;
}
if (flags & TK_CONFIG_OBJS) {
arg = Tcl_GetString((Tcl_Obj *) argv[1]);
} else {
+#if defined(TK_NO_DEPRECATED) || (TK_MAJOR_VERSION > 8)
+ Tcl_Panic("Flag TK_CONFIG_OBJS is mandatory");
+#else
arg = argv[1];
+#endif
}
if (DoConfig(interp, tkwin, specPtr, arg, 0, widgRec) != TCL_OK) {
Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf(
@@ -265,7 +283,7 @@ FindConfigSpec(
if (matchPtr != NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"ambiguous option \"%s\"", argvName));
- Tcl_SetErrorCode(interp, "TK", "LOOKUP", "OPTION", argvName,NULL);
+ Tcl_SetErrorCode(interp, "TK", "LOOKUP", "OPTION", argvName, (char *)NULL);
return NULL;
}
matchPtr = specPtr;
@@ -274,7 +292,7 @@ FindConfigSpec(
if (matchPtr == NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"unknown option \"%s\"", argvName));
- Tcl_SetErrorCode(interp, "TK", "LOOKUP", "OPTION", argvName, NULL);
+ Tcl_SetErrorCode(interp, "TK", "LOOKUP", "OPTION", argvName, (char *)NULL);
return NULL;
}
@@ -292,7 +310,7 @@ FindConfigSpec(
"couldn't find synonym for option \"%s\"",
argvName));
Tcl_SetErrorCode(interp, "TK", "LOOKUP", "OPTION", argvName,
- NULL);
+ (char *)NULL);
return NULL;
}
if ((specPtr->dbName == matchPtr->dbName)
@@ -333,15 +351,15 @@ DoConfig(
Tk_Uid value, /* Value to use to fill in widgRec. */
int valueIsUid, /* Non-zero means value is a Tk_Uid; zero
* means it's an ordinary string. */
- char *widgRec) /* Record whose fields are to be modified.
+ void *widgRec) /* Record whose fields are to be modified.
* Values must be properly initialized. */
{
- char *ptr;
+ void *ptr;
Tk_Uid uid;
int nullValue;
nullValue = 0;
- if ((*value == 0) && (specPtr->specFlags & (TK_CONFIG_NULL_OK|32 /* TCL_NULL_OK */))) {
+ if ((*value == 0) && (specPtr->specFlags & (TK_CONFIG_NULL_OK|TCL_NULL_OK|1))) {
nullValue = 1;
}
@@ -349,20 +367,20 @@ DoConfig(
if (specPtr->offset < 0) {
break;
}
- ptr = widgRec + specPtr->offset;
+ ptr = (char *)widgRec + specPtr->offset;
switch (specPtr->type) {
case TK_CONFIG_BOOLEAN:
- if (Tcl_GetBoolean(interp, value, (int *) ptr) != TCL_OK) {
+ 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) {
+ 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) {
+ if (Tcl_GetDouble(interp, value, (double *)ptr) != TCL_OK) {
return TCL_ERROR;
}
break;
@@ -464,7 +482,7 @@ DoConfig(
}
case TK_CONFIG_RELIEF:
uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value);
- if (Tk_GetRelief(interp, uid, (int *) ptr) != TCL_OK) {
+ if (Tk_GetRelief(interp, uid, (int *)ptr) != TCL_OK) {
return TCL_ERROR;
}
break;
@@ -505,24 +523,26 @@ DoConfig(
break;
case TK_CONFIG_CAP_STYLE:
uid = valueIsUid ? (Tk_Uid) value : Tk_GetUid(value);
- if (Tk_GetCapStyle(interp, uid, (int *) ptr) != TCL_OK) {
+ 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) {
+ 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)
+ if (nullValue) {
+ *(int *)ptr = INT_MIN;
+ } else 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) {
+ if (Tk_GetScreenMM(interp, tkwin, value, (double *)ptr) != TCL_OK) {
return TCL_ERROR;
}
break;
@@ -542,14 +562,14 @@ DoConfig(
}
case TK_CONFIG_CUSTOM:
if (specPtr->customPtr->parseProc(specPtr->customPtr->clientData,
- interp, tkwin, value, widgRec, specPtr->offset)!=TCL_OK) {
+ interp, tkwin, value, (char *)widgRec, specPtr->offset)!=TCL_OK) {
return TCL_ERROR;
}
break;
default:
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad config table: unknown type %d", specPtr->type));
- Tcl_SetErrorCode(interp, "TK", "BAD_CONFIG", NULL);
+ Tcl_SetErrorCode(interp, "TK", "BAD_CONFIG", (char *)NULL);
return TCL_ERROR;
}
specPtr++;
@@ -590,7 +610,7 @@ Tk_ConfigureInfo(
Tcl_Interp *interp, /* Interpreter for error reporting. */
Tk_Window tkwin, /* Window corresponding to widgRec. */
const Tk_ConfigSpec *specs, /* Describes legal options. */
- char *widgRec, /* Record whose fields contain current values
+ void *widgRec, /* Record whose fields contain current values
* for options. */
const char *argvName, /* If non-NULL, indicates a single option
* whose info is to be returned. Otherwise
@@ -630,7 +650,7 @@ Tk_ConfigureInfo(
return TCL_ERROR;
}
list = FormatConfigInfo(interp, tkwin, specPtr, widgRec);
- Tcl_SetObjResult(interp, Tcl_NewStringObj(list, -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(list, TCL_INDEX_NONE));
ckfree(list);
return TCL_OK;
}
@@ -652,7 +672,7 @@ Tk_ConfigureInfo(
continue;
}
list = FormatConfigInfo(interp, tkwin, specPtr, widgRec);
- Tcl_AppendResult(interp, leader, list, "}", NULL);
+ Tcl_AppendResult(interp, leader, list, "}", (char *)NULL);
ckfree(list);
leader = " {";
}
@@ -685,7 +705,7 @@ FormatConfigInfo(
const Tk_ConfigSpec *specPtr,
/* Pointer to information describing
* option. */
- char *widgRec) /* Pointer to record holding current values of
+ void *widgRec) /* Pointer to record holding current values of
* info for widget. */
{
const char *argv[6];
@@ -717,9 +737,9 @@ FormatConfigInfo(
result = Tcl_Merge(5, argv);
if (freeProc != NULL) {
if (freeProc == TCL_DYNAMIC) {
- ckfree((char *) argv[4]);
+ ckfree((char *)argv[4]);
} else {
- freeProc((char *) argv[4]);
+ freeProc((char *)argv[4]);
}
}
return result;
@@ -751,7 +771,7 @@ FormatConfigValue(
Tk_Window tkwin, /* Window corresponding to widget. */
const Tk_ConfigSpec *specPtr, /* Pointer to information describing option.
* Must not point to a synonym option. */
- char *widgRec, /* Pointer to record holding current values of
+ void *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. */
@@ -766,7 +786,7 @@ FormatConfigValue(
if (specPtr->offset < 0) {
return NULL;
}
- ptr = widgRec + specPtr->offset;
+ ptr = (char *)widgRec + specPtr->offset;
result = "";
switch (specPtr->type) {
case TK_CONFIG_BOOLEAN:
@@ -855,8 +875,10 @@ FormatConfigValue(
result = Tk_NameOfJoinStyle(*((int *)ptr));
break;
case TK_CONFIG_PIXELS:
- snprintf(buffer, 200, "%d", *((int *)ptr));
- result = buffer;
+ if ((*(int *)ptr != INT_MIN) || !(specPtr->specFlags & (TK_CONFIG_NULL_OK|TCL_NULL_OK|1))) {
+ snprintf(buffer, 200, "%d", *((int *)ptr));
+ result = buffer;
+ }
break;
case TK_CONFIG_MM:
Tcl_PrintDouble(interp, *((double *)ptr), buffer);
@@ -871,7 +893,7 @@ FormatConfigValue(
}
case TK_CONFIG_CUSTOM:
result = specPtr->customPtr->printProc(specPtr->customPtr->clientData,
- tkwin, widgRec, specPtr->offset, freeProcPtr);
+ tkwin, (char *)widgRec, specPtr->offset, freeProcPtr);
break;
default:
result = "?? unknown type ??";
@@ -904,7 +926,7 @@ Tk_ConfigureValue(
Tcl_Interp *interp, /* Interpreter for error reporting. */
Tk_Window tkwin, /* Window corresponding to widgRec. */
const Tk_ConfigSpec *specs, /* Describes legal options. */
- char *widgRec, /* Record whose fields contain current values
+ void *widgRec, /* Record whose fields contain current values
* for options. */
const char *argvName, /* Gives the command-line name for the option
* whose value is to be returned. */
@@ -937,12 +959,12 @@ Tk_ConfigureValue(
}
result = FormatConfigValue(interp, tkwin, specPtr, widgRec, buffer,
&freeProc);
- Tcl_SetObjResult(interp, Tcl_NewStringObj(result, -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(result, TCL_INDEX_NONE));
if (freeProc != NULL) {
if (freeProc == TCL_DYNAMIC) {
- ckfree((char *) result);
+ ckfree((char *)result);
} else {
- freeProc((char *) result);
+ freeProc((char *)result);
}
}
return TCL_OK;
@@ -972,7 +994,7 @@ Tk_ConfigureValue(
void
Tk_FreeOptions(
const Tk_ConfigSpec *specs, /* Describes legal options. */
- char *widgRec, /* Record whose fields contain current values
+ void *widgRec, /* Record whose fields contain current values
* for options. */
Display *display, /* X display; needed for freeing some
* resources. */
@@ -990,7 +1012,7 @@ Tk_FreeOptions(
if (specPtr->offset < 0) {
continue;
}
- ptr = widgRec + specPtr->offset;
+ ptr = (char *)widgRec + specPtr->offset;
switch (specPtr->type) {
case TK_CONFIG_STRING:
if (*((char **) ptr) != NULL) {
@@ -1156,7 +1178,7 @@ GetCachedSpecs(
static void
DeleteSpecCacheTable(
- ClientData clientData,
+ void *clientData,
TCL_UNUSED(Tcl_Interp *))
{
Tcl_HashTable *tablePtr = (Tcl_HashTable *)clientData;
diff --git a/generic/tkOldTest.c b/generic/tkOldTest.c
index b4d7f04..82b8ef2 100644
--- a/generic/tkOldTest.c
+++ b/generic/tkOldTest.c
@@ -6,9 +6,9 @@
* interfaces. These commands are not normally included in Tcl/Tk
* applications; they're only used for testing.
*
- * Copyright (c) 1993-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
- * Copyright (c) 1998-1999 Scriptics Corporation.
+ * Copyright © 1993-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1998-1999 Scriptics Corporation.
* Contributions by Don Porter, NIST, 2007. (not subject to US copyright)
*
* See the file "license.terms" for information on usage and redistribution of
@@ -28,6 +28,7 @@
#include "tkWinInt.h"
#endif
+#if !defined(TK_NO_DEPRECATED) && (TCL_MAJOR_VERSION < 9)
/*
* The following data structure represents the model for a test image:
*/
@@ -57,17 +58,17 @@ typedef struct TImageInstance {
*/
static int ImageCreate(Tcl_Interp *interp,
- char *name, int argc, char **argv,
+ char *name, Tcl_Size argc, char **argv,
Tk_ImageType *typePtr, Tk_ImageModel model,
- ClientData *clientDataPtr);
-static ClientData ImageGet(Tk_Window tkwin, ClientData clientData);
-static void ImageDisplay(ClientData clientData,
+ void **clientDataPtr);
+static void *ImageGet(Tk_Window tkwin, void *clientData);
+static void ImageDisplay(void *clientData,
Display *display, Drawable drawable,
int imageX, int imageY, int width,
int height, int drawableX,
int drawableY);
-static void ImageFree(ClientData clientData, Display *display);
-static void ImageDelete(ClientData clientData);
+static void ImageFree(void *clientData, Display *display);
+static void ImageDelete(void *clientData);
static Tk_ImageType imageType = {
"oldtest", /* name */
@@ -85,10 +86,8 @@ static Tk_ImageType imageType = {
* Forward declarations for functions defined later in this file:
*/
-static int ImageObjCmd(ClientData dummy,
- Tcl_Interp *interp, int objc,
- Tcl_Obj * const objv[]);
-
+static Tcl_ObjCmdProc ImageObjCmd;
+#endif
/*
*----------------------------------------------------------------------
@@ -110,13 +109,16 @@ static int ImageObjCmd(ClientData dummy,
int
TkOldTestInit(
- Tcl_Interp *interp)
+ Tcl_Interp *dummy)
{
static int initialized = 0;
+ (void)dummy;
if (!initialized) {
initialized = 1;
+#if !defined(TK_NO_DEPRECATED) && (TCL_MAJOR_VERSION < 9)
Tk_CreateImageType(&imageType);
+#endif
}
return TCL_OK;
}
@@ -136,25 +138,25 @@ TkOldTestInit(
*
*----------------------------------------------------------------------
*/
-
- /* ARGSUSED */
+#if !defined(TK_NO_DEPRECATED) && (TCL_MAJOR_VERSION < 9)
static int
ImageCreate(
Tcl_Interp *interp, /* Interpreter for application containing
* image. */
char *name, /* Name to use for image. */
- int argc, /* Number of arguments. */
+ Tcl_Size 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_ImageModel model, /* Token for image, to be used by us in later
* callbacks. */
- ClientData *clientDataPtr) /* Store manager's token for image here; it
+ void **clientDataPtr) /* Store manager's token for image here; it
* will be returned in later callbacks. */
{
TImageModel *timPtr;
const char *varName;
- int i;
+ Tcl_Size i;
+ (void)typePtr;
varName = "log";
for (i = 0; i < argc; i += 2) {
@@ -171,14 +173,14 @@ ImageCreate(
varName = argv[i+1];
}
- timPtr = ckalloc(sizeof(TImageModel));
+ timPtr = (TImageModel *)ckalloc(sizeof(TImageModel));
timPtr->model = model;
timPtr->interp = interp;
timPtr->width = 30;
timPtr->height = 15;
- timPtr->imageName = ckalloc(strlen(name) + 1);
+ timPtr->imageName = (char *)ckalloc(strlen(name) + 1);
strcpy(timPtr->imageName, name);
- timPtr->varName = ckalloc(strlen(varName) + 1);
+ timPtr->varName = (char *)ckalloc(strlen(varName) + 1);
strcpy(timPtr->varName, varName);
Tcl_CreateObjCommand(interp, name, ImageObjCmd, timPtr, NULL);
*clientDataPtr = timPtr;
@@ -203,15 +205,14 @@ ImageCreate(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
static int
ImageObjCmd(
- ClientData clientData, /* Main window for application. */
+ void *clientData, /* Main window for application. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
{
- TImageModel *timPtr = clientData;
+ TImageModel *timPtr = (TImageModel *)clientData;
int x, y, width, height;
if (objc < 2) {
@@ -260,13 +261,13 @@ ImageObjCmd(
*----------------------------------------------------------------------
*/
-static ClientData
+static void *
ImageGet(
Tk_Window tkwin, /* Token for window in which image will be
* used. */
- ClientData clientData) /* Pointer to TImageModel for image. */
+ void *clientData) /* Pointer to TImageModel for image. */
{
- TImageModel *timPtr = clientData;
+ TImageModel *timPtr = (TImageModel *)clientData;
TImageInstance *instPtr;
char buffer[100];
XGCValues gcValues;
@@ -275,7 +276,7 @@ ImageGet(
Tcl_SetVar2(timPtr->interp, timPtr->varName, NULL, buffer,
TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT);
- instPtr = ckalloc(sizeof(TImageInstance));
+ instPtr = (TImageInstance *)ckalloc(sizeof(TImageInstance));
instPtr->modelPtr = timPtr;
instPtr->fg = Tk_GetColor(timPtr->interp, tkwin, "#ff0000");
gcValues.foreground = instPtr->fg->pixel;
@@ -303,7 +304,7 @@ ImageGet(
static void
ImageDisplay(
- ClientData clientData, /* Pointer to TImageInstance for image. */
+ void *clientData, /* Pointer to TImageInstance for image. */
Display *display, /* Display to use for drawing. */
Drawable drawable, /* Where to redraw image. */
int imageX, int imageY, /* Origin of area to redraw, relative to
@@ -313,7 +314,7 @@ ImageDisplay(
/* Coordinates in drawable corresponding to
* imageX and imageY. */
{
- TImageInstance *instPtr = clientData;
+ TImageInstance *instPtr = (TImageInstance *)clientData;
char buffer[200 + TCL_INTEGER_SPACE * 6];
snprintf(buffer, sizeof(buffer), "%s display %d %d %d %d %d %d",
@@ -355,10 +356,10 @@ ImageDisplay(
static void
ImageFree(
- ClientData clientData, /* Pointer to TImageInstance for instance. */
+ void *clientData, /* Pointer to TImageInstance for instance. */
Display *display) /* Display where image was to be drawn. */
{
- TImageInstance *instPtr = clientData;
+ TImageInstance *instPtr = (TImageInstance *)clientData;
char buffer[200];
snprintf(buffer, sizeof(buffer), "%s free", instPtr->modelPtr->imageName);
@@ -388,11 +389,11 @@ ImageFree(
static void
ImageDelete(
- ClientData clientData) /* Pointer to TImageModel for image. When
+ void *clientData) /* Pointer to TImageModel for image. When
* this function is called, no more instances
* exist. */
{
- TImageModel *timPtr = clientData;
+ TImageModel *timPtr = (TImageModel *)clientData;
char buffer[100];
snprintf(buffer, sizeof(buffer), "%s delete", timPtr->imageName);
@@ -404,6 +405,7 @@ ImageDelete(
ckfree(timPtr->varName);
ckfree(timPtr);
}
+#endif
/*
* Local Variables:
diff --git a/generic/tkOption.c b/generic/tkOption.c
index 15fc405..f6976bd 100644
--- a/generic/tkOption.c
+++ b/generic/tkOption.c
@@ -5,8 +5,8 @@
* 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-1997 Sun Microsystems, Inc.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 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.
@@ -219,7 +219,7 @@ static void ExtendStacks(ElArray *arrayPtr, int leaf);
static int GetDefaultOptions(Tcl_Interp *interp,
TkWindow *winPtr);
static ElArray * NewArray(int numEls);
-static void OptionThreadExitProc(ClientData clientData);
+static void OptionThreadExitProc(void *clientData);
static void OptionInit(TkMainInfo *mainPtr);
static int ParsePriority(Tcl_Interp *interp, const char *string);
static int ReadOptionFile(Tcl_Interp *interp, Tk_Window tkwin,
@@ -521,7 +521,7 @@ Tk_GetOption(
if (masqName != NULL) {
char *masqClass;
Tk_Uid nodeId, winClassId, winNameId;
- size_t classNameLength;
+ Tcl_Size classNameLength;
Element *nodePtr, *leafPtr;
static const int searchOrder[] = {
EXACT_NODE_NAME, WILDCARD_NODE_NAME, EXACT_NODE_CLASS,
@@ -534,7 +534,7 @@ Tk_GetOption(
* Extract the masquerade class name from the name field.
*/
- classNameLength = (size_t) (masqName - name);
+ classNameLength = masqName - name;
masqClass = (char *)ckalloc(classNameLength + 1);
strncpy(masqClass, name, classNameLength);
masqClass[classNameLength] = '\0';
@@ -610,7 +610,7 @@ Tk_GetOption(
int
Tk_OptionObjCmd(
- ClientData clientData, /* Main window associated with interpreter. */
+ void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of Tcl_Obj arguments. */
Tcl_Obj *const objv[]) /* Tcl_Obj arguments. */
@@ -690,7 +690,7 @@ Tk_OptionObjCmd(
value = Tk_GetOption(window, Tcl_GetString(objv[3]),
Tcl_GetString(objv[4]));
if (value != NULL) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(value, -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(value, TCL_INDEX_NONE));
}
break;
}
@@ -751,11 +751,11 @@ TkOptionDeadWindow(
* XXX: tsd. Tk shutdown needs to be verified to handle this correctly.
*/
- if (tsdPtr->initialized && (winPtr->optionLevel != -1)) {
+ if (tsdPtr->initialized && (winPtr->optionLevel != TCL_INDEX_NONE)) {
int i;
for (i = 1; i <= tsdPtr->curLevel; i++) {
- tsdPtr->levels[i].winPtr->optionLevel = -1;
+ tsdPtr->levels[i].winPtr->optionLevel = TCL_INDEX_NONE;
}
tsdPtr->curLevel = -1;
tsdPtr->cachedWindow = NULL;
@@ -799,7 +799,7 @@ TkOptionClassChanged(
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
- if (winPtr->optionLevel == -1) {
+ if (winPtr->optionLevel < 0) {
return;
}
@@ -811,7 +811,7 @@ TkOptionClassChanged(
for (i = 1; i <= tsdPtr->curLevel; i++) {
if (tsdPtr->levels[i].winPtr == winPtr) {
for (j = i; j <= tsdPtr->curLevel; j++) {
- tsdPtr->levels[j].winPtr->optionLevel = -1;
+ tsdPtr->levels[j].winPtr->optionLevel = TCL_INDEX_NONE;
}
tsdPtr->curLevel = i-1;
basePtr = tsdPtr->levels[i].bases;
@@ -881,7 +881,7 @@ ParsePriority(
"bad priority level \"%s\": must be "
"widgetDefault, startupFile, userDefault, "
"interactive, or a number between 0 and 100", string));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "PRIORITY", NULL);
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "PRIORITY", (char *)NULL);
return -1;
}
}
@@ -965,7 +965,7 @@ AddFromString(
if ((*src == '\0') || (*src == '\n')) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"missing colon on line %d", lineNum));
- Tcl_SetErrorCode(interp, "TK", "OPTIONDB", "COLON", NULL);
+ Tcl_SetErrorCode(interp, "TK", "OPTIONDB", "COLON", (char *)NULL);
return TCL_ERROR;
}
if ((src[0] == '\\') && (src[1] == '\n')) {
@@ -1002,7 +1002,7 @@ AddFromString(
if (*src == '\0') {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"missing value on line %d", lineNum));
- Tcl_SetErrorCode(interp, "TK", "OPTIONDB", "VALUE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "OPTIONDB", "VALUE", (char *)NULL);
return TCL_ERROR;
}
@@ -1016,7 +1016,7 @@ AddFromString(
if (*src == '\0') {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"missing newline on line %d", lineNum));
- Tcl_SetErrorCode(interp, "TK", "OPTIONDB", "NEWLINE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "OPTIONDB", "NEWLINE", (char *)NULL);
return TCL_ERROR;
}
if (*src == '\\'){
@@ -1084,7 +1084,8 @@ ReadOptionFile(
{
const char *realName;
Tcl_Obj *buffer;
- int result, bufferSize;
+ int result;
+ Tcl_Size bufferSize;
Tcl_Channel chan;
Tcl_DString newName;
@@ -1094,8 +1095,8 @@ ReadOptionFile(
if (Tcl_IsSafe(interp)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "can't read options from a file in a safe interpreter", -1));
- Tcl_SetErrorCode(interp, "TK", "SAFE", "OPTION_FILE", NULL);
+ "can't read options from a file in a safe interpreter", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "SAFE", "OPTION_FILE", (char *)NULL);
return TCL_ERROR;
}
@@ -1114,8 +1115,8 @@ ReadOptionFile(
buffer = Tcl_NewObj();
Tcl_IncrRefCount(buffer);
Tcl_SetChannelOption(NULL, chan, "-encoding", "utf-8");
- bufferSize = Tcl_ReadChars(chan, buffer, -1, 0);
- if (bufferSize == -1) {
+ bufferSize = Tcl_ReadChars(chan, buffer, TCL_INDEX_NONE, 0);
+ if (bufferSize == TCL_IO_FAILURE) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"error reading file \"%s\": %s",
fileName, Tcl_PosixError(interp)));
@@ -1268,7 +1269,7 @@ SetupStacks(
if (tsdPtr->curLevel >= level) {
while (tsdPtr->curLevel >= level) {
- tsdPtr->levels[tsdPtr->curLevel].winPtr->optionLevel = -1;
+ tsdPtr->levels[tsdPtr->curLevel].winPtr->optionLevel = TCL_INDEX_NONE;
tsdPtr->curLevel--;
}
levelPtr = &tsdPtr->levels[level];
diff --git a/generic/tkPack.c b/generic/tkPack.c
index 1412a9d..65962bf 100644
--- a/generic/tkPack.c
+++ b/generic/tkPack.c
@@ -4,8 +4,8 @@
* 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-1997 Sun Microsystems, Inc.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 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.
@@ -13,9 +13,9 @@
#include "tkInt.h"
-typedef enum {TOP, BOTTOM, LEFT, RIGHT} Side;
+typedef enum {BOTTOM, LEFT, RIGHT, TOP} Side;
static const char *const sideNames[] = {
- "top", "bottom", "left", "right", NULL
+ "bottom", "left", "right", "top", NULL
};
/*
@@ -103,8 +103,8 @@ typedef struct Packer {
* The following structure is the official type record for the packer:
*/
-static void PackReqProc(ClientData clientData, Tk_Window tkwin);
-static void PackLostContentProc(ClientData clientData,
+static void PackReqProc(void *clientData, Tk_Window tkwin);
+static void PackLostContentProc(void *clientData,
Tk_Window tkwin);
static const Tk_GeomMgr packerType = {
@@ -117,14 +117,16 @@ static const Tk_GeomMgr packerType = {
* Forward declarations for functions defined later in this file:
*/
-static void ArrangePacking(ClientData clientData);
+static void ArrangePacking(void *clientData);
static int ConfigureContent(Tcl_Interp *interp, Tk_Window tkwin,
int objc, Tcl_Obj *const objv[]);
static Tcl_FreeProc DestroyPacker;
static Packer * GetPacker(Tk_Window tkwin);
+#ifndef TK_NO_DEPRECATED
static int PackAfter(Tcl_Interp *interp, Packer *prevPtr,
Packer *containerPtr, int objc,Tcl_Obj *const objv[]);
-static void PackStructureProc(ClientData clientData,
+#endif /* !TK_NO_DEPRECATED */
+static void PackStructureProc(void *clientData,
XEvent *eventPtr);
static void Unlink(Packer *packPtr);
static int XExpansion(Packer *contentPtr, int cavityWidth);
@@ -160,12 +162,12 @@ TkAppendPadAmount(
Tcl_Obj *padding[2];
if (halfSpace*2 == allSpace) {
- Tcl_DictObjPut(NULL, bufferObj, Tcl_NewStringObj(switchName, -1),
- Tcl_NewIntObj(halfSpace));
+ Tcl_DictObjPut(NULL, bufferObj, Tcl_NewStringObj(switchName, TCL_INDEX_NONE),
+ Tcl_NewWideIntObj(halfSpace));
} else {
- padding[0] = Tcl_NewIntObj(halfSpace);
- padding[1] = Tcl_NewIntObj(allSpace - halfSpace);
- Tcl_DictObjPut(NULL, bufferObj, Tcl_NewStringObj(switchName, -1),
+ padding[0] = Tcl_NewWideIntObj(halfSpace);
+ padding[1] = Tcl_NewWideIntObj(allSpace - halfSpace);
+ Tcl_DictObjPut(NULL, bufferObj, Tcl_NewStringObj(switchName, TCL_INDEX_NONE),
Tcl_NewListObj(2, padding));
}
}
@@ -189,7 +191,7 @@ TkAppendPadAmount(
int
Tk_PackObjCmd(
- ClientData clientData, /* Main window associated with interpreter. */
+ void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -197,12 +199,17 @@ Tk_PackObjCmd(
Tk_Window tkwin = (Tk_Window)clientData;
const char *argv2;
static const char *const optionStrings[] = {
- /* after, append, before and unpack are deprecated */
- "after", "append", "before", "unpack", "configure",
- "content", "forget", "info", "propagate", "slaves", NULL };
+#ifndef TK_NO_DEPRECATED
+ "after", "append", "before", "unpack",
+#endif /* !TK_NO_DEPRECATED */
+ "configure", "content", "forget", "info", "propagate", "slaves", NULL };
+ static const char *const optionStringsNoDep[] = {
+ "configure", "content", "forget", "info", "propagate", NULL };
enum options {
- PACK_AFTER, PACK_APPEND, PACK_BEFORE, PACK_UNPACK, PACK_CONFIGURE,
- PACK_CONTENT, PACK_FORGET, PACK_INFO, PACK_PROPAGATE, PACK_SLAVES };
+#ifndef TK_NO_DEPRECATED
+ PACK_AFTER, PACK_APPEND, PACK_BEFORE, PACK_UNPACK,
+#endif /* !TK_NO_DEPRECATED */
+ PACK_CONFIGURE, PACK_CONTENT, PACK_FORGET, PACK_INFO, PACK_PROPAGATE, PACK_SLAVES };
int index;
if (objc >= 2) {
@@ -225,13 +232,14 @@ Tk_PackObjCmd(
* deprecated and new options.
*/
- Tcl_GetIndexFromObj(interp, objv[1], &optionStrings[4],
+ Tcl_GetIndexFromObj(interp, objv[1], optionStringsNoDep,
"option", 0, &index);
return TCL_ERROR;
}
argv2 = Tcl_GetString(objv[2]);
switch ((enum options) index) {
+#ifndef TK_NO_DEPRECATED
case PACK_AFTER: {
Packer *prevPtr;
Tk_Window tkwin2;
@@ -243,7 +251,7 @@ Tk_PackObjCmd(
if (prevPtr->containerPtr == NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"window \"%s\" isn't packed", argv2));
- Tcl_SetErrorCode(interp, "TK", "PACK", "NOT_PACKED", NULL);
+ Tcl_SetErrorCode(interp, "TK", "PACK", "NOT_PACKED", (char *)NULL);
return TCL_ERROR;
}
return PackAfter(interp, prevPtr, prevPtr->containerPtr, objc-3, objv+3);
@@ -277,7 +285,7 @@ Tk_PackObjCmd(
if (packPtr->containerPtr == NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"window \"%s\" isn't packed", argv2));
- Tcl_SetErrorCode(interp, "TK", "PACK", "NOT_PACKED", NULL);
+ Tcl_SetErrorCode(interp, "TK", "PACK", "NOT_PACKED", (char *)NULL);
return TCL_ERROR;
}
containerPtr = packPtr->containerPtr;
@@ -296,11 +304,12 @@ Tk_PackObjCmd(
}
return PackAfter(interp, prevPtr, containerPtr, objc-3, objv+3);
}
+#endif /* !TK_NO_DEPRECATED */
case PACK_CONFIGURE:
if (argv2[0] != '.') {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad argument \"%s\": must be name of window", argv2));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "WINDOW_PATH", NULL);
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "WINDOW_PATH", (char *)NULL);
return TCL_ERROR;
}
return ConfigureContent(interp, tkwin, objc-2, objv+2);
@@ -342,41 +351,41 @@ Tk_PackObjCmd(
if (contentPtr->containerPtr == NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"window \"%s\" isn't packed", argv2));
- Tcl_SetErrorCode(interp, "TK", "PACK", "NOT_PACKED", NULL);
+ Tcl_SetErrorCode(interp, "TK", "PACK", "NOT_PACKED", (char *)NULL);
return TCL_ERROR;
}
infoObj = Tcl_NewObj();
- Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-in", -1),
- TkNewWindowObj(contentPtr->containerPtr->tkwin));
- Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-anchor", -1),
- Tcl_NewStringObj(Tk_NameOfAnchor(contentPtr->anchor), -1));
- Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-expand", -1),
+ Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-in", TCL_INDEX_NONE),
+ Tk_NewWindowObj(contentPtr->containerPtr->tkwin));
+ Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-anchor", TCL_INDEX_NONE),
+ Tcl_NewStringObj(Tk_NameOfAnchor(contentPtr->anchor), TCL_INDEX_NONE));
+ Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-expand", TCL_INDEX_NONE),
Tcl_NewBooleanObj(contentPtr->flags & EXPAND));
switch (contentPtr->flags & (FILLX|FILLY)) {
case 0:
- Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-fill", -1),
- Tcl_NewStringObj("none", -1));
+ Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-fill", TCL_INDEX_NONE),
+ Tcl_NewStringObj("none", TCL_INDEX_NONE));
break;
case FILLX:
- Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-fill", -1),
- Tcl_NewStringObj("x", -1));
+ Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-fill", TCL_INDEX_NONE),
+ Tcl_NewStringObj("x", TCL_INDEX_NONE));
break;
case FILLY:
- Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-fill", -1),
- Tcl_NewStringObj("y", -1));
+ Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-fill", TCL_INDEX_NONE),
+ Tcl_NewStringObj("y", TCL_INDEX_NONE));
break;
case FILLX|FILLY:
- Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-fill", -1),
- Tcl_NewStringObj("both", -1));
+ Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-fill", TCL_INDEX_NONE),
+ Tcl_NewStringObj("both", TCL_INDEX_NONE));
break;
}
TkAppendPadAmount(infoObj, "-ipadx", contentPtr->iPadX/2, contentPtr->iPadX);
TkAppendPadAmount(infoObj, "-ipady", contentPtr->iPadY/2, contentPtr->iPadY);
TkAppendPadAmount(infoObj, "-padx", contentPtr->padLeft,contentPtr->padX);
TkAppendPadAmount(infoObj, "-pady", contentPtr->padTop, contentPtr->padY);
- Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-side", -1),
- Tcl_NewStringObj(sideNames[contentPtr->side], -1));
+ Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-side", TCL_INDEX_NONE),
+ Tcl_NewStringObj(sideNames[contentPtr->side], TCL_INDEX_NONE));
Tcl_SetObjResult(interp, infoObj);
break;
}
@@ -453,11 +462,12 @@ Tk_PackObjCmd(
for (contentPtr = containerPtr->contentPtr; contentPtr != NULL;
contentPtr = contentPtr->nextPtr) {
Tcl_ListObjAppendElement(NULL, resultObj,
- TkNewWindowObj(contentPtr->tkwin));
+ Tk_NewWindowObj(contentPtr->tkwin));
}
Tcl_SetObjResult(interp, resultObj);
break;
}
+#ifndef TK_NO_DEPRECATED
case PACK_UNPACK: {
Tk_Window tkwin2;
Packer *packPtr;
@@ -481,6 +491,7 @@ Tk_PackObjCmd(
}
break;
}
+#endif /* !TK_NO_DEPRECATED */
}
return TCL_OK;
@@ -506,7 +517,7 @@ Tk_PackObjCmd(
static void
PackReqProc(
- ClientData clientData, /* Packer's information about window that got
+ void *clientData, /* Packer's information about window that got
* new preferred geometry. */
TCL_UNUSED(Tk_Window)) /* Other Tk-related information about the
* window. */
@@ -573,7 +584,7 @@ PackLostContentProc(
static void
ArrangePacking(
- ClientData clientData) /* Structure describing container whose content
+ void *clientData) /* Structure describing container whose content
* are to be re-layed out. */
{
Packer *containerPtr = (Packer *)clientData;
@@ -815,12 +826,10 @@ ArrangePacking(
x = frameX + borderLeft;
y = frameY + borderTop;
break;
- case TK_ANCHOR_CENTER:
+ default:
x = frameX + (borderLeft + frameWidth - width - borderRight)/2;
y = frameY + (borderTop + frameHeight - height - borderBtm)/2;
break;
- default:
- Tcl_Panic("bad frame factor in ArrangePacking");
}
width -= contentPtr->doubleBw;
height -= contentPtr->doubleBw;
@@ -1086,6 +1095,7 @@ GetPacker(
*------------------------------------------------------------------------
*/
+#ifndef TK_NO_DEPRECATED
static int
PackAfter(
Tcl_Interp *interp, /* Interpreter for error reporting. */
@@ -1101,7 +1111,8 @@ PackAfter(
Packer *packPtr;
Tk_Window tkwin, ancestor, parent;
Tcl_Obj **options;
- int index, optionCount, c;
+ int c;
+ Tcl_Size index, optionCount;
/*
* Iterate over all of the window specifiers, each consisting of two
@@ -1114,7 +1125,7 @@ PackAfter(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"wrong # args: window \"%s\" should be followed by options",
Tcl_GetString(objv[0])));
- Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL);
+ Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", (char *)NULL);
return TCL_ERROR;
}
@@ -1137,9 +1148,9 @@ PackAfter(
if (((Tk_FakeWin *) (ancestor))->flags & TK_TOP_HIERARCHY) {
badWindow:
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "can't pack %s inside %s", Tcl_GetString(objv[0]),
+ "can't pack \"%s\" inside \"%s\"", Tcl_GetString(objv[0]),
Tk_PathName(containerPtr->tkwin)));
- Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "HIERARCHY", NULL);
+ Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "HIERARCHY", (char *)NULL);
return TCL_ERROR;
}
}
@@ -1168,7 +1179,7 @@ PackAfter(
packPtr->flags |= OLD_STYLE;
for (index = 0 ; index < optionCount; index++) {
Tcl_Obj *curOptPtr = options[index];
- int length;
+ Tcl_Size length;
const char *curOpt = Tcl_GetStringFromObj(curOptPtr, &length);
c = curOpt[0];
@@ -1202,7 +1213,7 @@ PackAfter(
"wrong # args: \"%s\" option must be"
" followed by screen distance", curOpt));
Tcl_SetErrorCode(interp, "TK", "OLDPACK", "BAD_PARAMETER",
- NULL);
+ (char *)NULL);
return TCL_ERROR;
}
if (TkParsePadAmount(interp, tkwin, options[index+1],
@@ -1230,9 +1241,9 @@ PackAfter(
if (optionCount <= (index+1)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"wrong # args: \"frame\""
- " option must be followed by anchor point", -1));
+ " option must be followed by anchor point", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "OLDPACK", "BAD_PARAMETER",
- NULL);
+ (char *)NULL);
return TCL_ERROR;
}
if (Tk_GetAnchorFromObj(interp, options[index+1],
@@ -1246,7 +1257,7 @@ PackAfter(
" right, expand, fill, fillx, filly, padx, pady, or"
" frame", curOpt));
Tcl_SetErrorCode(interp, "TK", "OLDPACK", "BAD_PARAMETER",
- NULL);
+ (char *)NULL);
return TCL_ERROR;
}
}
@@ -1306,6 +1317,7 @@ PackAfter(
}
return TCL_OK;
}
+#endif /* !TK_NO_DEPRECATED */
/*
*----------------------------------------------------------------------
@@ -1359,11 +1371,15 @@ Unlink(
/*
* If we have emptied this container from content it means we are no longer
* handling it and should mark it as free.
+ *
+ * Send the event "NoManagedChild" to the container to inform it about there
+ * being no managed children inside it.
*/
if ((containerPtr->contentPtr == NULL) && (containerPtr->flags & ALLOCED_CONTAINER)) {
TkFreeGeometryContainer(containerPtr->tkwin, "pack");
containerPtr->flags &= ~ALLOCED_CONTAINER;
+ Tk_SendVirtualEvent(containerPtr->tkwin, "NoManagedChild", NULL);
}
}
@@ -1388,8 +1404,11 @@ Unlink(
static void
DestroyPacker(
- char *memPtr) /* Info about packed window that is now
- * dead. */
+#if TCL_MAJOR_VERSION > 8
+ void *memPtr) /* Info about packed window that is now dead. */
+#else
+ char *memPtr)
+#endif
{
Packer *packPtr = (Packer *)memPtr;
@@ -1419,7 +1438,7 @@ DestroyPacker(
static void
PackStructureProc(
- ClientData clientData, /* Our information about window referred to by
+ void *clientData, /* Our information about window referred to by
* eventPtr. */
XEvent *eventPtr) /* Describes what just happened. */
{
@@ -1432,7 +1451,7 @@ PackStructureProc(
Tcl_DoWhenIdle(ArrangePacking, packPtr);
}
if ((packPtr->containerPtr != NULL)
- && (packPtr->doubleBw != 2*Tk_Changes(packPtr->tkwin)->border_width)) {
+ && (packPtr->doubleBw != 2*Tk_Changes(packPtr->tkwin)->border_width)) {
if (!(packPtr->containerPtr->flags & REQUESTED_REPACK)) {
packPtr->doubleBw = 2*Tk_Changes(packPtr->tkwin)->border_width;
packPtr->containerPtr->flags |= REQUESTED_REPACK;
@@ -1457,8 +1476,8 @@ PackStructureProc(
if (packPtr->tkwin != NULL) {
TkDisplay *dispPtr = ((TkWindow *) packPtr->tkwin)->dispPtr;
- Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->packerHashTable,
- (void *)packPtr->tkwin));
+ Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->packerHashTable,
+ packPtr->tkwin));
}
if (packPtr->flags & REQUESTED_REPACK) {
@@ -1567,7 +1586,7 @@ ConfigureContent(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't pack \"%s\": it's a top-level window",
Tcl_GetString(objv[j])));
- Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "TOPLEVEL", NULL);
+ Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "TOPLEVEL", (char *)NULL);
return TCL_ERROR;
}
contentPtr = GetPacker(content);
@@ -1593,7 +1612,7 @@ ConfigureContent(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"extra option \"%s\" (option with no value?)",
Tcl_GetString(objv[i])));
- Tcl_SetErrorCode(interp, "TK", "PACK", "BAD_PARAMETER", NULL);
+ Tcl_SetErrorCode(interp, "TK", "PACK", "BAD_PARAMETER", (char *)NULL);
return TCL_ERROR;
}
if (Tcl_GetIndexFromObj(interp, objv[i], optionStrings,
@@ -1615,7 +1634,7 @@ ConfigureContent(
"window \"%s\" isn't packed",
Tcl_GetString(objv[i+1])));
Tcl_SetErrorCode(interp, "TK", "PACK", "NOT_PACKED",
- NULL);
+ (char *)NULL);
return TCL_ERROR;
}
containerPtr = prevPtr->containerPtr;
@@ -1673,7 +1692,7 @@ ConfigureContent(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad fill style \"%s\": must be "
"none, x, y, or both", string));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "FILL", NULL);
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "FILL", (char *)NULL);
return TCL_ERROR;
}
break;
@@ -1699,7 +1718,7 @@ ConfigureContent(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad ipadx value \"%s\": must be positive screen"
" distance", Tcl_GetString(objv[i+1])));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "INT_PAD", NULL);
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "INT_PAD", (char *)NULL);
return TCL_ERROR;
}
contentPtr->iPadX = tmp * 2;
@@ -1710,7 +1729,7 @@ ConfigureContent(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad ipady value \"%s\": must be positive screen"
" distance", Tcl_GetString(objv[i+1])));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "INT_PAD", NULL);
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "INT_PAD", (char *)NULL);
return TCL_ERROR;
}
contentPtr->iPadY = tmp * 2;
@@ -1788,16 +1807,16 @@ ConfigureContent(
}
if (Tk_TopWinHierarchy(ancestor)) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "can't pack %s inside %s", Tcl_GetString(objv[j]),
+ "can't pack \"%s\" inside \"%s\"", Tcl_GetString(objv[j]),
Tk_PathName(containerPtr->tkwin)));
- Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "HIERARCHY", NULL);
+ Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "HIERARCHY", (char *)NULL);
return TCL_ERROR;
}
}
if (content == containerPtr->tkwin) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "can't pack %s inside itself", Tcl_GetString(objv[j])));
- Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "SELF", NULL);
+ "can't pack \"%s\" inside itself", Tcl_GetString(objv[j])));
+ Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "SELF", (char *)NULL);
return TCL_ERROR;
}
@@ -1809,9 +1828,9 @@ ConfigureContent(
container = (TkWindow *)TkGetContainer(container)) {
if (container == (TkWindow *)content) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "can't put %s inside %s, would cause management loop",
- Tcl_GetString(objv[j]), Tk_PathName(containerPtr->tkwin)));
- Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "LOOP", NULL);
+ "can't put \"%s\" inside \"%s\": would cause management loop",
+ Tcl_GetString(objv[j]), Tk_PathName(containerPtr->tkwin)));
+ Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "LOOP", (char *)NULL);
return TCL_ERROR;
}
}
diff --git a/generic/tkPanedWindow.c b/generic/tkPanedWindow.c
index 5f542d0..b244c9a 100644
--- a/generic/tkPanedWindow.c
+++ b/generic/tkPanedWindow.c
@@ -6,8 +6,8 @@
* of other widgets, placing a movable "sash" between them, which can be
* used to alter the relative sizes of adjacent widgets.
*
- * Copyright (c) 1997 Sun Microsystems, Inc.
- * Copyright (c) 2000 Ajuba Solutions.
+ * Copyright © 1997 Sun Microsystems, Inc.
+ * Copyright © 2000 Ajuba Solutions.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -86,7 +86,7 @@ typedef struct Pane {
* the x dimension. */
int pady; /* Additional padding requested for pane, in
* the y dimension. */
- Tcl_Obj *widthPtr, *heightPtr;
+ Tcl_Obj *widthObj, *heightObj;
/* Tcl_Obj rep's of pane width/height, to
* allow for null values. */
int width; /* Pane width. */
@@ -125,8 +125,8 @@ typedef struct PanedWindow {
Tk_3DBorder background; /* Background color. */
int borderWidth; /* Value of -borderwidth option. */
int relief; /* 3D border effect (TK_RELIEF_RAISED, etc) */
- Tcl_Obj *widthPtr; /* Tcl_Obj rep for width. */
- Tcl_Obj *heightPtr; /* Tcl_Obj rep for height. */
+ Tcl_Obj *widthObj; /* Tcl_Obj rep for width. */
+ Tcl_Obj *heightObj; /* Tcl_Obj rep for height. */
int width, height; /* Width and height of the widget. */
enum orient orient; /* Orientation of the widget. */
Tk_Cursor cursor; /* Current cursor for window, or None. */
@@ -183,33 +183,30 @@ typedef struct PanedWindow {
* Forward declarations for functions defined later in this file:
*/
-int Tk_PanedWindowObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-static void PanedWindowCmdDeletedProc(ClientData clientData);
+static void PanedWindowCmdDeletedProc(void *clientData);
static int ConfigurePanedWindow(Tcl_Interp *interp,
PanedWindow *pwPtr, int objc,
Tcl_Obj *const objv[]);
static void DestroyPanedWindow(PanedWindow *pwPtr);
-static void DisplayPanedWindow(ClientData clientData);
-static void PanedWindowEventProc(ClientData clientData,
+static void DisplayPanedWindow(void *clientData);
+static void PanedWindowEventProc(void *clientData,
XEvent *eventPtr);
-static void ProxyWindowEventProc(ClientData clientData,
+static void ProxyWindowEventProc(void *clientData,
XEvent *eventPtr);
-static void DisplayProxyWindow(ClientData clientData);
-static void PanedWindowWorldChanged(ClientData instanceData);
-static int PanedWindowWidgetObjCmd(ClientData clientData,
+static void DisplayProxyWindow(void *clientData);
+static void PanedWindowWorldChanged(void *instanceData);
+static int PanedWindowWidgetObjCmd(void *clientData,
Tcl_Interp *, int objc, Tcl_Obj * const objv[]);
-static void PanedWindowLostPaneProc(ClientData clientData,
+static void PanedWindowLostPaneProc(void *clientData,
Tk_Window tkwin);
-static void PanedWindowReqProc(ClientData clientData,
+static void PanedWindowReqProc(void *clientData,
Tk_Window tkwin);
-static void ArrangePanes(ClientData clientData);
+static void ArrangePanes(void *clientData);
static void Unlink(Pane *panePtr);
static Pane * GetPane(PanedWindow *pwPtr, Tk_Window tkwin);
static void GetFirstLastVisiblePane(PanedWindow *pwPtr,
int *firstPtr, int *lastPtr);
-static void PaneStructureProc(ClientData clientData,
+static void PaneStructureProc(void *clientData,
XEvent *eventPtr);
static int PanedWindowSashCommand(PanedWindow *pwPtr,
Tcl_Interp *interp, int objc,
@@ -221,22 +218,22 @@ static void ComputeGeometry(PanedWindow *pwPtr);
static int ConfigurePanes(PanedWindow *pwPtr,
Tcl_Interp *interp, int objc,
Tcl_Obj * const objv[]);
-static void DestroyOptionTables(ClientData clientData,
+static void DestroyOptionTables(void *clientData,
Tcl_Interp *interp);
-static int SetSticky(ClientData clientData, Tcl_Interp *interp,
+static int SetSticky(void *clientData, Tcl_Interp *interp,
Tk_Window tkwin, Tcl_Obj **value, char *recordPtr,
- int internalOffset, char *oldInternalPtr,
+ Tcl_Size internalOffset, char *oldInternalPtr,
int flags);
-static Tcl_Obj * GetSticky(ClientData clientData, Tk_Window tkwin,
- char *recordPtr, int internalOffset);
-static void RestoreSticky(ClientData clientData, Tk_Window tkwin,
+static Tcl_Obj * GetSticky(void *clientData, Tk_Window tkwin,
+ char *recordPtr, Tcl_Size internalOffset);
+static void RestoreSticky(void *clientData, Tk_Window tkwin,
char *internalPtr, char *oldInternalPtr);
static void AdjustForSticky(int sticky, int cavityWidth,
int cavityHeight, int *xPtr, int *yPtr,
int *paneWidthPtr, int *paneHeightPtr);
static void MoveSash(PanedWindow *pwPtr, int sash, int diff);
static int ObjectIsEmpty(Tcl_Obj *objPtr);
-static char * ComputeSlotAddress(char *recordPtr, int offset);
+static void * ComputeSlotAddress(void *recordPtr, Tcl_Size offset);
static int PanedWindowIdentifyCoords(PanedWindow *pwPtr,
Tcl_Interp *interp, int x, int y);
@@ -275,92 +272,92 @@ static const Tk_ObjCustomOption stickyOption = {
static const Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_PANEDWINDOW_BG_COLOR, -1, Tk_Offset(PanedWindow, background), 0,
+ DEF_PANEDWINDOW_BG_COLOR, TCL_INDEX_NONE, offsetof(PanedWindow, background), 0,
DEF_PANEDWINDOW_BG_MONO, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL,
- NULL, 0, -1, 0, "-background", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_PANEDWINDOW_BORDERWIDTH, -1, Tk_Offset(PanedWindow, borderWidth),
+ DEF_PANEDWINDOW_BORDERWIDTH, TCL_INDEX_NONE, offsetof(PanedWindow, borderWidth),
0, 0, GEOMETRY},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_PANEDWINDOW_CURSOR, -1, Tk_Offset(PanedWindow, cursor),
+ DEF_PANEDWINDOW_CURSOR, TCL_INDEX_NONE, offsetof(PanedWindow, cursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-handlepad", "handlePad", "HandlePad",
- DEF_PANEDWINDOW_HANDLEPAD, -1, Tk_Offset(PanedWindow, handlePad),
+ DEF_PANEDWINDOW_HANDLEPAD, TCL_INDEX_NONE, offsetof(PanedWindow, handlePad),
0, 0, GEOMETRY},
{TK_OPTION_PIXELS, "-handlesize", "handleSize", "HandleSize",
- DEF_PANEDWINDOW_HANDLESIZE, Tk_Offset(PanedWindow, handleSizePtr),
- Tk_Offset(PanedWindow, handleSize), 0, 0, GEOMETRY},
+ DEF_PANEDWINDOW_HANDLESIZE, offsetof(PanedWindow, handleSizePtr),
+ offsetof(PanedWindow, handleSize), 0, 0, GEOMETRY},
{TK_OPTION_PIXELS, "-height", "height", "Height",
- DEF_PANEDWINDOW_HEIGHT, Tk_Offset(PanedWindow, heightPtr),
- Tk_Offset(PanedWindow, height), TK_OPTION_NULL_OK, 0, GEOMETRY},
+ DEF_PANEDWINDOW_HEIGHT, offsetof(PanedWindow, heightObj),
+ offsetof(PanedWindow, height), TK_OPTION_NULL_OK, 0, GEOMETRY},
{TK_OPTION_BOOLEAN, "-opaqueresize", "opaqueResize", "OpaqueResize",
- DEF_PANEDWINDOW_OPAQUERESIZE, -1,
- Tk_Offset(PanedWindow, resizeOpaque), 0, 0, 0},
+ DEF_PANEDWINDOW_OPAQUERESIZE, TCL_INDEX_NONE,
+ offsetof(PanedWindow, resizeOpaque), 0, 0, 0},
{TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient",
- DEF_PANEDWINDOW_ORIENT, -1, Tk_Offset(PanedWindow, orient),
+ DEF_PANEDWINDOW_ORIENT, TCL_INDEX_NONE, offsetof(PanedWindow, orient),
TK_OPTION_ENUM_VAR, orientStrings, GEOMETRY},
{TK_OPTION_BORDER, "-proxybackground", "proxyBackground", "ProxyBackground",
- 0, -1, Tk_Offset(PanedWindow, proxyBackground),
- TK_OPTION_NULL_OK, (ClientData) DEF_PANEDWINDOW_BG_MONO, 0},
+ 0, TCL_INDEX_NONE, offsetof(PanedWindow, proxyBackground), TK_OPTION_NULL_OK,
+ (void *)DEF_PANEDWINDOW_BG_MONO, 0},
{TK_OPTION_PIXELS, "-proxyborderwidth", "proxyBorderWidth", "ProxyBorderWidth",
- DEF_PANEDWINDOW_PROXYBORDER, Tk_Offset(PanedWindow, proxyBorderWidthPtr),
- Tk_Offset(PanedWindow, proxyBorderWidth), 0, 0, GEOMETRY},
+ DEF_PANEDWINDOW_PROXYBORDER, offsetof(PanedWindow, proxyBorderWidthPtr),
+ offsetof(PanedWindow, proxyBorderWidth), 0, 0, GEOMETRY},
{TK_OPTION_RELIEF, "-proxyrelief", "proxyRelief", "Relief",
- 0, -1, Tk_Offset(PanedWindow, proxyRelief),
+ 0, TCL_INDEX_NONE, offsetof(PanedWindow, proxyRelief),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_PANEDWINDOW_RELIEF, -1, Tk_Offset(PanedWindow, relief), 0, 0, 0},
+ DEF_PANEDWINDOW_RELIEF, TCL_INDEX_NONE, offsetof(PanedWindow, relief), 0, 0, 0},
{TK_OPTION_CURSOR, "-sashcursor", "sashCursor", "Cursor",
- DEF_PANEDWINDOW_SASHCURSOR, -1, Tk_Offset(PanedWindow, sashCursor),
+ DEF_PANEDWINDOW_SASHCURSOR, TCL_INDEX_NONE, offsetof(PanedWindow, sashCursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-sashpad", "sashPad", "SashPad",
- DEF_PANEDWINDOW_SASHPAD, -1, Tk_Offset(PanedWindow, sashPad),
+ DEF_PANEDWINDOW_SASHPAD, TCL_INDEX_NONE, offsetof(PanedWindow, sashPad),
0, 0, GEOMETRY},
{TK_OPTION_RELIEF, "-sashrelief", "sashRelief", "Relief",
- DEF_PANEDWINDOW_SASHRELIEF, -1, Tk_Offset(PanedWindow, sashRelief),
+ DEF_PANEDWINDOW_SASHRELIEF, TCL_INDEX_NONE, offsetof(PanedWindow, sashRelief),
0, 0, 0},
{TK_OPTION_PIXELS, "-sashwidth", "sashWidth", "Width",
- DEF_PANEDWINDOW_SASHWIDTH, Tk_Offset(PanedWindow, sashWidthPtr),
- Tk_Offset(PanedWindow, sashWidth), 0, 0, GEOMETRY},
+ DEF_PANEDWINDOW_SASHWIDTH, offsetof(PanedWindow, sashWidthPtr),
+ offsetof(PanedWindow, sashWidth), 0, 0, GEOMETRY},
{TK_OPTION_BOOLEAN, "-showhandle", "showHandle", "ShowHandle",
- DEF_PANEDWINDOW_SHOWHANDLE, -1, Tk_Offset(PanedWindow, showHandle),
+ DEF_PANEDWINDOW_SHOWHANDLE, TCL_INDEX_NONE, offsetof(PanedWindow, showHandle),
0, 0, GEOMETRY},
{TK_OPTION_PIXELS, "-width", "width", "Width",
- DEF_PANEDWINDOW_WIDTH, Tk_Offset(PanedWindow, widthPtr),
- Tk_Offset(PanedWindow, width), TK_OPTION_NULL_OK, 0, GEOMETRY},
+ DEF_PANEDWINDOW_WIDTH, offsetof(PanedWindow, widthObj),
+ offsetof(PanedWindow, width), TK_OPTION_NULL_OK, 0, GEOMETRY},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0}
};
static const Tk_OptionSpec paneOptionSpecs[] = {
{TK_OPTION_WINDOW, "-after", NULL, NULL,
- DEF_PANEDWINDOW_PANE_AFTER, -1, Tk_Offset(Pane, after),
+ DEF_PANEDWINDOW_PANE_AFTER, TCL_INDEX_NONE, offsetof(Pane, after),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_WINDOW, "-before", NULL, NULL,
- DEF_PANEDWINDOW_PANE_BEFORE, -1, Tk_Offset(Pane, before),
+ DEF_PANEDWINDOW_PANE_BEFORE, TCL_INDEX_NONE, offsetof(Pane, before),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-height", NULL, NULL,
- DEF_PANEDWINDOW_PANE_HEIGHT, Tk_Offset(Pane, heightPtr),
- Tk_Offset(Pane, height), TK_OPTION_NULL_OK, 0, 0},
+ DEF_PANEDWINDOW_PANE_HEIGHT, offsetof(Pane, heightObj),
+ offsetof(Pane, height), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_BOOLEAN, "-hide", "hide", "Hide",
- DEF_PANEDWINDOW_PANE_HIDE, -1, Tk_Offset(Pane, hide), 0,0,GEOMETRY},
+ DEF_PANEDWINDOW_PANE_HIDE, TCL_INDEX_NONE, offsetof(Pane, hide), 0,0,GEOMETRY},
{TK_OPTION_PIXELS, "-minsize", NULL, NULL,
- DEF_PANEDWINDOW_PANE_MINSIZE, -1, Tk_Offset(Pane, minSize), 0, 0, 0},
+ DEF_PANEDWINDOW_PANE_MINSIZE, TCL_INDEX_NONE, offsetof(Pane, minSize), 0, 0, 0},
{TK_OPTION_PIXELS, "-padx", NULL, NULL,
- DEF_PANEDWINDOW_PANE_PADX, -1, Tk_Offset(Pane, padx), 0, 0, 0},
+ DEF_PANEDWINDOW_PANE_PADX, TCL_INDEX_NONE, offsetof(Pane, padx), 0, 0, 0},
{TK_OPTION_PIXELS, "-pady", NULL, NULL,
- DEF_PANEDWINDOW_PANE_PADY, -1, Tk_Offset(Pane, pady), 0, 0, 0},
+ DEF_PANEDWINDOW_PANE_PADY, TCL_INDEX_NONE, offsetof(Pane, pady), 0, 0, 0},
{TK_OPTION_CUSTOM, "-sticky", NULL, NULL,
- DEF_PANEDWINDOW_PANE_STICKY, -1, Tk_Offset(Pane, sticky),
+ DEF_PANEDWINDOW_PANE_STICKY, TCL_INDEX_NONE, offsetof(Pane, sticky),
0, &stickyOption, 0},
{TK_OPTION_STRING_TABLE, "-stretch", "stretch", "Stretch",
- DEF_PANEDWINDOW_PANE_STRETCH, -1, Tk_Offset(Pane, stretch),
+ DEF_PANEDWINDOW_PANE_STRETCH, TCL_INDEX_NONE, offsetof(Pane, stretch),
TK_OPTION_ENUM_VAR, stretchStrings, 0},
{TK_OPTION_PIXELS, "-width", NULL, NULL,
- DEF_PANEDWINDOW_PANE_WIDTH, Tk_Offset(Pane, widthPtr),
- Tk_Offset(Pane, width), TK_OPTION_NULL_OK, 0, 0},
+ DEF_PANEDWINDOW_PANE_WIDTH, offsetof(Pane, widthObj),
+ offsetof(Pane, width), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0}
};
@@ -383,7 +380,7 @@ static const Tk_OptionSpec paneOptionSpecs[] = {
int
Tk_PanedWindowObjCmd(
- TCL_UNUSED(ClientData), /* NULL. */
+ TCL_UNUSED(void *), /* NULL. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj * const objv[]) /* Argument objects. */
@@ -414,7 +411,7 @@ Tk_PanedWindowObjCmd(
* easy access to it in the future.
*/
- pwOpts = ckalloc(sizeof(OptionTables));
+ pwOpts = (OptionTables *)ckalloc(sizeof(OptionTables));
/*
* Set up an exit handler to free the optionTables struct.
@@ -459,7 +456,7 @@ Tk_PanedWindowObjCmd(
Tcl_Preserve(pwPtr->tkwin);
- if (Tk_InitOptions(interp, (char *) pwPtr, pwOpts->pwOptions,
+ if (Tk_InitOptions(interp, pwPtr, pwOpts->pwOptions,
tkwin) != TCL_OK) {
Tk_DestroyWindow(pwPtr->tkwin);
return TCL_ERROR;
@@ -506,7 +503,7 @@ Tk_PanedWindowObjCmd(
return TCL_ERROR;
}
- Tcl_SetObjResult(interp, TkNewWindowObj(pwPtr->tkwin));
+ Tcl_SetObjResult(interp, Tk_NewWindowObj(pwPtr->tkwin));
return TCL_OK;
}
@@ -530,7 +527,7 @@ Tk_PanedWindowObjCmd(
static int
PanedWindowWidgetObjCmd(
- ClientData clientData, /* Information about square widget. */
+ void *clientData, /* Information about square widget. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj * const objv[]) /* Argument objects. */
@@ -551,7 +548,7 @@ PanedWindowWidgetObjCmd(
Pane *panePtr;
if (objc < 2) {
- Tcl_WrongNumArgs(interp, 1, objv, "option ?arg arg...?");
+ Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?");
return TCL_ERROR;
}
@@ -578,7 +575,7 @@ PanedWindowWidgetObjCmd(
result = TCL_ERROR;
break;
}
- resultObj = Tk_GetOptionValue(interp, (char *) pwPtr,
+ resultObj = Tk_GetOptionValue(interp, pwPtr,
pwPtr->optionTable, objv[2], pwPtr->tkwin);
if (resultObj == NULL) {
result = TCL_ERROR;
@@ -590,7 +587,7 @@ PanedWindowWidgetObjCmd(
case PW_CONFIGURE:
resultObj = NULL;
if (objc <= 3) {
- resultObj = Tk_GetOptionInfo(interp, (char *) pwPtr,
+ resultObj = Tk_GetOptionInfo(interp, pwPtr,
pwPtr->optionTable,
(objc == 3) ? objv[2] : NULL, pwPtr->tkwin);
if (resultObj == NULL) {
@@ -668,16 +665,16 @@ PanedWindowWidgetObjCmd(
for (i = 0; i < pwPtr->numPanes; i++) {
if (pwPtr->panes[i]->tkwin == tkwin) {
resultObj = Tk_GetOptionValue(interp,
- (char *) pwPtr->panes[i], pwPtr->paneOpts,
+ pwPtr->panes[i], pwPtr->paneOpts,
objv[3], tkwin);
}
}
if (resultObj == NULL) {
if (i == pwPtr->numPanes) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "not managed by this window", -1));
+ "not managed by this window", TCL_INDEX_NONE));
Tcl_SetErrorCode(interp, "TK", "PANEDWINDOW", "UNMANAGED",
- NULL);
+ (char *)NULL);
}
result = TCL_ERROR;
} else {
@@ -688,7 +685,7 @@ PanedWindowWidgetObjCmd(
case PW_PANECONFIGURE:
if (objc < 3) {
Tcl_WrongNumArgs(interp, 2, objv,
- "pane ?option? ?value option value ...?");
+ "pane ?-option value ...?");
result = TCL_ERROR;
break;
}
@@ -696,19 +693,19 @@ PanedWindowWidgetObjCmd(
if (objc <= 4) {
tkwin = Tk_NameToWindow(interp, Tcl_GetString(objv[2]),
pwPtr->tkwin);
- if (tkwin == NULL) {
- /*
- * Just a plain old bad window; Tk_NameToWindow filled in an
- * error message for us.
- */
-
- result = TCL_ERROR;
- break;
- }
+ if (tkwin == NULL) {
+ /*
+ * Just a plain old bad window; Tk_NameToWindow filled in an
+ * error message for us.
+ */
+
+ result = TCL_ERROR;
+ break;
+ }
for (i = 0; i < pwPtr->numPanes; i++) {
if (pwPtr->panes[i]->tkwin == tkwin) {
resultObj = Tk_GetOptionInfo(interp,
- (char *) pwPtr->panes[i], pwPtr->paneOpts,
+ pwPtr->panes[i], pwPtr->paneOpts,
(objc == 4) ? objv[3] : NULL,
pwPtr->tkwin);
if (resultObj == NULL) {
@@ -728,7 +725,7 @@ PanedWindowWidgetObjCmd(
resultObj = Tcl_NewObj();
for (i = 0; i < pwPtr->numPanes; i++) {
Tcl_ListObjAppendElement(NULL, resultObj,
- TkNewWindowObj(pwPtr->panes[i]->tkwin));
+ Tk_NewWindowObj(pwPtr->panes[i]->tkwin));
}
Tcl_SetObjResult(interp, resultObj);
break;
@@ -802,7 +799,7 @@ ConfigurePanes(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't add %s to itself", arg));
- Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "SELF", NULL);
+ Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "SELF", (char *)NULL);
return TCL_ERROR;
} else if (Tk_IsTopLevel(tkwin)) {
/*
@@ -812,7 +809,7 @@ ConfigurePanes(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't add toplevel %s to %s", arg,
Tk_PathName(pwPtr->tkwin)));
- Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "TOPLEVEL", NULL);
+ Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "TOPLEVEL", (char *)NULL);
return TCL_ERROR;
} else {
/*
@@ -830,7 +827,7 @@ ConfigurePanes(
"can't add %s to %s", arg,
Tk_PathName(pwPtr->tkwin)));
Tcl_SetErrorCode(interp, "TK", "GEOMETRY",
- "HIERARCHY", NULL);
+ "HIERARCHY", (char *)NULL);
return TCL_ERROR;
}
}
@@ -847,7 +844,7 @@ ConfigurePanes(
*/
memset((void *)&options, 0, sizeof(Pane));
- if (Tk_SetOptions(interp, (char *) &options, pwPtr->paneOpts,
+ if (Tk_SetOptions(interp, &options, pwPtr->paneOpts,
objc - firstOptionArg, objv + firstOptionArg,
pwPtr->tkwin, NULL, NULL) != TCL_OK) {
return TCL_ERROR;
@@ -890,8 +887,8 @@ ConfigurePanes(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"window \"%s\" is not managed by %s",
Tk_PathName(tkwin), Tk_PathName(pwPtr->tkwin)));
- Tcl_SetErrorCode(interp, "TK", "PANEDWINDOW", "UNMANAGED", NULL);
- Tk_FreeConfigOptions((char *) &options, pwPtr->paneOpts,
+ Tcl_SetErrorCode(interp, "TK", "PANEDWINDOW", "UNMANAGED", (char *)NULL);
+ Tk_FreeConfigOptions(&options, pwPtr->paneOpts,
pwPtr->tkwin);
return TCL_ERROR;
}
@@ -924,7 +921,7 @@ ConfigurePanes(
found = 0;
for (j = 0; j < pwPtr->numPanes; j++) {
if (pwPtr->panes[j] != NULL && pwPtr->panes[j]->tkwin == tkwin) {
- Tk_SetOptions(interp, (char *) pwPtr->panes[j],
+ Tk_SetOptions(interp, pwPtr->panes[j],
pwPtr->paneOpts, objc - firstOptionArg,
objv + firstOptionArg, pwPtr->tkwin, NULL, NULL);
if (pwPtr->panes[j]->minSize < 0) {
@@ -971,9 +968,9 @@ ConfigurePanes(
panePtr = (Pane *)ckalloc(sizeof(Pane));
memset(panePtr, 0, sizeof(Pane));
- Tk_InitOptions(interp, (char *)panePtr, pwPtr->paneOpts,
+ Tk_InitOptions(interp, panePtr, pwPtr->paneOpts,
pwPtr->tkwin);
- Tk_SetOptions(interp, (char *)panePtr, pwPtr->paneOpts,
+ Tk_SetOptions(interp, panePtr, pwPtr->paneOpts,
objc - firstOptionArg, objv + firstOptionArg,
pwPtr->tkwin, NULL, NULL);
panePtr->tkwin = tkwin;
@@ -1066,7 +1063,7 @@ ConfigurePanes(
pwPtr->numPanes += numNewPanes;
- Tk_FreeConfigOptions((char *) &options, pwPtr->paneOpts, pwPtr->tkwin);
+ Tk_FreeConfigOptions(&options, pwPtr->paneOpts, pwPtr->tkwin);
ComputeGeometry(pwPtr);
return TCL_OK;
@@ -1129,14 +1126,14 @@ PanedWindowSashCommand(
if (!ValidSashIndex(pwPtr, sash)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "invalid sash index", -1));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "SASH_INDEX", NULL);
+ "invalid sash index", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "SASH_INDEX", (char *)NULL);
return TCL_ERROR;
}
panePtr = pwPtr->panes[sash];
- coords[0] = Tcl_NewIntObj(panePtr->sashx);
- coords[1] = Tcl_NewIntObj(panePtr->sashy);
+ coords[0] = Tcl_NewWideIntObj(panePtr->sashx);
+ coords[1] = Tcl_NewWideIntObj(panePtr->sashy);
Tcl_SetObjResult(interp, Tcl_NewListObj(2, coords));
break;
@@ -1152,8 +1149,8 @@ PanedWindowSashCommand(
if (!ValidSashIndex(pwPtr, sash)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "invalid sash index", -1));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "SASH_INDEX", NULL);
+ "invalid sash index", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "SASH_INDEX", (char *)NULL);
return TCL_ERROR;
}
@@ -1169,8 +1166,8 @@ PanedWindowSashCommand(
pwPtr->panes[sash]->markx = x;
pwPtr->panes[sash]->marky = y;
} else {
- coords[0] = Tcl_NewIntObj(pwPtr->panes[sash]->markx);
- coords[1] = Tcl_NewIntObj(pwPtr->panes[sash]->marky);
+ coords[0] = Tcl_NewWideIntObj(pwPtr->panes[sash]->markx);
+ coords[1] = Tcl_NewWideIntObj(pwPtr->panes[sash]->marky);
Tcl_SetObjResult(interp, Tcl_NewListObj(2, coords));
}
break;
@@ -1188,8 +1185,8 @@ PanedWindowSashCommand(
if (!ValidSashIndex(pwPtr, sash)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "invalid sash index", -1));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "SASH_INDEX", NULL);
+ "invalid sash index", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "SASH_INDEX", (char *)NULL);
return TCL_ERROR;
}
@@ -1252,7 +1249,7 @@ ConfigurePanedWindow(
Tk_SavedOptions savedOptions;
int typemask = 0;
- if (Tk_SetOptions(interp, (char *)pwPtr, pwPtr->optionTable, objc, objv,
+ if (Tk_SetOptions(interp, pwPtr, pwPtr->optionTable, objc, objv,
pwPtr->tkwin, &savedOptions, &typemask) != TCL_OK) {
Tk_RestoreSavedOptions(&savedOptions);
return TCL_ERROR;
@@ -1294,7 +1291,7 @@ ConfigurePanedWindow(
static void
PanedWindowWorldChanged(
- ClientData instanceData) /* Information about the paned window. */
+ void *instanceData) /* Information about the paned window. */
{
XGCValues gcValues;
GC newGC;
@@ -1352,7 +1349,7 @@ PanedWindowWorldChanged(
static void
PanedWindowEventProc(
- ClientData clientData, /* Information about window. */
+ void *clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
PanedWindow *pwPtr = (PanedWindow *)clientData;
@@ -1372,17 +1369,17 @@ PanedWindowEventProc(
} else if (eventPtr->type == DestroyNotify) {
DestroyPanedWindow(pwPtr);
} else if (eventPtr->type == UnmapNotify) {
- for (i = 0; i < pwPtr->numPanes; i++) {
- if (!pwPtr->panes[i]->hide) {
- Tk_UnmapWindow(pwPtr->panes[i]->tkwin);
- }
- }
+ for (i = 0; i < pwPtr->numPanes; i++) {
+ if (!pwPtr->panes[i]->hide) {
+ Tk_UnmapWindow(pwPtr->panes[i]->tkwin);
+ }
+ }
} else if (eventPtr->type == MapNotify) {
- for (i = 0; i < pwPtr->numPanes; i++) {
- if (!pwPtr->panes[i]->hide) {
- Tk_MapWindow(pwPtr->panes[i]->tkwin);
- }
- }
+ for (i = 0; i < pwPtr->numPanes; i++) {
+ if (!pwPtr->panes[i]->hide) {
+ Tk_MapWindow(pwPtr->panes[i]->tkwin);
+ }
+ }
}
}
@@ -1406,7 +1403,7 @@ PanedWindowEventProc(
static void
PanedWindowCmdDeletedProc(
- ClientData clientData) /* Pointer to widget record for widget. */
+ void *clientData) /* Pointer to widget record for widget. */
{
PanedWindow *pwPtr = (PanedWindow *)clientData;
@@ -1443,7 +1440,7 @@ PanedWindowCmdDeletedProc(
static void
DisplayPanedWindow(
- ClientData clientData) /* Information about window. */
+ void *clientData) /* Information about window. */
{
PanedWindow *pwPtr = (PanedWindow *)clientData;
Pane *panePtr;
@@ -1582,7 +1579,7 @@ DestroyPanedWindow(
Tk_DeleteEventHandler(pwPtr->panes[i]->tkwin, StructureNotifyMask,
PaneStructureProc, pwPtr->panes[i]);
Tk_ManageGeometry(pwPtr->panes[i]->tkwin, NULL, NULL);
- Tk_FreeConfigOptions((char *) pwPtr->panes[i], pwPtr->paneOpts,
+ Tk_FreeConfigOptions(pwPtr->panes[i], pwPtr->paneOpts,
pwPtr->tkwin);
ckfree(pwPtr->panes[i]);
pwPtr->panes[i] = NULL;
@@ -1601,7 +1598,7 @@ DestroyPanedWindow(
* Let Tk_FreeConfigOptions clean up the rest.
*/
- Tk_FreeConfigOptions((char *) pwPtr, pwPtr->optionTable, pwPtr->tkwin);
+ Tk_FreeConfigOptions(pwPtr, pwPtr->optionTable, pwPtr->tkwin);
Tcl_Release(pwPtr->tkwin);
pwPtr->tkwin = NULL;
@@ -1628,7 +1625,7 @@ DestroyPanedWindow(
static void
PanedWindowReqProc(
- ClientData clientData, /* Paned window's information about window
+ void *clientData, /* Paned window's information about window
* that got new preferred geometry. */
TCL_UNUSED(Tk_Window)) /* Other Tk-related information about the
* window. */
@@ -1674,7 +1671,7 @@ PanedWindowReqProc(
static void
PanedWindowLostPaneProc(
- ClientData clientData, /* Grid structure for the pane that was
+ void *clientData, /* Grid structure for the pane that was
* stolen away. */
TCL_UNUSED(Tk_Window)) /* Tk's handle for the pane. */
{
@@ -1714,7 +1711,7 @@ PanedWindowLostPaneProc(
static void
ArrangePanes(
- ClientData clientData) /* Structure describing parent whose panes
+ void *clientData) /* Structure describing parent whose panes
* are to be re-layed out. */
{
PanedWindow *pwPtr = (PanedWindow *)clientData;
@@ -1792,18 +1789,18 @@ ArrangePanes(
*/
if (horizontal) {
- if (panePtr->width > 0) {
- paneSize = panePtr->width;
- } else {
- paneSize = panePtr->paneWidth;
- }
+ if (panePtr->width > 0) {
+ paneSize = panePtr->width;
+ } else {
+ paneSize = panePtr->paneWidth;
+ }
stretchReserve -= paneSize + (2 * panePtr->padx);
} else {
- if (panePtr->height > 0) {
- paneSize = panePtr->height;
- } else {
- paneSize = panePtr->paneHeight;
- }
+ if (panePtr->height > 0) {
+ paneSize = panePtr->height;
+ } else {
+ paneSize = panePtr->paneHeight;
+ }
stretchReserve -= paneSize + (2 * panePtr->pady);
}
if (IsStretchable(panePtr->stretch,i,first,last)
@@ -1853,18 +1850,18 @@ ArrangePanes(
*/
if (horizontal) {
- if (panePtr->width > 0) {
- paneSize = panePtr->width;
- } else {
- paneSize = panePtr->paneWidth;
- }
+ if (panePtr->width > 0) {
+ paneSize = panePtr->width;
+ } else {
+ paneSize = panePtr->paneWidth;
+ }
pwSize = pwWidth;
} else {
- if (panePtr->height > 0) {
- paneSize = panePtr->height;
- } else {
- paneSize = panePtr->paneHeight;
- }
+ if (panePtr->height > 0) {
+ paneSize = panePtr->height;
+ } else {
+ paneSize = panePtr->paneHeight;
+ }
pwSize = pwHeight;
}
if (IsStretchable(panePtr->stretch, i, first, last)) {
@@ -2160,7 +2157,7 @@ GetFirstLastVisiblePane(
static void
PaneStructureProc(
- ClientData clientData, /* Pointer to record describing window item. */
+ void *clientData, /* Pointer to record describing window item. */
XEvent *eventPtr) /* Describes what just happened. */
{
Pane *panePtr = (Pane *)clientData;
@@ -2372,7 +2369,7 @@ ComputeGeometry(
static void
DestroyOptionTables(
- ClientData clientData, /* Pointer to the OptionTables struct */
+ void *clientData, /* Pointer to the OptionTables struct */
TCL_UNUSED(Tcl_Interp *)) /* Pointer to the calling interp */
{
ckfree(clientData);
@@ -2400,7 +2397,7 @@ GetSticky(
TCL_UNUSED(void *),
TCL_UNUSED(Tk_Window),
char *recordPtr, /* Pointer to widget record. */
- int internalOffset) /* Offset within *recordPtr containing the
+ Tcl_Size internalOffset) /* Offset within *recordPtr containing the
* sticky value. */
{
int sticky = *(int *)(recordPtr + internalOffset);
@@ -2421,7 +2418,7 @@ GetSticky(
}
*p = '\0';
- return Tcl_NewStringObj(buffer, -1);
+ return Tcl_NewStringObj(buffer, TCL_INDEX_NONE);
}
/*
@@ -2452,13 +2449,14 @@ SetSticky(
* We use a pointer to the pointer because we
* may need to return a value (NULL). */
char *recordPtr, /* Pointer to storage for the widget record. */
- int internalOffset, /* Offset within *recordPtr at which the
+ Tcl_Size internalOffset, /* Offset within *recordPtr at which the
* internal value is to be stored. */
char *oldInternalPtr, /* Pointer to storage for the old value. */
int flags) /* Flags for the option, set Tk_SetOptions. */
{
int sticky = 0;
- char c, *internalPtr;
+ char c;
+ void *internalPtr;
const char *string;
internalPtr = ComputeSlotAddress(recordPtr, internalOffset);
@@ -2493,7 +2491,7 @@ SetSticky(
"bad stickyness value \"%s\": must be a string"
" containing zero or more of n, e, s, and w",
Tcl_GetString(*value)));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "STICKY", NULL);
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "STICKY", (char *)NULL);
return TCL_ERROR;
}
}
@@ -2754,7 +2752,7 @@ MoveSash(
static void
ProxyWindowEventProc(
- ClientData clientData, /* Information about window. */
+ void *clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
PanedWindow *pwPtr = (PanedWindow *)clientData;
@@ -2787,7 +2785,7 @@ ProxyWindowEventProc(
static void
DisplayProxyWindow(
- ClientData clientData) /* Information about window. */
+ void *clientData) /* Information about window. */
{
PanedWindow *pwPtr = (PanedWindow *)clientData;
Pixmap pixmap;
@@ -2879,8 +2877,8 @@ PanedWindowProxyCommand(
return TCL_ERROR;
}
- coords[0] = Tcl_NewIntObj(pwPtr->proxyx);
- coords[1] = Tcl_NewIntObj(pwPtr->proxyy);
+ coords[0] = Tcl_NewWideIntObj(pwPtr->proxyx);
+ coords[1] = Tcl_NewWideIntObj(pwPtr->proxyy);
Tcl_SetObjResult(interp, Tcl_NewListObj(2, coords));
break;
@@ -2909,16 +2907,16 @@ PanedWindowProxyCommand(
return TCL_ERROR;
}
- internalBW = Tk_InternalBorderLeft(pwPtr->tkwin);
+ internalBW = Tk_InternalBorderLeft(pwPtr->tkwin);
if (pwPtr->orient == ORIENT_HORIZONTAL) {
if (x < 0) {
x = 0;
}
- pwWidth = Tk_Width(pwPtr->tkwin) - (2 * internalBW);
- if (x > pwWidth) {
- x = pwWidth;
- }
- y = Tk_InternalBorderLeft(pwPtr->tkwin);
+ pwWidth = Tk_Width(pwPtr->tkwin) - (2 * internalBW);
+ if (x > pwWidth) {
+ x = pwWidth;
+ }
+ y = Tk_InternalBorderLeft(pwPtr->tkwin);
sashWidth = pwPtr->sashWidth;
sashHeight = Tk_Height(pwPtr->tkwin) -
(2 * Tk_InternalBorderLeft(pwPtr->tkwin));
@@ -2926,10 +2924,10 @@ PanedWindowProxyCommand(
if (y < 0) {
y = 0;
}
- pwHeight = Tk_Height(pwPtr->tkwin) - (2 * internalBW);
- if (y > pwHeight) {
- y = pwHeight;
- }
+ pwHeight = Tk_Height(pwPtr->tkwin) - (2 * internalBW);
+ if (y > pwHeight) {
+ y = pwHeight;
+ }
x = Tk_InternalBorderLeft(pwPtr->tkwin);
sashHeight = pwPtr->sashWidth;
sashWidth = Tk_Width(pwPtr->tkwin) -
@@ -3022,13 +3020,13 @@ ObjectIsEmpty(
*----------------------------------------------------------------------
*/
-static char *
+static void *
ComputeSlotAddress(
- char *recordPtr, /* Pointer to the start of a record. */
- int offset) /* Offset of a slot within that record; may be < 0. */
+ void *recordPtr, /* Pointer to the start of a record. */
+ Tcl_Size offset) /* Offset of a slot within that record; may be TCL_INDEX_NONE. */
{
- if (offset >= 0) {
- return recordPtr + offset;
+ if (offset != TCL_INDEX_NONE) {
+ return (char *)recordPtr + offset;
} else {
return NULL;
}
@@ -3144,8 +3142,8 @@ PanedWindowIdentifyCoords(
if (found != -1) {
Tcl_Obj *list[2];
- list[0] = Tcl_NewIntObj(found);
- list[1] = Tcl_NewStringObj((isHandle ? "handle" : "sash"), -1);
+ list[0] = Tcl_NewWideIntObj(found);
+ list[1] = Tcl_NewStringObj((isHandle ? "handle" : "sash"), TCL_INDEX_NONE);
Tcl_SetObjResult(interp, Tcl_NewListObj(2, list));
}
return TCL_OK;
diff --git a/generic/tkPkgConfig.c b/generic/tkPkgConfig.c
new file mode 100644
index 0000000..5050f8a
--- /dev/null
+++ b/generic/tkPkgConfig.c
@@ -0,0 +1,171 @@
+/*
+ * tkPkgConfig.c --
+ *
+ * This file contains the configuration information to embed into the tcl
+ * binary library.
+ *
+ * Copyright © 2002 Andreas Kupries <andreas_kupries@users.sourceforge.net>
+ * Copyright © 2017 Stuart Cassoff <stwo@users.sourceforge.net>
+ *
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ */
+
+/* Note, the definitions in this module are influenced by the following C
+ * preprocessor macros:
+ *
+ * OSCMa = shortcut for "old style configuration macro activates"
+ * NSCMdt = shortcut for "new style configuration macro declares that"
+ *
+ * - TCL_THREADS OSCMa compilation as threaded.
+ * - TCL_MEM_DEBUG OSCMa memory debugging.
+ *
+ * - TCL_CFG_DO64BIT NSCMdt tk is compiled for a 64bit system.
+ * - NDEBUG NSCMdt tk is compiled with symbol info off.
+ * - TCL_CFG_OPTIMIZED NSCMdt tk is compiled with cc optimizations on
+ * - TCL_CFG_PROFILED NSCMdt tk is compiled with profiling info.
+ *
+ * - _WIN32 || __CYGWIN__ The value for the fontsytem key will be
+ * MAC_OSX_TK chosen based on these macros/defines.
+ * HAVE_XFT NSCMdt xft font support was requested.
+ *
+ * - CFG_RUNTIME_* Paths to various stuff at runtime.
+ * - CFG_INSTALL_* Paths to various stuff at installation time.
+ *
+ * - TCL_CFGVAL_ENCODING string containing the encoding used for the
+ * configuration values.
+ */
+
+#include "tkInt.h"
+
+
+#ifndef TCL_CFGVAL_ENCODING
+#define TCL_CFGVAL_ENCODING "utf-8"
+#endif
+
+/*
+ * Use C preprocessor statements to define the various values for the embedded
+ * configuration information.
+ */
+
+#ifdef TCL_THREADS
+# define CFG_THREADED "1"
+#else
+# define CFG_THREADED "0"
+#endif
+
+#ifdef TCL_MEM_DEBUG
+# define CFG_MEMDEBUG "1"
+#else
+# define CFG_MEMDEBUG "0"
+#endif
+
+#ifdef TCL_CFG_DO64BIT
+# define CFG_64 "1"
+#else
+# define CFG_64 "0"
+#endif
+
+#ifndef NDEBUG
+# define CFG_DEBUG "1"
+#else
+# define CFG_DEBUG "0"
+#endif
+
+#ifdef TCL_CFG_OPTIMIZED
+# define CFG_OPTIMIZED "1"
+#else
+# define CFG_OPTIMIZED "0"
+#endif
+
+#ifdef TCL_CFG_PROFILED
+# define CFG_PROFILED "1"
+#else
+# define CFG_PROFILED "0"
+#endif
+
+#if defined(_WIN32)
+# define CFG_FONTSYSTEM "gdi"
+#elif defined(MAC_OSX_TK)
+# define CFG_FONTSYSTEM "cocoa"
+#elif defined(HAVE_XFT)
+# define CFG_FONTSYSTEM "xft"
+#else
+# define CFG_FONTSYSTEM "x11"
+#endif
+
+static const Tcl_Config cfg[] = {
+#if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
+ {"debug", CFG_DEBUG},
+ {"threaded", CFG_THREADED},
+ {"profiled", CFG_PROFILED},
+ {"64bit", CFG_64},
+ {"optimized", CFG_OPTIMIZED},
+ {"mem_debug", CFG_MEMDEBUG},
+#endif
+ {"fontsystem", CFG_FONTSYSTEM},
+
+ /* Runtime paths to various stuff */
+
+#ifdef CFG_RUNTIME_LIBDIR
+ {"libdir,runtime", CFG_RUNTIME_LIBDIR},
+#endif
+#ifdef CFG_RUNTIME_BINDIR
+ {"bindir,runtime", CFG_RUNTIME_BINDIR},
+#endif
+#ifdef CFG_RUNTIME_SCRDIR
+ {"scriptdir,runtime", CFG_RUNTIME_SCRDIR},
+#endif
+#ifdef CFG_RUNTIME_INCDIR
+ {"includedir,runtime", CFG_RUNTIME_INCDIR},
+#endif
+#ifdef CFG_RUNTIME_DOCDIR
+ {"docdir,runtime", CFG_RUNTIME_DOCDIR},
+#endif
+#ifdef CFG_RUNTIME_DEMODIR
+ {"demodir,runtime", CFG_RUNTIME_DEMODIR},
+#endif
+#if !defined(STATIC_BUILD)
+ {"dllfile,runtime", CFG_RUNTIME_DLLFILE},
+#endif
+
+ /* Installation paths to various stuff */
+
+#ifdef CFG_INSTALL_LIBDIR
+ {"libdir,install", CFG_INSTALL_LIBDIR},
+#endif
+#ifdef CFG_INSTALL_BINDIR
+ {"bindir,install", CFG_INSTALL_BINDIR},
+#endif
+#ifdef CFG_INSTALL_SCRDIR
+ {"scriptdir,install", CFG_INSTALL_SCRDIR},
+#endif
+#ifdef CFG_INSTALL_INCDIR
+ {"includedir,install", CFG_INSTALL_INCDIR},
+#endif
+#ifdef CFG_INSTALL_DOCDIR
+ {"docdir,install", CFG_INSTALL_DOCDIR},
+#endif
+#ifdef CFG_INSTALL_DEMODIR
+ {"demodir,install", CFG_INSTALL_DEMODIR},
+#endif
+
+ /* Last entry, closes the array */
+ {NULL, NULL}
+};
+
+void
+TkInitEmbeddedConfigurationInformation(
+ Tcl_Interp *interp) /* Interpreter the configuration command is
+ * registered in. */
+{
+ Tcl_RegisterConfig(interp, "tk", cfg, TCL_CFGVAL_ENCODING);
+}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */
diff --git a/generic/tkPlace.c b/generic/tkPlace.c
index b0577db..013c531 100644
--- a/generic/tkPlace.c
+++ b/generic/tkPlace.c
@@ -4,8 +4,8 @@
* 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-1997 Sun Microsystems, Inc.
+ * Copyright © 1992-1994 The Regents of the University of California.
+ * Copyright © 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.
@@ -25,10 +25,10 @@
*/
static const char *const borderModeStrings[] = {
- "inside", "outside", "ignore", NULL
+ "inside", "ignore", "outside", NULL
};
-typedef enum {BM_INSIDE, BM_OUTSIDE, BM_IGNORE} BorderMode;
+typedef enum {BM_INSIDE, BM_IGNORE, BM_OUTSIDE} BorderMode;
/*
* For each window whose geometry is managed by the placer there is a
@@ -54,24 +54,22 @@ typedef struct Content {
*/
int x, y; /* X and Y pixel coordinates for tkwin. */
- Tcl_Obj *xPtr, *yPtr; /* Tcl_Obj rep's of x, y coords, to keep pixel
+ Tcl_Obj *xObj, *yObj; /* Tcl_Obj rep's of x, y coords, to keep pixel
* spec. information. */
double relX, relY; /* X and Y coordinates relative to size of
* container. */
int width, height; /* Absolute dimensions for tkwin. */
- Tcl_Obj *widthPtr; /* Tcl_Obj rep of width, to keep pixel
+ Tcl_Obj *widthObj; /* Tcl_Obj rep of width, to keep pixel
* spec. */
- Tcl_Obj *heightPtr; /* Tcl_Obj rep of height, to keep pixel
+ Tcl_Obj *heightObj; /* Tcl_Obj rep of height, to keep pixel
* spec. */
double relWidth, relHeight; /* Dimensions for tkwin relative to size of
* container. */
- Tcl_Obj *relWidthPtr;
- Tcl_Obj *relHeightPtr;
+ Tcl_Obj *relWidthObj;
+ Tcl_Obj *relHeightObj;
Tk_Anchor anchor; /* Which point on tkwin is placed at the given
* position. */
BorderMode borderMode; /* How to treat borders of container window. */
- int flags; /* Various flags; see below for bit
- * definitions. */
} Content;
/*
@@ -81,55 +79,41 @@ typedef struct Content {
#define IN_MASK 1
static const Tk_OptionSpec optionSpecs[] = {
- {TK_OPTION_ANCHOR, "-anchor", NULL, NULL, "nw", -1,
- Tk_Offset(Content, anchor), 0, 0, 0},
- {TK_OPTION_STRING_TABLE, "-bordermode", NULL, NULL, "inside", -1,
- Tk_Offset(Content, borderMode), TK_OPTION_ENUM_VAR, borderModeStrings, 0},
- {TK_OPTION_PIXELS, "-height", NULL, NULL, "", Tk_Offset(Content, heightPtr),
- Tk_Offset(Content, height), TK_OPTION_NULL_OK, 0, 0},
- {TK_OPTION_WINDOW, "-in", NULL, NULL, "", -1, Tk_Offset(Content, inTkwin),
- 0, 0, IN_MASK},
- {TK_OPTION_DOUBLE, "-relheight", NULL, NULL, "",
- Tk_Offset(Content, relHeightPtr), Tk_Offset(Content, relHeight),
- TK_OPTION_NULL_OK, 0, 0},
- {TK_OPTION_DOUBLE, "-relwidth", NULL, NULL, "",
- Tk_Offset(Content, relWidthPtr), Tk_Offset(Content, relWidth),
- TK_OPTION_NULL_OK, 0, 0},
- {TK_OPTION_DOUBLE, "-relx", NULL, NULL, "0", -1,
- Tk_Offset(Content, relX), 0, 0, 0},
- {TK_OPTION_DOUBLE, "-rely", NULL, NULL, "0", -1,
- Tk_Offset(Content, relY), 0, 0, 0},
- {TK_OPTION_PIXELS, "-width", NULL, NULL, "", Tk_Offset(Content, widthPtr),
- Tk_Offset(Content, width), TK_OPTION_NULL_OK, 0, 0},
- {TK_OPTION_PIXELS, "-x", NULL, NULL, "0", Tk_Offset(Content, xPtr),
- Tk_Offset(Content, x), TK_OPTION_NULL_OK, 0, 0},
- {TK_OPTION_PIXELS, "-y", NULL, NULL, "0", Tk_Offset(Content, yPtr),
- Tk_Offset(Content, y), TK_OPTION_NULL_OK, 0, 0},
- {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0}
+ {TK_OPTION_ANCHOR, "-anchor", NULL, NULL, "nw", TCL_INDEX_NONE,
+ offsetof(Content, anchor), TK_OPTION_ENUM_VAR, 0, 0},
+ {TK_OPTION_STRING_TABLE, "-bordermode", NULL, NULL, "inside", TCL_INDEX_NONE,
+ offsetof(Content, borderMode), TK_OPTION_ENUM_VAR, borderModeStrings, 0},
+ {TK_OPTION_PIXELS, "-height", NULL, NULL, NULL, offsetof(Content, heightObj),
+ offsetof(Content, height), TK_OPTION_NULL_OK, 0, 0},
+ {TK_OPTION_WINDOW, "-in", NULL, NULL, "", TCL_INDEX_NONE, offsetof(Content, inTkwin),
+ 0, 0, IN_MASK},
+ {TK_OPTION_DOUBLE, "-relheight", NULL, NULL, NULL,
+ offsetof(Content, relHeightObj), offsetof(Content, relHeight),
+ TK_OPTION_NULL_OK, 0, 0},
+ {TK_OPTION_DOUBLE, "-relwidth", NULL, NULL, NULL,
+ offsetof(Content, relWidthObj), offsetof(Content, relWidth),
+ TK_OPTION_NULL_OK, 0, 0},
+ {TK_OPTION_DOUBLE, "-relx", NULL, NULL, "0.0", TCL_INDEX_NONE,
+ offsetof(Content, relX), 0, 0, 0},
+ {TK_OPTION_DOUBLE, "-rely", NULL, NULL, "0.0", TCL_INDEX_NONE,
+ offsetof(Content, relY), 0, 0, 0},
+ {TK_OPTION_PIXELS, "-width", NULL, NULL, NULL, offsetof(Content, widthObj),
+ offsetof(Content, width), TK_OPTION_NULL_OK, 0, 0},
+ {TK_OPTION_PIXELS, "-x", NULL, NULL, "0", offsetof(Content, xObj),
+ offsetof(Content, x), 0, 0, 0},
+ {TK_OPTION_PIXELS, "-y", NULL, NULL, "0", offsetof(Content, yObj),
+ offsetof(Content, y), 0, 0, 0},
+ {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0}
};
/*
- * Flag definitions for Content 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 container window that has a content managed by the placer there is a
* structure of the following form:
*/
typedef struct Container {
Tk_Window tkwin; /* Tk's token for container window. */
- struct Content *contentPtr; /* First in linked list of content placed
+ struct Content *contentPtr; /* First in linked list of content windowslaced
* relative to this container. */
int *abortPtr; /* If non-NULL, it means that there is a nested
* call to RecomputePlacement already working on
@@ -153,9 +137,9 @@ typedef struct Container {
* The following structure is the official type record for the placer:
*/
-static void PlaceRequestProc(ClientData clientData,
+static void PlaceRequestProc(void *clientData,
Tk_Window tkwin);
-static void PlaceLostContentProc(ClientData clientData,
+static void PlaceLostContentProc(void *clientData,
Tk_Window tkwin);
static const Tk_GeomMgr placerType = {
@@ -168,7 +152,7 @@ static const Tk_GeomMgr placerType = {
* Forward declarations for functions defined later in this file:
*/
-static void ContentStructureProc(ClientData clientData,
+static void ContentStructureProc(void *clientData,
XEvent *eventPtr);
static int ConfigureContent(Tcl_Interp *interp, Tk_Window tkwin,
Tk_OptionTable table, int objc,
@@ -179,9 +163,9 @@ static void FreeContent(Content *contentPtr);
static Content * FindContent(Tk_Window tkwin);
static Container * CreateContainer(Tk_Window tkwin);
static Container * FindContainer(Tk_Window tkwin);
-static void PlaceStructureProc(ClientData clientData,
+static void PlaceStructureProc(void *clientData,
XEvent *eventPtr);
-static void RecomputePlacement(ClientData clientData);
+static void RecomputePlacement(void *clientData);
static void UnlinkContent(Content *contentPtr);
/*
@@ -203,7 +187,7 @@ static void UnlinkContent(Content *contentPtr);
int
Tk_PlaceObjCmd(
- ClientData clientData, /* Interpreter main window. */
+ void *clientData, /* Interpreter main window. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -216,6 +200,9 @@ Tk_PlaceObjCmd(
static const char *const optionStrings[] = {
"configure", "content", "forget", "info", "slaves", NULL
};
+ static const char *const optionStringsNoDep[] = {
+ "configure", "content", "forget", "info", NULL
+ };
enum options { PLACE_CONFIGURE, PLACE_CONTENT, PLACE_FORGET, PLACE_INFO, PLACE_SLAVES };
int index;
@@ -247,8 +234,8 @@ Tk_PlaceObjCmd(
dispPtr = ((TkWindow *) tkwin)->dispPtr;
if (!dispPtr->placeInit) {
- Tcl_InitHashTable(&dispPtr->masterTable, TCL_ONE_WORD_KEYS);
- Tcl_InitHashTable(&dispPtr->slaveTable, TCL_ONE_WORD_KEYS);
+ Tcl_InitHashTable(&dispPtr->containerTable, TCL_ONE_WORD_KEYS);
+ Tcl_InitHashTable(&dispPtr->contentTable, TCL_ONE_WORD_KEYS);
dispPtr->placeInit = 1;
}
@@ -271,13 +258,21 @@ Tk_PlaceObjCmd(
dispPtr = ((TkWindow *) tkwin)->dispPtr;
if (!dispPtr->placeInit) {
- Tcl_InitHashTable(&dispPtr->masterTable, TCL_ONE_WORD_KEYS);
- Tcl_InitHashTable(&dispPtr->slaveTable, TCL_ONE_WORD_KEYS);
+ Tcl_InitHashTable(&dispPtr->containerTable, TCL_ONE_WORD_KEYS);
+ Tcl_InitHashTable(&dispPtr->contentTable, TCL_ONE_WORD_KEYS);
dispPtr->placeInit = 1;
}
- if (Tcl_GetIndexFromObj(interp, objv[1], optionStrings,
+ if (Tcl_GetIndexFromObj(NULL, objv[1], optionStrings,
"option", 0, &index) != TCL_OK) {
+ /*
+ * Call it again without the deprecated ones to get a proper error
+ * message. This works well since there can't be any ambiguity between
+ * deprecated and new options.
+ */
+
+ Tcl_GetIndexFromObjStruct(interp, objv[1], optionStringsNoDep,
+ sizeof(char *), "option", 0, &index);
return TCL_ERROR;
}
@@ -290,7 +285,7 @@ Tk_PlaceObjCmd(
if (contentPtr == NULL) {
return TCL_OK;
}
- objPtr = Tk_GetOptionInfo(interp, (char *)contentPtr, optionTable,
+ objPtr = Tk_GetOptionInfo(interp, contentPtr, optionTable,
(objc == 4) ? objv[3] : NULL, tkwin);
if (objPtr == NULL) {
return TCL_ERROR;
@@ -314,8 +309,8 @@ Tk_PlaceObjCmd(
Tk_UnmaintainGeometry(contentPtr->tkwin, contentPtr->containerPtr->tkwin);
}
UnlinkContent(contentPtr);
- Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->slaveTable,
- (void *)tkwin));
+ Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->contentTable,
+ tkwin));
Tk_DeleteEventHandler(tkwin, StructureNotifyMask, ContentStructureProc,
contentPtr);
Tk_ManageGeometry(tkwin, NULL, NULL);
@@ -345,7 +340,7 @@ Tk_PlaceObjCmd(
for (contentPtr = containerPtr->contentPtr; contentPtr != NULL;
contentPtr = contentPtr->nextPtr) {
Tcl_ListObjAppendElement(NULL, listPtr,
- TkNewWindowObj(contentPtr->tkwin));
+ Tk_NewWindowObj(contentPtr->tkwin));
}
Tcl_SetObjResult(interp, listPtr);
}
@@ -383,7 +378,7 @@ CreateContent(
int isNew;
TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
- hPtr = Tcl_CreateHashEntry(&dispPtr->slaveTable, (char *) tkwin, &isNew);
+ hPtr = Tcl_CreateHashEntry(&dispPtr->contentTable, (char *) tkwin, &isNew);
if (!isNew) {
return (Content *)Tcl_GetHashValue(hPtr);
}
@@ -399,6 +394,10 @@ CreateContent(
contentPtr->inTkwin = NULL;
contentPtr->anchor = TK_ANCHOR_NW;
contentPtr->borderMode = BM_INSIDE;
+ contentPtr->width = INT_MIN;
+ contentPtr->height = INT_MIN;
+ contentPtr->relWidth = NAN;
+ contentPtr->relHeight = NAN;
contentPtr->optionTable = table;
Tcl_SetHashValue(hPtr, contentPtr);
Tk_CreateEventHandler(tkwin, StructureNotifyMask, ContentStructureProc,
@@ -429,7 +428,7 @@ FreeContent(
if (contentPtr->containerPtr && (contentPtr->containerPtr->flags & PARENT_RECONFIG_PENDING)) {
Tcl_CancelIdleCall(RecomputePlacement, contentPtr->containerPtr);
}
- Tk_FreeConfigOptions((char *) contentPtr, contentPtr->optionTable,
+ Tk_FreeConfigOptions(contentPtr, contentPtr->optionTable,
contentPtr->tkwin);
ckfree(contentPtr);
}
@@ -459,7 +458,7 @@ FindContent(
Tcl_HashEntry *hPtr;
TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
- hPtr = Tcl_FindHashEntry(&dispPtr->slaveTable, (char *) tkwin);
+ hPtr = Tcl_FindHashEntry(&dispPtr->contentTable, tkwin);
if (hPtr == NULL) {
return NULL;
}
@@ -499,7 +498,7 @@ UnlinkContent(
} else {
for (prevPtr = containerPtr->contentPtr; ; prevPtr = prevPtr->nextPtr) {
if (prevPtr == NULL) {
- Tcl_Panic("UnlinkContent couldn't find slave to unlink");
+ Tcl_Panic("UnlinkContent couldn't find content to unlink");
}
if (prevPtr->nextPtr == contentPtr) {
prevPtr->nextPtr = contentPtr->nextPtr;
@@ -540,7 +539,7 @@ CreateContainer(
int isNew;
TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
- hPtr = Tcl_CreateHashEntry(&dispPtr->masterTable, (char *)tkwin, &isNew);
+ hPtr = Tcl_CreateHashEntry(&dispPtr->containerTable, (char *)tkwin, &isNew);
if (isNew) {
containerPtr = (Container *)ckalloc(sizeof(Container));
containerPtr->tkwin = tkwin;
@@ -582,7 +581,7 @@ FindContainer(
Tcl_HashEntry *hPtr;
TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
- hPtr = Tcl_FindHashEntry(&dispPtr->masterTable, (char *) tkwin);
+ hPtr = Tcl_FindHashEntry(&dispPtr->containerTable, tkwin);
if (hPtr == NULL) {
return NULL;
}
@@ -627,38 +626,17 @@ ConfigureContent(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't use placer on top-level window \"%s\"; use "
"wm command instead", Tk_PathName(tkwin)));
- Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "TOPLEVEL", NULL);
+ Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "TOPLEVEL", (char *)NULL);
return TCL_ERROR;
}
contentPtr = CreateContent(tkwin, table);
- if (Tk_SetOptions(interp, (char *)contentPtr, table, objc, objv,
+ if (Tk_SetOptions(interp, contentPtr, table, objc, objv,
contentPtr->tkwin, &savedOptions, &mask) != TCL_OK) {
goto error;
}
- /*
- * Set content flags. First clear the field, then add bits as needed.
- */
-
- contentPtr->flags = 0;
- if (contentPtr->heightPtr) {
- contentPtr->flags |= CHILD_HEIGHT;
- }
-
- if (contentPtr->relHeightPtr) {
- contentPtr->flags |= CHILD_REL_HEIGHT;
- }
-
- if (contentPtr->relWidthPtr) {
- contentPtr->flags |= CHILD_REL_WIDTH;
- }
-
- if (contentPtr->widthPtr) {
- contentPtr->flags |= CHILD_WIDTH;
- }
-
if (!(mask & IN_MASK) && (contentPtr->containerPtr != NULL)) {
/*
* If no -in option was passed and the content is already placed then
@@ -686,17 +664,17 @@ ConfigureContent(
}
if (Tk_TopWinHierarchy(ancestor)) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "can't place %s relative to %s",
+ "can't place \"%s\" relative to \"%s\"",
Tk_PathName(contentPtr->tkwin), Tk_PathName(win)));
- Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "HIERARCHY", NULL);
+ Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "HIERARCHY", (char *)NULL);
goto error;
}
}
if (contentPtr->tkwin == win) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "can't place %s relative to itself",
+ "can't place \"%s\" relative to itself",
Tk_PathName(contentPtr->tkwin)));
- Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "LOOP", NULL);
+ Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "LOOP", (char *)NULL);
goto error;
}
@@ -708,9 +686,9 @@ ConfigureContent(
container = (TkWindow *)TkGetContainer(container)) {
if (container == (TkWindow *)contentPtr->tkwin) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "can't put %s inside %s, would cause management loop",
- Tk_PathName(contentPtr->tkwin), Tk_PathName(win)));
- Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "LOOP", NULL);
+ "can't put \"%s\" inside \"%s\": would cause management loop",
+ Tk_PathName(contentPtr->tkwin), Tk_PathName(win)));
+ Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "LOOP", (char *)NULL);
goto error;
}
}
@@ -808,35 +786,35 @@ PlaceInfoCommand(
}
infoObj = Tcl_NewObj();
if (contentPtr->containerPtr != NULL) {
- Tcl_AppendToObj(infoObj, "-in", -1);
+ Tcl_AppendToObj(infoObj, "-in", TCL_INDEX_NONE);
Tcl_ListObjAppendElement(NULL, infoObj,
- TkNewWindowObj(contentPtr->containerPtr->tkwin));
- Tcl_AppendToObj(infoObj, " ", -1);
+ Tk_NewWindowObj(contentPtr->containerPtr->tkwin));
+ Tcl_AppendToObj(infoObj, " ", TCL_INDEX_NONE);
}
Tcl_AppendPrintfToObj(infoObj,
"-x %d -relx %.4g -y %d -rely %.4g",
contentPtr->x, contentPtr->relX, contentPtr->y, contentPtr->relY);
- if (contentPtr->flags & CHILD_WIDTH) {
+ if (contentPtr->widthObj) {
Tcl_AppendPrintfToObj(infoObj, " -width %d", contentPtr->width);
} else {
- Tcl_AppendToObj(infoObj, " -width {}", -1);
+ Tcl_AppendToObj(infoObj, " -width {}", TCL_INDEX_NONE);
}
- if (contentPtr->flags & CHILD_REL_WIDTH) {
+ if (contentPtr->relWidthObj) {
Tcl_AppendPrintfToObj(infoObj,
" -relwidth %.4g", contentPtr->relWidth);
} else {
- Tcl_AppendToObj(infoObj, " -relwidth {}", -1);
+ Tcl_AppendToObj(infoObj, " -relwidth {}", TCL_INDEX_NONE);
}
- if (contentPtr->flags & CHILD_HEIGHT) {
+ if (contentPtr->heightObj) {
Tcl_AppendPrintfToObj(infoObj, " -height %d", contentPtr->height);
} else {
- Tcl_AppendToObj(infoObj, " -height {}", -1);
+ Tcl_AppendToObj(infoObj, " -height {}", TCL_INDEX_NONE);
}
- if (contentPtr->flags & CHILD_REL_HEIGHT) {
+ if (contentPtr->relHeightObj) {
Tcl_AppendPrintfToObj(infoObj,
" -relheight %.4g", contentPtr->relHeight);
} else {
- Tcl_AppendToObj(infoObj, " -relheight {}", -1);
+ Tcl_AppendToObj(infoObj, " -relheight {}", TCL_INDEX_NONE);
}
Tcl_AppendPrintfToObj(infoObj, " -anchor %s -bordermode %s",
@@ -865,7 +843,7 @@ PlaceInfoCommand(
static void
RecomputePlacement(
- ClientData clientData) /* Pointer to Container record. */
+ void *clientData) /* Pointer to Container record. */
{
Container *containerPtr = (Container *)clientData;
Content *contentPtr;
@@ -928,12 +906,12 @@ RecomputePlacement(
x = (int) (x1 + ((x1 > 0) ? 0.5 : -0.5));
y1 = contentPtr->y + containerY + (contentPtr->relY*containerHeight);
y = (int) (y1 + ((y1 > 0) ? 0.5 : -0.5));
- if (contentPtr->flags & (CHILD_WIDTH|CHILD_REL_WIDTH)) {
+ if ((contentPtr->widthObj) || contentPtr->relWidthObj) {
width = 0;
- if (contentPtr->flags & CHILD_WIDTH) {
+ if (contentPtr->widthObj) {
width += contentPtr->width;
}
- if (contentPtr->flags & CHILD_REL_WIDTH) {
+ if (contentPtr->relWidthObj) {
/*
* The code below is a bit tricky. In order to round correctly
* when both relX and relWidth are specified, compute the
@@ -950,12 +928,12 @@ RecomputePlacement(
width = Tk_ReqWidth(contentPtr->tkwin)
+ 2*Tk_Changes(contentPtr->tkwin)->border_width;
}
- if (contentPtr->flags & (CHILD_HEIGHT|CHILD_REL_HEIGHT)) {
+ if (contentPtr->heightObj || contentPtr->relHeightObj) {
height = 0;
- if (contentPtr->flags & CHILD_HEIGHT) {
+ if (contentPtr->heightObj) {
height += contentPtr->height;
}
- if (contentPtr->flags & CHILD_REL_HEIGHT) {
+ if (contentPtr->relHeightObj) {
/*
* See note above for rounding errors in width computation.
*/
@@ -1002,7 +980,7 @@ RecomputePlacement(
break;
case TK_ANCHOR_NW:
break;
- case TK_ANCHOR_CENTER:
+ default:
x -= width/2;
y -= height/2;
break;
@@ -1037,9 +1015,9 @@ RecomputePlacement(
|| (height != Tk_Height(contentPtr->tkwin))) {
Tk_MoveResizeWindow(contentPtr->tkwin, x, y, width, height);
}
- if (abort) {
- break;
- }
+ if (abort) {
+ break;
+ }
/*
* Don't map the content unless the container is mapped: the content will
@@ -1084,7 +1062,7 @@ RecomputePlacement(
static void
PlaceStructureProc(
- ClientData clientData, /* Pointer to Container structure for window
+ void *clientData, /* Pointer to Container structure for window
* referred to by eventPtr. */
XEvent *eventPtr) /* Describes what just happened. */
{
@@ -1107,8 +1085,8 @@ PlaceStructureProc(
nextPtr = contentPtr->nextPtr;
contentPtr->nextPtr = NULL;
}
- Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->masterTable,
- (char *) containerPtr->tkwin));
+ Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->containerTable,
+ containerPtr->tkwin));
if (containerPtr->flags & PARENT_RECONFIG_PENDING) {
Tcl_CancelIdleCall(RecomputePlacement, containerPtr);
}
@@ -1163,7 +1141,7 @@ PlaceStructureProc(
static void
ContentStructureProc(
- ClientData clientData, /* Pointer to Content structure for window
+ void *clientData, /* Pointer to Content structure for window
* referred to by eventPtr. */
XEvent *eventPtr) /* Describes what just happened. */
{
@@ -1174,8 +1152,8 @@ ContentStructureProc(
if (contentPtr->containerPtr != NULL) {
UnlinkContent(contentPtr);
}
- Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->slaveTable,
- (char *) contentPtr->tkwin));
+ Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->contentTable,
+ contentPtr->tkwin));
FreeContent(contentPtr);
}
}
@@ -1200,20 +1178,20 @@ ContentStructureProc(
static void
PlaceRequestProc(
- ClientData clientData, /* Pointer to our record for content. */
+ void *clientData, /* Pointer to our record for content. */
TCL_UNUSED(Tk_Window)) /* Window that changed its desired size. */
{
Content *contentPtr = (Content *)clientData;
Container *containerPtr;
- if ((contentPtr->flags & (CHILD_WIDTH|CHILD_REL_WIDTH))
- && (contentPtr->flags & (CHILD_HEIGHT|CHILD_REL_HEIGHT))) {
- /*
- * Send a ConfigureNotify to indicate that the size change
- * request was rejected.
- */
+ if ((contentPtr->widthObj || contentPtr->relWidthObj)
+ && (contentPtr->heightObj || contentPtr->relHeightObj)) {
+ /*
+ * Send a ConfigureNotify to indicate that the size change
+ * request was rejected.
+ */
- TkDoConfigureNotify((TkWindow *)(contentPtr->tkwin));
+ TkDoConfigureNotify((TkWindow *)(contentPtr->tkwin));
return;
}
containerPtr = contentPtr->containerPtr;
@@ -1245,7 +1223,7 @@ PlaceRequestProc(
static void
PlaceLostContentProc(
- ClientData clientData, /* Content structure for content window that was
+ void *clientData, /* Content structure for content window that was
* stolen away. */
Tk_Window tkwin) /* Tk's handle for the content window. */
{
@@ -1257,8 +1235,8 @@ PlaceLostContentProc(
}
Tk_UnmapWindow(tkwin);
UnlinkContent(contentPtr);
- Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->slaveTable,
- (char *) tkwin));
+ Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->contentTable,
+ tkwin));
Tk_DeleteEventHandler(tkwin, StructureNotifyMask, ContentStructureProc,
contentPtr);
FreeContent(contentPtr);
diff --git a/generic/tkPlatDecls.h b/generic/tkPlatDecls.h
index 0e11746..46d425f 100644
--- a/generic/tkPlatDecls.h
+++ b/generic/tkPlatDecls.h
@@ -3,7 +3,7 @@
*
* Declarations of functions in the platform-specific public Tcl API.
*
- * Copyright (c) 1998-1999 Scriptics Corporation.
+ * Copyright © 1998-1999 Scriptics Corporation.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -54,28 +54,18 @@ EXTERN int Tk_TranslateWinEvent(HWND hwnd, UINT message,
LRESULT *result);
#endif /* WIN */
#ifdef MAC_OSX_TK /* AQUA */
-/* 0 */
-EXTERN void Tk_MacOSXSetEmbedHandler(
- Tk_MacOSXEmbedRegisterWinProc *registerWinProcPtr,
- Tk_MacOSXEmbedGetGrafPortProc *getPortProcPtr,
- Tk_MacOSXEmbedMakeContainerExistProc *containerExistProcPtr,
- Tk_MacOSXEmbedGetClipProc *getClipProc,
- Tk_MacOSXEmbedGetOffsetInParentProc *getOffsetProc);
-/* 1 */
-EXTERN void Tk_MacOSXTurnOffMenus(void);
-/* 2 */
-EXTERN void Tk_MacOSXTkOwnsCursor(int tkOwnsIt);
-/* 3 */
-EXTERN void TkMacOSXInitMenus(Tcl_Interp *interp);
+/* Slot 0 is reserved */
+/* Slot 1 is reserved */
+/* Slot 2 is reserved */
+/* Slot 3 is reserved */
/* 4 */
EXTERN void TkMacOSXInitAppleEvents(Tcl_Interp *interp);
/* 5 */
-EXTERN void TkGenWMConfigureEvent(Tk_Window tkwin, int x, int y,
+EXTERN void TkGenWMConfigureEvent_(Tk_Window tkwin, int x, int y,
int width, int height, int flags);
/* 6 */
EXTERN void TkMacOSXInvalClipRgns(Tk_Window tkwin);
-/* 7 */
-EXTERN void * TkMacOSXGetDrawablePort(Drawable drawable);
+/* Slot 7 is reserved */
/* 8 */
EXTERN void * TkMacOSXGetRootControl(Drawable drawable);
/* 9 */
@@ -91,7 +81,7 @@ EXTERN void * Tk_MacOSXGetNSWindowForDrawable(Drawable drawable);
/* Slot 14 is reserved */
/* Slot 15 is reserved */
/* 16 */
-EXTERN void TkGenWMConfigureEvent_(Tk_Window tkwin, int x, int y,
+EXTERN void TkGenWMConfigureEvent(Tk_Window tkwin, int x, int y,
int width, int height, int flags);
#endif /* AQUA */
@@ -108,14 +98,14 @@ typedef struct TkPlatStubs {
int (*tk_TranslateWinEvent) (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam, LRESULT *result); /* 5 */
#endif /* WIN */
#ifdef MAC_OSX_TK /* AQUA */
- void (*tk_MacOSXSetEmbedHandler) (Tk_MacOSXEmbedRegisterWinProc *registerWinProcPtr, Tk_MacOSXEmbedGetGrafPortProc *getPortProcPtr, Tk_MacOSXEmbedMakeContainerExistProc *containerExistProcPtr, Tk_MacOSXEmbedGetClipProc *getClipProc, Tk_MacOSXEmbedGetOffsetInParentProc *getOffsetProc); /* 0 */
- void (*tk_MacOSXTurnOffMenus) (void); /* 1 */
- void (*tk_MacOSXTkOwnsCursor) (int tkOwnsIt); /* 2 */
- void (*tkMacOSXInitMenus) (Tcl_Interp *interp); /* 3 */
+ void (*reserved0)(void);
+ void (*reserved1)(void);
+ void (*reserved2)(void);
+ void (*reserved3)(void);
void (*tkMacOSXInitAppleEvents) (Tcl_Interp *interp); /* 4 */
- void (*tkGenWMConfigureEvent) (Tk_Window tkwin, int x, int y, int width, int height, int flags); /* 5 */
+ void (*tkGenWMConfigureEvent_) (Tk_Window tkwin, int x, int y, int width, int height, int flags); /* 5 */
void (*tkMacOSXInvalClipRgns) (Tk_Window tkwin); /* 6 */
- void * (*tkMacOSXGetDrawablePort) (Drawable drawable); /* 7 */
+ void (*reserved7)(void);
void * (*tkMacOSXGetRootControl) (Drawable drawable); /* 8 */
void (*tk_MacOSXSetupTkNotifier) (void); /* 9 */
int (*tk_MacOSXIsAppInFront) (void); /* 10 */
@@ -124,7 +114,7 @@ typedef struct TkPlatStubs {
void * (*tk_MacOSXGetNSWindowForDrawable) (Drawable drawable); /* 13 */
void (*reserved14)(void);
void (*reserved15)(void);
- void (*tkGenWMConfigureEvent_) (Tk_Window tkwin, int x, int y, int width, int height, int flags); /* 16 */
+ void (*tkGenWMConfigureEvent) (Tk_Window tkwin, int x, int y, int width, int height, int flags); /* 16 */
#endif /* AQUA */
} TkPlatStubs;
@@ -155,22 +145,17 @@ extern const TkPlatStubs *tkPlatStubsPtr;
(tkPlatStubsPtr->tk_TranslateWinEvent) /* 5 */
#endif /* WIN */
#ifdef MAC_OSX_TK /* AQUA */
-#define Tk_MacOSXSetEmbedHandler \
- (tkPlatStubsPtr->tk_MacOSXSetEmbedHandler) /* 0 */
-#define Tk_MacOSXTurnOffMenus \
- (tkPlatStubsPtr->tk_MacOSXTurnOffMenus) /* 1 */
-#define Tk_MacOSXTkOwnsCursor \
- (tkPlatStubsPtr->tk_MacOSXTkOwnsCursor) /* 2 */
-#define TkMacOSXInitMenus \
- (tkPlatStubsPtr->tkMacOSXInitMenus) /* 3 */
+/* Slot 0 is reserved */
+/* Slot 1 is reserved */
+/* Slot 2 is reserved */
+/* Slot 3 is reserved */
#define TkMacOSXInitAppleEvents \
(tkPlatStubsPtr->tkMacOSXInitAppleEvents) /* 4 */
-#define TkGenWMConfigureEvent \
- (tkPlatStubsPtr->tkGenWMConfigureEvent) /* 5 */
+#define TkGenWMConfigureEvent_ \
+ (tkPlatStubsPtr->tkGenWMConfigureEvent_) /* 5 */
#define TkMacOSXInvalClipRgns \
(tkPlatStubsPtr->tkMacOSXInvalClipRgns) /* 6 */
-#define TkMacOSXGetDrawablePort \
- (tkPlatStubsPtr->tkMacOSXGetDrawablePort) /* 7 */
+/* Slot 7 is reserved */
#define TkMacOSXGetRootControl \
(tkPlatStubsPtr->tkMacOSXGetRootControl) /* 8 */
#define Tk_MacOSXSetupTkNotifier \
@@ -185,8 +170,8 @@ extern const TkPlatStubs *tkPlatStubsPtr;
(tkPlatStubsPtr->tk_MacOSXGetNSWindowForDrawable) /* 13 */
/* Slot 14 is reserved */
/* Slot 15 is reserved */
-#define TkGenWMConfigureEvent_ \
- (tkPlatStubsPtr->tkGenWMConfigureEvent_) /* 16 */
+#define TkGenWMConfigureEvent \
+ (tkPlatStubsPtr->tkGenWMConfigureEvent) /* 16 */
#endif /* AQUA */
#endif /* defined(USE_TK_STUBS) */
diff --git a/generic/tkPointer.c b/generic/tkPointer.c
index 905489a..2fbdedf 100644
--- a/generic/tkPointer.c
+++ b/generic/tkPointer.c
@@ -6,7 +6,7 @@
* to generate appropriate enter/leave events, and to update the global
* grab window information.
*
- * Copyright (c) 1996 Sun Microsystems, Inc.
+ * Copyright © 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.
@@ -20,7 +20,6 @@
#if defined(MAC_OSX_TK)
#include "tkMacOSXInt.h"
-#define Cursor XCursor
#endif
typedef struct {
@@ -126,7 +125,7 @@ GenerateEnterLeave(
int state) /* State flags. */
{
int crossed = 0; /* 1 if mouse crossed a window boundary */
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
TkWindow *restrictWinPtr = tsdPtr->restrictWinPtr;
TkWindow *lastWinPtr = tsdPtr->lastWinPtr;
@@ -219,7 +218,7 @@ Tk_UpdatePointer(
int x, int y, /* Pointer location in root coords. */
int state) /* Modifier state mask. */
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
TkWindow *winPtr = (TkWindow *)tkwin;
TkWindow *targetWinPtr;
@@ -255,8 +254,8 @@ Tk_UpdatePointer(
* between the current button state and the last known button state.
*/
- for (b = Button1; b <= Button5; b++) {
- mask = TkGetButtonMask(b);
+ for (b = Button1; b <= Button9; b++) {
+ mask = Tk_GetButtonMask(b);
if (changes & mask) {
if (state & mask) {
type = ButtonPress;
@@ -425,8 +424,15 @@ XGrabPointer(
Cursor cursor,
Time time)
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ (void)owner_events;
+ (void)event_mask;
+ (void)pointer_mode;
+ (void)keyboard_mode;
+ (void)confine_to;
+ (void)cursor;
+ (void)time;
LastKnownRequestProcessed(display)++;
tsdPtr->grabWinPtr = (TkWindow *) Tk_IdToWindow(display, grab_window);
@@ -460,8 +466,9 @@ XUngrabPointer(
Display *display,
Time time)
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ (void)time;
LastKnownRequestProcessed(display)++;
tsdPtr->grabWinPtr = NULL;
@@ -491,7 +498,7 @@ void
TkPointerDeadWindow(
TkWindow *winPtr)
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (winPtr == tsdPtr->lastWinPtr) {
@@ -538,7 +545,7 @@ UpdateCursor(
TkWindow *winPtr)
{
Cursor cursor = None;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -584,8 +591,9 @@ XDefineCursor(
Cursor cursor)
{
TkWindow *winPtr = (TkWindow *) Tk_IdToWindow(display, w);
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ (void)cursor;
if (tsdPtr->cursorWinPtr == winPtr) {
UpdateCursor(winPtr);
diff --git a/generic/tkPort.h b/generic/tkPort.h
index d6db449..cdc6bea 100644
--- a/generic/tkPort.h
+++ b/generic/tkPort.h
@@ -5,7 +5,7 @@
* differences between systems. It reads in platform specific
* portability files.
*
- * Copyright (c) 1995 Sun Microsystems, Inc.
+ * Copyright © 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.
diff --git a/generic/tkRectOval.c b/generic/tkRectOval.c
index 59d0a32..2162591 100644
--- a/generic/tkRectOval.c
+++ b/generic/tkRectOval.c
@@ -3,8 +3,8 @@
*
* This file implements rectangle and oval items for canvas widgets.
*
- * Copyright (c) 1991-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1991-1994 The Regents of the University of California.
+ * Copyright © 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.
@@ -61,62 +61,62 @@ static const Tk_CustomOption pixelOption = {
static const Tk_ConfigSpec configSpecs[] = {
{TK_CONFIG_CUSTOM, "-activedash", NULL, NULL,
- NULL, Tk_Offset(RectOvalItem, outline.activeDash),
+ NULL, offsetof(RectOvalItem, outline.activeDash),
TK_CONFIG_NULL_OK, &dashOption},
{TK_CONFIG_COLOR, "-activefill", NULL, NULL,
- NULL, Tk_Offset(RectOvalItem, activeFillColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(RectOvalItem, activeFillColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_COLOR, "-activeoutline", NULL, NULL,
- NULL, Tk_Offset(RectOvalItem, outline.activeColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(RectOvalItem, outline.activeColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-activeoutlinestipple", NULL, NULL,
- NULL, Tk_Offset(RectOvalItem, outline.activeStipple),
+ NULL, offsetof(RectOvalItem, outline.activeStipple),
TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-activestipple", NULL, NULL,
- NULL, Tk_Offset(RectOvalItem, activeFillStipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(RectOvalItem, activeFillStipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-activewidth", NULL, NULL,
- "0.0", Tk_Offset(RectOvalItem, outline.activeWidth),
+ "0.0", offsetof(RectOvalItem, outline.activeWidth),
TK_CONFIG_DONT_SET_DEFAULT, &pixelOption},
{TK_CONFIG_CUSTOM, "-dash", NULL, NULL,
- NULL, Tk_Offset(RectOvalItem, outline.dash),
+ NULL, offsetof(RectOvalItem, outline.dash),
TK_CONFIG_NULL_OK, &dashOption},
{TK_CONFIG_PIXELS, "-dashoffset", NULL, NULL,
- "0", Tk_Offset(RectOvalItem, outline.offset),
+ "0", offsetof(RectOvalItem, outline.offset),
TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_CUSTOM, "-disableddash", NULL, NULL,
- NULL, Tk_Offset(RectOvalItem, outline.disabledDash),
+ NULL, offsetof(RectOvalItem, outline.disabledDash),
TK_CONFIG_NULL_OK, &dashOption},
{TK_CONFIG_COLOR, "-disabledfill", NULL, NULL,
- NULL, Tk_Offset(RectOvalItem, disabledFillColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(RectOvalItem, disabledFillColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_COLOR, "-disabledoutline", NULL, NULL,
- NULL, Tk_Offset(RectOvalItem, outline.disabledColor),
+ NULL, offsetof(RectOvalItem, outline.disabledColor),
TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-disabledoutlinestipple", NULL, NULL,
- NULL, Tk_Offset(RectOvalItem, outline.disabledStipple),
+ NULL, offsetof(RectOvalItem, outline.disabledStipple),
TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-disabledstipple", NULL, NULL,
- NULL, Tk_Offset(RectOvalItem, disabledFillStipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(RectOvalItem, disabledFillStipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-disabledwidth", NULL, NULL,
- "0.0", Tk_Offset(RectOvalItem, outline.disabledWidth),
+ "0.0", offsetof(RectOvalItem, outline.disabledWidth),
TK_CONFIG_DONT_SET_DEFAULT, &pixelOption},
{TK_CONFIG_COLOR, "-fill", NULL, NULL,
- NULL, Tk_Offset(RectOvalItem, fillColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(RectOvalItem, fillColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-offset", NULL, NULL,
- "0,0", Tk_Offset(RectOvalItem, tsoffset),
+ "0,0", offsetof(RectOvalItem, tsoffset),
TK_CONFIG_DONT_SET_DEFAULT, &offsetOption},
{TK_CONFIG_COLOR, "-outline", NULL, NULL,
- DEF_CANVITEM_OUTLINE, Tk_Offset(RectOvalItem, outline.color), TK_CONFIG_NULL_OK, NULL},
+ DEF_CANVITEM_OUTLINE, offsetof(RectOvalItem, outline.color), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-outlineoffset", NULL, NULL,
- "0,0", Tk_Offset(RectOvalItem, outline.tsoffset),
+ "0,0", offsetof(RectOvalItem, outline.tsoffset),
TK_CONFIG_DONT_SET_DEFAULT, &offsetOption},
{TK_CONFIG_BITMAP, "-outlinestipple", NULL, NULL,
- NULL, Tk_Offset(RectOvalItem, outline.stipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(RectOvalItem, outline.stipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-state", NULL, NULL,
- NULL, Tk_Offset(Tk_Item, state),TK_CONFIG_NULL_OK, &stateOption},
+ NULL, offsetof(Tk_Item, state),TK_CONFIG_NULL_OK, &stateOption},
{TK_CONFIG_BITMAP, "-stipple", NULL, NULL,
- NULL, Tk_Offset(RectOvalItem, fillStipple),TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(RectOvalItem, fillStipple),TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-tags", NULL, NULL,
NULL, 0, TK_CONFIG_NULL_OK, &tagsOption},
{TK_CONFIG_CUSTOM, "-width", NULL, NULL,
- "1.0", Tk_Offset(RectOvalItem, outline.width),
+ "1.0", offsetof(RectOvalItem, outline.width),
TK_CONFIG_DONT_SET_DEFAULT, &pixelOption},
{TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}
};
@@ -128,10 +128,10 @@ static const Tk_ConfigSpec configSpecs[] = {
static void ComputeRectOvalBbox(Tk_Canvas canvas,
RectOvalItem *rectOvalPtr);
static int ConfigureRectOval(Tcl_Interp *interp, Tk_Canvas canvas,
- Tk_Item *itemPtr, int objc, Tcl_Obj *const objv[],
+ Tk_Item *itemPtr, Tcl_Size objc, Tcl_Obj *const objv[],
int flags);
static int CreateRectOval(Tcl_Interp *interp, Tk_Canvas canvas,
- Tk_Item *itemPtr, int objc, Tcl_Obj *const objv[]);
+ Tk_Item *itemPtr, Tcl_Size objc, Tcl_Obj *const objv[]);
static void DeleteRectOval(Tk_Canvas canvas, Tk_Item *itemPtr,
Display *display);
static void DisplayRectOval(Tk_Canvas canvas, Tk_Item *itemPtr,
@@ -142,13 +142,15 @@ static int OvalToArea(Tk_Canvas canvas, Tk_Item *itemPtr,
static double OvalToPoint(Tk_Canvas canvas, Tk_Item *itemPtr,
double *pointPtr);
static int RectOvalCoords(Tcl_Interp *interp, Tk_Canvas canvas,
- Tk_Item *itemPtr, int objc, Tcl_Obj *const objv[]);
+ Tk_Item *itemPtr, Tcl_Size objc, Tcl_Obj *const objv[]);
static int RectOvalToPostscript(Tcl_Interp *interp,
Tk_Canvas canvas, Tk_Item *itemPtr, int prepass);
static int RectToArea(Tk_Canvas canvas, Tk_Item *itemPtr,
double *areaPtr);
static double RectToPoint(Tk_Canvas canvas, Tk_Item *itemPtr,
double *pointPtr);
+static void RotateRectOval(Tk_Canvas canvas, Tk_Item *itemPtr,
+ double originX, double originY, double angleRad);
static void ScaleRectOval(Tk_Canvas canvas, Tk_Item *itemPtr,
double originX, double originY,
double scaleX, double scaleY);
@@ -181,7 +183,8 @@ Tk_ItemType tkRectangleType = {
NULL, /* insertProc */
NULL, /* dTextProc */
NULL, /* nextPtr */
- NULL, 0, NULL, NULL
+ RotateRectOval, /* rotateProc */
+ 0, NULL, NULL
};
Tk_ItemType tkOvalType = {
@@ -205,7 +208,8 @@ Tk_ItemType tkOvalType = {
NULL, /* insertProc */
NULL, /* dTextProc */
NULL, /* nextPtr */
- NULL, 0, NULL, NULL
+ RotateRectOval, /* rotateProc */
+ 0, NULL, NULL
};
/*
@@ -234,11 +238,11 @@ CreateRectOval(
Tk_Canvas canvas, /* Canvas to hold new item. */
Tk_Item *itemPtr, /* Record to hold new item; header has been
* initialized by caller. */
- int objc, /* Number of arguments in objv. */
+ Tcl_Size objc, /* Number of arguments in objv. */
Tcl_Obj *const objv[]) /* Arguments describing rectangle. */
{
RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr;
- int i;
+ Tcl_Size i;
if (objc == 0) {
Tcl_Panic("canvas did not pass any coords");
@@ -309,7 +313,7 @@ RectOvalCoords(
Tk_Canvas canvas, /* Canvas containing item. */
Tk_Item *itemPtr, /* Item whose coordinates are to be read or
* modified. */
- int objc, /* Number of coordinates supplied in objv. */
+ Tcl_Size objc, /* Number of coordinates supplied in objv. */
Tcl_Obj *const objv[]) /* Array of coordinates: x1,y1,x2,y2,... */
{
RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr;
@@ -346,7 +350,7 @@ RectOvalCoords(
if (objc != 4) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "wrong # coordinates: expected 0 or 4, got %d", objc));
+ "wrong # coordinates: expected 0 or 4, got %" TCL_SIZE_MODIFIER "d", objc));
Tcl_SetErrorCode(interp, "TK", "CANVAS", "COORDS",
(rectOvalPtr->header.typePtr == &tkRectangleType
? "RECTANGLE" : "OVAL"), NULL);
@@ -395,7 +399,7 @@ ConfigureRectOval(
Tcl_Interp *interp, /* Used for error reporting. */
Tk_Canvas canvas, /* Canvas containing itemPtr. */
Tk_Item *itemPtr, /* Rectangle item to reconfigure. */
- int objc, /* Number of elements in objv. */
+ Tcl_Size objc, /* Number of elements in objv. */
Tcl_Obj *const objv[], /* Arguments describing things to configure. */
int flags) /* Flags to pass to Tk_ConfigureWidget. */
{
@@ -570,7 +574,7 @@ ConfigureRectOval(
static void
DeleteRectOval(
- Tk_Canvas canvas, /* Info about overall widget. */
+ TCL_UNUSED(Tk_Canvas), /* Info about overall widget. */
Tk_Item *itemPtr, /* Item that is being deleted. */
Display *display) /* Display containing window for canvas. */
{
@@ -617,7 +621,6 @@ DeleteRectOval(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static void
ComputeRectOvalBbox(
Tk_Canvas canvas, /* Canvas that contains item. */
@@ -740,9 +743,10 @@ DisplayRectOval(
Tk_Item *itemPtr, /* Item to be displayed. */
Display *display, /* Display on which to draw item. */
Drawable drawable, /* Pixmap or window in which to draw item. */
- int x, int y, int width, int height)
- /* Describes region of canvas that must be
- * redisplayed (not used). */
+ TCL_UNUSED(int),/* Describes region of canvas that must be */
+ TCL_UNUSED(int),/* redisplayed (not used). */
+ TCL_UNUSED(int),
+ TCL_UNUSED(int))
{
RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr;
short x1, y1, x2, y2;
@@ -957,7 +961,6 @@ DisplayRectOval(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static double
RectToPoint(
Tk_Canvas canvas, /* Canvas containing item. */
@@ -1077,7 +1080,6 @@ RectToPoint(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static double
OvalToPoint(
Tk_Canvas canvas, /* Canvas containing item. */
@@ -1132,7 +1134,6 @@ OvalToPoint(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static int
RectToArea(
Tk_Canvas canvas, /* Canvas containing item. */
@@ -1206,7 +1207,6 @@ RectToArea(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static int
OvalToArea(
Tk_Canvas canvas, /* Canvas containing item. */
@@ -1286,6 +1286,57 @@ OvalToArea(
/*
*--------------------------------------------------------------
*
+ * RotateRectOval --
+ *
+ * This function is invoked to rotate a rectangle or oval item's
+ * coordinates. It works by rotating a computed point in the centre of
+ * the bounding box, NOT by rotating the corners of the bounding box.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * The position of the rectangle or oval is rotated by angleRad about
+ * (originX, originY), and the bounding box is updated in the generic
+ * part of the item structure.
+ *
+ *--------------------------------------------------------------
+ */
+
+static void
+RotateRectOval(
+ Tk_Canvas canvas, /* Canvas containing rectangle. */
+ Tk_Item *itemPtr, /* Rectangle to be scaled. */
+ double originX, double originY,
+ /* Origin about which to rotate rect. */
+ double angleRad) /* Amount to scale in X direction. */
+{
+ RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr;
+ double newX, newY, oldX, oldY;
+
+ /*
+ * Compute the centre of the box, then rotate that about the origin.
+ */
+
+ newX = oldX = (rectOvalPtr->bbox[0] + rectOvalPtr->bbox[2]) / 2.0;
+ newY = oldY = (rectOvalPtr->bbox[1] + rectOvalPtr->bbox[3]) / 2.0;
+ TkRotatePoint(originX, originY, sin(angleRad), cos(angleRad),
+ &newX, &newY);
+
+ /*
+ * Apply the translation to the box.
+ */
+
+ rectOvalPtr->bbox[0] += newX - oldX;
+ rectOvalPtr->bbox[1] += newY - oldY;
+ rectOvalPtr->bbox[2] += newX - oldX;
+ rectOvalPtr->bbox[3] += newY - oldY;
+ ComputeRectOvalBbox(canvas, rectOvalPtr);
+}
+
+/*
+ *--------------------------------------------------------------
+ *
* ScaleRectOval --
*
* This function is invoked to rescale a rectangle or oval item.
@@ -1379,7 +1430,7 @@ RectOvalToPostscript(
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
+ TCL_UNUSED(int)) /* 1 means this is a prepass to collect font
* information; 0 means final Postscript is
* being created. */
{
@@ -1465,24 +1516,20 @@ RectOvalToPostscript(
Tcl_AppendObjToObj(psObj, pathObj);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsColor(interp, canvas, fillColor) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsColor(interp, canvas, fillColor);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (fillStipple != None) {
- Tcl_AppendToObj(psObj, "clip ", -1);
+ Tcl_AppendToObj(psObj, "clip ", TCL_INDEX_NONE);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsStipple(interp, canvas, fillStipple) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsStipple(interp, canvas, fillStipple);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (color != NULL) {
- Tcl_AppendToObj(psObj, "grestore gsave\n", -1);
+ Tcl_AppendToObj(psObj, "grestore gsave\n", TCL_INDEX_NONE);
}
} else {
- Tcl_AppendToObj(psObj, "fill\n", -1);
+ Tcl_AppendToObj(psObj, "fill\n", TCL_INDEX_NONE);
}
}
@@ -1492,13 +1539,10 @@ RectOvalToPostscript(
if (color != NULL) {
Tcl_AppendObjToObj(psObj, pathObj);
- Tcl_AppendToObj(psObj, "0 setlinejoin 2 setlinecap\n", -1);
+ Tcl_AppendToObj(psObj, "0 setlinejoin 2 setlinecap\n", TCL_INDEX_NONE);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsOutline(canvas, itemPtr,
- &rectOvalPtr->outline)!= TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsOutline(canvas, itemPtr, &rectOvalPtr->outline);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
}
@@ -1511,12 +1555,6 @@ RectOvalToPostscript(
Tcl_DecrRefCount(psObj);
Tcl_DecrRefCount(pathObj);
return TCL_OK;
-
- error:
- Tcl_DiscardInterpState(interpState);
- Tcl_DecrRefCount(psObj);
- Tcl_DecrRefCount(pathObj);
- return TCL_ERROR;
}
/*
diff --git a/generic/tkScale.c b/generic/tkScale.c
index d8d0915..eeda9cd 100644
--- a/generic/tkScale.c
+++ b/generic/tkScale.c
@@ -9,17 +9,17 @@
* 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-1997 Sun Microsystems, Inc.
- * Copyright (c) 1998-2000 Scriptics Corporation.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1998-2000 Scriptics Corporation.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
-#include "default.h"
#include "tkInt.h"
#include "tkScale.h"
+#include "default.h"
#ifdef _WIN32
#include "tkWinInt.h"
@@ -36,97 +36,97 @@ static const char *const orientStrings[] = {
static const Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_BORDER, "-activebackground", "activeBackground", "Foreground",
- DEF_SCALE_ACTIVE_BG_COLOR, -1, Tk_Offset(TkScale, activeBorder),
+ DEF_SCALE_ACTIVE_BG_COLOR, TCL_INDEX_NONE, offsetof(TkScale, activeBorder),
0, DEF_SCALE_ACTIVE_BG_MONO, 0},
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_SCALE_BG_COLOR, -1, Tk_Offset(TkScale, bgBorder),
+ DEF_SCALE_BG_COLOR, TCL_INDEX_NONE, offsetof(TkScale, bgBorder),
0, DEF_SCALE_BG_MONO, 0},
{TK_OPTION_DOUBLE, "-bigincrement", "bigIncrement", "BigIncrement",
- DEF_SCALE_BIG_INCREMENT, -1, Tk_Offset(TkScale, bigIncrement),
+ DEF_SCALE_BIG_INCREMENT, TCL_INDEX_NONE, offsetof(TkScale, bigIncrement),
0, 0, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL,
- NULL, 0, -1, 0, "-background", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_SCALE_BORDER_WIDTH, -1, Tk_Offset(TkScale, borderWidth),
+ DEF_SCALE_BORDER_WIDTH, TCL_INDEX_NONE, offsetof(TkScale, borderWidth),
0, 0, 0},
{TK_OPTION_STRING, "-command", "command", "Command",
- DEF_SCALE_COMMAND, -1, Tk_Offset(TkScale, command),
+ DEF_SCALE_COMMAND, TCL_INDEX_NONE, offsetof(TkScale, command),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_SCALE_CURSOR, -1, Tk_Offset(TkScale, cursor),
+ DEF_SCALE_CURSOR, TCL_INDEX_NONE, offsetof(TkScale, cursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_INT, "-digits", "digits", "Digits",
- DEF_SCALE_DIGITS, -1, Tk_Offset(TkScale, digits),
+ DEF_SCALE_DIGITS, TCL_INDEX_NONE, offsetof(TkScale, digits),
0, 0, 0},
{TK_OPTION_SYNONYM, "-fg", "foreground", NULL,
- NULL, 0, -1, 0, "-foreground", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_SCALE_FONT, -1, Tk_Offset(TkScale, tkfont), 0, 0, 0},
+ DEF_SCALE_FONT, TCL_INDEX_NONE, offsetof(TkScale, tkfont), 0, 0, 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_SCALE_FG_COLOR, -1, Tk_Offset(TkScale, textColorPtr), 0,
- (ClientData) DEF_SCALE_FG_MONO, 0},
- {TK_OPTION_DOUBLE, "-from", "from", "From", DEF_SCALE_FROM, -1,
- Tk_Offset(TkScale, fromValue), 0, 0, 0},
+ DEF_SCALE_FG_COLOR, TCL_INDEX_NONE, offsetof(TkScale, textColorPtr), 0,
+ DEF_SCALE_FG_MONO, 0},
+ {TK_OPTION_DOUBLE, "-from", "from", "From", DEF_SCALE_FROM, TCL_INDEX_NONE,
+ offsetof(TkScale, fromValue), 0, 0, 0},
{TK_OPTION_BORDER, "-highlightbackground", "highlightBackground",
"HighlightBackground", DEF_SCALE_HIGHLIGHT_BG_COLOR,
- -1, Tk_Offset(TkScale, highlightBorder),
+ TCL_INDEX_NONE, offsetof(TkScale, highlightBorder),
0, DEF_SCALE_HIGHLIGHT_BG_MONO, 0},
{TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_SCALE_HIGHLIGHT, -1, Tk_Offset(TkScale, highlightColorPtr),
+ DEF_SCALE_HIGHLIGHT, TCL_INDEX_NONE, offsetof(TkScale, highlightColorPtr),
0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
- "HighlightThickness", DEF_SCALE_HIGHLIGHT_WIDTH, -1,
- Tk_Offset(TkScale, highlightWidth), 0, 0, 0},
+ "HighlightThickness", DEF_SCALE_HIGHLIGHT_WIDTH, TCL_INDEX_NONE,
+ offsetof(TkScale, highlightWidth), 0, 0, 0},
{TK_OPTION_STRING, "-label", "label", "Label",
- DEF_SCALE_LABEL, -1, Tk_Offset(TkScale, label),
+ DEF_SCALE_LABEL, TCL_INDEX_NONE, offsetof(TkScale, label),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-length", "length", "Length",
- DEF_SCALE_LENGTH, -1, Tk_Offset(TkScale, length), 0, 0, 0},
+ DEF_SCALE_LENGTH, TCL_INDEX_NONE, offsetof(TkScale, length), 0, 0, 0},
{TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient",
- DEF_SCALE_ORIENT, -1, Tk_Offset(TkScale, orient),
+ DEF_SCALE_ORIENT, TCL_INDEX_NONE, offsetof(TkScale, orient),
TK_OPTION_ENUM_VAR, orientStrings, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_SCALE_RELIEF, -1, Tk_Offset(TkScale, relief), 0, 0, 0},
+ DEF_SCALE_RELIEF, TCL_INDEX_NONE, offsetof(TkScale, relief), 0, 0, 0},
{TK_OPTION_INT, "-repeatdelay", "repeatDelay", "RepeatDelay",
- DEF_SCALE_REPEAT_DELAY, -1, Tk_Offset(TkScale, repeatDelay),
+ DEF_SCALE_REPEAT_DELAY, TCL_INDEX_NONE, offsetof(TkScale, repeatDelay),
0, 0, 0},
{TK_OPTION_INT, "-repeatinterval", "repeatInterval", "RepeatInterval",
- DEF_SCALE_REPEAT_INTERVAL, -1, Tk_Offset(TkScale, repeatInterval),
+ DEF_SCALE_REPEAT_INTERVAL, TCL_INDEX_NONE, offsetof(TkScale, repeatInterval),
0, 0, 0},
{TK_OPTION_DOUBLE, "-resolution", "resolution", "Resolution",
- DEF_SCALE_RESOLUTION, -1, Tk_Offset(TkScale, resolution),
+ DEF_SCALE_RESOLUTION, TCL_INDEX_NONE, offsetof(TkScale, resolution),
0, 0, 0},
{TK_OPTION_BOOLEAN, "-showvalue", "showValue", "ShowValue",
- DEF_SCALE_SHOW_VALUE, -1, Tk_Offset(TkScale, showValue),
+ DEF_SCALE_SHOW_VALUE, TCL_INDEX_NONE, offsetof(TkScale, showValue),
0, 0, 0},
{TK_OPTION_PIXELS, "-sliderlength", "sliderLength", "SliderLength",
- DEF_SCALE_SLIDER_LENGTH, -1, Tk_Offset(TkScale, sliderLength),
+ DEF_SCALE_SLIDER_LENGTH, TCL_INDEX_NONE, offsetof(TkScale, sliderLength),
0, 0, 0},
{TK_OPTION_RELIEF, "-sliderrelief", "sliderRelief", "SliderRelief",
- DEF_SCALE_SLIDER_RELIEF, -1, Tk_Offset(TkScale, sliderRelief),
+ DEF_SCALE_SLIDER_RELIEF, TCL_INDEX_NONE, offsetof(TkScale, sliderRelief),
0, 0, 0},
{TK_OPTION_STRING_TABLE, "-state", "state", "State",
- DEF_SCALE_STATE, -1, Tk_Offset(TkScale, state),
+ DEF_SCALE_STATE, TCL_INDEX_NONE, offsetof(TkScale, state),
TK_OPTION_ENUM_VAR, tkStateStrings, 0},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_SCALE_TAKE_FOCUS, Tk_Offset(TkScale, takeFocusPtr), -1,
+ DEF_SCALE_TAKE_FOCUS, offsetof(TkScale, takeFocusPtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_DOUBLE, "-tickinterval", "tickInterval", "TickInterval",
- DEF_SCALE_TICK_INTERVAL, -1, Tk_Offset(TkScale, tickInterval),
+ DEF_SCALE_TICK_INTERVAL, TCL_INDEX_NONE, offsetof(TkScale, tickInterval),
0, 0, 0},
{TK_OPTION_DOUBLE, "-to", "to", "To",
- DEF_SCALE_TO, -1, Tk_Offset(TkScale, toValue), 0, 0, 0},
+ DEF_SCALE_TO, TCL_INDEX_NONE, offsetof(TkScale, toValue), 0, 0, 0},
{TK_OPTION_COLOR, "-troughcolor", "troughColor", "Background",
- DEF_SCALE_TROUGH_COLOR, -1, Tk_Offset(TkScale, troughColorPtr),
+ DEF_SCALE_TROUGH_COLOR, TCL_INDEX_NONE, offsetof(TkScale, troughColorPtr),
0, DEF_SCALE_TROUGH_MONO, 0},
{TK_OPTION_STRING, "-variable", "variable", "Variable",
- DEF_SCALE_VARIABLE, Tk_Offset(TkScale, varNamePtr), -1,
+ DEF_SCALE_VARIABLE, offsetof(TkScale, varNamePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-width", "width", "Width",
- DEF_SCALE_WIDTH, -1, Tk_Offset(TkScale, width), 0, 0, 0},
- {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0}
+ DEF_SCALE_WIDTH, TCL_INDEX_NONE, offsetof(TkScale, width), 0, 0, 0},
+ {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0}
};
/*
@@ -152,19 +152,17 @@ static void ComputeFormat(TkScale *scalePtr, int forTicks);
static void ComputeScaleGeometry(TkScale *scalePtr);
static int ConfigureScale(Tcl_Interp *interp, TkScale *scalePtr,
int objc, Tcl_Obj *const objv[]);
-static void DestroyScale(char *memPtr);
+static void DestroyScale(void *memPtr);
static double MaxTickRoundingError(TkScale *scalePtr,
double tickResolution);
-static void ScaleCmdDeletedProc(ClientData clientData);
-static void ScaleEventProc(ClientData clientData,
+static void ScaleCmdDeletedProc(void *clientData);
+static void ScaleEventProc(void *clientData,
XEvent *eventPtr);
-static char * ScaleVarProc(ClientData clientData,
+static char * ScaleVarProc(void *clientData,
Tcl_Interp *interp, const char *name1,
const char *name2, int flags);
-static int ScaleWidgetObjCmd(ClientData clientData,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-static void ScaleWorldChanged(ClientData instanceData);
+static Tcl_ObjCmdProc ScaleWidgetObjCmd;
+static void ScaleWorldChanged(void *instanceData);
static void ScaleSetVariable(TkScale *scalePtr);
/*
@@ -239,7 +237,7 @@ ScaleRound(
int
Tk_ScaleObjCmd(
- ClientData clientData, /* NULL. */
+ TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument values. */
@@ -334,7 +332,7 @@ Tk_ScaleObjCmd(
ExposureMask|StructureNotifyMask|FocusChangeMask,
ScaleEventProc, scalePtr);
- if ((Tk_InitOptions(interp, (char *) scalePtr, optionTable, tkwin)
+ if ((Tk_InitOptions(interp, scalePtr, optionTable, tkwin)
!= TCL_OK) ||
(ConfigureScale(interp, scalePtr, objc - 2, objv + 2) != TCL_OK)) {
Tk_DestroyWindow(scalePtr->tkwin);
@@ -347,7 +345,7 @@ Tk_ScaleObjCmd(
scalePtr->flags &= ~INVOKE_COMMAND;
- Tcl_SetObjResult(interp, TkNewWindowObj(scalePtr->tkwin));
+ Tcl_SetObjResult(interp, Tk_NewWindowObj(scalePtr->tkwin));
return TCL_OK;
}
@@ -371,12 +369,12 @@ Tk_ScaleObjCmd(
static int
ScaleWidgetObjCmd(
- ClientData clientData, /* Information about scale widget. */
+ void *clientData, /* Information about scale widget. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
{
- TkScale *scalePtr = clientData;
+ TkScale *scalePtr = (TkScale *)clientData;
Tcl_Obj *objPtr;
int index, result;
@@ -397,7 +395,7 @@ ScaleWidgetObjCmd(
Tcl_WrongNumArgs(interp, 1, objv, "cget option");
goto error;
}
- objPtr = Tk_GetOptionValue(interp, (char *) scalePtr,
+ objPtr = Tk_GetOptionValue(interp, scalePtr,
scalePtr->optionTable, objv[2], scalePtr->tkwin);
if (objPtr == NULL) {
goto error;
@@ -406,7 +404,7 @@ ScaleWidgetObjCmd(
break;
case COMMAND_CONFIGURE:
if (objc <= 3) {
- objPtr = Tk_GetOptionInfo(interp, (char *) scalePtr,
+ objPtr = Tk_GetOptionInfo(interp, scalePtr,
scalePtr->optionTable,
(objc == 3) ? objv[2] : NULL, scalePtr->tkwin);
if (objPtr == NULL) {
@@ -442,8 +440,8 @@ ScaleWidgetObjCmd(
y = scalePtr->horizTroughY + scalePtr->width/2
+ scalePtr->borderWidth;
}
- coords[0] = Tcl_NewIntObj(x);
- coords[1] = Tcl_NewIntObj(y);
+ coords[0] = Tcl_NewWideIntObj(x);
+ coords[1] = Tcl_NewWideIntObj(y);
Tcl_SetObjResult(interp, Tcl_NewListObj(2, coords));
break;
}
@@ -484,7 +482,7 @@ ScaleWidgetObjCmd(
case SLIDER: zone = "slider"; break;
case TROUGH2: zone = "trough2"; break;
}
- Tcl_SetObjResult(interp, Tcl_NewStringObj(zone, -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(zone, TCL_INDEX_NONE));
break;
}
case COMMAND_SET: {
@@ -531,7 +529,7 @@ ScaleWidgetObjCmd(
static void
DestroyScale(
- char *memPtr) /* Info about scale widget. */
+ void *memPtr) /* Info about scale widget. */
{
TkScale *scalePtr = (TkScale *) memPtr;
@@ -561,7 +559,7 @@ DestroyScale(
if (scalePtr->textGC != NULL) {
Tk_FreeGC(scalePtr->display, scalePtr->textGC);
}
- Tk_FreeConfigOptions((char *) scalePtr, scalePtr->optionTable,
+ Tk_FreeConfigOptions(scalePtr, scalePtr->optionTable,
scalePtr->tkwin);
scalePtr->tkwin = NULL;
TkpDestroyScale(scalePtr);
@@ -616,7 +614,7 @@ ConfigureScale(
* First pass: set options to new values.
*/
- if (Tk_SetOptions(interp, (char *) scalePtr,
+ if (Tk_SetOptions(interp, scalePtr,
scalePtr->optionTable, objc, objv, scalePtr->tkwin,
&savedOptions, NULL) != TCL_OK) {
continue;
@@ -671,7 +669,7 @@ ConfigureScale(
ComputeFormat(scalePtr, 0);
ComputeFormat(scalePtr, 1);
- scalePtr->labelLength = scalePtr->label ? (int)strlen(scalePtr->label) : 0;
+ scalePtr->labelLength = scalePtr->label ? strlen(scalePtr->label) : 0;
Tk_SetBackgroundFromBorder(scalePtr->tkwin, scalePtr->bgBorder);
@@ -754,11 +752,11 @@ ConfigureScale(
static void
ScaleWorldChanged(
- ClientData instanceData) /* Information about widget. */
+ void *instanceData) /* Information about widget. */
{
XGCValues gcValues;
GC gc;
- TkScale *scalePtr = instanceData;
+ TkScale *scalePtr = (TkScale *)instanceData;
gcValues.foreground = scalePtr->troughColorPtr->pixel;
gc = Tk_GetGC(scalePtr->tkwin, GCForeground, &gcValues);
@@ -1149,10 +1147,10 @@ ComputeScaleGeometry(
static void
ScaleEventProc(
- ClientData clientData, /* Information about window. */
+ void *clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
- TkScale *scalePtr = clientData;
+ TkScale *scalePtr = (TkScale *)clientData;
if ((eventPtr->type == Expose) && (eventPtr->xexpose.count == 0)) {
TkEventuallyRedrawScale(scalePtr, REDRAW_ALL);
@@ -1198,9 +1196,9 @@ ScaleEventProc(
static void
ScaleCmdDeletedProc(
- ClientData clientData) /* Pointer to widget record for widget. */
+ void *clientData) /* Pointer to widget record for widget. */
{
- TkScale *scalePtr = clientData;
+ TkScale *scalePtr = (TkScale *)clientData;
Tk_Window tkwin = scalePtr->tkwin;
/*
@@ -1326,16 +1324,15 @@ TkRoundIntervalToResolution(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
static char *
ScaleVarProc(
- ClientData clientData, /* Information about button. */
+ void *clientData, /* Information about button. */
Tcl_Interp *interp, /* Interpreter containing variable. */
- const char *name1, /* Name of variable. */
- const char *name2, /* Second part of variable name. */
+ TCL_UNUSED(const char *), /* Name of variable. */
+ TCL_UNUSED(const char *), /* Second part of variable name. */
int flags) /* Information about what happened. */
{
- TkScale *scalePtr = clientData;
+ TkScale *scalePtr = (TkScale *)clientData;
const char *resultStr;
double value;
Tcl_Obj *valuePtr;
@@ -1348,14 +1345,14 @@ ScaleVarProc(
if (flags & TCL_TRACE_UNSETS) {
if (!Tcl_InterpDeleted(interp) && scalePtr->varNamePtr) {
- ClientData probe = NULL;
+ void *probe = NULL;
do {
probe = Tcl_VarTraceInfo(interp,
Tcl_GetString(scalePtr->varNamePtr),
TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
ScaleVarProc, probe);
- if (probe == (ClientData)scalePtr) {
+ if (probe == (void *)scalePtr) {
break;
}
} while (probe);
@@ -1499,7 +1496,7 @@ ScaleSetVariable(
}
scalePtr->flags |= SETTING_VAR;
Tcl_ObjSetVar2(scalePtr->interp, scalePtr->varNamePtr, NULL,
- Tcl_NewStringObj(string, -1), TCL_GLOBAL_ONLY);
+ Tcl_NewStringObj(string, TCL_INDEX_NONE), TCL_GLOBAL_ONLY);
scalePtr->flags &= ~SETTING_VAR;
}
}
diff --git a/generic/tkScale.h b/generic/tkScale.h
index 94839c3..7ecf1a1 100644
--- a/generic/tkScale.h
+++ b/generic/tkScale.h
@@ -4,8 +4,8 @@
* Declarations of types and functions used to implement the scale
* widget.
*
- * Copyright (c) 1996 Sun Microsystems, Inc.
- * Copyright (c) 1999-2000 Scriptics Corporation.
+ * Copyright © 1996 Sun Microsystems, Inc.
+ * Copyright © 1999-2000 Scriptics Corporation.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -87,7 +87,7 @@ typedef struct TkScale {
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. */
- int labelLength; /* Number of non-NULL chars. in label. */
+ Tcl_Size labelLength; /* Number of non-NULL chars. in label. */
enum state state; /* Values are active, normal, or disabled.
* Value of scale cannot be changed when
* disabled. */
@@ -233,7 +233,7 @@ MODULE_SCOPE double TkRoundValueToResolution(TkScale *scalePtr, double value);
MODULE_SCOPE double TkRoundIntervalToResolution(TkScale *scalePtr, double value);
MODULE_SCOPE TkScale * TkpCreateScale(Tk_Window tkwin);
MODULE_SCOPE void TkpDestroyScale(TkScale *scalePtr);
-MODULE_SCOPE void TkpDisplayScale(ClientData clientData);
+MODULE_SCOPE void TkpDisplayScale(void *clientData);
MODULE_SCOPE int TkpScaleElement(TkScale *scalePtr, int x, int y);
MODULE_SCOPE void TkScaleSetValue(TkScale *scalePtr, double value,
int setVar, int invokeCommand);
diff --git a/generic/tkScrollbar.c b/generic/tkScrollbar.c
index 8c80846..ec94418 100644
--- a/generic/tkScrollbar.c
+++ b/generic/tkScrollbar.c
@@ -5,8 +5,8 @@
* 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.
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 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.
@@ -33,62 +33,62 @@ char tkDefScrollbarWidth[TCL_INTEGER_SPACE] = DEF_SCROLLBAR_WIDTH;
static const Tk_ConfigSpec configSpecs[] = {
{TK_CONFIG_BORDER, "-activebackground", "activeBackground", "Foreground",
- DEF_SCROLLBAR_ACTIVE_BG_COLOR, Tk_Offset(TkScrollbar, activeBorder),
+ DEF_SCROLLBAR_ACTIVE_BG_COLOR, offsetof(TkScrollbar, activeBorder),
TK_CONFIG_COLOR_ONLY, NULL},
{TK_CONFIG_BORDER, "-activebackground", "activeBackground", "Foreground",
- DEF_SCROLLBAR_ACTIVE_BG_MONO, Tk_Offset(TkScrollbar, activeBorder),
+ DEF_SCROLLBAR_ACTIVE_BG_MONO, offsetof(TkScrollbar, activeBorder),
TK_CONFIG_MONO_ONLY, NULL},
{TK_CONFIG_RELIEF, "-activerelief", "activeRelief", "Relief",
- DEF_SCROLLBAR_ACTIVE_RELIEF, Tk_Offset(TkScrollbar, activeRelief), 0, NULL},
+ DEF_SCROLLBAR_ACTIVE_RELIEF, offsetof(TkScrollbar, activeRelief), 0, NULL},
{TK_CONFIG_BORDER, "-background", "background", "Background",
- DEF_SCROLLBAR_BG_COLOR, Tk_Offset(TkScrollbar, bgBorder),
+ DEF_SCROLLBAR_BG_COLOR, offsetof(TkScrollbar, bgBorder),
TK_CONFIG_COLOR_ONLY, NULL},
{TK_CONFIG_BORDER, "-background", "background", "Background",
- DEF_SCROLLBAR_BG_MONO, Tk_Offset(TkScrollbar, bgBorder),
+ DEF_SCROLLBAR_BG_MONO, offsetof(TkScrollbar, bgBorder),
TK_CONFIG_MONO_ONLY, NULL},
{TK_CONFIG_SYNONYM, "-bd", "borderWidth", NULL, NULL, 0, 0, NULL},
{TK_CONFIG_SYNONYM, "-bg", "background", NULL, NULL, 0, 0, NULL},
{TK_CONFIG_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_SCROLLBAR_BORDER_WIDTH, Tk_Offset(TkScrollbar, borderWidth), 0, NULL},
+ DEF_SCROLLBAR_BORDER_WIDTH, offsetof(TkScrollbar, borderWidth), 0, NULL},
{TK_CONFIG_STRING, "-command", "command", "Command",
- DEF_SCROLLBAR_COMMAND, Tk_Offset(TkScrollbar, command),
+ DEF_SCROLLBAR_COMMAND, offsetof(TkScrollbar, command),
TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_ACTIVE_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_SCROLLBAR_CURSOR, Tk_Offset(TkScrollbar, cursor), TK_CONFIG_NULL_OK, NULL},
+ DEF_SCROLLBAR_CURSOR, offsetof(TkScrollbar, cursor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_PIXELS, "-elementborderwidth", "elementBorderWidth",
"BorderWidth", DEF_SCROLLBAR_EL_BORDER_WIDTH,
- Tk_Offset(TkScrollbar, elementBorderWidth), 0, NULL},
+ offsetof(TkScrollbar, elementBorderWidth), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_COLOR, "-highlightbackground", "highlightBackground",
"HighlightBackground", DEF_SCROLLBAR_HIGHLIGHT_BG,
- Tk_Offset(TkScrollbar, highlightBgColorPtr), 0, NULL},
+ offsetof(TkScrollbar, highlightBgColorPtr), 0, NULL},
{TK_CONFIG_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
DEF_SCROLLBAR_HIGHLIGHT,
- Tk_Offset(TkScrollbar, highlightColorPtr), 0, NULL},
+ offsetof(TkScrollbar, highlightColorPtr), 0, NULL},
{TK_CONFIG_PIXELS, "-highlightthickness", "highlightThickness",
"HighlightThickness",
- DEF_SCROLLBAR_HIGHLIGHT_WIDTH, Tk_Offset(TkScrollbar, highlightWidth), 0, NULL},
+ DEF_SCROLLBAR_HIGHLIGHT_WIDTH, offsetof(TkScrollbar, highlightWidth), 0, NULL},
{TK_CONFIG_BOOLEAN, "-jump", "jump", "Jump",
- DEF_SCROLLBAR_JUMP, Tk_Offset(TkScrollbar, jump), 0, NULL},
+ DEF_SCROLLBAR_JUMP, offsetof(TkScrollbar, jump), 0, NULL},
{TK_CONFIG_CUSTOM, "-orient", "orient", "Orient",
- DEF_SCROLLBAR_ORIENT, Tk_Offset(TkScrollbar, vertical), 0,
+ DEF_SCROLLBAR_ORIENT, offsetof(TkScrollbar, vertical), 0,
&orientOption},
{TK_CONFIG_RELIEF, "-relief", "relief", "Relief",
- DEF_SCROLLBAR_RELIEF, Tk_Offset(TkScrollbar, relief), 0, NULL},
+ DEF_SCROLLBAR_RELIEF, offsetof(TkScrollbar, relief), 0, NULL},
{TK_CONFIG_INT, "-repeatdelay", "repeatDelay", "RepeatDelay",
- DEF_SCROLLBAR_REPEAT_DELAY, Tk_Offset(TkScrollbar, repeatDelay), 0, NULL},
+ DEF_SCROLLBAR_REPEAT_DELAY, offsetof(TkScrollbar, repeatDelay), 0, NULL},
{TK_CONFIG_INT, "-repeatinterval", "repeatInterval", "RepeatInterval",
- DEF_SCROLLBAR_REPEAT_INTERVAL, Tk_Offset(TkScrollbar, repeatInterval), 0, NULL},
+ DEF_SCROLLBAR_REPEAT_INTERVAL, offsetof(TkScrollbar, repeatInterval), 0, NULL},
{TK_CONFIG_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_SCROLLBAR_TAKE_FOCUS, Tk_Offset(TkScrollbar, takeFocus),
+ DEF_SCROLLBAR_TAKE_FOCUS, offsetof(TkScrollbar, takeFocus),
TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_COLOR, "-troughcolor", "troughColor", "Background",
- DEF_SCROLLBAR_TROUGH_COLOR, Tk_Offset(TkScrollbar, troughColorPtr),
+ DEF_SCROLLBAR_TROUGH_COLOR, offsetof(TkScrollbar, troughColorPtr),
TK_CONFIG_COLOR_ONLY, NULL},
{TK_CONFIG_COLOR, "-troughcolor", "troughColor", "Background",
- DEF_SCROLLBAR_TROUGH_MONO, Tk_Offset(TkScrollbar, troughColorPtr),
+ DEF_SCROLLBAR_TROUGH_MONO, offsetof(TkScrollbar, troughColorPtr),
TK_CONFIG_MONO_ONLY, NULL},
{TK_CONFIG_PIXELS, "-width", "width", "Width",
- tkDefScrollbarWidth, Tk_Offset(TkScrollbar, width), 0, NULL},
+ tkDefScrollbarWidth, offsetof(TkScrollbar, width), 0, NULL},
{TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}
};
@@ -97,11 +97,10 @@ static const Tk_ConfigSpec configSpecs[] = {
*/
static int ConfigureScrollbar(Tcl_Interp *interp,
- TkScrollbar *scrollPtr, int objc,
+ TkScrollbar *scrollPtr, Tcl_Size objc,
Tcl_Obj *const objv[], int flags);
-static void ScrollbarCmdDeletedProc(ClientData clientData);
-static int ScrollbarWidgetObjCmd(ClientData clientData,
- Tcl_Interp *, int objc, Tcl_Obj *const objv[]);
+static void ScrollbarCmdDeletedProc(void *clientData);
+static Tcl_ObjCmdProc ScrollbarWidgetObjCmd;
/*
*--------------------------------------------------------------
@@ -122,7 +121,7 @@ static int ScrollbarWidgetObjCmd(ClientData clientData,
int
Tk_ScrollbarObjCmd(
- ClientData clientData, /* Main window associated with interpreter. */
+ void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
@@ -179,10 +178,12 @@ Tk_ScrollbarObjCmd(
scrollPtr->sliderLast = 0;
scrollPtr->activeField = 0;
scrollPtr->activeRelief = TK_RELIEF_RAISED;
+#ifndef TK_NO_DEPRECATED
scrollPtr->totalUnits = 0;
scrollPtr->windowUnits = 0;
scrollPtr->firstUnit = 0;
scrollPtr->lastUnit = 0;
+#endif /* TK_NO_DEPRECATED */
scrollPtr->firstFraction = 0.0;
scrollPtr->lastFraction = 0.0;
scrollPtr->cursor = NULL;
@@ -194,7 +195,7 @@ Tk_ScrollbarObjCmd(
return TCL_ERROR;
}
- Tcl_SetObjResult(interp, TkNewWindowObj(scrollPtr->tkwin));
+ Tcl_SetObjResult(interp, Tk_NewWindowObj(scrollPtr->tkwin));
return TCL_OK;
}
@@ -218,14 +219,14 @@ Tk_ScrollbarObjCmd(
static int
ScrollbarWidgetObjCmd(
- ClientData clientData, /* Information about scrollbar widget. */
+ void *clientData, /* Information about scrollbar widget. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
{
TkScrollbar *scrollPtr = (TkScrollbar *)clientData;
- int result = TCL_OK;
- int length, cmdIndex;
+ int result = TCL_OK, cmdIndex, length;
+ Tcl_Size len;
static const char *const commandNames[] = {
"activate", "cget", "configure", "delta", "fraction",
"get", "identify", "set", NULL
@@ -262,20 +263,20 @@ ScrollbarWidgetObjCmd(
case SLIDER: zone = "slider"; break;
case BOTTOM_ARROW: zone = "arrow2"; break;
}
- Tcl_SetObjResult(interp, Tcl_NewStringObj(zone, -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(zone, TCL_INDEX_NONE));
goto done;
}
if (objc != 3) {
Tcl_WrongNumArgs(interp, 1, objv, "activate element");
goto error;
}
- c = Tcl_GetStringFromObj(objv[2], &length)[0];
+ c = Tcl_GetStringFromObj(objv[2], &len)[0];
oldActiveField = scrollPtr->activeField;
if ((c == 'a') && (strcmp(Tcl_GetString(objv[2]), "arrow1") == 0)) {
scrollPtr->activeField = TOP_ARROW;
} else if ((c == 'a') && (strcmp(Tcl_GetString(objv[2]), "arrow2") == 0)) {
scrollPtr->activeField = BOTTOM_ARROW;
- } else if ((c == 's') && (strncmp(Tcl_GetString(objv[2]), "slider", length) == 0)) {
+ } else if ((c == 's') && (strncmp(Tcl_GetString(objv[2]), "slider", len) == 0)) {
scrollPtr->activeField = SLIDER;
} else {
scrollPtr->activeField = OUTSIDE;
@@ -291,16 +292,16 @@ ScrollbarWidgetObjCmd(
goto error;
}
result = Tk_ConfigureValue(interp, scrollPtr->tkwin,
- configSpecs, (char *) scrollPtr, Tcl_GetString(objv[2]), 0);
+ configSpecs, scrollPtr, Tcl_GetString(objv[2]), 0);
break;
}
case COMMAND_CONFIGURE: {
if (objc == 2) {
result = Tk_ConfigureInfo(interp, scrollPtr->tkwin,
- configSpecs, (char *) scrollPtr, NULL, 0);
+ configSpecs, scrollPtr, NULL, 0);
} else if (objc == 3) {
result = Tk_ConfigureInfo(interp, scrollPtr->tkwin,
- configSpecs, (char *) scrollPtr, Tcl_GetString(objv[2]), 0);
+ configSpecs, scrollPtr, Tcl_GetString(objv[2]), 0);
} else {
result = ConfigureScrollbar(interp, scrollPtr, objc-2,
objv+2, TK_CONFIG_ARGV_ONLY);
@@ -377,17 +378,19 @@ ScrollbarWidgetObjCmd(
Tcl_WrongNumArgs(interp, 1, objv, "get");
goto error;
}
- if (scrollPtr->flags & NEW_STYLE_COMMANDS) {
- resObjs[0] = Tcl_NewDoubleObj(scrollPtr->firstFraction);
- resObjs[1] = Tcl_NewDoubleObj(scrollPtr->lastFraction);
- Tcl_SetObjResult(interp, Tcl_NewListObj(2, resObjs));
- } else {
- resObjs[0] = Tcl_NewIntObj(scrollPtr->totalUnits);
- resObjs[1] = Tcl_NewIntObj(scrollPtr->windowUnits);
- resObjs[2] = Tcl_NewIntObj(scrollPtr->firstUnit);
- resObjs[3] = Tcl_NewIntObj(scrollPtr->lastUnit);
+#ifndef TK_NO_DEPRECATED
+ if (scrollPtr->flags & OLD_STYLE_COMMANDS) {
+ resObjs[0] = Tcl_NewWideIntObj(scrollPtr->totalUnits);
+ resObjs[1] = Tcl_NewWideIntObj(scrollPtr->windowUnits);
+ resObjs[2] = Tcl_NewWideIntObj(scrollPtr->firstUnit);
+ resObjs[3] = Tcl_NewWideIntObj(scrollPtr->lastUnit);
Tcl_SetObjResult(interp, Tcl_NewListObj(4, resObjs));
+ break;
}
+#endif /* TK_NO_DEPRECATED */
+ resObjs[0] = Tcl_NewDoubleObj(scrollPtr->firstFraction);
+ resObjs[1] = Tcl_NewDoubleObj(scrollPtr->lastFraction);
+ Tcl_SetObjResult(interp, Tcl_NewListObj(2, resObjs));
break;
}
case COMMAND_IDENTIFY: {
@@ -409,12 +412,10 @@ ScrollbarWidgetObjCmd(
case BOTTOM_GAP: zone = "trough2"; break;
case BOTTOM_ARROW: zone = "arrow2"; break;
}
- Tcl_SetObjResult(interp, Tcl_NewStringObj(zone, -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(zone, TCL_INDEX_NONE));
break;
}
case COMMAND_SET: {
- int totalUnits, windowUnits, firstUnit, lastUnit;
-
if (objc == 4) {
double first, last;
@@ -438,8 +439,10 @@ ScrollbarWidgetObjCmd(
} else {
scrollPtr->lastFraction = last;
}
- scrollPtr->flags |= NEW_STYLE_COMMANDS;
+#ifndef TK_NO_DEPRECATED
+ scrollPtr->flags &= ~OLD_STYLE_COMMANDS;
} else if (objc == 6) {
+ int totalUnits, windowUnits, firstUnit, lastUnit;
if (Tcl_GetIntFromObj(interp, objv[2], &totalUnits) != TCL_OK) {
goto error;
}
@@ -476,11 +479,10 @@ ScrollbarWidgetObjCmd(
scrollPtr->firstFraction = ((double) firstUnit)/totalUnits;
scrollPtr->lastFraction = ((double) (lastUnit+1))/totalUnits;
}
- scrollPtr->flags &= ~NEW_STYLE_COMMANDS;
+ scrollPtr->flags |= OLD_STYLE_COMMANDS;
+#endif /* !TK_NO_DEPRECATED */
} else {
Tcl_WrongNumArgs(interp, 1, objv, "set firstFraction lastFraction");
- Tcl_AppendResult(interp, " or \"", Tcl_GetString(objv[0]),
- " set totalUnits windowUnits firstUnit lastUnit\"", NULL);
goto error;
}
TkpComputeScrollbarGeometry(scrollPtr);
@@ -524,7 +526,7 @@ ConfigureScrollbar(
TkScrollbar *scrollPtr,
/* Information about widget; may or may not
* already have values for some fields. */
- int objc, /* Number of valid entries in argv. */
+ Tcl_Size objc, /* Number of valid entries in argv. */
Tcl_Obj *const objv[], /* Arguments. */
int flags) /* Flags to pass to Tk_ConfigureWidget. */
{
@@ -543,6 +545,12 @@ ConfigureScrollbar(
} else {
scrollPtr->commandSize = 0;
}
+ if (scrollPtr->highlightWidth < 0) {
+ scrollPtr->highlightWidth = 0;
+ }
+ if (scrollPtr->elementBorderWidth < 0) {
+ scrollPtr->elementBorderWidth = -1;
+ }
/*
* Configure platform specific options.
@@ -581,7 +589,7 @@ ConfigureScrollbar(
void
TkScrollbarEventProc(
- ClientData clientData, /* Information about window. */
+ void *clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
TkScrollbar *scrollPtr = (TkScrollbar *)clientData;
@@ -603,7 +611,7 @@ TkScrollbarEventProc(
* Tk_FreeOptions handle all the standard option-related stuff.
*/
- Tk_FreeOptions(configSpecs, (char*) scrollPtr, scrollPtr->display, 0);
+ Tk_FreeOptions(configSpecs, scrollPtr, scrollPtr->display, 0);
Tcl_EventuallyFree(scrollPtr, TCL_DYNAMIC);
} else if (eventPtr->type == ConfigureNotify) {
TkpComputeScrollbarGeometry(scrollPtr);
@@ -647,7 +655,7 @@ TkScrollbarEventProc(
static void
ScrollbarCmdDeletedProc(
- ClientData clientData) /* Pointer to widget record for widget. */
+ void *clientData) /* Pointer to widget record for widget. */
{
TkScrollbar *scrollPtr = (TkScrollbar *)clientData;
Tk_Window tkwin = scrollPtr->tkwin;
diff --git a/generic/tkScrollbar.h b/generic/tkScrollbar.h
index 4d62263..6912e71 100644
--- a/generic/tkScrollbar.h
+++ b/generic/tkScrollbar.h
@@ -4,7 +4,7 @@
* Declarations of types and functions used to implement the scrollbar
* widget.
*
- * Copyright (c) 1996 Sun Microsystems, Inc.
+ * Copyright © 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.
@@ -93,21 +93,25 @@ typedef struct TkScrollbar {
* 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.
+ * the OLD_STYLE_COMMANDS flag is 1.
*/
+#ifndef TK_NO_DEPRECATED
int totalUnits; /* Total dimension of application, in units.
- * Valid only if the NEW_STYLE_COMMANDS flag
- * isn't set. */
+ * Valid only if the OLD_STYLE_COMMANDS flag
+ * is 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. */
+ * if the OLD_STYLE_COMMANDS flag is set. */
int firstUnit; /* Number of last unit visible in
* application's window. Valid only if the
- * NEW_STYLE_COMMANDS flag isn't set. */
+ * OLD_STYLE_COMMANDS flag is set. */
int lastUnit; /* Index of last unit visible in window.
- * Valid only if the NEW_STYLE_COMMANDS flag
+ * Valid only if the OLD_STYLE_COMMANDS flag
* isn't set. */
+#else
+ int dummy1,dummy2,dummy3,dummy4; /* sizeof(TkScrollbar) should not depend on TK_NO_DEPRECATED */
+#endif /* TK_NO_DEPRECATED */
double firstFraction; /* Position of first visible thing in window,
* specified as a fraction between 0 and
* 1.0. */
@@ -144,16 +148,18 @@ typedef struct TkScrollbar {
*
* 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
+ * OLD_STYLE_COMMANDS: Non-zero means the old style of commands
* should be used to communicate with the widget:
- * ".t yview scroll 2 lines", instead of
- * ".t yview 40", for example.
+ * ".t yview 40", instead of
+ * ".t yview scroll 2 lines", for example.
* GOT_FOCUS: Non-zero means this window has the input
* focus.
*/
#define REDRAW_PENDING 1
-#define NEW_STYLE_COMMANDS 2
+#ifndef TK_NO_DEPRECATED
+# define OLD_STYLE_COMMANDS 2
+#endif /* TK_NO_DEPRECATED */
#define GOT_FOCUS 4
/*
@@ -169,13 +175,13 @@ MODULE_SCOPE char tkDefScrollbarWidth[TCL_INTEGER_SPACE];
* widget.
*/
-MODULE_SCOPE void TkScrollbarEventProc(ClientData clientData,
+MODULE_SCOPE void TkScrollbarEventProc(void *clientData,
XEvent *eventPtr);
MODULE_SCOPE void TkScrollbarEventuallyRedraw(TkScrollbar *scrollPtr);
MODULE_SCOPE void TkpComputeScrollbarGeometry(TkScrollbar *scrollPtr);
MODULE_SCOPE TkScrollbar *TkpCreateScrollbar(Tk_Window tkwin);
MODULE_SCOPE void TkpDestroyScrollbar(TkScrollbar *scrollPtr);
-MODULE_SCOPE void TkpDisplayScrollbar(ClientData clientData);
+MODULE_SCOPE void TkpDisplayScrollbar(void *clientData);
MODULE_SCOPE void TkpConfigureScrollbar(TkScrollbar *scrollPtr);
MODULE_SCOPE int TkpScrollbarPosition(TkScrollbar *scrollPtr,
int x, int y);
diff --git a/generic/tkSelect.c b/generic/tkSelect.c
index 1f0214e..3478c3c 100644
--- a/generic/tkSelect.c
+++ b/generic/tkSelect.c
@@ -4,8 +4,8 @@
* 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-1997 Sun Microsystems, Inc.
+ * Copyright © 1990-1993 The Regents of the University of California.
+ * Copyright © 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.
@@ -26,11 +26,11 @@
typedef struct {
Tcl_Interp *interp; /* Interpreter in which to invoke command. */
- int cmdLength; /* # of non-NULL bytes in command. */
- int charOffset; /* The offset of the next char to retrieve. */
- int byteOffset; /* The expected byte offset of the next
+ Tcl_Size cmdLength; /* # of non-NULL bytes in command. */
+ Tcl_Size charOffset; /* The offset of the next char to retrieve. */
+ Tcl_Size byteOffset; /* The expected byte offset of the next
* chunk. */
- char buffer[4]; /* A buffer to hold part of a UTF character
+ char buffer[4]; /* A buffer to hold part of a UTF character
* that is split across chunks. */
char command[TKFLEXARRAY]; /* Command to invoke. Actual space is
* allocated as large as necessary. This must
@@ -63,10 +63,10 @@ static Tcl_ThreadDataKey dataKey;
* Forward declarations for functions defined in this file:
*/
-static int HandleTclCommand(ClientData clientData,
- int offset, char *buffer, int maxBytes);
-static void LostSelection(ClientData clientData);
-static int SelGetProc(ClientData clientData,
+static Tcl_Size HandleTclCommand(void *clientData,
+ Tcl_Size offset, char *buffer, Tcl_Size maxBytes);
+static void LostSelection(void *clientData);
+static int SelGetProc(void *clientData,
Tcl_Interp *interp, const char *portion);
/*
@@ -92,7 +92,7 @@ static int SelGetProc(ClientData clientData,
*
* int
* proc(
- * ClientData clientData,
+ * void *clientData,
* int offset,
* char *buffer,
* int maxBytes)
@@ -122,7 +122,7 @@ Tk_CreateSelHandler(
* STRING. */
Tk_SelectionProc *proc, /* Function to invoke to convert selection to
* type "target". */
- ClientData clientData, /* Value to pass to proc. */
+ void *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
@@ -194,7 +194,7 @@ Tk_CreateSelHandler(
* should make a copy for this selPtr.
*/
- unsigned cmdInfoLen = Tk_Offset(CommandInfo, command) + 1 +
+ size_t cmdInfoLen = offsetof(CommandInfo, command) + 1 +
((CommandInfo *)clientData)->cmdLength;
selPtr->clientData = ckalloc(cmdInfoLen);
@@ -354,14 +354,14 @@ Tk_OwnSelection(
Atom selection, /* Selection that window should own. */
Tk_LostSelProc *proc, /* Function to call when selection is taken
* away from tkwin. */
- ClientData clientData) /* Arbitrary one-word argument to pass to
+ void *clientData) /* Arbitrary one-word argument to pass to
* proc. */
{
TkWindow *winPtr = (TkWindow *) tkwin;
TkDisplay *dispPtr = winPtr->dispPtr;
TkSelectionInfo *infoPtr;
Tk_LostSelProc *clearProc = NULL;
- ClientData clearData = NULL;/* Initialization needed only to prevent
+ void *clearData = NULL;/* Initialization needed only to prevent
* compiler warning. */
if (dispPtr->multipleAtom == None) {
@@ -470,7 +470,7 @@ Tk_ClearSelection(
TkSelectionInfo *prevPtr;
TkSelectionInfo *nextPtr;
Tk_LostSelProc *clearProc = NULL;
- ClientData clearData = NULL;/* Initialization needed only to prevent
+ void *clearData = NULL;/* Initialization needed only to prevent
* compiler warning. */
if (dispPtr->multipleAtom == None) {
@@ -524,7 +524,7 @@ Tk_ClearSelection(
*
* int
* proc(
- * ClientData clientData,
+ * void *clientData,
* Tcl_Interp *interp,
* char *portion)
* {
@@ -555,7 +555,7 @@ Tk_GetSelection(
* returned. */
Tk_GetSelProc *proc, /* Function to call to process the selection,
* once it has been retrieved. */
- ClientData clientData) /* Arbitrary value to pass to proc. */
+ void *clientData) /* Arbitrary value to pass to proc. */
{
TkWindow *winPtr = (TkWindow *) tkwin;
TkDisplay *dispPtr = winPtr->dispPtr;
@@ -582,7 +582,8 @@ Tk_GetSelection(
}
if (infoPtr != NULL) {
TkSelHandler *selPtr;
- int offset, result, count;
+ Tcl_Size offset, count;
+ int result;
char buffer[TK_SEL_BYTES_AT_ONCE+1];
TkSelInProgress ip;
@@ -597,11 +598,10 @@ Tk_GetSelection(
count = TkSelDefaultSelection(infoPtr, target, buffer,
TK_SEL_BYTES_AT_ONCE, &type);
- if (count > TK_SEL_BYTES_AT_ONCE) {
- Tcl_Panic("selection handler returned too many bytes");
- }
if (count < 0) {
goto cantget;
+ } else if (count > TK_SEL_BYTES_AT_ONCE) {
+ Tcl_Panic("selection handler returned too many bytes");
}
buffer[count] = 0;
result = proc(clientData, interp, buffer);
@@ -668,7 +668,7 @@ Tk_GetSelection(
int
Tk_SelectionObjCmd(
- ClientData clientData, /* Main window associated with
+ void *clientData, /* Main window associated with
* interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
@@ -680,7 +680,7 @@ Tk_SelectionObjCmd(
const char *selName = NULL;
const char *string;
int count, index;
- Tcl_Obj **objs;
+ Tcl_Obj *const *objs;
static const char *const optionStrings[] = {
"clear", "get", "handle", "own", NULL
};
@@ -706,7 +706,7 @@ Tk_SelectionObjCmd(
enum clearOptions { CLEAR_DISPLAYOF, CLEAR_SELECTION };
int clearIndex;
- for (count = objc-2, objs = ((Tcl_Obj **)objv)+2; count > 0;
+ for (count = objc-2, objs = objv+2; count > 0;
count-=2, objs+=2) {
string = Tcl_GetString(objs[0]);
if (string[0] != '-') {
@@ -715,7 +715,7 @@ Tk_SelectionObjCmd(
if (count < 2) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"value for \"%s\" missing", string));
- Tcl_SetErrorCode(interp, "TK", "SELECTION", "VALUE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "SELECTION", "VALUE", (char *)NULL);
return TCL_ERROR;
}
@@ -775,7 +775,7 @@ Tk_SelectionObjCmd(
if (count < 2) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"value for \"%s\" missing", string));
- Tcl_SetErrorCode(interp, "TK", "SELECTION", "VALUE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "SELECTION", "VALUE", (char *)NULL);
return TCL_ERROR;
}
@@ -835,7 +835,7 @@ Tk_SelectionObjCmd(
const char *targetName = NULL;
const char *formatName = NULL;
CommandInfo *cmdInfoPtr;
- int cmdLength;
+ Tcl_Size cmdLength;
static const char *const handleOptionStrings[] = {
"-format", "-selection", "-type", NULL
};
@@ -853,7 +853,7 @@ Tk_SelectionObjCmd(
if (count < 2) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"value for \"%s\" missing", string));
- Tcl_SetErrorCode(interp, "TK", "SELECTION", "VALUE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "SELECTION", "VALUE", (char *)NULL);
return TCL_ERROR;
}
@@ -908,7 +908,7 @@ Tk_SelectionObjCmd(
if (cmdLength == 0) {
Tk_DeleteSelHandler(tkwin, selection, target);
} else {
- cmdInfoPtr = (CommandInfo *)ckalloc(Tk_Offset(CommandInfo, command)
+ cmdInfoPtr = (CommandInfo *)ckalloc(offsetof(CommandInfo, command)
+ 1 + cmdLength);
cmdInfoPtr->interp = interp;
cmdInfoPtr->charOffset = 0;
@@ -940,7 +940,7 @@ Tk_SelectionObjCmd(
if (count < 2) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"value for \"%s\" missing", string));
- Tcl_SetErrorCode(interp, "TK", "SELECTION", "VALUE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "SELECTION", "VALUE", (char *)NULL);
return TCL_ERROR;
}
@@ -996,7 +996,7 @@ Tk_SelectionObjCmd(
if ((infoPtr != NULL)
&& (infoPtr->owner != winPtr->dispPtr->clipWindow)) {
- Tcl_SetObjResult(interp, TkNewWindowObj(infoPtr->owner));
+ Tcl_SetObjResult(interp, Tk_NewWindowObj(infoPtr->owner));
}
return TCL_OK;
}
@@ -1250,7 +1250,7 @@ TkSelClearSelection(
}
if (infoPtr != NULL && (infoPtr->owner == tkwin) &&
- (eventPtr->xselectionclear.serial >= (unsigned) infoPtr->serial)) {
+ (eventPtr->xselectionclear.serial >= (unsigned long) infoPtr->serial)) {
if (prevPtr == NULL) {
dispPtr->selectionInfoPtr = infoPtr->nextPtr;
} else {
@@ -1291,13 +1291,13 @@ TkSelClearSelection(
static int
SelGetProc(
- ClientData clientData, /* Dynamic string holding partially assembled
+ void *clientData, /* Dynamic string holding partially assembled
* selection. */
TCL_UNUSED(Tcl_Interp *), /* Interpreter used for error reporting (not
* used). */
const char *portion) /* New information to be appended. */
{
- Tcl_DStringAppend((Tcl_DString *)clientData, portion, -1);
+ Tcl_DStringAppend((Tcl_DString *)clientData, portion, TCL_INDEX_NONE);
return TCL_OK;
}
@@ -1321,21 +1321,22 @@ SelGetProc(
*----------------------------------------------------------------------
*/
-static int
+static Tcl_Size
HandleTclCommand(
- ClientData clientData, /* Information about command to execute. */
- int offset, /* Return selection bytes starting at this
+ void *clientData, /* Information about command to execute. */
+ Tcl_Size offset, /* Return selection bytes starting at this
* offset. */
char *buffer, /* Place to store converted selection. */
- int maxBytes) /* Maximum # of bytes to store at buffer. */
+ Tcl_Size maxBytes) /* Maximum # of bytes to store at buffer. */
{
CommandInfo *cmdInfoPtr = (CommandInfo *)clientData;
- int length;
+ Tcl_Size length;
Tcl_Obj *command;
const char *string;
Tcl_Interp *interp = cmdInfoPtr->interp;
Tcl_InterpState savedState;
- int extraBytes, charOffset, count, numChars, code;
+ int code;
+ Tcl_Size extraBytes, charOffset, numChars, count;
const char *p;
/*
@@ -1371,7 +1372,7 @@ HandleTclCommand(
* the offset and maximum # of bytes.
*/
- command = Tcl_ObjPrintf("%s %d %d",
+ command = Tcl_ObjPrintf("%s %" TCL_SIZE_MODIFIER "d %" TCL_SIZE_MODIFIER "d",
cmdInfoPtr->command, charOffset, maxBytes);
Tcl_IncrRefCount(command);
@@ -1390,7 +1391,7 @@ HandleTclCommand(
string = Tcl_GetStringFromObj(Tcl_GetObjResult(interp), &length);
count = (length > maxBytes) ? maxBytes : length;
- memcpy(buffer, string, (size_t) count);
+ memcpy(buffer, string, count);
buffer[count] = '\0';
/*
@@ -1400,15 +1401,15 @@ HandleTclCommand(
if (cmdInfoPtr->interp != NULL) {
if (length <= maxBytes) {
- cmdInfoPtr->charOffset += Tcl_NumUtfChars(string, -1);
+ cmdInfoPtr->charOffset += TkNumUtfChars(string, TCL_INDEX_NONE);
cmdInfoPtr->buffer[0] = '\0';
} else {
- Tcl_UniChar ch = 0;
+ int ch = 0;
p = string;
string += count;
numChars = 0;
while (p < string) {
- p += Tcl_UtfToUniChar(p, &ch);
+ p += TkUtfToUniChar(p, &ch);
numChars++;
}
cmdInfoPtr->charOffset += numChars;
@@ -1431,7 +1432,7 @@ HandleTclCommand(
Tcl_AddErrorInfo(interp, "\n (command handling selection)");
Tcl_BackgroundException(interp, code);
}
- count = -1;
+ count = TCL_INDEX_NONE;
}
(void) Tcl_RestoreInterpState(interp, savedState);
@@ -1456,7 +1457,7 @@ HandleTclCommand(
* 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.
+ * transfers for this stuff!), then TCL_INDEX_NONE is returned.
*
* Side effects:
* None.
@@ -1464,12 +1465,12 @@ HandleTclCommand(
*----------------------------------------------------------------------
*/
-int
+Tcl_Size
TkSelDefaultSelection(
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. */
+ Tcl_Size 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. */
{
@@ -1478,7 +1479,7 @@ TkSelDefaultSelection(
if (target == dispPtr->timestampAtom) {
if (maxBytes < 20) {
- return -1;
+ return TCL_INDEX_NONE;
}
snprintf(buffer, maxBytes, "0x%x", (unsigned int) infoPtr->time);
*typePtr = XA_INTEGER;
@@ -1487,15 +1488,15 @@ TkSelDefaultSelection(
if (target == dispPtr->targetsAtom) {
TkSelHandler *selPtr;
- int length;
+ Tcl_Size length;
Tcl_DString ds;
if (maxBytes < 50) {
- return -1;
+ return TCL_INDEX_NONE;
}
Tcl_DStringInit(&ds);
Tcl_DStringAppend(&ds,
- "MULTIPLE TARGETS TIMESTAMP TK_APPLICATION TK_WINDOW", -1);
+ "MULTIPLE TARGETS TIMESTAMP TK_APPLICATION TK_WINDOW", TCL_INDEX_NONE);
for (selPtr = winPtr->selHandlerList; selPtr != NULL;
selPtr = selPtr->nextPtr) {
if ((selPtr->selection == infoPtr->selection)
@@ -1510,7 +1511,7 @@ TkSelDefaultSelection(
length = Tcl_DStringLength(&ds);
if (length >= maxBytes) {
Tcl_DStringFree(&ds);
- return -1;
+ return TCL_INDEX_NONE;
}
memcpy(buffer, Tcl_DStringValue(&ds), length + 1);
Tcl_DStringFree(&ds);
@@ -1519,12 +1520,12 @@ TkSelDefaultSelection(
}
if (target == dispPtr->applicationAtom) {
- int length;
+ Tcl_Size length;
Tk_Uid name = winPtr->mainPtr->winPtr->nameUid;
length = strlen(name);
if (maxBytes <= length) {
- return -1;
+ return TCL_INDEX_NONE;
}
strcpy(buffer, name);
*typePtr = XA_STRING;
@@ -1532,19 +1533,19 @@ TkSelDefaultSelection(
}
if (target == dispPtr->windowAtom) {
- int length;
+ Tcl_Size length;
char *name = winPtr->pathName;
length = strlen(name);
if (maxBytes <= length) {
- return -1;
+ return TCL_INDEX_NONE;
}
strcpy(buffer, name);
*typePtr = XA_STRING;
return length;
}
- return -1;
+ return TCL_INDEX_NONE;
}
/*
@@ -1567,7 +1568,7 @@ TkSelDefaultSelection(
static void
LostSelection(
- ClientData clientData) /* Pointer to LostCommand structure. */
+ void *clientData) /* Pointer to LostCommand structure. */
{
LostCommand *lostPtr = (LostCommand *)clientData;
Tcl_Interp *interp = lostPtr->interp;
diff --git a/generic/tkSelect.h b/generic/tkSelect.h
index 74326d0..074f956 100644
--- a/generic/tkSelect.h
+++ b/generic/tkSelect.h
@@ -4,7 +4,7 @@
* Declarations of types shared among the files that implement selection
* support.
*
- * Copyright (c) 1995 Sun Microsystems, Inc.
+ * Copyright © 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.
@@ -25,14 +25,18 @@
typedef struct TkSelectionInfo {
Atom selection; /* Selection name, e.g. XA_PRIMARY. */
Tk_Window owner; /* Current owner of this selection. */
- int serial; /* Serial number of last XSelectionSetOwner
+#if TCL_MAJOR_VERSION > 8
+ unsigned long serial; /* Serial number of last XSelectionSetOwner
* request made to server for this selection
* (used to filter out redundant
* SelectionClear events). */
+#else
+ int serial;
+#endif
Time time; /* Timestamp used to acquire selection. */
Tk_LostSelProc *clearProc; /* Procedure to call when owner loses
* selection. */
- ClientData clearData; /* Info to pass to clearProc. */
+ void *clearData; /* Info to pass to clearProc. */
struct TkSelectionInfo *nextPtr;
/* Next in list of current selections on this
* display. NULL means end of list. */
@@ -52,8 +56,8 @@ typedef struct TkSelHandler {
* returned, such as STRING or ATOM. */
Tk_SelectionProc *proc; /* Procedure to generate selection in this
* format. */
- ClientData clientData; /* Argument to pass to proc. */
- int size; /* Size of units returned by proc (8 for
+ void *clientData; /* Argument to pass to proc. */
+ Tcl_Size size; /* Size of units returned by proc (8 for
* STRING, 32 for almost anything else). */
struct TkSelHandler *nextPtr;
/* Next selection handler associated with same
@@ -77,7 +81,7 @@ typedef struct TkSelRetrievalInfo {
Atom target; /* Desired form for selection. */
Tk_GetSelProc *proc; /* Procedure to call to handle pieces of
* selection. */
- ClientData clientData; /* Argument for proc. */
+ void *clientData; /* Argument for proc. */
int result; /* Initially -1. Set to a Tcl return value
* once the selection has been retrieved. */
Tcl_TimerToken timeout; /* Token for current timeout procedure. */
@@ -103,7 +107,7 @@ typedef struct TkSelRetrievalInfo {
typedef struct TkClipboardBuffer {
char *buffer; /* Null terminated data buffer. */
- long length; /* Length of string in buffer. */
+ Tcl_Size length; /* Length of string in buffer. */
struct TkClipboardBuffer *nextPtr;
/* Next in list of buffers. NULL means end of
* list . */
@@ -156,8 +160,8 @@ typedef struct TkSelInProgress {
MODULE_SCOPE TkSelInProgress *TkSelGetInProgress(void);
MODULE_SCOPE void TkSelSetInProgress(TkSelInProgress *pendingPtr);
MODULE_SCOPE void TkSelClearSelection(Tk_Window tkwin, XEvent *eventPtr);
-MODULE_SCOPE int TkSelDefaultSelection(TkSelectionInfo *infoPtr,
- Atom target, char *buffer, int maxBytes,
+MODULE_SCOPE Tcl_Size TkSelDefaultSelection(TkSelectionInfo *infoPtr,
+ Atom target, char *buffer, Tcl_Size maxBytes,
Atom *typePtr);
#ifndef TkSelUpdateClipboard
MODULE_SCOPE void TkSelUpdateClipboard(TkWindow *winPtr,
diff --git a/generic/tkSquare.c b/generic/tkSquare.c
index 9b70ba3..708adbe 100644
--- a/generic/tkSquare.c
+++ b/generic/tkSquare.c
@@ -7,7 +7,7 @@
* build a widget; it isn't included in the normal wish, but it is
* included in "tktest".
*
- * Copyright (c) 1997 Sun Microsystems, Inc.
+ * Copyright © 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.
@@ -66,29 +66,29 @@ typedef struct {
static const Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_BORDER, "-background", "background", "Background",
- "#d9d9d9", Tk_Offset(Square, bgBorderPtr), -1, 0,
+ "#d9d9d9", offsetof(Square, bgBorderPtr), TCL_INDEX_NONE, 0,
"white", 0},
- {TK_OPTION_SYNONYM, "-bd", NULL, NULL, NULL, 0, -1, 0,
+ {TK_OPTION_SYNONYM, "-bd", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0,
"-borderwidth", 0},
- {TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, 0, -1, 0,
+ {TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0,
"-background", 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- "2", Tk_Offset(Square, borderWidthPtr), -1, 0, NULL, 0},
+ "2", offsetof(Square, borderWidthPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_BOOLEAN, "-dbl", "doubleBuffer", "DoubleBuffer",
- "1", Tk_Offset(Square, doubleBufferPtr), -1, 0 , NULL, 0},
- {TK_OPTION_SYNONYM, "-fg", NULL, NULL, NULL, 0, -1, 0,
+ "1", offsetof(Square, doubleBufferPtr), TCL_INDEX_NONE, 0 , NULL, 0},
+ {TK_OPTION_SYNONYM, "-fg", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0,
"-foreground", 0},
{TK_OPTION_BORDER, "-foreground", "foreground", "Foreground",
- "#b03060", Tk_Offset(Square, fgBorderPtr), -1, 0,
+ "#b03060", offsetof(Square, fgBorderPtr), TCL_INDEX_NONE, 0,
"black", 0},
{TK_OPTION_PIXELS, "-posx", "posx", "PosX", "0",
- Tk_Offset(Square, xPtr), -1, 0, NULL, 0},
+ offsetof(Square, xPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_PIXELS, "-posy", "posy", "PosY", "0",
- Tk_Offset(Square, yPtr), -1, 0, NULL, 0},
+ offsetof(Square, yPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- "raised", Tk_Offset(Square, reliefPtr), -1, 0, NULL, 0},
+ "raised", offsetof(Square, reliefPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_PIXELS, "-size", "size", "Size", "20",
- Tk_Offset(Square, sizeObjPtr), -1, 0, NULL, 0},
+ offsetof(Square, sizeObjPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0}
};
@@ -96,14 +96,13 @@ static const Tk_OptionSpec optionSpecs[] = {
* Forward declarations for procedures defined later in this file:
*/
-static void SquareDeletedProc(ClientData clientData);
+static void SquareDeletedProc(void *clientData);
static int SquareConfigure(Tcl_Interp *interp, Square *squarePtr);
-static void SquareDisplay(ClientData clientData);
+static void SquareDisplay(void *clientData);
static void KeepInWindow(Square *squarePtr);
-static void SquareObjEventProc(ClientData clientData,
+static void SquareObjEventProc(void *clientData,
XEvent *eventPtr);
-static int SquareWidgetObjCmd(ClientData clientData,
- Tcl_Interp *, int objc, Tcl_Obj * const objv[]);
+static Tcl_ObjCmdProc SquareWidgetObjCmd;
/*
*--------------------------------------------------------------
@@ -124,7 +123,7 @@ static int SquareWidgetObjCmd(ClientData clientData,
int
SquareObjCmd(
- ClientData clientData, /* NULL. */
+ TCL_UNUSED(void *),
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -159,7 +158,7 @@ SquareObjCmd(
* just the non-NULL/0 items.
*/
- squarePtr = ckalloc(sizeof(Square));
+ squarePtr = (Square *)ckalloc(sizeof(Square));
memset(squarePtr, 0, sizeof(Square));
squarePtr->tkwin = tkwin;
@@ -171,7 +170,7 @@ SquareObjCmd(
squarePtr->gc = NULL;
squarePtr->optionTable = optionTable;
- if (Tk_InitOptions(interp, (char *) squarePtr, optionTable, tkwin)
+ if (Tk_InitOptions(interp, squarePtr, optionTable, tkwin)
!= TCL_OK) {
Tk_DestroyWindow(squarePtr->tkwin);
ckfree(squarePtr);
@@ -180,7 +179,7 @@ SquareObjCmd(
Tk_CreateEventHandler(squarePtr->tkwin, ExposureMask|StructureNotifyMask,
SquareObjEventProc, squarePtr);
- if (Tk_SetOptions(interp, (char *) squarePtr, optionTable, objc - 2,
+ if (Tk_SetOptions(interp, squarePtr, optionTable, objc - 2,
objv + 2, tkwin, NULL, NULL) != TCL_OK) {
goto error;
}
@@ -189,7 +188,7 @@ SquareObjCmd(
}
Tcl_SetObjResult(interp,
- Tcl_NewStringObj(Tk_PathName(squarePtr->tkwin), -1));
+ Tcl_NewStringObj(Tk_PathName(squarePtr->tkwin), TCL_INDEX_NONE));
return TCL_OK;
error:
@@ -217,12 +216,12 @@ SquareObjCmd(
static int
SquareWidgetObjCmd(
- ClientData clientData, /* Information about square widget. */
+ void *clientData, /* Information about square widget. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj * const objv[]) /* Argument objects. */
{
- Square *squarePtr = clientData;
+ Square *squarePtr = (Square *)clientData;
int result = TCL_OK;
static const char *const squareOptions[] = {"cget", "configure", NULL};
enum {
@@ -232,7 +231,7 @@ SquareWidgetObjCmd(
int index;
if (objc < 2) {
- Tcl_WrongNumArgs(interp, 1, objv, "option ?arg arg...?");
+ Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?");
return TCL_ERROR;
}
@@ -249,7 +248,7 @@ SquareWidgetObjCmd(
Tcl_WrongNumArgs(interp, 2, objv, "option");
goto error;
}
- resultObjPtr = Tk_GetOptionValue(interp, (char *) squarePtr,
+ resultObjPtr = Tk_GetOptionValue(interp, squarePtr,
squarePtr->optionTable, objv[2], squarePtr->tkwin);
if (resultObjPtr == NULL) {
result = TCL_ERROR;
@@ -260,19 +259,19 @@ SquareWidgetObjCmd(
case SQUARE_CONFIGURE:
resultObjPtr = NULL;
if (objc == 2) {
- resultObjPtr = Tk_GetOptionInfo(interp, (char *) squarePtr,
+ resultObjPtr = Tk_GetOptionInfo(interp, squarePtr,
squarePtr->optionTable, NULL, squarePtr->tkwin);
if (resultObjPtr == NULL) {
result = TCL_ERROR;
}
} else if (objc == 3) {
- resultObjPtr = Tk_GetOptionInfo(interp, (char *) squarePtr,
+ resultObjPtr = Tk_GetOptionInfo(interp, squarePtr,
squarePtr->optionTable, objv[2], squarePtr->tkwin);
if (resultObjPtr == NULL) {
result = TCL_ERROR;
}
} else {
- result = Tk_SetOptions(interp, (char *) squarePtr,
+ result = Tk_SetOptions(interp, squarePtr,
squarePtr->optionTable, objc - 2, objv + 2,
squarePtr->tkwin, NULL, NULL);
if (result == TCL_OK) {
@@ -317,7 +316,7 @@ SquareWidgetObjCmd(
static int
SquareConfigure(
- Tcl_Interp *interp, /* Used for error reporting. */
+ TCL_UNUSED(Tcl_Interp *), /* Used for error reporting. */
Square *squarePtr) /* Information about widget. */
{
int borderWidth;
@@ -379,10 +378,10 @@ SquareConfigure(
static void
SquareObjEventProc(
- ClientData clientData, /* Information about window. */
+ void *clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
- Square *squarePtr = clientData;
+ Square *squarePtr = (Square *)clientData;
if (eventPtr->type == Expose) {
if (!squarePtr->updatePending) {
@@ -397,7 +396,7 @@ SquareObjEventProc(
}
} else if (eventPtr->type == DestroyNotify) {
if (squarePtr->tkwin != NULL) {
- Tk_FreeConfigOptions((char *) squarePtr, squarePtr->optionTable,
+ Tk_FreeConfigOptions(squarePtr, squarePtr->optionTable,
squarePtr->tkwin);
if (squarePtr->gc != NULL) {
Tk_FreeGC(squarePtr->display, squarePtr->gc);
@@ -433,9 +432,9 @@ SquareObjEventProc(
static void
SquareDeletedProc(
- ClientData clientData) /* Pointer to widget record for widget. */
+ void *clientData) /* Pointer to widget record for widget. */
{
- Square *squarePtr = clientData;
+ Square *squarePtr = (Square *)clientData;
Tk_Window tkwin = squarePtr->tkwin;
/*
@@ -470,9 +469,9 @@ SquareDeletedProc(
static void
SquareDisplay(
- ClientData clientData) /* Information about window. */
+ void *clientData) /* Information about window. */
{
- Square *squarePtr = clientData;
+ Square *squarePtr = (Square *)clientData;
Tk_Window tkwin = squarePtr->tkwin;
Pixmap pm = None;
Drawable d;
diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c
index 7cfbd3d..ac0af8e 100644
--- a/generic/tkStubInit.c
+++ b/generic/tkStubInit.c
@@ -3,7 +3,7 @@
*
* This file contains the initializers for the Tk stub vectors.
*
- * Copyright (c) 1998-1999 Scriptics Corporation.
+ * Copyright © 1998-1999 Scriptics Corporation.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -25,13 +25,14 @@
/* we could have used _TKMACINT */
#include "tkMacOSXInt.h"
#include "tkMacOSXPrivate.h"
+#else
+# define Tk_ClipDrawableToRect 0
#endif
/* TODO: These ought to come in some other way */
#include "tkPlatDecls.h"
#include "tkIntXlibDecls.h"
-static const TkIntStubs tkIntStubs;
MODULE_SCOPE const TkStubs tkStubs;
/*
@@ -39,15 +40,69 @@ MODULE_SCOPE const TkStubs tkStubs;
*/
#undef Tk_MainEx
-#undef XVisualIDFromVisual
-#undef XSynchronize
-#undef XUngrabServer
-#undef XNoOp
-#undef XGrabServer
-#undef XFree
-#undef XFlush
+#undef Tk_FreeXId
#undef Tk_FreeStyleFromObj
-#define TkUnusedStubEntry 0
+#undef Tk_GetStyleFromObj
+#undef TkWinGetPlatformId
+#undef TkPutImage
+#undef XPutImage
+#define TkMacOSXSetUpClippingRgn (void (*)(Drawable))(void *)doNothing
+#undef TkMacOSXIsCharacterMissing
+#define TkMacOSXIsCharacterMissing (int (*)(Tk_Font, unsigned int))(void *)doNothing
+
+#if defined(_WIN32) && !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
+# define Tk_TranslateWinEvent TkTranslateWinEvent
+# define Tk_PointerEvent TkWinPointerEvent
+#define TkWinGetPlatformId winGetPlatformId
+static int TkWinGetPlatformId(void) {
+ return 2;
+}
+#else
+# define Tk_TranslateWinEvent 0
+# define Tk_PointerEvent 0
+# define TkWinGetPlatformId 0
+#endif
+
+#if defined(TK_NO_DEPRECATED) || (TCL_MAJOR_VERSION > 8)
+# define TkSetWindowMenuBar 0
+# define TkpDrawHighlightBorder 0
+# define TkpUseWindow 0
+# define TkpSetMainMenubar 0
+# define TkpGetOtherWindow 0
+# define TkpGetSystemDefault 0
+# define TkpMakeContainer 0
+# define TkpMakeWindow 0
+#endif
+
+static int
+doNothing(void)
+{
+ /* dummy implementation, no need to do anything */
+ return 0;
+}
+
+#if defined(TK_NO_DEPRECATED) || TCL_MAJOR_VERSION > 8
+#define Tk_MainEx 0
+#define Tk_FreeXId 0
+#define Tk_FreeStyleFromObj 0
+#define Tk_GetStyleFromObj 0
+#define TkWinGetPlatformId 0
+#define Tk_PhotoPutBlock_NoComposite 0
+#define Tk_PhotoPutZoomedBlock_NoComposite 0
+#define Tk_PhotoExpand_Panic 0
+#define Tk_PhotoPutBlock_Panic 0
+#define Tk_PhotoPutZoomedBlock_Panic 0
+#define Tk_PhotoSetSize_Panic 0
+#define Tk_CreateOldPhotoImageFormat 0
+#else
+#define Tk_FreeXId ((void (*)(Display *, XID))(void *)doNothing)
+#define Tk_FreeStyleFromObj ((void (*)(Tcl_Obj *))(void *)doNothing)
+#define Tk_GetStyleFromObj getStyleFromObj
+static Tk_Style Tk_GetStyleFromObj(Tcl_Obj *obj)
+{
+ return Tk_AllocStyleFromObj(NULL, obj);
+}
+#endif /* !TK_NO_DEPRECATED */
#define TkpCmapStressed_ TkpCmapStressed
#define TkpSync_ TkpSync
@@ -59,39 +114,30 @@ MODULE_SCOPE const TkStubs tkStubs;
#define TkpTestsendCmd_ TkpTestsendCmd
#define TkGenWMConfigureEvent_ TkGenWMConfigureEvent
#define TkGenerateActivateEvents_ TkGenerateActivateEvents
+#define TkMacOSXDrawable Tk_MacOSXGetNSWindowForDrawable
-#if !defined(MAC_OSX_TK) && defined(MAC_OSX_TCL)
+#if !defined(MAC_OSX_TK)
# undef TkpWillDrawWidget
# undef TkpRedrawWidget
-static int
-doNothing(void)
-{
- /* dummy implementation, no need to do anything */
- return 0;
-}
# define TkpWillDrawWidget ((int (*)(Tk_Window))(void *)doNothing)
# define TkpRedrawWidget ((void (*)(Tk_Window))(void *)doNothing)
#endif
-#if defined(MAC_OSX_TK)
-# define Tk_MacOSXGetNSWindowForDrawable TkMacOSXDrawable
-# define Tk_MacOSXGetCGContextForDrawable GetCGContextForDrawable
-static void *GetCGContextForDrawable(Drawable d) {
- return TkMacOSXGetCGContextForDrawable(d);
-}
-#endif
-
#ifdef _WIN32
int
TkpCmapStressed(Tk_Window tkwin, Colormap colormap)
{
+ (void)tkwin;
+ (void)colormap;
+
/* dummy implementation, no need to do anything */
return 0;
}
void
TkpSync(Display *display)
{
+ (void)display;
/* dummy implementation, no need to do anything */
}
@@ -104,11 +150,8 @@ TkCreateXEventSource(void)
# define TkUnixContainerId 0
# define TkUnixDoOneXEvent 0
# define TkUnixSetMenubar 0
-# define XCreateWindow 0
-# define XOffsetRegion 0
-# define XUnionRegion 0
-# define TkWmCleanup (void (*)(TkDisplay *)) TkpSync
-# define TkSendCleanup (void (*)(TkDisplay *)) TkpSync
+# define TkWmCleanup (void (*)(TkDisplay *))(void *)TkpSync
+# define TkSendCleanup (void (*)(TkDisplay *))(void *)TkpSync
# define TkpTestsendCmd 0
#else /* !_WIN32 */
@@ -127,22 +170,21 @@ TkCreateXEventSource(void)
*/
#define GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS 0x00000004
+#ifdef __cplusplus
+extern "C" {
+#endif
int __stdcall GetModuleHandleExW(unsigned int, const char *, void *);
-
-void *Tk_GetHINSTANCE()
-{
- void *hInstance = NULL;
-
- GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
- (const char *) &tkIntStubs, &hInstance);
- return hInstance;
+#ifdef __cplusplus
}
+#endif
void
TkSetPixmapColormap(
Pixmap pixmap,
Colormap colormap)
{
+ (void)pixmap;
+ (void)colormap;
}
void
@@ -168,55 +210,16 @@ TkPutImage(
unsigned int width, unsigned int height)
/* Dimensions of subimage. */
{
- return XPutImage(display, d, gc, image, src_x, src_y, dest_x, dest_y, width, height);
-}
-
-TkRegion TkCreateRegion()
-{
- return (TkRegion) XCreateRegion();
-}
-
-int TkDestroyRegion(TkRegion r)
-{
- return XDestroyRegion((Region)r);
-}
+ (void)colors;
+ (void)ncolors;
-int TkSetRegion(Display *d, GC g, TkRegion r)
-{
- return XSetRegion(d, g, (Region)r);
-}
-
-int TkUnionRectWithRegion(XRectangle *a, TkRegion b, TkRegion c)
-{
- return XUnionRectWithRegion(a, (Region) b, (Region) c);
-}
-
-int TkClipBox(TkRegion a, XRectangle *b)
-{
- return XClipBox((Region) a, b);
-}
-
-int TkIntersectRegion(TkRegion a, TkRegion b, TkRegion c)
-{
- return XIntersectRegion((Region) a, (Region) b, (Region) c);
-}
-
-int TkRectInRegion (TkRegion r, int a, int b, unsigned int c, unsigned int d)
-{
- return XRectInRegion((Region) r, a, b, c, d);
-}
-
-int TkSubtractRegion (TkRegion a, TkRegion b, TkRegion c)
-{
- return XSubtractRegion((Region) a, (Region) b, (Region) c);
+ return XPutImage(display, d, gc, image, src_x, src_y, dest_x, dest_y, width, height);
}
/* TODO: To be implemented for Cygwin */
# define Tk_AttachHWND 0
# define Tk_GetHWND 0
# define Tk_HWNDToWindow 0
-# define Tk_PointerEvent 0
-# define Tk_TranslateWinEvent 0
# define TkAlignImageData 0
# define TkpGetMS 0
# define TkpGetCapture 0
@@ -245,33 +248,37 @@ int TkSubtractRegion (TkRegion a, TkRegion b, TkRegion c)
# define TkWinSetForegroundWindow 0
# define TkWinDialogDebug 0
# define TkWinGetMenuSystemDefault 0
-# define TkWinGetPlatformId 0
# define TkWinSetHINSTANCE 0
# define TkWinGetPlatformTheme 0
# define TkWinChildProc 0
-# elif !defined(MAC_OSX_TK) /* UNIX */
-
-# undef TkClipBox
-# undef TkCreateRegion
-# undef TkDestroyRegion
-# undef TkIntersectRegion
-# undef TkRectInRegion
-# undef TkSetRegion
-# undef TkUnionRectWithRegion
-# undef TkSubtractRegion
-
-# define TkClipBox (int (*) (TkRegion, XRectangle *)) XClipBox
-# define TkCreateRegion (TkRegion (*) ()) XCreateRegion
-# define TkDestroyRegion (int (*) (TkRegion)) XDestroyRegion
-# define TkIntersectRegion (int (*) (TkRegion, TkRegion, TkRegion)) XIntersectRegion
-# define TkRectInRegion (int (*) (TkRegion, int, int, unsigned int, unsigned int)) XRectInRegion
-# define TkSetRegion (int (*) (Display *, GC, TkRegion)) XSetRegion
-# define TkUnionRectWithRegion (int (*) (XRectangle *, TkRegion, TkRegion)) XUnionRectWithRegion
-# define TkSubtractRegion (int (*) (TkRegion, TkRegion, TkRegion)) XSubtractRegion
# endif
#endif /* !_WIN32 */
+#if defined(MAC_OSX_TCL)
+
+int
+TkPutImage(
+ unsigned long *colors, /* Array of pixel values used by this image.
+ * May be NULL. */
+ int ncolors, /* Number of colors used, or 0. */
+ Display *display,
+ Drawable d, /* Destination drawable. */
+ GC gc,
+ XImage *image, /* Source image. */
+ int src_x, int src_y, /* Offset of subimage. */
+ int dest_x, int dest_y, /* Position of subimage origin in drawable. */
+ unsigned int width, unsigned int height)
+ /* Dimensions of subimage. */
+{
+ (void)colors;
+ (void)ncolors;
+
+ return XPutImage(display, d, gc, image, src_x, src_y, dest_x, dest_y, width, height);
+}
+#endif /* MAC_OSX_TCL */
+
+
/*
* WARNING: The contents of this file is automatically generated by the
* tools/genStubs.tcl script. Any modifications to the function declarations
@@ -404,13 +411,13 @@ static const TkIntStubs tkIntStubs = {
TkpGetSubFonts, /* 110 */
TkpGetSystemDefault, /* 111 */
TkpMenuThreadInit, /* 112 */
- TkClipBox, /* 113 */
- TkCreateRegion, /* 114 */
- TkDestroyRegion, /* 115 */
- TkIntersectRegion, /* 116 */
- TkRectInRegion, /* 117 */
- TkSetRegion, /* 118 */
- TkUnionRectWithRegion, /* 119 */
+ XClipBox, /* 113 */
+ XCreateRegion, /* 114 */
+ XDestroyRegion, /* 115 */
+ XIntersectRegion, /* 116 */
+ XRectInRegion, /* 117 */
+ XSetRegion, /* 118 */
+ XUnionRectWithRegion, /* 119 */
0, /* 120 */
#if !(defined(_WIN32) || defined(MAC_OSX_TK)) /* X11 */
0, /* 121 */
@@ -469,7 +476,7 @@ static const TkIntStubs tkIntStubs = {
TkFocusFree, /* 142 */
TkClipCleanup, /* 143 */
TkGCCleanup, /* 144 */
- TkSubtractRegion, /* 145 */
+ XSubtractRegion, /* 145 */
TkStylePkgInit, /* 146 */
TkStylePkgFree, /* 147 */
TkToplevelWindowForCommand, /* 148 */
@@ -509,25 +516,9 @@ static const TkIntStubs tkIntStubs = {
TkUnderlineAngledTextLayout, /* 182 */
TkIntersectAngledTextLayout, /* 183 */
TkDrawAngledChars, /* 184 */
-#if !defined(_WIN32) && !defined(MAC_OSX_TCL) /* UNIX */
- 0, /* 185 */
-#endif /* UNIX */
-#if defined(_WIN32) /* WIN */
- 0, /* 185 */
-#endif /* WIN */
-#ifdef MAC_OSX_TCL /* MACOSX */
TkpRedrawWidget, /* 185 */
-#endif /* MACOSX */
-#if !defined(_WIN32) && !defined(MAC_OSX_TCL) /* UNIX */
- 0, /* 186 */
-#endif /* UNIX */
-#if defined(_WIN32) /* WIN */
- 0, /* 186 */
-#endif /* WIN */
-#ifdef MAC_OSX_TCL /* MACOSX */
TkpWillDrawWidget, /* 186 */
-#endif /* MACOSX */
- TkUnusedStubEntry, /* 187 */
+ TkDebugPhotoStringMatchDef, /* 187 */
};
static const TkIntPlatStubs tkIntPlatStubs = {
@@ -595,7 +586,7 @@ static const TkIntPlatStubs tkIntPlatStubs = {
TkMacOSXButtonKeyState, /* 8 */
TkMacOSXClearMenubarActive, /* 9 */
TkMacOSXDispatchMenuEvent, /* 10 */
- TkMacOSXInstallCursor, /* 11 */
+ 0, /* 11 */
TkMacOSXHandleTearoffMenu, /* 12 */
0, /* 13 */
TkMacOSXDoHLEvent, /* 14 */
@@ -631,9 +622,9 @@ static const TkIntPlatStubs tkIntPlatStubs = {
TkMacOSXGetHostToplevel, /* 44 */
TkMacOSXPreprocessMenu, /* 45 */
TkpIsWindowFloating, /* 46 */
- TkMacOSXGetCapture, /* 47 */
+ TkpGetCapture, /* 47 */
0, /* 48 */
- TkGetTransientMaster, /* 49 */
+ TkMacOSXGetContainer, /* 49 */
TkGenerateButtonEvent, /* 50 */
TkGenWMDestroyEvent, /* 51 */
TkMacOSXSetDrawingEnabled, /* 52 */
@@ -655,7 +646,7 @@ static const TkIntPlatStubs tkIntPlatStubs = {
TkSendCleanup, /* 10 */
0, /* 11 */
TkpWmSetState, /* 12 */
- TkpTestsendCmd, /* 13 */
+ TkpTestsendCmd_, /* 13 */
0, /* 14 */
0, /* 15 */
0, /* 16 */
@@ -687,7 +678,7 @@ static const TkIntPlatStubs tkIntPlatStubs = {
TkUnixSetMenubar_, /* 42 */
TkWmCleanup_, /* 43 */
TkSendCleanup_, /* 44 */
- TkpTestsendCmd_, /* 45 */
+ TkpTestsendCmd, /* 45 */
#endif /* X11 */
};
@@ -833,29 +824,29 @@ static const TkIntXlibStubs tkIntXlibStubs = {
XDrawPoints, /* 135 */
XReparentWindow, /* 136 */
XPutImage, /* 137 */
- 0, /* 138 */
- 0, /* 139 */
- 0, /* 140 */
- 0, /* 141 */
- 0, /* 142 */
- 0, /* 143 */
+ XPolygonRegion, /* 138 */
+ XPointInRegion, /* 139 */
+ XVaCreateNestedList, /* 140 */
+ XSetICValues, /* 141 */
+ XGetICValues, /* 142 */
+ XSetICFocus, /* 143 */
0, /* 144 */
0, /* 145 */
0, /* 146 */
- 0, /* 147 */
- 0, /* 148 */
- 0, /* 149 */
- 0, /* 150 */
- 0, /* 151 */
- 0, /* 152 */
- 0, /* 153 */
- 0, /* 154 */
- 0, /* 155 */
- 0, /* 156 */
- 0, /* 157 */
- TkUnusedStubEntry, /* 158 */
+ XFreeFontSet, /* 147 */
+ XCloseIM, /* 148 */
+ XRegisterIMInstantiateCallback, /* 149 */
+ XUnregisterIMInstantiateCallback, /* 150 */
+ XSetLocaleModifiers, /* 151 */
+ XOpenIM, /* 152 */
+ XGetIMValues, /* 153 */
+ XSetIMValues, /* 154 */
+ XCreateFontSet, /* 155 */
+ XFreeStringList, /* 156 */
+ XkbKeycodeToKeysym, /* 157 */
+ XkbOpenDisplay, /* 158 */
#endif /* WIN */
-#ifdef MAC_OSX_TK /* AQUA */
+#ifdef MAC_OSX_TCL /* MACOSX */
XSetDashes, /* 0 */
XGetModifierMapping, /* 1 */
XCreateImage, /* 2 */
@@ -948,20 +939,20 @@ static const TkIntXlibStubs tkIntXlibStubs = {
XQueryColors, /* 89 */
XQueryTree, /* 90 */
XSync, /* 91 */
- 0, /* 92 */
- 0, /* 93 */
- 0, /* 94 */
- 0, /* 95 */
- 0, /* 96 */
- 0, /* 97 */
- 0, /* 98 */
- 0, /* 99 */
- 0, /* 100 */
- 0, /* 101 */
- 0, /* 102 */
- 0, /* 103 */
- 0, /* 104 */
- 0, /* 105 */
+ XTranslateCoordinates, /* 92 */
+ XDeleteProperty, /* 93 */
+ XFreeCursor, /* 94 */
+ XGetInputFocus, /* 95 */
+ XmbLookupString, /* 96 */
+ XNextEvent, /* 97 */
+ XPutBackEvent, /* 98 */
+ XSetCommand, /* 99 */
+ XWindowEvent, /* 100 */
+ XGetWindowAttributes, /* 101 */
+ XGetWMColormapWindows, /* 102 */
+ XIconifyWindow, /* 103 */
+ XWithdrawWindow, /* 104 */
+ XListHosts, /* 105 */
XSetClipRectangles, /* 106 */
XFlush, /* 107 */
XGrabServer, /* 108 */
@@ -969,7 +960,7 @@ static const TkIntXlibStubs tkIntXlibStubs = {
XFree, /* 110 */
XNoOp, /* 111 */
XSynchronize, /* 112 */
- 0, /* 113 */
+ XLookupColor, /* 113 */
XVisualIDFromVisual, /* 114 */
0, /* 115 */
0, /* 116 */
@@ -977,8 +968,8 @@ static const TkIntXlibStubs tkIntXlibStubs = {
0, /* 118 */
0, /* 119 */
XOffsetRegion, /* 120 */
- 0, /* 121 */
- 0, /* 122 */
+ XUnionRegion, /* 121 */
+ XCreateWindow, /* 122 */
0, /* 123 */
0, /* 124 */
0, /* 125 */
@@ -986,36 +977,36 @@ static const TkIntXlibStubs tkIntXlibStubs = {
0, /* 127 */
0, /* 128 */
XLowerWindow, /* 129 */
- 0, /* 130 */
- 0, /* 131 */
- 0, /* 132 */
+ XFillArcs, /* 130 */
+ XDrawArcs, /* 131 */
+ XDrawRectangles, /* 132 */
0, /* 133 */
0, /* 134 */
0, /* 135 */
- 0, /* 136 */
+ XReparentWindow, /* 136 */
XPutImage, /* 137 */
- 0, /* 138 */
- 0, /* 139 */
- 0, /* 140 */
- 0, /* 141 */
- 0, /* 142 */
- 0, /* 143 */
+ XPolygonRegion, /* 138 */
+ XPointInRegion, /* 139 */
+ XVaCreateNestedList, /* 140 */
+ XSetICValues, /* 141 */
+ XGetICValues, /* 142 */
+ XSetICFocus, /* 143 */
XDestroyIC, /* 144 */
XCreatePixmapCursor, /* 145 */
XCreateGlyphCursor, /* 146 */
- 0, /* 147 */
- 0, /* 148 */
- 0, /* 149 */
- 0, /* 150 */
- 0, /* 151 */
- 0, /* 152 */
- 0, /* 153 */
- 0, /* 154 */
- 0, /* 155 */
- 0, /* 156 */
+ XFreeFontSet, /* 147 */
+ XCloseIM, /* 148 */
+ XRegisterIMInstantiateCallback, /* 149 */
+ XUnregisterIMInstantiateCallback, /* 150 */
+ XSetLocaleModifiers, /* 151 */
+ XOpenIM, /* 152 */
+ XGetIMValues, /* 153 */
+ XSetIMValues, /* 154 */
+ XCreateFontSet, /* 155 */
+ XFreeStringList, /* 156 */
XkbKeycodeToKeysym, /* 157 */
- TkUnusedStubEntry, /* 158 */
-#endif /* AQUA */
+ XkbOpenDisplay, /* 158 */
+#endif /* MACOSX */
};
static const TkPlatStubs tkPlatStubs = {
@@ -1030,14 +1021,14 @@ static const TkPlatStubs tkPlatStubs = {
Tk_TranslateWinEvent, /* 5 */
#endif /* WIN */
#ifdef MAC_OSX_TK /* AQUA */
- Tk_MacOSXSetEmbedHandler, /* 0 */
- Tk_MacOSXTurnOffMenus, /* 1 */
- Tk_MacOSXTkOwnsCursor, /* 2 */
- TkMacOSXInitMenus, /* 3 */
+ 0, /* 0 */
+ 0, /* 1 */
+ 0, /* 2 */
+ 0, /* 3 */
TkMacOSXInitAppleEvents, /* 4 */
- TkGenWMConfigureEvent, /* 5 */
+ TkGenWMConfigureEvent_, /* 5 */
TkMacOSXInvalClipRgns, /* 6 */
- TkMacOSXGetDrawablePort, /* 7 */
+ 0, /* 7 */
TkMacOSXGetRootControl, /* 8 */
Tk_MacOSXSetupTkNotifier, /* 9 */
Tk_MacOSXIsAppInFront, /* 10 */
@@ -1046,7 +1037,7 @@ static const TkPlatStubs tkPlatStubs = {
Tk_MacOSXGetNSWindowForDrawable, /* 13 */
0, /* 14 */
0, /* 15 */
- TkGenWMConfigureEvent_, /* 16 */
+ TkGenWMConfigureEvent, /* 16 */
#endif /* AQUA */
};
@@ -1158,7 +1149,7 @@ const TkStubs tkStubs = {
Tk_GetFontMetrics, /* 95 */
Tk_GetGC, /* 96 */
Tk_GetImage, /* 97 */
- Tk_GetImageMasterData, /* 98 */
+ Tk_GetImageModelData, /* 98 */
Tk_GetItemTypes, /* 99 */
Tk_GetJoinStyle, /* 100 */
Tk_GetJustify, /* 101 */
@@ -1334,23 +1325,36 @@ const TkStubs tkStubs = {
Tk_Interp, /* 271 */
Tk_CreateOldImageType, /* 272 */
Tk_CreateOldPhotoImageFormat, /* 273 */
- 0, /* 274 */
- 0, /* 275 */
- 0, /* 276 */
- 0, /* 277 */
- 0, /* 278 */
- 0, /* 279 */
- 0, /* 280 */
- 0, /* 281 */
- 0, /* 282 */
- 0, /* 283 */
- 0, /* 284 */
- 0, /* 285 */
- 0, /* 286 */
- 0, /* 287 */
- 0, /* 288 */
- 0, /* 289 */
- TkUnusedStubEntry, /* 290 */
+ Tk_AlwaysShowSelection, /* 274 */
+ Tk_GetButtonMask, /* 275 */
+ Tk_GetDoublePixelsFromObj, /* 276 */
+ Tk_NewWindowObj, /* 277 */
+ Tk_SendVirtualEvent, /* 278 */
+ Tk_FontGetDescription, /* 279 */
+ Tk_CreatePhotoImageFormatVersion3, /* 280 */
+ Tk_DrawHighlightBorder, /* 281 */
+ Tk_SetMainMenubar, /* 282 */
+ Tk_SetWindowMenubar, /* 283 */
+ Tk_ClipDrawableToRect, /* 284 */
+ Tk_GetSystemDefault, /* 285 */
+ Tk_UseWindow, /* 286 */
+ Tk_MakeContainer, /* 287 */
+ Tk_GetOtherWindow, /* 288 */
+ Tk_Get3DBorderColors, /* 289 */
+ Tk_MakeWindow, /* 290 */
};
/* !END!: Do not edit above this line. */
+
+
+#ifdef __CYGWIN__
+void *Tk_GetHINSTANCE(void)
+{
+ void *hInstance = NULL;
+
+ GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
+ (const char *) &tkIntStubs, &hInstance);
+ return hInstance;
+}
+#endif
+
diff --git a/generic/tkStubLib.c b/generic/tkStubLib.c
index 5cea659..8b669db 100644
--- a/generic/tkStubLib.c
+++ b/generic/tkStubLib.c
@@ -4,8 +4,8 @@
* Stub object that will be statically linked into extensions that want
* to access Tk.
*
- * Copyright (c) 1998-1999 Scriptics Corporation.
- * Copyright (c) 1998 Paul Duffin.
+ * Copyright © 1998-1999 Scriptics Corporation.
+ * Copyright © 1998 Paul Duffin.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -75,15 +75,19 @@ Tk_InitStubs(
const char *version,
int exact)
{
- const char *packageName = "Tk";
+ const char *packageName = "tk";
const char *errMsg = NULL;
- ClientData clientData = NULL;
+ void *clientData = NULL;
const char *actualVersion = tclStubsPtr->tcl_PkgRequireEx(interp,
packageName, version, 0, &clientData);
- const TkStubs *stubsPtr = (const TkStubs *)clientData;
if (actualVersion == NULL) {
- return NULL;
+ packageName = "Tk";
+ actualVersion = tclStubsPtr->tcl_PkgRequireEx(interp,
+ packageName, version, 0, &clientData);
+ if (actualVersion == NULL) {
+ return NULL;
+ }
}
if (exact) {
@@ -113,15 +117,15 @@ Tk_InitStubs(
}
}
}
- if (stubsPtr == NULL) {
+ if (clientData == NULL) {
errMsg = "missing stub table pointer";
} else {
- tkStubsPtr = stubsPtr;
- if (stubsPtr->hooks) {
- tkPlatStubsPtr = stubsPtr->hooks->tkPlatStubs;
- tkIntStubsPtr = stubsPtr->hooks->tkIntStubs;
- tkIntPlatStubsPtr = stubsPtr->hooks->tkIntPlatStubs;
- tkIntXlibStubsPtr = stubsPtr->hooks->tkIntXlibStubs;
+ tkStubsPtr = (const TkStubs *)clientData;
+ if (tkStubsPtr->hooks) {
+ tkPlatStubsPtr = tkStubsPtr->hooks->tkPlatStubs;
+ tkIntStubsPtr = tkStubsPtr->hooks->tkIntStubs;
+ tkIntPlatStubsPtr = tkStubsPtr->hooks->tkIntPlatStubs;
+ tkIntXlibStubsPtr = tkStubsPtr->hooks->tkIntXlibStubs;
} else {
tkPlatStubsPtr = NULL;
tkIntStubsPtr = NULL;
diff --git a/generic/tkStyle.c b/generic/tkStyle.c
index 8068404..b243674 100644
--- a/generic/tkStyle.c
+++ b/generic/tkStyle.c
@@ -3,8 +3,8 @@
*
* This file implements the widget styles and themes support.
*
- * Copyright (c) 1990-1993 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1990-1993 The Regents of the University of California.
+ * Copyright © 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.
@@ -78,7 +78,7 @@ typedef struct Style {
const char *name; /* Name of style. Points to a hash key. */
StyleEngine *enginePtr; /* Style engine of which the style is an
* instance. */
- ClientData clientData; /* Data provided during registration. */
+ void *clientData; /* Data provided during registration. */
} Style;
/*
@@ -99,7 +99,7 @@ typedef struct Element {
*/
typedef struct {
- int nbInit; /* Number of calls to the init proc. */
+ size_t nbInit; /* Number of calls to the init proc. */
Tcl_HashTable engineTable; /* Map a name to a style engine. Keys are
* strings, values are Tk_StyleEngine
* pointers. */
@@ -108,7 +108,7 @@ typedef struct {
* fallback for all engines. */
Tcl_HashTable styleTable; /* Map a name to a style. Keys are strings,
* values are Tk_Style pointers.*/
- int nbElements; /* Size of the below tables. */
+ Tcl_Size nbElements; /* Size of the below tables. */
Tcl_HashTable elementTable; /* Map a name to an element Id. Keys are
* strings, values are integer element IDs. */
Element *elements; /* Array of Elements. */
@@ -129,13 +129,13 @@ static void FreeStyleEngine(StyleEngine *enginePtr);
static void FreeStyleObjProc(Tcl_Obj *objPtr);
static void FreeWidgetSpec(StyledWidgetSpec *widgetSpecPtr);
static StyledElement * GetStyledElement(StyleEngine *enginePtr,
- int elementId);
+ Tcl_Size elementId);
static StyledWidgetSpec*GetWidgetSpec(StyledElement *elementPtr,
Tk_OptionTable optionTable);
static void InitElement(Element *elementPtr, const char *name,
int id, int genericId, int created);
static void InitStyle(Style *stylePtr, const char *name,
- StyleEngine *enginePtr, ClientData clientData);
+ StyleEngine *enginePtr, void *clientData);
static void InitStyledElement(StyledElement *elementPtr);
static void InitStyleEngine(StyleEngine *enginePtr,
const char *name, StyleEngine *parentPtr);
@@ -150,12 +150,14 @@ static int SetStyleFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr);
* style object points to the Style structure for the stylefont, or NULL.
*/
-static const Tcl_ObjType styleObjType = {
- "style", /* name */
+static const TkObjType styleObjType = {
+ {"style", /* name */
FreeStyleObjProc, /* freeIntRepProc */
DupStyleObjProc, /* dupIntRepProc */
NULL, /* updateStringProc */
- SetStyleFromAny /* setFromAnyProc */
+ NULL, /* setFromAnyProc */
+ TCL_OBJTYPE_V0},
+ 0
};
/*
@@ -240,7 +242,7 @@ TkStylePkgFree(
Tcl_HashSearch search;
Tcl_HashEntry *entryPtr;
StyleEngine *enginePtr;
- int i;
+ Tcl_Size i;
tsdPtr->nbInit--;
if (tsdPtr->nbInit != 0) {
@@ -366,7 +368,7 @@ InitStyleEngine(
{
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
- int elementId;
+ Tcl_Size elementId;
if (name == NULL || *name == '\0') {
/*
@@ -421,7 +423,7 @@ FreeStyleEngine(
{
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
- int elementId;
+ Tcl_Size elementId;
/*
* Free allocated elements.
@@ -841,7 +843,7 @@ static StyledElement *
GetStyledElement(
StyleEngine *enginePtr, /* Style engine providing the implementation.
* NULL means the default system engine. */
- int elementId) /* Unique element ID */
+ Tcl_Size elementId) /* Unique element ID */
{
StyledElement *elementPtr;
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
@@ -852,7 +854,7 @@ GetStyledElement(
enginePtr = tsdPtr->defaultEnginePtr;
}
- while (elementId >= 0 && elementId < tsdPtr->nbElements) {
+ while (elementId != TCL_INDEX_NONE && elementId < tsdPtr->nbElements) {
/*
* Look for an implemented element through the engine chain.
*/
@@ -1035,7 +1037,7 @@ GetWidgetSpec(
Tk_StyledElement
Tk_GetStyledElement(
Tk_Style style, /* The widget style. */
- int elementId, /* Unique element ID. */
+ Tcl_Size elementId, /* Unique element ID. */
Tk_OptionTable optionTable) /* Option table for the widget. */
{
Style *stylePtr = (Style *) style;
@@ -1076,7 +1078,7 @@ Tk_GetElementSize(
Tk_Style style, /* The widget style. */
Tk_StyledElement element, /* The styled element, previously returned by
* Tk_GetStyledElement. */
- char *recordPtr, /* The widget record. */
+ void *recordPtr, /* The widget record. */
Tk_Window tkwin, /* The widget window. */
int width, int height, /* Requested size. */
int inner, /* If TRUE, compute the outer size according
@@ -1090,7 +1092,7 @@ Tk_GetElementSize(
StyledWidgetSpec *widgetSpecPtr = (StyledWidgetSpec *) element;
widgetSpecPtr->elementPtr->specPtr->getSize(stylePtr->clientData,
- recordPtr, widgetSpecPtr->optionsPtr, tkwin, width, height, inner,
+ (char *)recordPtr, widgetSpecPtr->optionsPtr, tkwin, width, height, inner,
widthPtr, heightPtr);
}
@@ -1117,7 +1119,7 @@ Tk_GetElementBox(
Tk_Style style, /* The widget style. */
Tk_StyledElement element, /* The styled element, previously returned by
* Tk_GetStyledElement. */
- char *recordPtr, /* The widget record. */
+ void *recordPtr, /* The widget record. */
Tk_Window tkwin, /* The widget window. */
int x, int y, /* Top left corner of available area. */
int width, int height, /* Size of available area. */
@@ -1133,7 +1135,7 @@ Tk_GetElementBox(
StyledWidgetSpec *widgetSpecPtr = (StyledWidgetSpec *) element;
widgetSpecPtr->elementPtr->specPtr->getBox(stylePtr->clientData,
- recordPtr, widgetSpecPtr->optionsPtr, tkwin, x, y, width, height,
+ (char *)recordPtr, widgetSpecPtr->optionsPtr, tkwin, x, y, width, height,
inner, xPtr, yPtr, widthPtr, heightPtr);
}
@@ -1159,14 +1161,14 @@ Tk_GetElementBorderWidth(
Tk_Style style, /* The widget style. */
Tk_StyledElement element, /* The styled element, previously returned by
* Tk_GetStyledElement. */
- char *recordPtr, /* The widget record. */
+ void *recordPtr, /* The widget record. */
Tk_Window tkwin) /* The widget window. */
{
Style *stylePtr = (Style *) style;
StyledWidgetSpec *widgetSpecPtr = (StyledWidgetSpec *) element;
return widgetSpecPtr->elementPtr->specPtr->getBorderWidth(
- stylePtr->clientData, recordPtr, widgetSpecPtr->optionsPtr, tkwin);
+ stylePtr->clientData, (char *)recordPtr, widgetSpecPtr->optionsPtr, tkwin);
}
/*
@@ -1190,7 +1192,7 @@ Tk_DrawElement(
Tk_Style style, /* The widget style. */
Tk_StyledElement element, /* The styled element, previously returned by
* Tk_GetStyledElement. */
- char *recordPtr, /* The widget record. */
+ void *recordPtr, /* The widget record. */
Tk_Window tkwin, /* The widget window. */
Drawable d, /* Where to draw element. */
int x, int y, /* Top left corner of element. */
@@ -1201,7 +1203,7 @@ Tk_DrawElement(
StyledWidgetSpec *widgetSpecPtr = (StyledWidgetSpec *) element;
widgetSpecPtr->elementPtr->specPtr->draw(stylePtr->clientData,
- recordPtr, widgetSpecPtr->optionsPtr, tkwin, d, x, y, width,
+ (char *)recordPtr, widgetSpecPtr->optionsPtr, tkwin, d, x, y, width,
height, state);
}
@@ -1227,7 +1229,7 @@ Tk_CreateStyle(
const char *name, /* Name of the style to create. NULL or empty
* means the default system style. */
Tk_StyleEngine engine, /* The style engine. */
- ClientData clientData) /* Private data passed as is to engine code. */
+ void *clientData) /* Private data passed as is to engine code. */
{
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
@@ -1313,7 +1315,7 @@ InitStyle(
* means the default system style. Usually
* points to the hash key. */
StyleEngine *enginePtr, /* The style engine. */
- ClientData clientData) /* Private data passed as is to engine code. */
+ void *clientData) /* Private data passed as is to engine code. */
{
stylePtr->name = name;
stylePtr->enginePtr = enginePtr;
@@ -1357,7 +1359,7 @@ Tk_GetStyle(
if (interp != NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"style \"%s\" doesn't exist", name));
- Tcl_SetErrorCode(interp, "TK", "LOOKUP", "STYLE", name, NULL);
+ Tcl_SetErrorCode(interp, "TK", "LOOKUP", "STYLE", name, (char *)NULL);
}
return NULL;
}
@@ -1402,59 +1404,15 @@ Tk_AllocStyleFromObj(
Tcl_Obj *objPtr) /* Object containing name of the style to
* retrieve. */
{
- if (objPtr->typePtr != &styleObjType) {
- SetStyleFromAny(interp, objPtr);
- }
- return (Tk_Style)objPtr->internalRep.twoPtrValue.ptr1;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_GetStyleFromObj --
- *
- * Find the style that corresponds to a given object. The style must have
- * already been created by Tk_CreateStyle.
- *
- * Results:
- * The return value is a token for the style that matches objPtr, or NULL
- * if none found.
- *
- * Side effects:
- * If the object is not already a style ref, the conversion will free any
- * old internal representation.
- *
- *----------------------------------------------------------------------
- */
-
-Tk_Style
-Tk_GetStyleFromObj(
- Tcl_Obj *objPtr) /* The object from which to get the style. */
-{
- if (objPtr->typePtr != &styleObjType) {
- SetStyleFromAny(NULL, objPtr);
+ if (objPtr->typePtr != &styleObjType.objType) {
+ if (SetStyleFromAny(interp, objPtr) != TCL_OK) {
+ return NULL;
+ }
}
-
return (Tk_Style)objPtr->internalRep.twoPtrValue.ptr1;
}
/*
- *---------------------------------------------------------------------------
- *
- * Tk_FreeStyleFromObj --
- *
- * No-op. Present only for stubs compatibility.
- *
- *---------------------------------------------------------------------------
- */
-#undef Tk_FreeStyleFromObj
-void
-Tk_FreeStyleFromObj(
- TCL_UNUSED(Tcl_Obj *))
-{
-}
-
-/*
*----------------------------------------------------------------------
*
* SetStyleFromAny --
@@ -1463,8 +1421,8 @@ Tk_FreeStyleFromObj(
* internal form.
*
* Results:
- * Always returns TCL_OK. If an error occurs is returned (e.g. the style
- * doesn't exist), an error message will be left in interp's result.
+ * If an error occurs is returned (e.g. the style doesn't exist), an
+ * error message will be left in interp's result and TCL_ERROR is returned.
*
* Side effects:
* The object is left with its typePtr pointing to styleObjType.
@@ -1479,6 +1437,7 @@ SetStyleFromAny(
{
const Tcl_ObjType *typePtr;
const char *name;
+ Tk_Style style;
/*
* Free the old internalRep before setting the new one.
@@ -1490,8 +1449,12 @@ SetStyleFromAny(
typePtr->freeIntRepProc(objPtr);
}
- objPtr->typePtr = &styleObjType;
- objPtr->internalRep.twoPtrValue.ptr1 = Tk_GetStyle(interp, name);
+ style = Tk_GetStyle(interp, name);
+ if (style == NULL) {
+ return TCL_ERROR;
+ }
+ objPtr->typePtr = &styleObjType.objType;
+ objPtr->internalRep.twoPtrValue.ptr1 = style;
return TCL_OK;
}
diff --git a/generic/tkTest.c b/generic/tkTest.c
index 755a6be..4d96ad3 100644
--- a/generic/tkTest.c
+++ b/generic/tkTest.c
@@ -6,9 +6,9 @@
* commands are not normally included in Tcl applications; they're only
* used for testing.
*
- * Copyright (c) 1993-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
- * Copyright (c) 1998-1999 Scriptics Corporation.
+ * Copyright © 1993-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1998-1999 Scriptics Corporation.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -48,7 +48,18 @@
#undef TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS DLLEXPORT
+#ifdef __cplusplus
+extern "C" {
+#endif
EXTERN int Tktest_Init(Tcl_Interp *interp);
+#ifdef __cplusplus
+}
+#endif
+
+#if TCL_MAJOR_VERSION < 9
+# undef Tcl_CreateObjCommand2
+# define Tcl_CreateObjCommand2 Tcl_CreateObjCommand
+#endif
/*
* The following data structure represents the model for a test image:
*/
@@ -80,17 +91,17 @@ typedef struct TImageInstance {
*/
static int ImageCreate(Tcl_Interp *interp,
- const char *name, int objc, Tcl_Obj *const objv[],
+ const char *name, Tcl_Size objc, Tcl_Obj *const objv[],
const Tk_ImageType *typePtr, Tk_ImageModel model,
- ClientData *clientDataPtr);
-static ClientData ImageGet(Tk_Window tkwin, ClientData clientData);
-static void ImageDisplay(ClientData clientData,
+ void **clientDataPtr);
+static void *ImageGet(Tk_Window tkwin, void *clientData);
+static void ImageDisplay(void *clientData,
Display *display, Drawable drawable,
int imageX, int imageY, int width,
int height, int drawableX,
int drawableY);
-static void ImageFree(ClientData clientData, Display *display);
-static void ImageDelete(ClientData clientData);
+static void ImageFree(void *clientData, Display *display);
+static void ImageDelete(void *clientData);
static Tk_ImageType imageType = {
"test", /* name */
@@ -144,70 +155,35 @@ typedef struct TrivialCommandHeader {
* Forward declarations for functions defined later in this file:
*/
-static int ImageObjCmd(ClientData dummy,
- Tcl_Interp *interp, int objc,
- Tcl_Obj * const objv[]);
-static int TestbitmapObjCmd(ClientData dummy,
- Tcl_Interp *interp, int objc,
- Tcl_Obj * const objv[]);
-static int TestborderObjCmd(ClientData dummy,
- Tcl_Interp *interp, int objc,
- Tcl_Obj * const objv[]);
-static int TestcolorObjCmd(ClientData dummy,
- Tcl_Interp *interp, int objc,
- Tcl_Obj * const objv[]);
-static int TestcursorObjCmd(ClientData dummy,
- Tcl_Interp *interp, int objc,
- Tcl_Obj * const objv[]);
-static int TestdeleteappsObjCmd(ClientData dummy,
- Tcl_Interp *interp, int objc,
- Tcl_Obj * const objv[]);
-static int TestfontObjCmd(ClientData dummy,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
-static int TestmakeexistObjCmd(ClientData dummy,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
+static Tcl_ObjCmdProc ImageObjCmd;
+static Tcl_ObjCmdProc TestbitmapObjCmd;
+static Tcl_ObjCmdProc TestborderObjCmd;
+static Tcl_ObjCmdProc TestcolorObjCmd;
+static Tcl_ObjCmdProc TestcursorObjCmd;
+static Tcl_ObjCmdProc TestdeleteappsObjCmd;
+static Tcl_ObjCmdProc TestfontObjCmd;
+static Tcl_ObjCmdProc TestmakeexistObjCmd;
#if !(defined(_WIN32) || defined(MAC_OSX_TK) || defined(__CYGWIN__))
-static int TestmenubarObjCmd(ClientData dummy,
- Tcl_Interp *interp, int objc,
- Tcl_Obj *const objv[]);
+static Tcl_ObjCmdProc TestmenubarObjCmd;
#endif
#if defined(_WIN32)
-static int TestmetricsObjCmd(ClientData dummy,
- Tcl_Interp *interp, int objc,
- Tcl_Obj * const objv[]);
+static Tcl_ObjCmdProc TestmetricsObjCmd;
#endif
-static int TestobjconfigObjCmd(ClientData dummy,
- Tcl_Interp *interp, int objc,
- Tcl_Obj * const objv[]);
-static int CustomOptionSet(ClientData clientData,
- Tcl_Interp *interp, Tk_Window tkwin,
- Tcl_Obj **value, char *recordPtr,
- int internalOffset, char *saveInternalPtr,
- int flags);
-static Tcl_Obj * CustomOptionGet(ClientData clientData,
- Tk_Window tkwin, char *recordPtr,
- int internalOffset);
-static void CustomOptionRestore(ClientData clientData,
- Tk_Window tkwin, char *internalPtr,
- char *saveInternalPtr);
-static void CustomOptionFree(ClientData clientData,
- Tk_Window tkwin, char *internalPtr);
-static int TestpropObjCmd(ClientData dummy,
- Tcl_Interp *interp, int objc,
- Tcl_Obj * const objv[]);
+static Tcl_ObjCmdProc TestobjconfigObjCmd;
+static Tk_CustomOptionSetProc CustomOptionSet;
+static Tk_CustomOptionGetProc CustomOptionGet;
+static Tk_CustomOptionRestoreProc CustomOptionRestore;
+static Tk_CustomOptionFreeProc CustomOptionFree;
+static Tcl_ObjCmdProc TestpropObjCmd;
+static Tcl_ObjCmdProc TestprintfObjCmd;
#if !(defined(_WIN32) || defined(MAC_OSX_TK) || defined(__CYGWIN__))
-static int TestwrapperObjCmd(ClientData dummy,
- Tcl_Interp *interp, int objc,
- Tcl_Obj * const objv[]);
+static Tcl_ObjCmdProc TestwrapperObjCmd;
#endif
-static void TrivialCmdDeletedProc(ClientData clientData);
-static int TrivialConfigObjCmd(ClientData dummy,
- Tcl_Interp *interp, int objc,
- Tcl_Obj * const objv[]);
-static void TrivialEventProc(ClientData clientData,
+static void TrivialCmdDeletedProc(void *clientData);
+static Tcl_ObjCmdProc TrivialConfigObjCmd;
+static void TrivialEventProc(void *clientData,
XEvent *eventPtr);
+static Tcl_ObjCmdProc TestPhotoStringMatchCmd;
/*
*----------------------------------------------------------------------
@@ -232,7 +208,7 @@ Tktest_Init(
{
static int initialized = 0;
- if (Tcl_InitStubs(interp, "8.1", 0) == NULL) {
+ if (Tcl_InitStubs(interp, "8.6-", 0) == NULL) {
return TCL_ERROR;
}
if (Tk_InitStubs(interp, TK_VERSION, 0) == NULL) {
@@ -243,44 +219,48 @@ Tktest_Init(
* Create additional commands for testing Tk.
*/
- if (Tcl_PkgProvideEx(interp, "Tktest", TK_PATCH_LEVEL, NULL) == TCL_ERROR) {
+ if (Tcl_PkgProvideEx(interp, "tk::test", TK_PATCH_LEVEL, NULL) == TCL_ERROR) {
return TCL_ERROR;
}
Tcl_CreateObjCommand(interp, "square", SquareObjCmd, NULL, NULL);
Tcl_CreateObjCommand(interp, "testbitmap", TestbitmapObjCmd,
- (ClientData) Tk_MainWindow(interp), NULL);
+ Tk_MainWindow(interp), NULL);
Tcl_CreateObjCommand(interp, "testborder", TestborderObjCmd,
- (ClientData) Tk_MainWindow(interp), NULL);
+ Tk_MainWindow(interp), NULL);
Tcl_CreateObjCommand(interp, "testcolor", TestcolorObjCmd,
- (ClientData) Tk_MainWindow(interp), NULL);
+ Tk_MainWindow(interp), NULL);
Tcl_CreateObjCommand(interp, "testcursor", TestcursorObjCmd,
- (ClientData) Tk_MainWindow(interp), NULL);
+ Tk_MainWindow(interp), NULL);
Tcl_CreateObjCommand(interp, "testdeleteapps", TestdeleteappsObjCmd,
- (ClientData) Tk_MainWindow(interp), NULL);
- Tcl_CreateObjCommand(interp, "testembed", TkpTestembedCmd,
- (ClientData) Tk_MainWindow(interp), NULL);
+ Tk_MainWindow(interp), NULL);
+ Tcl_CreateObjCommand2(interp, "testembed", TkpTestembedCmd,
+ Tk_MainWindow(interp), NULL);
Tcl_CreateObjCommand(interp, "testobjconfig", TestobjconfigObjCmd,
- (ClientData) Tk_MainWindow(interp), NULL);
+ Tk_MainWindow(interp), NULL);
Tcl_CreateObjCommand(interp, "testfont", TestfontObjCmd,
- (ClientData) Tk_MainWindow(interp), NULL);
+ Tk_MainWindow(interp), NULL);
Tcl_CreateObjCommand(interp, "testmakeexist", TestmakeexistObjCmd,
- (ClientData) Tk_MainWindow(interp), NULL);
+ Tk_MainWindow(interp), NULL);
Tcl_CreateObjCommand(interp, "testprop", TestpropObjCmd,
- (ClientData) Tk_MainWindow(interp), NULL);
- Tcl_CreateObjCommand(interp, "testtext", TkpTesttextCmd,
- (ClientData) Tk_MainWindow(interp), NULL);
+ Tk_MainWindow(interp), NULL);
+ Tcl_CreateObjCommand(interp, "testprintf", TestprintfObjCmd, NULL, NULL);
+ Tcl_CreateObjCommand2(interp, "testtext", TkpTesttextCmd,
+ Tk_MainWindow(interp), NULL);
+ Tcl_CreateObjCommand(interp, "testphotostringmatch",
+ TestPhotoStringMatchCmd, Tk_MainWindow(interp),
+ NULL);
#if defined(_WIN32)
Tcl_CreateObjCommand(interp, "testmetrics", TestmetricsObjCmd,
- (ClientData) Tk_MainWindow(interp), NULL);
+ Tk_MainWindow(interp), NULL);
#elif !defined(__CYGWIN__) && !defined(MAC_OSX_TK)
Tcl_CreateObjCommand(interp, "testmenubar", TestmenubarObjCmd,
- (ClientData) Tk_MainWindow(interp), NULL);
- Tcl_CreateObjCommand(interp, "testsend", TkpTestsendCmd,
- (ClientData) Tk_MainWindow(interp), NULL);
+ Tk_MainWindow(interp), NULL);
+ Tcl_CreateObjCommand2(interp, "testsend", TkpTestsendCmd,
+ Tk_MainWindow(interp), NULL);
Tcl_CreateObjCommand(interp, "testwrapper", TestwrapperObjCmd,
- (ClientData) Tk_MainWindow(interp), NULL);
+ Tk_MainWindow(interp), NULL);
#endif /* _WIN32 */
/*
@@ -331,7 +311,6 @@ TestbitmapObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
-
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "bitmap");
return TCL_ERROR;
@@ -360,12 +339,11 @@ TestbitmapObjCmd(
static int
TestborderObjCmd(
- TCL_UNUSED(ClientData), /* Main window for application. */
+ TCL_UNUSED(void *), /* Main window for application. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
-
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "border");
return TCL_ERROR;
@@ -497,7 +475,7 @@ TestdeleteappsObjCmd(
static int
TestobjconfigObjCmd(
- ClientData clientData, /* Main window for application. */
+ void *clientData, /* Main window for application. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -523,7 +501,7 @@ TestobjconfigObjCmd(
CustomOptionFree,
INT2PTR(1)
};
- Tk_Window mainWin = (Tk_Window) clientData;
+ Tk_Window mainWin = (Tk_Window)clientData;
Tk_Window tkwin;
int index, result = TCL_OK;
@@ -532,7 +510,7 @@ TestobjconfigObjCmd(
* "chain2" subcommand:
*/
- typedef struct ExtensionWidgetRecord {
+ typedef struct {
TrivialCommandHeader header;
Tcl_Obj *base1ObjPtr;
Tcl_Obj *base2ObjPtr;
@@ -542,9 +520,9 @@ TestobjconfigObjCmd(
} ExtensionWidgetRecord;
static const Tk_OptionSpec baseSpecs[] = {
{TK_OPTION_STRING, "-one", "one", "One", "one",
- Tk_Offset(ExtensionWidgetRecord, base1ObjPtr), -1, 0, NULL, 0},
+ offsetof(ExtensionWidgetRecord, base1ObjPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_STRING, "-two", "two", "Two", "two",
- Tk_Offset(ExtensionWidgetRecord, base2ObjPtr), -1, 0, NULL, 0},
+ offsetof(ExtensionWidgetRecord, base2ObjPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0}
};
@@ -560,7 +538,7 @@ TestobjconfigObjCmd(
switch (index) {
case ALL_TYPES: {
- typedef struct TypesRecord {
+ typedef struct {
TrivialCommandHeader header;
Tcl_Obj *booleanPtr;
Tcl_Obj *integerPtr;
@@ -589,62 +567,62 @@ TestobjconfigObjCmd(
"one", "two", NULL
};
static const Tk_OptionSpec typesSpecs[] = {
- {TK_OPTION_BOOLEAN, "-boolean", "boolean", "Boolean", "1",
- Tk_Offset(TypesRecord, booleanPtr), -1, 0, 0, 0x1},
+ {TK_OPTION_BOOLEAN, "-boolean", "boolean", "Boolean", NULL,
+ offsetof(TypesRecord, booleanPtr), TCL_INDEX_NONE, TK_CONFIG_NULL_OK, 0, 0x1},
{TK_OPTION_INT, "-integer", "integer", "Integer", "7",
- Tk_Offset(TypesRecord, integerPtr), -1, 0, 0, 0x2},
+ offsetof(TypesRecord, integerPtr), TCL_INDEX_NONE, 0, 0, 0x2},
{TK_OPTION_DOUBLE, "-double", "double", "Double", "3.14159",
- Tk_Offset(TypesRecord, doublePtr), -1, 0, 0, 0x4},
+ offsetof(TypesRecord, doublePtr), TCL_INDEX_NONE, 0, 0, 0x4},
{TK_OPTION_STRING, "-string", "string", "String",
- "foo", Tk_Offset(TypesRecord, stringPtr), -1,
+ "foo", offsetof(TypesRecord, stringPtr), TCL_INDEX_NONE,
TK_CONFIG_NULL_OK, 0, 0x8},
{TK_OPTION_STRING_TABLE,
"-stringtable", "StringTable", "stringTable",
- "one", Tk_Offset(TypesRecord, stringTablePtr), -1,
- 0, stringTable, 0x10},
+ "one", offsetof(TypesRecord, stringTablePtr), TCL_INDEX_NONE,
+ TK_CONFIG_NULL_OK, stringTable, 0x10},
{TK_OPTION_STRING_TABLE,
"-stringtable2", "StringTable2", "stringTable2",
- "two", Tk_Offset(TypesRecord, stringTablePtr2), -1,
- 0, stringTable2, 0x10},
+ "two", offsetof(TypesRecord, stringTablePtr2), TCL_INDEX_NONE,
+ TK_CONFIG_NULL_OK, stringTable2, 0x10},
{TK_OPTION_COLOR, "-color", "color", "Color",
- "red", Tk_Offset(TypesRecord, colorPtr), -1,
+ "red", offsetof(TypesRecord, colorPtr), TCL_INDEX_NONE,
TK_CONFIG_NULL_OK, "black", 0x20},
{TK_OPTION_FONT, "-font", "font", "Font", "Helvetica 12",
- Tk_Offset(TypesRecord, fontPtr), -1,
+ offsetof(TypesRecord, fontPtr), TCL_INDEX_NONE,
TK_CONFIG_NULL_OK, 0, 0x40},
{TK_OPTION_BITMAP, "-bitmap", "bitmap", "Bitmap", "gray50",
- Tk_Offset(TypesRecord, bitmapPtr), -1,
+ offsetof(TypesRecord, bitmapPtr), TCL_INDEX_NONE,
TK_CONFIG_NULL_OK, 0, 0x80},
{TK_OPTION_BORDER, "-border", "border", "Border",
- "blue", Tk_Offset(TypesRecord, borderPtr), -1,
+ "blue", offsetof(TypesRecord, borderPtr), TCL_INDEX_NONE,
TK_CONFIG_NULL_OK, "white", 0x100},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief", NULL,
- Tk_Offset(TypesRecord, reliefPtr), -1,
+ offsetof(TypesRecord, reliefPtr), TCL_INDEX_NONE,
TK_CONFIG_NULL_OK, 0, 0x200},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", "xterm",
- Tk_Offset(TypesRecord, cursorPtr), -1,
+ offsetof(TypesRecord, cursorPtr), TCL_INDEX_NONE,
TK_CONFIG_NULL_OK, 0, 0x400},
{TK_OPTION_JUSTIFY, "-justify", NULL, NULL, "left",
- Tk_Offset(TypesRecord, justifyPtr), -1,
- 0, 0, 0x800},
+ offsetof(TypesRecord, justifyPtr), TCL_INDEX_NONE,
+ TK_CONFIG_NULL_OK, 0, 0x800},
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", "center",
- Tk_Offset(TypesRecord, anchorPtr), -1,
- 0, 0, 0x1000},
+ offsetof(TypesRecord, anchorPtr), TCL_INDEX_NONE,
+ TK_CONFIG_NULL_OK, 0, 0x1000},
{TK_OPTION_PIXELS, "-pixel", "pixel", "Pixel",
- "1", Tk_Offset(TypesRecord, pixelPtr), -1,
+ "1", offsetof(TypesRecord, pixelPtr), TCL_INDEX_NONE,
TK_CONFIG_NULL_OK, 0, 0x2000},
{TK_OPTION_CUSTOM, "-custom", NULL, NULL,
- "", Tk_Offset(TypesRecord, customPtr), -1,
+ "", offsetof(TypesRecord, customPtr), TCL_INDEX_NONE,
TK_CONFIG_NULL_OK, &CustomOption, 0x4000},
{TK_OPTION_SYNONYM, "-synonym", NULL, NULL,
- NULL, 0, -1, 0, "-color", 0x8000},
+ NULL, 0, TCL_INDEX_NONE, 0, "-color", 0x8000},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0}
};
Tk_OptionTable optionTable;
optionTable = Tk_CreateOptionTable(interp, typesSpecs);
tables[index] = optionTable;
- tkwin = Tk_CreateWindowFromPath(interp, (Tk_Window) clientData,
+ tkwin = Tk_CreateWindowFromPath(interp, (Tk_Window)clientData,
Tcl_GetString(objv[2]), NULL);
if (tkwin == NULL) {
return TCL_ERROR;
@@ -672,15 +650,15 @@ TestobjconfigObjCmd(
recordPtr->stringTablePtr = NULL;
recordPtr->stringTablePtr2 = NULL;
recordPtr->customPtr = NULL;
- result = Tk_InitOptions(interp, (char *) recordPtr, optionTable,
+ result = Tk_InitOptions(interp, recordPtr, optionTable,
tkwin);
if (result == TCL_OK) {
recordPtr->header.widgetCmd = Tcl_CreateObjCommand(interp,
Tcl_GetString(objv[2]), TrivialConfigObjCmd,
- (ClientData) recordPtr, TrivialCmdDeletedProc);
+ recordPtr, TrivialCmdDeletedProc);
Tk_CreateEventHandler(tkwin, StructureNotifyMask,
- TrivialEventProc, (ClientData) recordPtr);
- result = Tk_SetOptions(interp, (char *) recordPtr, optionTable,
+ TrivialEventProc, recordPtr);
+ result = Tk_SetOptions(interp, recordPtr, optionTable,
objc-3, objv+3, tkwin, NULL, NULL);
if (result != TCL_OK) {
Tk_DestroyWindow(tkwin);
@@ -699,7 +677,7 @@ TestobjconfigObjCmd(
ExtensionWidgetRecord *recordPtr;
Tk_OptionTable optionTable;
- tkwin = Tk_CreateWindowFromPath(interp, (Tk_Window) clientData,
+ tkwin = Tk_CreateWindowFromPath(interp, (Tk_Window)clientData,
Tcl_GetString(objv[2]), NULL);
if (tkwin == NULL) {
return TCL_ERROR;
@@ -714,20 +692,20 @@ TestobjconfigObjCmd(
recordPtr->header.tkwin = tkwin;
recordPtr->base1ObjPtr = recordPtr->base2ObjPtr = NULL;
recordPtr->extension3ObjPtr = recordPtr->extension4ObjPtr = NULL;
- result = Tk_InitOptions(interp, (char *)recordPtr, optionTable, tkwin);
+ result = Tk_InitOptions(interp, recordPtr, optionTable, tkwin);
if (result == TCL_OK) {
- result = Tk_SetOptions(interp, (char *) recordPtr, optionTable,
+ result = Tk_SetOptions(interp, recordPtr, optionTable,
objc-3, objv+3, tkwin, NULL, NULL);
if (result != TCL_OK) {
- Tk_FreeConfigOptions((char *) recordPtr, optionTable, tkwin);
+ Tk_FreeConfigOptions(recordPtr, optionTable, tkwin);
}
}
if (result == TCL_OK) {
recordPtr->header.widgetCmd = Tcl_CreateObjCommand(interp,
Tcl_GetString(objv[2]), TrivialConfigObjCmd,
- (ClientData) recordPtr, TrivialCmdDeletedProc);
+ recordPtr, TrivialCmdDeletedProc);
Tk_CreateEventHandler(tkwin, StructureNotifyMask,
- TrivialEventProc, (ClientData) recordPtr);
+ TrivialEventProc, recordPtr);
Tcl_SetObjResult(interp, objv[2]);
}
break;
@@ -738,20 +716,20 @@ TestobjconfigObjCmd(
ExtensionWidgetRecord *recordPtr;
static const Tk_OptionSpec extensionSpecs[] = {
{TK_OPTION_STRING, "-three", "three", "Three", "three",
- Tk_Offset(ExtensionWidgetRecord, extension3ObjPtr), -1, 0, NULL, 0},
+ offsetof(ExtensionWidgetRecord, extension3ObjPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_STRING, "-four", "four", "Four", "four",
- Tk_Offset(ExtensionWidgetRecord, extension4ObjPtr), -1, 0, NULL, 0},
+ offsetof(ExtensionWidgetRecord, extension4ObjPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_STRING, "-two", "two", "Two", "two and a half",
- Tk_Offset(ExtensionWidgetRecord, base2ObjPtr), -1, 0, NULL, 0},
+ offsetof(ExtensionWidgetRecord, base2ObjPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_STRING,
"-oneAgain", "oneAgain", "OneAgain", "one again",
- Tk_Offset(ExtensionWidgetRecord, extension5ObjPtr), -1, 0, NULL, 0},
- {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0,
- (ClientData) baseSpecs, 0}
+ offsetof(ExtensionWidgetRecord, extension5ObjPtr), TCL_INDEX_NONE, 0, NULL, 0},
+ {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0,
+ baseSpecs, 0}
};
Tk_OptionTable optionTable;
- tkwin = Tk_CreateWindowFromPath(interp, (Tk_Window) clientData,
+ tkwin = Tk_CreateWindowFromPath(interp, (Tk_Window)clientData,
Tcl_GetString(objv[2]), NULL);
if (tkwin == NULL) {
return TCL_ERROR;
@@ -767,33 +745,33 @@ TestobjconfigObjCmd(
recordPtr->base1ObjPtr = recordPtr->base2ObjPtr = NULL;
recordPtr->extension3ObjPtr = recordPtr->extension4ObjPtr = NULL;
recordPtr->extension5ObjPtr = NULL;
- result = Tk_InitOptions(interp, (char *)recordPtr, optionTable, tkwin);
+ result = Tk_InitOptions(interp, recordPtr, optionTable, tkwin);
if (result == TCL_OK) {
- result = Tk_SetOptions(interp, (char *) recordPtr, optionTable,
+ result = Tk_SetOptions(interp, recordPtr, optionTable,
objc-3, objv+3, tkwin, NULL, NULL);
if (result != TCL_OK) {
- Tk_FreeConfigOptions((char *) recordPtr, optionTable, tkwin);
+ Tk_FreeConfigOptions(recordPtr, optionTable, tkwin);
}
}
if (result == TCL_OK) {
recordPtr->header.widgetCmd = Tcl_CreateObjCommand(interp,
Tcl_GetString(objv[2]), TrivialConfigObjCmd,
- (ClientData) recordPtr, TrivialCmdDeletedProc);
+ recordPtr, TrivialCmdDeletedProc);
Tk_CreateEventHandler(tkwin, StructureNotifyMask,
- TrivialEventProc, (ClientData) recordPtr);
+ TrivialEventProc, recordPtr);
Tcl_SetObjResult(interp, objv[2]);
}
break;
}
case CONFIG_ERROR: {
- typedef struct ErrorWidgetRecord {
+ typedef struct {
Tcl_Obj *intPtr;
} ErrorWidgetRecord;
ErrorWidgetRecord widgetRecord;
static const Tk_OptionSpec errorSpecs[] = {
{TK_OPTION_INT, "-int", "integer", "Integer", "bogus",
- Tk_Offset(ErrorWidgetRecord, intPtr), 0, 0, NULL, 0},
+ offsetof(ErrorWidgetRecord, intPtr), 0, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0}
};
Tk_OptionTable optionTable;
@@ -801,7 +779,7 @@ TestobjconfigObjCmd(
widgetRecord.intPtr = NULL;
optionTable = Tk_CreateOptionTable(interp, errorSpecs);
tables[index] = optionTable;
- return Tk_InitOptions(interp, (char *) &widgetRecord, optionTable,
+ return Tk_InitOptions(interp, &widgetRecord, optionTable,
(Tk_Window) NULL);
}
@@ -841,9 +819,9 @@ TestobjconfigObjCmd(
* objects.
*/
- typedef struct InternalRecord {
+ typedef struct {
TrivialCommandHeader header;
- int boolean;
+ int boolValue;
int integer;
double doubleValue;
char *string;
@@ -867,71 +845,71 @@ TestobjconfigObjCmd(
};
static const Tk_OptionSpec internalSpecs[] = {
{TK_OPTION_BOOLEAN, "-boolean", "boolean", "Boolean", "1",
- -1, Tk_Offset(InternalRecord, boolean), 0, 0, 0x1},
+ TCL_INDEX_NONE, offsetof(InternalRecord, boolValue), TK_CONFIG_NULL_OK, 0, 0x1},
{TK_OPTION_INT, "-integer", "integer", "Integer", "148962237",
- -1, Tk_Offset(InternalRecord, integer), 0, 0, 0x2},
+ TCL_INDEX_NONE, offsetof(InternalRecord, integer), 0, 0, 0x2},
{TK_OPTION_DOUBLE, "-double", "double", "Double", "3.14159",
- -1, Tk_Offset(InternalRecord, doubleValue), 0, 0, 0x4},
+ TCL_INDEX_NONE, offsetof(InternalRecord, doubleValue), 0, 0, 0x4},
{TK_OPTION_STRING, "-string", "string", "String", "foo",
- -1, Tk_Offset(InternalRecord, string),
+ TCL_INDEX_NONE, offsetof(InternalRecord, string),
TK_CONFIG_NULL_OK, 0, 0x8},
{TK_OPTION_STRING_TABLE,
"-stringtable", "StringTable", "stringTable", "one",
- -1, Tk_Offset(InternalRecord, index),
+ TCL_INDEX_NONE, offsetof(InternalRecord, index),
TK_CONFIG_NULL_OK, internalStringTable, 0x10},
{TK_OPTION_COLOR, "-color", "color", "Color", "red",
- -1, Tk_Offset(InternalRecord, colorPtr),
+ TCL_INDEX_NONE, offsetof(InternalRecord, colorPtr),
TK_CONFIG_NULL_OK, "black", 0x20},
{TK_OPTION_FONT, "-font", "font", "Font", "Helvetica 12",
- -1, Tk_Offset(InternalRecord, tkfont),
+ TCL_INDEX_NONE, offsetof(InternalRecord, tkfont),
TK_CONFIG_NULL_OK, 0, 0x40},
{TK_OPTION_BITMAP, "-bitmap", "bitmap", "Bitmap", "gray50",
- -1, Tk_Offset(InternalRecord, bitmap),
+ TCL_INDEX_NONE, offsetof(InternalRecord, bitmap),
TK_CONFIG_NULL_OK, 0, 0x80},
{TK_OPTION_BORDER, "-border", "border", "Border", "blue",
- -1, Tk_Offset(InternalRecord, border),
+ TCL_INDEX_NONE, offsetof(InternalRecord, border),
TK_CONFIG_NULL_OK, "white", 0x100},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief", NULL,
- -1, Tk_Offset(InternalRecord, relief),
+ TCL_INDEX_NONE, offsetof(InternalRecord, relief),
TK_CONFIG_NULL_OK, 0, 0x200},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", "xterm",
- -1, Tk_Offset(InternalRecord, cursor),
+ TCL_INDEX_NONE, offsetof(InternalRecord, cursor),
TK_CONFIG_NULL_OK, 0, 0x400},
{TK_OPTION_JUSTIFY, "-justify", NULL, NULL, "left",
- -1, Tk_Offset(InternalRecord, justify),
- 0, 0, 0x800},
+ TCL_INDEX_NONE, offsetof(InternalRecord, justify),
+ TK_CONFIG_NULL_OK|TK_OPTION_ENUM_VAR, 0, 0x800},
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", "center",
- -1, Tk_Offset(InternalRecord, anchor),
- 0, 0, 0x1000},
+ TCL_INDEX_NONE, offsetof(InternalRecord, anchor),
+ TK_CONFIG_NULL_OK|TK_OPTION_ENUM_VAR, 0, 0x1000},
{TK_OPTION_PIXELS, "-pixel", "pixel", "Pixel", "1",
- -1, Tk_Offset(InternalRecord, pixels),
+ TCL_INDEX_NONE, offsetof(InternalRecord, pixels),
TK_CONFIG_NULL_OK, 0, 0x2000},
{TK_OPTION_WINDOW, "-window", "window", "Window", NULL,
- -1, Tk_Offset(InternalRecord, tkwin),
+ TCL_INDEX_NONE, offsetof(InternalRecord, tkwin),
TK_CONFIG_NULL_OK, 0, 0},
{TK_OPTION_CUSTOM, "-custom", NULL, NULL, "",
- -1, Tk_Offset(InternalRecord, custom),
+ TCL_INDEX_NONE, offsetof(InternalRecord, custom),
TK_CONFIG_NULL_OK, &CustomOption, 0x4000},
{TK_OPTION_SYNONYM, "-synonym", NULL, NULL,
- NULL, -1, -1, 0, "-color", 0x8000},
+ NULL, TCL_INDEX_NONE, TCL_INDEX_NONE, 0, "-color", 0x8000},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0}
};
Tk_OptionTable optionTable;
optionTable = Tk_CreateOptionTable(interp, internalSpecs);
tables[index] = optionTable;
- tkwin = Tk_CreateWindowFromPath(interp, (Tk_Window) clientData,
+ tkwin = Tk_CreateWindowFromPath(interp, (Tk_Window)clientData,
Tcl_GetString(objv[2]), NULL);
if (tkwin == NULL) {
return TCL_ERROR;
}
Tk_SetClass(tkwin, "Test");
- recordPtr = ckalloc(sizeof(InternalRecord));
+ recordPtr = (InternalRecord *)ckalloc(sizeof(InternalRecord));
recordPtr->header.interp = interp;
recordPtr->header.optionTable = optionTable;
recordPtr->header.tkwin = tkwin;
- recordPtr->boolean = 0;
+ recordPtr->boolValue = 0;
recordPtr->integer = 0;
recordPtr->doubleValue = 0.0;
recordPtr->string = NULL;
@@ -948,7 +926,7 @@ TestobjconfigObjCmd(
recordPtr->mm = 0.0;
recordPtr->tkwin = NULL;
recordPtr->custom = NULL;
- result = Tk_InitOptions(interp, (char *) recordPtr, optionTable,
+ result = Tk_InitOptions(interp, recordPtr, optionTable,
tkwin);
if (result == TCL_OK) {
recordPtr->header.widgetCmd = Tcl_CreateObjCommand(interp,
@@ -956,7 +934,7 @@ TestobjconfigObjCmd(
recordPtr, TrivialCmdDeletedProc);
Tk_CreateEventHandler(tkwin, StructureNotifyMask,
TrivialEventProc, recordPtr);
- result = Tk_SetOptions(interp, (char *) recordPtr, optionTable,
+ result = Tk_SetOptions(interp, recordPtr, optionTable,
objc - 3, objv + 3, tkwin, NULL, NULL);
if (result != TCL_OK) {
Tk_DestroyWindow(tkwin);
@@ -972,7 +950,7 @@ TestobjconfigObjCmd(
}
case NEW: {
- typedef struct FiveRecord {
+ typedef struct {
TrivialCommandHeader header;
Tcl_Obj *one;
Tcl_Obj *two;
@@ -983,15 +961,15 @@ TestobjconfigObjCmd(
FiveRecord *recordPtr;
static const Tk_OptionSpec smallSpecs[] = {
{TK_OPTION_INT, "-one", "one", "One", "1",
- Tk_Offset(FiveRecord, one), -1, 0, NULL, 0},
+ offsetof(FiveRecord, one), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_INT, "-two", "two", "Two", "2",
- Tk_Offset(FiveRecord, two), -1, 0, NULL, 0},
+ offsetof(FiveRecord, two), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_INT, "-three", "three", "Three", "3",
- Tk_Offset(FiveRecord, three), -1, 0, NULL, 0},
+ offsetof(FiveRecord, three), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_INT, "-four", "four", "Four", "4",
- Tk_Offset(FiveRecord, four), -1, 0, NULL, 0},
+ offsetof(FiveRecord, four), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_STRING, "-five", NULL, NULL, NULL,
- Tk_Offset(FiveRecord, five), -1, 0, NULL, 0},
+ offsetof(FiveRecord, five), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0}
};
@@ -1000,7 +978,7 @@ TestobjconfigObjCmd(
return TCL_ERROR;
}
- recordPtr = ckalloc(sizeof(FiveRecord));
+ recordPtr = (FiveRecord *)ckalloc(sizeof(FiveRecord));
recordPtr->header.interp = interp;
recordPtr->header.optionTable = Tk_CreateOptionTable(interp,
smallSpecs);
@@ -1009,18 +987,18 @@ TestobjconfigObjCmd(
recordPtr->one = recordPtr->two = recordPtr->three = NULL;
recordPtr->four = recordPtr->five = NULL;
Tcl_SetObjResult(interp, objv[2]);
- result = Tk_InitOptions(interp, (char *) recordPtr,
+ result = Tk_InitOptions(interp, recordPtr,
recordPtr->header.optionTable, (Tk_Window) NULL);
if (result == TCL_OK) {
- result = Tk_SetOptions(interp, (char *) recordPtr,
+ result = Tk_SetOptions(interp, recordPtr,
recordPtr->header.optionTable, objc - 3, objv + 3,
(Tk_Window) NULL, NULL, NULL);
if (result == TCL_OK) {
recordPtr->header.widgetCmd = Tcl_CreateObjCommand(interp,
Tcl_GetString(objv[2]), TrivialConfigObjCmd,
- (ClientData) recordPtr, TrivialCmdDeletedProc);
+ recordPtr, TrivialCmdDeletedProc);
} else {
- Tk_FreeConfigOptions((char *) recordPtr,
+ Tk_FreeConfigOptions(recordPtr,
recordPtr->header.optionTable, (Tk_Window) NULL);
}
}
@@ -1031,16 +1009,16 @@ TestobjconfigObjCmd(
break;
}
case NOT_ENOUGH_PARAMS: {
- typedef struct NotEnoughRecord {
+ typedef struct {
Tcl_Obj *fooObjPtr;
} NotEnoughRecord;
NotEnoughRecord record;
static const Tk_OptionSpec errorSpecs[] = {
{TK_OPTION_INT, "-foo", "foo", "Foo", "0",
- Tk_Offset(NotEnoughRecord, fooObjPtr), 0, 0, NULL, 0},
+ offsetof(NotEnoughRecord, fooObjPtr), 0, 0, NULL, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0}
};
- Tcl_Obj *newObjPtr = Tcl_NewStringObj("-foo", -1);
+ Tcl_Obj *newObjPtr = Tcl_NewStringObj("-foo", TCL_INDEX_NONE);
Tk_OptionTable optionTable;
record.fooObjPtr = NULL;
@@ -1049,8 +1027,8 @@ TestobjconfigObjCmd(
Tk_SetClass(tkwin, "Config");
optionTable = Tk_CreateOptionTable(interp, errorSpecs);
tables[index] = optionTable;
- Tk_InitOptions(interp, (char *) &record, optionTable, tkwin);
- if (Tk_SetOptions(interp, (char *) &record, optionTable, 1,
+ Tk_InitOptions(interp, &record, optionTable, tkwin);
+ if (Tk_SetOptions(interp, &record, optionTable, 1,
&newObjPtr, tkwin, NULL, NULL) != TCL_OK) {
result = TCL_ERROR;
}
@@ -1061,18 +1039,18 @@ TestobjconfigObjCmd(
}
case TWO_WINDOWS: {
- typedef struct ContentRecord {
+ typedef struct {
TrivialCommandHeader header;
Tcl_Obj *windowPtr;
} ContentRecord;
ContentRecord *recordPtr;
static const Tk_OptionSpec contentSpecs[] = {
{TK_OPTION_WINDOW, "-window", "window", "Window", ".bar",
- Tk_Offset(ContentRecord, windowPtr), -1, TK_CONFIG_NULL_OK, NULL, 0},
+ offsetof(ContentRecord, windowPtr), TCL_INDEX_NONE, TK_CONFIG_NULL_OK, NULL, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0}
};
tkwin = Tk_CreateWindowFromPath(interp,
- (Tk_Window) clientData, Tcl_GetString(objv[2]), NULL);
+ (Tk_Window)clientData, Tcl_GetString(objv[2]), NULL);
if (tkwin == NULL) {
return TCL_ERROR;
@@ -1087,10 +1065,10 @@ TestobjconfigObjCmd(
recordPtr->header.tkwin = tkwin;
recordPtr->windowPtr = NULL;
- result = Tk_InitOptions(interp, (char *) recordPtr,
+ result = Tk_InitOptions(interp, recordPtr,
recordPtr->header.optionTable, tkwin);
if (result == TCL_OK) {
- result = Tk_SetOptions(interp, (char *) recordPtr,
+ result = Tk_SetOptions(interp, recordPtr,
recordPtr->header.optionTable, objc - 3, objv + 3,
tkwin, NULL, NULL);
if (result == TCL_OK) {
@@ -1101,7 +1079,7 @@ TestobjconfigObjCmd(
TrivialEventProc, recordPtr);
Tcl_SetObjResult(interp, objv[2]);
} else {
- Tk_FreeConfigOptions((char *) recordPtr,
+ Tk_FreeConfigOptions(recordPtr,
recordPtr->header.optionTable, tkwin);
}
}
@@ -1134,7 +1112,7 @@ TestobjconfigObjCmd(
static int
TrivialConfigObjCmd(
- ClientData clientData, /* Main window for application. */
+ void *clientData, /* Main window for application. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -1148,12 +1126,12 @@ TrivialConfigObjCmd(
};
Tcl_Obj *resultObjPtr;
int index, mask;
- TrivialCommandHeader *headerPtr = (TrivialCommandHeader *) clientData;
+ TrivialCommandHeader *headerPtr = (TrivialCommandHeader *)clientData;
Tk_Window tkwin = headerPtr->tkwin;
Tk_SavedOptions saved;
if (objc < 2) {
- Tcl_WrongNumArgs(interp, 1, objv, "option ?arg arg...?");
+ Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?");
return TCL_ERROR;
}
@@ -1171,7 +1149,7 @@ TrivialConfigObjCmd(
result = TCL_ERROR;
goto done;
}
- resultObjPtr = Tk_GetOptionValue(interp, (char *) clientData,
+ resultObjPtr = Tk_GetOptionValue(interp, clientData,
headerPtr->optionTable, objv[2], tkwin);
if (resultObjPtr != NULL) {
Tcl_SetObjResult(interp, resultObjPtr);
@@ -1182,7 +1160,7 @@ TrivialConfigObjCmd(
break;
case CONFIGURE:
if (objc == 2) {
- resultObjPtr = Tk_GetOptionInfo(interp, (char *) clientData,
+ resultObjPtr = Tk_GetOptionInfo(interp, clientData,
headerPtr->optionTable, NULL, tkwin);
if (resultObjPtr == NULL) {
result = TCL_ERROR;
@@ -1190,7 +1168,7 @@ TrivialConfigObjCmd(
Tcl_SetObjResult(interp, resultObjPtr);
}
} else if (objc == 3) {
- resultObjPtr = Tk_GetOptionInfo(interp, (char *) clientData,
+ resultObjPtr = Tk_GetOptionInfo(interp, clientData,
headerPtr->optionTable, objv[2], tkwin);
if (resultObjPtr == NULL) {
result = TCL_ERROR;
@@ -1198,21 +1176,21 @@ TrivialConfigObjCmd(
Tcl_SetObjResult(interp, resultObjPtr);
}
} else {
- result = Tk_SetOptions(interp, (char *) clientData,
+ result = Tk_SetOptions(interp, clientData,
headerPtr->optionTable, objc - 2, objv + 2,
tkwin, NULL, &mask);
if (result == TCL_OK) {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(mask));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(mask));
}
}
break;
case CSAVE:
- result = Tk_SetOptions(interp, (char *) clientData,
+ result = Tk_SetOptions(interp, clientData,
headerPtr->optionTable, objc - 2, objv + 2,
tkwin, &saved, &mask);
Tk_FreeSavedOptions(&saved);
if (result == TCL_OK) {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(mask));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(mask));
}
break;
}
@@ -1241,7 +1219,7 @@ TrivialConfigObjCmd(
static void
TrivialCmdDeletedProc(
- ClientData clientData) /* Pointer to widget record for widget. */
+ void *clientData) /* Pointer to widget record for widget. */
{
TrivialCommandHeader *headerPtr = (TrivialCommandHeader *)clientData;
Tk_Window tkwin = headerPtr->tkwin;
@@ -1255,7 +1233,7 @@ TrivialCmdDeletedProc(
* here.
*/
- Tk_FreeConfigOptions((char *)clientData,
+ Tk_FreeConfigOptions(clientData,
headerPtr->optionTable, NULL);
Tcl_EventuallyFree(clientData, TCL_DYNAMIC);
}
@@ -1279,14 +1257,14 @@ TrivialCmdDeletedProc(
static void
TrivialEventProc(
- ClientData clientData, /* Information about window. */
+ void *clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
TrivialCommandHeader *headerPtr = (TrivialCommandHeader *)clientData;
if (eventPtr->type == DestroyNotify) {
if (headerPtr->tkwin != NULL) {
- Tk_FreeConfigOptions((char *)clientData,
+ Tk_FreeConfigOptions(clientData,
headerPtr->optionTable, headerPtr->tkwin);
headerPtr->optionTable = NULL;
headerPtr->tkwin = NULL;
@@ -1316,7 +1294,7 @@ TrivialEventProc(
static int
TestfontObjCmd(
- ClientData clientData, /* Main window for application. */
+ void *clientData, /* Main window for application. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -1378,29 +1356,29 @@ ImageCreate(
Tcl_Interp *interp, /* Interpreter for application containing
* image. */
const char *name, /* Name to use for image. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[], /* Argument strings for options (doesn't
* include image name or type). */
TCL_UNUSED(const Tk_ImageType *), /* Pointer to our type record (not used). */
Tk_ImageModel model, /* Token for image, to be used by us in later
* callbacks. */
- ClientData *clientDataPtr) /* Store manager's token for image here; it
+ void **clientDataPtr) /* Store manager's token for image here; it
* will be returned in later callbacks. */
{
TImageModel *timPtr;
const char *varName;
- int i;
+ Tcl_Size i;
varName = "log";
for (i = 0; i < objc; i += 2) {
if (strcmp(Tcl_GetString(objv[i]), "-variable") != 0) {
Tcl_AppendResult(interp, "bad option name \"",
- Tcl_GetString(objv[i]), "\"", NULL);
+ Tcl_GetString(objv[i]), "\"", (char *)NULL);
return TCL_ERROR;
}
if ((i+1) == objc) {
Tcl_AppendResult(interp, "no value given for \"",
- Tcl_GetString(objv[i]), "\" option", NULL);
+ Tcl_GetString(objv[i]), "\" option", (char *)NULL);
return TCL_ERROR;
}
varName = Tcl_GetString(objv[i+1]);
@@ -1440,7 +1418,7 @@ ImageCreate(
static int
ImageObjCmd(
- ClientData clientData, /* Main window for application. */
+ void *clientData, /* Main window for application. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
@@ -1494,11 +1472,11 @@ ImageObjCmd(
*----------------------------------------------------------------------
*/
-static ClientData
+static void *
ImageGet(
Tk_Window tkwin, /* Token for window in which image will be
* used. */
- ClientData clientData) /* Pointer to TImageModel for image. */
+ void *clientData) /* Pointer to TImageModel for image. */
{
TImageModel *timPtr = (TImageModel *)clientData;
TImageInstance *instPtr;
@@ -1538,7 +1516,7 @@ ImageGet(
static void
ImageDisplay(
- ClientData clientData, /* Pointer to TImageInstance for image. */
+ void *clientData, /* Pointer to TImageInstance for image. */
Display *display, /* Display to use for drawing. */
Drawable drawable, /* Where to redraw image. */
int imageX, int imageY, /* Origin of area to redraw, relative to
@@ -1629,7 +1607,7 @@ ImageDisplay(
static void
ImageFree(
- ClientData clientData, /* Pointer to TImageInstance for instance. */
+ void *clientData, /* Pointer to TImageInstance for instance. */
Display *display) /* Display where image was to be drawn. */
{
TImageInstance *instPtr = (TImageInstance *)clientData;
@@ -1662,7 +1640,7 @@ ImageFree(
static void
ImageDelete(
- ClientData clientData) /* Pointer to TImageModel for image. When
+ void *clientData) /* Pointer to TImageModel for image. When
* this function is called, no more instances
* exist. */
{
@@ -1699,7 +1677,7 @@ ImageDelete(
static int
TestmakeexistObjCmd(
- ClientData clientData, /* Main window for application. */
+ void *clientData, /* Main window for application. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
@@ -1740,7 +1718,7 @@ TestmakeexistObjCmd(
#if !(defined(_WIN32) || defined(MAC_OSX_TK) || defined(__CYGWIN__))
static int
TestmenubarObjCmd(
- ClientData clientData, /* Main window for application. */
+ void *clientData, /* Main window for application. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
@@ -1853,7 +1831,7 @@ TestmetricsObjCmd(
static int
TestpropObjCmd(
- ClientData clientData, /* Main window for application. */
+ void *clientData, /* Main window for application. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
@@ -1886,7 +1864,7 @@ TestpropObjCmd(
*p = '\n';
}
}
- Tcl_SetObjResult(interp, Tcl_NewStringObj((/*!unsigned*/char*)property, -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj((/*!unsigned*/char*)property, TCL_INDEX_NONE));
} else {
for (p = property; length > 0; length--) {
if (actualFormat == 32) {
@@ -1910,6 +1888,55 @@ TestpropObjCmd(
return TCL_OK;
}
+/*
+ *----------------------------------------------------------------------
+ *
+ * TestpropObjCmd --
+ *
+ * This function implements the "testprop" command. It fetches and prints
+ * the value of a property on a window.
+ *
+ * Results:
+ * A standard Tcl result.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+TestprintfObjCmd(
+ TCL_UNUSED(void *), /* Not used */
+ Tcl_Interp *interp, /* Current interpreter. */
+ int objc, /* Number of arguments. */
+ Tcl_Obj *const objv[]) /* Argument strings. */
+{
+ char buffer[256];
+ Tcl_WideInt wideInt;
+ long long longLongInt;
+
+ if (objc != 2) {
+ Tcl_WrongNumArgs(interp, 1, objv, "wideint");
+ return TCL_ERROR;
+ }
+ if (Tcl_GetWideIntFromObj(interp, objv[1], &wideInt) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ longLongInt = wideInt;
+
+ /* Just add a lot of arguments to snprintf. Reason: on AMD64, the first
+ * 4 or 6 arguments (we assume 8, just in case) might be put in registers,
+ * which still woudn't tell if the assumed size is correct: We want this
+ * test-case to fail if the 64-bit value is printed as truncated to 32-bit.
+ */
+ snprintf(buffer, sizeof(buffer), "%s%s%s%s%s%s%s%s%" TCL_LL_MODIFIER "d %"
+ TCL_LL_MODIFIER "u", "", "", "", "", "", "", "", "",
+ longLongInt, (unsigned long long)longLongInt);
+ Tcl_AppendResult(interp, buffer, NULL);
+ return TCL_OK;
+}
+
#if !(defined(_WIN32) || defined(MAC_OSX_TK) || defined(__CYGWIN__))
/*
*----------------------------------------------------------------------
@@ -1931,7 +1958,7 @@ TestpropObjCmd(
static int
TestwrapperObjCmd(
- ClientData clientData, /* Main window for application. */
+ void *clientData, /* Main window for application. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
@@ -1955,7 +1982,7 @@ TestwrapperObjCmd(
char buf[TCL_INTEGER_SPACE];
TkpPrintWindowId(buf, Tk_WindowId(wrapperPtr));
- Tcl_SetObjResult(interp, Tcl_NewStringObj(buf, -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(buf, TCL_INDEX_NONE));
}
return TCL_OK;
}
@@ -1993,7 +2020,7 @@ CustomOptionSet(
TCL_UNUSED(Tk_Window),
Tcl_Obj **value,
char *recordPtr,
- int internalOffset,
+ Tcl_Size internalOffset,
char *saveInternalPtr,
int flags)
{
@@ -2002,7 +2029,7 @@ CustomOptionSet(
objEmpty = 0;
- if (internalOffset >= 0) {
+ if (internalOffset != TCL_INDEX_NONE) {
internalPtr = recordPtr + internalOffset;
} else {
internalPtr = NULL;
@@ -2028,7 +2055,7 @@ CustomOptionSet(
string = Tcl_GetString(*value);
Tcl_UtfToUpper(string);
if (strcmp(string, "BAD") == 0) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj("expected good value, got \"BAD\"", -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("expected good value, got \"BAD\"", TCL_INDEX_NONE));
return TCL_ERROR;
}
}
@@ -2052,15 +2079,15 @@ CustomOptionGet(
TCL_UNUSED(void *),
TCL_UNUSED(Tk_Window),
char *recordPtr,
- int internalOffset)
+ Tcl_Size internalOffset)
{
- return (Tcl_NewStringObj(*(char **)(recordPtr + internalOffset), -1));
+ return (Tcl_NewStringObj(*(char **)(recordPtr + internalOffset), TCL_INDEX_NONE));
}
static void
CustomOptionRestore(
- ClientData clientData,
- Tk_Window tkwin,
+ TCL_UNUSED(void *),
+ TCL_UNUSED(Tk_Window),
char *internalPtr,
char *saveInternalPtr)
{
@@ -2070,14 +2097,61 @@ CustomOptionRestore(
static void
CustomOptionFree(
- ClientData clientData,
- Tk_Window tkwin,
+ TCL_UNUSED(void *),
+ TCL_UNUSED(Tk_Window),
char *internalPtr)
{
if (*(char **)internalPtr != NULL) {
ckfree(*(char **)internalPtr);
}
}
+/*
+ *----------------------------------------------------------------------
+ *
+ * TestPhotoStringMatchCmd --
+ *
+ * This function implements the "testphotostringmatch" command. It
+ * provides a way from Tcl to call the string match function for the
+ * default image handler directly.
+ *
+ * Results:
+ * A standard Tcl result. If data is in the proper format, the result in
+ * interp will contain width and height as a list. If the data cannot be
+ * parsed as default image format, returns TCL_ERROR and leaves an
+ * appropriate error message in interp.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+TestPhotoStringMatchCmd(
+ TCL_UNUSED(void *), /* Main window for application. */
+ Tcl_Interp *interp, /* Current interpreter. */
+ int objc, /* Number of arguments. */
+ Tcl_Obj *const objv[]) /* Argument strings. */
+{
+ Tcl_Obj *dummy = NULL;
+ Tcl_Obj *resultObj[2];
+ int width, height;
+
+ if (objc != 2) {
+ Tcl_WrongNumArgs(interp, 1, objv, "imageData");
+ return TCL_ERROR;
+ }
+ if (TkDebugPhotoStringMatchDef(interp, objv[1], dummy, &width, &height)) {
+ resultObj[0] = Tcl_NewWideIntObj(width);
+ resultObj[1] = Tcl_NewWideIntObj(height);
+ Tcl_SetObjResult(interp, Tcl_NewListObj(2, resultObj));
+ return TCL_OK;
+ } else {
+ return TCL_ERROR;
+ }
+}
+
+
/*
* Local Variables:
diff --git a/generic/tkText.c b/generic/tkText.c
index 013874b..f792c9c 100644
--- a/generic/tkText.c
+++ b/generic/tkText.c
@@ -6,9 +6,9 @@
* command interfaces to text widgets. The B-tree representation of text
* and its actual display are implemented elsewhere.
*
- * Copyright (c) 1992-1994 The Regents of the University of California.
- * Copyright (c) 1994-1996 Sun Microsystems, Inc.
- * Copyright (c) 1999 Scriptics Corporation.
+ * Copyright © 1992-1994 The Regents of the University of California.
+ * Copyright © 1994-1996 Sun Microsystems, Inc.
+ * Copyright © 1999 Scriptics Corporation.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -23,6 +23,10 @@
#define DInfo TkDInfo
#endif
+#ifdef _WIN32
+#include "tkWinInt.h"
+#endif
+
/*
* For compatibility with Tk 4.0 through 8.4.x, we allow tabs to be
* mis-specified with non-increasing values. These are converted into tabs
@@ -48,7 +52,7 @@
* table below.
*/
-static const char *const wrapStrings[] = {
+const char *const tkTextWrapStrings[] = {
"char", "none", "word", NULL
};
@@ -58,7 +62,7 @@ static const char *const wrapStrings[] = {
* the string table below.
*/
-static const char *const tabStyleStrings[] = {
+const char *const tkTextTabStyleStrings[] = {
"tabular", "wordprocessor", NULL
};
@@ -83,15 +87,15 @@ static const char *const insertUnfocussedStrings[] = {
* freeing.
*/
-static int SetLineStartEnd(ClientData clientData,
+static int SetLineStartEnd(void *clientData,
Tcl_Interp *interp, Tk_Window tkwin,
Tcl_Obj **value, char *recordPtr,
- int internalOffset, char *oldInternalPtr,
+ Tcl_Size internalOffset, char *oldInternalPtr,
int flags);
-static Tcl_Obj * GetLineStartEnd(ClientData clientData,
+static Tcl_Obj * GetLineStartEnd(void *clientData,
Tk_Window tkwin, char *recordPtr,
- int internalOffset);
-static void RestoreLineStartEnd(ClientData clientData,
+ Tcl_Size internalOffset);
+static void RestoreLineStartEnd(void *clientData,
Tk_Window tkwin, char *internalPtr,
char *oldInternalPtr);
static int ObjectIsEmpty(Tcl_Obj *objPtr);
@@ -111,139 +115,139 @@ static const Tk_ObjCustomOption lineOption = {
static const Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_BOOLEAN, "-autoseparators", "autoSeparators",
- "AutoSeparators", DEF_TEXT_AUTO_SEPARATORS, -1,
- Tk_Offset(TkText, autoSeparators),
+ "AutoSeparators", DEF_TEXT_AUTO_SEPARATORS, TCL_INDEX_NONE,
+ offsetof(TkText, autoSeparators),
TK_OPTION_DONT_SET_DEFAULT, 0, 0},
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_TEXT_BG_COLOR, -1, Tk_Offset(TkText, border),
+ DEF_TEXT_BG_COLOR, TCL_INDEX_NONE, offsetof(TkText, border),
0, DEF_TEXT_BG_MONO, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth",
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth",
TK_TEXT_LINE_GEOMETRY},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL,
- NULL, 0, -1, 0, "-background", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_BOOLEAN, "-blockcursor", "blockCursor",
- "BlockCursor", DEF_TEXT_BLOCK_CURSOR, -1,
- Tk_Offset(TkText, insertCursorType), 0, 0, 0},
+ "BlockCursor", DEF_TEXT_BLOCK_CURSOR, TCL_INDEX_NONE,
+ offsetof(TkText, insertCursorType), 0, 0, 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_TEXT_BORDER_WIDTH, -1, Tk_Offset(TkText, borderWidth),
+ DEF_TEXT_BORDER_WIDTH, TCL_INDEX_NONE, offsetof(TkText, borderWidth),
0, 0, TK_TEXT_LINE_GEOMETRY},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_TEXT_CURSOR, -1, Tk_Offset(TkText, cursor),
+ DEF_TEXT_CURSOR, TCL_INDEX_NONE, offsetof(TkText, cursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_CUSTOM, "-endline", NULL, NULL,
- NULL, -1, Tk_Offset(TkText, end), TK_OPTION_NULL_OK,
+ NULL, TCL_INDEX_NONE, offsetof(TkText, end), TK_OPTION_NULL_OK,
&lineOption, TK_TEXT_LINE_RANGE},
{TK_OPTION_BOOLEAN, "-exportselection", "exportSelection",
- "ExportSelection", DEF_TEXT_EXPORT_SELECTION, -1,
- Tk_Offset(TkText, exportSelection), 0, 0, 0},
+ "ExportSelection", DEF_TEXT_EXPORT_SELECTION, TCL_INDEX_NONE,
+ offsetof(TkText, exportSelection), 0, 0, 0},
{TK_OPTION_SYNONYM, "-fg", "foreground", NULL,
- NULL, 0, -1, 0, "-foreground", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_TEXT_FONT, -1, Tk_Offset(TkText, tkfont), 0, 0,
+ DEF_TEXT_FONT, TCL_INDEX_NONE, offsetof(TkText, tkfont), 0, 0,
TK_TEXT_LINE_GEOMETRY},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_TEXT_FG, -1, Tk_Offset(TkText, fgColor), 0,
+ DEF_TEXT_FG, TCL_INDEX_NONE, offsetof(TkText, fgColor), 0,
0, 0},
{TK_OPTION_PIXELS, "-height", "height", "Height",
- DEF_TEXT_HEIGHT, -1, Tk_Offset(TkText, height), 0, 0, 0},
+ DEF_TEXT_HEIGHT, TCL_INDEX_NONE, offsetof(TkText, height), 0, 0, 0},
{TK_OPTION_COLOR, "-highlightbackground", "highlightBackground",
"HighlightBackground", DEF_TEXT_HIGHLIGHT_BG,
- -1, Tk_Offset(TkText, highlightBgColorPtr),
+ TCL_INDEX_NONE, offsetof(TkText, highlightBgColorPtr),
0, 0, 0},
{TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_TEXT_HIGHLIGHT, -1, Tk_Offset(TkText, highlightColorPtr),
+ DEF_TEXT_HIGHLIGHT, TCL_INDEX_NONE, offsetof(TkText, highlightColorPtr),
0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
- "HighlightThickness", DEF_TEXT_HIGHLIGHT_WIDTH, -1,
- Tk_Offset(TkText, highlightWidth), 0, 0, TK_TEXT_LINE_GEOMETRY},
+ "HighlightThickness", DEF_TEXT_HIGHLIGHT_WIDTH, TCL_INDEX_NONE,
+ offsetof(TkText, highlightWidth), 0, 0, TK_TEXT_LINE_GEOMETRY},
{TK_OPTION_BORDER, "-inactiveselectbackground","inactiveSelectBackground",
"Foreground",
DEF_TEXT_INACTIVE_SELECT_COLOR,
- -1, Tk_Offset(TkText, inactiveSelBorder),
+ TCL_INDEX_NONE, offsetof(TkText, inactiveSelBorder),
TK_OPTION_NULL_OK, DEF_TEXT_SELECT_MONO, 0},
{TK_OPTION_BORDER, "-insertbackground", "insertBackground", "Foreground",
DEF_TEXT_INSERT_BG,
- -1, Tk_Offset(TkText, insertBorder),
+ TCL_INDEX_NONE, offsetof(TkText, insertBorder),
0, 0, 0},
{TK_OPTION_PIXELS, "-insertborderwidth", "insertBorderWidth",
- "BorderWidth", DEF_TEXT_INSERT_BD_COLOR, -1,
- Tk_Offset(TkText, insertBorderWidth), 0,
- (ClientData) DEF_TEXT_INSERT_BD_MONO, 0},
+ "BorderWidth", DEF_TEXT_INSERT_BD_COLOR, TCL_INDEX_NONE,
+ offsetof(TkText, insertBorderWidth), 0,
+ DEF_TEXT_INSERT_BD_MONO, 0},
{TK_OPTION_INT, "-insertofftime", "insertOffTime", "OffTime",
- DEF_TEXT_INSERT_OFF_TIME, -1, Tk_Offset(TkText, insertOffTime),
+ DEF_TEXT_INSERT_OFF_TIME, TCL_INDEX_NONE, offsetof(TkText, insertOffTime),
0, 0, 0},
{TK_OPTION_INT, "-insertontime", "insertOnTime", "OnTime",
- DEF_TEXT_INSERT_ON_TIME, -1, Tk_Offset(TkText, insertOnTime),
+ DEF_TEXT_INSERT_ON_TIME, TCL_INDEX_NONE, offsetof(TkText, insertOnTime),
0, 0, 0},
{TK_OPTION_STRING_TABLE,
"-insertunfocussed", "insertUnfocussed", "InsertUnfocussed",
- DEF_TEXT_INSERT_UNFOCUSSED, -1, Tk_Offset(TkText, insertUnfocussed),
+ DEF_TEXT_INSERT_UNFOCUSSED, TCL_INDEX_NONE, offsetof(TkText, insertUnfocussed),
TK_OPTION_ENUM_VAR, insertUnfocussedStrings, 0},
{TK_OPTION_PIXELS, "-insertwidth", "insertWidth", "InsertWidth",
- DEF_TEXT_INSERT_WIDTH, -1, Tk_Offset(TkText, insertWidth),
+ DEF_TEXT_INSERT_WIDTH, TCL_INDEX_NONE, offsetof(TkText, insertWidth),
0, 0, 0},
{TK_OPTION_INT, "-maxundo", "maxUndo", "MaxUndo",
- DEF_TEXT_MAX_UNDO, -1, Tk_Offset(TkText, maxUndo),
+ DEF_TEXT_MAX_UNDO, TCL_INDEX_NONE, offsetof(TkText, maxUndo),
TK_OPTION_DONT_SET_DEFAULT, 0, 0},
{TK_OPTION_PIXELS, "-padx", "padX", "Pad",
- DEF_TEXT_PADX, -1, Tk_Offset(TkText, padX), 0, 0,
+ DEF_TEXT_PADX, TCL_INDEX_NONE, offsetof(TkText, padX), 0, 0,
TK_TEXT_LINE_GEOMETRY},
{TK_OPTION_PIXELS, "-pady", "padY", "Pad",
- DEF_TEXT_PADY, -1, Tk_Offset(TkText, padY), 0, 0, 0},
+ DEF_TEXT_PADY, TCL_INDEX_NONE, offsetof(TkText, padY), 0, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_TEXT_RELIEF, -1, Tk_Offset(TkText, relief), 0, 0, 0},
+ DEF_TEXT_RELIEF, TCL_INDEX_NONE, offsetof(TkText, relief), 0, 0, 0},
{TK_OPTION_BORDER, "-selectbackground", "selectBackground", "Foreground",
- DEF_TEXT_SELECT_COLOR, -1, Tk_Offset(TkText, selBorder),
+ DEF_TEXT_SELECT_COLOR, TCL_INDEX_NONE, offsetof(TkText, selBorder),
0, DEF_TEXT_SELECT_MONO, 0},
{TK_OPTION_PIXELS, "-selectborderwidth", "selectBorderWidth",
"BorderWidth", DEF_TEXT_SELECT_BD_COLOR,
- Tk_Offset(TkText, selBorderWidthPtr),
- Tk_Offset(TkText, selBorderWidth),
+ offsetof(TkText, selBorderWidthPtr),
+ offsetof(TkText, selBorderWidth),
TK_OPTION_NULL_OK, DEF_TEXT_SELECT_BD_MONO, 0},
{TK_OPTION_COLOR, "-selectforeground", "selectForeground", "Background",
- DEF_TEXT_SELECT_FG_COLOR, -1, Tk_Offset(TkText, selFgColorPtr),
+ DEF_TEXT_SELECT_FG_COLOR, TCL_INDEX_NONE, offsetof(TkText, selFgColorPtr),
TK_OPTION_NULL_OK, DEF_TEXT_SELECT_FG_MONO, 0},
{TK_OPTION_BOOLEAN, "-setgrid", "setGrid", "SetGrid",
- DEF_TEXT_SET_GRID, -1, Tk_Offset(TkText, setGrid), 0, 0, 0},
+ DEF_TEXT_SET_GRID, TCL_INDEX_NONE, offsetof(TkText, setGrid), 0, 0, 0},
{TK_OPTION_PIXELS, "-spacing1", "spacing1", "Spacing",
- DEF_TEXT_SPACING1, -1, Tk_Offset(TkText, spacing1),
+ DEF_TEXT_SPACING1, TCL_INDEX_NONE, offsetof(TkText, spacing1),
0, 0 , TK_TEXT_LINE_GEOMETRY },
{TK_OPTION_PIXELS, "-spacing2", "spacing2", "Spacing",
- DEF_TEXT_SPACING2, -1, Tk_Offset(TkText, spacing2),
+ DEF_TEXT_SPACING2, TCL_INDEX_NONE, offsetof(TkText, spacing2),
0, 0 , TK_TEXT_LINE_GEOMETRY },
{TK_OPTION_PIXELS, "-spacing3", "spacing3", "Spacing",
- DEF_TEXT_SPACING3, -1, Tk_Offset(TkText, spacing3),
+ DEF_TEXT_SPACING3, TCL_INDEX_NONE, offsetof(TkText, spacing3),
0, 0 , TK_TEXT_LINE_GEOMETRY },
{TK_OPTION_CUSTOM, "-startline", NULL, NULL,
- NULL, -1, Tk_Offset(TkText, start), TK_OPTION_NULL_OK,
+ NULL, TCL_INDEX_NONE, offsetof(TkText, start), TK_OPTION_NULL_OK,
&lineOption, TK_TEXT_LINE_RANGE},
{TK_OPTION_STRING_TABLE, "-state", "state", "State",
- DEF_TEXT_STATE, -1, Tk_Offset(TkText, state),
- 0, &tkStateStrings[1], 0},
+ DEF_TEXT_STATE, TCL_INDEX_NONE, offsetof(TkText, state),
+ TK_OPTION_ENUM_VAR, &tkStateStrings[1], 0},
{TK_OPTION_STRING, "-tabs", "tabs", "Tabs",
- DEF_TEXT_TABS, Tk_Offset(TkText, tabOptionPtr), -1,
+ DEF_TEXT_TABS, offsetof(TkText, tabOptionPtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, TK_TEXT_LINE_GEOMETRY},
{TK_OPTION_STRING_TABLE, "-tabstyle", "tabStyle", "TabStyle",
- DEF_TEXT_TABSTYLE, -1, Tk_Offset(TkText, tabStyle),
- 0, tabStyleStrings, TK_TEXT_LINE_GEOMETRY},
+ DEF_TEXT_TABSTYLE, TCL_INDEX_NONE, offsetof(TkText, tabStyle),
+ TK_OPTION_ENUM_VAR, tkTextTabStyleStrings, TK_TEXT_LINE_GEOMETRY},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_TEXT_TAKE_FOCUS, -1, Tk_Offset(TkText, takeFocus),
+ DEF_TEXT_TAKE_FOCUS, TCL_INDEX_NONE, offsetof(TkText, takeFocus),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_BOOLEAN, "-undo", "undo", "Undo",
- DEF_TEXT_UNDO, -1, Tk_Offset(TkText, undo),
+ DEF_TEXT_UNDO, TCL_INDEX_NONE, offsetof(TkText, undo),
TK_OPTION_DONT_SET_DEFAULT, 0 , 0},
{TK_OPTION_INT, "-width", "width", "Width",
- DEF_TEXT_WIDTH, -1, Tk_Offset(TkText, width), 0, 0,
+ DEF_TEXT_WIDTH, TCL_INDEX_NONE, offsetof(TkText, width), 0, 0,
TK_TEXT_LINE_GEOMETRY},
{TK_OPTION_STRING_TABLE, "-wrap", "wrap", "Wrap",
- DEF_TEXT_WRAP, -1, Tk_Offset(TkText, wrapMode),
- TK_OPTION_ENUM_VAR, wrapStrings, TK_TEXT_LINE_GEOMETRY},
+ DEF_TEXT_WRAP, TCL_INDEX_NONE, offsetof(TkText, wrapMode),
+ TK_OPTION_ENUM_VAR, tkTextWrapStrings, TK_TEXT_LINE_GEOMETRY},
{TK_OPTION_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand",
- DEF_TEXT_XSCROLL_COMMAND, -1, Tk_Offset(TkText, xScrollCmd),
+ DEF_TEXT_XSCROLL_COMMAND, TCL_INDEX_NONE, offsetof(TkText, xScrollCmd),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-yscrollcommand", "yScrollCommand", "ScrollCommand",
- DEF_TEXT_YSCROLL_COMMAND, -1, Tk_Offset(TkText, yScrollCmd),
+ DEF_TEXT_YSCROLL_COMMAND, TCL_INDEX_NONE, offsetof(TkText, yScrollCmd),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_END, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0}
};
@@ -262,17 +266,17 @@ static const Tk_OptionSpec optionSpecs[] = {
struct SearchSpec; /* Forward declaration. */
-typedef ClientData SearchAddLineProc(int lineNum,
+typedef void *SearchAddLineProc(int lineNum,
struct SearchSpec *searchSpecPtr,
Tcl_Obj *theLine, int *lenPtr,
int *extraLinesPtr);
typedef int SearchMatchProc(int lineNum,
struct SearchSpec *searchSpecPtr,
- ClientData clientData, Tcl_Obj *theLine,
- int matchOffset, int matchLength);
+ void *clientData, Tcl_Obj *theLine,
+ Tcl_Size matchOffset, Tcl_Size matchLength);
typedef int SearchLineIndexProc(Tcl_Interp *interp,
Tcl_Obj *objPtr, struct SearchSpec *searchSpecPtr,
- int *linePosPtr, int *offsetPosPtr);
+ int *linePosPtr, Tcl_Size *offsetPosPtr);
typedef struct SearchSpec {
int exact; /* Whether search is exact or regexp. */
@@ -288,10 +292,10 @@ typedef struct SearchSpec {
int all; /* Whether all or the first match should be
* reported. */
int startLine; /* First line to examine. */
- int startOffset; /* Index in first line to start at. */
+ Tcl_Size startOffset; /* Index in first line to start at. */
int stopLine; /* Last line to examine, or -1 when we search
* all available text. */
- int stopOffset; /* Index to stop at, provided stopLine is not
+ Tcl_Size stopOffset; /* Index to stop at, provided stopLine is not
* -1. */
int numLines; /* Total lines which are available. */
int backwards; /* Searching forwards or backwards. */
@@ -309,7 +313,7 @@ typedef struct SearchSpec {
SearchLineIndexProc *lineIndexProc;
/* Function to call when we have found a
* match. */
- ClientData clientData; /* Information about structure being searched,
+ void *clientData; /* Information about structure being searched,
* in this case a text widget. */
} SearchSpec;
@@ -336,7 +340,7 @@ int tkTextDebug = 0;
*/
static int ConfigureText(Tcl_Interp *interp,
- TkText *textPtr, int objc, Tcl_Obj *const objv[]);
+ TkText *textPtr, Tcl_Size objc, Tcl_Obj *const objv[]);
static int DeleteIndexRange(TkSharedText *sharedPtr,
TkText *textPtr, const TkTextIndex *indexPtr1,
const TkTextIndex *indexPtr2, int viewUpdate);
@@ -348,39 +352,35 @@ static void DestroyText(TkText *textPtr);
static int InsertChars(TkSharedText *sharedTextPtr,
TkText *textPtr, TkTextIndex *indexPtr,
Tcl_Obj *stringPtr, int viewUpdate);
-static void TextBlinkProc(ClientData clientData);
-static void TextCmdDeletedProc(ClientData clientData);
+static void TextBlinkProc(void *clientData);
+static Tcl_CmdDeleteProc TextCmdDeletedProc;
static int CreateWidget(TkSharedText *sharedPtr, Tk_Window tkwin,
Tcl_Interp *interp, const TkText *parent,
- int objc, Tcl_Obj *const objv[]);
-static void TextEventProc(ClientData clientData,
+ Tcl_Size objc, Tcl_Obj *const objv[]);
+static void TextEventProc(void *clientData,
XEvent *eventPtr);
-static int TextFetchSelection(ClientData clientData, int offset,
- char *buffer, int maxBytes);
+static Tcl_Size TextFetchSelection(void *clientData, Tcl_Size offset,
+ char *buffer, Tcl_Size maxBytes);
static int TextIndexSortProc(const void *first,
const void *second);
static int TextInsertCmd(TkSharedText *sharedTextPtr,
TkText *textPtr, Tcl_Interp *interp,
- int objc, Tcl_Obj *const objv[],
+ Tcl_Size objc, Tcl_Obj *const objv[],
const TkTextIndex *indexPtr, int viewUpdate);
static int TextReplaceCmd(TkText *textPtr, Tcl_Interp *interp,
const TkTextIndex *indexFromPtr,
const TkTextIndex *indexToPtr,
- int objc, Tcl_Obj *const objv[], int viewUpdate);
+ Tcl_Size objc, Tcl_Obj *const objv[], int viewUpdate);
static int TextSearchCmd(TkText *textPtr, Tcl_Interp *interp,
- int objc, Tcl_Obj *const objv[]);
+ Tcl_Size objc, Tcl_Obj *const objv[]);
static int TextEditCmd(TkText *textPtr, Tcl_Interp *interp,
- int objc, Tcl_Obj *const objv[]);
-static int TextWidgetObjCmd(ClientData clientData,
- Tcl_Interp *interp,
- int objc, Tcl_Obj *const objv[]);
-static int SharedTextObjCmd(ClientData clientData,
- Tcl_Interp *interp,
- int objc, Tcl_Obj *const objv[]);
-static void TextWorldChangedCallback(ClientData instanceData);
+ Tcl_Size objc, Tcl_Obj *const objv[]);
+static Tcl_ObjCmdProc TextWidgetObjCmd;
+static Tcl_ObjCmdProc2 SharedTextObjCmd;
+static void TextWorldChangedCallback(void *instanceData);
static void TextWorldChanged(TkText *textPtr, int mask);
static int TextDumpCmd(TkText *textPtr, Tcl_Interp *interp,
- int objc, Tcl_Obj *const objv[]);
+ Tcl_Size objc, Tcl_Obj *const objv[]);
static int DumpLine(Tcl_Interp *interp, TkText *textPtr,
int what, TkTextLine *linePtr, int start, int end,
int lineno, Tcl_Obj *command);
@@ -400,10 +400,10 @@ static void TextPushUndoAction(TkText *textPtr,
Tcl_Obj *undoString, int insert,
const TkTextIndex *index1Ptr,
const TkTextIndex *index2Ptr);
-static int TextSearchIndexInLine(const SearchSpec *searchSpecPtr,
- TkTextLine *linePtr, int byteIndex);
+static Tcl_Size TextSearchIndexInLine(const SearchSpec *searchSpecPtr,
+ TkTextLine *linePtr, Tcl_Size byteIndex);
static int TextPeerCmd(TkText *textPtr, Tcl_Interp *interp,
- int objc, Tcl_Obj *const objv[]);
+ Tcl_Size objc, Tcl_Obj *const objv[]);
static TkUndoProc TextUndoRedoCallback;
/*
@@ -446,7 +446,7 @@ static const Tk_ClassProcs textClass = {
int
Tk_TextObjCmd(
- ClientData clientData, /* Main window associated with interpreter. */
+ void *clientData, /* Main window associated with interpreter. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -489,7 +489,7 @@ CreateWidget(
Tcl_Interp *interp, /* Current interpreter. */
const TkText *parent, /* If non-NULL then take default start, end
* from this parent. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
TkText *textPtr;
@@ -651,7 +651,7 @@ CreateWidget(
Tk_CreateSelHandler(textPtr->tkwin, XA_PRIMARY, XA_STRING,
TextFetchSelection, textPtr, XA_STRING);
- if (Tk_InitOptions(interp, (char *) textPtr, optionTable, textPtr->tkwin)
+ if (Tk_InitOptions(interp, textPtr, optionTable, textPtr->tkwin)
!= TCL_OK) {
Tk_DestroyWindow(textPtr->tkwin);
return TCL_ERROR;
@@ -661,7 +661,7 @@ CreateWidget(
return TCL_ERROR;
}
- Tcl_SetObjResult(interp, TkNewWindowObj(textPtr->tkwin));
+ Tcl_SetObjResult(interp, Tk_NewWindowObj(textPtr->tkwin));
return TCL_OK;
}
@@ -685,7 +685,7 @@ CreateWidget(
static int
TextWidgetObjCmd(
- ClientData clientData, /* Information about text widget. */
+ void *clientData, /* Information about text widget. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -739,10 +739,10 @@ TextWidgetObjCmd(
NULL) == 0) {
Tcl_Obj *listObj = Tcl_NewListObj(0, NULL);
- Tcl_ListObjAppendElement(interp, listObj, Tcl_NewIntObj(x));
- Tcl_ListObjAppendElement(interp, listObj, Tcl_NewIntObj(y));
- Tcl_ListObjAppendElement(interp, listObj, Tcl_NewIntObj(width));
- Tcl_ListObjAppendElement(interp, listObj, Tcl_NewIntObj(height));
+ Tcl_ListObjAppendElement(interp, listObj, Tcl_NewWideIntObj(x));
+ Tcl_ListObjAppendElement(interp, listObj, Tcl_NewWideIntObj(y));
+ Tcl_ListObjAppendElement(interp, listObj, Tcl_NewWideIntObj(width));
+ Tcl_ListObjAppendElement(interp, listObj, Tcl_NewWideIntObj(height));
Tcl_SetObjResult(interp, listObj);
}
@@ -754,7 +754,7 @@ TextWidgetObjCmd(
result = TCL_ERROR;
goto done;
} else {
- Tcl_Obj *objPtr = Tk_GetOptionValue(interp, (char *) textPtr,
+ Tcl_Obj *objPtr = Tk_GetOptionValue(interp, textPtr,
textPtr->optionTable, objv[2], textPtr->tkwin);
if (objPtr == NULL) {
@@ -811,13 +811,13 @@ TextWidgetObjCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad comparison operator \"%s\": must be"
" <, <=, ==, >=, >, or !=", Tcl_GetString(objv[3])));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "COMPARISON", NULL);
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "COMPARISON", (char *)NULL);
result = TCL_ERROR;
goto done;
}
case TEXT_CONFIGURE:
if (objc <= 3) {
- Tcl_Obj *objPtr = Tk_GetOptionInfo(interp, (char *) textPtr,
+ Tcl_Obj *objPtr = Tk_GetOptionInfo(interp, textPtr,
textPtr->optionTable, ((objc == 3) ? objv[2] : NULL),
textPtr->tkwin);
@@ -832,7 +832,8 @@ TextWidgetObjCmd(
break;
case TEXT_COUNT: {
const TkTextIndex *indexFromPtr, *indexToPtr;
- int i, found = 0, update = 0;
+ Tcl_Size i;
+ int found = 0, update = 0;
Tcl_Obj *objPtr = NULL;
if (objc < 4) {
@@ -855,7 +856,7 @@ TextWidgetObjCmd(
for (i = 2; i < objc-2; i++) {
int value;
- int length;
+ Tcl_Size length;
const char *option = Tcl_GetStringFromObj(objv[i], &length);
char c;
@@ -1010,7 +1011,7 @@ TextWidgetObjCmd(
countDone:
found++;
if (found == 1) {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(value));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(value));
} else {
if (found == 2) {
/*
@@ -1022,7 +1023,7 @@ TextWidgetObjCmd(
Tcl_ListObjAppendElement(NULL, objPtr,
Tcl_GetObjResult(interp));
}
- Tcl_ListObjAppendElement(NULL, objPtr, Tcl_NewIntObj(value));
+ Tcl_ListObjAppendElement(NULL, objPtr, Tcl_NewWideIntObj(value));
}
}
@@ -1034,7 +1035,7 @@ TextWidgetObjCmd(
int value = CountIndices(textPtr, indexFromPtr, indexToPtr,
COUNT_INDICES);
- Tcl_SetObjResult(interp, Tcl_NewIntObj(value));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(value));
} else if (found > 1) {
Tcl_SetObjResult(interp, objPtr);
}
@@ -1042,10 +1043,10 @@ TextWidgetObjCmd(
badOption:
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "bad option \"%s\" must be -chars, -displaychars, "
+ "bad option \"%s\": must be -chars, -displaychars, "
"-displayindices, -displaylines, -indices, -lines, -update, "
"-xpixels, or -ypixels", Tcl_GetString(objv[i])));
- Tcl_SetErrorCode(interp, "TK", "TEXT", "INDEX_OPTION", NULL);
+ Tcl_SetErrorCode(interp, "TK", "TEXT", "INDEX_OPTION", (char *)NULL);
result = TCL_ERROR;
goto done;
}
@@ -1072,7 +1073,7 @@ TextWidgetObjCmd(
result = TCL_ERROR;
goto done;
}
- if (textPtr->state == TK_TEXT_STATE_NORMAL) {
+ if (textPtr->state != TK_TEXT_STATE_DISABLED) {
if (objc < 5) {
/*
* Simple case requires no predetermination of indices.
@@ -1112,7 +1113,7 @@ TextWidgetObjCmd(
TkTextIndex *indices, *ixStart, *ixEnd, *lastStart;
char *useIdx;
- int i;
+ Tcl_Size i;
objc -= 2;
objv += 2;
@@ -1230,11 +1231,11 @@ TextWidgetObjCmd(
&base) == 0) {
Tcl_Obj *listObj = Tcl_NewListObj(0, NULL);
- Tcl_ListObjAppendElement(interp, listObj, Tcl_NewIntObj(x));
- Tcl_ListObjAppendElement(interp, listObj, Tcl_NewIntObj(y));
- Tcl_ListObjAppendElement(interp, listObj, Tcl_NewIntObj(width));
- Tcl_ListObjAppendElement(interp, listObj, Tcl_NewIntObj(height));
- Tcl_ListObjAppendElement(interp, listObj, Tcl_NewIntObj(base));
+ Tcl_ListObjAppendElement(interp, listObj, Tcl_NewWideIntObj(x));
+ Tcl_ListObjAppendElement(interp, listObj, Tcl_NewWideIntObj(y));
+ Tcl_ListObjAppendElement(interp, listObj, Tcl_NewWideIntObj(width));
+ Tcl_ListObjAppendElement(interp, listObj, Tcl_NewWideIntObj(height));
+ Tcl_ListObjAppendElement(interp, listObj, Tcl_NewWideIntObj(base));
Tcl_SetObjResult(interp, listObj);
}
@@ -1248,9 +1249,10 @@ TextWidgetObjCmd(
break;
case TEXT_GET: {
Tcl_Obj *objPtr = NULL;
- int i, found = 0, visible = 0;
+ Tcl_Size i;
+ int found = 0, visible = 0;
const char *name;
- int length;
+ Tcl_Size length;
if (objc < 3) {
Tcl_WrongNumArgs(interp, 2, objv,
@@ -1374,7 +1376,7 @@ TextWidgetObjCmd(
result = TCL_ERROR;
goto done;
}
- if (textPtr->state == TK_TEXT_STATE_NORMAL) {
+ if (textPtr->state != TK_TEXT_STATE_DISABLED) {
result = TextInsertCmd(NULL, textPtr, interp, objc-3, objv+3,
indexPtr, 1);
}
@@ -1419,12 +1421,13 @@ TextWidgetObjCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"index \"%s\" before \"%s\" in the text",
Tcl_GetString(objv[3]), Tcl_GetString(objv[2])));
- Tcl_SetErrorCode(interp, "TK", "TEXT", "INDEX_ORDER", NULL);
+ Tcl_SetErrorCode(interp, "TK", "TEXT", "INDEX_ORDER", (char *)NULL);
result = TCL_ERROR;
goto done;
}
- if (textPtr->state == TK_TEXT_STATE_NORMAL) {
- int lineNum, byteIndex;
+ if (textPtr->state != TK_TEXT_STATE_DISABLED) {
+ int lineNum;
+ Tcl_Size byteIndex;
TkTextIndex index;
/*
@@ -1453,11 +1456,12 @@ TextWidgetObjCmd(
* unnecessarily.
*/
- int deleteInsertOffset, insertLength, j, indexFromLine, indexFromByteOffset;
+ int deleteInsertOffset, insertLength, indexFromLine, indexFromByteOffset;
+ Tcl_Size j;
insertLength = 0;
for (j = 4; j < objc; j += 2) {
- insertLength += Tcl_GetCharLength(objv[j]);
+ insertLength += TkGetCharLength(objv[j]);
}
/*
@@ -1522,7 +1526,7 @@ TextWidgetObjCmd(
Tcl_Obj *cmd = objv[3];
const char *option = Tcl_GetString(objv[2]);
if (strncmp(option, "-command", objv[2]->length)) {
- Tcl_AppendResult(interp, "wrong option \"", option, "\": should be \"-command\"", NULL);
+ Tcl_AppendResult(interp, "wrong option \"", option, "\": should be \"-command\"", (char *)NULL);
result = TCL_ERROR;
goto done;
}
@@ -1534,7 +1538,7 @@ TextWidgetObjCmd(
textPtr->afterSyncCmd = cmd;
} else {
textPtr->afterSyncCmd = cmd;
- Tcl_DoWhenIdle(TkTextRunAfterSyncCmd, (ClientData) textPtr);
+ Tcl_DoWhenIdle(TkTextRunAfterSyncCmd, textPtr);
}
break;
} else if (objc != 2) {
@@ -1593,9 +1597,9 @@ TextWidgetObjCmd(
static int
SharedTextObjCmd(
- ClientData clientData, /* Information about shared test B-tree. */
+ void *clientData, /* Information about shared test B-tree. */
Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
TkSharedText *sharedPtr = (TkSharedText *)clientData;
@@ -1701,7 +1705,7 @@ static int
TextPeerCmd(
TkText *textPtr, /* Information about text widget. */
Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tk_Window tkwin = textPtr->tkwin;
@@ -1744,7 +1748,7 @@ TextPeerCmd(
while (tPtr != NULL) {
if (tPtr != textPtr) {
Tcl_ListObjAppendElement(NULL, peersObj,
- TkNewWindowObj(tPtr->tkwin));
+ Tk_NewWindowObj(tPtr->tkwin));
}
tPtr = tPtr->next;
}
@@ -1784,7 +1788,7 @@ TextReplaceCmd(
/* Index from which to replace. */
const TkTextIndex *indexToPtr,
/* Index to which to replace. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[], /* Argument objects. */
int viewUpdate) /* Update vertical view if set. */
{
@@ -2068,7 +2072,7 @@ ConfigureText(
Tcl_Interp *interp, /* Used for error reporting. */
TkText *textPtr, /* Information about widget; may or may not
* already have values for some fields. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
Tk_SavedOptions savedOptions;
@@ -2121,8 +2125,8 @@ ConfigureText(
}
if (start > end) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "-startline must be less than or equal to -endline", -1));
- Tcl_SetErrorCode(interp, "TK", "TEXT", "INDEX_ORDER", NULL);
+ "-startline must be less than or equal to -endline", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "TEXT", "INDEX_ORDER", (char *)NULL);
Tk_RestoreSavedOptions(&savedOptions);
return TCL_ERROR;
}
@@ -2264,16 +2268,16 @@ ConfigureText(
}
textPtr->selTagPtr->affectsDisplay = 0;
textPtr->selTagPtr->affectsDisplayGeometry = 0;
- if ((textPtr->selTagPtr->elideString != NULL)
+ if ((textPtr->selTagPtr->elide >= 0)
|| (textPtr->selTagPtr->tkfont != NULL)
- || (textPtr->selTagPtr->justifyString != NULL)
- || (textPtr->selTagPtr->lMargin1String != NULL)
- || (textPtr->selTagPtr->lMargin2String != NULL)
- || (textPtr->selTagPtr->offsetString != NULL)
- || (textPtr->selTagPtr->rMarginString != NULL)
- || (textPtr->selTagPtr->spacing1String != NULL)
- || (textPtr->selTagPtr->spacing2String != NULL)
- || (textPtr->selTagPtr->spacing3String != NULL)
+ || (textPtr->selTagPtr->justify != TK_JUSTIFY_NULL)
+ || (textPtr->selTagPtr->lMargin1 != INT_MIN)
+ || (textPtr->selTagPtr->lMargin2 != INT_MIN)
+ || (textPtr->selTagPtr->offset != INT_MIN)
+ || (textPtr->selTagPtr->rMargin != INT_MIN)
+ || (textPtr->selTagPtr->spacing1 != INT_MIN)
+ || (textPtr->selTagPtr->spacing2 != INT_MIN)
+ || (textPtr->selTagPtr->spacing3 != INT_MIN)
|| (textPtr->selTagPtr->tabStringPtr != NULL)
|| (textPtr->selTagPtr->tabStyle == TK_TEXT_TABSTYLE_TABULAR)
|| (textPtr->selTagPtr->tabStyle == TK_TEXT_TABSTYLE_WORDPROCESSOR)
@@ -2285,14 +2289,14 @@ ConfigureText(
}
if ((textPtr->selTagPtr->border != NULL)
|| (textPtr->selTagPtr->selBorder != NULL)
- || (textPtr->selTagPtr->reliefString != NULL)
+ || (textPtr->selTagPtr->relief != TK_RELIEF_NULL)
|| (textPtr->selTagPtr->bgStipple != None)
|| (textPtr->selTagPtr->fgColor != NULL)
|| (textPtr->selTagPtr->selFgColor != NULL)
|| (textPtr->selTagPtr->fgStipple != None)
- || (textPtr->selTagPtr->overstrikeString != NULL)
+ || (textPtr->selTagPtr->overstrike >= 0)
|| (textPtr->selTagPtr->overstrikeColor != NULL)
- || (textPtr->selTagPtr->underlineString != NULL)
+ || (textPtr->selTagPtr->underline >= 0)
|| (textPtr->selTagPtr->underlineColor != NULL)
|| (textPtr->selTagPtr->lMarginColor != NULL)
|| (textPtr->selTagPtr->rMarginColor != NULL)) {
@@ -2371,7 +2375,7 @@ ConfigureText(
static void
TextWorldChangedCallback(
- ClientData instanceData) /* Information about widget. */
+ void *instanceData) /* Information about widget. */
{
TkText *textPtr = (TkText *)instanceData;
@@ -2461,7 +2465,7 @@ TextWorldChanged(
static void
TextEventProc(
- ClientData clientData, /* Information about window. */
+ void *clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
TkText *textPtr = (TkText *)clientData;
@@ -2501,7 +2505,7 @@ TextEventProc(
textPtr->setGrid = 0;
}
if (!(textPtr->flags & OPTIONS_FREED)) {
- Tk_FreeConfigOptions((char *) textPtr, textPtr->optionTable,
+ Tk_FreeConfigOptions(textPtr, textPtr->optionTable,
textPtr->tkwin);
textPtr->flags |= OPTIONS_FREED;
}
@@ -2571,7 +2575,7 @@ TextEventProc(
static void
TextCmdDeletedProc(
- ClientData clientData) /* Pointer to widget record for widget. */
+ void *clientData) /* Pointer to widget record for widget. */
{
TkText *textPtr = (TkText *)clientData;
Tk_Window tkwin = textPtr->tkwin;
@@ -2626,7 +2630,7 @@ InsertChars(
int viewUpdate) /* Update the view if set. */
{
int lineIndex;
- int length;
+ Tcl_Size length;
TkText *tPtr;
int *lineAndByteIndex;
int resetViewCount;
@@ -2773,6 +2777,9 @@ TextPushUndoAction(
{
TkUndoSubAtom *iAtom, *dAtom;
int canUndo, canRedo;
+ char lMarkName[16 + TCL_INTEGER_SPACE] = "tk::undoMarkL";
+ char rMarkName[16 + TCL_INTEGER_SPACE] = "tk::undoMarkR";
+ char stringUndoMarkId[TCL_INTEGER_SPACE] = "";
/*
* Create the helpers.
@@ -2783,6 +2790,10 @@ TextPushUndoAction(
Tcl_Obj *markSet2InsertObj = NULL;
Tcl_Obj *insertCmdObj = Tcl_NewObj();
Tcl_Obj *deleteCmdObj = Tcl_NewObj();
+ Tcl_Obj *markSetLUndoMarkCmdObj = Tcl_NewObj();
+ Tcl_Obj *markSetRUndoMarkCmdObj = NULL;
+ Tcl_Obj *markGravityLUndoMarkCmdObj = Tcl_NewObj();
+ Tcl_Obj *markGravityRUndoMarkCmdObj = NULL;
/*
* Get the index positions.
@@ -2800,13 +2811,13 @@ TextPushUndoAction(
Tcl_IncrRefCount(index2Obj);
Tcl_ListObjAppendElement(NULL, seeInsertObj,
- Tcl_NewStringObj(Tk_PathName(textPtr->tkwin), -1));
+ Tcl_NewStringObj(Tk_PathName(textPtr->tkwin), TCL_INDEX_NONE));
Tcl_ListObjAppendElement(NULL, seeInsertObj, Tcl_NewStringObj("see", 3));
Tcl_ListObjAppendElement(NULL, seeInsertObj,
Tcl_NewStringObj("insert", 6));
Tcl_ListObjAppendElement(NULL, markSet1InsertObj,
- Tcl_NewStringObj(Tk_PathName(textPtr->tkwin), -1));
+ Tcl_NewStringObj(Tk_PathName(textPtr->tkwin), TCL_INDEX_NONE));
Tcl_ListObjAppendElement(NULL, markSet1InsertObj,
Tcl_NewStringObj("mark", 4));
Tcl_ListObjAppendElement(NULL, markSet1InsertObj,
@@ -2832,6 +2843,40 @@ TextPushUndoAction(
Tcl_ListObjAppendElement(NULL, deleteCmdObj, index1Obj);
Tcl_ListObjAppendElement(NULL, deleteCmdObj, index2Obj);
+ Tcl_ListObjAppendElement(NULL, markSetLUndoMarkCmdObj,
+ Tcl_NewStringObj(Tk_PathName(textPtr->tkwin), TCL_INDEX_NONE));
+ Tcl_ListObjAppendElement(NULL, markSetLUndoMarkCmdObj,
+ Tcl_NewStringObj("mark", 4));
+ Tcl_ListObjAppendElement(NULL, markSetLUndoMarkCmdObj,
+ Tcl_NewStringObj("set", 3));
+ markSetRUndoMarkCmdObj = Tcl_DuplicateObj(markSetLUndoMarkCmdObj);
+ textPtr->sharedTextPtr->undoMarkId++;
+ snprintf(stringUndoMarkId, TCL_INTEGER_SPACE, "%" TCL_SIZE_MODIFIER "d", textPtr->sharedTextPtr->undoMarkId);
+ strcat(lMarkName, stringUndoMarkId);
+ strcat(rMarkName, stringUndoMarkId);
+ Tcl_ListObjAppendElement(NULL, markSetLUndoMarkCmdObj,
+ Tcl_NewStringObj(lMarkName, TCL_INDEX_NONE));
+ Tcl_ListObjAppendElement(NULL, markSetRUndoMarkCmdObj,
+ Tcl_NewStringObj(rMarkName, TCL_INDEX_NONE));
+ Tcl_ListObjAppendElement(NULL, markSetLUndoMarkCmdObj, index1Obj);
+ Tcl_ListObjAppendElement(NULL, markSetRUndoMarkCmdObj, index2Obj);
+
+ Tcl_ListObjAppendElement(NULL, markGravityLUndoMarkCmdObj,
+ Tcl_NewStringObj(Tk_PathName(textPtr->tkwin), TCL_INDEX_NONE));
+ Tcl_ListObjAppendElement(NULL, markGravityLUndoMarkCmdObj,
+ Tcl_NewStringObj("mark", 4));
+ Tcl_ListObjAppendElement(NULL, markGravityLUndoMarkCmdObj,
+ Tcl_NewStringObj("gravity", 7));
+ markGravityRUndoMarkCmdObj = Tcl_DuplicateObj(markGravityLUndoMarkCmdObj);
+ Tcl_ListObjAppendElement(NULL, markGravityLUndoMarkCmdObj,
+ Tcl_NewStringObj(lMarkName, TCL_INDEX_NONE));
+ Tcl_ListObjAppendElement(NULL, markGravityRUndoMarkCmdObj,
+ Tcl_NewStringObj(rMarkName, TCL_INDEX_NONE));
+ Tcl_ListObjAppendElement(NULL, markGravityLUndoMarkCmdObj,
+ Tcl_NewStringObj("left", 4));
+ Tcl_ListObjAppendElement(NULL, markGravityRUndoMarkCmdObj,
+ Tcl_NewStringObj("right", 5));
+
/*
* Note: we don't wish to use textPtr->widgetCmd in these callbacks
* because if we delete the textPtr, but peers still exist, we will then
@@ -2849,11 +2894,19 @@ TextPushUndoAction(
insertCmdObj, NULL);
TkUndoMakeCmdSubAtom(NULL, markSet2InsertObj, iAtom);
TkUndoMakeCmdSubAtom(NULL, seeInsertObj, iAtom);
+ TkUndoMakeCmdSubAtom(NULL, markSetLUndoMarkCmdObj, iAtom);
+ TkUndoMakeCmdSubAtom(NULL, markSetRUndoMarkCmdObj, iAtom);
+ TkUndoMakeCmdSubAtom(NULL, markGravityLUndoMarkCmdObj, iAtom);
+ TkUndoMakeCmdSubAtom(NULL, markGravityRUndoMarkCmdObj, iAtom);
dAtom = TkUndoMakeSubAtom(&TextUndoRedoCallback, textPtr->sharedTextPtr,
deleteCmdObj, NULL);
TkUndoMakeCmdSubAtom(NULL, markSet1InsertObj, dAtom);
TkUndoMakeCmdSubAtom(NULL, seeInsertObj, dAtom);
+ TkUndoMakeCmdSubAtom(NULL, markSetLUndoMarkCmdObj, dAtom);
+ TkUndoMakeCmdSubAtom(NULL, markSetRUndoMarkCmdObj, dAtom);
+ TkUndoMakeCmdSubAtom(NULL, markGravityLUndoMarkCmdObj, dAtom);
+ TkUndoMakeCmdSubAtom(NULL, markGravityRUndoMarkCmdObj, dAtom);
Tcl_DecrRefCount(seeInsertObj);
Tcl_DecrRefCount(index1Obj);
@@ -2902,13 +2955,14 @@ TextPushUndoAction(
int
TextUndoRedoCallback(
Tcl_Interp *interp, /* Current interpreter. */
- ClientData clientData, /* Passed from undo code, but contains our
+ void *clientData, /* Passed from undo code, but contains our
* shared text data structure. */
Tcl_Obj *objPtr) /* Arguments of a command to be handled by the
* shared text data structure. */
{
TkSharedText *sharedPtr = (TkSharedText *)clientData;
- int res, objc;
+ int res;
+ Tcl_Size objc;
Tcl_Obj **objv;
TkText *textPtr;
@@ -2956,7 +3010,7 @@ TextUndoRedoCallback(
* allow it to take place here.
*/
- cmdNameObj = Tcl_NewStringObj(Tk_PathName(textPtr->tkwin), -1);
+ cmdNameObj = Tcl_NewStringObj(Tk_PathName(textPtr->tkwin), TCL_INDEX_NONE);
Tcl_ListObjAppendElement(NULL, evalObj, cmdNameObj);
Tcl_ListObjAppendList(NULL, evalObj, objPtr);
res = Tcl_EvalObjEx(interp, evalObj, TCL_EVAL_GLOBAL);
@@ -3073,7 +3127,7 @@ DeleteIndexRange(
int pixels[2*PIXEL_CLIENTS];
Tcl_HashSearch search;
Tcl_HashEntry *hPtr;
- int i;
+ Tcl_Size i;
if (sharedTextPtr == NULL) {
sharedTextPtr = textPtr->sharedTextPtr;
@@ -3119,7 +3173,7 @@ DeleteIndexRange(
line2 = TkBTreeLinesTo(textPtr, index2.linePtr);
if (line2 == TkBTreeNumLines(sharedTextPtr->tree, textPtr)) {
TkTextTag **arrayPtr;
- int arraySize;
+ Tcl_Size arraySize;
TkTextIndex oldIndex2;
oldIndex2 = index2;
@@ -3186,7 +3240,7 @@ DeleteIndexRange(
}
for (tPtr = sharedTextPtr->peers; tPtr != NULL ; tPtr = tPtr->next) {
int line = 0;
- int byteIndex = 0;
+ Tcl_Size byteIndex = 0;
int resetView = 0;
if (TkTextIndexCmp(&index2, &tPtr->topIndex) >= 0) {
@@ -3271,10 +3325,10 @@ DeleteIndexRange(
resetViewCount = 0;
for (tPtr = sharedTextPtr->peers; tPtr != NULL ; tPtr = tPtr->next) {
- int line = lineAndByteIndex[resetViewCount];
+ Tcl_Size line = lineAndByteIndex[resetViewCount];
if (line != -1) {
- int byteIndex = lineAndByteIndex[resetViewCount+1];
+ Tcl_Size byteIndex = lineAndByteIndex[resetViewCount+1];
TkTextIndex indexTmp;
if (tPtr == textPtr) {
@@ -3351,19 +3405,19 @@ DeleteIndexRange(
*----------------------------------------------------------------------
*/
-static int
+static Tcl_Size
TextFetchSelection(
- ClientData clientData, /* Information about text widget. */
- int offset, /* Offset within selection of first character
+ void *clientData, /* Information about text widget. */
+ Tcl_Size 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,
+ Tcl_Size maxBytes) /* Maximum number of bytes to place at buffer,
* not including terminating NULL
* character. */
{
TkText *textPtr = (TkText *)clientData;
TkTextIndex eof;
- int count, chunkSize, offsetInSeg;
+ Tcl_Size count, offsetInSeg, chunkSize;
TkTextSearch search;
TkTextSegment *segPtr;
@@ -3427,11 +3481,11 @@ TextFetchSelection(
}
segPtr = TkTextIndexToSeg(&textPtr->selIndex, &offsetInSeg);
chunkSize = segPtr->size - offsetInSeg;
- if (chunkSize > maxBytes) {
- chunkSize = maxBytes;
+ if (chunkSize > (int)maxBytes) {
+ chunkSize = (int)maxBytes;
}
if (textPtr->selIndex.linePtr == search.curIndex.linePtr) {
- int leftInRange;
+ Tcl_Size leftInRange;
leftInRange = search.curIndex.byteIndex
- textPtr->selIndex.byteIndex;
@@ -3490,11 +3544,11 @@ TextFetchSelection(
void
TkTextLostSelection(
- ClientData clientData) /* Information about text widget. */
+ void *clientData) /* Information about text widget. */
{
TkText *textPtr = (TkText *)clientData;
- if (TkpAlwaysShowSelection(textPtr->tkwin)) {
+ if (Tk_AlwaysShowSelection(textPtr->tkwin)) {
TkTextIndex start, end;
if ((!textPtr->exportSelection) || Tcl_IsSafe(textPtr->interp)) {
@@ -3552,7 +3606,7 @@ TkTextSelectionEvent(
* event generate $textWidget <<Selection>>
*/
- TkSendVirtualEvent(textPtr->tkwin, "Selection", NULL);
+ Tk_SendVirtualEvent(textPtr->tkwin, "Selection", NULL);
}
/*
@@ -3575,7 +3629,7 @@ TkTextSelectionEvent(
static void
TextBlinkProc(
- ClientData clientData) /* Pointer to record describing text. */
+ void *clientData) /* Pointer to record describing text. */
{
TkText *textPtr = (TkText *)clientData;
TkTextIndex index;
@@ -3653,13 +3707,13 @@ TextInsertCmd(
TkSharedText *sharedTextPtr,/* Shared portion of peer widgets. */
TkText *textPtr, /* Information about text widget. */
Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[], /* Argument objects. */
const TkTextIndex *indexPtr,/* Index at which to insert. */
int viewUpdate) /* Update the view if set. */
{
TkTextIndex index1, index2;
- int j;
+ Tcl_Size j;
if (sharedTextPtr == NULL) {
sharedTextPtr = textPtr->sharedTextPtr;
@@ -3674,18 +3728,18 @@ TextInsertCmd(
* insertions will fail.
*/
- int length = InsertChars(sharedTextPtr, textPtr, &index1, objv[j],
+ Tcl_Size length = InsertChars(sharedTextPtr, textPtr, &index1, objv[j],
viewUpdate);
if (objc > (j+1)) {
Tcl_Obj **tagNamePtrs;
TkTextTag **oldTagArrayPtr;
- int numTags;
+ Tcl_Size numTags;
TkTextIndexForwBytes(textPtr, &index1, length, &index2);
oldTagArrayPtr = TkBTreeGetTags(&index1, NULL, &numTags);
if (oldTagArrayPtr != NULL) {
- int i;
+ Tcl_Size i;
for (i = 0; i < numTags; i++) {
TkBTreeTag(&index1, &index2, oldTagArrayPtr[i], 0);
@@ -3696,7 +3750,7 @@ TextInsertCmd(
&tagNamePtrs) != TCL_OK) {
return TCL_ERROR;
} else {
- int i;
+ Tcl_Size i;
for (i = 0; i < numTags; i++) {
const char *strTag = Tcl_GetString(tagNamePtrs[i]);
@@ -3732,10 +3786,11 @@ static int
TextSearchCmd(
TkText *textPtr, /* Information about text widget. */
Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- int i, argsLeft, code;
+ Tcl_Size i, argsLeft;
+ int code;
SearchSpec searchSpec;
static const char *const switchStrings[] = {
@@ -3807,10 +3862,10 @@ TextSearchCmd(
searchSpec.backwards = 1;
break;
case TK_TEXT_SEARCH_COUNT:
- if (i >= objc-1) {
+ if (i + 1 >= objc) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "no value given for \"-count\" option", -1));
- Tcl_SetErrorCode(interp, "TK", "TEXT", "VALUE", NULL);
+ "no value given for \"-count\" option", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "TEXT", "VALUE", (char *)NULL);
return TCL_ERROR;
}
i++;
@@ -3863,16 +3918,16 @@ TextSearchCmd(
if (searchSpec.noLineStop && searchSpec.exact) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"the \"-nolinestop\" option requires the \"-regexp\" option"
- " to be present", -1));
- Tcl_SetErrorCode(interp, "TK", "TEXT", "SEARCH_USAGE", NULL);
+ " to be present", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "TEXT", "SEARCH_USAGE", (char *)NULL);
return TCL_ERROR;
}
if (searchSpec.overlap && !searchSpec.all) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"the \"-overlap\" option requires the \"-all\" option"
- " to be present", -1));
- Tcl_SetErrorCode(interp, "TK", "TEXT", "SEARCH_USAGE", NULL);
+ " to be present", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "TEXT", "SEARCH_USAGE", (char *)NULL);
return TCL_ERROR;
}
@@ -3952,7 +4007,7 @@ TextSearchGetLineIndex(
Tcl_Obj *objPtr, /* Contains a textual index like "1.2" */
SearchSpec *searchSpecPtr, /* Contains other search parameters. */
int *linePosPtr, /* For returning the line number. */
- int *offsetPosPtr) /* For returning the text offset in the
+ Tcl_Size *offsetPosPtr) /* For returning the text offset in the
* line. */
{
const TkTextIndex *indexPtr;
@@ -4012,16 +4067,17 @@ TextSearchGetLineIndex(
*----------------------------------------------------------------------
*/
-static int
+static Tcl_Size
TextSearchIndexInLine(
const SearchSpec *searchSpecPtr,
/* Search parameters. */
TkTextLine *linePtr, /* The line we're looking at. */
- int byteIndex) /* Index into the line. */
+ Tcl_Size byteIndex) /* Index into the line. */
{
TkTextSegment *segPtr;
TkTextIndex curIndex;
- int index, leftToScan;
+ Tcl_Size index;
+ int leftToScan;
TkText *textPtr = (TkText *)searchSpecPtr->clientData;
index = 0;
@@ -4037,12 +4093,12 @@ TextSearchIndexInLine(
if (searchSpecPtr->exact) {
index += leftToScan;
} else {
- index += Tcl_NumUtfChars(segPtr->body.chars, leftToScan);
+ index += TkNumUtfChars(segPtr->body.chars, leftToScan);
}
} else if (searchSpecPtr->exact) {
index += segPtr->size;
} else {
- index += Tcl_NumUtfChars(segPtr->body.chars, -1);
+ index += TkNumUtfChars(segPtr->body.chars, -1);
}
}
leftToScan -= segPtr->size;
@@ -4078,7 +4134,7 @@ TextSearchIndexInLine(
*----------------------------------------------------------------------
*/
-static ClientData
+static void *
TextSearchAddNextLine(
int lineNum, /* Line we must add. */
SearchSpec *searchSpecPtr, /* Search parameters. */
@@ -4167,7 +4223,7 @@ TextSearchAddNextLine(
Tcl_GetString(theLine);
*lenPtr = theLine->length;
} else {
- *lenPtr = Tcl_GetCharLength(theLine);
+ *lenPtr = TkGetCharLength(theLine);
}
}
return linePtr;
@@ -4197,19 +4253,19 @@ static int
TextSearchFoundMatch(
int lineNum, /* Line on which match was found. */
SearchSpec *searchSpecPtr, /* Search parameters. */
- ClientData clientData, /* Token returned by the 'addNextLineProc',
+ void *clientData, /* Token returned by the 'addNextLineProc',
* TextSearchAddNextLine. May be NULL, in
* which we case we must generate it (from
* lineNum). */
Tcl_Obj *theLine, /* Text from current line, only accessed for
* exact searches, and is allowed to be NULL
* for regexp searches. */
- int matchOffset, /* Offset of found item in utf-8 bytes for
+ Tcl_Size matchOffset, /* Offset of found item in utf-8 bytes for
* exact search, Unicode chars for regexp. */
- int matchLength) /* Length also in bytes/chars as per search
+ Tcl_Size matchLength) /* Length also in bytes/chars as per search
* type. */
{
- int numChars;
+ Tcl_Size numChars;
int leftToScan;
TkTextIndex curIndex, foundIndex;
TkTextSegment *segPtr;
@@ -4237,7 +4293,7 @@ TextSearchFoundMatch(
if (searchSpecPtr->exact) {
const char *startOfLine = Tcl_GetString(theLine);
- numChars = Tcl_NumUtfChars(startOfLine + matchOffset, matchLength);
+ numChars = TkNumUtfChars(startOfLine + matchOffset, matchLength);
} else {
numChars = matchLength;
}
@@ -4296,13 +4352,13 @@ TextSearchFoundMatch(
if (searchSpecPtr->exact) {
matchOffset += segPtr->size;
} else {
- matchOffset += Tcl_NumUtfChars(segPtr->body.chars, -1);
+ matchOffset += TkNumUtfChars(segPtr->body.chars, -1);
}
} else {
if (searchSpecPtr->exact) {
- leftToScan -= segPtr->size;
+ leftToScan -= (int)segPtr->size;
} else {
- leftToScan -= Tcl_NumUtfChars(segPtr->body.chars, -1);
+ leftToScan -= TkNumUtfChars(segPtr->body.chars, -1);
}
}
curIndex.byteIndex += segPtr->size;
@@ -4387,13 +4443,13 @@ TextSearchFoundMatch(
continue;
} else if (!searchSpecPtr->searchElide
&& TkTextIsElided(textPtr, &curIndex, NULL)) {
- numChars += Tcl_NumUtfChars(segPtr->body.chars, -1);
+ numChars += TkNumUtfChars(segPtr->body.chars, -1);
continue;
}
if (searchSpecPtr->exact) {
leftToScan -= segPtr->size;
} else {
- leftToScan -= Tcl_NumUtfChars(segPtr->body.chars, -1);
+ leftToScan -= TkNumUtfChars(segPtr->body.chars, -1);
}
}
@@ -4402,7 +4458,7 @@ TextSearchFoundMatch(
*/
if (searchSpecPtr->varPtr != NULL) {
- Tcl_Obj *tmpPtr = Tcl_NewIntObj(numChars);
+ Tcl_Obj *tmpPtr = Tcl_NewWideIntObj(numChars);
if (searchSpecPtr->all) {
if (searchSpecPtr->countPtr == NULL) {
searchSpecPtr->countPtr = Tcl_NewObj();
@@ -4437,11 +4493,11 @@ TextSearchFoundMatch(
TkTextTabArray *
TkTextGetTabs(
Tcl_Interp *interp, /* Used for error reporting. */
- TkText *textPtr, /* Information about the text widget. */
+ const TkText *textPtr, /* Information about the text widget. */
Tcl_Obj *stringPtr) /* Description of the tab stops. See the text
* manual entry for details. */
{
- int objc, i, count;
+ Tcl_Size objc, i, count;
Tcl_Obj **objv;
TkTextTabArray *tabArrayPtr;
TkTextTab *tabPtr;
@@ -4475,7 +4531,7 @@ TkTextGetTabs(
* Parse the elements of the list one at a time to fill in the array.
*/
- tabArrayPtr = (TkTextTabArray *)ckalloc(Tk_Offset(TkTextTabArray, tabs)
+ tabArrayPtr = (TkTextTabArray *)ckalloc(offsetof(TkTextTabArray, tabs)
+ count * sizeof(TkTextTab));
tabArrayPtr->numTabs = 0;
prevStop = 0.0;
@@ -4497,7 +4553,7 @@ TkTextGetTabs(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"tab stop \"%s\" is not at a positive distance",
Tcl_GetString(objv[i])));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "TAB_STOP", NULL);
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "TAB_STOP", (char *)NULL);
goto error;
}
@@ -4531,7 +4587,7 @@ TkTextGetTabs(
"tabs must be monotonically increasing, but \"%s\" is "
"smaller than or equal to the previous tab",
Tcl_GetString(objv[i])));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "TAB_STOP", NULL);
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "TAB_STOP", (char *)NULL);
goto error;
#endif /* _TK_ALLOW_DECREASING_TABS */
}
@@ -4604,13 +4660,13 @@ static int
TextDumpCmd(
TkText *textPtr, /* Information about text widget. */
Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. Someone else has already
* parsed this command enough to know that
* objv[1] is "dump". */
{
TkTextIndex index1, index2;
- int arg;
+ Tcl_Size arg;
int lineno; /* Current line number. */
int what = 0; /* bitfield to select segment types. */
int atEnd; /* True if dumping up to logical end. */
@@ -4675,7 +4731,7 @@ TextDumpCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"Usage: %s dump ?-all -image -text -mark -tag -window? "
"?-command script? index ?index2?", Tcl_GetString(objv[0])));
- Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL);
+ Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", (char *)NULL);
return TCL_ERROR;
}
if (what == 0) {
@@ -4689,7 +4745,7 @@ TextDumpCmd(
if (objc == arg) {
TkTextIndexForwChars(NULL, &index1, 1, &index2, COUNT_INDICES);
} else {
- int length;
+ Tcl_Size length;
const char *str;
if (TkTextGetObjIndex(interp, textPtr, objv[arg], &index2) != TCL_OK) {
@@ -5011,15 +5067,15 @@ DumpSegment(
Tcl_DecrRefCount(tuple);
return 0;
} else {
- int oldStateEpoch = TkBTreeEpoch(textPtr->sharedTextPtr->tree);
+ Tcl_Size oldStateEpoch = TkBTreeEpoch(textPtr->sharedTextPtr->tree);
Tcl_DString buf;
int code;
Tcl_DStringInit(&buf);
- Tcl_DStringAppend(&buf, Tcl_GetString(command), -1);
- Tcl_DStringAppend(&buf, " ", -1);
- Tcl_DStringAppend(&buf, Tcl_GetString(tuple), -1);
- code = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, TCL_EVAL_GLOBAL);
+ Tcl_DStringAppend(&buf, Tcl_GetString(command), TCL_INDEX_NONE);
+ Tcl_DStringAppend(&buf, " ", TCL_INDEX_NONE);
+ Tcl_DStringAppend(&buf, Tcl_GetString(tuple), TCL_INDEX_NONE);
+ code = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), TCL_INDEX_NONE, TCL_EVAL_GLOBAL);
Tcl_DStringFree(&buf);
if (code != TCL_OK) {
Tcl_AddErrorInfo(interp,
@@ -5054,6 +5110,8 @@ TextEditUndo(
TkText *textPtr) /* Overall information about text widget. */
{
int status;
+ Tcl_Obj *cmdObj;
+ int code;
if (!textPtr->sharedTextPtr->undo) {
return TCL_OK;
@@ -5085,6 +5143,22 @@ TextEditUndo(
TkUndoInsertUndoSeparator(textPtr->sharedTextPtr->undoStack);
}
+ /*
+ * Convert undo/redo temporary marks set by TkUndoRevert() into
+ * indices left in the interp result.
+ */
+
+ cmdObj = Tcl_ObjPrintf("::tk::TextUndoRedoProcessMarks %s",
+ Tk_PathName(textPtr->tkwin));
+ Tcl_IncrRefCount(cmdObj);
+ code = Tcl_EvalObjEx(textPtr->interp, cmdObj, TCL_EVAL_GLOBAL);
+ if (code != TCL_OK) {
+ Tcl_AddErrorInfo(textPtr->interp,
+ "\n (on undoing)");
+ Tcl_BackgroundException(textPtr->interp, code);
+ }
+ Tcl_DecrRefCount(cmdObj);
+
return status;
}
@@ -5110,6 +5184,8 @@ TextEditRedo(
TkText *textPtr) /* Overall information about text widget. */
{
int status;
+ Tcl_Obj *cmdObj;
+ int code;
if (!textPtr->sharedTextPtr->undo) {
return TCL_OK;
@@ -5132,6 +5208,23 @@ TextEditRedo(
textPtr->sharedTextPtr->dirtyMode = TK_TEXT_DIRTY_NORMAL;
}
textPtr->sharedTextPtr->undo = 1;
+
+ /*
+ * Convert undo/redo temporary marks set by TkUndoApply() into
+ * indices left in the interp result.
+ */
+
+ cmdObj = Tcl_ObjPrintf("::tk::TextUndoRedoProcessMarks %s",
+ Tk_PathName(textPtr->tkwin));
+ Tcl_IncrRefCount(cmdObj);
+ code = Tcl_EvalObjEx(textPtr->interp, cmdObj, TCL_EVAL_GLOBAL);
+ if (code != TCL_OK) {
+ Tcl_AddErrorInfo(textPtr->interp,
+ "\n (on undoing)");
+ Tcl_BackgroundException(textPtr->interp, code);
+ }
+ Tcl_DecrRefCount(cmdObj);
+
return status;
}
@@ -5156,7 +5249,7 @@ static int
TextEditCmd(
TkText *textPtr, /* Information about text widget. */
Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
int index, setModified, oldModified;
@@ -5247,7 +5340,7 @@ TextEditCmd(
canUndo = TkUndoCanUndo(textPtr->sharedTextPtr->undoStack);
if (TextEditRedo(textPtr)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj("nothing to redo", -1));
- Tcl_SetErrorCode(interp, "TK", "TEXT", "NO_REDO", NULL);
+ Tcl_SetErrorCode(interp, "TK", "TEXT", "NO_REDO", (char *)NULL);
return TCL_ERROR;
}
canRedo = TkUndoCanRedo(textPtr->sharedTextPtr->undoStack);
@@ -5282,7 +5375,7 @@ TextEditCmd(
canRedo = TkUndoCanRedo(textPtr->sharedTextPtr->undoStack);
if (TextEditUndo(textPtr)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj("nothing to undo", -1));
- Tcl_SetErrorCode(interp, "TK", "TEXT", "NO_UNDO", NULL);
+ Tcl_SetErrorCode(interp, "TK", "TEXT", "NO_UNDO", (char *)NULL);
return TCL_ERROR;
}
canUndo = TkUndoCanUndo(textPtr->sharedTextPtr->undoStack);
@@ -5341,7 +5434,7 @@ TextGetText(
if (TkTextIndexCmp(indexPtr1, indexPtr2) < 0) {
while (1) {
- int offset;
+ Tcl_Size offset;
TkTextSegment *segPtr = TkTextIndexToSeg(&tmpIndex, &offset);
int last = segPtr->size, last2;
@@ -5396,7 +5489,7 @@ GenerateModifiedEvent(
for (textPtr = textPtr->sharedTextPtr->peers; textPtr != NULL;
textPtr = textPtr->next) {
Tk_MakeWindowExist(textPtr->tkwin);
- TkSendVirtualEvent(textPtr->tkwin, "Modified", NULL);
+ Tk_SendVirtualEvent(textPtr->tkwin, "Modified", NULL);
}
}
@@ -5426,7 +5519,7 @@ GenerateUndoStackEvent(
for (textPtr = textPtr->sharedTextPtr->peers; textPtr != NULL;
textPtr = textPtr->next) {
Tk_MakeWindowExist(textPtr->tkwin);
- TkSendVirtualEvent(textPtr->tkwin, "UndoStack", NULL);
+ Tk_SendVirtualEvent(textPtr->tkwin, "UndoStack", NULL);
}
}
@@ -5504,7 +5597,7 @@ UpdateDirtyFlag(
void
TkTextRunAfterSyncCmd(
- ClientData clientData) /* Information about text widget. */
+ void *clientData) /* Information about text widget. */
{
TkText *textPtr = (TkText *)clientData;
int code;
@@ -5515,18 +5608,18 @@ TkTextRunAfterSyncCmd(
*/
if (textPtr->refCount-- <= 1) {
- ckfree((char *) textPtr);
+ ckfree(textPtr);
}
return;
}
- Tcl_Preserve((ClientData) textPtr->interp);
+ Tcl_Preserve(textPtr->interp);
code = Tcl_EvalObjEx(textPtr->interp, textPtr->afterSyncCmd, TCL_EVAL_GLOBAL);
if (code == TCL_ERROR) {
Tcl_AddErrorInfo(textPtr->interp, "\n (text sync)");
- Tcl_BackgroundError(textPtr->interp);
+ Tcl_BackgroundException(textPtr->interp, TCL_ERROR);
}
- Tcl_Release((ClientData) textPtr->interp);
+ Tcl_Release(textPtr->interp);
Tcl_DecrRefCount(textPtr->afterSyncCmd);
textPtr->afterSyncCmd = NULL;
}
@@ -5662,7 +5755,7 @@ SearchCore(
*/
int firstOffset, lastOffset;
- int matchOffset, matchLength;
+ Tcl_Size matchOffset, matchLength;
int passes;
int lineNum = searchSpecPtr->startLine;
int code = TCL_OK;
@@ -5683,9 +5776,9 @@ SearchCore(
#define LOTS_OF_MATCHES 20
int matchNum = LOTS_OF_MATCHES;
- int smArray[2 * LOTS_OF_MATCHES];
- int *storeMatch = smArray;
- int *storeLength = smArray + LOTS_OF_MATCHES;
+ Tcl_Size smArray[2 * LOTS_OF_MATCHES];
+ Tcl_Size *storeMatch = smArray;
+ Tcl_Size *storeLength = smArray + LOTS_OF_MATCHES;
int lastBackwardsLineMatch = -1;
int lastBackwardsMatchOffset = -1;
@@ -5767,7 +5860,7 @@ SearchCore(
Tcl_IncrRefCount(theLine);
for (passes = 0; passes < 2; ) {
- ClientData lineInfo;
+ void *lineInfo;
int linesSearched = 1;
int extraLinesSearched = 0;
@@ -5860,7 +5953,7 @@ SearchCore(
* begin.
*/
- matchOffset = -1;
+ matchOffset = TCL_INDEX_NONE;
if (searchSpecPtr->exact) {
int maxExtraLines = 0;
@@ -5870,7 +5963,7 @@ SearchCore(
do {
int ch;
const char *p;
- int lastFullLine = lastOffset;
+ Tcl_Size lastFullLine = lastOffset;
if (firstNewLine == -1) {
if (searchSpecPtr->strictLimits
@@ -5992,7 +6085,7 @@ SearchCore(
* exact searches.
*/
- if ((lastTotal - skipFirst) >= matchLength) {
+ if ((Tcl_Size)lastTotal - skipFirst >= matchLength) {
/*
* We now have enough text to match, so we
* make a final test and break whatever the
@@ -6074,7 +6167,7 @@ SearchCore(
}
} else {
firstOffset = matchLength ? p - startOfLine + matchLength
- : p - startOfLine + 1;
+ : p - startOfLine + (Tcl_Size)1;
if (firstOffset >= lastOffset) {
/*
* Now, we have to be careful not to find
@@ -6114,7 +6207,7 @@ SearchCore(
do {
Tcl_RegExpInfo info;
int match;
- int lastFullLine = lastOffset;
+ Tcl_Size lastFullLine = lastOffset;
match = Tcl_RegExpExecObj(interp, regexp, theLine,
firstOffset, 1, (firstOffset>0 ? TCL_REG_NOTBOL : 0));
@@ -6132,9 +6225,9 @@ SearchCore(
if (!match ||
((info.extendStart == info.matches[0].start)
- && (info.matches[0].end == lastOffset-firstOffset))) {
+ && (info.matches[0].end == (Tcl_Size) (lastOffset - firstOffset)))) {
int extraLines = 0;
- int prevFullLine;
+ Tcl_Size prevFullLine;
/*
* If we find a match that overlaps more than one line, we
@@ -6247,7 +6340,7 @@ SearchCore(
*/
if ((match &&
- firstOffset + info.matches[0].end != lastTotal &&
+ firstOffset + info.matches[0].end != (Tcl_Size) lastTotal &&
firstOffset + info.matches[0].end < prevFullLine)
|| info.extendStart < 0) {
break;
@@ -6317,8 +6410,8 @@ SearchCore(
* Possible overlap or enclosure.
*/
- if (thisOffset - lastNonOverlap >=
- lastBackwardsMatchOffset + matchLength){
+ if ((Tcl_Size)thisOffset - lastNonOverlap >=
+ lastBackwardsMatchOffset + matchLength + 1){
/*
* Totally encloses previous match, so
* forget the previous match.
@@ -6404,7 +6497,7 @@ SearchCore(
&& ((firstOffset < matchOffset)
|| ((firstOffset + info.matches[0].end
- info.matches[0].start)
- > (matchOffset + matchLength))))) {
+ > matchOffset + matchLength)))) {
matchOffset = firstOffset;
matchLength = info.matches[0].end - info.matches[0].start;
@@ -6422,11 +6515,11 @@ SearchCore(
* matches on the heap.
*/
- int *newArray = (int *)
- ckalloc(4 * matchNum * sizeof(int));
- memcpy(newArray, storeMatch, matchNum*sizeof(int));
+ Tcl_Size *newArray = (Tcl_Size *)
+ ckalloc(4 * matchNum * sizeof(Tcl_Size));
+ memcpy(newArray, storeMatch, matchNum*sizeof(Tcl_Size));
memcpy(newArray + 2*matchNum, storeLength,
- matchNum * sizeof(int));
+ matchNum * sizeof(Tcl_Size));
if (storeMatch != smArray) {
ckfree(storeMatch);
}
@@ -6567,7 +6660,7 @@ SearchCore(
* we are done.
*/
- if ((lastBackwardsLineMatch == -1) && (matchOffset >= 0)
+ if ((lastBackwardsLineMatch == -1) && (matchOffset != TCL_INDEX_NONE)
&& !searchSpecPtr->all) {
searchSpecPtr->foundMatchProc(lineNum, searchSpecPtr, lineInfo,
theLine, matchOffset, matchLength);
@@ -6686,7 +6779,7 @@ GetLineStartEnd(
TCL_UNUSED(void *),
TCL_UNUSED(Tk_Window),
char *recordPtr, /* Pointer to widget record. */
- int internalOffset) /* Offset within *recordPtr containing the
+ Tcl_Size internalOffset) /* Offset within *recordPtr containing the
* line value. */
{
TkTextLine *linePtr = *(TkTextLine **)(recordPtr + internalOffset);
@@ -6694,7 +6787,7 @@ GetLineStartEnd(
if (linePtr == NULL) {
return Tcl_NewObj();
}
- return Tcl_NewIntObj(1 + TkBTreeLinesTo(NULL, linePtr));
+ return Tcl_NewWideIntObj(1 + TkBTreeLinesTo(NULL, linePtr));
}
/*
@@ -6725,7 +6818,7 @@ SetLineStartEnd(
* We use a pointer to the pointer because we
* may need to return a value (NULL). */
char *recordPtr, /* Pointer to storage for the widget record. */
- int internalOffset, /* Offset within *recordPtr at which the
+ Tcl_Size internalOffset, /* Offset within *recordPtr at which the
* internal value is to be stored. */
char *oldInternalPtr, /* Pointer to storage for the old value. */
int flags) /* Flags for the option, set Tk_SetOptions. */
@@ -6734,8 +6827,8 @@ SetLineStartEnd(
char *internalPtr;
TkText *textPtr = (TkText *) recordPtr;
- if (internalOffset >= 0) {
- internalPtr = recordPtr + internalOffset;
+ if (internalOffset != TCL_INDEX_NONE) {
+ internalPtr = (char *)recordPtr + internalOffset;
} else {
internalPtr = NULL;
}
@@ -6838,12 +6931,13 @@ int
TkpTesttextCmd(
TCL_UNUSED(void *), /* Main window for application. */
Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
{
TkText *textPtr;
- size_t len;
- int lineIndex, byteIndex, byteOffset;
+ Tcl_Size len;
+ Tcl_WideInt lineIndex, byteIndex;
+ Tcl_WideInt byteOffset;
TkTextIndex index;
char buf[TK_POS_CHARS];
Tcl_CmdInfo info;
@@ -6861,8 +6955,13 @@ TkpTesttextCmd(
if (objc != 5) {
return TCL_ERROR;
}
- lineIndex = atoi(Tcl_GetString(objv[3])) - 1;
- byteIndex = atoi(Tcl_GetString(objv[4]));
+ if (Tcl_GetWideIntFromObj(interp, objv[3], &lineIndex)) {
+ return TCL_ERROR;
+ }
+ lineIndex--;
+ if (Tcl_GetWideIntFromObj(interp, objv[4], &byteIndex)) {
+ return TCL_ERROR;
+ }
TkTextMakeByteIndex(textPtr->sharedTextPtr->tree, textPtr, lineIndex,
byteIndex, &index);
@@ -6873,7 +6972,9 @@ TkpTesttextCmd(
if (TkTextGetIndex(interp, textPtr, Tcl_GetString(objv[3]), &index) != TCL_OK) {
return TCL_ERROR;
}
- byteOffset = atoi(Tcl_GetString(objv[4]));
+ if (Tcl_GetWideIntFromObj(interp, objv[4], &byteOffset)) {
+ return TCL_ERROR;
+ }
TkTextIndexForwBytes(textPtr, &index, byteOffset, &index);
} else if (strncmp(Tcl_GetString(objv[2]), "backbytes", len) == 0) {
if (objc != 5) {
@@ -6882,7 +6983,9 @@ TkpTesttextCmd(
if (TkTextGetIndex(interp, textPtr, Tcl_GetString(objv[3]), &index) != TCL_OK) {
return TCL_ERROR;
}
- byteOffset = atoi(Tcl_GetString(objv[4]));
+ if (Tcl_GetWideIntFromObj(interp, objv[4], &byteOffset)) {
+ return TCL_ERROR;
+ }
TkTextIndexBackBytes(textPtr, &index, byteOffset, &index);
} else {
return TCL_ERROR;
@@ -6890,7 +6993,7 @@ TkpTesttextCmd(
TkTextSetMark(textPtr, "insert", &index);
TkTextPrintIndex(textPtr, &index, buf);
- Tcl_SetObjResult(interp, Tcl_ObjPrintf("%s %d", buf, index.byteIndex));
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("%s %" TCL_SIZE_MODIFIER "d", buf, index.byteIndex));
return TCL_OK;
}
diff --git a/generic/tkText.h b/generic/tkText.h
index 962a269..ca7aa4c 100644
--- a/generic/tkText.h
+++ b/generic/tkText.h
@@ -3,8 +3,8 @@
*
* Declarations shared among the files that implement text widgets.
*
- * Copyright (c) 1992-1994 The Regents of the University of California.
- * Copyright (c) 1994-1995 Sun Microsystems, Inc.
+ * Copyright © 1992-1994 The Regents of the University of California.
+ * Copyright © 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.
@@ -99,6 +99,10 @@ typedef struct TkTextEmbWindowClient {
struct TkTextEmbWindowClient *next;
} TkTextEmbWindowClient;
+typedef enum {
+ TK_ALIGN_BASELINE, TK_ALIGN_BOTTOM, TK_ALIGN_CENTER, TK_ALIGN_TOP
+} TkAlignMode;
+
typedef struct TkTextEmbWindow {
struct TkSharedText *sharedTextPtr;
/* Information about the shared portion of the
@@ -112,7 +116,7 @@ typedef struct TkTextEmbWindow {
* window. */
char *create; /* Script to create window on-demand. NULL
* means no such script. Malloc-ed. */
- int align; /* How to align window in vertical space. See
+ TkAlignMode align; /* How to align window in vertical space. See
* definitions in tkTextWind.c. */
int padX, padY; /* Padding to leave around each side of
* window, in pixels. */
@@ -144,7 +148,7 @@ typedef struct TkTextEmbImage {
* the image. */
Tk_Image image; /* Image for this segment. NULL means that the
* image hasn't been created yet. */
- int align; /* How to align image in vertical space. See
+ TkAlignMode align; /* How to align image in vertical space. See
* definitions in tkTextImage.c. */
int padX, padY; /* Padding to leave around each side of image,
* in pixels. */
@@ -165,7 +169,7 @@ typedef struct TkTextSegment {
struct TkTextSegment *nextPtr;
/* Next in list of segments for this line, or
* NULL for end of list. */
- int size; /* Size of this segment (# of bytes of index
+ Tcl_Size size; /* Size of this segment (# of bytes of index
* space it occupies). */
union {
/* The TKFLEXARRAY macro - unfortunately - doesn't work inside a union. */
@@ -193,7 +197,7 @@ typedef struct TkTextIndex {
TkTextBTree tree; /* Tree containing desired position. */
TkTextLine *linePtr; /* Pointer to line containing position of
* interest. */
- int byteIndex; /* Index within line of desired character (0
+ Tcl_Size byteIndex; /* Index within line of desired character (0
* means first one). */
struct TkText *textPtr; /* May be NULL, but otherwise the text widget
* with which this index is associated. If not
@@ -213,9 +217,9 @@ typedef void Tk_ChunkDisplayProc(struct TkText *textPtr,
Drawable dst, int screenY);
typedef void Tk_ChunkUndisplayProc(struct TkText *textPtr,
TkTextDispChunk *chunkPtr);
-typedef int Tk_ChunkMeasureProc(TkTextDispChunk *chunkPtr, int x);
+typedef Tcl_Size Tk_ChunkMeasureProc(TkTextDispChunk *chunkPtr, int x);
typedef void Tk_ChunkBboxProc(struct TkText *textPtr,
- TkTextDispChunk *chunkPtr, int index, int y,
+ TkTextDispChunk *chunkPtr, Tcl_Size index, int y,
int lineHeight, int baseline, int *xPtr,
int *yPtr, int *widthPtr, int *heightPtr);
@@ -258,7 +262,7 @@ struct TkTextDispChunk {
* x-location. */
Tk_ChunkBboxProc *bboxProc; /* Procedure to find bounding box of character
* in chunk. */
- int numBytes; /* Number of bytes that will be displayed in
+ Tcl_Size numBytes; /* Number of bytes that will be displayed in
* the chunk. */
int minAscent; /* Minimum space above the baseline needed by
* this chunk. */
@@ -270,11 +274,11 @@ struct TkTextDispChunk {
* set by chunk-specific code, but may be
* increased to include tab or extra space at
* end of line. */
- int breakIndex; /* Index within chunk of last acceptable
+ Tcl_Size breakIndex; /* Index within chunk of last acceptable
* position for a line (break just before this
* byte index). <= 0 means don't break during
* or immediately after this chunk. */
- ClientData clientData; /* Additional information for use of
+ void *clientData; /* Additional information for use of
* displayProc and undisplayProc. */
};
@@ -285,10 +289,28 @@ struct TkTextDispChunk {
*/
typedef enum {
- TEXT_WRAPMODE_CHAR, TEXT_WRAPMODE_NONE, TEXT_WRAPMODE_WORD,
- TEXT_WRAPMODE_NULL
+ TEXT_WRAPMODE_NULL = -1,
+ TEXT_WRAPMODE_CHAR,
+ TEXT_WRAPMODE_NONE,
+ TEXT_WRAPMODE_WORD
} TkWrapMode;
+/*
+ * The following are the supported styles of tabbing, used for the -tabstyle
+ * option of the text widget. The first element is only used for tag options.
+ */
+
+typedef enum {
+ TK_TEXT_TABSTYLE_NULL = -1,
+ TK_TEXT_TABSTYLE_TABULAR,
+ TK_TEXT_TABSTYLE_WORDPROCESSOR
+} TkTextTabStyle;
+
+MODULE_SCOPE const char *const tkTextTabStyleStrings[];
+
+
+MODULE_SCOPE const char *const tkTextWrapStrings[];
+
typedef struct TkTextTag {
const char *name; /* Name of this tag. This field is actually a
* pointer to the key from the entry in
@@ -300,7 +322,7 @@ typedef struct TkTextTag {
/* If non-NULL, then this tag only applies to
* the given text widget (when there are peer
* widgets). */
- int priority; /* Priority of this tag within widget. 0 means
+ Tcl_Size priority; /* Priority of this tag within widget. 0 means
* lowest priority. Exactly one tag has each
* integer value between 0 and numTags-1. */
struct Node *tagRootPtr; /* Pointer into the B-Tree at the lowest node
@@ -309,7 +331,7 @@ typedef struct TkTextTag {
* there is no information about the tag. One
* or more children of the node do contain
* information about the tag. */
- int toggleCount; /* Total number of tag toggles. */
+ Tcl_Size toggleCount; /* Total number of tag toggles. */
/*
* Information for displaying text with this tag. The information belows
@@ -337,39 +359,34 @@ typedef struct TkTextTag {
* specified here.*/
char *justifyString; /* -justify option string (malloc-ed). NULL
* means option not specified. */
- Tk_Justify justify; /* How to justify text: TK_JUSTIFY_LEFT,
- * TK_JUSTIFY_RIGHT, or TK_JUSTIFY_CENTER.
+ Tk_Justify justify; /* How to justify text: TK_JUSTIFY_CENTER,
+ * TK_JUSTIFY_LEFT, or TK_JUSTIFY_RIGHT.
* Only valid if justifyString is non-NULL. */
char *lMargin1String; /* -lmargin1 option string (malloc-ed). NULL
* means option not specified. */
int lMargin1; /* Left margin for first display line of each
- * text line, in pixels. Only valid if
- * lMargin1String is non-NULL. */
+ * text line, in pixels. INT_MIN means option not specified. */
char *lMargin2String; /* -lmargin2 option string (malloc-ed). NULL
* means option not specified. */
- int lMargin2; /* Left margin for second and later display
- * lines of each text line, in pixels. Only
- * valid if lMargin2String is non-NULL. */
+ int lMargin2; /* Left margin for second and later display lines
+ * of each text line, in pixels. INT_MIN means option not specified. */
Tk_3DBorder lMarginColor; /* Used for drawing background in left margins.
- * This is used for both lmargin1 and lmargin2.
+ * This is used for both lmargin1 and lmargin2.
* NULL means no value specified here. */
char *offsetString; /* -offset option string (malloc-ed). NULL
* means option not specified. */
int offset; /* Vertical offset of text's baseline from
* baseline of line. Used for superscripts and
- * subscripts. Only valid if offsetString is
- * non-NULL. */
+ * subscripts. INT_MIN means option not specified. */
char *overstrikeString; /* -overstrike option string (malloc-ed). NULL
* means option not specified. */
- int overstrike; /* Non-zero means draw horizontal line through
- * middle of text. Only valid if
- * overstrikeString is non-NULL. */
+ int overstrike; /* > 0 means draw horizontal line through
+ * middle of text. -1 means not specified. */
XColor *overstrikeColor; /* Color for the overstrike. NULL means same
- * color as foreground. */
+ * color as foreground. */
char *rMarginString; /* -rmargin option string (malloc-ed). NULL
* means option not specified. */
- int rMargin; /* Right margin for text, in pixels. Only
- * valid if rMarginString is non-NULL. */
+ int rMargin; /* Right margin for text, in pixels. INT_MIN means option not specified. */
Tk_3DBorder rMarginColor; /* Used for drawing background in right margin.
* NULL means no value specified here. */
Tk_3DBorder selBorder; /* Used for drawing background for selected text.
@@ -379,41 +396,36 @@ typedef struct TkTextTag {
char *spacing1String; /* -spacing1 option string (malloc-ed). NULL
* means option not specified. */
int spacing1; /* Extra spacing above first display line for
- * text line. Only valid if spacing1String is
- * non-NULL. */
+ * text line. INT_MIN means option not specified. */
char *spacing2String; /* -spacing2 option string (malloc-ed). NULL
* means option not specified. */
int spacing2; /* Extra spacing between display lines for the
- * same text line. Only valid if
- * spacing2String is non-NULL. */
- char *spacing3String; /* -spacing2 option string (malloc-ed). NULL
+ * same text line. INT_MIN means option not specified. */
+ char *spacing3String; /* -spacing3 option string (malloc-ed). NULL
* means option not specified. */
int spacing3; /* Extra spacing below last display line for
- * text line. Only valid if spacing3String is
- * non-NULL. */
+ * text line. INT_MIN means option not specified. */
Tcl_Obj *tabStringPtr; /* -tabs option string. NULL means option not
* specified. */
struct TkTextTabArray *tabArrayPtr;
/* Info about tabs for tag (malloc-ed) or
* NULL. Corresponds to tabString. */
- int tabStyle; /* One of TABULAR or WORDPROCESSOR or NONE (if
- * not specified). */
+ TkTextTabStyle tabStyle; /* One of TK_TEXT_TABSTYLE_TABULAR, TK_TEXT_TABSTYLE_WORDPROCESSOR
+ * or TK_TEXT_TABSTYLE_NONE. (if not specified)*/
char *underlineString; /* -underline option string (malloc-ed). NULL
* means option not specified. */
- int underline; /* Non-zero means draw underline underneath
- * text. Only valid if underlineString is
- * non-NULL. */
+ int underline; /* > 0 means draw underline underneath
+ * text. -1 means not specified. */
XColor *underlineColor; /* Color for the underline. NULL means same
- * color as foreground. */
+ * color as foreground. */
TkWrapMode wrapMode; /* How to handle wrap-around for this tag.
- * Must be TEXT_WRAPMODE_CHAR,
- * TEXT_WRAPMODE_NONE, TEXT_WRAPMODE_WORD, or
- * TEXT_WRAPMODE_NULL to use wrapmode for
- * whole widget. */
+ * Must be TEXT_WRAPMODE_CHAR, TEXT_WRAPMODE_WORD,
+ * TEXT_WRAPMODE_NONE, or TEXT_WRAPMODE_NULL to
+ * use wrapmode for whole widget. */
char *elideString; /* -elide option string (malloc-ed). NULL
* means option not specified. */
- int elide; /* Non-zero means that data under this tag
- * should not be displayed. */
+ int elide; /* > 0 means that data under this tag
+ * should not be displayed. -1 means not specified. */
int affectsDisplay; /* Non-zero means that this tag affects the
* way information is displayed on the screen
* (so need to redisplay if tag changes). */
@@ -467,17 +479,6 @@ typedef struct TkTextSearch {
typedef enum {LEFT, RIGHT, CENTER, NUMERIC} TkTextTabAlign;
-/*
- * The following are the supported styles of tabbing, used for the -tabstyle
- * option of the text widget. The last element is only used for tag options.
- */
-
-typedef enum {
- TK_TEXT_TABSTYLE_TABULAR,
- TK_TEXT_TABSTYLE_WORDPROCESSOR,
- TK_TEXT_TABSTYLE_NONE
-} TkTextTabStyle;
-
typedef struct TkTextTab {
int location; /* Offset in pixels of this tab stop from the
* left margin (lmargin2) of the text. */
@@ -536,14 +537,14 @@ typedef enum {
*/
typedef struct TkSharedText {
- int refCount; /* Reference count this shared object. */
+ Tcl_Size refCount; /* Reference count this shared object. */
TkTextBTree tree; /* B-tree representation of text and tags for
* widget. */
Tcl_HashTable tagTable; /* Hash table that maps from tag names to
* pointers to TkTextTag structures. The "sel"
* tag does not feature in this table, since
* there's one of those for each text peer. */
- int numTags; /* Number of tags currently defined for
+ Tcl_Size numTags; /* Number of tags currently defined for
* widget; needed to keep track of
* priorities. */
Tcl_HashTable markTable; /* Hash table that maps from mark names to
@@ -565,7 +566,7 @@ typedef struct TkSharedText {
* exist, so the table hasn't been created.
* Each "object" used for this table is the
* name of a tag. */
- int stateEpoch; /* This is incremented each time the B-tree's
+ Tcl_Size stateEpoch; /* This is incremented each time the B-tree's
* contents change structurally, or when the
* start/end limits change, and means that any
* cached TkTextIndex objects are no longer
@@ -598,6 +599,9 @@ typedef struct TkSharedText {
*/
struct TkText *peers;
+
+ Tcl_Size undoMarkId; /* Counts undo marks temporarily used during
+ undo and redo operations. */
} TkSharedText;
/*
@@ -649,7 +653,7 @@ typedef struct TkText {
Tcl_Interp *interp; /* Interpreter associated with widget. Used to
* delete widget command. */
Tcl_Command widgetCmd; /* Token for text's widget command. */
- int state; /* Either STATE_NORMAL or STATE_DISABLED. A
+ TkTextState state; /* Either TK_TEXT_STATE_DISABLED or TK_TEXT_STATE_NORMAL. A
* text widget is read-only when disabled. */
/*
@@ -689,7 +693,7 @@ typedef struct TkText {
/* Information about tab stops (malloc'ed).
* NULL means perform default tabbing
* behavior. */
- int tabStyle; /* One of TABULAR or WORDPROCESSOR. */
+ TkTextTabStyle tabStyle; /* One of TK_TEXT_TABSTYLE_TABULAR or TK_TEXT_TABSTYLE_WORDPROCESSOR. */
/*
* Additional information used for displaying:
@@ -697,7 +701,8 @@ typedef struct TkText {
TkWrapMode wrapMode; /* How to handle wrap-around. Must be
* TEXT_WRAPMODE_CHAR, TEXT_WRAPMODE_NONE, or
- * TEXT_WRAPMODE_WORD. */
+ * TEXT_WRAPMODE_WORD, or TEXT_WRAPMODE_NULL to
+ * use wrapmode for whole widget. */
int width, height; /* Desired dimensions for window, measured in
* characters. */
int setGrid; /* Non-zero means pass gridding information to
@@ -785,7 +790,7 @@ typedef struct TkText {
* definitions. */
Tk_OptionTable optionTable; /* Token representing the configuration
* specifications. */
- int refCount; /* Number of cached TkTextIndex objects
+ Tcl_Size refCount; /* Number of cached TkTextIndex objects
* refering to us. */
int insertCursorType; /* 0 = standard insertion cursor, 1 = block
* cursor. */
@@ -803,7 +808,7 @@ typedef struct TkText {
int autoSeparators; /* Non-zero means the separators will be
* inserted automatically. */
Tcl_Obj *afterSyncCmd; /* Command to be executed when lines are up to
- * date */
+ * date */
} TkText;
/*
@@ -841,7 +846,7 @@ typedef struct TkText {
*/
typedef TkTextSegment * Tk_SegSplitProc(struct TkTextSegment *segPtr,
- int index);
+ Tcl_Size index);
typedef int Tk_SegDeleteProc(struct TkTextSegment *segPtr,
TkTextLine *linePtr, int treeGone);
typedef TkTextSegment * Tk_SegCleanupProc(struct TkTextSegment *segPtr,
@@ -850,8 +855,8 @@ typedef void Tk_SegLineChangeProc(struct TkTextSegment *segPtr,
TkTextLine *linePtr);
typedef int Tk_SegLayoutProc(struct TkText *textPtr,
struct TkTextIndex *indexPtr,
- TkTextSegment *segPtr, int offset, int maxX,
- int maxChars, int noCharsYet, TkWrapMode wrapMode,
+ TkTextSegment *segPtr, Tcl_Size offset, int maxX,
+ Tcl_Size maxChars, int noCharsYet, TkWrapMode wrapMode,
struct TkTextDispChunk *chunkPtr);
typedef void Tk_SegCheckProc(TkTextSegment *segPtr,
TkTextLine *linePtr);
@@ -909,9 +914,9 @@ typedef int TkTextCountType;
#define LOTSA_TAGS 1000
typedef struct TkTextElideInfo {
- int numTags; /* Total tags in widget. */
+ Tcl_Size numTags; /* Total tags in widget. */
int elide; /* Is the state currently elided. */
- int elidePriority; /* Tag priority controlling elide state. */
+ Tcl_Size elidePriority; /* Tag priority controlling elide state. */
TkTextSegment *segPtr; /* Segment to look at next. */
int segOffset; /* Offset of segment within line. */
int deftagCnts[LOTSA_TAGS];
@@ -941,22 +946,24 @@ typedef struct TkTextElideInfo {
* of individual lines displayed in the widget.
*/
-#define TK_TEXT_LINE_GEOMETRY 1
+#define TK_TEXT_LINE_GEOMETRY (1 << 0)
/*
- * Mask used for those options which may impact the start and end lines used
- * in the widget.
+ * Mask used for those options which may impact the start and end lines
+ * used in the widget.
*/
-#define TK_TEXT_LINE_RANGE 2
+#define TK_TEXT_LINE_RANGE (1 << 1)
/*
* Used as 'action' values in calls to TkTextInvalidateLineMetrics
*/
-#define TK_TEXT_INVALIDATE_ONLY 0
-#define TK_TEXT_INVALIDATE_INSERT 1
-#define TK_TEXT_INVALIDATE_DELETE 2
+typedef enum {
+ TK_TEXT_INVALIDATE_ONLY,
+ TK_TEXT_INVALIDATE_INSERT,
+ TK_TEXT_INVALIDATE_DELETE
+} TkTextInvalidateAction;
/*
* Used as special 'pickPlace' values in calls to TkTextSetYView. Zero or
@@ -1011,14 +1018,14 @@ MODULE_SCOPE void TkBTreeRemoveClient(TkTextBTree tree,
MODULE_SCOPE void TkBTreeDestroy(TkTextBTree tree);
MODULE_SCOPE void TkBTreeDeleteIndexRange(TkTextBTree tree,
TkTextIndex *index1Ptr, TkTextIndex *index2Ptr);
-MODULE_SCOPE int TkBTreeEpoch(TkTextBTree tree);
+MODULE_SCOPE Tcl_Size TkBTreeEpoch(TkTextBTree tree);
MODULE_SCOPE TkTextLine *TkBTreeFindLine(TkTextBTree tree,
const TkText *textPtr, int line);
MODULE_SCOPE TkTextLine *TkBTreeFindPixelLine(TkTextBTree tree,
const TkText *textPtr, int pixels,
int *pixelOffset);
MODULE_SCOPE TkTextTag **TkBTreeGetTags(const TkTextIndex *indexPtr,
- const TkText *textPtr, int *numTagsPtr);
+ const TkText *textPtr, Tcl_Size *numTagsPtr);
MODULE_SCOPE void TkBTreeInsertChars(TkTextBTree tree,
TkTextIndex *indexPtr, const char *string);
MODULE_SCOPE int TkBTreeLinesTo(const TkText *textPtr,
@@ -1046,7 +1053,7 @@ MODULE_SCOPE int TkBTreeTag(TkTextIndex *index1Ptr,
int add);
MODULE_SCOPE void TkBTreeUnlinkSegment(TkTextSegment *segPtr,
TkTextLine *linePtr);
-MODULE_SCOPE void TkTextBindProc(ClientData clientData,
+MODULE_SCOPE void TkTextBindProc(void *clientData,
XEvent *eventPtr);
MODULE_SCOPE void TkTextSelectionEvent(TkText *textPtr);
MODULE_SCOPE int TkTextIndexBbox(TkText *textPtr,
@@ -1054,7 +1061,7 @@ MODULE_SCOPE int TkTextIndexBbox(TkText *textPtr,
int *widthPtr, int *heightPtr, int *charWidthPtr);
MODULE_SCOPE int TkTextCharLayoutProc(TkText *textPtr,
TkTextIndex *indexPtr, TkTextSegment *segPtr,
- int offset, int maxX, int maxChars, int noBreakYet,
+ Tcl_Size offset, int maxX, Tcl_Size maxChars, int noBreakYet,
TkWrapMode wrapMode, TkTextDispChunk *chunkPtr);
MODULE_SCOPE void TkTextCreateDInfo(TkText *textPtr);
MODULE_SCOPE int TkTextDLineInfo(TkText *textPtr,
@@ -1077,7 +1084,7 @@ MODULE_SCOPE int TkTextSharedGetObjIndex(Tcl_Interp *interp,
MODULE_SCOPE const TkTextIndex *TkTextGetIndexFromObj(Tcl_Interp *interp,
TkText *textPtr, Tcl_Obj *objPtr);
MODULE_SCOPE TkTextTabArray *TkTextGetTabs(Tcl_Interp *interp,
- TkText *textPtr, Tcl_Obj *stringPtr);
+ const TkText *textPtr, Tcl_Obj *stringPtr);
MODULE_SCOPE void TkTextFindDisplayLineEnd(TkText *textPtr,
TkTextIndex *indexPtr, int end, int *xOffset);
MODULE_SCOPE void TkTextIndexBackChars(const TkText *textPtr,
@@ -1100,8 +1107,8 @@ MODULE_SCOPE void TkTextIndexOfX(TkText *textPtr, int x,
MODULE_SCOPE int TkTextIndexYPixels(TkText *textPtr,
const TkTextIndex *indexPtr);
MODULE_SCOPE TkTextSegment *TkTextIndexToSeg(const TkTextIndex *indexPtr,
- int *offsetPtr);
-MODULE_SCOPE void TkTextLostSelection(ClientData clientData);
+ Tcl_Size *offsetPtr);
+MODULE_SCOPE void TkTextLostSelection(void *clientData);
MODULE_SCOPE TkTextIndex *TkTextMakeCharIndex(TkTextBTree tree, TkText *textPtr,
int lineIndex, int charIndex,
TkTextIndex *indexPtr);
@@ -1115,14 +1122,14 @@ MODULE_SCOPE int TkTextMakePixelIndex(TkText *textPtr,
int pixelIndex, TkTextIndex *indexPtr);
MODULE_SCOPE void TkTextInvalidateLineMetrics(
TkSharedText *sharedTextPtr, TkText *textPtr,
- TkTextLine *linePtr, int lineCount, int action);
+ TkTextLine *linePtr, int lineCount, TkTextInvalidateAction action);
MODULE_SCOPE int TkTextUpdateLineMetrics(TkText *textPtr, int lineNum,
int endLine, int doThisMuch);
MODULE_SCOPE int TkTextUpdateOneLine(TkText *textPtr,
TkTextLine *linePtr, int pixelHeight,
TkTextIndex *indexPtr, int partialCalc);
MODULE_SCOPE int TkTextMarkCmd(TkText *textPtr, Tcl_Interp *interp,
- int objc, Tcl_Obj *const objv[]);
+ Tcl_Size objc, Tcl_Obj *const objv[]);
MODULE_SCOPE int TkTextMarkNameToIndex(TkText *textPtr,
const char *name, TkTextIndex *indexPtr);
MODULE_SCOPE void TkTextMarkSegToIndex(TkText *textPtr,
@@ -1142,28 +1149,28 @@ MODULE_SCOPE void TkTextRedrawTag(TkSharedText *sharedTextPtr,
int withTag);
MODULE_SCOPE void TkTextRelayoutWindow(TkText *textPtr, int mask);
MODULE_SCOPE int TkTextScanCmd(TkText *textPtr, Tcl_Interp *interp,
- int objc, Tcl_Obj *const objv[]);
+ Tcl_Size objc, Tcl_Obj *const objv[]);
MODULE_SCOPE int TkTextSeeCmd(TkText *textPtr, Tcl_Interp *interp,
- int objc, Tcl_Obj *const objv[]);
-MODULE_SCOPE int TkTextSegToOffset(const TkTextSegment *segPtr,
+ Tcl_Size objc, Tcl_Obj *const objv[]);
+MODULE_SCOPE Tcl_Size TkTextSegToOffset(const TkTextSegment *segPtr,
const TkTextLine *linePtr);
MODULE_SCOPE void TkTextSetYView(TkText *textPtr,
TkTextIndex *indexPtr, int pickPlace);
MODULE_SCOPE int TkTextTagCmd(TkText *textPtr, Tcl_Interp *interp,
- int objc, Tcl_Obj *const objv[]);
+ Tcl_Size objc, Tcl_Obj *const objv[]);
MODULE_SCOPE int TkTextImageCmd(TkText *textPtr, Tcl_Interp *interp,
- int objc, Tcl_Obj *const objv[]);
+ Tcl_Size objc, Tcl_Obj *const objv[]);
MODULE_SCOPE int TkTextImageIndex(TkText *textPtr,
const char *name, TkTextIndex *indexPtr);
MODULE_SCOPE int TkTextWindowCmd(TkText *textPtr, Tcl_Interp *interp,
- int objc, Tcl_Obj *const objv[]);
+ Tcl_Size objc, Tcl_Obj *const objv[]);
MODULE_SCOPE int TkTextWindowIndex(TkText *textPtr, const char *name,
TkTextIndex *indexPtr);
MODULE_SCOPE int TkTextYviewCmd(TkText *textPtr, Tcl_Interp *interp,
- int objc, Tcl_Obj *const objv[]);
+ Tcl_Size objc, Tcl_Obj *const objv[]);
MODULE_SCOPE void TkTextWinFreeClient(Tcl_HashEntry *hPtr,
TkTextEmbWindowClient *client);
-MODULE_SCOPE void TkTextRunAfterSyncCmd(ClientData clientData);
+MODULE_SCOPE void TkTextRunAfterSyncCmd(void *clientData);
MODULE_SCOPE int TkTextIndexAdjustToStartEnd(TkText *textPtr,
TkTextIndex *indexPtr, int err);
#endif /* _TKTEXT */
diff --git a/generic/tkTextBTree.c b/generic/tkTextBTree.c
index 88924e4..7a65ee1 100644
--- a/generic/tkTextBTree.c
+++ b/generic/tkTextBTree.c
@@ -5,8 +5,8 @@
* for Tk's text widget and implements character and toggle segment
* types.
*
- * Copyright (c) 1992-1994 The Regents of the University of California.
- * Copyright (c) 1994-1995 Sun Microsystems, Inc.
+ * Copyright © 1992-1994 The Regents of the University of California.
+ * Copyright © 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.
@@ -44,7 +44,7 @@
typedef struct Summary {
TkTextTag *tagPtr; /* Handle for tag. */
- int toggleCount; /* Number of transitions into or out of this
+ Tcl_Size toggleCount; /* Number of transitions into or out of this
* tag that occur in the subtree rooted at
* this node. */
struct Summary *nextPtr; /* Next in list of all tags for same node, or
@@ -63,7 +63,7 @@ typedef struct Node {
Summary *summaryPtr; /* First in malloc-ed list of info about tags
* in this subtree (NULL if no tag info in the
* subtree). */
- int level; /* Level of this node in the B-tree. 0 refers
+ Tcl_Size level; /* Level of this node in the B-tree. 0 refers
* to the bottom of the tree (children are
* lines, not nodes). */
union { /* First in linked list of children. */
@@ -105,7 +105,7 @@ typedef struct BTree {
int clients; /* Number of clients of this B-tree. */
int pixelReferences; /* Number of clients of this B-tree which care
* about pixel heights. */
- int stateEpoch; /* Updated each time any aspect of the B-tree
+ Tcl_Size stateEpoch; /* Updated each time any aspect of the B-tree
* changes. */
TkSharedText *sharedTextPtr;/* Used to find tagTable in consistency
* checking code, and to access list of all
@@ -140,10 +140,10 @@ int tkBTreeDebug = 0;
* Macros that determine how much space to allocate for new segments:
*/
-#define CSEG_SIZE(chars) ((unsigned)(Tk_Offset(TkTextSegment, body) \
- + 1 + (chars)))
-#define TSEG_SIZE ((unsigned)(Tk_Offset(TkTextSegment, body) \
- + sizeof(TkTextToggle)))
+#define CSEG_SIZE(chars) (offsetof(TkTextSegment, body) \
+ + 1 + (chars))
+#define TSEG_SIZE (offsetof(TkTextSegment, body) \
+ + sizeof(TkTextToggle))
/*
* Forward declarations for functions defined in this file:
@@ -154,14 +154,14 @@ static int AdjustPixelClient(BTree *treePtr, int defaultHeight,
int useReference, int newPixelReferences,
int *counting);
static void ChangeNodeToggleCount(Node *nodePtr,
- TkTextTag *tagPtr, int delta);
+ TkTextTag *tagPtr, Tcl_Size delta);
static void CharCheckProc(TkTextSegment *segPtr,
TkTextLine *linePtr);
static int CharDeleteProc(TkTextSegment *segPtr,
TkTextLine *linePtr, int treeGone);
static TkTextSegment * CharCleanupProc(TkTextSegment *segPtr,
TkTextLine *linePtr);
-static TkTextSegment * CharSplitProc(TkTextSegment *segPtr, int index);
+static TkTextSegment * CharSplitProc(TkTextSegment *segPtr, Tcl_Size index);
static void CheckNodeConsistency(Node *nodePtr, int references);
static void CleanupLine(TkTextLine *linePtr);
static void DeleteSummaries(Summary *tagPtr);
@@ -501,7 +501,7 @@ TkBTreeDestroy(
*----------------------------------------------------------------------
*/
-int
+Tcl_Size
TkBTreeEpoch(
TkTextBTree tree) /* Tree to get epoch for. */
{
@@ -1029,7 +1029,7 @@ TkBTreeInsertChars(
* this line). */
TkTextSegment *segPtr;
TkTextLine *newLinePtr;
- int chunkSize; /* # characters in current chunk. */
+ size_t chunkSize; /* # characters in current chunk. */
const char *eol; /* Pointer to character just after last one in
* current chunk. */
int changeToLineCount; /* Counts change to total number of lines in
@@ -1198,7 +1198,7 @@ SplitSeg(
{
TkTextSegment *prevPtr, *segPtr;
TkTextLine *linePtr;
- int count = indexPtr->byteIndex;
+ Tcl_Size count = indexPtr->byteIndex;
linePtr = indexPtr->linePtr;
prevPtr = NULL;
@@ -2019,32 +2019,32 @@ TkBTreeLinesTo(
}
}
if (textPtr != NULL) {
- /*
- * The index to return must be relative to textPtr, not to the entire
- * tree. Take care to never return a negative index when linePtr
- * denotes a line before -startline, or an index larger than the
- * number of lines in textPtr when linePtr is a line past -endline.
- */
-
- int indexStart, indexEnd;
-
- if (textPtr->start != NULL) {
- indexStart = TkBTreeLinesTo(NULL, textPtr->start);
- } else {
- indexStart = 0;
- }
- if (textPtr->end != NULL) {
- indexEnd = TkBTreeLinesTo(NULL, textPtr->end);
- } else {
- indexEnd = TkBTreeNumLines(textPtr->sharedTextPtr->tree, NULL);
- }
- if (index < indexStart) {
- index = 0;
- } else if (index > indexEnd) {
- index = TkBTreeNumLines(textPtr->sharedTextPtr->tree, textPtr);
- } else {
- index -= indexStart;
- }
+ /*
+ * The index to return must be relative to textPtr, not to the entire
+ * tree. Take care to never return a negative index when linePtr
+ * denotes a line before -startline, or an index larger than the
+ * number of lines in textPtr when linePtr is a line past -endline.
+ */
+
+ int indexStart, indexEnd;
+
+ if (textPtr->start != NULL) {
+ indexStart = TkBTreeLinesTo(NULL, textPtr->start);
+ } else {
+ indexStart = 0;
+ }
+ if (textPtr->end != NULL) {
+ indexEnd = TkBTreeLinesTo(NULL, textPtr->end);
+ } else {
+ indexEnd = TkBTreeNumLines(textPtr->sharedTextPtr->tree, NULL);
+ }
+ if (index < indexStart) {
+ index = 0;
+ } else if (index > indexEnd) {
+ index = TkBTreeNumLines(textPtr->sharedTextPtr->tree, textPtr);
+ } else {
+ index -= indexStart;
+ }
}
return index;
}
@@ -2314,12 +2314,12 @@ ChangeNodeToggleCount(
Node *nodePtr, /* Node whose toggle count for a tag must be
* changed. */
TkTextTag *tagPtr, /* Information about tag. */
- int delta) /* Amount to add to current toggle count for
+ Tcl_Size delta) /* Amount to add to current toggle count for
* tag (may be negative). */
{
Summary *summaryPtr, *prevPtr;
Node *node2Ptr;
- int rootLevel; /* Level of original tag root. */
+ Tcl_Size rootLevel; /* Level of original tag root. */
tagPtr->toggleCount += delta;
if (tagPtr->tagRootPtr == NULL) {
@@ -2366,7 +2366,7 @@ ChangeNodeToggleCount(
* first place).
*/
- Tcl_Panic("ChangeNodeToggleCount: bad toggle count (%d) max (%d)",
+ Tcl_Panic("ChangeNodeToggleCount: bad toggle count (%" TCL_SIZE_MODIFIER "d) max (%" TCL_SIZE_MODIFIER "d)",
summaryPtr->toggleCount, tagPtr->toggleCount);
}
@@ -2682,7 +2682,7 @@ TkBTreeStartSearch(
/* Where to store information about search's
* progress. */
{
- int offset;
+ Tcl_Size offset;
TkTextIndex index0; /* First index of the tag. */
TkTextSegment *seg0Ptr; /* First segment of the tag. */
@@ -2778,7 +2778,7 @@ TkBTreeStartSearchBack(
/* Where to store information about search's
* progress. */
{
- int offset;
+ Tcl_Size offset;
TkTextIndex index0; /* Last index of the tag. */
TkTextIndex backOne; /* One character before starting index. */
TkTextSegment *seg0Ptr; /* Last segment of the tag. */
@@ -3272,7 +3272,7 @@ TkBTreeCharTagged(
toggleSegPtr = NULL;
for (index = 0, segPtr = indexPtr->linePtr->segPtr;
- (index + segPtr->size) <= indexPtr->byteIndex;
+ (index + (int)segPtr->size) <= indexPtr->byteIndex;
index += segPtr->size, segPtr = segPtr->nextPtr) {
if (((segPtr->typePtr == &tkTextToggleOnType)
|| (segPtr->typePtr == &tkTextToggleOffType))
@@ -3369,7 +3369,7 @@ TkBTreeGetTags(
const TkText *textPtr, /* If non-NULL, then only return tags for this
* text widget (when there are peer
* widgets). */
- int *numTagsPtr) /* Store number of tags found at this
+ Tcl_Size *numTagsPtr) /* Store number of tags found at this
* location. */
{
Node *nodePtr;
@@ -3392,7 +3392,7 @@ TkBTreeGetTags(
linePtr = indexPtr->linePtr;
index = 0;
segPtr = linePtr->segPtr;
- while ((index + segPtr->size) <= indexPtr->byteIndex) {
+ while ((index + (int)segPtr->size) <= indexPtr->byteIndex) {
if ((segPtr->typePtr == &tkTextToggleOnType)
|| (segPtr->typePtr == &tkTextToggleOffType)) {
IncCount(segPtr->body.toggle.tagPtr, 1, &tagInfo);
@@ -3520,10 +3520,10 @@ TkTextIsElided(
TkTextLine *siblingLinePtr;
TkTextSegment *segPtr;
TkTextTag *tagPtr = NULL;
- int i, index;
+ Tcl_Size i;
TkTextElideInfo *infoPtr;
TkTextLine *linePtr;
- int elide;
+ int elide, index;
if (elideInfo == NULL) {
infoPtr = (TkTextElideInfo *)ckalloc(sizeof(TkTextElideInfo));
@@ -3556,11 +3556,11 @@ TkTextIsElided(
index = 0;
linePtr = indexPtr->linePtr;
segPtr = linePtr->segPtr;
- while ((index + segPtr->size) <= indexPtr->byteIndex) {
+ while ((index + (int)segPtr->size) <= indexPtr->byteIndex) {
if ((segPtr->typePtr == &tkTextToggleOnType)
|| (segPtr->typePtr == &tkTextToggleOffType)) {
tagPtr = segPtr->body.toggle.tagPtr;
- if (tagPtr->elideString != NULL) {
+ if (tagPtr->elide >= 0) {
infoPtr->tagPtrs[tagPtr->priority] = tagPtr;
infoPtr->tagCnts[tagPtr->priority]++;
}
@@ -3600,7 +3600,7 @@ TkTextIsElided(
if ((segPtr->typePtr == &tkTextToggleOnType)
|| (segPtr->typePtr == &tkTextToggleOffType)) {
tagPtr = segPtr->body.toggle.tagPtr;
- if (tagPtr->elideString != NULL) {
+ if (tagPtr->elide >= 0) {
infoPtr->tagPtrs[tagPtr->priority] = tagPtr;
infoPtr->tagCnts[tagPtr->priority]++;
}
@@ -3624,7 +3624,7 @@ TkTextIsElided(
summaryPtr = summaryPtr->nextPtr) {
if (summaryPtr->toggleCount & 1) {
tagPtr = summaryPtr->tagPtr;
- if (tagPtr->elideString != NULL) {
+ if (tagPtr->elide >= 0) {
infoPtr->tagPtrs[tagPtr->priority] = tagPtr;
infoPtr->tagCnts[tagPtr->priority] +=
summaryPtr->toggleCount;
@@ -3642,7 +3642,7 @@ TkTextIsElided(
infoPtr->elidePriority = -1;
for (i = infoPtr->numTags-1; i >=0; i--) {
if (infoPtr->tagCnts[i] & 1) {
- infoPtr->elide = infoPtr->tagPtrs[i]->elide;
+ infoPtr->elide = infoPtr->tagPtrs[i]->elide > 0;
/*
* Note: i == infoPtr->tagPtrs[i]->priority
@@ -3790,7 +3790,7 @@ TkBTreeCheck(
TkTextTag *tagPtr;
Tcl_HashEntry *entryPtr;
Tcl_HashSearch search;
- int count;
+ Tcl_Size count;
/*
* Make sure that the tag toggle counts and the tag root pointers are OK.
@@ -3802,7 +3802,7 @@ TkBTreeCheck(
nodePtr = tagPtr->tagRootPtr;
if (nodePtr == NULL) {
if (tagPtr->toggleCount != 0) {
- Tcl_Panic("TkBTreeCheck found \"%s\" with toggles (%d) but no root",
+ Tcl_Panic("TkBTreeCheck found \"%s\" with toggles (%" TCL_SIZE_MODIFIER "d) but no root",
tagPtr->name, tagPtr->toggleCount);
}
continue; /* No ranges for the tag. */
@@ -3810,7 +3810,7 @@ TkBTreeCheck(
Tcl_Panic("TkBTreeCheck found root for \"%s\" with no toggles",
tagPtr->name);
} else if (tagPtr->toggleCount & 1) {
- Tcl_Panic("TkBTreeCheck found odd toggle count for \"%s\" (%d)",
+ Tcl_Panic("TkBTreeCheck found odd toggle count for \"%s\" (%" TCL_SIZE_MODIFIER "d)",
tagPtr->name, tagPtr->toggleCount);
}
for (summaryPtr = nodePtr->summaryPtr; summaryPtr != NULL;
@@ -3844,7 +3844,7 @@ TkBTreeCheck(
}
}
if (count != tagPtr->toggleCount) {
- Tcl_Panic("TkBTreeCheck toggleCount (%d) wrong for \"%s\" should be (%d)",
+ Tcl_Panic("TkBTreeCheck toggleCount (%" TCL_SIZE_MODIFIER "d) wrong for \"%s\" should be (%" TCL_SIZE_MODIFIER "d)",
tagPtr->toggleCount, tagPtr->name, count);
}
}
@@ -3893,7 +3893,7 @@ TkBTreeCheck(
}
if (segPtr->size != 1) {
Tcl_Panic("TkBTreeCheck: last line has wrong # characters: %d",
- segPtr->size);
+ (int)segPtr->size);
}
if ((segPtr->body.chars[0] != '\n') || (segPtr->body.chars[1] != 0)) {
Tcl_Panic("TkBTreeCheck: last line had bad value: %s",
@@ -3930,8 +3930,9 @@ CheckNodeConsistency(
Summary *summaryPtr, *summaryPtr2;
TkTextLine *linePtr;
TkTextSegment *segPtr;
- int numChildren, numLines, toggleCount, minChildren, i;
+ int numChildren, numLines, minChildren, i;
int *numPixels;
+ Tcl_Size toggleCount;
int pixels[PIXEL_CLIENTS];
if (nodePtr->parentPtr != NULL) {
@@ -3996,7 +3997,7 @@ CheckNodeConsistency(
Tcl_Panic("CheckNodeConsistency: node doesn't point to parent");
}
if (childNodePtr->level != (nodePtr->level-1)) {
- Tcl_Panic("CheckNodeConsistency: level mismatch (%d %d)",
+ Tcl_Panic("CheckNodeConsistency: level mismatch (%" TCL_SIZE_MODIFIER "d %" TCL_SIZE_MODIFIER "d)",
nodePtr->level, childNodePtr->level);
}
CheckNodeConsistency(childNodePtr, references);
@@ -4077,7 +4078,7 @@ CheckNodeConsistency(
}
}
if (toggleCount != summaryPtr->toggleCount) {
- Tcl_Panic("CheckNodeConsistency: mismatch in toggleCount (%d %d)",
+ Tcl_Panic("CheckNodeConsistency: mismatch in toggleCount (%" TCL_SIZE_MODIFIER "d %" TCL_SIZE_MODIFIER "d)",
toggleCount, summaryPtr->toggleCount);
}
for (summaryPtr2 = summaryPtr->nextPtr; summaryPtr2 != NULL;
@@ -4573,7 +4574,7 @@ TkBTreeNumPixels(
static TkTextSegment *
CharSplitProc(
TkTextSegment *segPtr, /* Pointer to segment to split. */
- int index) /* Position within segment at which to
+ Tcl_Size index) /* Position within segment at which to
* split. */
{
TkTextSegment *newPtr1, *newPtr2;
@@ -4693,7 +4694,7 @@ CharCheckProc(
* to each other: they should be merged together.
*/
- if (segPtr->size <= 0) {
+ if (segPtr->size + 1 <= 1) {
Tcl_Panic("CharCheckProc: segment has size <= 0");
}
if (strlen(segPtr->body.chars) != (size_t)segPtr->size) {
diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c
index b34a255..a432a24 100644
--- a/generic/tkTextDisp.c
+++ b/generic/tkTextDisp.c
@@ -6,8 +6,8 @@
* widgets. (Well, strictly, each TkTextLine and B-tree node caches its
* last observed pixel height, but that information originates here).
*
- * Copyright (c) 1992-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1992-1994 The Regents of the University of California.
+ * Copyright © 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.
@@ -22,12 +22,9 @@
#include "tkUnixInt.h"
#elif defined(MAC_OSX_TK)
#include "tkMacOSXInt.h"
-#define OK_TO_LOG (!TkpWillDrawWidget(textPtr->tkwin))
#endif
-#if !defined(MAC_OSX_TK)
-#define OK_TO_LOG 1
-#endif
+#define OK_TO_LOG (!TkpWillDrawWidget(textPtr->tkwin))
/*
* "Calculations of line pixel heights and the size of the vertical
@@ -145,7 +142,7 @@ typedef struct StyleValues {
int overstrike; /* Non-zero means draw overstrike through
* text. */
XColor *overstrikeColor; /* Foreground color for overstrike through
- * text. */
+ * text. */
int rMargin; /* Right margin, in pixels. */
Tk_3DBorder rMarginColor; /* Color of right margin. */
int spacing1; /* Spacing above first dline in text line. */
@@ -153,11 +150,12 @@ typedef struct StyleValues {
int spacing3; /* Spacing below last dline in text line. */
TkTextTabArray *tabArrayPtr;/* Locations and types of tab stops (may be
* NULL). */
- int tabStyle; /* One of TK_TEXT_TABSTYLE_TABULAR or TK_TEXT_TABSTYLE_WORDPROCESSOR. */
+ TkTextTabStyle tabStyle; /* One of TK_TEXT_TABSTYLE_TABULAR
+ * or TK_TEXT_TABSTYLE_WORDPROCESSOR. */
int underline; /* Non-zero means draw underline underneath
* text. */
XColor *underlineColor; /* Foreground color for underline underneath
- * text. */
+ * text. */
int elide; /* Zero means draw text, otherwise not. */
TkWrapMode wrapMode; /* How to handle wrap-around for this tag.
* One of TEXT_WRAPMODE_CHAR,
@@ -171,7 +169,7 @@ typedef struct StyleValues {
*/
typedef struct TextStyle {
- int refCount; /* Number of times this structure is
+ Tcl_Size refCount; /* Number of times this structure is
* referenced in Chunks. */
GC bgGC; /* Graphics context for background. None means
* use widget background. */
@@ -216,7 +214,7 @@ typedef struct TextStyle {
#define LOG(toVar,what) \
if (OK_TO_LOG) \
- Tcl_SetVar2(textPtr->interp, toVar, NULL, (what), \
+ Tcl_SetVar2(textPtr->interp, toVar, NULL, (what), \
TCL_GLOBAL_ONLY|TCL_APPEND_VALUE|TCL_LIST_ELEMENT)
#define CLEAR(var) \
if (OK_TO_LOG) \
@@ -257,11 +255,11 @@ typedef struct DLine {
Tk_3DBorder lMarginColor; /* Background color of the area corresponding
* to the left margin of the display line. */
int lMarginWidth; /* Pixel width of the area corresponding to
- * the left margin. */
+ * the left margin. */
Tk_3DBorder rMarginColor; /* Background color of the area corresponding
* to the right margin of the display line. */
int rMarginWidth; /* Pixel width of the area corresponding to
- * the right margin. */
+ * the right margin. */
int length; /* Total length of line, in pixels. */
TkTextDispChunk *chunkPtr; /* Pointer to first chunk in list of all of
* those that are displayed on this line of
@@ -418,7 +416,7 @@ typedef struct TextDInfo {
* to so far... */
int metricPixelHeight; /* ...and this is for the height calculation
* so far...*/
- int metricEpoch; /* ...and this for the epoch of the partial
+ Tcl_Size metricEpoch; /* ...and this for the epoch of the partial
* calculation so it can be cancelled if
* things change once more. This field will be
* -1 if there is no long-line calculation in
@@ -443,7 +441,7 @@ typedef struct TextDInfo {
#ifndef TK_LAYOUT_WITH_BASE_CHUNKS
typedef struct CharInfo {
- int numBytes; /* Number of bytes to display. */
+ Tcl_Size numBytes; /* Number of bytes to display. */
char chars[TKFLEXARRAY]; /* UTF characters to display.
* Allocated as large as necessary. THIS MUST BE THE LAST
* FIELD IN THE STRUCTURE. */
@@ -455,7 +453,7 @@ typedef struct CharInfo {
TkTextDispChunk *baseChunkPtr;
int baseOffset; /* Starting offset in base chunk
* baseChars. */
- int numBytes; /* Number of bytes that belong to this
+ Tcl_Size numBytes; /* Number of bytes that belong to this
* chunk. */
const char *chars; /* UTF characters to display. Actually points
* into the baseChars of the base chunk. Only
@@ -538,10 +536,10 @@ static void AdjustForTab(TkText *textPtr,
TkTextTabArray *tabArrayPtr, int index,
TkTextDispChunk *chunkPtr);
static void CharBboxProc(TkText *textPtr,
- TkTextDispChunk *chunkPtr, int index, int y,
+ TkTextDispChunk *chunkPtr, Tcl_Size index, int y,
int lineHeight, int baseline, int *xPtr,
int *yPtr, int *widthPtr, int *heightPtr);
-static int CharChunkMeasureChars(TkTextDispChunk *chunkPtr,
+static Tcl_Size CharChunkMeasureChars(TkTextDispChunk *chunkPtr,
const char *chars, int charsLen,
int start, int end, int startX, int maxX,
int flags, int *nextX);
@@ -549,7 +547,7 @@ static void CharDisplayProc(TkText *textPtr,
TkTextDispChunk *chunkPtr, int x, int y,
int height, int baseline, Display *display,
Drawable dst, int screenY);
-static int CharMeasureProc(TkTextDispChunk *chunkPtr, int x);
+static Tcl_Size CharMeasureProc(TkTextDispChunk *chunkPtr, int x);
static void CharUndisplayProc(TkText *textPtr,
TkTextDispChunk *chunkPtr);
#ifdef TK_LAYOUT_WITH_BASE_CHUNKS
@@ -565,29 +563,29 @@ static void RemoveFromBaseChunk(TkTextDispChunk *chunkPtr);
* tag toggle-filled elided region.
*/
static void ElideBboxProc(TkText *textPtr,
- TkTextDispChunk *chunkPtr, int index, int y,
+ TkTextDispChunk *chunkPtr, Tcl_Size index, int y,
int lineHeight, int baseline, int *xPtr,
int *yPtr, int *widthPtr, int *heightPtr);
-static int ElideMeasureProc(TkTextDispChunk *chunkPtr, int x);
+static Tcl_Size ElideMeasureProc(TkTextDispChunk *chunkPtr, int x);
static void DisplayDLine(TkText *textPtr, DLine *dlPtr,
DLine *prevPtr, Pixmap pixmap);
static void DisplayLineBackground(TkText *textPtr, DLine *dlPtr,
DLine *prevPtr, Pixmap pixmap);
-static void DisplayText(ClientData clientData);
+static void DisplayText(void *clientData);
static DLine * FindDLine(TkText *textPtr, DLine *dlPtr,
- const TkTextIndex *indexPtr);
+ const TkTextIndex *indexPtr);
static void FreeDLines(TkText *textPtr, DLine *firstPtr,
DLine *lastPtr, int action);
static void FreeStyle(TkText *textPtr, TextStyle *stylePtr);
-static TextStyle * GetStyle(TkText *textPtr, const TkTextIndex *indexPtr);
-static void GetXView(Tcl_Interp *interp, TkText *textPtr,
+static TextStyle * GetStyle(const TkText *textPtr, const TkTextIndex *indexPtr);
+static void GetXView(Tcl_Interp *interp, const TkText *textPtr,
int report);
static void GetYView(Tcl_Interp *interp, TkText *textPtr,
int report);
static int GetYPixelCount(TkText *textPtr, DLine *dlPtr);
static DLine * LayoutDLine(TkText *textPtr,
const TkTextIndex *indexPtr);
-static int MeasureChars(Tk_Font tkfont, const char *source,
+static Tcl_Size MeasureChars(Tk_Font tkfont, const char *source,
int maxBytes, int rangeStart, int rangeLength,
int startX, int maxX, int flags, int *nextXPtr);
static void MeasureUp(TkText *textPtr,
@@ -597,7 +595,7 @@ static int NextTabStop(Tk_Font tkfont, int x, int tabOrigin);
static void UpdateDisplayInfo(TkText *textPtr);
static void YScrollByLines(TkText *textPtr, int offset);
static void YScrollByPixels(TkText *textPtr, int offset);
-static int SizeOfTab(TkText *textPtr, int tabStyle,
+static int SizeOfTab(TkText *textPtr, TkTextTabStyle tabStyle,
TkTextTabArray *tabArrayPtr, int *indexPtr, int x,
int maxX);
static void TextChanged(TkText *textPtr,
@@ -608,7 +606,7 @@ static void TextRedrawTag(TkText *textPtr,
TkTextIndex *index1Ptr, TkTextIndex *index2Ptr,
TkTextTag *tagPtr, int withTag);
static void TextInvalidateLineMetrics(TkText *textPtr,
- TkTextLine *linePtr, int lineCount, int action);
+ TkTextLine *linePtr, int lineCount, TkTextInvalidateAction action);
static int CalculateDisplayLineHeight(TkText *textPtr,
const TkTextIndex *indexPtr, int *byteCountPtr,
int *mergedLinePtr);
@@ -617,14 +615,14 @@ static void DlineIndexOfX(TkText *textPtr,
static int DlineXOfIndex(TkText *textPtr,
DLine *dlPtr, int byteIndex);
static int TextGetScrollInfoObj(Tcl_Interp *interp,
- TkText *textPtr, int objc,
+ TkText *textPtr, Tcl_Size objc,
Tcl_Obj *const objv[], double *dblPtr,
int *intPtr);
-static void AsyncUpdateLineMetrics(ClientData clientData);
+static void AsyncUpdateLineMetrics(void *clientData);
static void GenerateWidgetViewSyncEvent(TkText *textPtr, Bool InSync);
-static void AsyncUpdateYScrollbar(ClientData clientData);
-static int IsStartOfNotMergedLine(TkText *textPtr,
- const TkTextIndex *indexPtr);
+static void AsyncUpdateYScrollbar(void *clientData);
+static int IsStartOfNotMergedLine(const TkText *textPtr,
+ const TkTextIndex *indexPtr);
/*
* Result values returned by TextGetScrollInfoObj:
@@ -768,7 +766,7 @@ TkTextFreeDInfo(
static TextStyle *
GetStyle(
- TkText *textPtr, /* Overall information about text widget. */
+ const TkText *textPtr, /* Overall information about text widget. */
const TkTextIndex *indexPtr)/* The character in the text for which display
* information is wanted. */
{
@@ -777,7 +775,8 @@ GetStyle(
StyleValues styleValues;
TextStyle *stylePtr;
Tcl_HashEntry *hPtr;
- int numTags, isNew, i;
+ Tcl_Size numTags, i;
+ int isNew;
int isSelected;
XGCValues gcValues;
unsigned long mask;
@@ -785,13 +784,13 @@ GetStyle(
* The variables below keep track of the highest-priority specification
* that has occurred for each of the various fields of the StyleValues.
*/
- int borderPrio, borderWidthPrio, reliefPrio, bgStipplePrio;
- int fgPrio, fontPrio, fgStipplePrio;
- int underlinePrio, elidePrio, justifyPrio, offsetPrio;
- int lMargin1Prio, lMargin2Prio, rMarginPrio;
- int lMarginColorPrio, rMarginColorPrio;
- int spacing1Prio, spacing2Prio, spacing3Prio;
- int overstrikePrio, tabPrio, tabStylePrio, wrapPrio;
+ Tcl_Size borderPrio, borderWidthPrio, reliefPrio, bgStipplePrio;
+ Tcl_Size fgPrio, fontPrio, fgStipplePrio;
+ Tcl_Size underlinePrio, elidePrio, justifyPrio, offsetPrio;
+ Tcl_Size lMargin1Prio, lMargin2Prio, rMarginPrio;
+ Tcl_Size lMarginColorPrio, rMarginColorPrio;
+ Tcl_Size spacing1Prio, spacing2Prio, spacing3Prio;
+ Tcl_Size overstrikePrio, tabPrio, tabStylePrio, wrapPrio;
/*
* Find out what tags are present for the character, then compute a
@@ -824,19 +823,19 @@ GetStyle(
isSelected = 0;
for (i = 0 ; i < numTags; i++) {
- if (textPtr->selTagPtr == tagPtrs[i]) {
- isSelected = 1;
- break;
- }
+ if (textPtr->selTagPtr == tagPtrs[i]) {
+ isSelected = 1;
+ break;
+ }
}
for (i = 0 ; i < numTags; i++) {
Tk_3DBorder border;
- XColor *fgColor;
+ XColor *fgColor;
tagPtr = tagPtrs[i];
border = tagPtr->border;
- fgColor = tagPtr->fgColor;
+ fgColor = tagPtr->fgColor;
/*
* If this is the selection tag, and inactiveSelBorder is NULL (the
@@ -856,13 +855,13 @@ GetStyle(
border = textPtr->inactiveSelBorder;
}
- if ((tagPtr->selBorder != NULL) && (isSelected)) {
- border = tagPtr->selBorder;
- }
+ if ((tagPtr->selBorder != NULL) && (isSelected)) {
+ border = tagPtr->selBorder;
+ }
- if ((tagPtr->selFgColor != NULL) && isSelected) {
- fgColor = tagPtr->selFgColor;
- }
+ if ((tagPtr->selFgColor != NULL) && isSelected) {
+ fgColor = tagPtr->selFgColor;
+ }
if ((border != NULL) && (tagPtr->priority > borderPrio)) {
styleValues.border = border;
@@ -874,7 +873,7 @@ GetStyle(
styleValues.borderWidth = tagPtr->borderWidth;
borderWidthPrio = tagPtr->priority;
}
- if ((tagPtr->reliefString != NULL)
+ if ((tagPtr->relief != TK_RELIEF_NULL)
&& (tagPtr->priority > reliefPrio)) {
if (styleValues.border == NULL) {
styleValues.border = textPtr->border;
@@ -900,17 +899,17 @@ GetStyle(
styleValues.fgStipple = tagPtr->fgStipple;
fgStipplePrio = tagPtr->priority;
}
- if ((tagPtr->justifyString != NULL)
+ if ((tagPtr->justify != TK_JUSTIFY_NULL)
&& (tagPtr->priority > justifyPrio)) {
styleValues.justify = tagPtr->justify;
justifyPrio = tagPtr->priority;
}
- if ((tagPtr->lMargin1String != NULL)
+ if ((tagPtr->lMargin1 != INT_MIN)
&& (tagPtr->priority > lMargin1Prio)) {
styleValues.lMargin1 = tagPtr->lMargin1;
lMargin1Prio = tagPtr->priority;
}
- if ((tagPtr->lMargin2String != NULL)
+ if ((tagPtr->lMargin2 != INT_MIN)
&& (tagPtr->priority > lMargin2Prio)) {
styleValues.lMargin2 = tagPtr->lMargin2;
lMargin2Prio = tagPtr->priority;
@@ -920,22 +919,22 @@ GetStyle(
styleValues.lMarginColor = tagPtr->lMarginColor;
lMarginColorPrio = tagPtr->priority;
}
- if ((tagPtr->offsetString != NULL)
+ if ((tagPtr->offset != INT_MIN)
&& (tagPtr->priority > offsetPrio)) {
styleValues.offset = tagPtr->offset;
offsetPrio = tagPtr->priority;
}
- if ((tagPtr->overstrikeString != NULL)
+ if ((tagPtr->overstrike >= 0)
&& (tagPtr->priority > overstrikePrio)) {
- styleValues.overstrike = tagPtr->overstrike;
+ styleValues.overstrike = tagPtr->overstrike > 0;
overstrikePrio = tagPtr->priority;
- if (tagPtr->overstrikeColor != NULL) {
- styleValues.overstrikeColor = tagPtr->overstrikeColor;
- } else if (fgColor != NULL) {
- styleValues.overstrikeColor = fgColor;
- }
+ if (tagPtr->overstrikeColor != NULL) {
+ styleValues.overstrikeColor = tagPtr->overstrikeColor;
+ } else if (fgColor != NULL) {
+ styleValues.overstrikeColor = fgColor;
+ }
}
- if ((tagPtr->rMarginString != NULL)
+ if ((tagPtr->rMargin != INT_MIN)
&& (tagPtr->priority > rMarginPrio)) {
styleValues.rMargin = tagPtr->rMargin;
rMarginPrio = tagPtr->priority;
@@ -945,17 +944,17 @@ GetStyle(
styleValues.rMarginColor = tagPtr->rMarginColor;
rMarginColorPrio = tagPtr->priority;
}
- if ((tagPtr->spacing1String != NULL)
+ if ((tagPtr->spacing1 != INT_MIN)
&& (tagPtr->priority > spacing1Prio)) {
styleValues.spacing1 = tagPtr->spacing1;
spacing1Prio = tagPtr->priority;
}
- if ((tagPtr->spacing2String != NULL)
+ if ((tagPtr->spacing2 != INT_MIN)
&& (tagPtr->priority > spacing2Prio)) {
styleValues.spacing2 = tagPtr->spacing2;
spacing2Prio = tagPtr->priority;
}
- if ((tagPtr->spacing3String != NULL)
+ if ((tagPtr->spacing3 != INT_MIN)
&& (tagPtr->priority > spacing3Prio)) {
styleValues.spacing3 = tagPtr->spacing3;
spacing3Prio = tagPtr->priority;
@@ -971,25 +970,23 @@ GetStyle(
styleValues.tabStyle = tagPtr->tabStyle;
tabStylePrio = tagPtr->priority;
}
- if ((tagPtr->underlineString != NULL)
+ if ((tagPtr->underline >= 0)
&& (tagPtr->priority > underlinePrio)) {
- styleValues.underline = tagPtr->underline;
+ styleValues.underline = tagPtr->underline > 0;
underlinePrio = tagPtr->priority;
- if (tagPtr->underlineColor != NULL) {
- styleValues.underlineColor = tagPtr->underlineColor;
- } else if (fgColor != NULL) {
- styleValues.underlineColor = fgColor;
- }
+ if (tagPtr->underlineColor != NULL) {
+ styleValues.underlineColor = tagPtr->underlineColor;
+ } else if (fgColor != NULL) {
+ styleValues.underlineColor = fgColor;
+ }
}
- if ((tagPtr->elideString != NULL)
+ if ((tagPtr->elide >= 0)
&& (tagPtr->priority > elidePrio)) {
- styleValues.elide = tagPtr->elide;
+ styleValues.elide = tagPtr->elide > 0;
elidePrio = tagPtr->priority;
}
- if (((tagPtr->wrapMode == TEXT_WRAPMODE_CHAR)
- || (tagPtr->wrapMode == TEXT_WRAPMODE_NONE)
- || (tagPtr->wrapMode == TEXT_WRAPMODE_WORD))
- && (tagPtr->priority > wrapPrio)) {
+ if (((tagPtr->wrapMode == TEXT_WRAPMODE_CHAR) || (tagPtr->wrapMode == TEXT_WRAPMODE_NONE)
+ || (tagPtr->wrapMode == TEXT_WRAPMODE_WORD)) && (tagPtr->priority > wrapPrio)) {
styleValues.wrapMode = tagPtr->wrapMode;
wrapPrio = tagPtr->priority;
}
@@ -1173,14 +1170,16 @@ LayoutDLine(
* chunk. */
TkTextTabArray *tabArrayPtr;/* Tab stops for line; taken from style for
* the first character on line. */
- int tabStyle; /* One of TK_TEXT_TABSTYLE_TABULAR or TK_TEXT_TABSTYLE_WORDPROCESSOR. */
+ TkTextTabStyle tabStyle; /* One of TK_TEXT_TABSTYLE_TABULAR
+ * or TK_TEXT_TABSTYLE_WORDPROCESSOR. */
int tabSize; /* Number of pixels consumed by current tab
* stop. */
TkTextDispChunk *lastCharChunkPtr;
/* Pointer to last chunk in display lines with
* numBytes > 0. Used to drop 0-sized chunks
* from the end of the line. */
- int byteOffset, ascent, descent, code, elide, elidesize;
+ Tcl_Size byteOffset;
+ int ascent, descent, code, elide, elidesize;
StyleValues *sValuePtr;
TkTextElideInfo info; /* Keep track of elide state. */
@@ -1246,7 +1245,7 @@ LayoutDLine(
* toggled off), or it's a new tag with higher priority.
*/
- if (tagPtr->elideString != NULL) {
+ if (tagPtr->elide >= 0) {
info.tagCnts[tagPtr->priority]++;
if (info.tagCnts[tagPtr->priority] & 1) {
info.tagPtrs[tagPtr->priority] = tagPtr;
@@ -1272,12 +1271,12 @@ LayoutDLine(
while (--info.elidePriority > 0) {
if (info.tagCnts[info.elidePriority] & 1) {
elide = info.tagPtrs[info.elidePriority]
- ->elide;
+ ->elide > 0;
break;
}
}
} else {
- elide = tagPtr->elide;
+ elide = tagPtr->elide > 0;
info.elidePriority = tagPtr->priority;
}
}
@@ -1381,7 +1380,7 @@ LayoutDLine(
if (elide && (lastChunkPtr != NULL)
&& (lastChunkPtr->displayProc == NULL /*ElideDisplayProc*/)) {
elidesize = segPtr->size - byteOffset;
- if (elidesize > 0) {
+ if (segPtr->size > byteOffset) {
curIndex.byteIndex += elidesize;
lastChunkPtr->numBytes += elidesize;
breakByteOffset = lastChunkPtr->breakIndex
@@ -1393,9 +1392,9 @@ LayoutDLine(
*/
} else if ((segPtr->typePtr == &tkTextToggleOffType)
|| (segPtr->typePtr == &tkTextToggleOnType)) {
- if (segPtr->body.toggle.tagPtr->elideString != NULL) {
+ if (segPtr->body.toggle.tagPtr->elide >= 0) {
elide = (segPtr->typePtr == &tkTextToggleOffType)
- ^ segPtr->body.toggle.tagPtr->elide;
+ ^ (segPtr->body.toggle.tagPtr->elide > 0);
}
}
@@ -1477,7 +1476,7 @@ LayoutDLine(
x = chunkPtr->stylePtr->sValuePtr->lMargin2;
}
- dlPtr->lMarginWidth = x;
+ dlPtr->lMarginWidth = x;
if (wrapMode == TEXT_WRAPMODE_NONE) {
maxX = -1;
} else {
@@ -1792,7 +1791,7 @@ LayoutDLine(
dlPtr->lMarginColor = sValuePtr->lMarginColor;
dlPtr->rMarginColor = sValuePtr->rMarginColor;
if (wrapMode != TEXT_WRAPMODE_NONE) {
- dlPtr->rMarginWidth = rMargin;
+ dlPtr->rMarginWidth = rMargin;
}
/*
@@ -2100,9 +2099,9 @@ UpdateDisplayInfo(
* widget.
*/
- lineNum = TkBTreeNumLines(textPtr->sharedTextPtr->tree,
- textPtr) - 1;
- bytesToCount = INT_MAX;
+ lineNum = TkBTreeNumLines(textPtr->sharedTextPtr->tree,
+ textPtr) - 1;
+ bytesToCount = INT_MAX;
} else {
lineNum = TkBTreeLinesTo(textPtr,
dInfoPtr->dLinePtr->index.linePtr);
@@ -2467,7 +2466,7 @@ DisplayDLine(
}
#ifdef TK_NO_DOUBLE_BUFFERING
- TkpClipDrawableToRect(display, pixmap, dInfoPtr->x, y + y_off,
+ Tk_ClipDrawableToRect(display, pixmap, dInfoPtr->x, y + y_off,
dInfoPtr->maxX - dInfoPtr->x, height);
#endif /* TK_NO_DOUBLE_BUFFERING */
@@ -2489,14 +2488,14 @@ DisplayDLine(
* Third, draw the background color of the left and right margins.
*/
if (dlPtr->lMarginColor != NULL) {
- Tk_Fill3DRectangle(textPtr->tkwin, pixmap, dlPtr->lMarginColor, 0, y,
- dlPtr->lMarginWidth + dInfoPtr->x - dInfoPtr->curXPixelOffset,
- dlPtr->height, 0, TK_RELIEF_FLAT);
+ Tk_Fill3DRectangle(textPtr->tkwin, pixmap, dlPtr->lMarginColor, 0, y,
+ dlPtr->lMarginWidth + dInfoPtr->x - dInfoPtr->curXPixelOffset,
+ dlPtr->height, 0, TK_RELIEF_FLAT);
}
if (dlPtr->rMarginColor != NULL) {
- Tk_Fill3DRectangle(textPtr->tkwin, pixmap, dlPtr->rMarginColor,
- dInfoPtr->maxX - dlPtr->rMarginWidth + dInfoPtr->curXPixelOffset,
- y, dlPtr->rMarginWidth, dlPtr->height, 0, TK_RELIEF_FLAT);
+ Tk_Fill3DRectangle(textPtr->tkwin, pixmap, dlPtr->rMarginColor,
+ dInfoPtr->maxX - dlPtr->rMarginWidth + dInfoPtr->curXPixelOffset,
+ y, dlPtr->rMarginWidth, dlPtr->height, 0, TK_RELIEF_FLAT);
}
/*
@@ -2506,7 +2505,7 @@ DisplayDLine(
* will obscure the character to its left.
*/
- if (textPtr->state == TK_TEXT_STATE_NORMAL) {
+ if (textPtr->state != TK_TEXT_STATE_DISABLED) {
for (chunkPtr = dlPtr->chunkPtr; (chunkPtr != NULL);
chunkPtr = chunkPtr->nextPtr) {
if (chunkPtr->displayProc == TkTextInsertDisplayProc) {
@@ -2592,7 +2591,7 @@ DisplayDLine(
dInfoPtr->x, y + y_off, (unsigned) (dInfoPtr->maxX - dInfoPtr->x),
(unsigned) height, dInfoPtr->x, dlPtr->y + y_off);
#else
- TkpClipDrawableToRect(display, pixmap, 0, 0, -1, -1);
+ Tk_ClipDrawableToRect(display, pixmap, 0, 0, -1, -1);
#endif /* TK_NO_DOUBLE_BUFFERING */
linesRedrawn++;
}
@@ -2721,15 +2720,15 @@ DisplayLineBackground(
rightX = leftX + 32767;
}
- /*
- * Prevent the borders from leaking on adjacent characters,
- * which would happen for too large border width.
- */
+ /*
+ * Prevent the borders from leaking on adjacent characters,
+ * which would happen for too large border width.
+ */
- bw = sValuePtr->borderWidth;
- if (leftX + sValuePtr->borderWidth > rightX) {
- bw = rightX - leftX;
- }
+ bw = sValuePtr->borderWidth;
+ if (leftX + sValuePtr->borderWidth > rightX) {
+ bw = rightX - leftX;
+ }
XFillRectangle(display, pixmap, chunkPtr->stylePtr->bgGC,
leftX + xOffset, y, (unsigned int) (rightX - leftX),
@@ -2836,23 +2835,23 @@ DisplayLineBackground(
matchRight = (nextPtr2 != NULL)
&& SAME_BACKGROUND(nextPtr2->stylePtr, chunkPtr->stylePtr);
if (matchLeft && !matchRight) {
- bw = sValuePtr->borderWidth;
- if (rightX2 - sValuePtr->borderWidth < leftX) {
- bw = rightX2 - leftX;
- }
+ bw = sValuePtr->borderWidth;
+ if (rightX2 - sValuePtr->borderWidth < leftX) {
+ bw = rightX2 - leftX;
+ }
if (sValuePtr->relief != TK_RELIEF_FLAT) {
Tk_3DVerticalBevel(textPtr->tkwin, pixmap, sValuePtr->border,
rightX2 - bw + xOffset, y, bw,
sValuePtr->borderWidth, 0, sValuePtr->relief);
}
- leftX = rightX2 - bw;
+ leftX = rightX2 - bw;
leftXIn = 0;
} else if (!matchLeft && matchRight
&& (sValuePtr->relief != TK_RELIEF_FLAT)) {
- bw = sValuePtr->borderWidth;
- if (rightX2 + sValuePtr->borderWidth > rightX) {
- bw = rightX - rightX2;
- }
+ bw = sValuePtr->borderWidth;
+ if (rightX2 + sValuePtr->borderWidth > rightX) {
+ bw = rightX - rightX2;
+ }
Tk_3DVerticalBevel(textPtr->tkwin, pixmap, sValuePtr->border,
rightX2 + xOffset, y, bw, sValuePtr->borderWidth,
1, sValuePtr->relief);
@@ -2946,10 +2945,10 @@ DisplayLineBackground(
matchRight = (nextPtr2 != NULL)
&& SAME_BACKGROUND(nextPtr2->stylePtr, chunkPtr->stylePtr);
if (matchLeft && !matchRight) {
- bw = sValuePtr->borderWidth;
- if (rightX2 - sValuePtr->borderWidth < leftX) {
- bw = rightX2 - leftX;
- }
+ bw = sValuePtr->borderWidth;
+ if (rightX2 - sValuePtr->borderWidth < leftX) {
+ bw = rightX2 - leftX;
+ }
if (sValuePtr->relief != TK_RELIEF_FLAT) {
Tk_3DVerticalBevel(textPtr->tkwin, pixmap, sValuePtr->border,
rightX2 - bw + xOffset,
@@ -2960,10 +2959,10 @@ DisplayLineBackground(
leftXIn = 1;
} else if (!matchLeft && matchRight
&& (sValuePtr->relief != TK_RELIEF_FLAT)) {
- bw = sValuePtr->borderWidth;
- if (rightX2 + sValuePtr->borderWidth > rightX) {
- bw = rightX - rightX2;
- }
+ bw = sValuePtr->borderWidth;
+ if (rightX2 + sValuePtr->borderWidth > rightX) {
+ bw = rightX - rightX2;
+ }
Tk_3DVerticalBevel(textPtr->tkwin, pixmap, sValuePtr->border,
rightX2 + xOffset,
y + dlPtr->height - sValuePtr->borderWidth, bw,
@@ -3014,7 +3013,7 @@ DisplayLineBackground(
static void
AsyncUpdateLineMetrics(
- ClientData clientData) /* Information about widget. */
+ void *clientData) /* Information about widget. */
{
TkText *textPtr = (TkText *)clientData;
TextDInfo *dInfoPtr = textPtr->dInfoPtr;
@@ -3023,7 +3022,7 @@ AsyncUpdateLineMetrics(
dInfoPtr->lineUpdateTimer = NULL;
if ((textPtr->tkwin == NULL) || (textPtr->flags & DESTROYED)
- || !Tk_IsMapped(textPtr->tkwin)) {
+ || !Tk_IsMapped(textPtr->tkwin)) {
/*
* The widget has been deleted, or is not mapped. Don't do anything.
*/
@@ -3083,27 +3082,27 @@ AsyncUpdateLineMetrics(
* after the afterSyncCmd pointer had been set to NULL.
*/
- if (textPtr->afterSyncCmd) {
- int code;
+ if (textPtr->afterSyncCmd) {
+ int code;
Tcl_CancelIdleCall(TkTextRunAfterSyncCmd, textPtr);
- Tcl_Preserve((ClientData) textPtr->interp);
- code = Tcl_EvalObjEx(textPtr->interp, textPtr->afterSyncCmd,
- TCL_EVAL_GLOBAL);
+ Tcl_Preserve(textPtr->interp);
+ code = Tcl_EvalObjEx(textPtr->interp, textPtr->afterSyncCmd,
+ TCL_EVAL_GLOBAL);
if (code == TCL_ERROR) {
- Tcl_AddErrorInfo(textPtr->interp, "\n (text sync)");
- Tcl_BackgroundError(textPtr->interp);
+ Tcl_AddErrorInfo(textPtr->interp, "\n (text sync)");
+ Tcl_BackgroundException(textPtr->interp, TCL_ERROR);
}
- Tcl_Release((ClientData) textPtr->interp);
- Tcl_DecrRefCount(textPtr->afterSyncCmd);
- textPtr->afterSyncCmd = NULL;
+ Tcl_Release(textPtr->interp);
+ Tcl_DecrRefCount(textPtr->afterSyncCmd);
+ textPtr->afterSyncCmd = NULL;
}
- /*
- * Fire the <<WidgetViewSync>> event since the widget view is in sync
- * with its internal data (actually it will be after the next trip
- * through the event loop, because the widget redraws at idle-time).
- */
- GenerateWidgetViewSyncEvent(textPtr, 1);
+ /*
+ * Fire the <<WidgetViewSync>> event since the widget view is in sync
+ * with its internal data (actually it will be after the next trip
+ * through the event loop, because the widget redraws at idle-time).
+ */
+ GenerateWidgetViewSyncEvent(textPtr, 1);
if (textPtr->refCount-- <= 1) {
ckfree(textPtr);
@@ -3173,7 +3172,7 @@ GenerateWidgetViewSyncEvent(
} else {
textPtr->dInfoPtr->flags |= OUT_OF_SYNC;
}
- TkSendVirtualEvent(textPtr->tkwin, "WidgetViewSync",
+ Tk_SendVirtualEvent(textPtr->tkwin, "WidgetViewSync",
Tcl_NewBooleanObj(NewSyncState));
}
}
@@ -3219,8 +3218,8 @@ TkTextUpdateLineMetrics(
int count = 0;
int totalLines = TkBTreeNumLines(textPtr->sharedTextPtr->tree, textPtr);
int fullUpdateRequested = (lineNum == 0 &&
- endLine == totalLines &&
- doThisMuch == -1);
+ endLine == totalLines &&
+ doThisMuch == -1);
if (totalLines == 0) {
/*
@@ -3259,6 +3258,7 @@ TkTextUpdateLineMetrics(
if (textPtr->dInfoPtr->metricEpoch == -1 && lineNum == endLine) {
+
/*
* We have looped over all lines, so we're done.
*/
@@ -3398,7 +3398,7 @@ TkTextUpdateLineMetrics(
GetYView(textPtr->interp, textPtr, 1);
}
if (fullUpdateRequested) {
- GenerateWidgetViewSyncEvent(textPtr, 1);
+ GenerateWidgetViewSyncEvent(textPtr, 1);
}
return lineNum;
}
@@ -3428,13 +3428,13 @@ TkTextUpdateLineMetrics(
void
TkTextInvalidateLineMetrics(
- TkSharedText *sharedTextPtr,/* Shared widget section for all peers, or
- * NULL. */
- TkText *textPtr, /* Widget record for text widget. */
- TkTextLine *linePtr, /* Invalidation starts from this line. */
- int lineCount, /* And includes this many following lines. */
- int action) /* Indicates what type of invalidation
- * occurred (insert, delete, or simple). */
+ TkSharedText *sharedTextPtr, /* Shared widget section for all peers, or
+ * NULL. */
+ TkText *textPtr, /* Widget record for text widget. */
+ TkTextLine *linePtr, /* Invalidation starts from this line. */
+ int lineCount, /* And includes this many following lines. */
+ TkTextInvalidateAction action) /* Indicates what type of invalidation
+ * occurred, TK_TEXT_INVALIDATE_(ONLY|INSERT|DELETE). */
{
if (sharedTextPtr == NULL) {
TextInvalidateLineMetrics(textPtr, linePtr, lineCount, action);
@@ -3449,11 +3449,11 @@ TkTextInvalidateLineMetrics(
static void
TextInvalidateLineMetrics(
- TkText *textPtr, /* Widget record for text widget. */
- TkTextLine *linePtr, /* Invalidation starts from this line. */
- int lineCount, /* And includes this many following lines. */
- int action) /* Indicates what type of invalidation
- * occurred (insert, delete, or simple). */
+ TkText *textPtr, /* Widget record for text widget. */
+ TkTextLine *linePtr, /* Invalidation starts from this line. */
+ int lineCount, /* And includes this many following lines. */
+ TkTextInvalidateAction action) /* Indicates what type of invalidation
+ * occurred, TK_TEXT_INVALIDATE_(ONLY|INSERT|DELETE). */
{
int fromLine;
TextDInfo *dInfoPtr = textPtr->dInfoPtr;
@@ -3671,7 +3671,7 @@ TkTextFindDisplayLineEnd(
while (1) {
DLine *dlPtr;
- int byteCount;
+ Tcl_Size byteCount;
TkTextIndex nextLineStart;
dlPtr = LayoutDLine(textPtr, &index);
@@ -3774,24 +3774,24 @@ CalculateDisplayLineHeight(
int pixelHeight;
if (tkTextDebug) {
- int oldtkTextDebug = tkTextDebug;
- /*
- * Check that the indexPtr we are given really is at the start of a
- * display line. The gymnastics with tkTextDebug is to prevent
- * failure of a test suite test, that checks that lines are rendered
- * exactly once. TkTextFindDisplayLineEnd is used here for checking
- * indexPtr but it calls LayoutDLine/FreeDLine which makes the
- * counting wrong. The debug mode shall therefore be switched off
- * when calling TkTextFindDisplayLineEnd.
- */
-
- TkTextIndex indexPtr2 = *indexPtr;
- tkTextDebug = 0;
- TkTextFindDisplayLineEnd(textPtr, &indexPtr2, 0, NULL);
- tkTextDebug = oldtkTextDebug;
- if (TkTextIndexCmp(&indexPtr2,indexPtr) != 0) {
- Tcl_Panic("CalculateDisplayLineHeight called with bad indexPtr");
- }
+ int oldtkTextDebug = tkTextDebug;
+ /*
+ * Check that the indexPtr we are given really is at the start of a
+ * display line. The gymnastics with tkTextDebug is to prevent
+ * failure of a test suite test, that checks that lines are rendered
+ * exactly once. TkTextFindDisplayLineEnd is used here for checking
+ * indexPtr but it calls LayoutDLine/FreeDLine which makes the
+ * counting wrong. The debug mode shall therefore be switched off
+ * when calling TkTextFindDisplayLineEnd.
+ */
+
+ TkTextIndex indexPtr2 = *indexPtr;
+ tkTextDebug = 0;
+ TkTextFindDisplayLineEnd(textPtr, &indexPtr2, 0, NULL);
+ tkTextDebug = oldtkTextDebug;
+ if (TkTextIndexCmp(&indexPtr2,indexPtr) != 0) {
+ Tcl_Panic("CalculateDisplayLineHeight called with bad indexPtr");
+ }
}
/*
@@ -3870,12 +3870,12 @@ TkTextIndexYPixels(
index = *indexPtr;
while (1) {
- TkTextFindDisplayLineEnd(textPtr, &index, 0, NULL);
- if (index.byteIndex == 0) {
- break;
- }
- TkTextIndexBackBytes(textPtr, &index, 1, &index);
- alreadyStartOfLine = 0;
+ TkTextFindDisplayLineEnd(textPtr, &index, 0, NULL);
+ if (index.byteIndex == 0) {
+ break;
+ }
+ TkTextIndexBackBytes(textPtr, &index, 1, &index);
+ alreadyStartOfLine = 0;
}
pixelHeight = TkBTreePixelsTo(textPtr, index.linePtr);
@@ -3887,7 +3887,7 @@ TkTextIndexYPixels(
*/
if (alreadyStartOfLine) {
- return pixelHeight;
+ return pixelHeight;
}
/*
@@ -3909,10 +3909,10 @@ TkTextIndexYPixels(
height = CalculateDisplayLineHeight(textPtr, &index, &bytes, NULL);
- TkTextIndexForwBytes(textPtr, &index, bytes, &index);
+ TkTextIndexForwBytes(textPtr, &index, bytes, &index);
- compare = TkTextIndexCmp(&index,indexPtr);
- if (compare > 0) {
+ compare = TkTextIndexCmp(&index,indexPtr);
+ if (compare > 0) {
return pixelHeight;
}
@@ -3920,7 +3920,7 @@ TkTextIndexYPixels(
pixelHeight += height;
}
- if (compare == 0) {
+ if (compare == 0) {
return pixelHeight;
}
}
@@ -4020,7 +4020,7 @@ TkTextUpdateOneLine(
* test below this while loop.
*/
- height = CalculateDisplayLineHeight(textPtr, indexPtr, &bytes,
+ height = CalculateDisplayLineHeight(textPtr, indexPtr, &bytes,
&logicalLines);
if (height > 0) {
@@ -4034,31 +4034,31 @@ TkTextUpdateOneLine(
break;
}
- if (mergedLines == 0) {
- if (indexPtr->linePtr != linePtr) {
- /*
- * If we reached the end of the logical line, then either way
- * we don't have a partial calculation.
- */
-
- partialCalc = 0;
- break;
- }
- } else {
- if (IsStartOfNotMergedLine(textPtr, indexPtr)) {
- /*
- * We've ended a logical line.
- */
-
- partialCalc = 0;
- break;
- }
-
- /*
- * We must still be on the same wrapped line, on a new logical
- * line merged with the logical line 'linePtr'.
- */
- }
+ if (mergedLines == 0) {
+ if (indexPtr->linePtr != linePtr) {
+ /*
+ * If we reached the end of the logical line, then either way
+ * we don't have a partial calculation.
+ */
+
+ partialCalc = 0;
+ break;
+ }
+ } else {
+ if (IsStartOfNotMergedLine(textPtr, indexPtr)) {
+ /*
+ * We've ended a logical line.
+ */
+
+ partialCalc = 0;
+ break;
+ }
+
+ /*
+ * We must still be on the same wrapped line, on a new logical
+ * line merged with the logical line 'linePtr'.
+ */
+ }
if (partialCalc && displayLines > 50 && mergedLines == 0) {
/*
* Only calculate 50 display lines at a time, to avoid huge
@@ -4171,7 +4171,7 @@ TkTextUpdateOneLine(
static void
DisplayText(
- ClientData clientData) /* Information about widget. */
+ void *clientData) /* Information about widget. */
{
TkText *textPtr = (TkText *)clientData;
TextDInfo *dInfoPtr = textPtr->dInfoPtr;
@@ -4414,7 +4414,7 @@ DisplayText(
Tk_Width(textPtr->tkwin) - 2*textPtr->highlightWidth,
Tk_Height(textPtr->tkwin) - 2*textPtr->highlightWidth,
textPtr->borderWidth, textPtr->relief);
- if (textPtr->highlightWidth != 0) {
+ if (textPtr->highlightWidth > 0) {
GC fgGC, bgGC;
bgGC = Tk_GCForColor(textPtr->highlightBgColorPtr,
@@ -4422,10 +4422,10 @@ DisplayText(
if (textPtr->flags & GOT_FOCUS) {
fgGC = Tk_GCForColor(textPtr->highlightColorPtr,
Tk_WindowId(textPtr->tkwin));
- TkpDrawHighlightBorder(textPtr->tkwin, fgGC, bgGC,
+ Tk_DrawHighlightBorder(textPtr->tkwin, fgGC, bgGC,
textPtr->highlightWidth, Tk_WindowId(textPtr->tkwin));
} else {
- TkpDrawHighlightBorder(textPtr->tkwin, bgGC, bgGC,
+ Tk_DrawHighlightBorder(textPtr->tkwin, bgGC, bgGC,
textPtr->highlightWidth, Tk_WindowId(textPtr->tkwin));
}
}
@@ -4906,8 +4906,8 @@ TextChanged(
rounded.byteIndex = 0;
notBegin = 0;
while (!IsStartOfNotMergedLine(textPtr, &rounded) && notBegin) {
- notBegin = !TkTextIndexBackBytes(textPtr, &rounded, 1, &rounded);
- rounded.byteIndex = 0;
+ notBegin = !TkTextIndexBackBytes(textPtr, &rounded, 1, &rounded);
+ rounded.byteIndex = 0;
}
/*
@@ -4919,11 +4919,11 @@ TextChanged(
firstPtr = FindDLine(textPtr, dInfoPtr->dLinePtr, &rounded);
if (firstPtr == NULL) {
- /*
- * index1Ptr pertains to no display line, i.e this index is after
- * the last display line. Since index2Ptr is after index1Ptr, there
- * is no display line to free/redisplay and we can return early.
- */
+ /*
+ * index1Ptr pertains to no display line, i.e this index is after
+ * the last display line. Since index2Ptr is after index1Ptr, there
+ * is no display line to free/redisplay and we can return early.
+ */
return;
}
@@ -4931,38 +4931,38 @@ TextChanged(
rounded = *index2Ptr;
linePtr = index2Ptr->linePtr;
do {
- linePtr = TkBTreeNextLine(textPtr, linePtr);
- if (linePtr == NULL) {
- break;
- }
- rounded.linePtr = linePtr;
- rounded.byteIndex = 0;
+ linePtr = TkBTreeNextLine(textPtr, linePtr);
+ if (linePtr == NULL) {
+ break;
+ }
+ rounded.linePtr = linePtr;
+ rounded.byteIndex = 0;
} while (!IsStartOfNotMergedLine(textPtr, &rounded));
if (linePtr == NULL) {
- lastPtr = NULL;
+ lastPtr = NULL;
} else {
- /*
- * 'rounded' now points to the start of a display line as well as the
- * start of a logical line not merged with its previous line, and
- * this index is the closest after index2Ptr.
- */
+ /*
+ * 'rounded' now points to the start of a display line as well as the
+ * start of a logical line not merged with its previous line, and
+ * this index is the closest after index2Ptr.
+ */
- lastPtr = FindDLine(textPtr, dInfoPtr->dLinePtr, &rounded);
+ lastPtr = FindDLine(textPtr, dInfoPtr->dLinePtr, &rounded);
- /*
- * At least one display line is supposed to change. This makes the
- * redisplay OK in case the display line we expect to get here was
- * unlinked by a previous call to TkTextChanged and the text widget
- * did not update before reaching this point. This happens for
- * instance when moving the cursor up one line.
- * Note that lastPtr != NULL here, otherwise we would have returned
- * earlier when we tested for firstPtr being NULL.
- */
+ /*
+ * At least one display line is supposed to change. This makes the
+ * redisplay OK in case the display line we expect to get here was
+ * unlinked by a previous call to TkTextChanged and the text widget
+ * did not update before reaching this point. This happens for
+ * instance when moving the cursor up one line.
+ * Note that lastPtr != NULL here, otherwise we would have returned
+ * earlier when we tested for firstPtr being NULL.
+ */
- if (lastPtr == firstPtr) {
- lastPtr = lastPtr->nextPtr;
- }
+ if (lastPtr == firstPtr) {
+ lastPtr = lastPtr->nextPtr;
+ }
}
/*
@@ -5147,7 +5147,7 @@ TextRedrawTag(
} else {
TkTextIndex tmp = *curIndexPtr;
- TkTextIndexBackBytes(textPtr, &tmp, 1, &tmp);
+ TkTextIndexBackBytes(textPtr, &tmp, 1, &tmp);
dlPtr = FindDLine(textPtr, dlPtr, &tmp);
}
if (dlPtr == NULL) {
@@ -5166,7 +5166,7 @@ TextRedrawTag(
}
endPtr = FindDLine(textPtr, dlPtr, endIndexPtr);
if ((endPtr != NULL)
- && (TkTextIndexCmp(&endPtr->index,endIndexPtr) < 0)) {
+ && (TkTextIndexCmp(&endPtr->index,endIndexPtr) < 0)) {
endPtr = endPtr->nextPtr;
}
@@ -5327,7 +5327,7 @@ TkTextRelayoutWindow(
inSync = 0;
}
- GenerateWidgetViewSyncEvent(textPtr, inSync);
+ GenerateWidgetViewSyncEvent(textPtr, inSync);
}
}
@@ -5403,9 +5403,9 @@ TkTextSetYView(
*/
textPtr->topIndex = *indexPtr;
- if (!IsStartOfNotMergedLine(textPtr, indexPtr)) {
- TkTextFindDisplayLineEnd(textPtr, &textPtr->topIndex, 0, NULL);
- }
+ if (!IsStartOfNotMergedLine(textPtr, indexPtr)) {
+ TkTextFindDisplayLineEnd(textPtr, &textPtr->topIndex, 0, NULL);
+ }
dInfoPtr->newTopPixelOffset = pickPlace;
goto scheduleUpdate;
}
@@ -5428,23 +5428,23 @@ TkTextSetYView(
*/
dlPtr = NULL;
- } else {
- if (TkTextIndexCmp(&dlPtr->index, indexPtr) <= 0) {
- if (dInfoPtr->dLinePtr == dlPtr && dInfoPtr->topPixelOffset != 0) {
- /*
- * It is on the top line, but that line is hanging off the top
- * of the screen. Change the top overlap to zero and update.
- */
-
- dInfoPtr->newTopPixelOffset = 0;
- goto scheduleUpdate;
- }
- /*
- * The line is already on screen, with no need to scroll.
- */
- return;
- }
- }
+ } else {
+ if (TkTextIndexCmp(&dlPtr->index, indexPtr) <= 0) {
+ if (dInfoPtr->dLinePtr == dlPtr && dInfoPtr->topPixelOffset != 0) {
+ /*
+ * It is on the top line, but that line is hanging off the top
+ * of the screen. Change the top overlap to zero and update.
+ */
+
+ dInfoPtr->newTopPixelOffset = 0;
+ goto scheduleUpdate;
+ }
+ /*
+ * The line is already on screen, with no need to scroll.
+ */
+ return;
+ }
+ }
}
/*
@@ -5509,7 +5509,7 @@ TkTextSetYView(
*/
if (dInfoPtr->maxY - dInfoPtr->y < lineHeight) {
- bottomY = lineHeight;
+ bottomY = lineHeight;
}
/*
@@ -5645,8 +5645,8 @@ MeasureUp(
index.linePtr = TkBTreeFindLine(srcPtr->tree, textPtr, lineNum);
index.byteIndex = 0;
- TkTextFindDisplayLineEnd(textPtr, &index, 0, NULL);
- lineNum = TkBTreeLinesTo(textPtr, index.linePtr);
+ TkTextFindDisplayLineEnd(textPtr, &index, 0, NULL);
+ lineNum = TkBTreeLinesTo(textPtr, index.linePtr);
lowestPtr = NULL;
do {
dlPtr = LayoutDLine(textPtr, &index);
@@ -5667,21 +5667,21 @@ MeasureUp(
for (dlPtr = lowestPtr; dlPtr != NULL; dlPtr = dlPtr->nextPtr) {
distance -= dlPtr->height;
if (distance <= 0) {
- *dstPtr = dlPtr->index;
-
- /*
- * dstPtr is the start of a display line that is or is not
- * the start of a logical line. If it is the start of a
- * logical line, we must check whether this line is merged
- * with the previous logical line, and if so we must adjust
- * dstPtr to the start of the display line since a display
- * line start needs to be returned.
- */
- if (!IsStartOfNotMergedLine(textPtr, dstPtr)) {
- TkTextFindDisplayLineEnd(textPtr, dstPtr, 0, NULL);
- }
-
- if (overlap != NULL) {
+ *dstPtr = dlPtr->index;
+
+ /*
+ * dstPtr is the start of a display line that is or is not
+ * the start of a logical line. If it is the start of a
+ * logical line, we must check whether this line is merged
+ * with the previous logical line, and if so we must adjust
+ * dstPtr to the start of the display line since a display
+ * line start needs to be returned.
+ */
+ if (!IsStartOfNotMergedLine(textPtr, dstPtr)) {
+ TkTextFindDisplayLineEnd(textPtr, dstPtr, 0, NULL);
+ }
+
+ if (overlap != NULL) {
*overlap = -distance;
}
break;
@@ -5733,7 +5733,7 @@ int
TkTextSeeCmd(
TkText *textPtr, /* Information about text widget. */
Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. Someone else has already
* parsed this command enough to know that
* objv[1] is "see". */
@@ -5814,30 +5814,30 @@ TkTextSeeCmd(
*/
if (chunkPtr != NULL) {
- chunkPtr->bboxProc(textPtr, chunkPtr, byteCount,
- dlPtr->y + dlPtr->spaceAbove,
- dlPtr->height - dlPtr->spaceAbove - dlPtr->spaceBelow,
- dlPtr->baseline - dlPtr->spaceAbove, &x, &y, &width,
- &height);
- delta = x - dInfoPtr->curXPixelOffset;
- oneThird = lineWidth/3;
- if (delta < 0) {
- if (delta < -oneThird) {
- dInfoPtr->newXPixelOffset = x - lineWidth/2;
- } else {
- dInfoPtr->newXPixelOffset += delta;
- }
- } else {
- delta -= lineWidth - width;
- if (delta <= 0) {
- return TCL_OK;
- }
- if (delta > oneThird) {
- dInfoPtr->newXPixelOffset = x - lineWidth/2;
- } else {
- dInfoPtr->newXPixelOffset += delta;
- }
- }
+ chunkPtr->bboxProc(textPtr, chunkPtr, byteCount,
+ dlPtr->y + dlPtr->spaceAbove,
+ dlPtr->height - dlPtr->spaceAbove - dlPtr->spaceBelow,
+ dlPtr->baseline - dlPtr->spaceAbove, &x, &y, &width,
+ &height);
+ delta = x - dInfoPtr->curXPixelOffset;
+ oneThird = lineWidth/3;
+ if (delta < 0) {
+ if (delta < -oneThird) {
+ dInfoPtr->newXPixelOffset = x - lineWidth/2;
+ } else {
+ dInfoPtr->newXPixelOffset += delta;
+ }
+ } else {
+ delta -= lineWidth - width;
+ if (delta <= 0) {
+ return TCL_OK;
+ }
+ if (delta > oneThird) {
+ dInfoPtr->newXPixelOffset = x - lineWidth/2;
+ } else {
+ dInfoPtr->newXPixelOffset += delta;
+ }
+ }
}
dInfoPtr->flags |= DINFO_OUT_OF_DATE;
if (!(dInfoPtr->flags & REDRAW_PENDING)) {
@@ -5869,7 +5869,7 @@ int
TkTextXviewCmd(
TkText *textPtr, /* Information about text widget. */
Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. Someone else has already
* parsed this command enough to know that
* objv[1] is "xview". */
@@ -6075,24 +6075,24 @@ YScrollByLines(
if (offset == 0) {
textPtr->topIndex = dlPtr->index;
- /*
- * topIndex is the start of a logical line. However, if
- * the eol of the previous logical line is elided, then
- * topIndex may be elsewhere than the first character of
- * a display line, which is unwanted. Adjust to the start
- * of the display line, if needed.
- * topIndex is the start of a display line that is or is
- * not the start of a logical line. If it is the start of
- * a logical line, we must check whether this line is
- * merged with the previous logical line, and if so we
- * must adjust topIndex to the start of the display line.
- */
- if (!IsStartOfNotMergedLine(textPtr, &textPtr->topIndex)) {
- TkTextFindDisplayLineEnd(textPtr, &textPtr->topIndex,
- 0, NULL);
- }
-
- break;
+ /*
+ * topIndex is the start of a logical line. However, if
+ * the eol of the previous logical line is elided, then
+ * topIndex may be elsewhere than the first character of
+ * a display line, which is unwanted. Adjust to the start
+ * of the display line, if needed.
+ * topIndex is the start of a display line that is or is
+ * not the start of a logical line. If it is the start of
+ * a logical line, we must check whether this line is
+ * merged with the previous logical line, and if so we
+ * must adjust topIndex to the start of the display line.
+ */
+ if (!IsStartOfNotMergedLine(textPtr, &textPtr->topIndex)) {
+ TkTextFindDisplayLineEnd(textPtr, &textPtr->topIndex,
+ 0, NULL);
+ }
+
+ break;
}
}
@@ -6170,7 +6170,7 @@ int
TkTextYviewCmd(
TkText *textPtr, /* Information about text widget. */
Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. Someone else has already
* parsed this command enough to know that
* objv[1] is "yview". */
@@ -6178,7 +6178,7 @@ TkTextYviewCmd(
TextDInfo *dInfoPtr = textPtr->dInfoPtr;
int pickPlace, type;
int pixels, count;
- int switchLength;
+ Tcl_Size switchLength;
double fraction;
TkTextIndex index;
@@ -6377,7 +6377,7 @@ int
TkTextScanCmd(
TkText *textPtr, /* Information about text widget. */
Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. Someone else has already
* parsed this command enough to know that
* objv[1] is "scan". */
@@ -6385,12 +6385,12 @@ TkTextScanCmd(
TextDInfo *dInfoPtr = textPtr->dInfoPtr;
TkTextIndex index;
int c, x, y, totalScroll, gain=10;
- size_t length;
+ Tcl_Size length;
if ((objc != 5) && (objc != 6)) {
Tcl_WrongNumArgs(interp, 2, objv, "mark x y");
Tcl_AppendResult(interp, " or \"", Tcl_GetString(objv[0]),
- " scan dragto x y ?gain?\"", NULL);
+ " scan dragto x y ?gain?\"", (char *)NULL);
/*
* Ought to be:
* Tcl_WrongNumArgs(interp, 2, objc, "dragto x y ?gain?");
@@ -6406,8 +6406,7 @@ TkTextScanCmd(
if ((objc == 6) && (Tcl_GetIntFromObj(interp, objv[5], &gain) != TCL_OK)) {
return TCL_ERROR;
}
- c = Tcl_GetString(objv[2])[0];
- length = strlen(Tcl_GetString(objv[2]));
+ c = Tcl_GetStringFromObj(objv[2], &length)[0];
if (c=='d' && strncmp(Tcl_GetString(objv[2]), "dragto", length)==0) {
int newX, maxX;
@@ -6458,10 +6457,10 @@ TkTextScanCmd(
dInfoPtr->scanMarkY = y;
} else {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "bad scan option \"%s\": must be mark or dragto",
+ "bad scan option \"%s\": must be dragto or mark",
Tcl_GetString(objv[2])));
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "INDEX", "scan option",
- Tcl_GetString(objv[2]), NULL);
+ Tcl_GetString(objv[2]), (char *)NULL);
return TCL_ERROR;
}
return TCL_OK;
@@ -6497,7 +6496,7 @@ GetXView(
Tcl_Interp *interp, /* If "report" is FALSE, string describing
* visible range gets stored in the interp's
* result. */
- TkText *textPtr, /* Information about text widget. */
+ const TkText *textPtr, /* Information about text widget. */
int report) /* Non-zero means report info to scrollbar if
* it has changed. */
{
@@ -6541,10 +6540,10 @@ GetXView(
Tcl_PrintDouble(NULL, first, buf1+1);
Tcl_PrintDouble(NULL, last, buf2+1);
Tcl_DStringInit(&buf);
- Tcl_DStringAppend(&buf, textPtr->xScrollCmd, -1);
- Tcl_DStringAppend(&buf, buf1, -1);
- Tcl_DStringAppend(&buf, buf2, -1);
- code = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, TCL_EVAL_GLOBAL);
+ Tcl_DStringAppend(&buf, textPtr->xScrollCmd, TCL_INDEX_NONE);
+ Tcl_DStringAppend(&buf, buf1, TCL_INDEX_NONE);
+ Tcl_DStringAppend(&buf, buf2, TCL_INDEX_NONE);
+ code = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), TCL_INDEX_NONE, TCL_EVAL_GLOBAL);
Tcl_DStringFree(&buf);
if (code != TCL_OK) {
Tcl_AddErrorInfo(interp,
@@ -6826,10 +6825,10 @@ GetYView(
Tcl_PrintDouble(NULL, first, buf1+1);
Tcl_PrintDouble(NULL, last, buf2+1);
Tcl_DStringInit(&buf);
- Tcl_DStringAppend(&buf, textPtr->yScrollCmd, -1);
- Tcl_DStringAppend(&buf, buf1, -1);
- Tcl_DStringAppend(&buf, buf2, -1);
- code = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, TCL_EVAL_GLOBAL);
+ Tcl_DStringAppend(&buf, textPtr->yScrollCmd, TCL_INDEX_NONE);
+ Tcl_DStringAppend(&buf, buf1, TCL_INDEX_NONE);
+ Tcl_DStringAppend(&buf, buf2, TCL_INDEX_NONE);
+ code = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), TCL_INDEX_NONE, TCL_EVAL_GLOBAL);
Tcl_DStringFree(&buf);
if (code != TCL_OK) {
Tcl_AddErrorInfo(interp,
@@ -6859,7 +6858,7 @@ GetYView(
static void
AsyncUpdateYScrollbar(
- ClientData clientData) /* Information about widget. */
+ void *clientData) /* Information about widget. */
{
TkText *textPtr = (TkText *)clientData;
@@ -6923,63 +6922,63 @@ FindDLine(
*/
while (TkTextIndexCmp(&dlPtr->index,indexPtr) < 0) {
- dlPtrPrev = dlPtr;
- dlPtr = dlPtr->nextPtr;
- if (dlPtr == NULL) {
- /*
- * We're past the last display line, either because the desired
- * index lies past the visible text, or because the desired index
- * is on the last display line.
- */
- indexPtr2 = dlPtrPrev->index;
- TkTextIndexForwBytes(textPtr, &indexPtr2, dlPtrPrev->byteCount,
- &indexPtr2);
- if (TkTextIndexCmp(&indexPtr2,indexPtr) > 0) {
- /*
- * The desired index is on the last display line.
- * --> return this display line.
- */
- dlPtr = dlPtrPrev;
- } else {
- /*
- * The desired index is past the visible text. There is no
- * display line displaying something at the desired index.
- * --> return NULL.
- */
- }
- break;
- }
- if (TkTextIndexCmp(&dlPtr->index,indexPtr) > 0) {
- /*
- * If we're here then we would normally expect that:
- * dlPtrPrev->index <= indexPtr < dlPtr->index
- * i.e. we have found the searched display line being dlPtr.
- * However it is possible that some DLines were unlinked
- * previously, leading to a situation where going through
- * the list of display lines skips display lines that did
- * exist just a moment ago.
- */
- indexPtr2 = dlPtrPrev->index;
- TkTextIndexForwBytes(textPtr, &indexPtr2, dlPtrPrev->byteCount,
- &indexPtr2);
- if (TkTextIndexCmp(&indexPtr2,indexPtr) > 0) {
- /*
- * Confirmed:
- * dlPtrPrev->index <= indexPtr < dlPtr->index
- * --> return dlPtrPrev.
- */
- dlPtr = dlPtrPrev;
- } else {
- /*
- * The last (rightmost) index shown by dlPtrPrev is still
- * before the desired index. This may be because there was
- * previously a display line between dlPtrPrev and dlPtr
- * and this display line has been unlinked.
- * --> return dlPtr.
- */
- }
- break;
- }
+ dlPtrPrev = dlPtr;
+ dlPtr = dlPtr->nextPtr;
+ if (dlPtr == NULL) {
+ /*
+ * We're past the last display line, either because the desired
+ * index lies past the visible text, or because the desired index
+ * is on the last display line.
+ */
+ indexPtr2 = dlPtrPrev->index;
+ TkTextIndexForwBytes(textPtr, &indexPtr2, dlPtrPrev->byteCount,
+ &indexPtr2);
+ if (TkTextIndexCmp(&indexPtr2,indexPtr) > 0) {
+ /*
+ * The desired index is on the last display line.
+ * --> return this display line.
+ */
+ dlPtr = dlPtrPrev;
+ } else {
+ /*
+ * The desired index is past the visible text. There is no
+ * display line displaying something at the desired index.
+ * --> return NULL.
+ */
+ }
+ break;
+ }
+ if (TkTextIndexCmp(&dlPtr->index,indexPtr) > 0) {
+ /*
+ * If we're here then we would normally expect that:
+ * dlPtrPrev->index <= indexPtr < dlPtr->index
+ * i.e. we have found the searched display line being dlPtr.
+ * However it is possible that some DLines were unlinked
+ * previously, leading to a situation where going through
+ * the list of display lines skips display lines that did
+ * exist just a moment ago.
+ */
+ indexPtr2 = dlPtrPrev->index;
+ TkTextIndexForwBytes(textPtr, &indexPtr2, dlPtrPrev->byteCount,
+ &indexPtr2);
+ if (TkTextIndexCmp(&indexPtr2,indexPtr) > 0) {
+ /*
+ * Confirmed:
+ * dlPtrPrev->index <= indexPtr < dlPtr->index
+ * --> return dlPtrPrev.
+ */
+ dlPtr = dlPtrPrev;
+ } else {
+ /*
+ * The last (rightmost) index shown by dlPtrPrev is still
+ * before the desired index. This may be because there was
+ * previously a display line between dlPtrPrev and dlPtr
+ * and this display line has been unlinked.
+ * --> return dlPtr.
+ */
+ }
+ break;
+ }
}
return dlPtr;
@@ -7006,30 +7005,30 @@ FindDLine(
static int
IsStartOfNotMergedLine(
- TkText *textPtr, /* Widget record for text widget. */
+ const TkText *textPtr, /* Widget record for text widget. */
const TkTextIndex *indexPtr) /* Index to check. */
{
TkTextIndex indexPtr2;
if (indexPtr->byteIndex != 0) {
- /*
- * Not the start of a logical line.
- */
- return 0;
+ /*
+ * Not the start of a logical line.
+ */
+ return 0;
}
if (TkTextIndexBackBytes(textPtr, indexPtr, 1, &indexPtr2)) {
- /*
- * indexPtr is the first index of the text widget.
- */
- return 1;
+ /*
+ * indexPtr is the first index of the text widget.
+ */
+ return 1;
}
if (!TkTextIsElided(textPtr, &indexPtr2, NULL)) {
- /*
- * The eol of the line just before indexPtr is elided.
- */
- return 1;
+ /*
+ * The eol of the line just before indexPtr is elided.
+ */
+ return 1;
}
return 0;
@@ -7203,7 +7202,7 @@ DlineIndexOfX(
* We've reached the end of the text.
*/
- TkTextIndexBackChars(NULL, indexPtr, 1, indexPtr, COUNT_INDICES);
+ TkTextIndexBackChars(NULL, indexPtr, 1, indexPtr, COUNT_INDICES);
return;
}
if (chunkPtr->nextPtr == NULL) {
@@ -7211,7 +7210,7 @@ DlineIndexOfX(
* We've reached the end of the display line.
*/
- TkTextIndexBackChars(NULL, indexPtr, 1, indexPtr, COUNT_INDICES);
+ TkTextIndexBackChars(NULL, indexPtr, 1, indexPtr, COUNT_INDICES);
return;
}
chunkPtr = chunkPtr->nextPtr;
@@ -7367,7 +7366,7 @@ TkTextIndexBbox(
TextDInfo *dInfoPtr = textPtr->dInfoPtr;
DLine *dlPtr;
TkTextDispChunk *chunkPtr;
- int byteCount;
+ Tcl_Size byteCount;
/*
* Make sure that all of the screen layout information is up to date.
@@ -7435,9 +7434,9 @@ TkTextIndexBbox(
if (charWidthPtr != NULL) {
*charWidthPtr = dInfoPtr->maxX - *xPtr;
- if (*charWidthPtr > textPtr->charWidth) {
- *charWidthPtr = textPtr->charWidth;
- }
+ if (*charWidthPtr > textPtr->charWidth) {
+ *charWidthPtr = textPtr->charWidth;
+ }
}
if (*xPtr > dInfoPtr->maxX) {
*xPtr = dInfoPtr->maxX;
@@ -7560,7 +7559,7 @@ static void
ElideBboxProc(
TCL_UNUSED(TkText *),
TkTextDispChunk *chunkPtr, /* Chunk containing desired char. */
- TCL_UNUSED(int), /* Index of desired character within the
+ TCL_UNUSED(Tcl_Size), /* Index of desired character within the
* chunk. */
int y, /* Topmost pixel in area allocated for this
* line. */
@@ -7575,6 +7574,7 @@ ElideBboxProc(
int *heightPtr) /* Gets filled in with height of character, in
* pixels. */
{
+
*xPtr = chunkPtr->x;
*yPtr = y;
*widthPtr = *heightPtr = 0;
@@ -7584,7 +7584,7 @@ ElideBboxProc(
* Measure an elided chunk.
*/
-static int
+static Tcl_Size
ElideMeasureProc(
TCL_UNUSED(TkTextDispChunk *), /* Chunk containing desired coord. */
TCL_UNUSED(int)) /* X-coordinate, in same coordinate system as
@@ -7620,11 +7620,11 @@ TkTextCharLayoutProc(
TCL_UNUSED(TkTextIndex *), /* Index of first character to lay out
* (corresponds to segPtr and offset). */
TkTextSegment *segPtr, /* Segment being layed out. */
- int byteOffset, /* Byte offset within segment of first
+ Tcl_Size byteOffset, /* Byte offset within segment of first
* character to consider. */
int maxX, /* Chunk must not occupy pixels at this
* position or higher. */
- int maxBytes, /* Chunk must not include more than this many
+ Tcl_Size maxBytes, /* Chunk must not include more than this many
* characters. */
int noCharsYet, /* Non-zero means no characters have been
* assigned to this display line yet. */
@@ -7637,7 +7637,8 @@ TkTextCharLayoutProc(
* set by the caller. */
{
Tk_Font tkfont;
- int nextX, bytesThatFit, count;
+ int nextX, count;
+ Tcl_Size bytesThatFit;
CharInfo *ciPtr;
char *p;
TkTextSegment *nextPtr;
@@ -7699,7 +7700,7 @@ TkTextCharLayoutProc(
chunkPtr->x, maxX, TK_ISOLATE_END, &nextX);
#endif /* TK_LAYOUT_WITH_BASE_CHUNKS */
- if (bytesThatFit < maxBytes) {
+ if (bytesThatFit + 1 <= maxBytes) {
if ((bytesThatFit == 0) && noCharsYet) {
int ch;
int chLen = TkUtfToUniChar(p, &ch);
@@ -7724,21 +7725,21 @@ TkTextCharLayoutProc(
nextX = maxX;
bytesThatFit++;
}
- if (wrapMode == TEXT_WRAPMODE_WORD) {
- while (p[bytesThatFit] == ' ') {
- /*
- * Space characters that would go at the beginning of the
- * next line are allocated to the current line. This gives
- * the effect of trimming white spaces that would otherwise
- * be seen at the beginning of wrapped lines.
- * Note that testing for '\t' is useless here because the
- * chunk always includes at most one trailing \t, see
- * LayoutDLine.
- */
-
- bytesThatFit++;
- }
- }
+ if (wrapMode == TEXT_WRAPMODE_WORD) {
+ while (p[bytesThatFit] == ' ') {
+ /*
+ * Space characters that would go at the beginning of the
+ * next line are allocated to the current line. This gives
+ * the effect of trimming white spaces that would otherwise
+ * be seen at the beginning of wrapped lines.
+ * Note that testing for '\t' is useless here because the
+ * chunk always includes at most one trailing \t, see
+ * LayoutDLine.
+ */
+
+ bytesThatFit++;
+ }
+ }
if (p[bytesThatFit] == '\n') {
/*
* A newline character takes up no space, so if the previous
@@ -7782,7 +7783,7 @@ TkTextCharLayoutProc(
chunkPtr->breakIndex = -1;
#ifndef TK_LAYOUT_WITH_BASE_CHUNKS
- ciPtr = (CharInfo *)ckalloc((Tk_Offset(CharInfo, chars) + 1) + bytesThatFit);
+ ciPtr = (CharInfo *)ckalloc(offsetof(CharInfo, chars) + 1 + bytesThatFit);
chunkPtr->clientData = ciPtr;
memcpy(ciPtr->chars, p, bytesThatFit);
#endif /* TK_LAYOUT_WITH_BASE_CHUNKS */
@@ -7875,7 +7876,7 @@ TkTextCharLayoutProc(
*--------------------------------------------------------------
*/
-static int
+static Tcl_Size
CharChunkMeasureChars(
TkTextDispChunk *chunkPtr, /* Chunk from which to measure. */
const char *chars, /* Chars to use, instead of the chunk's own.
@@ -7988,7 +7989,8 @@ CharDisplayProc(
const char *string;
TextStyle *stylePtr;
StyleValues *sValuePtr;
- int numBytes, offsetBytes, offsetX;
+ Tcl_Size numBytes, offsetBytes;
+ int offsetX;
#ifdef TK_DRAW_IN_CONTEXT
BaseCharInfo *bciPtr;
#endif /* TK_DRAW_IN_CONTEXT */
@@ -8185,7 +8187,7 @@ CharUndisplayProc(
*--------------------------------------------------------------
*/
-static int
+static Tcl_Size
CharMeasureProc(
TkTextDispChunk *chunkPtr, /* Chunk containing desired coord. */
int x) /* X-coordinate, in same coordinate system as
@@ -8223,7 +8225,7 @@ static void
CharBboxProc(
TCL_UNUSED(TkText *),
TkTextDispChunk *chunkPtr, /* Chunk containing desired char. */
- int byteIndex, /* Byte offset of desired character within the
+ Tcl_Size byteIndex, /* Byte offset of desired character within the
* chunk. */
int y, /* Topmost pixel in area allocated for this
* line. */
@@ -8487,7 +8489,7 @@ static int
SizeOfTab(
TkText *textPtr, /* Information about the text widget as a
* whole. */
- int tabStyle, /* One of TK_TEXT_TABSTYLE_TABULAR
+ TkTextTabStyle tabStyle, /* One of TK_TEXT_TABSTYLE_TABULAR
* or TK_TEXT_TABSTYLE_WORDPROCESSOR. */
TkTextTabArray *tabArrayPtr,/* Information about the tab stops that apply
* to this line. NULL means use default
@@ -8673,7 +8675,7 @@ NextTabStop(
*--------------------------------------------------------------
*/
-static int
+static Tcl_Size
MeasureChars(
Tk_Font tkfont, /* Font in which to draw characters. */
const char *source, /* Characters to be displayed. Need not be
@@ -8781,7 +8783,7 @@ static int
TextGetScrollInfoObj(
Tcl_Interp *interp, /* Used for error reporting. */
TkText *textPtr, /* Information about the text widget. */
- int objc, /* # arguments for command. */
+ Tcl_Size objc, /* # arguments for command. */
Tcl_Obj *const objv[], /* Arguments for command. */
double *dblPtr, /* Filled in with argument "moveto" option, if
* any. */
@@ -8795,12 +8797,13 @@ TextGetScrollInfoObj(
VIEW_MOVETO, VIEW_SCROLL
};
static const char *const units[] = {
- "units", "pages", "pixels", NULL
+ "pages", "pixels", "units", NULL
};
enum viewUnits {
- VIEW_SCROLL_UNITS, VIEW_SCROLL_PAGES, VIEW_SCROLL_PIXELS
+ VIEW_SCROLL_PAGES, VIEW_SCROLL_PIXELS, VIEW_SCROLL_UNITS
};
int index;
+ double d;
if (Tcl_GetIndexFromObjStruct(interp, objv[2], subcommands,
sizeof(char *), "option", 0, &index) != TCL_OK) {
@@ -8819,7 +8822,7 @@ TextGetScrollInfoObj(
return TKTEXT_SCROLL_MOVETO;
case VIEW_SCROLL:
if (objc != 5) {
- Tcl_WrongNumArgs(interp, 3, objv, "number units|pages|pixels");
+ Tcl_WrongNumArgs(interp, 3, objv, "number pages|pixels|units");
return TKTEXT_SCROLL_ERROR;
}
if (Tcl_GetIndexFromObjStruct(interp, objv[4], units,
@@ -8828,25 +8831,35 @@ TextGetScrollInfoObj(
}
switch ((enum viewUnits) index) {
case VIEW_SCROLL_PAGES:
- if (Tcl_GetIntFromObj(interp, objv[3], intPtr) == TCL_OK) {
- return TKTEXT_SCROLL_PAGES;
+ if (Tcl_GetDoubleFromObj(interp, objv[3], &d) != TCL_OK) {
+ return TKTEXT_SCROLL_ERROR;
}
- break;
+ *intPtr = (d > 0) ? ceil(d) : floor(d);
+ if (dblPtr) {
+ *dblPtr = d;
+ }
+ return TKTEXT_SCROLL_PAGES;
case VIEW_SCROLL_PIXELS:
if (Tk_GetPixelsFromObj(interp, textPtr->tkwin, objv[3],
- intPtr) == TCL_OK) {
- return TKTEXT_SCROLL_PIXELS;
+ intPtr) != TCL_OK) {
+ return TKTEXT_SCROLL_ERROR;
}
- break;
+ if (dblPtr) {
+ *dblPtr = (double)*intPtr;
+ }
+ return TKTEXT_SCROLL_PIXELS;
case VIEW_SCROLL_UNITS:
- if (Tcl_GetIntFromObj(interp, objv[3], intPtr) == TCL_OK) {
- return TKTEXT_SCROLL_UNITS;
+ if (Tcl_GetDoubleFromObj(interp, objv[3], &d) != TCL_OK) {
+ return TKTEXT_SCROLL_ERROR;
}
- break;
- default:
- Tcl_Panic("unexpected switch fallthrough");
+ *intPtr = (d > 0) ? ceil(d) : floor(d);
+ if (dblPtr) {
+ *dblPtr = d;
+ }
+ return TKTEXT_SCROLL_UNITS;
}
}
+ Tcl_Panic("unexpected switch fallthrough");
return TKTEXT_SCROLL_ERROR;
}
diff --git a/generic/tkTextImage.c b/generic/tkTextImage.c
index b6b411c..7f292e8 100644
--- a/generic/tkTextImage.c
+++ b/generic/tkTextImage.c
@@ -4,7 +4,7 @@
* This file contains code that allows images to be nested inside text
* widgets. It also implements the "image" widget command for texts.
*
- * Copyright (c) 1997 Sun Microsystems, Inc.
+ * Copyright © 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.
@@ -22,7 +22,7 @@
*/
#define EI_SEG_SIZE \
- ((unsigned)(Tk_Offset(TkTextSegment, body) + sizeof(TkTextEmbImage)))
+ (offsetof(TkTextSegment, body) + sizeof(TkTextEmbImage))
/*
* Prototypes for functions defined in this file:
@@ -33,11 +33,11 @@ static TkTextSegment * EmbImageCleanupProc(TkTextSegment *segPtr,
static void EmbImageCheckProc(TkTextSegment *segPtr,
TkTextLine *linePtr);
static void EmbImageBboxProc(TkText *textPtr,
- TkTextDispChunk *chunkPtr, int index, int y,
+ TkTextDispChunk *chunkPtr, Tcl_Size index, int y,
int lineHeight, int baseline, int *xPtr, int *yPtr,
int *widthPtr, int *heightPtr);
static int EmbImageConfigure(TkText *textPtr,
- TkTextSegment *eiPtr, int objc,
+ TkTextSegment *eiPtr, Tcl_Size objc,
Tcl_Obj *const objv[]);
static int EmbImageDeleteProc(TkTextSegment *segPtr,
TkTextLine *linePtr, int treeGone);
@@ -47,10 +47,10 @@ static void EmbImageDisplayProc(TkText *textPtr,
Drawable dst, int screenY);
static int EmbImageLayoutProc(TkText *textPtr,
TkTextIndex *indexPtr, TkTextSegment *segPtr,
- int offset, int maxX, int maxChars,
+ Tcl_Size offset, int maxX, Tcl_Size maxChars,
int noCharsYet, TkWrapMode wrapMode,
TkTextDispChunk *chunkPtr);
-static void EmbImageProc(ClientData clientData, int x, int y,
+static void EmbImageProc(void *clientData, int x, int y,
int width, int height, int imageWidth,
int imageHeight);
@@ -77,27 +77,23 @@ static const char *const alignStrings[] = {
"baseline", "bottom", "center", "top", NULL
};
-typedef enum {
- ALIGN_BASELINE, ALIGN_BOTTOM, ALIGN_CENTER, ALIGN_TOP
-} alignMode;
-
/*
* Information used for parsing image configuration options:
*/
static const Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_STRING_TABLE, "-align", NULL, NULL,
- "center", -1, Tk_Offset(TkTextEmbImage, align),
- 0, alignStrings, 0},
+ "center", TCL_INDEX_NONE, offsetof(TkTextEmbImage, align),
+ TK_OPTION_ENUM_VAR, alignStrings, 0},
{TK_OPTION_PIXELS, "-padx", NULL, NULL,
- "0", -1, Tk_Offset(TkTextEmbImage, padX), 0, 0, 0},
+ "0", TCL_INDEX_NONE, offsetof(TkTextEmbImage, padX), 0, 0, 0},
{TK_OPTION_PIXELS, "-pady", NULL, NULL,
- "0", -1, Tk_Offset(TkTextEmbImage, padY), 0, 0, 0},
+ "0", TCL_INDEX_NONE, offsetof(TkTextEmbImage, padY), 0, 0, 0},
{TK_OPTION_STRING, "-image", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextEmbImage, imageString),
+ NULL, TCL_INDEX_NONE, offsetof(TkTextEmbImage, imageString),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-name", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextEmbImage, imageName),
+ NULL, TCL_INDEX_NONE, offsetof(TkTextEmbImage, imageName),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0}
};
@@ -123,7 +119,7 @@ int
TkTextImageCmd(
TkText *textPtr, /* Information about text widget. */
Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. Someone else has already
* parsed this command enough to know that
* objv[1] is "image". */
@@ -162,10 +158,10 @@ TkTextImageCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"no embedded image at index \"%s\"",
Tcl_GetString(objv[3])));
- Tcl_SetErrorCode(interp, "TK", "TEXT", "NO_IMAGE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "TEXT", "NO_IMAGE", (char *)NULL);
return TCL_ERROR;
}
- objPtr = Tk_GetOptionValue(interp, (char *)&eiPtr->body.ei,
+ objPtr = Tk_GetOptionValue(interp, &eiPtr->body.ei,
eiPtr->body.ei.optionTable, objv[4], textPtr->tkwin);
if (objPtr == NULL) {
return TCL_ERROR;
@@ -187,12 +183,12 @@ TkTextImageCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"no embedded image at index \"%s\"",
Tcl_GetString(objv[3])));
- Tcl_SetErrorCode(interp, "TK", "TEXT", "NO_IMAGE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "TEXT", "NO_IMAGE", (char *)NULL);
return TCL_ERROR;
}
if (objc <= 5) {
Tcl_Obj *objPtr = Tk_GetOptionInfo(interp,
- (char *)&eiPtr->body.ei, eiPtr->body.ei.optionTable,
+ &eiPtr->body.ei, eiPtr->body.ei.optionTable,
(objc == 5) ? objv[4] : NULL, textPtr->tkwin);
if (objPtr == NULL) {
@@ -255,7 +251,7 @@ TkTextImageCmd(
eiPtr->body.ei.imageString = NULL;
eiPtr->body.ei.name = NULL;
eiPtr->body.ei.image = NULL;
- eiPtr->body.ei.align = ALIGN_CENTER;
+ eiPtr->body.ei.align = TK_ALIGN_CENTER;
eiPtr->body.ei.padX = eiPtr->body.ei.padY = 0;
eiPtr->body.ei.chunkCount = 0;
eiPtr->body.ei.optionTable = Tk_CreateOptionTable(interp, optionSpecs);
@@ -283,18 +279,23 @@ TkTextImageCmd(
Tcl_HashEntry *hPtr;
Tcl_Obj *resultObj;
- if (objc == 3) {
- resultObj = Tcl_NewObj();
- for (hPtr = Tcl_FirstHashEntry(&textPtr->sharedTextPtr->imageTable,
- &search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
- Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj(
- (const char *)Tcl_GetHashKey(&textPtr->sharedTextPtr->markTable, hPtr), -1));
- }
+ if (objc != 3) {
+ Tcl_WrongNumArgs(interp, 3, objv, NULL);
+ return TCL_ERROR;
+ }
+ resultObj = Tcl_NewObj();
+ for (hPtr = Tcl_FirstHashEntry(&textPtr->sharedTextPtr->imageTable,
+ &search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
+ Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj(
+ (const char *)Tcl_GetHashKey(&textPtr->sharedTextPtr->markTable, hPtr),
+ -1));
+ }
+ if (resultObj == NULL) {
+ return TCL_ERROR;
+ } else {
Tcl_SetObjResult(interp, resultObj);
return TCL_OK;
}
- Tcl_WrongNumArgs(interp, 3, objv, NULL);
- break;
}
default:
Tcl_Panic("unexpected switch fallthrough");
@@ -326,7 +327,7 @@ EmbImageConfigure(
TkText *textPtr, /* Information about text widget that contains
* embedded image. */
TkTextSegment *eiPtr, /* Embedded image to be configured. */
- int objc, /* Number of strings in objv. */
+ Tcl_Size objc, /* Number of strings in objv. */
Tcl_Obj *const objv[]) /* Array of strings describing configuration
* options. */
{
@@ -336,7 +337,7 @@ EmbImageConfigure(
char *name;
int dummy, length;
- if (Tk_SetOptions(textPtr->interp, (char *)&eiPtr->body.ei,
+ if (Tk_SetOptions(textPtr->interp, &eiPtr->body.ei,
eiPtr->body.ei.optionTable,
objc, objv, textPtr->tkwin, NULL, NULL) != TCL_OK) {
return TCL_ERROR;
@@ -380,9 +381,9 @@ EmbImageConfigure(
if (name == NULL) {
Tcl_SetObjResult(textPtr->interp, Tcl_NewStringObj(
"Either a \"-name\" or a \"-image\" argument must be"
- " provided to the \"image create\" subcommand", -1));
+ " provided to the \"image create\" subcommand", TCL_INDEX_NONE));
Tcl_SetErrorCode(textPtr->interp, "TK", "TEXT", "IMAGE_CREATE_USAGE",
- NULL);
+ (char *)NULL);
return TCL_ERROR;
}
@@ -391,8 +392,8 @@ EmbImageConfigure(
char buf[4 + TCL_INTEGER_SPACE];
snprintf(buf, sizeof(buf), "#%d", ++textPtr->sharedTextPtr->imageCount);
Tcl_DStringSetLength(&newName, 0);
- Tcl_DStringAppend(&newName, name, -1);
- Tcl_DStringAppend(&newName, buf, -1);
+ Tcl_DStringAppend(&newName, name, TCL_INDEX_NONE);
+ Tcl_DStringAppend(&newName, buf, TCL_INDEX_NONE);
name = Tcl_DStringValue(&newName);
}
length = strlen(name);
@@ -402,7 +403,7 @@ EmbImageConfigure(
Tcl_SetHashValue(hPtr, eiPtr);
eiPtr->body.ei.name = (char *)ckalloc(length + 1);
memcpy(eiPtr->body.ei.name, name, length + 1);
- Tcl_SetObjResult(textPtr->interp, Tcl_NewStringObj(name, -1));
+ Tcl_SetObjResult(textPtr->interp, Tcl_NewStringObj(name, TCL_INDEX_NONE));
Tcl_DStringFree(&newName);
return TCL_OK;
@@ -456,7 +457,7 @@ EmbImageDeleteProc(
* options.
*/
- Tk_FreeConfigOptions((char *) &eiPtr->body.ei, eiPtr->body.ei.optionTable,
+ Tk_FreeConfigOptions(&eiPtr->body.ei, eiPtr->body.ei.optionTable,
NULL);
if (eiPtr->body.ei.name) {
ckfree(eiPtr->body.ei.name);
@@ -513,11 +514,11 @@ EmbImageLayoutProc(
TkText *textPtr, /* Text widget being layed out. */
TCL_UNUSED(TkTextIndex *), /* Identifies first character in chunk. */
TkTextSegment *eiPtr, /* Segment corresponding to indexPtr. */
- int offset, /* Offset within segPtr corresponding to
+ Tcl_Size offset, /* Offset within segPtr corresponding to
* indexPtr (always 0). */
int maxX, /* Chunk must not occupy pixels at this
* position or higher. */
- TCL_UNUSED(int), /* Chunk must not include more than this many
+ TCL_UNUSED(Tcl_Size), /* Chunk must not include more than this many
* characters. */
int noCharsYet, /* Non-zero means no characters have been
* assigned to this line yet. */
@@ -561,7 +562,7 @@ EmbImageLayoutProc(
chunkPtr->measureProc = NULL;
chunkPtr->bboxProc = EmbImageBboxProc;
chunkPtr->numBytes = 1;
- if (eiPtr->body.ei.align == ALIGN_BASELINE) {
+ if (eiPtr->body.ei.align == TK_ALIGN_BASELINE) {
chunkPtr->minAscent = height - eiPtr->body.ei.padY;
chunkPtr->minDescent = eiPtr->body.ei.padY;
chunkPtr->minHeight = 0;
@@ -606,7 +607,7 @@ EmbImageCheckProc(
}
if (eiPtr->size != 1) {
Tcl_Panic("EmbImageCheckProc: embedded image has size %d",
- eiPtr->size);
+ (int)eiPtr->size);
}
}
@@ -695,7 +696,7 @@ static void
EmbImageBboxProc(
TCL_UNUSED(TkText *),
TkTextDispChunk *chunkPtr, /* Chunk containing desired char. */
- TCL_UNUSED(int), /* Index of desired character within the
+ TCL_UNUSED(Tcl_Size), /* Index of desired character within the
* chunk. */
int y, /* Topmost pixel in area allocated for this
* line. */
@@ -723,16 +724,16 @@ EmbImageBboxProc(
*xPtr = chunkPtr->x + eiPtr->body.ei.padX;
switch (eiPtr->body.ei.align) {
- case ALIGN_BOTTOM:
+ case TK_ALIGN_BOTTOM:
*yPtr = y + (lineHeight - *heightPtr - eiPtr->body.ei.padY);
break;
- case ALIGN_CENTER:
+ case TK_ALIGN_CENTER:
*yPtr = y + (lineHeight - *heightPtr)/2;
break;
- case ALIGN_TOP:
+ case TK_ALIGN_TOP:
*yPtr = y + eiPtr->body.ei.padY;
break;
- case ALIGN_BASELINE:
+ case TK_ALIGN_BASELINE:
*yPtr = y + (baseline - *heightPtr);
break;
}
@@ -811,7 +812,7 @@ TkTextImageIndex(
static void
EmbImageProc(
- ClientData clientData, /* Pointer to widget record. */
+ void *clientData, /* Pointer to widget record. */
TCL_UNUSED(int), /* Upper left pixel (within image) that must
* be redisplayed. */
TCL_UNUSED(int),
diff --git a/generic/tkTextIndex.c b/generic/tkTextIndex.c
index 272f234..5a4115c 100644
--- a/generic/tkTextIndex.c
+++ b/generic/tkTextIndex.c
@@ -4,8 +4,8 @@
* This module provides functions that manipulate indices for text
* widgets.
*
- * Copyright (c) 1992-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1992-1994 The Regents of the University of California.
+ * Copyright © 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.
@@ -45,8 +45,16 @@ static int GetIndex(Tcl_Interp *interp, TkSharedText *sharedPtr,
TkText *textPtr, const char *string,
TkTextIndex *indexPtr, int *canCachePtr);
static int IndexCountBytesOrdered(const TkText *textPtr,
- const TkTextIndex *indexPtr1,
- const TkTextIndex *indexPtr2);
+ const TkTextIndex *indexPtr1,
+ const TkTextIndex *indexPtr2);
+
+#if defined(USE_TCL_STUBS) && (TCL_MAJOR_VERSION < 9)
+# undef Tcl_UtfPrev
+# define Tcl_UtfPrev (((&tclStubsPtr->tcl_PkgProvideEx)[631]) ? \
+ ((const char * (*)(const char *, const char *))(void *)((&tclStubsPtr->tcl_PkgProvideEx)[656])) \
+ : ((const char * (*)(const char *, const char *))(void *)((&tclStubsPtr->tcl_PkgProvideEx)[331])))
+#endif
+
/*
* The "textindex" Tcl_Obj definition:
@@ -68,19 +76,21 @@ static void UpdateStringOfTextIndex(Tcl_Obj *objPtr);
#define SET_TEXTINDEX(objPtr, indexPtr) \
((objPtr)->internalRep.twoPtrValue.ptr1 = (void *)(indexPtr))
#define SET_INDEXEPOCH(objPtr, epoch) \
- ((objPtr)->internalRep.twoPtrValue.ptr2 = INT2PTR(epoch))
+ ((objPtr)->internalRep.twoPtrValue.ptr2 = (void *) (size_t) (epoch))
/*
* Define the 'textindex' object type, which Tk uses to represent indices in
* text widgets internally.
*/
-const Tcl_ObjType tkTextIndexType = {
- "textindex", /* name */
+const TkObjType tkTextIndexType = {
+ {"textindex", /* name */
FreeTextIndexInternalRep, /* freeIntRepProc */
DupTextIndexInternalRep, /* dupIntRepProc */
NULL, /* updateStringProc */
- NULL /* setFromAnyProc */
+ NULL, /* setFromAnyProc */
+ TCL_OBJTYPE_V0},
+ 0
};
static void
@@ -108,7 +118,7 @@ DupTextIndexInternalRep(
Tcl_Obj *srcPtr, /* TextIndex obj with internal rep to copy. */
Tcl_Obj *copyPtr) /* TextIndex obj with internal rep to set. */
{
- int epoch;
+ Tcl_Size epoch;
TkTextIndex *dupIndexPtr, *indexPtr;
dupIndexPtr = (TkTextIndex *)ckalloc(sizeof(TkTextIndex));
@@ -124,7 +134,7 @@ DupTextIndexInternalRep(
}
SET_TEXTINDEX(copyPtr, dupIndexPtr);
SET_INDEXEPOCH(copyPtr, epoch);
- copyPtr->typePtr = &tkTextIndexType;
+ copyPtr->typePtr = &tkTextIndexType.objType;
}
/*
@@ -186,7 +196,7 @@ MakeObjIndex(
indexPtr->linePtr = origPtr->linePtr;
indexPtr->byteIndex = origPtr->byteIndex;
SET_TEXTINDEX(objPtr, indexPtr);
- objPtr->typePtr = &tkTextIndexType;
+ objPtr->typePtr = &tkTextIndexType.objType;
indexPtr->textPtr = textPtr;
if (textPtr != NULL) {
@@ -209,8 +219,8 @@ TkTextGetIndexFromObj(
TkTextIndex *indexPtr = NULL;
int cache;
- if (objPtr->typePtr == &tkTextIndexType) {
- int epoch;
+ if (objPtr->typePtr == &tkTextIndexType.objType) {
+ Tcl_Size epoch;
indexPtr = GET_TEXTINDEX(objPtr);
epoch = GET_INDEXEPOCH(objPtr);
@@ -385,7 +395,7 @@ TkTextMakeByteIndex(
const TkText *textPtr,
int lineIndex, /* Index of desired line (0 means first line
* of text). */
- int byteIndex, /* Byte index of desired character. */
+ Tcl_Size byteIndex, /* Byte index of desired character. */
TkTextIndex *indexPtr) /* Structure to fill in. */
{
TkTextSegment *segPtr;
@@ -429,7 +439,7 @@ TkTextMakeByteIndex(
indexPtr->byteIndex = index - sizeof(char);
break;
}
- if (index + segPtr->size > byteIndex) {
+ if (index + (int)segPtr->size > byteIndex) {
indexPtr->byteIndex = byteIndex;
if ((byteIndex > index) && (segPtr->typePtr == &tkTextCharType)) {
/*
@@ -440,7 +450,7 @@ TkTextMakeByteIndex(
*/
start = segPtr->body.chars + (byteIndex - index);
- p = TkUtfPrev(start, segPtr->body.chars);
+ p = Tcl_UtfPrev(start, segPtr->body.chars);
p += TkUtfToUniChar(p, &ch);
indexPtr->byteIndex += p - start;
}
@@ -484,7 +494,7 @@ TkTextMakeCharIndex(
TkTextSegment *segPtr;
char *p, *start, *end;
int index, offset;
- Tcl_UniChar ch = 0;
+ int ch = 0;
indexPtr->tree = tree;
if (lineIndex < 0) {
@@ -531,11 +541,11 @@ TkTextMakeCharIndex(
return indexPtr;
}
charIndex--;
- offset = Tcl_UtfToUniChar(p, &ch);
+ offset = TkUtfToUniChar(p, &ch);
index += offset;
}
} else {
- if (charIndex < segPtr->size) {
+ if (charIndex < (int)segPtr->size) {
indexPtr->byteIndex = index;
break;
}
@@ -569,11 +579,11 @@ TkTextMakeCharIndex(
TkTextSegment *
TkTextIndexToSeg(
const TkTextIndex *indexPtr,/* Text index. */
- int *offsetPtr) /* Where to store offset within segment, or
+ Tcl_Size *offsetPtr) /* Where to store offset within segment, or
* NULL if offset isn't wanted. */
{
TkTextSegment *segPtr;
- int offset;
+ Tcl_Size offset;
for (offset = indexPtr->byteIndex, segPtr = indexPtr->linePtr->segPtr;
offset >= segPtr->size;
@@ -604,13 +614,13 @@ TkTextIndexToSeg(
*---------------------------------------------------------------------------
*/
-int
+Tcl_Size
TkTextSegToOffset(
const TkTextSegment *segPtr,/* Segment whose offset is desired. */
const TkTextLine *linePtr) /* Line containing segPtr. */
{
const TkTextSegment *segPtr2;
- int offset = 0;
+ Tcl_Size offset = 0;
for (segPtr2 = linePtr->segPtr; segPtr2 != segPtr;
segPtr2 = segPtr2->nextPtr) {
@@ -790,7 +800,7 @@ GetIndex(
*/
Tcl_DStringInit(&copy);
- p = strrchr(Tcl_DStringAppend(&copy, string, -1), '.');
+ p = strrchr(Tcl_DStringAppend(&copy, string, TCL_INDEX_NONE), '.');
if (p != NULL) {
TkTextSearch search;
TkTextTag *tagPtr;
@@ -842,7 +852,7 @@ GetIndex(
"text doesn't contain any characters tagged with \"%s\"",
tagName));
Tcl_SetErrorCode(interp, "TK", "LOOKUP", "TEXT_INDEX", tagName,
- NULL);
+ (char *)NULL);
Tcl_DStringFree(&copy);
return TCL_ERROR;
}
@@ -1007,7 +1017,7 @@ GetIndex(
error:
Tcl_DStringFree(&copy);
Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad text index \"%s\"", string));
- Tcl_SetErrorCode(interp, "TK", "TEXT", "BAD_INDEX", NULL);
+ Tcl_SetErrorCode(interp, "TK", "TEXT", "BAD_INDEX", (char *)NULL);
return TCL_ERROR;
}
@@ -1090,7 +1100,7 @@ TkTextIndexAdjustToStartEnd(
*---------------------------------------------------------------------------
*/
-int
+Tcl_Size
TkTextPrintIndex(
const TkText *textPtr,
const TkTextIndex *indexPtr,/* Pointer to index. */
@@ -1099,7 +1109,7 @@ TkTextPrintIndex(
{
TkTextSegment *segPtr;
TkTextLine *linePtr;
- int numBytes, charIndex;
+ Tcl_Size numBytes, charIndex;
numBytes = indexPtr->byteIndex;
charIndex = 0;
@@ -1119,7 +1129,7 @@ TkTextPrintIndex(
break;
}
if (segPtr->typePtr == &tkTextCharType) {
- charIndex += Tcl_NumUtfChars(segPtr->body.chars, segPtr->size);
+ charIndex += TkNumUtfChars(segPtr->body.chars, segPtr->size);
} else {
charIndex += segPtr->size;
}
@@ -1127,12 +1137,12 @@ TkTextPrintIndex(
}
if (segPtr->typePtr == &tkTextCharType) {
- charIndex += Tcl_NumUtfChars(segPtr->body.chars, numBytes);
+ charIndex += TkNumUtfChars(segPtr->body.chars, numBytes);
} else {
charIndex += numBytes;
}
- return snprintf(string, TK_POS_CHARS, "%d.%d",
+ return snprintf(string, TK_POS_CHARS, "%d.%" TCL_SIZE_MODIFIER "d",
TkBTreeLinesTo(textPtr, indexPtr->linePtr) + 1, charIndex);
}
@@ -1377,7 +1387,7 @@ ForwBack(
} else {
TkTextFindDisplayLineEnd(textPtr, indexPtr, 0, &xOffset);
while (count-- > 0) {
- TkTextIndex indexPtr2;
+ TkTextIndex indexPtr2;
/*
* Go to the beginning of the line, then backward one
@@ -1388,20 +1398,20 @@ ForwBack(
TkTextIndexBackChars(textPtr, indexPtr, 1, &indexPtr2,
COUNT_DISPLAY_INDICES);
- /*
- * If we couldn't go to the previous line, then we wanted
- to go before the start of the text: arrange for returning
- the first index of the first display line.
- */
-
- if (!TkTextIndexCmp(indexPtr, &indexPtr2)) {
- xOffset = 0;
- break;
- }
- *indexPtr = indexPtr2;
+ /*
+ * If we couldn't go to the previous line, then we wanted
+ to go before the start of the text: arrange for returning
+ the first index of the first display line.
+ */
+
+ if (!TkTextIndexCmp(indexPtr, &indexPtr2)) {
+ xOffset = 0;
+ break;
+ }
+ *indexPtr = indexPtr2;
}
}
- TkTextFindDisplayLineEnd(textPtr, indexPtr, 0, NULL);
+ TkTextFindDisplayLineEnd(textPtr, indexPtr, 0, NULL);
/*
* This call assumes indexPtr is the beginning of a display line
@@ -1474,7 +1484,7 @@ int
TkTextIndexForwBytes(
const TkText *textPtr,
const TkTextIndex *srcPtr, /* Source index. */
- int byteCount, /* How many bytes forward to move. May be
+ Tcl_Size byteCount, /* How many bytes forward to move. May be
* negative. */
TkTextIndex *dstPtr) /* Destination index: gets modified. */
{
@@ -1554,7 +1564,7 @@ TkTextIndexForwChars(
TkTextLine *linePtr;
TkTextSegment *segPtr;
TkTextElideInfo *infoPtr = NULL;
- int byteOffset;
+ Tcl_Size byteOffset;
char *start, *end, *p;
int ch;
int elide = 0;
@@ -1611,7 +1621,7 @@ TkTextIndexForwChars(
* toggled off), or it's a new tag with higher priority.
*/
- if (tagPtr->elideString != NULL) {
+ if (tagPtr->elide >= 0) {
infoPtr->tagCnts[tagPtr->priority]++;
if (infoPtr->tagCnts[tagPtr->priority] & 1) {
infoPtr->tagPtrs[tagPtr->priority] = tagPtr;
@@ -1639,12 +1649,12 @@ TkTextIndexForwChars(
if (infoPtr->tagCnts[infoPtr->elidePriority]
& 1) {
elide = infoPtr->tagPtrs
- [infoPtr->elidePriority]->elide;
+ [infoPtr->elidePriority]->elide > 0;
break;
}
}
} else {
- elide = tagPtr->elide;
+ elide = tagPtr->elide > 0;
infoPtr->elidePriority = tagPtr->priority;
}
}
@@ -1742,12 +1752,12 @@ IndexCountBytesOrdered(
/* Index describing location of last character
* at which to stop the count. */
{
- int byteCount, offset;
+ Tcl_Size byteCount, offset;
TkTextSegment *segPtr, *segPtr1;
TkTextLine *linePtr;
if (indexPtr1->linePtr == indexPtr2->linePtr) {
- return indexPtr2->byteIndex - indexPtr1->byteIndex;
+ return indexPtr2->byteIndex - indexPtr1->byteIndex;
}
/*
@@ -1761,19 +1771,19 @@ IndexCountBytesOrdered(
segPtr1 = TkTextIndexToSeg(indexPtr1, &offset);
byteCount = -offset;
for (segPtr = segPtr1; segPtr != NULL; segPtr = segPtr->nextPtr) {
- byteCount += segPtr->size;
+ byteCount += segPtr->size;
}
linePtr = TkBTreeNextLine(textPtr, indexPtr1->linePtr);
while (linePtr != indexPtr2->linePtr) {
for (segPtr = linePtr->segPtr; segPtr != NULL;
- segPtr = segPtr->nextPtr) {
- byteCount += segPtr->size;
- }
- linePtr = TkBTreeNextLine(textPtr, linePtr);
- if (linePtr == NULL) {
- Tcl_Panic("TextIndexCountBytesOrdered ran out of lines");
- }
+ segPtr = segPtr->nextPtr) {
+ byteCount += segPtr->size;
+ }
+ linePtr = TkBTreeNextLine(textPtr, linePtr);
+ if (linePtr == NULL) {
+ Tcl_Panic("TextIndexCountBytesOrdered ran out of lines");
+ }
}
byteCount += indexPtr2->byteIndex;
@@ -1819,7 +1829,8 @@ TkTextIndexCount(
TkTextLine *linePtr1;
TkTextSegment *segPtr, *seg2Ptr = NULL;
TkTextElideInfo *infoPtr = NULL;
- int byteOffset, maxBytes, count = 0, elide = 0;
+ Tcl_Size byteOffset, maxBytes, count = 0;
+ int elide = 0;
int checkElided = (type & COUNT_DISPLAY);
/*
@@ -1860,7 +1871,7 @@ TkTextIndexCount(
* toggled off), or it's a new tag with higher priority.
*/
- if (tagPtr->elideString != NULL) {
+ if (tagPtr->elide >= 0) {
infoPtr->tagCnts[tagPtr->priority]++;
if (infoPtr->tagCnts[tagPtr->priority] & 1) {
infoPtr->tagPtrs[tagPtr->priority] = tagPtr;
@@ -1888,12 +1899,12 @@ TkTextIndexCount(
if (infoPtr->tagCnts[
infoPtr->elidePriority] & 1) {
elide = infoPtr->tagPtrs[
- infoPtr->elidePriority]->elide;
+ infoPtr->elidePriority]->elide > 0;
break;
}
}
} else {
- elide = tagPtr->elide;
+ elide = tagPtr->elide > 0;
infoPtr->elidePriority = tagPtr->priority;
}
}
@@ -1909,10 +1920,10 @@ TkTextIndexCount(
}
if (segPtr->typePtr == &tkTextCharType) {
- int byteLen = segPtr->size - byteOffset;
+ Tcl_Size byteLen = segPtr->size - byteOffset;
unsigned char *str = (unsigned char *)
segPtr->body.chars + byteOffset;
- int i;
+ Tcl_Size i;
if (segPtr == seg2Ptr) {
if (byteLen + byteOffset > maxBytes) {
@@ -1937,12 +1948,12 @@ TkTextIndexCount(
}
count += byteLen - i;
if (i) {
- count += Tcl_NumUtfChars(segPtr->body.chars + byteOffset
+ count += TkNumUtfChars(segPtr->body.chars + byteOffset
+ (byteLen - i), i);
}
} else {
if (type & COUNT_INDICES) {
- int byteLen = segPtr->size - byteOffset;
+ Tcl_Size byteLen = segPtr->size - byteOffset;
if (segPtr == seg2Ptr) {
if (byteLen + byteOffset > maxBytes) {
@@ -2004,7 +2015,7 @@ int
TkTextIndexBackBytes(
const TkText *textPtr,
const TkTextIndex *srcPtr, /* Source index. */
- int byteCount, /* How many bytes backward to move. May be
+ Tcl_Size byteCount, /* How many bytes backward to move. May be
* negative. */
TkTextIndex *dstPtr) /* Destination index: gets modified. */
{
@@ -2121,7 +2132,7 @@ TkTextIndexBackChars(
linePtr = TkBTreeNextLine(NULL, linePtr);
segPtr = linePtr->segPtr;
}
- if (segSize <= segPtr->size) {
+ if (segSize <= (int)segPtr->size) {
break;
}
segSize -= segPtr->size;
@@ -2149,7 +2160,7 @@ TkTextIndexBackChars(
* it's a new tag with higher priority.
*/
- if (tagPtr->elideString != NULL) {
+ if (tagPtr->elide >= 0) {
infoPtr->tagCnts[tagPtr->priority]++;
if (infoPtr->tagCnts[tagPtr->priority] & 1) {
infoPtr->tagPtrs[tagPtr->priority] = tagPtr;
@@ -2175,12 +2186,12 @@ TkTextIndexBackChars(
while (--infoPtr->elidePriority > 0) {
if (infoPtr->tagCnts[infoPtr->elidePriority] & 1) {
elide = infoPtr->tagPtrs[
- infoPtr->elidePriority]->elide;
+ infoPtr->elidePriority]->elide > 0;
break;
}
}
} else {
- elide = tagPtr->elide;
+ elide = tagPtr->elide > 0;
infoPtr->elidePriority = tagPtr->priority;
}
}
@@ -2191,7 +2202,7 @@ TkTextIndexBackChars(
if (segPtr->typePtr == &tkTextCharType) {
start = segPtr->body.chars;
end = segPtr->body.chars + segSize;
- for (p = end; ; p = TkUtfPrev(p, start)) {
+ for (p = end; ; p = Tcl_UtfPrev(p, start)) {
if (charCount == 0) {
dstPtr->byteIndex -= (end - p);
goto backwardCharDone;
@@ -2199,7 +2210,9 @@ TkTextIndexBackChars(
if (p == start) {
break;
}
- charCount--;
+ if (charCount != 0) {
+ charCount--;
+ }
}
} else {
if (type & COUNT_INDICES) {
@@ -2362,7 +2375,7 @@ StartEnd(
} else if ((*string == 'w') && (strncmp(string, "wordend", length) == 0)
&& (length >= 5)) {
int firstChar = 1;
- int offset;
+ Tcl_Size offset;
/*
* If the current character isn't part of a word then just move
@@ -2405,7 +2418,7 @@ StartEnd(
} else if ((*string == 'w') && (strncmp(string, "wordstart", length) == 0)
&& (length >= 5)) {
int firstChar = 1;
- int offset;
+ Tcl_Size offset;
if (modifier == TKINDEX_DISPLAY) {
TkTextIndexForwChars(textPtr, indexPtr, 0, indexPtr,
@@ -2430,28 +2443,28 @@ StartEnd(
if (!Tcl_UniCharIsWordChar(ch)) {
break;
}
- if (offset > 0) {
+ if (offset + 1 > 1) {
chSize = (segPtr->body.chars + offset
- - TkUtfPrev(segPtr->body.chars + offset,
+ - Tcl_UtfPrev(segPtr->body.chars + offset,
segPtr->body.chars));
}
firstChar = 0;
}
- if (offset == 0) {
+ if (offset == 0) {
if (indexPtr->byteIndex == 0) {
goto done;
}
- if (modifier == TKINDEX_DISPLAY) {
- TkTextIndexBackChars(textPtr, indexPtr, 1, indexPtr,
- COUNT_DISPLAY_INDICES);
- } else {
- TkTextIndexBackChars(NULL, indexPtr, 1, indexPtr,
- COUNT_INDICES);
- }
- } else {
- indexPtr->byteIndex -= chSize;
- }
- offset -= chSize;
+ if (modifier == TKINDEX_DISPLAY) {
+ TkTextIndexBackChars(textPtr, indexPtr, 1, indexPtr,
+ COUNT_DISPLAY_INDICES);
+ } else {
+ TkTextIndexBackChars(NULL, indexPtr, 1, indexPtr,
+ COUNT_INDICES);
+ }
+ } else {
+ indexPtr->byteIndex -= chSize;
+ }
+ offset -= chSize;
if (offset < 0) {
segPtr = TkTextIndexToSeg(indexPtr, &offset);
}
diff --git a/generic/tkTextMark.c b/generic/tkTextMark.c
index 15eb035..2339ed0 100644
--- a/generic/tkTextMark.c
+++ b/generic/tkTextMark.c
@@ -4,8 +4,8 @@
* This file contains the functions that implement marks for text
* widgets.
*
- * Copyright (c) 1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1994 The Regents of the University of California.
+ * Copyright © 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.
@@ -19,8 +19,8 @@
* Macro that determines the size of a mark segment:
*/
-#define MSEG_SIZE ((unsigned)(Tk_Offset(TkTextSegment, body) \
- + sizeof(TkTextMark)))
+#define MSEG_SIZE (offsetof(TkTextSegment, body) \
+ + sizeof(TkTextMark))
/*
* Forward references for functions defined in this file:
@@ -36,8 +36,8 @@ static TkTextSegment * MarkCleanupProc(TkTextSegment *segPtr,
static void MarkCheckProc(TkTextSegment *segPtr,
TkTextLine *linePtr);
static int MarkLayoutProc(TkText *textPtr, TkTextIndex *indexPtr,
- TkTextSegment *segPtr, int offset, int maxX,
- int maxChars, int noCharsYet, TkWrapMode wrapMode,
+ TkTextSegment *segPtr, Tcl_Size offset, int maxX,
+ Tcl_Size maxChars, int noCharsYet, TkWrapMode wrapMode,
TkTextDispChunk *chunkPtr);
static int MarkFindNext(Tcl_Interp *interp,
TkText *textPtr, Tcl_Obj *markName);
@@ -95,7 +95,7 @@ int
TkTextMarkCmd(
TkText *textPtr, /* Information about text widget. */
Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. Someone else has already
* parsed this command enough to know that
* objv[1] is "mark". */
@@ -114,7 +114,7 @@ TkTextMarkCmd(
MARK_UNSET
};
- if (objc < 3) {
+ if (objc + 1 < 4) {
Tcl_WrongNumArgs(interp, 2, objv, "option ?arg ...?");
return TCL_ERROR;
}
@@ -126,7 +126,7 @@ TkTextMarkCmd(
switch ((enum markOptions) optionIndex) {
case MARK_GRAVITY: {
char c;
- int length;
+ Tcl_Size length;
const char *str;
if (objc < 4 || objc > 5) {
@@ -144,7 +144,7 @@ TkTextMarkCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"there is no mark named \"%s\"", str));
Tcl_SetErrorCode(interp, "TK", "LOOKUP", "TEXT_MARK", str,
- NULL);
+ (char *)NULL);
return TCL_ERROR;
}
markPtr = (TkTextSegment *)Tcl_GetHashValue(hPtr);
@@ -157,7 +157,7 @@ TkTextMarkCmd(
} else {
typeStr = "left";
}
- Tcl_SetObjResult(interp, Tcl_NewStringObj(typeStr, -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(typeStr, TCL_INDEX_NONE));
return TCL_OK;
}
str = Tcl_GetStringFromObj(objv[4],&length);
@@ -170,7 +170,7 @@ TkTextMarkCmd(
} else {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad mark gravity \"%s\": must be left or right", str));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "MARK_GRAVITY", NULL);
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "MARK_GRAVITY", (char *)NULL);
return TCL_ERROR;
}
TkTextMarkSegToIndex(textPtr, markPtr, &index);
@@ -188,9 +188,9 @@ TkTextMarkCmd(
}
resultObj = Tcl_NewObj();
Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj(
- "insert", -1));
+ "insert", TCL_INDEX_NONE));
Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj(
- "current", -1));
+ "current", TCL_INDEX_NONE));
for (hPtr = Tcl_FirstHashEntry(&textPtr->sharedTextPtr->markTable,
&search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
Tcl_ListObjAppendElement(NULL, resultObj, Tcl_NewStringObj(
@@ -223,7 +223,7 @@ TkTextMarkCmd(
TkTextSetMark(textPtr, Tcl_GetString(objv[3]), &index);
return TCL_OK;
case MARK_UNSET: {
- int i;
+ Tcl_Size i;
for (i = 3; i < objc; i++) {
hPtr = Tcl_FindHashEntry(&textPtr->sharedTextPtr->markTable,
@@ -301,7 +301,7 @@ TkTextSetMark(
if (markPtr == textPtr->insertMarkPtr) {
TkTextIndex index, index2;
- int nblines;
+ int nblines;
TkTextMarkSegToIndex(textPtr, textPtr->insertMarkPtr, &index);
TkTextIndexForwChars(NULL, &index, 1, &index2, COUNT_INDICES);
@@ -313,12 +313,12 @@ TkTextSetMark(
TkTextChanged(NULL, textPtr, &index, &index2);
- /*
- * The number of lines in the widget is zero if and only if it is
- * a partial peer with -startline == -endline, i.e. an empty
- * peer. In this case the mark shall be set exactly at the given
- * index, and not one character backwards (bug 3487407).
- */
+ /*
+ * The number of lines in the widget is zero if and only if it is
+ * a partial peer with -startline == -endline, i.e. an empty
+ * peer. In this case the mark shall be set exactly at the given
+ * index, and not one character backwards (bug 3487407).
+ */
nblines = TkBTreeNumLines(textPtr->sharedTextPtr->tree, textPtr);
if ((TkBTreeLinesTo(textPtr, indexPtr->linePtr) == nblines)
@@ -436,7 +436,7 @@ TkTextMarkNameToIndex(
TkTextSegment *segPtr;
if (textPtr == NULL) {
- return TCL_ERROR;
+ return TCL_ERROR;
}
if (!strcmp(name, "insert")) {
@@ -547,11 +547,11 @@ MarkLayoutProc(
TkText *textPtr, /* Text widget being layed out. */
TCL_UNUSED(TkTextIndex *), /* Identifies first character in chunk. */
TkTextSegment *segPtr, /* Segment corresponding to indexPtr. */
- TCL_UNUSED(int), /* Offset within segPtr corresponding to
+ TCL_UNUSED(Tcl_Size), /* Offset within segPtr corresponding to
* indexPtr (always 0). */
TCL_UNUSED(int), /* Chunk must not occupy pixels at this
* position or higher. */
- TCL_UNUSED(int), /* Chunk must not include more than this many
+ TCL_UNUSED(Tcl_Size), /* Chunk must not include more than this many
* characters. */
TCL_UNUSED(int), /* Non-zero means no characters have been
* assigned to this line yet. */
@@ -749,7 +749,7 @@ MarkCheckProc(
*/
if (markPtr->body.mark.textPtr->insertMarkPtr == markPtr) {
- return;
+ return;
}
if (markPtr->body.mark.textPtr->currentMarkPtr == markPtr) {
return;
@@ -933,16 +933,16 @@ MarkFindPrev(
seg2Ptr = seg2Ptr->nextPtr) {
if (seg2Ptr->typePtr == &tkTextRightMarkType ||
seg2Ptr->typePtr == &tkTextLeftMarkType) {
- if (seg2Ptr->body.mark.hPtr == NULL) {
- if (seg2Ptr != textPtr->currentMarkPtr &&
- seg2Ptr != textPtr->insertMarkPtr) {
- /*
- * This is an insert or current mark from a
- * peer of textPtr.
- */
- continue;
- }
- }
+ if (seg2Ptr->body.mark.hPtr == NULL) {
+ if (seg2Ptr != textPtr->currentMarkPtr &&
+ seg2Ptr != textPtr->insertMarkPtr) {
+ /*
+ * This is an insert or current mark from a
+ * peer of textPtr.
+ */
+ continue;
+ }
+ }
prevPtr = seg2Ptr;
}
}
diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c
index d734b8d..4110e8f 100644
--- a/generic/tkTextTag.c
+++ b/generic/tkTextTag.c
@@ -5,8 +5,8 @@
* text widgets, plus most of the other high-level functions related to
* tags.
*
- * Copyright (c) 1992-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1992-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -16,28 +16,6 @@
#include "tkText.h"
#include "default.h"
-/*
- * The 'TkWrapMode' enum in tkText.h is used to define a type for the -wrap
- * option of tags in a Text widget. These values are used as indices into the
- * string table below. Tags are allowed an empty wrap value, but the widget as
- * a whole is not.
- */
-
-static const char *const wrapStrings[] = {
- "char", "none", "word", "", NULL
-};
-
-/*
- * The 'TkTextTabStyle' enum in tkText.h is used to define a type for the
- * -tabstyle option of the Text widget. These values are used as indices into
- * the string table below. Tags are allowed an empty tabstyle value, but the
- * widget as a whole is not.
- */
-
-static const char *const tabStyleStrings[] = {
- "tabular", "wordprocessor", "", NULL
-};
-
/* This struct can be used for booleans, relief and pixels */
typedef struct {
char *string;
@@ -65,26 +43,33 @@ ObjectIsEmpty(
#define OPTION_NONNEG (1 << 10)
static int
-SetPixels(void *clientData,
+SetPixels(
+ TCL_UNUSED(void *),
Tcl_Interp *interp,
Tk_Window tkwin,
Tcl_Obj **value,
char *recordPtr,
- int internalOffset,
+ Tcl_Size internalOffset,
char *oldInternalPtr,
int flags)
{
IntStruct pixel = {NULL, INT_MIN};
IntStruct *internalPtr = (IntStruct *)(recordPtr + internalOffset);
-
- if (!(flags & TK_OPTION_NULL_OK) || !ObjectIsEmpty(*value)) {
- if (Tk_GetPixelsFromObj(interp, tkwin, *value, &pixel.value) != TCL_OK) {
+ int nullOK = (flags & TK_OPTION_NULL_OK);
+
+ if (!nullOK || !ObjectIsEmpty(*value)) {
+ if (Tk_GetPixelsFromObj(nullOK ? NULL : interp, tkwin, *value, &pixel.value) != TCL_OK) {
+ if (nullOK) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "expected screen distance or \"\" but got \"%.50s\"", Tcl_GetString(*value)));
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "PIXELS", (char *)NULL);
+ }
return TCL_ERROR;
}
if ((flags & OPTION_NONNEG) && pixel.value < 0) {
pixel.value = 0;
}
- pixel.string = ckalloc((*value)->length + 1);
+ pixel.string = (char *)ckalloc((*value)->length + 1);
strcpy(pixel.string, (*value)->bytes);
}
@@ -94,23 +79,29 @@ SetPixels(void *clientData,
};
static int
-SetBoolean(void *clientData,
+SetBoolean(
+ TCL_UNUSED(void *),
Tcl_Interp *interp,
- Tk_Window tkwin,
+ TCL_UNUSED(Tk_Window),
Tcl_Obj **value,
char *recordPtr,
- int internalOffset,
+ Tcl_Size internalOffset,
char *oldInternalPtr,
int flags)
{
IntStruct booleanVal = {NULL, -1};
IntStruct *internalPtr = (IntStruct *)(recordPtr + internalOffset);
+ int nullOK = (flags & TK_OPTION_NULL_OK);
- if (!(flags & TK_OPTION_NULL_OK) || !ObjectIsEmpty(*value)) {
- if (Tcl_GetBooleanFromObj(interp, *value, &booleanVal.value) != TCL_OK) {
+ if (!nullOK || !ObjectIsEmpty(*value)) {
+ if (Tcl_GetBooleanFromObj(nullOK ? NULL : interp, *value, &booleanVal.value) != TCL_OK) {
+ if (nullOK) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "expected boolean value or \"\" but got \"%s\"", Tcl_GetString(*value)));
+ }
return TCL_ERROR;
}
- booleanVal.string = ckalloc((*value)->length + 1);
+ booleanVal.string = (char *)ckalloc((*value)->length + 1);
strcpy(booleanVal.string, (*value)->bytes);
}
@@ -120,23 +111,29 @@ SetBoolean(void *clientData,
};
static int
-SetRelief(void *clientData,
+SetRelief(
+ TCL_UNUSED(void *),
Tcl_Interp *interp,
- Tk_Window tkwin,
+ TCL_UNUSED(Tk_Window),
Tcl_Obj **value,
char *recordPtr,
- int internalOffset,
+ Tcl_Size internalOffset,
char *oldInternalPtr,
int flags)
{
IntStruct relief = {NULL, TK_RELIEF_NULL};
IntStruct *internalPtr = (IntStruct *)(recordPtr + internalOffset);
+ int nullOK = (flags & TK_OPTION_NULL_OK);
- if (!(flags & TK_OPTION_NULL_OK) || !ObjectIsEmpty(*value)) {
- if (Tk_GetReliefFromObj(interp, *value, &relief.value) != TCL_OK) {
+ if (!nullOK || !ObjectIsEmpty(*value)) {
+ if (Tk_GetReliefFromObj(nullOK ? NULL : interp, *value, &relief.value) != TCL_OK) {
+ if (nullOK) {
+ Tcl_AppendResult(interp, "bad relief \"",
+ Tcl_GetString(*value), "\": must be flat, groove, raised, ridge, solid, sunken, or \"\"", (char *)NULL);
+ }
return TCL_ERROR;
}
- relief.string = ckalloc((*value)->length + 1);
+ relief.string = (char *)ckalloc((*value)->length + 1);
strcpy(relief.string, (*value)->bytes);
}
@@ -146,23 +143,29 @@ SetRelief(void *clientData,
};
static int
-SetJustify(void *clientData,
+SetJustify(
+ TCL_UNUSED(void *),
Tcl_Interp *interp,
- Tk_Window tkwin,
+ TCL_UNUSED(Tk_Window),
Tcl_Obj **value,
char *recordPtr,
- int internalOffset,
+ Tcl_Size internalOffset,
char *oldInternalPtr,
int flags)
{
- JustifyStruct justify = {NULL, (Tk_Justify)-1};
+ JustifyStruct justify = {NULL, TK_JUSTIFY_NULL};
JustifyStruct *internalPtr = (JustifyStruct *)(recordPtr + internalOffset);
+ int nullOK = (flags & TK_OPTION_NULL_OK);
- if (!(flags & TK_OPTION_NULL_OK) || !ObjectIsEmpty(*value)) {
- if (Tk_GetJustifyFromObj(interp, *value, &justify.value) != TCL_OK) {
+ if (!nullOK || !ObjectIsEmpty(*value)) {
+ if (Tk_GetJustifyFromObj(nullOK ? NULL : interp, *value, &justify.value) != TCL_OK) {
+ if (nullOK) {
+ Tcl_AppendResult(interp, "bad justification \"",
+ Tcl_GetString(*value), "\": must be left, right, center, or \"\"", (char *)NULL);
+ }
return TCL_ERROR;
}
- justify.string = ckalloc((*value)->length + 1);
+ justify.string = (char *)ckalloc((*value)->length + 1);
strcpy(justify.string, (*value)->bytes);
}
@@ -172,23 +175,24 @@ SetJustify(void *clientData,
};
static Tcl_Obj *GetStruct(
- void *clientData,
- Tk_Window tkwin,
+ TCL_UNUSED(void *),
+ TCL_UNUSED(Tk_Window),
char *recordPtr,
- int internalOffset)
+ Tcl_Size internalOffset)
{
char **structPtr = (char **)(recordPtr + internalOffset);
if (*structPtr == NULL || **structPtr == '\0') {
return Tcl_NewObj();
}
- return Tcl_NewStringObj(*structPtr, -1);
+ return Tcl_NewStringObj(*structPtr, TCL_INDEX_NONE);
};
static void
-FreeStruct(void *clientData,
- Tk_Window tkwin,
+FreeStruct(
+ TCL_UNUSED(void *),
+ TCL_UNUSED(Tk_Window),
char *internalPtr)
{
char **structPtr = (char **)internalPtr;
@@ -236,67 +240,67 @@ static const Tk_ObjCustomOption reliefOption = {
static const Tk_OptionSpec tagOptionSpecs[] = {
{TK_OPTION_BORDER, "-background", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, border), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, border), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_BITMAP, "-bgstipple", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, bgStipple), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, bgStipple), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-borderwidth", NULL, NULL,
- NULL, Tk_Offset(TkTextTag, borderWidthPtr), Tk_Offset(TkTextTag, borderWidth),
+ NULL, offsetof(TkTextTag, borderWidthPtr), offsetof(TkTextTag, borderWidth),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_CUSTOM, "-elide", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, elideString),
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, elideString),
TK_OPTION_NULL_OK, &booleanOption, 0},
{TK_OPTION_BITMAP, "-fgstipple", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, fgStipple), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, fgStipple), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_FONT, "-font", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, tkfont), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, tkfont), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_COLOR, "-foreground", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, fgColor), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, fgColor), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_CUSTOM, "-justify", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, justifyString), TK_OPTION_NULL_OK, &justifyOption, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, justifyString), TK_OPTION_NULL_OK, &justifyOption,0},
{TK_OPTION_CUSTOM, "-lmargin1", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, lMargin1String), TK_OPTION_NULL_OK, &pixelsOption, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, lMargin1String), TK_OPTION_NULL_OK,&pixelsOption,0},
{TK_OPTION_CUSTOM, "-lmargin2", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, lMargin2String), TK_OPTION_NULL_OK, &pixelsOption, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, lMargin2String), TK_OPTION_NULL_OK,&pixelsOption,0},
{TK_OPTION_BORDER, "-lmargincolor", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, lMarginColor), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, lMarginColor), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_CUSTOM, "-offset", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, offsetString), TK_OPTION_NULL_OK, &pixelsOption, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, offsetString), TK_OPTION_NULL_OK, &pixelsOption, 0},
{TK_OPTION_CUSTOM, "-overstrike", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, overstrikeString),
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, overstrikeString),
TK_OPTION_NULL_OK, &booleanOption, 0},
{TK_OPTION_COLOR, "-overstrikefg", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, overstrikeColor),
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, overstrikeColor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_CUSTOM, "-relief", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, reliefString), TK_OPTION_NULL_OK, &reliefOption, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, reliefString), TK_OPTION_NULL_OK, &reliefOption, 0},
{TK_OPTION_CUSTOM, "-rmargin", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, rMarginString), TK_OPTION_NULL_OK, &pixelsOption, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, rMarginString), TK_OPTION_NULL_OK, &pixelsOption,0},
{TK_OPTION_BORDER, "-rmargincolor", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, rMarginColor), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, rMarginColor), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_BORDER, "-selectbackground", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, selBorder), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, selBorder), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_COLOR, "-selectforeground", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, selFgColor), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, selFgColor), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_CUSTOM, "-spacing1", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, spacing1String), TK_OPTION_NULL_OK|OPTION_NONNEG, &pixelsOption, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, spacing1String), TK_OPTION_NULL_OK|OPTION_NONNEG, &pixelsOption,0},
{TK_OPTION_CUSTOM, "-spacing2", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, spacing2String), TK_OPTION_NULL_OK|OPTION_NONNEG, &pixelsOption, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, spacing2String), TK_OPTION_NULL_OK|OPTION_NONNEG, &pixelsOption,0},
{TK_OPTION_CUSTOM, "-spacing3", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, spacing3String), TK_OPTION_NULL_OK|OPTION_NONNEG, &pixelsOption, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, spacing3String), TK_OPTION_NULL_OK|OPTION_NONNEG, &pixelsOption,0},
{TK_OPTION_STRING, "-tabs", NULL, NULL,
- NULL, Tk_Offset(TkTextTag, tabStringPtr), -1, TK_OPTION_NULL_OK, 0, 0},
+ NULL, offsetof(TkTextTag, tabStringPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING_TABLE, "-tabstyle", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, tabStyle),
- TK_OPTION_NULL_OK, tabStyleStrings, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, tabStyle),
+ TK_OPTION_NULL_OK|TK_OPTION_ENUM_VAR, tkTextTabStyleStrings, 0},
{TK_OPTION_CUSTOM, "-underline", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, underlineString),
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, underlineString),
TK_OPTION_NULL_OK, &booleanOption, 0},
{TK_OPTION_COLOR, "-underlinefg", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, underlineColor),
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, underlineColor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING_TABLE, "-wrap", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, wrapMode),
- TK_OPTION_NULL_OK|TK_OPTION_ENUM_VAR, wrapStrings, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, wrapMode),
+ TK_OPTION_NULL_OK|TK_OPTION_ENUM_VAR, tkTextWrapStrings, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0}
};
@@ -335,7 +339,7 @@ int
TkTextTagCmd(
TkText *textPtr, /* Information about text widget. */
Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. Someone else has already
* parsed this command enough to know that
* objv[1] is "tag". */
@@ -349,7 +353,8 @@ TkTextTagCmd(
TAG_NAMES, TAG_NEXTRANGE, TAG_PREVRANGE, TAG_RAISE, TAG_RANGES,
TAG_REMOVE
};
- int optionIndex, i;
+ int optionIndex;
+ Tcl_Size i;
TkTextTag *tagPtr;
TkTextIndex index1, index2;
@@ -475,7 +480,7 @@ TkTextTagCmd(
if (fifth[0] == 0) {
return Tk_DeleteBinding(interp,
textPtr->sharedTextPtr->bindingTable,
- (ClientData) tagPtr->name, Tcl_GetString(objv[4]));
+ (void *) tagPtr->name, Tcl_GetString(objv[4]));
}
if (fifth[0] == '+') {
fifth++;
@@ -483,7 +488,7 @@ TkTextTagCmd(
}
mask = Tk_CreateBinding(interp,
textPtr->sharedTextPtr->bindingTable,
- (ClientData) tagPtr->name, Tcl_GetString(objv[4]), fifth,
+ (void *) tagPtr->name, Tcl_GetString(objv[4]), fifth,
append);
if (mask == 0) {
return TCL_ERROR;
@@ -494,11 +499,11 @@ TkTextTagCmd(
|EnterWindowMask|LeaveWindowMask|KeyPressMask
|KeyReleaseMask|PointerMotionMask|VirtualEventMask)) {
Tk_DeleteBinding(interp, textPtr->sharedTextPtr->bindingTable,
- (ClientData) tagPtr->name, Tcl_GetString(objv[4]));
+ (void *) tagPtr->name, Tcl_GetString(objv[4]));
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"requested illegal events; only key, button, motion,"
- " enter, leave, and virtual events may be used", -1));
- Tcl_SetErrorCode(interp, "TK", "TEXT", "TAG_BIND_EVENT",NULL);
+ " enter, leave, and virtual events may be used", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "TEXT", "TAG_BIND_EVENT", (char *)NULL);
return TCL_ERROR;
}
} else if (objc == 5) {
@@ -506,7 +511,7 @@ TkTextTagCmd(
command = Tk_GetBinding(interp,
textPtr->sharedTextPtr->bindingTable,
- (ClientData) tagPtr->name, Tcl_GetString(objv[4]));
+ (void *) tagPtr->name, Tcl_GetString(objv[4]));
if (command == NULL) {
const char *string = Tcl_GetString(Tcl_GetObjResult(interp));
@@ -521,11 +526,11 @@ TkTextTagCmd(
}
Tcl_ResetResult(interp);
} else {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(command, -1));
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(command, TCL_INDEX_NONE));
}
} else {
Tk_GetAllBindings(interp, textPtr->sharedTextPtr->bindingTable,
- (ClientData) tagPtr->name);
+ (void *) tagPtr->name);
}
break;
case TAG_CGET:
@@ -539,7 +544,7 @@ TkTextTagCmd(
if (tagPtr == NULL) {
return TCL_ERROR;
}
- objPtr = Tk_GetOptionValue(interp, (char *)tagPtr,
+ objPtr = Tk_GetOptionValue(interp, tagPtr,
tagPtr->optionTable, objv[4], textPtr->tkwin);
if (objPtr == NULL) {
return TCL_ERROR;
@@ -553,12 +558,12 @@ TkTextTagCmd(
if (objc < 4) {
Tcl_WrongNumArgs(interp, 3, objv,
- "tagName ?-option? ?value? ?-option value ...?");
+ "tagName ?-option value ...?");
return TCL_ERROR;
}
tagPtr = TkTextCreateTag(textPtr, Tcl_GetString(objv[3]), &newTag);
if (objc <= 5) {
- Tcl_Obj *objPtr = Tk_GetOptionInfo(interp, (char *)tagPtr,
+ Tcl_Obj *objPtr = Tk_GetOptionInfo(interp, tagPtr,
tagPtr->optionTable,
(objc == 5) ? objv[4] : NULL, textPtr->tkwin);
@@ -568,7 +573,7 @@ TkTextTagCmd(
Tcl_SetObjResult(interp, objPtr);
return TCL_OK;
} else {
- if (Tk_SetOptions(interp, (char *)tagPtr, tagPtr->optionTable,
+ if (Tk_SetOptions(interp, tagPtr, tagPtr->optionTable,
objc-4, objv+4, textPtr->tkwin, NULL, NULL) != TCL_OK) {
return TCL_ERROR;
}
@@ -594,7 +599,7 @@ TkTextTagCmd(
return TCL_ERROR;
}
}
- if (tagPtr->elideString != NULL) {
+ if (tagPtr->elide >= 0) {
/*
* Indices are potentially obsolete after changing -elide,
* especially those computed with "display" or "any"
@@ -613,32 +618,32 @@ TkTextTagCmd(
*/
if (tagPtr == textPtr->selTagPtr) {
- if (tagPtr->selBorder == NULL) {
- textPtr->selBorder = tagPtr->border;
- } else {
- textPtr->selBorder = tagPtr->selBorder;
- }
+ if (tagPtr->selBorder == NULL) {
+ textPtr->selBorder = tagPtr->border;
+ } else {
+ textPtr->selBorder = tagPtr->selBorder;
+ }
textPtr->selBorderWidth = tagPtr->borderWidth;
textPtr->selBorderWidthPtr = tagPtr->borderWidthPtr;
- if (tagPtr->selFgColor == NULL) {
- textPtr->selFgColorPtr = tagPtr->fgColor;
- } else {
- textPtr->selFgColorPtr = tagPtr->selFgColor;
- }
+ if (tagPtr->selFgColor == NULL) {
+ textPtr->selFgColorPtr = tagPtr->fgColor;
+ } else {
+ textPtr->selFgColorPtr = tagPtr->selFgColor;
+ }
}
tagPtr->affectsDisplay = 0;
tagPtr->affectsDisplayGeometry = 0;
- if ((tagPtr->elideString != NULL)
+ if ((tagPtr->elide >= 0)
|| (tagPtr->tkfont != NULL)
- || (tagPtr->justifyString != NULL)
- || (tagPtr->lMargin1String != NULL)
- || (tagPtr->lMargin2String != NULL)
- || (tagPtr->offsetString != NULL)
- || (tagPtr->rMarginString != NULL)
- || (tagPtr->spacing1String != NULL)
- || (tagPtr->spacing2String != NULL)
- || (tagPtr->spacing3String != NULL)
+ || (tagPtr->justify != TK_JUSTIFY_NULL)
+ || (tagPtr->lMargin1 != INT_MIN)
+ || (tagPtr->lMargin2 != INT_MIN)
+ || (tagPtr->offset != INT_MIN)
+ || (tagPtr->rMargin != INT_MIN)
+ || (tagPtr->spacing1 != INT_MIN)
+ || (tagPtr->spacing2 != INT_MIN)
+ || (tagPtr->spacing3 != INT_MIN)
|| (tagPtr->tabStringPtr != NULL)
|| (tagPtr->tabStyle == TK_TEXT_TABSTYLE_TABULAR)
|| (tagPtr->tabStyle == TK_TEXT_TABSTYLE_WORDPROCESSOR)
@@ -650,17 +655,17 @@ TkTextTagCmd(
}
if ((tagPtr->border != NULL)
|| (tagPtr->selBorder != NULL)
- || (tagPtr->reliefString != NULL)
+ || (tagPtr->relief != TK_RELIEF_NULL)
|| (tagPtr->bgStipple != None)
|| (tagPtr->fgColor != NULL)
|| (tagPtr->selFgColor != NULL)
|| (tagPtr->fgStipple != None)
- || (tagPtr->overstrikeString != NULL)
- || (tagPtr->overstrikeColor != NULL)
- || (tagPtr->underlineString != NULL)
- || (tagPtr->underlineColor != NULL)
- || (tagPtr->lMarginColor != NULL)
- || (tagPtr->rMarginColor != NULL)) {
+ || (tagPtr->overstrike >= 0)
+ || (tagPtr->overstrikeColor != NULL)
+ || (tagPtr->underline >= 0)
+ || (tagPtr->underlineColor != NULL)
+ || (tagPtr->lMarginColor != NULL)
+ || (tagPtr->rMarginColor != NULL)) {
tagPtr->affectsDisplay = 1;
}
if (!newTag) {
@@ -751,7 +756,7 @@ TkTextTagCmd(
}
case TAG_NAMES: {
TkTextTag **arrayPtr;
- int arraySize;
+ Tcl_Size arraySize;
Tcl_Obj *listObj;
if ((objc != 3) && (objc != 4)) {
@@ -793,7 +798,7 @@ TkTextTagCmd(
for (i = 0; i < arraySize; i++) {
tagPtr = arrayPtr[i];
Tcl_ListObjAppendElement(interp, listObj,
- Tcl_NewStringObj(tagPtr->name,-1));
+ Tcl_NewStringObj(tagPtr->name, TCL_INDEX_NONE));
}
Tcl_SetObjResult(interp, listObj);
ckfree(arrayPtr);
@@ -875,11 +880,11 @@ TkTextTagCmd(
resultObj = Tcl_NewObj();
TkTextPrintIndex(textPtr, &tSearch.curIndex, position);
Tcl_ListObjAppendElement(NULL, resultObj,
- Tcl_NewStringObj(position, -1));
+ Tcl_NewStringObj(position, TCL_INDEX_NONE));
TkBTreeNextTag(&tSearch);
TkTextPrintIndex(textPtr, &tSearch.curIndex, position);
Tcl_ListObjAppendElement(NULL, resultObj,
- Tcl_NewStringObj(position, -1));
+ Tcl_NewStringObj(position, TCL_INDEX_NONE));
Tcl_SetObjResult(interp, resultObj);
break;
}
@@ -990,9 +995,9 @@ TkTextTagCmd(
gotPrevIndexPair:
resultObj = Tcl_NewObj();
Tcl_ListObjAppendElement(NULL, resultObj,
- Tcl_NewStringObj(position1, -1));
+ Tcl_NewStringObj(position1, TCL_INDEX_NONE));
Tcl_ListObjAppendElement(NULL, resultObj,
- Tcl_NewStringObj(position2, -1));
+ Tcl_NewStringObj(position2, TCL_INDEX_NONE));
Tcl_SetObjResult(interp, resultObj);
break;
}
@@ -1152,7 +1157,7 @@ TkTextCreateTag(
tagPtr->tkfont = NULL;
tagPtr->fgStipple = None;
tagPtr->justifyString = NULL;
- tagPtr->justify = (Tk_Justify)-1;
+ tagPtr->justify = TK_JUSTIFY_NULL;
tagPtr->lMargin1String = NULL;
tagPtr->lMargin1 = INT_MIN;
tagPtr->lMargin2String = NULL;
@@ -1176,7 +1181,7 @@ TkTextCreateTag(
tagPtr->spacing3 = INT_MIN;
tagPtr->tabStringPtr = NULL;
tagPtr->tabArrayPtr = NULL;
- tagPtr->tabStyle = TK_TEXT_TABSTYLE_NONE;
+ tagPtr->tabStyle = TK_TEXT_TABSTYLE_NULL;
tagPtr->underlineString = NULL;
tagPtr->underline = -1;
tagPtr->underlineColor = NULL;
@@ -1225,7 +1230,7 @@ FindTag(
Tcl_Obj *tagName) /* Name of desired tag. */
{
Tcl_HashEntry *hPtr;
- int len;
+ Tcl_Size len;
const char *str;
str = Tcl_GetStringFromObj(tagName, &len);
@@ -1242,7 +1247,7 @@ FindTag(
"tag \"%s\" isn't defined in text widget",
Tcl_GetString(tagName)));
Tcl_SetErrorCode(interp, "TK", "LOOKUP", "TEXT_TAG",
- Tcl_GetString(tagName), NULL);
+ Tcl_GetString(tagName), (char *)NULL);
}
return NULL;
}
@@ -1300,7 +1305,7 @@ TkTextDeleteTag(
if (textPtr->sharedTextPtr->bindingTable != NULL) {
Tk_DeleteAllBindings(textPtr->sharedTextPtr->bindingTable,
- (ClientData) tagPtr->name);
+ (void *) tagPtr->name);
}
}
@@ -1341,7 +1346,7 @@ TkTextFreeTag(
* Let Tk do most of the hard work for us.
*/
- Tk_FreeConfigOptions((char *) tagPtr, tagPtr->optionTable,
+ Tk_FreeConfigOptions(tagPtr, tagPtr->optionTable,
textPtr->tkwin);
/*
@@ -1557,7 +1562,7 @@ ChangeTagPriority(
void
TkTextBindProc(
- ClientData clientData, /* Pointer to text widget structure. */
+ void *clientData, /* Pointer to text widget structure. */
XEvent *eventPtr) /* Pointer to X event that just happened. */
{
TkText *textPtr = (TkText *)clientData;
@@ -1574,9 +1579,9 @@ TkTextBindProc(
if (eventPtr->type == ButtonPress) {
textPtr->flags |= BUTTON_DOWN;
} else if (eventPtr->type == ButtonRelease) {
- unsigned int mask;
+ unsigned long mask;
- mask = TkGetButtonMask(eventPtr->xbutton.button);
+ mask = Tk_GetButtonMask(eventPtr->xbutton.button);
if ((eventPtr->xbutton.state & ALL_BUTTONS) == mask) {
textPtr->flags &= ~BUTTON_DOWN;
repick = 1;
@@ -1616,7 +1621,7 @@ TkTextBindProc(
TkTextIndex index;
TkTextTag** tagArrayPtr;
- int numTags;
+ Tcl_Size numTags;
TkTextMarkNameToIndex(textPtr, "insert", &index);
tagArrayPtr = TkBTreeGetTags(&index, textPtr, &numTags);
@@ -1677,7 +1682,9 @@ TkTextPickCurrent(
TkTextTag **copyArrayPtr = NULL;
/* Initialization needed to prevent compiler
* warning. */
- int numOldTags, numNewTags, i, j, size, nearby;
+ int numOldTags, i, nearby;
+ Tcl_Size numNewTags, j;
+ size_t size;
XEvent event;
/*
@@ -1908,7 +1915,7 @@ TagBindEvent(
}
}
Tk_BindEvent(textPtr->sharedTextPtr->bindingTable, eventPtr,
- textPtr->tkwin, numTags, (ClientData *) nameArrPtr);
+ textPtr->tkwin, numTags, (void **) nameArrPtr);
if (numTags > NUM_BIND_TAGS) {
ckfree(nameArrPtr);
diff --git a/generic/tkTextWind.c b/generic/tkTextWind.c
index 46f84b0..8c71e48 100644
--- a/generic/tkTextWind.c
+++ b/generic/tkTextWind.c
@@ -5,8 +5,8 @@
* inside text widgets. It also implements the "window" widget command
* for texts.
*
- * Copyright (c) 1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1994 The Regents of the University of California.
+ * Copyright © 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.
@@ -20,23 +20,23 @@
* geometry manager:
*/
-static void EmbWinRequestProc(ClientData clientData,
+static void EmbWinRequestProc(void *clientData,
Tk_Window tkwin);
-static void EmbWinLostContentProc(ClientData clientData,
+static void EmbWinLostContentProc(void *clientData,
Tk_Window tkwin);
static const Tk_GeomMgr textGeomType = {
"text", /* name */
EmbWinRequestProc, /* requestProc */
- EmbWinLostContentProc, /* lostSlaveProc */
+ EmbWinLostContentProc, /* lostContentProc */
};
/*
* Macro that determines the size of an embedded window segment:
*/
-#define EW_SEG_SIZE ((unsigned)(Tk_Offset(TkTextSegment, body) \
- + sizeof(TkTextEmbWindow)))
+#define EW_SEG_SIZE (offsetof(TkTextSegment, body) \
+ + sizeof(TkTextEmbWindow))
/*
* Prototypes for functions defined in this file:
@@ -47,19 +47,19 @@ static TkTextSegment * EmbWinCleanupProc(TkTextSegment *segPtr,
static void EmbWinCheckProc(TkTextSegment *segPtr,
TkTextLine *linePtr);
static void EmbWinBboxProc(TkText *textPtr,
- TkTextDispChunk *chunkPtr, int index, int y,
+ TkTextDispChunk *chunkPtr, Tcl_Size index, int y,
int lineHeight, int baseline, int *xPtr,int *yPtr,
int *widthPtr, int *heightPtr);
static int EmbWinConfigure(TkText *textPtr, TkTextSegment *ewPtr,
- int objc, Tcl_Obj *const objv[]);
-static void EmbWinDelayedUnmap(ClientData clientData);
+ Tcl_Size objc, Tcl_Obj *const objv[]);
+static void EmbWinDelayedUnmap(void *clientData);
static int EmbWinDeleteProc(TkTextSegment *segPtr,
TkTextLine *linePtr, int treeGone);
static int EmbWinLayoutProc(TkText *textPtr,
TkTextIndex *indexPtr, TkTextSegment *segPtr,
- int offset, int maxX, int maxChars,int noCharsYet,
+ Tcl_Size offset, int maxX, Tcl_Size maxChars,int noCharsYet,
TkWrapMode wrapMode, TkTextDispChunk *chunkPtr);
-static void EmbWinStructureProc(ClientData clientData,
+static void EmbWinStructureProc(void *clientData,
XEvent *eventPtr);
static void EmbWinUndisplayProc(TkText *textPtr,
TkTextDispChunk *chunkPtr);
@@ -89,28 +89,24 @@ static const char *const alignStrings[] = {
"baseline", "bottom", "center", "top", NULL
};
-typedef enum {
- ALIGN_BASELINE, ALIGN_BOTTOM, ALIGN_CENTER, ALIGN_TOP
-} alignMode;
-
/*
* Information used for parsing window configuration options:
*/
static const Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_STRING_TABLE, "-align", NULL, NULL,
- "center", -1, Tk_Offset(TkTextEmbWindow, align),
- 0, alignStrings, 0},
+ "center", TCL_INDEX_NONE, offsetof(TkTextEmbWindow, align),
+ TK_OPTION_ENUM_VAR, alignStrings, 0},
{TK_OPTION_STRING, "-create", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextEmbWindow, create), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextEmbWindow, create), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-padx", NULL, NULL,
- "0", -1, Tk_Offset(TkTextEmbWindow, padX), 0, 0, 0},
+ "0", TCL_INDEX_NONE, offsetof(TkTextEmbWindow, padX), 0, 0, 0},
{TK_OPTION_PIXELS, "-pady", NULL, NULL,
- "0", -1, Tk_Offset(TkTextEmbWindow, padY), 0, 0, 0},
+ "0", TCL_INDEX_NONE, offsetof(TkTextEmbWindow, padY), 0, 0, 0},
{TK_OPTION_BOOLEAN, "-stretch", NULL, NULL,
- "0", -1, Tk_Offset(TkTextEmbWindow, stretch), 0, 0, 0},
+ "0", TCL_INDEX_NONE, offsetof(TkTextEmbWindow, stretch), 0, 0, 0},
{TK_OPTION_WINDOW, "-window", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextEmbWindow, tkwin), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextEmbWindow, tkwin), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0}
};
@@ -135,7 +131,7 @@ int
TkTextWindowCmd(
TkText *textPtr, /* Information about text widget. */
Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
+ Tcl_Size objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. Someone else has already
* parsed this command enough to know that
* objv[1] is "window". */
@@ -175,7 +171,7 @@ TkTextWindowCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"no embedded window at index \"%s\"",
Tcl_GetString(objv[3])));
- Tcl_SetErrorCode(interp, "TK", "TEXT", "NO_WINDOW", NULL);
+ Tcl_SetErrorCode(interp, "TK", "TEXT", "NO_WINDOW", (char *)NULL);
return TCL_ERROR;
}
@@ -190,7 +186,7 @@ TkTextWindowCmd(
ewPtr->body.ew.tkwin = NULL;
}
- objPtr = Tk_GetOptionValue(interp, (char *)&ewPtr->body.ew,
+ objPtr = Tk_GetOptionValue(interp, &ewPtr->body.ew,
ewPtr->body.ew.optionTable, objv[4], textPtr->tkwin);
if (objPtr == NULL) {
return TCL_ERROR;
@@ -213,7 +209,7 @@ TkTextWindowCmd(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"no embedded window at index \"%s\"",
Tcl_GetString(objv[3])));
- Tcl_SetErrorCode(interp, "TK", "TEXT", "NO_WINDOW", NULL);
+ Tcl_SetErrorCode(interp, "TK", "TEXT", "NO_WINDOW", (char *)NULL);
return TCL_ERROR;
}
if (objc <= 5) {
@@ -231,7 +227,7 @@ TkTextWindowCmd(
ewPtr->body.ew.tkwin = NULL;
}
- objPtr = Tk_GetOptionInfo(interp, (char *)&ewPtr->body.ew,
+ objPtr = Tk_GetOptionInfo(interp, &ewPtr->body.ew,
ewPtr->body.ew.optionTable, (objc == 5) ? objv[4] : NULL,
textPtr->tkwin);
if (objPtr == NULL) {
@@ -295,7 +291,7 @@ TkTextWindowCmd(
ewPtr->body.ew.linePtr = NULL;
ewPtr->body.ew.tkwin = NULL;
ewPtr->body.ew.create = NULL;
- ewPtr->body.ew.align = ALIGN_CENTER;
+ ewPtr->body.ew.align = TK_ALIGN_CENTER;
ewPtr->body.ew.padX = ewPtr->body.ew.padY = 0;
ewPtr->body.ew.stretch = 0;
ewPtr->body.ew.optionTable = Tk_CreateOptionTable(interp, optionSpecs);
@@ -382,7 +378,7 @@ EmbWinConfigure(
TkText *textPtr, /* Information about text widget that contains
* embedded window. */
TkTextSegment *ewPtr, /* Embedded window to be configured. */
- int objc, /* Number of strings in objv. */
+ Tcl_Size objc, /* Number of strings in objv. */
Tcl_Obj *const objv[]) /* Array of objects describing configuration
* options. */
{
@@ -401,7 +397,7 @@ EmbWinConfigure(
}
oldWindow = ewPtr->body.ew.tkwin;
- if (Tk_SetOptions(textPtr->interp, (char *)&ewPtr->body.ew,
+ if (Tk_SetOptions(textPtr->interp, &ewPtr->body.ew,
ewPtr->body.ew.optionTable, objc, objv, textPtr->tkwin, NULL,
NULL) != TCL_OK) {
return TCL_ERROR;
@@ -447,7 +443,7 @@ EmbWinConfigure(
Tk_PathName(ewPtr->body.ew.tkwin),
Tk_PathName(textPtr->tkwin)));
Tcl_SetErrorCode(textPtr->interp, "TK", "GEOMETRY",
- "HIERARCHY", NULL);
+ "HIERARCHY", (char *)NULL);
ewPtr->body.ew.tkwin = NULL;
if (client != NULL) {
client->tkwin = NULL;
@@ -521,7 +517,7 @@ EmbWinConfigure(
static void
EmbWinStructureProc(
- ClientData clientData, /* Pointer to record describing window item. */
+ void *clientData, /* Pointer to record describing window item. */
XEvent *eventPtr) /* Describes what just happened. */
{
TkTextEmbWindowClient *client = (TkTextEmbWindowClient *)clientData;
@@ -567,7 +563,7 @@ EmbWinStructureProc(
static void
EmbWinRequestProc(
- ClientData clientData, /* Pointer to record for window item. */
+ void *clientData, /* Pointer to record for window item. */
TCL_UNUSED(Tk_Window)) /* Window that changed its desired size. */
{
TkTextEmbWindowClient *client = (TkTextEmbWindowClient *)clientData;
@@ -611,7 +607,7 @@ EmbWinRequestProc(
static void
EmbWinLostContentProc(
- ClientData clientData, /* Pointer to record describing window item. */
+ void *clientData, /* Pointer to record describing window item. */
Tk_Window tkwin) /* Window that was claimed away by another
* geometry manager. */
{
@@ -760,7 +756,7 @@ EmbWinDeleteProc(
}
ewPtr->body.ew.clients = NULL;
- Tk_FreeConfigOptions((char *) &ewPtr->body.ew, ewPtr->body.ew.optionTable,
+ Tk_FreeConfigOptions(&ewPtr->body.ew, ewPtr->body.ew.optionTable,
NULL);
/*
@@ -819,11 +815,11 @@ EmbWinLayoutProc(
TkText *textPtr, /* Text widget being layed out. */
TCL_UNUSED(TkTextIndex *), /* Identifies first character in chunk. */
TkTextSegment *ewPtr, /* Segment corresponding to indexPtr. */
- int offset, /* Offset within segPtr corresponding to
+ Tcl_Size offset, /* Offset within segPtr corresponding to
* indexPtr (always 0). */
int maxX, /* Chunk must not occupy pixels at this
* position or higher. */
- TCL_UNUSED(int), /* Chunk must not include more than this many
+ TCL_UNUSED(Tcl_Size), /* Chunk must not include more than this many
* characters. */
int noCharsYet, /* Non-zero means no characters have been
* assigned to this line yet. */
@@ -872,7 +868,7 @@ EmbWinLayoutProc(
dsPtr = &buf;
}
if (string != before) {
- Tcl_DStringAppend(dsPtr, before, (int) (string-before));
+ Tcl_DStringAppend(dsPtr, before, string-before);
before = string;
}
if (string[1] == '%') {
@@ -907,11 +903,11 @@ EmbWinLayoutProc(
*/
if (dsPtr != NULL) {
- Tcl_DStringAppend(dsPtr, before, (int) (string-before));
- code = Tcl_EvalEx(textPtr->interp, Tcl_DStringValue(dsPtr), -1, TCL_EVAL_GLOBAL);
+ Tcl_DStringAppend(dsPtr, before, string-before);
+ code = Tcl_EvalEx(textPtr->interp, Tcl_DStringValue(dsPtr), TCL_INDEX_NONE, TCL_EVAL_GLOBAL);
Tcl_DStringFree(dsPtr);
} else {
- code = Tcl_EvalEx(textPtr->interp, ewPtr->body.ew.create, -1, TCL_EVAL_GLOBAL);
+ code = Tcl_EvalEx(textPtr->interp, ewPtr->body.ew.create, TCL_INDEX_NONE, TCL_EVAL_GLOBAL);
}
if (code != TCL_OK) {
Tcl_BackgroundException(textPtr->interp, code);
@@ -944,7 +940,7 @@ EmbWinLayoutProc(
Tk_PathName(ewPtr->body.ew.tkwin),
Tk_PathName(textPtr->tkwin)));
Tcl_SetErrorCode(textPtr->interp, "TK", "GEOMETRY", "HIERARCHY",
- NULL);
+ (char *)NULL);
Tcl_BackgroundException(textPtr->interp, TCL_ERROR);
ewPtr->body.ew.tkwin = NULL;
goto gotWindow;
@@ -1009,7 +1005,7 @@ EmbWinLayoutProc(
chunkPtr->measureProc = NULL;
chunkPtr->bboxProc = EmbWinBboxProc;
chunkPtr->numBytes = 1;
- if (ewPtr->body.ew.align == ALIGN_BASELINE) {
+ if (ewPtr->body.ew.align == TK_ALIGN_BASELINE) {
chunkPtr->minAscent = height - ewPtr->body.ew.padY;
chunkPtr->minDescent = ewPtr->body.ew.padY;
chunkPtr->minHeight = 0;
@@ -1055,7 +1051,7 @@ EmbWinCheckProc(
Tcl_Panic("EmbWinCheckProc: embedded window is last segment in line");
}
if (ewPtr->size != 1) {
- Tcl_Panic("EmbWinCheckProc: embedded window has size %d", ewPtr->size);
+ Tcl_Panic("EmbWinCheckProc: embedded window has size %" TCL_SIZE_MODIFIER "d", ewPtr->size);
}
}
@@ -1225,7 +1221,7 @@ static void
EmbWinBboxProc(
TkText *textPtr, /* Information about text widget. */
TkTextDispChunk *chunkPtr, /* Chunk containing desired char. */
- TCL_UNUSED(int), /* Index of desired character within the
+ TCL_UNUSED(Tcl_Size), /* Index of desired character within the
* chunk. */
int y, /* Topmost pixel in area allocated for this
* line. */
@@ -1257,23 +1253,23 @@ EmbWinBboxProc(
}
*xPtr = chunkPtr->x + ewPtr->body.ew.padX;
if (ewPtr->body.ew.stretch) {
- if (ewPtr->body.ew.align == ALIGN_BASELINE) {
+ if (ewPtr->body.ew.align == TK_ALIGN_BASELINE) {
*heightPtr = baseline - ewPtr->body.ew.padY;
} else {
*heightPtr = lineHeight - 2*ewPtr->body.ew.padY;
}
}
switch (ewPtr->body.ew.align) {
- case ALIGN_BOTTOM:
+ case TK_ALIGN_BOTTOM:
*yPtr = y + (lineHeight - *heightPtr - ewPtr->body.ew.padY);
break;
- case ALIGN_CENTER:
+ case TK_ALIGN_CENTER:
*yPtr = y + (lineHeight - *heightPtr)/2;
break;
- case ALIGN_TOP:
+ case TK_ALIGN_TOP:
*yPtr = y + ewPtr->body.ew.padY;
break;
- case ALIGN_BASELINE:
+ case TK_ALIGN_BASELINE:
*yPtr = y + (baseline - *heightPtr);
break;
}
@@ -1300,7 +1296,7 @@ EmbWinBboxProc(
static void
EmbWinDelayedUnmap(
- ClientData clientData) /* Token for the window to be unmapped. */
+ void *clientData) /* Token for the window to be unmapped. */
{
TkTextEmbWindowClient *client = (TkTextEmbWindowClient *)clientData;
diff --git a/generic/tkTrig.c b/generic/tkTrig.c
index 2e11db0..cac28e4 100644
--- a/generic/tkTrig.c
+++ b/generic/tkTrig.c
@@ -5,8 +5,8 @@
* are used by Tk and in particular by the canvas code. It also has
* miscellaneous geometry functions used by canvases.
*
- * Copyright (c) 1992-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1992-1994 The Regents of the University of California.
+ * Copyright © 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.
@@ -282,7 +282,6 @@ TkLineToArea(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
int
TkThickPolyLineToArea(
double *coordPtr, /* Points to an array of coordinates for the
@@ -652,7 +651,6 @@ TkPolygonToArea(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
double
TkOvalToPoint(
double ovalPtr[], /* Pointer to array of four coordinates (x1,
@@ -867,7 +865,6 @@ TkOvalToArea(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
void
TkIncludePoint(
Tk_Item *itemPtr, /* Item whose bounding box is being
diff --git a/generic/tkUndo.c b/generic/tkUndo.c
index ba3a3a5..0e48f69 100644
--- a/generic/tkUndo.c
+++ b/generic/tkUndo.c
@@ -3,8 +3,8 @@
*
* This module provides the implementation of an undo stack.
*
- * Copyright (c) 2002 Ludwig Callewaert.
- * Copyright (c) 2003-2004 Vincent Darley.
+ * Copyright © 2002 Ludwig Callewaert.
+ * Copyright © 2003-2004 Vincent Darley.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -244,7 +244,7 @@ TkUndoMakeCmdSubAtom(
atom->next = NULL;
atom->action = actionScript;
if (atom->action != NULL) {
- Tcl_IncrRefCount(atom->action);
+ Tcl_IncrRefCount(atom->action);
}
if (subAtomList != NULL) {
@@ -287,7 +287,7 @@ TkUndoSubAtom *
TkUndoMakeSubAtom(
TkUndoProc *funcPtr, /* Callback function to perform the
* undo/redo. */
- ClientData clientData, /* Data to pass to the callback function. */
+ void *clientData, /* Data to pass to the callback function. */
Tcl_Obj *actionScript, /* Additional Tcl data to pass to the callback
* function (may be NULL). */
TkUndoSubAtom *subAtomList) /* Add to the end of this list of actions if
@@ -306,7 +306,7 @@ TkUndoMakeSubAtom(
atom->next = NULL;
atom->action = actionScript;
if (atom->action != NULL) {
- Tcl_IncrRefCount(atom->action);
+ Tcl_IncrRefCount(atom->action);
}
if (subAtomList != NULL) {
@@ -712,7 +712,7 @@ EvaluateActionList(
Tcl_GetCommandFullName(interp, action->command, cmdNameObj);
Tcl_ListObjAppendElement(NULL, evalObj, cmdNameObj);
if (action->action != NULL) {
- Tcl_ListObjAppendList(NULL, evalObj, action->action);
+ Tcl_ListObjAppendList(NULL, evalObj, action->action);
}
result = Tcl_EvalObjEx(interp, evalObj, TCL_EVAL_GLOBAL);
Tcl_DecrRefCount(evalObj);
diff --git a/generic/tkUndo.h b/generic/tkUndo.h
index 490ede9..c568483 100644
--- a/generic/tkUndo.h
+++ b/generic/tkUndo.h
@@ -3,7 +3,7 @@
*
* Declarations shared among the files that implement an undo stack.
*
- * Copyright (c) 2002 Ludwig Callewaert.
+ * Copyright © 2002 Ludwig Callewaert.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -30,7 +30,7 @@ typedef enum {
* can also be defined by Tcl scripts).
*/
-typedef int (TkUndoProc)(Tcl_Interp *interp, ClientData clientData,
+typedef int (TkUndoProc)(Tcl_Interp *interp, void *clientData,
Tcl_Obj *objPtr);
/*
@@ -47,7 +47,7 @@ typedef struct TkUndoSubAtom {
* contain everything. */
TkUndoProc *funcPtr; /* Function pointer for callback to perform
* undo/redo actions. */
- ClientData clientData; /* Data for 'funcPtr'. */
+ void *clientData; /* Data for 'funcPtr'. */
Tcl_Obj *action; /* Command to apply the action that was
* taken. */
struct TkUndoSubAtom *next; /* Pointer to the next element in the linked
@@ -105,7 +105,7 @@ MODULE_SCOPE void TkUndoInsertUndoSeparator(TkUndoRedoStack *stack);
MODULE_SCOPE TkUndoSubAtom *TkUndoMakeCmdSubAtom(Tcl_Command command,
Tcl_Obj *actionScript, TkUndoSubAtom *subAtomList);
MODULE_SCOPE TkUndoSubAtom *TkUndoMakeSubAtom(TkUndoProc *funcPtr,
- ClientData clientData, Tcl_Obj *actionScript,
+ void *clientData, Tcl_Obj *actionScript,
TkUndoSubAtom *subAtomList);
MODULE_SCOPE void TkUndoPushAction(TkUndoRedoStack *stack,
TkUndoSubAtom *apply, TkUndoSubAtom *revert);
diff --git a/generic/tkUtil.c b/generic/tkUtil.c
index a673b68..60daffe 100644
--- a/generic/tkUtil.c
+++ b/generic/tkUtil.c
@@ -4,8 +4,8 @@
* This file contains miscellaneous utility functions that are used by
* the rest of Tk, such as a function for drawing a focus highlight.
*
- * Copyright (c) 1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1994 The Regents of the University of California.
+ * Copyright © 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.
@@ -22,12 +22,14 @@
* object, used for quickly finding a mapping in a TkStateMap.
*/
-const Tcl_ObjType tkStateKeyObjType = {
- "statekey", /* name */
+const TkObjType tkStateKeyObjType = {
+ {"statekey", /* name */
NULL, /* freeIntRepProc */
NULL, /* dupIntRepProc */
NULL, /* updateStringProc */
- NULL /* setFromAnyProc */
+ NULL, /* setFromAnyProc */
+ TCL_OBJTYPE_V0},
+ 0
};
/*
@@ -50,12 +52,12 @@ const Tcl_ObjType tkStateKeyObjType = {
int
TkStateParseProc(
- ClientData clientData, /* some flags.*/
+ void *clientData, /* some flags.*/
Tcl_Interp *interp, /* Used for reporting errors. */
- Tk_Window tkwin, /* Window containing canvas widget. */
+ TCL_UNUSED(Tk_Window), /* Window containing canvas widget. */
const char *value, /* Value of option. */
char *widgRec, /* Pointer to record for item. */
- int offset) /* Offset into item. */
+ Tcl_Size offset) /* Offset into item. */
{
int c;
int flags = PTR2INT(clientData);
@@ -91,17 +93,17 @@ TkStateParseProc(
msgObj = Tcl_ObjPrintf("bad %s value \"%s\": must be normal",
((flags & 4) ? "-default" : "state"), value);
if (flags & 1) {
- Tcl_AppendToObj(msgObj, ", active", -1);
+ Tcl_AppendToObj(msgObj, ", active", TCL_INDEX_NONE);
}
if (flags & 2) {
- Tcl_AppendToObj(msgObj, ", hidden", -1);
+ Tcl_AppendToObj(msgObj, ", hidden", TCL_INDEX_NONE);
}
if (flags & 3) {
- Tcl_AppendToObj(msgObj, ",", -1);
+ Tcl_AppendToObj(msgObj, ",", TCL_INDEX_NONE);
}
- Tcl_AppendToObj(msgObj, " or disabled", -1);
+ Tcl_AppendToObj(msgObj, " or disabled", TCL_INDEX_NONE);
Tcl_SetObjResult(interp, msgObj);
- Tcl_SetErrorCode(interp, "TK", "VALUE", "STATE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "STATE", (char *)NULL);
*statePtr = TK_STATE_NORMAL;
return TCL_ERROR;
}
@@ -129,11 +131,11 @@ TkStateParseProc(
const char *
TkStatePrintProc(
- ClientData clientData, /* Ignored. */
- Tk_Window tkwin, /* Window containing canvas widget. */
+ TCL_UNUSED(void *), /* Ignored. */
+ TCL_UNUSED(Tk_Window), /* Window containing canvas widget. */
char *widgRec, /* Pointer to record for item. */
- int offset, /* Offset into item. */
- Tcl_FreeProc **freeProcPtr) /* Pointer to variable to fill in with
+ Tcl_Size offset, /* Offset into item. */
+ TCL_UNUSED(Tcl_FreeProc **)) /* Pointer to variable to fill in with
* information about how to reclaim storage
* for return string. */
{
@@ -173,12 +175,12 @@ TkStatePrintProc(
int
TkOrientParseProc(
- ClientData clientData, /* some flags.*/
+ TCL_UNUSED(void *), /* some flags.*/
Tcl_Interp *interp, /* Used for reporting errors. */
- Tk_Window tkwin, /* Window containing canvas widget. */
+ TCL_UNUSED(Tk_Window), /* Window containing canvas widget. */
const char *value, /* Value of option. */
char *widgRec, /* Pointer to record for item. */
- int offset) /* Offset into item. */
+ Tcl_Size offset) /* Offset into item. */
{
int c;
size_t length;
@@ -203,7 +205,7 @@ TkOrientParseProc(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad orientation \"%s\": must be vertical or horizontal",
value));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "ORIENTATION", NULL);
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "ORIENTATION", (char *)NULL);
*orientPtr = 0;
return TCL_ERROR;
}
@@ -231,11 +233,11 @@ TkOrientParseProc(
const char *
TkOrientPrintProc(
- ClientData clientData, /* Ignored. */
- Tk_Window tkwin, /* Window containing canvas widget. */
+ TCL_UNUSED(void *), /* Ignored. */
+ TCL_UNUSED(Tk_Window), /* Window containing canvas widget. */
char *widgRec, /* Pointer to record for item. */
- int offset, /* Offset into item. */
- Tcl_FreeProc **freeProcPtr) /* Pointer to variable to fill in with
+ Tcl_Size offset, /* Offset into item. */
+ TCL_UNUSED(Tcl_FreeProc **)) /* Pointer to variable to fill in with
* information about how to reclaim storage
* for return string. */
{
@@ -261,12 +263,12 @@ TkOrientPrintProc(
int
TkOffsetParseProc(
- ClientData clientData, /* not used */
+ void *clientData, /* not used */
Tcl_Interp *interp, /* Interpreter to send results back to */
Tk_Window tkwin, /* Window on same display as tile */
const char *value, /* Name of image */
char *widgRec, /* Widget structure record */
- int offset) /* Offset of tile in record */
+ Tcl_Size offset) /* Offset of tile in record */
{
Tk_TSOffset *offsetPtr = (Tk_TSOffset *) (widgRec + offset);
Tk_TSOffset tsoffset;
@@ -387,14 +389,14 @@ TkOffsetParseProc(
badTSOffset:
msgObj = Tcl_ObjPrintf("bad offset \"%s\": expected \"x,y\"", value);
if (PTR2INT(clientData) & TK_OFFSET_RELATIVE) {
- Tcl_AppendToObj(msgObj, ", \"#x,y\"", -1);
+ Tcl_AppendToObj(msgObj, ", \"#x,y\"", TCL_INDEX_NONE);
}
if (PTR2INT(clientData) & TK_OFFSET_INDEX) {
- Tcl_AppendToObj(msgObj, ", <index>", -1);
+ Tcl_AppendToObj(msgObj, ", <index>", TCL_INDEX_NONE);
}
- Tcl_AppendToObj(msgObj, ", n, ne, e, se, s, sw, w, nw, or center", -1);
+ Tcl_AppendToObj(msgObj, ", n, ne, e, se, s, sw, w, nw, or center", TCL_INDEX_NONE);
Tcl_SetObjResult(interp, msgObj);
- Tcl_SetErrorCode(interp, "TK", "VALUE", "OFFSET", NULL);
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "OFFSET", (char *)NULL);
return TCL_ERROR;
}
@@ -413,10 +415,10 @@ TkOffsetParseProc(
const char *
TkOffsetPrintProc(
- ClientData clientData, /* not used */
- Tk_Window tkwin, /* not used */
+ TCL_UNUSED(void *), /* not used */
+ TCL_UNUSED(Tk_Window), /* not used */
char *widgRec, /* Widget structure record */
- int offset, /* Offset of tile in record */
+ Tcl_Size offset, /* Offset of tile in record */
Tcl_FreeProc **freeProcPtr) /* not used */
{
Tk_TSOffset *offsetPtr = (Tk_TSOffset *) (widgRec + offset);
@@ -477,13 +479,13 @@ TkOffsetPrintProc(
int
TkPixelParseProc(
- ClientData clientData, /* If non-NULL, negative values are allowed as
+ void *clientData, /* If non-NULL, negative values are allowed as
* well. */
Tcl_Interp *interp, /* Interpreter to send results back to */
Tk_Window tkwin, /* Window on same display as tile */
const char *value, /* Name of image */
char *widgRec, /* Widget structure record */
- int offset) /* Offset of tile in record */
+ Tcl_Size offset) /* Offset of tile in record */
{
double *doublePtr = (double *) (widgRec + offset);
int result;
@@ -492,8 +494,8 @@ TkPixelParseProc(
if ((result == TCL_OK) && (clientData == NULL) && (*doublePtr < 0.0)) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "bad screen distance \"%s\"", value));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "PIXELS", NULL);
+ "expected screen distance but got \"%.50s\"", value));
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "PIXELS", (char *)NULL);
return TCL_ERROR;
}
return result;
@@ -514,10 +516,10 @@ TkPixelParseProc(
const char *
TkPixelPrintProc(
- ClientData clientData, /* not used */
- Tk_Window tkwin, /* not used */
+ TCL_UNUSED(void *), /* not used */
+ TCL_UNUSED(Tk_Window), /* not used */
char *widgRec, /* Widget structure record */
- int offset, /* Offset of tile in record */
+ Tcl_Size offset, /* Offset of tile in record */
Tcl_FreeProc **freeProcPtr) /* not used */
{
double *doublePtr = (double *) (widgRec + offset);
@@ -588,7 +590,7 @@ TkDrawInsetFocusHighlight(
* This function draws a rectangular ring around the outside of a widget
* to indicate that it has received the input focus.
*
- * This function is now deprecated. Use TkpDrawHighlightBorder instead,
+ * This function is now deprecated. Use Tk_DrawHighlightBorder instead,
* since this function does not handle drawing the Focus ring properly on
* the Macintosh - you need to know the background GC as well as the
* foreground since the Mac focus ring separated from the widget by a 1
@@ -644,7 +646,7 @@ Tk_DrawFocusHighlight(
int
Tk_GetScrollInfo(
Tcl_Interp *interp, /* Used for error reporting. */
- int argc, /* # arguments for command. */
+ Tcl_Size argc, /* # arguments for command. */
const char **argv, /* Arguments for command. */
double *dblPtr, /* Filled in with argument "moveto" option, if
* any. */
@@ -659,7 +661,7 @@ Tk_GetScrollInfo(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"wrong # args: should be \"%s %s %s\"",
argv[0], argv[1], "moveto fraction"));
- Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL);
+ Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", (char *)NULL);
return TK_SCROLL_ERROR;
}
if (Tcl_GetDouble(interp, argv[3], dblPtr) != TCL_OK) {
@@ -668,16 +670,18 @@ Tk_GetScrollInfo(
return TK_SCROLL_MOVETO;
} else if ((c == 's')
&& (strncmp(argv[2], "scroll", length) == 0)) {
+ double d;
if (argc != 5) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"wrong # args: should be \"%s %s %s\"",
- argv[0], argv[1], "scroll number units|pages"));
- Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL);
+ argv[0], argv[1], "scroll number pages|units"));
+ Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", (char *)NULL);
return TK_SCROLL_ERROR;
}
- if (Tcl_GetInt(interp, argv[3], intPtr) != TCL_OK) {
+ if (Tcl_GetDouble(interp, argv[3], &d) != TCL_OK) {
return TK_SCROLL_ERROR;
}
+ *intPtr = (d > 0) ? ceil(d) : floor(d);
length = strlen(argv[4]);
c = argv[4][0];
if ((c == 'p') && (strncmp(argv[4], "pages", length) == 0)) {
@@ -687,14 +691,14 @@ Tk_GetScrollInfo(
}
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "bad argument \"%s\": must be units or pages", argv[4]));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "SCROLL_UNITS", NULL);
+ "bad argument \"%s\": must be pages or units", argv[4]));
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "SCROLL_UNITS", (char *)NULL);
return TK_SCROLL_ERROR;
}
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"unknown option \"%s\": must be moveto or scroll", argv[2]));
Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "INDEX", "option", argv[2],
- NULL);
+ (char *)NULL);
return TK_SCROLL_ERROR;
}
@@ -725,16 +729,21 @@ Tk_GetScrollInfo(
int
Tk_GetScrollInfoObj(
Tcl_Interp *interp, /* Used for error reporting. */
- int objc, /* # arguments for command. */
+ Tcl_Size objc, /* # arguments for command. */
Tcl_Obj *const objv[], /* Arguments for command. */
double *dblPtr, /* Filled in with argument "moveto" option, if
* any. */
int *intPtr) /* Filled in with number of pages or lines to
* scroll, if any. */
{
- const char *arg = Tcl_GetString(objv[2]);
- size_t length = objv[2]->length;
+ Tcl_Size length;
+ const char *arg;
+ if (objc + 1 < 5) {
+ Tcl_WrongNumArgs(interp, 2, objv, "moveto|scroll args");
+ return TK_SCROLL_ERROR;
+ }
+ arg = Tcl_GetStringFromObj(objv[2], &length);
#define ArgPfxEq(str) \
((arg[0] == str[0]) && !strncmp(arg, str, length))
@@ -748,16 +757,20 @@ Tk_GetScrollInfoObj(
}
return TK_SCROLL_MOVETO;
} else if (ArgPfxEq("scroll")) {
+ double d;
if (objc != 5) {
- Tcl_WrongNumArgs(interp, 2, objv, "scroll number units|pages");
+ Tcl_WrongNumArgs(interp, 2, objv, "scroll number pages|units");
return TK_SCROLL_ERROR;
}
- if (Tcl_GetIntFromObj(interp, objv[3], intPtr) != TCL_OK) {
+ if (Tcl_GetDoubleFromObj(interp, objv[3], &d) != TCL_OK) {
return TK_SCROLL_ERROR;
}
+ *intPtr = (d >= 0) ? ceil(d) : floor(d);
+ if (dblPtr) {
+ *dblPtr = d;
+ }
- arg = Tcl_GetString(objv[4]);
- length = objv[4]->length;
+ arg = Tcl_GetStringFromObj(objv[4], &length);
if (ArgPfxEq("pages")) {
return TK_SCROLL_PAGES;
} else if (ArgPfxEq("units")) {
@@ -765,13 +778,13 @@ Tk_GetScrollInfoObj(
}
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "bad argument \"%s\": must be units or pages", arg));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "SCROLL_UNITS", NULL);
+ "bad argument \"%s\": must be pages or units", arg));
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "SCROLL_UNITS", (char *)NULL);
return TK_SCROLL_ERROR;
}
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"unknown option \"%s\": must be moveto or scroll", arg));
- Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "INDEX", "option", arg, NULL);
+ Tcl_SetErrorCode(interp, "TCL", "LOOKUP", "INDEX", "option", arg, (char *)NULL);
return TK_SCROLL_ERROR;
}
@@ -818,17 +831,17 @@ TkComputeAnchor(
*xPtr = Tk_InternalBorderLeft(tkwin) + padX;
break;
- case TK_ANCHOR_N:
- case TK_ANCHOR_CENTER:
- case TK_ANCHOR_S:
- *xPtr = (Tk_Width(tkwin) - innerWidth - Tk_InternalBorderLeft(tkwin) -
- Tk_InternalBorderRight(tkwin)) / 2 +
- Tk_InternalBorderLeft(tkwin);
+ case TK_ANCHOR_NE:
+ case TK_ANCHOR_E:
+ case TK_ANCHOR_SE:
+ *xPtr = Tk_Width(tkwin) - Tk_InternalBorderRight(tkwin) - padX
+ - innerWidth;
break;
default:
- *xPtr = Tk_Width(tkwin) - Tk_InternalBorderRight(tkwin) - padX
- - innerWidth;
+ *xPtr = (Tk_Width(tkwin) - innerWidth - Tk_InternalBorderLeft(tkwin) -
+ Tk_InternalBorderRight(tkwin)) / 2 +
+ Tk_InternalBorderLeft(tkwin);
break;
}
@@ -843,17 +856,17 @@ TkComputeAnchor(
*yPtr = Tk_InternalBorderTop(tkwin) + padY;
break;
- case TK_ANCHOR_W:
- case TK_ANCHOR_CENTER:
- case TK_ANCHOR_E:
- *yPtr = (Tk_Height(tkwin) - innerHeight- Tk_InternalBorderTop(tkwin) -
- Tk_InternalBorderBottom(tkwin)) / 2 +
- Tk_InternalBorderTop(tkwin);
+ case TK_ANCHOR_SW:
+ case TK_ANCHOR_S:
+ case TK_ANCHOR_SE:
+ *yPtr = Tk_Height(tkwin) - Tk_InternalBorderBottom(tkwin) - padY
+ - innerHeight;
break;
default:
- *yPtr = Tk_Height(tkwin) - Tk_InternalBorderBottom(tkwin) - padY
- - innerHeight;
+ *yPtr = (Tk_Height(tkwin) - innerHeight- Tk_InternalBorderTop(tkwin) -
+ Tk_InternalBorderBottom(tkwin)) / 2 +
+ Tk_InternalBorderTop(tkwin);
break;
}
}
@@ -945,7 +958,7 @@ TkFindStateNum(
((mPtr[1].strKey != NULL) ? "" : "or "), mPtr->strKey);
}
Tcl_SetObjResult(interp, msgObj);
- Tcl_SetErrorCode(interp, "TK", "LOOKUP", option, strKey, NULL);
+ Tcl_SetErrorCode(interp, "TK", "LOOKUP", option, strKey, (char *)NULL);
}
return mPtr->numKey;
}
@@ -965,7 +978,7 @@ TkFindStateNumObj(
* See if the value is in the object cache.
*/
- if ((keyPtr->typePtr == &tkStateKeyObjType)
+ if ((keyPtr->typePtr == &tkStateKeyObjType.objType)
&& (keyPtr->internalRep.twoPtrValue.ptr1 == mapPtr)) {
return PTR2INT(keyPtr->internalRep.twoPtrValue.ptr2);
}
@@ -983,7 +996,7 @@ TkFindStateNumObj(
}
keyPtr->internalRep.twoPtrValue.ptr1 = (void *) mapPtr;
keyPtr->internalRep.twoPtrValue.ptr2 = INT2PTR(mPtr->numKey);
- keyPtr->typePtr = &tkStateKeyObjType;
+ keyPtr->typePtr = &tkStateKeyObjType.objType;
return mPtr->numKey;
}
}
@@ -1006,7 +1019,7 @@ TkFindStateNumObj(
}
Tcl_SetObjResult(interp, msgObj);
Tcl_SetErrorCode(interp, "TK", "LOOKUP", Tcl_GetString(optionPtr),
- key, NULL);
+ key, (char *)NULL);
}
return mPtr->numKey;
}
@@ -1033,12 +1046,13 @@ TkFindStateNumObj(
int
TkBackgroundEvalObjv(
Tcl_Interp *interp,
- int objc,
+ Tcl_Size objc,
Tcl_Obj *const *objv,
int flags)
{
Tcl_InterpState state;
- int n, r = TCL_OK;
+ int r = TCL_OK;
+ Tcl_Size n;
/*
* Record the state of the interpreter.
@@ -1092,7 +1106,7 @@ TkMakeEnsemble(
Tcl_Interp *interp,
const char *namesp,
const char *name,
- ClientData clientData,
+ void *clientData,
const TkEnsemble map[])
{
Tcl_Namespace *namespacePtr = NULL;
@@ -1115,7 +1129,7 @@ TkMakeEnsemble(
}
}
- nameObj = Tcl_NewStringObj(name, -1);
+ nameObj = Tcl_NewStringObj(name, TCL_INDEX_NONE);
ensemble = Tcl_FindEnsemble(interp, nameObj, 0);
Tcl_DecrRefCount(nameObj);
if (ensemble == NULL) {
@@ -1127,24 +1141,29 @@ TkMakeEnsemble(
}
Tcl_DStringSetLength(&ds, 0);
- Tcl_DStringAppend(&ds, namesp, -1);
+ Tcl_DStringAppend(&ds, namesp, TCL_INDEX_NONE);
if (!(strlen(namesp) == 2 && namesp[1] == ':')) {
- Tcl_DStringAppend(&ds, "::", -1);
+ Tcl_DStringAppend(&ds, "::", TCL_INDEX_NONE);
}
- Tcl_DStringAppend(&ds, name, -1);
+ Tcl_DStringAppend(&ds, name, TCL_INDEX_NONE);
dictObj = Tcl_NewObj();
for (i = 0; map[i].name != NULL ; ++i) {
Tcl_Obj *fqdnObj;
- nameObj = Tcl_NewStringObj(map[i].name, -1);
+ nameObj = Tcl_NewStringObj(map[i].name, TCL_INDEX_NONE);
fqdnObj = Tcl_NewStringObj(Tcl_DStringValue(&ds),
Tcl_DStringLength(&ds));
- Tcl_AppendStringsToObj(fqdnObj, "::", map[i].name, NULL);
+ Tcl_AppendStringsToObj(fqdnObj, "::", map[i].name, (char *)NULL);
Tcl_DictObjPut(NULL, dictObj, nameObj, fqdnObj);
if (map[i].proc) {
+#if TCL_MAJOR_VERSION > 8
+ Tcl_CreateObjCommand2(interp, Tcl_GetString(fqdnObj),
+ map[i].proc, clientData, NULL);
+#else
Tcl_CreateObjCommand(interp, Tcl_GetString(fqdnObj),
map[i].proc, clientData, NULL);
+#endif
} else if (map[i].subensemble) {
TkMakeEnsemble(interp, Tcl_DStringValue(&ds),
map[i].name, clientData, map[i].subensemble);
@@ -1162,7 +1181,39 @@ TkMakeEnsemble(
/*
*----------------------------------------------------------------------
*
- * TkSendVirtualEvent --
+ * TkScalingLevel --
+ *
+ * Returns the display's DPI scaling level as 1.0, 1.25, 1.5, ....
+ *
+ * Results:
+ * The scaling level.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+double
+TkScalingLevel(
+ Tk_Window tkwin)
+{
+ Tcl_Interp *interp = Tk_Interp(tkwin);
+ Tcl_Obj *scalingPctPtr = Tcl_GetVar2Ex(interp, "::tk::scalingPct", NULL,
+ TCL_GLOBAL_ONLY);
+ if (scalingPctPtr == NULL) {
+ return 1.0;
+ } else {
+ int scalingPct;
+ Tcl_GetIntFromObj(interp, scalingPctPtr, &scalingPct);
+ return scalingPct / 100.0;
+ }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * Tk_SendVirtualEvent --
*
* Send a virtual event notification to the specified target window.
* Equivalent to:
@@ -1175,7 +1226,7 @@ TkMakeEnsemble(
*/
void
-TkSendVirtualEvent(
+Tk_SendVirtualEvent(
Tk_Window target,
const char *eventName,
Tcl_Obj *detail)
@@ -1195,8 +1246,7 @@ TkSendVirtualEvent(
Tk_QueueWindowEvent(&event.general, TCL_QUEUE_TAIL);
}
-/* Tcl 8.6 has a different definition of Tcl_UniChar than other Tcl versions for TCL_UTF_MAX > 3 */
-#if TCL_UTF_MAX <= (3 + (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 6))
+#if TCL_MAJOR_VERSION < 9
/*
*---------------------------------------------------------------------------
*
@@ -1216,7 +1266,7 @@ TkSendVirtualEvent(
*---------------------------------------------------------------------------
*/
-int
+Tcl_Size
TkUtfToUniChar(
const char *src, /* The UTF-8 string. */
int *chPtr) /* Filled with the Unicode value represented by
@@ -1224,12 +1274,11 @@ TkUtfToUniChar(
{
Tcl_UniChar uniChar = 0;
- int len = Tcl_UtfToUniChar(src, &uniChar);
+ Tcl_Size len = Tcl_UtfToUniChar(src, &uniChar);
if ((uniChar & 0xFC00) == 0xD800) {
Tcl_UniChar low = uniChar;
- /* This can only happen if sizeof(Tcl_UniChar)== 2 and src points
- * to a character > U+FFFF */
- size_t len2 = Tcl_UtfToUniChar(src+len, &low);
+ /* This can only happen if src points to a character > U+FFFF */
+ Tcl_Size len2 = Tcl_UtfToUniChar(src+len, &low);
if ((low & 0xFC00) == 0xDC00) {
*chPtr = (((uniChar & 0x3FF) << 10) | (low & 0x3FF)) + 0x10000;
return len + len2;
@@ -1258,84 +1307,16 @@ TkUtfToUniChar(
*---------------------------------------------------------------------------
*/
-int TkUniCharToUtf(int ch, char *buf)
+Tcl_Size TkUniCharToUtf(int ch, char *buf)
{
if ((unsigned)(ch - 0x10000) <= 0xFFFFF) {
- /* Spit out a 4-byte UTF-8 character or 2 x 3-byte UTF-8 characters, depending on Tcl
- * version and/or TCL_UTF_MAX build value */
- int len = Tcl_UniCharToUtf(0xD800 | ((ch - 0x10000) >> 10), buf);
+ /* Spit out a 4-byte UTF-8 character (Tcl 8.7+) or
+ * 2 x 3-byte UTF-8 characters (Tcl 8.6) */
+ Tcl_Size len = Tcl_UniCharToUtf(0xD800 | ((ch - 0x10000) >> 10), buf);
return len + Tcl_UniCharToUtf(0xDC00 | (ch & 0x7FF), buf + len);
}
return Tcl_UniCharToUtf(ch, buf);
}
-/*
- *---------------------------------------------------------------------------
- *
- * TkUtfPrev --
- *
- * Almost the same as Tcl_UtfPrev.
- * This function is capable of jumping over a upper/lower surrogate pair.
- * So, might jump back up to 6 bytes.
- *
- * Results:
- * pointer to the first byte of the current UTF-8 character. A surrogate
- * pair is also handled as being a single entity.
- *
- * Side effects:
- * None.
- *
- *---------------------------------------------------------------------------
- */
-
-const char *
-TkUtfPrev(
- const char *src, /* The UTF-8 string. */
- const char *start) /* Start position of string */
-{
- const char *p = Tcl_UtfPrev(src, start);
- const char *first = Tcl_UtfPrev(p, start);
- int ch;
-
-#if TCL_UTF_MAX == 3
- if ((src - start > 3) && ((src[-1] & 0xC0) == 0x80) && ((src[-2] & 0xC0) == 0x80)
- && ((src[-3] & 0xC0) == 0x80) && (UCHAR(src[-4]) >= 0xF0)) {
- return src - 4;
- }
-#endif
-
- return (first + TkUtfToUniChar(first, &ch) >= src) ? first : p ;
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * TkUtfAtIndex --
- *
- * Returns a pointer to the specified character (not byte) position in
- * a CESU-8 string. This will never point at a low surrogate.
- *
- * Results:
- * As above.
- *
- * Side effects:
- * None.
- *
- *---------------------------------------------------------------------------
- */
-
-const char *
-TkUtfAtIndex(
- const char *src, /* The UTF-8 string. */
- int index) /* The position of the desired character. */
-{
- int ch;
- const char *p = Tcl_UtfAtIndex(src, index);
- if ((p > src) && (UCHAR(p[-1]) >= 0xF0)) {
- --p;
- return p + TkUtfToUniChar(p, &ch);
- }
- return p;
-}
#endif
/*
* Local Variables:
diff --git a/generic/tkVisual.c b/generic/tkVisual.c
index 9324499..9089e74 100644
--- a/generic/tkVisual.c
+++ b/generic/tkVisual.c
@@ -5,8 +5,8 @@
* visuals and colormaps. This code is based on a prototype
* implementation by Paul Mackerras.
*
- * Copyright (c) 1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1994 The Regents of the University of California.
+ * Copyright © 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.
@@ -20,10 +20,10 @@
*/
typedef struct VisualDictionary {
- const char *name; /* Textual name of class. */
- int minLength; /* Minimum # characters that must be specified
+ char name[12]; /* Textual name of class. */
+ unsigned short minLength; /* Minimum # characters that must be specified
* for an unambiguous match. */
- int c_class; /* X symbol for class. */
+ short c_class; /* X symbol for class. */
} VisualDictionary;
static const VisualDictionary visualNames[] = {
{"best", 1, 0},
@@ -35,7 +35,7 @@ static const VisualDictionary visualNames[] = {
{"staticgray", 7, StaticGray},
{"staticgrey", 7, StaticGray},
{"truecolor", 1, TrueColor},
- {NULL, 0, 0},
+ {"", 0, 0},
};
/*
@@ -46,7 +46,7 @@ static const VisualDictionary visualNames[] = {
struct TkColormap {
Colormap colormap; /* X's identifier for the colormap. */
Visual *visual; /* Visual for which colormap was allocated. */
- int refCount; /* How many uses of the colormap are still
+ size_t refCount; /* How many uses of the colormap are still
* outstanding (calls to Tk_GetColormap minus
* calls to Tk_FreeColormap). */
int shareable; /* 0 means this colormap was allocated by a
@@ -175,7 +175,7 @@ Tk_GetVisual(
if (Tcl_GetInt(interp, string, &visualId) == TCL_ERROR) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad X identifier for visual: \"%s\"", string));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "VISUALID", NULL);
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "VISUALID", (char *)NULL);
return NULL;
}
templ.visualid = visualId;
@@ -193,8 +193,8 @@ Tk_GetVisual(
}
length = p - string;
templ.c_class = -1;
- for (dictPtr = visualNames; dictPtr->name != NULL; dictPtr++) {
- if ((dictPtr->name[0] == c) && (length >= (size_t)dictPtr->minLength)
+ for (dictPtr = visualNames; dictPtr->minLength; dictPtr++) {
+ if ((dictPtr->name[0] == c) && (length >= dictPtr->minLength)
&& (strncmp(string, dictPtr->name, length) == 0)) {
templ.c_class = dictPtr->c_class;
break;
@@ -205,12 +205,12 @@ Tk_GetVisual(
"unknown or ambiguous visual name \"%s\": class must be ",
string);
- for (dictPtr = visualNames; dictPtr->name != NULL; dictPtr++) {
+ for (dictPtr = visualNames; dictPtr->minLength; dictPtr++) {
Tcl_AppendPrintfToObj(msgObj, "%s, ", dictPtr->name);
}
- Tcl_AppendToObj(msgObj, "or default", -1);
+ Tcl_AppendToObj(msgObj, "or default", TCL_INDEX_NONE);
Tcl_SetObjResult(interp, msgObj);
- Tcl_SetErrorCode(interp, "TK", "LOOKUP", "VISUAL", string, NULL);
+ Tcl_SetErrorCode(interp, "TK", "LOOKUP", "VISUAL", string, (char *)NULL);
return NULL;
}
while (isspace(UCHAR(*p))) {
@@ -239,8 +239,8 @@ Tk_GetVisual(
&numVisuals);
if (visInfoList == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "couldn't find an appropriate visual", -1));
- Tcl_SetErrorCode(interp, "TK", "VISUAL", "INAPPROPRIATE", NULL);
+ "couldn't find an appropriate visual", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "VISUAL", "INAPPROPRIATE", (char *)NULL);
return NULL;
}
@@ -306,7 +306,7 @@ Tk_GetVisual(
CLANG_ASSERT(bestPtr);
*depthPtr = bestPtr->depth;
visual = bestPtr->visual;
- XFree((char *) visInfoList);
+ XFree(visInfoList);
/*
* If we need to find a colormap for this visual, do it now. If the visual
@@ -407,13 +407,13 @@ Tk_GetColormap(
if (Tk_Screen(other) != Tk_Screen(tkwin)) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't use colormap for %s: not on same screen", string));
- Tcl_SetErrorCode(interp, "TK", "COLORMAP", "SCREEN", NULL);
+ Tcl_SetErrorCode(interp, "TK", "COLORMAP", "SCREEN", (char *)NULL);
return None;
}
if (Tk_Visual(other) != Tk_Visual(tkwin)) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"can't use colormap for %s: incompatible visuals", string));
- Tcl_SetErrorCode(interp, "TK", "COLORMAP", "INCOMPATIBLE", NULL);
+ Tcl_SetErrorCode(interp, "TK", "COLORMAP", "INCOMPATIBLE", (char *)NULL);
return None;
}
colormap = Tk_Colormap(other);
diff --git a/generic/tkWindow.c b/generic/tkWindow.c
index 5d664b9..ee0e1b8 100644
--- a/generic/tkWindow.c
+++ b/generic/tkWindow.c
@@ -5,8 +5,8 @@
* equivalent to functions in Xlib (and even invoke them) but also
* maintain the local Tk_Window structure.
*
- * Copyright (c) 1989-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 1989-1994 The Regents of the University of California.
+ * Copyright © 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.
@@ -96,7 +96,7 @@ static const XSetWindowAttributes defAtts= {
#define USEINITPROC 8
#define SAVEUPDATECMD 16 /* better only be one of these! */
-typedef int (TkInitProc)(Tcl_Interp *interp, ClientData clientData);
+typedef int (TkInitProc)(Tcl_Interp *interp, void *clientData);
typedef struct {
const char *name; /* Name of command. */
Tcl_ObjCmdProc *objProc; /* Command's object- (or string-) based
@@ -208,7 +208,7 @@ static const TkCmd commands[] = {
static Tk_Window CreateTopLevelWindow(Tcl_Interp *interp,
Tk_Window parent, const char *name,
const char *screenName, unsigned int flags);
-static void DeleteWindowsExitProc(ClientData clientData);
+static void DeleteWindowsExitProc(void *clientData);
static TkDisplay * GetScreen(Tcl_Interp *interp, const char *screenName,
int *screenPtr);
static int Initialize(Tcl_Interp *interp);
@@ -241,8 +241,6 @@ TkCloseDisplay(
{
TkClipCleanup(dispPtr);
- TkpCancelWarp(dispPtr);
-
if (dispPtr->name != NULL) {
ckfree(dispPtr->name);
}
@@ -338,9 +336,11 @@ CreateTopLevelWindow(
* Create built-in photo image formats.
*/
- Tk_CreatePhotoImageFormat(&tkImgFmtGIF);
- Tk_CreatePhotoImageFormat(&tkImgFmtPNG);
+ Tk_CreatePhotoImageFormat(&tkImgFmtDefault);
+ Tk_CreatePhotoImageFormatVersion3(&tkImgFmtGIF);
+ Tk_CreatePhotoImageFormatVersion3(&tkImgFmtPNG);
Tk_CreatePhotoImageFormat(&tkImgFmtPPM);
+ Tk_CreatePhotoImageFormat(&tkImgFmtSVGnano);
}
if ((parent != NULL) && (screenName != NULL) && (screenName[0] == '\0')) {
@@ -359,9 +359,7 @@ CreateTopLevelWindow(
* Set the flags specified in the call.
*/
-#ifdef TK_USE_INPUT_METHODS
winPtr->ximGeneration = 0;
-#endif /*TK_USE_INPUT_METHODS*/
winPtr->flags |= flags;
/*
@@ -437,8 +435,8 @@ GetScreen(
screenName = TkGetDefaultScreenName(interp, screenName);
if (screenName == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "no display name and no $DISPLAY environment variable", -1));
- Tcl_SetErrorCode(interp, "TK", "NO_DISPLAY", NULL);
+ "no display name and no $DISPLAY environment variable", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "NO_DISPLAY", (char *)NULL);
return NULL;
}
length = strlen(screenName);
@@ -448,8 +446,8 @@ GetScreen(
p--;
}
if ((*p == '.') && (p[1] != '\0')) {
- length = p - screenName;
- screenId = strtoul(p+1, NULL, 10);
+ length = (size_t)(p - screenName);
+ screenId = (int)strtoul(p+1, NULL, 10);
}
/*
@@ -468,7 +466,7 @@ GetScreen(
if (dispPtr == NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"couldn't connect to display \"%s\"", screenName));
- Tcl_SetErrorCode(interp, "TK", "DISPLAY", "CONNECT", NULL);
+ Tcl_SetErrorCode(interp, "TK", "DISPLAY", "CONNECT", (char *)NULL);
return NULL;
}
dispPtr->nextPtr = tsdPtr->displayList; /* TkGetDisplayList(); */
@@ -502,7 +500,7 @@ GetScreen(
if (screenId >= ScreenCount(dispPtr->display)) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad screen number \"%d\"", screenId));
- Tcl_SetErrorCode(interp, "TK", "DISPLAY", "SCREEN_NUMBER", NULL);
+ Tcl_SetErrorCode(interp, "TK", "DISPLAY", "SCREEN_NUMBER", (char *)NULL);
return NULL;
}
*screenPtr = screenId;
@@ -656,13 +654,11 @@ TkAllocWindow(
winPtr->dirtyAtts = CWEventMask|CWColormap|CWBitGravity;
winPtr->flags = 0;
winPtr->handlerList = NULL;
-#ifdef TK_USE_INPUT_METHODS
winPtr->ximGeneration = 0;
winPtr->inputContext = NULL;
-#endif /* TK_USE_INPUT_METHODS */
winPtr->tagPtr = NULL;
winPtr->numTags = 0;
- winPtr->optionLevel = -1;
+ winPtr->optionLevel = TCL_INDEX_NONE;
winPtr->selHandlerList = NULL;
winPtr->geomMgrPtr = NULL;
winPtr->geomData = NULL;
@@ -752,7 +748,7 @@ NameWindow(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"window name starts with an upper-case letter: \"%s\"",
name));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "WINDOW", "NOTCLASS", NULL);
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "WINDOW", "NOTCLASS", (char *)NULL);
return TCL_ERROR;
}
@@ -791,7 +787,7 @@ NameWindow(
if (!isNew) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"window name \"%s\" already exists in parent", name));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "WINDOW", "EXISTS", NULL);
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "WINDOW", "EXISTS", (char *)NULL);
return TCL_ERROR;
}
Tcl_SetHashValue(hPtr, winPtr);
@@ -842,7 +838,7 @@ TkCreateMainWindow(
TkMainInfo *mainPtr;
TkWindow *winPtr;
const TkCmd *cmdPtr;
- ClientData clientData;
+ void *clientData;
Tcl_CmdInfo info;
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
@@ -889,7 +885,10 @@ TkCreateMainWindow(
mainPtr->strictMotif = 0;
mainPtr->alwaysShowSelection = 0;
mainPtr->tclUpdateObjProc = NULL;
- if (Tcl_LinkVar(interp, "tk_strictMotif", (char *) &mainPtr->strictMotif,
+#if TCL_MAJOR_VERSION > 8
+ mainPtr->tclUpdateObjProc2 = NULL;
+#endif
+ if (Tcl_LinkVar(interp, "tk_strictMotif", (char *)&mainPtr->strictMotif,
TCL_LINK_BOOLEAN) != TCL_OK) {
Tcl_ResetResult(interp);
}
@@ -897,7 +896,7 @@ TkCreateMainWindow(
Tcl_ResetResult(interp);
}
if (Tcl_LinkVar(interp, "::tk::AlwaysShowSelection",
- (char *) &mainPtr->alwaysShowSelection,
+ (char *)&mainPtr->alwaysShowSelection,
TCL_LINK_BOOLEAN) != TCL_OK) {
Tcl_ResetResult(interp);
}
@@ -935,7 +934,7 @@ TkCreateMainWindow(
}
#if defined(_WIN32) && !defined(STATIC_BUILD)
- if ((cmdPtr->flags & WINMACONLY) && tclStubsPtr->reserved9) {
+ if ((cmdPtr->flags & WINMACONLY) && tclStubsPtr->tcl_CreateFileHandler) {
/*
* We are running on Cygwin, so don't use the win32 dialogs.
*/
@@ -951,8 +950,15 @@ TkCreateMainWindow(
}
if ((cmdPtr->flags & SAVEUPDATECMD) &&
Tcl_GetCommandInfo(interp, cmdPtr->name, &cmdInfo) &&
- cmdInfo.isNativeObjectProc && !cmdInfo.objClientData && !cmdInfo.deleteProc) {
- mainPtr->tclUpdateObjProc = cmdInfo.objProc;
+ cmdInfo.isNativeObjectProc && !cmdInfo.deleteProc) {
+#if TCL_MAJOR_VERSION > 8
+ if ((cmdInfo.isNativeObjectProc == 2) && !cmdInfo.objClientData2) {
+ mainPtr->tclUpdateObjProc2 = cmdInfo.objProc2;
+ } else
+#endif
+ if (!cmdInfo.objClientData) {
+ mainPtr->tclUpdateObjProc = cmdInfo.objProc;
+ }
}
if (cmdPtr->flags & USEINITPROC) {
((TkInitProc *)(void *)cmdPtr->objProc)(interp, clientData);
@@ -965,9 +971,7 @@ TkCreateMainWindow(
}
}
if (Tcl_GetCommandInfo(interp, "::tcl::build-info", &info)) {
- Tcl_CreateObjCommand(interp, "::tk::build-info",
- info.objProc, (void *)
- (TK_PATCH_LEVEL "+" STRINGIFY(TK_VERSION_UUID)
+ static const char version[] = TK_PATCH_LEVEL "+" STRINGIFY(TK_VERSION_UUID)
#if defined(MAC_OSX_TK)
".aqua"
#endif
@@ -1024,9 +1028,6 @@ TkCreateMainWindow(
#ifdef STATIC_BUILD
".static"
#endif
-#if TCL_UTF_MAX <= (3 + (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION == 6))
- ".utf-16"
-#endif
#if defined(_WIN32)
".win32"
#endif
@@ -1036,7 +1037,18 @@ TkCreateMainWindow(
".no-xft"
#endif
#endif
- ), NULL);
+ ;
+#if TCL_MAJOR_VERSION > 8
+ if (info.isNativeObjectProc == 2) {
+ Tcl_CreateObjCommand2(interp, "::tk::build-info",
+ info.objProc2, (void *)
+ version, NULL);
+
+ } else
+#endif
+ Tcl_CreateObjCommand(interp, "::tk::build-info",
+ info.objProc, (void *)
+ version, NULL);
}
/*
@@ -1091,14 +1103,14 @@ Tk_CreateWindow(
if (parentPtr) {
if (parentPtr->flags & TK_ALREADY_DEAD) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "can't create window: parent has been destroyed", -1));
- Tcl_SetErrorCode(interp, "TK", "CREATE", "DEAD_PARENT", NULL);
+ "can't create window: parent has been destroyed", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "CREATE", "DEAD_PARENT", (char *)NULL);
return NULL;
} else if (parentPtr->flags & TK_CONTAINER) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"can't create window: its parent has -container = yes",
- -1));
- Tcl_SetErrorCode(interp, "TK", "CREATE", "CONTAINER", NULL);
+ TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "CREATE", "CONTAINER", (char *)NULL);
return NULL;
} else if (screenName == NULL) {
TkWindow *winPtr = TkAllocWindow(parentPtr->dispPtr,
@@ -1155,14 +1167,14 @@ Tk_CreateAnonymousWindow(
if (parentPtr) {
if (parentPtr->flags & TK_ALREADY_DEAD) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "can't create window: parent has been destroyed", -1));
- Tcl_SetErrorCode(interp, "TK", "CREATE", "DEAD_PARENT", NULL);
+ "can't create window: parent has been destroyed", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "CREATE", "DEAD_PARENT", (char *)NULL);
return NULL;
} else if (parentPtr->flags & TK_CONTAINER) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"can't create window: its parent has -container = yes",
- -1));
- Tcl_SetErrorCode(interp, "TK", "CREATE", "CONTAINER", NULL);
+ TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "CREATE", "CONTAINER", (char *)NULL);
return NULL;
} else if (screenName == NULL) {
TkWindow *winPtr = TkAllocWindow(parentPtr->dispPtr,
@@ -1226,7 +1238,7 @@ Tk_CreateWindowFromPath(
char fixedSpace[FIXED_SPACE+1];
char *p;
Tk_Window parent;
- int numChars;
+ size_t numChars;
/*
* Strip the parent's name out of pathName (it's everything up to the last
@@ -1240,10 +1252,10 @@ Tk_CreateWindowFromPath(
if (p == NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad window path name \"%s\"", pathName));
- Tcl_SetErrorCode(interp, "TK", "VALUE", "WINDOW_PATH", NULL);
+ Tcl_SetErrorCode(interp, "TK", "VALUE", "WINDOW_PATH", (char *)NULL);
return NULL;
}
- numChars = (int) (p-pathName);
+ numChars = (size_t)(p - pathName);
if (numChars > FIXED_SPACE) {
p = (char *)ckalloc(numChars + 1);
} else {
@@ -1270,13 +1282,13 @@ Tk_CreateWindowFromPath(
}
if (((TkWindow *) parent)->flags & TK_ALREADY_DEAD) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "can't create window: parent has been destroyed", -1));
- Tcl_SetErrorCode(interp, "TK", "CREATE", "DEAD_PARENT", NULL);
+ "can't create window: parent has been destroyed", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "CREATE", "DEAD_PARENT", (char *)NULL);
return NULL;
} else if (((TkWindow *) parent)->flags & TK_CONTAINER) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "can't create window: its parent has -container = yes", -1));
- Tcl_SetErrorCode(interp, "TK", "CREATE", "CONTAINER", NULL);
+ "can't create window: its parent has -container = yes", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "CREATE", "CONTAINER", (char *)NULL);
return NULL;
}
@@ -1326,7 +1338,7 @@ void
Tk_DestroyWindow(
Tk_Window tkwin) /* Window to destroy. */
{
- TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *)tkwin;
TkDisplay *dispPtr = winPtr->dispPtr;
XEvent event;
TkHalfdeadWindow *halfdeadPtr, *prev_halfdeadPtr;
@@ -1443,10 +1455,10 @@ Tk_DestroyWindow(
* (otherwise, for example, the Tk window may appear to exist even
* though its X window is gone; this could cause errors). Special
* note: it's possible that the embedded window has already been
- * deleted, in which case TkpGetOtherWindow will return NULL.
+ * deleted, in which case Tk_GetOtherWindow will return NULL.
*/
- TkWindow *childPtr = TkpGetOtherWindow(winPtr);
+ TkWindow *childPtr = (TkWindow *)Tk_GetOtherWindow(tkwin);
if (childPtr != NULL) {
childPtr->flags |= TK_DONT_DESTROY_WINDOW;
@@ -1533,18 +1545,16 @@ Tk_DestroyWindow(
}
#endif
Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->winTable,
- (char *) winPtr->window));
+ winPtr->window));
winPtr->window = None;
}
UnlinkWindow(winPtr);
TkEventDeadWindow(winPtr);
-#ifdef TK_USE_INPUT_METHODS
if (winPtr->inputContext != NULL &&
- winPtr->ximGeneration == winPtr->dispPtr->ximGeneration) {
+ winPtr->ximGeneration == winPtr->dispPtr->ximGeneration) {
XDestroyIC(winPtr->inputContext);
}
winPtr->inputContext = NULL;
-#endif /* TK_USE_INPUT_METHODS */
if (winPtr->tagPtr != NULL) {
TkFreeBindingTags(winPtr);
}
@@ -1594,13 +1604,22 @@ Tk_DestroyWindow(
if ((winPtr->mainPtr->interp != NULL) &&
!Tcl_InterpDeleted(winPtr->mainPtr->interp)) {
for (cmdPtr = commands; cmdPtr->name != NULL; cmdPtr++) {
- if ((cmdPtr->flags & SAVEUPDATECMD) &&
- winPtr->mainPtr->tclUpdateObjProc != NULL) {
+ if (cmdPtr->flags & SAVEUPDATECMD) {
/* Restore Tcl's version of [update] */
- Tcl_CreateObjCommand(winPtr->mainPtr->interp,
- cmdPtr->name,
- winPtr->mainPtr->tclUpdateObjProc,
- NULL, NULL);
+#if TCL_MAJOR_VERSION > 8
+ if (winPtr->mainPtr->tclUpdateObjProc2 != NULL) {
+ Tcl_CreateObjCommand2(winPtr->mainPtr->interp,
+ cmdPtr->name,
+ winPtr->mainPtr->tclUpdateObjProc2,
+ NULL, NULL);
+ } else
+#endif
+ if (winPtr->mainPtr->tclUpdateObjProc != NULL) {
+ Tcl_CreateObjCommand(winPtr->mainPtr->interp,
+ cmdPtr->name,
+ winPtr->mainPtr->tclUpdateObjProc,
+ NULL, NULL);
+ }
} else {
Tcl_CreateObjCommand(winPtr->mainPtr->interp,
cmdPtr->name, TkDeadAppObjCmd,
@@ -1800,7 +1819,7 @@ Tk_MakeWindowExist(
if (createProc != NULL && parent != None) {
winPtr->window = createProc(tkwin, parent, winPtr->instanceData);
} else {
- winPtr->window = TkpMakeWindow(winPtr, parent);
+ winPtr->window = Tk_MakeWindow(tkwin, parent);
}
hPtr = Tcl_CreateHashEntry(&winPtr->dispPtr->winTable,
@@ -1978,8 +1997,8 @@ Tk_ResizeWindow(
{
TkWindow *winPtr = (TkWindow *) tkwin;
- winPtr->changes.width = (unsigned) width;
- winPtr->changes.height = (unsigned) height;
+ winPtr->changes.width = width;
+ winPtr->changes.height = height;
if (winPtr->window != None) {
XResizeWindow(winPtr->display, winPtr->window, (unsigned) width,
(unsigned) height);
@@ -2000,8 +2019,8 @@ Tk_MoveResizeWindow(
winPtr->changes.x = x;
winPtr->changes.y = y;
- winPtr->changes.width = (unsigned) width;
- winPtr->changes.height = (unsigned) height;
+ winPtr->changes.width = width;
+ winPtr->changes.height = height;
if (winPtr->window != None) {
XMoveResizeWindow(winPtr->display, winPtr->window, x, y,
(unsigned) width, (unsigned) height);
@@ -2173,11 +2192,7 @@ Tk_DefineCursor(
{
TkWindow *winPtr = (TkWindow *) tkwin;
-#if defined(MAC_OSX_TK)
- winPtr->atts.cursor = (XCursor) cursor;
-#else
winPtr->atts.cursor = (Cursor) cursor;
-#endif
if (winPtr->window != None) {
XDefineCursor(winPtr->display, winPtr->window, winPtr->atts.cursor);
@@ -2360,7 +2375,7 @@ void
Tk_SetClassProcs(
Tk_Window tkwin, /* Token for window to modify. */
const Tk_ClassProcs *procs, /* Class procs structure. */
- ClientData instanceData) /* Data to be passed to class functions. */
+ void *instanceData) /* Data to be passed to class functions. */
{
TkWindow *winPtr = (TkWindow *) tkwin;
@@ -2404,8 +2419,8 @@ Tk_NameToWindow(
*/
if (interp != NULL) {
- Tcl_SetObjResult(interp, Tcl_NewStringObj("NULL main window",-1));
- Tcl_SetErrorCode(interp, "TK", "NO_MAIN_WINDOW", NULL);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("NULL main window",TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "NO_MAIN_WINDOW", (char *)NULL);
}
return NULL;
}
@@ -2417,7 +2432,7 @@ Tk_NameToWindow(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad window path name \"%s\"", pathName));
Tcl_SetErrorCode(interp, "TK", "LOOKUP", "WINDOW", pathName,
- NULL);
+ (char *)NULL);
}
return NULL;
}
@@ -2463,7 +2478,7 @@ Tk_IdToWindow(
return NULL;
}
- hPtr = Tcl_FindHashEntry(&dispPtr->winTable, (char *) window);
+ hPtr = Tcl_FindHashEntry(&dispPtr->winTable, window);
if (hPtr == NULL) {
return NULL;
}
@@ -2734,8 +2749,8 @@ Tk_MainWindow(
}
}
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "this isn't a Tk application", -1));
- Tcl_SetErrorCode(interp, "TK", "NO_MAIN_WINDOW", NULL);
+ "this isn't a Tk application", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "NO_MAIN_WINDOW", (char *)NULL);
return NULL;
}
@@ -2803,7 +2818,7 @@ Tk_GetNumMainWindows(void)
/*
*----------------------------------------------------------------------
*
- * TkpAlwaysShowSelection --
+ * Tk_AlwaysShowSelection --
*
* Indicates whether text/entry widgets should always display
* their selection, regardless of window focus.
@@ -2821,7 +2836,7 @@ Tk_GetNumMainWindows(void)
*/
int
-TkpAlwaysShowSelection(
+Tk_AlwaysShowSelection(
Tk_Window tkwin) /* Window whose application is to be
* checked. */
{
@@ -2849,7 +2864,7 @@ TkpAlwaysShowSelection(
static void
DeleteWindowsExitProc(
- ClientData clientData) /* tsdPtr when handler was created. */
+ void *clientData) /* tsdPtr when handler was created. */
{
TkDisplay *dispPtr, *nextPtr;
Tcl_Interp *interp;
@@ -2895,8 +2910,8 @@ DeleteWindowsExitProc(
*/
for (dispPtr = tsdPtr->displayList; dispPtr != NULL;
- dispPtr = dispPtr->nextPtr) {
- XSync(dispPtr->display, False);
+ dispPtr = dispPtr->nextPtr) {
+ XSync(dispPtr->display, False);
}
/*
@@ -2942,7 +2957,7 @@ static HMODULE tkcygwindll = NULL;
MODULE_SCOPE void
TkCygwinMainEx(
- int argc, /* Number of arguments. */
+ Tcl_Size argc, /* Number of arguments. */
char **argv, /* Array of argument strings. */
Tcl_AppInitProc *appInitProc,
/* Application-specific initialization
@@ -2951,19 +2966,23 @@ TkCygwinMainEx(
Tcl_Interp *interp)
{
WCHAR name[MAX_PATH];
- int len;
- void (*tkmainex)(int, char **, Tcl_AppInitProc *, Tcl_Interp *);
+ size_t len;
+ void (*tkmainex)(Tcl_Size, char **, Tcl_AppInitProc *, Tcl_Interp *);
/* construct "<path>/libtk8.?.dll", from "<path>/tk8?.dll" */
len = GetModuleFileNameW((HINSTANCE)Tk_GetHINSTANCE(), name, MAX_PATH);
name[len-2] = '.';
name[len-1] = name[len-5];
wcscpy(name+len, L".dll");
+#if TCL_MAJOR_VERSION > 8
+ memcpy(name+len-12, L"libtcl9tk8", 10 * sizeof(WCHAR));
+#else
memcpy(name+len-8, L"libtk8", 6 * sizeof(WCHAR));
+#endif
tkcygwindll = LoadLibraryW(name);
if (tkcygwindll) {
- tkmainex = (void (*)(int, char **, Tcl_AppInitProc *, Tcl_Interp *))
+ tkmainex = (void (*)(Tcl_Size, char **, Tcl_AppInitProc *, Tcl_Interp *))
(void *)GetProcAddress(tkcygwindll, "Tk_MainEx");
if (tkmainex) {
tkmainex(argc, argv, appInitProc, interp);
@@ -3158,11 +3177,17 @@ Initialize(
* Ensure that we are getting a compatible version of Tcl.
*/
- if (Tcl_InitStubs(interp, "8.6", 0) == NULL) {
+ if (Tcl_InitStubs(interp, "8.6-", 0) == NULL) {
return TCL_ERROR;
}
/*
+ * TIP #59: Make embedded configuration information available.
+ */
+
+ TkInitEmbeddedConfigurationInformation(interp);
+
+ /*
* Ensure that our obj-types are registered with the Tcl runtime.
*/
@@ -3195,8 +3220,8 @@ Initialize(
parent = Tcl_GetParent(parent);
if (parent == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "no controlling parent interpreter", -1));
- Tcl_SetErrorCode(interp, "TK", "SAFE", "NO_MASTER", NULL);
+ "no controlling parent interpreter", TCL_INDEX_NONE));
+ Tcl_SetErrorCode(interp, "TK", "SAFE", "NO_PARENT", (char *)NULL);
return TCL_ERROR;
}
}
@@ -3216,7 +3241,7 @@ Initialize(
cmd = Tcl_NewListObj(2, NULL);
Tcl_ListObjAppendElement(NULL, cmd,
- Tcl_NewStringObj("::safe::TkInit", -1));
+ Tcl_NewStringObj("::safe::TkInit", TCL_INDEX_NONE));
Tcl_ListObjAppendElement(NULL, cmd, Tcl_GetObjResult(parent));
/*
@@ -3250,7 +3275,7 @@ Initialize(
}
if (value) {
- int objc;
+ Tcl_Size objc;
Tcl_Obj **objv, **rest;
Tcl_Obj *parseList = Tcl_NewListObj(1, NULL);
@@ -3302,7 +3327,7 @@ Initialize(
*/
{
- int numBytes;
+ Tcl_Size numBytes;
const char *bytes = Tcl_GetStringFromObj(nameObj, &numBytes);
classObj = Tcl_NewStringObj(bytes, numBytes);
@@ -3316,13 +3341,13 @@ Initialize(
* information parsed from argv, if any.
*/
- cmd = Tcl_NewStringObj("toplevel . -class", -1);
+ cmd = Tcl_NewStringObj("toplevel . -class", TCL_INDEX_NONE);
Tcl_ListObjAppendElement(NULL, cmd, classObj);
classObj = NULL;
if (displayObj) {
- Tcl_ListObjAppendElement(NULL, cmd, Tcl_NewStringObj("-screen", -1));
+ Tcl_ListObjAppendElement(NULL, cmd, Tcl_NewStringObj("-screen", TCL_INDEX_NONE));
Tcl_ListObjAppendElement(NULL, cmd, displayObj);
/*
@@ -3337,17 +3362,17 @@ Initialize(
displayObj = NULL;
}
if (colorMapObj) {
- Tcl_ListObjAppendElement(NULL, cmd, Tcl_NewStringObj("-colormap", -1));
+ Tcl_ListObjAppendElement(NULL, cmd, Tcl_NewStringObj("-colormap", TCL_INDEX_NONE));
Tcl_ListObjAppendElement(NULL, cmd, colorMapObj);
colorMapObj = NULL;
}
if (useObj) {
- Tcl_ListObjAppendElement(NULL, cmd, Tcl_NewStringObj("-use", -1));
+ Tcl_ListObjAppendElement(NULL, cmd, Tcl_NewStringObj("-use", TCL_INDEX_NONE));
Tcl_ListObjAppendElement(NULL, cmd, useObj);
useObj = NULL;
}
if (visualObj) {
- Tcl_ListObjAppendElement(NULL, cmd, Tcl_NewStringObj("-visual", -1));
+ Tcl_ListObjAppendElement(NULL, cmd, Tcl_NewStringObj("-visual", TCL_INDEX_NONE));
Tcl_ListObjAppendElement(NULL, cmd, visualObj);
visualObj = NULL;
}
@@ -3373,7 +3398,7 @@ Initialize(
Tcl_SetVar2Ex(interp, "geometry", NULL, geometryObj, TCL_GLOBAL_ONLY);
- cmd = Tcl_NewStringObj("wm geometry .", -1);
+ cmd = Tcl_NewStringObj("wm geometry .", TCL_INDEX_NONE);
Tcl_ListObjAppendElement(NULL, cmd, geometryObj);
Tcl_IncrRefCount(cmd);
code = Tcl_EvalObjEx(interp, cmd, 0);
@@ -3385,11 +3410,15 @@ Initialize(
}
/*
- * Provide Tk and its stub table.
+ * Provide "tk" and its stub table.
*/
- code = Tcl_PkgProvideEx(interp, "Tk", TK_PATCH_LEVEL,
- (ClientData) &tkStubs);
+#ifndef TK_NO_DEPRECATED
+ Tcl_PkgProvideEx(interp, "Tk", TK_PATCH_LEVEL,
+ (void *)&tkStubs);
+#endif
+ code = Tcl_PkgProvideEx(interp, "tk", TK_PATCH_LEVEL,
+ (void *)&tkStubs);
if (code != TCL_OK) {
goto done;
}
@@ -3439,7 +3468,7 @@ Initialize(
tcl_findLibrary tk $tk_version $tk_patchLevel tk.tcl TK_LIBRARY tk_library\n\
}\n\
}\n\
-tkInit", -1, TCL_EVAL_GLOBAL);
+tkInit", TCL_INDEX_NONE, TCL_EVAL_GLOBAL);
}
if (code == TCL_OK) {
/*
@@ -3487,7 +3516,7 @@ Tk_PkgInitStubsCheck(
const char * version,
int exact)
{
- const char *actualVersion = Tcl_PkgRequireEx(interp, "Tk", version, 0, NULL);
+ const char *actualVersion = Tcl_PkgRequireEx(interp, "tk", version, 0, NULL);
if (exact && actualVersion) {
const char *p = version;
@@ -3499,11 +3528,11 @@ Tk_PkgInitStubsCheck(
if (count == 1) {
if (0 != strncmp(version, actualVersion, strlen(version))) {
/* Construct error message */
- Tcl_PkgPresentEx(interp, "Tk", version, 1, NULL);
+ Tcl_PkgPresentEx(interp, "tk", version, 1, NULL);
return NULL;
}
} else {
- return Tcl_PkgPresentEx(interp, "Tk", version, 1, NULL);
+ return Tcl_PkgPresentEx(interp, "tk", version, 1, NULL);
}
}
return actualVersion;
diff --git a/generic/ttk/ttk.decls b/generic/ttk/ttk.decls
index e668a2a..1c98b23 100644
--- a/generic/ttk/ttk.decls
+++ b/generic/ttk/ttk.decls
@@ -25,7 +25,7 @@ declare 5 {
int Ttk_RegisterElementSpec(
Ttk_Theme theme,
const char *elementName,
- Ttk_ElementSpec *elementSpec,
+ const Ttk_ElementSpec *elementSpec,
void *clientData)
}
@@ -34,7 +34,7 @@ declare 6 {
Tcl_Interp *interp,
Ttk_Theme theme,
const char *elementName,
- Ttk_ElementSpec *elementSpec,
+ const Ttk_ElementSpec *elementSpec,
void *clientData)
}
@@ -72,7 +72,7 @@ declare 13 {
}
declare 14 {
int Ttk_StateTableLookup(
- Ttk_StateTable map[], Ttk_State state)
+ const Ttk_StateTable *map, Ttk_State state)
}
@@ -143,7 +143,7 @@ declare 35 {
#
# Utilities.
#
-declare 40 {
+declare 40 {deprecated {}} {
int Ttk_GetOrientFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, int *orient)
}
diff --git a/generic/ttk/ttkBlink.c b/generic/ttk/ttkBlink.c
index a7d4a9a..a2bc3ae 100644
--- a/generic/ttk/ttkBlink.c
+++ b/generic/ttk/ttkBlink.c
@@ -10,12 +10,10 @@
* to display the cursor or not (e.g., readonly or disabled states);
* TtkBlinkCursor() does not account for this.
*
- * TODO:
- * Add script-level access to configure application-wide blink rate.
*/
#include "tkInt.h"
-#include "ttkTheme.h"
+#include "ttkThemeInt.h"
#include "ttkWidget.h"
#define DEF_CURSOR_ON_TIME 600 /* milliseconds */
@@ -34,9 +32,12 @@ typedef struct
/* CursorManagerDeleteProc --
* InterpDeleteProc for cursor manager.
*/
-static void CursorManagerDeleteProc(ClientData clientData, Tcl_Interp *interp)
+static void CursorManagerDeleteProc(
+ void *clientData,
+ TCL_UNUSED(Tcl_Interp *))
{
CursorManager *cm = (CursorManager*)clientData;
+
if (cm->timer) {
Tcl_DeleteTimerHandler(cm->timer);
}
@@ -49,14 +50,38 @@ static void CursorManagerDeleteProc(ClientData clientData, Tcl_Interp *interp)
static CursorManager *GetCursorManager(Tcl_Interp *interp)
{
static const char *cm_key = "ttk::CursorManager";
- CursorManager *cm = Tcl_GetAssocData(interp, cm_key,0);
+ CursorManager *cm = (CursorManager *)Tcl_GetAssocData(interp, cm_key,0);
+ Tk_Window window;
+ Tk_Uid value;
+ int intValue;
if (!cm) {
- cm = ckalloc(sizeof(*cm));
+ cm = (CursorManager *)ckalloc(sizeof(*cm));
cm->timer = 0;
cm->owner = 0;
cm->onTime = DEF_CURSOR_ON_TIME;
cm->offTime = DEF_CURSOR_OFF_TIME;
+
+ /* Override on and off default times with values obtained from
+ * the option database (if such values are specified).
+ */
+
+ window = Tk_MainWindow(interp);
+ if (window) {
+ value = Tk_GetOption(window, "insertOnTime", "OnTime");
+ if (value) {
+ if (Tcl_GetInt(interp, value, &intValue) == TCL_OK) {
+ cm->onTime = intValue;
+ }
+ }
+ value = Tk_GetOption(window, "insertOffTime", "OffTime");
+ if (value) {
+ if (Tcl_GetInt(interp, value, &intValue) == TCL_OK) {
+ cm->offTime = intValue;
+ }
+ }
+ }
+
Tcl_SetAssocData(interp, cm_key, CursorManagerDeleteProc, cm);
}
return cm;
@@ -66,9 +91,9 @@ static CursorManager *GetCursorManager(Tcl_Interp *interp)
* Timer handler to blink the insert cursor on and off.
*/
static void
-CursorBlinkProc(ClientData clientData)
+CursorBlinkProc(void *clientData)
{
- CursorManager *cm = (CursorManager*)clientData;
+ CursorManager *cm = (CursorManager *)clientData;
int blinkTime;
if (cm->owner->flags & CURSOR_ON) {
@@ -129,7 +154,7 @@ static void ClaimCursor(CursorManager *cm, WidgetCore *corePtr)
(d == NotifyInferior || d == NotifyAncestor || d == NotifyNonlinear)
static void
-CursorEventProc(ClientData clientData, XEvent *eventPtr)
+CursorEventProc(void *clientData, XEvent *eventPtr)
{
WidgetCore *corePtr = (WidgetCore *)clientData;
CursorManager *cm = GetCursorManager(corePtr->interp);
@@ -152,6 +177,49 @@ CursorEventProc(ClientData clientData, XEvent *eventPtr)
}
}
+void TtkSetBlinkCursorOnTime(Tcl_Interp* interp, int onTime)
+{
+ CursorManager* cm = GetCursorManager(interp);
+
+ if (onTime >= 0)
+ cm->onTime = onTime;
+}
+
+void TtkSetBlinkCursorOffTime(Tcl_Interp* interp, int offTime)
+{
+ CursorManager* cm = GetCursorManager(interp);
+
+ if (offTime >= 0)
+ cm->offTime = offTime;
+}
+
+/*
+ * TtkSetBlinkCursorTimes --
+ * Set cursor blink on and off times from the "." style defaults
+ * -insertontime and -insertofftime - For instance to set cursor
+ * blinking off:
+ * ttk::style configure . -insertofftime 0
+ */
+void TtkSetBlinkCursorTimes(Tcl_Interp* interp)
+{
+ Ttk_Theme theme;
+ Ttk_Style style = NULL;
+ Tcl_Obj* result;
+ int timeInterval;
+
+ theme = Ttk_GetCurrentTheme(interp);
+ style = Ttk_GetStyle(theme, ".");
+ result = Ttk_StyleDefault(style, "-insertontime");
+ if (result) {
+ Tcl_GetIntFromObj(interp, result, &timeInterval);
+ TtkSetBlinkCursorOnTime(interp, timeInterval);
+ }
+ result = Ttk_StyleDefault(style, "-insertofftime");
+ if (result) {
+ Tcl_GetIntFromObj(interp, result, &timeInterval);
+ TtkSetBlinkCursorOffTime(interp, timeInterval);
+ }
+}
/*
* TtkBlinkCursor (main routine) --
* Arrange to blink the cursor on and off whenever the
diff --git a/generic/ttk/ttkButton.c b/generic/ttk/ttkButton.c
index a02bfa5..af72ea4 100644
--- a/generic/ttk/ttkButton.c
+++ b/generic/ttk/ttkButton.c
@@ -1,11 +1,11 @@
/*
- * Copyright (c) 2003, Joe English
+ * Copyright © 2003, Joe English
*
* label, button, checkbutton, radiobutton, and menubutton widgets.
*/
#include "tkInt.h"
-#include "ttkTheme.h"
+#include "ttkThemeInt.h"
#include "ttkWidget.h"
/* Bit fields for OptionSpec mask field:
@@ -22,6 +22,7 @@ typedef struct
* Text element resources:
*/
Tcl_Obj *textObj;
+ Tcl_Obj *justifyObj;
Tcl_Obj *textVariableObj;
Tcl_Obj *underlineObj;
Tcl_Obj *widthObj;
@@ -53,45 +54,46 @@ typedef struct
BasePart base;
} Base;
-static Tk_OptionSpec BaseOptionSpecs[] =
+static const Tk_OptionSpec BaseOptionSpecs[] =
{
+ {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
+ "left", offsetof(Base,base.justifyObj), TCL_INDEX_NONE,
+ TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
{TK_OPTION_STRING, "-text", "text", "Text", "",
- Tk_Offset(Base,base.textObj), -1,
+ offsetof(Base,base.textObj), TCL_INDEX_NONE,
0,0,GEOMETRY_CHANGED },
{TK_OPTION_STRING, "-textvariable", "textVariable", "Variable", "",
- Tk_Offset(Base,base.textVariableObj), -1,
+ offsetof(Base,base.textVariableObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
- {TK_OPTION_INT, "-underline", "underline", "Underline",
- "-1", Tk_Offset(Base,base.underlineObj), -1,
- 0,0,0 },
- /* SB: OPTION_INT, see <<NOTE-NULLOPTIONS>> */
+ {TK_OPTION_INDEX, "-underline", "underline", "Underline",
+ TTK_OPTION_UNDERLINE_DEF(Base, base.underlineObj), 0},
{TK_OPTION_STRING, "-width", "width", "Width",
- NULL, Tk_Offset(Base,base.widthObj), -1,
+ NULL, offsetof(Base,base.widthObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
/*
* Image options
*/
{TK_OPTION_STRING, "-image", "image", "Image", NULL/*default*/,
- Tk_Offset(Base,base.imageObj), -1,
+ offsetof(Base,base.imageObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
/*
* Compound base/image options
*/
{TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound",
- NULL, Tk_Offset(Base,base.compoundObj), -1,
+ NULL, offsetof(Base,base.compoundObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, ttkCompoundStrings,
GEOMETRY_CHANGED },
{TK_OPTION_STRING, "-padding", "padding", "Pad",
- NULL, Tk_Offset(Base,base.paddingObj), -1,
+ NULL, offsetof(Base,base.paddingObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED},
/*
* Compatibility/legacy options
*/
{TK_OPTION_STRING, "-state", "state", "State",
- "normal", Tk_Offset(Base,base.stateObj), -1,
+ "normal", offsetof(Base,base.stateObj), TCL_INDEX_NONE,
0,0,STATE_CHANGED },
WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
@@ -227,7 +229,6 @@ typedef struct
Tcl_Obj *borderWidthObj;
Tcl_Obj *reliefObj;
Tcl_Obj *anchorObj;
- Tcl_Obj *justifyObj;
Tcl_Obj *wrapLengthObj;
} LabelPart;
@@ -238,31 +239,28 @@ typedef struct
LabelPart label;
} Label;
-static Tk_OptionSpec LabelOptionSpecs[] =
+static const Tk_OptionSpec LabelOptionSpecs[] =
{
{TK_OPTION_BORDER, "-background", "frameColor", "FrameColor",
- NULL, Tk_Offset(Label,label.backgroundObj), -1,
+ NULL, offsetof(Label,label.backgroundObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,0 },
{TK_OPTION_COLOR, "-foreground", "textColor", "TextColor",
- NULL, Tk_Offset(Label,label.foregroundObj), -1,
+ NULL, offsetof(Label,label.foregroundObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,0 },
{TK_OPTION_FONT, "-font", "font", "Font",
- NULL, Tk_Offset(Label,label.fontObj), -1,
+ NULL, offsetof(Label,label.fontObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- NULL, Tk_Offset(Label,label.borderWidthObj), -1,
+ NULL, offsetof(Label,label.borderWidthObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- NULL, Tk_Offset(Label,label.reliefObj), -1,
+ NULL, offsetof(Label,label.reliefObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
- "w", Tk_Offset(Label,label.anchorObj), -1,
+ "w", offsetof(Label,label.anchorObj), TCL_INDEX_NONE,
0, 0, GEOMETRY_CHANGED},
- {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
- "left", Tk_Offset(Label, label.justifyObj), -1,
- 0,0,GEOMETRY_CHANGED },
{TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength",
- NULL, Tk_Offset(Label, label.wrapLengthObj), -1,
+ NULL, offsetof(Label, label.wrapLengthObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED /*SB: SIZE_CHANGED*/ },
WIDGET_TAKEFOCUS_FALSE,
@@ -270,15 +268,16 @@ static Tk_OptionSpec LabelOptionSpecs[] =
};
static const Ttk_Ensemble LabelCommands[] = {
- { "configure", TtkWidgetConfigureCommand,0 },
{ "cget", TtkWidgetCgetCommand,0 },
+ { "configure", TtkWidgetConfigureCommand,0 },
+ { "identify", TtkWidgetIdentifyCommand,0 },
{ "instate", TtkWidgetInstateCommand,0 },
{ "state", TtkWidgetStateCommand,0 },
- { "identify", TtkWidgetIdentifyCommand,0 },
+ { "style", TtkWidgetStyleCommand,0 },
{ 0,0,0 }
};
-static WidgetSpec LabelWidgetSpec =
+static const WidgetSpec LabelWidgetSpec =
{
"TLabel", /* className */
sizeof(Label), /* recordSize */
@@ -321,12 +320,12 @@ typedef struct
/*
* Option specifications:
*/
-static Tk_OptionSpec ButtonOptionSpecs[] =
+static const Tk_OptionSpec ButtonOptionSpecs[] =
{
{TK_OPTION_STRING, "-command", "command", "Command",
- "", Tk_Offset(Button, button.commandObj), -1, 0,0,0},
+ "", offsetof(Button, button.commandObj), TCL_INDEX_NONE, 0,0,0},
{TK_OPTION_STRING_TABLE, "-default", "default", "Default",
- "normal", Tk_Offset(Button, button.defaultStateObj), -1,
+ "normal", offsetof(Button, button.defaultStateObj), TCL_INDEX_NONE,
0, ttkDefaultStrings, DEFAULTSTATE_CHANGED},
WIDGET_TAKEFOCUS_TRUE,
@@ -344,7 +343,7 @@ static int ButtonConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
/* Handle "-default" option:
*/
if (mask & DEFAULTSTATE_CHANGED) {
- int defaultState = TTK_BUTTON_DEFAULT_DISABLED;
+ Ttk_ButtonDefaultState defaultState = TTK_BUTTON_DEFAULT_DISABLED;
Ttk_GetButtonDefaultStateFromObj(
NULL, buttonPtr->button.defaultStateObj, &defaultState);
if (defaultState == TTK_BUTTON_DEFAULT_ACTIVE) {
@@ -361,7 +360,7 @@ static int ButtonConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
*/
static int
ButtonInvokeCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Button *buttonPtr = (Button *)recordPtr;
if (objc > 2) {
@@ -375,16 +374,17 @@ ButtonInvokeCommand(
}
static const Ttk_Ensemble ButtonCommands[] = {
- { "configure", TtkWidgetConfigureCommand,0 },
{ "cget", TtkWidgetCgetCommand,0 },
- { "invoke", ButtonInvokeCommand,0 },
+ { "configure", TtkWidgetConfigureCommand,0 },
+ { "identify", TtkWidgetIdentifyCommand,0 },
{ "instate", TtkWidgetInstateCommand,0 },
+ { "invoke", ButtonInvokeCommand,0 },
{ "state", TtkWidgetStateCommand,0 },
- { "identify", TtkWidgetIdentifyCommand,0 },
+ { "style", TtkWidgetStyleCommand,0 },
{ 0,0,0 }
};
-static WidgetSpec ButtonWidgetSpec =
+static const WidgetSpec ButtonWidgetSpec =
{
"TButton", /* className */
sizeof(Button), /* recordSize */
@@ -431,19 +431,19 @@ typedef struct
/*
* Option specifications:
*/
-static Tk_OptionSpec CheckbuttonOptionSpecs[] =
+static const Tk_OptionSpec CheckbuttonOptionSpecs[] =
{
{TK_OPTION_STRING, "-variable", "variable", "Variable",
- NULL, Tk_Offset(Checkbutton, checkbutton.variableObj), -1,
+ NULL, offsetof(Checkbutton, checkbutton.variableObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,0},
{TK_OPTION_STRING, "-onvalue", "onValue", "OnValue",
- "1", Tk_Offset(Checkbutton, checkbutton.onValueObj), -1,
+ "1", offsetof(Checkbutton, checkbutton.onValueObj), TCL_INDEX_NONE,
0,0,0},
{TK_OPTION_STRING, "-offvalue", "offValue", "OffValue",
- "0", Tk_Offset(Checkbutton, checkbutton.offValueObj), -1,
+ "0", offsetof(Checkbutton, checkbutton.offValueObj), TCL_INDEX_NONE,
0,0,0},
{TK_OPTION_STRING, "-command", "command", "Command",
- "", Tk_Offset(Checkbutton, checkbutton.commandObj), -1,
+ "", offsetof(Checkbutton, checkbutton.commandObj), TCL_INDEX_NONE,
0,0,0},
WIDGET_TAKEFOCUS_TRUE,
@@ -544,7 +544,7 @@ CheckbuttonPostConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
*/
static int
CheckbuttonInvokeCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Checkbutton *checkPtr = (Checkbutton *)recordPtr;
WidgetCore *corePtr = &checkPtr->core;
@@ -582,17 +582,18 @@ CheckbuttonInvokeCommand(
}
static const Ttk_Ensemble CheckbuttonCommands[] = {
- { "configure", TtkWidgetConfigureCommand,0 },
{ "cget", TtkWidgetCgetCommand,0 },
- { "invoke", CheckbuttonInvokeCommand,0 },
+ { "configure", TtkWidgetConfigureCommand,0 },
+ { "identify", TtkWidgetIdentifyCommand,0 },
{ "instate", TtkWidgetInstateCommand,0 },
+ { "invoke", CheckbuttonInvokeCommand,0 },
{ "state", TtkWidgetStateCommand,0 },
- { "identify", TtkWidgetIdentifyCommand,0 },
+ { "style", TtkWidgetStyleCommand,0 },
/* MISSING: select, deselect, toggle */
{ 0,0,0 }
};
-static WidgetSpec CheckbuttonWidgetSpec =
+static const WidgetSpec CheckbuttonWidgetSpec =
{
"TCheckbutton", /* className */
sizeof(Checkbutton), /* recordSize */
@@ -639,16 +640,16 @@ typedef struct
/*
* Option specifications:
*/
-static Tk_OptionSpec RadiobuttonOptionSpecs[] =
+static const Tk_OptionSpec RadiobuttonOptionSpecs[] =
{
{TK_OPTION_STRING, "-variable", "variable", "Variable",
- "::selectedButton", Tk_Offset(Radiobutton, radiobutton.variableObj),-1,
+ "::selectedButton", offsetof(Radiobutton, radiobutton.variableObj),TCL_INDEX_NONE,
0,0,0},
{TK_OPTION_STRING, "-value", "Value", "Value",
- "1", Tk_Offset(Radiobutton, radiobutton.valueObj), -1,
+ "1", offsetof(Radiobutton, radiobutton.valueObj), TCL_INDEX_NONE,
0,0,0},
{TK_OPTION_STRING, "-command", "command", "Command",
- "", Tk_Offset(Radiobutton, radiobutton.commandObj), -1,
+ "", offsetof(Radiobutton, radiobutton.commandObj), TCL_INDEX_NONE,
0,0,0},
WIDGET_TAKEFOCUS_TRUE,
@@ -731,7 +732,7 @@ RadiobuttonPostConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
*/
static int
RadiobuttonInvokeCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Radiobutton *radioPtr = (Radiobutton *)recordPtr;
WidgetCore *corePtr = &radioPtr->core;
@@ -758,17 +759,18 @@ RadiobuttonInvokeCommand(
}
static const Ttk_Ensemble RadiobuttonCommands[] = {
- { "configure", TtkWidgetConfigureCommand,0 },
{ "cget", TtkWidgetCgetCommand,0 },
- { "invoke", RadiobuttonInvokeCommand,0 },
+ { "configure", TtkWidgetConfigureCommand,0 },
+ { "identify", TtkWidgetIdentifyCommand,0 },
{ "instate", TtkWidgetInstateCommand,0 },
+ { "invoke", RadiobuttonInvokeCommand,0 },
{ "state", TtkWidgetStateCommand,0 },
- { "identify", TtkWidgetIdentifyCommand,0 },
+ { "style", TtkWidgetStyleCommand,0 },
/* MISSING: select, deselect */
{ 0,0,0 }
};
-static WidgetSpec RadiobuttonWidgetSpec =
+static const WidgetSpec RadiobuttonWidgetSpec =
{
"TRadiobutton", /* className */
sizeof(Radiobutton), /* recordSize */
@@ -812,14 +814,14 @@ typedef struct
* Option specifications:
*/
static const char *const directionStrings[] = {
- "above", "below", "left", "right", "flush", NULL
+ "above", "below", "flush", "left", "right", NULL
};
-static Tk_OptionSpec MenubuttonOptionSpecs[] =
+static const Tk_OptionSpec MenubuttonOptionSpecs[] =
{
{TK_OPTION_STRING, "-menu", "menu", "Menu",
- "", Tk_Offset(Menubutton, menubutton.menuObj), -1, 0,0,0},
+ "", offsetof(Menubutton, menubutton.menuObj), TCL_INDEX_NONE, 0,0,0},
{TK_OPTION_STRING_TABLE, "-direction", "direction", "Direction",
- "below", Tk_Offset(Menubutton, menubutton.directionObj), -1,
+ "below", offsetof(Menubutton, menubutton.directionObj), TCL_INDEX_NONE,
0, directionStrings, GEOMETRY_CHANGED},
WIDGET_TAKEFOCUS_TRUE,
@@ -832,10 +834,11 @@ static const Ttk_Ensemble MenubuttonCommands[] = {
{ "instate", TtkWidgetInstateCommand,0 },
{ "state", TtkWidgetStateCommand,0 },
{ "identify", TtkWidgetIdentifyCommand,0 },
+ { "style", TtkWidgetStyleCommand,0 },
{ 0,0,0 }
};
-static WidgetSpec MenubuttonWidgetSpec =
+static const WidgetSpec MenubuttonWidgetSpec =
{
"TMenubutton", /* className */
sizeof(Menubutton), /* recordSize */
diff --git a/generic/ttk/ttkCache.c b/generic/ttk/ttkCache.c
index 41593d5..2f7ff28 100644
--- a/generic/ttk/ttkCache.c
+++ b/generic/ttk/ttkCache.c
@@ -1,7 +1,7 @@
/*
* Theme engine resource cache.
*
- * Copyright (c) 2004, Joe English
+ * Copyright © 2004, Joe English
*
* The problem:
*
@@ -52,7 +52,7 @@ struct Ttk_ResourceCache_ {
*/
Ttk_ResourceCache Ttk_CreateResourceCache(Tcl_Interp *interp)
{
- Ttk_ResourceCache cache = ckalloc(sizeof(*cache));
+ Ttk_ResourceCache cache = (Ttk_ResourceCache)ckalloc(sizeof(*cache));
cache->tkwin = NULL; /* initialized later */
cache->interp = interp;
@@ -79,7 +79,7 @@ static void Ttk_ClearCache(Ttk_ResourceCache cache)
*/
entryPtr = Tcl_FirstHashEntry(&cache->fontTable, &search);
while (entryPtr != NULL) {
- Tcl_Obj *fontObj = Tcl_GetHashValue(entryPtr);
+ Tcl_Obj *fontObj = (Tcl_Obj *)Tcl_GetHashValue(entryPtr);
if (fontObj) {
Tk_FreeFontFromObj(cache->tkwin, fontObj);
Tcl_DecrRefCount(fontObj);
@@ -94,7 +94,7 @@ static void Ttk_ClearCache(Ttk_ResourceCache cache)
*/
entryPtr = Tcl_FirstHashEntry(&cache->colorTable, &search);
while (entryPtr != NULL) {
- Tcl_Obj *colorObj = Tcl_GetHashValue(entryPtr);
+ Tcl_Obj *colorObj = (Tcl_Obj *)Tcl_GetHashValue(entryPtr);
if (colorObj) {
Tk_FreeColorFromObj(cache->tkwin, colorObj);
Tcl_DecrRefCount(colorObj);
@@ -109,7 +109,7 @@ static void Ttk_ClearCache(Ttk_ResourceCache cache)
*/
entryPtr = Tcl_FirstHashEntry(&cache->borderTable, &search);
while (entryPtr != NULL) {
- Tcl_Obj *borderObj = Tcl_GetHashValue(entryPtr);
+ Tcl_Obj *borderObj = (Tcl_Obj *)Tcl_GetHashValue(entryPtr);
if (borderObj) {
Tk_Free3DBorderFromObj(cache->tkwin, borderObj);
Tcl_DecrRefCount(borderObj);
@@ -124,7 +124,7 @@ static void Ttk_ClearCache(Ttk_ResourceCache cache)
*/
entryPtr = Tcl_FirstHashEntry(&cache->imageTable, &search);
while (entryPtr != NULL) {
- Tk_Image image = Tcl_GetHashValue(entryPtr);
+ Tk_Image image = (Tk_Image)Tcl_GetHashValue(entryPtr);
if (image) {
Tk_FreeImage(image);
}
@@ -157,7 +157,7 @@ void Ttk_FreeResourceCache(Ttk_ResourceCache cache)
*/
entryPtr = Tcl_FirstHashEntry(&cache->namedColors, &search);
while (entryPtr != NULL) {
- Tcl_Obj *colorNameObj = Tcl_GetHashValue(entryPtr);
+ Tcl_Obj *colorNameObj = (Tcl_Obj *)Tcl_GetHashValue(entryPtr);
Tcl_DecrRefCount(colorNameObj);
entryPtr = Tcl_NextHashEntry(&search);
}
@@ -170,9 +170,9 @@ void Ttk_FreeResourceCache(Ttk_ResourceCache cache)
* CacheWinEventHandler --
* Detect when the cache window is destroyed, clear cache.
*/
-static void CacheWinEventHandler(ClientData clientData, XEvent *eventPtr)
+static void CacheWinEventHandler(void *clientData, XEvent *eventPtr)
{
- Ttk_ResourceCache cache = clientData;
+ Ttk_ResourceCache cache = (Ttk_ResourceCache)clientData;
if (eventPtr->type != DestroyNotify) {
return;
@@ -220,7 +220,7 @@ void Ttk_RegisterNamedColor(
entryPtr = Tcl_CreateHashEntry(&cache->namedColors, colorName, &newEntry);
if (!newEntry) {
- Tcl_Obj *oldColor = Tcl_GetHashValue(entryPtr);
+ Tcl_Obj *oldColor = (Tcl_Obj *)Tcl_GetHashValue(entryPtr);
Tcl_DecrRefCount(oldColor);
}
@@ -238,7 +238,7 @@ static Tcl_Obj *CheckNamedColor(Ttk_ResourceCache cache, Tcl_Obj *objPtr)
Tcl_HashEntry *entryPtr =
Tcl_FindHashEntry(&cache->namedColors, Tcl_GetString(objPtr));
if (entryPtr) { /* Use named color instead */
- objPtr = Tcl_GetHashValue(entryPtr);
+ objPtr = (Tcl_Obj *)Tcl_GetHashValue(entryPtr);
}
return objPtr;
}
@@ -271,7 +271,7 @@ static Tcl_Obj *Ttk_Use(
Tcl_Obj *cacheObj;
if (!newEntry) {
- return Tcl_GetHashValue(entryPtr);
+ return (Tcl_Obj *)Tcl_GetHashValue(entryPtr);
}
cacheObj = Tcl_DuplicateObj(objPtr);
@@ -328,9 +328,16 @@ Tcl_Obj *Ttk_UseBorder(
* Tk_ImageChangedProc for Ttk_UseImage
*/
-static void NullImageChanged(ClientData clientData,
- int x, int y, int width, int height, int imageWidth, int imageHeight)
-{ /* No-op */ }
+static void NullImageChanged(
+ TCL_UNUSED(void *),
+ TCL_UNUSED(int),
+ TCL_UNUSED(int),
+ TCL_UNUSED(int),
+ TCL_UNUSED(int),
+ TCL_UNUSED(int),
+ TCL_UNUSED(int))
+{ /* No-op */
+}
/*
* Ttk_UseImage --
@@ -347,7 +354,7 @@ Tk_Image Ttk_UseImage(Ttk_ResourceCache cache, Tk_Window tkwin, Tcl_Obj *objPtr)
InitCacheWindow(cache, tkwin);
if (!newEntry) {
- return Tcl_GetHashValue(entryPtr);
+ return (Tk_Image)Tcl_GetHashValue(entryPtr);
}
image = Tk_GetImage(cache->interp, tkwin, imageName, NullImageChanged,0);
diff --git a/generic/ttk/ttkClamTheme.c b/generic/ttk/ttkClamTheme.c
index 8c2b33b..d13462d 100644
--- a/generic/ttk/ttkClamTheme.c
+++ b/generic/ttk/ttkClamTheme.c
@@ -1,11 +1,11 @@
/*
- * Copyright (C) 2004 Joe English
+ * Copyright © 2004 Joe English
*
* "clam" theme; inspired by the XFCE family of Gnome themes.
*/
#include "tkInt.h"
-#include "ttkTheme.h"
+#include "ttkThemeInt.h"
/*
* Under windows, the Tk-provided XDrawLine and XDrawArc have an
@@ -106,17 +106,17 @@ typedef struct {
Tcl_Obj *borderWidthObj; /* See <<NOTE-BORDERWIDTH>> */
} BorderElement;
-static Ttk_ElementOptionSpec BorderElementOptions[] = {
+static const Ttk_ElementOptionSpec BorderElementOptions[] = {
{ "-bordercolor", TK_OPTION_COLOR,
- Tk_Offset(BorderElement,borderColorObj), DARKEST_COLOR },
+ offsetof(BorderElement,borderColorObj), DARKEST_COLOR },
{ "-lightcolor", TK_OPTION_COLOR,
- Tk_Offset(BorderElement,lightColorObj), LIGHT_COLOR },
+ offsetof(BorderElement,lightColorObj), LIGHT_COLOR },
{ "-darkcolor", TK_OPTION_COLOR,
- Tk_Offset(BorderElement,darkColorObj), DARK_COLOR },
+ offsetof(BorderElement,darkColorObj), DARK_COLOR },
{ "-relief", TK_OPTION_RELIEF,
- Tk_Offset(BorderElement,reliefObj), "flat" },
+ offsetof(BorderElement,reliefObj), "flat" },
{ "-borderwidth", TK_OPTION_PIXELS,
- Tk_Offset(BorderElement,borderWidthObj), "2" },
+ offsetof(BorderElement,borderWidthObj), "2" },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -186,7 +186,7 @@ static void BorderElementDraw(
DrawSmoothBorder(tkwin, d, b, outer, upper, lower);
}
-static Ttk_ElementSpec BorderElementSpec = {
+static const Ttk_ElementSpec BorderElementSpec = {
TK_STYLE_VERSION_2,
sizeof(BorderElement),
BorderElementOptions,
@@ -204,13 +204,13 @@ typedef struct {
Tcl_Obj *backgroundObj;
} FieldElement;
-static Ttk_ElementOptionSpec FieldElementOptions[] = {
+static const Ttk_ElementOptionSpec FieldElementOptions[] = {
{ "-bordercolor", TK_OPTION_COLOR,
- Tk_Offset(FieldElement,borderColorObj), DARKEST_COLOR },
+ offsetof(FieldElement,borderColorObj), DARKEST_COLOR },
{ "-lightcolor", TK_OPTION_COLOR,
- Tk_Offset(FieldElement,lightColorObj), LIGHT_COLOR },
+ offsetof(FieldElement,lightColorObj), LIGHT_COLOR },
{ "-fieldbackground", TK_OPTION_BORDER,
- Tk_Offset(FieldElement,backgroundObj), "white" },
+ offsetof(FieldElement,backgroundObj), "white" },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -244,7 +244,7 @@ static void FieldElementDraw(
tkwin, d, bg, f.x, f.y, f.width, f.height, 0, TK_RELIEF_SUNKEN);
}
-static Ttk_ElementSpec FieldElementSpec = {
+static const Ttk_ElementSpec FieldElementSpec = {
TK_STYLE_VERSION_2,
sizeof(FieldElement),
FieldElementOptions,
@@ -271,7 +271,7 @@ static void ComboboxFieldElementDraw(
b.x + b.width - 1, b.y + b.height - 1 + WIN32_XDRAWLINE_HACK);
}
-static Ttk_ElementSpec ComboboxFieldElementSpec = {
+static const Ttk_ElementSpec ComboboxFieldElementSpec = {
TK_STYLE_VERSION_2,
sizeof(FieldElement),
FieldElementOptions,
@@ -283,8 +283,69 @@ static Ttk_ElementSpec ComboboxFieldElementSpec = {
* +++ Indicator elements for check and radio buttons.
*/
+/*
+ * Indicator image descriptor:
+ */
+typedef struct {
+ int width; /* unscaled width */
+ int height; /* unscaled height */
+ const char *const offDataPtr;
+ const char *const onDataPtr;
+} IndicatorSpec;
+
+static const char checkbtnOffData[] = "\
+ <svg width='16' height='16' version='1.1' xmlns='http://www.w3.org/2000/svg'>\n\
+ <path d='m0 0v16h1v-15h15v-1z' fill='#9e9a91'/>\n\
+ <path d='m15 1v14h-14v1h15v-15z' fill='#cfcdc8'/>\n\
+ <rect x='1' y='1' width='14' height='14' fill='#ffffff'/>\n\
+ </svg>";
+
+static const char checkbtnOnData[] = "\
+ <svg width='16' height='16' version='1.1' xmlns='http://www.w3.org/2000/svg'>\n\
+ <path d='m0 0v16h1v-15h15v-1z' fill='#9e9a91'/>\n\
+ <path d='m15 1v14h-14v1h15v-15z' fill='#cfcdc8'/>\n\
+ <rect x='1' y='1' width='14' height='14' fill='#ffffff'/>\n\
+ <path d='m5 5 6 6m0-6-6 6' fill='none' stroke='#000000' stroke-linecap='round' stroke-width='2'/>\n\
+ </svg>";
+
+static const IndicatorSpec checkbutton_spec = {
+ 16, 16,
+ checkbtnOffData,
+ checkbtnOnData
+};
+
+static const char radiobtnOffData[] = "\
+ <svg width='16' height='16' version='1.1' xmlns='http://www.w3.org/2000/svg'>\n\
+ <defs>\n\
+ <linearGradient id='linearGradient' x1='5' y1='5' x2='11' y2='11' gradientUnits='userSpaceOnUse'>\n\
+ <stop stop-color='#9e9a91' offset='0'/>\n\
+ <stop stop-color='#cfcdc8' offset='1'/>\n\
+ </linearGradient>\n\
+ </defs>\n\
+ <circle cx='8' cy='8' r='8' fill='url(#linearGradient)'/>\n\
+ <circle cx='8' cy='8' r='7' fill='#ffffff'/>\n\
+ </svg>";
+
+static const char radiobtnOnData[] = "\
+ <svg width='16' height='16' version='1.1' xmlns='http://www.w3.org/2000/svg'>\n\
+ <defs>\n\
+ <linearGradient id='linearGradient' x1='5' y1='5' x2='11' y2='11' gradientUnits='userSpaceOnUse'>\n\
+ <stop stop-color='#9e9a91' offset='0'/>\n\
+ <stop stop-color='#cfcdc8' offset='1'/>\n\
+ </linearGradient>\n\
+ </defs>\n\
+ <circle cx='8' cy='8' r='8' fill='url(#linearGradient)'/>\n\
+ <circle cx='8' cy='8' r='7' fill='#ffffff'/>\n\
+ <circle cx='8' cy='8' r='4' fill='#000000'/>\n\
+ </svg>";
+
+static const IndicatorSpec radiobutton_spec = {
+ 16, 16,
+ radiobtnOffData,
+ radiobtnOnData
+};
+
typedef struct {
- Tcl_Obj *sizeObj;
Tcl_Obj *marginObj;
Tcl_Obj *backgroundObj;
Tcl_Obj *foregroundObj;
@@ -292,185 +353,191 @@ typedef struct {
Tcl_Obj *lowerColorObj;
} IndicatorElement;
-static Ttk_ElementOptionSpec IndicatorElementOptions[] = {
- { "-indicatorsize", TK_OPTION_PIXELS,
- Tk_Offset(IndicatorElement,sizeObj), "10" },
+static const Ttk_ElementOptionSpec IndicatorElementOptions[] = {
{ "-indicatormargin", TK_OPTION_STRING,
- Tk_Offset(IndicatorElement,marginObj), "1" },
+ offsetof(IndicatorElement,marginObj), "1" },
{ "-indicatorbackground", TK_OPTION_COLOR,
- Tk_Offset(IndicatorElement,backgroundObj), "white" },
+ offsetof(IndicatorElement,backgroundObj), "white" },
{ "-indicatorforeground", TK_OPTION_COLOR,
- Tk_Offset(IndicatorElement,foregroundObj), "black" },
+ offsetof(IndicatorElement,foregroundObj), "black" },
{ "-upperbordercolor", TK_OPTION_COLOR,
- Tk_Offset(IndicatorElement,upperColorObj), DARKEST_COLOR },
+ offsetof(IndicatorElement,upperColorObj), DARKEST_COLOR },
{ "-lowerbordercolor", TK_OPTION_COLOR,
- Tk_Offset(IndicatorElement,lowerColorObj), DARK_COLOR },
+ offsetof(IndicatorElement,lowerColorObj), DARK_COLOR },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void IndicatorElementSize(
- TCL_UNUSED(void *), void *elementRecord, Tk_Window tkwin,
+ void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr,
TCL_UNUSED(Ttk_Padding *))
{
+ const IndicatorSpec *spec = (const IndicatorSpec *)clientData;
IndicatorElement *indicator = (IndicatorElement *)elementRecord;
Ttk_Padding margins;
- int size = 10;
+ double scalingLevel = TkScalingLevel(tkwin);
Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &margins);
- Tk_GetPixelsFromObj(NULL, tkwin, indicator->sizeObj, &size);
- *widthPtr = size + Ttk_PaddingWidth(margins);
- *heightPtr = size + Ttk_PaddingHeight(margins);
+ *widthPtr = spec->width * scalingLevel + Ttk_PaddingWidth(margins);
+ *heightPtr = spec->height * scalingLevel + Ttk_PaddingHeight(margins);
}
-static void RadioIndicatorElementDraw(
- TCL_UNUSED(void *), void *elementRecord, Tk_Window tkwin,
- Drawable d, Ttk_Box b, unsigned state)
+static void ColorToStr(
+ const XColor *colorPtr, char *colorStr) /* in the format "RRGGBB" */
{
- IndicatorElement *indicator = (IndicatorElement *)elementRecord;
- GC gcb=Ttk_GCForColor(tkwin,indicator->backgroundObj,d);
- GC gcf=Ttk_GCForColor(tkwin,indicator->foregroundObj,d);
- GC gcu=Ttk_GCForColor(tkwin,indicator->upperColorObj,d);
- GC gcl=Ttk_GCForColor(tkwin,indicator->lowerColorObj,d);
- Ttk_Padding padding;
-
- Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &padding);
- b = Ttk_PadBox(b, padding);
-
- XFillArc(Tk_Display(tkwin),d,gcb, b.x,b.y,b.width,b.height, 0,360*64);
- XDrawArc(Tk_Display(tkwin),d,gcl, b.x,b.y,b.width,b.height, 225*64,180*64);
- XDrawArc(Tk_Display(tkwin),d,gcu, b.x,b.y,b.width,b.height, 45*64,180*64);
+ snprintf(colorStr, 7, "%02x%02x%02x",
+ colorPtr->red >> 8, colorPtr->green >> 8, colorPtr->blue >> 8);
+}
- if (state & TTK_STATE_SELECTED) {
- b = Ttk_PadBox(b,Ttk_UniformPadding(3));
- XFillArc(Tk_Display(tkwin),d,gcf, b.x,b.y,b.width,b.height, 0,360*64);
- XDrawArc(Tk_Display(tkwin),d,gcf, b.x,b.y,b.width,b.height, 0,360*64);
-#if WIN32_XDRAWLINE_HACK
- XDrawArc(Tk_Display(tkwin),d,gcf, b.x,b.y,b.width,b.height, 300*64,360*64);
-#endif
- }
+static void ImageChanged( /* to be passed to Tk_GetImage() */
+ TCL_UNUSED(void *),
+ TCL_UNUSED(int),
+ TCL_UNUSED(int),
+ TCL_UNUSED(int),
+ TCL_UNUSED(int),
+ TCL_UNUSED(int),
+ TCL_UNUSED(int))
+{
}
-static void CheckIndicatorElementDraw(
- TCL_UNUSED(void *), void *elementRecord, Tk_Window tkwin,
+static void IndicatorElementDraw(
+ void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, Ttk_State state)
{
- Display *display = Tk_Display(tkwin);
IndicatorElement *indicator = (IndicatorElement *)elementRecord;
-
- GC gcb=Ttk_GCForColor(tkwin,indicator->backgroundObj,d);
- GC gcf=Ttk_GCForColor(tkwin,indicator->foregroundObj,d);
- GC gcu=Ttk_GCForColor(tkwin,indicator->upperColorObj,d);
- GC gcl=Ttk_GCForColor(tkwin,indicator->lowerColorObj,d);
Ttk_Padding padding;
- const int w = WIN32_XDRAWLINE_HACK;
+ const IndicatorSpec *spec = (const IndicatorSpec *)clientData;
+ double scalingLevel = TkScalingLevel(tkwin);
+ int width = spec->width * scalingLevel;
+ int height = spec->height * scalingLevel;
+
+ char upperBdColorStr[7], lowerBdColorStr[7], bgColorStr[7], fgColorStr[7];
+ unsigned int selected = (state & TTK_STATE_SELECTED);
+ Tcl_Interp *interp = Tk_Interp(tkwin);
+ char imgName[60];
+ Tk_Image img;
+
+ const char *svgDataPtr;
+ size_t svgDataLen;
+ char *svgDataCopy;
+ char *upperBdColorPtr, *lowerBdColorPtr, *bgColorPtr, *fgColorPtr;
+ const char *cmdFmt;
+ size_t scriptSize;
+ char *script;
+ int code;
Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &padding);
b = Ttk_PadBox(b, padding);
- XFillRectangle(display,d,gcb, b.x,b.y,b.width,b.height);
- XDrawLine(display,d,gcl,b.x,b.y+b.height,b.x+b.width+w,b.y+b.height);/*S*/
- XDrawLine(display,d,gcl,b.x+b.width,b.y,b.x+b.width,b.y+b.height+w); /*E*/
- XDrawLine(display,d,gcu,b.x,b.y, b.x,b.y+b.height+w); /*W*/
- XDrawLine(display,d,gcu,b.x,b.y, b.x+b.width+w,b.y); /*N*/
-
- if (state & TTK_STATE_SELECTED) {
- int p,q,r,s;
+ /*
+ * Sanity check
+ */
+ if ( b.x < 0
+ || b.y < 0
+ || Tk_Width(tkwin) < b.x + width
+ || Tk_Height(tkwin) < b.y + height)
+ {
+ /* Oops! Not enough room to display the image.
+ * Don't draw anything.
+ */
+ return;
+ }
- b = Ttk_PadBox(b,Ttk_UniformPadding(2));
- p = b.x, q = b.y, r = b.x+b.width, s = b.y+b.height;
+ /*
+ * Construct the color strings upperBdColorStr, lowerBdColorStr,
+ * bgColorStr, and fgColorStr
+ */
+ ColorToStr(Tk_GetColorFromObj(tkwin, indicator->upperColorObj),
+ upperBdColorStr);
+ ColorToStr(Tk_GetColorFromObj(tkwin, indicator->lowerColorObj),
+ lowerBdColorStr);
+ ColorToStr(Tk_GetColorFromObj(tkwin, indicator->backgroundObj),
+ bgColorStr);
+ ColorToStr(Tk_GetColorFromObj(tkwin, indicator->foregroundObj),
+ fgColorStr);
- r+=w, s+=w;
- XDrawLine(display, d, gcf, p, q, r, s);
- XDrawLine(display, d, gcf, p+1, q, r, s-1);
- XDrawLine(display, d, gcf, p, q+1, r-1, s);
+ /*
+ * Check whether there is an SVG image of this size for the indicator's
+ * type (0 = checkbtn, 1 = radiobtn) and these color strings
+ */
+ snprintf(imgName, sizeof(imgName),
+ "::tk::icons::indicator_clam%d_%d_%s_%s_%s_%s",
+ width, spec->offDataPtr == radiobtnOffData,
+ upperBdColorStr, lowerBdColorStr, bgColorStr,
+ selected ? fgColorStr : "XXXXXX");
+ img = Tk_GetImage(interp, tkwin, imgName, ImageChanged, NULL);
+ if (img == NULL) {
+ /*
+ * Determine the SVG data to use for the photo image
+ */
+ svgDataPtr = (selected ? spec->onDataPtr : spec->offDataPtr);
+
+ /*
+ * Copy the string pointed to by svgDataPtr to
+ * a newly allocated memory area svgDataCopy
+ */
+ svgDataLen = strlen(svgDataPtr);
+ svgDataCopy = (char *)attemptckalloc(svgDataLen + 1);
+ if (svgDataCopy == NULL) {
+ return;
+ }
+ memcpy(svgDataCopy, svgDataPtr, svgDataLen);
+ svgDataCopy[svgDataLen] = '\0';
+
+ /*
+ * Update the colors within svgDataCopy
+ */
+
+ upperBdColorPtr = strstr(svgDataCopy, "9e9a91");
+ lowerBdColorPtr = strstr(svgDataCopy, "cfcdc8");
+ bgColorPtr = strstr(svgDataCopy, "ffffff");
+ fgColorPtr = strstr(svgDataCopy, "000000");
+
+ assert(upperBdColorPtr);
+ assert(lowerBdColorPtr);
+ assert(bgColorPtr);
+
+ memcpy(upperBdColorPtr, upperBdColorStr, 6);
+ memcpy(lowerBdColorPtr, lowerBdColorStr, 6);
+ memcpy(bgColorPtr, bgColorStr, 6);
+ if (fgColorPtr != NULL) {
+ memcpy(fgColorPtr, fgColorStr, 6);
+ }
- s-=w, q-=w;
- XDrawLine(display, d, gcf, p, s, r, q);
- XDrawLine(display, d, gcf, p+1, s, r, q+1);
- XDrawLine(display, d, gcf, p, s-1, r-1, q);
+ /*
+ * Create an SVG photo image from svgDataCopy
+ */
+ cmdFmt = "image create photo %s -format $::tk::svgFmt -data {%s}";
+ scriptSize = strlen(cmdFmt) + strlen(imgName) + svgDataLen;
+ script = (char *)attemptckalloc(scriptSize);
+ if (script == NULL) {
+ ckfree(svgDataCopy);
+ return;
+ }
+ snprintf(script, scriptSize, cmdFmt, imgName, svgDataCopy);
+ ckfree(svgDataCopy);
+ code = Tcl_EvalEx(interp, script, -1, TCL_EVAL_GLOBAL);
+ ckfree(script);
+ if (code != TCL_OK) {
+ Tcl_BackgroundException(interp, code);
+ return;
+ }
+ img = Tk_GetImage(interp, tkwin, imgName, ImageChanged, NULL);
}
-}
-static Ttk_ElementSpec RadioIndicatorElementSpec = {
- TK_STYLE_VERSION_2,
- sizeof(IndicatorElement),
- IndicatorElementOptions,
- IndicatorElementSize,
- RadioIndicatorElementDraw
-};
+ /*
+ * Display the image
+ */
+ Tk_RedrawImage(img, 0, 0, width, height, d, b.x, b.y);
+ Tk_FreeImage(img);
+}
-static Ttk_ElementSpec CheckIndicatorElementSpec = {
+static const Ttk_ElementSpec IndicatorElementSpec = {
TK_STYLE_VERSION_2,
sizeof(IndicatorElement),
IndicatorElementOptions,
IndicatorElementSize,
- CheckIndicatorElementDraw
-};
-
-#define MENUBUTTON_ARROW_SIZE 5
-
-typedef struct {
- Tcl_Obj *sizeObj;
- Tcl_Obj *colorObj;
- Tcl_Obj *paddingObj;
-} MenuIndicatorElement;
-
-static Ttk_ElementOptionSpec MenuIndicatorElementOptions[] =
-{
- { "-arrowsize", TK_OPTION_PIXELS,
- Tk_Offset(MenuIndicatorElement,sizeObj),
- STR(MENUBUTTON_ARROW_SIZE)},
- { "-arrowcolor",TK_OPTION_COLOR,
- Tk_Offset(MenuIndicatorElement,colorObj),
- "black" },
- { "-arrowpadding",TK_OPTION_STRING,
- Tk_Offset(MenuIndicatorElement,paddingObj),
- "3" },
- { NULL, TK_OPTION_BOOLEAN, 0, NULL }
-};
-
-static void MenuIndicatorElementSize(
- TCL_UNUSED(void *), void *elementRecord, Tk_Window tkwin,
- int *widthPtr, int *heightPtr,
- TCL_UNUSED(Ttk_Padding *))
-{
- MenuIndicatorElement *indicator = (MenuIndicatorElement *)elementRecord;
- Ttk_Padding margins;
- int size = MENUBUTTON_ARROW_SIZE;
-
- Tk_GetPixelsFromObj(NULL, tkwin, indicator->sizeObj, &size);
- Ttk_GetPaddingFromObj(NULL, tkwin, indicator->paddingObj, &margins);
- TtkArrowSize(size, ARROW_DOWN, widthPtr, heightPtr);
- *widthPtr += Ttk_PaddingWidth(margins);
- *heightPtr += Ttk_PaddingHeight(margins);
-}
-
-static void MenuIndicatorElementDraw(
- TCL_UNUSED(void *), void *elementRecord, Tk_Window tkwin,
- Drawable d, Ttk_Box b,
- TCL_UNUSED(Ttk_State))
-{
- MenuIndicatorElement *indicator = (MenuIndicatorElement *)elementRecord;
- XColor *arrowColor = Tk_GetColorFromObj(tkwin, indicator->colorObj);
- GC gc = Tk_GCForColor(arrowColor, d);
- int size = MENUBUTTON_ARROW_SIZE;
- int width, height;
-
- Tk_GetPixelsFromObj(NULL, tkwin, indicator->sizeObj, &size);
-
- TtkArrowSize(size, ARROW_DOWN, &width, &height);
- b = Ttk_StickBox(b, width, height, 0);
- TtkFillArrow(Tk_Display(tkwin), d, gc, b, ARROW_DOWN);
-}
-
-static Ttk_ElementSpec MenuIndicatorElementSpec =
-{
- TK_STYLE_VERSION_2,
- sizeof(MenuIndicatorElement),
- MenuIndicatorElementOptions,
- MenuIndicatorElementSize,
- MenuIndicatorElementDraw
+ IndicatorElementDraw
};
/*------------------------------------------------------------------------
@@ -479,23 +546,19 @@ static Ttk_ElementSpec MenuIndicatorElementSpec =
* TODO: factor this with ThumbElementDraw
*/
-static Ttk_Orient GripClientData[] = {
- TTK_ORIENT_HORIZONTAL, TTK_ORIENT_VERTICAL
-};
-
typedef struct {
Tcl_Obj *lightColorObj;
Tcl_Obj *borderColorObj;
Tcl_Obj *gripCountObj;
} GripElement;
-static Ttk_ElementOptionSpec GripElementOptions[] = {
+static const Ttk_ElementOptionSpec GripElementOptions[] = {
{ "-lightcolor", TK_OPTION_COLOR,
- Tk_Offset(GripElement,lightColorObj), LIGHT_COLOR },
+ offsetof(GripElement,lightColorObj), LIGHT_COLOR },
{ "-bordercolor", TK_OPTION_COLOR,
- Tk_Offset(GripElement,borderColorObj), DARKEST_COLOR },
+ offsetof(GripElement,borderColorObj), DARKEST_COLOR },
{ "-gripcount", TK_OPTION_PIXELS,
- Tk_Offset(GripElement,gripCountObj), "5" },
+ offsetof(GripElement,gripCountObj), "5" },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -504,15 +567,16 @@ static void GripElementSize(
int *widthPtr, int *heightPtr,
TCL_UNUSED(Ttk_Padding *))
{
- int horizontal = *((Ttk_Orient*)clientData) == TTK_ORIENT_HORIZONTAL;
+ Ttk_Orient orient = (Ttk_Orient)PTR2INT(clientData);
GripElement *grip = (GripElement *)elementRecord;
- int gripCount = 0;
+ int gripSize = 0;
- Tk_GetPixelsFromObj(NULL, tkwin, grip->gripCountObj, &gripCount);
- if (horizontal) {
- *widthPtr = 2*gripCount;
+ Tk_GetPixelsFromObj(NULL, tkwin, grip->gripCountObj, &gripSize);
+ gripSize *= 2;
+ if (orient == TTK_ORIENT_HORIZONTAL) {
+ *widthPtr = gripSize;
} else {
- *heightPtr = 2*gripCount;
+ *heightPtr = gripSize;
}
}
@@ -522,33 +586,34 @@ static void GripElementDraw(
TCL_UNUSED(Ttk_State))
{
const int w = WIN32_XDRAWLINE_HACK;
- int horizontal = *((Ttk_Orient*)clientData) == TTK_ORIENT_HORIZONTAL;
+ Ttk_Orient orient = (Ttk_Orient)PTR2INT(clientData);
GripElement *grip = (GripElement *)elementRecord;
GC lightGC = Ttk_GCForColor(tkwin,grip->lightColorObj,d);
GC darkGC = Ttk_GCForColor(tkwin,grip->borderColorObj,d);
- int gripPad = 1, gripCount = 0;
+ int gripPad = 1, gripSize = 0;
int i;
- Tk_GetPixelsFromObj(NULL, tkwin, grip->gripCountObj, &gripCount);
+ Tk_GetPixelsFromObj(NULL, tkwin, grip->gripCountObj, &gripSize);
+ gripSize *= 2;
- if (horizontal) {
- int x = b.x + b.width / 2 - gripCount;
+ if (orient == TTK_ORIENT_HORIZONTAL) {
+ int x = b.x + (b.width - gripSize) / 2;
int y1 = b.y + gripPad, y2 = b.y + b.height - gripPad - 1 + w;
- for (i=0; i<gripCount; ++i) {
- XDrawLine(Tk_Display(tkwin), d, darkGC, x,y1, x,y2); ++x;
- XDrawLine(Tk_Display(tkwin), d, lightGC, x,y1, x,y2); ++x;
+ for (i=0; i<gripSize; ++i) {
+ XDrawLine(Tk_Display(tkwin), d, (i&1)?lightGC:darkGC, x,y1, x,y2);
+ ++x;
}
} else {
- int y = b.y + b.height / 2 - gripCount;
+ int y = b.y + (b.height - gripSize) / 2;
int x1 = b.x + gripPad, x2 = b.x + b.width - gripPad - 1 + w;
- for (i=0; i<gripCount; ++i) {
- XDrawLine(Tk_Display(tkwin), d, darkGC, x1,y, x2,y); ++y;
- XDrawLine(Tk_Display(tkwin), d, lightGC, x1,y, x2,y); ++y;
+ for (i=0; i<gripSize; ++i) {
+ XDrawLine(Tk_Display(tkwin), d, (i&1)?lightGC:darkGC, x1,y, x2,y);
+ ++y;
}
}
}
-static Ttk_ElementSpec GripElementSpec = {
+static const Ttk_ElementSpec GripElementSpec = {
TK_STYLE_VERSION_2,
sizeof(GripElement),
GripElementOptions,
@@ -576,27 +641,27 @@ typedef struct { /* Common element record for scrollbar elements */
Tcl_Obj *sliderlengthObj;
} ScrollbarElement;
-static Ttk_ElementOptionSpec ScrollbarElementOptions[] = {
+static const Ttk_ElementOptionSpec ScrollbarElementOptions[] = {
{ "-orient", TK_OPTION_ANY,
- Tk_Offset(ScrollbarElement, orientObj), "horizontal" },
+ offsetof(ScrollbarElement, orientObj), "horizontal" },
{ "-background", TK_OPTION_BORDER,
- Tk_Offset(ScrollbarElement,backgroundObj), FRAME_COLOR },
+ offsetof(ScrollbarElement,backgroundObj), FRAME_COLOR },
{ "-bordercolor", TK_OPTION_COLOR,
- Tk_Offset(ScrollbarElement,borderColorObj), DARKEST_COLOR },
+ offsetof(ScrollbarElement,borderColorObj), DARKEST_COLOR },
{ "-troughcolor", TK_OPTION_COLOR,
- Tk_Offset(ScrollbarElement,troughColorObj), DARKER_COLOR },
+ offsetof(ScrollbarElement,troughColorObj), DARKER_COLOR },
{ "-lightcolor", TK_OPTION_COLOR,
- Tk_Offset(ScrollbarElement,lightColorObj), LIGHT_COLOR },
+ offsetof(ScrollbarElement,lightColorObj), LIGHT_COLOR },
{ "-darkcolor", TK_OPTION_COLOR,
- Tk_Offset(ScrollbarElement,darkColorObj), DARK_COLOR },
+ offsetof(ScrollbarElement,darkColorObj), DARK_COLOR },
{ "-arrowcolor", TK_OPTION_COLOR,
- Tk_Offset(ScrollbarElement,arrowColorObj), "#000000" },
+ offsetof(ScrollbarElement,arrowColorObj), "#000000" },
{ "-arrowsize", TK_OPTION_PIXELS,
- Tk_Offset(ScrollbarElement,arrowSizeObj), STR(SCROLLBAR_THICKNESS) },
+ offsetof(ScrollbarElement,arrowSizeObj), STR(SCROLLBAR_THICKNESS) },
{ "-gripcount", TK_OPTION_PIXELS,
- Tk_Offset(ScrollbarElement,gripCountObj), "5" },
+ offsetof(ScrollbarElement,gripCountObj), "5" },
{ "-sliderlength", TK_OPTION_PIXELS,
- Tk_Offset(ScrollbarElement,sliderlengthObj), "30" },
+ offsetof(ScrollbarElement,sliderlengthObj), "30" },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -616,7 +681,7 @@ static void TroughElementDraw(
XDrawRectangle(Tk_Display(tkwin), d, gcb, b.x, b.y, b.width-1, b.height-1);
}
-static Ttk_ElementSpec TroughElementSpec = {
+static const Ttk_ElementSpec TroughElementSpec = {
TK_STYLE_VERSION_2,
sizeof(ScrollbarElement),
ScrollbarElementOptions,
@@ -648,8 +713,8 @@ static void ThumbElementDraw(
TCL_UNUSED(Ttk_State))
{
ScrollbarElement *sb = (ScrollbarElement *)elementRecord;
- int gripCount = 0;
- int orient = TTK_ORIENT_HORIZONTAL;
+ int gripSize = 0;
+ Ttk_Orient orient = TTK_ORIENT_HORIZONTAL;
GC lightGC, darkGC;
int x1, y1, x2, y2, dx, dy, i;
const int w = WIN32_XDRAWLINE_HACK;
@@ -663,32 +728,32 @@ static void ThumbElementDraw(
/*
* Draw grip:
*/
- Ttk_GetOrientFromObj(NULL, sb->orientObj, &orient);
- Tk_GetPixelsFromObj(NULL, tkwin, sb->gripCountObj, &gripCount);
+ TtkGetOrientFromObj(NULL, sb->orientObj, &orient);
+ Tk_GetPixelsFromObj(NULL, tkwin, sb->gripCountObj, &gripSize);
+ gripSize *= 2;
lightGC = Ttk_GCForColor(tkwin,sb->lightColorObj,d);
darkGC = Ttk_GCForColor(tkwin,sb->borderColorObj,d);
if (orient == TTK_ORIENT_HORIZONTAL) {
dx = 1; dy = 0;
- x1 = x2 = b.x + b.width / 2 - gripCount;
+ x1 = x2 = b.x + (b.width - gripSize) / 2;
y1 = b.y + 2;
y2 = b.y + b.height - 3 + w;
} else {
dx = 0; dy = 1;
- y1 = y2 = b.y + b.height / 2 - gripCount;
+ y1 = y2 = b.y + (b.height - gripSize) / 2;
x1 = b.x + 2;
x2 = b.x + b.width - 3 + w;
}
- for (i=0; i<gripCount; ++i) {
- XDrawLine(Tk_Display(tkwin), d, darkGC, x1,y1, x2,y2);
- x1 += dx; x2 += dx; y1 += dy; y2 += dy;
- XDrawLine(Tk_Display(tkwin), d, lightGC, x1,y1, x2,y2);
+ for (i=0; i<gripSize; ++i) {
+ XDrawLine(Tk_Display(tkwin), d, (i&1)?lightGC:darkGC, x1,y1, x2,y2);
x1 += dx; x2 += dx; y1 += dy; y2 += dy;
+
}
}
-static Ttk_ElementSpec ThumbElementSpec = {
+static const Ttk_ElementSpec ThumbElementSpec = {
TK_STYLE_VERSION_2,
sizeof(ScrollbarElement),
ScrollbarElementOptions,
@@ -709,10 +774,10 @@ static void SliderElementSize(
{
ScrollbarElement *sb = (ScrollbarElement *)elementRecord;
int length, thickness;
- int orient;
+ Ttk_Orient orient;
length = thickness = SCROLLBAR_THICKNESS;
- Ttk_GetOrientFromObj(NULL, sb->orientObj, &orient);
+ TtkGetOrientFromObj(NULL, sb->orientObj, &orient);
Tk_GetPixelsFromObj(NULL, tkwin, sb->arrowSizeObj, &thickness);
Tk_GetPixelsFromObj(NULL, tkwin, sb->sliderlengthObj, &length);
if (orient == TTK_ORIENT_VERTICAL) {
@@ -724,7 +789,7 @@ static void SliderElementSize(
}
}
-static Ttk_ElementSpec SliderElementSpec = {
+static const Ttk_ElementSpec SliderElementSpec = {
TK_STYLE_VERSION_2,
sizeof(ScrollbarElement),
ScrollbarElementOptions,
@@ -766,7 +831,7 @@ static void PbarElementDraw(
}
}
-static Ttk_ElementSpec PbarElementSpec = {
+static const Ttk_ElementSpec PbarElementSpec = {
TK_STYLE_VERSION_2,
sizeof(ScrollbarElement),
ScrollbarElementOptions,
@@ -777,16 +842,15 @@ static Ttk_ElementSpec PbarElementSpec = {
/*------------------------------------------------------------------------
* +++ Scrollbar arrows.
*/
-static int ArrowElements[] = { ARROW_UP, ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT };
-
static void ArrowElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr,
TCL_UNUSED(Ttk_Padding *))
{
ScrollbarElement *sb = (ScrollbarElement *)elementRecord;
- ArrowDirection direction = *(ArrowDirection*)clientData;
- Ttk_Padding padding = Ttk_UniformPadding(3);
+ ArrowDirection direction = (ArrowDirection)PTR2INT(clientData);
+ double scalingLevel = TkScalingLevel(tkwin);
+ Ttk_Padding padding = Ttk_UniformPadding(round(3 * scalingLevel));
int size = SCROLLBAR_THICKNESS;
Tk_GetPixelsFromObj(NULL, tkwin, sb->arrowSizeObj, &size);
@@ -807,8 +871,9 @@ static void ArrowElementDraw(
TCL_UNUSED(Ttk_State))
{
ScrollbarElement *sb = (ScrollbarElement *)elementRecord;
- ArrowDirection direction = *(ArrowDirection*)clientData;
- Ttk_Padding padding = Ttk_UniformPadding(3);
+ ArrowDirection direction = (ArrowDirection)PTR2INT(clientData);
+ double scalingLevel = TkScalingLevel(tkwin);
+ Ttk_Padding padding = Ttk_UniformPadding(round(3 * scalingLevel));
int cx, cy;
GC gc = Ttk_GCForColor(tkwin, sb->arrowColorObj, d);
@@ -843,7 +908,7 @@ static void ArrowElementDraw(
TtkFillArrow(Tk_Display(tkwin), d, gc, b, direction);
}
-static Ttk_ElementSpec ArrowElementSpec = {
+static const Ttk_ElementSpec ArrowElementSpec = {
TK_STYLE_VERSION_2,
sizeof(ScrollbarElement),
ScrollbarElementOptions,
@@ -861,8 +926,9 @@ static void SpinboxArrowElementSize(
TCL_UNUSED(Ttk_Padding *))
{
ScrollbarElement *sb = (ScrollbarElement *)elementRecord;
- ArrowDirection direction = *(ArrowDirection*)clientData;
- Ttk_Padding padding = Ttk_UniformPadding(3);
+ ArrowDirection direction = (ArrowDirection)PTR2INT(clientData);
+ double scalingLevel = TkScalingLevel(tkwin);
+ Ttk_Padding padding = Ttk_UniformPadding(round(3 * scalingLevel));
int size = 10;
Tk_GetPixelsFromObj(NULL, tkwin, sb->arrowSizeObj, &size);
@@ -872,7 +938,7 @@ static void SpinboxArrowElementSize(
*heightPtr += Ttk_PaddingHeight(padding);
}
-static Ttk_ElementSpec SpinboxArrowElementSpec = {
+static const Ttk_ElementSpec SpinboxArrowElementSpec = {
TK_STYLE_VERSION_2,
sizeof(ScrollbarElement),
ScrollbarElementOptions,
@@ -894,15 +960,15 @@ typedef struct {
Tcl_Obj *darkColorObj;
} NotebookElement;
-static Ttk_ElementOptionSpec NotebookElementOptions[] = {
+static const Ttk_ElementOptionSpec NotebookElementOptions[] = {
{ "-background", TK_OPTION_BORDER,
- Tk_Offset(NotebookElement,backgroundObj), FRAME_COLOR },
+ offsetof(NotebookElement,backgroundObj), FRAME_COLOR },
{ "-bordercolor", TK_OPTION_COLOR,
- Tk_Offset(NotebookElement,borderColorObj), DARKEST_COLOR },
+ offsetof(NotebookElement,borderColorObj), DARKEST_COLOR },
{ "-lightcolor", TK_OPTION_COLOR,
- Tk_Offset(NotebookElement,lightColorObj), LIGHT_COLOR },
+ offsetof(NotebookElement,lightColorObj), LIGHT_COLOR },
{ "-darkcolor", TK_OPTION_COLOR,
- Tk_Offset(NotebookElement,darkColorObj), DARK_COLOR },
+ offsetof(NotebookElement,darkColorObj), DARK_COLOR },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -969,7 +1035,7 @@ static void TabElementDraw(
switch (nbTabsStickBit) {
default:
case TTK_STICK_S:
- if (state & TTK_STATE_USER2) { /* rightmost tab */
+ if (state & TTK_STATE_LAST) { /* rightmost tab */
--b.width;
}
@@ -991,7 +1057,7 @@ static void TabElementDraw(
break;
case TTK_STICK_N:
- if (state & TTK_STATE_USER2) { /* rightmost tab */
+ if (state & TTK_STATE_LAST) { /* rightmost tab */
--b.width;
}
@@ -1013,7 +1079,7 @@ static void TabElementDraw(
break;
case TTK_STICK_E:
- if (state & TTK_STATE_USER2) { /* bottommost tab */
+ if (state & TTK_STATE_LAST) { /* bottommost tab */
--b.height;
}
@@ -1035,7 +1101,7 @@ static void TabElementDraw(
break;
case TTK_STICK_W:
- if (state & TTK_STATE_USER2) { /* bottommost tab */
+ if (state & TTK_STATE_LAST) { /* bottommost tab */
--b.height;
}
@@ -1058,7 +1124,7 @@ static void TabElementDraw(
}
}
-static Ttk_ElementSpec TabElementSpec =
+static const Ttk_ElementSpec TabElementSpec =
{
TK_STYLE_VERSION_2,
sizeof(NotebookElement),
@@ -1098,7 +1164,7 @@ static void ClientElementDraw(
ce->borderColorObj, ce->lightColorObj, ce->darkColorObj);
}
-static Ttk_ElementSpec ClientElementSpec =
+static const Ttk_ElementSpec ClientElementSpec =
{
TK_STYLE_VERSION_2,
sizeof(NotebookElement),
@@ -1153,26 +1219,24 @@ TtkClamTheme_Init(Tcl_Interp *interp)
Ttk_RegisterElement(interp, theme, "thumb",
&ThumbElementSpec, NULL);
Ttk_RegisterElement(interp, theme, "uparrow",
- &ArrowElementSpec, &ArrowElements[0]);
+ &ArrowElementSpec, INT2PTR(ARROW_UP));
Ttk_RegisterElement(interp, theme, "Spinbox.uparrow",
- &SpinboxArrowElementSpec, &ArrowElements[0]);
+ &SpinboxArrowElementSpec, INT2PTR(ARROW_UP));
Ttk_RegisterElement(interp, theme, "downarrow",
- &ArrowElementSpec, &ArrowElements[1]);
+ &ArrowElementSpec, INT2PTR(ARROW_DOWN));
Ttk_RegisterElement(interp, theme, "Spinbox.downarrow",
- &SpinboxArrowElementSpec, &ArrowElements[1]);
+ &SpinboxArrowElementSpec, INT2PTR(ARROW_DOWN));
Ttk_RegisterElement(interp, theme, "leftarrow",
- &ArrowElementSpec, &ArrowElements[2]);
+ &ArrowElementSpec, INT2PTR(ARROW_LEFT));
Ttk_RegisterElement(interp, theme, "rightarrow",
- &ArrowElementSpec, &ArrowElements[3]);
+ &ArrowElementSpec, INT2PTR(ARROW_RIGHT));
Ttk_RegisterElement(interp, theme, "arrow",
- &ArrowElementSpec, &ArrowElements[0]);
+ &ArrowElementSpec, INT2PTR(ARROW_UP));
Ttk_RegisterElement(interp, theme, "Checkbutton.indicator",
- &CheckIndicatorElementSpec, NULL);
+ &IndicatorElementSpec, (void *)&checkbutton_spec);
Ttk_RegisterElement(interp, theme, "Radiobutton.indicator",
- &RadioIndicatorElementSpec, NULL);
- Ttk_RegisterElement(interp, theme, "Menubutton.indicator",
- &MenuIndicatorElementSpec, NULL);
+ &IndicatorElementSpec, (void *)&radiobutton_spec);
Ttk_RegisterElement(interp, theme, "tab", &TabElementSpec, NULL);
Ttk_RegisterElement(interp, theme, "client", &ClientElementSpec, NULL);
@@ -1182,9 +1246,9 @@ TtkClamTheme_Init(Tcl_Interp *interp)
Ttk_RegisterElement(interp, theme, "pbar", &PbarElementSpec, NULL);
Ttk_RegisterElement(interp, theme, "hgrip",
- &GripElementSpec, &GripClientData[0]);
+ &GripElementSpec, INT2PTR(TTK_ORIENT_HORIZONTAL));
Ttk_RegisterElement(interp, theme, "vgrip",
- &GripElementSpec, &GripClientData[1]);
+ &GripElementSpec, INT2PTR(TTK_ORIENT_VERTICAL));
Ttk_RegisterLayouts(theme, LayoutTable);
diff --git a/generic/ttk/ttkClassicTheme.c b/generic/ttk/ttkClassicTheme.c
index 7a53930..c129b0f 100644
--- a/generic/ttk/ttkClassicTheme.c
+++ b/generic/ttk/ttkClassicTheme.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, Joe English
+ * Copyright © 2004, Joe English
*
* "classic" theme; implements the classic Motif-like Tk look.
*
@@ -22,13 +22,13 @@ typedef struct {
Tcl_Obj *defaultStateObj;
} HighlightElement;
-static Ttk_ElementOptionSpec HighlightElementOptions[] = {
+static const Ttk_ElementOptionSpec HighlightElementOptions[] = {
{ "-highlightcolor",TK_OPTION_COLOR,
- Tk_Offset(HighlightElement,highlightColorObj), DEFAULT_BACKGROUND },
+ offsetof(HighlightElement,highlightColorObj), DEFAULT_BACKGROUND },
{ "-highlightthickness",TK_OPTION_PIXELS,
- Tk_Offset(HighlightElement,highlightThicknessObj), "0" },
+ offsetof(HighlightElement,highlightThicknessObj), "0" },
{ "-default", TK_OPTION_ANY,
- Tk_Offset(HighlightElement,defaultStateObj), "disabled" },
+ offsetof(HighlightElement,defaultStateObj), "disabled" },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -58,24 +58,23 @@ static void HighlightElementDraw(
HighlightElement *hl = (HighlightElement *)elementRecord;
int highlightThickness = 0;
XColor *highlightColor = Tk_GetColorFromObj(tkwin, hl->highlightColorObj);
- int defaultState = TTK_BUTTON_DEFAULT_DISABLED;
+ Ttk_ButtonDefaultState defaultState = TTK_BUTTON_DEFAULT_DISABLED;
- Tk_GetPixelsFromObj(NULL, tkwin, hl->highlightThicknessObj,
- &highlightThickness);
+ Tk_GetPixelsFromObj(NULL, tkwin, hl->highlightThicknessObj, &highlightThickness);
if (highlightColor && highlightThickness > 0) {
- GC gc;
Ttk_GetButtonDefaultStateFromObj(NULL, hl->defaultStateObj,
&defaultState);
- gc = Tk_GCForColor(highlightColor, d);
+ GC gc = Tk_GCForColor(highlightColor, d);
if (defaultState == TTK_BUTTON_DEFAULT_NORMAL) {
- TkDrawInsetFocusHighlight(tkwin, gc, highlightThickness, d, 5);
+ TkDrawInsetFocusHighlight(tkwin, gc, highlightThickness, d,
+ round(5 * TkScalingLevel(tkwin)));
} else {
Tk_DrawFocusHighlight(tkwin, gc, highlightThickness, d);
}
}
}
-static Ttk_ElementSpec HighlightElementSpec =
+static const Ttk_ElementSpec HighlightElementSpec =
{
TK_STYLE_VERSION_2,
sizeof(HighlightElement),
@@ -101,16 +100,16 @@ typedef struct {
Tcl_Obj *defaultStateObj;
} ButtonBorderElement;
-static Ttk_ElementOptionSpec ButtonBorderElementOptions[] =
+static const Ttk_ElementOptionSpec ButtonBorderElementOptions[] =
{
{ "-background", TK_OPTION_BORDER,
- Tk_Offset(ButtonBorderElement,borderObj), DEFAULT_BACKGROUND },
+ offsetof(ButtonBorderElement,borderObj), DEFAULT_BACKGROUND },
{ "-borderwidth", TK_OPTION_PIXELS,
- Tk_Offset(ButtonBorderElement,borderWidthObj), DEFAULT_BORDERWIDTH },
+ offsetof(ButtonBorderElement,borderWidthObj), DEFAULT_BORDERWIDTH },
{ "-relief", TK_OPTION_RELIEF,
- Tk_Offset(ButtonBorderElement,reliefObj), "flat" },
+ offsetof(ButtonBorderElement,reliefObj), "flat" },
{ "-default", TK_OPTION_ANY,
- Tk_Offset(ButtonBorderElement,defaultStateObj), "disabled" },
+ offsetof(ButtonBorderElement,defaultStateObj), "disabled" },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -123,14 +122,14 @@ static void ButtonBorderElementSize(
Ttk_Padding *paddingPtr)
{
ButtonBorderElement *bd = (ButtonBorderElement *)elementRecord;
- int defaultState = TTK_BUTTON_DEFAULT_DISABLED;
+ Ttk_ButtonDefaultState defaultState = TTK_BUTTON_DEFAULT_DISABLED;
int borderWidth = 0;
Tk_GetPixelsFromObj(NULL, tkwin, bd->borderWidthObj, &borderWidth);
Ttk_GetButtonDefaultStateFromObj(NULL, bd->defaultStateObj, &defaultState);
if (defaultState != TTK_BUTTON_DEFAULT_DISABLED) {
- borderWidth += 5;
+ borderWidth += round(5 * TkScalingLevel(tkwin));
}
*paddingPtr = Ttk_UniformPadding((short)borderWidth);
}
@@ -151,7 +150,7 @@ static void ButtonBorderElementDraw(
ButtonBorderElement *bd = (ButtonBorderElement *)elementRecord;
Tk_3DBorder border = NULL;
int borderWidth = 1, relief = TK_RELIEF_FLAT;
- int defaultState = TTK_BUTTON_DEFAULT_DISABLED;
+ Ttk_ButtonDefaultState defaultState = TTK_BUTTON_DEFAULT_DISABLED;
int inset = 0;
/*
@@ -170,7 +169,7 @@ static void ButtonBorderElementDraw(
case TTK_BUTTON_DEFAULT_DISABLED :
break;
case TTK_BUTTON_DEFAULT_NORMAL :
- inset += 5;
+ inset += round(5 * TkScalingLevel(tkwin));
break;
case TTK_BUTTON_DEFAULT_ACTIVE :
Tk_Draw3DRectangle(tkwin, d, border,
@@ -198,7 +197,7 @@ static void ButtonBorderElementDraw(
}
}
-static Ttk_ElementSpec ButtonBorderElementSpec =
+static const Ttk_ElementSpec ButtonBorderElementSpec =
{
TK_STYLE_VERSION_2,
sizeof(ButtonBorderElement),
@@ -208,13 +207,258 @@ static Ttk_ElementSpec ButtonBorderElementSpec =
};
/*----------------------------------------------------------------------
+ * +++ Indicator element.
+ *
+ * Draws the on/off indicator for checkbuttons and radiobuttons.
+ *
+ * Draws a 3-D square (or diamond), raised if off, sunken if on.
+ *
+ * This is actually a regression from Tk 8.5 back to the ugly old Motif
+ * style; use the "alt", "clam", or "default" theme" for newer, nicer
+ * versions.
+ */
+
+typedef struct {
+ Tcl_Obj *backgroundObj;
+ Tcl_Obj *reliefObj;
+ Tcl_Obj *colorObj;
+ Tcl_Obj *sizeObj;
+ Tcl_Obj *marginObj;
+ Tcl_Obj *borderWidthObj;
+} IndicatorElement;
+
+static const Ttk_ElementOptionSpec IndicatorElementOptions[] = {
+ { "-background", TK_OPTION_BORDER,
+ offsetof(IndicatorElement,backgroundObj), DEFAULT_BACKGROUND },
+ { "-indicatorcolor", TK_OPTION_BORDER,
+ offsetof(IndicatorElement,colorObj), DEFAULT_BACKGROUND },
+ { "-indicatorrelief", TK_OPTION_RELIEF,
+ offsetof(IndicatorElement,reliefObj), "raised" },
+ { "-indicatordiameter", TK_OPTION_PIXELS,
+ offsetof(IndicatorElement,sizeObj), "9p" },
+ { "-indicatormargin", TK_OPTION_STRING,
+ offsetof(IndicatorElement,marginObj), "0 2 4 2" },
+ { "-borderwidth", TK_OPTION_PIXELS,
+ offsetof(IndicatorElement,borderWidthObj), DEFAULT_BORDERWIDTH },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
+};
+
+/*
+ * Checkbutton indicators: 3-D square.
+ */
+static void SquareIndicatorElementSize(
+ TCL_UNUSED(void *), /* clientData */
+ void *elementRecord,
+ Tk_Window tkwin,
+ int *widthPtr,
+ int *heightPtr,
+ TCL_UNUSED(Ttk_Padding *))
+{
+ IndicatorElement *indicator = (IndicatorElement *)elementRecord;
+ Ttk_Padding margins;
+ int diameter = 0;
+
+ Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &margins);
+ Tk_GetPixelsFromObj(NULL, tkwin, indicator->sizeObj, &diameter);
+ *widthPtr = diameter + Ttk_PaddingWidth(margins);
+ *heightPtr = diameter + Ttk_PaddingHeight(margins);
+}
+
+static void SquareIndicatorElementDraw(
+ TCL_UNUSED(void *), /* clientData */
+ void *elementRecord,
+ Tk_Window tkwin,
+ Drawable d,
+ Ttk_Box b,
+ TCL_UNUSED(Ttk_State))
+{
+ IndicatorElement *indicator = (IndicatorElement *)elementRecord;
+ Tk_3DBorder border = 0, interior = 0;
+ int relief = TK_RELIEF_RAISED;
+ Ttk_Padding padding;
+ int borderWidth = 2;
+ int diameter;
+
+ interior = Tk_Get3DBorderFromObj(tkwin, indicator->colorObj);
+ border = Tk_Get3DBorderFromObj(tkwin, indicator->backgroundObj);
+ Tk_GetPixelsFromObj(NULL, tkwin, indicator->borderWidthObj,&borderWidth);
+ Tk_GetReliefFromObj(NULL,indicator->reliefObj,&relief);
+ Ttk_GetPaddingFromObj(NULL,tkwin,indicator->marginObj,&padding);
+
+ b = Ttk_PadBox(b, padding);
+
+ diameter = b.width < b.height ? b.width : b.height;
+ Tk_Fill3DRectangle(tkwin, d, interior, b.x, b.y,
+ diameter, diameter,borderWidth, TK_RELIEF_FLAT);
+ Tk_Draw3DRectangle(tkwin, d, border, b.x, b.y,
+ diameter, diameter, borderWidth, relief);
+}
+
+/*
+ * Radiobutton indicators: 3-D diamond.
+ */
+static void DiamondIndicatorElementSize(
+ TCL_UNUSED(void *), /* clientData */
+ void *elementRecord,
+ Tk_Window tkwin,
+ int *widthPtr,
+ int *heightPtr,
+ TCL_UNUSED(Ttk_Padding *))
+{
+ IndicatorElement *indicator = (IndicatorElement *)elementRecord;
+ Ttk_Padding margins;
+ int diameter = 0;
+
+ Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &margins);
+ Tk_GetPixelsFromObj(NULL, tkwin, indicator->sizeObj, &diameter);
+ *widthPtr = diameter + 3 + Ttk_PaddingWidth(margins);
+ *heightPtr = diameter + 3 + Ttk_PaddingHeight(margins);
+}
+
+static void DiamondIndicatorElementDraw(
+ TCL_UNUSED(void *), /* clientData */
+ void *elementRecord,
+ Tk_Window tkwin,
+ Drawable d,
+ Ttk_Box b,
+ TCL_UNUSED(Ttk_State))
+{
+ IndicatorElement *indicator = (IndicatorElement *)elementRecord;
+ Tk_3DBorder border = 0, interior = 0;
+ int borderWidth = 2;
+ int relief = TK_RELIEF_RAISED;
+ int diameter, radius;
+ XPoint points[4];
+ Ttk_Padding padding;
+
+ interior = Tk_Get3DBorderFromObj(tkwin, indicator->colorObj);
+ border = Tk_Get3DBorderFromObj(tkwin, indicator->backgroundObj);
+ Tk_GetPixelsFromObj(NULL, tkwin, indicator->borderWidthObj, &borderWidth);
+ Tk_GetReliefFromObj(NULL,indicator->reliefObj,&relief);
+ Ttk_GetPaddingFromObj(NULL,tkwin,indicator->marginObj,&padding);
+
+ b = Ttk_PadBox(b, padding);
+
+ diameter = b.width < b.height ? b.width : b.height;
+ radius = diameter / 2;
+
+ points[0].x = b.x;
+ points[0].y = b.y + radius;
+ points[1].x = b.x + radius;
+ points[1].y = b.y + 2*radius;
+ points[2].x = b.x + 2*radius;
+ points[2].y = b.y + radius;
+ points[3].x = b.x + radius;
+ points[3].y = b.y;
+
+ Tk_Fill3DPolygon(tkwin,d,interior,points,4,borderWidth,TK_RELIEF_FLAT);
+ Tk_Draw3DPolygon(tkwin,d,border,points,4,borderWidth,relief);
+}
+
+static const Ttk_ElementSpec CheckbuttonIndicatorElementSpec = {
+ TK_STYLE_VERSION_2,
+ sizeof(IndicatorElement),
+ IndicatorElementOptions,
+ SquareIndicatorElementSize,
+ SquareIndicatorElementDraw
+};
+
+static const Ttk_ElementSpec RadiobuttonIndicatorElementSpec = {
+ TK_STYLE_VERSION_2,
+ sizeof(IndicatorElement),
+ IndicatorElementOptions,
+ DiamondIndicatorElementSize,
+ DiamondIndicatorElementDraw
+};
+
+/*----------------------------------------------------------------------
+ * +++ Menubutton indicators.
+ *
+ * These aren't functional like radio/check indicators,
+ * they're just affordability indicators.
+ *
+ * Standard Tk sets the indicator size to 4.0 mm by 1.7 mm.
+ * I have no idea where these numbers came from.
+ */
+
+typedef struct {
+ Tcl_Obj *backgroundObj;
+ Tcl_Obj *widthObj;
+ Tcl_Obj *heightObj;
+ Tcl_Obj *borderWidthObj;
+ Tcl_Obj *reliefObj;
+ Tcl_Obj *marginObj;
+} MenuIndicatorElement;
+
+static const Ttk_ElementOptionSpec MenuIndicatorElementOptions[] = {
+ { "-background", TK_OPTION_BORDER,
+ offsetof(MenuIndicatorElement,backgroundObj), DEFAULT_BACKGROUND },
+ { "-indicatorwidth", TK_OPTION_PIXELS,
+ offsetof(MenuIndicatorElement,widthObj), "4.0m" },
+ { "-indicatorheight", TK_OPTION_PIXELS,
+ offsetof(MenuIndicatorElement,heightObj), "1.7m" },
+ { "-indicatorborderwidth", TK_OPTION_PIXELS,
+ offsetof(MenuIndicatorElement,borderWidthObj), DEFAULT_BORDERWIDTH },
+ { "-indicatorrelief", TK_OPTION_RELIEF,
+ offsetof(MenuIndicatorElement,reliefObj), "raised" },
+ { "-indicatormargin", TK_OPTION_STRING,
+ offsetof(MenuIndicatorElement,marginObj), "5 0" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
+};
+
+static void MenuIndicatorElementSize(
+ TCL_UNUSED(void *), /* clientData */
+ void *elementRecord,
+ Tk_Window tkwin,
+ int *widthPtr,
+ int *heightPtr,
+ TCL_UNUSED(Ttk_Padding *))
+{
+ MenuIndicatorElement *mi = (MenuIndicatorElement *)elementRecord;
+ Ttk_Padding margins;
+
+ Tk_GetPixelsFromObj(NULL, tkwin, mi->widthObj, widthPtr);
+ Tk_GetPixelsFromObj(NULL, tkwin, mi->heightObj, heightPtr);
+ Ttk_GetPaddingFromObj(NULL, tkwin, mi->marginObj, &margins);
+ *widthPtr += Ttk_PaddingWidth(margins);
+ *heightPtr += Ttk_PaddingHeight(margins);
+}
+
+static void MenuIndicatorElementDraw(
+ TCL_UNUSED(void *), /* clientData */
+ void *elementRecord,
+ Tk_Window tkwin,
+ Drawable d,
+ Ttk_Box b,
+ TCL_UNUSED(Ttk_State))
+{
+ MenuIndicatorElement *mi = (MenuIndicatorElement *)elementRecord;
+ Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, mi->backgroundObj);
+ Ttk_Padding margins;
+ int borderWidth = 2;
+
+ Ttk_GetPaddingFromObj(NULL,tkwin,mi->marginObj,&margins);
+ b = Ttk_PadBox(b, margins);
+ Tk_GetPixelsFromObj(NULL, tkwin, mi->borderWidthObj, &borderWidth);
+ Tk_Fill3DRectangle(tkwin, d, border, b.x, b.y, b.width, b.height,
+ borderWidth, TK_RELIEF_RAISED);
+}
+
+static const Ttk_ElementSpec MenuIndicatorElementSpec = {
+ TK_STYLE_VERSION_2,
+ sizeof(MenuIndicatorElement),
+ MenuIndicatorElementOptions,
+ MenuIndicatorElementSize,
+ MenuIndicatorElementDraw
+};
+
+/*----------------------------------------------------------------------
* +++ Arrow element(s).
*
* Draws a 3-D shaded triangle.
* clientData is an enum ArrowDirection pointer.
*/
-static int ArrowElements[] = { ARROW_UP, ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT };
typedef struct
{
Tcl_Obj *sizeObj;
@@ -223,15 +467,15 @@ typedef struct
Tcl_Obj *reliefObj;
} ArrowElement;
-static Ttk_ElementOptionSpec ArrowElementOptions[] =
+static const Ttk_ElementOptionSpec ArrowElementOptions[] =
{
- { "-arrowsize", TK_OPTION_PIXELS, Tk_Offset(ArrowElement,sizeObj),
+ { "-arrowsize", TK_OPTION_PIXELS, offsetof(ArrowElement,sizeObj),
DEFAULT_ARROW_SIZE },
- { "-background", TK_OPTION_BORDER, Tk_Offset(ArrowElement,borderObj),
+ { "-background", TK_OPTION_BORDER, offsetof(ArrowElement,borderObj),
DEFAULT_BACKGROUND },
- { "-borderwidth", TK_OPTION_PIXELS, Tk_Offset(ArrowElement,borderWidthObj),
+ { "-borderwidth", TK_OPTION_PIXELS, offsetof(ArrowElement,borderWidthObj),
DEFAULT_BORDERWIDTH },
- { "-relief", TK_OPTION_RELIEF, Tk_Offset(ArrowElement,reliefObj),"raised" },
+ { "-relief", TK_OPTION_RELIEF, offsetof(ArrowElement,reliefObj),"raised" },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -255,7 +499,7 @@ static void ArrowElementDraw(
Drawable d, Ttk_Box b,
TCL_UNUSED(Ttk_State))
{
- int direction = *(int *)clientData;
+ ArrowDirection direction = (ArrowDirection)PTR2INT(clientData);
ArrowElement *arrow = (ArrowElement *)elementRecord;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, arrow->borderObj);
int borderWidth = 2;
@@ -298,7 +542,7 @@ static void ArrowElementDraw(
Tk_Fill3DPolygon(tkwin, d, border, points, 3, borderWidth, relief);
}
-static Ttk_ElementSpec ArrowElementSpec =
+static const Ttk_ElementSpec ArrowElementSpec =
{
TK_STYLE_VERSION_2,
sizeof(ArrowElement),
@@ -307,6 +551,120 @@ static Ttk_ElementSpec ArrowElementSpec =
ArrowElementDraw
};
+/*------------------------------------------------------------------------
+ * +++ Slider element.
+ *
+ * This is the moving part of the scale widget. Drawn as a raised box.
+ */
+
+typedef struct {
+ Tcl_Obj *orientObj; /* orientation of overall slider */
+ Tcl_Obj *lengthObj; /* slider length */
+ Tcl_Obj *thicknessObj; /* slider thickness */
+ Tcl_Obj *reliefObj; /* the relief for this object */
+ Tcl_Obj *borderObj; /* the background color */
+ Tcl_Obj *borderWidthObj; /* the size of the border */
+} SliderElement;
+
+static const Ttk_ElementOptionSpec SliderElementOptions[] = {
+ { "-sliderlength", TK_OPTION_PIXELS,
+ offsetof(SliderElement,lengthObj), "30" },
+ { "-sliderthickness",TK_OPTION_PIXELS,
+ offsetof(SliderElement,thicknessObj), "15" },
+ { "-sliderrelief", TK_OPTION_RELIEF,
+ offsetof(SliderElement,reliefObj), "raised" },
+ { "-sliderborderwidth", TK_OPTION_PIXELS,
+ offsetof(SliderElement,borderWidthObj), DEFAULT_BORDERWIDTH },
+ { "-background", TK_OPTION_BORDER,
+ offsetof(SliderElement,borderObj), DEFAULT_BACKGROUND },
+ { "-orient", TK_OPTION_ANY,
+ offsetof(SliderElement,orientObj), "horizontal" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
+};
+
+static void SliderElementSize(
+ TCL_UNUSED(void *), /* clientData */
+ void *elementRecord,
+ Tk_Window tkwin,
+ int *widthPtr,
+ int *heightPtr,
+ TCL_UNUSED(Ttk_Padding *))
+{
+ SliderElement *slider = (SliderElement *)elementRecord;
+ Ttk_Orient orient;
+ int length, thickness;
+
+ TtkGetOrientFromObj(NULL, slider->orientObj, &orient);
+ Tk_GetPixelsFromObj(NULL, tkwin, slider->lengthObj, &length);
+ Tk_GetPixelsFromObj(NULL, tkwin, slider->thicknessObj, &thickness);
+
+ switch (orient) {
+ case TTK_ORIENT_VERTICAL:
+ *widthPtr = thickness;
+ *heightPtr = length;
+ break;
+
+ case TTK_ORIENT_HORIZONTAL:
+ *widthPtr = length;
+ *heightPtr = thickness;
+ break;
+ }
+}
+
+static void SliderElementDraw(
+ TCL_UNUSED(void *), /* clientData */
+ void *elementRecord,
+ Tk_Window tkwin,
+ Drawable d,
+ Ttk_Box b,
+ TCL_UNUSED(Ttk_State))
+{
+ SliderElement *slider = (SliderElement *)elementRecord;
+ Tk_3DBorder border = NULL;
+ int relief = TK_RELIEF_RAISED, borderWidth = 2;
+ Ttk_Orient orient;
+
+ border = Tk_Get3DBorderFromObj(tkwin, slider->borderObj);
+ Tk_GetReliefFromObj(NULL, slider->reliefObj, &relief);
+ Tk_GetPixelsFromObj(NULL, tkwin, slider->borderWidthObj, &borderWidth);
+ TtkGetOrientFromObj(NULL, slider->orientObj, &orient);
+
+ Tk_Fill3DRectangle(tkwin, d, border,
+ b.x, b.y, b.width, b.height,
+ borderWidth, relief);
+
+ if (relief != TK_RELIEF_FLAT) {
+ if (orient == TTK_ORIENT_HORIZONTAL) {
+ if (b.width > 4) {
+ b.x += b.width/2;
+ XDrawLine(Tk_Display(tkwin), d,
+ Tk_3DBorderGC(tkwin, border, TK_3D_DARK_GC),
+ b.x-1, b.y+borderWidth, b.x-1, b.y+b.height-borderWidth);
+ XDrawLine(Tk_Display(tkwin), d,
+ Tk_3DBorderGC(tkwin, border, TK_3D_LIGHT_GC),
+ b.x, b.y+borderWidth, b.x, b.y+b.height-borderWidth);
+ }
+ } else {
+ if (b.height > 4) {
+ b.y += b.height/2;
+ XDrawLine(Tk_Display(tkwin), d,
+ Tk_3DBorderGC(tkwin, border, TK_3D_DARK_GC),
+ b.x+borderWidth, b.y-1, b.x+b.width-borderWidth, b.y-1);
+ XDrawLine(Tk_Display(tkwin), d,
+ Tk_3DBorderGC(tkwin, border, TK_3D_LIGHT_GC),
+ b.x+borderWidth, b.y, b.x+b.width-borderWidth, b.y);
+ }
+ }
+ }
+}
+
+static const Ttk_ElementSpec SliderElementSpec = {
+ TK_STYLE_VERSION_2,
+ sizeof(SliderElement),
+ SliderElementOptions,
+ SliderElementSize,
+ SliderElementDraw
+};
/*------------------------------------------------------------------------
* +++ Sash element (for ttk::panedwindow)
@@ -322,10 +680,6 @@ static Ttk_ElementSpec ArrowElementSpec =
* -sashrelief raised, but that looks wrong to me.
*/
-static Ttk_Orient SashClientData[] = {
- TTK_ORIENT_HORIZONTAL, TTK_ORIENT_VERTICAL
-};
-
typedef struct {
Tcl_Obj *borderObj; /* background color */
Tcl_Obj *sashReliefObj; /* sash relief */
@@ -335,19 +689,19 @@ typedef struct {
Tcl_Obj *handlePadObj; /* handle's distance from edge */
} SashElement;
-static Ttk_ElementOptionSpec SashOptions[] = {
+static const Ttk_ElementOptionSpec SashOptions[] = {
{ "-background", TK_OPTION_BORDER,
- Tk_Offset(SashElement,borderObj), DEFAULT_BACKGROUND },
+ offsetof(SashElement,borderObj), DEFAULT_BACKGROUND },
{ "-sashrelief", TK_OPTION_RELIEF,
- Tk_Offset(SashElement,sashReliefObj), "sunken" },
+ offsetof(SashElement,sashReliefObj), "sunken" },
{ "-sashthickness", TK_OPTION_PIXELS,
- Tk_Offset(SashElement,sashThicknessObj), "6" },
+ offsetof(SashElement,sashThicknessObj), "6" },
{ "-sashpad", TK_OPTION_PIXELS,
- Tk_Offset(SashElement,sashPadObj), "2" },
+ offsetof(SashElement,sashPadObj), "2" },
{ "-handlesize", TK_OPTION_PIXELS,
- Tk_Offset(SashElement,handleSizeObj), "8" },
+ offsetof(SashElement,handleSizeObj), "8" },
{ "-handlepad", TK_OPTION_PIXELS,
- Tk_Offset(SashElement,handlePadObj), "8" },
+ offsetof(SashElement,handlePadObj), "8" },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -358,7 +712,7 @@ static void SashElementSize(
{
SashElement *sash = (SashElement *)elementRecord;
int sashPad = 2, sashThickness = 6, handleSize = 8;
- int horizontal = *((Ttk_Orient*)clientData) == TTK_ORIENT_HORIZONTAL;
+ Ttk_Orient orient = (Ttk_Orient)PTR2INT(clientData);
Tk_GetPixelsFromObj(NULL, tkwin, sash->sashThicknessObj, &sashThickness);
Tk_GetPixelsFromObj(NULL, tkwin, sash->handleSizeObj, &handleSize);
@@ -367,7 +721,7 @@ static void SashElementSize(
if (sashThickness < handleSize + 2*sashPad)
sashThickness = handleSize + 2*sashPad;
- if (horizontal)
+ if (orient == TTK_ORIENT_HORIZONTAL)
*heightPtr = sashThickness;
else
*widthPtr = sashThickness;
@@ -383,7 +737,7 @@ static void SashElementDraw(
GC gc1,gc2;
int relief = TK_RELIEF_RAISED;
int handleSize = 8, handlePad = 8;
- int horizontal = *((Ttk_Orient*)clientData) == TTK_ORIENT_HORIZONTAL;
+ Ttk_Orient orient = (Ttk_Orient)PTR2INT(clientData);
Ttk_Box hb;
Tk_GetPixelsFromObj(NULL, tkwin, sash->handleSizeObj, &handleSize);
@@ -410,7 +764,7 @@ static void SashElementDraw(
/* Draw sash line:
*/
- if (horizontal) {
+ if (orient == TTK_ORIENT_HORIZONTAL) {
int y = b.y + b.height/2 - 1;
XDrawLine(Tk_Display(tkwin), d, gc1, b.x, y, b.x+b.width, y); ++y;
XDrawLine(Tk_Display(tkwin), d, gc2, b.x, y, b.x+b.width, y);
@@ -423,7 +777,7 @@ static void SashElementDraw(
/* Draw handle:
*/
if (handleSize >= 0) {
- if (horizontal) {
+ if (orient == TTK_ORIENT_HORIZONTAL) {
hb = Ttk_StickBox(b, handleSize, handleSize, TTK_STICK_W);
hb.x += handlePad;
} else {
@@ -435,7 +789,7 @@ static void SashElementDraw(
}
}
-static Ttk_ElementSpec SashElementSpec = {
+static const Ttk_ElementSpec SashElementSpec = {
TK_STYLE_VERSION_2,
sizeof(SashElement),
SashOptions,
@@ -486,10 +840,10 @@ TTK_LAYOUT("TEntry",
/* "classic" combobox, includes highlight border */
TTK_LAYOUT("TCombobox",
TTK_GROUP("Combobox.highlight", TTK_FILL_BOTH,
- TTK_GROUP("Combobox.field", TTK_FILL_BOTH,
+ TTK_GROUP("Combobox.field", TTK_FILL_BOTH,
TTK_NODE("Combobox.downarrow", TTK_PACK_RIGHT|TTK_FILL_Y)
TTK_GROUP("Combobox.padding", TTK_FILL_BOTH,
- TTK_NODE("Combobox.textarea", TTK_FILL_BOTH)))))
+ TTK_NODE("Combobox.textarea", TTK_FILL_BOTH)))))
/* "classic" spinbox, includes highlight border */
TTK_LAYOUT("TSpinbox",
@@ -544,21 +898,31 @@ TtkClassicTheme_Init(Tcl_Interp *interp)
Ttk_RegisterElement(interp, theme, "Button.border",
&ButtonBorderElementSpec, NULL);
+ Ttk_RegisterElement(interp, theme, "Checkbutton.indicator",
+ &CheckbuttonIndicatorElementSpec, NULL);
+ Ttk_RegisterElement(interp, theme, "Radiobutton.indicator",
+ &RadiobuttonIndicatorElementSpec, NULL);
+ Ttk_RegisterElement(interp, theme, "Menubutton.indicator",
+ &MenuIndicatorElementSpec, NULL);
+
Ttk_RegisterElement(interp, theme, "uparrow",
- &ArrowElementSpec, &ArrowElements[0]);
+ &ArrowElementSpec, INT2PTR(ARROW_UP));
Ttk_RegisterElement(interp, theme, "downarrow",
- &ArrowElementSpec, &ArrowElements[1]);
+ &ArrowElementSpec, INT2PTR(ARROW_DOWN));
Ttk_RegisterElement(interp, theme, "leftarrow",
- &ArrowElementSpec, &ArrowElements[2]);
+ &ArrowElementSpec, INT2PTR(ARROW_LEFT));
Ttk_RegisterElement(interp, theme, "rightarrow",
- &ArrowElementSpec, &ArrowElements[3]);
+ &ArrowElementSpec, INT2PTR(ARROW_RIGHT));
Ttk_RegisterElement(interp, theme, "arrow",
- &ArrowElementSpec, &ArrowElements[0]);
+ &ArrowElementSpec, INT2PTR(ARROW_UP));
+
+ Ttk_RegisterElement(interp, theme, "slider",
+ &SliderElementSpec, NULL);
Ttk_RegisterElement(interp, theme, "hsash",
- &SashElementSpec, &SashClientData[0]);
+ &SashElementSpec, INT2PTR(TTK_ORIENT_HORIZONTAL));
Ttk_RegisterElement(interp, theme, "vsash",
- &SashElementSpec, &SashClientData[1]);
+ &SashElementSpec, INT2PTR(TTK_ORIENT_VERTICAL));
/*
* Register layouts:
diff --git a/generic/ttk/ttkDecls.h b/generic/ttk/ttkDecls.h
index 6701724..2b074ac 100644
--- a/generic/ttk/ttkDecls.h
+++ b/generic/ttk/ttkDecls.h
@@ -13,11 +13,24 @@ extern const char *TtkInitializeStubs(
interp, TTK_VERSION, TTK_STUBS_EPOCH, TTK_STUBS_REVISION)
#else
-#define Ttk_InitStubs(interp) Tcl_PkgRequireEx(interp, "Ttk", TTK_VERSION, 0, NULL)
+#if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
+# define Ttk_InitStubs(interp) Tcl_PkgRequireEx(interp, "Ttk", TTK_VERSION, 0, NULL)
+#else
+# define Ttk_InitStubs(interp) Tcl_PkgRequireEx(interp, "ttk", TTK_VERSION, 0, NULL)
+#endif
+
+#endif
+#if !defined(BUILD_tk)
+# define TTK_DEPRECATED(msg) TTKAPI TCL_DEPRECATED_API(msg)
+#elif defined(TK_NO_DEPRECATED)
+# define TTK_DEPRECATED(msg) MODULE_SCOPE
+#else
+# define TTK_DEPRECATED(msg) TTKAPI
#endif
+
/* !BEGIN!: Do not edit below this line. */
#define TTK_STUBS_EPOCH 0
@@ -47,12 +60,12 @@ TTKAPI void Ttk_RegisterCleanup(Tcl_Interp *interp,
/* 5 */
TTKAPI int Ttk_RegisterElementSpec(Ttk_Theme theme,
const char *elementName,
- Ttk_ElementSpec *elementSpec,
+ const Ttk_ElementSpec *elementSpec,
void *clientData);
/* 6 */
TTKAPI Ttk_ElementClass * Ttk_RegisterElement(Tcl_Interp *interp,
Ttk_Theme theme, const char *elementName,
- Ttk_ElementSpec *elementSpec,
+ const Ttk_ElementSpec *elementSpec,
void *clientData);
/* 7 */
TTKAPI int Ttk_RegisterElementFactory(Tcl_Interp *interp,
@@ -77,7 +90,7 @@ TTKAPI Ttk_StateMap Ttk_GetStateMapFromObj(Tcl_Interp *interp,
TTKAPI Tcl_Obj * Ttk_StateMapLookup(Tcl_Interp *interp,
Ttk_StateMap map, Ttk_State state);
/* 14 */
-TTKAPI int Ttk_StateTableLookup(Ttk_StateTable map[],
+TTKAPI int Ttk_StateTableLookup(const Ttk_StateTable *map,
Ttk_State state);
/* Slot 15 is reserved */
/* Slot 16 is reserved */
@@ -130,7 +143,8 @@ TTKAPI Tcl_Obj * Ttk_NewBoxObj(Ttk_Box box);
/* Slot 38 is reserved */
/* Slot 39 is reserved */
/* 40 */
-TTKAPI int Ttk_GetOrientFromObj(Tcl_Interp *interp,
+TTK_DEPRECATED("")
+int Ttk_GetOrientFromObj(Tcl_Interp *interp,
Tcl_Obj *objPtr, int *orient);
typedef struct TtkStubs {
@@ -144,8 +158,8 @@ typedef struct TtkStubs {
Ttk_Theme (*ttk_GetCurrentTheme) (Tcl_Interp *interp); /* 2 */
Ttk_Theme (*ttk_CreateTheme) (Tcl_Interp *interp, const char *name, Ttk_Theme parent); /* 3 */
void (*ttk_RegisterCleanup) (Tcl_Interp *interp, void *deleteData, Ttk_CleanupProc *cleanupProc); /* 4 */
- int (*ttk_RegisterElementSpec) (Ttk_Theme theme, const char *elementName, Ttk_ElementSpec *elementSpec, void *clientData); /* 5 */
- Ttk_ElementClass * (*ttk_RegisterElement) (Tcl_Interp *interp, Ttk_Theme theme, const char *elementName, Ttk_ElementSpec *elementSpec, void *clientData); /* 6 */
+ int (*ttk_RegisterElementSpec) (Ttk_Theme theme, const char *elementName, const Ttk_ElementSpec *elementSpec, void *clientData); /* 5 */
+ Ttk_ElementClass * (*ttk_RegisterElement) (Tcl_Interp *interp, Ttk_Theme theme, const char *elementName, const Ttk_ElementSpec *elementSpec, void *clientData); /* 6 */
int (*ttk_RegisterElementFactory) (Tcl_Interp *interp, const char *name, Ttk_ElementFactory factoryProc, void *clientData); /* 7 */
void (*ttk_RegisterLayout) (Ttk_Theme theme, const char *className, Ttk_LayoutSpec layoutSpec); /* 8 */
void (*reserved9)(void);
@@ -153,7 +167,7 @@ typedef struct TtkStubs {
Tcl_Obj * (*ttk_NewStateSpecObj) (unsigned int onbits, unsigned int offbits); /* 11 */
Ttk_StateMap (*ttk_GetStateMapFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr); /* 12 */
Tcl_Obj * (*ttk_StateMapLookup) (Tcl_Interp *interp, Ttk_StateMap map, Ttk_State state); /* 13 */
- int (*ttk_StateTableLookup) (Ttk_StateTable map[], Ttk_State state); /* 14 */
+ int (*ttk_StateTableLookup) (const Ttk_StateTable *map, Ttk_State state); /* 14 */
void (*reserved15)(void);
void (*reserved16)(void);
void (*reserved17)(void);
@@ -179,7 +193,7 @@ typedef struct TtkStubs {
void (*reserved37)(void);
void (*reserved38)(void);
void (*reserved39)(void);
- int (*ttk_GetOrientFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, int *orient); /* 40 */
+ TCL_DEPRECATED_API("") int (*ttk_GetOrientFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, int *orient); /* 40 */
} TtkStubs;
extern const TtkStubs *ttkStubsPtr;
diff --git a/generic/ttk/ttkDefaultTheme.c b/generic/ttk/ttkDefaultTheme.c
index d75dbe0..8182c27 100644
--- a/generic/ttk/ttkDefaultTheme.c
+++ b/generic/ttk/ttkDefaultTheme.c
@@ -1,16 +1,16 @@
/*
- * Copyright (c) 2003, Joe English
+ * Copyright © 2003 Joe English
*
* Tk alternate theme, intended to match the MSUE and Gtk's (old) default theme
*/
#include "tkInt.h"
-#include "ttkTheme.h"
+#include "ttkThemeInt.h"
#if defined(_WIN32)
-static const int WIN32_XDRAWLINE_HACK = 1;
+ #define WIN32_XDRAWLINE_HACK 1
#else
-static const int WIN32_XDRAWLINE_HACK = 0;
+ #define WIN32_XDRAWLINE_HACK 0
#endif
#if defined(MAC_OSX_TK)
@@ -37,7 +37,7 @@ static const int WIN32_XDRAWLINE_HACK = 0;
enum BorderColor { FLAT = 1, LITE = 2, DARK = 3, BRDR = 4 };
/* top-left outer, top-left inner, bottom-right inner, bottom-right outer */
-static int const shadowColors[6][4] = {
+static const enum BorderColor shadowColors[6][4] = {
{ FLAT, FLAT, FLAT, FLAT }, /* TK_RELIEF_FLAT = 0*/
{ DARK, LITE, DARK, LITE }, /* TK_RELIEF_GROOVE = 1*/
{ LITE, FLAT, DARK, BRDR }, /* TK_RELIEF_RAISED = 2*/
@@ -47,7 +47,7 @@ static int const shadowColors[6][4] = {
};
/* top-left, bottom-right */
-static int const thinShadowColors[6][4] = {
+static const enum BorderColor thinShadowColors[6][4] = {
{ FLAT, FLAT }, /* TK_RELIEF_FLAT = 0*/
{ DARK, LITE }, /* TK_RELIEF_GROOVE = 1*/
{ LITE, DARK }, /* TK_RELIEF_RAISED = 2*/
@@ -116,21 +116,19 @@ static void DrawBorder(
/* Alternate shadow colors for entry fields:
* NOTE: FLAT color is normally white, and the LITE color is a darker shade.
*/
-static int fieldShadowColors[4] = { DARK, BRDR, LITE, FLAT };
-
static void DrawFieldBorder(
Tk_Window tkwin, Drawable d, Tk_3DBorder border, XColor *borderColor,
Ttk_Box b)
{
GC borderGC = Tk_GCForColor(borderColor, d);
DrawCorner(tkwin, d, border, borderGC,
- b.x, b.y, b.width, b.height, 0,fieldShadowColors[0]);
+ b.x, b.y, b.width, b.height, 0, DARK);
DrawCorner(tkwin, d, border, borderGC,
- b.x+1, b.y+1, b.width-2, b.height-2, 0,fieldShadowColors[1]);
+ b.x+1, b.y+1, b.width-2, b.height-2, 0, BRDR);
DrawCorner(tkwin, d, border, borderGC,
- b.x+1, b.y+1, b.width-2, b.height-2, 1,fieldShadowColors[2]);
+ b.x+1, b.y+1, b.width-2, b.height-2, 1, LITE);
DrawCorner(tkwin, d, border, borderGC,
- b.x, b.y, b.width, b.height, 1,fieldShadowColors[3]);
+ b.x, b.y, b.width, b.height, 1, FLAT);
return;
}
@@ -244,16 +242,16 @@ typedef struct {
Tcl_Obj *defaultStateObj; /* for buttons */
} BorderElement;
-static Ttk_ElementOptionSpec BorderElementOptions[] = {
- { "-background", TK_OPTION_BORDER, Tk_Offset(BorderElement,borderObj),
+static const Ttk_ElementOptionSpec BorderElementOptions[] = {
+ { "-background", TK_OPTION_BORDER, offsetof(BorderElement,borderObj),
DEFAULT_BACKGROUND },
{ "-bordercolor",TK_OPTION_COLOR,
- Tk_Offset(BorderElement,borderColorObj), "black" },
- { "-default", TK_OPTION_ANY, Tk_Offset(BorderElement,defaultStateObj),
+ offsetof(BorderElement,borderColorObj), "black" },
+ { "-default", TK_OPTION_ANY, offsetof(BorderElement,defaultStateObj),
"disabled" },
- { "-borderwidth",TK_OPTION_PIXELS, Tk_Offset(BorderElement,borderWidthObj),
+ { "-borderwidth",TK_OPTION_PIXELS, offsetof(BorderElement,borderWidthObj),
STRINGIFY(BORDERWIDTH) },
- { "-relief", TK_OPTION_RELIEF, Tk_Offset(BorderElement,reliefObj),
+ { "-relief", TK_OPTION_RELIEF, offsetof(BorderElement,reliefObj),
"flat" },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -268,7 +266,7 @@ static void BorderElementSize(
{
BorderElement *bd = (BorderElement *)elementRecord;
int borderWidth = 0;
- int defaultState = TTK_BUTTON_DEFAULT_DISABLED;
+ Ttk_ButtonDefaultState defaultState = TTK_BUTTON_DEFAULT_DISABLED;
Tk_GetPixelsFromObj(NULL, tkwin, bd->borderWidthObj, &borderWidth);
Ttk_GetButtonDefaultStateFromObj(NULL, bd->defaultStateObj, &defaultState);
@@ -293,7 +291,7 @@ static void BorderElementDraw(
XColor *borderColor = Tk_GetColorFromObj(tkwin, bd->borderColorObj);
int borderWidth = 2;
int relief = TK_RELIEF_FLAT;
- int defaultState = TTK_BUTTON_DEFAULT_DISABLED;
+ Ttk_ButtonDefaultState defaultState = TTK_BUTTON_DEFAULT_DISABLED;
/*
* Get option values.
@@ -315,7 +313,7 @@ static void BorderElementDraw(
DrawBorder(tkwin, d, border, borderColor, b, borderWidth, relief);
}
-static Ttk_ElementSpec BorderElementSpec = {
+static const Ttk_ElementSpec BorderElementSpec = {
TK_STYLE_VERSION_2,
sizeof(BorderElement),
BorderElementOptions,
@@ -334,14 +332,14 @@ typedef struct {
Tcl_Obj *focusColorObj;
} FieldElement;
-static Ttk_ElementOptionSpec FieldElementOptions[] = {
- { "-fieldbackground", TK_OPTION_BORDER, Tk_Offset(FieldElement,borderObj),
+static const Ttk_ElementOptionSpec FieldElementOptions[] = {
+ { "-fieldbackground", TK_OPTION_BORDER, offsetof(FieldElement,borderObj),
"white" },
- { "-bordercolor",TK_OPTION_COLOR, Tk_Offset(FieldElement,borderColorObj),
+ { "-bordercolor",TK_OPTION_COLOR, offsetof(FieldElement,borderColorObj),
"black" },
- { "-focuswidth", TK_OPTION_PIXELS, Tk_Offset(FieldElement,focusWidthObj),
+ { "-focuswidth", TK_OPTION_PIXELS, offsetof(FieldElement,focusWidthObj),
"2" },
- { "-focuscolor", TK_OPTION_COLOR, Tk_Offset(FieldElement,focusColorObj),
+ { "-focuscolor", TK_OPTION_COLOR, offsetof(FieldElement,focusColorObj),
"#4a6984" },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -378,7 +376,6 @@ static void FieldElementDraw(
int x1 = b.x, x2 = b.x + b.width - 1;
int y1 = b.y, y2 = b.y + b.height - 1;
int w = WIN32_XDRAWLINE_HACK;
- GC bgGC;
/*
* Draw the outer rounded rectangle
@@ -397,7 +394,7 @@ static void FieldElementDraw(
/*
* Fill the inner rectangle
*/
- bgGC = Tk_3DBorderGC(tkwin, border, TK_3D_FLAT_GC);
+ GC bgGC = Tk_3DBorderGC(tkwin, border, TK_3D_FLAT_GC);
XFillRectangle(disp, d, bgGC, b.x+1, b.y+1, b.width-2, b.height-2);
} else {
/*
@@ -419,7 +416,7 @@ static void FieldElementDraw(
}
}
-static Ttk_ElementSpec FieldElementSpec = {
+static const Ttk_ElementSpec FieldElementSpec = {
TK_STYLE_VERSION_2,
sizeof(FieldElement),
FieldElementOptions,
@@ -429,97 +426,82 @@ static Ttk_ElementSpec FieldElementSpec = {
/*------------------------------------------------------------------------
* Indicators --
- *
- * Code derived (probably incorrectly) from TIP 109 implementation,
- * unix/tkUnixButton.c r 1.15.
*/
/*
- * Indicator bitmap descriptor:
+ * Indicator image descriptor:
*/
typedef struct {
- int width; /* Width of each image */
- int height; /* Height of each image */
- int nimages; /* #images / row */
- const char *const *pixels; /* array[height] of char[width*nimage] */
- Ttk_StateTable *map;/* used to look up image index by state */
+ int width; /* unscaled width */
+ int height; /* unscaled height */
+ const char *const offDataPtr;
+ const char *const onDataPtr;
} IndicatorSpec;
-#if 0
-/*XPM*/
-static const char *const button_images[] = {
- /* width height ncolors chars_per_pixel */
- "52 13 8 1",
- /* colors */
- "A c #808000000000 s shadow",
- "B c #000080800000 s highlight",
- "C c #808080800000 s 3dlight",
- "D c #000000008080 s window",
- "E c #808000008080 s 3ddark",
- "F c #000080808080 s frame",
- "G c #000000000000 s foreground",
- "H c #000080800000 s disabledfg",
-};
-#endif
-
-static Ttk_StateTable checkbutton_states[] = {
- { 0, 0, TTK_STATE_SELECTED|TTK_STATE_DISABLED },
- { 1, TTK_STATE_SELECTED, TTK_STATE_DISABLED },
- { 2, TTK_STATE_DISABLED, TTK_STATE_SELECTED },
- { 3, TTK_STATE_SELECTED|TTK_STATE_DISABLED, 0 },
- { 0, 0, 0 }
-};
-
-static const char *const checkbutton_pixels[] = {
- "AAAAAAAAAAAABAAAAAAAAAAAABAAAAAAAAAAAABAAAAAAAAAAAAB",
- "AEEEEEEEEEECBAEEEEEEEEEECBAEEEEEEEEEECBAEEEEEEEEEECB",
- "AEDDDDDDDDDCBAEDDDDDDDDDCBAEFFFFFFFFFCBAEFFFFFFFFFCB",
- "AEDDDDDDDDDCBAEDDDDDDDGDCBAEFFFFFFFFFCBAEFFFFFFFHFCB",
- "AEDDDDDDDDDCBAEDDDDDDGGDCBAEFFFFFFFFFCBAEFFFFFFHHFCB",
- "AEDDDDDDDDDCBAEDGDDDGGGDCBAEFFFFFFFFFCBAEFHFFFHHHFCB",
- "AEDDDDDDDDDCBAEDGGDGGGDDCBAEFFFFFFFFFCBAEFHHFHHHFFCB",
- "AEDDDDDDDDDCBAEDGGGGGDDDCBAEFFFFFFFFFCBAEFHHHHHFFFCB",
- "AEDDDDDDDDDCBAEDDGGGDDDDCBAEFFFFFFFFFCBAEFFHHHFFFFCB",
- "AEDDDDDDDDDCBAEDDDGDDDDDCBAEFFFFFFFFFCBAEFFFHFFFFFCB",
- "AEDDDDDDDDDCBAEDDDDDDDDDCBAEFFFFFFFFFCBAEFFFFFFFFFCB",
- "ACCCCCCCCCCCBACCCCCCCCCCCBACCCCCCCCCCCBACCCCCCCCCCCB",
- "BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB",
+static const char checkbtnOffData[] = "\
+ <svg width='16' height='16' version='1.1' xmlns='http://www.w3.org/2000/svg'>\n\
+ <path d='m0 0v15h1v-14h14v-1z' fill='#888888'/>\n\
+ <path d='m1 1v13h1v-12h12v-1z' fill='#414141'/>\n\
+ <path d='m14 1v13h-13v1h14v-14z' fill='#d9d9d9'/>\n\
+ <path d='m15 0v15h-15v1h16v-16z' fill='#eeeeee'/>\n\
+ <rect x='2' y='2' width='12' height='12' fill='#ffffff'/>\n\
+ </svg>";
+
+static const char checkbtnOnData[] = "\
+ <svg width='16' height='16' version='1.1' xmlns='http://www.w3.org/2000/svg'>\n\
+ <path d='m0 0v15h1v-14h14v-1z' fill='#888888'/>\n\
+ <path d='m1 1v13h1v-12h12v-1z' fill='#414141'/>\n\
+ <path d='m14 1v13h-13v1h14v-14z' fill='#d9d9d9'/>\n\
+ <path d='m15 0v15h-15v1h16v-16z' fill='#eeeeee'/>\n\
+ <rect x='2' y='2' width='12' height='12' fill='#ffffff'/>\n\
+ <path d='m4.5 8 3 3 4-6' fill='none' stroke='#000000' stroke-linecap='round' stroke-linejoin='round' stroke-width='2'/>\n\
+ </svg>";
+
+static const IndicatorSpec checkbutton_spec = {
+ 16, 16,
+ checkbtnOffData,
+ checkbtnOnData
};
-static IndicatorSpec checkbutton_spec = {
- 13, 13, 4, /* width, height, nimages */
- checkbutton_pixels,
- checkbutton_states
-};
-
-static Ttk_StateTable radiobutton_states[] = {
- { 0, 0, TTK_STATE_SELECTED|TTK_STATE_DISABLED },
- { 1, TTK_STATE_SELECTED, TTK_STATE_DISABLED },
- { 2, TTK_STATE_DISABLED, TTK_STATE_SELECTED },
- { 3, TTK_STATE_SELECTED|TTK_STATE_DISABLED, 0 },
- { 0, 0, 0 }
-};
-
-static const char *const radiobutton_pixels[] = {
- "FFFFAAAAFFFFFFFFFAAAAFFFFFFFFFAAAAFFFFFFFFFAAAAFFFFF",
- "FFAAEEEEAAFFFFFAAEEEEAAFFFFFAAEEEEAAFFFFFAAEEEEAAFFF",
- "FAEEDDDDEEBFFFAEEDDDDEEBFFFAEEFFFFEEBFFFAEEFFFFEEBFF",
- "FAEDDDDDDCBFFFAEDDDDDDCBFFFAEFFFFFFCBFFFAEFFFFFFCBFF",
- "AEDDDDDDDDCBFAEDDDGGDDDCBFAEFFFFFFFFCBFAEFFFHHFFFCBF",
- "AEDDDDDDDDCBFAEDDGGGGDDCBFAEFFFFFFFFCBFAEFFHHHHFFCBF",
- "AEDDDDDDDDCBFAEDDGGGGDDCBFAEFFFFFFFFCBFAEFFHHHHFFCBF",
- "AEDDDDDDDDCBFAEDDDGGDDDCBFAEFFFFFFFFCBFAEFFFHHFFFCBF",
- "FAEDDDDDDCBFFFAEDDDDDDCBFFFAEFFFFFFCBFFFAEFFFFFFCBFF",
- "FACCDDDDCCBFFFACCDDDDCCBFFFACCFFFFCCBFFFACCFFFFCCBFF",
- "FFBBCCCCBBFFFFFBBCCCCBBFFFFFBBCCCCBBFFFFFBBCCCCBBFFF",
- "FFFFBBBBFFFFFFFFFBBBBFFFFFFFFFBBBBFFFFFFFFFBBBBFFFFF",
- "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF",
-};
-
-static IndicatorSpec radiobutton_spec = {
- 13, 13, 4, /* width, height, nimages */
- radiobutton_pixels,
- radiobutton_states
+static const char radiobtnOffData[] = "\
+ <svg width='16' height='16' version='1.1' xmlns='http://www.w3.org/2000/svg'>\n\
+ <defs>\n\
+ <linearGradient id='linearGradientOuter' x1='5' y1='5' x2='11' y2='11' gradientUnits='userSpaceOnUse'>\n\
+ <stop stop-color='#888888' offset='0'/>\n\
+ <stop stop-color='#eeeeee' offset='1'/>\n\
+ </linearGradient>\n\
+ <linearGradient id='linearGradientInner' x1='5' y1='5' x2='11' y2='11' gradientUnits='userSpaceOnUse'>\n\
+ <stop stop-color='#414141' offset='0'/>\n\
+ <stop stop-color='#d9d9d9' offset='1'/>\n\
+ </linearGradient>\n\
+ </defs>\n\
+ <circle cx='8' cy='8' r='8' fill='url(#linearGradientOuter)'/>\n\
+ <circle cx='8' cy='8' r='7' fill='url(#linearGradientInner)'/>\n\
+ <circle cx='8' cy='8' r='6' fill='#ffffff'/>\n\
+ </svg>";
+
+static const char radiobtnOnData[] = "\
+ <svg width='16' height='16' version='1.1' xmlns='http://www.w3.org/2000/svg'>\n\
+ <defs>\n\
+ <linearGradient id='linearGradientOuter' x1='5' y1='5' x2='11' y2='11' gradientUnits='userSpaceOnUse'>\n\
+ <stop stop-color='#888888' offset='0'/>\n\
+ <stop stop-color='#eeeeee' offset='1'/>\n\
+ </linearGradient>\n\
+ <linearGradient id='linearGradientInner' x1='5' y1='5' x2='11' y2='11' gradientUnits='userSpaceOnUse'>\n\
+ <stop stop-color='#414141' offset='0'/>\n\
+ <stop stop-color='#d9d9d9' offset='1'/>\n\
+ </linearGradient>\n\
+ </defs>\n\
+ <circle cx='8' cy='8' r='8' fill='url(#linearGradientOuter)'/>\n\
+ <circle cx='8' cy='8' r='7' fill='url(#linearGradientInner)'/>\n\
+ <circle cx='8' cy='8' r='6' fill='#ffffff'/>\n\
+ <circle cx='8' cy='8' r='3' fill='#000000'/>\n\
+ </svg>";
+
+static const IndicatorSpec radiobutton_spec = {
+ 16, 16,
+ radiobtnOffData,
+ radiobtnOnData
};
typedef struct {
@@ -532,21 +514,21 @@ typedef struct {
Tcl_Obj *marginObj;
} IndicatorElement;
-static Ttk_ElementOptionSpec IndicatorElementOptions[] = {
+static const Ttk_ElementOptionSpec IndicatorElementOptions[] = {
{ "-background", TK_OPTION_COLOR,
- Tk_Offset(IndicatorElement,backgroundObj), DEFAULT_BACKGROUND },
+ offsetof(IndicatorElement,backgroundObj), DEFAULT_BACKGROUND },
{ "-foreground", TK_OPTION_COLOR,
- Tk_Offset(IndicatorElement,foregroundObj), DEFAULT_FOREGROUND },
+ offsetof(IndicatorElement,foregroundObj), DEFAULT_FOREGROUND },
{ "-indicatorcolor", TK_OPTION_COLOR,
- Tk_Offset(IndicatorElement,colorObj), "#FFFFFF" },
+ offsetof(IndicatorElement,colorObj), "#FFFFFF" },
{ "-lightcolor", TK_OPTION_COLOR,
- Tk_Offset(IndicatorElement,lightColorObj), "#DDDDDD" },
+ offsetof(IndicatorElement,lightColorObj), "#DDDDDD" },
{ "-shadecolor", TK_OPTION_COLOR,
- Tk_Offset(IndicatorElement,shadeColorObj), "#888888" },
+ offsetof(IndicatorElement,shadeColorObj), "#888888" },
{ "-bordercolor", TK_OPTION_COLOR,
- Tk_Offset(IndicatorElement,borderColorObj), "black" },
+ offsetof(IndicatorElement,borderColorObj), "black" },
{ "-indicatormargin", TK_OPTION_STRING,
- Tk_Offset(IndicatorElement,marginObj), "0 2 4 2" },
+ offsetof(IndicatorElement,marginObj), "0 2 4 2" },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -555,29 +537,61 @@ static void IndicatorElementSize(
int *widthPtr, int *heightPtr,
TCL_UNUSED(Ttk_Padding *))
{
- IndicatorSpec *spec = (IndicatorSpec *)clientData;
+ const IndicatorSpec *spec = (const IndicatorSpec *)clientData;
IndicatorElement *indicator = (IndicatorElement *)elementRecord;
Ttk_Padding margins;
+ double scalingLevel = TkScalingLevel(tkwin);
+
Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &margins);
- *widthPtr = spec->width + Ttk_PaddingWidth(margins);
- *heightPtr = spec->height + Ttk_PaddingHeight(margins);
+ *widthPtr = spec->width * scalingLevel + Ttk_PaddingWidth(margins);
+ *heightPtr = spec->height * scalingLevel + Ttk_PaddingHeight(margins);
+}
+
+static void ColorToStr(
+ const XColor *colorPtr, char *colorStr) /* in the format "RRGGBB" */
+{
+ snprintf(colorStr, 7, "%02x%02x%02x",
+ colorPtr->red >> 8, colorPtr->green >> 8, colorPtr->blue >> 8);
+}
+
+static void ImageChanged( /* to be passed to Tk_GetImage() */
+ TCL_UNUSED(void *),
+ TCL_UNUSED(int),
+ TCL_UNUSED(int),
+ TCL_UNUSED(int),
+ TCL_UNUSED(int),
+ TCL_UNUSED(int),
+ TCL_UNUSED(int))
+{
}
static void IndicatorElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
- Drawable d, Ttk_Box b, unsigned int state)
+ Drawable d, Ttk_Box b, Ttk_State state)
{
- IndicatorSpec *spec = clientData;
- IndicatorElement *indicator = elementRecord;
- Display *display = Tk_Display(tkwin);
+ IndicatorElement *indicator = (IndicatorElement *)elementRecord;
Ttk_Padding padding;
- XColor *fgColor, *frameColor, *shadeColor, *indicatorColor, *borderColor;
-
- int index, ix, iy;
- XGCValues gcValues;
- GC copyGC;
- unsigned long imgColors[8];
- XImage *img = NULL;
+ const IndicatorSpec *spec = (const IndicatorSpec *)clientData;
+ double scalingLevel = TkScalingLevel(tkwin);
+ int width = spec->width * scalingLevel;
+ int height = spec->height * scalingLevel;
+
+ char bgColorStr[7], fgColorStr[7], indicatorColorStr[7],
+ shadeColorStr[7], borderColorStr[7];
+ unsigned int selected = (state & TTK_STATE_SELECTED);
+ Tcl_Interp *interp = Tk_Interp(tkwin);
+ char imgName[70];
+ Tk_Image img;
+
+ const char *svgDataPtr;
+ size_t svgDataLen;
+ char *svgDataCopy;
+ char *shadeColorPtr, *highlightColorPtr, *borderColorPtr, *bgColorPtr,
+ *indicatorColorPtr, *fgColorPtr;
+ const char *cmdFmt;
+ size_t scriptSize;
+ char *script;
+ int code;
Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &padding);
b = Ttk_PadBox(b, padding);
@@ -587,8 +601,8 @@ static void IndicatorElementDraw(
*/
if ( b.x < 0
|| b.y < 0
- || Tk_Width(tkwin) < b.x + spec->width
- || Tk_Height(tkwin) < b.y + spec->height)
+ || Tk_Width(tkwin) < b.x + width
+ || Tk_Height(tkwin) < b.y + height)
{
/* Oops! Not enough room to display the image.
* Don't draw anything.
@@ -597,109 +611,103 @@ static void IndicatorElementDraw(
}
/*
- * Fill in imgColors palette:
- *
- * (SHOULD: take light and shade colors from the border object,
- * but Tk doesn't provide easy access to these in the public API.)
+ * Construct the color strings bgColorStr, fgColorStr,
+ * indicatorColorStr, shadeColorStr, and borderColorStr
*/
- fgColor = Tk_GetColorFromObj(tkwin, indicator->foregroundObj);
- frameColor = Tk_GetColorFromObj(tkwin, indicator->backgroundObj);
- shadeColor = Tk_GetColorFromObj(tkwin, indicator->shadeColorObj);
- indicatorColor = Tk_GetColorFromObj(tkwin, indicator->colorObj);
- borderColor = Tk_GetColorFromObj(tkwin, indicator->borderColorObj);
-
- imgColors[0 /*A*/] = shadeColor->pixel;
- imgColors[1 /*B*/] = indicatorColor->pixel;
- imgColors[2 /*C*/] = frameColor->pixel;
- imgColors[3 /*D*/] = indicatorColor->pixel;
- imgColors[4 /*E*/] = borderColor->pixel;
- imgColors[5 /*F*/] = frameColor->pixel;
- imgColors[6 /*G*/] = fgColor->pixel;
- imgColors[7 /*H*/] = fgColor->pixel;
+ ColorToStr(Tk_GetColorFromObj(tkwin, indicator->backgroundObj),
+ bgColorStr);
+ ColorToStr(Tk_GetColorFromObj(tkwin, indicator->foregroundObj),
+ fgColorStr);
+ ColorToStr(Tk_GetColorFromObj(tkwin, indicator->colorObj),
+ indicatorColorStr);
+ ColorToStr(Tk_GetColorFromObj(tkwin, indicator->shadeColorObj),
+ shadeColorStr);
+ ColorToStr(Tk_GetColorFromObj(tkwin, indicator->borderColorObj),
+ borderColorStr);
/*
- * Create a scratch buffer to store the image:
+ * Check whether there is an SVG image of this size for the indicator's
+ * type (0 = checkbtn, 1 = radiobtn) and these color strings
*/
-
-#if defined(IGNORES_VISUAL)
-
- /*
- * Platforms which ignore the VisualInfo can use XCreateImage to get the
- * scratch image. This is essential on macOS, where it is not safe to call
- * XGetImage in a display procedure.
- */
-
- img = XCreateImage(display, NULL, 32, ZPixmap, 0, NULL,
- (unsigned int)spec->width, (unsigned int)spec->height,
- 0, 0);
-#else
-
- /*
- * This trick allows creating the scratch XImage without having to
- * construct a VisualInfo.
- */
-
- img = XGetImage(display, d, 0, 0,
- (unsigned int)spec->width, (unsigned int)spec->height,
- AllPlanes, ZPixmap);
-#endif
-
+ snprintf(imgName, sizeof(imgName),
+ "::tk::icons::indicator_alt%d_%d_%s_%s_%s_%s_%s",
+ width, spec->offDataPtr == radiobtnOffData,
+ shadeColorStr, indicatorColorStr, borderColorStr, bgColorStr,
+ selected ? fgColorStr : "XXXXXX");
+ img = Tk_GetImage(interp, tkwin, imgName, ImageChanged, NULL);
if (img == NULL) {
- return;
- }
-
-#if defined(IGNORES_VISUAL)
+ /*
+ * Determine the SVG data to use for the photo image
+ */
+ svgDataPtr = (selected ? spec->onDataPtr : spec->offDataPtr);
- img->data = ckalloc(img->bytes_per_line * img->height);
- if (img->data == NULL) {
- XDestroyImage(img);
- return;
- }
+ /*
+ * Copy the string pointed to by svgDataPtr to
+ * a newly allocated memory area svgDataCopy
+ */
+ svgDataLen = strlen(svgDataPtr);
+ svgDataCopy = (char *)attemptckalloc(svgDataLen + 1);
+ if (svgDataCopy == NULL) {
+ return;
+ }
+ memcpy(svgDataCopy, svgDataPtr, svgDataLen);
+ svgDataCopy[svgDataLen] = '\0';
-#endif
+ /*
+ * Update the colors within svgDataCopy
+ */
- /*
- * Create the image, painting it into the XImage one pixel at a time.
- */
+ shadeColorPtr = strstr(svgDataCopy, "888888");
+ highlightColorPtr = strstr(svgDataCopy, "eeeeee");
+ borderColorPtr = strstr(svgDataCopy, "414141");
+ bgColorPtr = strstr(svgDataCopy, "d9d9d9");
+ indicatorColorPtr = strstr(svgDataCopy, "ffffff");
+ fgColorPtr = strstr(svgDataCopy, "000000");
+
+ assert(shadeColorPtr);
+ assert(highlightColorPtr);
+ assert(borderColorPtr);
+ assert(bgColorPtr);
+ assert(indicatorColorPtr);
+
+ memcpy(shadeColorPtr, shadeColorStr, 6);
+ memcpy(highlightColorPtr, indicatorColorStr, 6);
+ memcpy(borderColorPtr, borderColorStr, 6);
+ memcpy(bgColorPtr, bgColorStr, 6);
+ memcpy(indicatorColorPtr, indicatorColorStr, 6);
+ if (fgColorPtr != NULL) {
+ memcpy(fgColorPtr, fgColorStr, 6);
+ }
- index = Ttk_StateTableLookup(spec->map, state);
- for (iy=0 ; iy<spec->height ; iy++) {
- for (ix=0 ; ix<spec->width ; ix++) {
- XPutPixel(img, ix, iy,
- imgColors[spec->pixels[iy][index*spec->width+ix] - 'A'] );
+ /*
+ * Create an SVG photo image from svgDataCopy
+ */
+ cmdFmt = "image create photo %s -format $::tk::svgFmt -data {%s}";
+ scriptSize = strlen(cmdFmt) + strlen(imgName) + svgDataLen;
+ script = (char *)attemptckalloc(scriptSize);
+ if (script == NULL) {
+ ckfree(svgDataCopy);
+ return;
+ }
+ snprintf(script, scriptSize, cmdFmt, imgName, svgDataCopy);
+ ckfree(svgDataCopy);
+ code = Tcl_EvalEx(interp, script, -1, TCL_EVAL_GLOBAL);
+ ckfree(script);
+ if (code != TCL_OK) {
+ Tcl_BackgroundException(interp, code);
+ return;
}
+ img = Tk_GetImage(interp, tkwin, imgName, ImageChanged, NULL);
}
/*
- * Copy the image onto our target drawable surface.
- */
-
- memset(&gcValues, 0, sizeof(gcValues));
- copyGC = Tk_GetGC(tkwin, 0, &gcValues);
- TkPutImage(NULL, 0, display, d, copyGC, img, 0, 0, b.x, b.y,
- spec->width, spec->height);
-
- /*
- * Tidy up.
- */
-
- Tk_FreeGC(display, copyGC);
-
- /*
- * Protect against the possibility that some future platform might
- * not use the Tk memory manager in its implementation of XDestroyImage,
- * even though that would be an extremely strange thing to do.
+ * Display the image
*/
-
-#if defined(IGNORES_VISUAL)
- ckfree(img->data);
- img->data = NULL;
-#endif
-
- XDestroyImage(img);
+ Tk_RedrawImage(img, 0, 0, width, height, d, b.x, b.y);
+ Tk_FreeImage(img);
}
-static Ttk_ElementSpec IndicatorElementSpec = {
+static const Ttk_ElementSpec IndicatorElementSpec = {
TK_STYLE_VERSION_2,
sizeof(IndicatorElement),
IndicatorElementOptions,
@@ -714,8 +722,6 @@ static Ttk_ElementSpec IndicatorElementSpec = {
* clientData is an enum ArrowDirection pointer.
*/
-static int ArrowElements[] = { ARROW_UP, ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT };
-
typedef struct {
Tcl_Obj *sizeObj;
Tcl_Obj *colorObj; /* Arrow color */
@@ -724,17 +730,17 @@ typedef struct {
Tcl_Obj *reliefObj;
} ArrowElement;
-static Ttk_ElementOptionSpec ArrowElementOptions[] = {
+static const Ttk_ElementOptionSpec ArrowElementOptions[] = {
{ "-arrowsize", TK_OPTION_PIXELS,
- Tk_Offset(ArrowElement,sizeObj), STRINGIFY(SCROLLBAR_WIDTH) },
+ offsetof(ArrowElement,sizeObj), STRINGIFY(SCROLLBAR_WIDTH) },
{ "-arrowcolor", TK_OPTION_COLOR,
- Tk_Offset(ArrowElement,colorObj), "black"},
+ offsetof(ArrowElement,colorObj), "black"},
{ "-background", TK_OPTION_BORDER,
- Tk_Offset(ArrowElement,borderObj), DEFAULT_BACKGROUND },
+ offsetof(ArrowElement,borderObj), DEFAULT_BACKGROUND },
{ "-bordercolor", TK_OPTION_COLOR,
- Tk_Offset(ArrowElement,borderColorObj), "black" },
+ offsetof(ArrowElement,borderColorObj), "black" },
{ "-relief", TK_OPTION_RELIEF,
- Tk_Offset(ArrowElement,reliefObj), "raised"},
+ offsetof(ArrowElement,reliefObj), "raised"},
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -743,7 +749,7 @@ static Ttk_ElementOptionSpec ArrowElementOptions[] = {
* top/left padding is 1 less than bottom/right,
* since in this theme 2-pixel borders are asymmetric.
*/
-static Ttk_Padding ArrowPadding = { 3,3,4,4 };
+static const Ttk_Padding ArrowPadding = { 3,3,4,4 };
static void ArrowElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
@@ -751,14 +757,21 @@ static void ArrowElementSize(
TCL_UNUSED(Ttk_Padding *))
{
ArrowElement *arrow = (ArrowElement *)elementRecord;
- int direction = *(int *)clientData;
+ ArrowDirection direction = (ArrowDirection)PTR2INT(clientData);
+ double scalingLevel = TkScalingLevel(tkwin);
+ Ttk_Padding padding;
int size = SCROLLBAR_WIDTH;
+ padding.left = round(ArrowPadding.left * scalingLevel);
+ padding.right = padding.left + 1;
+ padding.top = round(ArrowPadding.top * scalingLevel);
+ padding.bottom = padding.top + 1;
+
Tk_GetPixelsFromObj(NULL, tkwin, arrow->sizeObj, &size);
- size -= Ttk_PaddingWidth(ArrowPadding);
+ size -= Ttk_PaddingWidth(padding);
TtkArrowSize(size/2, direction, widthPtr, heightPtr);
- *widthPtr += Ttk_PaddingWidth(ArrowPadding);
- *heightPtr += Ttk_PaddingHeight(ArrowPadding);
+ *widthPtr += Ttk_PaddingWidth(padding);
+ *heightPtr += Ttk_PaddingHeight(padding);
if (*widthPtr < *heightPtr) {
*widthPtr = *heightPtr;
} else {
@@ -772,10 +785,12 @@ static void ArrowElementDraw(
TCL_UNUSED(Ttk_State))
{
ArrowElement *arrow = (ArrowElement *)elementRecord;
- int direction = *(int *)clientData;
+ ArrowDirection direction = (ArrowDirection)PTR2INT(clientData);
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, arrow->borderObj);
XColor *borderColor = Tk_GetColorFromObj(tkwin, arrow->borderColorObj);
int borderWidth = 2, relief = TK_RELIEF_RAISED;
+ Ttk_Padding padding;
+ double scalingLevel = TkScalingLevel(tkwin);
int cx = 0, cy = 0;
XColor *arrowColor = Tk_GetColorFromObj(tkwin, arrow->colorObj);
GC gc = Tk_GCForColor(arrowColor, d);
@@ -786,7 +801,12 @@ static void ArrowElementDraw(
0, TK_RELIEF_FLAT);
DrawBorder(tkwin, d, border, borderColor, b, borderWidth, relief);
- b = Ttk_PadBox(b, ArrowPadding);
+ padding.left = round(ArrowPadding.left * scalingLevel);
+ padding.right = padding.left + 1;
+ padding.top = round(ArrowPadding.top * scalingLevel);
+ padding.bottom = padding.top + 1;
+
+ b = Ttk_PadBox(b, padding);
switch (direction) {
case ARROW_UP:
@@ -810,7 +830,7 @@ static void ArrowElementDraw(
TtkFillArrow(Tk_Display(tkwin), d, gc, b, direction);
}
-static Ttk_ElementSpec ArrowElementSpec = {
+static const Ttk_ElementSpec ArrowElementSpec = {
TK_STYLE_VERSION_2,
sizeof(ArrowElement),
ArrowElementOptions,
@@ -830,14 +850,21 @@ static void BoxArrowElementSize(
TCL_UNUSED(Ttk_Padding *))
{
ArrowElement *arrow = (ArrowElement *)elementRecord;
- int direction = *(int *)clientData;
- int size = SCROLLBAR_WIDTH;
+ ArrowDirection direction = (ArrowDirection)PTR2INT(clientData);
+ double scalingLevel = TkScalingLevel(tkwin);
+ Ttk_Padding padding;
+ int size = 14;
+
+ padding.left = round(ArrowPadding.left * scalingLevel);
+ padding.top = round(ArrowPadding.top * scalingLevel);
+ padding.right = round(ArrowPadding.right * scalingLevel);
+ padding.bottom = round(ArrowPadding.bottom * scalingLevel);
Tk_GetPixelsFromObj(NULL, tkwin, arrow->sizeObj, &size);
- size -= Ttk_PaddingWidth(ArrowPadding);
+ size -= Ttk_PaddingWidth(padding);
TtkArrowSize(size/2, direction, widthPtr, heightPtr);
- *widthPtr += Ttk_PaddingWidth(ArrowPadding);
- *heightPtr += Ttk_PaddingHeight(ArrowPadding);
+ *widthPtr += Ttk_PaddingWidth(padding);
+ *heightPtr += Ttk_PaddingHeight(padding);
}
static void BoxArrowElementDraw(
@@ -846,13 +873,15 @@ static void BoxArrowElementDraw(
TCL_UNUSED(Ttk_State))
{
ArrowElement *arrow = (ArrowElement *)elementRecord;
- int direction = *(int *)clientData;
+ ArrowDirection direction = (ArrowDirection)PTR2INT(clientData);
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, arrow->borderObj);
XColor *borderColor = Tk_GetColorFromObj(tkwin, arrow->borderColorObj);
int borderWidth = 2, relief = TK_RELIEF_RAISED;
Display *disp = Tk_Display(tkwin);
GC darkGC = Tk_3DBorderGC(tkwin, border, TK_3D_DARK_GC);
int w = WIN32_XDRAWLINE_HACK;
+ Ttk_Padding padding;
+ double scalingLevel = TkScalingLevel(tkwin);
int cx = 0, cy = 0;
XColor *arrowColor = Tk_GetColorFromObj(tkwin, arrow->colorObj);
GC arrowGC = Tk_GCForColor(arrowColor, d);
@@ -863,7 +892,12 @@ static void BoxArrowElementDraw(
XDrawLine(disp, d, darkGC, b.x, b.y+1, b.x, b.y+b.height-2+w);
- b = Ttk_PadBox(b, ArrowPadding);
+ padding.left = round(ArrowPadding.left * scalingLevel);
+ padding.top = round(ArrowPadding.top * scalingLevel);
+ padding.right = round(ArrowPadding.right * scalingLevel);
+ padding.bottom = round(ArrowPadding.bottom * scalingLevel);
+
+ b = Ttk_PadBox(b, padding);
TtkArrowSize(b.width/2, direction, &cx, &cy);
if ((b.height - cy) % 2 == 1) {
@@ -875,7 +909,7 @@ static void BoxArrowElementDraw(
TtkFillArrow(disp, d, arrowGC, b, direction);
}
-static Ttk_ElementSpec BoxArrowElementSpec = {
+static const Ttk_ElementSpec BoxArrowElementSpec = {
TK_STYLE_VERSION_2,
sizeof(ArrowElement),
ArrowElementOptions,
@@ -897,21 +931,21 @@ typedef struct {
} MenubuttonArrowElement;
static const char *const directionStrings[] = { /* See also: button.c */
- "above", "below", "left", "right", "flush", NULL
+ "above", "below", "flush", "left", "right", NULL
};
-enum { POST_ABOVE, POST_BELOW, POST_LEFT, POST_RIGHT, POST_FLUSH };
+enum { POST_ABOVE, POST_BELOW, POST_FLUSH, POST_LEFT, POST_RIGHT };
-static Ttk_ElementOptionSpec MenubuttonArrowElementOptions[] = {
+static const Ttk_ElementOptionSpec MenubuttonArrowElementOptions[] = {
{ "-direction", TK_OPTION_STRING,
- Tk_Offset(MenubuttonArrowElement,directionObj), "below" },
+ offsetof(MenubuttonArrowElement,directionObj), "below" },
{ "-arrowsize", TK_OPTION_PIXELS,
- Tk_Offset(MenubuttonArrowElement,sizeObj), STRINGIFY(MENUBUTTON_ARROW_SIZE)},
+ offsetof(MenubuttonArrowElement,sizeObj), STRINGIFY(MENUBUTTON_ARROW_SIZE)},
{ "-arrowcolor", TK_OPTION_COLOR,
- Tk_Offset(MenubuttonArrowElement,colorObj), "black"},
+ offsetof(MenubuttonArrowElement,colorObj), "black"},
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
-static Ttk_Padding MenubuttonArrowPadding = { 3, 0, 3, 0 };
+static const Ttk_Padding MenubuttonArrowPadding = { 3, 0, 3, 0 };
static void MenubuttonArrowElementSize(
TCL_UNUSED(void *), /* clientData */
@@ -923,10 +957,19 @@ static void MenubuttonArrowElementSize(
{
MenubuttonArrowElement *arrow = (MenubuttonArrowElement *)elementRecord;
int size = MENUBUTTON_ARROW_SIZE;
+ Ttk_Padding padding;
+ double scalingLevel = TkScalingLevel(tkwin);
+
Tk_GetPixelsFromObj(NULL, tkwin, arrow->sizeObj, &size);
+
+ padding.left = round(MenubuttonArrowPadding.left * scalingLevel);
+ padding.top = round(MenubuttonArrowPadding.top * scalingLevel);
+ padding.right = round(MenubuttonArrowPadding.right * scalingLevel);
+ padding.bottom = round(MenubuttonArrowPadding.bottom * scalingLevel);
+
*widthPtr = *heightPtr = 2 * size + 1;
- *widthPtr += Ttk_PaddingWidth(MenubuttonArrowPadding);
- *heightPtr += Ttk_PaddingHeight(MenubuttonArrowPadding);
+ *widthPtr += Ttk_PaddingWidth(padding);
+ *heightPtr += Ttk_PaddingHeight(padding);
}
static void MenubuttonArrowElementDraw(
@@ -944,6 +987,8 @@ static void MenubuttonArrowElementDraw(
int postDirection = POST_BELOW;
ArrowDirection arrowDirection = ARROW_DOWN;
int width = 0, height = 0;
+ Ttk_Padding padding;
+ double scalingLevel = TkScalingLevel(tkwin);
Tk_GetPixelsFromObj(NULL, tkwin, arrow->sizeObj, &size);
Tcl_GetIndexFromObjStruct(NULL, arrow->directionObj, directionStrings,
@@ -959,12 +1004,18 @@ static void MenubuttonArrowElementDraw(
}
TtkArrowSize(size, arrowDirection, &width, &height);
- b = Ttk_PadBox(b, MenubuttonArrowPadding);
+
+ padding.left = round(MenubuttonArrowPadding.left * scalingLevel);
+ padding.top = round(MenubuttonArrowPadding.top * scalingLevel);
+ padding.right = round(MenubuttonArrowPadding.right * scalingLevel);
+ padding.bottom = round(MenubuttonArrowPadding.bottom * scalingLevel);
+
+ b = Ttk_PadBox(b, padding);
b = Ttk_AnchorBox(b, width, height, TK_ANCHOR_CENTER);
TtkFillArrow(Tk_Display(tkwin), d, gc, b, arrowDirection);
}
-static Ttk_ElementSpec MenubuttonArrowElementSpec = {
+static const Ttk_ElementSpec MenubuttonArrowElementSpec = {
TK_STYLE_VERSION_2,
sizeof(MenubuttonArrowElement),
MenubuttonArrowElementOptions,
@@ -972,92 +1023,6 @@ static Ttk_ElementSpec MenubuttonArrowElementSpec = {
MenubuttonArrowElementDraw
};
-/*----------------------------------------------------------------------
- * +++ Trough element
- *
- * Used in scrollbars and the scale.
- *
- * The -groovewidth option can be used to set the size of the short axis
- * for the drawn area. This will not affect the geometry, but can be used
- * to draw a thin centered trough inside the packet alloted. This is used
- * to show a win32-style scale widget. Use -1 or a large number to use the
- * full area (default).
- *
- */
-
-typedef struct {
- Tcl_Obj *colorObj;
- Tcl_Obj *borderWidthObj;
- Tcl_Obj *reliefObj;
- Tcl_Obj *grooveWidthObj;
- Tcl_Obj *orientObj;
-} TroughElement;
-
-static Ttk_ElementOptionSpec TroughElementOptions[] = {
- { "-orient", TK_OPTION_ANY,
- Tk_Offset(TroughElement, orientObj), "horizontal" },
- { "-troughborderwidth", TK_OPTION_PIXELS,
- Tk_Offset(TroughElement,borderWidthObj), "1" },
- { "-troughcolor", TK_OPTION_BORDER,
- Tk_Offset(TroughElement,colorObj), DEFAULT_BACKGROUND },
- { "-troughrelief",TK_OPTION_RELIEF,
- Tk_Offset(TroughElement,reliefObj), "sunken" },
- { "-groovewidth", TK_OPTION_PIXELS,
- Tk_Offset(TroughElement,grooveWidthObj), "-1" },
- { NULL, 0, 0, NULL }
-};
-
-static void TroughElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
-{
- TroughElement *troughPtr = elementRecord;
- int borderWidth = 2, grooveWidth = 0;
-
- Tk_GetPixelsFromObj(NULL, tkwin, troughPtr->borderWidthObj, &borderWidth);
- Tk_GetPixelsFromObj(NULL, tkwin, troughPtr->grooveWidthObj, &grooveWidth);
-
- if (grooveWidth <= 0) {
- *paddingPtr = Ttk_UniformPadding((short)borderWidth);
- }
-}
-
-static void TroughElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- Drawable d, Ttk_Box b, unsigned int state)
-{
- TroughElement *troughPtr = elementRecord;
- Tk_3DBorder border = NULL;
- int borderWidth = 2, relief = TK_RELIEF_SUNKEN, groove = -1, orient;
-
- border = Tk_Get3DBorderFromObj(tkwin, troughPtr->colorObj);
- Ttk_GetOrientFromObj(NULL, troughPtr->orientObj, &orient);
- Tk_GetReliefFromObj(NULL, troughPtr->reliefObj, &relief);
- Tk_GetPixelsFromObj(NULL, tkwin, troughPtr->borderWidthObj, &borderWidth);
- Tk_GetPixelsFromObj(NULL, tkwin, troughPtr->grooveWidthObj, &groove);
-
- if (groove != -1 && groove < b.height && groove < b.width) {
- if (orient == TTK_ORIENT_HORIZONTAL) {
- b.y = b.y + b.height/2 - groove/2;
- b.height = groove;
- } else {
- b.x = b.x + b.width/2 - groove/2;
- b.width = groove;
- }
- }
-
- Tk_Fill3DRectangle(tkwin, d, border, b.x, b.y, b.width, b.height,
- borderWidth, relief);
-}
-
-static Ttk_ElementSpec TroughElementSpec = {
- TK_STYLE_VERSION_2,
- sizeof(TroughElement),
- TroughElementOptions,
- TroughElementSize,
- TroughElementDraw
-};
-
/*
*----------------------------------------------------------------------
* +++ Thumb element.
@@ -1073,15 +1038,15 @@ typedef struct {
Tcl_Obj *orientObj;
} ThumbElement;
-static Ttk_ElementOptionSpec ThumbElementOptions[] = {
- { "-width", TK_OPTION_PIXELS, Tk_Offset(ThumbElement,sizeObj),
+static const Ttk_ElementOptionSpec ThumbElementOptions[] = {
+ { "-width", TK_OPTION_PIXELS, offsetof(ThumbElement,sizeObj),
STRINGIFY(SCROLLBAR_WIDTH) },
- { "-background", TK_OPTION_BORDER, Tk_Offset(ThumbElement,borderObj),
+ { "-background", TK_OPTION_BORDER, offsetof(ThumbElement,borderObj),
DEFAULT_BACKGROUND },
- { "-bordercolor", TK_OPTION_COLOR, Tk_Offset(ThumbElement,borderColorObj),
+ { "-bordercolor", TK_OPTION_COLOR, offsetof(ThumbElement,borderColorObj),
"black" },
- { "-relief", TK_OPTION_RELIEF, Tk_Offset(ThumbElement,reliefObj),"raised" },
- { "-orient", TK_OPTION_ANY, Tk_Offset(ThumbElement,orientObj),"horizontal"},
+ { "-relief", TK_OPTION_RELIEF, offsetof(ThumbElement,reliefObj),"raised" },
+ { "-orient", TK_OPTION_ANY, offsetof(ThumbElement,orientObj),"horizontal"},
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -1094,11 +1059,11 @@ static void ThumbElementSize(
TCL_UNUSED(Ttk_Padding *))
{
ThumbElement *thumb = (ThumbElement *)elementRecord;
- int orient;
+ Ttk_Orient orient;
int size;
Tk_GetPixelsFromObj(NULL, tkwin, thumb->sizeObj, &size);
- Ttk_GetOrientFromObj(NULL, thumb->orientObj, &orient);
+ TtkGetOrientFromObj(NULL, thumb->orientObj, &orient);
if (orient == TTK_ORIENT_VERTICAL) {
*widthPtr = size;
@@ -1137,7 +1102,7 @@ static void ThumbElementDraw(
DrawBorder(tkwin, d, border, borderColor, b, borderWidth, relief);
}
-static Ttk_ElementSpec ThumbElementSpec = {
+static const Ttk_ElementSpec ThumbElementSpec = {
TK_STYLE_VERSION_2,
sizeof(ThumbElement),
ThumbElementOptions,
@@ -1165,18 +1130,18 @@ typedef struct {
Tcl_Obj *orientObj; /* Orientation of overall slider */
} SliderElement;
-static Ttk_ElementOptionSpec SliderElementOptions[] = {
- { "-sliderthickness", TK_OPTION_PIXELS, Tk_Offset(SliderElement,thicknessObj),
+static const Ttk_ElementOptionSpec SliderElementOptions[] = {
+ { "-sliderthickness",TK_OPTION_PIXELS, offsetof(SliderElement,thicknessObj),
"15" },
- { "-sliderrelief", TK_OPTION_RELIEF, Tk_Offset(SliderElement,reliefObj),
+ { "-sliderrelief", TK_OPTION_RELIEF, offsetof(SliderElement,reliefObj),
"raised" },
- { "-background", TK_OPTION_BORDER, Tk_Offset(SliderElement,borderObj),
+ { "-background", TK_OPTION_BORDER, offsetof(SliderElement,borderObj),
DEFAULT_BACKGROUND },
- { "-bordercolor", TK_OPTION_COLOR, Tk_Offset(SliderElement,borderColorObj),
+ { "-bordercolor", TK_OPTION_COLOR, offsetof(SliderElement,borderColorObj),
"black" },
- { "-borderwidth", TK_OPTION_PIXELS, Tk_Offset(SliderElement,borderWidthObj),
+ { "-borderwidth", TK_OPTION_PIXELS, offsetof(SliderElement,borderWidthObj),
STRINGIFY(BORDERWIDTH) },
- { "-orient", TK_OPTION_ANY, Tk_Offset(SliderElement,orientObj),
+ { "-orient", TK_OPTION_ANY, offsetof(SliderElement,orientObj),
"horizontal" },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -1190,10 +1155,10 @@ static void SliderElementSize(
TCL_UNUSED(Ttk_Padding *))
{
SliderElement *slider = (SliderElement *)elementRecord;
- int orient;
+ Ttk_Orient orient;
int thickness, borderWidth;
- Ttk_GetOrientFromObj(NULL, slider->orientObj, &orient);
+ TtkGetOrientFromObj(NULL, slider->orientObj, &orient);
Tk_GetPixelsFromObj(NULL, tkwin, slider->thicknessObj, &thickness);
Tk_GetPixelsFromObj(NULL, tkwin, slider->borderWidthObj, &borderWidth);
@@ -1231,7 +1196,7 @@ static void SliderElementDraw(
DrawBorder(tkwin, d, border, borderColor, b, borderWidth, relief);
}
-static Ttk_ElementSpec SliderElementSpec = {
+static const Ttk_ElementSpec SliderElementSpec = {
TK_STYLE_VERSION_2,
sizeof(SliderElement),
SliderElementOptions,
@@ -1243,22 +1208,19 @@ static Ttk_ElementSpec SliderElementSpec = {
* +++ Tree indicator element.
*/
-#define TTK_STATE_OPEN TTK_STATE_USER1 /* XREF: treeview.c */
-#define TTK_STATE_LEAF TTK_STATE_USER2
-
typedef struct {
Tcl_Obj *colorObj;
Tcl_Obj *marginObj;
- Tcl_Obj *diameterObj;
+ Tcl_Obj *sizeObj;
} TreeitemIndicator;
-static Ttk_ElementOptionSpec TreeitemIndicatorOptions[] = {
+static const Ttk_ElementOptionSpec TreeitemIndicatorOptions[] = {
{ "-foreground", TK_OPTION_COLOR,
- Tk_Offset(TreeitemIndicator,colorObj), DEFAULT_FOREGROUND },
+ offsetof(TreeitemIndicator,colorObj), DEFAULT_FOREGROUND },
{ "-diameter", TK_OPTION_PIXELS,
- Tk_Offset(TreeitemIndicator,diameterObj), "9" },
+ offsetof(TreeitemIndicator,sizeObj), "6.75p" },
{ "-indicatormargins", TK_OPTION_STRING,
- Tk_Offset(TreeitemIndicator,marginObj), "2 2 4 2" },
+ offsetof(TreeitemIndicator,marginObj), "2 2 4 2" },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -1271,13 +1233,13 @@ static void TreeitemIndicatorSize(
TCL_UNUSED(Ttk_Padding *))
{
TreeitemIndicator *indicator = (TreeitemIndicator *)elementRecord;
- int size = 0;
+ int diameter = 0;
Ttk_Padding margins;
- Tk_GetPixelsFromObj(NULL, tkwin, indicator->diameterObj, &size);
+ Tk_GetPixelsFromObj(NULL, tkwin, indicator->sizeObj, &diameter);
Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &margins);
- *widthPtr = size + Ttk_PaddingWidth(margins);
- *heightPtr = size + Ttk_PaddingHeight(margins);
+ *widthPtr = diameter + Ttk_PaddingWidth(margins);
+ *heightPtr = diameter + Ttk_PaddingHeight(margins);
}
static void TreeitemIndicatorDraw(
@@ -1313,7 +1275,7 @@ static void TreeitemIndicatorDraw(
}
}
-static Ttk_ElementSpec TreeitemIndicatorElementSpec = {
+static const Ttk_ElementSpec TreeitemIndicatorElementSpec = {
TK_STYLE_VERSION_2,
sizeof(TreeitemIndicator),
TreeitemIndicatorOptions,
@@ -1346,26 +1308,25 @@ TtkAltTheme_Init(Tcl_Interp *interp)
Ttk_RegisterElement(interp, theme, "field", &FieldElementSpec, NULL);
- Ttk_RegisterElement(interp, theme, "trough", &TroughElementSpec, NULL);
Ttk_RegisterElement(interp, theme, "thumb", &ThumbElementSpec, NULL);
Ttk_RegisterElement(interp, theme, "slider", &SliderElementSpec, NULL);
Ttk_RegisterElement(interp, theme, "uparrow",
- &ArrowElementSpec, &ArrowElements[0]);
+ &ArrowElementSpec, INT2PTR(ARROW_UP));
Ttk_RegisterElement(interp, theme, "Spinbox.uparrow",
- &BoxArrowElementSpec, &ArrowElements[0]);
+ &BoxArrowElementSpec, INT2PTR(ARROW_UP));
Ttk_RegisterElement(interp, theme, "downarrow",
- &ArrowElementSpec, &ArrowElements[1]);
+ &ArrowElementSpec, INT2PTR(ARROW_DOWN));
Ttk_RegisterElement(interp, theme, "Spinbox.downarrow",
- &BoxArrowElementSpec, &ArrowElements[1]);
+ &BoxArrowElementSpec, INT2PTR(ARROW_DOWN));
Ttk_RegisterElement(interp, theme, "Combobox.downarrow",
- &BoxArrowElementSpec, &ArrowElements[1]);
+ &BoxArrowElementSpec, INT2PTR(ARROW_DOWN));
Ttk_RegisterElement(interp, theme, "leftarrow",
- &ArrowElementSpec, &ArrowElements[2]);
+ &ArrowElementSpec, INT2PTR(ARROW_LEFT));
Ttk_RegisterElement(interp, theme, "rightarrow",
- &ArrowElementSpec, &ArrowElements[3]);
+ &ArrowElementSpec, INT2PTR(ARROW_RIGHT));
Ttk_RegisterElement(interp, theme, "arrow",
- &ArrowElementSpec, &ArrowElements[0]);
+ &ArrowElementSpec, INT2PTR(ARROW_UP));
Ttk_RegisterElement(interp, theme, "Treeitem.indicator",
&TreeitemIndicatorElementSpec, NULL);
diff --git a/generic/ttk/ttkElements.c b/generic/ttk/ttkElements.c
index 365314f..7f46d6d 100644
--- a/generic/ttk/ttkElements.c
+++ b/generic/ttk/ttkElements.c
@@ -1,12 +1,12 @@
/*
- * Copyright (c) 2003 Joe English
+ * Copyright © 2003 Joe English
*
* Default implementation for themed elements.
*
*/
#include "tkInt.h"
-#include "ttkTheme.h"
+#include "ttkThemeInt.h"
#include "ttkWidget.h"
#if defined(_WIN32)
@@ -25,7 +25,7 @@
* and may be used in other engines.
*/
-/* public */ Ttk_ElementOptionSpec TtkNullElementOptions[] = { { NULL, TK_OPTION_BOOLEAN, 0, NULL } };
+/* public */ const Ttk_ElementOptionSpec TtkNullElementOptions[] = { { NULL, TK_OPTION_BOOLEAN, 0, NULL } };
/* public */ void
TtkNullElementSize(
@@ -70,9 +70,9 @@ typedef struct {
Tcl_Obj *backgroundObj;
} BackgroundElement;
-static Ttk_ElementOptionSpec BackgroundElementOptions[] = {
+static const Ttk_ElementOptionSpec BackgroundElementOptions[] = {
{ "-background", TK_OPTION_BORDER,
- Tk_Offset(BackgroundElement,backgroundObj), DEFAULT_BACKGROUND },
+ offsetof(BackgroundElement,backgroundObj), DEFAULT_BACKGROUND },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -103,7 +103,7 @@ static void BackgroundElementDraw(
d, Ttk_WinBox(tkwin), state);
}
-static Ttk_ElementSpec FillElementSpec = {
+static const Ttk_ElementSpec FillElementSpec = {
TK_STYLE_VERSION_2,
sizeof(BackgroundElement),
BackgroundElementOptions,
@@ -111,7 +111,7 @@ static Ttk_ElementSpec FillElementSpec = {
FillElementDraw
};
-static Ttk_ElementSpec BackgroundElementSpec = {
+static const Ttk_ElementSpec BackgroundElementSpec = {
TK_STYLE_VERSION_2,
sizeof(BackgroundElement),
BackgroundElementOptions,
@@ -129,13 +129,13 @@ typedef struct {
Tcl_Obj *reliefObj;
} BorderElement;
-static Ttk_ElementOptionSpec BorderElementOptions[] = {
+static const Ttk_ElementOptionSpec BorderElementOptions[] = {
{ "-background", TK_OPTION_BORDER,
- Tk_Offset(BorderElement,borderObj), DEFAULT_BACKGROUND },
+ offsetof(BorderElement,borderObj), DEFAULT_BACKGROUND },
{ "-borderwidth", TK_OPTION_PIXELS,
- Tk_Offset(BorderElement,borderWidthObj), DEFAULT_BORDERWIDTH },
+ offsetof(BorderElement,borderWidthObj), DEFAULT_BORDERWIDTH },
{ "-relief", TK_OPTION_RELIEF,
- Tk_Offset(BorderElement,reliefObj), "flat" },
+ offsetof(BorderElement,reliefObj), "flat" },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -176,7 +176,7 @@ static void BorderElementDraw(
}
}
-static Ttk_ElementSpec BorderElementSpec = {
+static const Ttk_ElementSpec BorderElementSpec = {
TK_STYLE_VERSION_2,
sizeof(BorderElement),
BorderElementOptions,
@@ -195,15 +195,15 @@ typedef struct {
Tcl_Obj *focusColorObj;
} FieldElement;
-static Ttk_ElementOptionSpec FieldElementOptions[] = {
+static const Ttk_ElementOptionSpec FieldElementOptions[] = {
{ "-fieldbackground", TK_OPTION_BORDER,
- Tk_Offset(FieldElement,borderObj), "white" },
+ offsetof(FieldElement,borderObj), "white" },
{ "-borderwidth", TK_OPTION_PIXELS,
- Tk_Offset(FieldElement,borderWidthObj), "2" },
+ offsetof(FieldElement,borderWidthObj), "2" },
{ "-focuswidth", TK_OPTION_PIXELS,
- Tk_Offset(FieldElement,focusWidthObj), "2" },
+ offsetof(FieldElement,focusWidthObj), "2" },
{ "-focuscolor", TK_OPTION_COLOR,
- Tk_Offset(FieldElement,focusColorObj), "#4a6984" },
+ offsetof(FieldElement,focusColorObj), "#4a6984" },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -247,7 +247,6 @@ static void FieldElementDraw(
int x1 = b.x, x2 = b.x + b.width - 1;
int y1 = b.y, y2 = b.y + b.height - 1;
int w = WIN32_XDRAWLINE_HACK;
- GC bgGC;
/*
* Draw the outer rounded rectangle
@@ -266,7 +265,7 @@ static void FieldElementDraw(
/*
* Fill the inner rectangle
*/
- bgGC = Tk_3DBorderGC(tkwin, border, TK_3D_FLAT_GC);
+ GC bgGC = Tk_3DBorderGC(tkwin, border, TK_3D_FLAT_GC);
XFillRectangle(disp, d, bgGC, b.x+1, b.y+1, b.width-2, b.height-2);
} else {
/*
@@ -291,7 +290,7 @@ static void FieldElementDraw(
}
}
-static Ttk_ElementSpec FieldElementSpec = {
+static const Ttk_ElementSpec FieldElementSpec = {
TK_STYLE_VERSION_2,
sizeof(FieldElement),
FieldElementOptions,
@@ -316,13 +315,13 @@ typedef struct {
Tcl_Obj *shiftreliefObj;
} PaddingElement;
-static Ttk_ElementOptionSpec PaddingElementOptions[] = {
+static const Ttk_ElementOptionSpec PaddingElementOptions[] = {
{ "-padding", TK_OPTION_STRING,
- Tk_Offset(PaddingElement,paddingObj), "0" },
+ offsetof(PaddingElement,paddingObj), "0" },
{ "-relief", TK_OPTION_RELIEF,
- Tk_Offset(PaddingElement,reliefObj), "flat" },
+ offsetof(PaddingElement,reliefObj), "flat" },
{ "-shiftrelief", TK_OPTION_PIXELS,
- Tk_Offset(PaddingElement,shiftreliefObj), "0" },
+ offsetof(PaddingElement,shiftreliefObj), "0" },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -345,7 +344,7 @@ static void PaddingElementSize(
*paddingPtr = Ttk_RelievePadding(pad, relief, shiftRelief);
}
-static Ttk_ElementSpec PaddingElementSpec = {
+static const Ttk_ElementSpec PaddingElementSpec = {
TK_STYLE_VERSION_2,
sizeof(PaddingElement),
PaddingElementOptions,
@@ -393,13 +392,13 @@ static void DrawFocusRing(
Tk_FreeGC(Tk_Display(tkwin), gc);
}
-static Ttk_ElementOptionSpec FocusElementOptions[] = {
+static const Ttk_ElementOptionSpec FocusElementOptions[] = {
{ "-focuscolor", TK_OPTION_COLOR,
- Tk_Offset(FocusElement,focusColorObj), "black" },
+ offsetof(FocusElement,focusColorObj), "black" },
{ "-focusthickness", TK_OPTION_PIXELS,
- Tk_Offset(FocusElement,focusThicknessObj), "1" },
+ offsetof(FocusElement,focusThicknessObj), "1" },
{ "-focussolid", TK_OPTION_BOOLEAN,
- Tk_Offset(FocusElement,focusSolidObj), "0" },
+ offsetof(FocusElement,focusSolidObj), "0" },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -438,7 +437,7 @@ static void FocusElementDraw(
}
}
-static Ttk_ElementSpec FocusElementSpec = {
+static const Ttk_ElementSpec FocusElementSpec = {
TK_STYLE_VERSION_2,
sizeof(FocusElement),
FocusElementOptions,
@@ -458,11 +457,11 @@ typedef struct {
Tcl_Obj *borderObj;
} SeparatorElement;
-static Ttk_ElementOptionSpec SeparatorElementOptions[] = {
+static const Ttk_ElementOptionSpec SeparatorElementOptions[] = {
{ "-orient", TK_OPTION_ANY,
- Tk_Offset(SeparatorElement, orientObj), "horizontal" },
+ offsetof(SeparatorElement, orientObj), "horizontal" },
{ "-background", TK_OPTION_BORDER,
- Tk_Offset(SeparatorElement,borderObj), DEFAULT_BACKGROUND },
+ offsetof(SeparatorElement,borderObj), DEFAULT_BACKGROUND },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -516,9 +515,9 @@ static void GeneralSeparatorElementDraw(
Drawable d, Ttk_Box b, Ttk_State state)
{
SeparatorElement *separator = (SeparatorElement *)elementRecord;
- int orient;
+ Ttk_Orient orient;
- Ttk_GetOrientFromObj(NULL, separator->orientObj, &orient);
+ TtkGetOrientFromObj(NULL, separator->orientObj, &orient);
switch (orient) {
case TTK_ORIENT_HORIZONTAL:
HorizontalSeparatorElementDraw(
@@ -531,7 +530,7 @@ static void GeneralSeparatorElementDraw(
}
}
-static Ttk_ElementSpec HorizontalSeparatorElementSpec = {
+static const Ttk_ElementSpec HorizontalSeparatorElementSpec = {
TK_STYLE_VERSION_2,
sizeof(SeparatorElement),
SeparatorElementOptions,
@@ -539,7 +538,7 @@ static Ttk_ElementSpec HorizontalSeparatorElementSpec = {
HorizontalSeparatorElementDraw
};
-static Ttk_ElementSpec VerticalSeparatorElementSpec = {
+static const Ttk_ElementSpec VerticalSeparatorElementSpec = {
TK_STYLE_VERSION_2,
sizeof(SeparatorElement),
SeparatorElementOptions,
@@ -547,7 +546,7 @@ static Ttk_ElementSpec VerticalSeparatorElementSpec = {
HorizontalSeparatorElementDraw
};
-static Ttk_ElementSpec SeparatorElementSpec = {
+static const Ttk_ElementSpec SeparatorElementSpec = {
TK_STYLE_VERSION_2,
sizeof(SeparatorElement),
SeparatorElementOptions,
@@ -561,11 +560,14 @@ static Ttk_ElementSpec SeparatorElementSpec = {
typedef struct {
Tcl_Obj *backgroundObj;
+ Tcl_Obj *gripSizeObj;
} SizegripElement;
-static Ttk_ElementOptionSpec SizegripOptions[] = {
+static const Ttk_ElementOptionSpec SizegripOptions[] = {
{ "-background", TK_OPTION_BORDER,
- Tk_Offset(SizegripElement,backgroundObj), DEFAULT_BACKGROUND },
+ offsetof(SizegripElement,backgroundObj), DEFAULT_BACKGROUND },
+ { "-gripsize", TK_OPTION_PIXELS,
+ offsetof(SizegripElement,gripSizeObj), "11.25p" },
{0, TK_OPTION_BOOLEAN, 0, 0}
};
@@ -577,8 +579,11 @@ static void SizegripSize(
int *heightPtr,
TCL_UNUSED(Ttk_Padding *))
{
- int gripCount = 3, gripSpace = 2, gripThickness = 3;
- *widthPtr = *heightPtr = gripCount * (gripSpace + gripThickness);
+ SizegripElement *grip = (SizegripElement *)elementRecord;
+ int gripSize = 0;
+
+ Tk_GetPixelsFromObj(NULL, tkwin, grip->gripSizeObj, &gripSize);
+ *widthPtr = *heightPtr = gripSize;
}
static void SizegripDraw(
@@ -590,21 +595,26 @@ static void SizegripDraw(
TCL_UNUSED(Ttk_State))
{
SizegripElement *grip = (SizegripElement *)elementRecord;
- int gripCount = 3, gripSpace = 2;
+ int gripSize = 0;
+ int gripCount = 3, gripSpace, gripThickness;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, grip->backgroundObj);
GC lightGC = Tk_3DBorderGC(tkwin, border, TK_3D_LIGHT_GC);
GC darkGC = Tk_3DBorderGC(tkwin, border, TK_3D_DARK_GC);
int x1 = b.x + b.width-1, y1 = b.y + b.height-1, x2 = x1, y2 = y1;
+ Tk_GetPixelsFromObj(NULL, tkwin, grip->gripSizeObj, &gripSize);
+ gripThickness = gripSize * 3 / (gripCount * 5);
+ gripSpace = gripSize / 3 - gripThickness;
while (gripCount--) {
x1 -= gripSpace; y2 -= gripSpace;
- XDrawLine(Tk_Display(tkwin), d, darkGC, x1, y1, x2, y2); --x1; --y2;
- XDrawLine(Tk_Display(tkwin), d, darkGC, x1, y1, x2, y2); --x1; --y2;
- XDrawLine(Tk_Display(tkwin), d, lightGC, x1, y1, x2, y2); --x1; --y2;
+ for (int i = 1; i < gripThickness; i++) {
+ XDrawLine(Tk_Display(tkwin), d, darkGC, x1,y1, x2,y2); --x1; --y2;
+ }
+ XDrawLine(Tk_Display(tkwin), d, lightGC, x1,y1, x2,y2); --x1; --y2;
}
}
-static Ttk_ElementSpec SizegripElementSpec = {
+static const Ttk_ElementSpec SizegripElementSpec = {
TK_STYLE_VERSION_2,
sizeof(SizegripElement),
SizegripOptions,
@@ -616,230 +626,278 @@ static Ttk_ElementSpec SizegripElementSpec = {
* +++ Indicator element.
*
* Draws the on/off indicator for checkbuttons and radiobuttons.
- *
- * Draws a 3-D square (or diamond), raised if off, sunken if on.
- *
- * This is actually a regression from Tk 8.5 back to the ugly old Motif
- * style; use "altTheme" for the newer, nicer version.
*/
+/*
+ * Indicator image descriptor:
+ */
+typedef struct {
+ int width; /* unscaled width */
+ int height; /* unscaled height */
+ const char *const offDataPtr;
+ const char *const onDataPtr;
+ const char *const triDataPtr;
+} IndicatorSpec;
+
+static const char checkbtnOffData[] = "\
+ <svg width='16' height='16' version='1.1' xmlns='http://www.w3.org/2000/svg'>\n\
+ <rect x='.5' y='.5' width='15' height='15' rx='1.5' fill='#ffffff' stroke='#888888'/>\n\
+ </svg>";
+
+static const char checkbtnOnData[] = "\
+ <svg width='16' height='16' version='1.1' xmlns='http://www.w3.org/2000/svg'>\n\
+ <rect x='0' y='0' width='16' height='16' fill='#4a6984' rx='2'/>\n\
+ <path d='m4.5 8 3 3 4-6' fill='none' stroke='#ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2'/>\n\
+ </svg>";
+
+static const char checkbtnTriData[] = "\
+ <svg width='16' height='16' version='1.1' xmlns='http://www.w3.org/2000/svg'>\n\
+ <rect x='0' y='0' width='16' height='16' fill='#4a6984' rx='2'/>\n\
+ <path d='m4 8h8' fill='none' stroke='#ffffff' stroke-width='2'/>\n\
+ </svg>";
+
+static const IndicatorSpec checkbutton_spec = {
+ 16, 16,
+ checkbtnOffData,
+ checkbtnOnData,
+ checkbtnTriData
+};
+
+static const char radiobtnOffData[] = "\
+ <svg width='16' height='16' version='1.1' xmlns='http://www.w3.org/2000/svg'>\n\
+ <circle cx='8' cy='8' r='7.5' fill='#ffffff' stroke='#888888'/>\n\
+ </svg>";
+
+static const char radiobtnOnData[] = "\
+ <svg width='16' height='16' version='1.1' xmlns='http://www.w3.org/2000/svg'>\n\
+ <circle cx='8' cy='8' r='8' fill='#4a6984'/>\n\
+ <circle cx='8' cy='8' r='3' fill='#ffffff'/>\n\
+ </svg>";
+
+static const char radiobtnTriData[] = "\
+ <svg width='16' height='16' version='1.1' xmlns='http://www.w3.org/2000/svg'>\n\
+ <circle cx='8' cy='8' r='8' fill='#4a6984'/>\n\
+ <path d='m4 8h8' fill='none' stroke='#ffffff' stroke-width='2'/>\n\
+ </svg>";
+
+static const IndicatorSpec radiobutton_spec = {
+ 16, 16,
+ radiobtnOffData,
+ radiobtnOnData,
+ radiobtnTriData
+};
+
typedef struct {
Tcl_Obj *backgroundObj;
- Tcl_Obj *reliefObj;
- Tcl_Obj *colorObj;
- Tcl_Obj *diameterObj;
+ Tcl_Obj *foregroundObj;
+ Tcl_Obj *borderColorObj;
Tcl_Obj *marginObj;
- Tcl_Obj *borderWidthObj;
} IndicatorElement;
-static Ttk_ElementOptionSpec IndicatorElementOptions[] = {
- { "-background", TK_OPTION_BORDER,
- Tk_Offset(IndicatorElement,backgroundObj), DEFAULT_BACKGROUND },
- { "-indicatorcolor", TK_OPTION_BORDER,
- Tk_Offset(IndicatorElement,colorObj), DEFAULT_BACKGROUND },
- { "-indicatorrelief", TK_OPTION_RELIEF,
- Tk_Offset(IndicatorElement,reliefObj), "raised" },
- { "-indicatordiameter", TK_OPTION_PIXELS,
- Tk_Offset(IndicatorElement,diameterObj), "12" },
+/*
+ * Note that the -indicatorbackground and -indicatorforeground options below
+ * have the same default value "#ffffff", but the -indicatorforeground option
+ * will only be used for the alternate and selected states, in which the
+ * -indicatorbackground option will have a different value (e.g., "#4a6984").
+ */
+static const Ttk_ElementOptionSpec IndicatorElementOptions[] = {
+ { "-indicatorbackground", TK_OPTION_COLOR,
+ offsetof(IndicatorElement,backgroundObj), "#ffffff" },
+ { "-indicatorforeground", TK_OPTION_COLOR,
+ offsetof(IndicatorElement,foregroundObj), "#ffffff" },
+ { "-bordercolor", TK_OPTION_COLOR,
+ offsetof(IndicatorElement,borderColorObj), "#888888" },
{ "-indicatormargin", TK_OPTION_STRING,
- Tk_Offset(IndicatorElement,marginObj), "0 2 4 2" },
- { "-borderwidth", TK_OPTION_PIXELS,
- Tk_Offset(IndicatorElement,borderWidthObj), DEFAULT_BORDERWIDTH },
+ offsetof(IndicatorElement,marginObj), "0 2 4 2" },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
-/*
- * Checkbutton indicators (default): 3-D square.
- */
-static void SquareIndicatorElementSize(
+static void IndicatorElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
- int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
+ int *widthPtr, int *heightPtr,
+ TCL_UNUSED(Ttk_Padding *))
{
- IndicatorElement *indicator = elementRecord;
+ const IndicatorSpec *spec = (const IndicatorSpec *)clientData;
+ IndicatorElement *indicator = (IndicatorElement *)elementRecord;
Ttk_Padding margins;
- int diameter = 0;
+ double scalingLevel = TkScalingLevel(tkwin);
+
Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &margins);
- Tk_GetPixelsFromObj(NULL, tkwin, indicator->diameterObj, &diameter);
- *widthPtr = diameter + Ttk_PaddingWidth(margins);
- *heightPtr = diameter + Ttk_PaddingHeight(margins);
+ *widthPtr = spec->width * scalingLevel + Ttk_PaddingWidth(margins);
+ *heightPtr = spec->height * scalingLevel + Ttk_PaddingHeight(margins);
}
-static void SquareIndicatorElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- Drawable d, Ttk_Box b, unsigned int state)
+static void ColorToStr(
+ const XColor *colorPtr, char *colorStr) /* in the format "RRGGBB" */
{
- IndicatorElement *indicator = elementRecord;
- Tk_3DBorder border = 0, interior = 0;
- int relief = TK_RELIEF_RAISED;
- Ttk_Padding padding;
- int borderWidth = 2;
- int diameter;
-
- interior = Tk_Get3DBorderFromObj(tkwin, indicator->colorObj);
- border = Tk_Get3DBorderFromObj(tkwin, indicator->backgroundObj);
- Tk_GetPixelsFromObj(NULL, tkwin, indicator->borderWidthObj, &borderWidth);
- Tk_GetReliefFromObj(NULL, indicator->reliefObj, &relief);
- Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &padding);
-
- b = Ttk_PadBox(b, padding);
-
- diameter = b.width < b.height ? b.width : b.height;
- Tk_Fill3DRectangle(tkwin, d, interior, b.x, b.y,
- diameter, diameter, borderWidth, TK_RELIEF_FLAT);
- Tk_Draw3DRectangle(tkwin, d, border, b.x, b.y,
- diameter, diameter, borderWidth, relief);
+ snprintf(colorStr, 7, "%02x%02x%02x",
+ colorPtr->red >> 8, colorPtr->green >> 8, colorPtr->blue >> 8);
}
-/*
- * Radiobutton indicators: 3-D diamond.
- */
-static void DiamondIndicatorElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
+static void ImageChanged( /* to be passed to Tk_GetImage() */
+ TCL_UNUSED(void *),
+ TCL_UNUSED(int),
+ TCL_UNUSED(int),
+ TCL_UNUSED(int),
+ TCL_UNUSED(int),
+ TCL_UNUSED(int),
+ TCL_UNUSED(int))
{
- IndicatorElement *indicator = (IndicatorElement *)elementRecord;
- Ttk_Padding margins;
- int diameter = 0;
- Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &margins);
- Tk_GetPixelsFromObj(NULL, tkwin, indicator->diameterObj, &diameter);
- *widthPtr = diameter + 3 + Ttk_PaddingWidth(margins);
- *heightPtr = diameter + 3 + Ttk_PaddingHeight(margins);
}
-static void DiamondIndicatorElementDraw(
+static void IndicatorElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, Ttk_State state)
{
IndicatorElement *indicator = (IndicatorElement *)elementRecord;
- Tk_3DBorder border = 0, interior = 0;
- int borderWidth = 2;
- int relief = TK_RELIEF_RAISED;
- int diameter, radius;
- XPoint points[4];
Ttk_Padding padding;
+ const IndicatorSpec *spec = (const IndicatorSpec *)clientData;
+ double scalingLevel = TkScalingLevel(tkwin);
+ int width = spec->width * scalingLevel;
+ int height = spec->height * scalingLevel;
+
+ char bgColorStr[7], fgColorStr[7], borderColorStr[7];
+ unsigned int selected = (state & TTK_STATE_SELECTED);
+ unsigned int tristate = (state & TTK_STATE_ALTERNATE);
+ Tcl_Interp *interp = Tk_Interp(tkwin);
+ char imgName[60];
+ Tk_Image img;
+
+ const char *svgDataPtr;
+ size_t svgDataLen;
+ char *svgDataCopy;
+ char *bgColorPtr, *fgColorPtr, *borderColorPtr;
+ const char *cmdFmt;
+ size_t scriptSize;
+ char *script;
+ int code;
- interior = Tk_Get3DBorderFromObj(tkwin, indicator->colorObj);
- border = Tk_Get3DBorderFromObj(tkwin, indicator->backgroundObj);
- Tk_GetPixelsFromObj(NULL, tkwin, indicator->borderWidthObj, &borderWidth);
- Tk_GetReliefFromObj(NULL, indicator->reliefObj, &relief);
Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &padding);
-
b = Ttk_PadBox(b, padding);
- diameter = b.width < b.height ? b.width : b.height;
- radius = diameter / 2;
+ /*
+ * Sanity check
+ */
+ if ( b.x < 0
+ || b.y < 0
+ || Tk_Width(tkwin) < b.x + width
+ || Tk_Height(tkwin) < b.y + height)
+ {
+ /* Oops! Not enough room to display the image.
+ * Don't draw anything.
+ */
+ return;
+ }
- points[0].x = b.x;
- points[0].y = b.y + radius;
- points[1].x = b.x + radius;
- points[1].y = b.y + 2*radius;
- points[2].x = b.x + 2*radius;
- points[2].y = b.y + radius;
- points[3].x = b.x + radius;
- points[3].y = b.y;
+ /*
+ * Construct the color strings bgColorStr, fgColorStr, and borderColorStr
+ */
+ ColorToStr(Tk_GetColorFromObj(tkwin, indicator->backgroundObj),
+ bgColorStr);
+ ColorToStr(Tk_GetColorFromObj(tkwin, indicator->foregroundObj),
+ fgColorStr);
+ ColorToStr(Tk_GetColorFromObj(tkwin, indicator->borderColorObj),
+ borderColorStr);
- Tk_Fill3DPolygon(tkwin, d, interior, points, 4, borderWidth, TK_RELIEF_FLAT);
- Tk_Draw3DPolygon(tkwin, d, border, points, 4, borderWidth, relief);
-}
+ /*
+ * Check whether there is an SVG image of this size for the
+ * indicator's type (0 = checkbtn, 1 = radiobtn), "state"
+ * (0 = off, 1 = on, 2 = tristate), and these color strings
+ */
+ snprintf(imgName, sizeof(imgName),
+ "::tk::icons::indicator_default%d_%d,%d_%s_%s_%s",
+ width,
+ spec->offDataPtr == radiobtnOffData,
+ tristate ? 2 : (selected ? 1 : 0),
+ bgColorStr,
+ selected || tristate ? fgColorStr : "XXXXXX",
+ selected || tristate ? "XXXXXX" : borderColorStr);
+ img = Tk_GetImage(interp, tkwin, imgName, ImageChanged, NULL);
+ if (img == NULL) {
+ /*
+ * Determine the SVG data to use for the photo image
+ */
+ svgDataPtr = (tristate ? spec->triDataPtr :
+ (selected ? spec->onDataPtr : spec->offDataPtr));
-static Ttk_ElementSpec CheckbuttonIndicatorElementSpec = {
- TK_STYLE_VERSION_2,
- sizeof(IndicatorElement),
- IndicatorElementOptions,
- SquareIndicatorElementSize,
- SquareIndicatorElementDraw
-};
+ /*
+ * Copy the string pointed to by svgDataPtr to
+ * a newly allocated memory area svgDataCopy
+ */
+ svgDataLen = strlen(svgDataPtr);
+ svgDataCopy = (char *)attemptckalloc(svgDataLen + 1);
+ if (svgDataCopy == NULL) {
+ return;
+ }
+ memcpy(svgDataCopy, svgDataPtr, svgDataLen);
+ svgDataCopy[svgDataLen] = '\0';
-static Ttk_ElementSpec RadiobuttonIndicatorElementSpec = {
- TK_STYLE_VERSION_2,
- sizeof(IndicatorElement),
- IndicatorElementOptions,
- DiamondIndicatorElementSize,
- DiamondIndicatorElementDraw
-};
+ /*
+ * Update the colors within svgDataCopy
+ */
+ if (selected || tristate) {
+ bgColorPtr = strstr(svgDataCopy, "4a6984");
+ fgColorPtr = strstr(svgDataCopy, "ffffff");
-/*
- *----------------------------------------------------------------------
- * +++ Menubutton indicators.
- *
- * These aren't functional like radio/check indicators,
- * they're just affordability indicators.
- *
- * Standard Tk sets the indicator size to 4.0 mm by 1.7 mm.
- * I have no idea where these numbers came from.
- */
+ assert(bgColorPtr);
+ assert(fgColorPtr);
-typedef struct {
- Tcl_Obj *backgroundObj;
- Tcl_Obj *widthObj;
- Tcl_Obj *heightObj;
- Tcl_Obj *borderWidthObj;
- Tcl_Obj *reliefObj;
- Tcl_Obj *marginObj;
-} MenuIndicatorElement;
+ memcpy(bgColorPtr, bgColorStr, 6);
+ memcpy(fgColorPtr, fgColorStr, 6);
+ } else {
+ bgColorPtr = strstr(svgDataCopy, "ffffff");
+ borderColorPtr = strstr(svgDataCopy, "888888");
-static Ttk_ElementOptionSpec MenuIndicatorElementOptions[] = {
- { "-background", TK_OPTION_BORDER,
- Tk_Offset(MenuIndicatorElement,backgroundObj), DEFAULT_BACKGROUND },
- { "-indicatorwidth", TK_OPTION_PIXELS,
- Tk_Offset(MenuIndicatorElement,widthObj), "4.0m" },
- { "-indicatorheight", TK_OPTION_PIXELS,
- Tk_Offset(MenuIndicatorElement,heightObj), "1.7m" },
- { "-indicatorborderwidth", TK_OPTION_PIXELS,
- Tk_Offset(MenuIndicatorElement,borderWidthObj), DEFAULT_BORDERWIDTH },
- { "-indicatorrelief", TK_OPTION_RELIEF,
- Tk_Offset(MenuIndicatorElement,reliefObj), "raised" },
- { "-indicatormargin", TK_OPTION_STRING,
- Tk_Offset(MenuIndicatorElement,marginObj), "5 0" },
- { NULL, 0, 0, NULL }
-};
+ assert(bgColorPtr);
+ assert(borderColorPtr);
-static void MenuIndicatorElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
-{
- MenuIndicatorElement *mi = elementRecord;
- Ttk_Padding margins;
- Tk_GetPixelsFromObj(NULL, tkwin, mi->widthObj, widthPtr);
- Tk_GetPixelsFromObj(NULL, tkwin, mi->heightObj, heightPtr);
- Ttk_GetPaddingFromObj(NULL, tkwin, mi->marginObj, &margins);
- *widthPtr += Ttk_PaddingWidth(margins);
- *heightPtr += Ttk_PaddingHeight(margins);
-}
+ memcpy(bgColorPtr, bgColorStr, 6);
+ memcpy(borderColorPtr, borderColorStr, 6);
+ }
-static void MenuIndicatorElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- Drawable d, Ttk_Box b, unsigned int state)
-{
- MenuIndicatorElement *mi = elementRecord;
- Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, mi->backgroundObj);
- Ttk_Padding margins;
- int borderWidth = 2;
+ /*
+ * Create an SVG photo image from svgDataCopy
+ */
+ cmdFmt = "image create photo %s -format $::tk::svgFmt -data {%s}";
+ scriptSize = strlen(cmdFmt) + strlen(imgName) + svgDataLen;
+ script = (char *)attemptckalloc(scriptSize);
+ if (script == NULL) {
+ ckfree(svgDataCopy);
+ return;
+ }
+ snprintf(script, scriptSize, cmdFmt, imgName, svgDataCopy);
+ ckfree(svgDataCopy);
+ code = Tcl_EvalEx(interp, script, -1, TCL_EVAL_GLOBAL);
+ ckfree(script);
+ if (code != TCL_OK) {
+ Tcl_BackgroundException(interp, code);
+ return;
+ }
+ img = Tk_GetImage(interp, tkwin, imgName, ImageChanged, NULL);
+ }
- Ttk_GetPaddingFromObj(NULL, tkwin, mi->marginObj, &margins);
- b = Ttk_PadBox(b, margins);
- Tk_GetPixelsFromObj(NULL, tkwin, mi->borderWidthObj, &borderWidth);
- Tk_Fill3DRectangle(tkwin, d, border, b.x, b.y, b.width, b.height,
- borderWidth, TK_RELIEF_RAISED);
+ /*
+ * Display the image
+ */
+ Tk_RedrawImage(img, 0, 0, width, height, d, b.x, b.y);
+ Tk_FreeImage(img);
}
-static Ttk_ElementSpec MenuIndicatorElementSpec = {
+static const Ttk_ElementSpec IndicatorElementSpec = {
TK_STYLE_VERSION_2,
- sizeof(MenuIndicatorElement),
- MenuIndicatorElementOptions,
- MenuIndicatorElementSize,
- MenuIndicatorElementDraw
+ sizeof(IndicatorElement),
+ IndicatorElementOptions,
+ IndicatorElementSize,
+ IndicatorElementDraw
};
/*----------------------------------------------------------------------
- * +++ Arrow elements.
+ * +++ Arrow element(s).
*
* Draws a solid triangle inside a box.
* clientData is an enum ArrowDirection pointer.
*/
-static int ArrowElements[] = { ARROW_UP, ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT };
-
typedef struct {
Tcl_Obj *sizeObj;
Tcl_Obj *colorObj;
@@ -848,21 +906,21 @@ typedef struct {
Tcl_Obj *reliefObj;
} ArrowElement;
-static Ttk_ElementOptionSpec ArrowElementOptions[] = {
+static const Ttk_ElementOptionSpec ArrowElementOptions[] = {
{ "-arrowsize", TK_OPTION_PIXELS,
- Tk_Offset(ArrowElement,sizeObj), "14" },
+ offsetof(ArrowElement,sizeObj), "14" },
{ "-arrowcolor", TK_OPTION_COLOR,
- Tk_Offset(ArrowElement,colorObj), "black"},
+ offsetof(ArrowElement,colorObj), "black"},
{ "-background", TK_OPTION_BORDER,
- Tk_Offset(ArrowElement,borderObj), DEFAULT_BACKGROUND },
+ offsetof(ArrowElement,borderObj), DEFAULT_BACKGROUND },
{ "-borderwidth", TK_OPTION_PIXELS,
- Tk_Offset(ArrowElement,borderWidthObj), "1" },
+ offsetof(ArrowElement,borderWidthObj), "1" },
{ "-relief", TK_OPTION_RELIEF,
- Tk_Offset(ArrowElement,reliefObj), "raised"},
+ offsetof(ArrowElement,reliefObj), "raised"},
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
-static Ttk_Padding ArrowPadding = { 3, 3, 3, 3 };
+static const Ttk_Padding ArrowPadding = { 3, 3, 3, 3 };
static void ArrowElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
@@ -870,14 +928,21 @@ static void ArrowElementSize(
TCL_UNUSED(Ttk_Padding *))
{
ArrowElement *arrow = (ArrowElement *)elementRecord;
- int direction = *(int *)clientData;
+ ArrowDirection direction = (ArrowDirection)PTR2INT(clientData);
+ double scalingLevel = TkScalingLevel(tkwin);
+ Ttk_Padding padding;
int size = 14;
+ padding.left = round(ArrowPadding.left * scalingLevel);
+ padding.top = round(ArrowPadding.top * scalingLevel);
+ padding.right = round(ArrowPadding.right * scalingLevel);
+ padding.bottom = round(ArrowPadding.bottom * scalingLevel);
+
Tk_GetPixelsFromObj(NULL, tkwin, arrow->sizeObj, &size);
- size -= Ttk_PaddingWidth(ArrowPadding);
+ size -= Ttk_PaddingWidth(padding);
TtkArrowSize(size/2, direction, widthPtr, heightPtr);
- *widthPtr += Ttk_PaddingWidth(ArrowPadding);
- *heightPtr += Ttk_PaddingWidth(ArrowPadding);
+ *widthPtr += Ttk_PaddingWidth(padding);
+ *heightPtr += Ttk_PaddingHeight(padding);
if (*widthPtr < *heightPtr) {
*widthPtr = *heightPtr;
} else {
@@ -891,9 +956,11 @@ static void ArrowElementDraw(
TCL_UNUSED(Ttk_State))
{
ArrowElement *arrow = (ArrowElement *)elementRecord;
- int direction = *(int *)clientData;
+ ArrowDirection direction = (ArrowDirection)PTR2INT(clientData);
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, arrow->borderObj);
int borderWidth = 1, relief = TK_RELIEF_RAISED;
+ Ttk_Padding padding;
+ double scalingLevel = TkScalingLevel(tkwin);
int cx = 0, cy = 0;
XColor *arrowColor = Tk_GetColorFromObj(tkwin, arrow->colorObj);
GC gc = Tk_GCForColor(arrowColor, d);
@@ -904,7 +971,12 @@ static void ArrowElementDraw(
Tk_Fill3DRectangle(tkwin, d, border, b.x, b.y, b.width, b.height,
borderWidth, relief);
- b = Ttk_PadBox(b, ArrowPadding);
+ padding.left = round(ArrowPadding.left * scalingLevel);
+ padding.top = round(ArrowPadding.top * scalingLevel);
+ padding.right = round(ArrowPadding.right * scalingLevel);
+ padding.bottom = round(ArrowPadding.bottom * scalingLevel);
+
+ b = Ttk_PadBox(b, padding);
switch (direction) {
case ARROW_UP:
@@ -928,7 +1000,7 @@ static void ArrowElementDraw(
TtkFillArrow(Tk_Display(tkwin), d, gc, b, direction);
}
-static Ttk_ElementSpec ArrowElementSpec = {
+static const Ttk_ElementSpec ArrowElementSpec = {
TK_STYLE_VERSION_2,
sizeof(ArrowElement),
ArrowElementOptions,
@@ -948,14 +1020,21 @@ static void BoxArrowElementSize(
TCL_UNUSED(Ttk_Padding *))
{
ArrowElement *arrow = (ArrowElement *)elementRecord;
- int direction = *(int *)clientData;
+ ArrowDirection direction = (ArrowDirection)PTR2INT(clientData);
+ double scalingLevel = TkScalingLevel(tkwin);
+ Ttk_Padding padding;
int size = 14;
+ padding.left = round(ArrowPadding.left * scalingLevel);
+ padding.top = round(ArrowPadding.top * scalingLevel);
+ padding.right = round(ArrowPadding.right * scalingLevel);
+ padding.bottom = round(ArrowPadding.bottom * scalingLevel);
+
Tk_GetPixelsFromObj(NULL, tkwin, arrow->sizeObj, &size);
- size -= Ttk_PaddingWidth(ArrowPadding);
+ size -= Ttk_PaddingWidth(padding);
TtkArrowSize(size/2, direction, widthPtr, heightPtr);
- *widthPtr += Ttk_PaddingWidth(ArrowPadding);
- *heightPtr += Ttk_PaddingWidth(ArrowPadding);
+ *widthPtr += Ttk_PaddingWidth(padding);
+ *heightPtr += Ttk_PaddingHeight(padding);
}
static void BoxArrowElementDraw(
@@ -964,12 +1043,14 @@ static void BoxArrowElementDraw(
TCL_UNUSED(Ttk_State))
{
ArrowElement *arrow = (ArrowElement *)elementRecord;
- int direction = *(int *)clientData;
+ ArrowDirection direction = (ArrowDirection)PTR2INT(clientData);
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, arrow->borderObj);
int borderWidth = 1, relief = TK_RELIEF_RAISED;
Display *disp = Tk_Display(tkwin);
GC darkGC = Tk_3DBorderGC(tkwin, border, TK_3D_DARK_GC);
int w = WIN32_XDRAWLINE_HACK;
+ Ttk_Padding padding;
+ double scalingLevel = TkScalingLevel(tkwin);
int cx = 0, cy = 0;
XColor *arrowColor = Tk_GetColorFromObj(tkwin, arrow->colorObj);
GC arrowGC = Tk_GCForColor(arrowColor, d);
@@ -979,7 +1060,12 @@ static void BoxArrowElementDraw(
XDrawLine(disp, d, darkGC, b.x, b.y+1, b.x, b.y+b.height-1+w);
- b = Ttk_PadBox(b, ArrowPadding);
+ padding.left = round(ArrowPadding.left * scalingLevel);
+ padding.top = round(ArrowPadding.top * scalingLevel);
+ padding.right = round(ArrowPadding.right * scalingLevel);
+ padding.bottom = round(ArrowPadding.bottom * scalingLevel);
+
+ b = Ttk_PadBox(b, padding);
TtkArrowSize(b.width/2, direction, &cx, &cy);
if ((b.height - cy) % 2 == 1) {
@@ -991,7 +1077,7 @@ static void BoxArrowElementDraw(
TtkFillArrow(disp, d, arrowGC, b, direction);
}
-static Ttk_ElementSpec BoxArrowElementSpec = {
+static const Ttk_ElementSpec BoxArrowElementSpec = {
TK_STYLE_VERSION_2,
sizeof(ArrowElement),
ArrowElementOptions,
@@ -999,27 +1085,111 @@ static Ttk_ElementSpec BoxArrowElementSpec = {
BoxArrowElementDraw
};
+/*
+ *----------------------------------------------------------------------
+ * +++ Menubutton indicators.
+ *
+ * These aren't functional like radio/check indicators,
+ * they're just affordability indicators.
+ */
+
+#define MENUBUTTON_ARROW_SIZE 5
+
+typedef struct {
+ Tcl_Obj *sizeObj;
+ Tcl_Obj *colorObj;
+ Tcl_Obj *paddingObj;
+} MenuIndicatorElement;
+
+static const Ttk_ElementOptionSpec MenuIndicatorElementOptions[] = {
+ { "-arrowsize", TK_OPTION_PIXELS,
+ offsetof(MenuIndicatorElement,sizeObj), STRINGIFY(MENUBUTTON_ARROW_SIZE)},
+ { "-arrowcolor", TK_OPTION_COLOR,
+ offsetof(MenuIndicatorElement,colorObj), "black" },
+ { "-arrowpadding", TK_OPTION_STRING,
+ offsetof(MenuIndicatorElement,paddingObj), "3" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
+};
+
+static void MenuIndicatorElementSize(
+ TCL_UNUSED(void *), /* clientData */
+ void *elementRecord,
+ Tk_Window tkwin,
+ int *widthPtr,
+ int *heightPtr,
+ TCL_UNUSED(Ttk_Padding *))
+{
+ MenuIndicatorElement *indicator = (MenuIndicatorElement *)elementRecord;
+ Ttk_Padding margins;
+ int size = MENUBUTTON_ARROW_SIZE;
+
+ Tk_GetPixelsFromObj(NULL, tkwin, indicator->sizeObj, &size);
+ Ttk_GetPaddingFromObj(NULL, tkwin, indicator->paddingObj, &margins);
+ TtkArrowSize(size, ARROW_DOWN, widthPtr, heightPtr);
+ *widthPtr += Ttk_PaddingWidth(margins);
+ *heightPtr += Ttk_PaddingHeight(margins);
+}
+
+static void MenuIndicatorElementDraw(
+ TCL_UNUSED(void *), /* clientData */
+ void *elementRecord,
+ Tk_Window tkwin,
+ Drawable d,
+ Ttk_Box b,
+ TCL_UNUSED(Ttk_State))
+{
+ MenuIndicatorElement *indicator = (MenuIndicatorElement *)elementRecord;
+ XColor *arrowColor = Tk_GetColorFromObj(tkwin, indicator->colorObj);
+ GC gc = Tk_GCForColor(arrowColor, d);
+ int size = MENUBUTTON_ARROW_SIZE;
+ int width, height;
+
+ Tk_GetPixelsFromObj(NULL, tkwin, indicator->sizeObj, &size);
+
+ TtkArrowSize(size, ARROW_DOWN, &width, &height);
+ b = Ttk_StickBox(b, width, height, 0);
+ TtkFillArrow(Tk_Display(tkwin), d, gc, b, ARROW_DOWN);
+}
+
+static const Ttk_ElementSpec MenuIndicatorElementSpec = {
+ TK_STYLE_VERSION_2,
+ sizeof(MenuIndicatorElement),
+ MenuIndicatorElementOptions,
+ MenuIndicatorElementSize,
+ MenuIndicatorElementDraw
+};
/*
*----------------------------------------------------------------------
* +++ Trough element.
*
* Used in scrollbars and scales in place of "border".
+ *
+ * The -groovewidth option can be used to set the size of the short axis
+ * for the drawn area. This will not affect the geometry, but can be used
+ * to draw a thin centered trough inside the packet alloted. Use -1 or a
+ * large number to use the full area (default).
*/
typedef struct {
- Tcl_Obj *colorObj;
Tcl_Obj *borderWidthObj;
Tcl_Obj *reliefObj;
+ Tcl_Obj *colorObj;
+ Tcl_Obj *grooveWidthObj;
+ Tcl_Obj *orientObj;
} TroughElement;
-static Ttk_ElementOptionSpec TroughElementOptions[] = {
- { "-borderwidth", TK_OPTION_PIXELS,
- Tk_Offset(TroughElement,borderWidthObj), DEFAULT_BORDERWIDTH },
+static const Ttk_ElementOptionSpec TroughElementOptions[] = {
+ { "-troughborderwidth", TK_OPTION_PIXELS,
+ offsetof(TroughElement,borderWidthObj), "1" },
+ { "-troughrelief",TK_OPTION_RELIEF,
+ offsetof(TroughElement,reliefObj), "sunken" },
{ "-troughcolor", TK_OPTION_BORDER,
- Tk_Offset(TroughElement,colorObj), DEFAULT_BACKGROUND },
- { "-troughrelief", TK_OPTION_RELIEF,
- Tk_Offset(TroughElement,reliefObj), "sunken" },
+ offsetof(TroughElement,colorObj), DEFAULT_BACKGROUND },
+ { "-groovewidth", TK_OPTION_PIXELS,
+ offsetof(TroughElement,grooveWidthObj), "-1" },
+ { "-orient", TK_OPTION_ANY,
+ offsetof(TroughElement, orientObj), "horizontal" },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -1031,11 +1201,15 @@ static void TroughElementSize(
TCL_UNUSED(int *), /* heightPtr */
Ttk_Padding *paddingPtr)
{
- TroughElement *troughPtr = elementRecord;
- int borderWidth = 2;
+ TroughElement *troughPtr = (TroughElement *)elementRecord;
+ int borderWidth = 1, grooveWidth = -1;
Tk_GetPixelsFromObj(NULL, tkwin, troughPtr->borderWidthObj, &borderWidth);
- *paddingPtr = Ttk_UniformPadding((short)borderWidth);
+ Tk_GetPixelsFromObj(NULL, tkwin, troughPtr->grooveWidthObj, &grooveWidth);
+
+ if (grooveWidth <= 0) {
+ *paddingPtr = Ttk_UniformPadding((short)borderWidth);
+ }
}
static void TroughElementDraw(
@@ -1045,18 +1219,41 @@ static void TroughElementDraw(
TCL_UNUSED(Ttk_State))
{
TroughElement *troughPtr = (TroughElement *)elementRecord;
- Tk_3DBorder border = NULL;
- int borderWidth = 2, relief = TK_RELIEF_SUNKEN;
+ Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, troughPtr->colorObj);
+ int borderWidth = 1, grooveWidth = -1, relief = TK_RELIEF_SUNKEN;
+ Ttk_Orient orient;
+ TkMainInfo *mainInfoPtr = ((TkWindow *) tkwin)->mainPtr;
- border = Tk_Get3DBorderFromObj(tkwin, troughPtr->colorObj);
- Tk_GetReliefFromObj(NULL, troughPtr->reliefObj, &relief);
Tk_GetPixelsFromObj(NULL, tkwin, troughPtr->borderWidthObj, &borderWidth);
+ Tk_GetPixelsFromObj(NULL, tkwin, troughPtr->grooveWidthObj, &grooveWidth);
+ Tk_GetReliefFromObj(NULL, troughPtr->reliefObj, &relief);
+ TtkGetOrientFromObj(NULL, troughPtr->orientObj, &orient);
+
+ if (grooveWidth > 0 && grooveWidth < b.height && grooveWidth < b.width) {
+ if (orient == TTK_ORIENT_HORIZONTAL) {
+ b.y += (b.height - grooveWidth) / 2;
+ b.height = grooveWidth;
+ } else {
+ b.x += (b.width - grooveWidth) / 2;
+ b.width = grooveWidth;
+ }
+
+ /*
+ * Save the data of the trough's inner box for later
+ */
+ if (mainInfoPtr != NULL) {
+ mainInfoPtr->troughInnerX = b.x + borderWidth;
+ mainInfoPtr->troughInnerY = b.y + borderWidth;
+ mainInfoPtr->troughInnerWidth = b.width - 2*borderWidth;
+ mainInfoPtr->troughInnerHeight = b.height - 2*borderWidth;
+ }
+ }
Tk_Fill3DRectangle(tkwin, d, border, b.x, b.y, b.width, b.height,
borderWidth, relief);
}
-static Ttk_ElementSpec TroughElementSpec = {
+static const Ttk_ElementSpec TroughElementSpec = {
TK_STYLE_VERSION_2,
sizeof(TroughElement),
TroughElementOptions,
@@ -1079,17 +1276,17 @@ typedef struct {
Tcl_Obj *borderWidthObj;
} ThumbElement;
-static Ttk_ElementOptionSpec ThumbElementOptions[] = {
+static const Ttk_ElementOptionSpec ThumbElementOptions[] = {
{ "-orient", TK_OPTION_ANY,
- Tk_Offset(ThumbElement, orientObj), "horizontal" },
+ offsetof(ThumbElement, orientObj), "horizontal" },
{ "-width", TK_OPTION_PIXELS,
- Tk_Offset(ThumbElement,thicknessObj), DEFAULT_ARROW_SIZE },
+ offsetof(ThumbElement,thicknessObj), DEFAULT_ARROW_SIZE },
{ "-relief", TK_OPTION_RELIEF,
- Tk_Offset(ThumbElement,reliefObj), "raised" },
+ offsetof(ThumbElement,reliefObj), "raised" },
{ "-background", TK_OPTION_BORDER,
- Tk_Offset(ThumbElement,borderObj), DEFAULT_BACKGROUND },
+ offsetof(ThumbElement,borderObj), DEFAULT_BACKGROUND },
{ "-borderwidth", TK_OPTION_PIXELS,
- Tk_Offset(ThumbElement,borderWidthObj), DEFAULT_BORDERWIDTH },
+ offsetof(ThumbElement,borderWidthObj), DEFAULT_BORDERWIDTH },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -1100,11 +1297,11 @@ static void ThumbElementSize(
TCL_UNUSED(Ttk_Padding *))
{
ThumbElement *thumb = (ThumbElement *)elementRecord;
- int orient;
+ Ttk_Orient orient;
int thickness;
Tk_GetPixelsFromObj(NULL, tkwin, thumb->thicknessObj, &thickness);
- Ttk_GetOrientFromObj(NULL, thumb->orientObj, &orient);
+ TtkGetOrientFromObj(NULL, thumb->orientObj, &orient);
if (orient == TTK_ORIENT_VERTICAL) {
*widthPtr = thickness;
@@ -1131,7 +1328,7 @@ static void ThumbElementDraw(
borderWidth, relief);
}
-static Ttk_ElementSpec ThumbElementSpec = {
+static const Ttk_ElementSpec ThumbElementSpec = {
TK_STYLE_VERSION_2,
sizeof(ThumbElement),
ThumbElementOptions,
@@ -1143,101 +1340,183 @@ static Ttk_ElementSpec ThumbElementSpec = {
*----------------------------------------------------------------------
* +++ Slider element.
*
- * This is the moving part of the scale widget. Drawn as a raised box.
+ * This is the moving part of the scale widget. Drawn as a filled circle.
*/
+#define SLIDER_DIM 16
+
+static const char sliderData[] = "\
+ <svg width='16' height='16' version='1.1' xmlns='http://www.w3.org/2000/svg'>\n\
+ <circle cx='8' cy='8' r='7.5' fill='#ffffff' stroke='#c3c3c3'/>\n\
+ <circle cx='8' cy='8' r='4' fill='#4a6984'/>\n\
+ </svg>";
+
typedef struct {
- Tcl_Obj *orientObj; /* orientation of overall slider */
- Tcl_Obj *lengthObj; /* slider length */
- Tcl_Obj *thicknessObj; /* slider thickness */
- Tcl_Obj *reliefObj; /* the relief for this object */
- Tcl_Obj *borderObj; /* the background color */
- Tcl_Obj *borderWidthObj; /* the size of the border */
+ Tcl_Obj *innerColorObj;
+ Tcl_Obj *outerColorObj;
+ Tcl_Obj *borderColorObj;
+ Tcl_Obj *orientObj; /* Orientation of overall slider */
} SliderElement;
-static Ttk_ElementOptionSpec SliderElementOptions[] = {
- { "-sliderlength", TK_OPTION_PIXELS,
- Tk_Offset(SliderElement,lengthObj), "30" },
- { "-sliderthickness", TK_OPTION_PIXELS,
- Tk_Offset(SliderElement,thicknessObj), "15" },
- { "-sliderrelief", TK_OPTION_RELIEF,
- Tk_Offset(SliderElement,reliefObj), "raised" },
- { "-sliderborderwidth", TK_OPTION_PIXELS,
- Tk_Offset(SliderElement,borderWidthObj), DEFAULT_BORDERWIDTH },
- { "-background", TK_OPTION_BORDER,
- Tk_Offset(SliderElement,borderObj), DEFAULT_BACKGROUND },
- { "-orient", TK_OPTION_ANY,
- Tk_Offset(SliderElement,orientObj), "horizontal" },
- { NULL, 0, 0, NULL }
+static const Ttk_ElementOptionSpec SliderElementOptions[] = {
+ { "-innercolor", TK_OPTION_COLOR, offsetof(SliderElement,innerColorObj),
+ "#4a6984" },
+ { "-outercolor", TK_OPTION_COLOR, offsetof(SliderElement,outerColorObj),
+ "#ffffff" },
+ { "-bordercolor", TK_OPTION_COLOR, offsetof(SliderElement,borderColorObj),
+ "#c3c3c3" },
+ { "-orient", TK_OPTION_ANY, offsetof(SliderElement,orientObj),
+ "horizontal" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void SliderElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
+ TCL_UNUSED(void *), /* clientData */
+ TCL_UNUSED(void *), /* elementRecord */
+ Tk_Window tkwin,
+ int *widthPtr, int *heightPtr,
+ TCL_UNUSED(Ttk_Padding *))
{
- SliderElement *slider = elementRecord;
- int orient, length, thickness;
+ double scalingLevel = TkScalingLevel(tkwin);
+ *widthPtr = *heightPtr = SLIDER_DIM * scalingLevel;
+}
- Ttk_GetOrientFromObj(NULL, slider->orientObj, &orient);
- Tk_GetPixelsFromObj(NULL, tkwin, slider->lengthObj, &length);
- Tk_GetPixelsFromObj(NULL, tkwin, slider->thicknessObj, &thickness);
+static void SliderElementDraw(
+ TCL_UNUSED(void *), /* clientData */
+ void *elementRecord, Tk_Window tkwin,
+ Drawable d, Ttk_Box b,
+ TCL_UNUSED(Ttk_State))
+{
+ double scalingLevel = TkScalingLevel(tkwin);
+ int dim = SLIDER_DIM * scalingLevel;
+ TkMainInfo *mainInfoPtr = ((TkWindow *) tkwin)->mainPtr;
- switch (orient) {
- case TTK_ORIENT_VERTICAL:
- *widthPtr = thickness;
- *heightPtr = length;
- break;
+ SliderElement *slider = (SliderElement *)elementRecord;
+ Ttk_Orient orient;
+ Display *disp = Tk_Display(tkwin);
+ XColor *innerColor = Tk_GetColorFromObj(tkwin, slider->innerColorObj);
+ XColor *outerColor = Tk_GetColorFromObj(tkwin, slider->outerColorObj);
+ XColor *borderColor = Tk_GetColorFromObj(tkwin, slider->borderColorObj);
+ GC gc = Tk_GCForColor(innerColor, d);
+
+ char innerColorStr[7], outerColorStr[7], borderColorStr[7];
+ Tcl_Interp *interp = Tk_Interp(tkwin);
+ char imgName[50];
+ Tk_Image img;
+
+ const char *svgDataPtr = sliderData;
+ size_t svgDataLen;
+ char *svgDataCopy;
+ char *innerColorPtr, *outerColorPtr, *borderColorPtr;
+ const char *cmdFmt;
+ size_t scriptSize;
+ char *script;
+ int code;
- case TTK_ORIENT_HORIZONTAL:
- *widthPtr = length;
- *heightPtr = thickness;
- break;
+ /*
+ * Sanity check
+ */
+ if ( b.x < 0
+ || b.y < 0
+ || Tk_Width(tkwin) < b.x + dim
+ || Tk_Height(tkwin) < b.y + dim)
+ {
+ /* Oops! Not enough room to display the image.
+ * Don't draw anything.
+ */
+ return;
}
-}
-static void SliderElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- Drawable d, Ttk_Box b, unsigned int state)
-{
- SliderElement *slider = elementRecord;
- Tk_3DBorder border = NULL;
- int relief = TK_RELIEF_RAISED, borderWidth = 2, orient;
+ /*
+ * Fill the thin trough area preceding the
+ * slider's center with the inner color
+ */
+ if (mainInfoPtr != NULL) {
+ TtkGetOrientFromObj(NULL, slider->orientObj, &orient);
+ switch (orient) {
+ case TTK_ORIENT_HORIZONTAL:
+ XFillRectangle(disp, d, gc,
+ mainInfoPtr->troughInnerX, mainInfoPtr->troughInnerY,
+ b.x + dim/2 - 1, mainInfoPtr->troughInnerHeight);
+ break;
+ case TTK_ORIENT_VERTICAL:
+ XFillRectangle(disp, d, gc,
+ mainInfoPtr->troughInnerX, mainInfoPtr->troughInnerY,
+ mainInfoPtr->troughInnerWidth, b.y + dim/2 - 1);
+ break;
+ }
+ }
- border = Tk_Get3DBorderFromObj(tkwin, slider->borderObj);
- Ttk_GetOrientFromObj(NULL, slider->orientObj, &orient);
- Tk_GetPixelsFromObj(NULL, tkwin, slider->borderWidthObj, &borderWidth);
- Tk_GetReliefFromObj(NULL, slider->reliefObj, &relief);
+ /*
+ * Construct the color strings innerColorStr,
+ * outerColorStr, and borderColorStr
+ */
+ ColorToStr(innerColor, innerColorStr);
+ ColorToStr(outerColor, outerColorStr);
+ ColorToStr(borderColor, borderColorStr);
- Tk_Fill3DRectangle(tkwin, d, border,
- b.x, b.y, b.width, b.height,
- borderWidth, relief);
+ /*
+ * Check whether there is an SVG image of this size for these color strings
+ */
+ snprintf(imgName, sizeof(imgName),
+ "::tk::icons::slider_default%d_%s_%s_%s",
+ dim, innerColorStr, outerColorStr, borderColorStr);
+ img = Tk_GetImage(interp, tkwin, imgName, ImageChanged, NULL);
+ if (img == NULL) {
+ /*
+ * Copy the string pointed to by svgDataPtr to
+ * a newly allocated memory area svgDataCopy
+ */
+ svgDataLen = strlen(svgDataPtr);
+ svgDataCopy = (char *)attemptckalloc(svgDataLen + 1);
+ if (svgDataCopy == NULL) {
+ return;
+ }
+ memcpy(svgDataCopy, svgDataPtr, svgDataLen);
+ svgDataCopy[svgDataLen] = '\0';
- if (relief != TK_RELIEF_FLAT) {
- if (orient == TTK_ORIENT_HORIZONTAL) {
- if (b.width > 4) {
- b.x += b.width/2;
- XDrawLine(Tk_Display(tkwin), d,
- Tk_3DBorderGC(tkwin, border, TK_3D_DARK_GC),
- b.x-1, b.y+borderWidth, b.x-1, b.y+b.height-borderWidth);
- XDrawLine(Tk_Display(tkwin), d,
- Tk_3DBorderGC(tkwin, border, TK_3D_LIGHT_GC),
- b.x, b.y+borderWidth, b.x, b.y+b.height-borderWidth);
- }
- } else {
- if (b.height > 4) {
- b.y += b.height/2;
- XDrawLine(Tk_Display(tkwin), d,
- Tk_3DBorderGC(tkwin, border, TK_3D_DARK_GC),
- b.x+borderWidth, b.y-1, b.x+b.width-borderWidth, b.y-1);
- XDrawLine(Tk_Display(tkwin), d,
- Tk_3DBorderGC(tkwin, border, TK_3D_LIGHT_GC),
- b.x+borderWidth, b.y, b.x+b.width-borderWidth, b.y);
- }
+ /*
+ * Update the colors within svgDataCopy
+ */
+ innerColorPtr = strstr(svgDataCopy, "4a6984");
+ outerColorPtr = strstr(svgDataCopy, "ffffff");
+ borderColorPtr = strstr(svgDataCopy, "c3c3c3");
+ assert(innerColorPtr);
+ assert(outerColorPtr);
+ assert(borderColorPtr);
+ memcpy(innerColorPtr, innerColorStr, 6);
+ memcpy(outerColorPtr, outerColorStr, 6);
+ memcpy(borderColorPtr, borderColorStr, 6);
+
+ /*
+ * Create an SVG photo image from svgDataCopy
+ */
+ cmdFmt = "image create photo %s -format $::tk::svgFmt -data {%s}";
+ scriptSize = strlen(cmdFmt) + strlen(imgName) + svgDataLen;
+ script = (char *)attemptckalloc(scriptSize);
+ if (script == NULL) {
+ ckfree(svgDataCopy);
+ return;
}
+ snprintf(script, scriptSize, cmdFmt, imgName, svgDataCopy);
+ ckfree(svgDataCopy);
+ code = Tcl_EvalEx(interp, script, -1, TCL_EVAL_GLOBAL);
+ ckfree(script);
+ if (code != TCL_OK) {
+ Tcl_BackgroundException(interp, code);
+ return;
+ }
+ img = Tk_GetImage(interp, tkwin, imgName, ImageChanged, NULL);
}
+
+ /*
+ * Display the image
+ */
+ Tk_RedrawImage(img, 0, 0, dim, dim, d, b.x, b.y);
+ Tk_FreeImage(img);
}
-static Ttk_ElementSpec SliderElementSpec = {
+static const Ttk_ElementSpec SliderElementSpec = {
TK_STYLE_VERSION_2,
sizeof(SliderElement),
SliderElementOptions,
@@ -1266,18 +1545,18 @@ typedef struct {
Tcl_Obj *borderWidthObj; /* thickness of the border */
} PbarElement;
-static Ttk_ElementOptionSpec PbarElementOptions[] = {
- { "-orient", TK_OPTION_ANY, Tk_Offset(PbarElement,orientObj),
+static const Ttk_ElementOptionSpec PbarElementOptions[] = {
+ { "-orient", TK_OPTION_ANY, offsetof(PbarElement,orientObj),
"horizontal" },
- { "-thickness", TK_OPTION_PIXELS, Tk_Offset(PbarElement,thicknessObj),
+ { "-thickness", TK_OPTION_PIXELS, offsetof(PbarElement,thicknessObj),
DEFAULT_PBAR_THICKNESS },
- { "-barsize", TK_OPTION_PIXELS, Tk_Offset(PbarElement,lengthObj),
+ { "-barsize", TK_OPTION_PIXELS, offsetof(PbarElement,lengthObj),
DEFAULT_PBAR_LENGTH },
- { "-pbarrelief", TK_OPTION_RELIEF, Tk_Offset(PbarElement,reliefObj),
+ { "-pbarrelief", TK_OPTION_RELIEF, offsetof(PbarElement,reliefObj),
"raised" },
- { "-borderwidth", TK_OPTION_PIXELS, Tk_Offset(PbarElement,borderWidthObj),
+ { "-borderwidth", TK_OPTION_PIXELS, offsetof(PbarElement,borderWidthObj),
DEFAULT_BORDERWIDTH },
- { "-background", TK_OPTION_BORDER, Tk_Offset(PbarElement,borderObj),
+ { "-background", TK_OPTION_BORDER, offsetof(PbarElement,borderObj),
DEFAULT_BACKGROUND },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -1289,10 +1568,10 @@ static void PbarElementSize(
TCL_UNUSED(Ttk_Padding *))
{
PbarElement *pbar = (PbarElement *)elementRecord;
- int orient;
+ Ttk_Orient orient;
int thickness = 15, length = 30, borderWidth = 2;
- Ttk_GetOrientFromObj(NULL, pbar->orientObj, &orient);
+ TtkGetOrientFromObj(NULL, pbar->orientObj, &orient);
Tk_GetPixelsFromObj(NULL, tkwin, pbar->thicknessObj, &thickness);
Tk_GetPixelsFromObj(NULL, tkwin, pbar->lengthObj, &length);
Tk_GetPixelsFromObj(NULL, tkwin, pbar->borderWidthObj, &borderWidth);
@@ -1327,7 +1606,7 @@ static void PbarElementDraw(
borderWidth, relief);
}
-static Ttk_ElementSpec PbarElementSpec = {
+static const Ttk_ElementSpec PbarElementSpec = {
TK_STYLE_VERSION_2,
sizeof(PbarElement),
PbarElementOptions,
@@ -1346,15 +1625,15 @@ typedef struct {
Tcl_Obj *highlightColorObj;
} TabElement;
-static Ttk_ElementOptionSpec TabElementOptions[] = {
+static const Ttk_ElementOptionSpec TabElementOptions[] = {
{ "-borderwidth", TK_OPTION_PIXELS,
- Tk_Offset(TabElement,borderWidthObj), "1" },
+ offsetof(TabElement,borderWidthObj), "1" },
{ "-background", TK_OPTION_BORDER,
- Tk_Offset(TabElement,backgroundObj), DEFAULT_BACKGROUND },
+ offsetof(TabElement,backgroundObj), DEFAULT_BACKGROUND },
{ "-highlight", TK_OPTION_BOOLEAN,
- Tk_Offset(TabElement,highlightObj), "0" },
+ offsetof(TabElement,highlightObj), "0" },
{ "-highlightcolor", TK_OPTION_COLOR,
- Tk_Offset(TabElement,highlightColorObj), "#4a6984" },
+ offsetof(TabElement,highlightColorObj), "#4a6984" },
{0, TK_OPTION_BOOLEAN, 0, 0}
};
@@ -1406,7 +1685,8 @@ static void TabElementDraw(
int highlight = 0;
XColor *hlColor = NULL;
XPoint pts[6];
- int cut = 2;
+ double scalingLevel = TkScalingLevel(tkwin);
+ int cut = round(2 * scalingLevel);
Display *disp = Tk_Display(tkwin);
int borderWidth = 1;
@@ -1547,7 +1827,7 @@ static void TabElementDraw(
}
}
-static Ttk_ElementSpec TabElementSpec = {
+static const Ttk_ElementSpec TabElementSpec = {
TK_STYLE_VERSION_2,
sizeof(TabElement),
TabElementOptions,
@@ -1592,7 +1872,7 @@ static void ClientElementDraw(
b.x, b.y, b.width, b.height, borderWidth, TK_RELIEF_RAISED);
}
-static Ttk_ElementSpec ClientElementSpec = {
+static const Ttk_ElementSpec ClientElementSpec = {
TK_STYLE_VERSION_2,
sizeof(ClientElement),
ClientElementOptions,
@@ -1624,30 +1904,30 @@ TtkElements_Init(Tcl_Interp *interp)
Ttk_RegisterElement(interp, theme, "padding", &PaddingElementSpec, NULL);
Ttk_RegisterElement(interp, theme, "Checkbutton.indicator",
- &CheckbuttonIndicatorElementSpec, NULL);
+ &IndicatorElementSpec, (void *)&checkbutton_spec);
Ttk_RegisterElement(interp, theme, "Radiobutton.indicator",
- &RadiobuttonIndicatorElementSpec, NULL);
+ &IndicatorElementSpec, (void *)&radiobutton_spec);
Ttk_RegisterElement(interp, theme, "Menubutton.indicator",
&MenuIndicatorElementSpec, NULL);
Ttk_RegisterElement(interp, theme, "indicator", &ttkNullElementSpec, NULL);
Ttk_RegisterElement(interp, theme, "uparrow",
- &ArrowElementSpec, &ArrowElements[0]);
+ &ArrowElementSpec, INT2PTR(ARROW_UP));
Ttk_RegisterElement(interp, theme, "Spinbox.uparrow",
- &BoxArrowElementSpec, &ArrowElements[0]);
+ &BoxArrowElementSpec, INT2PTR(ARROW_UP));
Ttk_RegisterElement(interp, theme, "downarrow",
- &ArrowElementSpec, &ArrowElements[1]);
+ &ArrowElementSpec, INT2PTR(ARROW_DOWN));
Ttk_RegisterElement(interp, theme, "Spinbox.downarrow",
- &BoxArrowElementSpec, &ArrowElements[1]);
+ &BoxArrowElementSpec, INT2PTR(ARROW_DOWN));
Ttk_RegisterElement(interp, theme, "Combobox.downarrow",
- &BoxArrowElementSpec, &ArrowElements[1]);
+ &BoxArrowElementSpec, INT2PTR(ARROW_DOWN));
Ttk_RegisterElement(interp, theme, "leftarrow",
- &ArrowElementSpec, &ArrowElements[2]);
+ &ArrowElementSpec, INT2PTR(ARROW_LEFT));
Ttk_RegisterElement(interp, theme, "rightarrow",
- &ArrowElementSpec, &ArrowElements[3]);
+ &ArrowElementSpec, INT2PTR(ARROW_RIGHT));
Ttk_RegisterElement(interp, theme, "arrow",
- &ArrowElementSpec, &ArrowElements[0]);
+ &ArrowElementSpec, INT2PTR(ARROW_UP));
Ttk_RegisterElement(interp, theme, "trough", &TroughElementSpec, NULL);
Ttk_RegisterElement(interp, theme, "thumb", &ThumbElementSpec, NULL);
diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c
index 08fd085..3620a9a 100644
--- a/generic/ttk/ttkEntry.c
+++ b/generic/ttk/ttkEntry.c
@@ -1,11 +1,11 @@
/*
* DERIVED FROM: tk/generic/tkEntry.c r1.35.
*
- * Copyright (c) 1990-1994 The Regents of the University of California.
- * Copyright (c) 1994-1997 Sun Microsystems, Inc.
- * Copyright (c) 2000 Ajuba Solutions.
- * Copyright (c) 2002 ActiveState Corporation.
- * Copyright (c) 2004 Joe English
+ * Copyright © 1990-1994 The Regents of the University of California.
+ * Copyright © 1994-1997 Sun Microsystems, Inc.
+ * Copyright © 2000 Ajuba Solutions.
+ * Copyright © 2002 ActiveState Corporation.
+ * Copyright © 2004 Joe English
*/
#include "tkInt.h"
@@ -73,6 +73,7 @@ static const char *const validateReasonStrings[] = {
/* Style parameters:
*/
typedef struct {
+ Tcl_Obj *placeholderForegroundObj;/* Foreground color for placeholder text */
Tcl_Obj *foregroundObj; /* Foreground color for normal text */
Tcl_Obj *backgroundObj; /* Entry widget background color */
Tcl_Obj *selBorderObj; /* Border and background for selection */
@@ -87,12 +88,12 @@ typedef struct {
* Internal state:
*/
char *string; /* Storage for string (malloced) */
- int numBytes; /* Length of string in bytes. */
- int numChars; /* Length of string in characters. */
+ Tcl_Size numBytes; /* Length of string in bytes. */
+ Tcl_Size numChars; /* Length of string in characters. */
- int insertPos; /* Insert index */
- int selectFirst; /* Index of start of selection, or -1 */
- int selectLast; /* Index of end of selection, or -1 */
+ Tcl_Size insertPos; /* Insert index */
+ Tcl_Size selectFirst; /* Index of start of selection, or TCL_INDEX_NONE */
+ Tcl_Size selectLast; /* Index of end of selection, or TCL_INDEX_NONE */
Scrollable xscroll; /* Current scroll position */
ScrollHandle xscrollHandle;
@@ -118,6 +119,8 @@ typedef struct {
Tcl_Obj *stateObj; /* Compatibility option -- see CheckStateObj */
+ Tcl_Obj *placeholderObj; /* Text to display for placeholder text */
+
/*
* Derived resources:
*/
@@ -148,54 +151,62 @@ typedef struct {
* Default option values:
*/
#define DEF_SELECT_BG "#000000"
-#define DEF_SELECT_FG "#FFFFFF"
+#define DEF_SELECT_FG "#ffffff"
+#define DEF_PLACEHOLDER_FG "#b3b3b3"
#define DEF_INSERT_BG "black"
#define DEF_ENTRY_WIDTH "20"
#define DEF_ENTRY_FONT "TkTextFont"
#define DEF_LIST_HEIGHT "10"
-static Tk_OptionSpec EntryOptionSpecs[] = {
+static const Tk_OptionSpec EntryOptionSpecs[] = {
{TK_OPTION_BOOLEAN, "-exportselection", "exportSelection",
- "ExportSelection", "1", -1, Tk_Offset(Entry, entry.exportSelection),
+ "ExportSelection", "1", TCL_INDEX_NONE, offsetof(Entry, entry.exportSelection),
0,0,0 },
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_ENTRY_FONT, Tk_Offset(Entry, entry.fontObj),-1,
+ DEF_ENTRY_FONT, offsetof(Entry, entry.fontObj),TCL_INDEX_NONE,
0,0,GEOMETRY_CHANGED},
{TK_OPTION_STRING, "-invalidcommand", "invalidCommand", "InvalidCommand",
- NULL, -1, Tk_Offset(Entry, entry.invalidCmd),
+ NULL, TCL_INDEX_NONE, offsetof(Entry, entry.invalidCmd),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
- "left", -1, Tk_Offset(Entry, entry.justify),
- 0, 0, GEOMETRY_CHANGED},
+ "left", TCL_INDEX_NONE, offsetof(Entry, entry.justify),
+ TK_OPTION_ENUM_VAR, 0, GEOMETRY_CHANGED},
+ {TK_OPTION_STRING, "-placeholder", "placeHolder", "PlaceHolder",
+ NULL, offsetof(Entry, entry.placeholderObj), TCL_INDEX_NONE,
+ TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-show", "show", "Show",
- NULL, -1, Tk_Offset(Entry, entry.showChar),
+ NULL, TCL_INDEX_NONE, offsetof(Entry, entry.showChar),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-state", "state", "State",
- "normal", Tk_Offset(Entry, entry.stateObj), -1,
+ "normal", offsetof(Entry, entry.stateObj), TCL_INDEX_NONE,
0,0,STATE_CHANGED},
{TK_OPTION_STRING, "-textvariable", "textVariable", "Variable",
- NULL, Tk_Offset(Entry, entry.textVariableObj), -1,
+ NULL, offsetof(Entry, entry.textVariableObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,TEXTVAR_CHANGED},
{TK_OPTION_STRING_TABLE, "-validate", "validate", "Validate",
- "none", -1, Tk_Offset(Entry, entry.validate),
+ "none", TCL_INDEX_NONE, offsetof(Entry, entry.validate),
TK_OPTION_ENUM_VAR, validateStrings, 0},
{TK_OPTION_STRING, "-validatecommand", "validateCommand", "ValidateCommand",
- NULL, -1, Tk_Offset(Entry, entry.validateCmd),
+ NULL, TCL_INDEX_NONE, offsetof(Entry, entry.validateCmd),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_INT, "-width", "width", "Width",
- DEF_ENTRY_WIDTH, Tk_Offset(Entry, entry.widthObj), -1,
+ DEF_ENTRY_WIDTH, offsetof(Entry, entry.widthObj), TCL_INDEX_NONE,
0,0,GEOMETRY_CHANGED},
{TK_OPTION_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand",
- NULL, -1, Tk_Offset(Entry, entry.xscroll.scrollCmd),
+ NULL, TCL_INDEX_NONE, offsetof(Entry, entry.xscroll.scrollCmd),
TK_OPTION_NULL_OK, 0, SCROLLCMD_CHANGED},
/* EntryStyleData options:
*/
+ {TK_OPTION_COLOR, "-background", "windowColor", "WindowColor",
+ NULL, offsetof(Entry, entry.styleData.backgroundObj), TCL_INDEX_NONE,
+ TK_OPTION_NULL_OK,0,0},
{TK_OPTION_COLOR, "-foreground", "textColor", "TextColor",
- NULL, Tk_Offset(Entry, entry.styleData.foregroundObj), -1,
+ NULL, offsetof(Entry, entry.styleData.foregroundObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,0},
- {TK_OPTION_COLOR, "-background", "windowColor", "WindowColor",
- NULL, Tk_Offset(Entry, entry.styleData.backgroundObj), -1,
+ {TK_OPTION_COLOR, "-placeholderforeground", "placeholderForeground",
+ "PlaceholderForeground", NULL,
+ offsetof(Entry, entry.styleData.placeholderForegroundObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,0},
WIDGET_TAKEFOCUS_TRUE,
@@ -216,6 +227,7 @@ static void EntryInitStyleDefaults(EntryStyleData *es)
#define INIT(member, value) \
es->member = Tcl_NewStringObj(value, -1); \
Tcl_IncrRefCount(es->member);
+ INIT(placeholderForegroundObj, DEF_PLACEHOLDER_FG)
INIT(foregroundObj, DEFAULT_FOREGROUND)
INIT(selBorderObj, DEF_SELECT_BG)
INIT(selForegroundObj, DEF_SELECT_FG)
@@ -227,6 +239,7 @@ static void EntryInitStyleDefaults(EntryStyleData *es)
static void EntryFreeStyleDefaults(EntryStyleData *es)
{
+ Tcl_DecrRefCount(es->placeholderForegroundObj);
Tcl_DecrRefCount(es->foregroundObj);
Tcl_DecrRefCount(es->selBorderObj);
Tcl_DecrRefCount(es->selForegroundObj);
@@ -253,6 +266,7 @@ static void EntryInitStyleData(Entry *entryPtr, EntryStyleData *es)
# define INIT(member, name) \
if ((tmp=Ttk_QueryOption(entryPtr->core.layout,name,state))) \
es->member=tmp;
+ INIT(placeholderForegroundObj, "-placeholderforeground");
INIT(foregroundObj, "-foreground");
INIT(selBorderObj, "-selectbackground")
INIT(selBorderWidthObj, "-selectborderwidth")
@@ -263,6 +277,7 @@ static void EntryInitStyleData(Entry *entryPtr, EntryStyleData *es)
/* Reacquire color & border resources from resource cache.
*/
+ es->placeholderForegroundObj = Ttk_UseColor(cache, tkwin, es->placeholderForegroundObj);
es->foregroundObj = Ttk_UseColor(cache, tkwin, es->foregroundObj);
es->selForegroundObj = Ttk_UseColor(cache, tkwin, es->selForegroundObj);
es->insertColorObj = Ttk_UseColor(cache, tkwin, es->insertColorObj);
@@ -304,12 +319,23 @@ static char *EntryDisplayString(const char *showChar, int numChars)
*/
static void EntryUpdateTextLayout(Entry *entryPtr)
{
+ Tcl_Size length;
+ char *text;
Tk_FreeTextLayout(entryPtr->entry.textLayout);
- entryPtr->entry.textLayout = Tk_ComputeTextLayout(
+ if ((entryPtr->entry.numChars != 0) || (entryPtr->entry.placeholderObj == NULL)) {
+ entryPtr->entry.textLayout = Tk_ComputeTextLayout(
Tk_GetFontFromObj(entryPtr->core.tkwin, entryPtr->entry.fontObj),
entryPtr->entry.displayString, entryPtr->entry.numChars,
0/*wraplength*/, entryPtr->entry.justify, TK_IGNORE_NEWLINES,
&entryPtr->entry.layoutWidth, &entryPtr->entry.layoutHeight);
+ } else {
+ text = Tcl_GetStringFromObj(entryPtr->entry.placeholderObj, &length);
+ entryPtr->entry.textLayout = Tk_ComputeTextLayout(
+ Tk_GetFontFromObj(entryPtr->core.tkwin, entryPtr->entry.fontObj),
+ text, length,
+ 0/*wraplength*/, entryPtr->entry.justify, TK_IGNORE_NEWLINES,
+ &entryPtr->entry.layoutWidth, &entryPtr->entry.layoutHeight);
+ }
}
/* EntryEditable --
@@ -328,32 +354,32 @@ EntryEditable(Entry *entryPtr)
/* EntryFetchSelection --
* Selection handler for entry widgets.
*/
-static int
+static Tcl_Size
EntryFetchSelection(
- void *clientData, int offset, char *buffer, int maxBytes)
+ void *clientData, Tcl_Size offset, char *buffer, Tcl_Size maxBytes)
{
Entry *entryPtr = (Entry *)clientData;
- int byteCount;
+ Tcl_Size byteCount;
const char *string;
const char *selStart, *selEnd;
if (entryPtr->entry.selectFirst < 0 || (!entryPtr->entry.exportSelection)
|| Tcl_IsSafe(entryPtr->core.interp)) {
- return -1;
+ return TCL_INDEX_NONE;
}
string = entryPtr->entry.displayString;
selStart = TkUtfAtIndex(string, entryPtr->entry.selectFirst);
selEnd = TkUtfAtIndex(selStart,
entryPtr->entry.selectLast - entryPtr->entry.selectFirst);
+ if (selEnd <= selStart + offset) {
+ return 0;
+ }
byteCount = selEnd - selStart - offset;
if (byteCount > maxBytes) {
/* @@@POSSIBLE BUG: Can transfer partial UTF-8 sequences. Is this OK? */
byteCount = maxBytes;
}
- if (byteCount <= 0) {
- return 0;
- }
memcpy(buffer, selStart + offset, byteCount);
buffer[byteCount] = '\0';
return byteCount;
@@ -367,7 +393,7 @@ static void EntryLostSelection(void *clientData)
{
Entry *entryPtr = (Entry *)clientData;
entryPtr->core.flags &= ~GOT_SELECTION;
- entryPtr->entry.selectFirst = entryPtr->entry.selectLast = -1;
+ entryPtr->entry.selectFirst = entryPtr->entry.selectLast = TCL_INDEX_NONE;
TtkRedisplayWidget(&entryPtr->core);
}
@@ -399,7 +425,7 @@ ExpandPercents(
Entry *entryPtr, /* Entry that needs validation. */
const char *templ, /* Script template */
const char *newValue, /* Potential new value of entry string */
- int index, /* index of insert/delete */
+ Tcl_Size index, /* index of insert/delete */
int count, /* #changed characters */
VREASON reason, /* Reason for change */
Tcl_DString *dsPtr) /* Result of %-substitutions */
@@ -420,7 +446,7 @@ ExpandPercents(
/* No more %-sequences to expand.
* Copy the rest of the template.
*/
- Tcl_DStringAppend(dsPtr, templ, -1);
+ Tcl_DStringAppend(dsPtr, templ, TCL_INDEX_NONE);
return;
}
if (string != templ) {
@@ -451,7 +477,7 @@ ExpandPercents(
string = numStorage;
break;
case 'i': /* index of insert/delete */
- snprintf(numStorage, sizeof(numStorage), "%d", index);
+ snprintf(numStorage, sizeof(numStorage), "%" TCL_SIZE_MODIFIER "d", index);
string = numStorage;
break;
case 'P': /* 'Peeked' new value of the string */
@@ -509,8 +535,8 @@ static int RunValidationScript(
const char *templ, /* Script template */
const char *optionName, /* "-validatecommand", "-invalidcommand" */
const char *newValue, /* Potential new value of entry string */
- int index, /* index of insert/delete */
- int count, /* #changed characters */
+ Tcl_Size index, /* index of insert/delete */
+ Tcl_Size count, /* #changed characters */
VREASON reason) /* Reason for change */
{
Tcl_DString script;
@@ -570,8 +596,8 @@ static int
EntryValidateChange(
Entry *entryPtr, /* Entry that needs validation. */
const char *newValue, /* Potential new value of entry string */
- int index, /* index of insert/delete, -1 otherwise */
- int count, /* #changed characters */
+ Tcl_Size index, /* index of insert/delete, TCL_INDEX_NONE otherwise */
+ Tcl_Size count, /* #changed characters */
VREASON reason) /* Reason for change */
{
Tcl_Interp *interp = entryPtr->core.interp;
@@ -701,7 +727,7 @@ static void AdjustIndices(Entry *entryPtr, int index, int nChars)
e->xscroll.first= AdjustIndex(e->xscroll.first, index+g, nChars);
if (e->selectLast <= e->selectFirst)
- e->selectFirst = e->selectLast = -1;
+ e->selectFirst = e->selectLast = TCL_INDEX_NONE;
}
/* EntryStoreValue --
@@ -714,7 +740,7 @@ static void
EntryStoreValue(Entry *entryPtr, const char *value)
{
size_t numBytes = strlen(value);
- int numChars = Tcl_NumUtfChars(value, numBytes);
+ Tcl_Size numChars = TkNumUtfChars(value, numBytes);
if (entryPtr->core.flags & VALIDATING)
entryPtr->core.flags |= VALIDATION_SET_VALUE;
@@ -815,13 +841,13 @@ static void EntryTextVariableTrace(void *recordPtr, const char *value)
static int
InsertChars(
Entry *entryPtr, /* Entry that is to get the new elements. */
- int index, /* Insert before this index */
+ Tcl_Size index, /* Insert before this index */
const char *value) /* New characters to add */
{
char *string = entryPtr->entry.string;
size_t byteIndex = TkUtfAtIndex(string, index) - string;
size_t byteCount = strlen(value);
- int charsAdded = Tcl_NumUtfChars(value, byteCount);
+ int charsAdded = TkNumUtfChars(value, byteCount);
size_t newByteCount = entryPtr->entry.numBytes + byteCount + 1;
char *newBytes;
int code;
@@ -855,8 +881,8 @@ InsertChars(
static int
DeleteChars(
Entry *entryPtr, /* Entry widget to modify. */
- int index, /* Index of first character to delete. */
- int count) /* How many characters to delete. */
+ Tcl_Size index, /* Index of first character to delete. */
+ Tcl_Size count) /* How many characters to delete. */
{
char *string = entryPtr->entry.string;
size_t byteIndex, byteCount, newByteCount;
@@ -866,7 +892,7 @@ DeleteChars(
if (index < 0) {
index = 0;
}
- if (count + index > entryPtr->entry.numChars) {
+ if (count + index > entryPtr->entry.numChars) {
count = entryPtr->entry.numChars - index;
}
if (count <= 0) {
@@ -954,8 +980,8 @@ EntryInitialize(
TtkCreateScrollHandle(&entryPtr->core, &entryPtr->entry.xscroll);
entryPtr->entry.insertPos = 0;
- entryPtr->entry.selectFirst = -1;
- entryPtr->entry.selectLast = -1;
+ entryPtr->entry.selectFirst = TCL_INDEX_NONE;
+ entryPtr->entry.selectLast = TCL_INDEX_NONE;
}
static void
@@ -1010,7 +1036,7 @@ static int EntryConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
/* Claim the selection, in case we've suddenly started exporting it.
*/
- if (entryPtr->entry.exportSelection && (entryPtr->entry.selectFirst != -1)
+ if (entryPtr->entry.exportSelection && (entryPtr->entry.selectFirst >= 0)
&& (!Tcl_IsSafe(entryPtr->core.interp))) {
EntryOwnSelection(entryPtr);
}
@@ -1071,7 +1097,7 @@ static int EntryPostConfigure(
* Precondition: textLayout and layoutX up-to-date.
*/
static int
-EntryCharPosition(Entry *entryPtr, int index)
+EntryCharPosition(Entry *entryPtr, Tcl_Size index)
{
int xPos;
Tk_CharBbox(entryPtr->entry.textLayout, index, &xPos, NULL, NULL, NULL);
@@ -1180,7 +1206,7 @@ static void EntryDisplay(void *clientData, Drawable d)
{
Entry *entryPtr = (Entry *)clientData;
Tk_Window tkwin = entryPtr->core.tkwin;
- int leftIndex = entryPtr->entry.xscroll.first,
+ Tcl_Size leftIndex = entryPtr->entry.xscroll.first,
rightIndex = entryPtr->entry.xscroll.last + 1,
selFirst = entryPtr->entry.selectFirst,
selLast = entryPtr->entry.selectLast;
@@ -1190,6 +1216,7 @@ static void EntryDisplay(void *clientData, Drawable d)
Ttk_Box textarea;
TkRegion clipRegion;
XRectangle rect;
+ Tcl_Obj *foregroundObj;
EntryInitStyleData(entryPtr, &es);
@@ -1289,7 +1316,21 @@ static void EntryDisplay(void *clientData, Drawable d)
/* Draw the text:
*/
- gc = EntryGetGC(entryPtr, es.foregroundObj, clipRegion);
+ if ((*(entryPtr->entry.displayString) == '\0')
+ && (entryPtr->entry.placeholderObj != NULL)) {
+ /* No text displayed, but -placeholder is given */
+ if (TkGetCharLength(es.placeholderForegroundObj) > 0) {
+ foregroundObj = es.placeholderForegroundObj;
+ } else {
+ foregroundObj = es.foregroundObj;
+ }
+ /* Use placeholder text width */
+ leftIndex = 0;
+ (void)Tcl_GetStringFromObj(entryPtr->entry.placeholderObj, &rightIndex);
+ } else {
+ foregroundObj = es.foregroundObj;
+ }
+ gc = EntryGetGC(entryPtr, foregroundObj, clipRegion);
if (showSelection) {
/* Draw the selected and unselected portions separately.
@@ -1359,15 +1400,25 @@ EntryIndex(
Tcl_Interp *interp, /* For error messages. */
Entry *entryPtr, /* Entry widget to query */
Tcl_Obj *indexObj, /* Symbolic index name */
- int *indexPtr) /* Return value */
+ Tcl_Size *indexPtr) /* Return value */
{
# define EntryWidth(e) (Tk_Width(entryPtr->core.tkwin)) /* Not Right */
- const char *string = Tcl_GetString(indexObj);
- size_t length = indexObj->length;
+ Tcl_Size length, idx;
+ const char *string;
+
+ if (TCL_OK == TkGetIntForIndex(indexObj, entryPtr->entry.numChars - 1, 1, &idx)) {
+ if (idx < 0) {
+ idx = 0;
+ } else if (idx > entryPtr->entry.numChars) {
+ idx = entryPtr->entry.numChars;
+ }
+ *indexPtr = idx;
+ return TCL_OK;
+ }
- if (strncmp(string, "end", length) == 0) {
- *indexPtr = entryPtr->entry.numChars;
- } else if (strncmp(string, "insert", length) == 0) {
+ string = Tcl_GetStringFromObj(indexObj, &length);
+
+ if (strncmp(string, "insert", length) == 0) {
*indexPtr = entryPtr->entry.insertPos;
} else if (strncmp(string, "left", length) == 0) { /* for debugging */
*indexPtr = entryPtr->entry.xscroll.first;
@@ -1419,14 +1470,7 @@ EntryIndex(
*indexPtr += 1;
}
} else {
- if (Tcl_GetIntFromObj(interp, indexObj, indexPtr) != TCL_OK) {
- goto badIndex;
- }
- if (*indexPtr < 0) {
- *indexPtr = 0;
- } else if (*indexPtr > entryPtr->entry.numChars) {
- *indexPtr = entryPtr->entry.numChars;
- }
+ goto badIndex;
}
return TCL_OK;
@@ -1442,11 +1486,11 @@ badIndex:
*/
static int
EntryBBoxCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Entry *entryPtr = (Entry *)recordPtr;
Ttk_Box b;
- int index;
+ Tcl_Size index;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "index");
@@ -1472,10 +1516,10 @@ EntryBBoxCommand(
*/
static int
EntryDeleteCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Entry *entryPtr = (Entry *)recordPtr;
- int first, last;
+ Tcl_Size first, last;
if ((objc < 3) || (objc > 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "firstIndex ?lastIndex?");
@@ -1501,7 +1545,7 @@ EntryDeleteCommand(
*/
static int
EntryGetCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Entry *entryPtr = (Entry *)recordPtr;
if (objc != 2) {
@@ -1517,7 +1561,7 @@ EntryGetCommand(
*/
static int
EntryICursorCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Entry *entryPtr = (Entry *)recordPtr;
if (objc != 3) {
@@ -1537,10 +1581,10 @@ EntryICursorCommand(
*/
static int
EntryIndexCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Entry *entryPtr = (Entry *)recordPtr;
- int index;
+ Tcl_Size index;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "string");
@@ -1549,7 +1593,7 @@ EntryIndexCommand(
if (EntryIndex(interp, entryPtr, objv[2], &index) != TCL_OK) {
return TCL_ERROR;
}
- Tcl_SetObjResult(interp, Tcl_NewIntObj(index));
+ Tcl_SetObjResult(interp, TkNewIndexObj(index));
return TCL_OK;
}
@@ -1559,10 +1603,10 @@ EntryIndexCommand(
*/
static int
EntryInsertCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Entry *entryPtr = (Entry *)recordPtr;
- int index;
+ Tcl_Size index;
if (objc != 4) {
Tcl_WrongNumArgs(interp, 2, objv, "index text");
@@ -1581,7 +1625,7 @@ EntryInsertCommand(
* Clear selection.
*/
static int EntrySelectionClearCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Entry *entryPtr = (Entry *)recordPtr;
@@ -1589,7 +1633,7 @@ static int EntrySelectionClearCommand(
Tcl_WrongNumArgs(interp, 3, objv, NULL);
return TCL_ERROR;
}
- entryPtr->entry.selectFirst = entryPtr->entry.selectLast = -1;
+ entryPtr->entry.selectFirst = entryPtr->entry.selectLast = TCL_INDEX_NONE;
TtkRedisplayWidget(&entryPtr->core);
return TCL_OK;
}
@@ -1598,7 +1642,7 @@ static int EntrySelectionClearCommand(
* Returns 1 if any characters are selected, 0 otherwise.
*/
static int EntrySelectionPresentCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Entry *entryPtr = (Entry *)recordPtr;
if (objc != 3) {
@@ -1614,10 +1658,10 @@ static int EntrySelectionPresentCommand(
* Explicitly set the selection range.
*/
static int EntrySelectionRangeCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Entry *entryPtr = (Entry *)recordPtr;
- int start, end;
+ Tcl_Size start, end;
if (objc != 5) {
Tcl_WrongNumArgs(interp, 3, objv, "start end");
return TCL_ERROR;
@@ -1631,7 +1675,7 @@ static int EntrySelectionRangeCommand(
}
if (start >= end) {
- entryPtr->entry.selectFirst = entryPtr->entry.selectLast = -1;
+ entryPtr->entry.selectFirst = entryPtr->entry.selectLast = TCL_INDEX_NONE;
} else {
entryPtr->entry.selectFirst = start;
entryPtr->entry.selectLast = end;
@@ -1652,7 +1696,7 @@ static const Ttk_Ensemble EntrySelectionCommands[] = {
* Sets the value of an entry widget.
*/
static int EntrySetCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Entry *entryPtr = (Entry *)recordPtr;
if (objc != 3) {
@@ -1668,7 +1712,7 @@ static int EntrySetCommand(
* or error status from -validatecommand / -invalidcommand.
*/
static int EntryValidateCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Entry *entryPtr = (Entry *)recordPtr;
int code;
@@ -1690,11 +1734,11 @@ static int EntryValidateCommand(
/* $entry xview -- horizontal scrolling interface
*/
static int EntryXViewCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Entry *entryPtr = (Entry *)recordPtr;
if (objc == 3) {
- int newFirst;
+ Tcl_Size newFirst;
if (EntryIndex(interp, entryPtr, objv[2], &newFirst) != TCL_OK) {
return TCL_ERROR;
}
@@ -1717,6 +1761,7 @@ static const Ttk_Ensemble EntryCommands[] = {
{ "instate", TtkWidgetInstateCommand,0 },
{ "selection", 0,EntrySelectionCommands },
{ "state", TtkWidgetStateCommand,0 },
+ { "style", TtkWidgetStyleCommand,0 },
{ "validate", EntryValidateCommand,0 },
{ "xview", EntryXViewCommand,0 },
{ 0,0,0 }
@@ -1726,7 +1771,7 @@ static const Ttk_Ensemble EntryCommands[] = {
* +++ Entry widget definition.
*/
-static WidgetSpec EntryWidgetSpec = {
+static const WidgetSpec EntryWidgetSpec = {
"TEntry", /* className */
sizeof(Entry), /* recordSize */
EntryOptionSpecs, /* optionSpecs */
@@ -1742,16 +1787,6 @@ static WidgetSpec EntryWidgetSpec = {
};
/*------------------------------------------------------------------------
- * Named indices for the combobox "current" command
- */
-static const char *const comboboxCurrentIndexNames[] = {
- "end", NULL
-};
-enum comboboxCurrentIndices {
- INDEX_END
-};
-
-/*------------------------------------------------------------------------
* +++ Combobox widget record.
*/
@@ -1759,7 +1794,7 @@ typedef struct {
Tcl_Obj *postCommandObj;
Tcl_Obj *valuesObj;
Tcl_Obj *heightObj;
- int currentIndex;
+ Tcl_Size currentIndex;
} ComboboxPart;
typedef struct {
@@ -1768,15 +1803,15 @@ typedef struct {
ComboboxPart combobox;
} Combobox;
-static Tk_OptionSpec ComboboxOptionSpecs[] = {
+static const Tk_OptionSpec ComboboxOptionSpecs[] = {
{TK_OPTION_STRING, "-height", "height", "Height",
- DEF_LIST_HEIGHT, Tk_Offset(Combobox, combobox.heightObj), -1,
+ DEF_LIST_HEIGHT, offsetof(Combobox, combobox.heightObj), TCL_INDEX_NONE,
0,0,0 },
{TK_OPTION_STRING, "-postcommand", "postCommand", "PostCommand",
- "", Tk_Offset(Combobox, combobox.postCommandObj), -1,
+ "", offsetof(Combobox, combobox.postCommandObj), TCL_INDEX_NONE,
0,0,0 },
{TK_OPTION_STRING, "-values", "values", "Values",
- "", Tk_Offset(Combobox, combobox.valuesObj), -1,
+ "", offsetof(Combobox, combobox.valuesObj), TCL_INDEX_NONE,
0,0,0 },
WIDGET_INHERIT_OPTIONS(EntryOptionSpecs)
};
@@ -1789,7 +1824,7 @@ ComboboxInitialize(Tcl_Interp *interp, void *recordPtr)
{
Combobox *cb = (Combobox *)recordPtr;
- cb->combobox.currentIndex = -1;
+ cb->combobox.currentIndex = TCL_INDEX_NONE;
TtkTrackElementState(&cb->core);
EntryInitialize(interp, recordPtr);
}
@@ -1801,7 +1836,7 @@ static int
ComboboxConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
{
Combobox *cbPtr = (Combobox *)recordPtr;
- int unused;
+ Tcl_Size unused;
/* Make sure -values is a valid list:
*/
@@ -1818,12 +1853,12 @@ ComboboxConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
* in sync at all times, [$cb current] double-checks
*/
static int ComboboxCurrentCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Combobox *cbPtr = (Combobox *)recordPtr;
- int currentIndex = cbPtr->combobox.currentIndex;
+ Tcl_Size currentIndex = cbPtr->combobox.currentIndex;
const char *currentValue = cbPtr->entry.string;
- int nValues;
+ Tcl_Size nValues;
Tcl_Obj **values;
Tcl_ListObjGetElements(interp, cbPtr->combobox.valuesObj, &nValues, &values);
@@ -1845,57 +1880,28 @@ static int ComboboxCurrentCommand(
}
if (currentIndex >= nValues) {
/* Not found */
- currentIndex = -1;
+ currentIndex = TCL_INDEX_NONE;
}
}
cbPtr->combobox.currentIndex = currentIndex;
- Tcl_SetObjResult(interp, Tcl_NewIntObj(currentIndex));
+ Tcl_SetObjResult(interp, TkNewIndexObj(currentIndex));
return TCL_OK;
} else if (objc == 3) {
- int result, index;
-
- result = Tcl_GetIndexFromObj(NULL, objv[2], comboboxCurrentIndexNames,
- "", 0, &index);
- if (result == TCL_OK) {
-
- /*
- * The index is one of the named indices.
- */
-
- switch (index) {
- case INDEX_END:
- /* "end" index */
- if (nValues <= 0) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "index \"end\" out of range"));
- Tcl_SetErrorCode(interp, "TTK", "COMBOBOX", "IDX_RANGE", NULL);
- return TCL_ERROR;
- }
- currentIndex = nValues - 1;
- break;
- default:
- Tcl_Panic("Unknown named index");
- return TCL_ERROR;
- }
- } else {
+ Tcl_Size idx;
- /*
- * The index should be just an integer.
- */
-
- if (Tcl_GetIntFromObj(NULL, objv[2], &currentIndex) != TCL_OK) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "Incorrect index %s", Tcl_GetString(objv[2])));
- Tcl_SetErrorCode(interp, "TTK", "COMBOBOX", "IDX_VALUE", NULL);
- return TCL_ERROR;
- }
-
- if (currentIndex < 0 || currentIndex >= nValues) {
+ if (TCL_OK == TkGetIntForIndex(objv[2], nValues - 1, 0, &idx)) {
+ if (idx < 0 || idx >= nValues) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "Index %s out of range", Tcl_GetString(objv[2])));
+ "index \"%s\" out of range", Tcl_GetString(objv[2])));
Tcl_SetErrorCode(interp, "TTK", "COMBOBOX", "IDX_RANGE", NULL);
return TCL_ERROR;
}
+ currentIndex = idx;
+ } else {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "bad index \"%s\"", Tcl_GetString(objv[2])));
+ Tcl_SetErrorCode(interp, "TTK", "COMBOBOX", "IDX_VALUE", NULL);
+ return TCL_ERROR;
}
cbPtr->combobox.currentIndex = currentIndex;
@@ -1924,14 +1930,15 @@ static const Ttk_Ensemble ComboboxCommands[] = {
{ "insert", EntryInsertCommand,0 },
{ "instate", TtkWidgetInstateCommand,0 },
{ "selection", 0,EntrySelectionCommands },
- { "state", TtkWidgetStateCommand,0 },
{ "set", EntrySetCommand,0 },
+ { "state", TtkWidgetStateCommand,0 },
+ { "style", TtkWidgetStyleCommand,0 },
{ "validate", EntryValidateCommand,0 },
{ "xview", EntryXViewCommand,0 },
{ 0,0,0 }
};
-static WidgetSpec ComboboxWidgetSpec = {
+static const WidgetSpec ComboboxWidgetSpec = {
"TCombobox", /* className */
sizeof(Combobox), /* recordSize */
ComboboxOptionSpecs, /* optionSpecs */
@@ -1968,29 +1975,29 @@ typedef struct {
SpinboxPart spinbox;
} Spinbox;
-static Tk_OptionSpec SpinboxOptionSpecs[] = {
+static const Tk_OptionSpec SpinboxOptionSpecs[] = {
{TK_OPTION_STRING, "-values", "values", "Values",
- "", Tk_Offset(Spinbox, spinbox.valuesObj), -1,
+ "", offsetof(Spinbox, spinbox.valuesObj), TCL_INDEX_NONE,
0,0,0 },
{TK_OPTION_DOUBLE, "-from", "from", "From",
- "0", Tk_Offset(Spinbox,spinbox.fromObj), -1,
+ "0.0", offsetof(Spinbox,spinbox.fromObj), TCL_INDEX_NONE,
0,0,0 },
{TK_OPTION_DOUBLE, "-to", "to", "To",
- "0", Tk_Offset(Spinbox,spinbox.toObj), -1,
+ "0.0", offsetof(Spinbox,spinbox.toObj), TCL_INDEX_NONE,
0,0,0 },
{TK_OPTION_DOUBLE, "-increment", "increment", "Increment",
- "1", Tk_Offset(Spinbox,spinbox.incrementObj), -1,
+ "1.0", offsetof(Spinbox,spinbox.incrementObj), TCL_INDEX_NONE,
0,0,0 },
{TK_OPTION_STRING, "-format", "format", "Format",
- "", Tk_Offset(Spinbox, spinbox.formatObj), -1,
+ "", offsetof(Spinbox, spinbox.formatObj), TCL_INDEX_NONE,
0,0,0 },
{TK_OPTION_STRING, "-command", "command", "Command",
- "", Tk_Offset(Spinbox, spinbox.commandObj), -1,
+ "", offsetof(Spinbox, spinbox.commandObj), TCL_INDEX_NONE,
0,0,0 },
{TK_OPTION_BOOLEAN, "-wrap", "wrap", "Wrap",
- "0", Tk_Offset(Spinbox,spinbox.wrapObj), -1,
+ "0", offsetof(Spinbox,spinbox.wrapObj), TCL_INDEX_NONE,
0,0,0 },
WIDGET_INHERIT_OPTIONS(EntryOptionSpecs)
@@ -2014,7 +2021,7 @@ static int
SpinboxConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
{
Spinbox *sb = (Spinbox *)recordPtr;
- int unused;
+ Tcl_Size unused;
/* Make sure -values is a valid list:
*/
@@ -2036,14 +2043,15 @@ static const Ttk_Ensemble SpinboxCommands[] = {
{ "insert", EntryInsertCommand,0 },
{ "instate", TtkWidgetInstateCommand,0 },
{ "selection", 0,EntrySelectionCommands },
- { "state", TtkWidgetStateCommand,0 },
{ "set", EntrySetCommand,0 },
+ { "state", TtkWidgetStateCommand,0 },
+ { "style", TtkWidgetStyleCommand,0 },
{ "validate", EntryValidateCommand,0 },
{ "xview", EntryXViewCommand,0 },
{ 0,0,0 }
};
-static WidgetSpec SpinboxWidgetSpec = {
+static const WidgetSpec SpinboxWidgetSpec = {
"TSpinbox", /* className */
sizeof(Spinbox), /* recordSize */
SpinboxOptionSpecs, /* optionSpecs */
@@ -2070,11 +2078,11 @@ typedef struct {
Tcl_Obj *widthObj;
} TextareaElement;
-static Ttk_ElementOptionSpec TextareaElementOptions[] = {
+static const Ttk_ElementOptionSpec TextareaElementOptions[] = {
{ "-font", TK_OPTION_FONT,
- Tk_Offset(TextareaElement,fontObj), DEF_ENTRY_FONT },
+ offsetof(TextareaElement,fontObj), DEF_ENTRY_FONT },
{ "-width", TK_OPTION_INT,
- Tk_Offset(TextareaElement,widthObj), "20" },
+ offsetof(TextareaElement,widthObj), "20" },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -2101,7 +2109,7 @@ static void TextareaElementSize(
*widthPtr = prefWidth * avgWidth;
}
-static Ttk_ElementSpec TextareaElementSpec = {
+static const Ttk_ElementSpec TextareaElementSpec = {
TK_STYLE_VERSION_2,
sizeof(TextareaElement),
TextareaElementOptions,
diff --git a/generic/ttk/ttkFrame.c b/generic/ttk/ttkFrame.c
index 0570502..cd877f3 100644
--- a/generic/ttk/ttkFrame.c
+++ b/generic/ttk/ttkFrame.c
@@ -1,11 +1,11 @@
/*
- * Copyright (c) 2004, Joe English
+ * Copyright © 2004 Joe English
*
* ttk::frame and ttk::labelframe widgets.
*/
#include "tkInt.h"
-#include "ttkTheme.h"
+#include "ttkThemeInt.h"
#include "ttkWidget.h"
#include "ttkManager.h"
@@ -26,21 +26,21 @@ typedef struct {
FramePart frame;
} Frame;
-static Tk_OptionSpec FrameOptionSpecs[] = {
+static const Tk_OptionSpec FrameOptionSpecs[] = {
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", NULL,
- Tk_Offset(Frame,frame.borderWidthObj), -1,
+ offsetof(Frame,frame.borderWidthObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
{TK_OPTION_STRING, "-padding", "padding", "Pad", NULL,
- Tk_Offset(Frame,frame.paddingObj), -1,
+ offsetof(Frame,frame.paddingObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
{TK_OPTION_RELIEF, "-relief", "relief", "Relief", NULL,
- Tk_Offset(Frame,frame.reliefObj), -1,
+ offsetof(Frame,frame.reliefObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,0 },
{TK_OPTION_PIXELS, "-width", "width", "Width", "0",
- Tk_Offset(Frame,frame.widthObj), -1,
+ offsetof(Frame,frame.widthObj), TCL_INDEX_NONE,
0,0,GEOMETRY_CHANGED },
{TK_OPTION_PIXELS, "-height", "height", "Height", "0",
- Tk_Offset(Frame,frame.heightObj), -1,
+ offsetof(Frame,frame.heightObj), TCL_INDEX_NONE,
0,0,GEOMETRY_CHANGED },
WIDGET_TAKEFOCUS_FALSE,
@@ -48,11 +48,12 @@ static Tk_OptionSpec FrameOptionSpecs[] = {
};
static const Ttk_Ensemble FrameCommands[] = {
- { "configure", TtkWidgetConfigureCommand,0 },
{ "cget", TtkWidgetCgetCommand,0 },
+ { "configure", TtkWidgetConfigureCommand,0 },
+ { "identify", TtkWidgetIdentifyCommand,0 },
{ "instate", TtkWidgetInstateCommand,0 },
{ "state", TtkWidgetStateCommand,0 },
- { "identify", TtkWidgetIdentifyCommand,0 },
+ { "style", TtkWidgetStyleCommand,0 },
{ 0,0,0 }
};
@@ -90,8 +91,8 @@ static Ttk_Padding FrameMargins(Frame *framePtr)
*/
static int FrameSize(
void *recordPtr,
- TCL_UNUSED(int *),
- TCL_UNUSED(int *))
+ TCL_UNUSED(int *), /* widthPtr */
+ TCL_UNUSED(int *)) /* heightPtr */
{
Frame *framePtr = (Frame *)recordPtr;
Ttk_SetMargins(framePtr->core.tkwin, FrameMargins(framePtr));
@@ -148,7 +149,7 @@ static int FrameConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
return TtkCoreConfigure(interp, recordPtr, mask);
}
-static WidgetSpec FrameWidgetSpec = {
+static const WidgetSpec FrameWidgetSpec = {
"TFrame", /* className */
sizeof(Frame), /* recordSize */
FrameOptionSpecs, /* optionSpecs */
@@ -234,7 +235,7 @@ static Ttk_Side LabelAnchorSide(Ttk_PositionSpec flags)
typedef struct {
Tcl_Obj *labelAnchorObj;
Tcl_Obj *textObj;
- Tcl_Obj *underlineObj;
+ Tcl_Obj *underlineObj;
Tk_Window labelWidget;
Ttk_Manager *mgr;
@@ -250,18 +251,17 @@ typedef struct {
#define LABELWIDGET_CHANGED 0x100
-static Tk_OptionSpec LabelframeOptionSpecs[] = {
+static const Tk_OptionSpec LabelframeOptionSpecs[] = {
{TK_OPTION_STRING, "-labelanchor", "labelAnchor", "LabelAnchor",
- "nw", Tk_Offset(Labelframe, label.labelAnchorObj),-1,
+ "nw", offsetof(Labelframe, label.labelAnchorObj),TCL_INDEX_NONE,
0,0,GEOMETRY_CHANGED},
{TK_OPTION_STRING, "-text", "text", "Text", "",
- Tk_Offset(Labelframe,label.textObj), -1,
+ offsetof(Labelframe,label.textObj), TCL_INDEX_NONE,
0,0,GEOMETRY_CHANGED },
- {TK_OPTION_INT, "-underline", "underline", "Underline",
- "-1", Tk_Offset(Labelframe,label.underlineObj), -1,
- 0,0,0 },
+ {TK_OPTION_INDEX, "-underline", "underline", "Underline",
+ TTK_OPTION_UNDERLINE_DEF(Labelframe, label.underlineObj), 0},
{TK_OPTION_WINDOW, "-labelwidget", "labelWidget", "LabelWidget", NULL,
- -1, Tk_Offset(Labelframe,label.labelWidget),
+ TCL_INDEX_NONE, offsetof(Labelframe,label.labelWidget),
TK_OPTION_NULL_OK,0,LABELWIDGET_CHANGED|GEOMETRY_CHANGED },
WIDGET_INHERIT_OPTIONS(FrameOptionSpecs)
@@ -298,7 +298,8 @@ static void LabelframeStyleOptions(Labelframe *lf, LabelframeStyle *style)
TtkGetLabelAnchorFromObj(NULL, objPtr, &style->labelAnchor);
}
if ((objPtr = Ttk_QueryOption(layout,"-labelmargins", 0)) != NULL) {
- Ttk_GetBorderFromObj(NULL, objPtr, &style->labelMargins);
+ Ttk_GetPaddingFromObj(NULL, lf->core.tkwin, objPtr,
+ &style->labelMargins);
} else {
if (style->labelAnchor & (TTK_PACK_TOP|TTK_PACK_BOTTOM)) {
style->labelMargins =
@@ -342,8 +343,8 @@ LabelframeLabelSize(Labelframe *lframePtr, int *widthPtr, int *heightPtr)
*/
static int LabelframeSize(
void *recordPtr,
- TCL_UNUSED(int *),
- TCL_UNUSED(int *))
+ TCL_UNUSED(int *), /* widthPtr */
+ TCL_UNUSED(int *)) /* heightPtr */
{
Labelframe *lframePtr = (Labelframe *)recordPtr;
WidgetCore *corePtr = &lframePtr->core;
@@ -494,10 +495,10 @@ static void LabelframePlaceContent(void *recordPtr)
}
static int LabelRequest(
- TCL_UNUSED(void *),
- TCL_UNUSED(int),
- TCL_UNUSED(int),
- TCL_UNUSED(int))
+ TCL_UNUSED(void *), /* managerData */
+ TCL_UNUSED(Tcl_Size), /* index */
+ TCL_UNUSED(int), /* width */
+ TCL_UNUSED(int)) /* height */
{
return 1;
}
@@ -511,14 +512,14 @@ static int LabelRequest(
*/
static void LabelRemoved(
void *managerData,
- TCL_UNUSED(int))
+ TCL_UNUSED(Tcl_Size)) /* index */
{
Labelframe *lframe = (Labelframe *)managerData;
lframe->label.labelWidget = 0;
}
-static Ttk_ManagerSpec LabelframeManagerSpec = {
+static const Ttk_ManagerSpec LabelframeManagerSpec = {
{ "labelframe", Ttk_GeometryRequestProc, Ttk_LostContentProc },
LabelframeSize,
LabelframePlaceContent,
@@ -626,7 +627,7 @@ static int LabelframeConfigure(Tcl_Interp *interp,void *recordPtr,int mask)
return TCL_OK;
}
-static WidgetSpec LabelframeWidgetSpec = {
+static const WidgetSpec LabelframeWidgetSpec = {
"TLabelframe", /* className */
sizeof(Labelframe), /* recordSize */
LabelframeOptionSpecs, /* optionSpecs */
diff --git a/generic/ttk/ttkGenStubs.tcl b/generic/ttk/ttkGenStubs.tcl
deleted file mode 100644
index af8a2a5..0000000
--- a/generic/ttk/ttkGenStubs.tcl
+++ /dev/null
@@ -1,1009 +0,0 @@
-# ttkGenStubs.tcl --
-#
-# This script generates a set of stub files for a given
-# interface.
-#
-#
-# Copyright (c) 1998-1999 Scriptics Corporation.
-# Copyright (c) 2007 Daniel A. Steffen <das@users.sourceforge.net>
-#
-# See the file "license.terms" for information on usage and redistribution
-# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
-#
-# SOURCE: tcl/tools/genStubs.tcl, revision 1.44
-#
-# CHANGES:
-# + Second argument to "declare" is used as a status guard
-# instead of a platform guard.
-# + Allow trailing semicolon in function declarations
-#
-
-namespace eval genStubs {
- # libraryName --
- #
- # The name of the entire library. This value is used to compute
- # the USE_*_STUBS macro and the name of the init file.
-
- variable libraryName "UNKNOWN"
-
- # interfaces --
- #
- # An array indexed by interface name that is used to maintain
- # the set of valid interfaces. The value is empty.
-
- array set interfaces {}
-
- # curName --
- #
- # The name of the interface currently being defined.
-
- variable curName "UNKNOWN"
-
- # scspec --
- #
- # Storage class specifier for external function declarations.
- # Normally "EXTERN", may be set to something like XYZAPI
- #
- variable scspec "EXTERN"
-
- # epoch, revision --
- #
- # The epoch and revision numbers of the interface currently being defined.
- # (@@@TODO: should be an array mapping interface names -> numbers)
- #
-
- variable epoch {}
- variable revision 0
-
- # hooks --
- #
- # An array indexed by interface name that contains the set of
- # subinterfaces that should be defined for a given interface.
-
- array set hooks {}
-
- # stubs --
- #
- # This three dimensional array is indexed first by interface name,
- # second by field name, and third by a numeric offset or the
- # constant "lastNum". The lastNum entry contains the largest
- # numeric offset used for a given interface.
- #
- # Field "decl,$i" contains the C function specification that
- # should be used for the given entry in the stub table. The spec
- # consists of a list in the form returned by parseDecl.
- # Other fields TBD later.
-
- array set stubs {}
-
- # outDir --
- #
- # The directory where the generated files should be placed.
-
- variable outDir .
-}
-
-# genStubs::library --
-#
-# This function is used in the declarations file to set the name
-# of the library that the interfaces are associated with (e.g. "tcl").
-# This value will be used to define the inline conditional macro.
-#
-# Arguments:
-# name The library name.
-#
-# Results:
-# None.
-
-proc genStubs::library {name} {
- variable libraryName $name
-}
-
-# genStubs::interface --
-#
-# This function is used in the declarations file to set the name
-# of the interface currently being defined.
-#
-# Arguments:
-# name The name of the interface.
-#
-# Results:
-# None.
-
-proc genStubs::interface {name} {
- variable curName $name
- variable interfaces
- variable stubs
-
- set interfaces($name) {}
- set stubs($name,lastNum) 0
- return
-}
-
-# genStubs::scspec --
-#
-# Define the storage class macro used for external function declarations.
-# Typically, this will be a macro like XYZAPI or EXTERN that
-# expands to either DLLIMPORT or DLLEXPORT, depending on whether
-# -DBUILD_XYZ has been set.
-#
-proc genStubs::scspec {value} {
- variable scspec $value
-}
-
-# genStubs::epoch --
-#
-# Define the epoch number for this library. The epoch
-# should be incrememented when a release is made that
-# contains incompatible changes to the public API.
-#
-proc genStubs::epoch {value} {
- variable epoch $value
-}
-
-# genStubs::hooks --
-#
-# This function defines the subinterface hooks for the current
-# interface.
-#
-# Arguments:
-# names The ordered list of interfaces that are reachable through the
-# hook vector.
-#
-# Results:
-# None.
-
-proc genStubs::hooks {names} {
- variable curName
- variable hooks
-
- set hooks($curName) $names
- return
-}
-
-# genStubs::declare --
-#
-# This function is used in the declarations file to declare a new
-# interface entry.
-#
-# Arguments:
-# index The index number of the interface.
-# status Status of the interface: one of "current",
-# "deprecated", or "obsolete".
-# decl The C function declaration, or {} for an undefined
-# entry.
-#
-# Results:
-# None.
-
-proc genStubs::declare {args} {
- variable stubs
- variable curName
- variable revision
-
- incr revision
- if {[llength $args] == 2} {
- lassign $args index decl
- set status current
- } elseif {[llength $args] == 3} {
- lassign $args index status decl
- } else {
- puts stderr "wrong # args: declare $args"
- return
- }
-
- # Check for duplicate declarations, then add the declaration and
- # bump the lastNum counter if necessary.
-
- if {[info exists stubs($curName,decl,$index)]} {
- puts stderr "Duplicate entry: $index"
- }
- regsub -all "\[ \t\n\]+" [string trim $decl] " " decl
- set decl [parseDecl $decl]
-
- set stubs($curName,status,$index) $status
- set stubs($curName,decl,$index) $decl
-
- if {$index > $stubs($curName,lastNum)} {
- set stubs($curName,lastNum) $index
- }
- return
-}
-
-# genStubs::export --
-#
-# This function is used in the declarations file to declare a symbol
-# that is exported from the library but is not in the stubs table.
-#
-# Arguments:
-# decl The C function declaration, or {} for an undefined
-# entry.
-#
-# Results:
-# None.
-
-proc genStubs::export {args} {
- if {[llength $args] != 1} {
- puts stderr "wrong # args: export $args"
- }
- return
-}
-
-# genStubs::rewriteFile --
-#
-# This function replaces the machine generated portion of the
-# specified file with new contents. It looks for the !BEGIN! and
-# !END! comments to determine where to place the new text.
-#
-# Arguments:
-# file The name of the file to modify.
-# text The new text to place in the file.
-#
-# Results:
-# None.
-
-proc genStubs::rewriteFile {file text} {
- if {![file exists $file]} {
- puts stderr "Cannot find file: $file"
- return
- }
- set in [open ${file} r]
- fconfigure $in -eofchar "\032 {}" -encoding utf-8
- set out [open ${file}.new w]
- fconfigure $out -translation lf -encoding utf-8
-
- while {![eof $in]} {
- set line [gets $in]
- if {[string match "*!BEGIN!*" $line]} {
- break
- }
- puts $out $line
- }
- puts $out "/* !BEGIN!: Do not edit below this line. */"
- puts $out $text
- while {![eof $in]} {
- set line [gets $in]
- if {[string match "*!END!*" $line]} {
- break
- }
- }
- puts $out "/* !END!: Do not edit above this line. */"
- puts -nonewline $out [read $in]
- close $in
- close $out
- file rename -force ${file}.new ${file}
- return
-}
-
-# genStubs::addPlatformGuard --
-#
-# Wrap a string inside a platform #ifdef.
-#
-# Arguments:
-# plat Platform to test.
-#
-# Results:
-# Returns the original text inside an appropriate #ifdef.
-
-proc genStubs::addPlatformGuard {plat iftxt {eltxt {}} {withCygwin 0}} {
- set text ""
- switch $plat {
- win {
- append text "#if defined(_WIN32)"
- if {$withCygwin} {
- append text " || defined(__CYGWIN__)"
- }
- append text " /* WIN */\n${iftxt}"
- if {$eltxt ne ""} {
- append text "#else /* WIN */\n${eltxt}"
- }
- append text "#endif /* WIN */\n"
- }
- unix {
- append text "#if !defined(_WIN32)"
- if {$withCygwin} {
- append text " && !defined(__CYGWIN__)"
- }
- append text " && !defined(MAC_OSX_TCL)\
- /* UNIX */\n${iftxt}"
- if {$eltxt ne ""} {
- append text "#else /* UNIX */\n${eltxt}"
- }
- append text "#endif /* UNIX */\n"
- }
- macosx {
- append text "#ifdef MAC_OSX_TCL /* MACOSX */\n${iftxt}"
- if {$eltxt ne ""} {
- append text "#else /* MACOSX */\n${eltxt}"
- }
- append text "#endif /* MACOSX */\n"
- }
- aqua {
- append text "#ifdef MAC_OSX_TK /* AQUA */\n${iftxt}"
- if {$eltxt ne ""} {
- append text "#else /* AQUA */\n${eltxt}"
- }
- append text "#endif /* AQUA */\n"
- }
- x11 {
- append text "#if !(defined(_WIN32)"
- if {$withCygwin} {
- append text " || defined(__CYGWIN__)"
- }
- append text " || defined(MAC_OSX_TK))\
- /* X11 */\n${iftxt}"
- if {$eltxt ne ""} {
- append text "#else /* X11 */\n${eltxt}"
- }
- append text "#endif /* X11 */\n"
- }
- default {
- append text "${iftxt}${eltxt}"
- }
- }
- return $text
-}
-
-# genStubs::emitSlots --
-#
-# Generate the stub table slots for the given interface. If there
-# are no generic slots, then one table is generated for each
-# platform, otherwise one table is generated for all platforms.
-#
-# Arguments:
-# name The name of the interface being emitted.
-# textVar The variable to use for output.
-#
-# Results:
-# None.
-
-proc genStubs::emitSlots {name textVar} {
- upvar $textVar text
-
- forAllStubs $name makeSlot noGuard text {" void (*reserved$i)(void);\n"}
- return
-}
-
-# genStubs::parseDecl --
-#
-# Parse a C function declaration into its component parts.
-#
-# Arguments:
-# decl The function declaration.
-#
-# Results:
-# Returns a list of the form {returnType name args}. The args
-# element consists of a list of type/name pairs, or a single
-# element "void". If the function declaration is malformed
-# then an error is displayed and the return value is {}.
-
-proc genStubs::parseDecl {decl} {
- if {![regexp {^(.*)\((.*)\);?$} $decl all prefix args]} {
- set prefix $decl
- set args {}
- }
- set prefix [string trim $prefix]
- if {![regexp {^(.+[ ][*]*)([^ *]+)$} $prefix all rtype fname]} {
- puts stderr "Bad return type: $decl"
- return
- }
- set rtype [string trim $rtype]
- if {$args eq ""} {
- return [list $rtype $fname {}]
- }
- foreach arg [split $args ,] {
- lappend argList [string trim $arg]
- }
- if {![string compare [lindex $argList end] "..."]} {
- set args TCL_VARARGS
- foreach arg [lrange $argList 0 end-1] {
- set argInfo [parseArg $arg]
- if {[llength $argInfo] == 2 || [llength $argInfo] == 3} {
- lappend args $argInfo
- } else {
- puts stderr "Bad argument: '$arg' in '$decl'"
- return
- }
- }
- } else {
- set args {}
- foreach arg $argList {
- set argInfo [parseArg $arg]
- if {![string compare $argInfo "void"]} {
- lappend args "void"
- break
- } elseif {[llength $argInfo] == 2 || [llength $argInfo] == 3} {
- lappend args $argInfo
- } else {
- puts stderr "Bad argument: '$arg' in '$decl'"
- return
- }
- }
- }
- return [list $rtype $fname $args]
-}
-
-# genStubs::parseArg --
-#
-# This function parses a function argument into a type and name.
-#
-# Arguments:
-# arg The argument to parse.
-#
-# Results:
-# Returns a list of type and name with an optional third array
-# indicator. If the argument is malformed, returns "".
-
-proc genStubs::parseArg {arg} {
- if {![regexp {^(.+[ ][*]*)([^][ *]+)(\[\])?$} $arg all type name array]} {
- if {$arg eq "void"} {
- return $arg
- } else {
- return
- }
- }
- set result [list [string trim $type] $name]
- if {$array ne ""} {
- lappend result $array
- }
- return $result
-}
-
-# genStubs::makeDecl --
-#
-# Generate the prototype for a function.
-#
-# Arguments:
-# name The interface name.
-# decl The function declaration.
-# index The slot index for this function.
-#
-# Results:
-# Returns the formatted declaration string.
-
-proc genStubs::makeDecl {name decl index} {
- variable scspec
- variable stubs
- variable libraryName
- lassign $decl rtype fname args
-
- append text "/* $index */\n"
- if {[info exists stubs($name,deprecated,$index)]} {
- append text "[string toupper $libraryName]_DEPRECATED(\"$stubs($name,deprecated,$index)\")\n"
- set line "$rtype"
- } elseif {[string range $rtype end-5 end] eq "MP_WUR"} {
- set line "$scspec [string trim [string range $rtype 0 end-6]]"
- } else {
- set line "$scspec $rtype"
- }
- set count [expr {2 - ([string length $line] / 8)}]
- if {$count >= 0} {
- append line [string range "\t\t\t" 0 $count]
- }
- set pad [expr {24 - [string length $line]}]
- if {$pad <= 0} {
- append line " "
- set pad 0
- }
- if {$args eq ""} {
- append line $fname
- append text $line
- append text ";\n"
- return $text
- }
- append line $fname
-
- set arg1 [lindex $args 0]
- switch -exact $arg1 {
- void {
- append line "(void)"
- }
- TCL_VARARGS {
- set sep "("
- foreach arg [lrange $args 1 end] {
- append line $sep
- set next {}
- append next [lindex $arg 0]
- if {[string index $next end] ne "*"} {
- append next " "
- }
- append next [lindex $arg 1] [lindex $arg 2]
- if {[string length $line] + [string length $next] \
- + $pad > 76} {
- append text [string trimright $line] \n
- set line "\t\t\t\t"
- set pad 28
- }
- append line $next
- set sep ", "
- }
- append line ", ...)"
- if {[lindex $args end] eq "{const char *} format"} {
- append line " TCL_FORMAT_PRINTF(" [expr {[llength $args] - 1}] ", " [llength $args] ")"
- }
- }
- default {
- set sep "("
- foreach arg $args {
- append line $sep
- set next {}
- append next [lindex $arg 0]
- if {[string index $next end] ne "*"} {
- append next " "
- }
- append next [lindex $arg 1] [lindex $arg 2]
- if {[string length $line] + [string length $next] \
- + $pad > 76} {
- append text [string trimright $line] \n
- set line "\t\t\t\t"
- set pad 28
- }
- append line $next
- set sep ", "
- }
- append line ")"
- }
- }
- if {[string range $rtype end-5 end] eq "MP_WUR"} {
- append line " MP_WUR"
- }
- return "$text$line;\n"
-}
-
-# genStubs::makeMacro --
-#
-# Generate the inline macro for a function.
-#
-# Arguments:
-# name The interface name.
-# decl The function declaration.
-# index The slot index for this function.
-#
-# Results:
-# Returns the formatted macro definition.
-
-proc genStubs::makeMacro {name decl index} {
- lassign $decl rtype fname args
-
- set lfname [string tolower [string index $fname 0]]
- append lfname [string range $fname 1 end]
-
- set text "#define $fname \\\n\t("
- if {$args eq ""} {
- append text "*"
- }
- append text "${name}StubsPtr->$lfname)"
- append text " /* $index */\n"
- return $text
-}
-
-# genStubs::makeSlot --
-#
-# Generate the stub table entry for a function.
-#
-# Arguments:
-# name The interface name.
-# decl The function declaration.
-# index The slot index for this function.
-#
-# Results:
-# Returns the formatted table entry.
-
-proc genStubs::makeSlot {name decl index} {
- lassign $decl rtype fname args
- variable stubs
-
- set lfname [string tolower [string index $fname 0]]
- append lfname [string range $fname 1 end]
-
- set text " "
- if {[info exists stubs($name,deprecated,$index)]} {
- append text "TCL_DEPRECATED_API(\"$stubs($name,deprecated,$index)\") "
- } elseif {[info exists stubs($name,nostub,$index)]} {
- append text "TCL_DEPRECATED_API(\"$stubs($name,nostub,$index)\") "
- }
- if {$args eq ""} {
- append text $rtype " *" $lfname "; /* $index */\n"
- return $text
- }
- if {[string range $rtype end-8 end] eq "__stdcall"} {
- append text [string trim [string range $rtype 0 end-9]] " (__stdcall *" $lfname ") "
- } elseif {[string range $rtype 0 11] eq "TCL_NORETURN"} {
- append text "TCL_NORETURN1 " [string trim [string range $rtype 12 end]] " (*" $lfname ") "
- } elseif {[string range $rtype end-5 end] eq "MP_WUR"} {
- append text [string trim [string range $rtype 0 end-6]] " (*" $lfname ") "
- } else {
- append text $rtype " (*" $lfname ") "
- }
- set arg1 [lindex $args 0]
- switch -exact $arg1 {
- void {
- append text "(void)"
- }
- TCL_VARARGS {
- set sep "("
- foreach arg [lrange $args 1 end] {
- append text $sep [lindex $arg 0]
- if {[string index $text end] ne "*"} {
- append text " "
- }
- append text [lindex $arg 1] [lindex $arg 2]
- set sep ", "
- }
- append text ", ...)"
- if {[lindex $args end] eq "{const char *} format"} {
- append text " TCL_FORMAT_PRINTF(" [expr {[llength $args] - 1}] ", " [llength $args] ")"
- }
- }
- default {
- set sep "("
- foreach arg $args {
- append text $sep [lindex $arg 0]
- if {[string index $text end] ne "*"} {
- append text " "
- }
- append text [lindex $arg 1] [lindex $arg 2]
- set sep ", "
- }
- append text ")"
- }
- }
-
- if {[string range $rtype end-5 end] eq "MP_WUR"} {
- append text " MP_WUR"
- }
- append text "; /* $index */\n"
- return $text
-}
-
-# genStubs::makeInit --
-#
-# Generate the prototype for a function.
-#
-# Arguments:
-# name The interface name.
-# decl The function declaration.
-# index The slot index for this function.
-#
-# Results:
-# Returns the formatted declaration string.
-
-proc genStubs::makeInit {name decl index} {
- if {[lindex $decl 2] eq ""} {
- append text " &" [lindex $decl 1] ", /* " $index " */\n"
- } else {
- append text " " [lindex $decl 1] ", /* " $index " */\n"
- }
- return $text
-}
-
-# genStubs::forAllStubs --
-#
-# This function iterates over all of the slots and invokes
-# a callback for each slot. The result of the callback is then
-# placed inside appropriate guards.
-#
-# Arguments:
-# name The interface name.
-# slotProc The proc to invoke to handle the slot. It will
-# have the interface name, the declaration, and
-# the index appended.
-# guardProc The proc to invoke to add guards. It will have
-# the slot status and text appended.
-# textVar The variable to use for output.
-# skipString The string to emit if a slot is skipped. This
-# string will be subst'ed in the loop so "$i" can
-# be used to substitute the index value.
-#
-# Results:
-# None.
-
-proc genStubs::forAllStubs {name slotProc guardProc textVar
- {skipString {"/* Slot $i is reserved */\n"}}} {
- variable stubs
- upvar $textVar text
-
- set lastNum $stubs($name,lastNum)
-
- for {set i 0} {$i <= $lastNum} {incr i} {
- if {[info exists stubs($name,decl,$i)]} {
- append text [$guardProc $stubs($name,status,$i) \
- [$slotProc $name $stubs($name,decl,$i) $i]]
- } else {
- eval {append text} $skipString
- }
- }
-}
-
-proc genStubs::noGuard {status text} { return $text }
-
-proc genStubs::addGuard {status text} {
- variable libraryName
- set upName [string toupper $libraryName]
-
- switch -- $status {
- current {
- # No change
- }
- deprecated {
- set text [ifdeffed "${upName}_DEPRECATED" $text]
- }
- obsolete {
- set text ""
- }
- default {
- puts stderr "Unrecognized status code $status"
- }
- }
- return $text
-}
-
-proc genStubs::ifdeffed {macro text} {
- join [list "#ifdef $macro" $text "#endif" ""] \n
-}
-
-# genStubs::emitDeclarations --
-#
-# This function emits the function declarations for this interface.
-#
-# Arguments:
-# name The interface name.
-# textVar The variable to use for output.
-#
-# Results:
-# None.
-
-proc genStubs::emitDeclarations {name textVar} {
- upvar $textVar text
-
- append text "\n/*\n * Exported function declarations:\n */\n\n"
- forAllStubs $name makeDecl noGuard text
- return
-}
-
-# genStubs::emitMacros --
-#
-# This function emits the inline macros for an interface.
-#
-# Arguments:
-# name The name of the interface being emitted.
-# textVar The variable to use for output.
-#
-# Results:
-# None.
-
-proc genStubs::emitMacros {name textVar} {
- variable libraryName
- upvar $textVar text
-
- set upName [string toupper $libraryName]
- append text "\n#if defined(USE_${upName}_STUBS)\n"
- append text "\n/*\n * Inline function declarations:\n */\n\n"
-
- forAllStubs $name makeMacro addGuard text
-
- append text "\n#endif /* defined(USE_${upName}_STUBS) */\n"
- return
-}
-
-# genStubs::emitHeader --
-#
-# This function emits the body of the <name>Decls.h file for
-# the specified interface.
-#
-# Arguments:
-# name The name of the interface being emitted.
-#
-# Results:
-# None.
-
-proc genStubs::emitHeader {name} {
- variable outDir
- variable hooks
- variable epoch
- variable revision
-
- set capName [string toupper [string index $name 0]]
- append capName [string range $name 1 end]
-
- if {$epoch ne ""} {
- set CAPName [string toupper $name]
- append text "\n"
- append text "#define ${CAPName}_STUBS_EPOCH $epoch\n"
- append text "#define ${CAPName}_STUBS_REVISION $revision\n"
- }
-
- append text "\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n"
-
- emitDeclarations $name text
-
- if {[info exists hooks($name)]} {
- append text "\ntypedef struct {\n"
- foreach hook $hooks($name) {
- set capHook [string toupper [string index $hook 0]]
- append capHook [string range $hook 1 end]
- append text " const struct ${capHook}Stubs *${hook}Stubs;\n"
- }
- append text "} ${capName}StubHooks;\n"
- }
- append text "\ntypedef struct ${capName}Stubs {\n"
- append text " int magic;\n"
- if {$epoch ne ""} {
- append text " int epoch;\n"
- append text " int revision;\n"
- }
- if {[info exists hooks($name)]} {
- append text " const ${capName}StubHooks *hooks;\n\n"
- } else {
- append text " void *hooks;\n\n"
- }
-
- emitSlots $name text
-
- append text "} ${capName}Stubs;\n\n"
-
- append text "extern const ${capName}Stubs *${name}StubsPtr;\n\n"
- append text "#ifdef __cplusplus\n}\n#endif\n"
-
- emitMacros $name text
-
- rewriteFile [file join $outDir ${name}Decls.h] $text
- return
-}
-
-# genStubs::emitInit --
-#
-# Generate the table initializers for an interface.
-#
-# Arguments:
-# name The name of the interface to initialize.
-# textVar The variable to use for output.
-#
-# Results:
-# Returns the formatted output.
-
-proc genStubs::emitInit {name textVar} {
- variable hooks
- variable interfaces
- variable epoch
- upvar $textVar text
- set root 1
-
- set capName [string toupper [string index $name 0]]
- append capName [string range $name 1 end]
-
- if {[info exists hooks($name)]} {
- append text "\nstatic const ${capName}StubHooks ${name}StubHooks = \{\n"
- set sep " "
- foreach sub $hooks($name) {
- append text $sep "&${sub}Stubs"
- set sep ",\n "
- }
- append text "\n\};\n"
- }
- foreach intf [array names interfaces] {
- if {[info exists hooks($intf)]} {
- if {$name in $hooks($intf)} {
- set root 0
- break
- }
- }
- }
-
- append text "\n"
- if {!$root} {
- append text "static "
- }
- append text "const ${capName}Stubs ${name}Stubs = \{\n TCL_STUB_MAGIC,\n"
- if {$epoch ne ""} {
- set CAPName [string toupper $name]
- append text " ${CAPName}_STUBS_EPOCH,\n"
- append text " ${CAPName}_STUBS_REVISION,\n"
- }
- if {[info exists hooks($name)]} {
- append text " &${name}StubHooks,\n"
- } else {
- append text " 0,\n"
- }
-
- forAllStubs $name makeInit noGuard text {" 0, /* $i */\n"}
-
- append text "\};\n"
- return
-}
-
-# genStubs::emitInits --
-#
-# This function emits the body of the <name>StubInit.c file for
-# the specified interface.
-#
-# Arguments:
-# name The name of the interface being emitted.
-#
-# Results:
-# None.
-
-proc genStubs::emitInits {} {
- variable hooks
- variable outDir
- variable libraryName
- variable interfaces
-
- # Assuming that dependencies only go one level deep, we need to emit
- # all of the leaves first to avoid needing forward declarations.
-
- set leaves {}
- set roots {}
- foreach name [lsort [array names interfaces]] {
- if {[info exists hooks($name)]} {
- lappend roots $name
- } else {
- lappend leaves $name
- }
- }
- foreach name $leaves {
- emitInit $name text
- }
- foreach name $roots {
- emitInit $name text
- }
-
- rewriteFile [file join $outDir ${libraryName}StubInit.c] $text
-}
-
-# genStubs::init --
-#
-# This is the main entry point.
-#
-# Arguments:
-# None.
-#
-# Results:
-# None.
-
-proc genStubs::init {} {
- global argv argv0
- variable outDir
- variable interfaces
-
- if {[llength $argv] < 2} {
- puts stderr "usage: $argv0 outDir declFile ?declFile...?"
- exit 1
- }
-
- set outDir [lindex $argv 0]
-
- foreach file [lrange $argv 1 end] {
- source -encoding utf-8 $file
- }
-
- foreach name [lsort [array names interfaces]] {
- puts "Emitting $name"
- emitHeader $name
- }
-
- emitInits
-}
-
-# lassign --
-#
-# This function emulates the TclX lassign command.
-#
-# Arguments:
-# valueList A list containing the values to be assigned.
-# args The list of variables to be assigned.
-#
-# Results:
-# Returns any values that were not assigned to variables.
-
-if {[string length [namespace which lassign]] == 0} {
- proc lassign {valueList args} {
- if {[llength $args] == 0} {
- error "wrong # args: should be \"lassign list varName ?varName ...?\""
- }
- uplevel [list foreach $args $valueList {break}]
- return [lrange $valueList [llength $args] end]
- }
-}
-
-genStubs::init
diff --git a/generic/ttk/ttkImage.c b/generic/ttk/ttkImage.c
index 7de4d92..35ec36f 100644
--- a/generic/ttk/ttkImage.c
+++ b/generic/ttk/ttkImage.c
@@ -1,8 +1,8 @@
/*
* Image specifications and image element factory.
*
- * Copyright (C) 2004 Pat Thoyts <patthoyts@users.sf.net>
- * Copyright (C) 2004 Joe English
+ * Copyright © 2004 Pat Thoyts <patthoyts@users.sf.net>
+ * Copyright © 2004 Joe English
*
* An imageSpec is a multi-element list; the first element
* is the name of the default image to use, the remainder of the
@@ -25,20 +25,28 @@ struct TtkImageSpec {
Ttk_StateSpec *states; /* array[mapCount] of states ... */
Tk_Image *images; /* ... per-state images to use */
Tk_ImageChangedProc *imageChanged;
- ClientData imageChangedClientData;
+ void *imageChangedClientData;
};
/* NullImageChanged --
* Do-nothing Tk_ImageChangedProc.
*/
-static void NullImageChanged(ClientData clientData,
- int x, int y, int width, int height, int imageWidth, int imageHeight)
-{ /* No-op */ }
+static void NullImageChanged(
+ TCL_UNUSED(void *),
+ TCL_UNUSED(int),
+ TCL_UNUSED(int),
+ TCL_UNUSED(int),
+ TCL_UNUSED(int),
+ TCL_UNUSED(int),
+ TCL_UNUSED(int))
+{
+ /* No-op */
+}
/* ImageSpecImageChanged --
* Image changes should trigger a repaint.
*/
-static void ImageSpecImageChanged(ClientData clientData,
+static void ImageSpecImageChanged(void *clientData,
int x, int y, int width, int height, int imageWidth, int imageHeight)
{
Ttk_ImageSpec *imageSpec = (Ttk_ImageSpec *)clientData;
@@ -68,13 +76,14 @@ TtkGetImageSpec(Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr)
*/
Ttk_ImageSpec *
TtkGetImageSpecEx(Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr,
- Tk_ImageChangedProc *imageChangedProc, ClientData imageChangedClientData)
+ Tk_ImageChangedProc *imageChangedProc, void *imageChangedClientData)
{
Ttk_ImageSpec *imageSpec = 0;
- int i = 0, n = 0, objc;
+ int i = 0, n = 0;
+ Tcl_Size objc;
Tcl_Obj **objv;
- imageSpec = ckalloc(sizeof(*imageSpec));
+ imageSpec = (Ttk_ImageSpec *)ckalloc(sizeof(*imageSpec));
imageSpec->baseImage = 0;
imageSpec->mapCount = 0;
imageSpec->states = 0;
@@ -97,8 +106,8 @@ TtkGetImageSpecEx(Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr,
}
n = (objc - 1) / 2;
- imageSpec->states = ckalloc(n * sizeof(Ttk_StateSpec));
- imageSpec->images = ckalloc(n * sizeof(Tk_Image *));
+ imageSpec->states = (Ttk_StateSpec *)ckalloc(n * sizeof(Ttk_StateSpec));
+ imageSpec->images = (Tk_Image *)ckalloc(n * sizeof(Tk_Image));
/* Get base image:
*/
@@ -203,7 +212,11 @@ static Ttk_Box BPadding(Ttk_Box b, Ttk_Padding p)
* the source area of the image.
*/
static void Ttk_Fill(
- Tk_Window tkwin, Drawable d, Tk_Image image, Ttk_Box src, Ttk_Box dst)
+ TCL_UNUSED(Tk_Window),
+ Drawable d,
+ Tk_Image image,
+ Ttk_Box src,
+ Ttk_Box dst)
{
int dr = dst.x + dst.width;
int db = dst.y + dst.height;
@@ -257,7 +270,7 @@ typedef struct { /* ClientData for image elements */
Ttk_Padding border; /* Fixed border region */
Ttk_Padding padding; /* Internal padding */
-#if TILE_07_COMPAT
+#ifdef TILE_07_COMPAT
Ttk_ResourceCache cache; /* Resource cache for images */
Ttk_StateMap imageMap; /* State-based lookup table for images */
#endif
@@ -265,19 +278,23 @@ typedef struct { /* ClientData for image elements */
static void FreeImageData(void *clientData)
{
- ImageData *imageData = clientData;
+ ImageData *imageData = (ImageData *)clientData;
if (imageData->imageSpec) { TtkFreeImageSpec(imageData->imageSpec); }
-#if TILE_07_COMPAT
+#ifdef TILE_07_COMPAT
if (imageData->imageMap) { Tcl_DecrRefCount(imageData->imageMap); }
#endif
ckfree(clientData);
}
static void ImageElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
+ void *clientData,
+ TCL_UNUSED(void *), /* elementRecord */
+ TCL_UNUSED(Tk_Window),
+ int *widthPtr,
+ int *heightPtr,
+ Ttk_Padding *paddingPtr)
{
- ImageData *imageData = clientData;
+ ImageData *imageData = (ImageData *)clientData;
Tk_Image image = imageData->imageSpec->baseImage;
if (image) {
@@ -294,15 +311,19 @@ static void ImageElementSize(
}
static void ImageElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
- Drawable d, Ttk_Box b, unsigned int state)
+ void *clientData,
+ TCL_UNUSED(void *), /* elementRecord */
+ Tk_Window tkwin,
+ Drawable d,
+ Ttk_Box b,
+ Ttk_State state)
{
- ImageData *imageData = clientData;
+ ImageData *imageData = (ImageData *)clientData;
Tk_Image image = 0;
int imgWidth, imgHeight;
Ttk_Box src, dst;
-#if TILE_07_COMPAT
+#ifdef TILE_07_COMPAT
if (imageData->imageMap) {
Tcl_Obj *imageObj = Ttk_StateMapLookup(NULL,imageData->imageMap,state);
if (imageObj) {
@@ -327,7 +348,7 @@ static void ImageElementDraw(
Ttk_Tile(tkwin, d, image, src, dst, imageData->border);
}
-static Ttk_ElementSpec ImageElementSpec =
+static const Ttk_ElementSpec ImageElementSpec =
{
TK_STYLE_VERSION_2,
sizeof(NullElement),
@@ -342,10 +363,10 @@ static Ttk_ElementSpec ImageElementSpec =
static int
Ttk_CreateImageElement(
Tcl_Interp *interp,
- void *clientData,
+ TCL_UNUSED(void *),
Ttk_Theme theme,
const char *elementName,
- int objc, Tcl_Obj *const objv[])
+ Tcl_Size objc, Tcl_Obj *const objv[])
{
static const char *const optionStrings[] =
{ "-border","-height","-padding","-sticky","-width",NULL };
@@ -354,9 +375,9 @@ Ttk_CreateImageElement(
Ttk_ImageSpec *imageSpec = 0;
ImageData *imageData = 0;
int padding_specified = 0;
- int i;
+ Tcl_Size i;
- if (objc <= 0) {
+ if (objc + 1 < 2) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"Must supply a base image", -1));
Tcl_SetErrorCode(interp, "TTK", "IMAGE", "BASE", NULL);
@@ -368,12 +389,12 @@ Ttk_CreateImageElement(
return TCL_ERROR;
}
- imageData = ckalloc(sizeof(*imageData));
+ imageData = (ImageData *)ckalloc(sizeof(*imageData));
imageData->imageSpec = imageSpec;
imageData->minWidth = imageData->minHeight = -1;
imageData->sticky = TTK_FILL_BOTH;
imageData->border = imageData->padding = Ttk_UniformPadding(0);
-#if TILE_07_COMPAT
+#ifdef TILE_07_COMPAT
imageData->cache = Ttk_GetResourceCache(interp);
imageData->imageMap = 0;
#endif
@@ -388,7 +409,7 @@ Ttk_CreateImageElement(
goto error;
}
-#if TILE_07_COMPAT
+#ifdef TILE_07_COMPAT
if (!strcmp("-map", Tcl_GetString(objv[i]))) {
imageData->imageMap = objv[i+1];
Tcl_IncrRefCount(imageData->imageMap);
diff --git a/generic/ttk/ttkInit.c b/generic/ttk/ttkInit.c
index d4a1599..716c477 100644
--- a/generic/ttk/ttkInit.c
+++ b/generic/ttk/ttkInit.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, Joe English
+ * Copyright © 2003 Joe English
*
* Ttk package: initialization routine and miscellaneous utilities.
*/
@@ -13,15 +13,18 @@
* See also: enum Ttk_ButtonDefaultState.
*/
const char *const ttkDefaultStrings[] = {
- "normal", "active", "disabled", NULL
+ "active", "disabled", "normal", NULL
};
int Ttk_GetButtonDefaultStateFromObj(
- Tcl_Interp *interp, Tcl_Obj *objPtr, int *statePtr)
+ Tcl_Interp *interp, Tcl_Obj *objPtr, Ttk_ButtonDefaultState *statePtr)
{
- *statePtr = TTK_BUTTON_DEFAULT_DISABLED;
- return Tcl_GetIndexFromObjStruct(interp, objPtr, ttkDefaultStrings,
- sizeof(char *), "default state", 0, statePtr);
+ int state = (int)TTK_BUTTON_DEFAULT_DISABLED;
+ int result = Tcl_GetIndexFromObj(interp, objPtr, ttkDefaultStrings,
+ "default state", 0, &state);
+
+ *statePtr = (Ttk_ButtonDefaultState)state;
+ return result;
}
/*
@@ -34,11 +37,14 @@ const char *const ttkCompoundStrings[] = {
};
int Ttk_GetCompoundFromObj(
- Tcl_Interp *interp, Tcl_Obj *objPtr, int *statePtr)
+ Tcl_Interp *interp, Tcl_Obj *objPtr, Ttk_Compound *compoundPtr)
{
- *statePtr = TTK_COMPOUND_NONE;
- return Tcl_GetIndexFromObjStruct(interp, objPtr, ttkCompoundStrings,
- sizeof(char *), "compound layout", 0, statePtr);
+ int compound = (int)TTK_COMPOUND_NONE;
+ int result = Tcl_GetIndexFromObj(interp, objPtr, ttkCompoundStrings,
+ "compound layout", 0, &compound);
+
+ *compoundPtr = (Ttk_Compound)compound;
+ return result;
}
/*
@@ -49,12 +55,25 @@ const char *const ttkOrientStrings[] = {
"horizontal", "vertical", NULL
};
+#if !defined(TK_NO_DEPRECATED) && TK_MAJOR_VERSION < 9
int Ttk_GetOrientFromObj(
Tcl_Interp *interp, Tcl_Obj *objPtr, int *resultPtr)
{
*resultPtr = TTK_ORIENT_HORIZONTAL;
- return Tcl_GetIndexFromObjStruct(interp, objPtr, ttkOrientStrings,
- sizeof(char *), "orientation", 0, resultPtr);
+ return Tcl_GetIndexFromObj(interp, objPtr, ttkOrientStrings,
+ "orientation", 0, resultPtr);
+}
+#endif
+
+int TtkGetOrientFromObj(
+ Tcl_Interp *interp, Tcl_Obj *objPtr, Ttk_Orient *resultPtr)
+{
+ int orient = (int)TTK_ORIENT_HORIZONTAL;
+ int result = Tcl_GetIndexFromObj(interp, objPtr, ttkOrientStrings,
+ "orientation", 0, &orient);
+
+ *resultPtr = (Ttk_Orient)orient;
+ return result;
}
/*
@@ -62,13 +81,13 @@ int Ttk_GetOrientFromObj(
* Other options are accepted and interpreted as synonyms for "normal".
*/
static const char *const ttkStateStrings[] = {
- "normal", "readonly", "disabled", "active", NULL
+ "active", "disabled", "normal", "readonly", NULL
};
enum {
- TTK_COMPAT_STATE_NORMAL,
- TTK_COMPAT_STATE_READONLY,
+ TTK_COMPAT_STATE_ACTIVE,
TTK_COMPAT_STATE_DISABLED,
- TTK_COMPAT_STATE_ACTIVE
+ TTK_COMPAT_STATE_NORMAL,
+ TTK_COMPAT_STATE_READONLY
};
/* TtkCheckStateOption --
@@ -85,8 +104,8 @@ void TtkCheckStateOption(WidgetCore *corePtr, Tcl_Obj *objPtr)
unsigned all = TTK_STATE_DISABLED|TTK_STATE_READONLY|TTK_STATE_ACTIVE;
# define SETFLAGS(f) TtkWidgetChangeState(corePtr, f, all^f)
- (void)Tcl_GetIndexFromObjStruct(NULL, objPtr, ttkStateStrings,
- sizeof(char *), "", 0, &stateOption);
+ Tcl_GetIndexFromObj(NULL, objPtr, ttkStateStrings,
+ "", 0, &stateOption);
switch (stateOption) {
case TTK_COMPAT_STATE_NORMAL:
default:
@@ -105,28 +124,6 @@ void TtkCheckStateOption(WidgetCore *corePtr, Tcl_Obj *objPtr)
# undef SETFLAGS
}
-/* TtkSendVirtualEvent --
- * Send a virtual event notification to the specified target window.
- * Equivalent to "event generate $tgtWindow <<$eventName>> -when tail"
- *
- * Note that we use Tk_QueueWindowEvent, not Tk_HandleEvent,
- * so this routine does not reenter the interpreter.
- */
-void TtkSendVirtualEvent(Tk_Window tgtWin, const char *eventName)
-{
- union {XEvent general; XVirtualEvent virt;} event;
-
- memset(&event, 0, sizeof(event));
- event.general.xany.type = VirtualEvent;
- event.general.xany.serial = NextRequest(Tk_Display(tgtWin));
- event.general.xany.send_event = False;
- event.general.xany.window = Tk_WindowId(tgtWin);
- event.general.xany.display = Tk_Display(tgtWin);
- event.virt.name = Tk_GetUid(eventName);
-
- Tk_QueueWindowEvent(&event.general, TCL_QUEUE_TAIL);
-}
-
/* TtkEnumerateOptions, TtkGetOptionValue --
* Common factors for data accessor commands.
*/
@@ -148,7 +145,7 @@ int TtkEnumerateOptions(
if (specPtr->type == TK_OPTION_END && specPtr->clientData != NULL) {
/* Chain to next option spec array: */
- specPtr = specPtr->clientData;
+ specPtr = (const Tk_OptionSpec *)specPtr->clientData;
}
}
Tcl_SetObjResult(interp, result);
@@ -175,14 +172,14 @@ int TtkGetOptionValue(
*/
/* public */
-Tk_OptionSpec ttkCoreOptionSpecs[] =
+const Tk_OptionSpec ttkCoreOptionSpecs[] =
{
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", NULL,
- Tk_Offset(WidgetCore, cursorObj), -1, TK_OPTION_NULL_OK,0,0 },
+ offsetof(WidgetCore, cursorObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,0 },
{TK_OPTION_STRING, "-style", "style", "Style", "",
- Tk_Offset(WidgetCore,styleObj), -1, 0,0,STYLE_CHANGED},
+ offsetof(WidgetCore,styleObj), TCL_INDEX_NONE, 0,0,STYLE_CHANGED},
{TK_OPTION_STRING, "-class", "", "", NULL,
- Tk_Offset(WidgetCore,classObj), -1, 0,0,READONLY_OPTION},
+ offsetof(WidgetCore,classObj), TCL_INDEX_NONE, 0,0,READONLY_OPTION},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0}
};
@@ -190,9 +187,9 @@ Tk_OptionSpec ttkCoreOptionSpecs[] =
* +++ Initialization: elements and element factories.
*/
-extern void TtkElements_Init(Tcl_Interp *);
-extern void TtkLabel_Init(Tcl_Interp *);
-extern void TtkImage_Init(Tcl_Interp *);
+MODULE_SCOPE void TtkElements_Init(Tcl_Interp *);
+MODULE_SCOPE void TtkLabel_Init(Tcl_Interp *);
+MODULE_SCOPE void TtkImage_Init(Tcl_Interp *);
static void RegisterElements(Tcl_Interp *interp)
{
@@ -205,19 +202,19 @@ static void RegisterElements(Tcl_Interp *interp)
* +++ Initialization: Widget definitions.
*/
-extern void TtkButton_Init(Tcl_Interp *);
-extern void TtkEntry_Init(Tcl_Interp *);
-extern void TtkFrame_Init(Tcl_Interp *);
-extern void TtkNotebook_Init(Tcl_Interp *);
-extern void TtkPanedwindow_Init(Tcl_Interp *);
-extern void TtkProgressbar_Init(Tcl_Interp *);
-extern void TtkScale_Init(Tcl_Interp *);
-extern void TtkScrollbar_Init(Tcl_Interp *);
-extern void TtkSeparator_Init(Tcl_Interp *);
-extern void TtkTreeview_Init(Tcl_Interp *);
+MODULE_SCOPE void TtkButton_Init(Tcl_Interp *);
+MODULE_SCOPE void TtkEntry_Init(Tcl_Interp *);
+MODULE_SCOPE void TtkFrame_Init(Tcl_Interp *);
+MODULE_SCOPE void TtkNotebook_Init(Tcl_Interp *);
+MODULE_SCOPE void TtkPanedwindow_Init(Tcl_Interp *);
+MODULE_SCOPE void TtkProgressbar_Init(Tcl_Interp *);
+MODULE_SCOPE void TtkScale_Init(Tcl_Interp *);
+MODULE_SCOPE void TtkScrollbar_Init(Tcl_Interp *);
+MODULE_SCOPE void TtkSeparator_Init(Tcl_Interp *);
+MODULE_SCOPE void TtkTreeview_Init(Tcl_Interp *);
#ifdef TTK_SQUARE_WIDGET
-extern int TtkSquareWidget_Init(Tcl_Interp *);
+MODULE_SCOPE int TtkSquareWidget_Init(Tcl_Interp *);
#endif
static void RegisterWidgets(Tcl_Interp *interp)
@@ -241,9 +238,9 @@ static void RegisterWidgets(Tcl_Interp *interp)
* +++ Initialization: Built-in themes.
*/
-extern int TtkAltTheme_Init(Tcl_Interp *);
-extern int TtkClassicTheme_Init(Tcl_Interp *);
-extern int TtkClamTheme_Init(Tcl_Interp *);
+MODULE_SCOPE int TtkAltTheme_Init(Tcl_Interp *);
+MODULE_SCOPE int TtkClassicTheme_Init(Tcl_Interp *);
+MODULE_SCOPE int TtkClamTheme_Init(Tcl_Interp *);
static void RegisterThemes(Tcl_Interp *interp)
{
@@ -274,7 +271,10 @@ Ttk_Init(Tcl_Interp *interp)
Ttk_PlatformInit(interp);
+#ifndef TK_NO_DEPRECATED
Tcl_PkgProvideEx(interp, "Ttk", TTK_PATCH_LEVEL, (void *)&ttkStubs);
+#endif
+ Tcl_PkgProvideEx(interp, "ttk", TTK_PATCH_LEVEL, (void *)&ttkStubs);
return TCL_OK;
}
diff --git a/generic/ttk/ttkLabel.c b/generic/ttk/ttkLabel.c
index c34d479..f9698ed 100644
--- a/generic/ttk/ttkLabel.c
+++ b/generic/ttk/ttkLabel.c
@@ -46,25 +46,29 @@ typedef struct {
/* Text element options table.
* NB: Keep in sync with label element option table.
*/
-static Ttk_ElementOptionSpec TextElementOptions[] = {
+static const Ttk_ElementOptionSpec TextElementOptions[] = {
{ "-text", TK_OPTION_STRING,
- Tk_Offset(TextElement,textObj), "" },
+ offsetof(TextElement,textObj), "" },
{ "-font", TK_OPTION_FONT,
- Tk_Offset(TextElement,fontObj), DEFAULT_FONT },
+ offsetof(TextElement,fontObj), DEFAULT_FONT },
{ "-foreground", TK_OPTION_COLOR,
- Tk_Offset(TextElement,foregroundObj), "black" },
- { "-underline", TK_OPTION_INT,
- Tk_Offset(TextElement,underlineObj), "-1"},
+ offsetof(TextElement,foregroundObj), "black" },
+ { "-underline", TK_OPTION_INDEX,
+#if !defined(TK_NO_DEPRECATED) && (TCL_MAJOR_VERSION < 9)
+ offsetof(TextElement,underlineObj), "-1"},
+#else
+ offsetof(TextElement,underlineObj), NULL},
+#endif
{ "-width", TK_OPTION_INT,
- Tk_Offset(TextElement,widthObj), "-1"},
+ offsetof(TextElement,widthObj), "-1"},
{ "-anchor", TK_OPTION_ANCHOR,
- Tk_Offset(TextElement,anchorObj), "w"},
+ offsetof(TextElement,anchorObj), "w"},
{ "-justify", TK_OPTION_JUSTIFY,
- Tk_Offset(TextElement,justifyObj), "left" },
+ offsetof(TextElement,justifyObj), "left" },
{ "-wraplength", TK_OPTION_PIXELS,
- Tk_Offset(TextElement,wrapLengthObj), "0" },
+ offsetof(TextElement,wrapLengthObj), "0" },
{ "-embossed", TK_OPTION_INT,
- Tk_Offset(TextElement,embossedObj), "0"},
+ offsetof(TextElement,embossedObj), "0"},
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -126,7 +130,7 @@ static void TextCleanup(TextElement *text)
static void TextDraw(TextElement *text, Tk_Window tkwin, Drawable d, Ttk_Box b)
{
XColor *color = Tk_GetColorFromObj(tkwin, text->foregroundObj);
- int underline = -1;
+ Tcl_Size underline = INT_MIN;
XGCValues gcValues;
GC gc1, gc2;
Tk_Anchor anchor = TK_ANCHOR_CENTER;
@@ -170,14 +174,21 @@ static void TextDraw(TextElement *text, Tk_Window tkwin, Drawable d, Ttk_Box b)
Tk_DrawTextLayout(Tk_Display(tkwin), d, gc1,
text->textLayout, b.x, b.y, 0/*firstChar*/, -1/*lastChar*/);
- Tcl_GetIntFromObj(NULL, text->underlineObj, &underline);
- if (underline >= 0) {
- if (text->embossed) {
- Tk_UnderlineTextLayout(Tk_Display(tkwin), d, gc2,
- text->textLayout, b.x+1, b.y+1, underline);
+ if (text->underlineObj != NULL) {
+ TkGetIntForIndex(text->underlineObj, TCL_INDEX_NONE, 0, &underline);
+ if (underline < INT_MIN) {
+ underline = INT_MIN;
+ } else if (underline > INT_MAX) {
+ underline = INT_MAX;
+ }
+ if (underline != INT_MIN) {
+ if (text->embossed) {
+ Tk_UnderlineTextLayout(Tk_Display(tkwin), d, gc2,
+ text->textLayout, b.x+1, b.y+1, underline);
+ }
+ Tk_UnderlineTextLayout(Tk_Display(tkwin), d, gc1,
+ text->textLayout, b.x, b.y, underline);
}
- Tk_UnderlineTextLayout(Tk_Display(tkwin), d, gc1,
- text->textLayout, b.x, b.y, underline);
}
if (clipRegion != NULL) {
@@ -229,7 +240,7 @@ static void TextElementDraw(
}
}
-static Ttk_ElementSpec TextElementSpec = {
+static const Ttk_ElementSpec TextElementSpec = {
TK_STYLE_VERSION_2,
sizeof(TextElement),
TextElementOptions,
@@ -238,6 +249,51 @@ static Ttk_ElementSpec TextElementSpec = {
};
/*----------------------------------------------------------------------
+ * +++ cText (collapsing text) element.
+ *
+ * This element is the same as the Text element, except its dimensions
+ * are 0,0 when the text to display is "".
+ */
+
+static int cTextSetup(TextElement *text, Tk_Window tkwin)
+{
+ if (*Tcl_GetString(text->textObj) == '\0') {
+ return 0;
+ } else {
+ return TextSetup(text, tkwin);
+ }
+}
+
+static void cTextElementSize(
+ TCL_UNUSED(void *), /* clientData */
+ void *elementRecord,
+ Tk_Window tkwin,
+ int *widthPtr,
+ int *heightPtr,
+ TCL_UNUSED(Ttk_Padding *))
+{
+ TextElement *text = (TextElement *)elementRecord;
+
+ if (!cTextSetup(text, tkwin))
+ return;
+
+ *heightPtr = text->height;
+ *widthPtr = TextReqWidth(text);
+
+ TextCleanup(text);
+
+ return;
+}
+
+static const Ttk_ElementSpec cTextElementSpec = {
+ TK_STYLE_VERSION_2,
+ sizeof(TextElement),
+ TextElementOptions,
+ cTextElementSize,
+ TextElementDraw
+};
+
+/*----------------------------------------------------------------------
* +++ Image element.
* Draws an image.
*/
@@ -255,13 +311,13 @@ typedef struct {
/* ===> NB: Keep in sync with label element option table. <===
*/
-static Ttk_ElementOptionSpec ImageElementOptions[] = {
+static const Ttk_ElementOptionSpec ImageElementOptions[] = {
{ "-image", TK_OPTION_STRING,
- Tk_Offset(ImageElement,imageObj), "" },
+ offsetof(ImageElement,imageObj), "" },
{ "-stipple", TK_OPTION_STRING, /* Really: TK_OPTION_BITMAP */
- Tk_Offset(ImageElement,stippleObj), "gray50" },
+ offsetof(ImageElement,stippleObj), "gray50" },
{ "-background", TK_OPTION_COLOR,
- Tk_Offset(ImageElement,backgroundObj), DEFAULT_BACKGROUND },
+ offsetof(ImageElement,backgroundObj), DEFAULT_BACKGROUND },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -401,7 +457,7 @@ static void ImageElementDraw(
}
}
-static Ttk_ElementSpec ImageElementSpec = {
+static const Ttk_ElementSpec ImageElementSpec = {
TK_STYLE_VERSION_2,
sizeof(ImageElement),
ImageElementOptions,
@@ -457,43 +513,47 @@ typedef struct {
int totalWidth, totalHeight;
} LabelElement;
-static Ttk_ElementOptionSpec LabelElementOptions[] = {
+static const Ttk_ElementOptionSpec LabelElementOptions[] = {
{ "-compound", TK_OPTION_ANY,
- Tk_Offset(LabelElement,compoundObj), "none" },
+ offsetof(LabelElement,compoundObj), "none" },
{ "-space", TK_OPTION_PIXELS,
- Tk_Offset(LabelElement,spaceObj), "4" },
+ offsetof(LabelElement,spaceObj), "4" },
/* Text element part:
* NB: Keep in sync with TextElementOptions.
*/
{ "-text", TK_OPTION_STRING,
- Tk_Offset(LabelElement,text.textObj), "" },
+ offsetof(LabelElement,text.textObj), "" },
{ "-font", TK_OPTION_FONT,
- Tk_Offset(LabelElement,text.fontObj), DEFAULT_FONT },
+ offsetof(LabelElement,text.fontObj), DEFAULT_FONT },
{ "-foreground", TK_OPTION_COLOR,
- Tk_Offset(LabelElement,text.foregroundObj), "black" },
- { "-underline", TK_OPTION_INT,
- Tk_Offset(LabelElement,text.underlineObj), "-1"},
+ offsetof(LabelElement,text.foregroundObj), "black" },
+ { "-underline", TK_OPTION_INDEX,
+#if !defined(TK_NO_DEPRECATED) && (TCL_MAJOR_VERSION < 9)
+ offsetof(LabelElement,text.underlineObj), "-1"},
+#else
+ offsetof(LabelElement,text.underlineObj), NULL},
+#endif
{ "-width", TK_OPTION_INT,
- Tk_Offset(LabelElement,text.widthObj), ""},
+ offsetof(LabelElement,text.widthObj), ""},
{ "-anchor", TK_OPTION_ANCHOR,
- Tk_Offset(LabelElement,text.anchorObj), "w"},
+ offsetof(LabelElement,text.anchorObj), "w"},
{ "-justify", TK_OPTION_JUSTIFY,
- Tk_Offset(LabelElement,text.justifyObj), "left" },
+ offsetof(LabelElement,text.justifyObj), "left" },
{ "-wraplength", TK_OPTION_PIXELS,
- Tk_Offset(LabelElement,text.wrapLengthObj), "0" },
+ offsetof(LabelElement,text.wrapLengthObj), "0" },
{ "-embossed", TK_OPTION_INT,
- Tk_Offset(LabelElement,text.embossedObj), "0"},
+ offsetof(LabelElement,text.embossedObj), "0"},
/* Image element part:
* NB: Keep in sync with ImageElementOptions.
*/
{ "-image", TK_OPTION_STRING,
- Tk_Offset(LabelElement,image.imageObj), "" },
+ offsetof(LabelElement,image.imageObj), "" },
{ "-stipple", TK_OPTION_STRING, /* Really: TK_OPTION_BITMAP */
- Tk_Offset(LabelElement,image.stippleObj), "gray50" },
+ offsetof(LabelElement,image.stippleObj), "gray50" },
{ "-background", TK_OPTION_COLOR,
- Tk_Offset(LabelElement,image.backgroundObj), DEFAULT_BACKGROUND },
+ offsetof(LabelElement,image.backgroundObj), DEFAULT_BACKGROUND },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -512,7 +572,7 @@ static void LabelSetup(
Ttk_Compound *compoundPtr = &c->compound;
Tk_GetPixelsFromObj(NULL, tkwin, c->spaceObj, &c->space);
- Ttk_GetCompoundFromObj(NULL, c->compoundObj, (int *)compoundPtr);
+ Ttk_GetCompoundFromObj(NULL, c->compoundObj, compoundPtr);
/*
* Deal with TTK_COMPOUND_NONE.
@@ -628,7 +688,7 @@ static void LabelElementSize(
*/
static void DrawCompound(
LabelElement *l, Ttk_Box b, Tk_Window tkwin, Drawable d, Ttk_State state,
- int imageSide, int textSide)
+ Ttk_Side imageSide, Ttk_Side textSide)
{
Ttk_Box imageBox =
Ttk_PlaceBox(&b, l->image.width, l->image.height, imageSide, 0);
@@ -698,7 +758,7 @@ static void LabelElementDraw(
LabelCleanup(l);
}
-static Ttk_ElementSpec LabelElementSpec = {
+static const Ttk_ElementSpec LabelElementSpec = {
TK_STYLE_VERSION_2,
sizeof(LabelElement),
LabelElementOptions,
@@ -716,6 +776,7 @@ TtkLabel_Init(Tcl_Interp *interp)
Ttk_Theme theme = Ttk_GetDefaultTheme(interp);
Ttk_RegisterElement(interp, theme, "text", &TextElementSpec, NULL);
+ Ttk_RegisterElement(interp, theme, "ctext", &cTextElementSpec, NULL);
Ttk_RegisterElement(interp, theme, "image", &ImageElementSpec, NULL);
Ttk_RegisterElement(interp, theme, "label", &LabelElementSpec, NULL);
}
diff --git a/generic/ttk/ttkLayout.c b/generic/ttk/ttkLayout.c
index 3e77ba4..31c5ed2 100644
--- a/generic/ttk/ttkLayout.c
+++ b/generic/ttk/ttkLayout.c
@@ -3,7 +3,7 @@
*
* Generic layout processing.
*
- * Copyright (c) 2003 Joe English. Freely redistributable.
+ * Copyright © 2003 Joe English. Freely redistributable.
*/
#include "tkInt.h"
@@ -43,10 +43,10 @@ Ttk_NewBoxObj(Ttk_Box box)
{
Tcl_Obj *result[4];
- result[0] = Tcl_NewIntObj(box.x);
- result[1] = Tcl_NewIntObj(box.y);
- result[2] = Tcl_NewIntObj(box.width);
- result[3] = Tcl_NewIntObj(box.height);
+ result[0] = Tcl_NewWideIntObj(box.x);
+ result[1] = Tcl_NewWideIntObj(box.y);
+ result[2] = Tcl_NewWideIntObj(box.width);
+ result[3] = Tcl_NewWideIntObj(box.height);
return Tcl_NewListObj(4, result);
}
@@ -227,8 +227,7 @@ static Ttk_Sticky AnchorToSticky(Tk_Anchor anchor)
case TK_ANCHOR_SW: return TTK_STICK_S | TTK_STICK_W;
case TK_ANCHOR_W: return TTK_STICK_W;
case TK_ANCHOR_NW: return TTK_STICK_N | TTK_STICK_W;
- default:
- case TK_ANCHOR_CENTER: return 0;
+ default: return 0;
}
}
@@ -325,7 +324,8 @@ int Ttk_GetPaddingFromObj(
Ttk_Padding *pad)
{
Tcl_Obj **padv;
- int i, padc, pixels[4];
+ Tcl_Size i, padc;
+ int pixels[4];
if (TCL_OK != Tcl_ListObjGetElements(interp, objPtr, &padc, &padv)) {
goto error;
@@ -363,7 +363,8 @@ error:
int Ttk_GetBorderFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, Ttk_Padding *pad)
{
Tcl_Obj **padv;
- int i, padc, pixels[4];
+ Tcl_Size i, padc;
+ int pixels[4];
if (TCL_OK != Tcl_ListObjGetElements(interp, objPtr, &padc, &padv)) {
goto error;
@@ -532,7 +533,7 @@ struct Ttk_LayoutNode_
static Ttk_LayoutNode *Ttk_NewLayoutNode(
unsigned flags, Ttk_ElementClass *elementClass)
{
- Ttk_LayoutNode *node = ckalloc(sizeof(*node));
+ Ttk_LayoutNode *node = (Ttk_LayoutNode *)ckalloc(sizeof(*node));
node->flags = flags;
node->eclass = elementClass;
@@ -565,8 +566,8 @@ struct Ttk_TemplateNode_ {
static Ttk_TemplateNode *Ttk_NewTemplateNode(const char *name, unsigned flags)
{
- Ttk_TemplateNode *op = ckalloc(sizeof(*op));
- op->name = ckalloc(strlen(name) + 1); strcpy(op->name, name);
+ Ttk_TemplateNode *op = (Ttk_TemplateNode *)ckalloc(sizeof(*op));
+ op->name = (char *)ckalloc(strlen(name) + 1); strcpy(op->name, name);
op->flags = flags;
op->next = op->child = 0;
return op;
@@ -620,7 +621,7 @@ Ttk_LayoutTemplate Ttk_ParseLayoutTemplate(Tcl_Interp *interp, Tcl_Obj *objPtr)
static const char *const optStrings[] = {
"-side", "-sticky", "-expand", "-border", "-unit", "-children", 0 };
- int i = 0, objc;
+ Tcl_Size i = 0, objc;
Tcl_Obj **objv;
Ttk_TemplateNode *head = 0, *tail = 0;
@@ -851,7 +852,7 @@ static Ttk_Layout TTKNewLayout(
void *recordPtr,Tk_OptionTable optionTable, Tk_Window tkwin,
Ttk_LayoutNode *root)
{
- Ttk_Layout layout = ckalloc(sizeof(*layout));
+ Ttk_Layout layout = (Ttk_Layout)ckalloc(sizeof(*layout));
layout->style = style;
layout->recordPtr = recordPtr;
layout->optionTable = optionTable;
@@ -920,8 +921,8 @@ Ttk_CreateSublayout(
Ttk_LayoutTemplate layoutTemplate;
Tcl_DStringInit(&buf);
- Tcl_DStringAppend(&buf, Ttk_StyleName(parentLayout->style), -1);
- Tcl_DStringAppend(&buf, baseName, -1);
+ Tcl_DStringAppend(&buf, Ttk_StyleName(parentLayout->style), TCL_INDEX_NONE);
+ Tcl_DStringAppend(&buf, baseName, TCL_INDEX_NONE);
styleName = Tcl_DStringValue(&buf);
style = Ttk_GetStyle(themePtr, styleName);
@@ -1256,6 +1257,37 @@ void Ttk_PlaceElement(Ttk_Layout layout, Ttk_Element node, Ttk_Box b)
}
/*
+ * AnchorToPosition --
+ * Convert a Tk_Anchor enum to a position bitmask.
+ */
+static Ttk_PositionSpec AnchorToPosition(Tk_Anchor anchor)
+{
+ switch (anchor)
+ {
+ case TK_ANCHOR_N: return TTK_PACK_TOP;
+ case TK_ANCHOR_S: return TTK_PACK_BOTTOM;
+ case TK_ANCHOR_NE: return TTK_PACK_RIGHT|TTK_STICK_N;
+ case TK_ANCHOR_SE: return TTK_PACK_RIGHT|TTK_STICK_S;
+ case TK_ANCHOR_E: return TTK_PACK_RIGHT;
+ case TK_ANCHOR_NW: return TTK_PACK_LEFT|TTK_STICK_N;
+ case TK_ANCHOR_SW: return TTK_PACK_LEFT|TTK_STICK_S;
+ case TK_ANCHOR_W: return TTK_PACK_LEFT;
+ case TK_ANCHOR_CENTER: return 0;
+ default:;
+ }
+ return TTK_PACK_LEFT;
+}
+
+/*
+ * Ttk_AnchorElement --
+ * Explicitly specify an element's anchoring.
+ */
+void Ttk_AnchorElement(Ttk_Element node, Tk_Anchor anchor)
+{
+ node->flags = AnchorToPosition(anchor);
+}
+
+/*
* Ttk_ChangeElementState --
*/
void Ttk_ChangeElementState(Ttk_LayoutNode *node,unsigned set,unsigned clr)
diff --git a/generic/ttk/ttkManager.c b/generic/ttk/ttkManager.c
index 9c02a54..1ea5f54 100644
--- a/generic/ttk/ttkManager.c
+++ b/generic/ttk/ttkManager.c
@@ -34,9 +34,9 @@
* (2) Manager voluntarily relinquishes control
* (3) Content window is destroyed
*
- * In case (1), Tk calls the manager's lostSlaveProc.
+ * In case (1), Tk calls the manager's lostContentProc.
* Case (2) is performed by calling Tk_ManageGeometry(window,NULL,0);
- * in this case Tk does _not_ call the lostSlaveProc (documented behavior).
+ * in this case Tk does _not_ call the lostContentProc (documented behavior).
* Tk doesn't handle case (3) either; to account for that we
* register an event handler on the content window to track <Destroy> events.
*/
@@ -57,11 +57,11 @@ typedef struct
struct TtkManager_
{
- Ttk_ManagerSpec *managerSpec;
+ const Ttk_ManagerSpec *managerSpec;
void *managerData;
Tk_Window window;
unsigned flags;
- int nContent;
+ Tcl_Size nContent;
Ttk_Content **content;
};
@@ -106,14 +106,14 @@ static void RecomputeSize(Ttk_Manager *mgr)
*/
static void RecomputeLayout(Ttk_Manager *mgr)
{
- mgr->managerSpec->PlaceSlaves(mgr->managerData);
+ mgr->managerSpec->PlaceContent(mgr->managerData);
mgr->flags &= ~MGR_RELAYOUT_REQUIRED;
}
/* ++ ManagerIdleProc --
* DoWhenIdle procedure for deferred updates.
*/
-static void ManagerIdleProc(ClientData clientData)
+static void ManagerIdleProc(void *clientData)
{
Ttk_Manager *mgr = (Ttk_Manager *)clientData;
mgr->flags &= ~MGR_UPDATE_PENDING;
@@ -139,10 +139,10 @@ static void ManagerIdleProc(ClientData clientData)
* Keep the content's map state in sync with the container's.
*/
static const int ManagerEventMask = StructureNotifyMask;
-static void ManagerEventHandler(ClientData clientData, XEvent *eventPtr)
+static void ManagerEventHandler(void *clientData, XEvent *eventPtr)
{
Ttk_Manager *mgr = (Ttk_Manager *)clientData;
- int i;
+ Tcl_Size i;
switch (eventPtr->type)
{
@@ -174,7 +174,7 @@ static void ContentLostEventHandler(void *clientData, XEvent *eventPtr)
{
Ttk_Content *content = (Ttk_Content *)clientData;
if (eventPtr->type == DestroyNotify) {
- content->manager->managerSpec->tkGeomMgr.lostSlaveProc(
+ content->manager->managerSpec->tkGeomMgr.lostContentProc(
content->manager, content->window);
}
}
@@ -206,7 +206,7 @@ static void DeleteContent(Ttk_Content *content)
*/
Ttk_Manager *Ttk_CreateManager(
- Ttk_ManagerSpec *managerSpec, void *managerData, Tk_Window window)
+ const Ttk_ManagerSpec *managerSpec, void *managerData, Tk_Window window)
{
Ttk_Manager *mgr = (Ttk_Manager *)ckalloc(sizeof(*mgr));
@@ -247,9 +247,9 @@ void Ttk_DeleteManager(Ttk_Manager *mgr)
/* ++ InsertContent --
* Adds content to the list of managed windows.
*/
-static void InsertContent(Ttk_Manager *mgr, Ttk_Content *content, int index)
+static void InsertContent(Ttk_Manager *mgr, Ttk_Content *content, Tcl_Size index)
{
- int endIndex = mgr->nContent++;
+ Tcl_Size endIndex = mgr->nContent++;
mgr->content = (Ttk_Content **)ckrealloc(mgr->content, mgr->nContent * sizeof(Ttk_Content *));
while (endIndex > index) {
@@ -276,14 +276,14 @@ static void InsertContent(Ttk_Manager *mgr, Ttk_Content *content, int index)
* [1] It's safe to call Tk_UnmapWindow / Tk_UnmaintainGeometry even if this
* routine is called from the content window's DestroyNotify event handler.
*/
-static void RemoveContent(Ttk_Manager *mgr, int index)
+static void RemoveContent(Ttk_Manager *mgr, Tcl_Size index)
{
Ttk_Content *content = mgr->content[index];
- int i;
+ Tcl_Size i;
/* Notify manager:
*/
- mgr->managerSpec->SlaveRemoved(mgr->managerData, index);
+ mgr->managerSpec->ContentRemoved(mgr->managerData, index);
/* Remove from array:
*/
@@ -310,25 +310,25 @@ static void RemoveContent(Ttk_Manager *mgr, int index)
* +++ Tk_GeomMgr hooks.
*/
-void Ttk_GeometryRequestProc(ClientData clientData, Tk_Window window)
+void Ttk_GeometryRequestProc(void *clientData, Tk_Window window)
{
Ttk_Manager *mgr = (Ttk_Manager *)clientData;
- int index = Ttk_ContentIndex(mgr, window);
+ Tcl_Size index = Ttk_ContentIndex(mgr, window);
if (index >= 0) {
int reqWidth = Tk_ReqWidth(window);
int reqHeight= Tk_ReqHeight(window);
- if (mgr->managerSpec->SlaveRequest(
+ if (mgr->managerSpec->ContentRequest(
mgr->managerData, index, reqWidth, reqHeight)) {
ScheduleUpdate(mgr, MGR_RESIZE_REQUIRED);
}
}
}
-void Ttk_LostContentProc(ClientData clientData, Tk_Window window)
+void Ttk_LostContentProc(void *clientData, Tk_Window window)
{
Ttk_Manager *mgr = (Ttk_Manager *)clientData;
- int index = Ttk_ContentIndex(mgr, window);
+ Tcl_Size index = Ttk_ContentIndex(mgr, window);
/* ASSERT: index >= 0 */
RemoveContent(mgr, index);
@@ -342,7 +342,7 @@ void Ttk_LostContentProc(ClientData clientData, Tk_Window window)
* Add a new content window at the specified index.
*/
void Ttk_InsertContent(
- Ttk_Manager *mgr, int index, Tk_Window tkwin, void *data)
+ Ttk_Manager *mgr, Tcl_Size index, Tk_Window tkwin, void *data)
{
Ttk_Content *content = NewContent(mgr, tkwin, data);
InsertContent(mgr, content, index);
@@ -351,7 +351,7 @@ void Ttk_InsertContent(
/* ++ Ttk_ForgetContent --
* Unmanage the specified content window.
*/
-void Ttk_ForgetContent(Ttk_Manager *mgr, int index)
+void Ttk_ForgetContent(Ttk_Manager *mgr, Tcl_Size index)
{
Tk_Window window = mgr->content[index]->window;
RemoveContent(mgr, index);
@@ -366,7 +366,7 @@ void Ttk_ForgetContent(Ttk_Manager *mgr, int index)
* map the content window.
*/
void Ttk_PlaceContent(
- Ttk_Manager *mgr, int index, int x, int y, int width, int height)
+ Ttk_Manager *mgr, Tcl_Size index, int x, int y, int width, int height)
{
Ttk_Content *content = mgr->content[index];
Tk_MaintainGeometry(content->window,mgr->window,x,y,width,height);
@@ -379,7 +379,7 @@ void Ttk_PlaceContent(
/* ++ Ttk_UnmapContent --
* Unmap the specified content window, but leave it managed.
*/
-void Ttk_UnmapContent(Ttk_Manager *mgr, int index)
+void Ttk_UnmapContent(Ttk_Manager *mgr, Tcl_Size index)
{
Ttk_Content *content = mgr->content[index];
Tk_UnmaintainGeometry(content->window, mgr->window);
@@ -405,15 +405,15 @@ void Ttk_ManagerSizeChanged(Ttk_Manager *mgr)
/* +++ Accessors.
*/
-int Ttk_NumberContent(Ttk_Manager *mgr)
+Tcl_Size Ttk_NumberContent(Ttk_Manager *mgr)
{
return mgr->nContent;
}
-void *Ttk_ContentData(Ttk_Manager *mgr, int index)
+void *Ttk_ContentData(Ttk_Manager *mgr, Tcl_Size index)
{
return mgr->content[index]->data;
}
-Tk_Window Ttk_ContentWindow(Ttk_Manager *mgr, int index)
+Tk_Window Ttk_ContentWindow(Ttk_Manager *mgr, Tcl_Size index)
{
return mgr->content[index]->window;
}
@@ -423,40 +423,49 @@ Tk_Window Ttk_ContentWindow(Ttk_Manager *mgr, int index)
*/
/* ++ Ttk_ContentIndex --
- * Returns the index of specified content window, -1 if not found.
+ * Returns the index of specified content window, TCL_INDEX_NONE if not found.
*/
-int Ttk_ContentIndex(Ttk_Manager *mgr, Tk_Window window)
+Tcl_Size Ttk_ContentIndex(Ttk_Manager *mgr, Tk_Window window)
{
- int index;
+ Tcl_Size index;
for (index = 0; index < mgr->nContent; ++index)
if (mgr->content[index]->window == window)
return index;
return -1;
}
-/* ++ Ttk_GetContentIndexFromObj(interp, mgr, objPtr, indexPtr) --
+/* ++ Ttk_GetContentIndexFromObj(interp, mgr, objPtr, lastOK, indexPtr) --
* Return the index of the content window specified by objPtr.
* Content windows may be specified as an integer index or
* as the name of the managed window.
*
+ * The parameter lastOK should be non-0 if the resolved index can be equal to
+ * the current size (i.e. one more than the current highest index) and 0
+ * otherwise.
+ *
* Returns:
* Standard Tcl completion code. Leaves an error message in case of error.
*/
int Ttk_GetContentIndexFromObj(
- Tcl_Interp *interp, Ttk_Manager *mgr, Tcl_Obj *objPtr, int *indexPtr)
+ Tcl_Interp *interp, Ttk_Manager *mgr, Tcl_Obj *objPtr, int lastOK, Tcl_Size *indexPtr)
{
const char *string = Tcl_GetString(objPtr);
- int index = 0;
+ Tcl_Size index = 0;
Tk_Window tkwin;
/* Try interpreting as an integer first:
*/
- if (Tcl_GetIntFromObj(NULL, objPtr, &index) == TCL_OK) {
- if (index < 0 || index >= mgr->nContent) {
+ if (TkGetIntForIndex(objPtr, mgr->nContent - 1, lastOK, &index) == TCL_OK) {
+ /*
+ * Note despite passing lastOK above, we still need to check here
+ * as well as TkGetIntForIndex only uses lastOK for end-relative indices,
+ * not integers.
+ */
+ if (index < 0 || (index - !!lastOK) >= mgr->nContent) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "Slave index %d out of bounds", index));
- Tcl_SetErrorCode(interp, "TTK", "SLAVE", "INDEX", NULL);
+ "Managed window index \"%s\" out of bounds", Tcl_GetString(objPtr)));
+ Tcl_SetErrorCode(interp, "TTK", "MANAGED", "INDEX", NULL);
return TCL_ERROR;
}
*indexPtr = index;
@@ -472,7 +481,7 @@ int Ttk_GetContentIndexFromObj(
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"%s is not managed by %s", string,
Tk_PathName(mgr->window)));
- Tcl_SetErrorCode(interp, "TTK", "SLAVE", "MANAGER", NULL);
+ Tcl_SetErrorCode(interp, "TTK", "MANAGED", "MANAGER", NULL);
return TCL_ERROR;
}
*indexPtr = index;
@@ -480,15 +489,15 @@ int Ttk_GetContentIndexFromObj(
}
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "Invalid slave specification %s", string));
- Tcl_SetErrorCode(interp, "TTK", "SLAVE", "SPEC", NULL);
+ "Invalid managed window specification %s", string));
+ Tcl_SetErrorCode(interp, "TTK", "MANAGED", "SPEC", NULL);
return TCL_ERROR;
}
/* ++ Ttk_ReorderContent(mgr, fromIndex, toIndex) --
* Change content window order.
*/
-void Ttk_ReorderContent(Ttk_Manager *mgr, int fromIndex, int toIndex)
+void Ttk_ReorderContent(Ttk_Manager *mgr, Tcl_Size fromIndex, Tcl_Size toIndex)
{
Ttk_Content *moved = mgr->content[fromIndex];
@@ -540,7 +549,7 @@ int Ttk_Maintainable(Tcl_Interp *interp, Tk_Window window, Tk_Window container)
return 1;
badWindow:
- Tcl_SetObjResult(interp, Tcl_ObjPrintf("can't add %s as slave of %s",
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("can't add %s as content of %s",
Tk_PathName(window), Tk_PathName(container)));
Tcl_SetErrorCode(interp, "TTK", "GEOMETRY", "MAINTAINABLE", NULL);
return 0;
diff --git a/generic/ttk/ttkManager.h b/generic/ttk/ttkManager.h
index d487dea..78b9b0b 100644
--- a/generic/ttk/ttkManager.h
+++ b/generic/ttk/ttkManager.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, Joe English. Freely redistributable.
+ * Copyright © 2005 Joe English. Freely redistributable.
*
* Geometry manager utilities.
*/
@@ -16,57 +16,57 @@ typedef struct TtkManager_ Ttk_Manager;
*
* RequestedSize computes the requested size of the container window.
*
- * PlaceSlaves sets the position and size of all managed content windows
+ * PlaceContent sets the position and size of all managed content windows
* by calling Ttk_PlaceContent().
*
- * SlaveRemoved() is called immediately before a content window is removed.
+ * ContentRemoved() is called immediately before a content window is removed.
* NB: the associated content window may have been destroyed when this
* routine is called.
*
- * SlaveRequest() is called when a content window requests a size change.
+ * ContentRequest() is called when a content window requests a size change.
* It should return 1 if the request should propagate, 0 otherwise.
*/
typedef struct { /* Manager hooks */
Tk_GeomMgr tkGeomMgr; /* "real" Tk Geometry Manager */
int (*RequestedSize)(void *managerData, int *widthPtr, int *heightPtr);
- void (*PlaceSlaves)(void *managerData);
- int (*SlaveRequest)(void *managerData, int index, int w, int h);
- void (*SlaveRemoved)(void *managerData, int index);
+ void (*PlaceContent)(void *managerData);
+ int (*ContentRequest)(void *managerData, Tcl_Size index, int width, int height);
+ void (*ContentRemoved)(void *managerData, Tcl_Size index);
} Ttk_ManagerSpec;
/*
* Default implementations for Tk_GeomMgr hooks:
*/
-#define Ttk_LostContentProc Ttk_LostSlaveProc
-MODULE_SCOPE void Ttk_GeometryRequestProc(ClientData, Tk_Window window);
-MODULE_SCOPE void Ttk_LostContentProc(ClientData, Tk_Window window);
+#define Ttk_LostSlaveProc Ttk_LostContentProc
+MODULE_SCOPE void Ttk_GeometryRequestProc(void *, Tk_Window window);
+MODULE_SCOPE void Ttk_LostContentProc(void *, Tk_Window window);
/*
* Public API:
*/
MODULE_SCOPE Ttk_Manager *Ttk_CreateManager(
- Ttk_ManagerSpec *, void *managerData, Tk_Window window);
+ const Ttk_ManagerSpec *, void *managerData, Tk_Window window);
MODULE_SCOPE void Ttk_DeleteManager(Ttk_Manager *);
-#define Ttk_InsertContent Ttk_InsertSlave
+#define Ttk_InsertSlave Ttk_InsertContent
MODULE_SCOPE void Ttk_InsertContent(
- Ttk_Manager *, int position, Tk_Window, void *data);
+ Ttk_Manager *, Tcl_Size position, Tk_Window, void *clientData);
-#define Ttk_ForgetContent Ttk_ForgetSlave
-MODULE_SCOPE void Ttk_ForgetContent(Ttk_Manager *, int index);
+#define Ttk_ForgetSlave Ttk_ForgetContent
+MODULE_SCOPE void Ttk_ForgetContent(Ttk_Manager *, Tcl_Size index);
-#define Ttk_ReorderContent Ttk_ReorderSlave
-MODULE_SCOPE void Ttk_ReorderContent(Ttk_Manager *, int fromIndex, int toIndex);
+#define Ttk_ReorderSlave Ttk_ReorderContent
+MODULE_SCOPE void Ttk_ReorderContent(Ttk_Manager *, Tcl_Size fromIndex, Tcl_Size toIndex);
/* Rearrange content window positions */
-#define Ttk_PlaceContent Ttk_PlaceSlave
+#define Ttk_PlaceSlave Ttk_PlaceContent
MODULE_SCOPE void Ttk_PlaceContent(
- Ttk_Manager *, int index, int x, int y, int width, int height);
+ Ttk_Manager *, Tcl_Size index, int x, int y, int width, int height);
/* Position and map the content window */
-#define Ttk_UnmapContent Ttk_UnmapSlave
-MODULE_SCOPE void Ttk_UnmapContent(Ttk_Manager *, int index);
+#define Ttk_UnmapSlave Ttk_UnmapContent
+MODULE_SCOPE void Ttk_UnmapContent(Ttk_Manager *, Tcl_Size index);
/* Unmap the content window */
MODULE_SCOPE void Ttk_ManagerSizeChanged(Ttk_Manager *);
@@ -75,26 +75,26 @@ MODULE_SCOPE void Ttk_ManagerLayoutChanged(Ttk_Manager *);
/* Utilities:
*/
-#define Ttk_ContentIndex Ttk_SlaveIndex
-MODULE_SCOPE int Ttk_ContentIndex(Ttk_Manager *, Tk_Window);
- /* Returns: index in content array of specified window, -1 if not found */
+#define Ttk_SlaveIndex Ttk_ContentIndex
+MODULE_SCOPE Tcl_Size Ttk_ContentIndex(Ttk_Manager *, Tk_Window);
+ /* Returns: index in content array of specified window, TCL_INDEX_NONE if not found */
-#define Ttk_GetContentIndexFromObj Ttk_GetSlaveIndexFromObj
+#define Ttk_GetSlaveIndexFromObj Ttk_GetContentIndexFromObj
MODULE_SCOPE int Ttk_GetContentIndexFromObj(
- Tcl_Interp *, Ttk_Manager *, Tcl_Obj *, int *indexPtr);
+ Tcl_Interp *, Ttk_Manager *, Tcl_Obj *, int lastOK, Tcl_Size *indexPtr);
/* Accessor functions:
*/
-#define Ttk_NumberContent Ttk_NumberSlaves
-MODULE_SCOPE int Ttk_NumberContent(Ttk_Manager *);
+#define Ttk_NumberSlaves Ttk_NumberContent
+MODULE_SCOPE Tcl_Size Ttk_NumberContent(Ttk_Manager *);
/* Returns: number of managed content windows */
-#define Ttk_ContentData Ttk_SlaveData
-MODULE_SCOPE void *Ttk_ContentData(Ttk_Manager *, int index);
+#define Ttk_SlaveData Ttk_ContentData
+MODULE_SCOPE void *Ttk_ContentData(Ttk_Manager *, Tcl_Size index);
/* Returns: client data associated with content window */
-#define Ttk_ContentWindow Ttk_SlaveWindow
-MODULE_SCOPE Tk_Window Ttk_ContentWindow(Ttk_Manager *, int index);
+#define Ttk_SlaveWindow Ttk_ContentWindow
+MODULE_SCOPE Tk_Window Ttk_ContentWindow(Ttk_Manager *, Tcl_Size index);
/* Returns: content window */
MODULE_SCOPE int Ttk_Maintainable(Tcl_Interp *, Tk_Window content, Tk_Window container);
diff --git a/generic/ttk/ttkNotebook.c b/generic/ttk/ttkNotebook.c
index 949e023..966f727 100644
--- a/generic/ttk/ttkNotebook.c
+++ b/generic/ttk/ttkNotebook.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, Joe English
+ * Copyright © 2004 Joe English
*/
#include "tkInt.h"
@@ -16,9 +16,9 @@
#define DEFAULT_MIN_TAB_WIDTH 24
-static const char *const TabStateStrings[] = { "normal", "disabled", "hidden", 0 };
+static const char *const TabStateStrings[] = { "disabled", "hidden", "normal", 0 };
typedef enum {
- TAB_STATE_NORMAL, TAB_STATE_DISABLED, TAB_STATE_HIDDEN
+ TAB_STATE_DISABLED, TAB_STATE_HIDDEN, TAB_STATE_NORMAL
} TAB_STATE;
typedef struct
@@ -55,29 +55,29 @@ typedef struct
* PaneOptionSpecs includes additional options for child window placement
* and is used to configure the pane.
*/
-static Tk_OptionSpec TabOptionSpecs[] =
+static const Tk_OptionSpec TabOptionSpecs[] =
{
{TK_OPTION_STRING_TABLE, "-state", "", "",
- "normal", -1, Tk_Offset(Tab,state),
+ "normal", TCL_INDEX_NONE, offsetof(Tab,state),
TK_OPTION_ENUM_VAR, TabStateStrings, 0 },
{TK_OPTION_STRING, "-text", "text", "Text", "",
- Tk_Offset(Tab,textObj), -1, 0, 0, GEOMETRY_CHANGED },
+ offsetof(Tab,textObj), TCL_INDEX_NONE, 0, 0, GEOMETRY_CHANGED },
{TK_OPTION_STRING, "-image", "image", "Image", NULL/*default*/,
- Tk_Offset(Tab,imageObj), -1, TK_OPTION_NULL_OK, 0, GEOMETRY_CHANGED },
+ offsetof(Tab,imageObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, GEOMETRY_CHANGED },
{TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound",
- NULL, Tk_Offset(Tab,compoundObj), -1,
+ NULL, offsetof(Tab,compoundObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, ttkCompoundStrings, GEOMETRY_CHANGED },
- {TK_OPTION_INT, "-underline", "underline", "Underline", "-1",
- Tk_Offset(Tab,underlineObj), -1, 0, 0, GEOMETRY_CHANGED },
+ {TK_OPTION_INDEX, "-underline", "underline", "Underline",
+ TTK_OPTION_UNDERLINE_DEF(Tab, underlineObj), GEOMETRY_CHANGED},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0 }
};
-static Tk_OptionSpec PaneOptionSpecs[] =
+static const Tk_OptionSpec PaneOptionSpecs[] =
{
{TK_OPTION_STRING, "-padding", "padding", "Padding", "0",
- Tk_Offset(Tab,paddingObj), -1, 0, 0,GEOMETRY_CHANGED },
+ offsetof(Tab,paddingObj), TCL_INDEX_NONE, 0, 0, GEOMETRY_CHANGED },
{TK_OPTION_STRING, "-sticky", "sticky", "Sticky", "nsew",
- Tk_Offset(Tab,stickyObj), -1, 0, 0,GEOMETRY_CHANGED },
+ offsetof(Tab,stickyObj), TCL_INDEX_NONE, 0, 0, GEOMETRY_CHANGED },
WIDGET_INHERIT_OPTIONS(TabOptionSpecs)
};
@@ -94,11 +94,11 @@ typedef struct
Ttk_Manager *mgr; /* Geometry manager */
Tk_OptionTable tabOptionTable; /* Tab options */
Tk_OptionTable paneOptionTable; /* Tab+pane options */
- int currentIndex; /* index of currently selected tab */
- int activeIndex; /* index of currently active tab */
+ Tcl_Size currentIndex; /* index of currently selected tab */
+ Tcl_Size activeIndex; /* index of currently active tab */
Ttk_Layout tabLayout; /* Sublayout for tabs */
- Ttk_Box clientArea; /* Where to pack content widgets */
+ Ttk_Box clientArea; /* Where to pack content windows */
} NotebookPart;
typedef struct
@@ -107,16 +107,16 @@ typedef struct
NotebookPart notebook;
} Notebook;
-static Tk_OptionSpec NotebookOptionSpecs[] =
+static const Tk_OptionSpec NotebookOptionSpecs[] =
{
{TK_OPTION_PIXELS, "-width", "width", "Width", "0",
- Tk_Offset(Notebook,notebook.widthObj),-1,
+ offsetof(Notebook,notebook.widthObj),TCL_INDEX_NONE,
0,0,GEOMETRY_CHANGED },
{TK_OPTION_PIXELS, "-height", "height", "Height", "0",
- Tk_Offset(Notebook,notebook.heightObj),-1,
+ offsetof(Notebook,notebook.heightObj),TCL_INDEX_NONE,
0,0,GEOMETRY_CHANGED },
{TK_OPTION_STRING, "-padding", "padding", "Padding", NULL,
- Tk_Offset(Notebook,notebook.paddingObj),-1,
+ offsetof(Notebook,notebook.paddingObj),TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
WIDGET_TAKEFOCUS_TRUE,
@@ -202,7 +202,7 @@ static Tab *CreateTab(Tcl_Interp *interp, Notebook *nb, Tk_Window window)
Tab *record = (Tab *)ckalloc(sizeof(Tab));
memset(record, 0, sizeof(Tab));
- if (Tk_InitOptions(interp, (char *)record, optionTable, window) != TCL_OK) {
+ if (Tk_InitOptions(interp, record, optionTable, window) != TCL_OK) {
ckfree(record);
return NULL;
}
@@ -219,14 +219,14 @@ static void DestroyTab(Notebook *nb, Tab *tab)
static int ConfigureTab(
Tcl_Interp *interp, Notebook *nb, Tab *tab, Tk_Window window,
- int objc, Tcl_Obj *const objv[])
+ Tcl_Size objc, Tcl_Obj *const objv[])
{
Ttk_Sticky sticky = tab->sticky;
Ttk_Padding padding = tab->padding;
Tk_SavedOptions savedOptions;
int mask = 0;
- if (Tk_SetOptions(interp, (void *)tab, nb->notebook.paneOptionTable,
+ if (Tk_SetOptions(interp, tab, nb->notebook.paneOptionTable,
objc, objv, window, &savedOptions, &mask) != TCL_OK)
{
return TCL_ERROR;
@@ -263,9 +263,9 @@ error:
* Return the index of the tab at point x,y,
* or -1 if no tab at that point.
*/
-static int IdentifyTab(Notebook *nb, int x, int y)
+static Tcl_Size IdentifyTab(Notebook *nb, int x, int y)
{
- int index;
+ Tcl_Size index;
for (index = 0; index < Ttk_NumberContent(nb->notebook.mgr); ++index) {
Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr,index);
if ( tab->state != TAB_STATE_HIDDEN
@@ -274,14 +274,14 @@ static int IdentifyTab(Notebook *nb, int x, int y)
return index;
}
}
- return -1;
+ return TCL_INDEX_NONE;
}
/*
* ActivateTab --
* Set the active tab index, redisplay if necessary.
*/
-static void ActivateTab(Notebook *nb, int index)
+static void ActivateTab(Notebook *nb, Tcl_Size index)
{
if (index != nb->notebook.activeIndex) {
nb->notebook.activeIndex = index;
@@ -296,11 +296,11 @@ static void ActivateTab(Notebook *nb, int index)
* The USER1 bit is set for the leftmost visible tab, and USER2
* is set for the rightmost visible tab.
*/
-static Ttk_State TabState(Notebook *nb, int index)
+static Ttk_State TabState(Notebook *nb, Tcl_Size index)
{
Ttk_State state = nb->core.state;
Tab *itab = (Tab *)Ttk_ContentData(nb->notebook.mgr, index);
- int i = 0;
+ Tcl_Size i = 0;
if (index == nb->notebook.currentIndex) {
state |= TTK_STATE_SELECTED;
@@ -317,17 +317,17 @@ static Ttk_State TabState(Notebook *nb, int index)
continue;
}
if (index == i) {
- state |= TTK_STATE_USER1;
+ state |= TTK_STATE_FIRST;
}
break;
}
- for (i = Ttk_NumberContent(nb->notebook.mgr) - 1; i != -1; --i) {
+ for (i = Ttk_NumberContent(nb->notebook.mgr) - 1; i >= 0; --i) {
Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, i);
if (tab->state == TAB_STATE_HIDDEN) {
continue;
}
if (index == i) {
- state |= TTK_STATE_USER2;
+ state |= TTK_STATE_LAST;
}
break;
}
@@ -360,7 +360,7 @@ static void TabrowSize(
{
Ttk_Layout tabLayout = nb->notebook.tabLayout;
int tabrowWidth = 0, tabrowHeight = 0;
- int i;
+ Tcl_Size i;
for (i = 0; i < Ttk_NumberContent(nb->notebook.mgr); ++i) {
Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, i);
@@ -368,7 +368,7 @@ static void TabrowSize(
Ttk_RebindSublayout(tabLayout, tab);
Ttk_LayoutSize(tabLayout,tabState,&tab->width,&tab->height);
- tab->width = MAX(tab->width, minTabWidth);
+ tab->width = MAX(tab->width, minTabWidth);
if (orient == TTK_ORIENT_HORIZONTAL) {
tabrowHeight = MAX(tabrowHeight, tab->height);
@@ -401,7 +401,7 @@ static int NotebookSize(void *clientData, int *widthPtr, int *heightPtr)
int clientWidth = 0, clientHeight = 0,
reqWidth = 0, reqHeight = 0,
tabrowWidth = 0, tabrowHeight = 0;
- int i;
+ Tcl_Size i;
NotebookStyleOptions(nb, &nbstyle, nbwin);
@@ -421,8 +421,8 @@ static int NotebookSize(void *clientData, int *widthPtr, int *heightPtr)
/* Client width/height overridable by widget options:
*/
- Tk_GetPixelsFromObj(NULL, nb->core.tkwin, nb->notebook.widthObj, &reqWidth);
- Tk_GetPixelsFromObj(NULL, nb->core.tkwin, nb->notebook.heightObj, &reqHeight);
+ Tk_GetPixelsFromObj(NULL, nbwin, nb->notebook.widthObj, &reqWidth);
+ Tk_GetPixelsFromObj(NULL, nbwin, nb->notebook.heightObj, &reqHeight);
if (reqWidth > 0)
clientWidth = reqWidth;
if (reqHeight > 0)
@@ -524,7 +524,7 @@ static void PlaceTabs(
* Set the position and size of a child widget
* based on the current client area and content window options:
*/
-static void NotebookPlaceContent(Notebook* nb, int index)
+static void NotebookPlaceContent(Notebook* nb, Tcl_Size index)
{
Tab* tab = (Tab*)Ttk_ContentData(nb->notebook.mgr, index);
Tk_Window window = Ttk_ContentWindow(nb->notebook.mgr, index);
@@ -551,7 +551,7 @@ static void NotebookDoLayout(void *recordPtr)
Ttk_Element clientNode = Ttk_FindElement(nb->core.layout, "client");
Ttk_Box tabrowBox;
NotebookStyle nbstyle;
- int currentIndex = nb->notebook.currentIndex;
+ Tcl_Size currentIndex = nb->notebook.currentIndex;
NotebookStyleOptions(nb, &nbstyle, nbwin);
@@ -605,7 +605,7 @@ static void NotebookDoLayout(void *recordPtr)
static void NotebookPlaceContents(void *recordPtr)
{
Notebook *nb = (Notebook *)recordPtr;
- int currentIndex = nb->notebook.currentIndex;
+ Tcl_Size currentIndex = nb->notebook.currentIndex;
if (currentIndex >= 0) {
NotebookDoLayout(nb);
NotebookPlaceContent(nb, currentIndex);
@@ -616,10 +616,10 @@ static void NotebookPlaceContents(void *recordPtr)
* SelectTab(nb, index) --
* Change the currently-selected tab.
*/
-static void SelectTab(Notebook *nb, int index)
+static void SelectTab(Notebook *nb, Tcl_Size index)
{
Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, index);
- int currentIndex = nb->notebook.currentIndex;
+ Tcl_Size currentIndex = nb->notebook.currentIndex;
if (index == currentIndex) {
return;
@@ -647,7 +647,7 @@ static void SelectTab(Notebook *nb, int index)
NotebookPlaceContent(nb, index);
TtkRedisplayWidget(&nb->core);
- TtkSendVirtualEvent(nb->core.tkwin, "NotebookTabChanged");
+ Tk_SendVirtualEvent(nb->core.tkwin, "NotebookTabChanged", NULL);
}
/* NextTab --
@@ -657,8 +657,8 @@ static void SelectTab(Notebook *nb, int index)
*/
static int NextTab(Notebook *nb, int index)
{
- int nTabs = Ttk_NumberContent(nb->notebook.mgr);
- int nextIndex;
+ Tcl_Size nTabs = Ttk_NumberContent(nb->notebook.mgr);
+ Tcl_Size nextIndex;
/* Scan forward for following usable tab:
*/
@@ -692,14 +692,14 @@ static int NextTab(Notebook *nb, int index)
*/
static void SelectNearestTab(Notebook *nb)
{
- int currentIndex = nb->notebook.currentIndex;
- int nextIndex = NextTab(nb, currentIndex);
+ Tcl_Size currentIndex = nb->notebook.currentIndex;
+ Tcl_Size nextIndex = NextTab(nb, currentIndex);
if (currentIndex >= 0) {
Ttk_UnmapContent(nb->notebook.mgr, currentIndex);
}
if (currentIndex != nextIndex) {
- TtkSendVirtualEvent(nb->core.tkwin, "NotebookTabChanged");
+ Tk_SendVirtualEvent(nb->core.tkwin, "NotebookTabChanged", NULL);
}
nb->notebook.currentIndex = nextIndex;
@@ -711,7 +711,7 @@ static void SelectNearestTab(Notebook *nb)
* Select the next tab if the current one is being removed.
* Adjust currentIndex to account for removed content window.
*/
-static void TabRemoved(void *managerData, int index)
+static void TabRemoved(void *managerData, Tcl_Size index)
{
Notebook *nb = (Notebook *)managerData;
Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, index);
@@ -731,7 +731,7 @@ static void TabRemoved(void *managerData, int index)
static int TabRequest(
TCL_UNUSED(void *), /* managerData */
- TCL_UNUSED(int), /* index */
+ TCL_UNUSED(Tcl_Size), /* index */
TCL_UNUSED(int), /* width */
TCL_UNUSED(int)) /* height */
{
@@ -743,8 +743,8 @@ static int TabRequest(
*/
static int AddTab(
Tcl_Interp *interp, Notebook *nb,
- int destIndex, Tk_Window window,
- int objc, Tcl_Obj *const objv[])
+ Tcl_Size destIndex, Tk_Window window,
+ Tcl_Size objc, Tcl_Obj *const objv[])
{
Tab *tab;
if (!Ttk_Maintainable(interp, window, nb->core.tkwin)) {
@@ -776,14 +776,14 @@ static int AddTab(
*/
if (nb->notebook.currentIndex < 0) {
SelectTab(nb, destIndex);
- } else if (nb->notebook.currentIndex >= destIndex) {
+ } else if (nb->notebook.currentIndex >= destIndex) {
++nb->notebook.currentIndex;
}
return TCL_OK;
}
-static Ttk_ManagerSpec NotebookManagerSpec = {
+static const Ttk_ManagerSpec NotebookManagerSpec = {
{ "notebook", Ttk_GeometryRequestProc, Ttk_LostContentProc },
NotebookSize,
NotebookPlaceContents,
@@ -811,7 +811,7 @@ static void NotebookEventHandler(void *clientData, XEvent *eventPtr)
Tk_DeleteEventHandler(nb->core.tkwin,
NotebookEventMask, NotebookEventHandler, clientData);
} else if (eventPtr->type == MotionNotify) {
- int index = IdentifyTab(nb, eventPtr->xmotion.x, eventPtr->xmotion.y);
+ Tcl_Size index = IdentifyTab(nb, eventPtr->xmotion.x, eventPtr->xmotion.y);
ActivateTab(nb, index);
} else if (eventPtr->type == LeaveNotify) {
ActivateTab(nb, -1);
@@ -839,12 +839,12 @@ static void NotebookEventHandler(void *clientData, XEvent *eventPtr)
* See also: GetTabIndex.
*/
static int FindTabIndex(
- Tcl_Interp *interp, Notebook *nb, Tcl_Obj *objPtr, int *index_rtn)
+ Tcl_Interp *interp, Notebook *nb, Tcl_Obj *objPtr, Tcl_Size *index_rtn)
{
const char *string = Tcl_GetString(objPtr);
int x, y;
- *index_rtn = -1;
+ *index_rtn = TCL_INDEX_NONE;
/* Check for @x,y ...
*/
@@ -863,10 +863,16 @@ static int FindTabIndex(
/* ... or integer index or content window name:
*/
if (Ttk_GetContentIndexFromObj(
- interp, nb->notebook.mgr, objPtr, index_rtn) == TCL_OK)
+ interp, nb->notebook.mgr, objPtr, 1, index_rtn) == TCL_OK)
{
return TCL_OK;
}
+ if (*index_rtn == Ttk_NumberContent(nb->notebook.mgr)) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "Invalid tab specification %s", string));
+ Tcl_SetErrorCode(interp, "TTK", "NOTEBOOK", "SPEC", NULL);
+ return TCL_ERROR;
+ }
/* Nothing matched; Ttk_GetContentIndexFromObj will have left error message.
*/
@@ -879,13 +885,19 @@ static int FindTabIndex(
* Returns TCL_ERROR if the tab does not exist.
*/
static int GetTabIndex(
- Tcl_Interp *interp, Notebook *nb, Tcl_Obj *objPtr, int *index_rtn)
+ Tcl_Interp *interp, Notebook *nb, Tcl_Obj *objPtr, Tcl_Size *index_rtn)
{
int status = FindTabIndex(interp, nb, objPtr, index_rtn);
+ if (status == TCL_OK && *index_rtn >= Ttk_NumberContent(nb->notebook.mgr)) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "Tab index \"%s\" out of bounds", Tcl_GetString(objPtr)));
+ Tcl_SetErrorCode(interp, "TTK", "NOTEBOOK", "INDEX", NULL);
+ return TCL_ERROR;
+ }
if (status == TCL_OK && *index_rtn < 0) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "tab '%s' not found", Tcl_GetString(objPtr)));
+ "Tab '%s' not found", Tcl_GetString(objPtr)));
Tcl_SetErrorCode(interp, "TTK", "NOTEBOOK", "TAB", NULL);
status = TCL_ERROR;
}
@@ -899,11 +911,11 @@ static int GetTabIndex(
/* $nb add window ?options ... ?
*/
static int NotebookAddCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Notebook *nb = (Notebook *)recordPtr;
Tk_Window window;
- int index;
+ Tcl_Size index;
Tab *tab;
if (objc <= 2 || objc % 2 != 1) {
@@ -938,22 +950,15 @@ static int NotebookAddCommand(
* Insert new tab, or move existing one.
*/
static int NotebookInsertCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Notebook *nb = (Notebook *)recordPtr;
- int current = nb->notebook.currentIndex;
- int nContent = Ttk_NumberContent(nb->notebook.mgr);
- int srcIndex, destIndex;
+ Tcl_Size current = nb->notebook.currentIndex;
+ Tcl_Size nContent = Ttk_NumberContent(nb->notebook.mgr);
+ Tcl_Size srcIndex, destIndex;
if (objc < 4) {
- Tcl_WrongNumArgs(interp, 2,objv, "index slave ?-option value ...?");
- return TCL_ERROR;
- }
-
- if (!strcmp(Tcl_GetString(objv[2]), "end")) {
- destIndex = Ttk_NumberContent(nb->notebook.mgr);
- } else if (TCL_OK != Ttk_GetContentIndexFromObj(
- interp, nb->notebook.mgr, objv[2], &destIndex)) {
+ Tcl_WrongNumArgs(interp, 2,objv, "index window ?-option value ...?");
return TCL_ERROR;
}
@@ -969,12 +974,23 @@ static int NotebookInsertCommand(
srcIndex = Ttk_ContentIndex(nb->notebook.mgr, window);
if (srcIndex < 0) { /* New content window */
+ if (TCL_OK != Ttk_GetContentIndexFromObj(
+ interp, nb->notebook.mgr, objv[2], 1, &destIndex)) {
+ return TCL_ERROR;
+ }
return AddTab(interp, nb, destIndex, window, objc-4,objv+4);
}
} else if (Ttk_GetContentIndexFromObj(
- interp, nb->notebook.mgr, objv[3], &srcIndex) != TCL_OK)
+ interp, nb->notebook.mgr, objv[3], 0, &srcIndex) != TCL_OK)
{
return TCL_ERROR;
+ } else if (srcIndex >= Ttk_NumberContent(nb->notebook.mgr)) {
+ srcIndex = Ttk_NumberContent(nb->notebook.mgr) - 1;
+ }
+
+ if (TCL_OK != Ttk_GetContentIndexFromObj(
+ interp, nb->notebook.mgr, objv[2], 0, &destIndex)) {
+ return TCL_ERROR;
}
/* Move existing content window:
@@ -987,14 +1003,14 @@ static int NotebookInsertCommand(
return TCL_ERROR;
}
- if (destIndex >= nContent) {
+ if (destIndex >= nContent) {
destIndex = nContent - 1;
}
Ttk_ReorderContent(nb->notebook.mgr, srcIndex, destIndex);
/* Adjust internal indexes:
*/
- nb->notebook.activeIndex = -1;
+ nb->notebook.activeIndex = TCL_INDEX_NONE;
if (current == srcIndex) {
nb->notebook.currentIndex = destIndex;
} else if (destIndex <= current && current < srcIndex) {
@@ -1012,10 +1028,10 @@ static int NotebookInsertCommand(
* Removes the specified tab.
*/
static int NotebookForgetCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Notebook *nb = (Notebook *)recordPtr;
- int index;
+ Tcl_Size index;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "tab");
@@ -1036,10 +1052,10 @@ static int NotebookForgetCommand(
* Hides the specified tab.
*/
static int NotebookHideCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Notebook *nb = (Notebook *)recordPtr;
- int index;
+ Tcl_Size index;
Tab *tab;
if (objc != 3) {
@@ -1056,7 +1072,7 @@ static int NotebookHideCommand(
if (index == nb->notebook.currentIndex) {
SelectNearestTab(nb);
} else {
- TtkRedisplayWidget(&nb->core);
+ TtkRedisplayWidget(&nb->core);
}
return TCL_OK;
@@ -1066,7 +1082,7 @@ static int NotebookHideCommand(
* Returns name of tab element at $x,$y; empty string if none.
*/
static int NotebookIdentifyCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
static const char *const whatTable[] = { "element", "tab", NULL };
enum { IDENTIFY_ELEMENT, IDENTIFY_TAB };
@@ -1074,7 +1090,7 @@ static int NotebookIdentifyCommand(
Notebook *nb = (Notebook *)recordPtr;
Ttk_Element element = NULL;
int x, y;
- int tabIndex;
+ Tcl_Size tabIndex;
if (objc < 4 || objc > 5) {
Tcl_WrongNumArgs(interp, 2,objv, "?what? x y");
@@ -1110,9 +1126,10 @@ static int NotebookIdentifyCommand(
}
break;
case IDENTIFY_TAB:
- if (tabIndex >= 0) {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(tabIndex));
- }
+#if !defined TK_NO_DEPRECATED && (TCL_MAJOR_VERSION < 9)
+ if (tabIndex >= 0)
+#endif
+ Tcl_SetObjResult(interp, TkNewIndexObj(tabIndex));
break;
}
return TCL_OK;
@@ -1124,10 +1141,10 @@ static int NotebookIdentifyCommand(
* See above for valid item formats.
*/
static int NotebookIndexCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Notebook *nb = (Notebook *)recordPtr;
- int index;
+ Tcl_Size index;
int status;
if (objc != 3) {
@@ -1135,18 +1152,12 @@ static int NotebookIndexCommand(
return TCL_ERROR;
}
- /*
- * Special-case for "end":
- */
- if (!strcmp("end", Tcl_GetString(objv[2]))) {
- int nContent = Ttk_NumberContent(nb->notebook.mgr);
- Tcl_SetObjResult(interp, Tcl_NewIntObj(nContent));
- return TCL_OK;
- }
-
status = FindTabIndex(interp, nb, objv[2], &index);
- if (status == TCL_OK && index >= 0) {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(index));
+ if (status == TCL_OK) {
+#if !defined(TK_NO_DEPRECATED) && (TCL_MAJOR_VERSION < 9)
+ if (index >= 0)
+#endif
+ Tcl_SetObjResult(interp, TkNewIndexObj(index));
}
return status;
@@ -1157,7 +1168,7 @@ static int NotebookIndexCommand(
* the currently-selected pane.
*/
static int NotebookSelectCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Notebook *nb = (Notebook *)recordPtr;
@@ -1169,7 +1180,7 @@ static int NotebookSelectCommand(
}
return TCL_OK;
} else if (objc == 3) {
- int index;
+ Tcl_Size index;
int status = GetTabIndex(interp, nb, objv[2], &index);
if (status == TCL_OK) {
SelectTab(nb, index);
@@ -1184,12 +1195,12 @@ static int NotebookSelectCommand(
* Return list of tabs.
*/
static int NotebookTabsCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Notebook *nb = (Notebook *)recordPtr;
Ttk_Manager *mgr = nb->notebook.mgr;
Tcl_Obj *result;
- int i;
+ Tcl_Size i;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 2, objv, "");
@@ -1209,11 +1220,11 @@ static int NotebookTabsCommand(
/* $nb tab $tab ?-option ?value -option value...??
*/
static int NotebookTabCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Notebook *nb = (Notebook *)recordPtr;
Ttk_Manager *mgr = nb->notebook.mgr;
- int index;
+ Tcl_Size index;
Tk_Window window;
Tab *tab;
@@ -1255,8 +1266,8 @@ static int NotebookTabCommand(
*/
static const Ttk_Ensemble NotebookCommands[] = {
{ "add", NotebookAddCommand,0 },
- { "configure", TtkWidgetConfigureCommand,0 },
{ "cget", TtkWidgetCgetCommand,0 },
+ { "configure", TtkWidgetConfigureCommand,0 },
{ "forget", NotebookForgetCommand,0 },
{ "hide", NotebookHideCommand,0 },
{ "identify", NotebookIdentifyCommand,0 },
@@ -1265,6 +1276,7 @@ static const Ttk_Ensemble NotebookCommands[] = {
{ "instate", TtkWidgetInstateCommand,0 },
{ "select", NotebookSelectCommand,0 },
{ "state", TtkWidgetStateCommand,0 },
+ { "style", TtkWidgetStyleCommand,0 },
{ "tab", NotebookTabCommand,0 },
{ "tabs", NotebookTabsCommand,0 },
{ 0,0,0 }
@@ -1284,8 +1296,8 @@ static void NotebookInitialize(Tcl_Interp *interp, void *recordPtr)
nb->notebook.tabOptionTable = Tk_CreateOptionTable(interp,TabOptionSpecs);
nb->notebook.paneOptionTable = Tk_CreateOptionTable(interp,PaneOptionSpecs);
- nb->notebook.currentIndex = -1;
- nb->notebook.activeIndex = -1;
+ nb->notebook.currentIndex = TCL_INDEX_NONE;
+ nb->notebook.activeIndex = TCL_INDEX_NONE;
nb->notebook.tabLayout = 0;
nb->notebook.clientArea = Ttk_MakeBox(0,0,1,1);
@@ -1370,8 +1382,8 @@ static void DisplayTab(Notebook *nb, int index, Drawable d)
static void NotebookDisplay(void *clientData, Drawable d)
{
Notebook *nb = (Notebook *)clientData;
- int nContent = Ttk_NumberContent(nb->notebook.mgr);
- int index;
+ Tcl_Size nContent = Ttk_NumberContent(nb->notebook.mgr);
+ Tcl_Size index;
/* Draw notebook background (base layout):
*/
@@ -1394,7 +1406,7 @@ static void NotebookDisplay(void *clientData, Drawable d)
* +++ Widget specification and layout definitions.
*/
-static WidgetSpec NotebookWidgetSpec =
+static const WidgetSpec NotebookWidgetSpec =
{
"TNotebook", /* className */
sizeof(Notebook), /* recordSize */
diff --git a/generic/ttk/ttkPanedwindow.c b/generic/ttk/ttkPanedwindow.c
index f3ac1dc..5a97ca8 100644
--- a/generic/ttk/ttkPanedwindow.c
+++ b/generic/ttk/ttkPanedwindow.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, Joe English. Freely redistributable.
+ * Copyright © 2005 Joe English. Freely redistributable.
*
* ttk::panedwindow widget implementation.
*
@@ -74,15 +74,15 @@ typedef struct {
/* @@@ NOTE: -orient is readonly 'cause dynamic oriention changes NYI
*/
-static Tk_OptionSpec PanedOptionSpecs[] = {
+static const Tk_OptionSpec PanedOptionSpecs[] = {
{TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "vertical",
- Tk_Offset(Paned,paned.orientObj), Tk_Offset(Paned,paned.orient),
+ offsetof(Paned,paned.orientObj), offsetof(Paned,paned.orient),
0, ttkOrientStrings, READONLY_OPTION|STYLE_CHANGED },
{TK_OPTION_INT, "-width", "width", "Width", "0",
- -1,Tk_Offset(Paned,paned.width),
+ TCL_INDEX_NONE, offsetof(Paned, paned.width),
0, 0, GEOMETRY_CHANGED },
{TK_OPTION_INT, "-height", "height", "Height", "0",
- -1,Tk_Offset(Paned,paned.height),
+ TCL_INDEX_NONE, offsetof(Paned, paned.height),
0, 0, GEOMETRY_CHANGED },
WIDGET_TAKEFOCUS_FALSE,
@@ -98,10 +98,10 @@ typedef struct {
int weight; /* Pane -weight, for resizing */
} Pane;
-static Tk_OptionSpec PaneOptionSpecs[] = {
+static const Tk_OptionSpec PaneOptionSpecs[] = {
{TK_OPTION_INT, "-weight", "weight", "Weight", "0",
- -1,Tk_Offset(Pane,weight), 0,0,GEOMETRY_CHANGED },
- {TK_OPTION_END, 0,0,0, NULL, -1,-1, 0,0,0}
+ TCL_INDEX_NONE, offsetof(Pane,weight), 0,0,GEOMETRY_CHANGED },
+ {TK_OPTION_END, 0,0,0, NULL, TCL_INDEX_NONE,TCL_INDEX_NONE, 0,0,0}
};
/* CreatePane --
@@ -141,13 +141,13 @@ static void DestroyPane(Paned *pw, Pane *pane)
*/
static int ConfigurePane(
Tcl_Interp *interp, Paned *pw, Pane *pane, Tk_Window window,
- int objc, Tcl_Obj *const objv[])
+ Tcl_Size objc, Tcl_Obj *const objv[])
{
Ttk_Manager *mgr = pw->paned.mgr;
Tk_SavedOptions savedOptions;
int mask = 0;
- if (Tk_SetOptions(interp, (void*)pane, pw->paned.paneOptionTable,
+ if (Tk_SetOptions(interp, pane, pw->paned.paneOptionTable,
objc, objv, window, &savedOptions, &mask) != TCL_OK)
{
return TCL_ERROR;
@@ -206,7 +206,7 @@ static int ShoveUp(Paned *pw, int i, int pos)
* Same as ShoveUp, but going in the opposite direction
* and stopping at the sentinel sash.
*/
-static int ShoveDown(Paned *pw, int i, int pos)
+static int ShoveDown(Paned *pw, Tcl_Size i, int pos)
{
Pane *pane = (Pane *)Ttk_ContentData(pw->paned.mgr,i);
int sashThickness = pw->paned.sashThickness;
@@ -275,7 +275,7 @@ static void AdjustPanes(Paned *pw)
{
int sashThickness = pw->paned.sashThickness;
int pos = 0;
- int index;
+ Tcl_Size index;
for (index = 0; index < Ttk_NumberContent(pw->paned.mgr); ++index) {
Pane *pane = (Pane *)Ttk_ContentData(pw->paned.mgr, index);
@@ -372,7 +372,7 @@ static void PlacePanes(Paned *pw)
int width = Tk_Width(pw->core.tkwin), height = Tk_Height(pw->core.tkwin);
int sashThickness = pw->paned.sashThickness;
int pos = 0;
- int index;
+ Tcl_Size index;
for (index = 0; index < Ttk_NumberContent(pw->paned.mgr); ++index) {
Pane *pane = (Pane *)Ttk_ContentData(pw->paned.mgr, index);
@@ -403,7 +403,7 @@ static void PanedPlaceContent(void *managerData)
PlacePanes(pw);
}
-static void PaneRemoved(void *managerData, int index)
+static void PaneRemoved(void *managerData, Tcl_Size index)
{
Paned *pw = (Paned *)managerData;
Pane *pane = (Pane *)Ttk_ContentData(pw->paned.mgr, index);
@@ -413,7 +413,7 @@ static void PaneRemoved(void *managerData, int index)
static int AddPane(
Tcl_Interp *interp, Paned *pw,
int destIndex, Tk_Window window,
- int objc, Tcl_Obj *const objv[])
+ Tcl_Size objc, Tcl_Obj *const objv[])
{
Pane *pane;
if (!Ttk_Maintainable(interp, window, pw->core.tkwin)) {
@@ -445,7 +445,7 @@ static int AddPane(
* in order to avoid unexpected pane resizes (esp. while the
* user is dragging a sash [#1325286]).
*/
-static int PaneRequest(void *managerData, int index, int width, int height)
+static int PaneRequest(void *managerData, Tcl_Size index, int width, int height)
{
Paned *pw = (Paned *)managerData;
Pane *pane = (Pane *)Ttk_ContentData(pw->paned.mgr, index);
@@ -458,7 +458,7 @@ static int PaneRequest(void *managerData, int index, int width, int height)
return 1;
}
-static Ttk_ManagerSpec PanedManagerSpec = {
+static const Ttk_ManagerSpec PanedManagerSpec = {
{ "panedwindow", Ttk_GeometryRequestProc, Ttk_LostContentProc },
PanedSize,
PanedPlaceContent,
@@ -482,13 +482,13 @@ static Ttk_ManagerSpec PanedManagerSpec = {
*/
static const unsigned PanedEventMask = LeaveWindowMask;
-static void PanedEventProc(ClientData clientData, XEvent *eventPtr)
+static void PanedEventProc(void *clientData, XEvent *eventPtr)
{
WidgetCore *corePtr = (WidgetCore *)clientData;
if ( eventPtr->type == LeaveNotify
&& eventPtr->xcrossing.detail == NotifyInferior)
{
- TtkSendVirtualEvent(corePtr->tkwin, "EnteredChild");
+ Tk_SendVirtualEvent(corePtr->tkwin, "EnteredChild", NULL);
}
}
@@ -608,11 +608,11 @@ static void DrawSash(Paned *pw, int index, Drawable d)
static void PanedDisplay(void *recordPtr, Drawable d)
{
Paned *pw = (Paned *)recordPtr;
- int i, nSashes = Ttk_NumberContent(pw->paned.mgr) - 1;
+ Tcl_Size i, nContent = Ttk_NumberContent(pw->paned.mgr);
TtkWidgetDisplay(recordPtr, d);
- for (i = 0; i < nSashes; ++i) {
- DrawSash(pw, i, d);
+ for (i = 1; i < nContent; ++i) {
+ DrawSash(pw, i - 1, d);
}
}
@@ -623,7 +623,7 @@ static void PanedDisplay(void *recordPtr, Drawable d)
/* $pw add window [ options ... ]
*/
static int PanedAddCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Paned *pw = (Paned *)recordPtr;
Tk_Window window;
@@ -648,15 +648,15 @@ static int PanedAddCommand(
* Insert new content window, or move existing one.
*/
static int PanedInsertCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Paned *pw = (Paned *)recordPtr;
- int nContent = Ttk_NumberContent(pw->paned.mgr);
- int srcIndex, destIndex;
+ Tcl_Size nContent = Ttk_NumberContent(pw->paned.mgr);
+ Tcl_Size srcIndex, destIndex;
Tk_Window window;
if (objc < 4) {
- Tcl_WrongNumArgs(interp, 2,objv, "index slave ?-option value ...?");
+ Tcl_WrongNumArgs(interp, 2,objv, "index window ?-option value ...?");
return TCL_ERROR;
}
@@ -666,10 +666,8 @@ static int PanedInsertCommand(
return TCL_ERROR;
}
- if (!strcmp(Tcl_GetString(objv[2]), "end")) {
- destIndex = Ttk_NumberContent(pw->paned.mgr);
- } else if (TCL_OK != Ttk_GetContentIndexFromObj(
- interp,pw->paned.mgr, objv[2], &destIndex))
+ if (TCL_OK != Ttk_GetContentIndexFromObj(
+ interp,pw->paned.mgr, objv[2], 1, &destIndex))
{
return TCL_ERROR;
}
@@ -693,10 +691,10 @@ static int PanedInsertCommand(
/* $pw forget $pane
*/
static int PanedForgetCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Paned *pw = (Paned *)recordPtr;
- int paneIndex;
+ Tcl_Size paneIndex;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2,objv, "pane");
@@ -704,9 +702,11 @@ static int PanedForgetCommand(
}
if (TCL_OK != Ttk_GetContentIndexFromObj(
- interp, pw->paned.mgr, objv[2], &paneIndex))
+ interp, pw->paned.mgr, objv[2], 0, &paneIndex))
{
return TCL_ERROR;
+ } else if (paneIndex >= Ttk_NumberContent(pw->paned.mgr)) {
+ paneIndex = Ttk_NumberContent(pw->paned.mgr) - 1;
}
Ttk_ForgetContent(pw->paned.mgr, paneIndex);
@@ -717,7 +717,7 @@ static int PanedForgetCommand(
* Return index of sash at $x,$y
*/
static int PanedIdentifyCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
static const char *const whatTable[] = { "element", "sash", NULL };
enum { IDENTIFY_ELEMENT, IDENTIFY_SASH };
@@ -747,7 +747,7 @@ static int PanedIdentifyCommand(
/* Found it. */
switch (what) {
case IDENTIFY_SASH:
- Tcl_SetObjResult(interp, Tcl_NewIntObj(index));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(index));
return TCL_OK;
case IDENTIFY_ELEMENT:
{
@@ -770,10 +770,10 @@ static int PanedIdentifyCommand(
* Query/modify pane options.
*/
static int PanedPaneCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Paned *pw = (Paned *)recordPtr;
- int paneIndex;
+ Tcl_Size paneIndex;
Tk_Window window;
Pane *pane;
@@ -783,9 +783,11 @@ static int PanedPaneCommand(
}
if (TCL_OK != Ttk_GetContentIndexFromObj(
- interp,pw->paned.mgr, objv[2], &paneIndex))
+ interp,pw->paned.mgr, objv[2], 0, &paneIndex))
{
return TCL_ERROR;
+ } else if (paneIndex >= Ttk_NumberContent(pw->paned.mgr)) {
+ paneIndex = Ttk_NumberContent(pw->paned.mgr) - 1;
}
pane = (Pane *)Ttk_ContentData(pw->paned.mgr, paneIndex);
@@ -807,12 +809,12 @@ static int PanedPaneCommand(
* Return list of managed panes.
*/
static int PanedPanesCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Paned *pw = (Paned *)recordPtr;
Ttk_Manager *mgr = pw->paned.mgr;
Tcl_Obj *panes;
- int i;
+ Tcl_Size i;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 2, objv, "");
@@ -834,22 +836,22 @@ static int PanedPanesCommand(
* Query or modify sash position.
*/
static int PanedSashposCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Paned *pw = (Paned *)recordPtr;
- int sashIndex, position = -1;
+ Tcl_WideInt sashIndex, position = -1;
Pane *pane;
if (objc < 3 || objc > 4) {
Tcl_WrongNumArgs(interp, 2,objv, "index ?newpos?");
return TCL_ERROR;
}
- if (Tcl_GetIntFromObj(interp, objv[2], &sashIndex) != TCL_OK) {
+ if (Tcl_GetWideIntFromObj(interp, objv[2], &sashIndex) != TCL_OK) {
return TCL_ERROR;
}
if (sashIndex < 0 || sashIndex >= Ttk_NumberContent(pw->paned.mgr) - 1) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "sash index %d out of range", sashIndex));
+ "sash index %" TCL_LL_MODIFIER "d out of range", sashIndex));
Tcl_SetErrorCode(interp, "TTK", "PANE", "SASH_INDEX", NULL);
return TCL_ERROR;
}
@@ -857,12 +859,12 @@ static int PanedSashposCommand(
pane = (Pane *)Ttk_ContentData(pw->paned.mgr, sashIndex);
if (objc == 3) {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(pane->sashPos));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(pane->sashPos));
return TCL_OK;
}
/* else -- set new sash position */
- if (Tcl_GetIntFromObj(interp, objv[3], &position) != TCL_OK) {
+ if (Tcl_GetWideIntFromObj(interp, objv[3], &position) != TCL_OK) {
return TCL_ERROR;
}
@@ -875,14 +877,14 @@ static int PanedSashposCommand(
AdjustPanes(pw);
Ttk_ManagerLayoutChanged(pw->paned.mgr);
- Tcl_SetObjResult(interp, Tcl_NewIntObj(pane->sashPos));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(pane->sashPos));
return TCL_OK;
}
static const Ttk_Ensemble PanedCommands[] = {
{ "add", PanedAddCommand,0 },
- { "configure", TtkWidgetConfigureCommand,0 },
{ "cget", TtkWidgetCgetCommand,0 },
+ { "configure", TtkWidgetConfigureCommand,0 },
{ "forget", PanedForgetCommand,0 },
{ "identify", PanedIdentifyCommand,0 },
{ "insert", PanedInsertCommand,0 },
@@ -891,6 +893,7 @@ static const Ttk_Ensemble PanedCommands[] = {
{ "panes", PanedPanesCommand,0 },
{ "sashpos", PanedSashposCommand,0 },
{ "state", TtkWidgetStateCommand,0 },
+ { "style", TtkWidgetStyleCommand,0 },
{ 0,0,0 }
};
@@ -898,7 +901,7 @@ static const Ttk_Ensemble PanedCommands[] = {
* +++ Widget specification.
*/
-static WidgetSpec PanedWidgetSpec =
+static const WidgetSpec PanedWidgetSpec =
{
"TPanedwindow", /* className */
sizeof(Paned), /* recordSize */
@@ -924,14 +927,14 @@ typedef struct {
Tcl_Obj *thicknessObj;
} SashElement;
-static Ttk_ElementOptionSpec SashElementOptions[] = {
+static const Ttk_ElementOptionSpec SashElementOptions[] = {
{ "-sashthickness", TK_OPTION_PIXELS,
- Tk_Offset(SashElement,thicknessObj), "5" },
+ offsetof(SashElement,thicknessObj), "5" },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void SashElementSize(
- TCL_UNUSED(void *),
+ TCL_UNUSED(void *), /* clientData */
void *elementRecord,
Tk_Window tkwin,
int *widthPtr,
@@ -945,7 +948,7 @@ static void SashElementSize(
*widthPtr = *heightPtr = thickness;
}
-static Ttk_ElementSpec SashElementSpec = {
+static const Ttk_ElementSpec SashElementSpec = {
TK_STYLE_VERSION_2,
sizeof(SashElement),
SashElementOptions,
diff --git a/generic/ttk/ttkProgress.c b/generic/ttk/ttkProgress.c
index 0b6d30f..b5e9d5f 100644
--- a/generic/ttk/ttkProgress.c
+++ b/generic/ttk/ttkProgress.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) Joe English, Pat Thoyts, Michael Kirkham
+ * Copyright © Joe English, Pat Thoyts, Michael Kirkham
*
* ttk::progressbar widget.
*/
@@ -21,13 +21,19 @@ static const char *const ProgressbarModeStrings[] = {
};
typedef struct {
- Tcl_Obj *orientObj;
+ Tcl_Obj *anchorObj;
+ Tcl_Obj *fontObj;
+ Tcl_Obj *foregroundObj;
+ Tcl_Obj *justifyObj;
Tcl_Obj *lengthObj;
- Tcl_Obj *modeObj;
- Tcl_Obj *variableObj;
Tcl_Obj *maximumObj;
- Tcl_Obj *valueObj;
+ Tcl_Obj *modeObj;
+ Tcl_Obj *orientObj;
Tcl_Obj *phaseObj;
+ Tcl_Obj *textObj;
+ Tcl_Obj *valueObj;
+ Tcl_Obj *variableObj;
+ Tcl_Obj *wrapLengthObj;
int mode;
Ttk_TraceHandle *variableTrace; /* Trace handle for -variable option */
@@ -42,30 +48,48 @@ typedef struct {
ProgressbarPart progress;
} Progressbar;
-static Tk_OptionSpec ProgressbarOptionSpecs[] =
+static const Tk_OptionSpec ProgressbarOptionSpecs[] =
{
- {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient",
- "horizontal", Tk_Offset(Progressbar,progress.orientObj), -1,
- 0, ttkOrientStrings, STYLE_CHANGED },
+ {TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
+ "w", offsetof(Progressbar,progress.anchorObj), TCL_INDEX_NONE,
+ TK_OPTION_NULL_OK, 0, GEOMETRY_CHANGED},
+ {TK_OPTION_FONT, "-font", "font", "Font",
+ DEFAULT_FONT, offsetof(Progressbar,progress.fontObj), TCL_INDEX_NONE,
+ TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
+ {TK_OPTION_COLOR, "-foreground", "textColor", "TextColor",
+ "black", offsetof(Progressbar,progress.foregroundObj), TCL_INDEX_NONE,
+ TK_OPTION_NULL_OK,0,0 },
+ {TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
+ "left", offsetof(Progressbar,progress.justifyObj), TCL_INDEX_NONE,
+ TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
{TK_OPTION_PIXELS, "-length", "length", "Length",
- DEF_PROGRESSBAR_LENGTH, Tk_Offset(Progressbar,progress.lengthObj), -1,
+ DEF_PROGRESSBAR_LENGTH, offsetof(Progressbar,progress.lengthObj), TCL_INDEX_NONE,
0, 0, GEOMETRY_CHANGED },
+ {TK_OPTION_DOUBLE, "-maximum", "maximum", "Maximum",
+ "100.0", offsetof(Progressbar,progress.maximumObj), TCL_INDEX_NONE,
+ 0, 0, 0 },
{TK_OPTION_STRING_TABLE, "-mode", "mode", "ProgressMode", "determinate",
- Tk_Offset(Progressbar,progress.modeObj),
- Tk_Offset(Progressbar,progress.mode),
+ offsetof(Progressbar,progress.modeObj),
+ offsetof(Progressbar,progress.mode),
0, ProgressbarModeStrings, 0 },
- {TK_OPTION_DOUBLE, "-maximum", "maximum", "Maximum",
- "100", Tk_Offset(Progressbar,progress.maximumObj), -1,
+ {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient",
+ "horizontal", offsetof(Progressbar,progress.orientObj), TCL_INDEX_NONE,
+ 0, ttkOrientStrings, STYLE_CHANGED },
+ {TK_OPTION_INT, "-phase", "phase", "Phase",
+ "0", offsetof(Progressbar,progress.phaseObj), TCL_INDEX_NONE,
0, 0, 0 },
- {TK_OPTION_STRING, "-variable", "variable", "Variable",
- NULL, Tk_Offset(Progressbar,progress.variableObj), -1,
- TK_OPTION_NULL_OK, 0, 0 },
+ {TK_OPTION_STRING, "-text", "text", "Text", "",
+ offsetof(Progressbar,progress.textObj), TCL_INDEX_NONE,
+ 0,0,GEOMETRY_CHANGED },
{TK_OPTION_DOUBLE, "-value", "value", "Value",
- "0.0", Tk_Offset(Progressbar,progress.valueObj), -1,
- 0, 0, 0 },
- {TK_OPTION_INT, "-phase", "phase", "Phase",
- "0", Tk_Offset(Progressbar,progress.phaseObj), -1,
+ "0.0", offsetof(Progressbar,progress.valueObj), TCL_INDEX_NONE,
0, 0, 0 },
+ {TK_OPTION_STRING, "-variable", "variable", "Variable",
+ NULL, offsetof(Progressbar,progress.variableObj), TCL_INDEX_NONE,
+ TK_OPTION_NULL_OK, 0, 0 },
+ {TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength",
+ "0", offsetof(Progressbar, progress.wrapLengthObj), TCL_INDEX_NONE,
+ TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED},
WIDGET_TAKEFOCUS_FALSE,
WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
@@ -114,7 +138,7 @@ static void AnimateProgressProc(void *clientData)
phase = 0;
}
Tcl_DecrRefCount(pb->progress.phaseObj);
- pb->progress.phaseObj = Tcl_NewIntObj(phase);
+ pb->progress.phaseObj = Tcl_NewWideIntObj(phase);
Tcl_IncrRefCount(pb->progress.phaseObj);
/*
@@ -272,14 +296,14 @@ static int ProgressbarSize(void *recordPtr, int *widthPtr, int *heightPtr)
{
Progressbar *pb = (Progressbar *)recordPtr;
int length = 100;
- int orient = TTK_ORIENT_HORIZONTAL;
+ Ttk_Orient orient = TTK_ORIENT_HORIZONTAL;
TtkWidgetSize(recordPtr, widthPtr, heightPtr);
/* Override requested width (height) based on -length and -orient
*/
Tk_GetPixelsFromObj(NULL, pb->core.tkwin, pb->progress.lengthObj, &length);
- Ttk_GetOrientFromObj(NULL, pb->progress.orientObj, &orient);
+ TtkGetOrientFromObj(NULL, pb->progress.orientObj, &orient);
if (orient == TTK_ORIENT_HORIZONTAL) {
*widthPtr = length;
@@ -343,7 +367,7 @@ static void ProgressbarDoLayout(void *recordPtr)
WidgetCore *corePtr = &pb->core;
Ttk_Element pbar = Ttk_FindElement(corePtr->layout, "pbar");
double value = 0.0, maximum = 100.0;
- int orient = TTK_ORIENT_HORIZONTAL;
+ Ttk_Orient orient = TTK_ORIENT_HORIZONTAL;
Ttk_PlaceLayout(corePtr->layout,corePtr->state,Ttk_WinBox(corePtr->tkwin));
@@ -352,7 +376,7 @@ static void ProgressbarDoLayout(void *recordPtr)
Tcl_GetDoubleFromObj(NULL, pb->progress.valueObj, &value);
Tcl_GetDoubleFromObj(NULL, pb->progress.maximumObj, &maximum);
- Ttk_GetOrientFromObj(NULL, pb->progress.orientObj, &orient);
+ TtkGetOrientFromObj(NULL, pb->progress.orientObj, &orient);
if (pbar) {
double fraction = value / maximum;
@@ -399,7 +423,7 @@ static Ttk_Layout ProgressbarGetLayout(
/* $sb step ?amount?
*/
static int ProgressbarStepCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Progressbar *pb = (Progressbar *)recordPtr;
double value = 0.0, stepAmount = 1.0;
@@ -455,7 +479,7 @@ static int ProgressbarStepCommand(
* and pass to interpreter.
*/
static int ProgressbarStartStopCommand(
- Tcl_Interp *interp, const char *cmdName, int objc, Tcl_Obj *const objv[])
+ Tcl_Interp *interp, const char *cmdName, Tcl_Size objc, Tcl_Obj *const objv[])
{
Tcl_Obj *cmd = Tcl_NewListObj(objc, objv);
Tcl_Obj *prefix[2];
@@ -477,7 +501,7 @@ static int ProgressbarStartStopCommand(
static int ProgressbarStartCommand(
TCL_UNUSED(void *),
Tcl_Interp *interp,
- int objc,
+ Tcl_Size objc,
Tcl_Obj *const objv[])
{
return ProgressbarStartStopCommand(
@@ -487,7 +511,7 @@ static int ProgressbarStartCommand(
static int ProgressbarStopCommand(
TCL_UNUSED(void *),
Tcl_Interp *interp,
- int objc,
+ Tcl_Size objc,
Tcl_Obj *const objv[])
{
return ProgressbarStartStopCommand(
@@ -495,21 +519,22 @@ static int ProgressbarStopCommand(
}
static const Ttk_Ensemble ProgressbarCommands[] = {
- { "configure", TtkWidgetConfigureCommand,0 },
{ "cget", TtkWidgetCgetCommand,0 },
+ { "configure", TtkWidgetConfigureCommand,0 },
{ "identify", TtkWidgetIdentifyCommand,0 },
{ "instate", TtkWidgetInstateCommand,0 },
{ "start", ProgressbarStartCommand,0 },
{ "state", TtkWidgetStateCommand,0 },
{ "step", ProgressbarStepCommand,0 },
{ "stop", ProgressbarStopCommand,0 },
+ { "style", TtkWidgetStyleCommand,0 },
{ 0,0,0 }
};
/*
* Widget specification:
*/
-static WidgetSpec ProgressbarWidgetSpec =
+static const WidgetSpec ProgressbarWidgetSpec =
{
"TProgressbar", /* className */
sizeof(Progressbar), /* recordSize */
@@ -535,7 +560,8 @@ TTK_END_LAYOUT
TTK_BEGIN_LAYOUT(HorizontalProgressbarLayout)
TTK_GROUP("Horizontal.Progressbar.trough", TTK_FILL_BOTH,
- TTK_NODE("Horizontal.Progressbar.pbar", TTK_PACK_LEFT|TTK_FILL_Y))
+ TTK_NODE("Horizontal.Progressbar.pbar", TTK_PACK_LEFT|TTK_FILL_Y)
+ TTK_NODE("Horizontal.Progressbar.ctext", TTK_PACK_LEFT))
TTK_END_LAYOUT
/*
diff --git a/generic/ttk/ttkScale.c b/generic/ttk/ttkScale.c
index a80d6e8..ec2343a 100644
--- a/generic/ttk/ttkScale.c
+++ b/generic/ttk/ttkScale.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004 Pat Thoyts <patthoyts@users.sourceforge.net>
+ * Copyright © 2004 Pat Thoyts <patthoyts@users.sourceforge.net>
*
* ttk::scale widget.
*/
@@ -50,31 +50,31 @@ typedef struct
ScalePart scale;
} Scale;
-static Tk_OptionSpec ScaleOptionSpecs[] =
+static const Tk_OptionSpec ScaleOptionSpecs[] =
{
{TK_OPTION_STRING, "-command", "command", "Command", "",
- Tk_Offset(Scale,scale.commandObj), -1,
+ offsetof(Scale,scale.commandObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,0},
{TK_OPTION_STRING, "-variable", "variable", "Variable", "",
- Tk_Offset(Scale,scale.variableObj), -1,
+ offsetof(Scale,scale.variableObj), TCL_INDEX_NONE,
0, 0, 0},
{TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "horizontal",
- Tk_Offset(Scale,scale.orientObj),
- Tk_Offset(Scale,scale.orient),
+ offsetof(Scale,scale.orientObj),
+ offsetof(Scale,scale.orient),
0, ttkOrientStrings, STYLE_CHANGED },
- {TK_OPTION_DOUBLE, "-from", "from", "From", "0",
- Tk_Offset(Scale,scale.fromObj), -1, 0, 0, 0},
+ {TK_OPTION_DOUBLE, "-from", "from", "From", "0.0",
+ offsetof(Scale,scale.fromObj), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_DOUBLE, "-to", "to", "To", "1.0",
- Tk_Offset(Scale,scale.toObj), -1, 0, 0, 0},
- {TK_OPTION_DOUBLE, "-value", "value", "Value", "0",
- Tk_Offset(Scale,scale.valueObj), -1, 0, 0, 0},
+ offsetof(Scale,scale.toObj), TCL_INDEX_NONE, 0, 0, 0},
+ {TK_OPTION_DOUBLE, "-value", "value", "Value", "0.0",
+ offsetof(Scale,scale.valueObj), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_PIXELS, "-length", "length", "Length",
- DEF_SCALE_LENGTH, Tk_Offset(Scale,scale.lengthObj), -1, 0, 0,
+ DEF_SCALE_LENGTH, offsetof(Scale,scale.lengthObj), TCL_INDEX_NONE, 0, 0,
GEOMETRY_CHANGED},
{TK_OPTION_STRING, "-state", "state", "State",
- "normal", Tk_Offset(Scale,scale.stateObj), -1,
+ "normal", offsetof(Scale,scale.stateObj), TCL_INDEX_NONE,
0, 0, STATE_CHANGED},
WIDGET_TAKEFOCUS_TRUE,
@@ -261,19 +261,15 @@ static double ScaleFraction(Scale *scalePtr, double value)
*/
static int
ScaleGetCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Scale *scalePtr = (Scale *)recordPtr;
int x, y, r = TCL_OK;
double value = 0;
- if ((objc != 2) && (objc != 4)) {
- Tcl_WrongNumArgs(interp, 1, objv, "get ?x y?");
- return TCL_ERROR;
- }
if (objc == 2) {
Tcl_SetObjResult(interp, scalePtr->scale.valueObj);
- } else {
+ } else if (objc == 4) {
r = Tcl_GetIntFromObj(interp, objv[2], &x);
if (r == TCL_OK)
r = Tcl_GetIntFromObj(interp, objv[3], &y);
@@ -281,6 +277,9 @@ ScaleGetCommand(
value = PointToValue(scalePtr, x, y);
Tcl_SetObjResult(interp, Tcl_NewDoubleObj(value));
}
+ } else {
+ Tcl_WrongNumArgs(interp, 1, objv, "get ?x y?");
+ return TCL_ERROR;
}
return r;
}
@@ -289,7 +288,7 @@ ScaleGetCommand(
*/
static int
ScaleSetCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Scale *scalePtr = (Scale *)recordPtr;
double from = 0.0, to = 1.0, value;
@@ -357,28 +356,26 @@ ScaleSetCommand(
static int
ScaleCoordsCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Scale *scalePtr = (Scale *)recordPtr;
double value;
int r = TCL_OK;
- if (objc < 2 || objc > 3) {
- Tcl_WrongNumArgs(interp, 1, objv, "coords ?value?");
- return TCL_ERROR;
- }
-
if (objc == 3) {
r = Tcl_GetDoubleFromObj(interp, objv[2], &value);
- } else {
+ } else if (objc == 2) {
r = Tcl_GetDoubleFromObj(interp, scalePtr->scale.valueObj, &value);
+ } else {
+ Tcl_WrongNumArgs(interp, 1, objv, "coords ?value?");
+ return TCL_ERROR;
}
if (r == TCL_OK) {
Tcl_Obj *point[2];
XPoint pt = ValueToPoint(scalePtr, value);
- point[0] = Tcl_NewIntObj(pt.x);
- point[1] = Tcl_NewIntObj(pt.y);
+ point[0] = Tcl_NewWideIntObj(pt.x);
+ point[1] = Tcl_NewWideIntObj(pt.y);
Tcl_SetObjResult(interp, Tcl_NewListObj(2, point));
}
return r;
@@ -482,18 +479,19 @@ ValueToPoint(Scale *scalePtr, double value)
}
static const Ttk_Ensemble ScaleCommands[] = {
- { "configure", TtkWidgetConfigureCommand,0 },
{ "cget", TtkWidgetCgetCommand,0 },
- { "state", TtkWidgetStateCommand,0 },
- { "instate", TtkWidgetInstateCommand,0 },
+ { "configure", TtkWidgetConfigureCommand,0 },
+ { "coords", ScaleCoordsCommand,0 },
+ { "get", ScaleGetCommand,0 },
{ "identify", TtkWidgetIdentifyCommand,0 },
+ { "instate", TtkWidgetInstateCommand,0 },
{ "set", ScaleSetCommand,0 },
- { "get", ScaleGetCommand,0 },
- { "coords", ScaleCoordsCommand,0 },
+ { "state", TtkWidgetStateCommand,0 },
+ { "style", TtkWidgetStyleCommand,0 },
{ 0,0,0 }
};
-static WidgetSpec ScaleWidgetSpec =
+static const WidgetSpec ScaleWidgetSpec =
{
"TScale", /* Class name */
sizeof(Scale), /* record size */
diff --git a/generic/ttk/ttkScroll.c b/generic/ttk/ttkScroll.c
index c3b847a..7a7f588 100644
--- a/generic/ttk/ttkScroll.c
+++ b/generic/ttk/ttkScroll.c
@@ -55,7 +55,7 @@ struct ScrollHandleRec
*/
ScrollHandle TtkCreateScrollHandle(WidgetCore *corePtr, Scrollable *scrollPtr)
{
- ScrollHandle h = ckalloc(sizeof(*h));
+ ScrollHandle h = (ScrollHandle)ckalloc(sizeof(*h));
h->flags = 0;
h->corePtr = corePtr;
@@ -90,9 +90,9 @@ static int UpdateScrollbar(Tcl_Interp *interp, ScrollHandle h)
Tcl_PrintDouble(interp, (double)s->first / s->total, arg1+1);
Tcl_PrintDouble(interp, (double)s->last / s->total, arg2+1);
Tcl_DStringInit(&buf);
- Tcl_DStringAppend(&buf, s->scrollCmd, -1);
- Tcl_DStringAppend(&buf, arg1, -1);
- Tcl_DStringAppend(&buf, arg2, -1);
+ Tcl_DStringAppend(&buf, s->scrollCmd, TCL_INDEX_NONE);
+ Tcl_DStringAppend(&buf, arg1, TCL_INDEX_NONE);
+ Tcl_DStringAppend(&buf, arg2, TCL_INDEX_NONE);
Tcl_Preserve(corePtr);
code = Tcl_EvalEx(interp, Tcl_DStringValue(&buf), -1, TCL_EVAL_GLOBAL);
@@ -123,19 +123,19 @@ static int UpdateScrollbar(Tcl_Interp *interp, ScrollHandle h)
/* UpdateScrollbarBG --
* Idle handler to update the scrollbar.
*/
-static void UpdateScrollbarBG(ClientData clientData)
+static void UpdateScrollbarBG(void *clientData)
{
ScrollHandle h = (ScrollHandle)clientData;
Tcl_Interp *interp = h->corePtr->interp;
int code;
h->flags &= ~SCROLL_UPDATE_PENDING;
- Tcl_Preserve((ClientData) interp);
+ Tcl_Preserve(interp);
code = UpdateScrollbar(interp, h);
if (code == TCL_ERROR && !Tcl_InterpDeleted(interp)) {
Tcl_BackgroundException(interp, code);
}
- Tcl_Release((ClientData) interp);
+ Tcl_Release(interp);
}
/* TtkScrolled --
@@ -167,7 +167,7 @@ void TtkScrolled(ScrollHandle h, int first, int last, int total)
s->total = total;
if (!(h->flags & SCROLL_UPDATE_PENDING)) {
- Tcl_DoWhenIdle(UpdateScrollbarBG, (ClientData)h);
+ Tcl_DoWhenIdle(UpdateScrollbarBG, h);
h->flags |= SCROLL_UPDATE_PENDING;
}
}
@@ -206,7 +206,7 @@ void TtkUpdateScrollInfo(ScrollHandle h)
* $w [xy]view scroll $number $what -- scrollbar interface
*/
int TtkScrollviewCommand(
- Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], ScrollHandle h)
+ Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[], ScrollHandle h)
{
Scrollable *s = h->scrollPtr;
int newFirst;
@@ -274,7 +274,7 @@ void TtkScrollTo(ScrollHandle h, int newFirst, int updateScrollInfo)
void TtkFreeScrollHandle(ScrollHandle h)
{
if (h->flags & SCROLL_UPDATE_PENDING) {
- Tcl_CancelIdleCall(UpdateScrollbarBG, (ClientData)h);
+ Tcl_CancelIdleCall(UpdateScrollbarBG, h);
}
ckfree(h);
}
diff --git a/generic/ttk/ttkScrollbar.c b/generic/ttk/ttkScrollbar.c
index 31f291a..03eb3d6 100644
--- a/generic/ttk/ttkScrollbar.c
+++ b/generic/ttk/ttkScrollbar.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, Joe English
+ * Copyright © 2003 Joe English
*
* ttk::scrollbar widget.
*/
@@ -31,14 +31,14 @@ typedef struct
ScrollbarPart scrollbar;
} Scrollbar;
-static Tk_OptionSpec ScrollbarOptionSpecs[] =
+static const Tk_OptionSpec ScrollbarOptionSpecs[] =
{
{TK_OPTION_STRING, "-command", "command", "Command", "",
- Tk_Offset(Scrollbar,scrollbar.commandObj), -1, 0, 0, 0},
+ offsetof(Scrollbar, scrollbar.commandObj), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "vertical",
- Tk_Offset(Scrollbar,scrollbar.orientObj),
- Tk_Offset(Scrollbar,scrollbar.orient),
+ offsetof(Scrollbar, scrollbar.orientObj),
+ offsetof(Scrollbar, scrollbar.orient),
0, ttkOrientStrings, STYLE_CHANGED },
WIDGET_TAKEFOCUS_FALSE,
@@ -133,7 +133,7 @@ static void ScrollbarDoLayout(void *recordPtr)
*/
static int
ScrollbarSetCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Scrollbar *scrollbar = (Scrollbar *)recordPtr;
Tcl_Obj *firstObj, *lastObj;
@@ -184,7 +184,7 @@ ScrollbarSetCommand(
*/
static int
ScrollbarGetCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Scrollbar *scrollbar = (Scrollbar *)recordPtr;
Tcl_Obj *result[2];
@@ -207,7 +207,7 @@ ScrollbarGetCommand(
*/
static int
ScrollbarDeltaCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Scrollbar *sb = (Scrollbar *)recordPtr;
double dx, dy;
@@ -247,7 +247,7 @@ ScrollbarDeltaCommand(
*/
static int
ScrollbarFractionCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Scrollbar *sb = (Scrollbar *)recordPtr;
Ttk_Box b = sb->scrollbar.troughBox;
@@ -282,8 +282,8 @@ ScrollbarFractionCommand(
}
static const Ttk_Ensemble ScrollbarCommands[] = {
- { "configure", TtkWidgetConfigureCommand,0 },
{ "cget", TtkWidgetCgetCommand,0 },
+ { "configure", TtkWidgetConfigureCommand,0 },
{ "delta", ScrollbarDeltaCommand,0 },
{ "fraction", ScrollbarFractionCommand,0 },
{ "get", ScrollbarGetCommand,0 },
@@ -291,13 +291,14 @@ static const Ttk_Ensemble ScrollbarCommands[] = {
{ "instate", TtkWidgetInstateCommand,0 },
{ "set", ScrollbarSetCommand,0 },
{ "state", TtkWidgetStateCommand,0 },
+ { "style", TtkWidgetStyleCommand,0 },
{ 0,0,0 }
};
/*------------------------------------------------------------------------
* +++ Widget specification.
*/
-static WidgetSpec ScrollbarWidgetSpec =
+static const WidgetSpec ScrollbarWidgetSpec =
{
"TScrollbar", /* className */
sizeof(Scrollbar), /* recordSize */
diff --git a/generic/ttk/ttkSeparator.c b/generic/ttk/ttkSeparator.c
index 26c169f..fa8c37d 100644
--- a/generic/ttk/ttkSeparator.c
+++ b/generic/ttk/ttkSeparator.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, Joe English
+ * Copyright © 2004 Joe English
*
* ttk::separator and ttk::sizegrip widgets.
*/
@@ -22,10 +22,10 @@ typedef struct
SeparatorPart separator;
} Separator;
-static Tk_OptionSpec SeparatorOptionSpecs[] = {
+static const Tk_OptionSpec SeparatorOptionSpecs[] = {
{TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "horizontal",
- Tk_Offset(Separator,separator.orientObj),
- Tk_Offset(Separator,separator.orient),
+ offsetof(Separator,separator.orientObj),
+ offsetof(Separator,separator.orient),
0, ttkOrientStrings, STYLE_CHANGED },
WIDGET_TAKEFOCUS_FALSE,
@@ -39,7 +39,7 @@ static Tk_OptionSpec SeparatorOptionSpecs[] = {
static Ttk_Layout SeparatorGetLayout(
Tcl_Interp *interp, Ttk_Theme theme, void *recordPtr)
{
- Separator *sep = recordPtr;
+ Separator *sep = (Separator *)recordPtr;
return TtkWidgetGetOrientedLayout(
interp, theme, recordPtr, sep->separator.orientObj);
}
@@ -48,18 +48,19 @@ static Ttk_Layout SeparatorGetLayout(
* Widget commands:
*/
static const Ttk_Ensemble SeparatorCommands[] = {
- { "configure", TtkWidgetConfigureCommand,0 },
{ "cget", TtkWidgetCgetCommand,0 },
+ { "configure", TtkWidgetConfigureCommand,0 },
{ "identify", TtkWidgetIdentifyCommand,0 },
{ "instate", TtkWidgetInstateCommand,0 },
{ "state", TtkWidgetStateCommand,0 },
+ { "style", TtkWidgetStyleCommand,0 },
{ 0,0,0 }
};
/*
* Widget specification:
*/
-static WidgetSpec SeparatorWidgetSpec =
+static const WidgetSpec SeparatorWidgetSpec =
{
"TSeparator", /* className */
sizeof(Separator), /* recordSize */
@@ -83,21 +84,22 @@ TTK_END_LAYOUT
* Has no options or methods other than the standard ones.
*/
-static Tk_OptionSpec SizegripOptionSpecs[] = {
+static const Tk_OptionSpec SizegripOptionSpecs[] = {
WIDGET_TAKEFOCUS_FALSE,
WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
};
static const Ttk_Ensemble SizegripCommands[] = {
- { "configure", TtkWidgetConfigureCommand,0 },
{ "cget", TtkWidgetCgetCommand,0 },
+ { "configure", TtkWidgetConfigureCommand,0 },
{ "identify", TtkWidgetIdentifyCommand,0 },
{ "instate", TtkWidgetInstateCommand,0 },
{ "state", TtkWidgetStateCommand,0 },
+ { "style", TtkWidgetStyleCommand,0 },
{ 0,0,0 }
};
-static WidgetSpec SizegripWidgetSpec =
+static const WidgetSpec SizegripWidgetSpec =
{
"TSizegrip", /* className */
sizeof(WidgetCore), /* recordSize */
diff --git a/generic/ttk/ttkSquare.c b/generic/ttk/ttkSquare.c
index 8629ae9..3022f1a 100644
--- a/generic/ttk/ttkSquare.c
+++ b/generic/ttk/ttkSquare.c
@@ -1,4 +1,4 @@
-/* square.c - Copyright (C) 2004 Pat Thoyts <patthoyts@users.sourceforge.net>
+/* square.c - Copyright © 2004 Pat Thoyts <patthoyts@users.sourceforge.net>
*
* Minimal sample ttk widget.
*/
@@ -48,31 +48,31 @@ typedef struct
* defined for all widgets.
*/
-static Tk_OptionSpec SquareOptionSpecs[] =
+static const Tk_OptionSpec SquareOptionSpecs[] =
{
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEFAULT_BORDERWIDTH, Tk_Offset(Square,square.borderWidthObj), -1,
+ DEFAULT_BORDERWIDTH, offsetof(Square,square.borderWidthObj), TCL_INDEX_NONE,
0,0,GEOMETRY_CHANGED },
{TK_OPTION_BORDER, "-foreground", "foreground", "Foreground",
- DEFAULT_BACKGROUND, Tk_Offset(Square,square.foregroundObj),
- -1, 0, 0, 0},
+ DEFAULT_BACKGROUND, offsetof(Square,square.foregroundObj),
+ TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_PIXELS, "-width", "width", "Width",
- "50", Tk_Offset(Square,square.widthObj), -1, 0, 0,
+ "50", offsetof(Square,square.widthObj), TCL_INDEX_NONE, 0, 0,
GEOMETRY_CHANGED},
{TK_OPTION_PIXELS, "-height", "height", "Height",
- "50", Tk_Offset(Square,square.heightObj), -1, 0, 0,
+ "50", offsetof(Square,square.heightObj), TCL_INDEX_NONE, 0, 0,
GEOMETRY_CHANGED},
{TK_OPTION_STRING, "-padding", "padding", "Pad", NULL,
- Tk_Offset(Square,square.paddingObj), -1,
+ offsetof(Square,square.paddingObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- NULL, Tk_Offset(Square,square.reliefObj), -1, TK_OPTION_NULL_OK, 0, 0},
+ NULL, offsetof(Square,square.reliefObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
- "center", Tk_Offset(Square,square.anchorObj), -1, 0, 0, 0},
+ "center", offsetof(Square,square.anchorObj), TCL_INDEX_NONE, 0, 0, 0},
WIDGET_TAKEFOCUS_TRUE,
WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
@@ -129,11 +129,12 @@ SquareDoLayout(void *clientData)
*/
static const Ttk_Ensemble SquareCommands[] = {
- { "configure", TtkWidgetConfigureCommand,0 },
{ "cget", TtkWidgetCgetCommand,0 },
+ { "configure", TtkWidgetConfigureCommand,0 },
{ "identify", TtkWidgetIdentifyCommand,0 },
{ "instate", TtkWidgetInstateCommand,0 },
{ "state", TtkWidgetStateCommand,0 },
+ { "style", TtkWidgetStyleCommand,0 },
{ 0,0,0 }
};
@@ -143,7 +144,7 @@ static const Ttk_Ensemble SquareCommands[] = {
* with Tk in the package initialization code (see bottom).
*/
-static WidgetSpec SquareWidgetSpec =
+static const WidgetSpec SquareWidgetSpec =
{
"TSquare", /* className */
sizeof(Square), /* recordSize */
@@ -176,18 +177,18 @@ typedef struct
Tcl_Obj *heightObj;
} SquareElement;
-static Ttk_ElementOptionSpec SquareElementOptions[] =
+static const Ttk_ElementOptionSpec SquareElementOptions[] =
{
- { "-background", TK_OPTION_BORDER, Tk_Offset(SquareElement,borderObj),
+ { "-background", TK_OPTION_BORDER, offsetof(SquareElement,borderObj),
DEFAULT_BACKGROUND },
- { "-foreground", TK_OPTION_BORDER, Tk_Offset(SquareElement,foregroundObj),
+ { "-foreground", TK_OPTION_BORDER, offsetof(SquareElement,foregroundObj),
DEFAULT_BACKGROUND },
- { "-borderwidth", TK_OPTION_PIXELS, Tk_Offset(SquareElement,borderWidthObj),
+ { "-borderwidth", TK_OPTION_PIXELS, offsetof(SquareElement,borderWidthObj),
DEFAULT_BORDERWIDTH },
- { "-relief", TK_OPTION_RELIEF, Tk_Offset(SquareElement,reliefObj),
+ { "-relief", TK_OPTION_RELIEF, offsetof(SquareElement,reliefObj),
"raised" },
- { "-width", TK_OPTION_PIXELS, Tk_Offset(SquareElement,widthObj), "20"},
- { "-height", TK_OPTION_PIXELS, Tk_Offset(SquareElement,heightObj), "20"},
+ { "-width", TK_OPTION_PIXELS, offsetof(SquareElement,widthObj), "20"},
+ { "-height", TK_OPTION_PIXELS, offsetof(SquareElement,heightObj), "20"},
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -238,7 +239,7 @@ static void SquareElementDraw(
b.x, b.y, b.width, b.height, borderWidth, relief);
}
-static Ttk_ElementSpec SquareElementSpec =
+static const Ttk_ElementSpec SquareElementSpec =
{
TK_STYLE_VERSION_2,
sizeof(SquareElement),
diff --git a/generic/ttk/ttkState.c b/generic/ttk/ttkState.c
index 2cff741..be15fdb 100644
--- a/generic/ttk/ttkState.c
+++ b/generic/ttk/ttkState.c
@@ -1,7 +1,7 @@
/*
* Tk widget state utilities.
*
- * Copyright (c) 2003 Joe English. Freely redistributable.
+ * Copyright © 2003 Joe English. Freely redistributable.
*
*/
@@ -16,21 +16,21 @@ static const struct {
int value;
} stateNames[] = {
{"active", TTK_STATE_ACTIVE}, /* Mouse cursor is over widget or element */
+ {"alternate", TTK_STATE_ALTERNATE}, /* Widget-specific alternate display style */
+ {"background", TTK_STATE_BACKGROUND}, /* Top-level window lost focus (Mac,Win "inactive") */
{"disabled", TTK_STATE_DISABLED}, /* Widget is disabled */
{"focus", TTK_STATE_FOCUS}, /* Widget has keyboard focus */
- {"pressed", TTK_STATE_PRESSED}, /* Pressed or "armed" */
- {"selected", TTK_STATE_SELECTED}, /* "on", "true", "current", etc. */
- {"background", TTK_STATE_BACKGROUND}, /* Top-level window lost focus (Mac,Win "inactive") */
- {"alternate", TTK_STATE_ALTERNATE}, /* Widget-specific alternate display style */
+ {"hover", TTK_STATE_HOVER}, /* Mouse cursor is over widget */
{"invalid", TTK_STATE_INVALID}, /* Bad value */
+ {"pressed", TTK_STATE_PRESSED}, /* Pressed or "armed" */
{"readonly", TTK_STATE_READONLY}, /* Editing/modification disabled */
- {"hover", TTK_STATE_HOVER}, /* Mouse cursor is over widget */
- {"user6", TTK_STATE_USER6}, /* User-definable state */
- {"user5", TTK_STATE_USER5}, /* User-definable state */
- {"user4", TTK_STATE_USER4}, /* User-definable state */
- {"user3", TTK_STATE_USER3}, /* User-definable state */
- {"user2", TTK_STATE_USER2}, /* User-definable state */
+ {"selected", TTK_STATE_SELECTED}, /* "on", "true", "current", etc. */
{"user1", TTK_STATE_USER1}, /* User-definable state */
+ {"user2", TTK_STATE_USER2}, /* User-definable state */
+ {"user3", TTK_STATE_USER3}, /* User-definable state */
+ {"user4", TTK_STATE_USER4}, /* User-definable state */
+ {"user5", TTK_STATE_USER5}, /* User-definable state */
+ {"user6", TTK_STATE_USER6}, /* User-definable state */
{"", 0}
};
@@ -40,37 +40,38 @@ static const struct {
* The string representation consists of a list of state names,
* each optionally prefixed by an exclamation point (!).
*
- * The internal representation uses the upper half of the longValue
+ * The internal representation uses the upper half of the wideValue
* to store the on bits and the lower half to store the off bits.
- * If we ever get more than 16 states, this will need to be reconsidered...
+ * If we ever get more than 32 states, this will need to be reconsidered...
*/
static int StateSpecSetFromAny(Tcl_Interp *interp, Tcl_Obj *obj);
static void StateSpecDupIntRep(Tcl_Obj *, Tcl_Obj *);
static void StateSpecUpdateString(Tcl_Obj *);
-static
-struct Tcl_ObjType StateSpecObjType =
+static const
+TkObjType StateSpecObjType =
{
- "StateSpec",
+ {"StateSpec",
0,
StateSpecDupIntRep,
StateSpecUpdateString,
- StateSpecSetFromAny
+ StateSpecSetFromAny,
+ TCL_OBJTYPE_V0},
+ 0
};
static void StateSpecDupIntRep(Tcl_Obj *srcPtr, Tcl_Obj *copyPtr)
{
- copyPtr->internalRep.longValue = srcPtr->internalRep.longValue;
- copyPtr->typePtr = &StateSpecObjType;
+ copyPtr->internalRep.wideValue = srcPtr->internalRep.wideValue;
+ copyPtr->typePtr = &StateSpecObjType.objType;
}
static int StateSpecSetFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr)
{
int status;
- int objc;
+ Tcl_Size i, objc;
Tcl_Obj **objv;
- int i;
unsigned int onbits = 0, offbits = 0;
status = Tcl_ListObjGetElements(interp, objPtr, &objc, &objv);
@@ -115,16 +116,16 @@ static int StateSpecSetFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr)
objPtr->typePtr->freeIntRepProc(objPtr);
}
- objPtr->typePtr = &StateSpecObjType;
- objPtr->internalRep.longValue = (onbits << 16) | offbits;
+ objPtr->typePtr = &StateSpecObjType.objType;
+ objPtr->internalRep.wideValue = ((Tcl_WideInt)onbits << 32) | offbits;
return TCL_OK;
}
static void StateSpecUpdateString(Tcl_Obj *objPtr)
{
- unsigned int onbits = objPtr->internalRep.longValue >> 16;
- unsigned int offbits = objPtr->internalRep.longValue & 0x0000FFFF;
+ unsigned int onbits = objPtr->internalRep.wideValue >> 32;
+ unsigned int offbits = objPtr->internalRep.wideValue & 0xFFFFFFFFLL;
unsigned int mask = onbits | offbits;
Tcl_DString result;
int i;
@@ -137,7 +138,7 @@ static void StateSpecUpdateString(Tcl_Obj *objPtr)
if (offbits & stateNames[i].value) {
Tcl_DStringAppend(&result, "!", 1);
}
- Tcl_DStringAppend(&result, stateNames[i].name, -1);
+ Tcl_DStringAppend(&result, stateNames[i].name, TCL_INDEX_NONE);
Tcl_DStringAppend(&result, " ", 1);
}
}
@@ -164,8 +165,8 @@ Tcl_Obj *Ttk_NewStateSpecObj(unsigned int onbits, unsigned int offbits)
Tcl_Obj *objPtr = Tcl_NewObj();
Tcl_InvalidateStringRep(objPtr);
- objPtr->typePtr = &StateSpecObjType;
- objPtr->internalRep.longValue = (onbits << 16) | offbits;
+ objPtr->typePtr = &StateSpecObjType.objType;
+ objPtr->internalRep.wideValue = ((Tcl_WideInt)onbits << 32) | offbits;
return objPtr;
}
@@ -175,14 +176,14 @@ int Ttk_GetStateSpecFromObj(
Tcl_Obj *objPtr,
Ttk_StateSpec *spec)
{
- if (objPtr->typePtr != &StateSpecObjType) {
+ if (objPtr->typePtr != &StateSpecObjType.objType) {
int status = StateSpecSetFromAny(interp, objPtr);
if (status != TCL_OK)
return status;
}
- spec->onbits = objPtr->internalRep.longValue >> 16;
- spec->offbits = objPtr->internalRep.longValue & 0x0000FFFF;
+ spec->onbits = objPtr->internalRep.wideValue >> 32;
+ spec->offbits = objPtr->internalRep.wideValue & 0xFFFFFFFFLL;
return TCL_OK;
}
@@ -200,7 +201,7 @@ Tcl_Obj *Ttk_StateMapLookup(
Ttk_State state) /* State to look up */
{
Tcl_Obj **specs;
- int j, nSpecs;
+ Tcl_Size j, nSpecs;
int status;
status = Tcl_ListObjGetElements(interp, map, &nSpecs, &specs);
@@ -232,7 +233,7 @@ Ttk_StateMap Ttk_GetStateMapFromObj(
Tcl_Obj *mapObj) /* State map */
{
Tcl_Obj **specs;
- int j, nSpecs;
+ Tcl_Size j, nSpecs;
int status;
status = Tcl_ListObjGetElements(interp, mapObj, &nSpecs, &specs);
@@ -261,7 +262,7 @@ Ttk_StateMap Ttk_GetStateMapFromObj(
* Ttk_StateTableLooup --
* Look up an index from a statically allocated state table.
*/
-int Ttk_StateTableLookup(Ttk_StateTable *map, Ttk_State state)
+int Ttk_StateTableLookup(const Ttk_StateTable *map, Ttk_State state)
{
while ((state & map->onBits) != map->onBits
|| (~state & map->offBits) != map->offBits)
diff --git a/generic/ttk/ttkStubInit.c b/generic/ttk/ttkStubInit.c
index 0039585..51acf3a 100644
--- a/generic/ttk/ttkStubInit.c
+++ b/generic/ttk/ttkStubInit.c
@@ -8,6 +8,18 @@
MODULE_SCOPE const TtkStubs ttkStubs;
+#if defined(TK_NO_DEPRECATED) || TK_MAJOR_VERSION > 8
+#define Ttk_GetOrientFromObj 0
+#endif
+
+#ifdef __GNUC__
+/*
+ * The rest of this file shouldn't warn about deprecated functions; they're
+ * there because we intend them to be so and know that this file is OK to
+ * touch those fields.
+ */
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
/* !BEGIN!: Do not edit below this line. */
const TtkStubs ttkStubs = {
diff --git a/generic/ttk/ttkStubLib.c b/generic/ttk/ttkStubLib.c
index faeabe8..a3b3376 100644
--- a/generic/ttk/ttkStubLib.c
+++ b/generic/ttk/ttkStubLib.c
@@ -34,17 +34,23 @@ TtkInitializeStubs(
Tcl_Interp *interp, const char *version, int epoch, int revision)
{
int exact = 0;
- const char *packageName = "Ttk";
+ const char *packageName = "ttk";
const char *errMsg = NULL;
void *pkgClientData = NULL;
const char *actualVersion = Tcl_PkgRequireEx(
interp, packageName, version, exact, &pkgClientData);
- const TtkStubs *stubsPtr = (const TtkStubs *)pkgClientData;
+ const TtkStubs *stubsPtr;
if (!actualVersion) {
- return NULL;
+ packageName = "Ttk";
+ actualVersion = Tcl_PkgRequireEx(
+ interp, packageName, version, exact, &pkgClientData);
+ if (!actualVersion) {
+ return NULL;
+ }
}
+ stubsPtr = (const TtkStubs *)pkgClientData;
if (!stubsPtr) {
errMsg = "missing stub table pointer";
goto error;
diff --git a/generic/ttk/ttkTagSet.c b/generic/ttk/ttkTagSet.c
index 0ce5cea..5645325 100644
--- a/generic/ttk/ttkTagSet.c
+++ b/generic/ttk/ttkTagSet.c
@@ -1,11 +1,10 @@
/*
* Tag tables. 3/4-baked, work in progress.
*
- * Copyright (C) 2005, Joe English. Freely redistributable.
+ * Copyright © 2005, Joe English. Freely redistributable.
*/
#include "tkInt.h"
-
#include "ttkTheme.h"
#include "ttkWidget.h"
@@ -13,17 +12,17 @@
* +++ Internal data structures.
*/
struct TtkTag {
- int priority; /* 1=>highest */
+ Tcl_Size priority; /* 1=>highest */
const char *tagName; /* Back-pointer to hash table entry */
void *tagRecord; /* User data */
};
struct TtkTagTable {
Tk_Window tkwin; /* owner window */
- Tk_OptionSpec *optionSpecs; /* ... */
+ const Tk_OptionSpec *optionSpecs; /* ... */
Tk_OptionTable optionTable; /* ... */
- int recordSize; /* size of tag record */
- int nTags; /* #tags defined so far */
+ size_t recordSize; /* size of tag record */
+ Tcl_Size nTags; /* #tags defined so far */
Tcl_HashTable tags; /* defined tags */
};
@@ -54,7 +53,7 @@ static void DeleteTag(Ttk_TagTable tagTable, Ttk_Tag tag)
Ttk_TagTable Ttk_CreateTagTable(
Tcl_Interp *interp, Tk_Window tkwin,
- Tk_OptionSpec optionSpecs[], int recordSize)
+ const Tk_OptionSpec *optionSpecs, size_t recordSize)
{
Ttk_TagTable tagTable = (Ttk_TagTable)ckalloc(sizeof(*tagTable));
tagTable->tkwin = tkwin;
@@ -81,6 +80,17 @@ void Ttk_DeleteTagTable(Ttk_TagTable tagTable)
ckfree(tagTable);
}
+void Ttk_DeleteTagFromTable(Ttk_TagTable tagTable, Ttk_Tag tag)
+{
+ Tcl_HashEntry *entryPtr;
+
+ entryPtr = Tcl_FindHashEntry(&tagTable->tags, tag->tagName);
+ if (entryPtr != NULL) {
+ DeleteTag(tagTable, tag);
+ Tcl_DeleteHashEntry(entryPtr);
+ }
+}
+
Ttk_Tag Ttk_GetTag(Ttk_TagTable tagTable, const char *tagName)
{
int isNew = 0;
@@ -116,7 +126,7 @@ Ttk_TagSet Ttk_GetTagSetFromObj(
{
Ttk_TagSet tagset = (Ttk_TagSet)ckalloc(sizeof(*tagset));
Tcl_Obj **objv;
- int i, objc;
+ Tcl_Size i, objc;
if (objPtr == NULL) {
tagset->tags = NULL;
@@ -130,7 +140,7 @@ Ttk_TagSet Ttk_GetTagSetFromObj(
}
tagset->tags = (Ttk_Tag *)ckalloc((objc+1) * sizeof(Ttk_Tag));
- for (i=0; i<objc; ++i) {
+ for (i = 0; i < objc; ++i) {
tagset->tags[i] = Ttk_GetTagFromObj(tagTable, objv[i]);
}
tagset->tags[i] = NULL;
@@ -145,7 +155,7 @@ Ttk_TagSet Ttk_GetTagSetFromObj(
Tcl_Obj *Ttk_NewTagSetObj(Ttk_TagSet tagset)
{
Tcl_Obj *result = Tcl_NewListObj(0,0);
- int i;
+ Tcl_Size i;
for (i = 0; i < tagset->nTags; ++i) {
Tcl_ListObjAppendElement(
@@ -164,7 +174,7 @@ void Ttk_FreeTagSet(Ttk_TagSet tagset)
*/
int Ttk_TagSetContains(Ttk_TagSet tagset, Ttk_Tag tag)
{
- int i;
+ Tcl_Size i;
for (i = 0; i < tagset->nTags; ++i) {
if (tagset->tags[i] == tag) {
return 1;
@@ -180,7 +190,7 @@ int Ttk_TagSetContains(Ttk_TagSet tagset, Ttk_Tag tag)
*/
int Ttk_TagSetAdd(Ttk_TagSet tagset, Ttk_Tag tag)
{
- int i;
+ Tcl_Size i;
for (i = 0; i < tagset->nTags; ++i) {
if (tagset->tags[i] == tag) {
return 0;
@@ -192,6 +202,36 @@ int Ttk_TagSetAdd(Ttk_TagSet tagset, Ttk_Tag tag)
return 1;
}
+/* Ttk_TagSetAddSet -- add a tag set to a tag set.
+ *
+ * Returns: 0 if tagset already contained tags,
+ * 1 if tagset was modified.
+ */
+int Ttk_TagSetAddSet(Ttk_TagSet tagset, Ttk_TagSet tagsetFrom)
+{
+ Tcl_Size i, j, total, nTags = tagset->nTags;
+ int result = 0, found;
+ Ttk_Tag tag;
+
+ total = tagsetFrom->nTags + tagset->nTags;
+ tagset->tags = (Ttk_Tag *)ckrealloc(tagset->tags,
+ (total)*sizeof(tagset->tags[0]));
+ for (j = 0; j < tagsetFrom->nTags; ++j) {
+ tag = tagsetFrom->tags[j];
+ found = 0;
+ for (i = 0; i < nTags; ++i) {
+ if (tagset->tags[i] == tag) {
+ found = 1;
+ break;
+ }
+ }
+ if (found) continue;
+ tagset->tags[tagset->nTags++] = tag;
+ result = 1;
+ }
+ return result;
+}
+
/* Ttk_TagSetRemove -- remove a tag from a tag set.
*
* Returns: 0 if tagset did not contain tag,
@@ -199,7 +239,7 @@ int Ttk_TagSetAdd(Ttk_TagSet tagset, Ttk_Tag tag)
*/
int Ttk_TagSetRemove(Ttk_TagSet tagset, Ttk_Tag tag)
{
- int i = 0, j = 0;
+ Tcl_Size i = 0, j = 0;
while (i < tagset->nTags) {
if ((tagset->tags[j] = tagset->tags[i]) != tag) {
++j;
@@ -249,7 +289,7 @@ int Ttk_ConfigureTag(
Tcl_Interp *interp,
Ttk_TagTable tagTable,
Ttk_Tag tag,
- int objc, Tcl_Obj *const objv[])
+ Tcl_Size objc, Tcl_Obj *const objv[])
{
return Tk_SetOptions(
interp, tag->tagRecord, tagTable->optionTable,
@@ -262,16 +302,27 @@ int Ttk_ConfigureTag(
#define OBJ_AT(record, offset) (*(Tcl_Obj**)(((char*)record)+offset))
+void Ttk_TagSetDefaults(Ttk_TagTable tagTable, Ttk_Style style, void *record)
+{
+ const Tk_OptionSpec *optionSpec = tagTable->optionSpecs;
+ memset(record, 0, tagTable->recordSize);
+
+ while (optionSpec->type != TK_OPTION_END) {
+ int offset = optionSpec->objOffset;
+ const char *optionName = optionSpec->optionName;
+ OBJ_AT(record, offset) = Ttk_StyleDefault(style, optionName);
+ ++optionSpec;
+ }
+}
+
void Ttk_TagSetValues(Ttk_TagTable tagTable, Ttk_TagSet tagSet, void *record)
{
const int LOWEST_PRIORITY = 0x7FFFFFFF;
- int i, j;
-
- memset(record, 0, tagTable->recordSize);
+ Tcl_Size i, j;
for (i = 0; tagTable->optionSpecs[i].type != TK_OPTION_END; ++i) {
- Tk_OptionSpec *optionSpec = tagTable->optionSpecs + i;
- int offset = optionSpec->objOffset;
+ const Tk_OptionSpec *optionSpec = tagTable->optionSpecs + i;
+ Tcl_Size offset = optionSpec->objOffset;
int prio = LOWEST_PRIORITY;
for (j = 0; j < tagSet->nTags; ++j) {
@@ -287,16 +338,14 @@ void Ttk_TagSetValues(Ttk_TagTable tagTable, Ttk_TagSet tagSet, void *record)
void Ttk_TagSetApplyStyle(
Ttk_TagTable tagTable, Ttk_Style style, Ttk_State state, void *record)
{
- Tk_OptionSpec *optionSpec = tagTable->optionSpecs;
+ const Tk_OptionSpec *optionSpec = tagTable->optionSpecs;
while (optionSpec->type != TK_OPTION_END) {
- int offset = optionSpec->objOffset;
+ Tcl_Size offset = optionSpec->objOffset;
const char *optionName = optionSpec->optionName;
Tcl_Obj *val = Ttk_StyleMap(style, optionName, state);
if (val) {
OBJ_AT(record, offset) = val;
- } else if (OBJ_AT(record, offset) == 0) {
- OBJ_AT(record, offset) = Ttk_StyleDefault(style, optionName);
}
++optionSpec;
}
diff --git a/generic/ttk/ttkTheme.c b/generic/ttk/ttkTheme.c
index 730de5d..c60dd13 100644
--- a/generic/ttk/ttkTheme.c
+++ b/generic/ttk/ttkTheme.c
@@ -3,8 +3,8 @@
*
* This file implements the widget styles and themes support.
*
- * Copyright (c) 2002 Frederic Bonnet
- * Copyright (c) 2003 Joe English
+ * Copyright © 2002 Frederic Bonnet
+ * Copyright © 2003 Joe English
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -95,7 +95,7 @@ Tcl_Obj *Ttk_StyleMap(Ttk_Style style, const char *optionName, Ttk_State state)
/*
* Ttk_StyleDefault --
- * Look up default resource setting the in the specified style.
+ * Look up default resource setting in the specified style.
*/
Tcl_Obj *Ttk_StyleDefault(Ttk_Style style, const char *optionName)
{
@@ -117,7 +117,7 @@ typedef const Tk_OptionSpec **OptionMap;
struct Ttk_ElementClass_ {
const char *name; /* Points to hash table key */
- Ttk_ElementSpec *specPtr; /* Template provided during registration. */
+ const Ttk_ElementSpec *specPtr; /* Template provided during registration. */
void *clientData; /* Client data passed in at registration time */
void *elementRecord; /* Scratch buffer for element record storage */
int nResources; /* #Element options */
@@ -181,7 +181,7 @@ BuildOptionMap(Ttk_ElementClass *elementClass, Tk_OptionTable optionTable)
int i;
for (i = 0; i < elementClass->nResources; ++i) {
- Ttk_ElementOptionSpec *e = elementClass->specPtr->options+i;
+ const Ttk_ElementOptionSpec *e = elementClass->specPtr->options+i;
optionMap[i] = TTKGetOptionSpec(e->optionName, optionTable, e->type);
}
@@ -216,7 +216,7 @@ GetOptionMap(Ttk_ElementClass *elementClass, Tk_OptionTable optionTable)
* from the specified element specification.
*/
static Ttk_ElementClass *
-NewElementClass(const char *name, Ttk_ElementSpec *specPtr,void *clientData)
+NewElementClass(const char *name, const Ttk_ElementSpec *specPtr, void *clientData)
{
Ttk_ElementClass *elementClass = (Ttk_ElementClass *)ckalloc(sizeof(Ttk_ElementClass));
int i;
@@ -407,7 +407,7 @@ typedef struct
* Cleanup procedure for StylePackageData.
*/
static void Ttk_StylePkgFree(
- ClientData clientData,
+ void *clientData,
TCL_UNUSED(Tcl_Interp *))
{
StylePackageData *pkgPtr = (StylePackageData *)clientData;
@@ -475,7 +475,7 @@ static StylePackageData *GetStylePackageData(Tcl_Interp *interp)
*
*/
void Ttk_RegisterCleanup(
- Tcl_Interp *interp, ClientData clientData, Ttk_CleanupProc *cleanupProc)
+ Tcl_Interp *interp, void *clientData, Ttk_CleanupProc *cleanupProc)
{
StylePackageData *pkgPtr = GetStylePackageData(interp);
Cleanup *cleanup = (Cleanup *)ckalloc(sizeof(*cleanup));
@@ -498,7 +498,7 @@ void Ttk_RegisterCleanup(
* the widget hierarchy, so this is done by evaluating a Tcl script.
*/
-static void ThemeChangedProc(ClientData clientData)
+static void ThemeChangedProc(void *clientData)
{
static char ThemeChangedScript[] = "ttk::ThemeChanged";
StylePackageData *pkgPtr = (StylePackageData *)clientData;
@@ -516,6 +516,8 @@ static void ThemeChangedProc(ClientData clientData)
*/
static void ThemeChanged(StylePackageData *pkgPtr)
{
+ TtkSetBlinkCursorTimes(pkgPtr->interp);
+
if (!pkgPtr->themeChangePending) {
Tcl_DoWhenIdle(ThemeChangedProc, pkgPtr);
pkgPtr->themeChangePending = 1;
@@ -839,7 +841,7 @@ int Ttk_RegisterElementFactory(
static int Ttk_CloneElement(
Tcl_Interp *interp, TCL_UNUSED(void *),
Ttk_Theme theme, const char *elementName,
- int objc, Tcl_Obj *const objv[])
+ Tcl_Size objc, Tcl_Obj *const objv[])
{
Ttk_Theme fromTheme;
Ttk_ElementClass *fromElement;
@@ -882,7 +884,7 @@ Ttk_ElementClass *Ttk_RegisterElement(
Tcl_Interp *interp, /* Where to leave error messages */
Ttk_Theme theme, /* Style engine providing the implementation. */
const char *name, /* Name of new element */
- Ttk_ElementSpec *specPtr, /* Static template information */
+ const Ttk_ElementSpec *specPtr, /* Static template information */
void *clientData) /* application-specific data */
{
Ttk_ElementClass *elementClass;
@@ -923,7 +925,7 @@ Ttk_ElementClass *Ttk_RegisterElement(
* Register a new element.
*/
int Ttk_RegisterElementSpec(Ttk_Theme theme,
- const char *name, Ttk_ElementSpec *specPtr, void *clientData)
+ const char *name, const Ttk_ElementSpec *specPtr, void *clientData)
{
return Ttk_RegisterElement(NULL, theme, name, specPtr, clientData)
? TCL_OK : TCL_ERROR;
@@ -987,16 +989,16 @@ static
int InitializeElementRecord(
Ttk_ElementClass *eclass, /* Element instance to initialize */
Ttk_Style style, /* Style table */
- char *widgetRecord, /* Source of widget option values */
+ void *widgetRecord, /* Source of widget option values */
Tk_OptionTable optionTable, /* Option table describing widget record */
Tk_Window tkwin, /* Corresponding window */
Ttk_State state) /* Widget or element state */
{
- char *elementRecord = eclass->elementRecord;
+ void *elementRecord = eclass->elementRecord;
OptionMap optionMap = GetOptionMap(eclass,optionTable);
int nResources = eclass->nResources;
Ttk_ResourceCache cache = style->cache;
- Ttk_ElementOptionSpec *elementOption = eclass->specPtr->options;
+ const Ttk_ElementOptionSpec *elementOption = eclass->specPtr->options;
int i;
for (i=0; i<nResources; ++i, ++elementOption) {
@@ -1081,7 +1083,7 @@ void
Ttk_ElementSize(
Ttk_ElementClass *eclass, /* Element to query */
Ttk_Style style, /* Style settings */
- char *recordPtr, /* The widget record. */
+ void *recordPtr, /* The widget record. */
Tk_OptionTable optionTable, /* Description of widget record */
Tk_Window tkwin, /* The widget window. */
Ttk_State state, /* Current widget state */
@@ -1111,7 +1113,7 @@ void
Ttk_DrawElement(
Ttk_ElementClass *eclass, /* Element instance */
Ttk_Style style, /* Style settings */
- char *recordPtr, /* The widget record. */
+ void *recordPtr, /* The widget record. */
Tk_OptionTable optionTable, /* Description of option table */
Tk_Window tkwin, /* The widget window. */
Drawable d, /* Where to draw element. */
@@ -1188,9 +1190,9 @@ static Tcl_Obj* HashTableToDict(Tcl_HashTable *ht)
*/
static int
StyleMapCmd(
- ClientData clientData, /* StylePackageData pointer */
+ void *clientData, /* StylePackageData pointer */
Tcl_Interp *interp, /* Current interpreter */
- int objc, /* Number of arguments */
+ Tcl_Size objc, /* Number of arguments */
Tcl_Obj *const objv[]) /* Argument objects */
{
StylePackageData *pkgPtr = (StylePackageData *)clientData;
@@ -1255,7 +1257,7 @@ usage:
/* + style configure $style -option ?value...
*/
static int StyleConfigureCmd(
- ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *clientData, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
StylePackageData *pkgPtr = (StylePackageData *)clientData;
Ttk_Theme theme = pkgPtr->currentTheme;
@@ -1272,10 +1274,10 @@ usage:
styleName = Tcl_GetString(objv[2]);
stylePtr = Ttk_GetStyle(theme, styleName);
- if (objc == 3) { /* style default $styleName */
+ if (objc == 3) { /* style configure $styleName */
Tcl_SetObjResult(interp, HashTableToDict(&stylePtr->defaultsTable));
return TCL_OK;
- } else if (objc == 4) { /* style default $styleName -option */
+ } else if (objc == 4) { /* style configure $styleName -option */
const char *optionName = Tcl_GetString(objv[3]);
Tcl_HashEntry *entryPtr =
Tcl_FindHashEntry(&stylePtr->defaultsTable, optionName);
@@ -1310,7 +1312,7 @@ usage:
/* + style lookup $style -option ?statespec? ?defaultValue?
*/
static int StyleLookupCmd(
- ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *clientData, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
StylePackageData *pkgPtr = (StylePackageData *)clientData;
Ttk_Theme theme = pkgPtr->currentTheme;
@@ -1325,9 +1327,7 @@ static int StyleLookupCmd(
}
style = Ttk_GetStyle(theme, Tcl_GetString(objv[2]));
- if (!style) {
- return TCL_ERROR;
- }
+
optionName = Tcl_GetString(objv[3]);
if (objc >= 5) {
@@ -1352,7 +1352,7 @@ static int StyleLookupCmd(
}
static int StyleThemeCurrentCmd(
- ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[])
+ void *clientData, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj * const objv[])
{
StylePackageData *pkgPtr = (StylePackageData *)clientData;
Tcl_HashSearch search;
@@ -1388,7 +1388,7 @@ static int StyleThemeCurrentCmd(
/* + style theme create name ?-parent $theme? ?-settings { script }?
*/
static int StyleThemeCreateCmd(
- ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *clientData, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
StylePackageData *pkgPtr = (StylePackageData *)clientData;
static const char *const optStrings[] =
@@ -1452,10 +1452,10 @@ static int StyleThemeCreateCmd(
* Return list of registered themes.
*/
static int StyleThemeNamesCmd(
- ClientData clientData,
+ void *clientData,
Tcl_Interp *interp,
- TCL_UNUSED(int),
- TCL_UNUSED(Tcl_Obj *const *))
+ TCL_UNUSED(Tcl_Size), /* objc */
+ TCL_UNUSED(Tcl_Obj *const *)) /* objv */
{
StylePackageData *pkgPtr = (StylePackageData *)clientData;
@@ -1469,9 +1469,9 @@ static int StyleThemeNamesCmd(
*/
static int
StyleThemeSettingsCmd(
- ClientData clientData, /* StylePackageData pointer */
+ void *clientData, /* StylePackageData pointer */
Tcl_Interp *interp, /* Current interpreter */
- int objc, /* Number of arguments */
+ Tcl_Size objc, /* Number of arguments */
Tcl_Obj *const objv[]) /* Argument objects */
{
StylePackageData *pkgPtr = (StylePackageData *)clientData;
@@ -1498,7 +1498,7 @@ StyleThemeSettingsCmd(
/* + style element create name type ? ...args ?
*/
static int StyleElementCreateCmd(
- ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *clientData, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
StylePackageData *pkgPtr = (StylePackageData *)clientData;
Ttk_Theme theme = pkgPtr->currentTheme;
@@ -1533,7 +1533,7 @@ static int StyleElementCreateCmd(
* Return a list of elements defined in the current theme.
*/
static int StyleElementNamesCmd(
- ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *clientData, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
StylePackageData *pkgPtr = (StylePackageData *)clientData;
Ttk_Theme theme = pkgPtr->currentTheme;
@@ -1549,7 +1549,7 @@ static int StyleElementNamesCmd(
* Return list of element options for specified element
*/
static int StyleElementOptionsCmd(
- ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *clientData, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
StylePackageData *pkgPtr = (StylePackageData *)clientData;
Ttk_Theme theme = pkgPtr->currentTheme;
@@ -1564,8 +1564,8 @@ static int StyleElementOptionsCmd(
elementName = Tcl_GetString(objv[3]);
elementClass = Ttk_GetElement(theme, elementName);
if (elementClass) {
- Ttk_ElementSpec *specPtr = elementClass->specPtr;
- Ttk_ElementOptionSpec *option = specPtr->options;
+ const Ttk_ElementSpec *specPtr = elementClass->specPtr;
+ const Ttk_ElementOptionSpec *option = specPtr->options;
Tcl_Obj *result = Tcl_NewListObj(0,0);
while (option->optionName) {
@@ -1587,7 +1587,7 @@ static int StyleElementOptionsCmd(
/* + style layout name ?spec?
*/
static int StyleLayoutCmd(
- ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *clientData, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
StylePackageData *pkgPtr = (StylePackageData *)clientData;
Ttk_Theme theme = pkgPtr->currentTheme;
@@ -1622,14 +1622,42 @@ static int StyleLayoutCmd(
return TCL_OK;
}
+/* + style theme styles ?$theme? --
+ * Return list of styles available in $theme.
+ * Use the current theme if $theme is omitted.
+ */
+static int StyleThemeStylesCmd(
+ TCL_UNUSED(void *),
+ Tcl_Interp *interp,
+ Tcl_Size objc,
+ Tcl_Obj *const objv[])
+{
+ Ttk_Theme themePtr;
+
+ if (objc < 3 || objc > 4) {
+ Tcl_WrongNumArgs(interp, 3, objv, "?theme?");
+ return TCL_ERROR;
+ }
+
+ if (objc == 3) {
+ themePtr = Ttk_GetCurrentTheme(interp);
+ } else {
+ themePtr = Ttk_GetTheme(interp, Tcl_GetString(objv[3]));
+ }
+ if (!themePtr)
+ return TCL_ERROR;
+
+ return TtkEnumerateHashTable(interp, &themePtr->styleTable);
+}
+
/* + style theme use $theme --
* Sets the current theme to $theme
*/
static int
StyleThemeUseCmd(
- ClientData clientData, /* StylePackageData pointer */
+ void *clientData, /* StylePackageData pointer */
Tcl_Interp *interp, /* Current interpreter */
- int objc, /* Number of arguments */
+ Tcl_Size objc, /* Number of arguments */
Tcl_Obj *const objv[]) /* Argument objects */
{
StylePackageData *pkgPtr = (StylePackageData *)clientData;
@@ -1661,6 +1689,7 @@ static const Ttk_Ensemble StyleThemeEnsemble[] = {
{ "create", StyleThemeCreateCmd, 0 },
{ "names", StyleThemeNamesCmd, 0 },
{ "settings", StyleThemeSettingsCmd, 0 },
+ { "styles", StyleThemeStylesCmd, 0 },
{ "use", StyleThemeUseCmd, 0 },
{ NULL, 0, 0 }
};
@@ -1684,7 +1713,7 @@ static const Ttk_Ensemble StyleEnsemble[] = {
static int
StyleObjCmd(
- ClientData clientData, /* StylePackageData pointer */
+ void *clientData, /* StylePackageData pointer */
Tcl_Interp *interp, /* Current interpreter */
int objc, /* Number of arguments */
Tcl_Obj *const objv[]) /* Argument objects */
@@ -1694,8 +1723,8 @@ StyleObjCmd(
MODULE_SCOPE int
Ttk_InvokeEnsemble( /* Run an ensemble command */
- const Ttk_Ensemble *ensemble, int cmdIndex,
- void *clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ const Ttk_Ensemble *ensemble, Tcl_Size cmdIndex,
+ void *clientData, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
while (cmdIndex < objc) {
int index;
diff --git a/generic/ttk/ttkTheme.h b/generic/ttk/ttkTheme.h
index c927209..a148fd0 100644
--- a/generic/ttk/ttkTheme.h
+++ b/generic/ttk/ttkTheme.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003 Joe English. Freely redistributable.
+ * Copyright © 2003 Joe English. Freely redistributable.
*
* Declarations for Tk theme engine.
*/
@@ -75,17 +75,11 @@ typedef struct
#define Ttk_ModifyState(state, spec) \
(((state) & ~(spec)->offbits) | (spec)->onbits)
-TTKAPI int Ttk_GetStateSpecFromObj(Tcl_Interp *, Tcl_Obj *, Ttk_StateSpec *);
-TTKAPI Tcl_Obj *Ttk_NewStateSpecObj(unsigned int onbits,unsigned int offbits);
-
/*------------------------------------------------------------------------
* +++ State maps and state tables.
*/
typedef Tcl_Obj *Ttk_StateMap;
-TTKAPI Ttk_StateMap Ttk_GetStateMapFromObj(Tcl_Interp *, Tcl_Obj *);
-TTKAPI Tcl_Obj *Ttk_StateMapLookup(Tcl_Interp*, Ttk_StateMap, Ttk_State);
-
/*
* Table for looking up an integer index based on widget state:
*/
@@ -96,8 +90,6 @@ typedef struct
unsigned int offBits; /* Bits which must be cleared */
} Ttk_StateTable;
-TTKAPI int Ttk_StateTableLookup(Ttk_StateTable map[], Ttk_State);
-
/*------------------------------------------------------------------------
* +++ Padding.
* Used to represent internal padding and borders.
@@ -110,14 +102,6 @@ typedef struct
short bottom;
} Ttk_Padding;
-TTKAPI int Ttk_GetPaddingFromObj(Tcl_Interp*,Tk_Window,Tcl_Obj*,Ttk_Padding*);
-TTKAPI int Ttk_GetBorderFromObj(Tcl_Interp*,Tcl_Obj*,Ttk_Padding*);
-
-TTKAPI Ttk_Padding Ttk_MakePadding(short l, short t, short r, short b);
-TTKAPI Ttk_Padding Ttk_UniformPadding(short borderWidth);
-TTKAPI Ttk_Padding Ttk_AddPadding(Ttk_Padding, Ttk_Padding);
-TTKAPI Ttk_Padding Ttk_RelievePadding(Ttk_Padding, int relief, int n);
-
#define Ttk_PaddingWidth(p) ((p).left + (p).right)
#define Ttk_PaddingHeight(p) ((p).top + (p).bottom)
@@ -136,9 +120,6 @@ typedef struct /* Hey, this is an XRectangle! */
int height;
} Ttk_Box;
-TTKAPI Ttk_Box Ttk_MakeBox(int x, int y, int width, int height);
-TTKAPI int Ttk_BoxContains(Ttk_Box, int x, int y);
-
#define Ttk_WinBox(tkwin) Ttk_MakeBox(0,0,Tk_Width(tkwin),Tk_Height(tkwin))
/*------------------------------------------------------------------------
@@ -165,7 +146,6 @@ typedef unsigned int Ttk_Sticky;
#define TTK_FILL_Y (0xC) /* -sticky ns */
#define TTK_FILL_BOTH (0xF) /* -sticky nswe */
-TTKAPI int Ttk_GetStickyFromObj(Tcl_Interp *, Tcl_Obj *, Ttk_Sticky *);
TTKAPI Tcl_Obj *Ttk_NewStickyObj(Ttk_Sticky);
/*
@@ -192,12 +172,6 @@ typedef unsigned int Ttk_PositionSpec; /* See below */
#define _TTK_MASK_STICK (0x0F) /* See Ttk_UnparseLayout() */
#define _TTK_MASK_PACK (0xF0) /* See Ttk_UnparseLayout(), packStrings */
-TTKAPI Ttk_Box Ttk_PackBox(Ttk_Box *cavity, int w, int h, Ttk_Side side);
-TTKAPI Ttk_Box Ttk_StickBox(Ttk_Box parcel, int w, int h, Ttk_Sticky sticky);
-TTKAPI Ttk_Box Ttk_AnchorBox(Ttk_Box parcel, int w, int h, Tk_Anchor anchor);
-TTKAPI Ttk_Box Ttk_PadBox(Ttk_Box b, Ttk_Padding p);
-TTKAPI Ttk_Box Ttk_ExpandBox(Ttk_Box b, Ttk_Padding p);
-TTKAPI Ttk_Box Ttk_PlaceBox(Ttk_Box *cavity, int w,int h, Ttk_Side,Ttk_Sticky);
TTKAPI Ttk_Box Ttk_PositionBox(Ttk_Box *cavity, int w, int h, Ttk_PositionSpec);
/*------------------------------------------------------------------------
@@ -211,21 +185,12 @@ typedef struct Ttk_Layout_ *Ttk_Layout;
typedef struct Ttk_LayoutNode_ *Ttk_Element;
typedef struct Ttk_Style_ *Ttk_Style;
-TTKAPI Ttk_Theme Ttk_GetTheme(Tcl_Interp *interp, const char *name);
-TTKAPI Ttk_Theme Ttk_GetDefaultTheme(Tcl_Interp *interp);
-TTKAPI Ttk_Theme Ttk_GetCurrentTheme(Tcl_Interp *interp);
-
-TTKAPI Ttk_Theme Ttk_CreateTheme(
- Tcl_Interp *interp, const char *name, Ttk_Theme parent);
-
typedef int (Ttk_ThemeEnabledProc)(Ttk_Theme theme, void *clientData);
MODULE_SCOPE void Ttk_SetThemeEnabledProc(Ttk_Theme, Ttk_ThemeEnabledProc, void *);
MODULE_SCOPE int Ttk_UseTheme(Tcl_Interp *, Ttk_Theme);
typedef void (Ttk_CleanupProc)(void *clientData);
-TTKAPI void Ttk_RegisterCleanup(
- Tcl_Interp *interp, void *deleteData, Ttk_CleanupProc *cleanupProc);
/*------------------------------------------------------------------------
* +++ Elements.
@@ -242,7 +207,7 @@ typedef struct Ttk_ElementOptionSpec
{
const char *optionName; /* Command-line name of the widget option */
Tk_OptionType type; /* Accepted option types */
- int offset; /* Offset of Tcl_Obj* field in element record */
+ Tcl_Size offset; /* Offset of Tcl_Obj* field in element record */
const char *defaultValue; /* Default value to used if resource missing */
} Ttk_ElementOptionSpec;
@@ -251,21 +216,14 @@ typedef struct Ttk_ElementOptionSpec
typedef struct Ttk_ElementSpec {
enum TTKStyleVersion2 version; /* Version of the style support. */
size_t elementSize; /* Size of element record */
- Ttk_ElementOptionSpec *options; /* List of options, NULL-terminated */
+ const Ttk_ElementOptionSpec *options; /* List of options, NULL-terminated */
Ttk_ElementSizeProc *size; /* Compute min size and padding */
Ttk_ElementDrawProc *draw; /* Draw the element */
} Ttk_ElementSpec;
-TTKAPI Ttk_ElementClass *Ttk_RegisterElement(
- Tcl_Interp *interp, Ttk_Theme theme, const char *elementName,
- Ttk_ElementSpec *, void *clientData);
-
typedef int (*Ttk_ElementFactory)
(Tcl_Interp *, void *clientData,
- Ttk_Theme, const char *elementName, int objc, Tcl_Obj *const objv[]);
-
-TTKAPI int Ttk_RegisterElementFactory(
- Tcl_Interp *, const char *name, Ttk_ElementFactory, void *clientData);
+ Ttk_Theme, const char *elementName, Tcl_Size objc, Tcl_Obj *const objv[]);
/*
* Null element implementation:
@@ -276,11 +234,9 @@ typedef struct {
Tcl_Obj *unused;
} NullElement;
-MODULE_SCOPE void TtkNullElementSize
- (void *, void *, Tk_Window, int *, int *, Ttk_Padding *);
-MODULE_SCOPE void TtkNullElementDraw
- (void *, void *, Tk_Window, Drawable, Ttk_Box, Ttk_State);
-MODULE_SCOPE Ttk_ElementOptionSpec TtkNullElementOptions[];
+MODULE_SCOPE Ttk_ElementSizeProc TtkNullElementSize;
+MODULE_SCOPE Ttk_ElementDrawProc TtkNullElementDraw;
+MODULE_SCOPE const Ttk_ElementOptionSpec TtkNullElementOptions[];
MODULE_SCOPE Ttk_ElementSpec ttkNullElementSpec;
/*------------------------------------------------------------------------
@@ -307,9 +263,6 @@ typedef struct {
#define TTK_BEGIN_LAYOUT(name) static TTKLayoutInstruction name[] = {
#define TTK_END_LAYOUT { 0, _TTK_LAYOUT_END } };
-TTKAPI void Ttk_RegisterLayout(
- Ttk_Theme theme, const char *className, Ttk_LayoutSpec layoutSpec);
-
TTKAPI void Ttk_RegisterLayouts(
Ttk_Theme theme, Ttk_LayoutSpec layoutTable);
@@ -345,6 +298,7 @@ MODULE_SCOPE Ttk_Padding Ttk_LayoutNodeInternalPadding(Ttk_Layout,Ttk_Element);
MODULE_SCOPE void Ttk_LayoutNodeReqSize(Ttk_Layout, Ttk_Element, int *w, int *h);
MODULE_SCOPE void Ttk_PlaceElement(Ttk_Layout, Ttk_Element, Ttk_Box);
+MODULE_SCOPE void Ttk_AnchorElement(Ttk_Element node, Tk_Anchor anchor);
MODULE_SCOPE void Ttk_ChangeElementState(Ttk_Element,unsigned set,unsigned clr);
MODULE_SCOPE Tcl_Obj *Ttk_QueryOption(Ttk_Layout, const char *, Ttk_State);
@@ -377,7 +331,7 @@ MODULE_SCOPE void Ttk_RegisterNamedColor(Ttk_ResourceCache, const char *, XColor
typedef struct TtkImageSpec Ttk_ImageSpec;
TTKAPI Ttk_ImageSpec *TtkGetImageSpec(Tcl_Interp *, Tk_Window, Tcl_Obj *);
TTKAPI Ttk_ImageSpec *TtkGetImageSpecEx(Tcl_Interp *, Tk_Window, Tcl_Obj *,
- Tk_ImageChangedProc *, ClientData);
+ Tk_ImageChangedProc *, void *);
TTKAPI void TtkFreeImageSpec(Ttk_ImageSpec *);
TTKAPI Tk_Image TtkSelectImage(Ttk_ImageSpec *, Tk_Window, Ttk_State);
@@ -387,12 +341,12 @@ TTKAPI Tk_Image TtkSelectImage(Ttk_ImageSpec *, Tk_Window, Ttk_State);
*/
typedef enum /* -default option values */
{
- TTK_BUTTON_DEFAULT_NORMAL, /* widget defaultable */
TTK_BUTTON_DEFAULT_ACTIVE, /* currently the default widget */
- TTK_BUTTON_DEFAULT_DISABLED /* not defaultable */
+ TTK_BUTTON_DEFAULT_DISABLED, /* not defaultable */
+ TTK_BUTTON_DEFAULT_NORMAL /* widget defaultable */
} Ttk_ButtonDefaultState;
-TTKAPI int Ttk_GetButtonDefaultStateFromObj(Tcl_Interp *, Tcl_Obj *, int *);
+TTKAPI int Ttk_GetButtonDefaultStateFromObj(Tcl_Interp *, Tcl_Obj *, Ttk_ButtonDefaultState *);
typedef enum /* -compound option values */
{
@@ -406,26 +360,29 @@ typedef enum /* -compound option values */
TTK_COMPOUND_RIGHT /* image to right of text */
} Ttk_Compound;
-TTKAPI int Ttk_GetCompoundFromObj(Tcl_Interp *, Tcl_Obj *, int *);
+TTKAPI int Ttk_GetCompoundFromObj(Tcl_Interp *, Tcl_Obj *, Ttk_Compound *);
typedef enum { /* -orient option values */
TTK_ORIENT_HORIZONTAL,
TTK_ORIENT_VERTICAL
} Ttk_Orient;
+MODULE_SCOPE int TtkGetOrientFromObj(Tcl_Interp *interp,
+ Tcl_Obj *objPtr, Ttk_Orient *orient);
+
/*------------------------------------------------------------------------
* +++ Utilities.
*/
typedef struct TtkEnsemble {
const char *name; /* subcommand name */
- Tcl_ObjCmdProc *command; /* subcommand implementation, OR: */
+ Tcl_ObjCmdProc2 *command; /* subcommand implementation, OR: */
const struct TtkEnsemble *ensemble; /* subcommand ensemble */
} Ttk_Ensemble;
MODULE_SCOPE int Ttk_InvokeEnsemble( /* Run an ensemble command */
- const Ttk_Ensemble *commands, int cmdIndex,
- void *clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[]);
+ const Ttk_Ensemble *commands, Tcl_Size cmdIndex,
+ void *clientData, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[]);
MODULE_SCOPE int TtkEnumerateHashTable(Tcl_Interp *, Tcl_HashTable *);
diff --git a/generic/ttk/ttkThemeInt.h b/generic/ttk/ttkThemeInt.h
index cd95ebe..37e9c83 100644
--- a/generic/ttk/ttkThemeInt.h
+++ b/generic/ttk/ttkThemeInt.h
@@ -1,7 +1,7 @@
/*
* Theme engine: private definitions.
*
- * Copyright (c) 2004 Joe English. Freely redistributable.
+ * Copyright © 2004 Joe English. Freely redistributable.
*/
#ifndef _TTKTHEMEINT
@@ -9,17 +9,26 @@
#include "ttkTheme.h"
+/*------------------------------------------------------------------------
+ * +++ Widget states (internal).
+ */
+
+#define TTK_STATE_OPEN (1<<16)
+#define TTK_STATE_LEAF (1<<17)
+#define TTK_STATE_FIRST (1<<18)
+#define TTK_STATE_LAST (1<<19)
+
typedef struct Ttk_TemplateNode_ Ttk_TemplateNode, *Ttk_LayoutTemplate;
MODULE_SCOPE Ttk_ElementClass *Ttk_GetElement(Ttk_Theme, const char *name);
MODULE_SCOPE const char *Ttk_ElementClassName(Ttk_ElementClass *);
MODULE_SCOPE void Ttk_ElementSize(
- Ttk_ElementClass *, Ttk_Style, char *recordPtr, Tk_OptionTable,
+ Ttk_ElementClass *, Ttk_Style, void *recordPtr, Tk_OptionTable,
Tk_Window tkwin, Ttk_State state,
int *widthPtr, int *heightPtr, Ttk_Padding*);
MODULE_SCOPE void Ttk_DrawElement(
- Ttk_ElementClass *, Ttk_Style, char *recordPtr, Tk_OptionTable,
+ Ttk_ElementClass *, Ttk_Style, void *recordPtr, Tk_OptionTable,
Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state);
MODULE_SCOPE Tcl_Obj *Ttk_QueryStyle(
@@ -39,6 +48,14 @@ MODULE_SCOPE Ttk_LayoutTemplate Ttk_FindLayoutTemplate(
MODULE_SCOPE const char *Ttk_StyleName(Ttk_Style);
+MODULE_SCOPE void TtkSetBlinkCursorTimes(Tcl_Interp* interp);
+
MODULE_SCOPE int TtkBoxEqual(Ttk_Box, Ttk_Box);
+#if !defined(TK_NO_DEPRECATED) && (TCL_MAJOR_VERSION < 9)
+# define TTK_OPTION_UNDERLINE_DEF(type, field) "-1", offsetof(type, field), TCL_INDEX_NONE, 0, NULL
+#else
+# define TTK_OPTION_UNDERLINE_DEF(type, field) NULL, offsetof(type, field), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL
+#endif
+
#endif /* _TTKTHEMEINT */
diff --git a/generic/ttk/ttkTrack.c b/generic/ttk/ttkTrack.c
index fa2a7e0..332a3f6 100644
--- a/generic/ttk/ttkTrack.c
+++ b/generic/ttk/ttkTrack.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, Joe English
+ * Copyright © 2004, Joe English
*
* TtkTrackElementState() -- helper routine for widgets
* like scrollbars in which individual elements may
@@ -16,11 +16,11 @@
* and is normally set to the ACTIVE state unless another element
* is currently being pressed.
*
- * The active element becomes "pressed" on <ButtonPress> events,
+ * The active element becomes "pressed" on <Button> events,
* and remains "active" and "pressed" until the corresponding
* <ButtonRelease> event.
*
- * TODO: Handle "chords" properly (e.g., <B1-ButtonPress-2>)
+ * TODO: Handle "chords" properly (e.g., <B1-Button-2>)
*/
#include "tkInt.h"
@@ -116,9 +116,9 @@ static const unsigned ElementStateMask =
;
static void
-ElementStateEventProc(ClientData clientData, XEvent *ev)
+ElementStateEventProc(void *clientData, XEvent *ev)
{
- ElementStateTracker *es = clientData;
+ ElementStateTracker *es = (ElementStateTracker *)clientData;
Ttk_Layout layout = es->corePtr->layout;
Ttk_Element element;
@@ -173,7 +173,7 @@ ElementStateEventProc(ClientData clientData, XEvent *ev)
void TtkTrackElementState(WidgetCore *corePtr)
{
- ElementStateTracker *es = ckalloc(sizeof(*es));
+ ElementStateTracker *es = (ElementStateTracker *)ckalloc(sizeof(*es));
es->corePtr = corePtr;
es->tracking = 0;
es->activeElement = es->pressedElement = 0;
diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c
index 944115d..884c1f3 100644
--- a/generic/ttk/ttkTreeview.c
+++ b/generic/ttk/ttkTreeview.c
@@ -1,11 +1,11 @@
/*
- * Copyright (c) 2004, Joe English
+ * Copyright © 2004, Joe English
*
* ttk::treeview widget implementation.
*/
#include "tkInt.h"
-#include "ttkTheme.h"
+#include "ttkThemeInt.h"
#include "ttkWidget.h"
#ifdef _WIN32
@@ -13,16 +13,16 @@
#endif
#define DEF_TREE_ROWS "10"
+#define DEF_TITLECOLUMNS "0"
+#define DEF_TITLEITEMS "0"
+#define DEF_STRIPED "0"
#define DEF_COLWIDTH "200"
#define DEF_MINWIDTH "20"
-static const int DEFAULT_ROWHEIGHT = 20;
+static const Tk_Anchor DEFAULT_IMAGEANCHOR = TK_ANCHOR_W;
static const int DEFAULT_INDENT = 20;
static const int HALO = 4; /* heading separator */
-#define TTK_STATE_OPEN TTK_STATE_USER1
-#define TTK_STATE_LEAF TTK_STATE_USER2
-
#define STATE_CHANGED (0x100) /* item state option changed */
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
@@ -54,37 +54,60 @@ struct TreeItemRec {
Tcl_Obj *valuesObj;
Tcl_Obj *openObj;
Tcl_Obj *tagsObj;
+ Tcl_Obj *selObj;
+ Tcl_Obj *imageAnchorObj;
+ int hidden;
+ int height; /* Height is in number of row heights */
+
+ Ttk_TagSet *cellTagSets;
+ Tcl_Size nTagSets;
/*
* Derived resources:
*/
Ttk_TagSet tagset;
Ttk_ImageSpec *imagespec;
+ int itemPos; /* Counting items */
+ int visiblePos; /* Counting visible items */
+ int rowPos; /* Counting rows (visible physical space) */
};
#define ITEM_OPTION_TAGS_CHANGED 0x100
#define ITEM_OPTION_IMAGE_CHANGED 0x200
-static Tk_OptionSpec ItemOptionSpecs[] = {
+static const Tk_OptionSpec ItemOptionSpecs[] = {
{TK_OPTION_STRING, "-text", "text", "Text",
- "", Tk_Offset(TreeItem,textObj), -1,
+ "", offsetof(TreeItem,textObj), TCL_INDEX_NONE,
+ 0,0,0 },
+ {TK_OPTION_INT, "-height", "height", "Height",
+ "1", TCL_INDEX_NONE, offsetof(TreeItem,height),
+ 0,0,0 },
+ {TK_OPTION_BOOLEAN, "-hidden", "hidden", "Hidden",
+ "0", TCL_INDEX_NONE, offsetof(TreeItem,hidden),
0,0,0 },
{TK_OPTION_STRING, "-image", "image", "Image",
- NULL, Tk_Offset(TreeItem,imageObj), -1,
+ NULL, offsetof(TreeItem,imageObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,ITEM_OPTION_IMAGE_CHANGED },
+ {TK_OPTION_ANCHOR, "-imageanchor", "imageAnchor", "ImageAnchor",
+ NULL, offsetof(TreeItem,imageAnchorObj), TCL_INDEX_NONE,
+ TK_OPTION_NULL_OK,0,0 },
{TK_OPTION_STRING, "-values", "values", "Values",
- NULL, Tk_Offset(TreeItem,valuesObj), -1,
+ NULL, offsetof(TreeItem,valuesObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,0 },
{TK_OPTION_BOOLEAN, "-open", "open", "Open",
- "0", Tk_Offset(TreeItem,openObj), -1,
+ "0", offsetof(TreeItem,openObj), TCL_INDEX_NONE,
0,0,0 },
{TK_OPTION_STRING, "-tags", "tags", "Tags",
- NULL, Tk_Offset(TreeItem,tagsObj), -1,
+ NULL, offsetof(TreeItem,tagsObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,ITEM_OPTION_TAGS_CHANGED },
- {TK_OPTION_END, 0,0,0, NULL, -1,-1, 0,0,0}
+ {TK_OPTION_END, 0,0,0, NULL, TCL_INDEX_NONE,TCL_INDEX_NONE, 0,0,0}
};
+/* Forward declarations */
+static void RemoveTag(TreeItem *, Ttk_Tag);
+static void RemoveTagFromCellsAtItem(TreeItem *, Ttk_Tag);
+
/* + NewItem --
* Allocate a new, uninitialized, unlinked item
*/
@@ -101,6 +124,12 @@ static TreeItem *NewItem(void)
item->valuesObj = NULL;
item->openObj = NULL;
item->tagsObj = NULL;
+ item->selObj = NULL;
+ item->imageAnchorObj = NULL;
+ item->hidden = 0;
+ item->height = 1;
+ item->cellTagSets = NULL;
+ item->nTagSets = 0;
item->tagset = NULL;
item->imagespec = NULL;
@@ -113,14 +142,25 @@ static TreeItem *NewItem(void)
*/
static void FreeItem(TreeItem *item)
{
+ Tcl_Size i;
if (item->textObj) { Tcl_DecrRefCount(item->textObj); }
if (item->imageObj) { Tcl_DecrRefCount(item->imageObj); }
if (item->valuesObj) { Tcl_DecrRefCount(item->valuesObj); }
if (item->openObj) { Tcl_DecrRefCount(item->openObj); }
if (item->tagsObj) { Tcl_DecrRefCount(item->tagsObj); }
+ if (item->selObj) { Tcl_DecrRefCount(item->selObj); }
+ if (item->imageAnchorObj) { Tcl_DecrRefCount(item->imageAnchorObj); }
if (item->tagset) { Ttk_FreeTagSet(item->tagset); }
if (item->imagespec) { TtkFreeImageSpec(item->imagespec); }
+ if (item->cellTagSets) {
+ for (i = 0; i < item->nTagSets; ++i) {
+ if (item->cellTagSets[i] != NULL) {
+ Ttk_FreeTagSet(item->cellTagSets[i]);
+ }
+ }
+ ckfree(item->cellTagSets);
+ }
ckfree(item);
}
@@ -186,36 +226,53 @@ static TreeItem *NextPreorder(TreeItem *item)
typedef struct {
Tcl_Obj *textObj; /* taken from item / data cell */
- Tcl_Obj *imageObj; /* taken from item */
+ Tcl_Obj *imageObj; /* taken from item or tag*/
+ Tcl_Obj *imageAnchorObj; /* taken from item or tag */
Tcl_Obj *anchorObj; /* from column <<NOTE-ANCHOR>> */
Tcl_Obj *backgroundObj; /* remainder from tag */
+ Tcl_Obj *stripedBgObj;
Tcl_Obj *foregroundObj;
Tcl_Obj *fontObj;
+ Tcl_Obj *paddingObj;
} DisplayItem;
-static Tk_OptionSpec TagOptionSpecs[] = {
+static const Tk_OptionSpec DisplayOptionSpecs[] = {
{TK_OPTION_STRING, "-text", "text", "Text",
- NULL, Tk_Offset(DisplayItem,textObj), -1,
- TK_OPTION_NULL_OK,0,0 },
- {TK_OPTION_STRING, "-image", "image", "Image",
- NULL, Tk_Offset(DisplayItem,imageObj), -1,
+ NULL, offsetof(DisplayItem,textObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,0 },
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
- "center", Tk_Offset(DisplayItem,anchorObj), -1,
+ "center", offsetof(DisplayItem,anchorObj), TCL_INDEX_NONE,
0, 0, GEOMETRY_CHANGED}, /* <<NOTE-ANCHOR>> */
+ /* From here down are the tags options. The index in TagOptionSpecs
+ * below should be kept in synch with this position.
+ */
+ {TK_OPTION_STRING, "-image", "image", "Image",
+ NULL, offsetof(DisplayItem,imageObj), TCL_INDEX_NONE,
+ TK_OPTION_NULL_OK,0,0 },
+ {TK_OPTION_ANCHOR, "-imageanchor", "imageAnchor", "ImageAnchor",
+ NULL, offsetof(DisplayItem,imageAnchorObj), TCL_INDEX_NONE,
+ TK_OPTION_NULL_OK,0,0 },
{TK_OPTION_COLOR, "-background", "windowColor", "WindowColor",
- NULL, Tk_Offset(DisplayItem,backgroundObj), -1,
+ NULL, offsetof(DisplayItem,backgroundObj), TCL_INDEX_NONE,
+ TK_OPTION_NULL_OK,0,0 },
+ {TK_OPTION_COLOR, "-stripedbackground", "windowColor", "WindowColor",
+ NULL, offsetof(DisplayItem,stripedBgObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,0 },
{TK_OPTION_COLOR, "-foreground", "textColor", "TextColor",
- NULL, Tk_Offset(DisplayItem,foregroundObj), -1,
+ NULL, offsetof(DisplayItem,foregroundObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,0 },
{TK_OPTION_FONT, "-font", "font", "Font",
- NULL, Tk_Offset(DisplayItem,fontObj), -1,
+ NULL, offsetof(DisplayItem,fontObj), TCL_INDEX_NONE,
+ TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
+ {TK_OPTION_STRING, "-padding", "padding", "Pad",
+ NULL, offsetof(DisplayItem,paddingObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
- {TK_OPTION_END, 0,0,0, NULL, -1,-1, 0,0,0}
+ {TK_OPTION_END, 0,0,0, NULL, TCL_INDEX_NONE,TCL_INDEX_NONE, 0,0,0}
};
+static const Tk_OptionSpec *TagOptionSpecs = &DisplayOptionSpecs[2];
+
/*------------------------------------------------------------------------
* +++ Columns.
*
@@ -227,6 +284,7 @@ typedef struct {
int width; /* Column width, in pixels */
int minWidth; /* Minimum column width, in pixels */
int stretch; /* Should column stretch while resizing? */
+ int separator; /* Should this column have a separator? */
Tcl_Obj *idObj; /* Column identifier, from -columns option */
Tcl_Obj *anchorObj; /* -anchor for cell data <<NOTE-ANCHOR>> */
@@ -243,6 +301,8 @@ typedef struct {
/* Temporary storage for cell data
*/
Tcl_Obj *data;
+ int selected;
+ Ttk_TagSet tagset;
} TreeColumn;
static void InitColumn(TreeColumn *column)
@@ -250,6 +310,7 @@ static void InitColumn(TreeColumn *column)
column->width = atoi(DEF_COLWIDTH);
column->minWidth = atoi(DEF_MINWIDTH);
column->stretch = 1;
+ column->separator = 0;
column->idObj = 0;
column->anchorObj = 0;
@@ -261,6 +322,7 @@ static void InitColumn(TreeColumn *column)
column->headingCommandObj = 0;
column->data = 0;
+ column->tagset = NULL;
}
static void FreeColumn(TreeColumn *column)
@@ -277,42 +339,45 @@ static void FreeColumn(TreeColumn *column)
/* Don't touch column->data, it's scratch storage */
}
-static Tk_OptionSpec ColumnOptionSpecs[] = {
+static const Tk_OptionSpec ColumnOptionSpecs[] = {
{TK_OPTION_INT, "-width", "width", "Width",
- DEF_COLWIDTH, -1, Tk_Offset(TreeColumn,width),
+ DEF_COLWIDTH, TCL_INDEX_NONE, offsetof(TreeColumn,width),
0,0,GEOMETRY_CHANGED },
{TK_OPTION_INT, "-minwidth", "minWidth", "MinWidth",
- DEF_MINWIDTH, -1, Tk_Offset(TreeColumn,minWidth),
+ DEF_MINWIDTH, TCL_INDEX_NONE, offsetof(TreeColumn,minWidth),
+ 0,0,0 },
+ {TK_OPTION_BOOLEAN, "-separator", "separator", "Separator",
+ "0", TCL_INDEX_NONE, offsetof(TreeColumn,separator),
0,0,0 },
{TK_OPTION_BOOLEAN, "-stretch", "stretch", "Stretch",
- "1", -1, Tk_Offset(TreeColumn,stretch),
+ "1", TCL_INDEX_NONE, offsetof(TreeColumn,stretch),
0,0,GEOMETRY_CHANGED },
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
- "w", Tk_Offset(TreeColumn,anchorObj), -1, /* <<NOTE-ANCHOR>> */
+ "w", offsetof(TreeColumn,anchorObj), TCL_INDEX_NONE, /* <<NOTE-ANCHOR>> */
0,0,0 },
{TK_OPTION_STRING, "-id", "id", "ID",
- NULL, Tk_Offset(TreeColumn,idObj), -1,
+ NULL, offsetof(TreeColumn,idObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,READONLY_OPTION },
- {TK_OPTION_END, 0,0,0, NULL, -1,-1, 0,0,0}
+ {TK_OPTION_END, 0,0,0, NULL, TCL_INDEX_NONE,TCL_INDEX_NONE, 0,0,0}
};
-static Tk_OptionSpec HeadingOptionSpecs[] = {
+static const Tk_OptionSpec HeadingOptionSpecs[] = {
{TK_OPTION_STRING, "-text", "text", "Text",
- "", Tk_Offset(TreeColumn,headingObj), -1,
+ "", offsetof(TreeColumn,headingObj), TCL_INDEX_NONE,
0,0,0 },
{TK_OPTION_STRING, "-image", "image", "Image",
- "", Tk_Offset(TreeColumn,headingImageObj), -1,
+ "", offsetof(TreeColumn,headingImageObj), TCL_INDEX_NONE,
0,0,0 },
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
- "center", Tk_Offset(TreeColumn,headingAnchorObj), -1,
+ "center", offsetof(TreeColumn,headingAnchorObj), TCL_INDEX_NONE,
0,0,0 },
{TK_OPTION_STRING, "-command", "", "",
- "", Tk_Offset(TreeColumn,headingCommandObj), -1,
+ "", offsetof(TreeColumn,headingCommandObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,0 },
{TK_OPTION_STRING, "state", "", "",
- "", Tk_Offset(TreeColumn,headingStateObj), -1,
+ "", offsetof(TreeColumn,headingStateObj), TCL_INDEX_NONE,
0,0,STATE_CHANGED },
- {TK_OPTION_END, 0,0,0, NULL, -1,-1, 0,0,0}
+ {TK_OPTION_END, 0,0,0, NULL, TCL_INDEX_NONE,TCL_INDEX_NONE, 0,0,0}
};
/*------------------------------------------------------------------------
@@ -336,7 +401,7 @@ static int GetEnumSetFromObj(
unsigned *resultPtr)
{
unsigned result = 0;
- int i, objc;
+ Tcl_Size i, objc;
Tcl_Obj **objv;
if (Tcl_ListObjGetElements(interp, objPtr, &objc, &objv) != TCL_OK)
@@ -371,7 +436,7 @@ typedef struct {
Tk_OptionTable itemOptionTable;
Tk_OptionTable columnOptionTable;
Tk_OptionTable headingOptionTable;
- Tk_OptionTable tagOptionTable;
+ Tk_OptionTable displayOptionTable;
Tk_BindingTable bindingTable;
Ttk_TagTable tagTable;
@@ -381,9 +446,11 @@ typedef struct {
Ttk_Layout cellLayout;
Ttk_Layout headingLayout;
Ttk_Layout rowLayout;
+ Ttk_Layout separatorLayout;
int headingHeight; /* Space for headings */
int rowHeight; /* Height of each item */
+ int colSeparatorWidth; /* Width of column separator, if used (screen units) */
int indent; /* Horizontal offset for child items (screen units) */
/* Tree data:
@@ -405,9 +472,13 @@ typedef struct {
Tcl_Obj *heightObj; /* height (rows) */
Tcl_Obj *paddingObj; /* internal padding */
+ Tcl_Size nTitleColumns; /* -titlecolumns */
+ Tcl_Size nTitleItems; /* -titleitems */
+ int striped; /* -striped option */
Tcl_Obj *showObj; /* -show list */
Tcl_Obj *selectModeObj; /* -selectmode option */
+ Tcl_Obj *selectTypeObj; /* -selecttype option */
Scrollable xscroll;
ScrollHandle xscrollHandle;
@@ -417,15 +488,17 @@ typedef struct {
/* Derived resources:
*/
Tcl_HashTable columnNames; /* Map: column name -> column table entry */
- int nColumns; /* #columns */
- unsigned showFlags; /* bitmask of subparts to display */
-
+ Tcl_Size nColumns; /* #columns */
+ Tcl_Size nDisplayColumns; /* #display columns */
TreeColumn **displayColumns; /* List of columns for display (incl tree) */
- int nDisplayColumns; /* #display columns */
+ int titleWidth; /* Width of non-scrolled columns */
+ int titleRows; /* Height of non-scrolled items, in rows */
+ int totalRows; /* Height of non-hidden items, in rows */
+ int rowPosNeedsUpdate; /* Internal rowPos data needs update */
Ttk_Box headingArea; /* Display area for column headings */
Ttk_Box treeArea; /* Display area for tree */
int slack; /* Slack space (see Resizing section) */
-
+ unsigned showFlags; /* bitmask of subparts to display */
} TreePart;
typedef struct {
@@ -440,34 +513,47 @@ typedef struct {
#define SHOW_CHANGED (USER_MASK<<3)
static const char *const SelectModeStrings[] = { "none", "browse", "extended", NULL };
+static const char *const SelectTypeStrings[] = { "item", "cell", NULL };
-static Tk_OptionSpec TreeviewOptionSpecs[] = {
+static const Tk_OptionSpec TreeviewOptionSpecs[] = {
{TK_OPTION_STRING, "-columns", "columns", "Columns",
- "", Tk_Offset(Treeview,tree.columnsObj), -1,
+ "", offsetof(Treeview,tree.columnsObj), TCL_INDEX_NONE,
0, 0, COLUMNS_CHANGED | GEOMETRY_CHANGED /*| READONLY_OPTION*/ },
{TK_OPTION_STRING, "-displaycolumns","displayColumns","DisplayColumns",
- "#all", Tk_Offset(Treeview,tree.displayColumnsObj), -1,
+ "#all", offsetof(Treeview,tree.displayColumnsObj), TCL_INDEX_NONE,
0, 0, DCOLUMNS_CHANGED | GEOMETRY_CHANGED },
{TK_OPTION_STRING, "-show", "show", "Show",
- DEFAULT_SHOW, Tk_Offset(Treeview,tree.showObj), -1,
+ DEFAULT_SHOW, offsetof(Treeview,tree.showObj), TCL_INDEX_NONE,
0, 0, SHOW_CHANGED | GEOMETRY_CHANGED },
{TK_OPTION_STRING_TABLE, "-selectmode", "selectMode", "SelectMode",
- "extended", Tk_Offset(Treeview,tree.selectModeObj), -1,
+ "extended", offsetof(Treeview,tree.selectModeObj), TCL_INDEX_NONE,
0, SelectModeStrings, 0 },
+ {TK_OPTION_STRING_TABLE, "-selecttype", "selectType", "SelectType",
+ "item", offsetof(Treeview,tree.selectTypeObj), TCL_INDEX_NONE,
+ 0, SelectTypeStrings, 0 },
{TK_OPTION_PIXELS, "-height", "height", "Height",
- DEF_TREE_ROWS, Tk_Offset(Treeview,tree.heightObj), -1,
+ DEF_TREE_ROWS, offsetof(Treeview,tree.heightObj), TCL_INDEX_NONE,
0, 0, GEOMETRY_CHANGED},
{TK_OPTION_STRING, "-padding", "padding", "Pad",
- NULL, Tk_Offset(Treeview,tree.paddingObj), -1,
+ NULL, offsetof(Treeview,tree.paddingObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, GEOMETRY_CHANGED },
+ {TK_OPTION_INT, "-titlecolumns", "titlecolumns", "Titlecolumns",
+ DEF_TITLECOLUMNS, TCL_INDEX_NONE, offsetof(Treeview,tree.nTitleColumns),
+ TK_OPTION_VAR(Tcl_Size), 0, GEOMETRY_CHANGED},
+ {TK_OPTION_INT, "-titleitems", "titleitems", "Titleitems",
+ DEF_TITLEITEMS, TCL_INDEX_NONE, offsetof(Treeview,tree.nTitleItems),
+ TK_OPTION_VAR(Tcl_Size), 0, GEOMETRY_CHANGED},
+ {TK_OPTION_BOOLEAN, "-striped", "striped", "Striped",
+ DEF_STRIPED, TCL_INDEX_NONE, offsetof(Treeview,tree.striped),
+ 0, 0, GEOMETRY_CHANGED},
{TK_OPTION_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand",
- NULL, -1, Tk_Offset(Treeview, tree.xscroll.scrollCmd),
+ NULL, TCL_INDEX_NONE, offsetof(Treeview, tree.xscroll.scrollCmd),
TK_OPTION_NULL_OK, 0, SCROLLCMD_CHANGED},
{TK_OPTION_STRING, "-yscrollcommand", "yScrollCommand", "ScrollCommand",
- NULL, -1, Tk_Offset(Treeview, tree.yscroll.scrollCmd),
+ NULL, TCL_INDEX_NONE, offsetof(Treeview, tree.yscroll.scrollCmd),
TK_OPTION_NULL_OK, 0, SCROLLCMD_CHANGED},
WIDGET_TAKEFOCUS_TRUE,
@@ -489,6 +575,20 @@ static void foreachHashEntry(Tcl_HashTable *ht, HashEntryIterator func)
}
}
+static int CellSelectionClear(Treeview *tv)
+{
+ TreeItem *item;
+ int anyChange = 0;
+ for (item=tv->tree.root; item; item = NextPreorder(item)) {
+ if (item->selObj != NULL) {
+ Tcl_DecrRefCount(item->selObj);
+ item->selObj = NULL;
+ anyChange = 1;
+ }
+ }
+ return anyChange;
+}
+
/* + unshareObj(objPtr) --
* Ensure that a Tcl_Obj * has refcount 1 -- either return objPtr
* itself, or a duplicated copy.
@@ -515,6 +615,33 @@ static void DisplayLayout(
Ttk_DrawLayout(layout, state, d);
}
+/* DisplayLayoutTree --
+ * Like DisplayLayout, but for the tree column.
+ */
+static void DisplayLayoutTree(
+ Tk_Anchor imageAnchor, Tk_Anchor textAnchor,
+ Ttk_Layout layout, void *recordPtr, Ttk_State state, Ttk_Box b, Drawable d)
+{
+ Ttk_Element elem;
+ Ttk_RebindSublayout(layout, recordPtr);
+
+ elem = Ttk_FindElement(layout, "image");
+ if (elem != NULL) {
+ Ttk_AnchorElement(elem, imageAnchor);
+ }
+ elem = Ttk_FindElement(layout, "text");
+ if (elem != NULL) {
+ Ttk_AnchorElement(elem, textAnchor);
+ }
+ elem = Ttk_FindElement(layout, "focus");
+ if (elem != NULL) {
+ Ttk_AnchorElement(elem, textAnchor);
+ }
+
+ Ttk_PlaceLayout(layout, state, b);
+ Ttk_DrawLayout(layout, state, d);
+}
+
/* + GetColumn --
* Look up column by name or number.
* Returns: pointer to column table entry, NULL if not found.
@@ -524,7 +651,7 @@ static TreeColumn *GetColumn(
Tcl_Interp *interp, Treeview *tv, Tcl_Obj *columnIDObj)
{
Tcl_HashEntry *entryPtr;
- int columnIndex;
+ Tcl_Size columnIndex;
/* Check for named column:
*/
@@ -534,12 +661,12 @@ static TreeColumn *GetColumn(
return (TreeColumn *)Tcl_GetHashValue(entryPtr);
}
- /* Check for number:
+ /* Check for index:
*/
- if (Tcl_GetIntFromObj(NULL, columnIDObj, &columnIndex) == TCL_OK) {
+ if (TkGetIntForIndex(columnIDObj, tv->tree.nColumns - 1, 1, &columnIndex) == TCL_OK) {
if (columnIndex < 0 || columnIndex >= tv->tree.nColumns) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "Column index %s out of bounds",
+ "Column index \"%s\" out of bounds",
Tcl_GetString(columnIDObj)));
Tcl_SetErrorCode(interp, "TTK", "TREE", "COLBOUND", NULL);
return NULL;
@@ -548,7 +675,7 @@ static TreeColumn *GetColumn(
return tv->tree.columns + columnIndex;
}
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "Invalid column index %s", Tcl_GetString(columnIDObj)));
+ "Invalid column index \"%s\"", Tcl_GetString(columnIDObj)));
Tcl_SetErrorCode(interp, "TTK", "TREE", "COLUMN", NULL);
return NULL;
}
@@ -559,9 +686,9 @@ static TreeColumn *GetColumn(
static TreeColumn *FindColumn(
Tcl_Interp *interp, Treeview *tv, Tcl_Obj *columnIDObj)
{
- int colno;
+ Tcl_WideInt colno;
- if (sscanf(Tcl_GetString(columnIDObj), "#%d", &colno) == 1)
+ if (sscanf(Tcl_GetString(columnIDObj), "#%" TCL_LL_MODIFIER "d", &colno) == 1)
{ /* Display column specification, #n */
if (colno >= 0 && colno < tv->tree.nDisplayColumns) {
return tv->tree.displayColumns[colno];
@@ -607,7 +734,7 @@ static TreeItem **GetItemListFromObj(
{
TreeItem **items;
Tcl_Obj **elements;
- int i, nElements;
+ Tcl_Size i, nElements;
if (Tcl_ListObjGetElements(interp,objPtr,&nElements,&elements) != TCL_OK) {
return NULL;
@@ -651,7 +778,7 @@ static Tcl_Obj *ItemID(Treeview *tv, TreeItem *item)
*/
static void TreeviewFreeColumns(Treeview *tv)
{
- int i;
+ Tcl_Size i;
Tcl_DeleteHashTable(&tv->tree.columnNames);
Tcl_InitHashTable(&tv->tree.columnNames, TCL_STRING_KEYS);
@@ -671,7 +798,7 @@ static void TreeviewFreeColumns(Treeview *tv)
static int TreeviewInitColumns(Tcl_Interp *interp, Treeview *tv)
{
Tcl_Obj **columns;
- int i, ncols;
+ Tcl_Size i, ncols;
if (Tcl_ListObjGetElements(
interp, tv->tree.columnsObj, &ncols, &columns) != TCL_OK)
@@ -700,10 +827,10 @@ static int TreeviewInitColumns(Tcl_Interp *interp, Treeview *tv)
InitColumn(tv->tree.columns + i);
Tk_InitOptions(
- interp, (void *)(tv->tree.columns + i),
+ interp, tv->tree.columns + i,
tv->tree.columnOptionTable, tv->core.tkwin);
Tk_InitOptions(
- interp, (void *)(tv->tree.columns + i),
+ interp, tv->tree.columns + i,
tv->tree.headingOptionTable, tv->core.tkwin);
Tcl_IncrRefCount(columnName);
tv->tree.columns[i].idObj = columnName;
@@ -723,7 +850,7 @@ static int TreeviewInitColumns(Tcl_Interp *interp, Treeview *tv)
static int TreeviewInitDisplayColumns(Tcl_Interp *interp, Treeview *tv)
{
Tcl_Obj **dcolumns;
- int index, ndcols;
+ Tcl_Size index, ndcols;
TreeColumn **displayColumns = 0;
if (Tcl_ListObjGetElements(interp,
@@ -769,12 +896,19 @@ static int TreeviewInitDisplayColumns(Tcl_Interp *interp, Treeview *tv)
*/
static int TreeWidth(Treeview *tv)
{
- int i = FirstColumn(tv);
+ Tcl_Size i = FirstColumn(tv);
int width = 0;
+ tv->tree.titleWidth = 0;
while (i < tv->tree.nDisplayColumns) {
+ if (i == tv->tree.nTitleColumns) {
+ tv->tree.titleWidth = width;
+ }
width += tv->tree.displayColumns[i++]->width;
}
+ if (tv->tree.nTitleColumns >= tv->tree.nDisplayColumns) {
+ tv->tree.titleWidth = width;
+ }
return width;
}
@@ -830,9 +964,9 @@ static int Stretch(TreeColumn *c, int n)
* Adjust width of (stretchable) columns to the left by N pixels.
* Returns: leftover slack.
*/
-static int ShoveLeft(Treeview *tv, int i, int n)
+static int ShoveLeft(Treeview *tv, Tcl_Size i, int n)
{
- int first = FirstColumn(tv);
+ Tcl_Size first = FirstColumn(tv);
while (n != 0 && i >= first) {
TreeColumn *c = tv->tree.displayColumns[i];
if (c->stretch) {
@@ -847,7 +981,7 @@ static int ShoveLeft(Treeview *tv, int i, int n)
* Adjust width of (stretchable) columns to the right by N pixels.
* Returns: leftover slack.
*/
-static int ShoveRight(Treeview *tv, int i, int n)
+static int ShoveRight(Treeview *tv, Tcl_Size i, int n)
{
while (n != 0 && i < tv->tree.nDisplayColumns) {
TreeColumn *c = tv->tree.displayColumns[i];
@@ -870,7 +1004,7 @@ static int DistributeWidth(Treeview *tv, int n)
{
int w = TreeWidth(tv);
int m = 0;
- int i;
+ Tcl_Size i;
int d, r;
for (i = FirstColumn(tv); i < tv->tree.nDisplayColumns; ++i) {
@@ -913,7 +1047,7 @@ static void ResizeColumns(Treeview *tv, int newWidth)
* Move the separator to the right of specified column,
* adjusting other column widths as necessary.
*/
-static void DragColumn(Treeview *tv, int i, int delta)
+static void DragColumn(Treeview *tv, Tcl_Size i, int delta)
{
TreeColumn *c = tv->tree.displayColumns[i];
int dl = delta - ShoveLeft(tv, i-1, delta - Stretch(c, delta));
@@ -922,10 +1056,119 @@ static void DragColumn(Treeview *tv, int i, int delta)
}
/*------------------------------------------------------------------------
+ * +++ Cells.
+ */
+
+typedef struct {
+ TreeItem *item;
+ TreeColumn *column;
+ Tcl_Obj *colObj;
+} TreeCell;
+
+/* + GetCellFromObj
+ * Get Row and Column from a cell ID.
+ */
+static int GetCellFromObj(
+ Tcl_Interp *interp, Treeview *tv, Tcl_Obj *obj,
+ int displayColumnOnly, int *displayColumn,
+ TreeCell *cell)
+{
+ Tcl_Size nElements;
+ Tcl_Obj **elements;
+
+ if (Tcl_ListObjGetElements(interp, obj, &nElements, &elements) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ if (nElements != 2) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "Cell id must be a list of two elements", -1));
+ Tcl_SetErrorCode(interp, "TTK", "TREE", "CELL", NULL);
+ return TCL_ERROR;
+ }
+ /* Valid item/column in each pair? */
+ cell->item = FindItem(interp, tv, elements[0]);
+ if (!cell->item) {
+ return TCL_ERROR;
+ }
+ cell->column = FindColumn(interp, tv, elements[1]);
+ if (!cell->column) {
+ return TCL_ERROR;
+ }
+ /* colObj is short lived and do not keep a reference counted */
+ cell->colObj = elements[1];
+ if (displayColumnOnly) {
+ Tcl_Size i = FirstColumn(tv);
+ while (i < tv->tree.nDisplayColumns) {
+ if (tv->tree.displayColumns[i] == cell->column) {
+ break;
+ }
+ ++i;
+ }
+ if (i == tv->tree.nDisplayColumns) { /* specified column unviewable */
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "Cell id must be in a visible column", -1));
+ Tcl_SetErrorCode(interp, "TTK", "TREE", "CELL", NULL);
+ return TCL_ERROR;
+ }
+ if (displayColumn != NULL) {
+ *displayColumn = i;
+ }
+ }
+ return TCL_OK;
+}
+
+/* + GetCellListFromObj --
+ * Parse a Tcl_Obj * as a list of cells.
+ * Returns an array of cells; result must be ckfree()d.
+ * On error, returns NULL and leaves an error
+ * message in interp.
+ */
+
+static TreeCell *GetCellListFromObj(
+ Tcl_Interp *interp, Treeview *tv, Tcl_Obj *objPtr, Tcl_Size *nCells)
+{
+ TreeCell *cells;
+ TreeCell cell;
+ Tcl_Obj **elements;
+ Tcl_Obj *oneCell;
+ Tcl_Size i, n;
+
+ if (Tcl_ListObjGetElements(interp, objPtr, &n, &elements) != TCL_OK) {
+ return NULL;
+ }
+
+ /* A two element list might be a single cell */
+ if (n == 2) {
+ if (GetCellFromObj(interp, tv, objPtr, 0, NULL, &cell)
+ == TCL_OK) {
+ n = 1;
+ oneCell = objPtr;
+ elements = &oneCell;
+ } else {
+ Tcl_ResetResult(interp);
+ }
+ }
+
+ cells = (TreeCell *) ckalloc(n * sizeof(TreeCell));
+ for (i = 0; i < n; ++i) {
+ if (GetCellFromObj(interp, tv, elements[i], 0, NULL, &cells[i]) != TCL_OK) {
+ ckfree(cells);
+ return NULL;
+ }
+ }
+
+ if (nCells) {
+ *nCells = n;
+ }
+ return cells;
+}
+
+/*------------------------------------------------------------------------
* +++ Event handlers.
*/
static TreeItem *IdentifyItem(Treeview *tv, int y); /*forward*/
+static Tcl_Size IdentifyDisplayColumn(Treeview *tv, int x, int *x1); /*forward*/
static const unsigned long TreeviewBindEventMask =
KeyPressMask|KeyReleaseMask
@@ -939,6 +1182,9 @@ static void TreeviewBindEventProc(void *clientData, XEvent *event)
Treeview *tv = (Treeview *)clientData;
TreeItem *item = NULL;
Ttk_TagSet tagset;
+ int unused;
+ Tcl_Size colno = TCL_INDEX_NONE;
+ TreeColumn *column = NULL;
/*
* Figure out where to deliver the event.
@@ -953,9 +1199,11 @@ static void TreeviewBindEventProc(void *clientData, XEvent *event)
case ButtonPress:
case ButtonRelease:
item = IdentifyItem(tv, event->xbutton.y);
+ colno = IdentifyDisplayColumn(tv, event->xbutton.x, &unused);
break;
case MotionNotify:
item = IdentifyItem(tv, event->xmotion.y);
+ colno = IdentifyDisplayColumn(tv, event->xmotion.x, &unused);
break;
default:
break;
@@ -972,6 +1220,23 @@ static void TreeviewBindEventProc(void *clientData, XEvent *event)
tagset = Ttk_GetTagSetFromObj(NULL, tv->tree.tagTable, item->tagsObj);
/*
+ * Pick up any cell tags.
+ */
+ if (colno >= 0) {
+ column = tv->tree.displayColumns[colno];
+ if (column == &tv->tree.column0) {
+ colno = 0;
+ } else {
+ colno = column - tv->tree.columns + 1;
+ }
+ if (colno < item->nTagSets) {
+ if (item->cellTagSets[colno] != NULL) {
+ Ttk_TagSetAddSet(tagset, item->cellTagSets[colno]);
+ }
+ }
+ }
+
+ /*
* Fire binding:
*/
Tcl_Preserve(clientData);
@@ -997,8 +1262,8 @@ static void TreeviewInitialize(Tcl_Interp *interp, void *recordPtr)
Tk_CreateOptionTable(interp, ColumnOptionSpecs);
tv->tree.headingOptionTable =
Tk_CreateOptionTable(interp, HeadingOptionSpecs);
- tv->tree.tagOptionTable =
- Tk_CreateOptionTable(interp, TagOptionSpecs);
+ tv->tree.displayOptionTable =
+ Tk_CreateOptionTable(interp, DisplayOptionSpecs);
tv->tree.tagTable = Ttk_CreateTagTable(
interp, tv->core.tkwin, TagOptionSpecs, sizeof(DisplayItem));
@@ -1010,22 +1275,33 @@ static void TreeviewInitialize(Tcl_Interp *interp, void *recordPtr)
= tv->tree.cellLayout
= tv->tree.headingLayout
= tv->tree.rowLayout
+ = tv->tree.separatorLayout
= 0;
- tv->tree.headingHeight = tv->tree.rowHeight = DEFAULT_ROWHEIGHT;
+ tv->tree.headingHeight = tv->tree.rowHeight = 0;
+ tv->tree.colSeparatorWidth = 1;
tv->tree.indent = DEFAULT_INDENT;
Tcl_InitHashTable(&tv->tree.columnNames, TCL_STRING_KEYS);
tv->tree.nColumns = tv->tree.nDisplayColumns = 0;
+ tv->tree.nTitleColumns = 0;
+ tv->tree.nTitleItems = 0;
+ tv->tree.titleWidth = 0;
+ tv->tree.titleRows = 0;
+ tv->tree.totalRows = 0;
+ tv->tree.rowPosNeedsUpdate = 1;
+ tv->tree.striped = 0;
tv->tree.columns = NULL;
tv->tree.displayColumns = NULL;
tv->tree.showFlags = ~0;
InitColumn(&tv->tree.column0);
+ tv->tree.column0.idObj = Tcl_NewStringObj("#0", 2);
+ Tcl_IncrRefCount(tv->tree.column0.idObj);
Tk_InitOptions(
- interp, (void *)(&tv->tree.column0),
+ interp, &tv->tree.column0,
tv->tree.columnOptionTable, tv->core.tkwin);
Tk_InitOptions(
- interp, (void *)(&tv->tree.column0),
+ interp, &tv->tree.column0,
tv->tree.headingOptionTable, tv->core.tkwin);
Tcl_InitHashTable(&tv->tree.items, TCL_STRING_KEYS);
@@ -1036,7 +1312,7 @@ static void TreeviewInitialize(Tcl_Interp *interp, void *recordPtr)
/* Create root item "":
*/
tv->tree.root = NewItem();
- Tk_InitOptions(interp, (void *)tv->tree.root,
+ Tk_InitOptions(interp, tv->tree.root,
tv->tree.itemOptionTable, tv->core.tkwin);
tv->tree.root->tagset = Ttk_GetTagSetFromObj(NULL, tv->tree.tagTable, NULL);
tv->tree.root->entryPtr = Tcl_CreateHashEntry(&tv->tree.items, "", &unused);
@@ -1066,11 +1342,13 @@ static void TreeviewCleanup(void *recordPtr)
if (tv->tree.cellLayout) Ttk_FreeLayout(tv->tree.cellLayout);
if (tv->tree.headingLayout) Ttk_FreeLayout(tv->tree.headingLayout);
if (tv->tree.rowLayout) Ttk_FreeLayout(tv->tree.rowLayout);
+ if (tv->tree.separatorLayout) Ttk_FreeLayout(tv->tree.separatorLayout);
+ FreeColumn(&tv->tree.column0);
TreeviewFreeColumns(tv);
if (tv->tree.displayColumns)
- ckfree((void *)tv->tree.displayColumns);
+ ckfree(tv->tree.displayColumns);
foreachHashEntry(&tv->tree.items, FreeItemCB);
Tcl_DeleteHashTable(&tv->tree.items);
@@ -1100,6 +1378,23 @@ TreeviewConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
if (TreeviewInitDisplayColumns(interp, tv) != TCL_OK)
return TCL_ERROR;
}
+ if (mask & COLUMNS_CHANGED) {
+ CellSelectionClear(tv);
+ }
+ if (tv->tree.nTitleColumns < 0) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "\"#%" TCL_SIZE_MODIFIER "d\" is out of range",
+ tv->tree.nTitleColumns));
+ Tcl_SetErrorCode(interp, "TTK", "TREE", "TITLECOLUMNS", NULL);
+ return TCL_ERROR;
+ }
+ if (tv->tree.nTitleItems < 0) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "\"%" TCL_SIZE_MODIFIER "d\" is out of range",
+ tv->tree.nTitleItems));
+ Tcl_SetErrorCode(interp, "TTK", "TREE", "TITLEITEMS", NULL);
+ return TCL_ERROR;
+ }
if (mask & SCROLLCMD_CHANGED) {
TtkScrollbarUpdateRequired(tv->tree.xscrollHandle);
TtkScrollbarUpdateRequired(tv->tree.yscrollHandle);
@@ -1114,6 +1409,7 @@ TreeviewConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
return TCL_ERROR;
}
+ tv->tree.rowPosNeedsUpdate = 1;
tv->tree.showFlags = showFlags;
if (mask & (SHOW_CHANGED | DCOLUMNS_CHANGED)) {
@@ -1127,14 +1423,14 @@ TreeviewConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
*/
static int ConfigureItem(
Tcl_Interp *interp, Treeview *tv, TreeItem *item,
- int objc, Tcl_Obj *const objv[])
+ Tcl_Size objc, Tcl_Obj *const objv[])
{
Tk_SavedOptions savedOptions;
int mask;
Ttk_ImageSpec *newImageSpec = NULL;
Ttk_TagSet newTagSet = NULL;
- if (Tk_SetOptions(interp, (void *)item, tv->tree.itemOptionTable,
+ if (Tk_SetOptions(interp, item, tv->tree.itemOptionTable,
objc, objv, tv->core.tkwin, &savedOptions, &mask)
!= TCL_OK)
{
@@ -1144,11 +1440,20 @@ static int ConfigureItem(
/* Make sure that -values is a valid list:
*/
if (item->valuesObj) {
- int unused;
+ Tcl_Size unused;
if (Tcl_ListObjLength(interp, item->valuesObj, &unused) != TCL_OK)
goto error;
}
+ /* Check -height
+ */
+ if (item->height < 1) {
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
+ "Invalid item height %d", item->height));
+ Tcl_SetErrorCode(interp, "TTK", "TREE", "HEIGHT", NULL);
+ goto error;
+ }
+
/* Check -image.
*/
if ((mask & ITEM_OPTION_IMAGE_CHANGED) && item->imageObj) {
@@ -1194,6 +1499,7 @@ static int ConfigureItem(
if (item->imagespec) { TtkFreeImageSpec(item->imagespec); }
item->imagespec = newImageSpec;
}
+ tv->tree.rowPosNeedsUpdate = 1;
TtkRedisplayWidget(&tv->core);
return TCL_OK;
@@ -1209,12 +1515,12 @@ error:
*/
static int ConfigureColumn(
Tcl_Interp *interp, Treeview *tv, TreeColumn *column,
- int objc, Tcl_Obj *const objv[])
+ Tcl_Size objc, Tcl_Obj *const objv[])
{
Tk_SavedOptions savedOptions;
int mask;
- if (Tk_SetOptions(interp, (void *)column,
+ if (Tk_SetOptions(interp, column,
tv->tree.columnOptionTable, objc, objv, tv->core.tkwin,
&savedOptions,&mask) != TCL_OK)
{
@@ -1235,10 +1541,10 @@ static int ConfigureColumn(
if (mask & GEOMETRY_CHANGED) {
if (!Tk_IsMapped(tv->core.tkwin)) {
TtkResizeWidget(&tv->core);
- } else {
+ } else {
RecomputeSlack(tv);
ResizeColumns(tv, TreeWidth(tv));
- }
+ }
}
TtkRedisplayWidget(&tv->core);
@@ -1255,12 +1561,12 @@ error:
*/
static int ConfigureHeading(
Tcl_Interp *interp, Treeview *tv, TreeColumn *column,
- int objc, Tcl_Obj *const objv[])
+ Tcl_Size objc, Tcl_Obj *const objv[])
{
Tk_SavedOptions savedOptions;
int mask;
- if (Tk_SetOptions(interp, (void *)column,
+ if (Tk_SetOptions(interp, column,
tv->tree.headingOptionTable, objc, objv, tv->core.tkwin,
&savedOptions,&mask) != TCL_OK)
{
@@ -1294,48 +1600,55 @@ error:
* +++ Geometry routines.
*/
-/* + CountRows --
- * Returns the number of viewable rows rooted at item
+/* + UpdatePositionItem --
+ * Update position data for all visible items.
*/
-static int CountRows(TreeItem *item)
+static void UpdatePositionItem(
+ Treeview *tv, TreeItem *item, int hidden,
+ int *rowPos, int *itemPos, int *visiblePos)
{
- int rows = 1;
+ TreeItem *child = item->children;
+ item->itemPos = *itemPos;
+ *itemPos += 1;
- if (item->state & TTK_STATE_OPEN) {
- TreeItem *child = item->children;
- while (child) {
- rows += CountRows(child);
- child = child->next;
+ if (item->hidden) {
+ hidden = 1;
+ }
+
+ if (hidden) {
+ item->rowPos = -1;
+ item->visiblePos = -1;
+ } else {
+ item->rowPos = *rowPos;
+ item->visiblePos = *visiblePos;
+ if (*visiblePos == tv->tree.nTitleItems) {
+ tv->tree.titleRows = *rowPos;
}
+
+ *visiblePos += 1;
+ *rowPos += item->height;
+ }
+
+ if (!(item->state & TTK_STATE_OPEN)) {
+ hidden = 1;
+ }
+ while (child) {
+ UpdatePositionItem(tv, child, hidden, rowPos, itemPos, visiblePos);
+ child = child->next;
}
- return rows;
}
-/* + IdentifyRow --
- * Recursive search for item at specified y position.
- * Main work routine for IdentifyItem()
+/* + UpdatePositionTree --
+ * Update position data for all visible items.
*/
-static TreeItem *IdentifyRow(
- Treeview *tv, /* Widget record */
- TreeItem *item, /* Where to start search */
- int *ypos, /* Scan position */
- int y) /* Target y coordinate */
+static void UpdatePositionTree(Treeview *tv)
{
- while (item) {
- int next_ypos = *ypos + tv->tree.rowHeight;
- if (*ypos <= y && y <= next_ypos) {
- return item;
- }
- *ypos = next_ypos;
- if (item->state & TTK_STATE_OPEN) {
- TreeItem *subitem = IdentifyRow(tv, item->children, ypos, y);
- if (subitem) {
- return subitem;
- }
- }
- item = item->next;
- }
- return 0;
+ /* -1 for the invisible root */
+ int rowPos = -1, itemPos = -1, visiblePos = -1;
+ tv->tree.titleRows = 0;
+ UpdatePositionItem(tv, tv->tree.root, 0, &rowPos, &itemPos, &visiblePos);
+ tv->tree.totalRows = rowPos;
+ tv->tree.rowPosNeedsUpdate = 0;
}
/* + IdentifyItem --
@@ -1343,19 +1656,39 @@ static TreeItem *IdentifyRow(
*/
static TreeItem *IdentifyItem(Treeview *tv, int y)
{
+ TreeItem *item;
int rowHeight = tv->tree.rowHeight;
- int ypos = tv->tree.treeArea.y - rowHeight * tv->tree.yscroll.first;
- return IdentifyRow(tv, tv->tree.root->children, &ypos, y);
+ int ypos = tv->tree.treeArea.y;
+ int nextRow, row;
+ if (y < ypos) {
+ return NULL;
+ }
+ if (tv->tree.rowPosNeedsUpdate) {
+ UpdatePositionTree(tv);
+ }
+ row = (y - ypos) / rowHeight;
+ if (row >= tv->tree.titleRows) {
+ row += tv->tree.yscroll.first;
+ }
+ for (item = tv->tree.root->children; item; item = NextPreorder(item)) {
+ nextRow = item->rowPos + item->height;
+ if (item->rowPos <= row && row < nextRow) break;
+ }
+ return item;
}
/* + IdentifyDisplayColumn --
* Returns the display column number at the specified x position,
* or -1 if x is outside any columns.
*/
-static int IdentifyDisplayColumn(Treeview *tv, int x, int *x1)
+static Tcl_Size IdentifyDisplayColumn(Treeview *tv, int x, int *x1)
{
- int colno = FirstColumn(tv);
- int xpos = tv->tree.treeArea.x - tv->tree.xscroll.first;
+ Tcl_Size colno = FirstColumn(tv);
+ int xpos = tv->tree.treeArea.x;
+
+ if (tv->tree.nTitleColumns <= colno) {
+ xpos -= tv->tree.xscroll.first;
+ }
while (colno < tv->tree.nDisplayColumns) {
TreeColumn *column = tv->tree.displayColumns[colno];
@@ -1366,40 +1699,12 @@ static int IdentifyDisplayColumn(Treeview *tv, int x, int *x1)
}
++colno;
xpos = next_xpos;
- }
-
- return -1;
-}
-
-/* + RowNumber --
- * Calculate which row the specified item appears on;
- * returns -1 if the item is not viewable.
- * Xref: DrawForest, IdentifyItem.
- */
-static int RowNumber(Treeview *tv, TreeItem *item)
-{
- TreeItem *p = tv->tree.root->children;
- int n = 0;
-
- while (p) {
- if (p == item)
- return n;
-
- ++n;
-
- /* Find next viewable item in preorder traversal order
- */
- if (p->children && (p->state & TTK_STATE_OPEN)) {
- p = p->children;
- } else {
- while (!p->next && p && p->parent)
- p = p->parent;
- if (p)
- p = p->next;
+ if (tv->tree.nTitleColumns == colno) {
+ xpos -= tv->tree.xscroll.first;
}
}
- return -1;
+ return TCL_INDEX_NONE;
}
/* + ItemDepth -- return the depth of a tree item.
@@ -1416,31 +1721,23 @@ static int ItemDepth(TreeItem *item)
return depth-1;
}
-/* + ItemRow --
- * Returns row number of specified item relative to root,
- * -1 if item is not viewable.
+/* + DisplayRow --
+ * Returns the position row has on screen, or -1 if off-screen.
*/
-static int ItemRow(Treeview *tv, TreeItem *p)
+static int DisplayRow(int row, Treeview *tv)
{
- TreeItem *root = tv->tree.root;
- int rowNumber = 0;
-
- for (;;) {
- if (p->prev) {
- p = p->prev;
- rowNumber += CountRows(p);
- } else {
- p = p->parent;
- if (!(p && (p->state & TTK_STATE_OPEN))) {
- /* detached or closed ancestor */
- return -1;
- }
- if (p == root) {
- return rowNumber;
- }
- ++rowNumber;
- }
+ int visibleRows = tv->tree.treeArea.height / tv->tree.rowHeight
+ - tv->tree.titleRows;
+ if (row < tv->tree.titleRows) {
+ return row;
+ }
+ row -= tv->tree.titleRows;
+ if (row < tv->tree.yscroll.first
+ || row > tv->tree.yscroll.first + visibleRows) {
+ /* not viewable, or off-screen */
+ return -1;
}
+ return row - tv->tree.yscroll.first + tv->tree.titleRows;
}
/* + BoundingBox --
@@ -1454,23 +1751,27 @@ static int BoundingBox(
TreeColumn *column, /* desired column */
Ttk_Box *bbox_rtn) /* bounding box of item */
{
- int row = ItemRow(tv, item);
+ int dispRow;
Ttk_Box bbox = tv->tree.treeArea;
- if (row < tv->tree.yscroll.first || row > tv->tree.yscroll.last) {
+ if (tv->tree.rowPosNeedsUpdate) {
+ UpdatePositionTree(tv);
+ }
+ dispRow = DisplayRow(item->rowPos, tv);
+ if (dispRow < 0) {
/* not viewable, or off-screen */
return 0;
}
- bbox.y += (row - tv->tree.yscroll.first) * tv->tree.rowHeight;
- bbox.height = tv->tree.rowHeight;
+ bbox.y += dispRow * tv->tree.rowHeight;
+ bbox.height = tv->tree.rowHeight * item->height;
bbox.x -= tv->tree.xscroll.first;
bbox.width = TreeWidth(tv);
if (column) {
int xpos = 0;
- int i = FirstColumn(tv);
+ Tcl_Size i = FirstColumn(tv);
while (i < tv->tree.nDisplayColumns) {
if (tv->tree.displayColumns[i] == column) {
break;
@@ -1484,6 +1785,11 @@ static int BoundingBox(
bbox.x += xpos;
bbox.width = column->width;
+ if (i < tv->tree.nTitleColumns) {
+ /* Unscrollable column, remove scroll shift */
+ bbox.x += tv->tree.xscroll.first;
+ }
+
/* Account for indentation in tree column:
*/
if (column == &tv->tree.column0) {
@@ -1514,7 +1820,7 @@ static const char *const regionStrings[] = {
static TreeRegion IdentifyRegion(Treeview *tv, int x, int y)
{
int x1 = 0;
- int colno = IdentifyDisplayColumn(tv, x, &x1);
+ Tcl_Size colno = IdentifyDisplayColumn(tv, x, &x1);
if (Ttk_BoxContains(tv->tree.headingArea, x, y)) {
if (colno < 0) {
@@ -1570,18 +1876,22 @@ static Ttk_Layout TreeviewGetLayout(
Treeview *tv = (Treeview *)recordPtr;
Ttk_Layout treeLayout = TtkWidgetGetLayout(interp, themePtr, recordPtr);
Tcl_Obj *objPtr;
- int unused;
+ int unused, cellHeight;
+ DisplayItem displayItem;
+ Ttk_Style style;
if (!(
treeLayout
&& GetSublayout(interp, themePtr, treeLayout, ".Item",
- tv->tree.tagOptionTable, &tv->tree.itemLayout)
+ tv->tree.displayOptionTable, &tv->tree.itemLayout)
&& GetSublayout(interp, themePtr, treeLayout, ".Cell",
- tv->tree.tagOptionTable, &tv->tree.cellLayout)
+ tv->tree.displayOptionTable, &tv->tree.cellLayout)
&& GetSublayout(interp, themePtr, treeLayout, ".Heading",
tv->tree.headingOptionTable, &tv->tree.headingLayout)
&& GetSublayout(interp, themePtr, treeLayout, ".Row",
- tv->tree.tagOptionTable, &tv->tree.rowLayout)
+ tv->tree.displayOptionTable, &tv->tree.rowLayout)
+ && GetSublayout(interp, themePtr, treeLayout, ".Separator",
+ tv->tree.displayOptionTable, &tv->tree.separatorLayout)
)) {
return 0;
}
@@ -1591,14 +1901,34 @@ static Ttk_Layout TreeviewGetLayout(
Ttk_RebindSublayout(tv->tree.headingLayout, &tv->tree.column0);
Ttk_LayoutSize(tv->tree.headingLayout, 0, &unused, &tv->tree.headingHeight);
- /* Get item height, indent from style:
+ /* Get row height from style, or compute it to fit Item and Cell.
+ * Pick up default font from the Treeview style.
*/
- tv->tree.rowHeight = DEFAULT_ROWHEIGHT;
- tv->tree.indent = DEFAULT_INDENT;
+ style = Ttk_LayoutStyle(treeLayout);
+ Ttk_TagSetDefaults(tv->tree.tagTable, style, &displayItem);
+
+ Ttk_RebindSublayout(tv->tree.itemLayout, &displayItem);
+ Ttk_LayoutSize(tv->tree.itemLayout, 0, &unused, &tv->tree.rowHeight);
+
+ Ttk_RebindSublayout(tv->tree.cellLayout, &displayItem);
+ Ttk_LayoutSize(tv->tree.cellLayout, 0, &unused, &cellHeight);
+
+ if (cellHeight > tv->tree.rowHeight) {
+ tv->tree.rowHeight = cellHeight;
+ }
+
if ((objPtr = Ttk_QueryOption(treeLayout, "-rowheight", 0))) {
(void)Tk_GetPixelsFromObj(NULL, tv->core.tkwin, objPtr, &tv->tree.rowHeight);
- tv->tree.rowHeight = MAX(tv->tree.rowHeight, 1);
}
+ tv->tree.rowHeight = MAX(tv->tree.rowHeight, 1);
+
+ if ((objPtr = Ttk_QueryOption(treeLayout, "-columnseparatorwidth", 0))) {
+ (void)Tk_GetPixelsFromObj(NULL, tv->core.tkwin, objPtr, &tv->tree.colSeparatorWidth);
+ }
+
+ /* Get item indent from style:
+ */
+ tv->tree.indent = DEFAULT_INDENT;
if ((objPtr = Ttk_QueryOption(treeLayout, "-indent", 0))) {
(void)Tk_GetPixelsFromObj(NULL, tv->core.tkwin, objPtr, &tv->tree.indent);
}
@@ -1617,17 +1947,18 @@ static Ttk_Layout TreeviewGetLayout(
static void TreeviewDoLayout(void *clientData)
{
Treeview *tv = (Treeview *)clientData;
- int totalRows, visibleRows;
+ int visibleRows;
+ int first, last, total;
Ttk_PlaceLayout(tv->core.layout,tv->core.state,Ttk_WinBox(tv->core.tkwin));
tv->tree.treeArea = Ttk_ClientRegion(tv->core.layout, "treearea");
ResizeColumns(tv, tv->tree.treeArea.width);
- TtkScrolled(tv->tree.xscrollHandle,
- tv->tree.xscroll.first,
- tv->tree.xscroll.first + tv->tree.treeArea.width,
- TreeWidth(tv));
+ first = tv->tree.xscroll.first;
+ last = first + tv->tree.treeArea.width - tv->tree.titleWidth;
+ total = TreeWidth(tv) - tv->tree.titleWidth;
+ TtkScrolled(tv->tree.xscrollHandle, first, last, total);
if (tv->tree.showFlags & SHOW_HEADINGS) {
tv->tree.headingArea = Ttk_PackBox(
@@ -1636,22 +1967,22 @@ static void TreeviewDoLayout(void *clientData)
tv->tree.headingArea = Ttk_MakeBox(0,0,0,0);
}
- tv->tree.root->state |= TTK_STATE_OPEN;
- totalRows = CountRows(tv->tree.root) - 1;
visibleRows = tv->tree.treeArea.height / tv->tree.rowHeight;
+ tv->tree.root->state |= TTK_STATE_OPEN;
+ UpdatePositionTree(tv);
+ first = tv->tree.yscroll.first;
+ last = tv->tree.yscroll.first + visibleRows - tv->tree.titleRows;
+ total = tv->tree.totalRows - tv->tree.titleRows;
if (tv->tree.treeArea.height % tv->tree.rowHeight) {
- /* When the treeview height doesn't correspond to an exact number
- * of rows, the visible row count must be incremented to draw a
- * partial row at the bottom. The total row count must also be
- * incremented to be able to scroll all the way to the bottom.
- */
- visibleRows++;
- totalRows++;
+ /* When the treeview height doesn't correspond to an exact number
+ * of rows, the last row count must be incremented to draw a
+ * partial row at the bottom. The total row count must also be
+ * incremented to be able to scroll all the way to the bottom.
+ */
+ last++;
+ total++;
}
- TtkScrolled(tv->tree.yscrollHandle,
- tv->tree.yscroll.first,
- tv->tree.yscroll.first + visibleRows,
- totalRows);
+ TtkScrolled(tv->tree.yscrollHandle, first, last, total);
}
/* + TreeviewSize --
@@ -1695,15 +2026,34 @@ static Ttk_State ItemState(Treeview *tv, TreeItem *item)
*/
static void DrawHeadings(Treeview *tv, Drawable d)
{
- const int x0 = tv->tree.headingArea.x - tv->tree.xscroll.first;
+ int x0 = tv->tree.headingArea.x - tv->tree.xscroll.first;
const int y0 = tv->tree.headingArea.y;
const int h0 = tv->tree.headingArea.height;
- int i = FirstColumn(tv);
+ Tcl_Size i = FirstColumn(tv);
int x = 0;
+ if (tv->tree.nTitleColumns > i) {
+ x = tv->tree.titleWidth;
+ i = tv->tree.nTitleColumns;
+ }
+
while (i < tv->tree.nDisplayColumns) {
TreeColumn *column = tv->tree.displayColumns[i];
Ttk_Box parcel = Ttk_MakeBox(x0+x, y0, column->width, h0);
+ if (x0+x+column->width > tv->tree.titleWidth) {
+ DisplayLayout(tv->tree.headingLayout,
+ column, column->headingState, parcel, d);
+ }
+ x += column->width;
+ ++i;
+ }
+
+ x0 = tv->tree.headingArea.x;
+ i = FirstColumn(tv);
+ x = 0;
+ while ((i < tv->tree.nTitleColumns) && (i < tv->tree.nDisplayColumns)) {
+ TreeColumn *column = tv->tree.displayColumns[i];
+ Ttk_Box parcel = Ttk_MakeBox(x0+x, y0, column->width, h0);
DisplayLayout(tv->tree.headingLayout,
column, column->headingState, parcel, d);
x += column->width;
@@ -1711,53 +2061,200 @@ static void DrawHeadings(Treeview *tv, Drawable d)
}
}
+/* + DrawSeparators --
+ * Draw separators between columns
+ */
+static void DrawSeparators(Treeview *tv, Drawable d)
+{
+ const int y0 = tv->tree.treeArea.y;
+ const int h0 = tv->tree.treeArea.height;
+ DisplayItem displayItem;
+ Ttk_Style style = Ttk_LayoutStyle(tv->tree.separatorLayout);
+ int x = tv->tree.treeArea.x;
+ Tcl_Size i;
+
+ Ttk_TagSetDefaults(tv->tree.tagTable, style, &displayItem);
+
+ for (i = FirstColumn(tv); i < tv->tree.nDisplayColumns; ++i) {
+ TreeColumn *column = tv->tree.displayColumns[i];
+ Ttk_Box parcel;
+ int xDraw = x + column->width;
+ x += column->width;
+
+ if (!column->separator) continue;
+
+ if (i >= tv->tree.nTitleColumns) {
+ xDraw -= tv->tree.xscroll.first;
+ if (xDraw < tv->tree.titleWidth) continue;
+ }
+
+ parcel = Ttk_MakeBox(xDraw - (tv->tree.colSeparatorWidth+1)/2, y0,
+ tv->tree.colSeparatorWidth, h0);
+ DisplayLayout(tv->tree.separatorLayout, &displayItem, 0, parcel, d);
+ }
+}
+
+/* + OverrideStriped --
+ * Each level of settings might add stripedbackground, and it should
+ * override background if this is indeed on a striped item.
+ * By copying it between each level, and NULL-ing stripedBgObj,
+ * it can be detected if the next level overrides it.
+ */
+ static void OverrideStriped(
+ Treeview *tv, TreeItem *item, DisplayItem *displayItem)
+{
+ int striped = item->visiblePos % 2 && tv->tree.striped;
+ if (striped && displayItem->stripedBgObj) {
+ displayItem->backgroundObj = displayItem->stripedBgObj;
+ displayItem->stripedBgObj = NULL;
+ }
+}
+
/* + PrepareItem --
* Fill in a displayItem record.
*/
static void PrepareItem(
- Treeview *tv, TreeItem *item, DisplayItem *displayItem)
+ Treeview *tv, TreeItem *item, DisplayItem *displayItem, Ttk_State state)
{
Ttk_Style style = Ttk_LayoutStyle(tv->core.layout);
- Ttk_State state = ItemState(tv, item);
+ Ttk_TagSetDefaults(tv->tree.tagTable, style, displayItem);
+ OverrideStriped(tv, item, displayItem);
Ttk_TagSetValues(tv->tree.tagTable, item->tagset, displayItem);
+ OverrideStriped(tv, item, displayItem);
Ttk_TagSetApplyStyle(tv->tree.tagTable, style, state, displayItem);
}
+/* Fill in data from item to temporary storage in columns. */
+static void PrepareCells(
+ Treeview *tv, TreeItem *item)
+{
+ Tcl_Size i, nValues = 0;
+ Tcl_Obj **values = NULL;
+ TreeColumn *column;
+
+ if (item->valuesObj) {
+ Tcl_ListObjGetElements(NULL, item->valuesObj, &nValues, &values);
+ }
+ for (i = 0; i < tv->tree.nColumns; ++i) {
+ tv->tree.columns[i].data = (i < nValues) ? values[i] : 0;
+ tv->tree.columns[i].selected = 0;
+ tv->tree.columns[i].tagset = NULL;
+ }
+ tv->tree.column0.data = NULL;
+ tv->tree.column0.selected = 0;
+ tv->tree.column0.tagset = NULL;
+
+ if (item->selObj != NULL) {
+ Tcl_ListObjGetElements(NULL, item->selObj, &nValues, &values);
+ for (i = 0; i < nValues; ++i) {
+ column = FindColumn(NULL, tv, values[i]);
+ /* Just in case. It should not be possible for column to be NULL */
+ if (column != NULL) {
+ column->selected = 1;
+ }
+ }
+ }
+ if (item->nTagSets > 0) {
+ tv->tree.column0.tagset = item->cellTagSets[0];
+ }
+ for (i = 1; i < item->nTagSets && i <= tv->tree.nColumns; ++i) {
+ tv->tree.columns[i-1].tagset = item->cellTagSets[i];
+ }
+}
+
/* + DrawCells --
* Draw data cells for specified item.
*/
static void DrawCells(
- Treeview *tv, TreeItem *item, DisplayItem *displayItem,
- Drawable d, int x, int y)
+ Treeview *tv, TreeItem *item,
+ DisplayItem *displayItem, DisplayItem *displayItemSel,
+ Drawable d, int x, int y, int title)
{
Ttk_Layout layout = tv->tree.cellLayout;
+ Ttk_Style style = Ttk_LayoutStyle(tv->core.layout);
Ttk_State state = ItemState(tv, item);
Ttk_Padding cellPadding = {4, 0, 4, 0};
- int rowHeight = tv->tree.rowHeight;
- int nValues = 0;
- Tcl_Obj **values = 0;
- int i;
+ DisplayItem displayItemLocal;
+ DisplayItem displayItemCell, displayItemCellSel;
+ int rowHeight = tv->tree.rowHeight * item->height;
+ int xPad = 0, defaultPadding = 1;
+ Tcl_Size i;
- if (!item->valuesObj) {
- return;
+ /* Adjust if the tree column has a separator */
+ if (tv->tree.showFlags & SHOW_TREE && tv->tree.column0.separator) {
+ xPad = tv->tree.colSeparatorWidth/2;
}
- Tcl_ListObjGetElements(NULL, item->valuesObj, &nValues, &values);
- for (i = 0; i < tv->tree.nColumns; ++i) {
- tv->tree.columns[i].data = (i < nValues) ? values[i] : 0;
+ /* An Item's image should not propagate to a Cell.
+ A Cell's image can only be set by cell tags. */
+ displayItemCell = *displayItem;
+ displayItemCellSel = *displayItemSel;
+ displayItemCell.imageObj = NULL;
+ displayItemCellSel.imageObj = NULL;
+ displayItemCell.imageAnchorObj = NULL;
+ displayItemCellSel.imageAnchorObj = NULL;
+
+ /* If explicit padding was asked for, skip default. */
+ if (Ttk_QueryStyle(Ttk_LayoutStyle(tv->tree.cellLayout), &displayItemCell,
+ tv->tree.displayOptionTable, "-padding", state) != NULL) {
+ defaultPadding = 0;
}
for (i = 1; i < tv->tree.nDisplayColumns; ++i) {
TreeColumn *column = tv->tree.displayColumns[i];
- Ttk_Box parcel = Ttk_PadBox(
- Ttk_MakeBox(x, y, column->width, rowHeight), cellPadding);
-
- displayItem->textObj = column->data;
- displayItem->anchorObj = column->anchorObj; /* <<NOTE-ANCHOR>> */
+ int parcelX = x + xPad;
+ int parcelWidth = column->separator ?
+ column->width - tv->tree.colSeparatorWidth : column->width;
+ Ttk_Box parcel = Ttk_MakeBox(parcelX, y, parcelWidth, rowHeight);
+ DisplayItem *displayItemUsed = &displayItemCell;
+ Ttk_State stateCell = state;
+ Tk_Anchor textAnchor, imageAnchor;
+ xPad = column->separator ? tv->tree.colSeparatorWidth/2 : 0;
- DisplayLayout(layout, displayItem, state, parcel, d);
x += column->width;
+ if (title && i >= tv->tree.nTitleColumns) break;
+ if (!title && i < tv->tree.nTitleColumns) continue;
+ if (!title && x < tv->tree.titleWidth) continue;
+
+ if (column->selected) {
+ displayItemUsed = &displayItemCellSel;
+ stateCell |= TTK_STATE_SELECTED;
+ }
+
+ if (column->tagset) {
+ displayItemLocal = *displayItemUsed;
+ displayItemUsed = &displayItemLocal;
+ Ttk_TagSetValues(tv->tree.tagTable, column->tagset,
+ displayItemUsed);
+ OverrideStriped(tv, item, displayItemUsed);
+ Ttk_TagSetApplyStyle(tv->tree.tagTable, style, stateCell,
+ displayItemUsed);
+ }
+
+ displayItemUsed->textObj = column->data;
+ displayItemUsed->anchorObj = column->anchorObj;/* <<NOTE-ANCHOR>> */
+ Tk_GetAnchorFromObj(NULL, column->anchorObj, &textAnchor);
+
+ imageAnchor = DEFAULT_IMAGEANCHOR;
+ if (displayItemUsed->imageAnchorObj) {
+ Tk_GetAnchorFromObj(NULL, displayItemUsed->imageAnchorObj,
+ &imageAnchor);
+ }
+ /* displayItem was used to draw the full item backgound.
+ Redraw cell background if needed. */
+ if (displayItemUsed != &displayItemCell) {
+ DisplayLayout(tv->tree.rowLayout, displayItemUsed, stateCell,
+ parcel, d);
+ }
+
+ if (defaultPadding && displayItemUsed->paddingObj == NULL) {
+ /* If no explicit padding was asked for, add some default. */
+ parcel = Ttk_PadBox(parcel, cellPadding);
+ }
+
+ DisplayLayoutTree(imageAnchor, textAnchor,
+ layout, displayItemUsed, state, parcel, d);
}
}
@@ -1765,17 +2262,19 @@ static void DrawCells(
* Draw an item (row background, tree label, and cells).
*/
static void DrawItem(
- Treeview *tv, TreeItem *item, Drawable d, int depth, int row)
+ Treeview *tv, TreeItem *item, Drawable d, int depth)
{
+ Ttk_Style style = Ttk_LayoutStyle(tv->core.layout);
Ttk_State state = ItemState(tv, item);
- DisplayItem displayItem;
- int rowHeight = tv->tree.rowHeight;
+ DisplayItem displayItem, displayItemSel, displayItemLocal;
+ int rowHeight = tv->tree.rowHeight * item->height;
int x = tv->tree.treeArea.x - tv->tree.xscroll.first;
- int y = tv->tree.treeArea.y + rowHeight * (row - tv->tree.yscroll.first);
+ int xTitle = tv->tree.treeArea.x;
+ int dispRow = DisplayRow(item->rowPos, tv);
+ int y = tv->tree.treeArea.y + tv->tree.rowHeight * dispRow;
- if (row % 2) state |= TTK_STATE_ALTERNATE;
-
- PrepareItem(tv, item, &displayItem);
+ PrepareItem(tv, item, &displayItem, state);
+ PrepareItem(tv, item, &displayItemSel, state | TTK_STATE_SELECTED);
/* Draw row background:
*/
@@ -1784,63 +2283,118 @@ static void DrawItem(
DisplayLayout(tv->tree.rowLayout, &displayItem, state, rowBox, d);
}
+ /* Make room for tree label:
+ */
+ if (tv->tree.showFlags & SHOW_TREE) {
+ x += tv->tree.column0.width;
+ }
+
+ /* Draw data cells:
+ */
+ PrepareCells(tv, item);
+ DrawCells(tv, item, &displayItem, &displayItemSel, d, x, y, 0);
+
+ /* Draw row background for non-scrolled area:
+ */
+ if (tv->tree.nTitleColumns >= 1) {
+ Ttk_Box rowBox = Ttk_MakeBox(tv->tree.treeArea.x, y,
+ tv->tree.titleWidth, rowHeight);
+ DisplayLayout(tv->tree.rowLayout, &displayItem, state, rowBox, d);
+ }
+
/* Draw tree label:
*/
+ x = tv->tree.treeArea.x - tv->tree.xscroll.first;
if (tv->tree.showFlags & SHOW_TREE) {
+ TreeColumn *column = &tv->tree.column0;
int indent = depth * tv->tree.indent;
- int colwidth = tv->tree.column0.width;
- Ttk_Box parcel = Ttk_MakeBox(
- x+indent, y, colwidth-indent, rowHeight);
- if (item->textObj) { displayItem.textObj = item->textObj; }
- if (item->imageObj) { displayItem.imageObj = item->imageObj; }
- displayItem.anchorObj = tv->tree.column0.anchorObj;
- DisplayLayout(tv->tree.itemLayout, &displayItem, state, parcel, d);
- x += colwidth;
+ int colwidth = tv->tree.column0.width -
+ (tv->tree.column0.separator ? tv->tree.colSeparatorWidth/2 : 0);
+ int xTree = tv->tree.nTitleColumns >= 1 ? xTitle : x;
+ Ttk_Box parcel = Ttk_MakeBox(xTree, y, colwidth, rowHeight);
+ DisplayItem *displayItemUsed = &displayItem;
+ Ttk_State stateCell = state;
+ Tk_Anchor textAnchor, imageAnchor = DEFAULT_IMAGEANCHOR;
+ Ttk_Padding cellPadding = {(short)indent, 0, 0, 0};
+
+ if (column->selected) {
+ displayItemUsed = &displayItemSel;
+ stateCell |= TTK_STATE_SELECTED;
+ }
+
+ if (column->tagset) {
+ displayItemLocal = *displayItemUsed;
+ displayItemUsed = &displayItemLocal;
+ Ttk_TagSetValues(tv->tree.tagTable, column->tagset,
+ displayItemUsed);
+ OverrideStriped(tv, item, displayItemUsed);
+ Ttk_TagSetApplyStyle(tv->tree.tagTable, style, stateCell,
+ displayItemUsed);
+ }
+
+ displayItem.anchorObj = tv->tree.column0.anchorObj;
+ Tk_GetAnchorFromObj(NULL, column->anchorObj, &textAnchor);
+ displayItemUsed->textObj = item->textObj;
+ /* Item's image can be null, and may come from the tag */
+ if (item->imageObj) {
+ displayItemUsed->imageObj = item->imageObj;
+ }
+ if (item->imageAnchorObj) {
+ displayItemUsed->imageAnchorObj = item->imageAnchorObj;
+ }
+ if (displayItemUsed->imageAnchorObj) {
+ Tk_GetAnchorFromObj(NULL, displayItemUsed->imageAnchorObj,
+ &imageAnchor);
+ }
+
+ if (displayItemUsed != &displayItem) {
+ DisplayLayout(tv->tree.rowLayout, displayItemUsed, stateCell,
+ parcel, d);
+ }
+
+ parcel = Ttk_PadBox(parcel, cellPadding);
+ DisplayLayoutTree(imageAnchor, textAnchor,
+ tv->tree.itemLayout, displayItemUsed, state, parcel, d);
+ xTitle += colwidth;
}
- /* Draw data cells:
+ /* Draw non-scrolled data cells:
*/
- DrawCells(tv, item, &displayItem, d, x, y);
+ if (tv->tree.nTitleColumns > 1) {
+ DrawCells(tv, item, &displayItem, &displayItemSel, d, xTitle, y, 1);
+ }
}
/* + DrawSubtree --
* Draw an item and all of its (viewable) descendants.
- *
- * Returns:
- * Row number of the last item drawn.
*/
-static int DrawForest( /* forward */
- Treeview *tv, TreeItem *item, Drawable d, int depth, int row);
+static void DrawForest( /* forward */
+ Treeview *tv, TreeItem *item, Drawable d, int depth);
-static int DrawSubtree(
- Treeview *tv, TreeItem *item, Drawable d, int depth, int row)
+static void DrawSubtree(
+ Treeview *tv, TreeItem *item, Drawable d, int depth)
{
- if (row >= tv->tree.yscroll.first) {
- DrawItem(tv, item, d, depth, row);
+ int dispRow = DisplayRow(item->rowPos, tv);
+ if (dispRow >= 0) {
+ DrawItem(tv, item, d, depth);
}
if (item->state & TTK_STATE_OPEN) {
- return DrawForest(tv, item->children, d, depth + 1, row + 1);
- } else {
- return row + 1;
+ DrawForest(tv, item->children, d, depth + 1);
}
}
/* + DrawForest --
* Draw a sequence of items and their visible descendants.
- *
- * Returns:
- * Row number of the last item drawn.
*/
-static int DrawForest(
- Treeview *tv, TreeItem *item, Drawable d, int depth, int row)
+static void DrawForest(
+ Treeview *tv, TreeItem *item, Drawable d, int depth)
{
- while (item && row < tv->tree.yscroll.last) {
- row = DrawSubtree(tv, item, d, depth, row);
+ while (item) {
+ DrawSubtree(tv, item, d, depth);
item = item->next;
}
- return row;
}
/* + TreeviewDisplay --
@@ -1854,7 +2408,8 @@ static void TreeviewDisplay(void *clientData, Drawable d)
if (tv->tree.showFlags & SHOW_HEADINGS) {
DrawHeadings(tv, d);
}
- DrawForest(tv, tv->tree.root->children, d, 0, 0);
+ DrawForest(tv, tv->tree.root->children, d, 0);
+ DrawSeparators(tv, d);
}
/*------------------------------------------------------------------------
@@ -1960,7 +2515,7 @@ static TreeItem *DeleteItems(TreeItem *item, TreeItem *delq)
* Return the list of children associated with $item
*/
static int TreeviewChildrenCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Treeview *tv = (Treeview *)recordPtr;
TreeItem *item;
@@ -2030,6 +2585,7 @@ static int TreeviewChildrenCommand(
}
ckfree(newChildren);
+ tv->tree.rowPosNeedsUpdate = 1;
TtkRedisplayWidget(&tv->core);
}
@@ -2040,7 +2596,7 @@ static int TreeviewChildrenCommand(
* Return the item ID of $item's parent.
*/
static int TreeviewParentCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Treeview *tv = (Treeview *)recordPtr;
TreeItem *item;
@@ -2068,7 +2624,7 @@ static int TreeviewParentCommand(
* Return the ID of $item's next sibling.
*/
static int TreeviewNextCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Treeview *tv = (Treeview *)recordPtr;
TreeItem *item;
@@ -2093,7 +2649,7 @@ static int TreeviewNextCommand(
* Return the ID of $item's previous sibling.
*/
static int TreeviewPrevCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Treeview *tv = (Treeview *)recordPtr;
TreeItem *item;
@@ -2118,11 +2674,11 @@ static int TreeviewPrevCommand(
* Return the index of $item within its parent.
*/
static int TreeviewIndexCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Treeview *tv = (Treeview *)recordPtr;
TreeItem *item;
- int index = 0;
+ Tcl_Size index = 0;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "item");
@@ -2138,7 +2694,7 @@ static int TreeviewIndexCommand(
item = item->prev;
}
- Tcl_SetObjResult(interp, Tcl_NewIntObj(index));
+ Tcl_SetObjResult(interp, TkNewIndexObj(index));
return TCL_OK;
}
@@ -2146,7 +2702,7 @@ static int TreeviewIndexCommand(
* Test if the specified item id is present in the tree.
*/
static int TreeviewExistsCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Treeview *tv = (Treeview *)recordPtr;
Tcl_HashEntry *entryPtr;
@@ -2165,7 +2721,7 @@ static int TreeviewExistsCommand(
* Return bounding box [x y width height] of specified item.
*/
static int TreeviewBBoxCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Treeview *tv = (Treeview *)recordPtr;
TreeItem *item = 0;
@@ -2203,14 +2759,14 @@ static int TreeviewBBoxCommand(
*/
static int TreeviewHorribleIdentify(
Tcl_Interp *interp,
- TCL_UNUSED(int), /* objc */
+ TCL_UNUSED(Tcl_Size), /* objc */
Tcl_Obj *const objv[],
Treeview *tv)
{
const char *what = "nothing", *detail = NULL;
TreeItem *item = 0;
Tcl_Obj *result;
- int dColumnNumber;
+ Tcl_Size dColumnNumber;
char dcolbuf[32];
int x, y, x1;
@@ -2225,7 +2781,7 @@ static int TreeviewHorribleIdentify(
if (dColumnNumber < 0) {
goto done;
}
- snprintf(dcolbuf, sizeof(dcolbuf), "#%d", dColumnNumber);
+ snprintf(dcolbuf, sizeof(dcolbuf), "#%" TCL_SIZE_MODIFIER "d", dColumnNumber);
if (Ttk_BoxContains(tv->tree.headingArea,x,y)) {
if (-HALO <= x1 - x && x1 - x <= HALO) {
@@ -2244,13 +2800,14 @@ static int TreeviewHorribleIdentify(
Ttk_Box itemBox;
DisplayItem displayItem;
Ttk_Element element;
+ Ttk_State state = ItemState(tv, item);
BoundingBox(tv, item, NULL, &itemBox);
- PrepareItem(tv, item, &displayItem);
- if (item->textObj) { displayItem.textObj = item->textObj; }
- if (item->imageObj) { displayItem.imageObj = item->imageObj; }
+ PrepareItem(tv, item, &displayItem, state);
+ if (item->textObj) { displayItem.textObj = item->textObj; }
+ if (item->imageObj) { displayItem.imageObj = item->imageObj; }
Ttk_RebindSublayout(layout, &displayItem);
- Ttk_PlaceLayout(layout, ItemState(tv,item), itemBox);
+ Ttk_PlaceLayout(layout, state, itemBox);
element = Ttk_IdentifyElement(layout, x, y);
if (element) {
@@ -2279,11 +2836,11 @@ done:
*/
static int TreeviewIdentifyCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
static const char *const submethodStrings[] =
- { "region", "item", "column", "row", "element", NULL };
- enum { I_REGION, I_ITEM, I_COLUMN, I_ROW, I_ELEMENT };
+ { "region", "item", "column", "row", "element", "cell", NULL };
+ enum { I_REGION, I_ITEM, I_COLUMN, I_ROW, I_ELEMENT, I_CELL };
Treeview *tv = (Treeview *)recordPtr;
int submethod;
@@ -2293,7 +2850,7 @@ static int TreeviewIdentifyCommand(
Ttk_Box bbox;
TreeItem *item;
TreeColumn *column = 0;
- int colno;
+ Tcl_Size colno;
int x1;
if (objc == 4) { /* Old form */
@@ -2305,7 +2862,7 @@ static int TreeviewIdentifyCommand(
if (Tcl_GetIndexFromObjStruct(interp, objv[2], submethodStrings,
sizeof(char *), "command", TCL_EXACT, &submethod) != TCL_OK
- || Tk_GetPixelsFromObj(interp, tv->core.tkwin, objv[3], &x) != TCL_OK
+ || Tk_GetPixelsFromObj(interp, tv->core.tkwin, objv[3], &x) != TCL_OK
|| Tk_GetPixelsFromObj(interp, tv->core.tkwin, objv[4], &y) != TCL_OK
) {
return TCL_ERROR;
@@ -2331,7 +2888,16 @@ static int TreeviewIdentifyCommand(
case I_COLUMN :
if (colno >= 0) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf("#%d", colno));
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("#%" TCL_SIZE_MODIFIER "d", colno));
+ }
+ break;
+
+ case I_CELL :
+ if (item && colno >= 0) {
+ Tcl_Obj *elem[2];
+ elem[0] = ItemID(tv, item);
+ elem[1] = Tcl_ObjPrintf("#%" TCL_SIZE_MODIFIER "d", colno);
+ Tcl_SetObjResult(interp, Tcl_NewListObj(2, elem));
}
break;
@@ -2340,6 +2906,7 @@ static int TreeviewIdentifyCommand(
Ttk_Layout layout = 0;
DisplayItem displayItem;
Ttk_Element element;
+ Ttk_State state;
switch (region) {
case REGION_NOTHING:
@@ -2357,15 +2924,18 @@ static int TreeviewIdentifyCommand(
break;
}
+ if (item == NULL) {
+ return TCL_OK;
+ }
if (!BoundingBox(tv, item, column, &bbox)) {
return TCL_OK;
}
-
- PrepareItem(tv, item, &displayItem);
- if (item->textObj) { displayItem.textObj = item->textObj; }
- if (item->imageObj) { displayItem.imageObj = item->imageObj; }
+ state = ItemState(tv, item);
+ PrepareItem(tv, item, &displayItem, state);
+ if (item->textObj) { displayItem.textObj = item->textObj; }
+ if (item->imageObj) { displayItem.imageObj = item->imageObj; }
Ttk_RebindSublayout(layout, &displayItem);
- Ttk_PlaceLayout(layout, ItemState(tv,item), bbox);
+ Ttk_PlaceLayout(layout, state, bbox);
element = Ttk_IdentifyElement(layout, x, y);
if (element) {
@@ -2386,13 +2956,13 @@ static int TreeviewIdentifyCommand(
* Query or configure item options.
*/
static int TreeviewItemCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Treeview *tv = (Treeview *)recordPtr;
TreeItem *item;
if (objc < 3) {
- Tcl_WrongNumArgs(interp, 2, objv, "item ?option ?value??...");
+ Tcl_WrongNumArgs(interp, 2, objv, "item ?-option ?value??...");
return TCL_ERROR;
}
if (!(item = FindItem(interp, tv, objv[2]))) {
@@ -2414,7 +2984,7 @@ static int TreeviewItemCommand(
* Column data accessor
*/
static int TreeviewColumnCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Treeview *tv = (Treeview *)recordPtr;
TreeColumn *column;
@@ -2442,7 +3012,7 @@ static int TreeviewColumnCommand(
* Heading data accessor
*/
static int TreeviewHeadingCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Treeview *tv = (Treeview *)recordPtr;
Tk_OptionTable optionTable = tv->tree.headingOptionTable;
@@ -2472,12 +3042,12 @@ static int TreeviewHeadingCommand(
* Query or configure cell values
*/
static int TreeviewSetCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Treeview *tv = (Treeview *)recordPtr;
TreeItem *item;
TreeColumn *column;
- int columnNumber;
+ Tcl_Size columnNumber;
if (objc < 3 || objc > 5) {
Tcl_WrongNumArgs(interp, 2, objv, "item ?column ?value??");
@@ -2537,7 +3107,7 @@ static int TreeviewSetCommand(
Tcl_SetObjResult(interp, result);
return TCL_OK;
} else { /* set column */
- int length;
+ Tcl_Size length;
item->valuesObj = unshareObj(item->valuesObj);
@@ -2566,7 +3136,7 @@ static int TreeviewSetCommand(
* Insert a new item.
*/
static int TreeviewInsertCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Treeview *tv = (Treeview *)recordPtr;
TreeItem *parent, *sibling, *newItem;
@@ -2624,7 +3194,7 @@ static int TreeviewInsertCommand(
*/
newItem = NewItem();
Tk_InitOptions(
- interp, (void *)newItem, tv->tree.itemOptionTable, tv->core.tkwin);
+ interp, newItem, tv->tree.itemOptionTable, tv->core.tkwin);
newItem->tagset = Ttk_GetTagSetFromObj(NULL, tv->tree.tagTable, NULL);
if (ConfigureItem(interp, tv, newItem, objc, objv) != TCL_OK) {
Tcl_DeleteHashEntry(entryPtr);
@@ -2637,6 +3207,7 @@ static int TreeviewInsertCommand(
Tcl_SetHashValue(entryPtr, newItem);
newItem->entryPtr = entryPtr;
InsertItem(parent, sibling, newItem);
+ tv->tree.rowPosNeedsUpdate = 1;
TtkRedisplayWidget(&tv->core);
Tcl_SetObjResult(interp, ItemID(tv, newItem));
@@ -2647,11 +3218,11 @@ static int TreeviewInsertCommand(
* Unlink each item in $items from the tree.
*/
static int TreeviewDetachCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Treeview *tv = (Treeview *)recordPtr;
TreeItem **items;
- int i;
+ Tcl_Size i;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "item");
@@ -2676,6 +3247,7 @@ static int TreeviewDetachCommand(
DetachItem(items[i]);
}
+ tv->tree.rowPosNeedsUpdate = 1;
TtkRedisplayWidget(&tv->core);
ckfree(items);
return TCL_OK;
@@ -2694,11 +3266,11 @@ static int TreeviewDetachCommand(
*/
static int TreeviewDeleteCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Treeview *tv = (Treeview *)recordPtr;
TreeItem **items, *delq;
- int i;
+ Tcl_Size i;
int selChange = 0;
if (objc != 3) {
@@ -2726,9 +3298,15 @@ static int TreeviewDeleteCommand(
*/
delq = 0;
for (i = 0; items[i]; ++i) {
- if (items[i]->state & TTK_STATE_SELECTED) {
- selChange = 1;
- }
+ if (items[i]->state & TTK_STATE_SELECTED) {
+ selChange = 1;
+ } else if (items[i]->selObj != NULL) {
+ Tcl_Size length;
+ Tcl_ListObjLength(interp, items[i]->selObj, &length);
+ if (length > 0) {
+ selChange = 1;
+ }
+ }
delq = DeleteItems(items[i], delq);
}
@@ -2746,8 +3324,9 @@ static int TreeviewDeleteCommand(
ckfree(items);
if (selChange) {
- TtkSendVirtualEvent(tv->core.tkwin, "TreeviewSelect");
+ Tk_SendVirtualEvent(tv->core.tkwin, "TreeviewSelect", NULL);
}
+ tv->tree.rowPosNeedsUpdate = 1;
TtkRedisplayWidget(&tv->core);
return TCL_OK;
}
@@ -2756,7 +3335,7 @@ static int TreeviewDeleteCommand(
* Move $item to the specified $index in $parent's child list.
*/
static int TreeviewMoveCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Treeview *tv = (Treeview *)recordPtr;
TreeItem *item, *parent;
@@ -2809,6 +3388,7 @@ static int TreeviewMoveCommand(
DetachItem(item);
InsertItem(parent, sibling, item);
+ tv->tree.rowPosNeedsUpdate = 1;
TtkRedisplayWidget(&tv->core);
return TCL_OK;
}
@@ -2818,14 +3398,14 @@ static int TreeviewMoveCommand(
*/
static int TreeviewXViewCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Treeview *tv = (Treeview *)recordPtr;
return TtkScrollviewCommand(interp, objc, objv, tv->tree.xscrollHandle);
}
static int TreeviewYViewCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Treeview *tv = (Treeview *)recordPtr;
return TtkScrollviewCommand(interp, objc, objv, tv->tree.yscrollHandle);
@@ -2835,11 +3415,11 @@ static int TreeviewYViewCommand(
* Ensure that $item is visible.
*/
static int TreeviewSeeCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Treeview *tv = (Treeview *)recordPtr;
TreeItem *item, *parent;
- int rowNumber;
+ int scrollRow1, scrollRow2, visibleRows;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "item");
@@ -2856,18 +3436,28 @@ static int TreeviewSeeCommand(
parent->openObj = unshareObj(parent->openObj);
Tcl_SetBooleanObj(parent->openObj, 1);
parent->state |= TTK_STATE_OPEN;
+ tv->tree.rowPosNeedsUpdate = 1;
TtkRedisplayWidget(&tv->core);
}
}
+ if (tv->tree.rowPosNeedsUpdate) {
+ UpdatePositionTree(tv);
+ }
/* Make sure item is visible:
*/
- rowNumber = RowNumber(tv, item);
- if (rowNumber < tv->tree.yscroll.first) {
- TtkScrollTo(tv->tree.yscrollHandle, rowNumber, 1);
- } else if (rowNumber >= tv->tree.yscroll.last) {
- TtkScrollTo(tv->tree.yscrollHandle,
- tv->tree.yscroll.first + (1+rowNumber - tv->tree.yscroll.last), 1);
+ if (item->rowPos < tv->tree.titleRows) {
+ return TCL_OK;
+ }
+ visibleRows = tv->tree.treeArea.height / tv->tree.rowHeight
+ - tv->tree.titleRows;
+ scrollRow1 = item->rowPos - tv->tree.titleRows;
+ scrollRow2 = scrollRow1 + item->height - 1;
+ if (scrollRow1 < tv->tree.yscroll.first || item->height > visibleRows) {
+ TtkScrollTo(tv->tree.yscrollHandle, scrollRow1, 1);
+ } else if (scrollRow2 >= tv->tree.yscroll.first + visibleRows) {
+ scrollRow1 = 1 + scrollRow2 - visibleRows;
+ TtkScrollTo(tv->tree.yscrollHandle, scrollRow1, 1);
}
return TCL_OK;
@@ -2881,11 +3471,11 @@ static int TreeviewSeeCommand(
* Set right edge of display column $column to x position $X
*/
static int TreeviewDragCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Treeview *tv = (Treeview *)recordPtr;
int left = tv->tree.treeArea.x - tv->tree.xscroll.first;
- int i = FirstColumn(tv);
+ Tcl_Size i = FirstColumn(tv);
TreeColumn *column;
int newx;
@@ -2903,6 +3493,10 @@ static int TreeviewDragCommand(
TreeColumn *c = tv->tree.displayColumns[i];
int right = left + c->width;
if (c == column) {
+ if (i < tv->tree.nTitleColumns) {
+ /* Unscrollable column, remove scroll shift */
+ right += tv->tree.xscroll.first;
+ }
DragColumn(tv, i, newx - right);
TtkRedisplayWidget(&tv->core);
return TCL_OK;
@@ -2917,7 +3511,7 @@ static int TreeviewDragCommand(
}
static int TreeviewDropCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Treeview *tv = (Treeview *)recordPtr;
@@ -2937,7 +3531,7 @@ static int TreeviewDropCommand(
/* + $tree focus ?item?
*/
static int TreeviewFocusCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Treeview *tv = (Treeview *)recordPtr;
@@ -2962,7 +3556,7 @@ static int TreeviewFocusCommand(
/* + $tree selection ?add|remove|set|toggle $items?
*/
static int TreeviewSelectionCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
enum {
SELECTION_SET, SELECTION_ADD, SELECTION_REMOVE, SELECTION_TOGGLE
@@ -3041,7 +3635,252 @@ static int TreeviewSelectionCommand(
ckfree(items);
if (selChange) {
- TtkSendVirtualEvent(tv->core.tkwin, "TreeviewSelect");
+ Tk_SendVirtualEvent(tv->core.tkwin, "TreeviewSelect", NULL);
+ }
+ TtkRedisplayWidget(&tv->core);
+
+ return TCL_OK;
+}
+
+/* + SelObjChangeElement --
+ * Change an element in a cell selection list.
+ */
+static int SelObjChangeElement(
+ Treeview *tv, Tcl_Obj *listPtr, Tcl_Obj *elemPtr,
+ int add,
+ TCL_UNUSED(int) /*remove*/,
+ int toggle)
+{
+ Tcl_Size i, nElements;
+ int anyChange = 0;
+ TreeColumn *column, *elemColumn;
+ Tcl_Obj **elements;
+
+ elemColumn = FindColumn(NULL, tv, elemPtr);
+ Tcl_ListObjGetElements(NULL, listPtr, &nElements, &elements);
+ for (i = 0; i < nElements; i++) {
+ column = FindColumn(NULL, tv, elements[i]);
+ if (column == elemColumn) {
+ if (add) {
+ return anyChange;
+ }
+ Tcl_ListObjReplace(NULL, listPtr, i, 1, 0, NULL);
+ anyChange = 1;
+ return anyChange;
+ }
+ }
+ if (add || toggle) {
+ Tcl_ListObjAppendElement(NULL, listPtr, elemColumn->idObj);
+ anyChange = 1;
+ }
+ return anyChange;
+}
+
+/* + $tree cellselection ?add|remove|set|toggle $items?
+ */
+static int CellSelectionRange(
+ Tcl_Interp *interp, Treeview *tv, Tcl_Obj *fromCell, Tcl_Obj *toCell,
+ int add, int remove, int toggle)
+{
+ TreeCell cellFrom, cellTo;
+ TreeItem *item;
+ Tcl_Obj *columns, **elements;
+ int colno, fromNo, toNo, anyChange = 0;
+ Tcl_Size i, nElements;
+ int set = !(add || remove || toggle);
+
+ if (GetCellFromObj(interp, tv, fromCell, 1, &fromNo, &cellFrom)
+ != TCL_OK) {
+ return TCL_ERROR;
+ }
+ if (GetCellFromObj(interp, tv, toCell, 1, &toNo, &cellTo)
+ != TCL_OK) {
+ return TCL_ERROR;
+ }
+
+ /* Correct order.
+ */
+ if (fromNo > toNo) {
+ colno = fromNo;
+ fromNo = toNo;
+ toNo = colno;
+ }
+
+ /* Make a list of columns in this rectangle.
+ */
+ columns = Tcl_NewListObj(0, 0);
+ Tcl_IncrRefCount(columns);
+ for (colno = fromNo; colno <= toNo; colno++) {
+ Tcl_ListObjAppendElement(NULL, columns,
+ tv->tree.displayColumns[colno]->idObj);
+ }
+
+ /* Set is the only operation that affects items outside its rectangle.
+ * Start with clearing out.
+ */
+ if (set) {
+ anyChange = CellSelectionClear(tv);
+ }
+
+ /* Correct order.
+ */
+ if (tv->tree.rowPosNeedsUpdate) {
+ UpdatePositionTree(tv);
+ }
+ if (cellFrom.item->itemPos > cellTo.item->itemPos) {
+ item = cellFrom.item;
+ cellFrom.item = cellTo.item;
+ cellTo.item = item;
+ }
+
+ /* Go through all items in this rectangle.
+ */
+ for (item = cellFrom.item; item; item = NextPreorder(item)) {
+ if (item->selObj != NULL) {
+ item->selObj = unshareObj(item->selObj);
+
+ Tcl_ListObjGetElements(NULL, columns, &nElements, &elements);
+ for (i = 0; i < nElements; ++i) {
+ anyChange |= SelObjChangeElement(tv, item->selObj, elements[i],
+ add, remove, toggle);
+ }
+ } else {
+ /* Set, add and toggle do the same thing when empty before.
+ */
+ if (!remove) {
+ item->selObj = columns;
+ Tcl_IncrRefCount(item->selObj);
+ anyChange = 1;
+ }
+ }
+ if (item == cellTo.item) {
+ break;
+ }
+ }
+
+ Tcl_DecrRefCount(columns);
+
+ if (anyChange) {
+ Tk_SendVirtualEvent(tv->core.tkwin, "TreeviewSelect", NULL);
+ }
+ TtkRedisplayWidget(&tv->core);
+ return TCL_OK;
+}
+
+/* + $tree cellselection ?add|remove|set|toggle $items?
+ */
+static int TreeviewCellSelectionCommand(
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
+{
+ enum {
+ SELECTION_SET, SELECTION_ADD, SELECTION_REMOVE, SELECTION_TOGGLE
+ };
+ static const char *const selopStrings[] = {
+ "set", "add", "remove", "toggle", NULL
+ };
+
+ Treeview *tv = (Treeview *)recordPtr;
+ int selop, anyChange = 0;
+ Tcl_Size i, nCells;
+ TreeCell *cells;
+ TreeItem *item;
+
+ if (objc == 2) {
+ Tcl_Obj *result = Tcl_NewListObj(0,0);
+ for (item = tv->tree.root->children; item; item = NextPreorder(item)) {
+ if (item->selObj != NULL) {
+ Tcl_Size n, elemc;
+ Tcl_Obj **elemv;
+
+ Tcl_ListObjGetElements(interp, item->selObj, &n, &elemv);
+ elemc = n;
+ for (i = 0; i < elemc; ++i) {
+ Tcl_Obj *elem[2];
+ elem[0] = ItemID(tv, item);
+ elem[1] = elemv[i];
+ Tcl_ListObjAppendElement(NULL, result,
+ Tcl_NewListObj(2, elem));
+ }
+ }
+ }
+ Tcl_SetObjResult(interp, result);
+ return TCL_OK;
+ }
+
+ if (objc < 4 || objc > 5) {
+ Tcl_WrongNumArgs(interp, 2, objv, "?add|remove|set|toggle arg...?");
+ return TCL_ERROR;
+ }
+
+ if (Tcl_GetIndexFromObjStruct(interp, objv[2], selopStrings,
+ sizeof(char *), "cellselection operation", 0, &selop) != TCL_OK) {
+ return TCL_ERROR;
+ }
+
+ if (objc == 5) {
+ switch (selop)
+ {
+ case SELECTION_SET:
+ return CellSelectionRange(interp, tv, objv[3], objv[4], 0, 0, 0);
+ case SELECTION_ADD:
+ return CellSelectionRange(interp, tv, objv[3], objv[4], 1, 0, 0);
+ case SELECTION_REMOVE:
+ return CellSelectionRange(interp, tv, objv[3], objv[4], 0, 1, 0);
+ case SELECTION_TOGGLE:
+ return CellSelectionRange(interp, tv, objv[3], objv[4], 0, 0, 1);
+ }
+ }
+
+ cells = GetCellListFromObj(interp, tv, objv[3], &nCells);
+ if (cells == NULL) {
+ return TCL_ERROR;
+ }
+
+ switch (selop)
+ {
+ case SELECTION_SET:
+ anyChange = CellSelectionClear(tv);
+ /*FALLTHRU*/
+ case SELECTION_ADD:
+ for (i = 0; i < nCells; i++) {
+ item = cells[i].item;
+ if (item->selObj == NULL) {
+ item->selObj = Tcl_NewListObj(0, 0);
+ Tcl_IncrRefCount(item->selObj);
+ }
+ item->selObj = unshareObj(item->selObj);
+ anyChange |= SelObjChangeElement(tv, item->selObj,
+ cells[i].colObj, 1, 0, 0);
+ }
+ break;
+ case SELECTION_REMOVE:
+ for (i = 0; i < nCells; i++) {
+ item = cells[i].item;
+ if (item->selObj == NULL) {
+ continue;
+ }
+ item->selObj = unshareObj(item->selObj);
+ anyChange |= SelObjChangeElement(tv, item->selObj,
+ cells[i].colObj, 0, 1, 0);
+ }
+ break;
+ case SELECTION_TOGGLE:
+ for (i = 0; i < nCells; i++) {
+ item = cells[i].item;
+ if (item->selObj == NULL) {
+ item->selObj = Tcl_NewListObj(0, 0);
+ Tcl_IncrRefCount(item->selObj);
+ }
+ item->selObj = unshareObj(item->selObj);
+ anyChange = SelObjChangeElement(tv, item->selObj,
+ cells[i].colObj, 0, 0, 1);
+ }
+ break;
+ }
+
+ ckfree(cells);
+ if (anyChange) {
+ Tk_SendVirtualEvent(tv->core.tkwin, "TreeviewSelect", NULL);
}
TtkRedisplayWidget(&tv->core);
@@ -3055,7 +3894,7 @@ static int TreeviewSelectionCommand(
/* + $tv tag bind $tag ?$sequence ?$script??
*/
static int TreeviewTagBindCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Treeview *tv = (Treeview *)recordPtr;
Ttk_TagTable tagTable = tv->tree.tagTable;
@@ -3108,7 +3947,7 @@ static int TreeviewTagBindCommand(
/* + $tv tag configure $tag ?-option ?value -option value...??
*/
static int TreeviewTagConfigureCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Treeview *tv = (Treeview *)recordPtr;
Ttk_TagTable tagTable = tv->tree.tagTable;
@@ -3136,10 +3975,40 @@ static int TreeviewTagConfigureCommand(
return Ttk_ConfigureTag(interp, tagTable, tag, objc - 4, objv + 4);
}
+/* + $tv tag delete $tag
+ */
+static int TreeviewTagDeleteCommand(
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
+{
+ Treeview *tv = (Treeview *)recordPtr;
+ Ttk_TagTable tagTable = tv->tree.tagTable;
+ TreeItem *item = tv->tree.root;
+ Ttk_Tag tag;
+
+ if (objc != 4) {
+ Tcl_WrongNumArgs(interp, 3, objv, "tagName");
+ return TCL_ERROR;
+ }
+
+ tag = Ttk_GetTagFromObj(tagTable, objv[3]);
+ /* remove the tag from all cells and items */
+ while (item) {
+ RemoveTagFromCellsAtItem(item, tag);
+ RemoveTag(item, tag);
+ item = NextPreorder(item);
+ }
+ /* then remove the tag from the tag table */
+ Tk_DeleteAllBindings(tv->tree.bindingTable, tag);
+ Ttk_DeleteTagFromTable(tagTable, tag);
+ TtkRedisplayWidget(&tv->core);
+
+ return TCL_OK;
+}
+
/* + $tv tag has $tag ?$item?
*/
static int TreeviewTagHasCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Treeview *tv = (Treeview *)recordPtr;
@@ -3172,10 +4041,72 @@ static int TreeviewTagHasCommand(
}
}
+/* + $tv tag cell has $tag ?$cell?
+ */
+static int TreeviewCtagHasCommand(
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
+{
+ Treeview *tv = (Treeview *)recordPtr;
+ TreeCell cell;
+ Tcl_Size i, columnNumber;
+
+ if (objc == 5) { /* Return list of all cells with tag */
+ Ttk_Tag tag = Ttk_GetTagFromObj(tv->tree.tagTable, objv[4]);
+ TreeItem *item = tv->tree.root;
+ Tcl_Obj *result = Tcl_NewListObj(0,0);
+
+ while (item) {
+ for (i = 0; i < item->nTagSets && i <= tv->tree.nColumns; ++i) {
+ if (item->cellTagSets[i] != NULL) {
+ if (Ttk_TagSetContains(item->cellTagSets[i], tag)) {
+ Tcl_Obj *elem[2];
+ elem[0] = ItemID(tv, item);
+ if (i == 0) {
+ elem[1] = tv->tree.column0.idObj;
+ } else {
+ elem[1] = tv->tree.columns[i-1].idObj;
+ }
+ Tcl_ListObjAppendElement(NULL, result,
+ Tcl_NewListObj(2, elem));
+ }
+ }
+ }
+ item = NextPreorder(item);
+ }
+
+ Tcl_SetObjResult(interp, result);
+ return TCL_OK;
+ } else if (objc == 6) { /* Test if cell has specified tag */
+ Ttk_Tag tag = Ttk_GetTagFromObj(tv->tree.tagTable, objv[4]);
+ int result = 0;
+ if (GetCellFromObj(interp, tv, objv[5], 0, NULL, &cell) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ if (cell.column == &tv->tree.column0) {
+ columnNumber = 0;
+ } else {
+ columnNumber = cell.column - tv->tree.columns + 1;
+ }
+ if (columnNumber < cell.item->nTagSets) {
+ if (cell.item->cellTagSets[columnNumber] != NULL) {
+ result = Ttk_TagSetContains(
+ cell.item->cellTagSets[columnNumber],
+ tag);
+ }
+ }
+
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(result));
+ return TCL_OK;
+ } else {
+ Tcl_WrongNumArgs(interp, 4, objv, "tagName ?cell?");
+ return TCL_ERROR;
+ }
+}
+
/* + $tv tag names
*/
static int TreeviewTagNamesCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Treeview *tv = (Treeview *)recordPtr;
@@ -3199,12 +4130,12 @@ static void AddTag(TreeItem *item, Ttk_Tag tag)
}
static int TreeviewTagAddCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Treeview *tv = (Treeview *)recordPtr;
Ttk_Tag tag;
TreeItem **items;
- int i;
+ Tcl_Size i;
if (objc != 5) {
Tcl_WrongNumArgs(interp, 3, objv, "tagName items");
@@ -3221,12 +4152,77 @@ static int TreeviewTagAddCommand(
for (i = 0; items[i]; ++i) {
AddTag(items[i], tag);
}
+ ckfree(items);
TtkRedisplayWidget(&tv->core);
return TCL_OK;
}
+/* Make sure tagset at column is allocated and initialised */
+static void AllocCellTagSets(Treeview *tv, TreeItem *item, Tcl_Size columnNumber)
+{
+ Tcl_Size i, newSize = MAX(columnNumber + 1, tv->tree.nColumns + 1);
+ if (item->nTagSets < newSize) {
+ if (item->cellTagSets == NULL) {
+ item->cellTagSets = (Ttk_TagSet *)
+ ckalloc(sizeof(Ttk_TagSet)*newSize);
+ } else {
+ item->cellTagSets = (Ttk_TagSet *)
+ ckrealloc(item->cellTagSets, sizeof(Ttk_TagSet) * newSize);
+ }
+ for (i = item->nTagSets; i < newSize; i++) {
+ item->cellTagSets[i] = NULL;
+ }
+ item->nTagSets = newSize;
+ }
+
+ if (item->cellTagSets[columnNumber] == NULL) {
+ item->cellTagSets[columnNumber] =
+ Ttk_GetTagSetFromObj(NULL, tv->tree.tagTable, NULL);
+ }
+}
+
+/* + $tv tag cell add $tag $cells
+ */
+static int TreeviewCtagAddCommand(
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
+{
+ Treeview *tv = (Treeview *)recordPtr;
+ Ttk_Tag tag;
+ TreeCell *cells;
+ TreeItem *item;
+ Tcl_Size i, nCells, columnNumber;
+
+ if (objc != 6) {
+ Tcl_WrongNumArgs(interp, 4, objv, "tagName cells");
+ return TCL_ERROR;
+ }
+
+ cells = GetCellListFromObj(interp, tv, objv[5], &nCells);
+ if (cells == NULL) {
+ return TCL_ERROR;
+ }
+
+ tag = Ttk_GetTagFromObj(tv->tree.tagTable, objv[4]);
+
+ for (i = 0; i < nCells; i++) {
+ if (cells[i].column == &tv->tree.column0) {
+ columnNumber = 0;
+ } else {
+ columnNumber = cells[i].column - tv->tree.columns + 1;
+ }
+ item = cells[i].item;
+ AllocCellTagSets(tv, item, columnNumber);
+ Ttk_TagSetAdd(item->cellTagSets[columnNumber], tag);
+ }
+
+ ckfree(cells);
+ TtkRedisplayWidget(&tv->core);
+
+ return TCL_OK;
+}
+
/* + $tv tag remove $tag ?$items?
*/
static void RemoveTag(TreeItem *item, Ttk_Tag tag)
@@ -3238,14 +4234,27 @@ static void RemoveTag(TreeItem *item, Ttk_Tag tag)
}
}
+/* Remove tag from all cells at row 'item'
+ */
+static void RemoveTagFromCellsAtItem(TreeItem *item, Ttk_Tag tag)
+{
+ Tcl_Size i;
+
+ for (i = 0; i < item->nTagSets; i++) {
+ if (item->cellTagSets[i] != NULL) {
+ Ttk_TagSetRemove(item->cellTagSets[i], tag);
+ }
+ }
+}
+
static int TreeviewTagRemoveCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
Treeview *tv = (Treeview *)recordPtr;
Ttk_Tag tag;
- if (objc < 4) {
- Tcl_WrongNumArgs(interp, 3, objv, "tagName items");
+ if (objc < 4 || objc > 5) {
+ Tcl_WrongNumArgs(interp, 3, objv, "tagName ?items?");
return TCL_ERROR;
}
@@ -3261,6 +4270,7 @@ static int TreeviewTagRemoveCommand(
for (i = 0; items[i]; ++i) {
RemoveTag(items[i], tag);
}
+ ckfree(items);
} else if (objc == 4) {
TreeItem *item = tv->tree.root;
while (item) {
@@ -3274,10 +4284,67 @@ static int TreeviewTagRemoveCommand(
return TCL_OK;
}
+/* + $tv tag cell remove $tag ?$cells?
+ */
+static int TreeviewCtagRemoveCommand(
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
+{
+ Treeview *tv = (Treeview *)recordPtr;
+ Ttk_Tag tag;
+ TreeCell *cells;
+ TreeItem *item;
+ Tcl_Size i, nCells, columnNumber;
+
+ if (objc < 5 || objc > 6) {
+ Tcl_WrongNumArgs(interp, 4, objv, "tagName ?cells?");
+ return TCL_ERROR;
+ }
+
+ tag = Ttk_GetTagFromObj(tv->tree.tagTable, objv[4]);
+
+ if (objc == 6) {
+ cells = GetCellListFromObj(interp, tv, objv[5], &nCells);
+ if (cells == NULL) {
+ return TCL_ERROR;
+ }
+
+ for (i = 0; i < nCells; i++) {
+ if (cells[i].column == &tv->tree.column0) {
+ columnNumber = 0;
+ } else {
+ columnNumber = cells[i].column - tv->tree.columns + 1;
+ }
+ item = cells[i].item;
+ AllocCellTagSets(tv, item, columnNumber);
+ Ttk_TagSetRemove(item->cellTagSets[columnNumber], tag);
+ }
+ ckfree(cells);
+ } else {
+ item = tv->tree.root;
+ while (item) {
+ RemoveTagFromCellsAtItem(item, tag);
+ item = NextPreorder(item);
+ }
+ }
+
+ TtkRedisplayWidget(&tv->core);
+
+ return TCL_OK;
+}
+
+static const Ttk_Ensemble TreeviewCtagCommands[] = {
+ { "add", TreeviewCtagAddCommand,0 },
+ { "has", TreeviewCtagHasCommand,0 },
+ { "remove", TreeviewCtagRemoveCommand,0 },
+ { 0,0,0 }
+};
+
static const Ttk_Ensemble TreeviewTagCommands[] = {
{ "add", TreeviewTagAddCommand,0 },
{ "bind", TreeviewTagBindCommand,0 },
+ { "cell", 0,TreeviewCtagCommands },
{ "configure", TreeviewTagConfigureCommand,0 },
+ { "delete", TreeviewTagDeleteCommand,0 },
{ "has", TreeviewTagHasCommand,0 },
{ "names", TreeviewTagNamesCommand,0 },
{ "remove", TreeviewTagRemoveCommand,0 },
@@ -3289,6 +4356,7 @@ static const Ttk_Ensemble TreeviewTagCommands[] = {
*/
static const Ttk_Ensemble TreeviewCommands[] = {
{ "bbox", TreeviewBBoxCommand,0 },
+ { "cellselection", TreeviewCellSelectionCommand,0 },
{ "children", TreeviewChildrenCommand,0 },
{ "cget", TtkWidgetCgetCommand,0 },
{ "column", TreeviewColumnCommand,0 },
@@ -3302,17 +4370,18 @@ static const Ttk_Ensemble TreeviewCommands[] = {
{ "heading", TreeviewHeadingCommand,0 },
{ "identify", TreeviewIdentifyCommand,0 },
{ "index", TreeviewIndexCommand,0 },
- { "instate", TtkWidgetInstateCommand,0 },
{ "insert", TreeviewInsertCommand,0 },
+ { "instate", TtkWidgetInstateCommand,0 },
{ "item", TreeviewItemCommand,0 },
{ "move", TreeviewMoveCommand,0 },
{ "next", TreeviewNextCommand,0 },
{ "parent", TreeviewParentCommand,0 },
{ "prev", TreeviewPrevCommand,0 },
{ "see", TreeviewSeeCommand,0 },
- { "selection" , TreeviewSelectionCommand,0 },
+ { "selection", TreeviewSelectionCommand,0 },
{ "set", TreeviewSetCommand,0 },
{ "state", TtkWidgetStateCommand,0 },
+ { "style", TtkWidgetStyleCommand,0 },
{ "tag", 0,TreeviewTagCommands },
{ "xview", TreeviewXViewCommand,0 },
{ "yview", TreeviewYViewCommand,0 },
@@ -3323,7 +4392,7 @@ static const Ttk_Ensemble TreeviewCommands[] = {
* +++ Widget definition.
*/
-static WidgetSpec TreeviewWidgetSpec = {
+static const WidgetSpec TreeviewWidgetSpec = {
"Treeview", /* className */
sizeof(Treeview), /* recordSize */
TreeviewOptionSpecs, /* optionSpecs */
@@ -3357,6 +4426,7 @@ TTK_LAYOUT("Item",
TTK_LAYOUT("Cell",
TTK_GROUP("Treedata.padding", TTK_FILL_BOTH,
+ TTK_NODE("Treeitem.image", TTK_PACK_LEFT)
TTK_NODE("Treeitem.text", TTK_FILL_BOTH)))
TTK_LAYOUT("Heading",
@@ -3369,6 +4439,9 @@ TTK_LAYOUT("Heading",
TTK_LAYOUT("Row",
TTK_NODE("Treeitem.row", TTK_FILL_BOTH))
+TTK_LAYOUT("Separator",
+ TTK_NODE("Treeitem.separator", TTK_FILL_BOTH))
+
TTK_END_LAYOUT_TABLE
/*------------------------------------------------------------------------
@@ -3381,13 +4454,13 @@ typedef struct {
Tcl_Obj *marginsObj;
} TreeitemIndicator;
-static Ttk_ElementOptionSpec TreeitemIndicatorOptions[] = {
+static const Ttk_ElementOptionSpec TreeitemIndicatorOptions[] = {
{ "-foreground", TK_OPTION_COLOR,
- Tk_Offset(TreeitemIndicator,colorObj), DEFAULT_FOREGROUND },
+ offsetof(TreeitemIndicator,colorObj), DEFAULT_FOREGROUND },
{ "-indicatorsize", TK_OPTION_PIXELS,
- Tk_Offset(TreeitemIndicator,sizeObj), "12" },
+ offsetof(TreeitemIndicator,sizeObj), "12" },
{ "-indicatormargins", TK_OPTION_STRING,
- Tk_Offset(TreeitemIndicator,marginsObj), "2 2 4 2" },
+ offsetof(TreeitemIndicator,marginsObj), "2 2 4 2" },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -3441,7 +4514,7 @@ static void TreeitemIndicatorDraw(
Tk_FreeGC(Tk_Display(tkwin), gc);
}
-static Ttk_ElementSpec TreeitemIndicatorElementSpec = {
+static const Ttk_ElementSpec TreeitemIndicatorElementSpec = {
TK_STYLE_VERSION_2,
sizeof(TreeitemIndicator),
TreeitemIndicatorOptions,
@@ -3458,11 +4531,11 @@ typedef struct {
Tcl_Obj *rowNumberObj;
} RowElement;
-static Ttk_ElementOptionSpec RowElementOptions[] = {
+static const Ttk_ElementOptionSpec RowElementOptions[] = {
{ "-background", TK_OPTION_COLOR,
- Tk_Offset(RowElement,backgroundObj), DEFAULT_BACKGROUND },
+ offsetof(RowElement,backgroundObj), DEFAULT_BACKGROUND },
{ "-rownumber", TK_OPTION_INT,
- Tk_Offset(RowElement,rowNumberObj), "0" },
+ offsetof(RowElement,rowNumberObj), "0" },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -3482,7 +4555,7 @@ static void RowElementDraw(
b.x, b.y, b.width, b.height);
}
-static Ttk_ElementSpec RowElementSpec = {
+static const Ttk_ElementSpec RowElementSpec = {
TK_STYLE_VERSION_2,
sizeof(RowElement),
RowElementOptions,
@@ -3504,6 +4577,7 @@ TtkTreeview_Init(Tcl_Interp *interp)
Ttk_RegisterElement(interp, theme, "Treeitem.indicator",
&TreeitemIndicatorElementSpec, 0);
Ttk_RegisterElement(interp, theme, "Treeitem.row", &RowElementSpec, 0);
+ Ttk_RegisterElement(interp, theme, "Treeitem.separator", &RowElementSpec, 0);
Ttk_RegisterElement(interp, theme, "Treeheading.cell", &RowElementSpec, 0);
Ttk_RegisterElement(interp, theme, "treearea", &ttkNullElementSpec, 0);
diff --git a/generic/ttk/ttkWidget.c b/generic/ttk/ttkWidget.c
index 2c4f28e..3176dca 100644
--- a/generic/ttk/ttkWidget.c
+++ b/generic/ttk/ttkWidget.c
@@ -1,11 +1,11 @@
/*
- * Copyright (c) 2003, Joe English
+ * Copyright © 2003, Joe English
*
* Core widget utilities.
*/
#include "tkInt.h"
-#include "ttkTheme.h"
+#include "ttkThemeInt.h"
#include "ttkWidget.h"
/*------------------------------------------------------------------------
@@ -81,15 +81,19 @@ static void EndDrawing(Tk_Window tkwin, Drawable d)
#else
/* No double-buffering: draw directly into the window. */
static Drawable BeginDrawing(Tk_Window tkwin) { return Tk_WindowId(tkwin); }
-static void EndDrawing(Tk_Window tkwin, Drawable d) { }
+static void EndDrawing(
+ TCL_UNUSED(Tk_Window),
+ TCL_UNUSED(Drawable))
+{
+}
#endif
/* DrawWidget --
* Redraw a widget. Called as an idle handler.
*/
-static void DrawWidget(ClientData recordPtr)
+static void DrawWidget(void *recordPtr)
{
- WidgetCore *corePtr = recordPtr;
+ WidgetCore *corePtr = (WidgetCore *)recordPtr;
corePtr->flags &= ~REDISPLAY_PENDING;
if (Tk_IsMapped(corePtr->tkwin)) {
@@ -121,9 +125,10 @@ void TtkRedisplayWidget(WidgetCore *corePtr)
* Invoked whenever fonts or other system resources are changed;
* recomputes geometry.
*/
-static void WidgetWorldChanged(ClientData clientData)
+static void WidgetWorldChanged(void *clientData)
{
- WidgetCore *corePtr = clientData;
+ WidgetCore *corePtr = (WidgetCore *)clientData;
+ (void)UpdateLayout(corePtr->interp, corePtr);
SizeChanged(corePtr);
TtkRedisplayWidget(corePtr);
}
@@ -158,9 +163,9 @@ void TtkWidgetChangeState(WidgetCore *corePtr,
*/
static int
WidgetInstanceObjCmd(
- ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- WidgetCore *corePtr = clientData;
+ WidgetCore *corePtr = (WidgetCore *)clientData;
const Ttk_Ensemble *commands = corePtr->widgetSpec->commands;
int status;
@@ -193,9 +198,9 @@ WidgetInstanceObjCmd(
* Widget instance command deletion callback.
*/
static void
-WidgetInstanceObjCmdDeleted(ClientData clientData)
+WidgetInstanceObjCmdDeleted(void *clientData)
{
- WidgetCore *corePtr = clientData;
+ WidgetCore *corePtr = (WidgetCore *)clientData;
corePtr->widgetCmd = NULL;
if (corePtr->tkwin != NULL)
Tk_DestroyWindow(corePtr->tkwin);
@@ -212,7 +217,7 @@ DestroyWidget(WidgetCore *corePtr)
corePtr->widgetSpec->cleanupProc(corePtr);
Tk_FreeConfigOptions(
- (ClientData)corePtr, corePtr->optionTable, corePtr->tkwin);
+ corePtr, corePtr->optionTable, corePtr->tkwin);
if (corePtr->layout) {
Ttk_FreeLayout(corePtr->layout);
@@ -257,7 +262,7 @@ static const unsigned CoreEventMask
| LeaveWindowMask
;
-static void CoreEventProc(ClientData clientData, XEvent *eventPtr)
+static void CoreEventProc(void *clientData, XEvent *eventPtr)
{
WidgetCore *corePtr = (WidgetCore *)clientData;
@@ -309,7 +314,6 @@ static void CoreEventProc(ClientData clientData, XEvent *eventPtr)
case VirtualEvent: {
const char *name = ((XVirtualEvent *)eventPtr)->name;
if ((name != NULL) && !strcmp("ThemeChanged", name)) {
- (void)UpdateLayout(corePtr->interp, corePtr);
WidgetWorldChanged(corePtr);
}
break;
@@ -320,7 +324,7 @@ static void CoreEventProc(ClientData clientData, XEvent *eventPtr)
}
}
-static Tk_ClassProcs widgetClassProcs = {
+static const Tk_ClassProcs widgetClassProcs = {
sizeof(Tk_ClassProcs), /* size */
WidgetWorldChanged, /* worldChangedProc */
NULL, /* createProc */
@@ -333,9 +337,9 @@ static Tk_ClassProcs widgetClassProcs = {
* ClientData is a WidgetSpec *.
*/
int TtkWidgetConstructorObjCmd(
- ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *clientData, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
- WidgetSpec *widgetSpec = clientData;
+ WidgetSpec *widgetSpec = (WidgetSpec *)clientData;
const char *className = widgetSpec->className;
Tk_OptionTable optionTable =
Tk_CreateOptionTable(interp, widgetSpec->optionSpecs);
@@ -343,7 +347,7 @@ int TtkWidgetConstructorObjCmd(
void *recordPtr;
WidgetCore *corePtr;
Tk_SavedOptions savedOptions;
- int i;
+ Tcl_Size i;
if (objc < 2 || objc % 2 == 1) {
Tcl_WrongNumArgs(interp, 1, objv, "pathName ?-option value ...?");
@@ -371,7 +375,7 @@ int TtkWidgetConstructorObjCmd(
*/
recordPtr = ckalloc(widgetSpec->recordSize);
memset(recordPtr, 0, widgetSpec->recordSize);
- corePtr = recordPtr;
+ corePtr = (WidgetCore *)recordPtr;
corePtr->tkwin = tkwin;
corePtr->interp = interp;
@@ -446,7 +450,7 @@ error:
Ttk_Layout TtkWidgetGetLayout(
Tcl_Interp *interp, Ttk_Theme themePtr, void *recordPtr)
{
- WidgetCore *corePtr = recordPtr;
+ WidgetCore *corePtr = (WidgetCore *)recordPtr;
const char *styleName = 0;
if (corePtr->styleObj)
@@ -468,21 +472,21 @@ Ttk_Layout TtkWidgetGetLayout(
Ttk_Layout TtkWidgetGetOrientedLayout(
Tcl_Interp *interp, Ttk_Theme themePtr, void *recordPtr, Tcl_Obj *orientObj)
{
- WidgetCore *corePtr = recordPtr;
+ WidgetCore *corePtr = (WidgetCore *)recordPtr;
const char *baseStyleName = 0;
Tcl_DString styleName;
- int orient = TTK_ORIENT_HORIZONTAL;
+ Ttk_Orient orient = TTK_ORIENT_HORIZONTAL;
Ttk_Layout layout;
Tcl_DStringInit(&styleName);
/* Prefix:
*/
- Ttk_GetOrientFromObj(NULL, orientObj, &orient);
+ TtkGetOrientFromObj(NULL, orientObj, &orient);
if (orient == TTK_ORIENT_HORIZONTAL)
- Tcl_DStringAppend(&styleName, "Horizontal.", -1);
+ Tcl_DStringAppend(&styleName, "Horizontal.", TCL_INDEX_NONE);
else
- Tcl_DStringAppend(&styleName, "Vertical.", -1);
+ Tcl_DStringAppend(&styleName, "Vertical.", TCL_INDEX_NONE);
/* Add base style name:
*/
@@ -491,7 +495,7 @@ Ttk_Layout TtkWidgetGetOrientedLayout(
if (!baseStyleName || *baseStyleName == '\0')
baseStyleName = corePtr->widgetSpec->className;
- Tcl_DStringAppend(&styleName, baseStyleName, -1);
+ Tcl_DStringAppend(&styleName, baseStyleName, TCL_INDEX_NONE);
/* Create layout:
*/
@@ -506,14 +510,19 @@ Ttk_Layout TtkWidgetGetOrientedLayout(
/* TtkNullInitialize --
* Default widget initializeProc (no-op)
*/
-void TtkNullInitialize(Tcl_Interp *interp, void *recordPtr)
+void TtkNullInitialize(
+ TCL_UNUSED(Tcl_Interp *),
+ TCL_UNUSED(void *))
{
}
/* TtkNullPostConfigure --
* Default widget postConfigureProc (no-op)
*/
-int TtkNullPostConfigure(Tcl_Interp *interp, void *clientData, int mask)
+int TtkNullPostConfigure(
+ TCL_UNUSED(Tcl_Interp *),
+ TCL_UNUSED(void *),
+ TCL_UNUSED(int))
{
return TCL_OK;
}
@@ -524,7 +533,7 @@ int TtkNullPostConfigure(Tcl_Interp *interp, void *clientData, int mask)
*/
int TtkCoreConfigure(Tcl_Interp *interp, void *clientData, int mask)
{
- WidgetCore *corePtr = clientData;
+ WidgetCore *corePtr = (WidgetCore *)clientData;
int status = TCL_OK;
if (mask & STYLE_CHANGED) {
@@ -537,7 +546,8 @@ int TtkCoreConfigure(Tcl_Interp *interp, void *clientData, int mask)
/* TtkNullCleanup --
* Default widget cleanupProc (no-op)
*/
-void TtkNullCleanup(void *recordPtr)
+void TtkNullCleanup(
+ TCL_UNUSED(void *))
{
return;
}
@@ -547,7 +557,7 @@ void TtkNullCleanup(void *recordPtr)
*/
void TtkWidgetDoLayout(void *clientData)
{
- WidgetCore *corePtr = clientData;
+ WidgetCore *corePtr = (WidgetCore *)clientData;
Ttk_PlaceLayout(corePtr->layout,corePtr->state,Ttk_WinBox(corePtr->tkwin));
}
@@ -556,7 +566,7 @@ void TtkWidgetDoLayout(void *clientData)
*/
void TtkWidgetDisplay(void *recordPtr, Drawable d)
{
- WidgetCore *corePtr = recordPtr;
+ WidgetCore *corePtr = (WidgetCore *)recordPtr;
Ttk_DrawLayout(corePtr->layout, corePtr->state, d);
}
@@ -565,7 +575,7 @@ void TtkWidgetDisplay(void *recordPtr, Drawable d)
*/
int TtkWidgetSize(void *recordPtr, int *widthPtr, int *heightPtr)
{
- WidgetCore *corePtr = recordPtr;
+ WidgetCore *corePtr = (WidgetCore *)recordPtr;
Ttk_LayoutSize(corePtr->layout, corePtr->state, widthPtr, heightPtr);
return 1;
}
@@ -577,9 +587,9 @@ int TtkWidgetSize(void *recordPtr, int *widthPtr, int *heightPtr)
/* $w cget -option
*/
int TtkWidgetCgetCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
- WidgetCore *corePtr = recordPtr;
+ WidgetCore *corePtr = (WidgetCore *)recordPtr;
Tcl_Obj *result;
if (objc != 3) {
@@ -597,9 +607,9 @@ int TtkWidgetCgetCommand(
/* $w configure ?-option ?value ....??
*/
int TtkWidgetConfigureCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
- WidgetCore *corePtr = recordPtr;
+ WidgetCore *corePtr = (WidgetCore *)recordPtr;
Tcl_Obj *result;
if (objc == 2) {
@@ -667,9 +677,9 @@ int TtkWidgetConfigureCommand(
*/
int TtkWidgetStateCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
- WidgetCore *corePtr = recordPtr;
+ WidgetCore *corePtr = (WidgetCore *)recordPtr;
Ttk_StateSpec spec;
int status;
Ttk_State oldState, changed;
@@ -707,9 +717,9 @@ int TtkWidgetStateCommand(
*/
int TtkWidgetInstateCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
- WidgetCore *corePtr = recordPtr;
+ WidgetCore *corePtr = (WidgetCore *)recordPtr;
Ttk_State state = corePtr->state;
Ttk_StateSpec spec;
int status = TCL_OK;
@@ -738,9 +748,9 @@ int TtkWidgetInstateCommand(
* Returns: name of element at $x, $y
*/
int TtkWidgetIdentifyCommand(
- void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
{
- WidgetCore *corePtr = recordPtr;
+ WidgetCore *corePtr = (WidgetCore *)recordPtr;
Ttk_Element element;
static const char *const whatTable[] = { "element", NULL };
int x, y, what;
@@ -772,4 +782,24 @@ int TtkWidgetIdentifyCommand(
return TCL_OK;
}
+/* $w style
+ * Return the style currently applied to the widget.
+ */
+
+int TtkWidgetStyleCommand(
+ void *recordPtr, Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[])
+{
+ WidgetCore *corePtr = (WidgetCore *)recordPtr;
+
+ if (objc != 2) {
+ Tcl_WrongNumArgs(interp, 2, objv, "");
+ return TCL_ERROR;
+ }
+
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ Ttk_StyleName(Ttk_LayoutStyle(corePtr->layout)), -1));
+
+ return TCL_OK;
+}
+
/*EOF*/
diff --git a/generic/ttk/ttkWidget.h b/generic/ttk/ttkWidget.h
index c6b2dc9..453b788 100644
--- a/generic/ttk/ttkWidget.h
+++ b/generic/ttk/ttkWidget.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, Joe English
+ * Copyright © 2003 Joe English
* Helper routines for widget implementations.
*/
@@ -89,25 +89,32 @@ MODULE_SCOPE int TtkCoreConfigure(Tcl_Interp*, void *, int mask);
/* Common widget commands:
*/
-MODULE_SCOPE int TtkWidgetConfigureCommand(
- void *,Tcl_Interp *, int, Tcl_Obj*const[]);
MODULE_SCOPE int TtkWidgetCgetCommand(
- void *,Tcl_Interp *, int, Tcl_Obj*const[]);
+ void *,Tcl_Interp *, Tcl_Size, Tcl_Obj*const[]);
+MODULE_SCOPE int TtkWidgetConfigureCommand(
+ void *,Tcl_Interp *, Tcl_Size, Tcl_Obj*const[]);
+MODULE_SCOPE int TtkWidgetIdentifyCommand(
+ void *,Tcl_Interp *, Tcl_Size, Tcl_Obj*const[]);
MODULE_SCOPE int TtkWidgetInstateCommand(
- void *,Tcl_Interp *, int, Tcl_Obj*const[]);
+ void *,Tcl_Interp *, Tcl_Size, Tcl_Obj*const[]);
MODULE_SCOPE int TtkWidgetStateCommand(
- void *,Tcl_Interp *, int, Tcl_Obj*const[]);
-MODULE_SCOPE int TtkWidgetIdentifyCommand(
- void *,Tcl_Interp *, int, Tcl_Obj*const[]);
+ void *,Tcl_Interp *, Tcl_Size, Tcl_Obj*const[]);
+MODULE_SCOPE int TtkWidgetStyleCommand(
+ void *,Tcl_Interp *, Tcl_Size, Tcl_Obj*const[]);
/* Widget constructor:
*/
-MODULE_SCOPE int TtkWidgetConstructorObjCmd(
- ClientData, Tcl_Interp*, int, Tcl_Obj*const[]);
+MODULE_SCOPE Tcl_ObjCmdProc2 TtkWidgetConstructorObjCmd;
+#if TCL_MAJOR_VERSION > 8
+#define RegisterWidget(interp, name, specPtr) \
+ Tcl_CreateObjCommand2(interp, name, \
+ TtkWidgetConstructorObjCmd, (void *)specPtr,NULL)
+#else
#define RegisterWidget(interp, name, specPtr) \
Tcl_CreateObjCommand(interp, name, \
- TtkWidgetConstructorObjCmd, (ClientData)specPtr,NULL)
+ TtkWidgetConstructorObjCmd, (void *)specPtr,NULL)
+#endif
/* WIDGET_TAKEFOCUS_TRUE --
* WIDGET_TAKEFOCUS_FALSE --
@@ -117,21 +124,21 @@ MODULE_SCOPE int TtkWidgetConstructorObjCmd(
*/
#define WIDGET_TAKEFOCUS_TRUE \
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus", \
- "ttk::takefocus", Tk_Offset(WidgetCore, takeFocusPtr), -1, 0,0,0 }
+ "ttk::takefocus", offsetof(WidgetCore, takeFocusPtr), TCL_INDEX_NONE, 0,0,0 }
#define WIDGET_TAKEFOCUS_FALSE \
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus", \
- "", Tk_Offset(WidgetCore, takeFocusPtr), -1, 0,0,0 }
+ "", offsetof(WidgetCore, takeFocusPtr), TCL_INDEX_NONE, 0,0,0 }
/* WIDGET_INHERIT_OPTIONS(baseOptionSpecs) --
* Add this at the end of an OptionSpecs table to inherit
* the options from 'baseOptionSpecs'.
*/
#define WIDGET_INHERIT_OPTIONS(baseOptionSpecs) \
- {TK_OPTION_END, 0,0,0, NULL, -1,-1, 0, (ClientData)baseOptionSpecs, 0}
+ {TK_OPTION_END, 0,0,0, NULL, TCL_INDEX_NONE,TCL_INDEX_NONE, 0, baseOptionSpecs, 0}
/* All widgets should inherit from ttkCoreOptionSpecs[].
*/
-MODULE_SCOPE Tk_OptionSpec ttkCoreOptionSpecs[];
+MODULE_SCOPE const Tk_OptionSpec ttkCoreOptionSpecs[];
/*
* Useful routines for use inside widget implementations:
@@ -165,11 +172,6 @@ MODULE_SCOPE void Ttk_UntraceVariable(Ttk_TraceHandle *);
MODULE_SCOPE int Ttk_FireTrace(Ttk_TraceHandle *);
/*
- * Virtual events:
- */
-MODULE_SCOPE void TtkSendVirtualEvent(Tk_Window tgtWin, const char *eventName);
-
-/*
* Helper routines for data accessor commands:
*/
MODULE_SCOPE int TtkEnumerateOptions(
@@ -193,7 +195,7 @@ MODULE_SCOPE ScrollHandle TtkCreateScrollHandle(WidgetCore *, Scrollable *);
MODULE_SCOPE void TtkFreeScrollHandle(ScrollHandle);
MODULE_SCOPE int TtkScrollviewCommand(
- Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], ScrollHandle);
+ Tcl_Interp *interp, Tcl_Size objc, Tcl_Obj *const objv[], ScrollHandle);
MODULE_SCOPE void TtkUpdateScrollInfo(ScrollHandle h);
MODULE_SCOPE void TtkScrollTo(ScrollHandle, int newFirst, int updateScrollInfo);
@@ -208,11 +210,11 @@ typedef struct TtkTag *Ttk_Tag;
typedef struct TtkTagTable *Ttk_TagTable;
typedef struct TtkTagSet { /* TODO: make opaque */
Ttk_Tag *tags;
- int nTags;
+ Tcl_Size nTags;
} *Ttk_TagSet;
MODULE_SCOPE Ttk_TagTable Ttk_CreateTagTable(
- Tcl_Interp *, Tk_Window tkwin, Tk_OptionSpec[], int recordSize);
+ Tcl_Interp *, Tk_Window tkwin, const Tk_OptionSpec *, size_t recordSize);
MODULE_SCOPE void Ttk_DeleteTagTable(Ttk_TagTable);
MODULE_SCOPE Ttk_Tag Ttk_GetTag(Ttk_TagTable, const char *tagName);
@@ -226,9 +228,11 @@ MODULE_SCOPE int Ttk_EnumerateTagOptions(
MODULE_SCOPE int Ttk_EnumerateTags(Tcl_Interp *, Ttk_TagTable);
+MODULE_SCOPE void Ttk_DeleteTagFromTable(Ttk_TagTable, Ttk_Tag);
+
MODULE_SCOPE int Ttk_ConfigureTag(
Tcl_Interp *interp, Ttk_TagTable tagTable, Ttk_Tag tag,
- int objc, Tcl_Obj *const objv[]);
+ Tcl_Size objc, Tcl_Obj *const objv[]);
MODULE_SCOPE Ttk_TagSet Ttk_GetTagSetFromObj(
Tcl_Interp *interp, Ttk_TagTable, Tcl_Obj *objPtr);
@@ -238,8 +242,10 @@ MODULE_SCOPE void Ttk_FreeTagSet(Ttk_TagSet);
MODULE_SCOPE int Ttk_TagSetContains(Ttk_TagSet, Ttk_Tag tag);
MODULE_SCOPE int Ttk_TagSetAdd(Ttk_TagSet, Ttk_Tag tag);
+MODULE_SCOPE int Ttk_TagSetAddSet(Ttk_TagSet, Ttk_TagSet);
MODULE_SCOPE int Ttk_TagSetRemove(Ttk_TagSet, Ttk_Tag tag);
+MODULE_SCOPE void Ttk_TagSetDefaults(Ttk_TagTable, Ttk_Style, void *);
MODULE_SCOPE void Ttk_TagSetValues(Ttk_TagTable, Ttk_TagSet, void *record);
MODULE_SCOPE void Ttk_TagSetApplyStyle(Ttk_TagTable,Ttk_Style,Ttk_State,void*);