summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
Diffstat (limited to 'generic')
-rw-r--r--generic/ks_names.h1196
-rw-r--r--generic/nanosvg.h3129
-rw-r--r--generic/nanosvgrast.h1467
-rw-r--r--generic/tk.decls140
-rw-r--r--generic/tk.h250
-rw-r--r--generic/tk3d.c33
-rw-r--r--generic/tk3d.h4
-rw-r--r--generic/tkArgv.c18
-rw-r--r--generic/tkArray.h8
-rw-r--r--generic/tkAtom.c10
-rw-r--r--generic/tkBind.c217
-rw-r--r--generic/tkBitmap.c60
-rw-r--r--generic/tkBusy.c45
-rw-r--r--generic/tkButton.c399
-rw-r--r--generic/tkCanvArc.c296
-rw-r--r--generic/tkCanvBmap.c83
-rw-r--r--generic/tkCanvImg.c59
-rw-r--r--generic/tkCanvLine.c252
-rw-r--r--generic/tkCanvPoly.c202
-rw-r--r--generic/tkCanvPs.c48
-rw-r--r--generic/tkCanvText.c223
-rw-r--r--generic/tkCanvUtil.c148
-rw-r--r--generic/tkCanvWind.c77
-rw-r--r--generic/tkCanvas.c1211
-rw-r--r--generic/tkCanvas.h4
-rw-r--r--generic/tkClipboard.c57
-rw-r--r--generic/tkCmds.c292
-rw-r--r--generic/tkColor.c32
-rw-r--r--generic/tkColor.h4
-rw-r--r--generic/tkConfig.c288
-rw-r--r--generic/tkConsole.c6
-rw-r--r--generic/tkCursor.c42
-rw-r--r--generic/tkDList.h20
-rw-r--r--generic/tkDecls.h244
-rw-r--r--generic/tkEntry.c854
-rw-r--r--generic/tkEntry.h29
-rw-r--r--generic/tkError.c11
-rw-r--r--generic/tkEvent.c31
-rw-r--r--generic/tkFileFilter.c34
-rw-r--r--generic/tkFileFilter.h8
-rw-r--r--generic/tkFocus.c24
-rw-r--r--generic/tkFont.c126
-rw-r--r--generic/tkFont.h12
-rw-r--r--generic/tkFrame.c462
-rw-r--r--generic/tkGC.c23
-rw-r--r--generic/tkGeometry.c10
-rw-r--r--generic/tkGrab.c35
-rw-r--r--generic/tkGrid.c93
-rw-r--r--generic/tkImage.c4
-rw-r--r--generic/tkImgBmap.c47
-rw-r--r--generic/tkImgGIF.c86
-rw-r--r--generic/tkImgListFormat.c1145
-rw-r--r--generic/tkImgPNG.c85
-rw-r--r--generic/tkImgPPM.c19
-rw-r--r--generic/tkImgPhInstance.c85
-rw-r--r--generic/tkImgPhoto.c724
-rw-r--r--generic/tkImgPhoto.h29
-rw-r--r--generic/tkImgSVGnano.c810
-rw-r--r--generic/tkImgUtil.c2
-rw-r--r--generic/tkInt.decls493
-rw-r--r--generic/tkInt.h204
-rw-r--r--generic/tkIntDecls.h209
-rw-r--r--generic/tkIntPlatDecls.h34
-rw-r--r--generic/tkIntXlibDecls.h540
-rw-r--r--generic/tkListbox.c282
-rw-r--r--generic/tkMacWinMenu.c8
-rw-r--r--generic/tkMain.c22
-rw-r--r--generic/tkMenu.c477
-rw-r--r--generic/tkMenu.h24
-rw-r--r--generic/tkMenuDraw.c45
-rw-r--r--generic/tkMenubutton.c129
-rw-r--r--generic/tkMessage.c105
-rw-r--r--generic/tkObj.c111
-rw-r--r--generic/tkOldConfig.c65
-rw-r--r--generic/tkOldTest.c32
-rw-r--r--generic/tkOption.c9
-rw-r--r--generic/tkPack.c64
-rw-r--r--generic/tkPanedWindow.c143
-rw-r--r--generic/tkPkgConfig.c169
-rw-r--r--generic/tkPlace.c111
-rw-r--r--generic/tkPlatDecls.h61
-rw-r--r--generic/tkPointer.c28
-rw-r--r--generic/tkRectOval.c135
-rw-r--r--generic/tkScale.c128
-rw-r--r--generic/tkScale.h2
-rw-r--r--generic/tkScrollbar.c83
-rw-r--r--generic/tkScrollbar.h26
-rw-r--r--generic/tkSelect.c40
-rw-r--r--generic/tkSelect.h14
-rw-r--r--generic/tkSquare.c56
-rw-r--r--generic/tkStubInit.c376
-rw-r--r--generic/tkStubLib.c4
-rw-r--r--generic/tkStyle.c84
-rw-r--r--generic/tkTest.c327
-rw-r--r--generic/tkText.c392
-rw-r--r--generic/tkText.h30
-rw-r--r--generic/tkTextBTree.c36
-rw-r--r--generic/tkTextDisp.c44
-rw-r--r--generic/tkTextImage.c49
-rw-r--r--generic/tkTextIndex.c41
-rw-r--r--generic/tkTextMark.c18
-rw-r--r--generic/tkTextTag.c73
-rw-r--r--generic/tkTextWind.c32
-rw-r--r--generic/tkTrig.c19
-rw-r--r--generic/tkUndo.c10
-rw-r--r--generic/tkUtil.c144
-rw-r--r--generic/tkVisual.c70
-rw-r--r--generic/tkWindow.c164
-rw-r--r--generic/ttk/ttk.decls8
-rw-r--r--generic/ttk/ttkBlink.c10
-rw-r--r--generic/ttk/ttkButton.c86
-rw-r--r--generic/ttk/ttkCache.c35
-rw-r--r--generic/ttk/ttkClamTheme.c150
-rw-r--r--generic/ttk/ttkClassicTheme.c84
-rw-r--r--generic/ttk/ttkDecls.h26
-rw-r--r--generic/ttk/ttkDefaultTheme.c325
-rw-r--r--generic/ttk/ttkElements.c485
-rw-r--r--generic/ttk/ttkEntry.c512
-rw-r--r--generic/ttk/ttkFrame.c30
-rw-r--r--generic/ttk/ttkGenStubs.tcl1008
-rw-r--r--generic/ttk/ttkImage.c38
-rw-r--r--generic/ttk/ttkInit.c76
-rw-r--r--generic/ttk/ttkLabel.c68
-rw-r--r--generic/ttk/ttkLayout.c21
-rw-r--r--generic/ttk/ttkManager.c73
-rw-r--r--generic/ttk/ttkManager.h56
-rw-r--r--generic/ttk/ttkNotebook.c204
-rw-r--r--generic/ttk/ttkPanedwindow.c79
-rw-r--r--generic/ttk/ttkProgress.c80
-rw-r--r--generic/ttk/ttkScale.c33
-rw-r--r--generic/ttk/ttkScroll.c10
-rw-r--r--generic/ttk/ttkScrollbar.c10
-rw-r--r--generic/ttk/ttkSeparator.c14
-rw-r--r--generic/ttk/ttkSquare.c36
-rw-r--r--generic/ttk/ttkState.c7
-rw-r--r--generic/ttk/ttkStubInit.c12
-rw-r--r--generic/ttk/ttkTagSet.c25
-rw-r--r--generic/ttk/ttkTheme.c28
-rw-r--r--generic/ttk/ttkTheme.h66
-rw-r--r--generic/ttk/ttkThemeInt.h4
-rw-r--r--generic/ttk/ttkTrack.c8
-rw-r--r--generic/ttk/ttkTreeview.c320
-rw-r--r--generic/ttk/ttkWidget.c56
-rw-r--r--generic/ttk/ttkWidget.h23
144 files changed, 17148 insertions, 8072 deletions
diff --git a/generic/ks_names.h b/generic/ks_names.h
index 3577390..7d11cae 100644
--- a/generic/ks_names.h
+++ b/generic/ks_names.h
@@ -22,6 +22,10 @@
{ "Escape", 0xFF1B },
{ "Delete", 0xFFFF },
{ "Multi_key", 0xFF20 },
+{ "Codeinput", 0xFF37 },
+{ "SingleCandidate", 0xFF3C },
+{ "MultipleCandidate", 0xFF3D },
+{ "PreviousCandidate", 0xFF3E },
{ "Kanji", 0xFF21 },
{ "Muhenkan", 0xFF22 },
{ "Henkan_Mode", 0xFF23 },
@@ -39,6 +43,9 @@
{ "Kana_Shift", 0xFF2E },
{ "Eisu_Shift", 0xFF2F },
{ "Eisu_toggle", 0xFF30 },
+{ "Kanji_Bangou", 0xFF37 },
+{ "Zen_Koho", 0xFF3D },
+{ "Mae_Koho", 0xFF3E },
{ "Home", 0xFF50 },
{ "Left", 0xFF51 },
{ "Up", 0xFF52 },
@@ -178,6 +185,180 @@
{ "Super_R", 0xFFEC },
{ "Hyper_L", 0xFFED },
{ "Hyper_R", 0xFFEE },
+{ "ISO_Lock", 0xFE01 },
+{ "ISO_Level2_Latch", 0xFE02 },
+{ "ISO_Level3_Shift", 0xFE03 },
+{ "ISO_Level3_Latch", 0xFE04 },
+{ "ISO_Level3_Lock", 0xFE05 },
+{ "ISO_Level5_Shift", 0xFE11 },
+{ "ISO_Level5_Latch", 0xFE12 },
+{ "ISO_Level5_Lock", 0xFE13 },
+{ "ISO_Group_Shift", 0xFF7E },
+{ "ISO_Group_Latch", 0xFE06 },
+{ "ISO_Group_Lock", 0xFE07 },
+{ "ISO_Next_Group", 0xFE08 },
+{ "ISO_Next_Group_Lock", 0xFE09 },
+{ "ISO_Prev_Group", 0xFE0A },
+{ "ISO_Prev_Group_Lock", 0xFE0B },
+{ "ISO_First_Group", 0xFE0C },
+{ "ISO_First_Group_Lock", 0xFE0D },
+{ "ISO_Last_Group", 0xFE0E },
+{ "ISO_Last_Group_Lock", 0xFE0F },
+{ "ISO_Left_Tab", 0xFE20 },
+{ "ISO_Move_Line_Up", 0xFE21 },
+{ "ISO_Move_Line_Down", 0xFE22 },
+{ "ISO_Partial_Line_Up", 0xFE23 },
+{ "ISO_Partial_Line_Down", 0xFE24 },
+{ "ISO_Partial_Space_Left", 0xFE25 },
+{ "ISO_Partial_Space_Right", 0xFE26 },
+{ "ISO_Set_Margin_Left", 0xFE27 },
+{ "ISO_Set_Margin_Right", 0xFE28 },
+{ "ISO_Release_Margin_Left", 0xFE29 },
+{ "ISO_Release_Margin_Right", 0xFE2A },
+{ "ISO_Release_Both_Margins", 0xFE2B },
+{ "ISO_Fast_Cursor_Left", 0xFE2C },
+{ "ISO_Fast_Cursor_Right", 0xFE2D },
+{ "ISO_Fast_Cursor_Up", 0xFE2E },
+{ "ISO_Fast_Cursor_Down", 0xFE2F },
+{ "ISO_Continuous_Underline", 0xFE30 },
+{ "ISO_Discontinuous_Underline", 0xFE31 },
+{ "ISO_Emphasize", 0xFE32 },
+{ "ISO_Center_Object", 0xFE33 },
+{ "ISO_Enter", 0xFE34 },
+{ "dead_grave", 0xFE50 },
+{ "dead_acute", 0xFE51 },
+{ "dead_circumflex", 0xFE52 },
+{ "dead_tilde", 0xFE53 },
+{ "dead_perispomeni", 0xFE53 },
+{ "dead_macron", 0xFE54 },
+{ "dead_breve", 0xFE55 },
+{ "dead_abovedot", 0xFE56 },
+{ "dead_diaeresis", 0xFE57 },
+{ "dead_abovering", 0xFE58 },
+{ "dead_doubleacute", 0xFE59 },
+{ "dead_caron", 0xFE5A },
+{ "dead_cedilla", 0xFE5B },
+{ "dead_ogonek", 0xFE5C },
+{ "dead_iota", 0xFE5D },
+{ "dead_voiced_sound", 0xFE5E },
+{ "dead_semivoiced_sound", 0xFE5F },
+{ "dead_belowdot", 0xFE60 },
+{ "dead_hook", 0xFE61 },
+{ "dead_horn", 0xFE62 },
+{ "dead_stroke", 0xFE63 },
+{ "dead_abovecomma", 0xFE64 },
+{ "dead_psili", 0xFE64 },
+{ "dead_abovereversedcomma", 0xFE65 },
+{ "dead_dasia", 0xFE65 },
+{ "dead_doublegrave", 0xFE66 },
+{ "dead_belowring", 0xFE67 },
+{ "dead_belowmacron", 0xFE68 },
+{ "dead_belowcircumflex", 0xFE69 },
+{ "dead_belowtilde", 0xFE6A },
+{ "dead_belowbreve", 0xFE6B },
+{ "dead_belowdiaeresis", 0xFE6C },
+{ "dead_invertedbreve", 0xFE6D },
+{ "dead_belowcomma", 0xFE6E },
+{ "dead_currency", 0xFE6F },
+{ "dead_lowline", 0xFE90 },
+{ "dead_aboveverticalline", 0xFE91 },
+{ "dead_belowverticalline", 0xFE92 },
+{ "dead_longsolidusoverlay", 0xFE93 },
+{ "dead_a", 0xFE80 },
+{ "dead_A", 0xFE81 },
+{ "dead_e", 0xFE82 },
+{ "dead_E", 0xFE83 },
+{ "dead_i", 0xFE84 },
+{ "dead_I", 0xFE85 },
+{ "dead_o", 0xFE86 },
+{ "dead_O", 0xFE87 },
+{ "dead_u", 0xFE88 },
+{ "dead_U", 0xFE89 },
+{ "dead_small_schwa", 0xFE8A },
+{ "dead_capital_schwa", 0xFE8B },
+{ "dead_greek", 0xFE8C },
+{ "First_Virtual_Screen", 0xFED0 },
+{ "Prev_Virtual_Screen", 0xFED1 },
+{ "Next_Virtual_Screen", 0xFED2 },
+{ "Last_Virtual_Screen", 0xFED4 },
+{ "Terminate_Server", 0xFED5 },
+{ "AccessX_Enable", 0xFE70 },
+{ "AccessX_Feedback_Enable", 0xFE71 },
+{ "RepeatKeys_Enable", 0xFE72 },
+{ "SlowKeys_Enable", 0xFE73 },
+{ "BounceKeys_Enable", 0xFE74 },
+{ "StickyKeys_Enable", 0xFE75 },
+{ "MouseKeys_Enable", 0xFE76 },
+{ "MouseKeys_Accel_Enable", 0xFE77 },
+{ "Overlay1_Enable", 0xFE78 },
+{ "Overlay2_Enable", 0xFE79 },
+{ "AudibleBell_Enable", 0xFE7A },
+{ "Pointer_Left", 0xFEE0 },
+{ "Pointer_Right", 0xFEE1 },
+{ "Pointer_Up", 0xFEE2 },
+{ "Pointer_Down", 0xFEE3 },
+{ "Pointer_UpLeft", 0xFEE4 },
+{ "Pointer_UpRight", 0xFEE5 },
+{ "Pointer_DownLeft", 0xFEE6 },
+{ "Pointer_DownRight", 0xFEE7 },
+{ "Pointer_Button_Dflt", 0xFEE8 },
+{ "Pointer_Button1", 0xFEE9 },
+{ "Pointer_Button2", 0xFEEA },
+{ "Pointer_Button3", 0xFEEB },
+{ "Pointer_Button4", 0xFEEC },
+{ "Pointer_Button5", 0xFEED },
+{ "Pointer_DblClick_Dflt", 0xFEEE },
+{ "Pointer_DblClick1", 0xFEEF },
+{ "Pointer_DblClick2", 0xFEF0 },
+{ "Pointer_DblClick3", 0xFEF1 },
+{ "Pointer_DblClick4", 0xFEF2 },
+{ "Pointer_DblClick5", 0xFEF3 },
+{ "Pointer_Drag_Dflt", 0xFEF4 },
+{ "Pointer_Drag1", 0xFEF5 },
+{ "Pointer_Drag2", 0xFEF6 },
+{ "Pointer_Drag3", 0xFEF7 },
+{ "Pointer_Drag4", 0xFEF8 },
+{ "Pointer_Drag5", 0xFEFD },
+{ "Pointer_EnableKeys", 0xFEF9 },
+{ "Pointer_Accelerate", 0xFEFA },
+{ "Pointer_DfltBtnNext", 0xFEFB },
+{ "Pointer_DfltBtnPrev", 0xFEFC },
+{ "ch", 0xFEA0 },
+{ "Ch", 0xFEA1 },
+{ "CH", 0xFEA2 },
+{ "c_h", 0xFEA3 },
+{ "C_h", 0xFEA4 },
+{ "C_H", 0xFEA5 },
+{ "3270_Duplicate", 0xFD01 },
+{ "3270_FieldMark", 0xFD02 },
+{ "3270_Right2", 0xFD03 },
+{ "3270_Left2", 0xFD04 },
+{ "3270_BackTab", 0xFD05 },
+{ "3270_EraseEOF", 0xFD06 },
+{ "3270_EraseInput", 0xFD07 },
+{ "3270_Reset", 0xFD08 },
+{ "3270_Quit", 0xFD09 },
+{ "3270_PA1", 0xFD0A },
+{ "3270_PA2", 0xFD0B },
+{ "3270_PA3", 0xFD0C },
+{ "3270_Test", 0xFD0D },
+{ "3270_Attn", 0xFD0E },
+{ "3270_CursorBlink", 0xFD0F },
+{ "3270_AltCursor", 0xFD10 },
+{ "3270_KeyClick", 0xFD11 },
+{ "3270_Jump", 0xFD12 },
+{ "3270_Ident", 0xFD13 },
+{ "3270_Rule", 0xFD14 },
+{ "3270_Copy", 0xFD15 },
+{ "3270_Play", 0xFD16 },
+{ "3270_Setup", 0xFD17 },
+{ "3270_Record", 0xFD18 },
+{ "3270_ChangeScreen", 0xFD19 },
+{ "3270_DeleteWord", 0xFD1A },
+{ "3270_ExSelect", 0xFD1B },
+{ "3270_CursorSelect", 0xFD1C },
+{ "3270_PrintScreen", 0xFD1D },
+{ "3270_Enter", 0xFD1E },
{ "space", 0x20 },
{ "exclam", 0x21 },
{ "quotedbl", 0x22 },
@@ -333,7 +514,9 @@
{ "Odiaeresis", 0xD6 },
{ "multiply", 0xD7 },
{ "Oslash", 0xD8 },
+#ifndef TK_NO_DEPRECATED
{ "Ooblique", 0xD8 },
+#endif
{ "Ugrave", 0xD9 },
{ "Uacute", 0xDA },
{ "Ucircumflex", 0xDB },
@@ -367,6 +550,9 @@
{ "odiaeresis", 0xF6 },
{ "division", 0xF7 },
{ "oslash", 0xF8 },
+#ifndef TK_NO_DEPRECATED
+{ "ooblique", 0xF8 },
+#endif
{ "ugrave", 0xF9 },
{ "uacute", 0xFA },
{ "ucircumflex", 0xFB },
@@ -454,7 +640,9 @@
{ "ubreve", 0x2FD },
{ "scircumflex", 0x2FE },
{ "kra", 0x3A2 },
+#ifndef TK_NO_DEPRECATED
{ "kappa", 0x3A2 },
+#endif
{ "Rcedilla", 0x3A3 },
{ "Itilde", 0x3A5 },
{ "Lcedilla", 0x3A6 },
@@ -466,7 +654,9 @@
{ "lcedilla", 0x3B6 },
{ "emacron", 0x3BA },
{ "gcedilla", 0x3BB },
+#ifndef TK_NO_DEPRECATED
{ "gacute", 0x3BB },
+#endif
{ "tslash", 0x3BC },
{ "ENG", 0x3BD },
{ "eng", 0x3BF },
@@ -490,13 +680,44 @@
{ "uogonek", 0x3F9 },
{ "utilde", 0x3FD },
{ "umacron", 0x3FE },
+{ "Wcircumflex", 0x1000174 },
+{ "wcircumflex", 0x1000175 },
+{ "Ycircumflex", 0x1000176 },
+{ "ycircumflex", 0x1000177 },
+{ "Babovedot", 0x1001E02 },
+{ "babovedot", 0x1001E03 },
+{ "Dabovedot", 0x1001E0A },
+{ "dabovedot", 0x1001E0B },
+{ "Fabovedot", 0x1001E1E },
+{ "fabovedot", 0x1001E1F },
+{ "Mabovedot", 0x1001E40 },
+{ "mabovedot", 0x1001E41 },
+{ "Pabovedot", 0x1001E56 },
+{ "pabovedot", 0x1001E57 },
+{ "Sabovedot", 0x1001E60 },
+{ "sabovedot", 0x1001E61 },
+{ "Tabovedot", 0x1001E6A },
+{ "tabovedot", 0x1001E6B },
+{ "Wgrave", 0x1001E80 },
+{ "wgrave", 0x1001E81 },
+{ "Wacute", 0x1001E82 },
+{ "wacute", 0x1001E83 },
+{ "Wdiaeresis", 0x1001E84 },
+{ "wdiaeresis", 0x1001E85 },
+{ "Ygrave", 0x1001EF2 },
+{ "ygrave", 0x1001EF3 },
+{ "OE", 0x13BC },
+{ "oe", 0x13BD },
+{ "Ydiaeresis", 0x13BE },
{ "overline", 0x47E },
{ "kana_fullstop", 0x4A1 },
{ "kana_openingbracket", 0x4A2 },
{ "kana_closingbracket", 0x4A3 },
{ "kana_comma", 0x4A4 },
{ "kana_conjunctive", 0x4A5 },
+#ifndef TK_NO_DEPRECATED
{ "kana_middledot", 0x4A5 },
+#endif
{ "kana_WO", 0x4A6 },
{ "kana_a", 0x4A7 },
{ "kana_i", 0x4A8 },
@@ -507,7 +728,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 },
@@ -526,9 +749,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 },
@@ -539,7 +766,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 },
@@ -560,7 +789,35 @@
{ "voicedsound", 0x4DE },
{ "semivoicedsound", 0x4DF },
{ "kana_switch", 0xFF7E },
+{ "Farsi_0", 0x10006F0 },
+{ "Farsi_1", 0x10006F1 },
+{ "Farsi_2", 0x10006F2 },
+{ "Farsi_3", 0x10006F3 },
+{ "Farsi_4", 0x10006F4 },
+{ "Farsi_5", 0x10006F5 },
+{ "Farsi_6", 0x10006F6 },
+{ "Farsi_7", 0x10006F7 },
+{ "Farsi_8", 0x10006F8 },
+{ "Farsi_9", 0x10006F9 },
+{ "Arabic_percent", 0x100066A },
+{ "Arabic_superscript_alef", 0x1000670 },
+{ "Arabic_tteh", 0x1000679 },
+{ "Arabic_peh", 0x100067E },
+{ "Arabic_tcheh", 0x1000686 },
+{ "Arabic_ddal", 0x1000688 },
+{ "Arabic_rreh", 0x1000691 },
{ "Arabic_comma", 0x5AC },
+{ "Arabic_fullstop", 0x10006D4 },
+{ "Arabic_0", 0x1000660 },
+{ "Arabic_1", 0x1000661 },
+{ "Arabic_2", 0x1000662 },
+{ "Arabic_3", 0x1000663 },
+{ "Arabic_4", 0x1000664 },
+{ "Arabic_5", 0x1000665 },
+{ "Arabic_6", 0x1000666 },
+{ "Arabic_7", 0x1000667 },
+{ "Arabic_8", 0x1000668 },
+{ "Arabic_9", 0x1000669 },
{ "Arabic_semicolon", 0x5BB },
{ "Arabic_question_mark", 0x5BF },
{ "Arabic_hamza", 0x5C1 },
@@ -597,7 +854,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 },
@@ -609,52 +868,123 @@
{ "Arabic_kasra", 0x5F0 },
{ "Arabic_shadda", 0x5F1 },
{ "Arabic_sukun", 0x5F2 },
+{ "Arabic_madda_above", 0x1000653 },
+{ "Arabic_hamza_above", 0x1000654 },
+{ "Arabic_hamza_below", 0x1000655 },
+{ "Arabic_jeh", 0x1000698 },
+{ "Arabic_veh", 0x10006A4 },
+{ "Arabic_keheh", 0x10006A9 },
+{ "Arabic_gaf", 0x10006AF },
+{ "Arabic_noon_ghunna", 0x10006BA },
+{ "Arabic_heh_doachashmee", 0x10006BE },
+{ "Farsi_yeh", 0x10006CC },
+{ "Arabic_farsi_yeh", 0x10006CC },
+{ "Arabic_yeh_baree", 0x10006D2 },
+{ "Arabic_heh_goal", 0x10006C1 },
{ "Arabic_switch", 0xFF7E },
+{ "Cyrillic_GHE_bar", 0x1000492 },
+{ "Cyrillic_ghe_bar", 0x1000493 },
+{ "Cyrillic_ZHE_descender", 0x1000496 },
+{ "Cyrillic_zhe_descender", 0x1000497 },
+{ "Cyrillic_KA_descender", 0x100049A },
+{ "Cyrillic_ka_descender", 0x100049B },
+{ "Cyrillic_KA_vertstroke", 0x100049C },
+{ "Cyrillic_ka_vertstroke", 0x100049D },
+{ "Cyrillic_EN_descender", 0x10004A2 },
+{ "Cyrillic_en_descender", 0x10004A3 },
+{ "Cyrillic_U_straight", 0x10004AE },
+{ "Cyrillic_u_straight", 0x10004AF },
+{ "Cyrillic_U_straight_bar", 0x10004B0 },
+{ "Cyrillic_u_straight_bar", 0x10004B1 },
+{ "Cyrillic_HA_descender", 0x10004B2 },
+{ "Cyrillic_ha_descender", 0x10004B3 },
+{ "Cyrillic_CHE_descender", 0x10004B6 },
+{ "Cyrillic_che_descender", 0x10004B7 },
+{ "Cyrillic_CHE_vertstroke", 0x10004B8 },
+{ "Cyrillic_che_vertstroke", 0x10004B9 },
+{ "Cyrillic_SHHA", 0x10004BA },
+{ "Cyrillic_shha", 0x10004BB },
+{ "Cyrillic_SCHWA", 0x10004D8 },
+{ "Cyrillic_schwa", 0x10004D9 },
+{ "Cyrillic_I_macron", 0x10004E2 },
+{ "Cyrillic_i_macron", 0x10004E3 },
+{ "Cyrillic_O_bar", 0x10004E8 },
+{ "Cyrillic_o_bar", 0x10004E9 },
+{ "Cyrillic_U_macron", 0x10004EE },
+{ "Cyrillic_u_macron", 0x10004EF },
{ "Serbian_dje", 0x6A1 },
{ "Macedonia_gje", 0x6A2 },
{ "Cyrillic_io", 0x6A3 },
{ "Ukrainian_ie", 0x6A4 },
+#ifndef TK_NO_DEPRECATED
{ "Ukranian_je", 0x6A4 },
+#endif
{ "Macedonia_dse", 0x6A5 },
{ "Ukrainian_i", 0x6A6 },
+#ifndef TK_NO_DEPRECATED
{ "Ukranian_i", 0x6A6 },
+#endif
{ "Ukrainian_yi", 0x6A7 },
+#ifndef TK_NO_DEPRECATED
{ "Ukranian_yi", 0x6A7 },
+#endif
{ "Cyrillic_je", 0x6A8 },
+#ifndef TK_NO_DEPRECATED
{ "Serbian_je", 0x6A8 },
+#endif
{ "Cyrillic_lje", 0x6A9 },
+#ifndef TK_NO_DEPRECATED
{ "Serbian_lje", 0x6A9 },
+#endif
{ "Cyrillic_nje", 0x6AA },
+#ifndef TK_NO_DEPRECATED
{ "Serbian_nje", 0x6AA },
+#endif
{ "Serbian_tshe", 0x6AB },
{ "Macedonia_kje", 0x6AC },
{ "Ukrainian_ghe_with_upturn", 0x6AD },
{ "Byelorussian_shortu", 0x6AE },
{ "Cyrillic_dzhe", 0x6AF },
+#ifndef TK_NO_DEPRECATED
{ "Serbian_dze", 0x6AF },
+#endif
{ "numerosign", 0x6B0 },
{ "Serbian_DJE", 0x6B1 },
{ "Macedonia_GJE", 0x6B2 },
{ "Cyrillic_IO", 0x6B3 },
{ "Ukrainian_IE", 0x6B4 },
+#ifndef TK_NO_DEPRECATED
{ "Ukranian_JE", 0x6B4 },
+#endif
{ "Macedonia_DSE", 0x6B5 },
{ "Ukrainian_I", 0x6B6 },
+#ifndef TK_NO_DEPRECATED
{ "Ukranian_I", 0x6B6 },
+#endif
{ "Ukrainian_YI", 0x6B7 },
+#ifndef TK_NO_DEPRECATED
{ "Ukranian_YI", 0x6B7 },
+#endif
{ "Cyrillic_JE", 0x6B8 },
+#ifndef TK_NO_DEPRECATED
{ "Serbian_JE", 0x6B8 },
+#endif
{ "Cyrillic_LJE", 0x6B9 },
+#ifndef TK_NO_DEPRECATED
{ "Serbian_LJE", 0x6B9 },
+#endif
{ "Cyrillic_NJE", 0x6BA },
+#ifndef TK_NO_DEPRECATED
{ "Serbian_NJE", 0x6BA },
+#endif
{ "Serbian_TSHE", 0x6BB },
{ "Macedonia_KJE", 0x6BC },
{ "Ukrainian_GHE_WITH_UPTURN", 0x6BD },
{ "Byelorussian_SHORTU", 0x6BE },
{ "Cyrillic_DZHE", 0x6BF },
+#ifndef TK_NO_DEPRECATED
{ "Serbian_DZE", 0x6BF },
+#endif
{ "Cyrillic_yu", 0x6C0 },
{ "Cyrillic_a", 0x6C1 },
{ "Cyrillic_be", 0x6C2 },
@@ -975,19 +1305,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 },
@@ -997,21 +1339,852 @@
{ "hebrew_finalnun", 0xCEF },
{ "hebrew_nun", 0xCF0 },
{ "hebrew_samech", 0xCF1 },
+#ifndef TK_NO_DEPRECATED
{ "hebrew_samekh", 0xCF1 },
+#endif
{ "hebrew_ayin", 0xCF2 },
{ "hebrew_finalpe", 0xCF3 },
{ "hebrew_pe", 0xCF4 },
{ "hebrew_finalzade", 0xCF5 },
+#ifndef TK_NO_DEPRECATED
{ "hebrew_finalzadi", 0xCF5 },
+#endif
{ "hebrew_zade", 0xCF6 },
+#ifndef TK_NO_DEPRECATED
{ "hebrew_zadi", 0xCF6 },
+#endif
{ "hebrew_qoph", 0xCF7 },
+#ifndef TK_NO_DEPRECATED
{ "hebrew_kuf", 0xCF7 },
+#endif
{ "hebrew_resh", 0xCF8 },
{ "hebrew_shin", 0xCF9 },
{ "hebrew_taw", 0xCFA },
+#ifndef TK_NO_DEPRECATED
{ "hebrew_taf", 0xCFA },
+#endif
{ "Hebrew_switch", 0xFF7E },
+{ "Thai_kokai", 0xDA1 },
+{ "Thai_khokhai", 0xDA2 },
+{ "Thai_khokhuat", 0xDA3 },
+{ "Thai_khokhwai", 0xDA4 },
+{ "Thai_khokhon", 0xDA5 },
+{ "Thai_khorakhang", 0xDA6 },
+{ "Thai_ngongu", 0xDA7 },
+{ "Thai_chochan", 0xDA8 },
+{ "Thai_choching", 0xDA9 },
+{ "Thai_chochang", 0xDAA },
+{ "Thai_soso", 0xDAB },
+{ "Thai_chochoe", 0xDAC },
+{ "Thai_yoying", 0xDAD },
+{ "Thai_dochada", 0xDAE },
+{ "Thai_topatak", 0xDAF },
+{ "Thai_thothan", 0xDB0 },
+{ "Thai_thonangmontho", 0xDB1 },
+{ "Thai_thophuthao", 0xDB2 },
+{ "Thai_nonen", 0xDB3 },
+{ "Thai_dodek", 0xDB4 },
+{ "Thai_totao", 0xDB5 },
+{ "Thai_thothung", 0xDB6 },
+{ "Thai_thothahan", 0xDB7 },
+{ "Thai_thothong", 0xDB8 },
+{ "Thai_nonu", 0xDB9 },
+{ "Thai_bobaimai", 0xDBA },
+{ "Thai_popla", 0xDBB },
+{ "Thai_phophung", 0xDBC },
+{ "Thai_fofa", 0xDBD },
+{ "Thai_phophan", 0xDBE },
+{ "Thai_fofan", 0xDBF },
+{ "Thai_phosamphao", 0xDC0 },
+{ "Thai_moma", 0xDC1 },
+{ "Thai_yoyak", 0xDC2 },
+{ "Thai_rorua", 0xDC3 },
+{ "Thai_ru", 0xDC4 },
+{ "Thai_loling", 0xDC5 },
+{ "Thai_lu", 0xDC6 },
+{ "Thai_wowaen", 0xDC7 },
+{ "Thai_sosala", 0xDC8 },
+{ "Thai_sorusi", 0xDC9 },
+{ "Thai_sosua", 0xDCA },
+{ "Thai_hohip", 0xDCB },
+{ "Thai_lochula", 0xDCC },
+{ "Thai_oang", 0xDCD },
+{ "Thai_honokhuk", 0xDCE },
+{ "Thai_paiyannoi", 0xDCF },
+{ "Thai_saraa", 0xDD0 },
+{ "Thai_maihanakat", 0xDD1 },
+{ "Thai_saraaa", 0xDD2 },
+{ "Thai_saraam", 0xDD3 },
+{ "Thai_sarai", 0xDD4 },
+{ "Thai_saraii", 0xDD5 },
+{ "Thai_saraue", 0xDD6 },
+{ "Thai_sarauee", 0xDD7 },
+{ "Thai_sarau", 0xDD8 },
+{ "Thai_sarauu", 0xDD9 },
+{ "Thai_phinthu", 0xDDA },
+{ "Thai_maihanakat_maitho", 0xDDE },
+{ "Thai_baht", 0xDDF },
+{ "Thai_sarae", 0xDE0 },
+{ "Thai_saraae", 0xDE1 },
+{ "Thai_sarao", 0xDE2 },
+{ "Thai_saraaimaimuan", 0xDE3 },
+{ "Thai_saraaimaimalai", 0xDE4 },
+{ "Thai_lakkhangyao", 0xDE5 },
+{ "Thai_maiyamok", 0xDE6 },
+{ "Thai_maitaikhu", 0xDE7 },
+{ "Thai_maiek", 0xDE8 },
+{ "Thai_maitho", 0xDE9 },
+{ "Thai_maitri", 0xDEA },
+{ "Thai_maichattawa", 0xDEB },
+{ "Thai_thanthakhat", 0xDEC },
+{ "Thai_nikhahit", 0xDED },
+{ "Thai_leksun", 0xDF0 },
+{ "Thai_leknung", 0xDF1 },
+{ "Thai_leksong", 0xDF2 },
+{ "Thai_leksam", 0xDF3 },
+{ "Thai_leksi", 0xDF4 },
+{ "Thai_lekha", 0xDF5 },
+{ "Thai_lekhok", 0xDF6 },
+{ "Thai_lekchet", 0xDF7 },
+{ "Thai_lekpaet", 0xDF8 },
+{ "Thai_lekkao", 0xDF9 },
+{ "Hangul", 0xFF31 },
+{ "Hangul_Start", 0xFF32 },
+{ "Hangul_End", 0xFF33 },
+{ "Hangul_Hanja", 0xFF34 },
+{ "Hangul_Jamo", 0xFF35 },
+{ "Hangul_Romaja", 0xFF36 },
+{ "Hangul_Codeinput", 0xFF37 },
+{ "Hangul_Jeonja", 0xFF38 },
+{ "Hangul_Banja", 0xFF39 },
+{ "Hangul_PreHanja", 0xFF3A },
+{ "Hangul_PostHanja", 0xFF3B },
+{ "Hangul_SingleCandidate", 0xFF3C },
+{ "Hangul_MultipleCandidate", 0xFF3D },
+{ "Hangul_PreviousCandidate", 0xFF3E },
+{ "Hangul_Special", 0xFF3F },
+{ "Hangul_switch", 0xFF7E },
+{ "Hangul_Kiyeog", 0xEA1 },
+{ "Hangul_SsangKiyeog", 0xEA2 },
+{ "Hangul_KiyeogSios", 0xEA3 },
+{ "Hangul_Nieun", 0xEA4 },
+{ "Hangul_NieunJieuj", 0xEA5 },
+{ "Hangul_NieunHieuh", 0xEA6 },
+{ "Hangul_Dikeud", 0xEA7 },
+{ "Hangul_SsangDikeud", 0xEA8 },
+{ "Hangul_Rieul", 0xEA9 },
+{ "Hangul_RieulKiyeog", 0xEAA },
+{ "Hangul_RieulMieum", 0xEAB },
+{ "Hangul_RieulPieub", 0xEAC },
+{ "Hangul_RieulSios", 0xEAD },
+{ "Hangul_RieulTieut", 0xEAE },
+{ "Hangul_RieulPhieuf", 0xEAF },
+{ "Hangul_RieulHieuh", 0xEB0 },
+{ "Hangul_Mieum", 0xEB1 },
+{ "Hangul_Pieub", 0xEB2 },
+{ "Hangul_SsangPieub", 0xEB3 },
+{ "Hangul_PieubSios", 0xEB4 },
+{ "Hangul_Sios", 0xEB5 },
+{ "Hangul_SsangSios", 0xEB6 },
+{ "Hangul_Ieung", 0xEB7 },
+{ "Hangul_Jieuj", 0xEB8 },
+{ "Hangul_SsangJieuj", 0xEB9 },
+{ "Hangul_Cieuc", 0xEBA },
+{ "Hangul_Khieuq", 0xEBB },
+{ "Hangul_Tieut", 0xEBC },
+{ "Hangul_Phieuf", 0xEBD },
+{ "Hangul_Hieuh", 0xEBE },
+{ "Hangul_A", 0xEBF },
+{ "Hangul_AE", 0xEC0 },
+{ "Hangul_YA", 0xEC1 },
+{ "Hangul_YAE", 0xEC2 },
+{ "Hangul_EO", 0xEC3 },
+{ "Hangul_E", 0xEC4 },
+{ "Hangul_YEO", 0xEC5 },
+{ "Hangul_YE", 0xEC6 },
+{ "Hangul_O", 0xEC7 },
+{ "Hangul_WA", 0xEC8 },
+{ "Hangul_WAE", 0xEC9 },
+{ "Hangul_OE", 0xECA },
+{ "Hangul_YO", 0xECB },
+{ "Hangul_U", 0xECC },
+{ "Hangul_WEO", 0xECD },
+{ "Hangul_WE", 0xECE },
+{ "Hangul_WI", 0xECF },
+{ "Hangul_YU", 0xED0 },
+{ "Hangul_EU", 0xED1 },
+{ "Hangul_YI", 0xED2 },
+{ "Hangul_I", 0xED3 },
+{ "Hangul_J_Kiyeog", 0xED4 },
+{ "Hangul_J_SsangKiyeog", 0xED5 },
+{ "Hangul_J_KiyeogSios", 0xED6 },
+{ "Hangul_J_Nieun", 0xED7 },
+{ "Hangul_J_NieunJieuj", 0xED8 },
+{ "Hangul_J_NieunHieuh", 0xED9 },
+{ "Hangul_J_Dikeud", 0xEDA },
+{ "Hangul_J_Rieul", 0xEDB },
+{ "Hangul_J_RieulKiyeog", 0xEDC },
+{ "Hangul_J_RieulMieum", 0xEDD },
+{ "Hangul_J_RieulPieub", 0xEDE },
+{ "Hangul_J_RieulSios", 0xEDF },
+{ "Hangul_J_RieulTieut", 0xEE0 },
+{ "Hangul_J_RieulPhieuf", 0xEE1 },
+{ "Hangul_J_RieulHieuh", 0xEE2 },
+{ "Hangul_J_Mieum", 0xEE3 },
+{ "Hangul_J_Pieub", 0xEE4 },
+{ "Hangul_J_PieubSios", 0xEE5 },
+{ "Hangul_J_Sios", 0xEE6 },
+{ "Hangul_J_SsangSios", 0xEE7 },
+{ "Hangul_J_Ieung", 0xEE8 },
+{ "Hangul_J_Jieuj", 0xEE9 },
+{ "Hangul_J_Cieuc", 0xEEA },
+{ "Hangul_J_Khieuq", 0xEEB },
+{ "Hangul_J_Tieut", 0xEEC },
+{ "Hangul_J_Phieuf", 0xEED },
+{ "Hangul_J_Hieuh", 0xEEE },
+{ "Hangul_RieulYeorinHieuh", 0xEEF },
+{ "Hangul_SunkyeongeumMieum", 0xEF0 },
+{ "Hangul_SunkyeongeumPieub", 0xEF1 },
+{ "Hangul_PanSios", 0xEF2 },
+{ "Hangul_KkogjiDalrinIeung", 0xEF3 },
+{ "Hangul_SunkyeongeumPhieuf", 0xEF4 },
+{ "Hangul_YeorinHieuh", 0xEF5 },
+{ "Hangul_AraeA", 0xEF6 },
+{ "Hangul_AraeAE", 0xEF7 },
+{ "Hangul_J_PanSios", 0xEF8 },
+{ "Hangul_J_KkogjiDalrinIeung", 0xEF9 },
+{ "Hangul_J_YeorinHieuh", 0xEFA },
+{ "Korean_Won", 0xEFF },
+{ "Armenian_ligature_ew", 0x1000587 },
+{ "Armenian_full_stop", 0x1000589 },
+{ "Armenian_verjaket", 0x1000589 },
+{ "Armenian_separation_mark", 0x100055D },
+{ "Armenian_but", 0x100055D },
+{ "Armenian_hyphen", 0x100058A },
+{ "Armenian_yentamna", 0x100058A },
+{ "Armenian_exclam", 0x100055C },
+{ "Armenian_amanak", 0x100055C },
+{ "Armenian_accent", 0x100055B },
+{ "Armenian_shesht", 0x100055B },
+{ "Armenian_question", 0x100055E },
+{ "Armenian_paruyk", 0x100055E },
+{ "Armenian_AYB", 0x1000531 },
+{ "Armenian_ayb", 0x1000561 },
+{ "Armenian_BEN", 0x1000532 },
+{ "Armenian_ben", 0x1000562 },
+{ "Armenian_GIM", 0x1000533 },
+{ "Armenian_gim", 0x1000563 },
+{ "Armenian_DA", 0x1000534 },
+{ "Armenian_da", 0x1000564 },
+{ "Armenian_YECH", 0x1000535 },
+{ "Armenian_yech", 0x1000565 },
+{ "Armenian_ZA", 0x1000536 },
+{ "Armenian_za", 0x1000566 },
+{ "Armenian_E", 0x1000537 },
+{ "Armenian_e", 0x1000567 },
+{ "Armenian_AT", 0x1000538 },
+{ "Armenian_at", 0x1000568 },
+{ "Armenian_TO", 0x1000539 },
+{ "Armenian_to", 0x1000569 },
+{ "Armenian_ZHE", 0x100053A },
+{ "Armenian_zhe", 0x100056A },
+{ "Armenian_INI", 0x100053B },
+{ "Armenian_ini", 0x100056B },
+{ "Armenian_LYUN", 0x100053C },
+{ "Armenian_lyun", 0x100056C },
+{ "Armenian_KHE", 0x100053D },
+{ "Armenian_khe", 0x100056D },
+{ "Armenian_TSA", 0x100053E },
+{ "Armenian_tsa", 0x100056E },
+{ "Armenian_KEN", 0x100053F },
+{ "Armenian_ken", 0x100056F },
+{ "Armenian_HO", 0x1000540 },
+{ "Armenian_ho", 0x1000570 },
+{ "Armenian_DZA", 0x1000541 },
+{ "Armenian_dza", 0x1000571 },
+{ "Armenian_GHAT", 0x1000542 },
+{ "Armenian_ghat", 0x1000572 },
+{ "Armenian_TCHE", 0x1000543 },
+{ "Armenian_tche", 0x1000573 },
+{ "Armenian_MEN", 0x1000544 },
+{ "Armenian_men", 0x1000574 },
+{ "Armenian_HI", 0x1000545 },
+{ "Armenian_hi", 0x1000575 },
+{ "Armenian_NU", 0x1000546 },
+{ "Armenian_nu", 0x1000576 },
+{ "Armenian_SHA", 0x1000547 },
+{ "Armenian_sha", 0x1000577 },
+{ "Armenian_VO", 0x1000548 },
+{ "Armenian_vo", 0x1000578 },
+{ "Armenian_CHA", 0x1000549 },
+{ "Armenian_cha", 0x1000579 },
+{ "Armenian_PE", 0x100054A },
+{ "Armenian_pe", 0x100057A },
+{ "Armenian_JE", 0x100054B },
+{ "Armenian_je", 0x100057B },
+{ "Armenian_RA", 0x100054C },
+{ "Armenian_ra", 0x100057C },
+{ "Armenian_SE", 0x100054D },
+{ "Armenian_se", 0x100057D },
+{ "Armenian_VEV", 0x100054E },
+{ "Armenian_vev", 0x100057E },
+{ "Armenian_TYUN", 0x100054F },
+{ "Armenian_tyun", 0x100057F },
+{ "Armenian_RE", 0x1000550 },
+{ "Armenian_re", 0x1000580 },
+{ "Armenian_TSO", 0x1000551 },
+{ "Armenian_tso", 0x1000581 },
+{ "Armenian_VYUN", 0x1000552 },
+{ "Armenian_vyun", 0x1000582 },
+{ "Armenian_PYUR", 0x1000553 },
+{ "Armenian_pyur", 0x1000583 },
+{ "Armenian_KE", 0x1000554 },
+{ "Armenian_ke", 0x1000584 },
+{ "Armenian_O", 0x1000555 },
+{ "Armenian_o", 0x1000585 },
+{ "Armenian_FE", 0x1000556 },
+{ "Armenian_fe", 0x1000586 },
+{ "Armenian_apostrophe", 0x100055A },
+{ "Georgian_an", 0x10010D0 },
+{ "Georgian_ban", 0x10010D1 },
+{ "Georgian_gan", 0x10010D2 },
+{ "Georgian_don", 0x10010D3 },
+{ "Georgian_en", 0x10010D4 },
+{ "Georgian_vin", 0x10010D5 },
+{ "Georgian_zen", 0x10010D6 },
+{ "Georgian_tan", 0x10010D7 },
+{ "Georgian_in", 0x10010D8 },
+{ "Georgian_kan", 0x10010D9 },
+{ "Georgian_las", 0x10010DA },
+{ "Georgian_man", 0x10010DB },
+{ "Georgian_nar", 0x10010DC },
+{ "Georgian_on", 0x10010DD },
+{ "Georgian_par", 0x10010DE },
+{ "Georgian_zhar", 0x10010DF },
+{ "Georgian_rae", 0x10010E0 },
+{ "Georgian_san", 0x10010E1 },
+{ "Georgian_tar", 0x10010E2 },
+{ "Georgian_un", 0x10010E3 },
+{ "Georgian_phar", 0x10010E4 },
+{ "Georgian_khar", 0x10010E5 },
+{ "Georgian_ghan", 0x10010E6 },
+{ "Georgian_qar", 0x10010E7 },
+{ "Georgian_shin", 0x10010E8 },
+{ "Georgian_chin", 0x10010E9 },
+{ "Georgian_can", 0x10010EA },
+{ "Georgian_jil", 0x10010EB },
+{ "Georgian_cil", 0x10010EC },
+{ "Georgian_char", 0x10010ED },
+{ "Georgian_xan", 0x10010EE },
+{ "Georgian_jhan", 0x10010EF },
+{ "Georgian_hae", 0x10010F0 },
+{ "Georgian_he", 0x10010F1 },
+{ "Georgian_hie", 0x10010F2 },
+{ "Georgian_we", 0x10010F3 },
+{ "Georgian_har", 0x10010F4 },
+{ "Georgian_hoe", 0x10010F5 },
+{ "Georgian_fi", 0x10010F6 },
+{ "Xabovedot", 0x1001E8A },
+{ "Ibreve", 0x100012C },
+{ "Zstroke", 0x10001B5 },
+{ "Gcaron", 0x10001E6 },
+{ "Ocaron", 0x10001D1 },
+{ "Obarred", 0x100019F },
+{ "xabovedot", 0x1001E8B },
+{ "ibreve", 0x100012D },
+{ "zstroke", 0x10001B6 },
+{ "gcaron", 0x10001E7 },
+{ "ocaron", 0x10001D2 },
+{ "obarred", 0x1000275 },
+{ "SCHWA", 0x100018F },
+{ "schwa", 0x1000259 },
+{ "EZH", 0x10001B7 },
+{ "ezh", 0x1000292 },
+{ "Lbelowdot", 0x1001E36 },
+{ "lbelowdot", 0x1001E37 },
+{ "Abelowdot", 0x1001EA0 },
+{ "abelowdot", 0x1001EA1 },
+{ "Ahook", 0x1001EA2 },
+{ "ahook", 0x1001EA3 },
+{ "Acircumflexacute", 0x1001EA4 },
+{ "acircumflexacute", 0x1001EA5 },
+{ "Acircumflexgrave", 0x1001EA6 },
+{ "acircumflexgrave", 0x1001EA7 },
+{ "Acircumflexhook", 0x1001EA8 },
+{ "acircumflexhook", 0x1001EA9 },
+{ "Acircumflextilde", 0x1001EAA },
+{ "acircumflextilde", 0x1001EAB },
+{ "Acircumflexbelowdot", 0x1001EAC },
+{ "acircumflexbelowdot", 0x1001EAD },
+{ "Abreveacute", 0x1001EAE },
+{ "abreveacute", 0x1001EAF },
+{ "Abrevegrave", 0x1001EB0 },
+{ "abrevegrave", 0x1001EB1 },
+{ "Abrevehook", 0x1001EB2 },
+{ "abrevehook", 0x1001EB3 },
+{ "Abrevetilde", 0x1001EB4 },
+{ "abrevetilde", 0x1001EB5 },
+{ "Abrevebelowdot", 0x1001EB6 },
+{ "abrevebelowdot", 0x1001EB7 },
+{ "Ebelowdot", 0x1001EB8 },
+{ "ebelowdot", 0x1001EB9 },
+{ "Ehook", 0x1001EBA },
+{ "ehook", 0x1001EBB },
+{ "Etilde", 0x1001EBC },
+{ "etilde", 0x1001EBD },
+{ "Ecircumflexacute", 0x1001EBE },
+{ "ecircumflexacute", 0x1001EBF },
+{ "Ecircumflexgrave", 0x1001EC0 },
+{ "ecircumflexgrave", 0x1001EC1 },
+{ "Ecircumflexhook", 0x1001EC2 },
+{ "ecircumflexhook", 0x1001EC3 },
+{ "Ecircumflextilde", 0x1001EC4 },
+{ "ecircumflextilde", 0x1001EC5 },
+{ "Ecircumflexbelowdot", 0x1001EC6 },
+{ "ecircumflexbelowdot", 0x1001EC7 },
+{ "Ihook", 0x1001EC8 },
+{ "ihook", 0x1001EC9 },
+{ "Ibelowdot", 0x1001ECA },
+{ "ibelowdot", 0x1001ECB },
+{ "Obelowdot", 0x1001ECC },
+{ "obelowdot", 0x1001ECD },
+{ "Ohook", 0x1001ECE },
+{ "ohook", 0x1001ECF },
+{ "Ocircumflexacute", 0x1001ED0 },
+{ "ocircumflexacute", 0x1001ED1 },
+{ "Ocircumflexgrave", 0x1001ED2 },
+{ "ocircumflexgrave", 0x1001ED3 },
+{ "Ocircumflexhook", 0x1001ED4 },
+{ "ocircumflexhook", 0x1001ED5 },
+{ "Ocircumflextilde", 0x1001ED6 },
+{ "ocircumflextilde", 0x1001ED7 },
+{ "Ocircumflexbelowdot", 0x1001ED8 },
+{ "ocircumflexbelowdot", 0x1001ED9 },
+{ "Ohornacute", 0x1001EDA },
+{ "ohornacute", 0x1001EDB },
+{ "Ohorngrave", 0x1001EDC },
+{ "ohorngrave", 0x1001EDD },
+{ "Ohornhook", 0x1001EDE },
+{ "ohornhook", 0x1001EDF },
+{ "Ohorntilde", 0x1001EE0 },
+{ "ohorntilde", 0x1001EE1 },
+{ "Ohornbelowdot", 0x1001EE2 },
+{ "ohornbelowdot", 0x1001EE3 },
+{ "Ubelowdot", 0x1001EE4 },
+{ "ubelowdot", 0x1001EE5 },
+{ "Uhook", 0x1001EE6 },
+{ "uhook", 0x1001EE7 },
+{ "Uhornacute", 0x1001EE8 },
+{ "uhornacute", 0x1001EE9 },
+{ "Uhorngrave", 0x1001EEA },
+{ "uhorngrave", 0x1001EEB },
+{ "Uhornhook", 0x1001EEC },
+{ "uhornhook", 0x1001EED },
+{ "Uhorntilde", 0x1001EEE },
+{ "uhorntilde", 0x1001EEF },
+{ "Uhornbelowdot", 0x1001EF0 },
+{ "uhornbelowdot", 0x1001EF1 },
+{ "Ybelowdot", 0x1001EF4 },
+{ "ybelowdot", 0x1001EF5 },
+{ "Yhook", 0x1001EF6 },
+{ "yhook", 0x1001EF7 },
+{ "Ytilde", 0x1001EF8 },
+{ "ytilde", 0x1001EF9 },
+{ "Ohorn", 0x10001A0 },
+{ "ohorn", 0x10001A1 },
+{ "Uhorn", 0x10001AF },
+{ "uhorn", 0x10001B0 },
+{ "EcuSign", 0x10020A0 },
+{ "ColonSign", 0x10020A1 },
+{ "CruzeiroSign", 0x10020A2 },
+{ "FFrancSign", 0x10020A3 },
+{ "LiraSign", 0x10020A4 },
+{ "MillSign", 0x10020A5 },
+{ "NairaSign", 0x10020A6 },
+{ "PesetaSign", 0x10020A7 },
+{ "RupeeSign", 0x10020A8 },
+{ "WonSign", 0x10020A9 },
+{ "NewSheqelSign", 0x10020AA },
+{ "DongSign", 0x10020AB },
+{ "EuroSign", 0x20AC },
+{ "zerosuperior", 0x1002070 },
+{ "foursuperior", 0x1002074 },
+{ "fivesuperior", 0x1002075 },
+{ "sixsuperior", 0x1002076 },
+{ "sevensuperior", 0x1002077 },
+{ "eightsuperior", 0x1002078 },
+{ "ninesuperior", 0x1002079 },
+{ "zerosubscript", 0x1002080 },
+{ "onesubscript", 0x1002081 },
+{ "twosubscript", 0x1002082 },
+{ "threesubscript", 0x1002083 },
+{ "foursubscript", 0x1002084 },
+{ "fivesubscript", 0x1002085 },
+{ "sixsubscript", 0x1002086 },
+{ "sevensubscript", 0x1002087 },
+{ "eightsubscript", 0x1002088 },
+{ "ninesubscript", 0x1002089 },
+{ "partdifferential", 0x1002202 },
+{ "emptyset", 0x1002205 },
+{ "elementof", 0x1002208 },
+{ "notelementof", 0x1002209 },
+{ "containsas", 0x100220B },
+{ "squareroot", 0x100221A },
+{ "cuberoot", 0x100221B },
+{ "fourthroot", 0x100221C },
+{ "dintegral", 0x100222C },
+{ "tintegral", 0x100222D },
+{ "because", 0x1002235 },
+{ "approxeq", 0x1002248 },
+{ "notapproxeq", 0x1002247 },
+{ "notidentical", 0x1002262 },
+{ "stricteq", 0x1002263 },
+{ "braille_dot_1", 0xFFF1 },
+{ "braille_dot_2", 0xFFF2 },
+{ "braille_dot_3", 0xFFF3 },
+{ "braille_dot_4", 0xFFF4 },
+{ "braille_dot_5", 0xFFF5 },
+{ "braille_dot_6", 0xFFF6 },
+{ "braille_dot_7", 0xFFF7 },
+{ "braille_dot_8", 0xFFF8 },
+{ "braille_dot_9", 0xFFF9 },
+{ "braille_dot_10", 0xFFFA },
+{ "braille_blank", 0x1002800 },
+{ "braille_dots_1", 0x1002801 },
+{ "braille_dots_2", 0x1002802 },
+{ "braille_dots_12", 0x1002803 },
+{ "braille_dots_3", 0x1002804 },
+{ "braille_dots_13", 0x1002805 },
+{ "braille_dots_23", 0x1002806 },
+{ "braille_dots_123", 0x1002807 },
+{ "braille_dots_4", 0x1002808 },
+{ "braille_dots_14", 0x1002809 },
+{ "braille_dots_24", 0x100280A },
+{ "braille_dots_124", 0x100280B },
+{ "braille_dots_34", 0x100280C },
+{ "braille_dots_134", 0x100280D },
+{ "braille_dots_234", 0x100280E },
+{ "braille_dots_1234", 0x100280F },
+{ "braille_dots_5", 0x1002810 },
+{ "braille_dots_15", 0x1002811 },
+{ "braille_dots_25", 0x1002812 },
+{ "braille_dots_125", 0x1002813 },
+{ "braille_dots_35", 0x1002814 },
+{ "braille_dots_135", 0x1002815 },
+{ "braille_dots_235", 0x1002816 },
+{ "braille_dots_1235", 0x1002817 },
+{ "braille_dots_45", 0x1002818 },
+{ "braille_dots_145", 0x1002819 },
+{ "braille_dots_245", 0x100281A },
+{ "braille_dots_1245", 0x100281B },
+{ "braille_dots_345", 0x100281C },
+{ "braille_dots_1345", 0x100281D },
+{ "braille_dots_2345", 0x100281E },
+{ "braille_dots_12345", 0x100281F },
+{ "braille_dots_6", 0x1002820 },
+{ "braille_dots_16", 0x1002821 },
+{ "braille_dots_26", 0x1002822 },
+{ "braille_dots_126", 0x1002823 },
+{ "braille_dots_36", 0x1002824 },
+{ "braille_dots_136", 0x1002825 },
+{ "braille_dots_236", 0x1002826 },
+{ "braille_dots_1236", 0x1002827 },
+{ "braille_dots_46", 0x1002828 },
+{ "braille_dots_146", 0x1002829 },
+{ "braille_dots_246", 0x100282A },
+{ "braille_dots_1246", 0x100282B },
+{ "braille_dots_346", 0x100282C },
+{ "braille_dots_1346", 0x100282D },
+{ "braille_dots_2346", 0x100282E },
+{ "braille_dots_12346", 0x100282F },
+{ "braille_dots_56", 0x1002830 },
+{ "braille_dots_156", 0x1002831 },
+{ "braille_dots_256", 0x1002832 },
+{ "braille_dots_1256", 0x1002833 },
+{ "braille_dots_356", 0x1002834 },
+{ "braille_dots_1356", 0x1002835 },
+{ "braille_dots_2356", 0x1002836 },
+{ "braille_dots_12356", 0x1002837 },
+{ "braille_dots_456", 0x1002838 },
+{ "braille_dots_1456", 0x1002839 },
+{ "braille_dots_2456", 0x100283A },
+{ "braille_dots_12456", 0x100283B },
+{ "braille_dots_3456", 0x100283C },
+{ "braille_dots_13456", 0x100283D },
+{ "braille_dots_23456", 0x100283E },
+{ "braille_dots_123456", 0x100283F },
+{ "braille_dots_7", 0x1002840 },
+{ "braille_dots_17", 0x1002841 },
+{ "braille_dots_27", 0x1002842 },
+{ "braille_dots_127", 0x1002843 },
+{ "braille_dots_37", 0x1002844 },
+{ "braille_dots_137", 0x1002845 },
+{ "braille_dots_237", 0x1002846 },
+{ "braille_dots_1237", 0x1002847 },
+{ "braille_dots_47", 0x1002848 },
+{ "braille_dots_147", 0x1002849 },
+{ "braille_dots_247", 0x100284A },
+{ "braille_dots_1247", 0x100284B },
+{ "braille_dots_347", 0x100284C },
+{ "braille_dots_1347", 0x100284D },
+{ "braille_dots_2347", 0x100284E },
+{ "braille_dots_12347", 0x100284F },
+{ "braille_dots_57", 0x1002850 },
+{ "braille_dots_157", 0x1002851 },
+{ "braille_dots_257", 0x1002852 },
+{ "braille_dots_1257", 0x1002853 },
+{ "braille_dots_357", 0x1002854 },
+{ "braille_dots_1357", 0x1002855 },
+{ "braille_dots_2357", 0x1002856 },
+{ "braille_dots_12357", 0x1002857 },
+{ "braille_dots_457", 0x1002858 },
+{ "braille_dots_1457", 0x1002859 },
+{ "braille_dots_2457", 0x100285A },
+{ "braille_dots_12457", 0x100285B },
+{ "braille_dots_3457", 0x100285C },
+{ "braille_dots_13457", 0x100285D },
+{ "braille_dots_23457", 0x100285E },
+{ "braille_dots_123457", 0x100285F },
+{ "braille_dots_67", 0x1002860 },
+{ "braille_dots_167", 0x1002861 },
+{ "braille_dots_267", 0x1002862 },
+{ "braille_dots_1267", 0x1002863 },
+{ "braille_dots_367", 0x1002864 },
+{ "braille_dots_1367", 0x1002865 },
+{ "braille_dots_2367", 0x1002866 },
+{ "braille_dots_12367", 0x1002867 },
+{ "braille_dots_467", 0x1002868 },
+{ "braille_dots_1467", 0x1002869 },
+{ "braille_dots_2467", 0x100286A },
+{ "braille_dots_12467", 0x100286B },
+{ "braille_dots_3467", 0x100286C },
+{ "braille_dots_13467", 0x100286D },
+{ "braille_dots_23467", 0x100286E },
+{ "braille_dots_123467", 0x100286F },
+{ "braille_dots_567", 0x1002870 },
+{ "braille_dots_1567", 0x1002871 },
+{ "braille_dots_2567", 0x1002872 },
+{ "braille_dots_12567", 0x1002873 },
+{ "braille_dots_3567", 0x1002874 },
+{ "braille_dots_13567", 0x1002875 },
+{ "braille_dots_23567", 0x1002876 },
+{ "braille_dots_123567", 0x1002877 },
+{ "braille_dots_4567", 0x1002878 },
+{ "braille_dots_14567", 0x1002879 },
+{ "braille_dots_24567", 0x100287A },
+{ "braille_dots_124567", 0x100287B },
+{ "braille_dots_34567", 0x100287C },
+{ "braille_dots_134567", 0x100287D },
+{ "braille_dots_234567", 0x100287E },
+{ "braille_dots_1234567", 0x100287F },
+{ "braille_dots_8", 0x1002880 },
+{ "braille_dots_18", 0x1002881 },
+{ "braille_dots_28", 0x1002882 },
+{ "braille_dots_128", 0x1002883 },
+{ "braille_dots_38", 0x1002884 },
+{ "braille_dots_138", 0x1002885 },
+{ "braille_dots_238", 0x1002886 },
+{ "braille_dots_1238", 0x1002887 },
+{ "braille_dots_48", 0x1002888 },
+{ "braille_dots_148", 0x1002889 },
+{ "braille_dots_248", 0x100288A },
+{ "braille_dots_1248", 0x100288B },
+{ "braille_dots_348", 0x100288C },
+{ "braille_dots_1348", 0x100288D },
+{ "braille_dots_2348", 0x100288E },
+{ "braille_dots_12348", 0x100288F },
+{ "braille_dots_58", 0x1002890 },
+{ "braille_dots_158", 0x1002891 },
+{ "braille_dots_258", 0x1002892 },
+{ "braille_dots_1258", 0x1002893 },
+{ "braille_dots_358", 0x1002894 },
+{ "braille_dots_1358", 0x1002895 },
+{ "braille_dots_2358", 0x1002896 },
+{ "braille_dots_12358", 0x1002897 },
+{ "braille_dots_458", 0x1002898 },
+{ "braille_dots_1458", 0x1002899 },
+{ "braille_dots_2458", 0x100289A },
+{ "braille_dots_12458", 0x100289B },
+{ "braille_dots_3458", 0x100289C },
+{ "braille_dots_13458", 0x100289D },
+{ "braille_dots_23458", 0x100289E },
+{ "braille_dots_123458", 0x100289F },
+{ "braille_dots_68", 0x10028A0 },
+{ "braille_dots_168", 0x10028A1 },
+{ "braille_dots_268", 0x10028A2 },
+{ "braille_dots_1268", 0x10028A3 },
+{ "braille_dots_368", 0x10028A4 },
+{ "braille_dots_1368", 0x10028A5 },
+{ "braille_dots_2368", 0x10028A6 },
+{ "braille_dots_12368", 0x10028A7 },
+{ "braille_dots_468", 0x10028A8 },
+{ "braille_dots_1468", 0x10028A9 },
+{ "braille_dots_2468", 0x10028AA },
+{ "braille_dots_12468", 0x10028AB },
+{ "braille_dots_3468", 0x10028AC },
+{ "braille_dots_13468", 0x10028AD },
+{ "braille_dots_23468", 0x10028AE },
+{ "braille_dots_123468", 0x10028AF },
+{ "braille_dots_568", 0x10028B0 },
+{ "braille_dots_1568", 0x10028B1 },
+{ "braille_dots_2568", 0x10028B2 },
+{ "braille_dots_12568", 0x10028B3 },
+{ "braille_dots_3568", 0x10028B4 },
+{ "braille_dots_13568", 0x10028B5 },
+{ "braille_dots_23568", 0x10028B6 },
+{ "braille_dots_123568", 0x10028B7 },
+{ "braille_dots_4568", 0x10028B8 },
+{ "braille_dots_14568", 0x10028B9 },
+{ "braille_dots_24568", 0x10028BA },
+{ "braille_dots_124568", 0x10028BB },
+{ "braille_dots_34568", 0x10028BC },
+{ "braille_dots_134568", 0x10028BD },
+{ "braille_dots_234568", 0x10028BE },
+{ "braille_dots_1234568", 0x10028BF },
+{ "braille_dots_78", 0x10028C0 },
+{ "braille_dots_178", 0x10028C1 },
+{ "braille_dots_278", 0x10028C2 },
+{ "braille_dots_1278", 0x10028C3 },
+{ "braille_dots_378", 0x10028C4 },
+{ "braille_dots_1378", 0x10028C5 },
+{ "braille_dots_2378", 0x10028C6 },
+{ "braille_dots_12378", 0x10028C7 },
+{ "braille_dots_478", 0x10028C8 },
+{ "braille_dots_1478", 0x10028C9 },
+{ "braille_dots_2478", 0x10028CA },
+{ "braille_dots_12478", 0x10028CB },
+{ "braille_dots_3478", 0x10028CC },
+{ "braille_dots_13478", 0x10028CD },
+{ "braille_dots_23478", 0x10028CE },
+{ "braille_dots_123478", 0x10028CF },
+{ "braille_dots_578", 0x10028D0 },
+{ "braille_dots_1578", 0x10028D1 },
+{ "braille_dots_2578", 0x10028D2 },
+{ "braille_dots_12578", 0x10028D3 },
+{ "braille_dots_3578", 0x10028D4 },
+{ "braille_dots_13578", 0x10028D5 },
+{ "braille_dots_23578", 0x10028D6 },
+{ "braille_dots_123578", 0x10028D7 },
+{ "braille_dots_4578", 0x10028D8 },
+{ "braille_dots_14578", 0x10028D9 },
+{ "braille_dots_24578", 0x10028DA },
+{ "braille_dots_124578", 0x10028DB },
+{ "braille_dots_34578", 0x10028DC },
+{ "braille_dots_134578", 0x10028DD },
+{ "braille_dots_234578", 0x10028DE },
+{ "braille_dots_1234578", 0x10028DF },
+{ "braille_dots_678", 0x10028E0 },
+{ "braille_dots_1678", 0x10028E1 },
+{ "braille_dots_2678", 0x10028E2 },
+{ "braille_dots_12678", 0x10028E3 },
+{ "braille_dots_3678", 0x10028E4 },
+{ "braille_dots_13678", 0x10028E5 },
+{ "braille_dots_23678", 0x10028E6 },
+{ "braille_dots_123678", 0x10028E7 },
+{ "braille_dots_4678", 0x10028E8 },
+{ "braille_dots_14678", 0x10028E9 },
+{ "braille_dots_24678", 0x10028EA },
+{ "braille_dots_124678", 0x10028EB },
+{ "braille_dots_34678", 0x10028EC },
+{ "braille_dots_134678", 0x10028ED },
+{ "braille_dots_234678", 0x10028EE },
+{ "braille_dots_1234678", 0x10028EF },
+{ "braille_dots_5678", 0x10028F0 },
+{ "braille_dots_15678", 0x10028F1 },
+{ "braille_dots_25678", 0x10028F2 },
+{ "braille_dots_125678", 0x10028F3 },
+{ "braille_dots_35678", 0x10028F4 },
+{ "braille_dots_135678", 0x10028F5 },
+{ "braille_dots_235678", 0x10028F6 },
+{ "braille_dots_1235678", 0x10028F7 },
+{ "braille_dots_45678", 0x10028F8 },
+{ "braille_dots_145678", 0x10028F9 },
+{ "braille_dots_245678", 0x10028FA },
+{ "braille_dots_1245678", 0x10028FB },
+{ "braille_dots_345678", 0x10028FC },
+{ "braille_dots_1345678", 0x10028FD },
+{ "braille_dots_2345678", 0x10028FE },
+{ "braille_dots_12345678", 0x10028FF },
+{ "Sinh_ng", 0x1000D82 },
+{ "Sinh_h2", 0x1000D83 },
+{ "Sinh_a", 0x1000D85 },
+{ "Sinh_aa", 0x1000D86 },
+{ "Sinh_ae", 0x1000D87 },
+{ "Sinh_aee", 0x1000D88 },
+{ "Sinh_i", 0x1000D89 },
+{ "Sinh_ii", 0x1000D8A },
+{ "Sinh_u", 0x1000D8B },
+{ "Sinh_uu", 0x1000D8C },
+{ "Sinh_ri", 0x1000D8D },
+{ "Sinh_rii", 0x1000D8E },
+{ "Sinh_lu", 0x1000D8F },
+{ "Sinh_luu", 0x1000D90 },
+{ "Sinh_e", 0x1000D91 },
+{ "Sinh_ee", 0x1000D92 },
+{ "Sinh_ai", 0x1000D93 },
+{ "Sinh_o", 0x1000D94 },
+{ "Sinh_oo", 0x1000D95 },
+{ "Sinh_au", 0x1000D96 },
+{ "Sinh_ka", 0x1000D9A },
+{ "Sinh_kha", 0x1000D9B },
+{ "Sinh_ga", 0x1000D9C },
+{ "Sinh_gha", 0x1000D9D },
+{ "Sinh_ng2", 0x1000D9E },
+{ "Sinh_nga", 0x1000D9F },
+{ "Sinh_ca", 0x1000DA0 },
+{ "Sinh_cha", 0x1000DA1 },
+{ "Sinh_ja", 0x1000DA2 },
+{ "Sinh_jha", 0x1000DA3 },
+{ "Sinh_nya", 0x1000DA4 },
+{ "Sinh_jnya", 0x1000DA5 },
+{ "Sinh_nja", 0x1000DA6 },
+{ "Sinh_tta", 0x1000DA7 },
+{ "Sinh_ttha", 0x1000DA8 },
+{ "Sinh_dda", 0x1000DA9 },
+{ "Sinh_ddha", 0x1000DAA },
+{ "Sinh_nna", 0x1000DAB },
+{ "Sinh_ndda", 0x1000DAC },
+{ "Sinh_tha", 0x1000DAD },
+{ "Sinh_thha", 0x1000DAE },
+{ "Sinh_dha", 0x1000DAF },
+{ "Sinh_dhha", 0x1000DB0 },
+{ "Sinh_na", 0x1000DB1 },
+{ "Sinh_ndha", 0x1000DB3 },
+{ "Sinh_pa", 0x1000DB4 },
+{ "Sinh_pha", 0x1000DB5 },
+{ "Sinh_ba", 0x1000DB6 },
+{ "Sinh_bha", 0x1000DB7 },
+{ "Sinh_ma", 0x1000DB8 },
+{ "Sinh_mba", 0x1000DB9 },
+{ "Sinh_ya", 0x1000DBA },
+{ "Sinh_ra", 0x1000DBB },
+{ "Sinh_la", 0x1000DBD },
+{ "Sinh_va", 0x1000DC0 },
+{ "Sinh_sha", 0x1000DC1 },
+{ "Sinh_ssha", 0x1000DC2 },
+{ "Sinh_sa", 0x1000DC3 },
+{ "Sinh_ha", 0x1000DC4 },
+{ "Sinh_lla", 0x1000DC5 },
+{ "Sinh_fa", 0x1000DC6 },
+{ "Sinh_al", 0x1000DCA },
+{ "Sinh_aa2", 0x1000DCF },
+{ "Sinh_ae2", 0x1000DD0 },
+{ "Sinh_aee2", 0x1000DD1 },
+{ "Sinh_i2", 0x1000DD2 },
+{ "Sinh_ii2", 0x1000DD3 },
+{ "Sinh_u2", 0x1000DD4 },
+{ "Sinh_uu2", 0x1000DD6 },
+{ "Sinh_ru2", 0x1000DD8 },
+{ "Sinh_e2", 0x1000DD9 },
+{ "Sinh_ee2", 0x1000DDA },
+{ "Sinh_ai2", 0x1000DDB },
+{ "Sinh_o2", 0x1000DDC },
+{ "Sinh_oo2", 0x1000DDD },
+{ "Sinh_au2", 0x1000DDE },
+{ "Sinh_lu2", 0x1000DDF },
+{ "Sinh_ruu2", 0x1000DF2 },
+{ "Sinh_luu2", 0x1000DF3 },
+{ "Sinh_kunddaliya", 0x1000DF4 },
{ "XF86ModeLock", 0x1008FF01 },
{ "XF86MonBrightnessUp", 0x1008FF02 },
{ "XF86MonBrightnessDown", 0x1008FF03 },
@@ -1195,3 +2368,26 @@
{ "XF86Prev_VMode", 0x1008FE23 },
{ "XF86LogWindowTree", 0x1008FE24 },
{ "XF86LogGrabInfo", 0x1008FE25 },
+{ "SunFA_Grave", 0x1005FF00 },
+{ "SunFA_Circum", 0x1005FF01 },
+{ "SunFA_Tilde", 0x1005FF02 },
+{ "SunFA_Acute", 0x1005FF03 },
+{ "SunFA_Diaeresis", 0x1005FF04 },
+{ "SunFA_Cedilla", 0x1005FF05 },
+{ "SunF36", 0x1005FF10 },
+{ "SunF37", 0x1005FF11 },
+{ "SunSys_Req", 0x1005FF60 },
+{ "SunProps", 0x1005FF70 },
+{ "SunFront", 0x1005FF71 },
+{ "SunCopy", 0x1005FF72 },
+{ "SunOpen", 0x1005FF73 },
+{ "SunPaste", 0x1005FF74 },
+{ "SunCut", 0x1005FF75 },
+{ "SunPowerSwitch", 0x1005FF76 },
+{ "SunAudioLowerVolume", 0x1005FF77 },
+{ "SunAudioMute", 0x1005FF78 },
+{ "SunAudioRaiseVolume", 0x1005FF79 },
+{ "SunVideoDegauss", 0x1005FF7A },
+{ "SunVideoLowerBrightness", 0x1005FF7B },
+{ "SunVideoRaiseBrightness", 0x1005FF7C },
+{ "SunPowerSwitchShift", 0x1005FF7D },
diff --git a/generic/nanosvg.h b/generic/nanosvg.h
new file mode 100644
index 0000000..3f9548b
--- /dev/null
+++ b/generic/nanosvg.h
@@ -0,0 +1,3129 @@
+/*
+ * 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 (_MSC_VER == 1200)
+#define tanf(a) (float)tan(a)
+#define cosf(a) (float)cos(a)
+#define sinf(a) (float)sin(a)
+#define sqrtf(a) (float)sqrt(a)
+#define fabsf(a) (float)fabs(a)
+#define acosf(a) (float)acos(a)
+#define atan2f(a,b) (float)atan2(a,b)
+#define ceilf(a) (float)ceil(a)
+#define fmodf(a,b) (float)fmod(a,b)
+#define floorf(a) (float)floor(a)
+#endif
+// float emulation for MS VC8++ compiler
+#if (_MSC_VER == 1400)
+#define fabsf(a) (float)fabs(a)
+#endif
+
+enum NSVGpaintType {
+ NSVG_PAINT_NONE = 0,
+ NSVG_PAINT_COLOR = 1,
+ NSVG_PAINT_LINEAR_GRADIENT = 2,
+ NSVG_PAINT_RADIAL_GRADIENT = 3
+};
+
+enum NSVGspreadType {
+ NSVG_SPREAD_PAD = 0,
+ NSVG_SPREAD_REFLECT = 1,
+ NSVG_SPREAD_REPEAT = 2
+};
+
+enum NSVGlineJoin {
+ NSVG_JOIN_MITER = 0,
+ NSVG_JOIN_ROUND = 1,
+ NSVG_JOIN_BEVEL = 2
+};
+
+enum NSVGlineCap {
+ NSVG_CAP_BUTT = 0,
+ NSVG_CAP_ROUND = 1,
+ NSVG_CAP_SQUARE = 2
+};
+
+enum NSVGfillRule {
+ NSVG_FILLRULE_NONZERO = 0,
+ NSVG_FILLRULE_EVENODD = 1
+};
+
+enum NSVGflags {
+ NSVG_FLAGS_VISIBLE = 0x01
+};
+
+typedef struct NSVGgradientStop {
+ unsigned int color;
+ float offset;
+} NSVGgradientStop;
+
+typedef struct NSVGgradient {
+ float xform[6];
+ char spread;
+ float fx, fy;
+ int nstops;
+ NSVGgradientStop stops[1];
+} NSVGgradient;
+
+typedef struct NSVGpaint {
+ char type;
+ union {
+ unsigned int color;
+ NSVGgradient* gradient;
+ };
+} NSVGpaint;
+
+typedef struct NSVGpath
+{
+ float* pts; // Cubic bezier points: x0,y0, [cpx1,cpx1,cpx2,cpy2,x1,y1], ...
+ int npts; // Total number of bezier points.
+ char closed; // Flag indicating if shapes should be treated as closed.
+ float bounds[4]; // Tight bounding box of the shape [minx,miny,maxx,maxy].
+ struct NSVGpath* next; // Pointer to next path, or NULL if last element.
+} NSVGpath;
+
+typedef struct NSVGshape
+{
+ char id[64]; // Optional 'id' attr of the shape or its group
+ NSVGpaint fill; // Fill paint
+ NSVGpaint stroke; // Stroke paint
+ float opacity; // Opacity of the shape.
+ float strokeWidth; // Stroke width (scaled).
+ float strokeDashOffset; // Stroke dash offset (scaled).
+ float strokeDashArray[8]; // Stroke dash array (scaled).
+ char strokeDashCount; // Number of dash values in dash array.
+ char strokeLineJoin; // Stroke join type.
+ char strokeLineCap; // Stroke cap type.
+ float miterLimit; // Miter limit
+ char fillRule; // Fill rule, see NSVGfillRule.
+ unsigned char flags; // Logical or of NSVG_FLAGS_* flags
+ float bounds[4]; // Tight bounding box of the shape [minx,miny,maxx,maxy].
+ NSVGpath* paths; // Linked list of paths in the image.
+ struct NSVGshape* next; // Pointer to next shape, or NULL if last element.
+} NSVGshape;
+
+typedef struct NSVGimage
+{
+ float width; // Width of the image.
+ float height; // Height of the image.
+ NSVGshape* shapes; // Linked list of shapes in the image.
+} NSVGimage;
+
+// Parses SVG file from a file, returns SVG image as paths.
+NANOSVG_SCOPE NSVGimage* nsvgParseFromFile(const char* filename, const char* units, float dpi);
+
+// Parses SVG file from a null terminated string, returns SVG image as paths.
+// Important note: changes the string.
+NANOSVG_SCOPE NSVGimage* nsvgParse(char* input, const char* units, float dpi);
+
+// Deletes list of paths.
+NANOSVG_SCOPE void nsvgDelete(NSVGimage* image);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // NANOSVG_H
+
+#ifdef NANOSVG_IMPLEMENTATION
+
+#include <string.h>
+#include <stdlib.h>
+#include <math.h>
+
+#define NSVG_PI (3.14159265358979323846264338327f)
+#define NSVG_KAPPA90 (0.5522847493f) // Length proportional to radius of a cubic bezier handle for 90deg arcs.
+
+#define NSVG_ALIGN_MIN 0
+#define NSVG_ALIGN_MID 1
+#define NSVG_ALIGN_MAX 2
+#define NSVG_ALIGN_NONE 0
+#define NSVG_ALIGN_MEET 1
+#define NSVG_ALIGN_SLICE 2
+
+#define NSVG_NOTUSED(v) do { (void)(1 ? (void)0 : ( (void)(v) ) ); } while(0)
+#define NSVG_RGB(r, g, b) (((unsigned int)r) | ((unsigned int)g << 8) | ((unsigned int)b << 16))
+
+#ifdef _MSC_VER
+ #pragma warning (disable: 4996) // Switch off security warnings
+ #pragma warning (disable: 4100) // Switch off unreferenced formal parameter warnings
+ #ifdef __cplusplus
+ #define NSVG_INLINE inline
+ #else
+ #define NSVG_INLINE
+ #endif
+ #if !defined(strtoll) // old MSVC versions do not have strtoll()
+ #define strtoll _strtoi64
+ #endif
+#else
+ #define NSVG_INLINE inline
+#endif
+
+
+static int nsvg__isspace(char c)
+{
+ return strchr(" \t\n\v\f\r", c) != 0;
+}
+
+static int nsvg__isdigit(char c)
+{
+ return c >= '0' && c <= '9';
+}
+
+static NSVG_INLINE float nsvg__minf(float a, float b) { return a < b ? a : b; }
+static NSVG_INLINE float nsvg__maxf(float a, float b) { return a > b ? a : b; }
+
+
+// Simple XML parser
+
+#define NSVG_XML_TAG 1
+#define NSVG_XML_CONTENT 2
+#define NSVG_XML_MAX_ATTRIBS 256
+
+static void nsvg__parseContent(char* s,
+ void (*contentCb)(void* ud, const char* s),
+ void* ud)
+{
+ // Trim start white spaces
+ while (*s && nsvg__isspace(*s)) s++;
+ if (!*s) return;
+
+ if (contentCb)
+ (*contentCb)(ud, s);
+}
+
+static void nsvg__parseElement(char* s,
+ void (*startelCb)(void* ud, const char* el, const char** attr),
+ void (*endelCb)(void* ud, const char* el),
+ void* ud)
+{
+ const char* attr[NSVG_XML_MAX_ATTRIBS];
+ int nattr = 0;
+ char* name;
+ int start = 0;
+ int end = 0;
+ char quote;
+
+ // Skip white space after the '<'
+ while (*s && nsvg__isspace(*s)) s++;
+
+ // Check if the tag is end tag
+ if (*s == '/') {
+ s++;
+ end = 1;
+ } else {
+ start = 1;
+ }
+
+ // Skip comments, data and preprocessor stuff.
+ if (!*s || *s == '?' || *s == '!')
+ return;
+
+ // Get tag name
+ name = s;
+ while (*s && !nsvg__isspace(*s)) s++;
+ if (*s) { *s++ = '\0'; }
+
+ // Get attribs
+ while (!end && *s && nattr < NSVG_XML_MAX_ATTRIBS-3) {
+ char* name = NULL;
+ char* value = NULL;
+
+ // Skip white space before the attrib name
+ while (*s && nsvg__isspace(*s)) s++;
+ if (!*s) break;
+ if (*s == '/') {
+ end = 1;
+ break;
+ }
+ name = s;
+ // Find end of the attrib name.
+ while (*s && !nsvg__isspace(*s) && *s != '=') s++;
+ if (*s) { *s++ = '\0'; }
+ // Skip until the beginning of the value.
+ while (*s && *s != '\"' && *s != '\'') s++;
+ if (!*s) break;
+ quote = *s;
+ s++;
+ // Store value and find the end of it.
+ value = s;
+ while (*s && *s != quote) s++;
+ if (*s) { *s++ = '\0'; }
+
+ // Store only well formed attributes
+ if (name && value) {
+ attr[nattr++] = name;
+ attr[nattr++] = value;
+ }
+ }
+
+ // List terminator
+ attr[nattr++] = 0;
+ attr[nattr++] = 0;
+
+ // Call callbacks.
+ if (start && startelCb)
+ (*startelCb)(ud, name, attr);
+ if (end && endelCb)
+ (*endelCb)(ud, name);
+}
+
+NANOSVG_SCOPE
+int nsvg__parseXML(char* input,
+ void (*startelCb)(void* ud, const char* el, const char** attr),
+ void (*endelCb)(void* ud, const char* el),
+ void (*contentCb)(void* ud, const char* s),
+ void* ud)
+{
+ char* s = input;
+ char* mark = s;
+ int state = NSVG_XML_CONTENT;
+ while (*s) {
+ if (*s == '<' && state == NSVG_XML_CONTENT) {
+ // Start of a tag
+ *s++ = '\0';
+ nsvg__parseContent(mark, contentCb, ud);
+ mark = s;
+ state = NSVG_XML_TAG;
+ } else if (*s == '>' && state == NSVG_XML_TAG) {
+ // Start of a content or new tag.
+ *s++ = '\0';
+ nsvg__parseContent(mark, contentCb, ud);
+ nsvg__parseElement(mark, startelCb, endelCb, ud);
+ mark = s;
+ state = NSVG_XML_CONTENT;
+ } else {
+ s++;
+ }
+ }
+
+ return 1;
+}
+
+
+/* Simple SVG parser. */
+
+#define NSVG_MAX_ATTR 128
+
+enum NSVGgradientUnits {
+ NSVG_USER_SPACE = 0,
+ NSVG_OBJECT_SPACE = 1
+};
+
+#define NSVG_MAX_DASHES 8
+
+enum NSVGunits {
+ NSVG_UNITS_USER,
+ NSVG_UNITS_PX,
+ NSVG_UNITS_PT,
+ NSVG_UNITS_PC,
+ NSVG_UNITS_MM,
+ NSVG_UNITS_CM,
+ NSVG_UNITS_IN,
+ NSVG_UNITS_PERCENT,
+ NSVG_UNITS_EM,
+ NSVG_UNITS_EX
+};
+
+enum NSVGvisible {
+ NSVG_VIS_DISPLAY = 1,
+ NSVG_VIS_VISIBLE = 2
+};
+
+typedef struct NSVGcoordinate {
+ float value;
+ int units;
+} NSVGcoordinate;
+
+typedef struct NSVGlinearData {
+ NSVGcoordinate x1, y1, x2, y2;
+} NSVGlinearData;
+
+typedef struct NSVGradialData {
+ NSVGcoordinate cx, cy, r, fx, fy;
+} NSVGradialData;
+
+typedef struct NSVGgradientData
+{
+ char id[64];
+ char ref[64];
+ char type;
+ union {
+ NSVGlinearData linear;
+ NSVGradialData radial;
+ };
+ char spread;
+ char units;
+ float xform[6];
+ int nstops;
+ NSVGgradientStop* stops;
+ struct NSVGgradientData* next;
+} NSVGgradientData;
+
+typedef struct NSVGattrib
+{
+ char id[64];
+ float xform[6];
+ unsigned int fillColor;
+ unsigned int strokeColor;
+ float opacity;
+ float fillOpacity;
+ float strokeOpacity;
+ char fillGradient[64];
+ char strokeGradient[64];
+ float strokeWidth;
+ float strokeDashOffset;
+ float strokeDashArray[NSVG_MAX_DASHES];
+ int strokeDashCount;
+ char strokeLineJoin;
+ char strokeLineCap;
+ float miterLimit;
+ char fillRule;
+ float fontSize;
+ unsigned int stopColor;
+ float stopOpacity;
+ float stopOffset;
+ char hasFill;
+ char hasStroke;
+ char visible;
+} NSVGattrib;
+
+typedef struct NSVGstyles
+{
+ char* name;
+ char* description;
+ struct NSVGstyles* next;
+} NSVGstyles;
+
+typedef struct NSVGparser
+{
+ NSVGattrib attr[NSVG_MAX_ATTR];
+ int attrHead;
+ float* pts;
+ int npts;
+ int cpts;
+ NSVGpath* plist;
+ NSVGimage* image;
+ NSVGstyles* styles;
+ NSVGgradientData* gradients;
+ NSVGshape* shapesTail;
+ float viewMinx, viewMiny, viewWidth, viewHeight;
+ int alignX, alignY, alignType;
+ float dpi;
+ char pathFlag;
+ char defsFlag;
+ char styleFlag;
+} NSVGparser;
+
+static void nsvg__xformIdentity(float* t)
+{
+ t[0] = 1.0f; t[1] = 0.0f;
+ t[2] = 0.0f; t[3] = 1.0f;
+ t[4] = 0.0f; t[5] = 0.0f;
+}
+
+static void nsvg__xformSetTranslation(float* t, float tx, float ty)
+{
+ t[0] = 1.0f; t[1] = 0.0f;
+ t[2] = 0.0f; t[3] = 1.0f;
+ t[4] = tx; t[5] = ty;
+}
+
+static void nsvg__xformSetScale(float* t, float sx, float sy)
+{
+ t[0] = sx; t[1] = 0.0f;
+ t[2] = 0.0f; t[3] = sy;
+ t[4] = 0.0f; t[5] = 0.0f;
+}
+
+static void nsvg__xformSetSkewX(float* t, float a)
+{
+ t[0] = 1.0f; t[1] = 0.0f;
+ t[2] = tanf(a); t[3] = 1.0f;
+ t[4] = 0.0f; t[5] = 0.0f;
+}
+
+static void nsvg__xformSetSkewY(float* t, float a)
+{
+ t[0] = 1.0f; t[1] = tanf(a);
+ t[2] = 0.0f; t[3] = 1.0f;
+ t[4] = 0.0f; t[5] = 0.0f;
+}
+
+static void nsvg__xformSetRotation(float* t, float a)
+{
+ float cs = cosf(a), sn = sinf(a);
+ t[0] = cs; t[1] = sn;
+ t[2] = -sn; t[3] = cs;
+ t[4] = 0.0f; t[5] = 0.0f;
+}
+
+static void nsvg__xformMultiply(float* t, float* s)
+{
+ float t0 = t[0] * s[0] + t[1] * s[2];
+ float t2 = t[2] * s[0] + t[3] * s[2];
+ float t4 = t[4] * s[0] + t[5] * s[2] + s[4];
+ t[1] = t[0] * s[1] + t[1] * s[3];
+ t[3] = t[2] * s[1] + t[3] * s[3];
+ t[5] = t[4] * s[1] + t[5] * s[3] + s[5];
+ t[0] = t0;
+ t[2] = t2;
+ t[4] = t4;
+}
+
+static void nsvg__xformInverse(float* inv, float* t)
+{
+ double invdet, det = (double)t[0] * t[3] - (double)t[2] * t[1];
+ if (det > -1e-6 && det < 1e-6) {
+ nsvg__xformIdentity(t);
+ return;
+ }
+ invdet = 1.0 / det;
+ inv[0] = (float)(t[3] * invdet);
+ inv[2] = (float)(-t[2] * invdet);
+ inv[4] = (float)(((double)t[2] * t[5] - (double)t[3] * t[4]) * invdet);
+ inv[1] = (float)(-t[1] * invdet);
+ inv[3] = (float)(t[0] * invdet);
+ inv[5] = (float)(((double)t[1] * t[4] - (double)t[0] * t[5]) * invdet);
+}
+
+static void nsvg__xformPremultiply(float* t, float* s)
+{
+ float s2[6];
+ memcpy(s2, s, sizeof(float)*6);
+ nsvg__xformMultiply(s2, t);
+ memcpy(t, s2, sizeof(float)*6);
+}
+
+static void nsvg__xformPoint(float* dx, float* dy, float x, float y, float* t)
+{
+ *dx = x*t[0] + y*t[2] + t[4];
+ *dy = x*t[1] + y*t[3] + t[5];
+}
+
+static void nsvg__xformVec(float* dx, float* dy, float x, float y, float* t)
+{
+ *dx = x*t[0] + y*t[2];
+ *dy = x*t[1] + y*t[3];
+}
+
+#define NSVG_EPSILON (1e-12)
+
+static int nsvg__ptInBounds(float* pt, float* bounds)
+{
+ return pt[0] >= bounds[0] && pt[0] <= bounds[2] && pt[1] >= bounds[1] && pt[1] <= bounds[3];
+}
+
+
+static double nsvg__evalBezier(double t, double p0, double p1, double p2, double p3)
+{
+ double it = 1.0-t;
+ return it*it*it*p0 + 3.0*it*it*t*p1 + 3.0*it*t*t*p2 + t*t*t*p3;
+}
+
+static void nsvg__curveBounds(float* bounds, float* curve)
+{
+ int i, j, count;
+ double roots[2], a, b, c, b2ac, t, v;
+ float* v0 = &curve[0];
+ float* v1 = &curve[2];
+ float* v2 = &curve[4];
+ float* v3 = &curve[6];
+
+ // Start the bounding box by end points
+ bounds[0] = nsvg__minf(v0[0], v3[0]);
+ bounds[1] = nsvg__minf(v0[1], v3[1]);
+ bounds[2] = nsvg__maxf(v0[0], v3[0]);
+ bounds[3] = nsvg__maxf(v0[1], v3[1]);
+
+ // Bezier curve fits inside the convex hull of it's control points.
+ // If control points are inside the bounds, we're done.
+ if (nsvg__ptInBounds(v1, bounds) && nsvg__ptInBounds(v2, bounds))
+ return;
+
+ // Add bezier curve inflection points in X and Y.
+ for (i = 0; i < 2; i++) {
+ a = -3.0 * v0[i] + 9.0 * v1[i] - 9.0 * v2[i] + 3.0 * v3[i];
+ b = 6.0 * v0[i] - 12.0 * v1[i] + 6.0 * v2[i];
+ c = 3.0 * v1[i] - 3.0 * v0[i];
+ count = 0;
+ if (fabs(a) < NSVG_EPSILON) {
+ if (fabs(b) > NSVG_EPSILON) {
+ t = -c / b;
+ if (t > NSVG_EPSILON && t < 1.0-NSVG_EPSILON)
+ roots[count++] = t;
+ }
+ } else {
+ b2ac = b*b - 4.0*c*a;
+ if (b2ac > NSVG_EPSILON) {
+ t = (-b + sqrt(b2ac)) / (2.0 * a);
+ if (t > NSVG_EPSILON && t < 1.0-NSVG_EPSILON)
+ roots[count++] = t;
+ t = (-b - sqrt(b2ac)) / (2.0 * a);
+ if (t > NSVG_EPSILON && t < 1.0-NSVG_EPSILON)
+ roots[count++] = t;
+ }
+ }
+ for (j = 0; j < count; j++) {
+ v = nsvg__evalBezier(roots[j], v0[i], v1[i], v2[i], v3[i]);
+ bounds[0+i] = nsvg__minf(bounds[0+i], (float)v);
+ bounds[2+i] = nsvg__maxf(bounds[2+i], (float)v);
+ }
+ }
+}
+
+static NSVGparser* nsvg__createParser(void)
+{
+ NSVGparser* p;
+ p = (NSVGparser*)NANOSVG_malloc(sizeof(NSVGparser));
+ if (p == NULL) goto error;
+ memset(p, 0, sizeof(NSVGparser));
+
+ p->image = (NSVGimage*)NANOSVG_malloc(sizeof(NSVGimage));
+ if (p->image == NULL) goto error;
+ memset(p->image, 0, sizeof(NSVGimage));
+
+ // Init style
+ nsvg__xformIdentity(p->attr[0].xform);
+ memset(p->attr[0].id, 0, sizeof p->attr[0].id);
+ p->attr[0].fillColor = NSVG_RGB(0,0,0);
+ p->attr[0].strokeColor = NSVG_RGB(0,0,0);
+ p->attr[0].opacity = 1;
+ p->attr[0].fillOpacity = 1;
+ p->attr[0].strokeOpacity = 1;
+ p->attr[0].stopOpacity = 1;
+ p->attr[0].strokeWidth = 1;
+ p->attr[0].strokeLineJoin = NSVG_JOIN_MITER;
+ p->attr[0].strokeLineCap = NSVG_CAP_BUTT;
+ p->attr[0].miterLimit = 4;
+ p->attr[0].fillRule = NSVG_FILLRULE_NONZERO;
+ p->attr[0].hasFill = 1;
+ p->attr[0].visible = NSVG_VIS_DISPLAY | NSVG_VIS_VISIBLE;
+
+ return p;
+
+error:
+ if (p) {
+ if (p->image) NANOSVG_free(p->image);
+ NANOSVG_free(p);
+ }
+ return NULL;
+}
+
+static void nsvg__deleteStyles(NSVGstyles* style) {
+ while (style) {
+ NSVGstyles *next = style->next;
+ if (style->name!= NULL)
+ NANOSVG_free(style->name);
+ if (style->description != NULL)
+ NANOSVG_free(style->description);
+ NANOSVG_free(style);
+ style = next;
+ }
+}
+
+static void nsvg__deletePaths(NSVGpath* path)
+{
+ while (path) {
+ NSVGpath *next = path->next;
+ if (path->pts != NULL)
+ NANOSVG_free(path->pts);
+ NANOSVG_free(path);
+ path = next;
+ }
+}
+
+static void nsvg__deletePaint(NSVGpaint* paint)
+{
+ if (paint->type == NSVG_PAINT_LINEAR_GRADIENT || paint->type == NSVG_PAINT_RADIAL_GRADIENT)
+ NANOSVG_free(paint->gradient);
+}
+
+static void nsvg__deleteGradientData(NSVGgradientData* grad)
+{
+ NSVGgradientData* next;
+ while (grad != NULL) {
+ next = grad->next;
+ NANOSVG_free(grad->stops);
+ NANOSVG_free(grad);
+ grad = next;
+ }
+}
+
+static void nsvg__deleteParser(NSVGparser* p)
+{
+ if (p != NULL) {
+ nsvg__deleteStyles(p->styles);
+ nsvg__deletePaths(p->plist);
+ nsvg__deleteGradientData(p->gradients);
+ nsvgDelete(p->image);
+ NANOSVG_free(p->pts);
+ NANOSVG_free(p);
+ }
+}
+
+static void nsvg__resetPath(NSVGparser* p)
+{
+ p->npts = 0;
+}
+
+static void nsvg__addPoint(NSVGparser* p, float x, float y)
+{
+ if (p->npts+1 > p->cpts) {
+ p->cpts = p->cpts ? p->cpts*2 : 8;
+ p->pts = (float*)NANOSVG_realloc(p->pts, p->cpts*2*sizeof(float));
+ if (!p->pts) return;
+ }
+ p->pts[p->npts*2+0] = x;
+ p->pts[p->npts*2+1] = y;
+ p->npts++;
+}
+
+static void nsvg__moveTo(NSVGparser* p, float x, float y)
+{
+ if (p->npts > 0) {
+ p->pts[(p->npts-1)*2+0] = x;
+ p->pts[(p->npts-1)*2+1] = y;
+ } else {
+ nsvg__addPoint(p, x, y);
+ }
+}
+
+static void nsvg__lineTo(NSVGparser* p, float x, float y)
+{
+ float px,py, dx,dy;
+ if (p->npts > 0) {
+ px = p->pts[(p->npts-1)*2+0];
+ py = p->pts[(p->npts-1)*2+1];
+ dx = x - px;
+ dy = y - py;
+ nsvg__addPoint(p, px + dx/3.0f, py + dy/3.0f);
+ nsvg__addPoint(p, x - dx/3.0f, y - dy/3.0f);
+ nsvg__addPoint(p, x, y);
+ }
+}
+
+static void nsvg__cubicBezTo(NSVGparser* p, float cpx1, float cpy1, float cpx2, float cpy2, float x, float y)
+{
+ 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, char* paintType)
+{
+ NSVGattrib* attr = nsvg__getAttr(p);
+ NSVGgradientData* data = NULL;
+ NSVGgradientData* ref = NULL;
+ NSVGgradientStop* stops = NULL;
+ NSVGgradient* grad;
+ float ox, oy, sw, sh, sl;
+ int nstops = 0;
+ 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, attr->xform);
+
+ grad->spread = data->spread;
+ memcpy(grad->stops, stops, nstops*sizeof(NSVGgradientStop));
+ grad->nstops = nstops;
+
+ *paintType = data->type;
+
+ return grad;
+}
+
+static float nsvg__getAverageScale(float* t)
+{
+ float sx = sqrtf(t[0]*t[0] + t[2]*t[2]);
+ float sy = sqrtf(t[1]*t[1] + t[3]*t[3]);
+ return (sx + sy) * 0.5f;
+}
+
+static void nsvg__getLocalBounds(float* bounds, NSVGshape *shape, float* xform)
+{
+ NSVGpath* path;
+ float curve[4*2], curveBounds[4];
+ int i, first = 1;
+ for (path = shape->paths; path != NULL; path = path->next) {
+ nsvg__xformPoint(&curve[0], &curve[1], path->pts[0], path->pts[1], xform);
+ for (i = 0; i < path->npts-1; i += 3) {
+ nsvg__xformPoint(&curve[2], &curve[3], path->pts[(i+1)*2], path->pts[(i+1)*2+1], xform);
+ nsvg__xformPoint(&curve[4], &curve[5], path->pts[(i+2)*2], path->pts[(i+2)*2+1], xform);
+ nsvg__xformPoint(&curve[6], &curve[7], path->pts[(i+3)*2], path->pts[(i+3)*2+1], xform);
+ nsvg__curveBounds(curveBounds, curve);
+ if (first) {
+ bounds[0] = curveBounds[0];
+ bounds[1] = curveBounds[1];
+ bounds[2] = curveBounds[2];
+ bounds[3] = curveBounds[3];
+ first = 0;
+ } else {
+ bounds[0] = nsvg__minf(bounds[0], curveBounds[0]);
+ bounds[1] = nsvg__minf(bounds[1], curveBounds[1]);
+ bounds[2] = nsvg__maxf(bounds[2], curveBounds[2]);
+ bounds[3] = nsvg__maxf(bounds[3], curveBounds[3]);
+ }
+ curve[0] = curve[6];
+ curve[1] = curve[7];
+ }
+ }
+}
+
+static void nsvg__addShape(NSVGparser* p)
+{
+ NSVGattrib* attr = nsvg__getAttr(p);
+ float scale = 1.0f;
+ NSVGshape* shape;
+ NSVGpath* path;
+ int i;
+
+ if (p->plist == NULL)
+ return;
+
+ shape = (NSVGshape*)NANOSVG_malloc(sizeof(NSVGshape));
+ if (shape == NULL) goto error;
+ memset(shape, 0, sizeof(NSVGshape));
+
+ memcpy(shape->id, attr->id, sizeof shape->id);
+ scale = nsvg__getAverageScale(attr->xform);
+ shape->strokeWidth = attr->strokeWidth * scale;
+ shape->strokeDashOffset = attr->strokeDashOffset * scale;
+ shape->strokeDashCount = (char)attr->strokeDashCount;
+ for (i = 0; i < attr->strokeDashCount; i++)
+ shape->strokeDashArray[i] = attr->strokeDashArray[i] * scale;
+ shape->strokeLineJoin = attr->strokeLineJoin;
+ shape->strokeLineCap = attr->strokeLineCap;
+ shape->miterLimit = attr->miterLimit;
+ shape->fillRule = attr->fillRule;
+ shape->opacity = attr->opacity;
+
+ shape->paths = p->plist;
+ p->plist = NULL;
+
+ // Calculate shape bounds
+ shape->bounds[0] = shape->paths->bounds[0];
+ shape->bounds[1] = shape->paths->bounds[1];
+ shape->bounds[2] = shape->paths->bounds[2];
+ shape->bounds[3] = shape->paths->bounds[3];
+ for (path = shape->paths->next; path != NULL; path = path->next) {
+ shape->bounds[0] = nsvg__minf(shape->bounds[0], path->bounds[0]);
+ shape->bounds[1] = nsvg__minf(shape->bounds[1], path->bounds[1]);
+ shape->bounds[2] = nsvg__maxf(shape->bounds[2], path->bounds[2]);
+ shape->bounds[3] = nsvg__maxf(shape->bounds[3], path->bounds[3]);
+ }
+
+ // Set fill
+ if (attr->hasFill == 0) {
+ shape->fill.type = NSVG_PAINT_NONE;
+ } else if (attr->hasFill == 1) {
+ shape->fill.type = NSVG_PAINT_COLOR;
+ shape->fill.color = attr->fillColor;
+ shape->fill.color |= (unsigned int)(attr->fillOpacity*255) << 24;
+ } else if (attr->hasFill == 2) {
+ float inv[6], localBounds[4];
+ nsvg__xformInverse(inv, attr->xform);
+ nsvg__getLocalBounds(localBounds, shape, inv);
+ shape->fill.gradient = nsvg__createGradient(p, attr->fillGradient, localBounds, &shape->fill.type);
+ if (shape->fill.gradient == NULL) {
+ shape->fill.type = NSVG_PAINT_NONE;
+ }
+ }
+
+ // Set stroke
+ if (attr->hasStroke == 0) {
+ shape->stroke.type = NSVG_PAINT_NONE;
+ } else if (attr->hasStroke == 1) {
+ shape->stroke.type = NSVG_PAINT_COLOR;
+ shape->stroke.color = attr->strokeColor;
+ shape->stroke.color |= (unsigned int)(attr->strokeOpacity*255) << 24;
+ } else if (attr->hasStroke == 2) {
+ float inv[6], localBounds[4];
+ nsvg__xformInverse(inv, attr->xform);
+ nsvg__getLocalBounds(localBounds, shape, inv);
+ shape->stroke.gradient = nsvg__createGradient(p, attr->strokeGradient, localBounds, &shape->stroke.type);
+ if (shape->stroke.gradient == NULL)
+ shape->stroke.type = NSVG_PAINT_NONE;
+ }
+
+ // Set flags
+ shape->flags = ((attr->visible & NSVG_VIS_DISPLAY) && (attr->visible & NSVG_VIS_VISIBLE) ? NSVG_FLAGS_VISIBLE : 0x00);
+
+ // Add to tail
+ if (p->image->shapes == NULL)
+ p->image->shapes = shape;
+ else
+ p->shapesTail->next = shape;
+ p->shapesTail = shape;
+
+ return;
+
+error:
+ if (shape) NANOSVG_free(shape);
+}
+
+static void nsvg__addPath(NSVGparser* p, char closed)
+{
+ NSVGattrib* attr = nsvg__getAttr(p);
+ NSVGpath* path = NULL;
+ float bounds[4];
+ float* curve;
+ int i;
+
+ if (p->npts < 4)
+ return;
+
+ if (closed)
+ nsvg__lineTo(p, p->pts[0], p->pts[1]);
+
+ // 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 (_MSC_VER == 1200)
+ __int64 intPart = 0, fracPart = 0;
+#else
+ long long intPart = 0, fracPart = 0;
+#endif
+ char hasIntPart = 0, hasFracPart = 0;
+
+ // Parse optional sign
+ if (*cur == '+') {
+ cur++;
+ } else if (*cur == '-') {
+ sign = -1;
+ cur++;
+ }
+
+ // Parse integer part
+ if (nsvg__isdigit(*cur)) {
+ // Parse digit sequence
+#if (_MSC_VER == 1200)
+ intPart = strtol(cur, &end, 10);
+#else
+ intPart = strtoll(cur, &end, 10);
+#endif
+ if (cur != end) {
+ res = (double)intPart;
+ hasIntPart = 1;
+ cur = end;
+ }
+ }
+
+ // Parse fractional part.
+ if (*cur == '.') {
+ cur++; // Skip '.'
+ if (nsvg__isdigit(*cur)) {
+ // Parse digit sequence
+#if (_MSC_VER == 1200)
+ fracPart = strtol(cur, &end, 10);
+#else
+ fracPart = strtoll(cur, &end, 10);
+#endif
+ if (cur != end) {
+ res += (double)fracPart / pow(10.0, (double)(end - cur));
+ hasFracPart = 1;
+ cur = end;
+ }
+ }
+ }
+
+ // A valid number should have integer or fractional part.
+ if (!hasIntPart && !hasFracPart)
+ return 0.0;
+
+ // Parse optional exponent
+ if (*cur == 'e' || *cur == 'E') {
+ int expPart = 0;
+ cur++; // skip 'E'
+ expPart = strtol(cur, &end, 10); // Parse digit sequence with sign
+ if (cur != end) {
+ res *= pow(10.0, (double)expPart);
+ }
+ }
+
+ return res * sign;
+}
+
+
+static const char* nsvg__parseNumber(const char* s, char* it, const int size)
+{
+ const int last = size-1;
+ int i = 0;
+
+ // sign
+ if (*s == '-' || *s == '+') {
+ if (i < last) it[i++] = *s;
+ s++;
+ }
+ // integer part
+ while (*s && nsvg__isdigit(*s)) {
+ if (i < last) it[i++] = *s;
+ s++;
+ }
+ if (*s == '.') {
+ // decimal point
+ if (i < last) it[i++] = *s;
+ s++;
+ // fraction part
+ while (*s && nsvg__isdigit(*s)) {
+ if (i < last) it[i++] = *s;
+ s++;
+ }
+ }
+ // exponent
+ if (*s == 'e' || *s == 'E') {
+ if (i < last) it[i++] = *s;
+ s++;
+ if (*s == '-' || *s == '+') {
+ if (i < last) it[i++] = *s;
+ s++;
+ }
+ while (*s && nsvg__isdigit(*s)) {
+ if (i < last) it[i++] = *s;
+ s++;
+ }
+ }
+ it[i] = '\0';
+
+ return s;
+}
+
+static const char* nsvg__getNextPathItem(const char* s, char* it)
+{
+ it[0] = '\0';
+ // Skip white spaces and commas
+ while (*s && (nsvg__isspace(*s) || *s == ',')) s++;
+ if (!*s) return s;
+ if (*s == '-' || *s == '+' || *s == '.' || nsvg__isdigit(*s)) {
+ s = nsvg__parseNumber(s, it, 64);
+ } else {
+ // Parse command
+ it[0] = *s++;
+ it[1] = '\0';
+ return s;
+ }
+
+ return s;
+}
+
+static unsigned int nsvg__parseColorHex(const char* str)
+{
+ unsigned int c = 0, r = 0, g = 0, b = 0;
+ int n = 0;
+ str++; // skip #
+ // Calculate number of characters.
+ while(str[n] && !nsvg__isspace(str[n]))
+ n++;
+ if (n == 6) {
+ sscanf(str, "%x", &c);
+ } else if (n == 3) {
+ sscanf(str, "%x", &c);
+ c = (c&0xf) | ((c&0xf0) << 4) | ((c&0xf00) << 8);
+ c |= c<<4;
+ }
+ r = (c >> 16) & 0xff;
+ g = (c >> 8) & 0xff;
+ b = c & 0xff;
+ return NSVG_RGB(r,g,b);
+}
+
+static unsigned int nsvg__parseColorRGB(const char* str)
+{
+ int r = -1, g = -1, b = -1;
+ char s1[32]="", s2[32]="";
+ sscanf(str + 4, "%d%[%%, \t]%d%[%%, \t]%d", &r, s1, &g, s2, &b);
+ if (strchr(s1, '%')) {
+ return NSVG_RGB((r*255)/100,(g*255)/100,(b*255)/100);
+ } else {
+ return NSVG_RGB(r,g,b);
+ }
+}
+
+typedef struct NSVGNamedColor {
+ const char* name;
+ unsigned int color;
+} NSVGNamedColor;
+
+NSVGNamedColor nsvg__colors[] = {
+
+ { "red", NSVG_RGB(255, 0, 0) },
+ { "green", NSVG_RGB( 0, 128, 0) },
+ { "blue", NSVG_RGB( 0, 0, 255) },
+ { "yellow", NSVG_RGB(255, 255, 0) },
+ { "cyan", NSVG_RGB( 0, 255, 255) },
+ { "magenta", NSVG_RGB(255, 0, 255) },
+ { "black", NSVG_RGB( 0, 0, 0) },
+ { "grey", NSVG_RGB(128, 128, 128) },
+ { "gray", NSVG_RGB(128, 128, 128) },
+ { "white", NSVG_RGB(255, 255, 255) },
+
+#ifdef NANOSVG_ALL_COLOR_KEYWORDS
+ { "aliceblue", NSVG_RGB(240, 248, 255) },
+ { "antiquewhite", NSVG_RGB(250, 235, 215) },
+ { "aqua", NSVG_RGB( 0, 255, 255) },
+ { "aquamarine", NSVG_RGB(127, 255, 212) },
+ { "azure", NSVG_RGB(240, 255, 255) },
+ { "beige", NSVG_RGB(245, 245, 220) },
+ { "bisque", NSVG_RGB(255, 228, 196) },
+ { "blanchedalmond", NSVG_RGB(255, 235, 205) },
+ { "blueviolet", NSVG_RGB(138, 43, 226) },
+ { "brown", NSVG_RGB(165, 42, 42) },
+ { "burlywood", NSVG_RGB(222, 184, 135) },
+ { "cadetblue", NSVG_RGB( 95, 158, 160) },
+ { "chartreuse", NSVG_RGB(127, 255, 0) },
+ { "chocolate", NSVG_RGB(210, 105, 30) },
+ { "coral", NSVG_RGB(255, 127, 80) },
+ { "cornflowerblue", NSVG_RGB(100, 149, 237) },
+ { "cornsilk", NSVG_RGB(255, 248, 220) },
+ { "crimson", NSVG_RGB(220, 20, 60) },
+ { "darkblue", NSVG_RGB( 0, 0, 139) },
+ { "darkcyan", NSVG_RGB( 0, 139, 139) },
+ { "darkgoldenrod", NSVG_RGB(184, 134, 11) },
+ { "darkgray", NSVG_RGB(169, 169, 169) },
+ { "darkgreen", NSVG_RGB( 0, 100, 0) },
+ { "darkgrey", NSVG_RGB(169, 169, 169) },
+ { "darkkhaki", NSVG_RGB(189, 183, 107) },
+ { "darkmagenta", NSVG_RGB(139, 0, 139) },
+ { "darkolivegreen", NSVG_RGB( 85, 107, 47) },
+ { "darkorange", NSVG_RGB(255, 140, 0) },
+ { "darkorchid", NSVG_RGB(153, 50, 204) },
+ { "darkred", NSVG_RGB(139, 0, 0) },
+ { "darksalmon", NSVG_RGB(233, 150, 122) },
+ { "darkseagreen", NSVG_RGB(143, 188, 143) },
+ { "darkslateblue", NSVG_RGB( 72, 61, 139) },
+ { "darkslategray", NSVG_RGB( 47, 79, 79) },
+ { "darkslategrey", NSVG_RGB( 47, 79, 79) },
+ { "darkturquoise", NSVG_RGB( 0, 206, 209) },
+ { "darkviolet", NSVG_RGB(148, 0, 211) },
+ { "deeppink", NSVG_RGB(255, 20, 147) },
+ { "deepskyblue", NSVG_RGB( 0, 191, 255) },
+ { "dimgray", NSVG_RGB(105, 105, 105) },
+ { "dimgrey", NSVG_RGB(105, 105, 105) },
+ { "dodgerblue", NSVG_RGB( 30, 144, 255) },
+ { "firebrick", NSVG_RGB(178, 34, 34) },
+ { "floralwhite", NSVG_RGB(255, 250, 240) },
+ { "forestgreen", NSVG_RGB( 34, 139, 34) },
+ { "fuchsia", NSVG_RGB(255, 0, 255) },
+ { "gainsboro", NSVG_RGB(220, 220, 220) },
+ { "ghostwhite", NSVG_RGB(248, 248, 255) },
+ { "gold", NSVG_RGB(255, 215, 0) },
+ { "goldenrod", NSVG_RGB(218, 165, 32) },
+ { "greenyellow", NSVG_RGB(173, 255, 47) },
+ { "honeydew", NSVG_RGB(240, 255, 240) },
+ { "hotpink", NSVG_RGB(255, 105, 180) },
+ { "indianred", NSVG_RGB(205, 92, 92) },
+ { "indigo", NSVG_RGB( 75, 0, 130) },
+ { "ivory", NSVG_RGB(255, 255, 240) },
+ { "khaki", NSVG_RGB(240, 230, 140) },
+ { "lavender", NSVG_RGB(230, 230, 250) },
+ { "lavenderblush", NSVG_RGB(255, 240, 245) },
+ { "lawngreen", NSVG_RGB(124, 252, 0) },
+ { "lemonchiffon", NSVG_RGB(255, 250, 205) },
+ { "lightblue", NSVG_RGB(173, 216, 230) },
+ { "lightcoral", NSVG_RGB(240, 128, 128) },
+ { "lightcyan", NSVG_RGB(224, 255, 255) },
+ { "lightgoldenrodyellow", NSVG_RGB(250, 250, 210) },
+ { "lightgray", NSVG_RGB(211, 211, 211) },
+ { "lightgreen", NSVG_RGB(144, 238, 144) },
+ { "lightgrey", NSVG_RGB(211, 211, 211) },
+ { "lightpink", NSVG_RGB(255, 182, 193) },
+ { "lightsalmon", NSVG_RGB(255, 160, 122) },
+ { "lightseagreen", NSVG_RGB( 32, 178, 170) },
+ { "lightskyblue", NSVG_RGB(135, 206, 250) },
+ { "lightslategray", NSVG_RGB(119, 136, 153) },
+ { "lightslategrey", NSVG_RGB(119, 136, 153) },
+ { "lightsteelblue", NSVG_RGB(176, 196, 222) },
+ { "lightyellow", NSVG_RGB(255, 255, 224) },
+ { "lime", NSVG_RGB( 0, 255, 0) },
+ { "limegreen", NSVG_RGB( 50, 205, 50) },
+ { "linen", NSVG_RGB(250, 240, 230) },
+ { "maroon", NSVG_RGB(128, 0, 0) },
+ { "mediumaquamarine", NSVG_RGB(102, 205, 170) },
+ { "mediumblue", NSVG_RGB( 0, 0, 205) },
+ { "mediumorchid", NSVG_RGB(186, 85, 211) },
+ { "mediumpurple", NSVG_RGB(147, 112, 219) },
+ { "mediumseagreen", NSVG_RGB( 60, 179, 113) },
+ { "mediumslateblue", NSVG_RGB(123, 104, 238) },
+ { "mediumspringgreen", NSVG_RGB( 0, 250, 154) },
+ { "mediumturquoise", NSVG_RGB( 72, 209, 204) },
+ { "mediumvioletred", NSVG_RGB(199, 21, 133) },
+ { "midnightblue", NSVG_RGB( 25, 25, 112) },
+ { "mintcream", NSVG_RGB(245, 255, 250) },
+ { "mistyrose", NSVG_RGB(255, 228, 225) },
+ { "moccasin", NSVG_RGB(255, 228, 181) },
+ { "navajowhite", NSVG_RGB(255, 222, 173) },
+ { "navy", NSVG_RGB( 0, 0, 128) },
+ { "oldlace", NSVG_RGB(253, 245, 230) },
+ { "olive", NSVG_RGB(128, 128, 0) },
+ { "olivedrab", NSVG_RGB(107, 142, 35) },
+ { "orange", NSVG_RGB(255, 165, 0) },
+ { "orangered", NSVG_RGB(255, 69, 0) },
+ { "orchid", NSVG_RGB(218, 112, 214) },
+ { "palegoldenrod", NSVG_RGB(238, 232, 170) },
+ { "palegreen", NSVG_RGB(152, 251, 152) },
+ { "paleturquoise", NSVG_RGB(175, 238, 238) },
+ { "palevioletred", NSVG_RGB(219, 112, 147) },
+ { "papayawhip", NSVG_RGB(255, 239, 213) },
+ { "peachpuff", NSVG_RGB(255, 218, 185) },
+ { "peru", NSVG_RGB(205, 133, 63) },
+ { "pink", NSVG_RGB(255, 192, 203) },
+ { "plum", NSVG_RGB(221, 160, 221) },
+ { "powderblue", NSVG_RGB(176, 224, 230) },
+ { "purple", NSVG_RGB(128, 0, 128) },
+ { "rosybrown", NSVG_RGB(188, 143, 143) },
+ { "royalblue", NSVG_RGB( 65, 105, 225) },
+ { "saddlebrown", NSVG_RGB(139, 69, 19) },
+ { "salmon", NSVG_RGB(250, 128, 114) },
+ { "sandybrown", NSVG_RGB(244, 164, 96) },
+ { "seagreen", NSVG_RGB( 46, 139, 87) },
+ { "seashell", NSVG_RGB(255, 245, 238) },
+ { "sienna", NSVG_RGB(160, 82, 45) },
+ { "silver", NSVG_RGB(192, 192, 192) },
+ { "skyblue", NSVG_RGB(135, 206, 235) },
+ { "slateblue", NSVG_RGB(106, 90, 205) },
+ { "slategray", NSVG_RGB(112, 128, 144) },
+ { "slategrey", NSVG_RGB(112, 128, 144) },
+ { "snow", NSVG_RGB(255, 250, 250) },
+ { "springgreen", NSVG_RGB( 0, 255, 127) },
+ { "steelblue", NSVG_RGB( 70, 130, 180) },
+ { "tan", NSVG_RGB(210, 180, 140) },
+ { "teal", NSVG_RGB( 0, 128, 128) },
+ { "thistle", NSVG_RGB(216, 191, 216) },
+ { "tomato", NSVG_RGB(255, 99, 71) },
+ { "turquoise", NSVG_RGB( 64, 224, 208) },
+ { "violet", NSVG_RGB(238, 130, 238) },
+ { "wheat", NSVG_RGB(245, 222, 179) },
+ { "whitesmoke", NSVG_RGB(245, 245, 245) },
+ { "yellowgreen", NSVG_RGB(154, 205, 50) },
+#endif
+};
+
+static unsigned int nsvg__parseColorName(const char* str)
+{
+ int i, ncolors = sizeof(nsvg__colors) / sizeof(NSVGNamedColor);
+
+ for (i = 0; i < ncolors; i++) {
+ if (strcmp(nsvg__colors[i].name, str) == 0) {
+ return nsvg__colors[i].color;
+ }
+ }
+
+ return NSVG_RGB(128, 128, 128);
+}
+
+static unsigned int nsvg__parseColor(const char* str)
+{
+ size_t len = 0;
+ while(*str == ' ') ++str;
+ len = strlen(str);
+ if (len >= 1 && *str == '#')
+ return nsvg__parseColorHex(str);
+ else if (len >= 4 && str[0] == 'r' && str[1] == 'g' && str[2] == 'b' && str[3] == '(')
+ return nsvg__parseColorRGB(str);
+ return nsvg__parseColorName(str);
+}
+
+static float nsvg__parseOpacity(const char* str)
+{
+ float val = 0;
+ sscanf(str, "%f", &val);
+ if (val < 0.0f) val = 0.0f;
+ if (val > 1.0f) val = 1.0f;
+ return val;
+}
+
+static float nsvg__parseMiterLimit(const char* str)
+{
+ float val = 0;
+ sscanf(str, "%f", &val);
+ if (val < 0.0f) val = 0.0f;
+ return val;
+}
+
+static int nsvg__parseUnits(const char* units)
+{
+ if (units[0] == 'p' && units[1] == 'x')
+ return NSVG_UNITS_PX;
+ else if (units[0] == 'p' && units[1] == 't')
+ return NSVG_UNITS_PT;
+ else if (units[0] == 'p' && units[1] == 'c')
+ return NSVG_UNITS_PC;
+ else if (units[0] == 'm' && units[1] == 'm')
+ return NSVG_UNITS_MM;
+ else if (units[0] == 'c' && units[1] == 'm')
+ return NSVG_UNITS_CM;
+ else if (units[0] == 'i' && units[1] == 'n')
+ return NSVG_UNITS_IN;
+ else if (units[0] == '%')
+ return NSVG_UNITS_PERCENT;
+ else if (units[0] == 'e' && units[1] == 'm')
+ return NSVG_UNITS_EM;
+ else if (units[0] == 'e' && units[1] == 'x')
+ return NSVG_UNITS_EX;
+ return NSVG_UNITS_USER;
+}
+
+static int nsvg__isCoordinate(const char* s)
+{
+ // optional sign
+ if (*s == '-' || *s == '+')
+ s++;
+ // must have at least one digit
+ return nsvg__isdigit(*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++;
+ while (i < 63 && *str != ')') {
+ id[i] = *str++;
+ i++;
+ }
+ id[i] = '\0';
+}
+
+static char nsvg__parseLineCap(const char* str)
+{
+ if (strcmp(str, "butt") == 0)
+ return NSVG_CAP_BUTT;
+ else if (strcmp(str, "round") == 0)
+ return NSVG_CAP_ROUND;
+ else if (strcmp(str, "square") == 0)
+ return NSVG_CAP_SQUARE;
+ // TODO: handle inherit.
+ return NSVG_CAP_BUTT;
+}
+
+static char nsvg__parseLineJoin(const char* str)
+{
+ if (strcmp(str, "miter") == 0)
+ return NSVG_JOIN_MITER;
+ else if (strcmp(str, "round") == 0)
+ return NSVG_JOIN_ROUND;
+ else if (strcmp(str, "bevel") == 0)
+ return NSVG_JOIN_BEVEL;
+ // TODO: handle inherit.
+ return NSVG_JOIN_MITER;
+}
+
+static char nsvg__parseFillRule(const char* str)
+{
+ if (strcmp(str, "nonzero") == 0)
+ return NSVG_FILLRULE_NONZERO;
+ else if (strcmp(str, "evenodd") == 0)
+ return NSVG_FILLRULE_EVENODD;
+ // TODO: handle inherit.
+ return NSVG_FILLRULE_NONZERO;
+}
+
+static const char* nsvg__getNextDashItem(const char* s, char* it)
+{
+ int n = 0;
+ it[0] = '\0';
+ // Skip white spaces and commas
+ while (*s && (nsvg__isspace(*s) || *s == ',')) s++;
+ // Advance until whitespace, comma or end.
+ while (*s && (!nsvg__isspace(*s) && *s != ',')) {
+ if (n < 63)
+ it[n++] = *s;
+ s++;
+ }
+ it[n++] = '\0';
+ return s;
+}
+
+static int nsvg__parseStrokeDashArray(NSVGparser* p, const char* str, float* strokeDashArray)
+{
+ char item[64];
+ int count = 0, i;
+ float sum = 0.0f;
+
+ // Handle "none"
+ if (str[0] == 'n')
+ return 0;
+
+ // Parse dashes
+ while (*str) {
+ str = nsvg__getNextDashItem(str, item);
+ if (!*item) break;
+ if (count < NSVG_MAX_DASHES)
+ strokeDashArray[count++] = fabsf(nsvg__parseCoordinate(p, item, 0.0f, nsvg__actualLength(p)));
+ }
+
+ for (i = 0; i < count; i++)
+ sum += strokeDashArray[i];
+ if (sum <= 1e-6f)
+ count = 0;
+
+ return count;
+}
+
+static void nsvg__parseStyle(NSVGparser* p, const char* str);
+
+static int nsvg__parseAttr(NSVGparser* p, const char* name, const char* value)
+{
+ float xform[6];
+ NSVGattrib* attr = nsvg__getAttr(p);
+ if (!attr) return 0;
+
+ if (strcmp(name, "style") == 0) {
+ nsvg__parseStyle(p, value);
+ } else if (strcmp(name, "display") == 0) {
+ if (strcmp(value, "none") == 0)
+ attr->visible &= ~NSVG_VIS_DISPLAY;
+ // Don't reset ->visible on display:inline, one display:none hides the whole subtree
+
+ } else if (strcmp(name, "visibility") == 0) {
+ if (strcmp(value, "hidden") == 0) {
+ attr->visible &= ~NSVG_VIS_VISIBLE;
+ } else if (strcmp(value, "visible") == 0) {
+ attr->visible |= NSVG_VIS_VISIBLE;
+ }
+ } else if (strcmp(name, "fill") == 0) {
+ if (strcmp(value, "none") == 0) {
+ attr->hasFill = 0;
+ } else if (strncmp(value, "url(", 4) == 0) {
+ attr->hasFill = 2;
+ nsvg__parseUrl(attr->fillGradient, value);
+ } else {
+ attr->hasFill = 1;
+ attr->fillColor = nsvg__parseColor(value);
+ }
+ } else if (strcmp(name, "opacity") == 0) {
+ attr->opacity = nsvg__parseOpacity(value);
+ } else if (strcmp(name, "fill-opacity") == 0) {
+ attr->fillOpacity = nsvg__parseOpacity(value);
+ } else if (strcmp(name, "stroke") == 0) {
+ if (strcmp(value, "none") == 0) {
+ attr->hasStroke = 0;
+ } else if (strncmp(value, "url(", 4) == 0) {
+ attr->hasStroke = 2;
+ nsvg__parseUrl(attr->strokeGradient, value);
+ } else {
+ attr->hasStroke = 1;
+ attr->strokeColor = nsvg__parseColor(value);
+ }
+ } else if (strcmp(name, "stroke-width") == 0) {
+ attr->strokeWidth = nsvg__parseCoordinate(p, value, 0.0f, nsvg__actualLength(p));
+ } else if (strcmp(name, "stroke-dasharray") == 0) {
+ attr->strokeDashCount = nsvg__parseStrokeDashArray(p, value, attr->strokeDashArray);
+ } else if (strcmp(name, "stroke-dashoffset") == 0) {
+ attr->strokeDashOffset = nsvg__parseCoordinate(p, value, 0.0f, nsvg__actualLength(p));
+ } else if (strcmp(name, "stroke-opacity") == 0) {
+ attr->strokeOpacity = nsvg__parseOpacity(value);
+ } else if (strcmp(name, "stroke-linecap") == 0) {
+ attr->strokeLineCap = nsvg__parseLineCap(value);
+ } else if (strcmp(name, "stroke-linejoin") == 0) {
+ attr->strokeLineJoin = nsvg__parseLineJoin(value);
+ } else if (strcmp(name, "stroke-miterlimit") == 0) {
+ attr->miterLimit = nsvg__parseMiterLimit(value);
+ } else if (strcmp(name, "fill-rule") == 0) {
+ attr->fillRule = nsvg__parseFillRule(value);
+ } else if (strcmp(name, "font-size") == 0) {
+ attr->fontSize = nsvg__parseCoordinate(p, value, 0.0f, nsvg__actualLength(p));
+ } else if (strcmp(name, "transform") == 0) {
+ nsvg__parseTransform(xform, value);
+ nsvg__xformPremultiply(attr->xform, xform);
+ } else if (strcmp(name, "stop-color") == 0) {
+ attr->stopColor = nsvg__parseColor(value);
+ } else if (strcmp(name, "stop-opacity") == 0) {
+ attr->stopOpacity = nsvg__parseOpacity(value);
+ } else if (strcmp(name, "offset") == 0) {
+ attr->stopOffset = nsvg__parseCoordinate(p, value, 0.0f, 1.0f);
+ } else if (strcmp(name, "id") == 0) {
+ strncpy(attr->id, value, 63);
+ attr->id[63] = '\0';
+ } else if (strcmp(name, "class") == 0) {
+ NSVGstyles* style = p->styles;
+ while (style) {
+ if (strcmp(style->name + 1, value) == 0) {
+ break;
+ }
+ style = style->next;
+ }
+ if (style) {
+ nsvg__parseStyle(p, style->description);
+ }
+ } else {
+ return 0;
+ }
+ return 1;
+}
+
+static int nsvg__parseNameValue(NSVGparser* p, const char* start, const char* end)
+{
+ const char* str;
+ const char* val;
+ char name[512];
+ char value[512];
+ int n;
+
+ str = start;
+ while (str < end && *str != ':') ++str;
+
+ val = str;
+
+ // Right Trim
+ while (str > start && (*str == ':' || nsvg__isspace(*str))) --str;
+ ++str;
+
+ n = (int)(str - start);
+ if (n > 511) n = 511;
+ if (n) memcpy(name, start, n);
+ name[n] = 0;
+
+ while (val < end && (*val == ':' || nsvg__isspace(*val))) ++val;
+
+ n = (int)(end - val);
+ if (n > 511) n = 511;
+ if (n) memcpy(value, val, n);
+ value[n] = 0;
+
+ return nsvg__parseAttr(p, name, value);
+}
+
+static void nsvg__parseStyle(NSVGparser* p, const char* str)
+{
+ const char* start;
+ const char* end;
+
+ while (*str) {
+ // Left Trim
+ while(*str && nsvg__isspace(*str)) ++str;
+ start = str;
+ while(*str && *str != ';') ++str;
+ end = str;
+
+ // Right Trim
+ while (end > start && (*end == ';' || nsvg__isspace(*end))) --end;
+ ++end;
+
+ nsvg__parseNameValue(p, start, end);
+ if (*str) ++str;
+ }
+}
+
+static void nsvg__parseAttribs(NSVGparser* p, const char** attr)
+{
+ int i;
+ for (i = 0; attr[i]; i += 2)
+ {
+ if (strcmp(attr[i], "style") == 0)
+ nsvg__parseStyle(p, attr[i + 1]);
+ else
+ nsvg__parseAttr(p, attr[i], attr[i + 1]);
+ }
+}
+
+static int nsvg__getArgsPerElement(char cmd)
+{
+ switch (cmd) {
+ case 'v':
+ case 'V':
+ case 'h':
+ case 'H':
+ return 1;
+ case 'm':
+ case 'M':
+ case 'l':
+ case 'L':
+ case 't':
+ case 'T':
+ return 2;
+ case 'q':
+ case 'Q':
+ case 's':
+ case 'S':
+ return 4;
+ case 'c':
+ case 'C':
+ return 6;
+ case 'a':
+ case 'A':
+ return 7;
+ 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;
+ kappa = fabsf(4.0f / 3.0f * (1.0f - cosf(hda)) / sinf(hda));
+ if (da < 0.0f)
+ kappa = -kappa;
+
+ for (i = 0; i <= ndivs; i++) {
+ a = a1 + da * ((float)i/(float)ndivs);
+ dx = cosf(a);
+ dy = sinf(a);
+ nsvg__xformPoint(&x, &y, dx*rx, dy*ry, t); // position
+ nsvg__xformVec(&tanx, &tany, -dy*rx * kappa, dx*ry * kappa, t); // tangent
+ if (i > 0)
+ nsvg__cubicBezTo(p, px+ptanx,py+ptany, x-tanx, y-tany, x, y);
+ px = x;
+ py = y;
+ ptanx = tanx;
+ ptany = tany;
+ }
+
+ *cpx = x2;
+ *cpy = y2;
+}
+
+static void nsvg__parsePath(NSVGparser* p, const char** attr)
+{
+ const char* s = NULL;
+ char cmd = '\0';
+ float args[10];
+ int nargs;
+ int rargs = 0;
+ 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) {
+ 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, char type)
+{
+ int i;
+ NSVGgradientData* grad = (NSVGgradientData*)NANOSVG_malloc(sizeof(NSVGgradientData));
+ if (grad == NULL) return;
+ memset(grad, 0, sizeof(NSVGgradientData));
+ grad->units = NSVG_OBJECT_SPACE;
+ grad->type = type;
+ if (grad->type == NSVG_PAINT_LINEAR_GRADIENT) {
+ grad->linear.x1 = nsvg__coord(0.0f, NSVG_UNITS_PERCENT);
+ grad->linear.y1 = nsvg__coord(0.0f, NSVG_UNITS_PERCENT);
+ grad->linear.x2 = nsvg__coord(100.0f, NSVG_UNITS_PERCENT);
+ grad->linear.y2 = nsvg__coord(0.0f, NSVG_UNITS_PERCENT);
+ } else if (grad->type == NSVG_PAINT_RADIAL_GRADIENT) {
+ grad->radial.cx = nsvg__coord(50.0f, NSVG_UNITS_PERCENT);
+ grad->radial.cy = nsvg__coord(50.0f, NSVG_UNITS_PERCENT);
+ grad->radial.r = nsvg__coord(50.0f, NSVG_UNITS_PERCENT);
+ }
+
+ nsvg__xformIdentity(grad->xform);
+
+ for (i = 0; attr[i]; i += 2) {
+ if (strcmp(attr[i], "id") == 0) {
+ strncpy(grad->id, attr[i+1], 63);
+ grad->id[63] = '\0';
+ } else if (!nsvg__parseAttr(p, attr[i], attr[i + 1])) {
+ if (strcmp(attr[i], "gradientUnits") == 0) {
+ if (strcmp(attr[i+1], "objectBoundingBox") == 0)
+ grad->units = NSVG_OBJECT_SPACE;
+ else
+ grad->units = NSVG_USER_SPACE;
+ } else if (strcmp(attr[i], "gradientTransform") == 0) {
+ nsvg__parseTransform(grad->xform, attr[i + 1]);
+ } else if (strcmp(attr[i], "cx") == 0) {
+ grad->radial.cx = nsvg__parseCoordinateRaw(attr[i + 1]);
+ } else if (strcmp(attr[i], "cy") == 0) {
+ grad->radial.cy = nsvg__parseCoordinateRaw(attr[i + 1]);
+ } else if (strcmp(attr[i], "r") == 0) {
+ grad->radial.r = nsvg__parseCoordinateRaw(attr[i + 1]);
+ } else if (strcmp(attr[i], "fx") == 0) {
+ grad->radial.fx = nsvg__parseCoordinateRaw(attr[i + 1]);
+ } else if (strcmp(attr[i], "fy") == 0) {
+ grad->radial.fy = nsvg__parseCoordinateRaw(attr[i + 1]);
+ } else if (strcmp(attr[i], "x1") == 0) {
+ grad->linear.x1 = nsvg__parseCoordinateRaw(attr[i + 1]);
+ } else if (strcmp(attr[i], "y1") == 0) {
+ grad->linear.y1 = nsvg__parseCoordinateRaw(attr[i + 1]);
+ } else if (strcmp(attr[i], "x2") == 0) {
+ grad->linear.x2 = nsvg__parseCoordinateRaw(attr[i + 1]);
+ } else if (strcmp(attr[i], "y2") == 0) {
+ grad->linear.y2 = nsvg__parseCoordinateRaw(attr[i + 1]);
+ } else if (strcmp(attr[i], "spreadMethod") == 0) {
+ if (strcmp(attr[i+1], "pad") == 0)
+ grad->spread = NSVG_SPREAD_PAD;
+ else if (strcmp(attr[i+1], "reflect") == 0)
+ grad->spread = NSVG_SPREAD_REFLECT;
+ else if (strcmp(attr[i+1], "repeat") == 0)
+ grad->spread = NSVG_SPREAD_REPEAT;
+ } else if (strcmp(attr[i], "xlink:href") == 0) {
+ const char *href = attr[i+1];
+ strncpy(grad->ref, href+1, 62);
+ grad->ref[62] = '\0';
+ }
+ }
+ }
+
+ grad->next = p->gradients;
+ p->gradients = grad;
+}
+
+static void nsvg__parseGradientStop(NSVGparser* p, const char** attr)
+{
+ NSVGattrib* curAttr = nsvg__getAttr(p);
+ NSVGgradientData* grad;
+ NSVGgradientStop* stop;
+ int i, idx;
+
+ curAttr->stopOffset = 0;
+ curAttr->stopColor = 0;
+ curAttr->stopOpacity = 1.0f;
+
+ for (i = 0; attr[i]; i += 2) {
+ nsvg__parseAttr(p, attr[i], attr[i + 1]);
+ }
+
+ // Add stop to the last gradient.
+ grad = p->gradients;
+ if (grad == NULL) return;
+
+ grad->nstops++;
+ grad->stops = (NSVGgradientStop*)NANOSVG_realloc(grad->stops, sizeof(NSVGgradientStop)*grad->nstops);
+ if (grad->stops == NULL) return;
+
+ // Insert
+ idx = grad->nstops-1;
+ for (i = 0; i < grad->nstops-1; i++) {
+ if (curAttr->stopOffset < grad->stops[i].offset) {
+ idx = i;
+ break;
+ }
+ }
+ if (idx != grad->nstops-1) {
+ for (i = grad->nstops-1; i > idx; i--)
+ grad->stops[i] = grad->stops[i-1];
+ }
+
+ stop = &grad->stops[idx];
+ stop->color = curAttr->stopColor;
+ stop->color |= (unsigned int)(curAttr->stopOpacity*255) << 24;
+ stop->offset = curAttr->stopOffset;
+}
+
+static void nsvg__startElement(void* ud, const char* el, const char** attr)
+{
+ NSVGparser* p = (NSVGparser*)ud;
+
+ if (p->defsFlag) {
+ // Skip everything but gradients in defs
+ if (strcmp(el, "linearGradient") == 0) {
+ nsvg__parseGradient(p, attr, NSVG_PAINT_LINEAR_GRADIENT);
+ } else if (strcmp(el, "radialGradient") == 0) {
+ nsvg__parseGradient(p, attr, NSVG_PAINT_RADIAL_GRADIENT);
+ } else if (strcmp(el, "stop") == 0) {
+ nsvg__parseGradientStop(p, attr);
+ }
+ return;
+ }
+
+ if (strcmp(el, "g") == 0) {
+ nsvg__pushAttr(p);
+ nsvg__parseAttribs(p, attr);
+ } else if (strcmp(el, "path") == 0) {
+ if (p->pathFlag) // Do not allow nested paths.
+ return;
+ nsvg__pushAttr(p);
+ nsvg__parsePath(p, attr);
+ nsvg__popAttr(p);
+ } else if (strcmp(el, "rect") == 0) {
+ nsvg__pushAttr(p);
+ nsvg__parseRect(p, attr);
+ nsvg__popAttr(p);
+ } else if (strcmp(el, "circle") == 0) {
+ nsvg__pushAttr(p);
+ nsvg__parseCircle(p, attr);
+ nsvg__popAttr(p);
+ } else if (strcmp(el, "ellipse") == 0) {
+ nsvg__pushAttr(p);
+ nsvg__parseEllipse(p, attr);
+ nsvg__popAttr(p);
+ } else if (strcmp(el, "line") == 0) {
+ nsvg__pushAttr(p);
+ nsvg__parseLine(p, attr);
+ nsvg__popAttr(p);
+ } else if (strcmp(el, "polyline") == 0) {
+ nsvg__pushAttr(p);
+ nsvg__parsePoly(p, attr, 0);
+ nsvg__popAttr(p);
+ } else if (strcmp(el, "polygon") == 0) {
+ nsvg__pushAttr(p);
+ nsvg__parsePoly(p, attr, 1);
+ nsvg__popAttr(p);
+ } else if (strcmp(el, "linearGradient") == 0) {
+ nsvg__parseGradient(p, attr, NSVG_PAINT_LINEAR_GRADIENT);
+ } else if (strcmp(el, "radialGradient") == 0) {
+ nsvg__parseGradient(p, attr, NSVG_PAINT_RADIAL_GRADIENT);
+ } else if (strcmp(el, "stop") == 0) {
+ nsvg__parseGradientStop(p, attr);
+ } else if (strcmp(el, "defs") == 0) {
+ p->defsFlag = 1;
+ } else if (strcmp(el, "svg") == 0) {
+ nsvg__parseSVG(p, attr);
+ } else if (strcmp(el, "style") == 0) {
+ p->styleFlag = 1;
+ }
+}
+
+static void nsvg__endElement(void* ud, const char* el)
+{
+ NSVGparser* p = (NSVGparser*)ud;
+
+ if (strcmp(el, "g") == 0) {
+ nsvg__popAttr(p);
+ } else if (strcmp(el, "path") == 0) {
+ p->pathFlag = 0;
+ } else if (strcmp(el, "defs") == 0) {
+ p->defsFlag = 0;
+ } else if (strcmp(el, "style") == 0) {
+ p->styleFlag = 0;
+ }
+}
+
+static char *nsvg__strndup(const char *s, size_t n)
+{
+ char *result;
+ size_t len = strlen(s);
+
+ if (n < len)
+ len = n;
+
+ result = (char*)NANOSVG_malloc(len+1);
+ if (!result)
+ return 0;
+
+ result[len] = '\0';
+ return (char *)memcpy(result, s, len);
+}
+
+static void nsvg__content(void* ud, const char* s)
+{
+ NSVGparser* p = (NSVGparser*)ud;
+ if (p->styleFlag) {
+
+ int state = 0;
+ const char* start = NULL;
+ while (*s) {
+ char c = *s;
+ if (nsvg__isspace(c) || c == '{') {
+ if (state == 1) {
+ NSVGstyles* next = p->styles;
+
+ p->styles = (NSVGstyles*)NANOSVG_malloc(sizeof(NSVGstyles));
+ p->styles->next = next;
+ p->styles->name = nsvg__strndup(start, (size_t)(s - start));
+ start = s + 1;
+ state = 2;
+ }
+ } else if (state == 2 && c == '}') {
+ p->styles->description = nsvg__strndup(start, (size_t)(s - start));
+ state = 0;
+ }
+ else if (state == 0) {
+ start = s;
+ state = 1;
+ }
+ s++;
+ /*
+ if (*s == '{' && state == NSVG_XML_CONTENT) {
+ // Start of a tag
+ *s++ = '\0';
+ nsvg__parseContent(mark, contentCb, ud);
+ mark = s;
+ state = NSVG_XML_TAG;
+ }
+ else if (*s == '>' && state == NSVG_XML_TAG) {
+ // Start of a content or new tag.
+ *s++ = '\0';
+ nsvg__parseElement(mark, startelCb, endelCb, ud);
+ mark = s;
+ state = NSVG_XML_CONTENT;
+ }
+ else {
+ s++;
+ }
+ */
+ }
+
+ }
+}
+
+static void nsvg__imageBounds(NSVGparser* p, float* bounds)
+{
+ NSVGshape* shape;
+ shape = p->image->shapes;
+ if (shape == NULL) {
+ bounds[0] = bounds[1] = bounds[2] = bounds[3] = 0.0;
+ return;
+ }
+ bounds[0] = shape->bounds[0];
+ bounds[1] = shape->bounds[1];
+ bounds[2] = shape->bounds[2];
+ bounds[3] = shape->bounds[3];
+ for (shape = shape->next; shape != NULL; shape = shape->next) {
+ bounds[0] = nsvg__minf(bounds[0], shape->bounds[0]);
+ bounds[1] = nsvg__minf(bounds[1], shape->bounds[1]);
+ bounds[2] = nsvg__maxf(bounds[2], shape->bounds[2]);
+ bounds[3] = nsvg__maxf(bounds[3], shape->bounds[3]);
+ }
+}
+
+static float nsvg__viewAlign(float content, float container, int type)
+{
+ if (type == NSVG_ALIGN_MIN)
+ return 0;
+ else if (type == NSVG_ALIGN_MAX)
+ return container - content;
+ // mid
+ return (container - content) * 0.5f;
+}
+
+static void nsvg__scaleGradient(NSVGgradient* grad, float tx, float ty, float sx, float sy)
+{
+ float t[6];
+ nsvg__xformSetTranslation(t, tx, ty);
+ nsvg__xformMultiply (grad->xform, t);
+
+ nsvg__xformSetScale(t, sx, sy);
+ nsvg__xformMultiply (grad->xform, t);
+}
+
+static void nsvg__scaleToViewbox(NSVGparser* p, const char* units)
+{
+ NSVGshape* shape;
+ NSVGpath* path;
+ float tx, ty, sx, sy, us, bounds[4], t[6], avgs;
+ int i;
+ float* pt;
+
+ // Guess image size if not set completely.
+ nsvg__imageBounds(p, bounds);
+
+ if (p->viewWidth == 0) {
+ if (p->image->width > 0) {
+ p->viewWidth = p->image->width;
+ } else {
+ p->viewMinx = bounds[0];
+ p->viewWidth = bounds[2] - bounds[0];
+ }
+ }
+ if (p->viewHeight == 0) {
+ if (p->image->height > 0) {
+ p->viewHeight = p->image->height;
+ } else {
+ p->viewMiny = bounds[1];
+ p->viewHeight = bounds[3] - bounds[1];
+ }
+ }
+ if (p->image->width == 0)
+ p->image->width = p->viewWidth;
+ if (p->image->height == 0)
+ p->image->height = p->viewHeight;
+
+ tx = -p->viewMinx;
+ ty = -p->viewMiny;
+ sx = p->viewWidth > 0 ? p->image->width / p->viewWidth : 0;
+ sy = p->viewHeight > 0 ? p->image->height / p->viewHeight : 0;
+ // Unit scaling
+ us = 1.0f / nsvg__convertToPixels(p, nsvg__coord(1.0f, nsvg__parseUnits(units)), 0.0f, 1.0f);
+
+ // Fix aspect ratio
+ if (p->alignType == NSVG_ALIGN_MEET) {
+ // fit whole image into viewbox
+ sx = sy = nsvg__minf(sx, sy);
+ tx += nsvg__viewAlign(p->viewWidth*sx, p->image->width, p->alignX) / sx;
+ ty += nsvg__viewAlign(p->viewHeight*sy, p->image->height, p->alignY) / sy;
+ } else if (p->alignType == NSVG_ALIGN_SLICE) {
+ // fill whole viewbox with image
+ sx = sy = nsvg__maxf(sx, sy);
+ tx += nsvg__viewAlign(p->viewWidth*sx, p->image->width, p->alignX) / sx;
+ ty += nsvg__viewAlign(p->viewHeight*sy, p->image->height, p->alignY) / sy;
+ }
+
+ // Transform
+ sx *= us;
+ sy *= us;
+ avgs = (sx+sy) / 2.0f;
+ for (shape = p->image->shapes; shape != NULL; shape = shape->next) {
+ shape->bounds[0] = (shape->bounds[0] + tx) * sx;
+ shape->bounds[1] = (shape->bounds[1] + ty) * sy;
+ shape->bounds[2] = (shape->bounds[2] + tx) * sx;
+ shape->bounds[3] = (shape->bounds[3] + ty) * sy;
+ for (path = shape->paths; path != NULL; path = path->next) {
+ path->bounds[0] = (path->bounds[0] + tx) * sx;
+ path->bounds[1] = (path->bounds[1] + ty) * sy;
+ path->bounds[2] = (path->bounds[2] + tx) * sx;
+ path->bounds[3] = (path->bounds[3] + ty) * sy;
+ for (i =0; i < path->npts; i++) {
+ pt = &path->pts[i*2];
+ pt[0] = (pt[0] + tx) * sx;
+ pt[1] = (pt[1] + ty) * sy;
+ }
+ }
+
+ if (shape->fill.type == NSVG_PAINT_LINEAR_GRADIENT || shape->fill.type == NSVG_PAINT_RADIAL_GRADIENT) {
+ nsvg__scaleGradient(shape->fill.gradient, tx,ty, sx,sy);
+ memcpy(t, shape->fill.gradient->xform, sizeof(float)*6);
+ nsvg__xformInverse(shape->fill.gradient->xform, t);
+ }
+ if (shape->stroke.type == NSVG_PAINT_LINEAR_GRADIENT || shape->stroke.type == NSVG_PAINT_RADIAL_GRADIENT) {
+ nsvg__scaleGradient(shape->stroke.gradient, tx,ty, sx,sy);
+ memcpy(t, shape->stroke.gradient->xform, sizeof(float)*6);
+ nsvg__xformInverse(shape->stroke.gradient->xform, t);
+ }
+
+ shape->strokeWidth *= avgs;
+ shape->strokeDashOffset *= avgs;
+ for (i = 0; i < shape->strokeDashCount; i++)
+ shape->strokeDashArray[i] *= avgs;
+ }
+}
+
+NANOSVG_SCOPE
+NSVGimage* nsvgParse(char* input, const char* units, float dpi)
+{
+ NSVGparser* p;
+ NSVGimage* ret = 0;
+
+ p = nsvg__createParser();
+ if (p == NULL) {
+ return NULL;
+ }
+ p->dpi = dpi;
+
+ nsvg__parseXML(input, nsvg__startElement, nsvg__endElement, nsvg__content, p);
+
+ // Scale to viewBox
+ nsvg__scaleToViewbox(p, units);
+
+ ret = p->image;
+ p->image = NULL;
+
+ nsvg__deleteParser(p);
+
+ return ret;
+}
+
+NANOSVG_SCOPE
+NSVGimage* nsvgParseFromFile(const char* filename, const char* units, float dpi)
+{
+ FILE* fp = NULL;
+ size_t size;
+ char* data = NULL;
+ NSVGimage* image = NULL;
+
+ fp = fopen(filename, "rb");
+ if (!fp) goto error;
+ fseek(fp, 0, SEEK_END);
+ size = ftell(fp);
+ fseek(fp, 0, SEEK_SET);
+ data = (char*)NANOSVG_malloc(size+1);
+ if (data == NULL) goto error;
+ if (fread(data, 1, size, fp) != size) goto error;
+ data[size] = '\0'; // Must be null terminated.
+ fclose(fp);
+ image = nsvgParse(data, units, dpi);
+ NANOSVG_free(data);
+
+ return image;
+
+error:
+ if (fp) fclose(fp);
+ if (data) NANOSVG_free(data);
+ if (image) nsvgDelete(image);
+ return NULL;
+}
+
+NANOSVG_SCOPE
+void nsvgDelete(NSVGimage* image)
+{
+ NSVGshape *snext, *shape;
+ if (image == NULL) return;
+ shape = image->shapes;
+ while (shape != NULL) {
+ snext = shape->next;
+ nsvg__deletePaths(shape->paths);
+ nsvg__deletePaint(&shape->fill);
+ nsvg__deletePaint(&shape->stroke);
+ NANOSVG_free(shape);
+ shape = snext;
+ }
+ NANOSVG_free(image);
+}
+
+#endif
diff --git a/generic/nanosvgrast.h b/generic/nanosvgrast.h
new file mode 100644
index 0000000..2720ce5
--- /dev/null
+++ b/generic/nanosvgrast.h
@@ -0,0 +1,1467 @@
+/*
+ * Copyright (c) 2013-14 Mikko Mononen memon@inside.org
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty. In no event will the authors be held liable for any damages
+ * arising from the use of this software.
+ *
+ * Permission is granted to anyone to use this software for any purpose,
+ * including commercial applications, and to alter it and redistribute it
+ * freely, subject to the following restrictions:
+ *
+ * 1. The origin of this software must not be misrepresented; you must not
+ * claim that you wrote the original software. If you use this software
+ * in a product, an acknowledgment in the product documentation would be
+ * appreciated but is not required.
+ * 2. Altered source versions must be plainly marked as such, and must not be
+ * misrepresented as being the original software.
+ * 3. This notice may not be removed or altered from any source distribution.
+ *
+ * The polygon rasterization is heavily based on stb_truetype rasterizer
+ * by Sean Barrett - http://nothings.org/
+ *
+ */
+
+#ifndef NANOSVGRAST_H
+#define NANOSVGRAST_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifndef NANOSVG_SCOPE
+#define NANOSVG_SCOPE
+#endif
+
+#ifndef NANOSVG_malloc
+#define NANOSVG_malloc malloc
+#endif
+
+#ifndef NANOSVG_realloc
+#define NANOSVG_realloc realloc
+#endif
+
+#ifndef NANOSVG_free
+#define NANOSVG_free free
+#endif
+
+typedef struct NSVGrasterizer NSVGrasterizer;
+
+/* Example Usage:
+ // Load SVG
+ struct SNVGImage* image = nsvgParseFromFile("test.svg.");
+
+ // Create rasterizer (can be used to render multiple images).
+ struct NSVGrasterizer* rast = nsvgCreateRasterizer();
+ // Allocate memory for image
+ unsigned char* img = malloc(w*h*4);
+ // Rasterize
+ nsvgRasterize(rast, image, 0,0,1, img, w, h, w*4);
+*/
+
+// Allocated rasterizer context.
+NANOSVG_SCOPE NSVGrasterizer* nsvgCreateRasterizer(void);
+
+// Rasterizes SVG image, returns RGBA image (non-premultiplied alpha)
+// r - pointer to rasterizer context
+// image - pointer to image to rasterize
+// tx,ty - image offset (applied after scaling)
+// scale - image scale
+// dst - pointer to destination image data, 4 bytes per pixel (RGBA)
+// w - width of the image to render
+// h - height of the image to render
+// stride - number of bytes per scaleline in the destination buffer
+NANOSVG_SCOPE void nsvgRasterize(NSVGrasterizer* r,
+ NSVGimage* image, float tx, float ty, float scale,
+ unsigned char* dst, int w, int h, int stride);
+
+// Deletes rasterizer context.
+NANOSVG_SCOPE void nsvgDeleteRasterizer(NSVGrasterizer*);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // NANOSVGRAST_H
+
+#ifdef NANOSVGRAST_IMPLEMENTATION
+
+#include <math.h>
+
+#define NSVG__SUBSAMPLES 5
+#define NSVG__FIXSHIFT 10
+#define NSVG__FIX (1 << NSVG__FIXSHIFT)
+#define NSVG__FIXMASK (NSVG__FIX-1)
+#define NSVG__MEMPAGE_SIZE 1024
+
+typedef struct NSVGedge {
+ float x0,y0, x1,y1;
+ int dir;
+ struct NSVGedge* next;
+} NSVGedge;
+
+typedef struct NSVGpoint {
+ float x, y;
+ float dx, dy;
+ float len;
+ float dmx, dmy;
+ unsigned char flags;
+} NSVGpoint;
+
+typedef struct NSVGactiveEdge {
+ int x,dx;
+ float ey;
+ int dir;
+ struct NSVGactiveEdge *next;
+} NSVGactiveEdge;
+
+typedef struct NSVGmemPage {
+ unsigned char mem[NSVG__MEMPAGE_SIZE];
+ int size;
+ struct NSVGmemPage* next;
+} NSVGmemPage;
+
+typedef struct NSVGcachedPaint {
+ char type;
+ char spread;
+ float xform[6];
+ unsigned int colors[256];
+} NSVGcachedPaint;
+
+struct NSVGrasterizer
+{
+ float px, py;
+
+ float tessTol;
+ float distTol;
+
+ NSVGedge* edges;
+ int nedges;
+ int cedges;
+
+ NSVGpoint* points;
+ int npoints;
+ int cpoints;
+
+ NSVGpoint* points2;
+ int npoints2;
+ int cpoints2;
+
+ NSVGactiveEdge* freelist;
+ NSVGmemPage* pages;
+ NSVGmemPage* curpage;
+
+ unsigned char* scanline;
+ int cscanline;
+
+ unsigned char* bitmap;
+ int width, height, stride;
+};
+
+NANOSVG_SCOPE
+NSVGrasterizer* nsvgCreateRasterizer(void)
+{
+ NSVGrasterizer* r = (NSVGrasterizer*)NANOSVG_malloc(sizeof(NSVGrasterizer));
+ if (r == NULL) goto error;
+ memset(r, 0, sizeof(NSVGrasterizer));
+
+ r->tessTol = 0.25f;
+ r->distTol = 0.01f;
+
+ return r;
+
+error:
+ nsvgDeleteRasterizer(r);
+ return NULL;
+}
+
+NANOSVG_SCOPE
+void nsvgDeleteRasterizer(NSVGrasterizer* r)
+{
+ NSVGmemPage* p;
+
+ if (r == NULL) return;
+
+ p = r->pages;
+ while (p != NULL) {
+ NSVGmemPage* next = p->next;
+ NANOSVG_free(p);
+ p = next;
+ }
+
+ if (r->edges) NANOSVG_free(r->edges);
+ if (r->points) NANOSVG_free(r->points);
+ if (r->points2) NANOSVG_free(r->points2);
+ if (r->scanline) NANOSVG_free(r->scanline);
+
+ NANOSVG_free(r);
+}
+
+static NSVGmemPage* nsvg__nextPage(NSVGrasterizer* r, NSVGmemPage* cur)
+{
+ NSVGmemPage *newp;
+
+ // If using existing chain, return the next page in chain
+ if (cur != NULL && cur->next != NULL) {
+ return cur->next;
+ }
+
+ // Alloc new page
+ newp = (NSVGmemPage*)NANOSVG_malloc(sizeof(NSVGmemPage));
+ if (newp == NULL) return NULL;
+ memset(newp, 0, sizeof(NSVGmemPage));
+
+ // Add to linked list
+ if (cur != NULL)
+ cur->next = newp;
+ else
+ r->pages = newp;
+
+ return newp;
+}
+
+static void nsvg__resetPool(NSVGrasterizer* r)
+{
+ NSVGmemPage* p = r->pages;
+ while (p != NULL) {
+ p->size = 0;
+ p = p->next;
+ }
+ r->curpage = r->pages;
+}
+
+static unsigned char* nsvg__alloc(NSVGrasterizer* r, int size)
+{
+ unsigned char* buf;
+ if (size > NSVG__MEMPAGE_SIZE) return NULL;
+ if (r->curpage == NULL || r->curpage->size+size > NSVG__MEMPAGE_SIZE) {
+ r->curpage = nsvg__nextPage(r, r->curpage);
+ }
+ buf = &r->curpage->mem[r->curpage->size];
+ r->curpage->size += size;
+ return buf;
+}
+
+static int nsvg__ptEquals(float x1, float y1, float x2, float y2, float tol)
+{
+ float dx = x2 - x1;
+ float dy = y2 - y1;
+ return dx*dx + dy*dy < tol*tol;
+}
+
+static void nsvg__addPathPoint(NSVGrasterizer* r, float x, float y, int flags)
+{
+ NSVGpoint* pt;
+
+ if (r->npoints > 0) {
+ pt = &r->points[r->npoints-1];
+ if (nsvg__ptEquals(pt->x,pt->y, x,y, r->distTol)) {
+ pt->flags = (unsigned char)(pt->flags | flags);
+ return;
+ }
+ }
+
+ if (r->npoints+1 > r->cpoints) {
+ r->cpoints = r->cpoints > 0 ? r->cpoints * 2 : 64;
+ r->points = (NSVGpoint*)NANOSVG_realloc(r->points, sizeof(NSVGpoint) * r->cpoints);
+ if (r->points == NULL) return;
+ }
+
+ pt = &r->points[r->npoints];
+ pt->x = x;
+ pt->y = y;
+ pt->flags = (unsigned char)flags;
+ r->npoints++;
+}
+
+static void nsvg__appendPathPoint(NSVGrasterizer* r, NSVGpoint pt)
+{
+ if (r->npoints+1 > r->cpoints) {
+ r->cpoints = r->cpoints > 0 ? r->cpoints * 2 : 64;
+ r->points = (NSVGpoint*)NANOSVG_realloc(r->points, sizeof(NSVGpoint) * r->cpoints);
+ if (r->points == NULL) return;
+ }
+ r->points[r->npoints] = pt;
+ r->npoints++;
+}
+
+static void nsvg__duplicatePoints(NSVGrasterizer* r)
+{
+ if (r->npoints > r->cpoints2) {
+ r->cpoints2 = r->npoints;
+ r->points2 = (NSVGpoint*)NANOSVG_realloc(r->points2, sizeof(NSVGpoint) * r->cpoints2);
+ if (r->points2 == NULL) return;
+ }
+
+ memcpy(r->points2, r->points, sizeof(NSVGpoint) * r->npoints);
+ r->npoints2 = r->npoints;
+}
+
+static void nsvg__addEdge(NSVGrasterizer* r, float x0, float y0, float x1, float y1)
+{
+ NSVGedge* e;
+
+ // Skip horizontal edges
+ if (y0 == y1)
+ return;
+
+ if (r->nedges+1 > r->cedges) {
+ r->cedges = r->cedges > 0 ? r->cedges * 2 : 64;
+ r->edges = (NSVGedge*)NANOSVG_realloc(r->edges, sizeof(NSVGedge) * r->cedges);
+ if (r->edges == NULL) return;
+ }
+
+ e = &r->edges[r->nedges];
+ r->nedges++;
+
+ if (y0 < y1) {
+ e->x0 = x0;
+ e->y0 = y0;
+ e->x1 = x1;
+ e->y1 = y1;
+ e->dir = 1;
+ } else {
+ e->x0 = x1;
+ e->y0 = y1;
+ e->x1 = x0;
+ e->y1 = y0;
+ e->dir = -1;
+ }
+}
+
+static float nsvg__normalize(float *x, float* y)
+{
+ float d = sqrtf((*x)*(*x) + (*y)*(*y));
+ if (d > 1e-6f) {
+ float id = 1.0f / d;
+ *x *= id;
+ *y *= id;
+ }
+ return d;
+}
+
+static float nsvg__absf(float x) { return x < 0 ? -x : x; }
+
+static void nsvg__flattenCubicBez(NSVGrasterizer* r,
+ float x1, float y1, float x2, float y2,
+ float x3, float y3, float x4, float y4,
+ int level, int type)
+{
+ float x12,y12,x23,y23,x34,y34,x123,y123,x234,y234,x1234,y1234;
+ float dx,dy,d2,d3;
+
+ if (level > 10) return;
+
+ x12 = (x1+x2)*0.5f;
+ y12 = (y1+y2)*0.5f;
+ x23 = (x2+x3)*0.5f;
+ y23 = (y2+y3)*0.5f;
+ x34 = (x3+x4)*0.5f;
+ y34 = (y3+y4)*0.5f;
+ x123 = (x12+x23)*0.5f;
+ y123 = (y12+y23)*0.5f;
+
+ dx = x4 - x1;
+ dy = y4 - y1;
+ d2 = nsvg__absf(((x2 - x4) * dy - (y2 - y4) * dx));
+ d3 = nsvg__absf(((x3 - x4) * dy - (y3 - y4) * dx));
+
+ if ((d2 + d3)*(d2 + d3) < r->tessTol * (dx*dx + dy*dy)) {
+ nsvg__addPathPoint(r, x4, y4, type);
+ return;
+ }
+
+ x234 = (x23+x34)*0.5f;
+ y234 = (y23+y34)*0.5f;
+ x1234 = (x123+x234)*0.5f;
+ y1234 = (y123+y234)*0.5f;
+
+ nsvg__flattenCubicBez(r, x1,y1, x12,y12, x123,y123, x1234,y1234, level+1, 0);
+ nsvg__flattenCubicBez(r, x1234,y1234, x234,y234, x34,y34, x4,y4, level+1, type);
+}
+
+static void nsvg__flattenShape(NSVGrasterizer* r, NSVGshape* shape, float scale)
+{
+ int i, j;
+ NSVGpath* path;
+
+ for (path = shape->paths; path != NULL; path = path->next) {
+ r->npoints = 0;
+ // Flatten path
+ nsvg__addPathPoint(r, path->pts[0]*scale, path->pts[1]*scale, 0);
+ for (i = 0; i < path->npts-1; i += 3) {
+ float* p = &path->pts[i*2];
+ nsvg__flattenCubicBez(r, p[0]*scale,p[1]*scale, p[2]*scale,p[3]*scale, p[4]*scale,p[5]*scale, p[6]*scale,p[7]*scale, 0, 0);
+ }
+ // Close path
+ nsvg__addPathPoint(r, path->pts[0]*scale, path->pts[1]*scale, 0);
+ // Build edges
+ for (i = 0, j = r->npoints-1; i < r->npoints; j = i++)
+ nsvg__addEdge(r, r->points[j].x, r->points[j].y, r->points[i].x, r->points[i].y);
+ }
+}
+
+enum NSVGpointFlags
+{
+ NSVG_PT_CORNER = 0x01,
+ NSVG_PT_BEVEL = 0x02,
+ NSVG_PT_LEFT = 0x04
+};
+
+static void nsvg__initClosed(NSVGpoint* left, NSVGpoint* right, NSVGpoint* p0, NSVGpoint* p1, float lineWidth)
+{
+ float w = lineWidth * 0.5f;
+ float dx = p1->x - p0->x;
+ float dy = p1->y - p0->y;
+ float len = nsvg__normalize(&dx, &dy);
+ float px = p0->x + dx*len*0.5f, py = p0->y + dy*len*0.5f;
+ float dlx = dy, dly = -dx;
+ float lx = px - dlx*w, ly = py - dly*w;
+ float rx = px + dlx*w, ry = py + dly*w;
+ left->x = lx; left->y = ly;
+ right->x = rx; right->y = ry;
+}
+
+static void nsvg__buttCap(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right, NSVGpoint* p, float dx, float dy, float lineWidth, int connect)
+{
+ float w = lineWidth * 0.5f;
+ float px = p->x, py = p->y;
+ float dlx = dy, dly = -dx;
+ float lx = px - dlx*w, ly = py - dly*w;
+ float rx = px + dlx*w, ry = py + dly*w;
+
+ nsvg__addEdge(r, lx, ly, rx, ry);
+
+ if (connect) {
+ nsvg__addEdge(r, left->x, left->y, lx, ly);
+ nsvg__addEdge(r, rx, ry, right->x, right->y);
+ }
+ left->x = lx; left->y = ly;
+ right->x = rx; right->y = ry;
+}
+
+static void nsvg__squareCap(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right, NSVGpoint* p, float dx, float dy, float lineWidth, int connect)
+{
+ float w = lineWidth * 0.5f;
+ float px = p->x - dx*w, py = p->y - dy*w;
+ float dlx = dy, dly = -dx;
+ float lx = px - dlx*w, ly = py - dly*w;
+ float rx = px + dlx*w, ry = py + dly*w;
+
+ nsvg__addEdge(r, lx, ly, rx, ry);
+
+ if (connect) {
+ nsvg__addEdge(r, left->x, left->y, lx, ly);
+ nsvg__addEdge(r, rx, ry, right->x, right->y);
+ }
+ left->x = lx; left->y = ly;
+ right->x = rx; right->y = ry;
+}
+
+#ifndef NSVG_PI
+#define NSVG_PI (3.14159265358979323846264338327f)
+#endif
+
+static void nsvg__roundCap(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right, NSVGpoint* p, float dx, float dy, float lineWidth, int ncap, int connect)
+{
+ int i;
+ float w = lineWidth * 0.5f;
+ float px = p->x, py = p->y;
+ float dlx = dy, dly = -dx;
+ float lx = 0, ly = 0, rx = 0, ry = 0, prevx = 0, prevy = 0;
+
+ for (i = 0; i < ncap; i++) {
+ float a = (float)i/(float)(ncap-1)*NSVG_PI;
+ float ax = cosf(a) * w, ay = sinf(a) * w;
+ float x = px - dlx*ax - dx*ay;
+ float y = py - dly*ax - dy*ay;
+
+ if (i > 0)
+ nsvg__addEdge(r, prevx, prevy, x, y);
+
+ prevx = x;
+ prevy = y;
+
+ if (i == 0) {
+ lx = x; ly = y;
+ } else if (i == ncap-1) {
+ rx = x; ry = y;
+ }
+ }
+
+ if (connect) {
+ nsvg__addEdge(r, left->x, left->y, lx, ly);
+ nsvg__addEdge(r, rx, ry, right->x, right->y);
+ }
+
+ left->x = lx; left->y = ly;
+ right->x = rx; right->y = ry;
+}
+
+static void nsvg__bevelJoin(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right, NSVGpoint* p0, NSVGpoint* p1, float lineWidth)
+{
+ float w = lineWidth * 0.5f;
+ float dlx0 = p0->dy, dly0 = -p0->dx;
+ float dlx1 = p1->dy, dly1 = -p1->dx;
+ float lx0 = p1->x - (dlx0 * w), ly0 = p1->y - (dly0 * w);
+ float rx0 = p1->x + (dlx0 * w), ry0 = p1->y + (dly0 * w);
+ float lx1 = p1->x - (dlx1 * w), ly1 = p1->y - (dly1 * w);
+ float rx1 = p1->x + (dlx1 * w), ry1 = p1->y + (dly1 * w);
+
+ nsvg__addEdge(r, lx0, ly0, left->x, left->y);
+ nsvg__addEdge(r, lx1, ly1, lx0, ly0);
+
+ nsvg__addEdge(r, right->x, right->y, rx0, ry0);
+ nsvg__addEdge(r, rx0, ry0, rx1, ry1);
+
+ left->x = lx1; left->y = ly1;
+ right->x = rx1; right->y = ry1;
+}
+
+static void nsvg__miterJoin(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right, NSVGpoint* p0, NSVGpoint* p1, float lineWidth)
+{
+ float w = lineWidth * 0.5f;
+ float dlx0 = p0->dy, dly0 = -p0->dx;
+ float dlx1 = p1->dy, dly1 = -p1->dx;
+ float lx0, rx0, lx1, rx1;
+ float ly0, ry0, ly1, ry1;
+
+ if (p1->flags & NSVG_PT_LEFT) {
+ lx0 = lx1 = p1->x - p1->dmx * w;
+ ly0 = ly1 = p1->y - p1->dmy * w;
+ nsvg__addEdge(r, lx1, ly1, left->x, left->y);
+
+ rx0 = p1->x + (dlx0 * w);
+ ry0 = p1->y + (dly0 * w);
+ rx1 = p1->x + (dlx1 * w);
+ ry1 = p1->y + (dly1 * w);
+ nsvg__addEdge(r, right->x, right->y, rx0, ry0);
+ nsvg__addEdge(r, rx0, ry0, rx1, ry1);
+ } else {
+ lx0 = p1->x - (dlx0 * w);
+ ly0 = p1->y - (dly0 * w);
+ lx1 = p1->x - (dlx1 * w);
+ ly1 = p1->y - (dly1 * w);
+ nsvg__addEdge(r, lx0, ly0, left->x, left->y);
+ nsvg__addEdge(r, lx1, ly1, lx0, ly0);
+
+ rx0 = rx1 = p1->x + p1->dmx * w;
+ ry0 = ry1 = p1->y + p1->dmy * w;
+ nsvg__addEdge(r, right->x, right->y, rx1, ry1);
+ }
+
+ left->x = lx1; left->y = ly1;
+ right->x = rx1; right->y = ry1;
+}
+
+static void nsvg__roundJoin(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right, NSVGpoint* p0, NSVGpoint* p1, float lineWidth, int ncap)
+{
+ int i, n;
+ float w = lineWidth * 0.5f;
+ float dlx0 = p0->dy, dly0 = -p0->dx;
+ float dlx1 = p1->dy, dly1 = -p1->dx;
+ float a0 = atan2f(dly0, dlx0);
+ float a1 = atan2f(dly1, dlx1);
+ float da = a1 - a0;
+ float lx, ly, rx, ry;
+
+ if (da < NSVG_PI) da += NSVG_PI*2;
+ if (da > NSVG_PI) da -= NSVG_PI*2;
+
+ n = (int)ceilf((nsvg__absf(da) / NSVG_PI) * (float)ncap);
+ if (n < 2) n = 2;
+ if (n > ncap) n = ncap;
+
+ lx = left->x;
+ ly = left->y;
+ rx = right->x;
+ ry = right->y;
+
+ for (i = 0; i < n; i++) {
+ float u = (float)i/(float)(n-1);
+ float a = a0 + u*da;
+ float ax = cosf(a) * w, ay = sinf(a) * w;
+ float lx1 = p1->x - ax, ly1 = p1->y - ay;
+ float rx1 = p1->x + ax, ry1 = p1->y + ay;
+
+ nsvg__addEdge(r, lx1, ly1, lx, ly);
+ nsvg__addEdge(r, rx, ry, rx1, ry1);
+
+ lx = lx1; ly = ly1;
+ rx = rx1; ry = ry1;
+ }
+
+ left->x = lx; left->y = ly;
+ right->x = rx; right->y = ry;
+}
+
+static void nsvg__straightJoin(NSVGrasterizer* r, NSVGpoint* left, NSVGpoint* right, NSVGpoint* p1, float lineWidth)
+{
+ float w = lineWidth * 0.5f;
+ float lx = p1->x - (p1->dmx * w), ly = p1->y - (p1->dmy * w);
+ float rx = p1->x + (p1->dmx * w), ry = p1->y + (p1->dmy * w);
+
+ nsvg__addEdge(r, lx, ly, left->x, left->y);
+ nsvg__addEdge(r, right->x, right->y, rx, ry);
+
+ left->x = lx; left->y = ly;
+ right->x = rx; right->y = ry;
+}
+
+static int nsvg__curveDivs(float r, float arc, float tol)
+{
+ float da = acosf(r / (r + tol)) * 2.0f;
+ int divs = (int)ceilf(arc / da);
+ if (divs < 2) divs = 2;
+ return divs;
+}
+
+static void nsvg__expandStroke(NSVGrasterizer* r, NSVGpoint* points, int npoints, int closed, int lineJoin, int lineCap, float lineWidth)
+{
+ int ncap = nsvg__curveDivs(lineWidth*0.5f, NSVG_PI, r->tessTol); // Calculate divisions per half circle.
+ NSVGpoint left = {0,0,0,0,0,0,0,0}, right = {0,0,0,0,0,0,0,0}, firstLeft = {0,0,0,0,0,0,0,0}, firstRight = {0,0,0,0,0,0,0,0};
+ NSVGpoint* p0, *p1;
+ int j, s, e;
+
+ // Build stroke edges
+ if (closed) {
+ // Looping
+ p0 = &points[npoints-1];
+ p1 = &points[0];
+ s = 0;
+ e = npoints;
+ } else {
+ // Add cap
+ p0 = &points[0];
+ p1 = &points[1];
+ s = 1;
+ e = npoints-1;
+ }
+
+ if (closed) {
+ nsvg__initClosed(&left, &right, p0, p1, lineWidth);
+ firstLeft = left;
+ firstRight = right;
+ } else {
+ // Add cap
+ float dx = p1->x - p0->x;
+ float dy = p1->y - p0->y;
+ nsvg__normalize(&dx, &dy);
+ if (lineCap == NSVG_CAP_BUTT)
+ nsvg__buttCap(r, &left, &right, p0, dx, dy, lineWidth, 0);
+ else if (lineCap == NSVG_CAP_SQUARE)
+ nsvg__squareCap(r, &left, &right, p0, dx, dy, lineWidth, 0);
+ else if (lineCap == NSVG_CAP_ROUND)
+ nsvg__roundCap(r, &left, &right, p0, dx, dy, lineWidth, ncap, 0);
+ }
+
+ for (j = s; j < e; ++j) {
+ if (p1->flags & NSVG_PT_CORNER) {
+ if (lineJoin == NSVG_JOIN_ROUND)
+ nsvg__roundJoin(r, &left, &right, p0, p1, lineWidth, ncap);
+ else if (lineJoin == NSVG_JOIN_BEVEL || (p1->flags & NSVG_PT_BEVEL))
+ nsvg__bevelJoin(r, &left, &right, p0, p1, lineWidth);
+ else
+ nsvg__miterJoin(r, &left, &right, p0, p1, lineWidth);
+ } else {
+ nsvg__straightJoin(r, &left, &right, p1, lineWidth);
+ }
+ p0 = p1++;
+ }
+
+ if (closed) {
+ // Loop it
+ nsvg__addEdge(r, firstLeft.x, firstLeft.y, left.x, left.y);
+ nsvg__addEdge(r, right.x, right.y, firstRight.x, firstRight.y);
+ } else {
+ // Add cap
+ float dx = p1->x - p0->x;
+ float dy = p1->y - p0->y;
+ nsvg__normalize(&dx, &dy);
+ if (lineCap == NSVG_CAP_BUTT)
+ nsvg__buttCap(r, &right, &left, p1, -dx, -dy, lineWidth, 1);
+ else if (lineCap == NSVG_CAP_SQUARE)
+ nsvg__squareCap(r, &right, &left, p1, -dx, -dy, lineWidth, 1);
+ else if (lineCap == NSVG_CAP_ROUND)
+ nsvg__roundCap(r, &right, &left, p1, -dx, -dy, lineWidth, ncap, 1);
+ }
+}
+
+static void nsvg__prepareStroke(NSVGrasterizer* r, float miterLimit, int lineJoin)
+{
+ int i, j;
+ NSVGpoint* p0, *p1;
+
+ p0 = &r->points[r->npoints-1];
+ p1 = &r->points[0];
+ for (i = 0; i < r->npoints; i++) {
+ // Calculate segment direction and length
+ p0->dx = p1->x - p0->x;
+ p0->dy = p1->y - p0->y;
+ p0->len = nsvg__normalize(&p0->dx, &p0->dy);
+ // Advance
+ p0 = p1++;
+ }
+
+ // calculate joins
+ p0 = &r->points[r->npoints-1];
+ p1 = &r->points[0];
+ for (j = 0; j < r->npoints; j++) {
+ float dlx0, dly0, dlx1, dly1, dmr2, cross;
+ dlx0 = p0->dy;
+ dly0 = -p0->dx;
+ dlx1 = p1->dy;
+ dly1 = -p1->dx;
+ // Calculate extrusions
+ p1->dmx = (dlx0 + dlx1) * 0.5f;
+ p1->dmy = (dly0 + dly1) * 0.5f;
+ dmr2 = p1->dmx*p1->dmx + p1->dmy*p1->dmy;
+ if (dmr2 > 0.000001f) {
+ float s2 = 1.0f / dmr2;
+ if (s2 > 600.0f) {
+ s2 = 600.0f;
+ }
+ p1->dmx *= s2;
+ p1->dmy *= s2;
+ }
+
+ // Clear flags, but keep the corner.
+ p1->flags = (p1->flags & NSVG_PT_CORNER) ? NSVG_PT_CORNER : 0;
+
+ // Keep track of left turns.
+ cross = p1->dx * p0->dy - p0->dx * p1->dy;
+ if (cross > 0.0f)
+ p1->flags |= NSVG_PT_LEFT;
+
+ // Check to see if the corner needs to be beveled.
+ if (p1->flags & NSVG_PT_CORNER) {
+ if ((dmr2 * miterLimit*miterLimit) < 1.0f || lineJoin == NSVG_JOIN_BEVEL || lineJoin == NSVG_JOIN_ROUND) {
+ p1->flags |= NSVG_PT_BEVEL;
+ }
+ }
+
+ p0 = p1++;
+ }
+}
+
+static void nsvg__flattenShapeStroke(NSVGrasterizer* r, NSVGshape* shape, float scale)
+{
+ int i, j, closed;
+ NSVGpath* path;
+ NSVGpoint* p0, *p1;
+ float miterLimit = shape->miterLimit;
+ int lineJoin = shape->strokeLineJoin;
+ int lineCap = shape->strokeLineCap;
+ float lineWidth = shape->strokeWidth * scale;
+
+ for (path = shape->paths; path != NULL; path = path->next) {
+ // Flatten path
+ r->npoints = 0;
+ nsvg__addPathPoint(r, path->pts[0]*scale, path->pts[1]*scale, NSVG_PT_CORNER);
+ for (i = 0; i < path->npts-1; i += 3) {
+ float* p = &path->pts[i*2];
+ nsvg__flattenCubicBez(r, p[0]*scale,p[1]*scale, p[2]*scale,p[3]*scale, p[4]*scale,p[5]*scale, p[6]*scale,p[7]*scale, 0, NSVG_PT_CORNER);
+ }
+ if (r->npoints < 2)
+ continue;
+
+ closed = path->closed;
+
+ // If the first and last points are the same, remove the last, mark as closed path.
+ p0 = &r->points[r->npoints-1];
+ p1 = &r->points[0];
+ if (nsvg__ptEquals(p0->x,p0->y, p1->x,p1->y, r->distTol)) {
+ r->npoints--;
+ p0 = &r->points[r->npoints-1];
+ closed = 1;
+ }
+
+ if (shape->strokeDashCount > 0) {
+ int idash = 0, dashState = 1;
+ float totalDist = 0, dashLen, allDashLen, dashOffset;
+ NSVGpoint cur;
+
+ if (closed)
+ nsvg__appendPathPoint(r, r->points[0]);
+
+ // Duplicate points -> points2.
+ nsvg__duplicatePoints(r);
+
+ r->npoints = 0;
+ cur = r->points2[0];
+ nsvg__appendPathPoint(r, cur);
+
+ // Figure out dash offset.
+ allDashLen = 0;
+ for (j = 0; j < shape->strokeDashCount; j++)
+ allDashLen += shape->strokeDashArray[j];
+ if (shape->strokeDashCount & 1)
+ allDashLen *= 2.0f;
+ // Find location inside pattern
+ dashOffset = fmodf(shape->strokeDashOffset, allDashLen);
+ if (dashOffset < 0.0f)
+ dashOffset += allDashLen;
+
+ while (dashOffset > shape->strokeDashArray[idash]) {
+ dashOffset -= shape->strokeDashArray[idash];
+ idash = (idash + 1) % shape->strokeDashCount;
+ }
+ dashLen = (shape->strokeDashArray[idash] - dashOffset) * scale;
+
+ for (j = 1; j < r->npoints2; ) {
+ float dx = r->points2[j].x - cur.x;
+ float dy = r->points2[j].y - cur.y;
+ float dist = sqrtf(dx*dx + dy*dy);
+
+ if ((totalDist + dist) > dashLen) {
+ // Calculate intermediate point
+ float d = (dashLen - totalDist) / dist;
+ float x = cur.x + dx * d;
+ float y = cur.y + dy * d;
+ nsvg__addPathPoint(r, x, y, NSVG_PT_CORNER);
+
+ // Stroke
+ if (r->npoints > 1 && dashState) {
+ nsvg__prepareStroke(r, miterLimit, lineJoin);
+ nsvg__expandStroke(r, r->points, r->npoints, 0, lineJoin, lineCap, lineWidth);
+ }
+ // Advance dash pattern
+ dashState = !dashState;
+ idash = (idash+1) % shape->strokeDashCount;
+ dashLen = shape->strokeDashArray[idash] * scale;
+ // Restart
+ cur.x = x;
+ cur.y = y;
+ cur.flags = NSVG_PT_CORNER;
+ totalDist = 0.0f;
+ r->npoints = 0;
+ nsvg__appendPathPoint(r, cur);
+ } else {
+ totalDist += dist;
+ cur = r->points2[j];
+ nsvg__appendPathPoint(r, cur);
+ j++;
+ }
+ }
+ // Stroke any leftover path
+ if (r->npoints > 1 && dashState)
+ nsvg__expandStroke(r, r->points, r->npoints, 0, lineJoin, lineCap, lineWidth);
+ } else {
+ nsvg__prepareStroke(r, miterLimit, lineJoin);
+ nsvg__expandStroke(r, r->points, r->npoints, closed, lineJoin, lineCap, lineWidth);
+ }
+ }
+}
+
+static int nsvg__cmpEdge(const void *p, const void *q)
+{
+ const NSVGedge* a = (const NSVGedge*)p;
+ const NSVGedge* b = (const NSVGedge*)q;
+
+ if (a->y0 < b->y0) return -1;
+ if (a->y0 > b->y0) return 1;
+ return 0;
+}
+
+
+static NSVGactiveEdge* nsvg__addActive(NSVGrasterizer* r, NSVGedge* e, float startPoint)
+{
+ NSVGactiveEdge* z;
+ float dxdy;
+
+ if (r->freelist != NULL) {
+ // Restore from freelist.
+ z = r->freelist;
+ r->freelist = z->next;
+ } else {
+ // Alloc new edge.
+ z = (NSVGactiveEdge*)nsvg__alloc(r, sizeof(NSVGactiveEdge));
+ if (z == NULL) return NULL;
+ }
+
+ dxdy = (e->x1 - e->x0) / (e->y1 - e->y0);
+// STBTT_assert(e->y0 <= start_point);
+ // round dx down to avoid going too far
+ if (dxdy < 0)
+ z->dx = (int)(-floorf(NSVG__FIX * -dxdy));
+ else
+ z->dx = (int)floorf(NSVG__FIX * dxdy);
+ z->x = (int)floorf(NSVG__FIX * (e->x0 + dxdy * (startPoint - e->y0)));
+// z->x -= off_x * FIX;
+ z->ey = e->y1;
+ z->next = 0;
+ z->dir = e->dir;
+
+ return z;
+}
+
+static void nsvg__freeActive(NSVGrasterizer* r, NSVGactiveEdge* z)
+{
+ z->next = r->freelist;
+ r->freelist = z;
+}
+
+static void nsvg__fillScanline(unsigned char* scanline, int len, int x0, int x1, int maxWeight, int* xmin, int* xmax)
+{
+ int i = x0 >> NSVG__FIXSHIFT;
+ int j = x1 >> NSVG__FIXSHIFT;
+ if (i < *xmin) *xmin = i;
+ if (j > *xmax) *xmax = j;
+ if (i < len && j >= 0) {
+ if (i == j) {
+ // x0,x1 are the same pixel, so compute combined coverage
+ scanline[i] = (unsigned char)(scanline[i] + ((x1 - x0) * maxWeight >> NSVG__FIXSHIFT));
+ } else {
+ if (i >= 0) // add antialiasing for x0
+ scanline[i] = (unsigned char)(scanline[i] + (((NSVG__FIX - (x0 & NSVG__FIXMASK)) * maxWeight) >> NSVG__FIXSHIFT));
+ else
+ i = -1; // clip
+
+ if (j < len) // add antialiasing for x1
+ scanline[j] = (unsigned char)(scanline[j] + (((x1 & NSVG__FIXMASK) * maxWeight) >> NSVG__FIXSHIFT));
+ else
+ j = len; // clip
+
+ for (++i; i < j; ++i) // fill pixels between x0 and x1
+ scanline[i] = (unsigned char)(scanline[i] + maxWeight);
+ }
+ }
+}
+
+// note: this routine clips fills that extend off the edges... ideally this
+// wouldn't happen, but it could happen if the truetype glyph bounding boxes
+// are wrong, or if the user supplies a too-small bitmap
+static void nsvg__fillActiveEdges(unsigned char* scanline, int len, NSVGactiveEdge* e, int maxWeight, int* xmin, int* xmax, char fillRule)
+{
+ // non-zero winding fill
+ int x0 = 0, w = 0;
+
+ if (fillRule == NSVG_FILLRULE_NONZERO) {
+ // Non-zero
+ while (e != NULL) {
+ if (w == 0) {
+ // if we're currently at zero, we need to record the edge start point
+ x0 = e->x; w += e->dir;
+ } else {
+ int x1 = e->x; w += e->dir;
+ // if we went to zero, we need to draw
+ if (w == 0)
+ nsvg__fillScanline(scanline, len, x0, x1, maxWeight, xmin, xmax);
+ }
+ e = e->next;
+ }
+ } else if (fillRule == NSVG_FILLRULE_EVENODD) {
+ // Even-odd
+ while (e != NULL) {
+ if (w == 0) {
+ // if we're currently at zero, we need to record the edge start point
+ x0 = e->x; w = 1;
+ } else {
+ int x1 = e->x; w = 0;
+ nsvg__fillScanline(scanline, len, x0, x1, maxWeight, xmin, xmax);
+ }
+ e = e->next;
+ }
+ }
+}
+
+static float nsvg__clampf(float a, float mn, float mx) { return a < mn ? mn : (a > mx ? mx : a); }
+
+static unsigned int nsvg__RGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
+{
+ return (r) | (g << 8) | (b << 16) | (a << 24);
+}
+
+static unsigned int nsvg__lerpRGBA(unsigned int c0, unsigned int c1, float u)
+{
+ int iu = (int)(nsvg__clampf(u, 0.0f, 1.0f) * 256.0f);
+ int r = (((c0) & 0xff)*(256-iu) + (((c1) & 0xff)*iu)) >> 8;
+ int g = (((c0>>8) & 0xff)*(256-iu) + (((c1>>8) & 0xff)*iu)) >> 8;
+ int b = (((c0>>16) & 0xff)*(256-iu) + (((c1>>16) & 0xff)*iu)) >> 8;
+ int a = (((c0>>24) & 0xff)*(256-iu) + (((c1>>24) & 0xff)*iu)) >> 8;
+ return nsvg__RGBA((unsigned char)r, (unsigned char)g, (unsigned char)b, (unsigned char)a);
+}
+
+static unsigned int nsvg__applyOpacity(unsigned int c, float u)
+{
+ int iu = (int)(nsvg__clampf(u, 0.0f, 1.0f) * 256.0f);
+ int r = (c) & 0xff;
+ int g = (c>>8) & 0xff;
+ int b = (c>>16) & 0xff;
+ int a = (((c>>24) & 0xff)*iu) >> 8;
+ return nsvg__RGBA((unsigned char)r, (unsigned char)g, (unsigned char)b, (unsigned char)a);
+}
+
+static inline int nsvg__div255(int x)
+{
+ return ((x+1) * 257) >> 16;
+}
+
+static void nsvg__scanlineSolid(unsigned char* dst, int count, unsigned char* cover, int x, int y,
+ float tx, float ty, float scale, NSVGcachedPaint* cache)
+{
+
+ if (cache->type == NSVG_PAINT_COLOR) {
+ int i, cr, cg, cb, ca;
+ cr = cache->colors[0] & 0xff;
+ cg = (cache->colors[0] >> 8) & 0xff;
+ cb = (cache->colors[0] >> 16) & 0xff;
+ ca = (cache->colors[0] >> 24) & 0xff;
+
+ for (i = 0; i < count; i++) {
+ int r,g,b;
+ int a = nsvg__div255((int)cover[0] * ca);
+ int ia = 255 - a;
+ // Premultiply
+ r = nsvg__div255(cr * a);
+ g = nsvg__div255(cg * a);
+ b = nsvg__div255(cb * a);
+
+ // Blend over
+ r += nsvg__div255(ia * (int)dst[0]);
+ g += nsvg__div255(ia * (int)dst[1]);
+ b += nsvg__div255(ia * (int)dst[2]);
+ a += nsvg__div255(ia * (int)dst[3]);
+
+ dst[0] = (unsigned char)r;
+ dst[1] = (unsigned char)g;
+ dst[2] = (unsigned char)b;
+ dst[3] = (unsigned char)a;
+
+ cover++;
+ dst += 4;
+ }
+ } else if (cache->type == NSVG_PAINT_LINEAR_GRADIENT) {
+ // TODO: spread modes.
+ // TODO: plenty of opportunities to optimize.
+ float fx, fy, dx, gy;
+ float* t = cache->xform;
+ int i, cr, cg, cb, ca;
+ unsigned int c;
+
+ fx = ((float)x - tx) / scale;
+ fy = ((float)y - ty) / scale;
+ dx = 1.0f / scale;
+
+ for (i = 0; i < count; i++) {
+ int r,g,b,a,ia;
+ gy = fx*t[1] + fy*t[3] + t[5];
+ c = cache->colors[(int)nsvg__clampf(gy*255.0f, 0, 255.0f)];
+ cr = (c) & 0xff;
+ cg = (c >> 8) & 0xff;
+ cb = (c >> 16) & 0xff;
+ ca = (c >> 24) & 0xff;
+
+ a = nsvg__div255((int)cover[0] * ca);
+ ia = 255 - a;
+
+ // Premultiply
+ r = nsvg__div255(cr * a);
+ g = nsvg__div255(cg * a);
+ b = nsvg__div255(cb * a);
+
+ // Blend over
+ r += nsvg__div255(ia * (int)dst[0]);
+ g += nsvg__div255(ia * (int)dst[1]);
+ b += nsvg__div255(ia * (int)dst[2]);
+ a += nsvg__div255(ia * (int)dst[3]);
+
+ dst[0] = (unsigned char)r;
+ dst[1] = (unsigned char)g;
+ dst[2] = (unsigned char)b;
+ dst[3] = (unsigned char)a;
+
+ cover++;
+ dst += 4;
+ fx += dx;
+ }
+ } else if (cache->type == NSVG_PAINT_RADIAL_GRADIENT) {
+ // TODO: spread modes.
+ // TODO: plenty of opportunities to optimize.
+ // TODO: focus (fx,fy)
+ float fx, fy, dx, gx, gy, gd;
+ float* t = cache->xform;
+ int i, cr, cg, cb, ca;
+ unsigned int c;
+
+ fx = ((float)x - tx) / scale;
+ fy = ((float)y - ty) / scale;
+ dx = 1.0f / scale;
+
+ for (i = 0; i < count; i++) {
+ int r,g,b,a,ia;
+ gx = fx*t[0] + fy*t[2] + t[4];
+ gy = fx*t[1] + fy*t[3] + t[5];
+ gd = sqrtf(gx*gx + gy*gy);
+ c = cache->colors[(int)nsvg__clampf(gd*255.0f, 0, 255.0f)];
+ cr = (c) & 0xff;
+ cg = (c >> 8) & 0xff;
+ cb = (c >> 16) & 0xff;
+ ca = (c >> 24) & 0xff;
+
+ a = nsvg__div255((int)cover[0] * ca);
+ ia = 255 - a;
+
+ // Premultiply
+ r = nsvg__div255(cr * a);
+ g = nsvg__div255(cg * a);
+ b = nsvg__div255(cb * a);
+
+ // Blend over
+ r += nsvg__div255(ia * (int)dst[0]);
+ g += nsvg__div255(ia * (int)dst[1]);
+ b += nsvg__div255(ia * (int)dst[2]);
+ a += nsvg__div255(ia * (int)dst[3]);
+
+ dst[0] = (unsigned char)r;
+ dst[1] = (unsigned char)g;
+ dst[2] = (unsigned char)b;
+ dst[3] = (unsigned char)a;
+
+ cover++;
+ dst += 4;
+ fx += dx;
+ }
+ }
+}
+
+static void nsvg__rasterizeSortedEdges(NSVGrasterizer *r, float tx, float ty, float scale, NSVGcachedPaint* cache, char fillRule)
+{
+ NSVGactiveEdge *active = NULL;
+ int y, s;
+ int e = 0;
+ int maxWeight = (255 / NSVG__SUBSAMPLES); // weight per vertical scanline
+ int xmin, xmax;
+
+ for (y = 0; y < r->height; y++) {
+ memset(r->scanline, 0, r->width);
+ xmin = r->width;
+ xmax = 0;
+ for (s = 0; s < NSVG__SUBSAMPLES; ++s) {
+ // find center of pixel for this scanline
+ float scany = (float)(y*NSVG__SUBSAMPLES + s) + 0.5f;
+ NSVGactiveEdge **step = &active;
+
+ // update all active edges;
+ // remove all active edges that terminate before the center of this scanline
+ while (*step) {
+ NSVGactiveEdge *z = *step;
+ if (z->ey <= scany) {
+ *step = z->next; // delete from list
+// NSVG__assert(z->valid);
+ nsvg__freeActive(r, z);
+ } else {
+ z->x += z->dx; // advance to position for current scanline
+ step = &((*step)->next); // advance through list
+ }
+ }
+
+ // resort the list if needed
+ for (;;) {
+ int changed = 0;
+ step = &active;
+ while (*step && (*step)->next) {
+ if ((*step)->x > (*step)->next->x) {
+ NSVGactiveEdge* t = *step;
+ NSVGactiveEdge* q = t->next;
+ t->next = q->next;
+ q->next = t;
+ *step = q;
+ changed = 1;
+ }
+ step = &(*step)->next;
+ }
+ if (!changed) break;
+ }
+
+ // insert all edges that start before the center of this scanline -- omit ones that also end on this scanline
+ while (e < r->nedges && r->edges[e].y0 <= scany) {
+ if (r->edges[e].y1 > scany) {
+ NSVGactiveEdge* z = nsvg__addActive(r, &r->edges[e], scany);
+ if (z == NULL) break;
+ // find insertion point
+ if (active == NULL) {
+ active = z;
+ } else if (z->x < active->x) {
+ // insert at front
+ z->next = active;
+ active = z;
+ } else {
+ // find thing to insert AFTER
+ NSVGactiveEdge* p = active;
+ while (p->next && p->next->x < z->x)
+ p = p->next;
+ // at this point, p->next->x is NOT < z->x
+ z->next = p->next;
+ p->next = z;
+ }
+ }
+ e++;
+ }
+
+ // now process all active edges in non-zero fashion
+ if (active != NULL)
+ nsvg__fillActiveEdges(r->scanline, r->width, active, maxWeight, &xmin, &xmax, fillRule);
+ }
+ // Blit
+ if (xmin < 0) xmin = 0;
+ if (xmax > r->width-1) xmax = r->width-1;
+ if (xmin <= xmax) {
+ nsvg__scanlineSolid(&r->bitmap[y * r->stride] + xmin*4, xmax-xmin+1, &r->scanline[xmin], xmin, y, tx,ty, scale, cache);
+ }
+ }
+
+}
+
+static void nsvg__unpremultiplyAlpha(unsigned char* image, int w, int h, int stride)
+{
+ int x,y;
+
+ // Unpremultiply
+ for (y = 0; y < h; y++) {
+ unsigned char *row = &image[y*stride];
+ for (x = 0; x < w; x++) {
+ int r = row[0], g = row[1], b = row[2], a = row[3];
+ if (a != 0) {
+ row[0] = (unsigned char)(r*255/a);
+ row[1] = (unsigned char)(g*255/a);
+ row[2] = (unsigned char)(b*255/a);
+ }
+ row += 4;
+ }
+ }
+
+ // Defringe
+ for (y = 0; y < h; y++) {
+ unsigned char *row = &image[y*stride];
+ for (x = 0; x < w; x++) {
+ int r = 0, g = 0, b = 0, a = row[3], n = 0;
+ if (a == 0) {
+ if (x-1 > 0 && row[-1] != 0) {
+ r += row[-4];
+ g += row[-3];
+ b += row[-2];
+ n++;
+ }
+ if (x+1 < w && row[7] != 0) {
+ r += row[4];
+ g += row[5];
+ b += row[6];
+ n++;
+ }
+ if (y-1 > 0 && row[-stride+3] != 0) {
+ r += row[-stride];
+ g += row[-stride+1];
+ b += row[-stride+2];
+ n++;
+ }
+ if (y+1 < h && row[stride+3] != 0) {
+ r += row[stride];
+ g += row[stride+1];
+ b += row[stride+2];
+ n++;
+ }
+ if (n > 0) {
+ row[0] = (unsigned char)(r/n);
+ row[1] = (unsigned char)(g/n);
+ row[2] = (unsigned char)(b/n);
+ }
+ }
+ row += 4;
+ }
+ }
+}
+
+
+static void nsvg__initPaint(NSVGcachedPaint* cache, NSVGpaint* paint, float opacity)
+{
+ int i, j;
+ NSVGgradient* grad;
+
+ cache->type = paint->type;
+
+ if (paint->type == NSVG_PAINT_COLOR) {
+ cache->colors[0] = nsvg__applyOpacity(paint->color, opacity);
+ return;
+ }
+
+ grad = paint->gradient;
+
+ cache->spread = grad->spread;
+ memcpy(cache->xform, grad->xform, sizeof(float)*6);
+
+ if (grad->nstops == 0) {
+ for (i = 0; i < 256; i++)
+ cache->colors[i] = 0;
+ } if (grad->nstops == 1) {
+ for (i = 0; i < 256; i++)
+ cache->colors[i] = nsvg__applyOpacity(grad->stops[i].color, opacity);
+ } else {
+ unsigned int ca, cb = 0;
+ float ua, ub, du, u;
+ int ia, ib, count;
+
+ ca = nsvg__applyOpacity(grad->stops[0].color, opacity);
+ ua = nsvg__clampf(grad->stops[0].offset, 0, 1);
+ ub = nsvg__clampf(grad->stops[grad->nstops-1].offset, ua, 1);
+ ia = (int)(ua * 255.0f);
+ ib = (int)(ub * 255.0f);
+ for (i = 0; i < ia; i++) {
+ cache->colors[i] = ca;
+ }
+
+ for (i = 0; i < grad->nstops-1; i++) {
+ ca = nsvg__applyOpacity(grad->stops[i].color, opacity);
+ cb = nsvg__applyOpacity(grad->stops[i+1].color, opacity);
+ ua = nsvg__clampf(grad->stops[i].offset, 0, 1);
+ ub = nsvg__clampf(grad->stops[i+1].offset, 0, 1);
+ ia = (int)(ua * 255.0f);
+ ib = (int)(ub * 255.0f);
+ count = ib - ia;
+ if (count <= 0) continue;
+ u = 0;
+ du = 1.0f / (float)count;
+ for (j = 0; j < count; j++) {
+ cache->colors[ia+j] = nsvg__lerpRGBA(ca,cb,u);
+ u += du;
+ }
+ }
+
+ for (i = ib; i < 256; i++)
+ cache->colors[i] = cb;
+ }
+
+}
+
+/*
+static void dumpEdges(NSVGrasterizer* r, const char* name)
+{
+ float xmin = 0, xmax = 0, ymin = 0, ymax = 0;
+ NSVGedge *e = NULL;
+ int i;
+ if (r->nedges == 0) return;
+ FILE* fp = fopen(name, "w");
+ if (fp == NULL) return;
+
+ xmin = xmax = r->edges[0].x0;
+ ymin = ymax = r->edges[0].y0;
+ for (i = 0; i < r->nedges; i++) {
+ e = &r->edges[i];
+ xmin = nsvg__minf(xmin, e->x0);
+ xmin = nsvg__minf(xmin, e->x1);
+ xmax = nsvg__maxf(xmax, e->x0);
+ xmax = nsvg__maxf(xmax, e->x1);
+ ymin = nsvg__minf(ymin, e->y0);
+ ymin = nsvg__minf(ymin, e->y1);
+ ymax = nsvg__maxf(ymax, e->y0);
+ ymax = nsvg__maxf(ymax, e->y1);
+ }
+
+ fprintf(fp, "<svg viewBox=\"%f %f %f %f\" xmlns=\"http://www.w3.org/2000/svg\">", xmin, ymin, (xmax - xmin), (ymax - ymin));
+
+ for (i = 0; i < r->nedges; i++) {
+ e = &r->edges[i];
+ fprintf(fp ,"<line x1=\"%f\" y1=\"%f\" x2=\"%f\" y2=\"%f\" style=\"stroke:#000;\" />", e->x0,e->y0, e->x1,e->y1);
+ }
+
+ for (i = 0; i < r->npoints; i++) {
+ if (i+1 < r->npoints)
+ fprintf(fp ,"<line x1=\"%f\" y1=\"%f\" x2=\"%f\" y2=\"%f\" style=\"stroke:#f00;\" />", r->points[i].x, r->points[i].y, r->points[i+1].x, r->points[i+1].y);
+ fprintf(fp ,"<circle cx=\"%f\" cy=\"%f\" r=\"1\" style=\"fill:%s;\" />", r->points[i].x, r->points[i].y, r->points[i].flags == 0 ? "#f00" : "#0f0");
+ }
+
+ fprintf(fp, "</svg>");
+ fclose(fp);
+}
+*/
+
+NANOSVG_SCOPE
+void nsvgRasterize(NSVGrasterizer* r,
+ NSVGimage* image, float tx, float ty, float scale,
+ unsigned char* dst, int w, int h, int stride)
+{
+ NSVGshape *shape = NULL;
+ NSVGedge *e = NULL;
+ NSVGcachedPaint cache;
+ int i;
+
+ r->bitmap = dst;
+ r->width = w;
+ r->height = h;
+ r->stride = stride;
+
+ if (w > r->cscanline) {
+ r->cscanline = w;
+ r->scanline = (unsigned char*)NANOSVG_realloc(r->scanline, w);
+ if (r->scanline == NULL) return;
+ }
+
+ for (i = 0; i < h; i++)
+ memset(&dst[i*stride], 0, w*4);
+
+ for (shape = image->shapes; shape != NULL; shape = shape->next) {
+ if (!(shape->flags & NSVG_FLAGS_VISIBLE))
+ continue;
+
+ if (shape->fill.type != NSVG_PAINT_NONE) {
+ nsvg__resetPool(r);
+ r->freelist = NULL;
+ r->nedges = 0;
+
+ nsvg__flattenShape(r, shape, scale);
+
+ // Scale and translate edges
+ for (i = 0; i < r->nedges; i++) {
+ e = &r->edges[i];
+ e->x0 = tx + e->x0;
+ e->y0 = (ty + e->y0) * NSVG__SUBSAMPLES;
+ e->x1 = tx + e->x1;
+ e->y1 = (ty + e->y1) * NSVG__SUBSAMPLES;
+ }
+
+ // Rasterize edges
+ qsort(r->edges, r->nedges, sizeof(NSVGedge), nsvg__cmpEdge);
+
+ // now, traverse the scanlines and find the intersections on each scanline, use non-zero rule
+ nsvg__initPaint(&cache, &shape->fill, shape->opacity);
+
+ nsvg__rasterizeSortedEdges(r, tx,ty,scale, &cache, shape->fillRule);
+ }
+ if (shape->stroke.type != NSVG_PAINT_NONE && (shape->strokeWidth * scale) > 0.01f) {
+ nsvg__resetPool(r);
+ r->freelist = NULL;
+ r->nedges = 0;
+
+ nsvg__flattenShapeStroke(r, shape, scale);
+
+// dumpEdges(r, "edge.svg");
+
+ // Scale and translate edges
+ for (i = 0; i < r->nedges; i++) {
+ e = &r->edges[i];
+ e->x0 = tx + e->x0;
+ e->y0 = (ty + e->y0) * NSVG__SUBSAMPLES;
+ e->x1 = tx + e->x1;
+ e->y1 = (ty + e->y1) * NSVG__SUBSAMPLES;
+ }
+
+ // Rasterize edges
+ qsort(r->edges, r->nedges, sizeof(NSVGedge), nsvg__cmpEdge);
+
+ // now, traverse the scanlines and find the intersections on each scanline, use non-zero rule
+ nsvg__initPaint(&cache, &shape->stroke, shape->opacity);
+
+ nsvg__rasterizeSortedEdges(r, tx,ty,scale, &cache, NSVG_FILLRULE_NONZERO);
+ }
+ }
+
+ nsvg__unpremultiplyAlpha(dst, w, h, stride);
+
+ r->bitmap = NULL;
+ r->width = 0;
+ r->height = 0;
+ r->stride = 0;
+}
+
+#endif
diff --git a/generic/tk.decls b/generic/tk.decls
index e891dbb..4a4f01d 100644
--- a/generic/tk.decls
+++ b/generic/tk.decls
@@ -105,7 +105,7 @@ declare 18 {
Tk_Window tkwin, const char *value, char *widgRec, int offset)
}
declare 19 {
- CONST86 char *Tk_CanvasTagsPrintProc(ClientData clientData, Tk_Window tkwin,
+ const char *Tk_CanvasTagsPrintProc(ClientData clientData, Tk_Window tkwin,
char *widgRec, int offset, Tcl_FreeProc **freeProcPtr)
}
declare 20 {
@@ -146,7 +146,7 @@ declare 28 {
declare 29 {
int Tk_ConfigureWidget(Tcl_Interp *interp,
Tk_Window tkwin, const Tk_ConfigSpec *specs,
- int argc, CONST84 char **argv, char *widgRec,
+ int argc, const char **argv, char *widgRec,
int flags)
}
declare 30 {
@@ -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)
@@ -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 {
@@ -348,10 +348,10 @@ declare 82 {
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,
+ const char *Tk_GetBinding(Tcl_Interp *interp,
Tk_BindingTable bindingTable, ClientData object,
const char *eventStr)
}
@@ -403,8 +403,8 @@ declare 97 {
Tk_ImageChangedProc *changeProc, ClientData clientData)
}
declare 98 {
- ClientData Tk_GetImageMasterData(Tcl_Interp *interp,
- const char *name, CONST86 Tk_ImageType **typePtrPtr)
+ ClientData 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)
+ int argc, const char **argv, double *dblPtr, int *intPtr)
}
declare 109 {
int Tk_GetScreenMM(Tcl_Interp *interp,
@@ -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 {
@@ -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,
@@ -561,15 +561,15 @@ declare 142 {
}
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 {
@@ -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 {
@@ -802,10 +802,10 @@ declare 210 {
int 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 {
+declare 212 {nostub {Don't use this function in a stub-enabled extension}} {
void Tk_MainEx(int argc, char **argv, Tcl_AppInitProc *appInitProc,
Tcl_Interp *interp)
}
@@ -813,7 +813,7 @@ declare 213 {
void Tk_RestoreSavedOptions(Tk_SavedOptions *savePtr)
}
declare 214 {
- int Tk_SetOptions(Tcl_Interp *interp, char *recordPtr,
+ int Tk_SetOptions(Tcl_Interp *interp, void *recordPtr,
Tk_OptionTable optionTable, int objc,
Tcl_Obj *const objv[], Tk_Window tkwin,
Tk_SavedOptions *savePtr, int *maskPtr)
@@ -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,
@@ -1001,22 +1001,22 @@ declare 260 {
}
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,8 +1068,27 @@ declare 272 {
declare 273 {
void Tk_CreateOldPhotoImageFormat(const Tk_PhotoImageFormat *formatPtr)
}
-declare 280 {
- void TkUnusedStubEntry(void)
+
+# 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)
}
# Define the platform specific public Tk interface. These functions are
@@ -1102,37 +1121,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 +1159,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)
}
@@ -1165,6 +1171,14 @@ export {
const char *Tk_PkgInitStubsCheck(Tcl_Interp *interp, const char *version,
int exact)
}
+export {
+ void Tk_MainEx(int argc, char **argv, Tcl_AppInitProc *appInitProc,
+ Tcl_Interp *interp)
+}
+export {
+ void Tk_MainExW(int argc, wchar_t **argv,
+ Tcl_AppInitProc *appInitProc, Tcl_Interp *interp);
+}
# Local Variables:
# mode: tcl
diff --git a/generic/tk.h b/generic/tk.h
index 50195b9..0c7c69f 100644
--- a/generic/tk.h
+++ b/generic/tk.h
@@ -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)
@@ -73,12 +66,12 @@ extern "C" {
*/
#define TK_MAJOR_VERSION 8
-#define TK_MINOR_VERSION 6
-#define TK_RELEASE_LEVEL TCL_FINAL_RELEASE
-#define TK_RELEASE_SERIAL 10
+#define TK_MINOR_VERSION 7
+#define TK_RELEASE_LEVEL TCL_ALPHA_RELEASE
+#define TK_RELEASE_SERIAL 4
-#define TK_VERSION "8.6"
-#define TK_PATCH_LEVEL "8.6.10"
+#define TK_VERSION "8.7"
+#define TK_PATCH_LEVEL "8.7a4"
/*
* A special definition used to allow this header file to be included from
@@ -93,6 +86,9 @@ extern "C" {
#ifndef RC_INVOKED
#if !defined(_XLIB_H) && !defined(_X11_XLIB_H_)
+#if defined(__GNUC__) && !defined(__cplusplus)
+# pragma GCC diagnostic ignored "-Wc++-compat"
+#endif
# include <X11/Xlib.h>
# ifdef MAC_OSX_TK
# include <X11/X.h>
@@ -106,6 +102,10 @@ extern "C" {
#ifdef BUILD_tk
#undef TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS DLLEXPORT
+#else
+# ifndef TCL_STORAGE_CLASS
+# define TCL_STORAGE_CLASS DLLIMPORT
+# endif
#endif
/*
@@ -114,7 +114,7 @@ extern "C" {
* Decide whether or not to use input methods.
*/
-#ifdef XNQueryInputStyle
+#if defined(XNQueryInputStyle) && !defined(_WIN32) && !defined(MAC_OSX_TK)
#define TK_USE_INPUT_METHODS
#endif
@@ -122,14 +122,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;
@@ -192,20 +192,25 @@ 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
+#if TCL_MAJOR_VERSION > 8
+ size_t objOffset; /* Where in record to store a Tcl_Obj * that
* holds the value of this option, specified
* as an offset in bytes from the start of the
- * record. Use the Tk_Offset macro to generate
- * values for this. -1 means don't store the
- * Tcl_Obj in the record. */
- 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. */
+ size_t internalOffset; /* Where in record to store the internal
* representation of the value of this option,
* such as an int or XColor *. This field is
* specified as an offset in bytes from the
- * start of the record. Use the Tk_Offset
- * macro to generate values for it. -1 means
- * don't store the internal representation in
- * the record. */
+ * start of the record. Use the offsetof
+ * macro to generate values for it.
+ * TCL_INDEX_NONE means don't store the
+ * internal representation in the record. */
+#else
+ int objOffset;
+ int internalOffset;
+#endif
int flags; /* Any combination of the values defined
* below. */
const void *clientData; /* An alternate place to put option-specific
@@ -234,11 +239,19 @@ typedef struct Tk_OptionSpec {
* option config code to handle a custom option.
*/
+#if TCL_MAJOR_VERSION > 8
+typedef int (Tk_CustomOptionSetProc) (ClientData clientData,
+ Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj **value, char *widgRec,
+ size_t offset, char *saveInternalPtr, int flags);
+typedef Tcl_Obj *(Tk_CustomOptionGetProc) (ClientData clientData,
+ Tk_Window tkwin, char *widgRec, size_t offset);
+#else
typedef int (Tk_CustomOptionSetProc) (ClientData 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);
+#endif
typedef void (Tk_CustomOptionRestoreProc) (ClientData clientData,
Tk_Window tkwin, char *internalPtr, char *saveInternalPtr);
typedef void (Tk_CustomOptionFreeProc) (ClientData clientData, Tk_Window tkwin,
@@ -268,7 +281,9 @@ 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))
+#ifndef TK_NO_DEPRECATED
+# define Tk_Offset(type, field) ((int) offsetof(type, field))
+#endif
/* Workaround for platforms missing offsetof(), e.g. VC++ 6.0 */
#ifndef offsetof
# define offsetof(type, field) ((size_t) ((char *) &((type *) 0)->field))
@@ -292,7 +307,7 @@ typedef struct Tk_SavedOption {
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
@@ -308,11 +323,15 @@ 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. */
+#if TCL_MAJOR_VERSION > 8
+ size_t numItems; /* The number of valid items in items field. */
+#else
+ int numItems;
+#endif
Tk_SavedOption items[TK_NUM_SAVED_OPTIONS];
/* Items used to hold old values. */
struct Tk_SavedOptions *nextPtr;
@@ -336,10 +355,17 @@ typedef struct Tk_SavedOptions {
#ifndef __NO_OLD_CONFIG
+#if TCL_MAJOR_VERSION > 8
+typedef int (Tk_OptionParseProc) (ClientData clientData, Tcl_Interp *interp,
+ Tk_Window tkwin, const char *value, char *widgRec, size_t offset);
+typedef const char *(Tk_OptionPrintProc) (ClientData clientData,
+ Tk_Window tkwin, char *widgRec, size_t offset, Tcl_FreeProc **freeProcPtr);
+#else
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, const char *value, char *widgRec, int offset);
+typedef const char *(Tk_OptionPrintProc) (ClientData clientData,
Tk_Window tkwin, char *widgRec, int offset, Tcl_FreeProc **freeProcPtr);
+#endif
typedef struct Tk_CustomOption {
Tk_OptionParseProc *parseProc;
@@ -364,19 +390,23 @@ 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
+#if TCL_MAJOR_VERSION > 8
+ size_t offset; /* Where in widget record to store value; use
+ * offsetof macro to generate values for
* this. */
+#else
+ int offset;
+#endif
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
@@ -416,7 +446,9 @@ typedef enum {
#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 */
#define TK_CONFIG_USER_BIT 0x100
#endif /* __NO_OLD_CONFIG */
@@ -425,14 +457,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;
@@ -577,7 +609,11 @@ typedef void (Tk_ClassWorldChangedProc) (ClientData instanceData);
typedef void (Tk_ClassModalProc) (Tk_Window tkwin, XEvent *eventPtr);
typedef struct Tk_ClassProcs {
+#if TCL_MAJOR_VERSION > 8
+ size_t size;
+#else
unsigned int size;
+#endif
Tk_ClassWorldChangedProc *worldChangedProc;
/* Procedure to invoke when the widget needs
* to respond in some way to a change in the
@@ -602,12 +638,12 @@ typedef struct Tk_ClassProcs {
*
* #define Tk_GetField(name, who, which) \
* (((who) == NULL) ? NULL :
- * (((who)->size <= Tk_Offset(name, which)) ? NULL :(name)->which))
+ * (((who)->size <= offsetof(name, which)) ? NULL :(name)->which))
*/
#define Tk_GetClassProc(procs, which) \
(((procs) == NULL) ? NULL : \
- (((procs)->size <= Tk_Offset(Tk_ClassProcs, which)) ? NULL:(procs)->which))
+ (((procs)->size <= offsetof(Tk_ClassProcs, which)) ? NULL:(procs)->which))
/*
* Each geometry manager (the packer, the placer, etc.) is represented by a
@@ -615,7 +651,7 @@ typedef struct Tk_ClassProcs {
* the geometry manager to carry out certain functions.
*/
-#define Tk_GeomLostContentProc Tk_GeomLostSlaveProc
+#define Tk_GeomLostSlaveProc Tk_GeomLostContentProc
typedef void (Tk_GeomRequestProc) (ClientData clientData, Tk_Window tkwin);
typedef void (Tk_GeomLostContentProc) (ClientData clientData, Tk_Window tkwin);
@@ -626,7 +662,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
@@ -749,9 +785,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) \
@@ -796,7 +833,7 @@ typedef struct Tk_FakeWin {
unsigned long dummy7; /* dirtyAtts */
unsigned int flags;
char *dummy8; /* handlerList */
-#ifdef TK_USE_INPUT_METHODS
+#if defined(TK_USE_INPUT_METHODS) || (TCL_MAJOR_VERSION > 8)
XIC dummy9; /* inputContext */
#endif /* TK_USE_INPUT_METHODS */
ClientData *dummy10; /* tagPtr */
@@ -816,11 +853,15 @@ typedef struct Tk_FakeWin {
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;
/*
@@ -928,7 +969,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,
@@ -944,8 +985,12 @@ typedef struct Tk_SmoothMethod {
#define TK_TAG_SPACE 3
typedef struct Tk_Item {
- int id; /* Unique identifier for this item (also
+#if TCL_MAJOR_VERSION > 8
+ size_t id; /* Unique identifier for this item (also
* serves as first tag for item). */
+#else
+ int id;
+#endif
struct Tk_Item *nextPtr; /* Next in display list of all items in this
* canvas. Later items in list are drawn on
* top of earlier ones. */
@@ -954,10 +999,14 @@ 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
+#if TCL_MAJOR_VERSION > 8
+ size_t tagSpace; /* Total amount of tag space available at
* tagPtr. */
- int numTags; /* Number of tag slots actually used at
+ size_t numTags; /* Number of tag slots actually used at
* *tagPtr. */
+#else
+ int tagSpace, numTags;
+#endif
struct Tk_ItemType *typePtr;/* Table of procedures that implement this
* type of item. */
int x1, y1, x2, y2; /* Bounding box for item, in integer canvas
@@ -1000,13 +1049,17 @@ 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);
typedef int (Tk_ItemConfigureProc)(Tcl_Interp *interp, Tk_Canvas canvas,
Tk_Item *itemPtr, int argc, char **argv, int flags);
typedef int (Tk_ItemCoordProc)(Tcl_Interp *interp, Tk_Canvas canvas,
Tk_Item *itemPtr, int 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 argc, Tcl_Obj *const objv[]);
@@ -1015,6 +1068,17 @@ typedef int (Tk_ItemConfigureProc)(Tcl_Interp *interp, Tk_Canvas canvas,
int flags);
typedef int (Tk_ItemCoordProc)(Tcl_Interp *interp, Tk_Canvas canvas,
Tk_Item *itemPtr, int argc, Tcl_Obj *const argv[]);
+#if TCL_MAJOR_VERSION > 8
+typedef void (Tk_ItemInsertProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
+ size_t beforeThis, Tcl_Obj *string);
+typedef int (Tk_ItemIndexProc)(Tcl_Interp *interp, Tk_Canvas canvas,
+ Tk_Item *itemPtr, Tcl_Obj *indexString, size_t *indexPtr);
+#else
+typedef void (Tk_ItemInsertProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
+ int beforeThis, Tcl_Obj *string);
+typedef int (Tk_ItemIndexProc)(Tcl_Interp *interp, Tk_Canvas canvas,
+ Tk_Item *itemPtr, Tcl_Obj *indexString, int *indexPtr);
+#endif
#endif /* USE_OLD_CANVAS */
typedef void (Tk_ItemDeleteProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
Display *display);
@@ -1027,43 +1091,44 @@ 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);
+#if TCL_MAJOR_VERSION > 8
+typedef void (Tk_ItemCursorProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
+ size_t index);
+typedef size_t (Tk_ItemSelectionProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
+ size_t offset, char *buffer, size_t maxBytes);
+typedef void (Tk_ItemDCharsProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
+ size_t first, size_t last);
#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 */
typedef void (Tk_ItemDCharsProc)(Tk_Canvas canvas, Tk_Item *itemPtr,
int first, int last);
+#endif
#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
+#if TCL_MAJOR_VERSION > 8
+ size_t itemSize; /* Total amount of space needed for item's
* record. */
+#else
+ int itemSize;
+#endif
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;
@@ -1106,7 +1171,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;
@@ -1139,17 +1206,25 @@ 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
+#if TCL_MAJOR_VERSION > 8
+ size_t selectFirst; /* Character index of first selected
* character. Writable by items. */
- int selectLast; /* Character index of last selected character.
+ size_t selectLast; /* Character index of last selected character.
* Writable by items. */
+#else
+ int selectFirst, selectLast;
+#endif
Tk_Item *anchorItemPtr; /* Item corresponding to "selectAnchor": not
* necessarily selItemPtr. Read-only to
* items. */
- int selectAnchor; /* Character index of fixed end of selection
+#if TCL_MAJOR_VERSION > 8
+ size_t 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. */
+#else
+ int selectAnchor;
+#endif
Tk_3DBorder insertBorder; /* Used to draw vertical bar for insertion
* cursor. Read-only to items. */
int insertWidth; /* Total width of insertion cursor. Read-only
@@ -1228,13 +1303,13 @@ typedef struct Tk_Outline {
*/
typedef struct Tk_ImageType Tk_ImageType;
-#ifdef USE_OLD_IMAGE
+#if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9 && defined(USE_OLD_IMAGE)
typedef int (Tk_ImageCreateProc) (Tcl_Interp *interp, char *name, int argc,
- char **argv, Tk_ImageType *typePtr, Tk_ImageMaster model,
+ char **argv, Tk_ImageType *typePtr, Tk_ImageModel model,
ClientData *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,
+typedef int (Tk_ImageCreateProc) (Tcl_Interp *interp, const char *name, int objc,
+ Tcl_Obj *const objv[], const Tk_ImageType *typePtr, Tk_ImageModel model,
ClientData *clientDataPtr);
#endif /* USE_OLD_IMAGE */
typedef ClientData (Tk_ImageGetProc) (Tk_Window tkwin, ClientData clientData);
@@ -1258,7 +1333,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. */
@@ -1370,7 +1445,7 @@ typedef int (Tk_ImageStringWriteProc) (Tcl_Interp *interp, Tcl_Obj *format,
*/
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. */
@@ -1474,6 +1549,7 @@ typedef struct Tk_ElementSpec {
*----------------------------------------------------------------------
*/
+#if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
#define TK_READABLE TCL_READABLE
#define TK_WRITABLE TCL_WRITABLE
#define TK_EXCEPTION TCL_EXCEPTION
@@ -1507,6 +1583,7 @@ typedef struct Tk_ElementSpec {
#define Tk_FreeProc Tcl_FreeProc
#define Tk_Preserve Tcl_Preserve
#define Tk_Release Tcl_Release
+#endif
/* Removed Tk_Main, use macro instead */
#if defined(_WIN32) || defined(__CYGWIN__)
@@ -1541,12 +1618,17 @@ typedef void (Tk_EventProc) (ClientData clientData, XEvent *eventPtr);
typedef int (Tk_GenericProc) (ClientData clientData, XEvent *eventPtr);
typedef int (Tk_ClientMessageProc) (Tk_Window tkwin, XEvent *eventPtr);
typedef int (Tk_GetSelProc) (ClientData clientData, Tcl_Interp *interp,
- CONST86 char *portion);
+ const char *portion);
typedef void (Tk_LostSelProc) (ClientData clientData);
typedef Tk_RestrictAction (Tk_RestrictProc) (ClientData clientData,
XEvent *eventPtr);
+#if TCL_MAJOR_VERSION > 8
+typedef size_t (Tk_SelectionProc) (ClientData clientData, size_t offset,
+ char *buffer, size_t maxBytes);
+#else
typedef int (Tk_SelectionProc) (ClientData clientData, int offset,
char *buffer, int maxBytes);
+#endif
/*
*----------------------------------------------------------------------
@@ -1569,12 +1651,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
@@ -1607,6 +1690,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 987bace..155f6ae 100644
--- a/generic/tk3d.c
+++ b/generic/tk3d.c
@@ -90,7 +90,7 @@ Tk_Alloc3DBorderFromObj(
if (objPtr->typePtr != &tkBorderObjType) {
InitBorderObj(objPtr);
}
- borderPtr = objPtr->internalRep.twoPtrValue.ptr1;
+ borderPtr = (TkBorder *)objPtr->internalRep.twoPtrValue.ptr1;
/*
* If the object currently points to a TkBorder, see if it's the one we
@@ -127,7 +127,7 @@ Tk_Alloc3DBorderFromObj(
*/
if (borderPtr != NULL) {
- TkBorder *firstBorderPtr = Tcl_GetHashValue(borderPtr->hashPtr);
+ TkBorder *firstBorderPtr = (TkBorder *)Tcl_GetHashValue(borderPtr->hashPtr);
FreeBorderObj(objPtr);
for (borderPtr = firstBorderPtr ; borderPtr != NULL;
@@ -200,7 +200,7 @@ Tk_Get3DBorder(
hashPtr = Tcl_CreateHashEntry(&dispPtr->borderTable, colorName, &isNew);
if (!isNew) {
- existingBorderPtr = Tcl_GetHashValue(hashPtr);
+ existingBorderPtr = (TkBorder *)Tcl_GetHashValue(hashPtr);
for (borderPtr = existingBorderPtr; borderPtr != NULL;
borderPtr = borderPtr->nextPtr) {
if ((Tk_Screen(tkwin) == borderPtr->screen)
@@ -420,12 +420,11 @@ Tk_Free3DBorder(
Display *display = DisplayOfScreen(borderPtr->screen);
TkBorder *prevPtr;
- borderPtr->resourceRefCount--;
- if (borderPtr->resourceRefCount > 0) {
+ if (borderPtr->resourceRefCount-- > 1) {
return;
}
- prevPtr = Tcl_GetHashValue(borderPtr->hashPtr);
+ prevPtr = (TkBorder *)Tcl_GetHashValue(borderPtr->hashPtr);
TkpFreeBorder(borderPtr);
if (borderPtr->bgColorPtr != NULL) {
Tk_FreeColor(borderPtr->bgColorPtr);
@@ -527,7 +526,7 @@ static void
FreeBorderObj(
Tcl_Obj *objPtr) /* The object we are releasing. */
{
- TkBorder *borderPtr = objPtr->internalRep.twoPtrValue.ptr1;
+ TkBorder *borderPtr = (TkBorder *)objPtr->internalRep.twoPtrValue.ptr1;
if (borderPtr != NULL) {
borderPtr->objRefCount--;
@@ -562,7 +561,7 @@ DupBorderObjProc(
Tcl_Obj *srcObjPtr, /* The object we are copying from. */
Tcl_Obj *dupObjPtr) /* The object we are copying to. */
{
- TkBorder *borderPtr = srcObjPtr->internalRep.twoPtrValue.ptr1;
+ TkBorder *borderPtr = (TkBorder *)srcObjPtr->internalRep.twoPtrValue.ptr1;
dupObjPtr->typePtr = srcObjPtr->typePtr;
dupObjPtr->internalRep.twoPtrValue.ptr1 = borderPtr;
@@ -594,7 +593,7 @@ Tk_SetBackgroundFromBorder(
Tk_Window tkwin, /* Window whose background is to be set. */
Tk_3DBorder border) /* Token for border. */
{
- register TkBorder *borderPtr = (TkBorder *) border;
+ TkBorder *borderPtr = (TkBorder *) border;
Tk_SetWindowBackground(tkwin, borderPtr->bgColorPtr->pixel);
}
@@ -759,7 +758,7 @@ Tk_Draw3DPolygon(
{
XPoint poly[4], b1, b2, newB1, newB2;
XPoint perp, c, shift1, shift2; /* Used for handling parallel lines. */
- register XPoint *p1Ptr, *p2Ptr;
+ XPoint *p1Ptr, *p2Ptr;
TkBorder *borderPtr = (TkBorder *) border;
GC gc;
int i, lightOnLeft, dx, dy, parallel, pointsSeen;
@@ -956,7 +955,7 @@ Tk_Fill3DRectangle(
int relief) /* Indicates 3D effect: TK_RELIEF_FLAT,
* TK_RELIEF_RAISED, or TK_RELIEF_SUNKEN. */
{
- register TkBorder *borderPtr = (TkBorder *) border;
+ TkBorder *borderPtr = (TkBorder *) border;
int doubleBorder;
/*
@@ -1027,7 +1026,7 @@ Tk_Fill3DPolygon(
* TK_RELIEF_FLAT, TK_RELIEF_RAISED, or
* TK_RELIEF_SUNKEN. */
{
- register TkBorder *borderPtr = (TkBorder *) border;
+ TkBorder *borderPtr = (TkBorder *) border;
XFillPolygon(Tk_Display(tkwin), drawable, borderPtr->bgGC,
pointPtr, numPoints, Complex, CoordModeOrigin);
@@ -1253,7 +1252,7 @@ Tk_Get3DBorderFromObj(
* cached in the internal representation of the Tcl_Obj. Check it out...
*/
- borderPtr = objPtr->internalRep.twoPtrValue.ptr1;
+ borderPtr = (TkBorder *)objPtr->internalRep.twoPtrValue.ptr1;
if ((borderPtr != NULL)
&& (borderPtr->resourceRefCount > 0)
&& (Tk_Screen(tkwin) == borderPtr->screen)
@@ -1281,7 +1280,7 @@ Tk_Get3DBorderFromObj(
if (hashPtr == NULL) {
goto error;
}
- for (borderPtr = Tcl_GetHashValue(hashPtr); borderPtr != NULL;
+ for (borderPtr = (TkBorder *)Tcl_GetHashValue(hashPtr); borderPtr != NULL;
borderPtr = borderPtr->nextPtr) {
if ((Tk_Screen(tkwin) == borderPtr->screen)
&& (Tk_Colormap(tkwin) == borderPtr->colormap)) {
@@ -1371,7 +1370,7 @@ TkDebugBorder(
resultPtr = Tcl_NewObj();
hashPtr = Tcl_FindHashEntry(&dispPtr->borderTable, name);
if (hashPtr != NULL) {
- TkBorder *borderPtr = Tcl_GetHashValue(hashPtr);
+ TkBorder *borderPtr = (TkBorder *)Tcl_GetHashValue(hashPtr);
if (borderPtr == NULL) {
Tcl_Panic("TkDebugBorder found empty hash table entry");
@@ -1380,9 +1379,9 @@ 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);
}
}
diff --git a/generic/tk3d.h b/generic/tk3d.h
index ec7f7c7..d36b95e 100644
--- a/generic/tk3d.h
+++ b/generic/tk3d.h
@@ -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
+ TkSizeT 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
+ TkSizeT 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 6c2c5c5..81e7a44 100644
--- a/generic/tkArgv.c
+++ b/generic/tkArgv.c
@@ -67,12 +67,12 @@ Tk_ParseArgv(
int flags) /* Or'ed combination of various flag bits,
* such as TK_ARGV_NO_DEFAULTS. */
{
- register const Tk_ArgvInfo *infoPtr;
+ const Tk_ArgvInfo *infoPtr;
/* Pointer to the current entry in the table
* of argument descriptions. */
const Tk_ArgvInfo *matchPtr;/* Descriptor that matches current argument. */
const char *curArg; /* Current argument */
- register char c; /* Second character of current arg (used for
+ char c; /* Second character of current arg (used for
* quick check for matching; use 2nd char.
* because first char. will almost always be
* '-'). */
@@ -228,9 +228,9 @@ Tk_ParseArgv(
break;
case TK_ARGV_FUNC: {
typedef int (ArgvFunc)(char *, const char *, const char *);
- ArgvFunc *handlerProc = (ArgvFunc *) infoPtr->src;
+ ArgvFunc *handlerProc = (ArgvFunc *)infoPtr->src;
- if (handlerProc(infoPtr->dst, infoPtr->key, argv[srcIndex])) {
+ if (handlerProc((char *)infoPtr->dst, infoPtr->key, argv[srcIndex])) {
srcIndex++;
argc--;
}
@@ -239,9 +239,9 @@ Tk_ParseArgv(
case TK_ARGV_GENFUNC: {
typedef int (ArgvGenFunc)(char *, Tcl_Interp *, const char *, int,
const char **);
- ArgvGenFunc *handlerProc = (ArgvGenFunc *) infoPtr->src;
+ ArgvGenFunc *handlerProc = (ArgvGenFunc *)infoPtr->src;
- argc = handlerProc(infoPtr->dst, interp, infoPtr->key, argc,
+ argc = handlerProc((char *)infoPtr->dst, interp, infoPtr->key, argc,
argv+srcIndex);
if (argc < 0) {
return TCL_ERROR;
@@ -253,14 +253,14 @@ Tk_ParseArgv(
Tcl_SetErrorCode(interp, "TK", "ARG", "HELP", NULL);
return TCL_ERROR;
case TK_ARGV_CONST_OPTION:
- Tk_AddOption(tkwin, infoPtr->dst, infoPtr->src,
+ Tk_AddOption(tkwin, (char *)infoPtr->dst, (char *)infoPtr->src,
TK_INTERACTIVE_PRIO);
break;
case TK_ARGV_OPTION_VALUE:
if (argc < 1) {
goto missingArg;
}
- Tk_AddOption(tkwin, infoPtr->dst, argv[srcIndex],
+ Tk_AddOption(tkwin, (char *)infoPtr->dst, argv[srcIndex],
TK_INTERACTIVE_PRIO);
srcIndex++;
argc--;
@@ -338,7 +338,7 @@ PrintUsage(
* this word, then don't generate information
* for default options. */
{
- register const Tk_ArgvInfo *infoPtr;
+ const Tk_ArgvInfo *infoPtr;
size_t width, i, numSpaces;
Tcl_Obj *message;
diff --git a/generic/tkArray.h b/generic/tkArray.h
index 65693fe..81f3198 100644
--- a/generic/tkArray.h
+++ b/generic/tkArray.h
@@ -188,7 +188,7 @@ AT##_Init(AT *arr) \
\
__TK_ARRAY_UNUSED \
static size_t \
-AT##_ElemSize() \
+AT##_ElemSize(void) \
{ \
return sizeof(ElemType); \
} \
@@ -273,7 +273,7 @@ AT##_Resize(AT **arrp, size_t newSize) \
} else { \
int init = *arrp == NULL; \
size_t memSize = AT##_BufferSize(newSize - 1) + sizeof(AT); \
- *arrp = ckrealloc(*arrp, memSize); \
+ *arrp = (AT *)ckrealloc(*arrp, memSize); \
if (init) { \
(*arrp)->size = 0; \
} else if (newSize < (*arrp)->size) { \
@@ -399,7 +399,7 @@ typedef struct AT { \
\
__TK_ARRAY_UNUSED \
static size_t \
-AT##_ElemSize() \
+AT##_ElemSize(void) \
{ \
return sizeof(ElemType); \
} \
@@ -484,7 +484,7 @@ AT##_Resize(AT **arrp, size_t newCapacity) \
} else { \
int init = *arrp == NULL; \
size_t memSize = AT##_BufferSize(newCapacity - 1) + sizeof(AT); \
- *arrp = ckrealloc(*arrp, memSize); \
+ *arrp = (AT *)ckrealloc(*arrp, memSize); \
if (init) { \
(*arrp)->size = 0; \
} else if (newCapacity < (*arrp)->size) { \
diff --git a/generic/tkAtom.c b/generic/tkAtom.c
index 2491fb2..a4e1e11 100644
--- a/generic/tkAtom.c
+++ b/generic/tkAtom.c
@@ -154,11 +154,11 @@ Tk_GetAtomName(
if (mustFree) {
XFree(mustFree);
}
- name = Tcl_GetHashKey(&dispPtr->nameTable, hPtr);
+ name = (const char *)Tcl_GetHashKey(&dispPtr->nameTable, hPtr);
hPtr = Tcl_CreateHashEntry(&dispPtr->atomTable, INT2PTR(atom), &isNew);
- Tcl_SetHashValue(hPtr, name);
+ Tcl_SetHashValue(hPtr, (char *)name);
}
- return Tcl_GetHashValue(hPtr);
+ return (const char *)Tcl_GetHashValue(hPtr);
}
/*
@@ -200,9 +200,9 @@ AtomInit(
name = atomNameArray[atom - 1];
hPtr = Tcl_CreateHashEntry(&dispPtr->nameTable, name, &isNew);
Tcl_SetHashValue(hPtr, INT2PTR(atom));
- name = Tcl_GetHashKey(&dispPtr->nameTable, hPtr);
+ name = (const char *)Tcl_GetHashKey(&dispPtr->nameTable, hPtr);
hPtr = Tcl_CreateHashEntry(&dispPtr->atomTable, INT2PTR(atom), &isNew);
- Tcl_SetHashValue(hPtr, name);
+ Tcl_SetHashValue(hPtr, (char *)name);
}
}
diff --git a/generic/tkBind.c b/generic/tkBind.c
index ad59299..4ab98f5 100644
--- a/generic/tkBind.c
+++ b/generic/tkBind.c
@@ -62,21 +62,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
/*
@@ -445,6 +445,14 @@ static const ModInfo modArray[] = {
{"Button4", Button4Mask, 0},
{"B5", Button5Mask, 0},
{"Button5", Button5Mask, 0},
+ {"B6", Button6Mask, 0},
+ {"Button6", Button6Mask, 0},
+ {"B7", Button7Mask, 0},
+ {"Button7", Button7Mask, 0},
+ {"B8", Button8Mask, 0},
+ {"Button8", Button8Mask, 0},
+ {"B9", Button9Mask, 0},
+ {"Button9", Button9Mask, 0},
{"Mod1", Mod1Mask, 0},
{"M1", Mod1Mask, 0},
{"Command", Mod1Mask, 0},
@@ -723,7 +731,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(ClientData clientData);
static PSList * GetLookupForEvent(LookupTables* lookupPtr, const Event *eventPtr,
Tcl_Obj *object, int onlyConsiderDetailedEvents);
static void ClearLookupTable(LookupTables *lookupTables, ClientData object);
@@ -786,7 +793,7 @@ GetButtonNumber(
const char *field)
{
assert(field);
- return (field[0] >= '1' && field[0] <= '5' && field[1] == '\0') ? field[0] - '0' : 0;
+ return (field[0] >= '1' && field[0] <= '9' && field[1] == '\0') ? field[0] - '0' : 0;
}
static Time
@@ -946,6 +953,7 @@ FreePatSeqEntry(
PSEntry *entry)
{
PSEntry *next = PSList_Next(entry);
+
PSModMaskArr_Free(&entry->lastModMaskArr);
ckfree(entry);
return next;
@@ -983,7 +991,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
@@ -1272,49 +1284,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
@@ -1621,7 +1633,7 @@ Tk_CreateBinding(
ClientData object, /* Token for object with which binding is associated. */
const char *eventString, /* String describing event sequence that triggers binding. */
const char *script, /* Contains Tcl script to execute when binding triggers. */
- int append) /* 0 means replace any existing binding for eventString;
+ int append) /* 0 means replace any existing binding for eventString;
* 1 means append to that binding. If the existing binding is
* for a callback function and not a Tcl command string, the
* existing binding will always be replaced. */
@@ -4401,10 +4413,19 @@ 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);
+ }
}
/*
@@ -4488,46 +4509,47 @@ NameToWindow(
/*
*-------------------------------------------------------------------------
*
- * DoWarp --
+ * TkDoWarpWrtWin --
*
- * Perform Warping of X pointer. Executed as an idle handler only.
+ * Perform warping of mouse pointer with respect to a window.
*
* Results:
* None
*
* Side effects:
- * X Pointer will move to a new location.
+ * Mouse pointer moves to a new location.
*
*-------------------------------------------------------------------------
*/
-static void
-DoWarp(
- ClientData clientData)
+void
+TkDoWarpWrtWin(
+ TkDisplay *dispPtr)
{
- TkDisplay *dispPtr = 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) {
- Tcl_Release(dispPtr->warpWindow);
- dispPtr->warpWindow = NULL;
+
+ /*
+ * 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;
}
/*
@@ -4610,7 +4632,7 @@ FindSequence(
* associated. For virtual event table, NULL. */
const char *eventString, /* String description of pattern to match on. See user
* documentation for details. */
- int create, /* 0 means don't create the entry if it doesn't already exist.
+ int create, /* 0 means don't create the entry if it doesn't already exist.
* 1 means create. */
int allowVirtual, /* 0 means that virtual events are not allowed in the sequence.
* 1 otherwise. */
@@ -4979,7 +5001,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)));
@@ -4989,7 +5011,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
@@ -5167,8 +5189,8 @@ GetPatternObj(
}
case ButtonPress:
case ButtonRelease:
- assert(patPtr->info <= Button5);
- Tcl_AppendPrintfToObj(patternObj, "-%u", (unsigned) patPtr->info);
+ assert(patPtr->info <= Button9);
+ Tcl_AppendPrintfToObj(patternObj, "-%u", (unsigned)patPtr->info);
break;
#if PRINT_SHORT_MOTION_SYNTAX
case MotionNotify: {
@@ -5176,7 +5198,7 @@ GetPatternObj(
while (mask & ALL_BUTTONS) {
unsigned button = ButtonNumberFromState(mask);
Tcl_AppendPrintfToObj(patternObj, "-%u", button);
- mask &= ~TkGetButtonMask(button);
+ mask &= ~Tk_GetButtonMask(button);
}
break;
}
@@ -5298,35 +5320,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 54bab69..36fb382 100644
--- a/generic/tkBitmap.c
+++ b/generic/tkBitmap.c
@@ -167,7 +167,7 @@ Tk_AllocBitmapFromObj(
if (objPtr->typePtr != &tkBitmapObjType) {
InitBitmapObj(objPtr);
}
- bitmapPtr = objPtr->internalRep.twoPtrValue.ptr1;
+ bitmapPtr = (TkBitmap *)objPtr->internalRep.twoPtrValue.ptr1;
/*
* If the object currently points to a TkBitmap, see if it's the one we
@@ -197,7 +197,7 @@ Tk_AllocBitmapFromObj(
*/
if (bitmapPtr != NULL) {
- TkBitmap *firstBitmapPtr = Tcl_GetHashValue(bitmapPtr->nameHashPtr);
+ TkBitmap *firstBitmapPtr = (TkBitmap *)Tcl_GetHashValue(bitmapPtr->nameHashPtr);
FreeBitmapObj(objPtr);
for (bitmapPtr = firstBitmapPtr; bitmapPtr != NULL;
@@ -307,7 +307,7 @@ GetBitmap(
Pixmap bitmap;
int isNew, width = 0, height = 0, dummy2;
TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (!dispPtr->bitmapInit) {
@@ -317,7 +317,7 @@ GetBitmap(
nameHashPtr = Tcl_CreateHashEntry(&dispPtr->bitmapNameTable, string,
&isNew);
if (!isNew) {
- existingBitmapPtr = Tcl_GetHashValue(nameHashPtr);
+ existingBitmapPtr = (TkBitmap *)Tcl_GetHashValue(nameHashPtr);
for (bitmapPtr = existingBitmapPtr; bitmapPtr != NULL;
bitmapPtr = bitmapPtr->nextPtr) {
if ((Tk_Display(tkwin) == bitmapPtr->display) &&
@@ -395,7 +395,7 @@ GetBitmap(
goto error;
}
} else {
- predefPtr = Tcl_GetHashValue(predefHashPtr);
+ predefPtr = (TkPredefBitmap *)Tcl_GetHashValue(predefHashPtr);
width = predefPtr->width;
height = predefPtr->height;
if (predefPtr->native) {
@@ -407,7 +407,7 @@ GetBitmap(
} else {
bitmap = XCreateBitmapFromData(Tk_Display(tkwin),
RootWindowOfScreen(Tk_Screen(tkwin)),
- predefPtr->source, (unsigned)width, (unsigned)height);
+ (const char *)predefPtr->source, (unsigned)width, (unsigned)height);
}
}
}
@@ -416,7 +416,7 @@ GetBitmap(
* Add information about this bitmap to our database.
*/
- bitmapPtr = ckalloc(sizeof(TkBitmap));
+ bitmapPtr = (TkBitmap *)ckalloc(sizeof(TkBitmap));
bitmapPtr->bitmap = bitmap;
bitmapPtr->width = width;
bitmapPtr->height = height;
@@ -474,7 +474,7 @@ Tk_DefineBitmap(
int isNew;
Tcl_HashEntry *predefHashPtr;
TkPredefBitmap *predefPtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -497,7 +497,7 @@ Tk_DefineBitmap(
Tcl_SetErrorCode(interp, "TK", "BITMAP", "EXISTS", NULL);
return TCL_ERROR;
}
- predefPtr = ckalloc(sizeof(TkPredefBitmap));
+ predefPtr = (TkPredefBitmap *)ckalloc(sizeof(TkPredefBitmap));
predefPtr->source = source;
predefPtr->width = width;
predefPtr->height = height;
@@ -536,11 +536,11 @@ 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;
}
- bitmapPtr = Tcl_GetHashValue(idHashPtr);
+ bitmapPtr = (TkBitmap *)Tcl_GetHashValue(idHashPtr);
return bitmapPtr->nameHashPtr->key.string;
}
@@ -578,11 +578,11 @@ 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;
}
- bitmapPtr = Tcl_GetHashValue(idHashPtr);
+ bitmapPtr = (TkBitmap *)Tcl_GetHashValue(idHashPtr);
*widthPtr = bitmapPtr->width;
*heightPtr = bitmapPtr->height;
}
@@ -612,14 +612,13 @@ FreeBitmap(
{
TkBitmap *prevPtr;
- bitmapPtr->resourceRefCount--;
- if (bitmapPtr->resourceRefCount > 0) {
+ if (bitmapPtr->resourceRefCount-- > 1) {
return;
}
Tk_FreePixmap(bitmapPtr->display, bitmapPtr->bitmap);
Tcl_DeleteHashEntry(bitmapPtr->idHashPtr);
- prevPtr = Tcl_GetHashValue(bitmapPtr->nameHashPtr);
+ prevPtr = (TkBitmap *)Tcl_GetHashValue(bitmapPtr->nameHashPtr);
if (prevPtr == bitmapPtr) {
if (bitmapPtr->nextPtr == NULL) {
Tcl_DeleteHashEntry(bitmapPtr->nameHashPtr);
@@ -667,11 +666,11 @@ 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");
}
- FreeBitmap(Tcl_GetHashValue(idHashPtr));
+ FreeBitmap((TkBitmap *)Tcl_GetHashValue(idHashPtr));
}
/*
@@ -735,7 +734,7 @@ static void
FreeBitmapObj(
Tcl_Obj *objPtr) /* The object we are releasing. */
{
- TkBitmap *bitmapPtr = objPtr->internalRep.twoPtrValue.ptr1;
+ TkBitmap *bitmapPtr = (TkBitmap *)objPtr->internalRep.twoPtrValue.ptr1;
if (bitmapPtr != NULL) {
bitmapPtr->objRefCount--;
@@ -770,7 +769,7 @@ DupBitmapObjProc(
Tcl_Obj *srcObjPtr, /* The object we are copying from. */
Tcl_Obj *dupObjPtr) /* The object we are copying to. */
{
- TkBitmap *bitmapPtr = srcObjPtr->internalRep.twoPtrValue.ptr1;
+ TkBitmap *bitmapPtr = (TkBitmap *)srcObjPtr->internalRep.twoPtrValue.ptr1;
dupObjPtr->typePtr = srcObjPtr->typePtr;
dupObjPtr->internalRep.twoPtrValue.ptr1 = bitmapPtr;
@@ -806,7 +805,6 @@ DupBitmapObjProc(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
Pixmap
Tk_GetBitmapFromData(
Tcl_Interp *interp, /* Interpreter to use for error reporting. */
@@ -820,20 +818,20 @@ Tk_GetBitmapFromData(
char string[16 + TCL_INTEGER_SPACE];
char *name;
TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (!tsdPtr->initialized) {
BitmapInit(dispPtr);
}
- nameKey.source = source;
+ nameKey.source = (const char *)source;
nameKey.width = width;
nameKey.height = height;
dataHashPtr = Tcl_CreateHashEntry(&dispPtr->bitmapDataTable,
(char *) &nameKey, &isNew);
if (!isNew) {
- name = Tcl_GetHashValue(dataHashPtr);
+ name = (char *)Tcl_GetHashValue(dataHashPtr);
} else {
dispPtr->bitmapAutoNumber++;
sprintf(string, "_tk%d", dispPtr->bitmapAutoNumber);
@@ -911,7 +909,7 @@ GetBitmapFromObj(
InitBitmapObj(objPtr);
}
- bitmapPtr = objPtr->internalRep.twoPtrValue.ptr1;
+ bitmapPtr = (TkBitmap *)objPtr->internalRep.twoPtrValue.ptr1;
if (bitmapPtr != NULL) {
if ((bitmapPtr->resourceRefCount > 0)
&& (Tk_Display(tkwin) == bitmapPtr->display)) {
@@ -932,7 +930,7 @@ GetBitmapFromObj(
* more TkBitmap structures. See if any of them will work.
*/
- for (bitmapPtr = Tcl_GetHashValue(hashPtr); bitmapPtr != NULL;
+ for (bitmapPtr = (TkBitmap *)Tcl_GetHashValue(hashPtr); bitmapPtr != NULL;
bitmapPtr = bitmapPtr->nextPtr) {
if (Tk_Display(tkwin) == bitmapPtr->display) {
objPtr->internalRep.twoPtrValue.ptr1 = bitmapPtr;
@@ -1012,7 +1010,7 @@ BitmapInit(
* or NULL if unavailable. */
{
Tcl_Interp *dummy;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -1150,16 +1148,16 @@ TkDebugBitmap(
resultPtr = Tcl_NewObj();
hashPtr = Tcl_FindHashEntry(&dispPtr->bitmapNameTable, name);
if (hashPtr != NULL) {
- bitmapPtr = Tcl_GetHashValue(hashPtr);
+ bitmapPtr = (TkBitmap *)Tcl_GetHashValue(hashPtr);
if (bitmapPtr == NULL) {
Tcl_Panic("TkDebugBitmap found empty hash table entry");
}
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);
}
}
@@ -1190,7 +1188,7 @@ TkDebugBitmap(
Tcl_HashTable *
TkGetBitmapPredefTable(void)
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
return &tsdPtr->predefBitmapTable;
diff --git a/generic/tkBusy.c b/generic/tkBusy.c
index 1e4e91f..f6ae494 100644
--- a/generic/tkBusy.c
+++ b/generic/tkBusy.c
@@ -23,7 +23,7 @@
static const Tk_OptionSpec busyOptionSpecs[] = {
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_BUSY_CURSOR, -1, Tk_Offset(Busy, cursor),
+ DEF_BUSY_CURSOR, TCL_INDEX_NONE, offsetof(Busy, cursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0}
};
@@ -570,7 +570,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;
@@ -637,7 +637,7 @@ ConfigureBusy(
{
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;
}
@@ -686,7 +686,7 @@ GetBusy(
&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)));
@@ -760,6 +760,9 @@ HoldBusy(
} else {
TkpHideBusyWindow(busyPtr);
}
+ if (result == TCL_OK) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(Tk_PathName(busyPtr->tkBusy), -1));
+ }
return result;
}
@@ -793,15 +796,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;
}
@@ -811,7 +815,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);
@@ -822,6 +826,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), -1));
+ return TCL_OK;
+
case BUSY_CGET:
if (objc != 4) {
Tcl_WrongNumArgs(interp, 2, objv, "window option");
@@ -832,7 +849,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;
@@ -844,7 +861,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]);
@@ -853,7 +870,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) {
@@ -879,7 +896,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);
@@ -901,7 +918,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 3c15bf6..69d4b12 100644
--- a/generic/tkButton.c
+++ b/generic/tkButton.c
@@ -70,413 +70,413 @@ char tkDefLabelPady[TCL_INTEGER_SPACE] = DEF_LABCHKRAD_PADY;
static const Tk_OptionSpec labelOptionSpecs[] = {
{TK_OPTION_BORDER, "-activebackground", "activeBackground", "Foreground",
- DEF_BUTTON_ACTIVE_BG_COLOR, -1, Tk_Offset(TkButton, activeBorder),
+ DEF_BUTTON_ACTIVE_BG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, activeBorder),
0, DEF_BUTTON_ACTIVE_BG_MONO, 0},
{TK_OPTION_COLOR, "-activeforeground", "activeForeground", "Background",
- DEF_BUTTON_ACTIVE_FG_COLOR, -1, Tk_Offset(TkButton, activeFg),
+ DEF_BUTTON_ACTIVE_FG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, activeFg),
TK_OPTION_NULL_OK, DEF_BUTTON_ACTIVE_FG_MONO, 0},
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
- DEF_BUTTON_ANCHOR, -1, Tk_Offset(TkButton, anchor), 0, 0, 0},
+ DEF_BUTTON_ANCHOR, TCL_INDEX_NONE, offsetof(TkButton, anchor), 0, 0, 0},
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_BUTTON_BG_COLOR, -1, Tk_Offset(TkButton, normalBorder),
+ DEF_BUTTON_BG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, normalBorder),
0, DEF_BUTTON_BG_MONO, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL,
- NULL, 0, -1, 0, "-background", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_BITMAP, "-bitmap", "bitmap", "Bitmap",
- DEF_BUTTON_BITMAP, -1, Tk_Offset(TkButton, bitmap),
+ DEF_BUTTON_BITMAP, TCL_INDEX_NONE, offsetof(TkButton, bitmap),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- tkDefButtonBorderWidth, Tk_Offset(TkButton, borderWidthPtr),
- Tk_Offset(TkButton, borderWidth), 0, 0, 0},
+ tkDefButtonBorderWidth, offsetof(TkButton, borderWidthPtr),
+ offsetof(TkButton, borderWidth), 0, 0, 0},
{TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound",
- DEF_BUTTON_COMPOUND, -1, Tk_Offset(TkButton, compound), 0,
+ DEF_BUTTON_COMPOUND, TCL_INDEX_NONE, offsetof(TkButton, compound), 0,
compoundStrings, 0},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_BUTTON_CURSOR, -1, Tk_Offset(TkButton, cursor),
+ DEF_BUTTON_CURSOR, TCL_INDEX_NONE, offsetof(TkButton, cursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_COLOR, "-disabledforeground", "disabledForeground",
"DisabledForeground", DEF_BUTTON_DISABLED_FG_COLOR,
- -1, Tk_Offset(TkButton, disabledFg), TK_OPTION_NULL_OK,
+ TCL_INDEX_NONE, offsetof(TkButton, disabledFg), TK_OPTION_NULL_OK,
(ClientData) DEF_BUTTON_DISABLED_FG_MONO, 0},
{TK_OPTION_SYNONYM, "-fg", "foreground", NULL,
- NULL, 0, -1, 0, "-foreground", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_BUTTON_FONT, -1, Tk_Offset(TkButton, tkfont), 0, 0, 0},
+ DEF_BUTTON_FONT, TCL_INDEX_NONE, offsetof(TkButton, tkfont), 0, 0, 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_BUTTON_FG, -1, Tk_Offset(TkButton, normalFg), 0, 0, 0},
+ DEF_BUTTON_FG, TCL_INDEX_NONE, offsetof(TkButton, normalFg), 0, 0, 0},
{TK_OPTION_STRING, "-height", "height", "Height",
- DEF_BUTTON_HEIGHT, Tk_Offset(TkButton, heightPtr), -1, 0, 0, 0},
+ DEF_BUTTON_HEIGHT, offsetof(TkButton, heightPtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_BORDER, "-highlightbackground", "highlightBackground",
"HighlightBackground", DEF_BUTTON_HIGHLIGHT_BG_COLOR,
- -1, Tk_Offset(TkButton, highlightBorder), 0,
+ TCL_INDEX_NONE, offsetof(TkButton, highlightBorder), 0,
(ClientData) DEF_BUTTON_HIGHLIGHT_BG_MONO, 0},
{TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_BUTTON_HIGHLIGHT, -1, Tk_Offset(TkButton, highlightColorPtr),
+ DEF_BUTTON_HIGHLIGHT, TCL_INDEX_NONE, offsetof(TkButton, highlightColorPtr),
0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
"HighlightThickness", tkDefLabelHighlightWidth,
- Tk_Offset(TkButton, highlightWidthPtr),
- Tk_Offset(TkButton, highlightWidth), 0, 0, 0},
+ offsetof(TkButton, highlightWidthPtr),
+ offsetof(TkButton, highlightWidth), 0, 0, 0},
{TK_OPTION_STRING, "-image", "image", "Image",
- DEF_BUTTON_IMAGE, Tk_Offset(TkButton, imagePtr), -1,
+ DEF_BUTTON_IMAGE, offsetof(TkButton, imagePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
- DEF_BUTTON_JUSTIFY, -1, Tk_Offset(TkButton, justify), 0, 0, 0},
+ DEF_BUTTON_JUSTIFY, TCL_INDEX_NONE, offsetof(TkButton, justify), 0, 0, 0},
{TK_OPTION_PIXELS, "-padx", "padX", "Pad",
- tkDefLabelPadx, Tk_Offset(TkButton, padXPtr),
- Tk_Offset(TkButton, padX), 0, 0, 0},
+ tkDefLabelPadx, offsetof(TkButton, padXPtr),
+ offsetof(TkButton, padX), 0, 0, 0},
{TK_OPTION_PIXELS, "-pady", "padY", "Pad",
- tkDefLabelPady, Tk_Offset(TkButton, padYPtr),
- Tk_Offset(TkButton, padY), 0, 0, 0},
+ tkDefLabelPady, offsetof(TkButton, padYPtr),
+ offsetof(TkButton, padY), 0, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_LABCHKRAD_RELIEF, -1, Tk_Offset(TkButton, relief), 0, 0, 0},
+ DEF_LABCHKRAD_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, relief), 0, 0, 0},
{TK_OPTION_STRING_TABLE, "-state", "state", "State",
- DEF_BUTTON_STATE, -1, Tk_Offset(TkButton, state),
+ DEF_BUTTON_STATE, TCL_INDEX_NONE, offsetof(TkButton, state),
0, stateStrings, 0},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_LABEL_TAKE_FOCUS, Tk_Offset(TkButton, takeFocusPtr), -1,
+ DEF_LABEL_TAKE_FOCUS, offsetof(TkButton, takeFocusPtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-text", "text", "Text",
- DEF_BUTTON_TEXT, Tk_Offset(TkButton, textPtr), -1, 0, 0, 0},
+ DEF_BUTTON_TEXT, offsetof(TkButton, textPtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_STRING, "-textvariable", "textVariable", "Variable",
- DEF_BUTTON_TEXT_VARIABLE, Tk_Offset(TkButton, textVarNamePtr), -1,
+ DEF_BUTTON_TEXT_VARIABLE, offsetof(TkButton, textVarNamePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_INT, "-underline", "underline", "Underline",
- DEF_BUTTON_UNDERLINE, -1, Tk_Offset(TkButton, underline), 0, 0, 0},
+ DEF_BUTTON_UNDERLINE, TCL_INDEX_NONE, offsetof(TkButton, underline), 0, 0, 0},
{TK_OPTION_STRING, "-width", "width", "Width",
- DEF_BUTTON_WIDTH, Tk_Offset(TkButton, widthPtr), -1, 0, 0, 0},
+ DEF_BUTTON_WIDTH, offsetof(TkButton, widthPtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength",
- DEF_BUTTON_WRAP_LENGTH, Tk_Offset(TkButton, wrapLengthPtr),
- Tk_Offset(TkButton, wrapLength), 0, 0, 0},
+ DEF_BUTTON_WRAP_LENGTH, offsetof(TkButton, wrapLengthPtr),
+ offsetof(TkButton, wrapLength), 0, 0, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0}
};
static const Tk_OptionSpec buttonOptionSpecs[] = {
{TK_OPTION_BORDER, "-activebackground", "activeBackground", "Foreground",
- DEF_BUTTON_ACTIVE_BG_COLOR, -1, Tk_Offset(TkButton, activeBorder),
+ DEF_BUTTON_ACTIVE_BG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, activeBorder),
0, DEF_BUTTON_ACTIVE_BG_MONO, 0},
{TK_OPTION_COLOR, "-activeforeground", "activeForeground", "Background",
- DEF_BUTTON_ACTIVE_FG_COLOR, -1, Tk_Offset(TkButton, activeFg),
+ DEF_BUTTON_ACTIVE_FG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, activeFg),
TK_OPTION_NULL_OK, DEF_BUTTON_ACTIVE_FG_MONO, 0},
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
- DEF_BUTTON_ANCHOR, -1, Tk_Offset(TkButton, anchor), 0, 0, 0},
+ DEF_BUTTON_ANCHOR, TCL_INDEX_NONE, offsetof(TkButton, anchor), 0, 0, 0},
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_BUTTON_BG_COLOR, -1, Tk_Offset(TkButton, normalBorder),
+ DEF_BUTTON_BG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, normalBorder),
0, DEF_BUTTON_BG_MONO, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL,
- NULL, 0, -1, 0, "-background", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_BITMAP, "-bitmap", "bitmap", "Bitmap",
- DEF_BUTTON_BITMAP, -1, Tk_Offset(TkButton, bitmap),
+ DEF_BUTTON_BITMAP, TCL_INDEX_NONE, offsetof(TkButton, bitmap),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- tkDefButtonBorderWidth, Tk_Offset(TkButton, borderWidthPtr),
- Tk_Offset(TkButton, borderWidth), 0, 0, 0},
+ tkDefButtonBorderWidth, offsetof(TkButton, borderWidthPtr),
+ offsetof(TkButton, borderWidth), 0, 0, 0},
{TK_OPTION_STRING, "-command", "command", "Command",
- DEF_BUTTON_COMMAND, Tk_Offset(TkButton, commandPtr), -1,
+ DEF_BUTTON_COMMAND, offsetof(TkButton, commandPtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound",
- DEF_BUTTON_COMPOUND, -1, Tk_Offset(TkButton, compound), 0,
+ DEF_BUTTON_COMPOUND, TCL_INDEX_NONE, offsetof(TkButton, compound), 0,
compoundStrings, 0},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_BUTTON_CURSOR, -1, Tk_Offset(TkButton, cursor),
+ DEF_BUTTON_CURSOR, TCL_INDEX_NONE, offsetof(TkButton, cursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING_TABLE, "-default", "default", "Default",
- DEF_BUTTON_DEFAULT, -1, Tk_Offset(TkButton, defaultState),
+ DEF_BUTTON_DEFAULT, TCL_INDEX_NONE, offsetof(TkButton, defaultState),
0, defaultStrings, 0},
{TK_OPTION_COLOR, "-disabledforeground", "disabledForeground",
"DisabledForeground", DEF_BUTTON_DISABLED_FG_COLOR,
- -1, Tk_Offset(TkButton, disabledFg), TK_OPTION_NULL_OK,
+ TCL_INDEX_NONE, offsetof(TkButton, disabledFg), TK_OPTION_NULL_OK,
(ClientData) DEF_BUTTON_DISABLED_FG_MONO, 0},
{TK_OPTION_SYNONYM, "-fg", "foreground", NULL,
- NULL, 0, -1, 0, "-foreground", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_BUTTON_FONT, -1, Tk_Offset(TkButton, tkfont), 0, 0, 0},
+ DEF_BUTTON_FONT, TCL_INDEX_NONE, offsetof(TkButton, tkfont), 0, 0, 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_BUTTON_FG, -1, Tk_Offset(TkButton, normalFg), 0, 0, 0},
+ DEF_BUTTON_FG, TCL_INDEX_NONE, offsetof(TkButton, normalFg), 0, 0, 0},
{TK_OPTION_STRING, "-height", "height", "Height",
- DEF_BUTTON_HEIGHT, Tk_Offset(TkButton, heightPtr), -1, 0, 0, 0},
+ DEF_BUTTON_HEIGHT, offsetof(TkButton, heightPtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_BORDER, "-highlightbackground", "highlightBackground",
"HighlightBackground", DEF_BUTTON_HIGHLIGHT_BG_COLOR,
- -1, Tk_Offset(TkButton, highlightBorder), 0,
+ TCL_INDEX_NONE, offsetof(TkButton, highlightBorder), 0,
(ClientData) DEF_BUTTON_HIGHLIGHT_BG_MONO, 0},
{TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_BUTTON_HIGHLIGHT, -1, Tk_Offset(TkButton, highlightColorPtr),
+ DEF_BUTTON_HIGHLIGHT, TCL_INDEX_NONE, offsetof(TkButton, highlightColorPtr),
0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
"HighlightThickness", tkDefButtonHighlightWidth,
- Tk_Offset(TkButton, highlightWidthPtr),
- Tk_Offset(TkButton, highlightWidth), 0, 0, 0},
+ offsetof(TkButton, highlightWidthPtr),
+ offsetof(TkButton, highlightWidth), 0, 0, 0},
{TK_OPTION_STRING, "-image", "image", "Image",
- DEF_BUTTON_IMAGE, Tk_Offset(TkButton, imagePtr), -1,
+ DEF_BUTTON_IMAGE, offsetof(TkButton, imagePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
- DEF_BUTTON_JUSTIFY, -1, Tk_Offset(TkButton, justify), 0, 0, 0},
+ DEF_BUTTON_JUSTIFY, TCL_INDEX_NONE, offsetof(TkButton, justify), 0, 0, 0},
{TK_OPTION_RELIEF, "-overrelief", "overRelief", "OverRelief",
- DEF_BUTTON_OVER_RELIEF, -1, Tk_Offset(TkButton, overRelief),
+ DEF_BUTTON_OVER_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, overRelief),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-padx", "padX", "Pad",
- tkDefButtonPadx, Tk_Offset(TkButton, padXPtr),
- Tk_Offset(TkButton, padX), 0, 0, 0},
+ tkDefButtonPadx, offsetof(TkButton, padXPtr),
+ offsetof(TkButton, padX), 0, 0, 0},
{TK_OPTION_PIXELS, "-pady", "padY", "Pad",
- tkDefButtonPady, Tk_Offset(TkButton, padYPtr),
- Tk_Offset(TkButton, padY), 0, 0, 0},
+ tkDefButtonPady, offsetof(TkButton, padYPtr),
+ offsetof(TkButton, padY), 0, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_BUTTON_RELIEF, -1, Tk_Offset(TkButton, relief),
+ DEF_BUTTON_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, relief),
0, 0, 0},
{TK_OPTION_INT, "-repeatdelay", "repeatDelay", "RepeatDelay",
- DEF_BUTTON_REPEAT_DELAY, -1, Tk_Offset(TkButton, repeatDelay),
+ DEF_BUTTON_REPEAT_DELAY, TCL_INDEX_NONE, offsetof(TkButton, repeatDelay),
0, 0, 0},
{TK_OPTION_INT, "-repeatinterval", "repeatInterval", "RepeatInterval",
- DEF_BUTTON_REPEAT_INTERVAL, -1, Tk_Offset(TkButton, repeatInterval),
+ DEF_BUTTON_REPEAT_INTERVAL, TCL_INDEX_NONE, offsetof(TkButton, repeatInterval),
0, 0, 0},
{TK_OPTION_STRING_TABLE, "-state", "state", "State",
- DEF_BUTTON_STATE, -1, Tk_Offset(TkButton, state),
+ DEF_BUTTON_STATE, TCL_INDEX_NONE, offsetof(TkButton, state),
0, stateStrings, 0},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_BUTTON_TAKE_FOCUS, Tk_Offset(TkButton, takeFocusPtr), -1,
+ DEF_BUTTON_TAKE_FOCUS, offsetof(TkButton, takeFocusPtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-text", "text", "Text",
- DEF_BUTTON_TEXT, Tk_Offset(TkButton, textPtr), -1, 0, 0, 0},
+ DEF_BUTTON_TEXT, offsetof(TkButton, textPtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_STRING, "-textvariable", "textVariable", "Variable",
- DEF_BUTTON_TEXT_VARIABLE, Tk_Offset(TkButton, textVarNamePtr), -1,
+ DEF_BUTTON_TEXT_VARIABLE, offsetof(TkButton, textVarNamePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_INT, "-underline", "underline", "Underline",
- DEF_BUTTON_UNDERLINE, -1, Tk_Offset(TkButton, underline), 0, 0, 0},
+ DEF_BUTTON_UNDERLINE, TCL_INDEX_NONE, offsetof(TkButton, underline), 0, 0, 0},
{TK_OPTION_STRING, "-width", "width", "Width",
- DEF_BUTTON_WIDTH, Tk_Offset(TkButton, widthPtr), -1, 0, 0, 0},
+ DEF_BUTTON_WIDTH, offsetof(TkButton, widthPtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength",
- DEF_BUTTON_WRAP_LENGTH, Tk_Offset(TkButton, wrapLengthPtr),
- Tk_Offset(TkButton, wrapLength), 0, 0, 0},
- {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0}
+ DEF_BUTTON_WRAP_LENGTH, offsetof(TkButton, wrapLengthPtr),
+ offsetof(TkButton, wrapLength), 0, 0, 0},
+ {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0}
};
static const Tk_OptionSpec checkbuttonOptionSpecs[] = {
{TK_OPTION_BORDER, "-activebackground", "activeBackground", "Foreground",
- DEF_BUTTON_ACTIVE_BG_COLOR, -1, Tk_Offset(TkButton, activeBorder),
+ DEF_BUTTON_ACTIVE_BG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, activeBorder),
0, DEF_BUTTON_ACTIVE_BG_MONO, 0},
{TK_OPTION_COLOR, "-activeforeground", "activeForeground", "Background",
- DEF_CHKRAD_ACTIVE_FG_COLOR, -1, Tk_Offset(TkButton, activeFg),
+ DEF_CHKRAD_ACTIVE_FG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, activeFg),
TK_OPTION_NULL_OK, DEF_BUTTON_ACTIVE_FG_MONO, 0},
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
- DEF_BUTTON_ANCHOR, -1, Tk_Offset(TkButton, anchor), 0, 0, 0},
+ DEF_BUTTON_ANCHOR, TCL_INDEX_NONE, offsetof(TkButton, anchor), 0, 0, 0},
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_BUTTON_BG_COLOR, -1, Tk_Offset(TkButton, normalBorder),
+ DEF_BUTTON_BG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, normalBorder),
0, DEF_BUTTON_BG_MONO, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL,
- NULL, 0, -1, 0, "-background", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_BITMAP, "-bitmap", "bitmap", "Bitmap",
- DEF_BUTTON_BITMAP, -1, Tk_Offset(TkButton, bitmap),
+ DEF_BUTTON_BITMAP, TCL_INDEX_NONE, offsetof(TkButton, bitmap),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- tkDefButtonBorderWidth, Tk_Offset(TkButton, borderWidthPtr),
- Tk_Offset(TkButton, borderWidth), 0, 0, 0},
+ tkDefButtonBorderWidth, offsetof(TkButton, borderWidthPtr),
+ offsetof(TkButton, borderWidth), 0, 0, 0},
{TK_OPTION_STRING, "-command", "command", "Command",
- DEF_BUTTON_COMMAND, Tk_Offset(TkButton, commandPtr), -1,
+ DEF_BUTTON_COMMAND, offsetof(TkButton, commandPtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound",
- DEF_BUTTON_COMPOUND, -1, Tk_Offset(TkButton, compound), 0,
+ DEF_BUTTON_COMPOUND, TCL_INDEX_NONE, offsetof(TkButton, compound), 0,
compoundStrings, 0},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_BUTTON_CURSOR, -1, Tk_Offset(TkButton, cursor),
+ DEF_BUTTON_CURSOR, TCL_INDEX_NONE, offsetof(TkButton, cursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_COLOR, "-disabledforeground", "disabledForeground",
"DisabledForeground", DEF_BUTTON_DISABLED_FG_COLOR,
- -1, Tk_Offset(TkButton, disabledFg), TK_OPTION_NULL_OK,
+ TCL_INDEX_NONE, offsetof(TkButton, disabledFg), TK_OPTION_NULL_OK,
(ClientData) DEF_BUTTON_DISABLED_FG_MONO, 0},
{TK_OPTION_SYNONYM, "-fg", "foreground", NULL,
- NULL, 0, -1, 0, "-foreground", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_BUTTON_FONT, -1, Tk_Offset(TkButton, tkfont), 0, 0, 0},
+ DEF_BUTTON_FONT, TCL_INDEX_NONE, offsetof(TkButton, tkfont), 0, 0, 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_CHKRAD_FG, -1, Tk_Offset(TkButton, normalFg), 0, 0, 0},
+ DEF_CHKRAD_FG, TCL_INDEX_NONE, offsetof(TkButton, normalFg), 0, 0, 0},
{TK_OPTION_STRING, "-height", "height", "Height",
- DEF_BUTTON_HEIGHT, Tk_Offset(TkButton, heightPtr), -1, 0, 0, 0},
+ DEF_BUTTON_HEIGHT, offsetof(TkButton, heightPtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_BORDER, "-highlightbackground", "highlightBackground",
"HighlightBackground", DEF_BUTTON_HIGHLIGHT_BG_COLOR,
- -1, Tk_Offset(TkButton, highlightBorder), 0,
+ TCL_INDEX_NONE, offsetof(TkButton, highlightBorder), 0,
(ClientData) DEF_BUTTON_HIGHLIGHT_BG_MONO, 0},
{TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_BUTTON_HIGHLIGHT, -1, Tk_Offset(TkButton, highlightColorPtr),
+ DEF_BUTTON_HIGHLIGHT, TCL_INDEX_NONE, offsetof(TkButton, highlightColorPtr),
0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
"HighlightThickness", tkDefButtonHighlightWidth,
- Tk_Offset(TkButton, highlightWidthPtr),
- Tk_Offset(TkButton, highlightWidth), 0, 0, 0},
+ offsetof(TkButton, highlightWidthPtr),
+ offsetof(TkButton, highlightWidth), 0, 0, 0},
{TK_OPTION_STRING, "-image", "image", "Image",
- DEF_BUTTON_IMAGE, Tk_Offset(TkButton, imagePtr), -1,
+ DEF_BUTTON_IMAGE, offsetof(TkButton, imagePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_BOOLEAN, "-indicatoron", "indicatorOn", "IndicatorOn",
- DEF_BUTTON_INDICATOR, -1, Tk_Offset(TkButton, indicatorOn), 0, 0, 0},
+ DEF_BUTTON_INDICATOR, TCL_INDEX_NONE, offsetof(TkButton, indicatorOn), 0, 0, 0},
{TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
- DEF_BUTTON_JUSTIFY, -1, Tk_Offset(TkButton, justify), 0, 0, 0},
+ DEF_BUTTON_JUSTIFY, TCL_INDEX_NONE, offsetof(TkButton, justify), 0, 0, 0},
{TK_OPTION_RELIEF, "-offrelief", "offRelief", "OffRelief",
- DEF_BUTTON_RELIEF, -1, Tk_Offset(TkButton, offRelief), 0, 0, 0},
+ DEF_BUTTON_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, offRelief), 0, 0, 0},
{TK_OPTION_STRING, "-offvalue", "offValue", "Value",
- DEF_BUTTON_OFF_VALUE, Tk_Offset(TkButton, offValuePtr), -1, 0, 0, 0},
+ DEF_BUTTON_OFF_VALUE, offsetof(TkButton, offValuePtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_STRING, "-onvalue", "onValue", "Value",
- DEF_BUTTON_ON_VALUE, Tk_Offset(TkButton, onValuePtr), -1, 0, 0, 0},
+ DEF_BUTTON_ON_VALUE, offsetof(TkButton, onValuePtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_RELIEF, "-overrelief", "overRelief", "OverRelief",
- DEF_BUTTON_OVER_RELIEF, -1, Tk_Offset(TkButton, overRelief),
+ DEF_BUTTON_OVER_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, overRelief),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-padx", "padX", "Pad",
- tkDefLabelPadx, Tk_Offset(TkButton, padXPtr),
- Tk_Offset(TkButton, padX), 0, 0, 0},
+ tkDefLabelPadx, offsetof(TkButton, padXPtr),
+ offsetof(TkButton, padX), 0, 0, 0},
{TK_OPTION_PIXELS, "-pady", "padY", "Pad",
- tkDefLabelPady, Tk_Offset(TkButton, padYPtr),
- Tk_Offset(TkButton, padY), 0, 0, 0},
+ tkDefLabelPady, offsetof(TkButton, padYPtr),
+ offsetof(TkButton, padY), 0, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_LABCHKRAD_RELIEF, -1, Tk_Offset(TkButton, relief), 0, 0, 0},
+ DEF_LABCHKRAD_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, relief), 0, 0, 0},
{TK_OPTION_BORDER, "-selectcolor", "selectColor", "Background",
- DEF_BUTTON_SELECT_COLOR, -1, Tk_Offset(TkButton, selectBorder),
+ DEF_BUTTON_SELECT_COLOR, TCL_INDEX_NONE, offsetof(TkButton, selectBorder),
TK_OPTION_NULL_OK, DEF_BUTTON_SELECT_MONO, 0},
{TK_OPTION_STRING, "-selectimage", "selectImage", "SelectImage",
- DEF_BUTTON_SELECT_IMAGE, Tk_Offset(TkButton, selectImagePtr), -1,
+ DEF_BUTTON_SELECT_IMAGE, offsetof(TkButton, selectImagePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING_TABLE, "-state", "state", "State",
- DEF_BUTTON_STATE, -1, Tk_Offset(TkButton, state),
+ DEF_BUTTON_STATE, TCL_INDEX_NONE, offsetof(TkButton, state),
0, stateStrings, 0},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_BUTTON_TAKE_FOCUS, Tk_Offset(TkButton, takeFocusPtr), -1,
+ DEF_BUTTON_TAKE_FOCUS, offsetof(TkButton, takeFocusPtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-text", "text", "Text",
- DEF_BUTTON_TEXT, Tk_Offset(TkButton, textPtr), -1, 0, 0, 0},
+ DEF_BUTTON_TEXT, offsetof(TkButton, textPtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_STRING, "-textvariable", "textVariable", "Variable",
- DEF_BUTTON_TEXT_VARIABLE, Tk_Offset(TkButton, textVarNamePtr), -1,
+ DEF_BUTTON_TEXT_VARIABLE, offsetof(TkButton, textVarNamePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-tristateimage", "tristateImage", "TristateImage",
- DEF_BUTTON_IMAGE, Tk_Offset(TkButton, tristateImagePtr), -1,
+ DEF_BUTTON_IMAGE, offsetof(TkButton, tristateImagePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-tristatevalue", "tristateValue", "TristateValue",
- DEF_BUTTON_TRISTATE_VALUE, Tk_Offset(TkButton, tristateValuePtr), -1, 0, 0, 0},
+ DEF_BUTTON_TRISTATE_VALUE, offsetof(TkButton, tristateValuePtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_INT, "-underline", "underline", "Underline",
- DEF_BUTTON_UNDERLINE, -1, Tk_Offset(TkButton, underline), 0, 0, 0},
+ DEF_BUTTON_UNDERLINE, TCL_INDEX_NONE, offsetof(TkButton, underline), 0, 0, 0},
{TK_OPTION_STRING, "-variable", "variable", "Variable",
- DEF_CHECKBUTTON_VARIABLE, Tk_Offset(TkButton, selVarNamePtr), -1,
+ DEF_CHECKBUTTON_VARIABLE, offsetof(TkButton, selVarNamePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-width", "width", "Width",
- DEF_BUTTON_WIDTH, Tk_Offset(TkButton, widthPtr), -1, 0, 0, 0},
+ DEF_BUTTON_WIDTH, offsetof(TkButton, widthPtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength",
- DEF_BUTTON_WRAP_LENGTH, Tk_Offset(TkButton, wrapLengthPtr),
- Tk_Offset(TkButton, wrapLength), 0, 0, 0},
- {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0}
+ DEF_BUTTON_WRAP_LENGTH, offsetof(TkButton, wrapLengthPtr),
+ offsetof(TkButton, wrapLength), 0, 0, 0},
+ {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0}
};
static const Tk_OptionSpec radiobuttonOptionSpecs[] = {
{TK_OPTION_BORDER, "-activebackground", "activeBackground", "Foreground",
- DEF_BUTTON_ACTIVE_BG_COLOR, -1, Tk_Offset(TkButton, activeBorder),
+ DEF_BUTTON_ACTIVE_BG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, activeBorder),
0, DEF_BUTTON_ACTIVE_BG_MONO, 0},
{TK_OPTION_COLOR, "-activeforeground", "activeForeground", "Background",
- DEF_CHKRAD_ACTIVE_FG_COLOR, -1, Tk_Offset(TkButton, activeFg),
+ DEF_CHKRAD_ACTIVE_FG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, activeFg),
TK_OPTION_NULL_OK, DEF_BUTTON_ACTIVE_FG_MONO, 0},
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
- DEF_BUTTON_ANCHOR, -1, Tk_Offset(TkButton, anchor), 0, 0, 0},
+ DEF_BUTTON_ANCHOR, TCL_INDEX_NONE, offsetof(TkButton, anchor), 0, 0, 0},
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_BUTTON_BG_COLOR, -1, Tk_Offset(TkButton, normalBorder),
+ DEF_BUTTON_BG_COLOR, TCL_INDEX_NONE, offsetof(TkButton, normalBorder),
0, DEF_BUTTON_BG_MONO, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL,
- NULL, 0, -1, 0, "-background", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_BITMAP, "-bitmap", "bitmap", "Bitmap",
- DEF_BUTTON_BITMAP, -1, Tk_Offset(TkButton, bitmap),
+ DEF_BUTTON_BITMAP, TCL_INDEX_NONE, offsetof(TkButton, bitmap),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- tkDefButtonBorderWidth, Tk_Offset(TkButton, borderWidthPtr),
- Tk_Offset(TkButton, borderWidth), 0, 0, 0},
+ tkDefButtonBorderWidth, offsetof(TkButton, borderWidthPtr),
+ offsetof(TkButton, borderWidth), 0, 0, 0},
{TK_OPTION_STRING, "-command", "command", "Command",
- DEF_BUTTON_COMMAND, Tk_Offset(TkButton, commandPtr), -1,
+ DEF_BUTTON_COMMAND, offsetof(TkButton, commandPtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound",
- DEF_BUTTON_COMPOUND, -1, Tk_Offset(TkButton, compound), 0,
+ DEF_BUTTON_COMPOUND, TCL_INDEX_NONE, offsetof(TkButton, compound), 0,
compoundStrings, 0},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_BUTTON_CURSOR, -1, Tk_Offset(TkButton, cursor),
+ DEF_BUTTON_CURSOR, TCL_INDEX_NONE, offsetof(TkButton, cursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_COLOR, "-disabledforeground", "disabledForeground",
"DisabledForeground", DEF_BUTTON_DISABLED_FG_COLOR,
- -1, Tk_Offset(TkButton, disabledFg), TK_OPTION_NULL_OK,
+ TCL_INDEX_NONE, offsetof(TkButton, disabledFg), TK_OPTION_NULL_OK,
(ClientData) DEF_BUTTON_DISABLED_FG_MONO, 0},
{TK_OPTION_SYNONYM, "-fg", "foreground", NULL,
- NULL, 0, -1, 0, "-foreground", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_BUTTON_FONT, -1, Tk_Offset(TkButton, tkfont), 0, 0, 0},
+ DEF_BUTTON_FONT, TCL_INDEX_NONE, offsetof(TkButton, tkfont), 0, 0, 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_CHKRAD_FG, -1, Tk_Offset(TkButton, normalFg), 0, 0, 0},
+ DEF_CHKRAD_FG, TCL_INDEX_NONE, offsetof(TkButton, normalFg), 0, 0, 0},
{TK_OPTION_STRING, "-height", "height", "Height",
- DEF_BUTTON_HEIGHT, Tk_Offset(TkButton, heightPtr), -1, 0, 0, 0},
+ DEF_BUTTON_HEIGHT, offsetof(TkButton, heightPtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_BORDER, "-highlightbackground", "highlightBackground",
"HighlightBackground", DEF_BUTTON_HIGHLIGHT_BG_COLOR,
- -1, Tk_Offset(TkButton, highlightBorder), 0,
+ TCL_INDEX_NONE, offsetof(TkButton, highlightBorder), 0,
(ClientData) DEF_BUTTON_HIGHLIGHT_BG_MONO, 0},
{TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_BUTTON_HIGHLIGHT, -1, Tk_Offset(TkButton, highlightColorPtr),
+ DEF_BUTTON_HIGHLIGHT, TCL_INDEX_NONE, offsetof(TkButton, highlightColorPtr),
0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
"HighlightThickness", tkDefButtonHighlightWidth,
- Tk_Offset(TkButton, highlightWidthPtr),
- Tk_Offset(TkButton, highlightWidth), 0, 0, 0},
+ offsetof(TkButton, highlightWidthPtr),
+ offsetof(TkButton, highlightWidth), 0, 0, 0},
{TK_OPTION_STRING, "-image", "image", "Image",
- DEF_BUTTON_IMAGE, Tk_Offset(TkButton, imagePtr), -1,
+ DEF_BUTTON_IMAGE, offsetof(TkButton, imagePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_BOOLEAN, "-indicatoron", "indicatorOn", "IndicatorOn",
- DEF_BUTTON_INDICATOR, -1, Tk_Offset(TkButton, indicatorOn),
+ DEF_BUTTON_INDICATOR, TCL_INDEX_NONE, offsetof(TkButton, indicatorOn),
0, 0, 0},
{TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
- DEF_BUTTON_JUSTIFY, -1, Tk_Offset(TkButton, justify), 0, 0, 0},
+ DEF_BUTTON_JUSTIFY, TCL_INDEX_NONE, offsetof(TkButton, justify), 0, 0, 0},
{TK_OPTION_RELIEF, "-offrelief", "offRelief", "OffRelief",
- DEF_BUTTON_RELIEF, -1, Tk_Offset(TkButton, offRelief), 0, 0, 0},
+ DEF_BUTTON_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, offRelief), 0, 0, 0},
{TK_OPTION_RELIEF, "-overrelief", "overRelief", "OverRelief",
- DEF_BUTTON_OVER_RELIEF, -1, Tk_Offset(TkButton, overRelief),
+ DEF_BUTTON_OVER_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, overRelief),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-padx", "padX", "Pad",
- tkDefLabelPadx, Tk_Offset(TkButton, padXPtr),
- Tk_Offset(TkButton, padX), 0, 0, 0},
+ tkDefLabelPadx, offsetof(TkButton, padXPtr),
+ offsetof(TkButton, padX), 0, 0, 0},
{TK_OPTION_PIXELS, "-pady", "padY", "Pad",
- tkDefLabelPady, Tk_Offset(TkButton, padYPtr),
- Tk_Offset(TkButton, padY), 0, 0, 0},
+ tkDefLabelPady, offsetof(TkButton, padYPtr),
+ offsetof(TkButton, padY), 0, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_LABCHKRAD_RELIEF, -1, Tk_Offset(TkButton, relief), 0, 0, 0},
+ DEF_LABCHKRAD_RELIEF, TCL_INDEX_NONE, offsetof(TkButton, relief), 0, 0, 0},
{TK_OPTION_BORDER, "-selectcolor", "selectColor", "Background",
- DEF_BUTTON_SELECT_COLOR, -1, Tk_Offset(TkButton, selectBorder),
+ DEF_BUTTON_SELECT_COLOR, TCL_INDEX_NONE, offsetof(TkButton, selectBorder),
TK_OPTION_NULL_OK, DEF_BUTTON_SELECT_MONO, 0},
{TK_OPTION_STRING, "-selectimage", "selectImage", "SelectImage",
- DEF_BUTTON_SELECT_IMAGE, Tk_Offset(TkButton, selectImagePtr), -1,
+ DEF_BUTTON_SELECT_IMAGE, offsetof(TkButton, selectImagePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING_TABLE, "-state", "state", "State",
- DEF_BUTTON_STATE, -1, Tk_Offset(TkButton, state),
+ DEF_BUTTON_STATE, TCL_INDEX_NONE, offsetof(TkButton, state),
0, stateStrings, 0},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_BUTTON_TAKE_FOCUS, Tk_Offset(TkButton, takeFocusPtr), -1,
+ DEF_BUTTON_TAKE_FOCUS, offsetof(TkButton, takeFocusPtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-text", "text", "Text",
- DEF_BUTTON_TEXT, Tk_Offset(TkButton, textPtr), -1, 0, 0, 0},
+ DEF_BUTTON_TEXT, offsetof(TkButton, textPtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_STRING, "-textvariable", "textVariable", "Variable",
- DEF_BUTTON_TEXT_VARIABLE, Tk_Offset(TkButton, textVarNamePtr), -1,
+ DEF_BUTTON_TEXT_VARIABLE, offsetof(TkButton, textVarNamePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-tristateimage", "tristateImage", "TristateImage",
- DEF_BUTTON_IMAGE, Tk_Offset(TkButton, tristateImagePtr), -1,
+ DEF_BUTTON_IMAGE, offsetof(TkButton, tristateImagePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-tristatevalue", "tristateValue", "TristateValue",
- DEF_BUTTON_TRISTATE_VALUE, Tk_Offset(TkButton, tristateValuePtr), -1, 0, 0, 0},
+ DEF_BUTTON_TRISTATE_VALUE, offsetof(TkButton, tristateValuePtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_INT, "-underline", "underline", "Underline",
- DEF_BUTTON_UNDERLINE, -1, Tk_Offset(TkButton, underline), 0, 0, 0},
+ DEF_BUTTON_UNDERLINE, TCL_INDEX_NONE, offsetof(TkButton, underline), 0, 0, 0},
{TK_OPTION_STRING, "-value", "value", "Value",
- DEF_BUTTON_VALUE, Tk_Offset(TkButton, onValuePtr), -1, 0, 0, 0},
+ DEF_BUTTON_VALUE, offsetof(TkButton, onValuePtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_STRING, "-variable", "variable", "Variable",
- DEF_RADIOBUTTON_VARIABLE, Tk_Offset(TkButton, selVarNamePtr), -1,
+ DEF_RADIOBUTTON_VARIABLE, offsetof(TkButton, selVarNamePtr), TCL_INDEX_NONE,
0, 0, 0},
{TK_OPTION_STRING, "-width", "width", "Width",
- DEF_BUTTON_WIDTH, Tk_Offset(TkButton, widthPtr), -1, 0, 0, 0},
+ DEF_BUTTON_WIDTH, offsetof(TkButton, widthPtr), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength",
- DEF_BUTTON_WRAP_LENGTH, Tk_Offset(TkButton, wrapLengthPtr),
- Tk_Offset(TkButton, wrapLength), 0, 0, 0},
- {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0}
+ DEF_BUTTON_WRAP_LENGTH, offsetof(TkButton, wrapLengthPtr),
+ offsetof(TkButton, wrapLength), 0, 0, 0},
+ {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0}
};
/*
@@ -628,7 +628,7 @@ Tk_RadiobuttonObjCmd(
static int
ButtonCreate(
- ClientData clientData, /* NULL. */
+ ClientData dummy, /* NULL. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[], /* Argument values. */
@@ -639,8 +639,9 @@ ButtonCreate(
TkButton *butPtr;
Tk_OptionTable optionTable;
Tk_Window tkwin;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ (void)dummy;
if (!tsdPtr->defaultsInitialized) {
TkpButtonSetDefaults();
@@ -749,7 +750,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;
@@ -759,7 +760,7 @@ ButtonCreate(
return TCL_ERROR;
}
- Tcl_SetObjResult(interp, TkNewWindowObj(butPtr->tkwin));
+ Tcl_SetObjResult(interp, Tk_NewWindowObj(butPtr->tkwin));
return TCL_OK;
}
@@ -788,7 +789,7 @@ ButtonWidgetObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument values. */
{
- TkButton *butPtr = clientData;
+ TkButton *butPtr = (TkButton *)clientData;
int index;
int result;
Tcl_Obj *objPtr;
@@ -810,7 +811,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;
@@ -820,7 +821,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) {
@@ -1036,7 +1037,7 @@ DestroyButton(
static int
ConfigureButton(
Tcl_Interp *interp, /* Used for error reporting. */
- register TkButton *butPtr, /* Information about widget; may or may
+ TkButton *butPtr, /* Information about widget; may or may
* not already have values for some fields. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument values. */
@@ -1074,7 +1075,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;
@@ -1126,7 +1127,7 @@ ConfigureButton(
if (butPtr->selVarNamePtr == NULL) {
butPtr->selVarNamePtr = Tcl_NewStringObj(
- Tk_Name(butPtr->tkwin), -1);
+ Tk_Name(butPtr->tkwin), TCL_INDEX_NONE);
Tcl_IncrRefCount(butPtr->selVarNamePtr);
}
namePtr = butPtr->selVarNamePtr;
@@ -1348,7 +1349,7 @@ TkButtonWorldChanged(
XGCValues gcValues;
GC newGC;
unsigned long mask;
- TkButton *butPtr = instanceData;
+ TkButton *butPtr = (TkButton *)instanceData;
/*
* Recompute GCs.
@@ -1459,7 +1460,7 @@ ButtonEventProc(
ClientData clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
- TkButton *butPtr = clientData;
+ TkButton *butPtr = (TkButton *)clientData;
if ((eventPtr->type == Expose) && (eventPtr->xexpose.count == 0)) {
goto redraw;
} else if (eventPtr->type == ConfigureNotify) {
@@ -1517,7 +1518,7 @@ static void
ButtonCmdDeletedProc(
ClientData clientData) /* Pointer to widget record for widget. */
{
- TkButton *butPtr = clientData;
+ TkButton *butPtr = (TkButton *)clientData;
/*
* This function could be invoked either because the window was destroyed
@@ -1603,7 +1604,6 @@ TkInvokeButton(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static char *
ButtonVarProc(
ClientData clientData, /* Information about button. */
@@ -1612,9 +1612,11 @@ ButtonVarProc(
const char *name2, /* Second part of variable name. */
int flags) /* Information about what happened. */
{
- register TkButton *butPtr = clientData;
+ TkButton *butPtr = (TkButton *)clientData;
const char *value;
Tcl_Obj *valuePtr;
+ (void)name1;
+ (void)name2;
/*
* If the variable is being unset, then just re-establish the trace unless
@@ -1713,7 +1715,6 @@ ButtonVarProc(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static char *
ButtonTextVarProc(
ClientData clientData, /* Information about button. */
@@ -1722,8 +1723,10 @@ ButtonTextVarProc(
const char *name2, /* Not used. */
int flags) /* Information about what happened. */
{
- TkButton *butPtr = clientData;
+ TkButton *butPtr = (TkButton *)clientData;
Tcl_Obj *valuePtr;
+ (void)name1;
+ (void)name2;
if (butPtr->flags & BUTTON_DELETED) {
return NULL;
@@ -1817,7 +1820,13 @@ ButtonImageProc(
* <= 0). */
int imgWidth, int imgHeight)/* New dimensions of image. */
{
- register TkButton *butPtr = clientData;
+ TkButton *butPtr = (TkButton *)clientData;
+ (void)x;
+ (void)y;
+ (void)width;
+ (void)height;
+ (void)imgWidth;
+ (void)imgHeight;
if (butPtr->tkwin != NULL) {
TkpComputeButtonGeometry(butPtr);
@@ -1855,7 +1864,13 @@ ButtonSelectImageProc(
* <= 0). */
int imgWidth, int imgHeight)/* New dimensions of image. */
{
- register TkButton *butPtr = clientData;
+ TkButton *butPtr = (TkButton *)clientData;
+ (void)x;
+ (void)y;
+ (void)width;
+ (void)height;
+ (void)imgWidth;
+ (void)imgHeight;
#ifdef MAC_OSX_TK
if (butPtr->tkwin != NULL) {
@@ -1902,7 +1917,13 @@ ButtonTristateImageProc(
* <= 0). */
int imgWidth, int imgHeight)/* New dimensions of image. */
{
- register TkButton *butPtr = clientData;
+ TkButton *butPtr = (TkButton *)clientData;
+ (void)x;
+ (void)y;
+ (void)width;
+ (void)height;
+ (void)imgWidth;
+ (void)imgHeight;
#ifdef MAC_OSX_TK
if (butPtr->tkwin != NULL) {
diff --git a/generic/tkCanvArc.c b/generic/tkCanvArc.c
index ccfe116..257dcfc 100644
--- a/generic/tkCanvArc.c
+++ b/generic/tkCanvArc.c
@@ -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;
/*
@@ -80,9 +88,9 @@ typedef struct ArcItem {
static int StyleParseProc(ClientData clientData, Tcl_Interp *interp,
Tk_Window tkwin, const char *value,
- char *widgRec, int offset);
+ char *widgRec, TkSizeT offset);
static const char * StylePrintProc(ClientData clientData, Tk_Window tkwin,
- char *widgRec, int offset, Tcl_FreeProc **freeProcPtr);
+ char *widgRec, TkSizeT offset, Tcl_FreeProc **freeProcPtr);
static const Tk_CustomOption stateOption = {
TkStateParseProc, TkStatePrintProc, INT2PTR(2)
@@ -91,7 +99,7 @@ static const Tk_CustomOption styleOption = {
StyleParseProc, StylePrintProc, NULL
};
static const Tk_CustomOption tagsOption = {
- Tk_CanvasTagsParseProc, Tk_CanvasTagsPrintProc, NULL
+ TkCanvasTagsParseProc, TkCanvasTagsPrintProc, NULL
};
static const Tk_CustomOption dashOption = {
TkCanvasDashParseProc, TkCanvasDashPrintProc, NULL
@@ -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}
};
@@ -176,6 +186,7 @@ static void ComputeArcBbox(Tk_Canvas canvas, ArcItem *arcPtr);
static int ConfigureArc(Tcl_Interp *interp,
Tk_Canvas canvas, Tk_Item *itemPtr, int objc,
Tcl_Obj *const objv[], int flags);
+static void ComputeArcParametersFromHeight(ArcItem *arcPtr);
static int CreateArc(Tcl_Interp *interp,
Tk_Canvas canvas, struct Tk_Item *itemPtr,
int objc, Tcl_Obj *const objv[]);
@@ -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
};
/*
@@ -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.
@@ -375,6 +390,17 @@ 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(
@@ -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,14 +507,6 @@ 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));
if (mask) {
gcValues.cap_style = CapButt;
@@ -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.
@@ -1898,18 +2083,14 @@ ArcToPostscript(
ang1, ang2);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsColor(interp, canvas, fillColor) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsColor(interp, canvas, fillColor);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (fillStipple != None) {
Tcl_AppendToObj(psObj, "clip ", -1);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsStipple(interp, canvas, fillStipple) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsStipple(interp, canvas, fillStipple);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (arcPtr->outline.gc != NULL) {
@@ -1935,9 +2116,7 @@ ArcToPostscript(
ang1, ang2);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsOutline(canvas, itemPtr, &arcPtr->outline) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsOutline(canvas, itemPtr, &arcPtr->outline);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (arcPtr->style != ARC_STYLE) {
@@ -1950,18 +2129,14 @@ ArcToPostscript(
} else {
Tk_CanvasPsPath(interp, canvas, arcPtr->outlinePtr,
PIE_OUTLINE1_PTS);
- if (Tk_CanvasPsColor(interp, canvas, color) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsColor(interp, canvas, color);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (stipple != None) {
Tcl_AppendToObj(psObj, "clip ", -1);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsStipple(interp, canvas, stipple) !=TCL_OK){
- goto error;
- }
+ Tk_CanvasPsStipple(interp, canvas, stipple);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
} else {
Tcl_AppendToObj(psObj, "fill\n", -1);
@@ -1973,18 +2148,14 @@ ArcToPostscript(
arcPtr->outlinePtr + 2*PIE_OUTLINE1_PTS,
PIE_OUTLINE2_PTS);
}
- if (Tk_CanvasPsColor(interp, canvas, color) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsColor(interp, canvas, color);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (stipple != None) {
Tcl_AppendToObj(psObj, "clip ", -1);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsStipple(interp, canvas, stipple) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsStipple(interp, canvas, stipple);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
} else {
Tcl_AppendToObj(psObj, "fill\n", -1);
@@ -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. */
+ TkSizeT offset) /* Offset into item. */
{
int c;
size_t length;
@@ -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. */
+ TkSizeT 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..b2dc012 100644
--- a/generic/tkCanvBmap.c
+++ b/generic/tkCanvBmap.c
@@ -45,35 +45,35 @@ static const Tk_CustomOption stateOption = {
TkStateParseProc, TkStatePrintProc, INT2PTR(2)
};
static const Tk_CustomOption tagsOption = {
- Tk_CanvasTagsParseProc, Tk_CanvasTagsPrintProc, NULL
+ TkCanvasTagsParseProc, TkCanvasTagsPrintProc, NULL
};
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},
@@ -106,6 +106,8 @@ static void DeleteBitmap(Tk_Canvas canvas,
static void DisplayBitmap(Tk_Canvas canvas,
Tk_Item *itemPtr, Display *display, Drawable dst,
int x, int y, int width, int height);
+static void RotateBitmap(Tk_Canvas canvas, Tk_Item *itemPtr,
+ double originX, double originY, double angleRad);
static void ScaleBitmap(Tk_Canvas canvas,
Tk_Item *itemPtr, double originX, double originY,
double scaleX, double scaleY);
@@ -138,7 +140,8 @@ Tk_ItemType tkBitmapType = {
NULL, /* insertProc */
NULL, /* dTextProc */
NULL, /* nextPtr */
- NULL, 0, NULL, NULL
+ RotateBitmap, /* rotateProc */
+ 0, NULL, NULL
};
/*
@@ -419,6 +422,7 @@ DeleteBitmap(
Display *display) /* Display containing window for canvas. */
{
BitmapItem *bmapPtr = (BitmapItem *) itemPtr;
+ (void)canvas;
if (bmapPtr->bitmap != None) {
Tk_FreeBitmap(display, bmapPtr->bitmap);
@@ -470,7 +474,6 @@ DeleteBitmap(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static void
ComputeBitmapBbox(
Tk_Canvas canvas, /* Canvas that contains item. */
@@ -668,7 +671,6 @@ DisplayBitmap(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static double
BitmapToPoint(
Tk_Canvas canvas, /* Canvas containing item. */
@@ -677,6 +679,7 @@ BitmapToPoint(
{
BitmapItem *bmapPtr = (BitmapItem *) itemPtr;
double x1, x2, y1, y2, xDiff, yDiff;
+ (void)canvas;
x1 = bmapPtr->header.x1;
y1 = bmapPtr->header.y1;
@@ -725,7 +728,6 @@ BitmapToPoint(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static int
BitmapToArea(
Tk_Canvas canvas, /* Canvas containing item. */
@@ -735,6 +737,7 @@ BitmapToArea(
* area. */
{
BitmapItem *bmapPtr = (BitmapItem *) itemPtr;
+ (void)canvas;
if ((rectPtr[2] <= bmapPtr->header.x1)
|| (rectPtr[0] >= bmapPtr->header.x2)
@@ -791,6 +794,39 @@ ScaleBitmap(
/*
*--------------------------------------------------------------
*
+ * RotateBitmap --
+ *
+ * This function is called to rotate a bitmap's origin by a given amount.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * The position of the bitmap is rotated by angleRad radians about
+ * (originX, originY), and the bounding box is updated in the generic
+ * part of the item structure.
+ *
+ *--------------------------------------------------------------
+ */
+
+static void
+RotateBitmap(
+ Tk_Canvas canvas,
+ Tk_Item *itemPtr,
+ double originX,
+ double originY,
+ double angleRad)
+{
+ BitmapItem *bmapPtr = (BitmapItem *) itemPtr;
+
+ TkRotatePoint(originX, originY, sin(angleRad), cos(angleRad),
+ &bmapPtr->x, &bmapPtr->y);
+ ComputeBitmapBbox(canvas, bmapPtr);
+}
+
+/*
+ *--------------------------------------------------------------
+ *
* TranslateBitmap --
*
* This function is called to move an item by a given amount.
@@ -857,6 +893,7 @@ BitmapToPostscript(
Tk_State state = itemPtr->state;
Tcl_Obj *psObj;
Tcl_InterpState interpState;
+ (void)prepass;
if (state == TK_STATE_NULL) {
state = Canvas(canvas)->canvas_state;
@@ -929,9 +966,7 @@ BitmapToPostscript(
x, y, width, height, -width);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsColor(interp, canvas, bgColor) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsColor(interp, canvas, bgColor);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
Tcl_AppendToObj(psObj, "fill\n", -1);
@@ -946,9 +981,7 @@ BitmapToPostscript(
if (fgColor != NULL) {
Tcl_ResetResult(interp);
- if (Tk_CanvasPsColor(interp, canvas, fgColor) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsColor(interp, canvas, fgColor);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (width > 60000) {
@@ -977,10 +1010,8 @@ BitmapToPostscript(
(double) rowsThisTime, width, rowsThisTime);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsBitmap(interp, canvas, bitmap,
- 0, curRow, width, rowsThisTime) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsBitmap(interp, canvas, bitmap, 0, curRow, width,
+ rowsThisTime);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
Tcl_AppendToObj(psObj, "\n} imagemask\n", -1);
diff --git a/generic/tkCanvImg.c b/generic/tkCanvImg.c
index 70b9c79..53e9c25 100644
--- a/generic/tkCanvImg.c
+++ b/generic/tkCanvImg.c
@@ -47,20 +47,20 @@ static const Tk_CustomOption stateOption = {
TkStateParseProc, TkStatePrintProc, INT2PTR(2)
};
static const Tk_CustomOption tagsOption = {
- Tk_CanvasTagsParseProc, Tk_CanvasTagsPrintProc, NULL
+ TkCanvasTagsParseProc, TkCanvasTagsPrintProc, NULL
};
static const Tk_ConfigSpec configSpecs[] = {
{TK_CONFIG_STRING, "-activeimage", NULL, NULL,
- NULL, Tk_Offset(ImageItem, activeImageString), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ImageItem, activeImageString), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_ANCHOR, "-anchor", NULL, NULL,
- "center", Tk_Offset(ImageItem, anchor), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "center", offsetof(ImageItem, anchor), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_STRING, "-disabledimage", NULL, NULL,
- NULL, Tk_Offset(ImageItem, disabledImageString), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ImageItem, disabledImageString), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_STRING, "-image", NULL, NULL,
- NULL, Tk_Offset(ImageItem, imageString), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(ImageItem, imageString), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-state", NULL, NULL,
- NULL, Tk_Offset(Tk_Item, state), TK_CONFIG_NULL_OK, &stateOption},
+ NULL, offsetof(Tk_Item, state), TK_CONFIG_NULL_OK, &stateOption},
{TK_CONFIG_CUSTOM, "-tags", NULL, NULL,
NULL, 0, TK_CONFIG_NULL_OK, &tagsOption},
{TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}
@@ -94,6 +94,8 @@ static void DeleteImage(Tk_Canvas canvas,
static void DisplayImage(Tk_Canvas canvas,
Tk_Item *itemPtr, Display *display, Drawable dst,
int x, int y, int width, int height);
+static void RotateImage(Tk_Canvas canvas, Tk_Item *itemPtr,
+ double originX, double originY, double angleRad);
static void ScaleImage(Tk_Canvas canvas,
Tk_Item *itemPtr, double originX, double originY,
double scaleX, double scaleY);
@@ -126,7 +128,8 @@ Tk_ItemType tkImageType = {
NULL, /* insertProc */
NULL, /* dTextProc */
NULL, /* nextPtr */
- NULL, 0, NULL, NULL
+ RotateImage, /* rotateProc */
+ 0, NULL, NULL
};
/*
@@ -382,6 +385,8 @@ DeleteImage(
Display *display) /* Display containing window for canvas. */
{
ImageItem *imgPtr = (ImageItem *) itemPtr;
+ (void)canvas;
+ (void)display;
if (imgPtr->imageString != NULL) {
ckfree(imgPtr->imageString);
@@ -421,7 +426,6 @@ DeleteImage(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static void
ComputeImageBbox(
Tk_Canvas canvas, /* Canvas that contains item. */
@@ -534,6 +538,7 @@ DisplayImage(
short drawableX, drawableY;
Tk_Image image;
Tk_State state = itemPtr->state;
+ (void)display;
if (state == TK_STATE_NULL) {
state = Canvas(canvas)->canvas_state;
@@ -592,6 +597,7 @@ ImageToPoint(
{
ImageItem *imgPtr = (ImageItem *) itemPtr;
double x1, x2, y1, y2, xDiff, yDiff;
+ (void)canvas;
x1 = imgPtr->header.x1;
y1 = imgPtr->header.y1;
@@ -649,6 +655,7 @@ ImageToArea(
* area. */
{
ImageItem *imgPtr = (ImageItem *) itemPtr;
+ (void)canvas;
if ((rectPtr[2] <= imgPtr->header.x1)
|| (rectPtr[0] >= imgPtr->header.x2)
@@ -761,6 +768,40 @@ ImageToPostscript(
/*
*--------------------------------------------------------------
*
+ * RotateImage --
+ *
+ * This function is called to rotate an image's origin by a given amount.
+ * This does *not* rotate the contents of the image.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * The position of the image anchor is rotated by angleRad radians about
+ * (originX, originY), and the bounding box is updated in the generic
+ * part of the item structure.
+ *
+ *--------------------------------------------------------------
+ */
+
+static void
+RotateImage(
+ Tk_Canvas canvas,
+ Tk_Item *itemPtr,
+ double originX,
+ double originY,
+ double angleRad)
+{
+ ImageItem *imgPtr = (ImageItem *) itemPtr;
+
+ TkRotatePoint(originX, originY, sin(angleRad), cos(angleRad),
+ &imgPtr->x, &imgPtr->y);
+ ComputeImageBbox(canvas, imgPtr);
+}
+
+/*
+ *--------------------------------------------------------------
+ *
* ScaleImage --
*
* This function is invoked to rescale an item.
@@ -851,7 +892,7 @@ ImageChangedProc(
* 0). */
int imgWidth, int imgHeight)/* New dimensions of image. */
{
- ImageItem *imgPtr = clientData;
+ ImageItem *imgPtr = (ImageItem *)clientData;
/*
* If the image's size changed and it's not anchored at its northwest
diff --git a/generic/tkCanvLine.c b/generic/tkCanvLine.c
index ba7753e..28764d8 100644
--- a/generic/tkCanvLine.c
+++ b/generic/tkCanvLine.c
@@ -92,14 +92,14 @@ 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, TkSizeT *indexPtr);
static int LineCoords(Tcl_Interp *interp,
Tk_Canvas canvas, Tk_Item *itemPtr,
int objc, Tcl_Obj *const objv[]);
static void LineDeleteCoords(Tk_Canvas canvas,
- Tk_Item *itemPtr, int first, int last);
+ Tk_Item *itemPtr, TkSizeT first, TkSizeT last);
static void LineInsert(Tk_Canvas canvas,
- Tk_Item *itemPtr, int beforeThis, Tcl_Obj *obj);
+ Tk_Item *itemPtr, TkSizeT beforeThis, Tcl_Obj *obj);
static int LineToArea(Tk_Canvas canvas,
Tk_Item *itemPtr, double *rectPtr);
static double LineToPoint(Tk_Canvas canvas,
@@ -108,16 +108,18 @@ static int LineToPostscript(Tcl_Interp *interp,
Tk_Canvas canvas, Tk_Item *itemPtr, int prepass);
static int ArrowParseProc(ClientData clientData,
Tcl_Interp *interp, Tk_Window tkwin,
- const char *value, char *recordPtr, int offset);
+ const char *value, char *recordPtr, TkSizeT offset);
static const char * ArrowPrintProc(ClientData clientData,
- Tk_Window tkwin, char *recordPtr, int offset,
+ Tk_Window tkwin, char *recordPtr, TkSizeT offset,
Tcl_FreeProc **freeProcPtr);
static int ParseArrowShape(ClientData clientData,
Tcl_Interp *interp, Tk_Window tkwin,
- const char *value, char *recordPtr, int offset);
+ const char *value, char *recordPtr, TkSizeT offset);
static const char * PrintArrowShape(ClientData clientData,
- Tk_Window tkwin, char *recordPtr, int offset,
+ Tk_Window tkwin, char *recordPtr, TkSizeT 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);
@@ -143,7 +145,7 @@ static const Tk_CustomOption stateOption = {
TkStateParseProc, TkStatePrintProc, INT2PTR(2)
};
static const Tk_CustomOption tagsOption = {
- Tk_CanvasTagsParseProc, Tk_CanvasTagsPrintProc, NULL
+ TkCanvasTagsParseProc, TkCanvasTagsPrintProc, NULL
};
static const Tk_CustomOption dashOption = {
TkCanvasDashParseProc, TkCanvasDashPrintProc, NULL
@@ -158,58 +160,58 @@ static const Tk_CustomOption pixelOption = {
static const Tk_ConfigSpec configSpecs[] = {
{TK_CONFIG_CUSTOM, "-activedash", NULL, NULL,
- NULL, Tk_Offset(LineItem, outline.activeDash),
+ NULL, offsetof(LineItem, outline.activeDash),
TK_CONFIG_NULL_OK, &dashOption},
{TK_CONFIG_COLOR, "-activefill", NULL, NULL,
- NULL, Tk_Offset(LineItem, outline.activeColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(LineItem, outline.activeColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-activestipple", NULL, NULL,
- NULL, Tk_Offset(LineItem, outline.activeStipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(LineItem, outline.activeStipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-activewidth", NULL, NULL,
- "0.0", Tk_Offset(LineItem, outline.activeWidth),
+ "0.0", offsetof(LineItem, outline.activeWidth),
TK_CONFIG_DONT_SET_DEFAULT, &pixelOption},
{TK_CONFIG_CUSTOM, "-arrow", NULL, NULL,
- "none", Tk_Offset(LineItem, arrow),
+ "none", offsetof(LineItem, arrow),
TK_CONFIG_DONT_SET_DEFAULT, &arrowOption},
{TK_CONFIG_CUSTOM, "-arrowshape", NULL, NULL,
- "8 10 3", Tk_Offset(LineItem, arrowShapeA),
+ "8 10 3", offsetof(LineItem, arrowShapeA),
TK_CONFIG_DONT_SET_DEFAULT, &arrowShapeOption},
{TK_CONFIG_CAP_STYLE, "-capstyle", NULL, NULL,
- "butt", Tk_Offset(LineItem, capStyle), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "butt", offsetof(LineItem, capStyle), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_COLOR, "-fill", NULL, NULL,
- 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}
};
@@ -240,7 +242,8 @@ Tk_ItemType tkLineType = {
LineInsert, /* insertProc */
LineDeleteCoords, /* dTextProc */
NULL, /* nextPtr */
- NULL, 0, NULL, NULL
+ RotateLine, /* rotateProc */
+ 0, NULL, NULL
};
/*
@@ -833,9 +836,9 @@ DisplayLine(
TCL_UNUSED(int), /* Describes region of canvas that must be */
TCL_UNUSED(int), /* redisplayed (not used). */
TCL_UNUSED(int),
- TCL_UNUSED(int))
+ TCL_UNUSED(int))
{
- LineItem *linePtr = (LineItem *) itemPtr;
+ LineItem *linePtr = (LineItem *)itemPtr;
XPoint staticPoints[MAX_STATIC_POINTS*3];
XPoint *pointPtr;
double linewidth;
@@ -952,7 +955,7 @@ 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
+ TkSizeT beforeThis, /* Index before which new coordinates are to
* be inserted. */
Tcl_Obj *obj) /* New coordinates to be inserted. */
{
@@ -971,10 +974,10 @@ LineInsert(
return;
}
length = 2*linePtr->numPoints;
- if (beforeThis < 0) {
+ if (beforeThis == TCL_INDEX_NONE) {
beforeThis = 0;
}
- if (beforeThis > length) {
+ if (beforeThis + 1 > (TkSizeT)length + 1) {
beforeThis = length;
}
if (linePtr->firstArrowPtr != NULL) {
@@ -986,7 +989,7 @@ LineInsert(
linePtr->coordPtr[length-1] = linePtr->lastArrowPtr[1];
}
newCoordPtr = (double *)ckalloc(sizeof(double) * (length + objc));
- for (i=0; i<beforeThis; i++) {
+ for (i=0; i<(int)beforeThis; i++) {
newCoordPtr[i] = linePtr->coordPtr[i];
}
for (i=0; i<objc; i++) {
@@ -1020,25 +1023,25 @@ LineInsert(
itemPtr->redraw_flags |= TK_ITEM_DONT_REDRAW;
- if (beforeThis > 0) {
+ if ((int)beforeThis > 0) {
beforeThis -= 2;
objc += 2;
}
- if (beforeThis+objc < length) {
+ if ((int)beforeThis+objc < length) {
objc += 2;
}
if (linePtr->smooth) {
- if (beforeThis > 0) {
+ if ((int)beforeThis > 0) {
beforeThis -= 2;
objc += 2;
}
- if (beforeThis+objc+2 < length) {
+ if ((int)beforeThis+objc+2 < length) {
objc += 2;
}
}
itemPtr->x1 = itemPtr->x2 = (int) linePtr->coordPtr[beforeThis];
itemPtr->y1 = itemPtr->y2 = (int) linePtr->coordPtr[beforeThis+1];
- if ((linePtr->firstArrowPtr != NULL) && (beforeThis < 1)) {
+ if ((linePtr->firstArrowPtr != NULL) && ((int)beforeThis < 1)) {
/*
* Include old first arrow.
*/
@@ -1048,7 +1051,7 @@ LineInsert(
TkIncludePoint(itemPtr, coordPtr);
}
}
- if ((linePtr->lastArrowPtr != NULL) && (beforeThis+objc >= length)) {
+ if ((linePtr->lastArrowPtr != NULL) && ((int)beforeThis+objc >= length)) {
/*
* Include old last arrow.
*/
@@ -1080,7 +1083,7 @@ LineInsert(
double width;
int intWidth;
- if ((linePtr->firstArrowPtr != NULL) && (beforeThis > 2)) {
+ if ((linePtr->firstArrowPtr != NULL) && ((int)beforeThis > 2)) {
/*
* Include new first arrow.
*/
@@ -1090,7 +1093,7 @@ LineInsert(
TkIncludePoint(itemPtr, coordPtr);
}
}
- if ((linePtr->lastArrowPtr != NULL) && (beforeThis+objc < length-2)) {
+ if ((linePtr->lastArrowPtr != NULL) && ((int)beforeThis+objc < length-2)) {
/*
* Include new right arrow.
*/
@@ -1146,8 +1149,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. */
+ TkSizeT first, /* Index of first character to delete. */
+ TkSizeT last) /* Index of last character to delete. */
{
LineItem *linePtr = (LineItem *) itemPtr;
int count, i, first1, last1;
@@ -1162,13 +1165,13 @@ LineDeleteCoords(
first &= -2;
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;
}
if (linePtr->firstArrowPtr != NULL) {
@@ -1738,18 +1741,28 @@ GetLineIndex(
* specified. */
Tcl_Obj *obj, /* Specification of a particular coord in
* itemPtr's line. */
- int *indexPtr) /* Where to store converted index. */
+ TkSizeT *indexPtr) /* Where to store converted index. */
{
+ TkSizeT idx, length;
LineItem *linePtr = (LineItem *) itemPtr;
- const char *string = Tcl_GetString(obj);
-
- if (string[0] == 'e') {
- if (strncmp(string, "end", obj->length) == 0) {
- *indexPtr = 2*linePtr->numPoints;
+ const char *string;
+ (void)canvas;
+
+ if (TCL_OK == TkGetIntForIndex(obj, 2*linePtr->numPoints - 1, 0, &idx)) {
+ if (idx == TCL_INDEX_NONE) {
+ idx = 0;
+ } else if (idx > (2*(TkSizeT)linePtr->numPoints)) {
+ idx = 2*linePtr->numPoints;
} else {
- goto badIndex;
+ idx &= (TkSizeT)-2; /* If index is odd, make it even. */
}
- } else if (string[0] == '@') {
+ *indexPtr = idx;
+ return TCL_OK;
+ }
+
+ string = TkGetStringFromObj(obj, &length);
+
+ if (string[0] == '@') {
int i;
double x, y, bestDist, dist, *coordPtr;
char *end;
@@ -1777,28 +1790,18 @@ GetLineIndex(
coordPtr += 2;
}
} else {
- if (Tcl_GetIntFromObj(interp, obj, indexPtr) != TCL_OK) {
- goto badIndex;
- }
- *indexPtr &= -2; /* If index is odd, make it even. */
- if (*indexPtr < 0){
- *indexPtr = 0;
- } else if (*indexPtr > (2*linePtr->numPoints)) {
- *indexPtr = (2*linePtr->numPoints);
- }
- }
- return TCL_OK;
- /*
- * Some of the paths here leave messages in interp->result, so we have to
- * clear it out before storing our own message.
- */
+ /*
+ * Some of the paths here leave messages in interp->result, so we have to
+ * clear it out before storing our own message.
+ */
- badIndex:
- Tcl_ResetResult(interp);
- Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad index \"%s\"", string));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "ITEM_INDEX", "LINE", NULL);
- return TCL_ERROR;
+ badIndex:
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad index \"%s\"", string));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "ITEM_INDEX", "LINE", NULL);
+ return TCL_ERROR;
+ }
+ return TCL_OK;
}
/*
@@ -1854,6 +1857,56 @@ TranslateLine(
/*
*--------------------------------------------------------------
*
+ * RotateLine --
+ *
+ * This function is called to rotate a line by a given amount about a
+ * point.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * The position of the line is rotated by angleRad about (originX,
+ * originY), and the bounding box is updated in the generic part of the
+ * item structure.
+ *
+ *--------------------------------------------------------------
+ */
+
+static void
+RotateLine(
+ Tk_Canvas canvas, /* Canvas containing item. */
+ Tk_Item *itemPtr, /* Item that is being moved. */
+ double originX, double originY,
+ double angleRad) /* Amount by which item is to be rotated. */
+{
+ LineItem *linePtr = (LineItem *) itemPtr;
+ double *coordPtr;
+ int i;
+ double s = sin(angleRad), c = cos(angleRad);
+
+ for (i = 0, coordPtr = linePtr->coordPtr; i < linePtr->numPoints;
+ i++, coordPtr += 2) {
+ TkRotatePoint(originX, originY, s, c, &coordPtr[0], &coordPtr[1]);
+ }
+ if (linePtr->firstArrowPtr != NULL) {
+ for (i = 0, coordPtr = linePtr->firstArrowPtr; i < PTS_IN_ARROW;
+ i++, coordPtr += 2) {
+ TkRotatePoint(originX, originY, s, c, &coordPtr[0], &coordPtr[1]);
+ }
+ }
+ if (linePtr->lastArrowPtr != NULL) {
+ for (i = 0, coordPtr = linePtr->lastArrowPtr; i < PTS_IN_ARROW;
+ i++, coordPtr += 2) {
+ TkRotatePoint(originX, originY, s, c, &coordPtr[0], &coordPtr[1]);
+ }
+ }
+ ComputeLineBbox(canvas, linePtr);
+}
+
+/*
+ *--------------------------------------------------------------
+ *
* ParseArrowShape --
*
* This function is called back during option parsing to parse arrow
@@ -1878,7 +1931,7 @@ 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
+ TkSizeT offset) /* Offset of shape information in widget
* record. */
{
LineItem *linePtr = (LineItem *) recordPtr;
@@ -1886,7 +1939,7 @@ ParseArrowShape(
int argc;
const char **argv = NULL;
- if (offset != Tk_Offset(LineItem, arrowShapeA)) {
+ if ((size_t)offset != offsetof(LineItem, arrowShapeA)) {
Tcl_Panic("ParseArrowShape received bogus offset");
}
@@ -1944,12 +1997,12 @@ 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(TkSizeT), /* Offset of arrow information in record. */
Tcl_FreeProc **freeProcPtr) /* Store address of function to call to free
* string here. */
{
LineItem *linePtr = (LineItem *) recordPtr;
- char *buffer = ckalloc(120);
+ char *buffer = (char *)ckalloc(120);
sprintf(buffer, "%.5g %.5g %.5g", linePtr->arrowShapeA,
linePtr->arrowShapeB, linePtr->arrowShapeC);
@@ -1982,7 +2035,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. */
+ TkSizeT offset) /* Offset into item. */
{
int c;
size_t length;
@@ -2047,7 +2100,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. */
+ TkSizeT offset, /* Offset into item. */
TCL_UNUSED(Tcl_FreeProc **)) /* Pointer to variable to fill in with
* information about how to reclaim storage
* for return string. */
@@ -2313,17 +2366,13 @@ LineToPostscript(
" scale 1 0 moveto 0 0 1 0 360 arc\nsetmatrix\n", -1);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsColor(interp, canvas, color) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsColor(interp, canvas, color);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (stipple != None) {
Tcl_AppendToObj(psObj, "clip ", -1);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsStipple(interp, canvas, stipple) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsStipple(interp, canvas, stipple);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
} else {
Tcl_AppendToObj(psObj, "fill\n", -1);
@@ -2392,9 +2441,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));
/*
@@ -2405,19 +2452,15 @@ LineToPostscript(
if (stipple != None) {
Tcl_AppendToObj(psObj, "grestore gsave\n", -1);
}
- if (ArrowheadPostscript(interp, canvas, linePtr,
- linePtr->firstArrowPtr, psObj) != TCL_OK) {
- goto error;
- }
+ ArrowheadPostscript(interp, canvas, linePtr,
+ linePtr->firstArrowPtr, psObj);
}
if (linePtr->lastArrowPtr != NULL) {
if (stipple != None) {
Tcl_AppendToObj(psObj, "grestore gsave\n", -1);
}
- if (ArrowheadPostscript(interp, canvas, linePtr,
- linePtr->lastArrowPtr, psObj) != TCL_OK) {
- goto error;
- }
+ ArrowheadPostscript(interp, canvas, linePtr,
+ linePtr->lastArrowPtr, psObj);
}
/*
@@ -2429,11 +2472,6 @@ LineToPostscript(
Tcl_AppendObjToObj(Tcl_GetObjResult(interp), psObj);
Tcl_DecrRefCount(psObj);
return TCL_OK;
-
- error:
- Tcl_DiscardInterpState(interpState);
- Tcl_DecrRefCount(psObj);
- return TCL_ERROR;
}
/*
@@ -2493,9 +2531,7 @@ ArrowheadPostscript(
Tcl_AppendToObj(psObj, "clip ", -1);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsStipple(interp, canvas, stipple) != TCL_OK) {
- return TCL_ERROR;
- }
+ Tk_CanvasPsStipple(interp, canvas, stipple);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
} else {
Tcl_AppendToObj(psObj, "fill\n", -1);
diff --git a/generic/tkCanvPoly.c b/generic/tkCanvPoly.c
index 513613d..a827fdb 100644
--- a/generic/tkCanvPoly.c
+++ b/generic/tkCanvPoly.c
@@ -62,7 +62,7 @@ static const Tk_CustomOption stateOption = {
TkStateParseProc, TkStatePrintProc, INT2PTR(2)
};
static const Tk_CustomOption tagsOption = {
- Tk_CanvasTagsParseProc, Tk_CanvasTagsPrintProc, NULL
+ TkCanvasTagsParseProc, TkCanvasTagsPrintProc, NULL
};
static const Tk_CustomOption dashOption = {
TkCanvasDashParseProc, TkCanvasDashPrintProc, NULL
@@ -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}
};
@@ -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, TkSizeT *indexPtr);
static int PolygonCoords(Tcl_Interp *interp,
Tk_Canvas canvas, Tk_Item *itemPtr,
int objc, Tcl_Obj *const objv[]);
static void PolygonDeleteCoords(Tk_Canvas canvas,
- Tk_Item *itemPtr, int first, int last);
+ Tk_Item *itemPtr, TkSizeT first, TkSizeT last);
static void PolygonInsert(Tk_Canvas canvas,
- Tk_Item *itemPtr, int beforeThis, Tcl_Obj *obj);
+ Tk_Item *itemPtr, TkSizeT 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
};
/*
@@ -1014,7 +1016,7 @@ 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
+ TkSizeT beforeThis, /* Index before which new coordinates are to
* be inserted. */
Tcl_Obj *obj) /* New coordinates to be inserted. */
{
@@ -1033,14 +1035,14 @@ PolygonInsert(
return;
}
length = 2*(polyPtr->numPoints - polyPtr->autoClosed);
- 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++) {
@@ -1051,7 +1053,7 @@ PolygonInsert(
}
}
- for (i=beforeThis; i<length; i++) {
+ for (i=(int)beforeThis; i<length; i++) {
newCoordPtr[i+objc] = polyPtr->coordPtr[i];
}
if (polyPtr->coordPtr) {
@@ -1117,7 +1119,7 @@ PolygonInsert(
* Be careful; beforeThis could now be negative
*/
- for (i=beforeThis; i<beforeThis+objc; i+=2) {
+ for (i=beforeThis; i<(int)beforeThis+objc; i+=2) {
j = i;
if (j < 0) {
j += length;
@@ -1168,23 +1170,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. */
+ TkSizeT first, /* Index of first character to delete. */
+ TkSizeT 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;
}
@@ -1211,7 +1213,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];
}
}
@@ -1671,17 +1673,26 @@ GetPolygonIndex(
* specified. */
Tcl_Obj *obj, /* Specification of a particular coord in
* itemPtr's line. */
- int *indexPtr) /* Where to store converted index. */
+ TkSizeT *indexPtr) /* Where to store converted index. */
{
+ TkSizeT length, idx;
PolygonItem *polyPtr = (PolygonItem *) itemPtr;
- const char *string = Tcl_GetString(obj);
+ const char *string;
+ TkSizeT count = 2*(polyPtr->numPoints - polyPtr->autoClosed);
- if (string[0] == 'e') {
- if (strncmp(string, "end", obj->length) != 0) {
- goto badIndex;
+ if (TCL_OK == TkGetIntForIndex(obj, (INT_MAX - 1) - ((INT_MAX) % count), 1, &idx)) {
+ if (idx == TCL_INDEX_NONE) {
+ idx = 0;
+ } else {
+ idx = (idx & (TkSizeT)-2) % count;
}
- *indexPtr = 2*(polyPtr->numPoints - polyPtr->autoClosed);
- } else if (string[0] == '@') {
+ *indexPtr = idx;
+ return TCL_OK;
+ }
+
+ string = TkGetStringFromObj(obj, &length);
+
+ if (string[0] == '@') {
int i;
double x, y, bestDist, dist, *coordPtr;
char *end;
@@ -1709,31 +1720,55 @@ GetPolygonIndex(
coordPtr += 2;
}
} else {
- int count = 2*(polyPtr->numPoints - polyPtr->autoClosed);
+ /*
+ * Some of the paths here leave messages in interp->result, so we have to
+ * clear it out before storing our own message.
+ */
- if (Tcl_GetIntFromObj(interp, obj, indexPtr) != TCL_OK) {
- goto badIndex;
- }
- *indexPtr &= -2; /* if odd, make it even */
- if (!count) {
- *indexPtr = 0;
- } else if (*indexPtr > 0) {
- *indexPtr = ((*indexPtr - 2) % count) + 2;
- } else {
- *indexPtr = -((-(*indexPtr)) % count);
- }
+ badIndex:
+ Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad index \"%s\"", string));
+ Tcl_SetErrorCode(interp, "TK", "CANVAS", "ITEM_INDEX", "POLY", NULL);
+ return TCL_ERROR;
}
return TCL_OK;
+}
+
+/*
+ *--------------------------------------------------------------
+ *
+ * RotatePolygon --
+ *
+ * This function is called to rotate a polygon by a given amount about a
+ * point.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * The position of the polygon is rotated by angleRad about (originX,
+ * originY), and the bounding box is updated in the generic part of the
+ * item structure.
+ *
+ *--------------------------------------------------------------
+ */
- /*
- * Some of the paths here leave messages in interp->result, so we have to
- * clear it out before storing our own message.
- */
+static void
+RotatePolygon(
+ Tk_Canvas canvas, /* Canvas containing item. */
+ Tk_Item *itemPtr, /* Item that is being moved. */
+ double originX, double originY,
+ double angleRad) /* Amount by which item is to be rotated. */
+{
+ PolygonItem *polyPtr = (PolygonItem *) itemPtr;
+ double *coordPtr;
+ int i;
+ double s = sin(angleRad), c = cos(angleRad);
- badIndex:
- Tcl_SetObjResult(interp, Tcl_ObjPrintf("bad index \"%s\"", string));
- Tcl_SetErrorCode(interp, "TK", "CANVAS", "ITEM_INDEX", "POLY", NULL);
- return TCL_ERROR;
+ for (i = 0, coordPtr = polyPtr->coordPtr; i < polyPtr->numPoints;
+ i++, coordPtr += 2) {
+ TkRotatePoint(originX, originY, s, c, &coordPtr[0], &coordPtr[1]);
+ }
+ ComputePolygonBbox(canvas, polyPtr);
}
/*
@@ -1890,18 +1925,14 @@ PolygonToPostscript(
*/
Tcl_ResetResult(interp);
- if (Tk_CanvasPsColor(interp, canvas, color) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsColor(interp, canvas, color);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (stipple != None) {
Tcl_AppendToObj(psObj, "clip ", -1);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsStipple(interp, canvas, stipple) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsStipple(interp, canvas, stipple);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
} else {
Tcl_AppendToObj(psObj, "fill\n", -1);
@@ -1922,18 +1953,14 @@ PolygonToPostscript(
polyPtr->smooth->postscriptProc(interp, canvas, polyPtr->coordPtr,
polyPtr->numPoints, polyPtr->splineSteps);
}
- if (Tk_CanvasPsColor(interp, canvas, fillColor) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsColor(interp, canvas, fillColor);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (fillStipple != None) {
Tcl_AppendToObj(psObj, "eoclip ", -1);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsStipple(interp, canvas, fillStipple) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsStipple(interp, canvas, fillStipple);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (color != NULL) {
@@ -1969,9 +1996,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));
}
@@ -1984,11 +2009,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 1a8b3d3..a8ce9de 100644
--- a/generic/tkCanvPs.c
+++ b/generic/tkCanvPs.c
@@ -94,37 +94,37 @@ typedef struct TkPostscriptInfo {
static const Tk_ConfigSpec configSpecs[] = {
{TK_CONFIG_STRING, "-colormap", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, colorVar), 0, NULL},
+ "", offsetof(TkPostscriptInfo, colorVar), 0, NULL},
{TK_CONFIG_STRING, "-colormode", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, colorMode), 0, NULL},
+ "", offsetof(TkPostscriptInfo, colorMode), 0, NULL},
{TK_CONFIG_STRING, "-file", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, fileName), 0, NULL},
+ "", offsetof(TkPostscriptInfo, fileName), 0, NULL},
{TK_CONFIG_STRING, "-channel", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, channelName), 0, NULL},
+ "", offsetof(TkPostscriptInfo, channelName), 0, NULL},
{TK_CONFIG_STRING, "-fontmap", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, fontVar), 0, NULL},
+ "", offsetof(TkPostscriptInfo, fontVar), 0, NULL},
{TK_CONFIG_PIXELS, "-height", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, height), 0, NULL},
+ "", offsetof(TkPostscriptInfo, height), 0, NULL},
{TK_CONFIG_ANCHOR, "-pageanchor", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, pageAnchor), 0, NULL},
+ "", offsetof(TkPostscriptInfo, pageAnchor), 0, NULL},
{TK_CONFIG_STRING, "-pageheight", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, pageHeightString), 0, NULL},
+ "", offsetof(TkPostscriptInfo, pageHeightString), 0, NULL},
{TK_CONFIG_STRING, "-pagewidth", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, pageWidthString), 0, NULL},
+ "", offsetof(TkPostscriptInfo, pageWidthString), 0, NULL},
{TK_CONFIG_STRING, "-pagex", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, pageXString), 0, NULL},
+ "", offsetof(TkPostscriptInfo, pageXString), 0, NULL},
{TK_CONFIG_STRING, "-pagey", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, pageYString), 0, NULL},
+ "", offsetof(TkPostscriptInfo, pageYString), 0, NULL},
{TK_CONFIG_BOOLEAN, "-prolog", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, prolog), 0, NULL},
+ "", offsetof(TkPostscriptInfo, prolog), 0, NULL},
{TK_CONFIG_BOOLEAN, "-rotate", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, rotate), 0, NULL},
+ "", offsetof(TkPostscriptInfo, rotate), 0, NULL},
{TK_CONFIG_PIXELS, "-width", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, width), 0, NULL},
+ "", offsetof(TkPostscriptInfo, width), 0, NULL},
{TK_CONFIG_PIXELS, "-x", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, x), 0, NULL},
+ "", offsetof(TkPostscriptInfo, x), 0, NULL},
{TK_CONFIG_PIXELS, "-y", NULL, NULL,
- "", Tk_Offset(TkPostscriptInfo, y), 0, NULL},
+ "", offsetof(TkPostscriptInfo, y), 0, NULL},
{TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}
};
@@ -157,7 +157,6 @@ static inline Tcl_Obj * GetPostscriptBuffer(Tcl_Interp *interp);
*--------------------------------------------------------------
*/
- /* ARGSUSED */
int
TkCanvPostscriptCmd(
TkCanvas *canvasPtr, /* Information about canvas widget. */
@@ -491,7 +490,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",
@@ -545,7 +544,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,7 +576,7 @@ TkCanvPostscriptCmd(
if (result != TCL_OK) {
Tcl_AppendObjToErrorInfo(interp, Tcl_ObjPrintf(
"\n (generating Postscript for item %d)",
- itemPtr->id));
+ (int)itemPtr->id));
goto cleanup;
}
@@ -587,7 +586,7 @@ TkCanvPostscriptCmd(
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);
@@ -608,7 +607,7 @@ TkCanvPostscriptCmd(
"%%EOF\n", -1);
if (psInfo.chan != NULL) {
- if (Tcl_WriteObj(psInfo.chan, psObj) == -1) {
+ if (Tcl_WriteObj(psInfo.chan, psObj) == TCL_IO_FAILURE) {
goto channelWriteFailed;
}
}
@@ -1194,6 +1193,8 @@ TkImageGetColor(
double *red, double *green, double *blue)
/* Color data to return */
{
+ (void)cdata;
+
*red = (double) GetRValue(pixel) / 255.0;
*green = (double) GetGValue(pixel) / 255.0;
*blue = (double) GetBValue(pixel) / 255.0;
@@ -1262,6 +1263,7 @@ TkPostscriptImage(
Visual *visual;
TkColormapData cdata;
Tcl_Obj *psObj;
+ (void)y;
if (psInfoPtr->prepass) {
return TCL_OK;
@@ -1276,7 +1278,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) {
diff --git a/generic/tkCanvText.c b/generic/tkCanvText.c
index 0945857..e597434 100644
--- a/generic/tkCanvText.c
+++ b/generic/tkCanvText.c
@@ -32,7 +32,7 @@ typedef struct TextItem {
*/
double x, y; /* Positioning point for text. */
- int insertPos; /* Character index of character just before
+ TkSizeT insertPos; /* Character index of character just before
* which the insertion cursor is displayed. */
/*
@@ -62,8 +62,8 @@ typedef struct TextItem {
* configuration settings above.
*/
- int numChars; /* Length of text in characters. */
- int numBytes; /* Length of text in bytes. */
+ TkSizeT numChars; /* Length of text in characters. */
+ TkSizeT 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
@@ -87,7 +87,7 @@ static const Tk_CustomOption stateOption = {
TkStateParseProc, TkStatePrintProc, INT2PTR(2)
};
static const Tk_CustomOption tagsOption = {
- Tk_CanvasTagsParseProc, Tk_CanvasTagsPrintProc, NULL
+ TkCanvasTagsParseProc, TkCanvasTagsPrintProc, NULL
};
static const Tk_CustomOption offsetOption = {
TkOffsetParseProc, TkOffsetPrintProc, INT2PTR(TK_OFFSET_RELATIVE)
@@ -95,38 +95,38 @@ static const Tk_CustomOption offsetOption = {
static const Tk_ConfigSpec configSpecs[] = {
{TK_CONFIG_COLOR, "-activefill", NULL, NULL,
- NULL, Tk_Offset(TextItem, activeColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(TextItem, activeColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-activestipple", NULL, NULL,
- NULL, Tk_Offset(TextItem, activeStipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(TextItem, activeStipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_ANCHOR, "-anchor", NULL, NULL,
- "center", Tk_Offset(TextItem, anchor), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "center", offsetof(TextItem, anchor), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_DOUBLE, "-angle", NULL, NULL,
- "0.0", Tk_Offset(TextItem, angle), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "0.0", offsetof(TextItem, angle), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_COLOR, "-disabledfill", NULL, NULL,
- NULL, Tk_Offset(TextItem, disabledColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(TextItem, disabledColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BITMAP, "-disabledstipple", NULL, NULL,
- NULL, Tk_Offset(TextItem, disabledStipple), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(TextItem, disabledStipple), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_COLOR, "-fill", NULL, NULL,
- 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},
+ "", offsetof(TextItem, text), 0, NULL},
{TK_CONFIG_INT, "-underline", NULL, NULL,
- "-1", Tk_Offset(TextItem, underline), 0, NULL},
+ "-1", offsetof(TextItem, underline), 0, NULL},
{TK_CONFIG_PIXELS, "-width", NULL, NULL,
- "0", Tk_Offset(TextItem, width), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "0", offsetof(TextItem, width), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}
};
@@ -146,30 +146,32 @@ static void DeleteText(Tk_Canvas canvas,
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 TkSizeT GetSelText(Tk_Canvas canvas,
+ Tk_Item *itemPtr, TkSizeT offset, char *buffer,
+ TkSizeT maxBytes);
static int GetTextIndex(Tcl_Interp *interp,
Tk_Canvas canvas, Tk_Item *itemPtr,
- Tcl_Obj *obj, int *indexPtr);
+ Tcl_Obj *obj, TkSizeT *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, TkSizeT index);
static int TextCoords(Tcl_Interp *interp,
Tk_Canvas canvas, Tk_Item *itemPtr,
int argc, Tcl_Obj *const objv[]);
static void TextDeleteChars(Tk_Canvas canvas,
- Tk_Item *itemPtr, int first, int last);
+ Tk_Item *itemPtr, TkSizeT first, TkSizeT last);
static void TextInsert(Tk_Canvas canvas,
- Tk_Item *itemPtr, int beforeThis, Tcl_Obj *obj);
+ Tk_Item *itemPtr, TkSizeT 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 +201,8 @@ Tk_ItemType tkTextType = {
TextInsert, /* insertProc */
TextDeleteChars, /* dTextProc */
NULL, /* nextPtr */
- NULL, 0, NULL, NULL
+ RotateText, /* rotateProc */
+ 0, NULL, NULL
};
#define ROUND(d) ((int) floor((d) + 0.5))
@@ -507,19 +510,19 @@ ConfigureText(
textPtr->numChars = Tcl_NumUtfChars(textPtr->text, textPtr->numBytes);
if (textInfoPtr->selItemPtr == itemPtr) {
- if (textInfoPtr->selectFirst >= textPtr->numChars) {
+ if (textInfoPtr->selectFirst + 1 >= textPtr->numChars + 1) {
textInfoPtr->selItemPtr = NULL;
} else {
- if (textInfoPtr->selectLast >= textPtr->numChars) {
+ if (textInfoPtr->selectLast + 1 >= textPtr->numChars + 1) {
textInfoPtr->selectLast = textPtr->numChars - 1;
}
if ((textInfoPtr->anchorItemPtr == itemPtr)
- && (textInfoPtr->selectAnchor >= textPtr->numChars)) {
+ && (textInfoPtr->selectAnchor + 1 >= textPtr->numChars + 1)) {
textInfoPtr->selectAnchor = textPtr->numChars - 1;
}
}
}
- if (textPtr->insertPos >= textPtr->numChars) {
+ if (textPtr->insertPos + 1 >= textPtr->numChars + 1) {
textPtr->insertPos = textPtr->numChars;
}
@@ -567,6 +570,7 @@ DeleteText(
Display *display) /* Display containing window for canvas. */
{
TextItem *textPtr = (TextItem *) itemPtr;
+ (void)canvas;
if (textPtr->color != NULL) {
Tk_FreeColor(textPtr->color);
@@ -798,7 +802,7 @@ DisplayCanvText(
{
TextItem *textPtr;
Tk_CanvasTextInfo *textInfoPtr;
- int selFirstChar, selLastChar;
+ TkSizeT selFirstChar, selLastChar;
short drawableX, drawableY;
Pixmap stipple;
Tk_State state = itemPtr->state;
@@ -834,18 +838,18 @@ DisplayCanvText(
Tk_CanvasSetOffset(canvas, textPtr->gc, &textPtr->tsoffset);
}
- selFirstChar = -1;
- selLastChar = 0; /* lint. */
+ selFirstChar = TCL_INDEX_NONE;
+ selLastChar = 0;
Tk_CanvasDrawableCoords(canvas, textPtr->drawOrigin[0],
textPtr->drawOrigin[1], &drawableX, &drawableY);
if (textInfoPtr->selItemPtr == itemPtr) {
selFirstChar = textInfoPtr->selectFirst;
selLastChar = textInfoPtr->selectLast;
- if (selLastChar > textPtr->numChars) {
+ if (selLastChar + 1 > textPtr->numChars + 1 ) {
selLastChar = textPtr->numChars - 1;
}
- if ((selFirstChar >= 0) && (selFirstChar <= selLastChar)) {
+ if (((int)selFirstChar >= 0) && (selFirstChar + 1 <= selLastChar + 1 )) {
int xFirst, yFirst, hFirst;
int xLast, yLast, wLast;
@@ -956,7 +960,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,
@@ -1005,27 +1009,28 @@ 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
+ TkSizeT index, /* Character index before which string is to
* be inserted. */
Tcl_Obj *obj) /* New characters to be inserted. */
{
TextItem *textPtr = (TextItem *) itemPtr;
- int byteIndex, byteCount, charsAdded;
+ int byteIndex, charsAdded;
+ TkSizeT byteCount;
char *newStr, *text;
const char *string;
Tk_CanvasTextInfo *textInfoPtr = textPtr->textInfoPtr;
- string = Tcl_GetStringFromObj(obj, &byteCount);
+ string = TkGetStringFromObj(obj, &byteCount);
text = textPtr->text;
- if (index < 0) {
+ if (index == TCL_INDEX_NONE) {
index = 0;
}
- if (index > textPtr->numChars) {
+ if (index + 1 > textPtr->numChars + 1) {
index = textPtr->numChars;
}
- byteIndex = TkUtfAtIndex(text, index) - text;
+ byteIndex = Tcl_UtfAtIndex(text, index) - text;
byteCount = strlen(string);
if (byteCount == 0) {
return;
@@ -1048,18 +1053,18 @@ TextInsert(
*/
if (textInfoPtr->selItemPtr == itemPtr) {
- if (textInfoPtr->selectFirst >= index) {
+ if (textInfoPtr->selectFirst + 1 >= index + 1) {
textInfoPtr->selectFirst += charsAdded;
}
- if (textInfoPtr->selectLast >= index) {
+ if (textInfoPtr->selectLast + 1 >= index + 1) {
textInfoPtr->selectLast += charsAdded;
}
if ((textInfoPtr->anchorItemPtr == itemPtr)
- && (textInfoPtr->selectAnchor >= index)) {
+ && (textInfoPtr->selectAnchor + 1 >= index + 1)) {
textInfoPtr->selectAnchor += charsAdded;
}
}
- if (textPtr->insertPos >= index) {
+ if (textPtr->insertPos + 1 >= index + 1) {
textPtr->insertPos += charsAdded;
}
ComputeTextBbox(canvas, textPtr);
@@ -1086,9 +1091,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
+ TkSizeT first, /* Character index of first character to
* delete. */
- int last) /* Character index of last character to delete
+ TkSizeT last) /* Character index of last character to delete
* (inclusive). */
{
TextItem *textPtr = (TextItem *) itemPtr;
@@ -1097,19 +1102,19 @@ TextDeleteChars(
Tk_CanvasTextInfo *textInfoPtr = textPtr->textInfoPtr;
text = textPtr->text;
- if (first < 0) {
+ if ((int)first < 0) {
first = 0;
}
- if (last >= textPtr->numChars) {
+ if (last + 1 >= textPtr->numChars + 1) {
last = textPtr->numChars - 1;
}
- if (first > last) {
+ if (first + 1 > last + 1) {
return;
}
charsRemoved = last + 1 - first;
- byteIndex = TkUtfAtIndex(text, first) - text;
- byteCount = TkUtfAtIndex(text + byteIndex, charsRemoved)
+ byteIndex = Tcl_UtfAtIndex(text, first) - text;
+ byteCount = Tcl_UtfAtIndex(text + byteIndex, charsRemoved)
- (text + byteIndex);
newStr = (char *)ckalloc(textPtr->numBytes + 1 - byteCount);
@@ -1127,32 +1132,32 @@ TextDeleteChars(
*/
if (textInfoPtr->selItemPtr == itemPtr) {
- if (textInfoPtr->selectFirst > first) {
+ if (textInfoPtr->selectFirst + 1 > first + 1) {
textInfoPtr->selectFirst -= charsRemoved;
- if (textInfoPtr->selectFirst < first) {
+ if ((int)textInfoPtr->selectFirst + 1 < (int)first + 1) {
textInfoPtr->selectFirst = first;
}
}
- if (textInfoPtr->selectLast >= first) {
+ if (textInfoPtr->selectLast + 1 >= first + 1) {
textInfoPtr->selectLast -= charsRemoved;
- if (textInfoPtr->selectLast < first - 1) {
+ if (textInfoPtr->selectLast + 1 < first) {
textInfoPtr->selectLast = first - 1;
}
}
- if (textInfoPtr->selectFirst > textInfoPtr->selectLast) {
+ if ((int)textInfoPtr->selectFirst + 1 > (int)textInfoPtr->selectLast + 1) {
textInfoPtr->selItemPtr = NULL;
}
if ((textInfoPtr->anchorItemPtr == itemPtr)
- && (textInfoPtr->selectAnchor > first)) {
+ && (textInfoPtr->selectAnchor + 1 > first + 1)) {
textInfoPtr->selectAnchor -= charsRemoved;
- if (textInfoPtr->selectAnchor < first) {
+ if (textInfoPtr->selectAnchor + 1 < first + 1) {
textInfoPtr->selectAnchor = first;
}
}
}
- if (textPtr->insertPos > first) {
+ if (textPtr->insertPos + 1 > first + 1) {
textPtr->insertPos -= charsRemoved;
- if (textPtr->insertPos < first) {
+ if ((int)textPtr->insertPos + 1 < (int)first + 1) {
textPtr->insertPos = first;
}
}
@@ -1253,6 +1258,39 @@ TextToArea(
/*
*--------------------------------------------------------------
*
+ * RotateText --
+ *
+ * This function is called to rotate a text item by a given amount about a
+ * point. Note that this does *not* rotate the text of the item.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * The position of the text anchor is rotated by angleRad about (originX,
+ * originY), and the bounding box is updated in the generic part of the
+ * item structure.
+ *
+ *--------------------------------------------------------------
+ */
+
+static void
+RotateText(
+ Tk_Canvas canvas, /* Canvas containing item. */
+ Tk_Item *itemPtr, /* Item that is being rotated. */
+ double originX, double originY,
+ double angleRad) /* Amount by which item is to be rotated. */
+{
+ TextItem *textPtr = (TextItem *) itemPtr;
+
+ TkRotatePoint(originX, originY, sin(angleRad), cos(angleRad),
+ &textPtr->x, &textPtr->y);
+ ComputeTextBbox(canvas, textPtr);
+}
+
+/*
+ *--------------------------------------------------------------
+ *
* ScaleText --
*
* This function is invoked to rescale a text item.
@@ -1342,20 +1380,29 @@ GetTextIndex(
* specified. */
Tcl_Obj *obj, /* Specification of a particular character in
* itemPtr's text. */
- int *indexPtr) /* Where to store converted character
+ TkSizeT *indexPtr) /* Where to store converted character
* index. */
{
TextItem *textPtr = (TextItem *) itemPtr;
- int length;
+ TkSizeT 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 == TCL_INDEX_NONE) {
+ idx = 0;
+ } else if (idx > textPtr->numChars) {
+ idx = textPtr->numChars;
+ }
+ *indexPtr = idx;
+ return TCL_OK;
+ }
+ string = TkGetStringFromObj(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)
@@ -1398,12 +1445,6 @@ 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
@@ -1439,12 +1480,12 @@ 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
+ TkSizeT index) /* Character index of character just before
* which cursor is to be positioned. */
{
TextItem *textPtr = (TextItem *) itemPtr;
- if (index < 0) {
+ if (index == TCL_INDEX_NONE) {
textPtr->insertPos = 0;
} else if (index > textPtr->numChars) {
textPtr->insertPos = textPtr->numChars;
@@ -1473,39 +1514,39 @@ SetTextCursor(
*--------------------------------------------------------------
*/
-static int
+static TkSizeT
GetSelText(
TCL_UNUSED(Tk_Canvas), /* Canvas containing selection. */
Tk_Item *itemPtr, /* Text item containing selection. */
- int offset, /* Byte offset within selection of first
+ TkSizeT 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,
+ TkSizeT maxBytes) /* Maximum number of bytes to place at buffer,
* not including terminating NULL
* character. */
{
TextItem *textPtr = (TextItem *) itemPtr;
- int byteCount;
+ TkSizeT byteCount;
char *text;
const char *selStart, *selEnd;
Tk_CanvasTextInfo *textInfoPtr = textPtr->textInfoPtr;
- if ((textInfoPtr->selectFirst < 0) ||
- (textInfoPtr->selectFirst > textInfoPtr->selectLast)) {
+ if (((int)textInfoPtr->selectFirst < 0) ||
+ (textInfoPtr->selectFirst + 1 > textInfoPtr->selectLast + 1)) {
return 0;
}
text = textPtr->text;
- selStart = TkUtfAtIndex(text, textInfoPtr->selectFirst);
- selEnd = TkUtfAtIndex(selStart,
+ selStart = Tcl_UtfAtIndex(text, textInfoPtr->selectFirst);
+ selEnd = Tcl_UtfAtIndex(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;
}
@@ -1594,9 +1635,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 c2ff2bf..a1fe265 100644
--- a/generic/tkCanvUtil.c
+++ b/generic/tkCanvUtil.c
@@ -231,12 +231,14 @@ Tk_CanvasWindowCoords(
int
Tk_CanvasGetCoord(
- Tcl_Interp *interp, /* Interpreter for error reporting. */
+ Tcl_Interp *dummy, /* Interpreter for error reporting. */
Tk_Canvas canvas, /* Canvas to which coordinate applies. */
const char *string, /* Describes coordinate (any screen coordinate
* form may be used here). */
double *doublePtr) /* Place to store converted coordinate. */
{
+ (void)dummy;
+
if (Tk_GetScreenMM(Canvas(canvas)->interp, Canvas(canvas)->tkwin, string,
doublePtr) != TCL_OK) {
return TCL_ERROR;
@@ -267,12 +269,14 @@ Tk_CanvasGetCoord(
int
Tk_CanvasGetCoordFromObj(
- Tcl_Interp *interp, /* Interpreter for error reporting. */
+ Tcl_Interp *dummy, /* Interpreter for error reporting. */
Tk_Canvas canvas, /* Canvas to which coordinate applies. */
Tcl_Obj *obj, /* Describes coordinate (any screen coordinate
* form may be used here). */
double *doublePtr) /* Place to store converted coordinate. */
{
+ (void)dummy;
+
return Tk_GetDoublePixelsFromObj(Canvas(canvas)->interp, Canvas(canvas)->tkwin, obj, doublePtr);
}
@@ -332,7 +336,7 @@ Tk_CanvasSetOffset(
* redisplaying the canvas. */
Tk_TSOffset *offset) /* Offset (may be NULL pointer)*/
{
- register TkCanvas *canvasPtr = Canvas(canvas);
+ TkCanvas *canvasPtr = Canvas(canvas);
int flags = 0;
int x = - canvasPtr->drawableXOrigin;
int y = - canvasPtr->drawableYOrigin;
@@ -398,18 +402,21 @@ Tk_CanvasGetTextInfo(
*/
int
-Tk_CanvasTagsParseProc(
- ClientData clientData, /* Not used.*/
+TkCanvasTagsParseProc(
+ ClientData dummy, /* Not used.*/
Tcl_Interp *interp, /* Used for reporting errors. */
Tk_Window tkwin, /* Window containing canvas widget. */
const char *value, /* Value of option (list of tag names). */
char *widgRec, /* Pointer to record for item. */
- int offset) /* Offset into item (ignored). */
+ TkSizeT offset) /* Offset into item (ignored). */
{
- register Tk_Item *itemPtr = (Tk_Item *) widgRec;
+ Tk_Item *itemPtr = (Tk_Item *) widgRec;
int argc, i;
const char **argv;
Tk_Uid *newPtr;
+ (void)dummy;
+ (void)tkwin;
+ (void)offset;
/*
* Break the value up into the individual tag names.
@@ -423,9 +430,9 @@ Tk_CanvasTagsParseProc(
* Make sure that there's enough space in the item to hold the tag names.
*/
- if (itemPtr->tagSpace < argc) {
- newPtr = ckalloc(argc * sizeof(Tk_Uid));
- for (i = itemPtr->numTags-1; i >= 0; i--) {
+ if ((int)itemPtr->tagSpace < argc) {
+ newPtr = (Tk_Uid *)ckalloc(argc * sizeof(Tk_Uid));
+ for (i = (int)itemPtr->numTags - 1; i >= 0; i--) {
newPtr[i] = itemPtr->tagPtr[i];
}
if (itemPtr->tagPtr != itemPtr->staticTagSpace) {
@@ -465,16 +472,19 @@ Tk_CanvasTagsParseProc(
*/
const char *
-Tk_CanvasTagsPrintProc(
- ClientData clientData, /* Ignored. */
+TkCanvasTagsPrintProc(
+ ClientData dummy, /* Ignored. */
Tk_Window tkwin, /* Window containing canvas widget. */
char *widgRec, /* Pointer to record for item. */
- int offset, /* Ignored. */
+ TkSizeT offset, /* Ignored. */
Tcl_FreeProc **freeProcPtr) /* Pointer to variable to fill in with
* information about how to reclaim storage
* for return string. */
{
- register Tk_Item *itemPtr = (Tk_Item *) widgRec;
+ Tk_Item *itemPtr = (Tk_Item *) widgRec;
+ (void)dummy;
+ (void)tkwin;
+ (void)offset;
if (itemPtr->numTags == 0) {
*freeProcPtr = NULL;
@@ -508,13 +518,16 @@ Tk_CanvasTagsPrintProc(
int
TkCanvasDashParseProc(
- ClientData clientData, /* Not used.*/
+ ClientData dummy, /* Not used.*/
Tcl_Interp *interp, /* Used for reporting errors. */
Tk_Window tkwin, /* Window containing canvas widget. */
const char *value, /* Value of option. */
char *widgRec, /* Pointer to record for item. */
- int offset) /* Offset into item. */
+ TkSizeT offset) /* Offset into item. */
{
+ (void)dummy;
+ (void)tkwin;
+
return Tk_GetDash(interp, value, (Tk_Dash *) (widgRec+offset));
}
@@ -542,10 +555,10 @@ TkCanvasDashParseProc(
const char *
TkCanvasDashPrintProc(
- ClientData clientData, /* Ignored. */
+ ClientData dummy, /* Ignored. */
Tk_Window tkwin, /* Window containing canvas widget. */
char *widgRec, /* Pointer to record for item. */
- int offset, /* Offset in record for item. */
+ TkSizeT 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. */
@@ -553,11 +566,13 @@ TkCanvasDashPrintProc(
Tk_Dash *dash = (Tk_Dash *) (widgRec+offset);
char *buffer, *p;
int i = dash->number;
+ (void)dummy;
+ (void)tkwin;
if (i < 0) {
i = -i;
*freeProcPtr = TCL_DYNAMIC;
- buffer = ckalloc(i + 1);
+ buffer = (char *)ckalloc(i + 1);
p = (i > (int)sizeof(char *)) ? dash->pattern.pt : dash->pattern.array;
memcpy(buffer, p, (unsigned int) i);
buffer[i] = 0;
@@ -566,7 +581,7 @@ TkCanvasDashPrintProc(
*freeProcPtr = NULL;
return "";
}
- buffer = ckalloc(4 * i);
+ buffer = (char *)ckalloc(4 * i);
*freeProcPtr = TCL_DYNAMIC;
p = (i > (int)sizeof(char *)) ? dash->pattern.pt : dash->pattern.array;
@@ -602,12 +617,12 @@ InitSmoothMethods(
{
SmoothAssocData *methods, *ptr;
- methods = ckalloc(sizeof(SmoothAssocData));
+ methods = (SmoothAssocData *)ckalloc(sizeof(SmoothAssocData));
methods->smooth.name = tkRawSmoothMethod.name;
methods->smooth.coordProc = tkRawSmoothMethod.coordProc;
methods->smooth.postscriptProc = tkRawSmoothMethod.postscriptProc;
- ptr = methods->nextPtr = ckalloc(sizeof(SmoothAssocData));
+ ptr = methods->nextPtr = (SmoothAssocData *)ckalloc(sizeof(SmoothAssocData));
ptr->smooth.name = tkBezierSmoothMethod.name;
ptr->smooth.coordProc = tkBezierSmoothMethod.coordProc;
ptr->smooth.postscriptProc = tkBezierSmoothMethod.postscriptProc;
@@ -641,7 +656,7 @@ Tk_CreateSmoothMethod(
const Tk_SmoothMethod *smooth)
{
SmoothAssocData *methods, *typePtr2, *prevPtr, *ptr;
- methods = Tcl_GetAssocData(interp, "smoothMethod", NULL);
+ methods = (SmoothAssocData *)Tcl_GetAssocData(interp, "smoothMethod", NULL);
/*
* Initialize if we were not previously initialized.
@@ -667,7 +682,7 @@ Tk_CreateSmoothMethod(
break;
}
}
- ptr = ckalloc(sizeof(SmoothAssocData));
+ ptr = (SmoothAssocData *)ckalloc(sizeof(SmoothAssocData));
ptr->smooth.name = smooth->name;
ptr->smooth.coordProc = smooth->coordProc;
ptr->smooth.postscriptProc = smooth->postscriptProc;
@@ -696,9 +711,10 @@ static void
SmoothMethodCleanupProc(
ClientData clientData, /* Points to "smoothMethod" AssocData for the
* interpreter. */
- Tcl_Interp *interp) /* Interpreter that is being deleted. */
+ Tcl_Interp *dummy) /* Interpreter that is being deleted. */
{
- SmoothAssocData *ptr, *methods = clientData;
+ SmoothAssocData *ptr, *methods = (SmoothAssocData *)clientData;
+ (void)dummy;
while (methods != NULL) {
ptr = methods;
@@ -726,26 +742,28 @@ SmoothMethodCleanupProc(
int
TkSmoothParseProc(
- ClientData clientData, /* Ignored. */
+ ClientData dummy, /* Ignored. */
Tcl_Interp *interp, /* Used for reporting errors. */
Tk_Window tkwin, /* Window containing canvas widget. */
const char *value, /* Value of option. */
char *widgRec, /* Pointer to record for item. */
- int offset) /* Offset into item. */
+ TkSizeT offset) /* Offset into item. */
{
- register const Tk_SmoothMethod **smoothPtr =
+ const Tk_SmoothMethod **smoothPtr =
(const Tk_SmoothMethod **) (widgRec + offset);
const Tk_SmoothMethod *smooth = NULL;
int b;
size_t length;
SmoothAssocData *methods;
+ (void)dummy;
+ (void)tkwin;
if (value == NULL || *value == 0) {
*smoothPtr = NULL;
return TCL_OK;
}
length = strlen(value);
- methods = Tcl_GetAssocData(interp, "smoothMethod", NULL);
+ methods = (SmoothAssocData *)Tcl_GetAssocData(interp, "smoothMethod", NULL);
/*
* Not initialized yet; fix that now.
@@ -818,16 +836,19 @@ TkSmoothParseProc(
const char *
TkSmoothPrintProc(
- ClientData clientData, /* Ignored. */
+ ClientData dummy, /* Ignored. */
Tk_Window tkwin, /* Window containing canvas widget. */
char *widgRec, /* Pointer to record for item. */
- int offset, /* Offset into item. */
+ TkSizeT offset, /* Offset into item. */
Tcl_FreeProc **freeProcPtr) /* Pointer to variable to fill in with
* information about how to reclaim storage
* for return string. */
{
- register const Tk_SmoothMethod *smoothPtr =
+ const Tk_SmoothMethod *smoothPtr =
* (Tk_SmoothMethod **) (widgRec + offset);
+ (void)dummy;
+ (void)tkwin;
+ (void)freeProcPtr;
return smoothPtr ? smoothPtr->name : "0";
}
@@ -877,7 +898,7 @@ Tk_GetDash(
}
i = strlen(value);
if (i > (int) sizeof(char *)) {
- dash->pattern.pt = pt = ckalloc(strlen(value));
+ dash->pattern.pt = pt = (char *)ckalloc(strlen(value));
} else {
pt = dash->pattern.array;
}
@@ -895,7 +916,7 @@ Tk_GetDash(
ckfree(dash->pattern.pt);
}
if (argc > (int) sizeof(char *)) {
- dash->pattern.pt = pt = ckalloc(argc);
+ dash->pattern.pt = pt = (char *)ckalloc(argc);
} else {
pt = dash->pattern.array;
}
@@ -1226,7 +1247,7 @@ Tk_ChangeOutlineGC(
int i = -dash->number;
p = (i > (int)sizeof(char *)) ? dash->pattern.pt : dash->pattern.array;
- q = ckalloc(2 * i);
+ q = (char *)ckalloc(2 * i);
i = DashConvert(q, p, i, width);
XSetDashes(Canvas(canvas)->display, outline->gc, outline->offset, q,i);
ckfree(q);
@@ -1265,7 +1286,6 @@ Tk_ChangeOutlineGC(
}
return 0;
}
-
/*
*--------------------------------------------------------------
@@ -1448,7 +1468,7 @@ Tk_CanvasPsOutline(
Tcl_AppendPrintfToObj(psObj, "] %d setdash\n", outline->offset);
} else if (dash->number < 0) {
if (dash->number < -5) {
- lptr = ckalloc(1 - 2*dash->number);
+ lptr = (char *)ckalloc(1 - 2*dash->number);
}
i = DashConvert(lptr, ptr, -dash->number, width);
if (i > 0) {
@@ -1469,19 +1489,11 @@ Tk_CanvasPsOutline(
Tcl_AppendToObj(psObj, "] 0 setdash\n", -1);
}
- if (Tk_CanvasPsColor(interp, canvas, color) != TCL_OK) {
- return TCL_ERROR;
- }
-
- /*
- * Note that psObj might hold an invalid reference now.
- */
+ Tk_CanvasPsColor(interp, canvas, color);
if (stipple != None) {
Tcl_AppendToObj(GetPostscriptBuffer(interp), "StrokeClip ", -1);
- if (Tk_CanvasPsStipple(interp, canvas, stipple) != TCL_OK) {
- return TCL_ERROR;
- }
+ Tk_CanvasPsStipple(interp, canvas, stipple);
} else {
Tcl_AppendToObj(GetPostscriptBuffer(interp), "stroke\n", -1);
}
@@ -1661,6 +1673,7 @@ TkCanvTranslatePath(
int i, j; /* Loop counters */
double limit[4]; /* Boundries at which clipping occurs */
double staticSpace[480]; /* Temp space from the stack */
+ (void)closedPath;
/*
* Constrain all vertices of the path to be within a box that is no larger
@@ -1720,7 +1733,7 @@ TkCanvTranslatePath(
if (numVertex*12 <= (int) (sizeof(staticSpace) / sizeof(double))) {
tempArr = staticSpace;
} else {
- tempArr = ckalloc(numVertex * 12 * sizeof(double));
+ tempArr = (double *)ckalloc(numVertex * 12 * sizeof(double));
}
for (i=0; i<numVertex*2; i++){
tempArr[i] = coordArr[i];
@@ -1865,6 +1878,43 @@ TkCanvTranslatePath(
}
/*
+ *--------------------------------------------------------------
+ *
+ * TkRotatePoint --
+ *
+ * Rotate a point about another point. The angle should be converted into
+ * its sine and cosine before calling this function.
+ *
+ * Results:
+ * None
+ *
+ * Side effects:
+ * The point in (*xPtr,*yPtr) is updated to be rotated about
+ * (originX,originY) by the amount given by the sine and cosine of the
+ * angle to rotate.
+ *
+ *--------------------------------------------------------------
+ */
+
+void
+TkRotatePoint(
+ double originX, double originY, /* The point about which to rotate. */
+ double sine, double cosine, /* How much to rotate? */
+ double *xPtr, double *yPtr) /* The point to be rotated. (INOUT) */
+{
+ double x = *xPtr - originX;
+ double y = *yPtr - originY;
+
+ /*
+ * Beware! The canvas coordinate space is flipped vertically, so rotations
+ * go the "wrong" way with respect to mathematics.
+ */
+
+ *xPtr = originX + x * cosine + y * sine;
+ *yPtr = originY - x * sine + y * cosine;
+}
+
+/*
* Local Variables:
* mode: c
* c-basic-offset: 4
diff --git a/generic/tkCanvWind.c b/generic/tkCanvWind.c
index 4047b0f..37530dd 100644
--- a/generic/tkCanvWind.c
+++ b/generic/tkCanvWind.c
@@ -41,22 +41,22 @@ static const Tk_CustomOption stateOption = {
TkStateParseProc, TkStatePrintProc, INT2PTR(2)
};
static const Tk_CustomOption tagsOption = {
- Tk_CanvasTagsParseProc, Tk_CanvasTagsPrintProc, NULL
+ TkCanvasTagsParseProc, TkCanvasTagsPrintProc, NULL
};
static const Tk_ConfigSpec configSpecs[] = {
{TK_CONFIG_ANCHOR, "-anchor", NULL, NULL,
- "center", Tk_Offset(WindowItem, anchor), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "center", offsetof(WindowItem, anchor), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_PIXELS, "-height", NULL, NULL,
- "0", Tk_Offset(WindowItem, height), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "0", offsetof(WindowItem, height), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_CUSTOM, "-state", NULL, NULL,
- NULL, Tk_Offset(Tk_Item, state), TK_CONFIG_NULL_OK, &stateOption},
+ NULL, offsetof(Tk_Item, state), TK_CONFIG_NULL_OK, &stateOption},
{TK_CONFIG_CUSTOM, "-tags", NULL, NULL,
NULL, 0, TK_CONFIG_NULL_OK, &tagsOption},
{TK_CONFIG_PIXELS, "-width", NULL, NULL,
- "0", Tk_Offset(WindowItem, width), TK_CONFIG_DONT_SET_DEFAULT, NULL},
+ "0", offsetof(WindowItem, width), TK_CONFIG_DONT_SET_DEFAULT, NULL},
{TK_CONFIG_WINDOW, "-window", NULL, NULL,
- NULL, Tk_Offset(WindowItem, tkwin), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(WindowItem, tkwin), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}
};
@@ -77,6 +77,8 @@ static void DeleteWinItem(Tk_Canvas canvas,
static void DisplayWinItem(Tk_Canvas canvas,
Tk_Item *itemPtr, Display *display, Drawable dst,
int x, int y, int width, int height);
+static void RotateWinItem(Tk_Canvas canvas, Tk_Item *itemPtr,
+ double originX, double originY, double angleRad);
static void ScaleWinItem(Tk_Canvas canvas,
Tk_Item *itemPtr, double originX, double originY,
double scaleX, double scaleY);
@@ -130,7 +132,8 @@ Tk_ItemType tkWindowType = {
NULL, /* insertProc */
NULL, /* dTextProc */
NULL, /* nextPtr */
- NULL, 0, NULL, NULL
+ RotateWinItem, /* rotateProc */
+ 0, NULL, NULL
};
/*
@@ -141,7 +144,7 @@ Tk_ItemType tkWindowType = {
static const Tk_GeomMgr canvasGeomType = {
"canvas", /* name */
WinItemRequestProc, /* requestProc */
- WinItemLostContentProc, /* lostSlaveProc */
+ WinItemLostContentProc, /* lostContentProc */
};
/*
@@ -405,6 +408,7 @@ DeleteWinItem(
{
WindowItem *winItemPtr = (WindowItem *) itemPtr;
Tk_Window canvasTkwin = Tk_CanvasTkwin(canvas);
+ (void)display;
if (winItemPtr->tkwin != NULL) {
Tk_DeleteEventHandler(winItemPtr->tkwin, StructureNotifyMask,
@@ -567,6 +571,11 @@ DisplayWinItem(
short x, y;
Tk_Window canvasTkwin = Tk_CanvasTkwin(canvas);
Tk_State state = itemPtr->state;
+ (void)display;
+ (void)regionX;
+ (void)regionY;
+ (void)regionWidth;
+ (void)regionHeight;
if (winItemPtr->tkwin == NULL) {
return;
@@ -655,6 +664,7 @@ WinItemToPoint(
{
WindowItem *winItemPtr = (WindowItem *) itemPtr;
double x1, x2, y1, y2, xDiff, yDiff;
+ (void)canvas;
x1 = winItemPtr->header.x1;
y1 = winItemPtr->header.y1;
@@ -712,6 +722,7 @@ WinItemToArea(
* area. */
{
WindowItem *winItemPtr = (WindowItem *) itemPtr;
+ (void)canvas;
if ((rectPtr[2] <= winItemPtr->header.x1)
|| (rectPtr[0] >= winItemPtr->header.x2)
@@ -748,9 +759,12 @@ WinItemToArea(
#ifdef X_GetImage
static int
xerrorhandler(
- ClientData clientData,
+ ClientData dummy,
XErrorEvent *e)
{
+ (void)dummy;
+ (void)e;
+
return 0;
}
#endif /* X_GetImage */
@@ -915,6 +929,40 @@ CanvasPsWindow(
/*
*--------------------------------------------------------------
*
+ * RotateWinItem --
+ *
+ * This function is called to rotate a window item by a given amount
+ * about a point. Note that this does *not* rotate the window of the
+ * item.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * The position of the window anchor is rotated by angleRad about (originX,
+ * originY), and the bounding box is updated in the generic part of the
+ * item structure.
+ *
+ *--------------------------------------------------------------
+ */
+
+static void
+RotateWinItem(
+ Tk_Canvas canvas, /* Canvas containing item. */
+ Tk_Item *itemPtr, /* Item that is being rotated. */
+ double originX, double originY,
+ double angleRad) /* Amount by which item is to be rotated. */
+{
+ WindowItem *winItemPtr = (WindowItem *) itemPtr;
+
+ TkRotatePoint(originX, originY, sin(angleRad), cos(angleRad),
+ &winItemPtr->x, &winItemPtr->y);
+ ComputeWindowBbox(canvas, winItemPtr);
+}
+
+/*
+ *--------------------------------------------------------------
+ *
* ScaleWinItem --
*
* This function is invoked to rescale a window item.
@@ -1007,7 +1055,7 @@ WinItemStructureProc(
ClientData clientData, /* Pointer to record describing window item. */
XEvent *eventPtr) /* Describes what just happened. */
{
- WindowItem *winItemPtr = clientData;
+ WindowItem *winItemPtr = (WindowItem *)clientData;
if (eventPtr->type == DestroyNotify) {
winItemPtr->tkwin = NULL;
@@ -1037,7 +1085,8 @@ WinItemRequestProc(
ClientData clientData, /* Pointer to record for window item. */
Tk_Window tkwin) /* Window that changed its desired size. */
{
- WindowItem *winItemPtr = clientData;
+ WindowItem *winItemPtr = (WindowItem *)clientData;
+ (void)tkwin;
ComputeWindowBbox(winItemPtr->canvas, winItemPtr);
@@ -1067,15 +1116,15 @@ WinItemRequestProc(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static void
WinItemLostContentProc(
- ClientData clientData, /* WindowItem structure for content window that
+ ClientData clientData, /* WindowItem structure for content window window that
* was stolen away. */
Tk_Window tkwin) /* Tk's handle for the content window. */
{
- WindowItem *winItemPtr = clientData;
+ WindowItem *winItemPtr = (WindowItem *)clientData;
Tk_Window canvasTkwin = Tk_CanvasTkwin(winItemPtr->canvas);
+ (void)tkwin;
Tk_DeleteEventHandler(winItemPtr->tkwin, StructureNotifyMask,
WinItemStructureProc, winItemPtr);
diff --git a/generic/tkCanvas.c b/generic/tkCanvas.c
index 2ce5e50..0550fbe 100644
--- a/generic/tkCanvas.c
+++ b/generic/tkCanvas.c
@@ -13,11 +13,9 @@
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
-/* #define USE_OLD_TAG_SEARCH 1 */
-
-#include "default.h"
#include "tkInt.h"
#include "tkCanvas.h"
+#include "default.h"
#ifdef TK_NO_DOUBLE_BUFFERING
#ifdef MAC_OSX_TK
#include "tkMacOSXInt.h"
@@ -28,26 +26,6 @@
* 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 +52,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 */
+ TkSizeT 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 +72,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 +91,92 @@ static const Tk_CustomOption offsetOption = {
static const Tk_ConfigSpec configSpecs[] = {
{TK_CONFIG_BORDER, "-background", "background", "Background",
- DEF_CANVAS_BG_COLOR, Tk_Offset(TkCanvas, bgBorder),
+ DEF_CANVAS_BG_COLOR, offsetof(TkCanvas, bgBorder),
TK_CONFIG_COLOR_ONLY, NULL},
{TK_CONFIG_BORDER, "-background", "background", "Background",
- DEF_CANVAS_BG_MONO, Tk_Offset(TkCanvas, bgBorder),
+ DEF_CANVAS_BG_MONO, offsetof(TkCanvas, bgBorder),
TK_CONFIG_MONO_ONLY, NULL},
{TK_CONFIG_SYNONYM, "-bd", "borderWidth", NULL, NULL, 0, 0, NULL},
{TK_CONFIG_SYNONYM, "-bg", "background", NULL, NULL, 0, 0, NULL},
{TK_CONFIG_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_CANVAS_BORDER_WIDTH, Tk_Offset(TkCanvas, borderWidth), 0, NULL},
+ DEF_CANVAS_BORDER_WIDTH, offsetof(TkCanvas, borderWidth), 0, NULL},
{TK_CONFIG_DOUBLE, "-closeenough", "closeEnough", "CloseEnough",
- DEF_CANVAS_CLOSE_ENOUGH, Tk_Offset(TkCanvas, closeEnough), 0, NULL},
+ DEF_CANVAS_CLOSE_ENOUGH, offsetof(TkCanvas, closeEnough), 0, NULL},
{TK_CONFIG_BOOLEAN, "-confine", "confine", "Confine",
- DEF_CANVAS_CONFINE, Tk_Offset(TkCanvas, confine), 0, NULL},
+ DEF_CANVAS_CONFINE, offsetof(TkCanvas, confine), 0, NULL},
{TK_CONFIG_ACTIVE_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_CANVAS_CURSOR, Tk_Offset(TkCanvas, cursor), TK_CONFIG_NULL_OK, NULL},
+ DEF_CANVAS_CURSOR, offsetof(TkCanvas, cursor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_PIXELS, "-height", "height", "Height",
- DEF_CANVAS_HEIGHT, Tk_Offset(TkCanvas, height), 0, NULL},
+ DEF_CANVAS_HEIGHT, offsetof(TkCanvas, height), 0, NULL},
{TK_CONFIG_COLOR, "-highlightbackground", "highlightBackground",
"HighlightBackground", DEF_CANVAS_HIGHLIGHT_BG,
- Tk_Offset(TkCanvas, highlightBgColorPtr), 0, NULL},
+ offsetof(TkCanvas, highlightBgColorPtr), 0, NULL},
{TK_CONFIG_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_CANVAS_HIGHLIGHT, Tk_Offset(TkCanvas, highlightColorPtr), 0, NULL},
+ DEF_CANVAS_HIGHLIGHT, offsetof(TkCanvas, highlightColorPtr), 0, NULL},
{TK_CONFIG_PIXELS, "-highlightthickness", "highlightThickness",
"HighlightThickness",
- DEF_CANVAS_HIGHLIGHT_WIDTH, Tk_Offset(TkCanvas, highlightWidth), 0, NULL},
+ DEF_CANVAS_HIGHLIGHT_WIDTH, offsetof(TkCanvas, highlightWidth), 0, NULL},
{TK_CONFIG_BORDER, "-insertbackground", "insertBackground", "Foreground",
- DEF_CANVAS_INSERT_BG, Tk_Offset(TkCanvas, textInfo.insertBorder), 0, NULL},
+ DEF_CANVAS_INSERT_BG, offsetof(TkCanvas, textInfo.insertBorder), 0, NULL},
{TK_CONFIG_PIXELS, "-insertborderwidth", "insertBorderWidth", "BorderWidth",
DEF_CANVAS_INSERT_BD_COLOR,
- Tk_Offset(TkCanvas, textInfo.insertBorderWidth), TK_CONFIG_COLOR_ONLY, NULL},
+ offsetof(TkCanvas, textInfo.insertBorderWidth), TK_CONFIG_COLOR_ONLY, NULL},
{TK_CONFIG_PIXELS, "-insertborderwidth", "insertBorderWidth", "BorderWidth",
DEF_CANVAS_INSERT_BD_MONO,
- Tk_Offset(TkCanvas, textInfo.insertBorderWidth), TK_CONFIG_MONO_ONLY, NULL},
+ offsetof(TkCanvas, textInfo.insertBorderWidth), TK_CONFIG_MONO_ONLY, NULL},
{TK_CONFIG_INT, "-insertofftime", "insertOffTime", "OffTime",
- DEF_CANVAS_INSERT_OFF_TIME, Tk_Offset(TkCanvas, insertOffTime), 0, NULL},
+ DEF_CANVAS_INSERT_OFF_TIME, offsetof(TkCanvas, insertOffTime), 0, NULL},
{TK_CONFIG_INT, "-insertontime", "insertOnTime", "OnTime",
- DEF_CANVAS_INSERT_ON_TIME, Tk_Offset(TkCanvas, insertOnTime), 0, NULL},
+ DEF_CANVAS_INSERT_ON_TIME, offsetof(TkCanvas, insertOnTime), 0, NULL},
{TK_CONFIG_PIXELS, "-insertwidth", "insertWidth", "InsertWidth",
- DEF_CANVAS_INSERT_WIDTH, Tk_Offset(TkCanvas, textInfo.insertWidth), 0, NULL},
+ DEF_CANVAS_INSERT_WIDTH, offsetof(TkCanvas, textInfo.insertWidth), 0, NULL},
{TK_CONFIG_CUSTOM, "-offset", "offset", "Offset", "0,0",
- Tk_Offset(TkCanvas, tsoffset),TK_CONFIG_DONT_SET_DEFAULT,
+ offsetof(TkCanvas, tsoffset),TK_CONFIG_DONT_SET_DEFAULT,
&offsetOption},
{TK_CONFIG_RELIEF, "-relief", "relief", "Relief",
- DEF_CANVAS_RELIEF, Tk_Offset(TkCanvas, relief), 0, NULL},
+ DEF_CANVAS_RELIEF, offsetof(TkCanvas, relief), 0, NULL},
{TK_CONFIG_STRING, "-scrollregion", "scrollRegion", "ScrollRegion",
- DEF_CANVAS_SCROLL_REGION, Tk_Offset(TkCanvas, regionString),
+ DEF_CANVAS_SCROLL_REGION, offsetof(TkCanvas, regionString),
TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_BORDER, "-selectbackground", "selectBackground", "Foreground",
- DEF_CANVAS_SELECT_COLOR, Tk_Offset(TkCanvas, textInfo.selBorder),
+ DEF_CANVAS_SELECT_COLOR, offsetof(TkCanvas, textInfo.selBorder),
TK_CONFIG_COLOR_ONLY, NULL},
{TK_CONFIG_BORDER, "-selectbackground", "selectBackground", "Foreground",
- DEF_CANVAS_SELECT_MONO, Tk_Offset(TkCanvas, textInfo.selBorder),
+ DEF_CANVAS_SELECT_MONO, offsetof(TkCanvas, textInfo.selBorder),
TK_CONFIG_MONO_ONLY, NULL},
{TK_CONFIG_PIXELS, "-selectborderwidth", "selectBorderWidth", "BorderWidth",
DEF_CANVAS_SELECT_BD_COLOR,
- Tk_Offset(TkCanvas, textInfo.selBorderWidth), TK_CONFIG_COLOR_ONLY, NULL},
+ offsetof(TkCanvas, textInfo.selBorderWidth), TK_CONFIG_COLOR_ONLY, NULL},
{TK_CONFIG_PIXELS, "-selectborderwidth", "selectBorderWidth", "BorderWidth",
- DEF_CANVAS_SELECT_BD_MONO, Tk_Offset(TkCanvas, textInfo.selBorderWidth),
+ DEF_CANVAS_SELECT_BD_MONO, offsetof(TkCanvas, textInfo.selBorderWidth),
TK_CONFIG_MONO_ONLY, NULL},
{TK_CONFIG_COLOR, "-selectforeground", "selectForeground", "Background",
- DEF_CANVAS_SELECT_FG_COLOR, Tk_Offset(TkCanvas, textInfo.selFgColorPtr),
+ DEF_CANVAS_SELECT_FG_COLOR, offsetof(TkCanvas, textInfo.selFgColorPtr),
TK_CONFIG_COLOR_ONLY|TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_COLOR, "-selectforeground", "selectForeground", "Background",
- DEF_CANVAS_SELECT_FG_MONO, Tk_Offset(TkCanvas, textInfo.selFgColorPtr),
+ DEF_CANVAS_SELECT_FG_MONO, offsetof(TkCanvas, textInfo.selFgColorPtr),
TK_CONFIG_MONO_ONLY|TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-state", "state", "State",
- "normal", Tk_Offset(TkCanvas, canvas_state), TK_CONFIG_DONT_SET_DEFAULT,
+ "normal", offsetof(TkCanvas, canvas_state), TK_CONFIG_DONT_SET_DEFAULT,
&stateOption},
{TK_CONFIG_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_CANVAS_TAKE_FOCUS, Tk_Offset(TkCanvas, takeFocus),
+ DEF_CANVAS_TAKE_FOCUS, offsetof(TkCanvas, takeFocus),
TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_PIXELS, "-width", "width", "Width",
- DEF_CANVAS_WIDTH, Tk_Offset(TkCanvas, width), 0, NULL},
+ DEF_CANVAS_WIDTH, offsetof(TkCanvas, width), 0, NULL},
{TK_CONFIG_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand",
- DEF_CANVAS_X_SCROLL_CMD, Tk_Offset(TkCanvas, xScrollCmd),
+ DEF_CANVAS_X_SCROLL_CMD, offsetof(TkCanvas, xScrollCmd),
TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_PIXELS, "-xscrollincrement", "xScrollIncrement",
"ScrollIncrement",
- DEF_CANVAS_X_SCROLL_INCREMENT, Tk_Offset(TkCanvas, xScrollIncrement),
+ DEF_CANVAS_X_SCROLL_INCREMENT, offsetof(TkCanvas, xScrollIncrement),
0, NULL},
{TK_CONFIG_STRING, "-yscrollcommand", "yScrollCommand", "ScrollCommand",
- DEF_CANVAS_Y_SCROLL_CMD, Tk_Offset(TkCanvas, yScrollCmd),
+ DEF_CANVAS_Y_SCROLL_CMD, offsetof(TkCanvas, yScrollCmd),
TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_PIXELS, "-yscrollincrement", "yScrollIncrement",
"ScrollIncrement",
- DEF_CANVAS_Y_SCROLL_INCREMENT, Tk_Offset(TkCanvas, yScrollIncrement),
+ DEF_CANVAS_Y_SCROLL_INCREMENT, offsetof(TkCanvas, yScrollIncrement),
0, NULL},
{TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}
};
@@ -215,7 +191,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,7 +211,6 @@ typedef struct {
static Tcl_ThreadDataKey dataKey;
static SearchUids * GetStaticUids(void);
-#endif /* USE_OLD_TAG_SEARCH */
/*
* Prototypes for functions defined later in this file:
@@ -249,14 +223,14 @@ static void CanvasCmdDeletedProc(ClientData clientData);
static void CanvasDoEvent(TkCanvas *canvasPtr, XEvent *eventPtr);
static void CanvasEventProc(ClientData clientData,
XEvent *eventPtr);
-static int CanvasFetchSelection(ClientData clientData, int offset,
- char *buffer, int maxBytes);
+static TkSizeT CanvasFetchSelection(ClientData clientData, TkSizeT offset,
+ char *buffer, TkSizeT maxBytes);
static Tk_Item * CanvasFindClosest(TkCanvas *canvasPtr,
double coords[2]);
static void CanvasFocusProc(TkCanvas *canvasPtr, int gotFocus);
static void CanvasLostSelection(ClientData clientData);
static void CanvasSelectTo(TkCanvas *canvasPtr,
- Tk_Item *itemPtr, int index);
+ Tk_Item *itemPtr, TkSizeT index);
static void CanvasSetOrigin(TkCanvas *canvasPtr,
int xOrigin, int yOrigin);
static void CanvasUpdateScrollbars(TkCanvas *canvasPtr);
@@ -267,39 +241,28 @@ static void CanvasWorldChanged(ClientData instanceData);
static int ConfigureCanvas(Tcl_Interp *interp,
TkCanvas *canvasPtr, int argc,
Tcl_Obj *const *argv, int flags);
-static void DestroyCanvas(char *memPtr);
+static void DefaultRotateImplementation(TkCanvas *canvasPtr,
+ Tk_Item *itemPtr, double x, double y,
+ double angleRadians);
+static void DestroyCanvas(void *memPtr);
+static int DrawCanvas(Tcl_Interp *interp, ClientData clientData, Tk_PhotoHandle photohandle, int subsample, int zoom);
static void DisplayCanvas(ClientData clientData);
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 argc, Tcl_Obj *const *argv,
Tcl_Obj *newTagObj, int first,
TagSearch **searchPtrPtr);
-#endif /* USE_OLD_TAG_SEARCH */
static int FindArea(Tcl_Interp *interp, TkCanvas *canvasPtr,
Tcl_Obj *const *argv, Tk_Uid uid, int enclosed);
static double GridAlign(double coord, double spacing);
static const char** TkGetStringsFromObjs(int argc, Tcl_Obj *const *objv);
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 +276,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 +293,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 +308,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 */
/*
* ----------------------------------------------------------------------
@@ -522,7 +472,7 @@ ItemIndex(
TkCanvas *canvasPtr,
Tk_Item *itemPtr,
Tcl_Obj *objPtr,
- int *indexPtr)
+ TkSizeT *indexPtr)
{
Tcl_Interp *interp = canvasPtr->interp;
@@ -613,6 +563,102 @@ ItemTranslate(
itemPtr->typePtr->translateProc((Tk_Canvas) canvasPtr, itemPtr,
xDelta, yDelta);
}
+
+static inline void
+ItemRotate(
+ TkCanvas *canvasPtr,
+ Tk_Item *itemPtr,
+ double x,
+ double y,
+ double angleRadians)
+{
+ if (itemPtr->typePtr->rotateProc != NULL) {
+ itemPtr->typePtr->rotateProc((Tk_Canvas) canvasPtr,
+ itemPtr, x, y, angleRadians);
+ } else {
+ DefaultRotateImplementation(canvasPtr, itemPtr, x, y, angleRadians);
+ }
+}
+
+/*
+ *--------------------------------------------------------------
+ *
+ * DefaultRotateImplementation --
+ *
+ * The default implementation of the rotation operation, used when items
+ * do not provide their own version.
+ *
+ *--------------------------------------------------------------
+ */
+
+static void
+DefaultRotateImplementation(
+ TkCanvas *canvasPtr,
+ Tk_Item *itemPtr,
+ double x,
+ double y,
+ double angleRadians)
+{
+ int objc, i, ok = 1;
+ Tcl_Obj **objv, **newObjv;
+ double *coordv;
+ double s = sin(angleRadians);
+ double c = cos(angleRadians);
+ Tcl_Interp *interp = canvasPtr->interp;
+
+ /*
+ * Get the coordinates out of the item.
+ */
+
+ if (ItemCoords(canvasPtr, itemPtr, 0, NULL) == TCL_OK &&
+ Tcl_ListObjGetElements(NULL, Tcl_GetObjResult(interp),
+ &objc, &objv) == TCL_OK) {
+ coordv = (double *) ckalloc(sizeof(double) * objc);
+ for (i=0 ; i<objc ; i++) {
+ if (Tcl_GetDoubleFromObj(NULL, objv[i], &coordv[i]) != TCL_OK) {
+ ok = 0;
+ break;
+ }
+ }
+ if (ok) {
+ /*
+ * Apply the rotation.
+ */
+
+ for (i=0 ; i<objc ; i+=2) {
+ double px = coordv[i+0] - x;
+ double py = coordv[i+1] - y;
+ double nx = px * c - py * s;
+ double ny = px * s + py * c;
+
+ coordv[i+0] = nx + x;
+ coordv[i+1] = ny + y;
+ }
+
+ /*
+ * Write the coordinates back into the item.
+ */
+
+ newObjv = (Tcl_Obj **) ckalloc(sizeof(Tcl_Obj *) * objc);
+ for (i=0 ; i<objc ; i++) {
+ newObjv[i] = Tcl_NewDoubleObj(coordv[i]);
+ Tcl_IncrRefCount(newObjv[i]);
+ }
+ ItemCoords(canvasPtr, itemPtr, objc, newObjv);
+ for (i=0 ; i<objc ; i++) {
+ Tcl_DecrRefCount(newObjv[i]);
+ }
+ ckfree((char *) newObjv);
+ }
+ ckfree((char *) coordv);
+ }
+
+ /*
+ * The interpreter result was (probably) modified above; reset it.
+ */
+
+ Tcl_ResetResult(interp);
+}
/*
*--------------------------------------------------------------
@@ -686,8 +732,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 +781,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 +799,7 @@ Tk_CanvasObjCmd(
goto error;
}
- Tcl_SetObjResult(interp, TkNewWindowObj(canvasPtr->tkwin));
+ Tcl_SetObjResult(interp, Tk_NewWindowObj(canvasPtr->tkwin));
return TCL_OK;
error:
@@ -792,12 +836,8 @@ 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[] = {
@@ -805,23 +845,24 @@ CanvasWidgetCmd(
"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 {
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) {
@@ -888,10 +929,10 @@ CanvasWidgetCmd(
if (gotAny) {
Tcl_Obj *resultObjs[4];
- resultObjs[0] = Tcl_NewIntObj(x1);
- resultObjs[1] = Tcl_NewIntObj(y1);
- resultObjs[2] = Tcl_NewIntObj(x2);
- resultObjs[3] = Tcl_NewIntObj(y2);
+ resultObjs[0] = Tcl_NewWideIntObj(x1);
+ resultObjs[1] = Tcl_NewWideIntObj(y1);
+ resultObjs[2] = Tcl_NewWideIntObj(x2);
+ resultObjs[3] = Tcl_NewWideIntObj(y2);
Tcl_SetObjResult(interp, Tcl_NewListObj(4, resultObjs));
}
break;
@@ -911,35 +952,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;
@@ -963,9 +975,8 @@ CanvasWidgetCmd(
goto done;
}
} else {
- object = (ClientData) 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 +996,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 +1026,6 @@ CanvasWidgetCmd(
searchPtr->expr = NULL;
}
}
-#endif /* not USE_OLD_TAG_SEARCH */
if (argv4[0] == '+') {
argv4++;
append = 1;
@@ -1185,6 +1194,7 @@ CanvasWidgetCmd(
tmpObj = Tcl_NewListObj(2, objv+4);
FOR_EVERY_CANVAS_ITEM_MATCHING(objv[2], &searchPtr, goto doneImove) {
+ TkSizeT index;
int x1, x2, y1, y2;
int dontRedraw1, dontRedraw2;
@@ -1240,15 +1250,14 @@ CanvasWidgetCmd(
int isNew = 0;
Tcl_HashEntry *entryPtr;
const char *arg;
- size_t length;
+ TkSizeT length;
if (objc < 3) {
Tcl_WrongNumArgs(interp, 2, objv, "type coords ?arg ...?");
result = TCL_ERROR;
goto done;
}
- arg = Tcl_GetString(objv[2]);
- length = objv[2]->length;
+ arg = TkGetStringFromObj(objv[2], &length);
c = arg[0];
/*
@@ -1326,11 +1335,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;
+ TkSizeT first, last;
int x1, x2, y1, y2;
if ((objc != 4) && (objc != 5)) {
@@ -1446,7 +1455,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 = (int)itemPtr->numTags-1; i >= 0; i--) {
if (itemPtr->tagPtr[i] == tag) {
/*
@@ -1485,7 +1494,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,7 +1529,7 @@ 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));
}
@@ -1528,6 +1537,7 @@ CanvasWidgetCmd(
}
break;
case CANV_ICURSOR: {
+ TkSizeT index;
if (objc != 4) {
Tcl_WrongNumArgs(interp, 2, objv, "tagOrId index");
@@ -1552,6 +1562,7 @@ CanvasWidgetCmd(
break;
}
case CANV_INDEX: {
+ TkSizeT index;
if (objc != 4) {
Tcl_WrongNumArgs(interp, 2, objv, "tagOrId string");
@@ -1575,11 +1586,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;
+ TkSizeT beforeThis;
int x1, x2, y1, y2;
if (objc != 5) {
@@ -1667,11 +1678,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;
@@ -1794,11 +1800,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 +1807,7 @@ CanvasWidgetCmd(
break;
}
case CANV_RCHARS: {
- int first, last;
+ TkSizeT first, last;
int x1, x2, y1, y2;
int dontRedraw1, dontRedraw2;
@@ -1857,6 +1858,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;
@@ -1935,6 +1960,7 @@ CanvasWidgetCmd(
break;
}
case CANV_SELECT: {
+ TkSizeT index;
int optionindex;
static const char *const optionStrings[] = {
"adjust", "clear", "from", "item", "to", NULL
@@ -1984,8 +2010,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 +2047,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:
@@ -2138,12 +2164,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 +2232,11 @@ CanvasWidgetCmd(
static void
DestroyCanvas(
- char *memPtr) /* Info about canvas widget. */
+ void *memPtr) /* Info about canvas widget. */
{
- TkCanvas *canvasPtr = (TkCanvas *) memPtr;
+ 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,14 +2261,12 @@ 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);
@@ -2426,6 +2486,500 @@ 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 */
+
+/* From stackoverflow.com/questions/2100331/c-macro-definition-to-determine-big-endian-or-little-endian-machine */
+#define IS_BIG_ENDIAN (*(unsigned short *)"\0\xff" < 0x100)
+
+#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 */
+ ClientData 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!", 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!", 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?", 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", 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", 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", NULL);
+ result = TCL_ERROR;
+ goto done;
+ }
+
+#ifdef DEBUG_DRAWCANVAS
+ Tcl_AppendResult(interp, "ximagePtr {", NULL);
+ sprintf(buffer,"%d",ximagePtr->width); Tcl_AppendResult(interp, " width ", buffer, NULL);
+ sprintf(buffer,"%d",ximagePtr->height); Tcl_AppendResult(interp, " height ", buffer, NULL);
+ sprintf(buffer,"%d",ximagePtr->xoffset); Tcl_AppendResult(interp, " xoffset ", buffer, NULL);
+ sprintf(buffer,"%d",ximagePtr->format); Tcl_AppendResult(interp, " format ", buffer, NULL);
+ Tcl_AppendResult(interp, " ximagePtr->data", NULL);
+ if (ximagePtr->data != NULL) {
+ int ix, iy;
+
+ Tcl_AppendResult(interp, " {", NULL);
+ for (iy = 0; iy < ximagePtr->height; ++ iy) {
+ Tcl_AppendResult(interp, " {", NULL);
+ for (ix = 0; ix < ximagePtr->bytes_per_line; ++ ix) {
+ if (ix > 0) {
+ if (ix % 4 == 0)
+ Tcl_AppendResult(interp, "-", NULL);
+ else
+ Tcl_AppendResult(interp, " ", NULL);
+ }
+ sprintf(buffer,"%2.2x",ximagePtr->data[ximagePtr->bytes_per_line * iy + ix]&0xFF);
+ Tcl_AppendResult(interp, buffer, NULL);
+ }
+ Tcl_AppendResult(interp, " }", NULL);
+ }
+ Tcl_AppendResult(interp, " }", NULL);
+ } else
+ sprintf(buffer," NULL");
+ sprintf(buffer,"%d",ximagePtr->byte_order); Tcl_AppendResult(interp, " byte_order ", buffer, NULL);
+ sprintf(buffer,"%d",ximagePtr->bitmap_unit); Tcl_AppendResult(interp, " bitmap_unit ", buffer, NULL);
+ sprintf(buffer,"%d",ximagePtr->bitmap_bit_order); Tcl_AppendResult(interp, " bitmap_bit_order ", buffer, NULL);
+ sprintf(buffer,"%d",ximagePtr->bitmap_pad); Tcl_AppendResult(interp, " bitmap_pad ", buffer, NULL);
+ sprintf(buffer,"%d",ximagePtr->depth); Tcl_AppendResult(interp, " depth ", buffer, NULL);
+ sprintf(buffer,"%d",ximagePtr->bytes_per_line); Tcl_AppendResult(interp, " bytes_per_line ", buffer, NULL);
+ sprintf(buffer,"%d",ximagePtr->bits_per_pixel); Tcl_AppendResult(interp, " bits_per_pixel ", buffer, NULL);
+ sprintf(buffer,"0x%8.8lx",ximagePtr->red_mask); Tcl_AppendResult(interp, " red_mask ", buffer, NULL);
+ sprintf(buffer,"0x%8.8lx",ximagePtr->green_mask); Tcl_AppendResult(interp, " green_mask ", buffer, NULL);
+ sprintf(buffer,"0x%8.8lx",ximagePtr->blue_mask); Tcl_AppendResult(interp, " blue_mask ", buffer, NULL);
+ Tcl_AppendResult(interp, " }", NULL);
+
+ Tcl_AppendResult(interp, "\nvisualPtr {", NULL);
+ sprintf(buffer,"0x%8.8lx",visualPtr->red_mask); Tcl_AppendResult(interp, " red_mask ", buffer, NULL);
+ sprintf(buffer,"0x%8.8lx",visualPtr->green_mask); Tcl_AppendResult(interp, " green_mask ", buffer, NULL);
+ sprintf(buffer,"0x%8.8lx",visualPtr->blue_mask); Tcl_AppendResult(interp, " blue_mask ", buffer, NULL);
+ Tcl_AppendResult(interp, " }", 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;
+ blockPtr.offset[0] = 0;
+ blockPtr.offset[1] = 1;
+ blockPtr.offset[2] = 2;
+ blockPtr.offset[3] = 3;
+ 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
+ sprintf(buffer,"%d",rshift); Tcl_AppendResult(interp, "\nbits { rshift ", buffer, NULL);
+ sprintf(buffer,"%d",gshift); Tcl_AppendResult(interp, " gshift ", buffer, NULL);
+ sprintf(buffer,"%d",bshift); Tcl_AppendResult(interp, " bshift ", buffer, NULL);
+ sprintf(buffer,"%d",rbits); Tcl_AppendResult(interp, " rbits ", buffer, NULL);
+ sprintf(buffer,"%d",gbits); Tcl_AppendResult(interp, " gbits ", buffer, NULL);
+ sprintf(buffer,"%d",bbits); Tcl_AppendResult(interp, " bbits ", buffer, " }", NULL);
+ Tcl_AppendResult(interp, "\nConverted_image {", 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, " {", NULL);
+#endif
+
+ for(x = 0; x < blockPtr.width; ++x) {
+ unsigned int pixel = 0;
+
+ 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 2
+#define B_OFFSET 0
+#else
+#define R_OFFSET 0
+#define B_OFFSET 2
+#endif
+ blockPtr.pixelPtr[blockPtr.pitch * y + blockPtr.pixelSize * x + R_OFFSET] =
+ (unsigned char)((pixel & visualPtr->red_mask) >> rshift);
+ blockPtr.pixelPtr[blockPtr.pitch * y + blockPtr.pixelSize * x +1] =
+ (unsigned char)((pixel & visualPtr->green_mask) >> gshift);
+ blockPtr.pixelPtr[blockPtr.pitch * y + blockPtr.pixelSize * x + B_OFFSET] =
+ (unsigned char)((pixel & visualPtr->blue_mask) >> bshift);
+ blockPtr.pixelPtr[blockPtr.pitch * y + blockPtr.pixelSize * x +3] = 0xFF;
+
+#ifdef DEBUG_DRAWCANVAS
+ {
+ int ix;
+ if (x > 0)
+ Tcl_AppendResult(interp, "-", NULL);
+ for (ix = 0; ix < 4; ++ix) {
+ if (ix > 0)
+ Tcl_AppendResult(interp, " ", NULL);
+ sprintf(buffer,"%2.2x",blockPtr.pixelPtr[blockPtr.pitch * y
+ + blockPtr.pixelSize * x + ix]&0xFF);
+ Tcl_AppendResult(interp, buffer, NULL);
+ }
+ }
+#endif
+
+ }
+
+#ifdef DEBUG_DRAWCANVAS
+ Tcl_AppendResult(interp, " }", NULL);
+#endif
+
+ }
+
+#ifdef DEBUG_DRAWCANVAS
+ Tcl_AppendResult(interp, " }", 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
@@ -3057,208 +3611,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 */
/*
*----------------------------------------------------------------------
*
@@ -3869,7 +4221,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;
@@ -3889,7 +4241,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;
@@ -4055,7 +4407,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;
@@ -4157,7 +4509,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;
@@ -4187,7 +4539,6 @@ TagSearchNext(
searchPtr->searchOver = 1;
return NULL;
}
-#endif /* USE_OLD_TAG_SEARCH */
/*
*--------------------------------------------------------------
@@ -4224,11 +4575,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;
@@ -4300,14 +4651,9 @@ FindItems(
int 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;
@@ -4624,16 +4970,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. */
@@ -4643,12 +4979,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;
@@ -4700,11 +5032,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) {
@@ -4725,9 +5053,7 @@ RelinkItems(
if (canvasPtr->lastItemPtr == prevPtr) {
canvasPtr->lastItemPtr = lastMovePtr;
}
-#ifndef USE_OLD_TAG_SEARCH
return TCL_OK;
-#endif /* not USE_OLD_TAG_SEARCH */
}
/*
@@ -4767,7 +5093,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
@@ -4852,9 +5178,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
@@ -4975,12 +5299,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 = (int)itemPtr->numTags-1; i >= 0; i--) {
if (itemPtr->tagPtr[i] == searchUids->currentUid)
-#endif /* USE_OLD_TAG_SEARCH */
/* then */ {
memmove((void *)(itemPtr->tagPtr + i),
itemPtr->tagPtr + i + 1,
@@ -5019,11 +5339,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);
@@ -5121,11 +5437,9 @@ CanvasDoEvent(
void **objectPtr;
int numObjects, i;
Tk_Item *itemPtr;
-#ifndef USE_OLD_TAG_SEARCH
TagSearchExpr *expr;
int numExprs;
SearchUids *searchUids = GetStaticUids();
-#endif /* not USE_OLD_TAG_SEARCH */
if (canvasPtr->bindingTable == NULL) {
return;
@@ -5139,16 +5453,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:
@@ -5177,23 +5481,17 @@ CanvasDoEvent(
}
numObjects = itemPtr->numTags + numExprs + 2;
-#endif /* not USE_OLD_TAG_SEARCH */
if (numObjects <= NUM_STATIC) {
objectPtr = staticObjects;
} else {
- objectPtr = ckalloc(numObjects * sizeof(ClientData));
+ objectPtr = (void **)ckalloc(numObjects * sizeof(void *));
}
-#ifdef USE_OLD_TAG_SEARCH
- objectPtr[0] = (ClientData) Tk_GetUid("all");
-#else /* USE_OLD_TAG_SEARCH */
- objectPtr[0] = (ClientData) searchUids->allUid;
-#endif /* USE_OLD_TAG_SEARCH */
- for (i = itemPtr->numTags-1; i >= 0; i--) {
- objectPtr[i+1] = (ClientData) itemPtr->tagPtr[i];
+ objectPtr[0] = (char *)searchUids->allUid;
+ for (i = (int)itemPtr->numTags - 1; i >= 0; i--) {
+ objectPtr[i+1] = (char *)itemPtr->tagPtr[i];
}
- objectPtr[itemPtr->numTags+1] = itemPtr;
+ objectPtr[itemPtr->numTags + 1] = itemPtr;
-#ifndef USE_OLD_TAG_SEARCH
/*
* Copy uids of matching expressions into object array
*/
@@ -5206,7 +5504,6 @@ CanvasDoEvent(
}
expr = expr->next;
}
-#endif /* not USE_OLD_TAG_SEARCH */
/*
* Invoke the binding system, then free up the object array if it was
@@ -5329,10 +5626,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
+ TkSizeT index) /* Index of element that is to become the
* "other" end of the selection. */
{
- int oldFirst, oldLast;
+ TkSizeT oldFirst, oldLast;
Tk_Item *oldSelPtr;
oldFirst = canvasPtr->textInfo.selectFirst;
@@ -5355,11 +5652,11 @@ CanvasSelectTo(
canvasPtr->textInfo.anchorItemPtr = itemPtr;
canvasPtr->textInfo.selectAnchor = index;
}
- if (canvasPtr->textInfo.selectAnchor <= index) {
+ if (canvasPtr->textInfo.selectAnchor + 1 <= index + 1) {
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)
@@ -5390,13 +5687,13 @@ CanvasSelectTo(
*--------------------------------------------------------------
*/
-static int
+static TkSizeT
CanvasFetchSelection(
ClientData clientData, /* Information about canvas widget. */
- int offset, /* Offset within selection of first character
+ TkSizeT 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,
+ TkSizeT maxBytes) /* Maximum number of bytes to place at buffer,
* not including terminating NULL
* character. */
{
diff --git a/generic/tkCanvas.h b/generic/tkCanvas.h
index e2221a8..f1adbc4 100644
--- a/generic/tkCanvas.h
+++ b/generic/tkCanvas.h
@@ -147,7 +147,7 @@ typedef struct TkCanvas {
* currentItem is based. Must be saved so that
* if the currentItem is deleted, can pick
* another. */
- int state; /* Last known modifier state. Used to defer
+ unsigned int state; /* Last known modifier state. Used to defer
* picking a new current object while buttons
* are down. */
@@ -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
+ TkSizeT 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
diff --git a/generic/tkClipboard.c b/generic/tkClipboard.c
index 703ef41..67b91a2 100644
--- a/generic/tkClipboard.c
+++ b/generic/tkClipboard.c
@@ -19,12 +19,12 @@
* 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 TkSizeT ClipboardAppHandler(ClientData clientData,
+ TkSizeT offset, char *buffer, TkSizeT maxBytes);
+static TkSizeT ClipboardHandler(ClientData clientData,
+ TkSizeT offset, char *buffer, TkSizeT maxBytes);
+static TkSizeT ClipboardWindowHandler(ClientData clientData,
+ TkSizeT offset, char *buffer, TkSizeT maxBytes);
static void ClipboardLostSel(ClientData clientData);
static int ClipboardGetProc(ClientData clientData,
Tcl_Interp *interp, const char *portion);
@@ -48,20 +48,20 @@ static int ClipboardGetProc(ClientData clientData,
*----------------------------------------------------------------------
*/
-static int
+static TkSizeT
ClipboardHandler(
ClientData clientData, /* Information about data to fetch. */
- int offset, /* Return selection bytes starting at this
+ TkSizeT offset, /* Return selection bytes starting at this
* offset. */
char *buffer, /* Place to store converted selection. */
- int maxBytes) /* Maximum # of bytes to store at buffer. */
+ TkSizeT 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;
+ TkSizeT count = 0;
+ TkSizeT scanned = 0;
+ TkSizeT 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,30 +126,30 @@ ClipboardHandler(
*----------------------------------------------------------------------
*/
-static int
+static TkSizeT
ClipboardAppHandler(
ClientData clientData, /* Pointer to TkDisplay structure. */
- int offset, /* Return selection bytes starting at this
+ TkSizeT offset, /* Return selection bytes starting at this
* offset. */
char *buffer, /* Place to store converted selection. */
- int maxBytes) /* Maximum # of bytes to store at buffer. */
+ TkSizeT maxBytes) /* Maximum # of bytes to store at buffer. */
{
- TkDisplay *dispPtr = clientData;
- size_t length;
+ TkDisplay *dispPtr = (TkDisplay *)clientData;
+ TkSizeT length;
const char *p;
p = dispPtr->clipboardAppPtr->winPtr->nameUid;
length = strlen(p);
- length -= offset;
- if (length <= 0) {
+ if (length <= offset) {
return 0;
}
- if (length > (size_t) maxBytes) {
+ length -= offset;
+ if (length > maxBytes) {
length = maxBytes;
}
memcpy(buffer, p, length);
buffer[length] = 0;
- return (int)length;
+ return length;
}
/*
@@ -171,13 +171,13 @@ ClipboardAppHandler(
*----------------------------------------------------------------------
*/
-static int
+static TkSizeT
ClipboardWindowHandler(
TCL_UNUSED(void *), /* Not used. */
- TCL_UNUSED(int), /* Return selection bytes starting at this
+ TCL_UNUSED(TkSizeT), /* 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(TkSizeT)) /* Maximum # of bytes to store at buffer. */
{
buffer[0] = '.';
buffer[1] = 0;
@@ -450,10 +450,11 @@ Tk_ClipboardObjCmd(
"-displayof", "-format", "-type", NULL
};
enum appendOptions { APPEND_DISPLAYOF, APPEND_FORMAT, APPEND_TYPE };
- int subIndex, length;
+ int subIndex;
+ TkSizeT length;
for (i = 2; i < objc - 1; i++) {
- string = Tcl_GetStringFromObj(objv[i], &length);
+ string = TkGetStringFromObj(objv[i], &length);
if (string[0] != '-') {
break;
}
@@ -708,7 +709,7 @@ ClipboardGetProc(
* used). */
const char *portion) /* New information to be appended. */
{
- Tcl_DStringAppend((Tcl_DString *) clientData, portion, -1);
+ Tcl_DStringAppend((Tcl_DString *)clientData, portion, -1);
return TCL_OK;
}
diff --git a/generic/tkCmds.c b/generic/tkCmds.c
index 193c3d6..a8d72fc 100644
--- a/generic/tkCmds.c
+++ b/generic/tkCmds.c
@@ -744,15 +744,15 @@ CaretCmd(
Tcl_ListObjAppendElement(interp, objPtr,
Tcl_NewStringObj("-height", 7));
Tcl_ListObjAppendElement(interp, objPtr,
- Tcl_NewIntObj(caretPtr->height));
+ Tcl_NewWideIntObj(caretPtr->height));
Tcl_ListObjAppendElement(interp, objPtr,
Tcl_NewStringObj("-x", 2));
Tcl_ListObjAppendElement(interp, objPtr,
- Tcl_NewIntObj(caretPtr->x));
+ Tcl_NewWideIntObj(caretPtr->x));
Tcl_ListObjAppendElement(interp, objPtr,
Tcl_NewStringObj("-y", 2));
Tcl_ListObjAppendElement(interp, objPtr,
- Tcl_NewIntObj(caretPtr->y));
+ Tcl_NewWideIntObj(caretPtr->y));
Tcl_SetObjResult(interp, objPtr);
} else if (objc == 3) {
int value;
@@ -772,7 +772,7 @@ CaretCmd(
} else /* if (index == TK_CARET_HEIGHT) -- last case */ {
value = caretPtr->height;
}
- Tcl_SetObjResult(interp, Tcl_NewIntObj(value));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(value));
} else {
int i, value, x = 0, y = 0, height = -1;
@@ -873,11 +873,6 @@ UseinputmethodsCmd(
}
dispPtr = ((TkWindow *) tkwin)->dispPtr;
if ((objc - skip) == 2) {
- /*
- * In the case where TK_USE_INPUT_METHODS is not defined, this
- * will be ignored and we will always return 0. That will indicate
- * to the user that input methods are just not available.
- */
int boolVal;
@@ -885,13 +880,11 @@ UseinputmethodsCmd(
&boolVal) != TCL_OK) {
return TCL_ERROR;
}
-#ifdef TK_USE_INPUT_METHODS
- if (boolVal) {
+ if (boolVal && (dispPtr->inputMethod != NULL)) {
dispPtr->flags |= TK_DISPLAY_USE_IM;
} else {
dispPtr->flags &= ~TK_DISPLAY_USE_IM;
}
-#endif /* TK_USE_INPUT_METHODS */
} else if ((objc - skip) != 1) {
Tcl_WrongNumArgs(interp, 1, objv,
"?-displayof window? ?boolean?");
@@ -940,11 +933,11 @@ InactiveCmd(
return TCL_ERROR;
}
if (objc - skip == 1) {
- long inactive;
+ Tcl_WideInt inactive;
inactive = (Tcl_IsSafe(interp) ? -1 :
Tk_GetUserInactiveTime(Tk_Display(tkwin)));
- Tcl_SetObjResult(interp, Tcl_NewLongObj(inactive));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(inactive));
} else if (objc - skip == 2) {
const char *string;
@@ -1357,7 +1350,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();
@@ -1380,14 +1373,14 @@ Tk_WinfoObjCmd(
Tcl_NewBooleanObj(TkpCmapStressed(tkwin,Tk_Colormap(tkwin))));
break;
case WIN_DEPTH:
- Tcl_SetObjResult(interp, Tcl_NewIntObj(Tk_Depth(tkwin)));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(Tk_Depth(tkwin)));
break;
case WIN_GEOMETRY:
Tcl_SetObjResult(interp, Tcl_ObjPrintf("%dx%d+%d+%d",
Tk_Width(tkwin), Tk_Height(tkwin), Tk_X(tkwin), Tk_Y(tkwin)));
break;
case WIN_HEIGHT:
- Tcl_SetObjResult(interp, Tcl_NewIntObj(Tk_Height(tkwin)));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(Tk_Height(tkwin)));
break;
case WIN_ID: {
char buf[TCL_INTEGER_SPACE];
@@ -1438,28 +1431,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",
@@ -1467,27 +1460,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;
@@ -1533,28 +1526,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;
/*
@@ -1729,7 +1722,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: {
@@ -1822,224 +1815,7 @@ Tk_WinfoObjCmd(
return TCL_OK;
}
-#if 0
-/*
- *----------------------------------------------------------------------
- *
- * Tk_WmObjCmd --
- *
- * This function is invoked to process the "wm" Tcl command. See the user
- * documentation for details on what it does.
- *
- * Results:
- * A standard Tcl result.
- *
- * Side effects:
- * See the user documentation.
- *
- *----------------------------------------------------------------------
- */
-
- /* ARGSUSED */
-int
-Tk_WmObjCmd(
- ClientData clientData, /* Main window associated with interpreter. */
- Tcl_Interp *interp, /* Current interpreter. */
- int objc, /* Number of arguments. */
- Tcl_Obj *const objv[]) /* Argument objects. */
-{
- Tk_Window tkwin;
- TkWindow *winPtr;
-
- static const char *const optionStrings[] = {
- "aspect", "client", "command", "deiconify",
- "focusmodel", "frame", "geometry", "grid",
- "group", "iconbitmap", "iconify", "iconmask",
- "iconname", "iconposition", "iconwindow", "maxsize",
- "minsize", "overrideredirect", "positionfrom", "protocol",
- "resizable", "sizefrom", "state", "title",
- "tracing", "transient", "withdraw", NULL
- };
- enum options {
- TKWM_ASPECT, TKWM_CLIENT, TKWM_COMMAND, TKWM_DEICONIFY,
- TKWM_FOCUSMOD, TKWM_FRAME, TKWM_GEOMETRY, TKWM_GRID,
- TKWM_GROUP, TKWM_ICONBMP, TKWM_ICONIFY, TKWM_ICONMASK,
- TKWM_ICONNAME, TKWM_ICONPOS, TKWM_ICONWIN, TKWM_MAXSIZE,
- TKWM_MINSIZE, TKWM_OVERRIDE, TKWM_POSFROM, TKWM_PROTOCOL,
- TKWM_RESIZABLE, TKWM_SIZEFROM, TKWM_STATE, TKWM_TITLE,
- TKWM_TRACING, TKWM_TRANSIENT, TKWM_WITHDRAW
- };
-
- tkwin = (Tk_Window) clientData;
-
- if (objc < 2) {
- Tcl_WrongNumArgs(interp, 1, objv, "option window ?arg?");
- return TCL_ERROR;
- }
- if (Tcl_GetIndexFromObj(interp, objv[1], optionStrings, "option", 0,
- &index) != TCL_OK) {
- return TCL_ERROR;
- }
-
- if (index == TKWM_TRACING) {
- int wmTracing;
- TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
-
- if ((objc != 2) && (objc != 3)) {
- Tcl_WrongNumArgs(interp, 1, objv, "tracing ?boolean?");
- return TCL_ERROR;
- }
- if (objc == 2) {
- Tcl_SetObjResult(interp, Tcl_NewBooleanObj(
- dispPtr->flags & TK_DISPLAY_WM_TRACING));
- return TCL_OK;
- }
- if (Tcl_GetBooleanFromObj(interp, objv[2], &wmTracing) != TCL_OK) {
- return TCL_ERROR;
- }
- if (wmTracing) {
- dispPtr->flags |= TK_DISPLAY_WM_TRACING;
- } else {
- dispPtr->flags &= ~TK_DISPLAY_WM_TRACING;
- }
- return TCL_OK;
- }
-
- if (objc < 3) {
- Tcl_WrongNumArgs(interp, 2, objv, "window ?arg?");
- return TCL_ERROR;
- }
-
- winPtr = (TkWindow *) Tk_NameToWindow(interp,
- Tcl_GetString(objv[2]), tkwin);
- if (winPtr == NULL) {
- return TCL_ERROR;
- }
- if (!(winPtr->flags & TK_TOP_LEVEL)) {
- Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "window \"%s\" isn't a top-level window", winPtr->pathName));
- Tcl_SetErrorCode(interp, "TK", "LOOKUP", "TOPLEVEL", winPtr->pathName,
- NULL);
- return TCL_ERROR;
- }
- switch ((enum options) index) {
- case TKWM_ASPECT:
- TkpWmAspectCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_CLIENT:
- TkpWmClientCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_COMMAND:
- TkpWmCommandCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_DEICONIFY:
- TkpWmDeiconifyCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_FOCUSMOD:
- TkpWmFocusmodCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_FRAME:
- TkpWmFrameCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_GEOMETRY:
- TkpWmGeometryCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_GRID:
- TkpWmGridCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_GROUP:
- TkpWmGroupCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_ICONBMP:
- TkpWmIconbitmapCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_ICONIFY:
- TkpWmIconifyCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_ICONMASK:
- TkpWmIconmaskCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_ICONNAME:
- /*
- * Slight Unix variation.
- */
- TkpWmIconnameCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_ICONPOS:
- /*
- * nearly same - 1 line more on Unix.
- */
- TkpWmIconpositionCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_ICONWIN:
- TkpWmIconwindowCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_MAXSIZE:
- /*
- * Nearly same, win diffs.
- */
- TkpWmMaxsizeCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_MINSIZE:
- /*
- * Nearly same, win diffs
- */
- TkpWmMinsizeCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_OVERRIDE:
- /*
- * Almost same.
- */
- TkpWmOverrideCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_POSFROM:
- /*
- * Equal across platforms
- */
- TkpWmPositionfromCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_PROTOCOL:
- /*
- * Equal across platforms
- */
- TkpWmProtocolCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_RESIZABLE:
- /*
- * Almost same
- */
- TkpWmResizableCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_SIZEFROM:
- /*
- * Equal across platforms
- */
- TkpWmSizefromCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_STATE:
- TkpWmStateCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_TITLE:
- TkpWmTitleCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_TRANSIENT:
- TkpWmTransientCmd(interp, tkwin, winPtr, objc, objv);
- break;
- case TKWM_WITHDRAW:
- TkpWmWithdrawCmd(interp, tkwin, winPtr, objc, objv);
- break;
- }
-
- updateGeom:
- if (!(wmPtr->flags & (WM_UPDATE_PENDING|WM_NEVER_MAPPED))) {
- Tcl_DoWhenIdle(UpdateGeometryInfo, winPtr);
- wmPtr->flags |= WM_UPDATE_PENDING;
- }
- return TCL_OK;
-}
-#endif
-
/*
*----------------------------------------------------------------------
*
@@ -2081,12 +1857,12 @@ TkGetDisplayOf(
* present. */
{
const char *string;
- int length;
+ TkSizeT length;
if (objc < 1) {
return 0;
}
- string = Tcl_GetStringFromObj(objv[0], &length);
+ string = TkGetStringFromObj(objv[0], &length);
if ((length >= 2) &&
(strncmp(string, "-displayof", length) == 0)) {
if (objc < 2) {
diff --git a/generic/tkColor.c b/generic/tkColor.c
index f6650f9..cf5c5f6 100644
--- a/generic/tkColor.c
+++ b/generic/tkColor.c
@@ -128,7 +128,7 @@ Tk_AllocColorFromObj(
*/
if (tkColPtr != NULL) {
- TkColor *firstColorPtr = Tcl_GetHashValue(tkColPtr->hashPtr);
+ TkColor *firstColorPtr = (TkColor *)Tcl_GetHashValue(tkColPtr->hashPtr);
FreeColorObj(objPtr);
for (tkColPtr = firstColorPtr; tkColPtr != NULL;
@@ -203,7 +203,7 @@ Tk_GetColor(
nameHashPtr = Tcl_CreateHashEntry(&dispPtr->colorNameTable, name, &isNew);
if (!isNew) {
- existingColPtr = Tcl_GetHashValue(nameHashPtr);
+ existingColPtr = (TkColor *)Tcl_GetHashValue(nameHashPtr);
for (tkColPtr = existingColPtr; tkColPtr != NULL;
tkColPtr = tkColPtr->nextPtr) {
if ((tkColPtr->screen == Tk_Screen(tkwin))
@@ -314,7 +314,7 @@ Tk_GetColorByValue(
valueHashPtr = Tcl_CreateHashEntry(&dispPtr->colorValueTable,
(char *) &valueKey, &isNew);
if (!isNew) {
- tkColPtr = Tcl_GetHashValue(valueHashPtr);
+ tkColPtr = (TkColor *)Tcl_GetHashValue(valueHashPtr);
tkColPtr->resourceRefCount++;
return &tkColPtr->color;
}
@@ -363,12 +363,12 @@ const char *
Tk_NameOfColor(
XColor *colorPtr) /* Color whose name is desired. */
{
- register TkColor *tkColPtr = (TkColor *) colorPtr;
+ TkColor *tkColPtr = (TkColor *) colorPtr;
if (tkColPtr->magic==COLOR_MAGIC && tkColPtr->type==TK_COLOR_BY_NAME) {
return tkColPtr->hashPtr->key.string;
} else {
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
sprintf(tsdPtr->rgbString, "#%04x%04x%04x", colorPtr->red,
@@ -480,8 +480,7 @@ Tk_FreeColor(
Tcl_Panic("Tk_FreeColor called with bogus color");
}
- tkColPtr->resourceRefCount--;
- if (tkColPtr->resourceRefCount > 0) {
+ if (tkColPtr->resourceRefCount-- > 1) {
return;
}
@@ -497,7 +496,7 @@ Tk_FreeColor(
}
TkpFreeColor(tkColPtr);
- prevPtr = Tcl_GetHashValue(tkColPtr->hashPtr);
+ prevPtr = (TkColor *)Tcl_GetHashValue(tkColPtr->hashPtr);
if (prevPtr == tkColPtr) {
if (tkColPtr->nextPtr == NULL) {
Tcl_DeleteHashEntry(tkColPtr->hashPtr);
@@ -584,11 +583,10 @@ static void
FreeColorObj(
Tcl_Obj *objPtr) /* The object we are releasing. */
{
- TkColor *tkColPtr = objPtr->internalRep.twoPtrValue.ptr1;
+ TkColor *tkColPtr = (TkColor *)objPtr->internalRep.twoPtrValue.ptr1;
if (tkColPtr != NULL) {
- tkColPtr->objRefCount--;
- if ((tkColPtr->objRefCount == 0)
+ if ((tkColPtr->objRefCount-- <= 1)
&& (tkColPtr->resourceRefCount == 0)) {
ckfree(tkColPtr);
}
@@ -619,7 +617,7 @@ DupColorObjProc(
Tcl_Obj *srcObjPtr, /* The object we are copying from. */
Tcl_Obj *dupObjPtr) /* The object we are copying to. */
{
- TkColor *tkColPtr = srcObjPtr->internalRep.twoPtrValue.ptr1;
+ TkColor *tkColPtr = (TkColor *)srcObjPtr->internalRep.twoPtrValue.ptr1;
dupObjPtr->typePtr = srcObjPtr->typePtr;
dupObjPtr->internalRep.twoPtrValue.ptr1 = tkColPtr;
@@ -669,7 +667,7 @@ Tk_GetColorFromObj(
* map. If it is, we are done.
*/
- tkColPtr = objPtr->internalRep.twoPtrValue.ptr1;
+ tkColPtr = (TkColor *)objPtr->internalRep.twoPtrValue.ptr1;
if ((tkColPtr != NULL)
&& (tkColPtr->resourceRefCount > 0)
&& (Tk_Screen(tkwin) == tkColPtr->screen)
@@ -695,7 +693,7 @@ Tk_GetColorFromObj(
if (hashPtr == NULL) {
goto error;
}
- for (tkColPtr = Tcl_GetHashValue(hashPtr);
+ for (tkColPtr = (TkColor *)Tcl_GetHashValue(hashPtr);
(tkColPtr != NULL); tkColPtr = tkColPtr->nextPtr) {
if ((Tk_Screen(tkwin) == tkColPtr->screen)
&& (Tk_Colormap(tkwin) == tkColPtr->colormap)) {
@@ -811,7 +809,7 @@ TkDebugColor(
resultPtr = Tcl_NewObj();
hashPtr = Tcl_FindHashEntry(&dispPtr->colorNameTable, name);
if (hashPtr != NULL) {
- TkColor *tkColPtr = Tcl_GetHashValue(hashPtr);
+ TkColor *tkColPtr = (TkColor *)Tcl_GetHashValue(hashPtr);
if (tkColPtr == NULL) {
Tcl_Panic("TkDebugColor found empty hash table entry");
@@ -820,9 +818,9 @@ TkDebugColor(
Tcl_Obj *objPtr = Tcl_NewObj();
Tcl_ListObjAppendElement(NULL, objPtr,
- Tcl_NewIntObj(tkColPtr->resourceRefCount));
+ Tcl_NewWideIntObj(tkColPtr->resourceRefCount));
Tcl_ListObjAppendElement(NULL, objPtr,
- Tcl_NewIntObj(tkColPtr->objRefCount));
+ Tcl_NewWideIntObj(tkColPtr->objRefCount));
Tcl_ListObjAppendElement(NULL, resultPtr, objPtr);
}
}
diff --git a/generic/tkColor.h b/generic/tkColor.h
index 54e8cdc..bcd71fe 100644
--- a/generic/tkColor.h
+++ b/generic/tkColor.h
@@ -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
+ TkSizeT 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
+ TkSizeT 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 65e28a6..925cb72 100644
--- a/generic/tkConfig.c
+++ b/generic/tkConfig.c
@@ -91,7 +91,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
@@ -103,7 +103,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
@@ -115,14 +115,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,
@@ -177,7 +177,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));
@@ -279,7 +279,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)
@@ -330,7 +330,7 @@ Tk_DeleteOptionTable(
{
OptionTable *tablePtr = (OptionTable *) optionTable;
Option *optionPtr;
- int count;
+ size_t count;
if (tablePtr->refCount-- > 1) {
return;
@@ -381,7 +381,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. */
@@ -552,7 +552,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. */
@@ -568,10 +568,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
@@ -584,8 +584,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;
@@ -597,8 +597,8 @@ 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;
}
@@ -656,15 +656,15 @@ DoObjConfig(
case TK_OPTION_STRING: {
char *newStr;
const char *value;
- int length;
+ TkSizeT length;
if (nullOK && ObjectIsEmpty(valuePtr)) {
valuePtr = NULL;
}
if (internalPtr != NULL) {
if (valuePtr != NULL) {
- value = Tcl_GetStringFromObj(valuePtr, &length);
- newStr = ckalloc(length + 1);
+ value = TkGetStringFromObj(valuePtr, &length);
+ newStr = (char *)ckalloc(length + 1);
strcpy(newStr, value);
} else {
newStr = NULL;
@@ -883,7 +883,7 @@ DoObjConfig(
const Tk_ObjCustomOption *custom = optionPtr->extra.custom;
if (custom->setProc(custom->clientData, interp, tkwin,
- &valuePtr, recordPtr, optionPtr->specPtr->internalOffset,
+ &valuePtr, (char *)recordPtr, optionPtr->specPtr->internalOffset,
(char *)oldInternalPtr, optionPtr->specPtr->flags) != TCL_OK) {
return TCL_ERROR;
}
@@ -979,7 +979,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
@@ -1227,7 +1227,7 @@ 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_Obj *const objv[], /* Contains one or more name-value pairs. */
@@ -1345,12 +1345,12 @@ Tk_RestoreSavedOptions(
Tk_SavedOptions *savePtr) /* Holds saved option information; must have
* been passed to Tk_SetOptions. */
{
- int i;
+ size_t 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;
@@ -1365,7 +1365,7 @@ Tk_RestoreSavedOptions(
ckfree(savePtr->nextPtr);
savePtr->nextPtr = NULL;
}
- for (i = savePtr->numItems - 1; i >= 0; i--) {
+ for (i = savePtr->numItems - 1; i != (size_t)-1; i--) {
optionPtr = savePtr->items[i].optionPtr;
specPtr = optionPtr->specPtr;
@@ -1374,13 +1374,13 @@ Tk_RestoreSavedOptions(
* record.
*/
- if (specPtr->objOffset >= 0) {
- newPtr = *((Tcl_Obj **) (savePtr->recordPtr + specPtr->objOffset));
+ if (specPtr->objOffset != TCL_INDEX_NONE) {
+ newPtr = *((Tcl_Obj **) ((char *)savePtr->recordPtr + specPtr->objOffset));
} else {
newPtr = NULL;
}
- if (specPtr->internalOffset >= 0) {
- internalPtr = savePtr->recordPtr + specPtr->internalOffset;
+ if (specPtr->internalOffset != TCL_INDEX_NONE) {
+ internalPtr = (char *)savePtr->recordPtr + specPtr->internalOffset;
} else {
internalPtr = NULL;
}
@@ -1395,18 +1395,16 @@ 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) {
- register char *ptr = (char *) &savePtr->items[i].internalForm;
+ if (specPtr->internalOffset != TCL_INDEX_NONE) {
+ char *ptr = (char *) &savePtr->items[i].internalForm;
CLANG_ASSERT(internalPtr);
switch (specPtr->type) {
case TK_OPTION_BOOLEAN:
- *((int *) internalPtr) = *((int *) ptr);
- break;
case TK_OPTION_INT:
*((int *) internalPtr) = *((int *) ptr);
break;
@@ -1458,7 +1456,7 @@ Tk_RestoreSavedOptions(
if (custom->restoreProc != NULL) {
custom->restoreProc(custom->clientData, savePtr->tkwin,
- internalPtr, ptr);
+ (char *)internalPtr, ptr);
}
break;
}
@@ -1492,7 +1490,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) {
@@ -1530,7 +1528,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
@@ -1538,9 +1536,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;
@@ -1551,15 +1549,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;
}
@@ -1596,10 +1594,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;
@@ -1610,7 +1608,7 @@ 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) {
@@ -1642,8 +1640,6 @@ FreeResources(
if (internalFormExists) {
Tk_FreeStyle(*((Tk_Style *) internalPtr));
*((Tk_Style *) internalPtr) = NULL;
- } else if (objPtr != NULL) {
- Tk_FreeStyleFromObj(objPtr);
}
break;
case TK_OPTION_BITMAP:
@@ -1679,7 +1675,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;
}
@@ -1718,7 +1714,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
@@ -1732,7 +1728,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
@@ -1786,7 +1782,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. */
@@ -1829,8 +1825,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();
@@ -1864,7 +1860,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
@@ -1872,109 +1868,109 @@ GetObjectForOption(
Tk_Window tkwin) /* Window corresponding to recordPtr. */
{
Tcl_Obj *objPtr;
- char *internalPtr; /* Points to internal value of option in
+ void *internalPtr; /* Points to internal value of option in
* record. */
- internalPtr = recordPtr + optionPtr->specPtr->internalOffset;
objPtr = NULL;
- switch (optionPtr->specPtr->type) {
- case TK_OPTION_BOOLEAN:
- objPtr = Tcl_NewIntObj(*((int *)internalPtr));
- break;
- case TK_OPTION_INT:
- objPtr = Tcl_NewIntObj(*((int *)internalPtr));
- break;
- case TK_OPTION_DOUBLE:
- objPtr = Tcl_NewDoubleObj(*((double *)internalPtr));
- break;
- case TK_OPTION_STRING:
- objPtr = Tcl_NewStringObj(*((char **)internalPtr), -1);
- break;
- case TK_OPTION_STRING_TABLE:
- objPtr = Tcl_NewStringObj(((char **) optionPtr->specPtr->clientData)[
- *((int *) internalPtr)], -1);
- break;
- case TK_OPTION_COLOR: {
- XColor *colorPtr = *((XColor **)internalPtr);
+ if (optionPtr->specPtr->internalOffset != TCL_INDEX_NONE) {
+ internalPtr = (char *)recordPtr + optionPtr->specPtr->internalOffset;
+ switch (optionPtr->specPtr->type) {
+ case TK_OPTION_BOOLEAN:
+ case TK_OPTION_INT:
+ objPtr = Tcl_NewWideIntObj(*((int *)internalPtr));
+ break;
+ case TK_OPTION_DOUBLE:
+ objPtr = Tcl_NewDoubleObj(*((double *) internalPtr));
+ break;
+ case TK_OPTION_STRING:
+ objPtr = Tcl_NewStringObj(*((char **)internalPtr), -1);
+ break;
+ case TK_OPTION_STRING_TABLE:
+ objPtr = Tcl_NewStringObj(((char **) optionPtr->specPtr->clientData)[
+ *((int *) internalPtr)], -1);
+ break;
+ case TK_OPTION_COLOR: {
+ XColor *colorPtr = *((XColor **)internalPtr);
- if (colorPtr != NULL) {
- objPtr = Tcl_NewStringObj(Tk_NameOfColor(colorPtr), -1);
+ if (colorPtr != NULL) {
+ objPtr = Tcl_NewStringObj(Tk_NameOfColor(colorPtr), -1);
+ }
+ break;
}
- break;
- }
- case TK_OPTION_FONT: {
- Tk_Font tkfont = *((Tk_Font *)internalPtr);
+ case TK_OPTION_FONT: {
+ Tk_Font tkfont = *((Tk_Font *)internalPtr);
- if (tkfont != NULL) {
- objPtr = Tcl_NewStringObj(Tk_NameOfFont(tkfont), -1);
+ if (tkfont != NULL) {
+ objPtr = Tcl_NewStringObj(Tk_NameOfFont(tkfont), -1);
+ }
+ break;
}
- break;
- }
- case TK_OPTION_STYLE: {
- Tk_Style style = *((Tk_Style *)internalPtr);
+ case TK_OPTION_STYLE: {
+ Tk_Style style = *((Tk_Style *)internalPtr);
- if (style != NULL) {
- objPtr = Tcl_NewStringObj(Tk_NameOfStyle(style), -1);
+ if (style != NULL) {
+ objPtr = Tcl_NewStringObj(Tk_NameOfStyle(style), -1);
+ }
+ break;
}
- break;
- }
- case TK_OPTION_BITMAP: {
- Pixmap pixmap = *((Pixmap *)internalPtr);
+ case TK_OPTION_BITMAP: {
+ Pixmap pixmap = *((Pixmap *)internalPtr);
- if (pixmap != None) {
- objPtr = Tcl_NewStringObj(
+ if (pixmap != None) {
+ objPtr = Tcl_NewStringObj(
Tk_NameOfBitmap(Tk_Display(tkwin), pixmap), -1);
+ }
+ break;
}
- break;
- }
- case TK_OPTION_BORDER: {
- Tk_3DBorder border = *((Tk_3DBorder *)internalPtr);
+ case TK_OPTION_BORDER: {
+ Tk_3DBorder border = *((Tk_3DBorder *)internalPtr);
- if (border != NULL) {
- objPtr = Tcl_NewStringObj(Tk_NameOf3DBorder(border), -1);
+ if (border != NULL) {
+ objPtr = Tcl_NewStringObj(Tk_NameOf3DBorder(border), -1);
+ }
+ break;
}
- break;
- }
- case TK_OPTION_RELIEF:
- objPtr = Tcl_NewStringObj(Tk_NameOfRelief(*((int *)internalPtr)), -1);
- break;
- case TK_OPTION_CURSOR: {
- Tk_Cursor cursor = *((Tk_Cursor *)internalPtr);
+ case TK_OPTION_RELIEF:
+ objPtr = Tcl_NewStringObj(Tk_NameOfRelief(*((int *)internalPtr)), -1);
+ break;
+ case TK_OPTION_CURSOR: {
+ Tk_Cursor cursor = *((Tk_Cursor *)internalPtr);
- if (cursor != NULL) {
- objPtr = Tcl_NewStringObj(
- Tk_NameOfCursor(Tk_Display(tkwin), cursor), -1);
+ if (cursor != NULL) {
+ objPtr = Tcl_NewStringObj(
+ Tk_NameOfCursor(Tk_Display(tkwin), cursor), -1);
+ }
+ break;
}
- break;
- }
- case TK_OPTION_JUSTIFY:
- objPtr = Tcl_NewStringObj(Tk_NameOfJustify(
- *((Tk_Justify *)internalPtr)), -1);
- break;
- case TK_OPTION_ANCHOR:
- objPtr = Tcl_NewStringObj(Tk_NameOfAnchor(
- *((Tk_Anchor *) internalPtr)), -1);
- break;
- case TK_OPTION_PIXELS:
- objPtr = Tcl_NewIntObj(*((int *)internalPtr));
- break;
- case TK_OPTION_WINDOW: {
- tkwin = *((Tk_Window *)internalPtr);
+ case TK_OPTION_JUSTIFY:
+ objPtr = Tcl_NewStringObj(Tk_NameOfJustify(
+ *((Tk_Justify *)internalPtr)), -1);
+ break;
+ case TK_OPTION_ANCHOR:
+ objPtr = Tcl_NewStringObj(Tk_NameOfAnchor(
+ *((Tk_Anchor *)internalPtr)), -1);
+ break;
+ case TK_OPTION_PIXELS:
+ objPtr = Tcl_NewWideIntObj(*((int *)internalPtr));
+ break;
+ case TK_OPTION_WINDOW: {
+ tkwin = *((Tk_Window *) internalPtr);
- if (tkwin != NULL) {
- objPtr = Tcl_NewStringObj(Tk_PathName(tkwin), -1);
+ if (tkwin != NULL) {
+ objPtr = Tcl_NewStringObj(Tk_PathName(tkwin), -1);
+ }
+ break;
}
- break;
- }
- case TK_OPTION_CUSTOM: {
- const Tk_ObjCustomOption *custom = optionPtr->extra.custom;
+ case TK_OPTION_CUSTOM: {
+ const Tk_ObjCustomOption *custom = optionPtr->extra.custom;
- objPtr = custom->getProc(custom->clientData, tkwin, recordPtr,
- optionPtr->specPtr->internalOffset);
- break;
- }
- default:
- Tcl_Panic("bad option type in GetObjectForOption");
+ objPtr = custom->getProc(custom->clientData, tkwin, (char *)recordPtr,
+ optionPtr->specPtr->internalOffset);
+ break;
+ }
+ default:
+ Tcl_Panic("bad option type in GetObjectForOption");
+ }
}
if (objPtr == NULL) {
objPtr = Tcl_NewObj();
@@ -2006,7 +2002,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
@@ -2024,8 +2020,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
@@ -2095,9 +2091,9 @@ TkDebugConfig(
if (tablePtr == (OptionTable *) Tcl_GetHashValue(hashEntryPtr)) {
for ( ; tablePtr != NULL; tablePtr = tablePtr->nextPtr) {
Tcl_ListObjAppendElement(NULL, objPtr,
- Tcl_NewIntObj(tablePtr->refCount));
+ Tcl_NewWideIntObj(tablePtr->refCount));
Tcl_ListObjAppendElement(NULL, objPtr,
- Tcl_NewIntObj(tablePtr->numOptions));
+ Tcl_NewWideIntObj(tablePtr->numOptions));
Tcl_ListObjAppendElement(NULL, objPtr, Tcl_NewStringObj(
tablePtr->options[0].specPtr->optionName, -1));
}
diff --git a/generic/tkConsole.c b/generic/tkConsole.c
index 095d132..345c937 100644
--- a/generic/tkConsole.c
+++ b/generic/tkConsole.c
@@ -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;
/*
@@ -68,7 +68,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,7 +224,7 @@ Tk_InitConsoleChannels(
* 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;
}
diff --git a/generic/tkCursor.c b/generic/tkCursor.c
index 21c713a..98f018a 100644
--- a/generic/tkCursor.c
+++ b/generic/tkCursor.c
@@ -100,7 +100,7 @@ Tk_AllocCursorFromObj(
if (objPtr->typePtr != &tkCursorObjType) {
InitCursorObj(objPtr);
}
- cursorPtr = objPtr->internalRep.twoPtrValue.ptr1;
+ cursorPtr = (TkCursor *)objPtr->internalRep.twoPtrValue.ptr1;
/*
* If the object currently points to a TkCursor, see if it's the one we
@@ -129,7 +129,7 @@ Tk_AllocCursorFromObj(
*/
if (cursorPtr != NULL) {
- TkCursor *firstCursorPtr = Tcl_GetHashValue(cursorPtr->hashPtr);
+ TkCursor *firstCursorPtr = (TkCursor *)Tcl_GetHashValue(cursorPtr->hashPtr);
FreeCursorObj(objPtr);
for (cursorPtr = firstCursorPtr; cursorPtr != NULL;
@@ -229,7 +229,7 @@ TkcGetCursor(
* details on legal syntax. */
{
Tcl_HashEntry *nameHashPtr;
- register TkCursor *cursorPtr;
+ TkCursor *cursorPtr;
TkCursor *existingCursorPtr = NULL;
int isNew;
TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
@@ -241,7 +241,7 @@ TkcGetCursor(
nameHashPtr = Tcl_CreateHashEntry(&dispPtr->cursorNameTable,
string, &isNew);
if (!isNew) {
- existingCursorPtr = Tcl_GetHashValue(nameHashPtr);
+ existingCursorPtr = (TkCursor *)Tcl_GetHashValue(nameHashPtr);
for (cursorPtr = existingCursorPtr; cursorPtr != NULL;
cursorPtr = cursorPtr->nextPtr) {
if (Tk_Display(tkwin) == cursorPtr->display) {
@@ -320,7 +320,7 @@ Tk_GetCursorFromData(
{
DataKey dataKey;
Tcl_HashEntry *dataHashPtr;
- register TkCursor *cursorPtr;
+ TkCursor *cursorPtr;
int isNew;
XColor fgColor, bgColor;
TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
@@ -341,7 +341,7 @@ Tk_GetCursorFromData(
dataHashPtr = Tcl_CreateHashEntry(&dispPtr->cursorDataTable,
(char *) &dataKey, &isNew);
if (!isNew) {
- cursorPtr = Tcl_GetHashValue(dataHashPtr);
+ cursorPtr = (TkCursor *)Tcl_GetHashValue(dataHashPtr);
cursorPtr->resourceRefCount++;
return cursorPtr->cursor;
}
@@ -428,11 +428,11 @@ Tk_NameOfCursor(
sprintf(dispPtr->cursorString, "cursor id 0x%" TCL_Z_MODIFIER "x", (size_t)cursor);
return dispPtr->cursorString;
}
- idHashPtr = Tcl_FindHashEntry(&dispPtr->cursorIdTable, (char *) cursor);
+ idHashPtr = Tcl_FindHashEntry(&dispPtr->cursorIdTable, cursor);
if (idHashPtr == NULL) {
goto printid;
}
- cursorPtr = Tcl_GetHashValue(idHashPtr);
+ cursorPtr = (TkCursor *)Tcl_GetHashValue(idHashPtr);
if (cursorPtr->otherTable != &dispPtr->cursorNameTable) {
goto printid;
}
@@ -463,13 +463,12 @@ FreeCursor(
{
TkCursor *prevPtr;
- cursorPtr->resourceRefCount--;
- if (cursorPtr->resourceRefCount > 0) {
+ if (cursorPtr->resourceRefCount-- > 1) {
return;
}
Tcl_DeleteHashEntry(cursorPtr->idHashPtr);
- prevPtr = Tcl_GetHashValue(cursorPtr->hashPtr);
+ prevPtr = (TkCursor *)Tcl_GetHashValue(cursorPtr->hashPtr);
if (prevPtr == cursorPtr) {
if (cursorPtr->nextPtr == NULL) {
Tcl_DeleteHashEntry(cursorPtr->hashPtr);
@@ -518,11 +517,11 @@ 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");
}
- FreeCursor(Tcl_GetHashValue(idHashPtr));
+ FreeCursor((TkCursor *)Tcl_GetHashValue(idHashPtr));
}
/*
@@ -587,11 +586,10 @@ static void
FreeCursorObj(
Tcl_Obj *objPtr) /* The object we are releasing. */
{
- TkCursor *cursorPtr = objPtr->internalRep.twoPtrValue.ptr1;
+ TkCursor *cursorPtr = (TkCursor *)objPtr->internalRep.twoPtrValue.ptr1;
if (cursorPtr != NULL) {
- cursorPtr->objRefCount--;
- if ((cursorPtr->objRefCount == 0)
+ if ((cursorPtr->objRefCount-- <= 1)
&& (cursorPtr->resourceRefCount == 0)) {
ckfree(cursorPtr);
}
@@ -622,7 +620,7 @@ DupCursorObjProc(
Tcl_Obj *srcObjPtr, /* The object we are copying from. */
Tcl_Obj *dupObjPtr) /* The object we are copying to. */
{
- TkCursor *cursorPtr = srcObjPtr->internalRep.twoPtrValue.ptr1;
+ TkCursor *cursorPtr = (TkCursor *)srcObjPtr->internalRep.twoPtrValue.ptr1;
dupObjPtr->typePtr = srcObjPtr->typePtr;
dupObjPtr->internalRep.twoPtrValue.ptr1 = cursorPtr;
@@ -707,7 +705,7 @@ GetCursorFromObj(
* cached is the one that is needed.
*/
- cursorPtr = objPtr->internalRep.twoPtrValue.ptr1;
+ cursorPtr = (TkCursor *)objPtr->internalRep.twoPtrValue.ptr1;
if ((cursorPtr != NULL) && (Tk_Display(tkwin) == cursorPtr->display)) {
return cursorPtr;
}
@@ -722,7 +720,7 @@ GetCursorFromObj(
if (hashPtr == NULL) {
goto error;
}
- for (cursorPtr = Tcl_GetHashValue(hashPtr);
+ for (cursorPtr = (TkCursor *)Tcl_GetHashValue(hashPtr);
cursorPtr != NULL; cursorPtr = cursorPtr->nextPtr) {
if (Tk_Display(tkwin) == cursorPtr->display) {
FreeCursorObj(objPtr);
@@ -857,16 +855,16 @@ TkDebugCursor(
resultPtr = Tcl_NewObj();
hashPtr = Tcl_FindHashEntry(&dispPtr->cursorNameTable, name);
if (hashPtr != NULL) {
- cursorPtr = Tcl_GetHashValue(hashPtr);
+ cursorPtr = (TkCursor *)Tcl_GetHashValue(hashPtr);
if (cursorPtr == NULL) {
Tcl_Panic("TkDebugCursor found empty hash table entry");
}
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 2448439..57af7d8 100644
--- a/generic/tkDList.h
+++ b/generic/tkDList.h
@@ -28,8 +28,8 @@
* MyList listHdr = TK_DLIST_LIST_INITIALIZER; // or MyList_Init(&listHdr)
* MyListEntry *p;
* int i = 0;
- * MyList_Append(&listHdr, ckalloc(sizeof(MyListEntry)));
- * MyList_Append(&listHdr, ckalloc(sizeof(MyListEntry)));
+ * MyList_Append(&listHdr, (MyListEntry *)ckalloc(sizeof(MyListEntry)));
+ * MyList_Append(&listHdr, (MyListEntry *)ckalloc(sizeof(MyListEntry)));
* TK_DLIST_FOREACH(p, &listHdr) { p->value = i++; }
* // ...
* MyList_RemoveHead(&listHdr);
@@ -361,9 +361,9 @@ LT##_Prepend(LT *head, struct ElemType *elem) \
{ \
assert(head); \
assert(elem); \
- elem->_dl_.prev = (void *) head; \
+ elem->_dl_.prev = (PSEntry *) head; \
if (!head->first) { \
- elem->_dl_.next = (void *) head; \
+ elem->_dl_.next = (PSEntry *) head; \
head->last = elem; \
} else { \
elem->_dl_.next = head->first; \
@@ -378,9 +378,9 @@ LT##_Append(LT *head, struct ElemType *elem) \
{ \
assert(head); \
assert(elem); \
- elem->_dl_.next = (void *) head; \
+ elem->_dl_.next = (PSEntry *) head; \
if (!head->first) { \
- elem->_dl_.prev = (void *) head; \
+ elem->_dl_.prev = (PSEntry *) head; \
head->first = elem; \
} else { \
elem->_dl_.prev = head->last; \
@@ -402,9 +402,9 @@ LT##_Move(LT *dst, LT *src) \
dst->last = src->last; \
} else { \
*dst = *src; \
- dst->first->_dl_.prev = (void *) dst; \
+ dst->first->_dl_.prev = (PSEntry *) dst; \
} \
- dst->last->_dl_.next = (void *) dst; \
+ dst->last->_dl_.next = (PSEntry *) dst; \
LT##_Init(src); \
} \
} \
@@ -528,11 +528,11 @@ LT##_Traverse(LT *head, LT##_Func func) \
#define TK_DLIST_FOREACH(var, head) \
assert(head); \
- for (var = head->first ? head->first : (void *) head; var != (void *) head; var = var->_dl_.next)
+ for (var = head->first ? head->first : (PSEntry *) head; var != (PSEntry *) head; var = var->_dl_.next)
#define TK_DLIST_FOREACH_REVERSE(var, head) \
assert(head); \
- for (var = head->last ? head->last : (void *) head; var != (void *) head; var = var->_dl_.prev)
+ for (var = head->last ? head->last : (PSEntry *) head; var != (PSEntry *) head; var = var->_dl_.prev)
#endif /* TK_DLIST_DEFINED */
diff --git a/generic/tkDecls.h b/generic/tkDecls.h
index 87bb218..07d3699 100644
--- a/generic/tkDecls.h
+++ b/generic/tkDecls.h
@@ -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
@@ -95,7 +103,7 @@ EXTERN int Tk_CanvasTagsParseProc(ClientData clientData,
Tcl_Interp *interp, Tk_Window tkwin,
const char *value, char *widgRec, int offset);
/* 19 */
-EXTERN CONST86 char * Tk_CanvasTagsPrintProc(ClientData clientData,
+EXTERN const char * Tk_CanvasTagsPrintProc(ClientData clientData,
Tk_Window tkwin, char *widgRec, int offset,
Tcl_FreeProc **freeProcPtr);
/* 20 */
@@ -133,7 +141,7 @@ EXTERN int Tk_ConfigureValue(Tcl_Interp *interp,
/* 29 */
EXTERN int Tk_ConfigureWidget(Tcl_Interp *interp,
Tk_Window tkwin, const Tk_ConfigSpec *specs,
- int argc, CONST84 char **argv, char *widgRec,
+ int argc, const char **argv, char *widgRec,
int flags);
/* 30 */
EXTERN void Tk_ConfigureWindow(Tk_Window tkwin,
@@ -215,7 +223,7 @@ 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);
@@ -281,7 +289,8 @@ 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 */
@@ -298,9 +307,9 @@ EXTERN void Tk_GetAllBindings(Tcl_Interp *interp,
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,
+EXTERN const char * Tk_GetBinding(Tcl_Interp *interp,
Tk_BindingTable bindingTable,
ClientData object, const char *eventStr);
/* 85 */
@@ -346,9 +355,9 @@ EXTERN Tk_Image Tk_GetImage(Tcl_Interp *interp, Tk_Window tkwin,
Tk_ImageChangedProc *changeProc,
ClientData clientData);
/* 98 */
-EXTERN ClientData Tk_GetImageMasterData(Tcl_Interp *interp,
+EXTERN ClientData Tk_GetImageModelData(Tcl_Interp *interp,
const char *name,
- CONST86 Tk_ImageType **typePtrPtr);
+ const Tk_ImageType **typePtrPtr);
/* 99 */
EXTERN Tk_ItemType * Tk_GetItemTypes(void);
/* 100 */
@@ -376,7 +385,7 @@ 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,
+ const char **argv, double *dblPtr,
int *intPtr);
/* 109 */
EXTERN int Tk_GetScreenMM(Tcl_Interp *interp, Tk_Window tkwin,
@@ -402,7 +411,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 */
@@ -438,28 +447,27 @@ 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);
@@ -468,14 +476,16 @@ EXTERN void Tk_OwnSelection(Tk_Window tkwin, Atom selection,
Tk_LostSelProc *proc, ClientData 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 +496,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);
@@ -620,7 +632,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 +654,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,
@@ -667,7 +679,7 @@ EXTERN int Tk_GetScrollInfoObj(Tcl_Interp *interp, int 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 void Tk_MainEx(int argc, char **argv,
@@ -676,7 +688,7 @@ EXTERN void Tk_MainEx(int argc, char **argv,
/* 213 */
EXTERN void Tk_RestoreSavedOptions(Tk_SavedOptions *savePtr);
/* 214 */
-EXTERN int Tk_SetOptions(Tcl_Interp *interp, char *recordPtr,
+EXTERN int Tk_SetOptions(Tcl_Interp *interp, void *recordPtr,
Tk_OptionTable optionTable, int objc,
Tcl_Obj *const objv[], Tk_Window tkwin,
Tk_SavedOptions *savePtr, int *maskPtr);
@@ -776,11 +788,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);
@@ -818,22 +832,22 @@ EXTERN Tk_StyledElement Tk_GetStyledElement(Tk_Style style, int 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,14 +878,21 @@ 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 */
-/* 280 */
-EXTERN void TkUnusedStubEntry(void);
+/* 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);
typedef struct {
const struct TkPlatStubs *tkPlatStubs;
@@ -903,7 +924,7 @@ typedef struct TkStubs {
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 */
+ const char * (*tk_CanvasTagsPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, int 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 */
@@ -913,7 +934,7 @@ typedef struct TkStubs {
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_ConfigureWidget) (Tcl_Interp *interp, Tk_Window tkwin, const Tk_ConfigSpec *specs, int argc, const char **argv, char *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_Window (*tk_CoordsToWindow) (int rootX, int rootY, Tk_Window tkwin); /* 32 */
@@ -939,7 +960,7 @@ typedef struct TkStubs {
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_Draw3DRectangle) (Tk_Window tkwin, Drawable drawable, Tk_3DBorder border, int x, int y, int width, int height, int borderWidth, int relief); /* 58 */
@@ -961,14 +982,14 @@ typedef struct TkStubs {
void (*tk_FreeOptions) (const Tk_ConfigSpec *specs, char *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 */
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, ClientData 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 */
@@ -982,7 +1003,7 @@ typedef struct TkStubs {
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 */
+ ClientData (*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 */
@@ -992,7 +1013,7 @@ 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, int 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 */
Tk_Uid (*tk_GetUid) (const char *str); /* 111 */
@@ -1001,7 +1022,7 @@ typedef struct TkStubs {
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 */
@@ -1014,27 +1035,27 @@ typedef struct TkStubs {
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 */
+ 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 */
@@ -1079,7 +1100,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 */
@@ -1088,17 +1109,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 */
- void (*tk_MainEx) (int argc, char **argv, Tcl_AppInitProc *appInitProc, Tcl_Interp *interp); /* 212 */
+ 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") void (*tk_MainEx) (int 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, int 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 */
@@ -1130,8 +1151,8 @@ typedef struct TkStubs {
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 */
@@ -1145,10 +1166,10 @@ typedef struct TkStubs {
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 */
+ 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 */
@@ -1158,13 +1179,12 @@ 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 (*tkUnusedStubEntry) (void); /* 280 */
+ 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 */
} TkStubs;
extern const TkStubs *tkStubsPtr;
@@ -1375,8 +1395,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 \
@@ -1725,14 +1745,18 @@ 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 */
-#define TkUnusedStubEntry \
- (tkStubsPtr->tkUnusedStubEntry) /* 280 */
+#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 */
#endif /* defined(USE_TK_STUBS) */
@@ -1743,7 +1767,14 @@ 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
#if defined(_WIN32) && defined(UNICODE)
# define Tk_MainEx Tk_MainExW
@@ -1751,6 +1782,17 @@ extern const TkStubs *tkStubsPtr;
Tcl_AppInitProc *appInitProc, Tcl_Interp *interp);
#endif
+
+#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 4ffb48b..fbb7e29 100644
--- a/generic/tkEntry.c
+++ b/generic/tkEntry.c
@@ -16,8 +16,8 @@
*/
#include "tkInt.h"
-#include "default.h"
#include "tkEntry.h"
+#include "default.h"
/*
* The following macro defines how many extra pixels to leave on each side of
@@ -63,102 +63,108 @@ enum validateType {
static const Tk_OptionSpec entryOptSpec[] = {
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_ENTRY_BG_COLOR, -1, Tk_Offset(Entry, normalBorder),
+ DEF_ENTRY_BG_COLOR, TCL_INDEX_NONE, offsetof(Entry, normalBorder),
0, DEF_ENTRY_BG_MONO, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL,
- NULL, 0, -1, 0, "-background", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_ENTRY_BORDER_WIDTH, -1, Tk_Offset(Entry, borderWidth), 0, 0, 0},
+ DEF_ENTRY_BORDER_WIDTH, TCL_INDEX_NONE, offsetof(Entry, borderWidth), 0, 0, 0},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_ENTRY_CURSOR, -1, Tk_Offset(Entry, cursor),
+ DEF_ENTRY_CURSOR, TCL_INDEX_NONE, offsetof(Entry, cursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_BORDER, "-disabledbackground", "disabledBackground",
- "DisabledBackground", DEF_ENTRY_DISABLED_BG_COLOR, -1,
- Tk_Offset(Entry, disabledBorder), TK_OPTION_NULL_OK,
+ "DisabledBackground", DEF_ENTRY_DISABLED_BG_COLOR, TCL_INDEX_NONE,
+ offsetof(Entry, disabledBorder), TK_OPTION_NULL_OK,
(ClientData) DEF_ENTRY_DISABLED_BG_MONO, 0},
{TK_OPTION_COLOR, "-disabledforeground", "disabledForeground",
- "DisabledForeground", DEF_ENTRY_DISABLED_FG, -1,
- Tk_Offset(Entry, dfgColorPtr), TK_OPTION_NULL_OK, 0, 0},
+ "DisabledForeground", DEF_ENTRY_DISABLED_FG, TCL_INDEX_NONE,
+ offsetof(Entry, dfgColorPtr), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_BOOLEAN, "-exportselection", "exportSelection",
- "ExportSelection", DEF_ENTRY_EXPORT_SELECTION, -1,
- Tk_Offset(Entry, exportSelection), 0, 0, 0},
+ "ExportSelection", DEF_ENTRY_EXPORT_SELECTION, TCL_INDEX_NONE,
+ offsetof(Entry, exportSelection), 0, 0, 0},
{TK_OPTION_SYNONYM, "-fg", "foreground", NULL,
- NULL, 0, -1, 0, "-foreground", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_ENTRY_FONT, -1, Tk_Offset(Entry, tkfont), 0, 0, 0},
+ DEF_ENTRY_FONT, TCL_INDEX_NONE, offsetof(Entry, tkfont), 0, 0, 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_ENTRY_FG, -1, Tk_Offset(Entry, fgColorPtr), 0, 0, 0},
+ DEF_ENTRY_FG, TCL_INDEX_NONE, offsetof(Entry, fgColorPtr), 0, 0, 0},
{TK_OPTION_COLOR, "-highlightbackground", "highlightBackground",
"HighlightBackground", DEF_ENTRY_HIGHLIGHT_BG,
- -1, Tk_Offset(Entry, highlightBgColorPtr), 0, 0, 0},
+ TCL_INDEX_NONE, offsetof(Entry, highlightBgColorPtr), 0, 0, 0},
{TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_ENTRY_HIGHLIGHT, -1, Tk_Offset(Entry, highlightColorPtr), 0, 0, 0},
+ DEF_ENTRY_HIGHLIGHT, TCL_INDEX_NONE, offsetof(Entry, highlightColorPtr), 0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
- "HighlightThickness", DEF_ENTRY_HIGHLIGHT_WIDTH, -1,
- Tk_Offset(Entry, highlightWidth), 0, 0, 0},
+ "HighlightThickness", DEF_ENTRY_HIGHLIGHT_WIDTH, TCL_INDEX_NONE,
+ offsetof(Entry, highlightWidth), 0, 0, 0},
{TK_OPTION_BORDER, "-insertbackground", "insertBackground", "Foreground",
- DEF_ENTRY_INSERT_BG, -1, Tk_Offset(Entry, insertBorder), 0, 0, 0},
+ DEF_ENTRY_INSERT_BG, TCL_INDEX_NONE, offsetof(Entry, insertBorder), 0, 0, 0},
{TK_OPTION_PIXELS, "-insertborderwidth", "insertBorderWidth",
- "BorderWidth", DEF_ENTRY_INSERT_BD_COLOR, -1,
- Tk_Offset(Entry, insertBorderWidth), 0,
+ "BorderWidth", DEF_ENTRY_INSERT_BD_COLOR, TCL_INDEX_NONE,
+ offsetof(Entry, insertBorderWidth), 0,
(ClientData) DEF_ENTRY_INSERT_BD_MONO, 0},
{TK_OPTION_INT, "-insertofftime", "insertOffTime", "OffTime",
- DEF_ENTRY_INSERT_OFF_TIME, -1, Tk_Offset(Entry, insertOffTime),
+ DEF_ENTRY_INSERT_OFF_TIME, TCL_INDEX_NONE, offsetof(Entry, insertOffTime),
0, 0, 0},
{TK_OPTION_INT, "-insertontime", "insertOnTime", "OnTime",
- DEF_ENTRY_INSERT_ON_TIME, -1, Tk_Offset(Entry, insertOnTime), 0, 0, 0},
+ DEF_ENTRY_INSERT_ON_TIME, TCL_INDEX_NONE, offsetof(Entry, insertOnTime), 0, 0, 0},
{TK_OPTION_PIXELS, "-insertwidth", "insertWidth", "InsertWidth",
- DEF_ENTRY_INSERT_WIDTH, -1, Tk_Offset(Entry, insertWidth), 0, 0, 0},
+ DEF_ENTRY_INSERT_WIDTH, TCL_INDEX_NONE, offsetof(Entry, insertWidth), 0, 0, 0},
{TK_OPTION_STRING, "-invalidcommand", "invalidCommand", "InvalidCommand",
- DEF_ENTRY_INVALIDCMD, -1, Tk_Offset(Entry, invalidCmd),
+ DEF_ENTRY_INVALIDCMD, TCL_INDEX_NONE, offsetof(Entry, invalidCmd),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_SYNONYM, "-invcmd", NULL, NULL,
- NULL, 0, -1, 0, "-invalidcommand", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-invalidcommand", 0},
{TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
- DEF_ENTRY_JUSTIFY, -1, Tk_Offset(Entry, justify), 0, 0, 0},
+ DEF_ENTRY_JUSTIFY, TCL_INDEX_NONE, offsetof(Entry, justify), 0, 0, 0},
+ {TK_OPTION_STRING, "-placeholder", "placeHolder", "PlaceHolder",
+ DEF_ENTRY_PLACEHOLDER, 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,
(ClientData) DEF_ENTRY_READONLY_BG_MONO, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_ENTRY_RELIEF, -1, Tk_Offset(Entry, relief), 0, 0, 0},
+ DEF_ENTRY_RELIEF, TCL_INDEX_NONE, offsetof(Entry, relief), 0, 0, 0},
{TK_OPTION_BORDER, "-selectbackground", "selectBackground", "Foreground",
- DEF_ENTRY_SELECT_COLOR, -1, Tk_Offset(Entry, selBorder),
+ DEF_ENTRY_SELECT_COLOR, TCL_INDEX_NONE, offsetof(Entry, selBorder),
0, DEF_ENTRY_SELECT_MONO, 0},
{TK_OPTION_PIXELS, "-selectborderwidth", "selectBorderWidth",
- "BorderWidth", DEF_ENTRY_SELECT_BD_COLOR, -1,
- Tk_Offset(Entry, selBorderWidth),
+ "BorderWidth", DEF_ENTRY_SELECT_BD_COLOR, TCL_INDEX_NONE,
+ offsetof(Entry, selBorderWidth),
0, DEF_ENTRY_SELECT_BD_MONO, 0},
{TK_OPTION_COLOR, "-selectforeground", "selectForeground", "Background",
- DEF_ENTRY_SELECT_FG_COLOR, -1, Tk_Offset(Entry, selFgColorPtr),
+ DEF_ENTRY_SELECT_FG_COLOR, TCL_INDEX_NONE, offsetof(Entry, selFgColorPtr),
TK_OPTION_NULL_OK, DEF_ENTRY_SELECT_FG_MONO, 0},
{TK_OPTION_STRING, "-show", "show", "Show",
- DEF_ENTRY_SHOW, -1, Tk_Offset(Entry, showChar),
+ DEF_ENTRY_SHOW, TCL_INDEX_NONE, offsetof(Entry, showChar),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING_TABLE, "-state", "state", "State",
- DEF_ENTRY_STATE, -1, Tk_Offset(Entry, state),
+ DEF_ENTRY_STATE, TCL_INDEX_NONE, offsetof(Entry, state),
0, stateStrings, 0},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_ENTRY_TAKE_FOCUS, -1, Tk_Offset(Entry, takeFocus),
+ DEF_ENTRY_TAKE_FOCUS, TCL_INDEX_NONE, offsetof(Entry, takeFocus),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-textvariable", "textVariable", "Variable",
- DEF_ENTRY_TEXT_VARIABLE, -1, Tk_Offset(Entry, textVarName),
+ DEF_ENTRY_TEXT_VARIABLE, TCL_INDEX_NONE, offsetof(Entry, textVarName),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING_TABLE, "-validate", "validate", "Validate",
- DEF_ENTRY_VALIDATE, -1, Tk_Offset(Entry, validate),
+ DEF_ENTRY_VALIDATE, TCL_INDEX_NONE, offsetof(Entry, validate),
0, validateStrings, 0},
{TK_OPTION_STRING, "-validatecommand", "validateCommand","ValidateCommand",
- NULL, -1, Tk_Offset(Entry, validateCmd), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(Entry, validateCmd), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_SYNONYM, "-vcmd", NULL, NULL,
- NULL, 0, -1, 0, "-validatecommand", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-validatecommand", 0},
{TK_OPTION_INT, "-width", "width", "Width",
- DEF_ENTRY_WIDTH, -1, Tk_Offset(Entry, prefWidth), 0, 0, 0},
+ DEF_ENTRY_WIDTH, TCL_INDEX_NONE, offsetof(Entry, prefWidth), 0, 0, 0},
{TK_OPTION_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand",
- DEF_ENTRY_SCROLL_COMMAND, -1, Tk_Offset(Entry, scrollCmd),
+ DEF_ENTRY_SCROLL_COMMAND, TCL_INDEX_NONE, offsetof(Entry, scrollCmd),
TK_OPTION_NULL_OK, 0, 0},
- {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0}
+ {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0}
};
/*
@@ -180,135 +186,141 @@ static const Tk_OptionSpec entryOptSpec[] = {
static const Tk_OptionSpec sbOptSpec[] = {
{TK_OPTION_BORDER, "-activebackground", "activeBackground", "Background",
- DEF_BUTTON_ACTIVE_BG_COLOR, -1, Tk_Offset(Spinbox, activeBorder),
+ DEF_BUTTON_ACTIVE_BG_COLOR, TCL_INDEX_NONE, offsetof(Spinbox, activeBorder),
0, DEF_BUTTON_ACTIVE_BG_MONO, 0},
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_ENTRY_BG_COLOR, -1, Tk_Offset(Entry, normalBorder),
+ DEF_ENTRY_BG_COLOR, TCL_INDEX_NONE, offsetof(Entry, normalBorder),
0, DEF_ENTRY_BG_MONO, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL,
- NULL, 0, -1, 0, "-background", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_ENTRY_BORDER_WIDTH, -1, Tk_Offset(Entry, borderWidth), 0, 0, 0},
+ 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,
(ClientData) DEF_ENTRY_DISABLED_BG_MONO, 0},
{TK_OPTION_COLOR, "-disabledforeground", "disabledForeground",
- "DisabledForeground", DEF_ENTRY_DISABLED_FG, -1,
- Tk_Offset(Entry, dfgColorPtr), TK_OPTION_NULL_OK, 0, 0},
+ "DisabledForeground", DEF_ENTRY_DISABLED_FG, TCL_INDEX_NONE,
+ offsetof(Entry, dfgColorPtr), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_BOOLEAN, "-exportselection", "exportSelection",
- "ExportSelection", DEF_ENTRY_EXPORT_SELECTION, -1,
- Tk_Offset(Entry, exportSelection), 0, 0, 0},
+ "ExportSelection", DEF_ENTRY_EXPORT_SELECTION, TCL_INDEX_NONE,
+ offsetof(Entry, exportSelection), 0, 0, 0},
{TK_OPTION_SYNONYM, "-fg", "foreground", NULL,
- NULL, 0, -1, 0, "-foreground", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_ENTRY_FONT, -1, Tk_Offset(Entry, tkfont), 0, 0, 0},
+ DEF_ENTRY_FONT, TCL_INDEX_NONE, offsetof(Entry, tkfont), 0, 0, 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_ENTRY_FG, -1, Tk_Offset(Entry, fgColorPtr), 0, 0, 0},
+ DEF_ENTRY_FG, TCL_INDEX_NONE, offsetof(Entry, fgColorPtr), 0, 0, 0},
{TK_OPTION_STRING, "-format", "format", "Format",
- DEF_SPINBOX_FORMAT, -1, Tk_Offset(Spinbox, reqFormat),
+ DEF_SPINBOX_FORMAT, TCL_INDEX_NONE, offsetof(Spinbox, reqFormat),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_DOUBLE, "-from", "from", "From",
- DEF_SPINBOX_FROM, -1, Tk_Offset(Spinbox, fromValue), 0, 0, 0},
+ DEF_SPINBOX_FROM, TCL_INDEX_NONE, offsetof(Spinbox, fromValue), 0, 0, 0},
{TK_OPTION_COLOR, "-highlightbackground", "highlightBackground",
"HighlightBackground", DEF_ENTRY_HIGHLIGHT_BG,
- -1, Tk_Offset(Entry, highlightBgColorPtr), 0, 0, 0},
+ TCL_INDEX_NONE, offsetof(Entry, highlightBgColorPtr), 0, 0, 0},
{TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_ENTRY_HIGHLIGHT, -1, Tk_Offset(Entry, highlightColorPtr), 0, 0, 0},
+ DEF_ENTRY_HIGHLIGHT, TCL_INDEX_NONE, offsetof(Entry, highlightColorPtr), 0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
- "HighlightThickness", DEF_ENTRY_HIGHLIGHT_WIDTH, -1,
- Tk_Offset(Entry, highlightWidth), 0, 0, 0},
+ "HighlightThickness", DEF_ENTRY_HIGHLIGHT_WIDTH, TCL_INDEX_NONE,
+ offsetof(Entry, highlightWidth), 0, 0, 0},
{TK_OPTION_DOUBLE, "-increment", "increment", "Increment",
- DEF_SPINBOX_INCREMENT, -1, Tk_Offset(Spinbox, increment), 0, 0, 0},
+ DEF_SPINBOX_INCREMENT, TCL_INDEX_NONE, offsetof(Spinbox, increment), 0, 0, 0},
{TK_OPTION_BORDER, "-insertbackground", "insertBackground", "Foreground",
- DEF_ENTRY_INSERT_BG, -1, Tk_Offset(Entry, insertBorder), 0, 0, 0},
+ DEF_ENTRY_INSERT_BG, TCL_INDEX_NONE, offsetof(Entry, insertBorder), 0, 0, 0},
{TK_OPTION_PIXELS, "-insertborderwidth", "insertBorderWidth",
- "BorderWidth", DEF_ENTRY_INSERT_BD_COLOR, -1,
- Tk_Offset(Entry, insertBorderWidth), 0,
+ "BorderWidth", DEF_ENTRY_INSERT_BD_COLOR, TCL_INDEX_NONE,
+ offsetof(Entry, insertBorderWidth), 0,
(ClientData) DEF_ENTRY_INSERT_BD_MONO, 0},
{TK_OPTION_INT, "-insertofftime", "insertOffTime", "OffTime",
- DEF_ENTRY_INSERT_OFF_TIME, -1, Tk_Offset(Entry, insertOffTime),
+ DEF_ENTRY_INSERT_OFF_TIME, TCL_INDEX_NONE, offsetof(Entry, insertOffTime),
0, 0, 0},
{TK_OPTION_INT, "-insertontime", "insertOnTime", "OnTime",
- DEF_ENTRY_INSERT_ON_TIME, -1, Tk_Offset(Entry, insertOnTime), 0, 0, 0},
+ DEF_ENTRY_INSERT_ON_TIME, TCL_INDEX_NONE, offsetof(Entry, insertOnTime), 0, 0, 0},
{TK_OPTION_PIXELS, "-insertwidth", "insertWidth", "InsertWidth",
- DEF_ENTRY_INSERT_WIDTH, -1, Tk_Offset(Entry, insertWidth), 0, 0, 0},
+ DEF_ENTRY_INSERT_WIDTH, TCL_INDEX_NONE, offsetof(Entry, insertWidth), 0, 0, 0},
{TK_OPTION_STRING, "-invalidcommand", "invalidCommand", "InvalidCommand",
- DEF_ENTRY_INVALIDCMD, -1, Tk_Offset(Entry, invalidCmd),
+ DEF_ENTRY_INVALIDCMD, TCL_INDEX_NONE, offsetof(Entry, invalidCmd),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_SYNONYM, "-invcmd", NULL, NULL,
- NULL, 0, -1, 0, "-invalidcommand", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-invalidcommand", 0},
{TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
- DEF_ENTRY_JUSTIFY, -1, Tk_Offset(Entry, justify), 0, 0, 0},
+ DEF_ENTRY_JUSTIFY, TCL_INDEX_NONE, offsetof(Entry, justify), 0, 0, 0},
+ {TK_OPTION_STRING, "-placeholder", "placeHolder", "PlaceHolder",
+ DEF_ENTRY_PLACEHOLDER, 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,
(ClientData) DEF_ENTRY_READONLY_BG_MONO, 0},
{TK_OPTION_INT, "-repeatdelay", "repeatDelay", "RepeatDelay",
- DEF_SPINBOX_REPEAT_DELAY, -1, Tk_Offset(Spinbox, repeatDelay),
+ DEF_SPINBOX_REPEAT_DELAY, TCL_INDEX_NONE, offsetof(Spinbox, repeatDelay),
0, 0, 0},
{TK_OPTION_INT, "-repeatinterval", "repeatInterval", "RepeatInterval",
- DEF_SPINBOX_REPEAT_INTERVAL, -1, Tk_Offset(Spinbox, repeatInterval),
+ DEF_SPINBOX_REPEAT_INTERVAL, TCL_INDEX_NONE, offsetof(Spinbox, repeatInterval),
0, 0, 0},
{TK_OPTION_BORDER, "-selectbackground", "selectBackground", "Foreground",
- DEF_ENTRY_SELECT_COLOR, -1, Tk_Offset(Entry, selBorder),
+ DEF_ENTRY_SELECT_COLOR, TCL_INDEX_NONE, offsetof(Entry, selBorder),
0, DEF_ENTRY_SELECT_MONO, 0},
{TK_OPTION_PIXELS, "-selectborderwidth", "selectBorderWidth",
- "BorderWidth", DEF_ENTRY_SELECT_BD_COLOR, -1,
- Tk_Offset(Entry, selBorderWidth),
+ "BorderWidth", DEF_ENTRY_SELECT_BD_COLOR, TCL_INDEX_NONE,
+ offsetof(Entry, selBorderWidth),
0, DEF_ENTRY_SELECT_BD_MONO, 0},
{TK_OPTION_COLOR, "-selectforeground", "selectForeground", "Background",
- DEF_ENTRY_SELECT_FG_COLOR, -1, Tk_Offset(Entry, selFgColorPtr),
+ DEF_ENTRY_SELECT_FG_COLOR, TCL_INDEX_NONE, offsetof(Entry, selFgColorPtr),
TK_OPTION_NULL_OK, DEF_ENTRY_SELECT_FG_MONO, 0},
{TK_OPTION_STRING_TABLE, "-state", "state", "State",
- DEF_ENTRY_STATE, -1, Tk_Offset(Entry, state),
+ DEF_ENTRY_STATE, TCL_INDEX_NONE, offsetof(Entry, state),
0, stateStrings, 0},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_ENTRY_TAKE_FOCUS, -1, Tk_Offset(Entry, takeFocus),
+ DEF_ENTRY_TAKE_FOCUS, TCL_INDEX_NONE, offsetof(Entry, takeFocus),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-textvariable", "textVariable", "Variable",
- DEF_ENTRY_TEXT_VARIABLE, -1, Tk_Offset(Entry, textVarName),
+ DEF_ENTRY_TEXT_VARIABLE, TCL_INDEX_NONE, offsetof(Entry, textVarName),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_DOUBLE, "-to", "to", "To",
- DEF_SPINBOX_TO, -1, Tk_Offset(Spinbox, toValue), 0, 0, 0},
+ DEF_SPINBOX_TO, TCL_INDEX_NONE, offsetof(Spinbox, toValue), 0, 0, 0},
{TK_OPTION_STRING_TABLE, "-validate", "validate", "Validate",
- DEF_ENTRY_VALIDATE, -1, Tk_Offset(Entry, validate),
+ DEF_ENTRY_VALIDATE, TCL_INDEX_NONE, offsetof(Entry, validate),
0, validateStrings, 0},
{TK_OPTION_STRING, "-validatecommand", "validateCommand","ValidateCommand",
- NULL, -1, Tk_Offset(Entry, validateCmd), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(Entry, validateCmd), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-values", "values", "Values",
- DEF_SPINBOX_VALUES, -1, Tk_Offset(Spinbox, valueStr),
+ DEF_SPINBOX_VALUES, TCL_INDEX_NONE, offsetof(Spinbox, valueStr),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_SYNONYM, "-vcmd", NULL, NULL,
- NULL, 0, -1, 0, "-validatecommand", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-validatecommand", 0},
{TK_OPTION_INT, "-width", "width", "Width",
- DEF_ENTRY_WIDTH, -1, Tk_Offset(Entry, prefWidth), 0, 0, 0},
+ DEF_ENTRY_WIDTH, TCL_INDEX_NONE, offsetof(Entry, prefWidth), 0, 0, 0},
{TK_OPTION_BOOLEAN, "-wrap", "wrap", "Wrap",
- DEF_SPINBOX_WRAP, -1, Tk_Offset(Spinbox, wrap), 0, 0, 0},
+ DEF_SPINBOX_WRAP, TCL_INDEX_NONE, offsetof(Spinbox, wrap), 0, 0, 0},
{TK_OPTION_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand",
- DEF_ENTRY_SCROLL_COMMAND, -1, Tk_Offset(Entry, scrollCmd),
+ DEF_ENTRY_SCROLL_COMMAND, TCL_INDEX_NONE, offsetof(Entry, scrollCmd),
TK_OPTION_NULL_OK, 0, 0},
- {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0}
+ {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0}
};
/*
@@ -391,7 +403,7 @@ 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);
+static int DeleteChars(Entry *entryPtr, TkSizeT index, TkSizeT count);
static void DestroyEntry(void *memPtr);
static void DisplayEntry(ClientData clientData);
static void EntryBlinkProc(ClientData clientData);
@@ -400,22 +412,22 @@ static void EntryComputeGeometry(Entry *entryPtr);
static void EntryEventProc(ClientData clientData,
XEvent *eventPtr);
static void EntryFocusProc(Entry *entryPtr, int gotFocus);
-static int EntryFetchSelection(ClientData clientData, int offset,
- char *buffer, int maxBytes);
+static TkSizeT EntryFetchSelection(ClientData clientData, TkSizeT offset,
+ char *buffer, TkSizeT maxBytes);
static void EntryLostSelection(ClientData 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, TkSizeT index);
static char * EntryTextVarProc(ClientData 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, TkSizeT 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, TkSizeT index,
int type, Tcl_DString *dsPtr);
static int EntryValueChanged(Entry *entryPtr,
const char *newValue);
@@ -426,8 +438,8 @@ static int EntryWidgetObjCmd(ClientData clientData,
Tcl_Obj *const objv[]);
static void EntryWorldChanged(ClientData 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, TkSizeT *indexPtr);
+static int InsertChars(Entry *entryPtr, TkSizeT index, const char *string);
/*
* These forward declarations are the spinbox specific ones:
@@ -472,15 +484,16 @@ static const Tk_ClassProcs entryClass = {
int
Tk_EntryObjCmd(
- ClientData clientData, /* NULL. */
+ ClientData dummy, /* NULL. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register Entry *entryPtr;
+ Entry *entryPtr;
Tk_OptionTable optionTable;
Tk_Window tkwin;
char *tmp;
+ (void)dummy;
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "pathName ?-option value ...?");
@@ -507,7 +520,7 @@ Tk_EntryObjCmd(
* initialized as memset covers the rest.
*/
- entryPtr = ckalloc(sizeof(Entry));
+ entryPtr = (Entry *)ckalloc(sizeof(Entry));
memset(entryPtr, 0, sizeof(Entry));
entryPtr->tkwin = tkwin;
@@ -518,11 +531,11 @@ Tk_EntryObjCmd(
EntryCmdDeletedProc);
entryPtr->optionTable = optionTable;
entryPtr->type = TK_ENTRY;
- tmp = ckalloc(1);
+ tmp = (char *)ckalloc(1);
tmp[0] = '\0';
entryPtr->string = tmp;
- entryPtr->selectFirst = -1;
- entryPtr->selectLast = -1;
+ entryPtr->selectFirst = TCL_INDEX_NONE;
+ entryPtr->selectLast = TCL_INDEX_NONE;
entryPtr->cursor = NULL;
entryPtr->exportSelection = 1;
@@ -537,6 +550,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.
@@ -552,14 +567,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;
}
@@ -588,7 +603,7 @@ EntryWidgetObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- Entry *entryPtr = clientData;
+ Entry *entryPtr = (Entry *)clientData;
int cmdIndex, selIndex, result;
Tcl_Obj *objPtr;
@@ -611,7 +626,8 @@ EntryWidgetObjCmd(
Tcl_Preserve(entryPtr);
switch ((enum entryCmd) cmdIndex) {
case COMMAND_BBOX: {
- int index, x, y, width, height;
+ TkSizeT index;
+ int x, y, width, height;
Tcl_Obj *bbox[4];
if (objc != 3) {
@@ -622,14 +638,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;
}
@@ -640,7 +656,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;
@@ -650,7 +666,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);
@@ -664,7 +680,8 @@ EntryWidgetObjCmd(
break;
case COMMAND_DELETE: {
- int first, last, code;
+ TkSizeT first, last;
+ int code;
if ((objc < 3) || (objc > 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "firstIndex ?lastIndex?");
@@ -680,7 +697,7 @@ EntryWidgetObjCmd(
&last) != TCL_OK) {
goto error;
}
- if ((last >= first) && (entryPtr->state == STATE_NORMAL)) {
+ if ((last + 1 >= first + 1 ) && (entryPtr->state == STATE_NORMAL)) {
code = DeleteChars(entryPtr, first, last - first);
if (code != TCL_OK) {
goto error;
@@ -694,7 +711,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:
@@ -710,7 +727,7 @@ EntryWidgetObjCmd(
break;
case COMMAND_INDEX: {
- int index;
+ TkSizeT index;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "string");
@@ -720,12 +737,13 @@ EntryWidgetObjCmd(
&index) != TCL_OK) {
goto error;
}
- Tcl_SetObjResult(interp, Tcl_NewIntObj(index));
+ Tcl_SetObjResult(interp, TkNewIndexObj(index));
break;
}
case COMMAND_INSERT: {
- int index, code;
+ TkSizeT index;
+ int code;
if (objc != 4) {
Tcl_WrongNumArgs(interp, 2, objv, "index text");
@@ -776,7 +794,7 @@ EntryWidgetObjCmd(
}
case COMMAND_SELECTION: {
- int index, index2;
+ TkSizeT index, index2;
if (objc < 3) {
Tcl_WrongNumArgs(interp, 2, objv, "option ?index?");
@@ -814,14 +832,14 @@ EntryWidgetObjCmd(
objv[3], &index) != TCL_OK) {
goto error;
}
- if (entryPtr->selectFirst >= 0) {
- int half1, half2;
+ if (entryPtr->selectFirst != TCL_INDEX_NONE) {
+ TkSizeT half1, half2;
half1 = (entryPtr->selectFirst + entryPtr->selectLast)/2;
half2 = (entryPtr->selectFirst + entryPtr->selectLast + 1)/2;
- if (index < half1) {
+ if (index + 1 < half1 + 1 ) {
entryPtr->selectAnchor = entryPtr->selectLast;
- } else if (index > half2) {
+ } else if (index + 1 > half2 + 1 ) {
entryPtr->selectAnchor = entryPtr->selectFirst;
} else {
/*
@@ -838,9 +856,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;
@@ -863,7 +881,7 @@ EntryWidgetObjCmd(
goto error;
}
Tcl_SetObjResult(interp,
- Tcl_NewBooleanObj(entryPtr->selectFirst >= 0));
+ Tcl_NewWideIntObj(entryPtr->selectFirst != TCL_INDEX_NONE));
goto done;
case SELECTION_RANGE:
@@ -879,9 +897,9 @@ EntryWidgetObjCmd(
&index2) != TCL_OK) {
goto error;
}
- if (index >= index2) {
- entryPtr->selectFirst = -1;
- entryPtr->selectLast = -1;
+ if (index + 1 >= index2 + 1 ) {
+ entryPtr->selectFirst = TCL_INDEX_NONE;
+ entryPtr->selectLast = TCL_INDEX_NONE;
} else {
entryPtr->selectFirst = index;
entryPtr->selectLast = index2;
@@ -930,7 +948,7 @@ EntryWidgetObjCmd(
}
case COMMAND_XVIEW: {
- int index;
+ TkSizeT index;
if (objc == 2) {
double first, last;
@@ -974,10 +992,10 @@ EntryWidgetObjCmd(
break;
}
}
- if (index >= entryPtr->numChars) {
+ if (index + 1 >= entryPtr->numChars + 1) {
index = entryPtr->numChars - 1;
}
- if (index < 0) {
+ if ((int)index < 0) {
index = 0;
}
entryPtr->leftIndex = index;
@@ -1019,7 +1037,7 @@ static void
DestroyEntry(
void *memPtr) /* Info about entry widget. */
{
- Entry *entryPtr = memPtr;
+ Entry *entryPtr = (Entry *)memPtr;
/*
* Free up all the stuff that requires special handling, then let
@@ -1097,13 +1115,13 @@ ConfigureEntry(
Spinbox *sbPtr = (Spinbox *) entryPtr;
/* Only used when this widget is of type
* TK_SPINBOX */
- char *oldValues = NULL; /* lint initialization */
- char *oldFormat = NULL; /* lint initialization */
+ char *oldValues = NULL;
+ char *oldFormat = NULL;
int error;
- int oldExport = 0; /* lint initialization */
- int valuesChanged = 0; /* lint initialization */
- double oldFrom = 0.0; /* lint initialization */
- double oldTo = 0.0; /* lint initialization */
+ int oldExport = 0;
+ int valuesChanged = 0;
+ double oldFrom = 0.0;
+ double oldTo = 0.0;
int code;
/*
@@ -1137,7 +1155,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;
@@ -1177,13 +1195,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)) {
/*
@@ -1220,7 +1240,7 @@ ConfigureEntry(
if (formatSpace < TCL_DOUBLE_SPACE) {
formatSpace = TCL_DOUBLE_SPACE;
}
- sbPtr->formatBuf = ckrealloc(sbPtr->formatBuf, formatSpace);
+ sbPtr->formatBuf = (char *)ckrealloc(sbPtr->formatBuf, formatSpace);
/*
* We perturb the value of oldFrom to allow us to go into the
@@ -1243,7 +1263,7 @@ ConfigureEntry(
Tcl_Obj *newObjPtr;
int nelems;
- newObjPtr = Tcl_NewStringObj(sbPtr->valueStr, -1);
+ newObjPtr = Tcl_NewStringObj(sbPtr->valueStr, TCL_INDEX_NONE);
if (Tcl_ListObjLength(interp, newObjPtr, &nelems)
!= TCL_OK) {
valuesChanged = -1;
@@ -1278,7 +1298,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);
@@ -1434,7 +1454,7 @@ EntryWorldChanged(
unsigned long mask;
Tk_3DBorder border;
XColor *colorPtr;
- Entry *entryPtr = instanceData;
+ Entry *entryPtr = (Entry *)instanceData;
entryPtr->avgWidth = Tk_TextWidth(entryPtr->tkfont, "0", 1);
if (entryPtr->avgWidth == 0) {
@@ -1487,8 +1507,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;
@@ -1532,6 +1564,10 @@ TkpDrawEntryBorderAndFocus(
Drawable pixmap,
int isSpinbox)
{
+ (void)entryPtr;
+ (void)pixmap;
+ (void)isSpinbox;
+
return 0;
}
@@ -1558,6 +1594,9 @@ TkpDrawSpinboxButtons(
Spinbox *sbPtr,
Pixmap pixmap)
{
+ (void)sbPtr;
+ (void)pixmap;
+
return 0;
}
#endif /* Not MAC_OSX_TK */
@@ -1582,7 +1621,7 @@ static void
DisplayEntry(
ClientData clientData) /* Information about window. */
{
- Entry *entryPtr = clientData;
+ Entry *entryPtr = (Entry *)clientData;
Tk_Window tkwin = entryPtr->tkwin;
int baseY, selStartX, selEndX, cursorX;
int showSelection, xBound;
@@ -1645,7 +1684,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);
@@ -1670,7 +1709,7 @@ DisplayEntry(
0, 0, Tk_Width(tkwin), Tk_Height(tkwin), 0, TK_RELIEF_FLAT);
if (showSelection && (entryPtr->state != STATE_DISABLED)
- && (entryPtr->selectLast > entryPtr->leftIndex)) {
+ && (entryPtr->selectLast + 1 > entryPtr->leftIndex + 1)) {
if (entryPtr->selectFirst <= entryPtr->leftIndex) {
selStartX = entryPtr->leftX;
} else {
@@ -1713,7 +1752,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 + 1 >= entryPtr->leftIndex + 1) && cursorX < xBound) {
if (entryPtr->flags & CURSOR_ON) {
Tk_Fill3DRectangle(tkwin, pixmap, entryPtr->insertBorder,
cursorX, baseY - fm.ascent, entryPtr->insertWidth,
@@ -1727,43 +1766,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 + 1 < entryPtr->selectLast + 1)) {
+
+ /*
+ * Draw the selected and unselected portions separately.
+ */
+
+ TkSizeT selFirst;
+
+ if (entryPtr->selectFirst + 1 < entryPtr->leftIndex + 1) {
+ 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 {
- Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->textGC,
- entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY,
- entryPtr->leftIndex, entryPtr->numChars);
+ /*
+ * Draw the entire visible text
+ */
+
+ Tk_DrawTextLayout(entryPtr->display, pixmap, entryPtr->textGC,
+ entryPtr->textLayout, entryPtr->layoutX, entryPtr->layoutY,
+ entryPtr->leftIndex, entryPtr->numChars);
+ }
}
if (entryPtr->type == TK_SPINBOX) {
@@ -1920,7 +1972,8 @@ static void
EntryComputeGeometry(
Entry *entryPtr) /* Widget record for entry. */
{
- int totalLength, overflow, maxOffScreen, rightX;
+ int totalLength, overflow, rightX;
+ TkSizeT maxOffScreen;
int height, width, i;
Tk_FontMetrics fm;
char *p;
@@ -1952,16 +2005,68 @@ EntryComputeGeometry(
size = TkUniCharToUtf(ch, buf);
entryPtr->numDisplayBytes = entryPtr->numChars * size;
- p = ckalloc(entryPtr->numDisplayBytes + 1);
+ p = (char *)ckalloc(entryPtr->numDisplayBytes + 1);
entryPtr->displayString = p;
- for (i = entryPtr->numChars; --i >= 0; ) {
+ 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,
@@ -2004,7 +2109,7 @@ EntryComputeGeometry(
if (rightX < overflow) {
maxOffScreen++;
}
- if (entryPtr->leftIndex > maxOffScreen) {
+ if (entryPtr->leftIndex + 1 > maxOffScreen + 1) {
entryPtr->leftIndex = maxOffScreen;
}
Tk_CharBbox(entryPtr->textLayout, entryPtr->leftIndex, &rightX,
@@ -2052,26 +2157,24 @@ EntryComputeGeometry(
static int
InsertChars(
Entry *entryPtr, /* Entry that is to get the new elements. */
- int index, /* Add the new elements before this character
+ TkSizeT 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;
string = entryPtr->string;
- byteIndex = TkUtfAtIndex(string, index) - string;
+ byteIndex = Tcl_UtfAtIndex(string, index) - string;
byteCount = strlen(value);
if (byteCount == 0) {
return TCL_OK;
}
newByteCount = entryPtr->numBytes + byteCount + 1;
- newStr = ckalloc(newByteCount);
+ newStr = (char *)ckalloc(newByteCount);
memcpy(newStr, string, byteIndex);
strcpy(newStr + byteIndex, value);
strcpy(newStr + byteIndex + byteCount, string + byteIndex);
@@ -2088,8 +2191,6 @@ InsertChars(
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
@@ -2099,7 +2200,7 @@ InsertChars(
*/
oldChars = entryPtr->numChars;
- entryPtr->numChars = Tcl_NumUtfChars(newStr, -1);
+ entryPtr->numChars = Tcl_NumUtfChars(newStr, TCL_INDEX_NONE);
charsAdded = entryPtr->numChars - oldChars;
entryPtr->numBytes += byteCount;
@@ -2116,19 +2217,19 @@ InsertChars(
* selection.
*/
- if (entryPtr->selectFirst >= index) {
+ if (entryPtr->selectFirst + 1 >= index + 1) {
entryPtr->selectFirst += charsAdded;
}
- if (entryPtr->selectLast > index) {
+ if (entryPtr->selectLast + 1 > index + 1) {
entryPtr->selectLast += charsAdded;
}
- if ((entryPtr->selectAnchor > index) || (entryPtr->selectFirst >= index)) {
+ if ((entryPtr->selectAnchor + 1 > index + 1) || (entryPtr->selectFirst + 1 >= index + 1)) {
entryPtr->selectAnchor += charsAdded;
}
- if (entryPtr->leftIndex > index) {
+ if (entryPtr->leftIndex + 1 > index + 1) {
entryPtr->leftIndex += charsAdded;
}
- if (entryPtr->insertPos >= index) {
+ if (entryPtr->insertPos + 1 >= index + 1) {
entryPtr->insertPos += charsAdded;
}
return EntryValueChanged(entryPtr, NULL);
@@ -2155,30 +2256,30 @@ 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. */
+ TkSizeT index, /* Index of first character to delete. */
+ TkSizeT count) /* How many characters to delete. */
{
int byteIndex, byteCount, newByteCount;
const char *string;
char *newStr, *toDelete;
- if ((index + count) > entryPtr->numChars) {
+ if (index + count + 1 > entryPtr->numChars + 1) {
count = entryPtr->numChars - index;
}
- if (count <= 0) {
+ if ((int)count <= 0) {
return TCL_OK;
}
string = entryPtr->string;
- byteIndex = TkUtfAtIndex(string, index) - string;
- byteCount = TkUtfAtIndex(string + byteIndex, count) - (string+byteIndex);
+ byteIndex = Tcl_UtfAtIndex(string, index) - string;
+ byteCount = Tcl_UtfAtIndex(string + byteIndex, count) - (string+byteIndex);
newByteCount = entryPtr->numBytes + 1 - byteCount;
- newStr = ckalloc(newByteCount);
+ newStr = (char *)ckalloc(newByteCount);
memcpy(newStr, string, (size_t) byteIndex);
strcpy(newStr + byteIndex, string + byteIndex + byteCount);
- toDelete = ckalloc(byteCount + 1);
+ toDelete = (char *)ckalloc(byteCount + 1);
memcpy(toDelete, string + byteIndex, (size_t) byteCount);
toDelete[byteCount] = '\0';
@@ -2208,40 +2309,40 @@ DeleteChars(
* change.
*/
- if (entryPtr->selectFirst >= index) {
- if (entryPtr->selectFirst >= (index + count)) {
+ if (entryPtr->selectFirst + 1 >= index + 1) {
+ if (entryPtr->selectFirst + 1 >= index + count + 1) {
entryPtr->selectFirst -= count;
} else {
entryPtr->selectFirst = index;
}
}
- if (entryPtr->selectLast >= index) {
- if (entryPtr->selectLast >= (index + count)) {
+ if (entryPtr->selectLast + 1 >= index + 1) {
+ if (entryPtr->selectLast + 1 >= index + count + 1) {
entryPtr->selectLast -= count;
} else {
entryPtr->selectLast = index;
}
}
- if (entryPtr->selectLast <= entryPtr->selectFirst) {
- entryPtr->selectFirst = -1;
- entryPtr->selectLast = -1;
+ if (entryPtr->selectLast + 1 <= entryPtr->selectFirst + 1) {
+ entryPtr->selectFirst = TCL_INDEX_NONE;
+ entryPtr->selectLast = TCL_INDEX_NONE;
}
- if (entryPtr->selectAnchor >= index) {
- if (entryPtr->selectAnchor >= (index+count)) {
+ if (entryPtr->selectAnchor + 1 >= index + 1) {
+ if (entryPtr->selectAnchor + 1 >= index + count + 1) {
entryPtr->selectAnchor -= count;
} else {
entryPtr->selectAnchor = index;
}
}
- if (entryPtr->leftIndex > index) {
- if (entryPtr->leftIndex >= (index + count)) {
+ if (entryPtr->leftIndex + 1 > index + 1) {
+ if (entryPtr->leftIndex + 1 >= index + count + 1) {
entryPtr->leftIndex -= count;
} else {
entryPtr->leftIndex = index;
}
}
- if (entryPtr->insertPos >= index) {
- if (entryPtr->insertPos >= (index + count)) {
+ if (entryPtr->insertPos + 1 >= index + 1) {
+ if (entryPtr->insertPos + 1 >= index + count + 1) {
entryPtr->insertPos -= count;
} else {
entryPtr->insertPos = index;
@@ -2364,7 +2465,7 @@ EntrySetValue(
* during validation
*/
- char *tmp = ckalloc(valueLen + 1);
+ char *tmp = (char *)ckalloc(valueLen + 1);
strcpy(tmp, value);
value = tmp;
@@ -2393,7 +2494,7 @@ EntrySetValue(
if (malloced) {
entryPtr->string = value;
} else {
- char *tmp = ckalloc(valueLen + 1);
+ char *tmp = (char *)ckalloc(valueLen + 1);
strcpy(tmp, value);
entryPtr->string = tmp;
@@ -2406,22 +2507,22 @@ EntrySetValue(
entryPtr->numDisplayBytes = entryPtr->numBytes;
}
- if (entryPtr->selectFirst >= 0) {
- if (entryPtr->selectFirst >= entryPtr->numChars) {
- entryPtr->selectFirst = -1;
- entryPtr->selectLast = -1;
- } else if (entryPtr->selectLast > entryPtr->numChars) {
+ if (entryPtr->selectFirst != TCL_INDEX_NONE) {
+ if (entryPtr->selectFirst + 1 >= entryPtr->numChars + 1) {
+ entryPtr->selectFirst = TCL_INDEX_NONE;
+ entryPtr->selectLast = TCL_INDEX_NONE;
+ } else if (entryPtr->selectLast + 1 > entryPtr->numChars + 1) {
entryPtr->selectLast = entryPtr->numChars;
}
}
- if (entryPtr->leftIndex >= entryPtr->numChars) {
- if (entryPtr->numChars > 0) {
+ if (entryPtr->leftIndex + 1 >= entryPtr->numChars + 1) {
+ if (entryPtr->numChars + 1 > 1) {
entryPtr->leftIndex = entryPtr->numChars - 1;
} else {
entryPtr->leftIndex = 0;
}
}
- if (entryPtr->insertPos > entryPtr->numChars) {
+ if (entryPtr->insertPos + 1 > entryPtr->numChars + 1) {
entryPtr->insertPos = entryPtr->numChars;
}
@@ -2453,10 +2554,10 @@ EntryEventProc(
ClientData clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
- Entry *entryPtr = clientData;
+ Entry *entryPtr = (Entry *)clientData;
if ((entryPtr->type == TK_SPINBOX) && (eventPtr->type == MotionNotify)) {
- Spinbox *sbPtr = clientData;
+ Spinbox *sbPtr = (Spinbox *)clientData;
int elem;
elem = GetSpinboxElement(sbPtr, eventPtr->xmotion.x,
@@ -2534,7 +2635,7 @@ static void
EntryCmdDeletedProc(
ClientData clientData) /* Pointer to widget record for widget. */
{
- Entry *entryPtr = clientData;
+ Entry *entryPtr = (Entry *)clientData;
/*
* This function could be invoked either because the window was destroyed
@@ -2574,10 +2675,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 */
+ TkSizeT *indexPtr) /* Where to store converted character index */
{
- const char *string = Tcl_GetString(indexObj);
- size_t length = indexObj->length;
+ TkSizeT length, idx;
+ const char *string;
+
+ if (TCL_OK == TkGetIntForIndex(indexObj, entryPtr->numChars - 1, 1, &idx)) {
+ if (idx == TCL_INDEX_NONE) {
+ idx = 0;
+ } else if (idx > entryPtr->numChars) {
+ idx = entryPtr->numChars;
+ }
+ *indexPtr = idx;
+ return TCL_OK;
+ }
+
+ string = TkGetStringFromObj(indexObj, &length);
switch (string[0]) {
case 'a':
@@ -2586,12 +2699,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;
@@ -2599,7 +2706,7 @@ GetEntryIndex(
*indexPtr = entryPtr->insertPos;
break;
case 's':
- if (entryPtr->selectFirst < 0) {
+ if (entryPtr->selectFirst == TCL_INDEX_NONE) {
Tcl_ResetResult(interp);
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"selection isn't in widget %s",
@@ -2646,30 +2753,21 @@ GetEntryIndex(
* be selected, for example.
*/
- if (roundUp && (*indexPtr < entryPtr->numChars)) {
+ if (roundUp && (*indexPtr + 1 < entryPtr->numChars + 1)) {
*indexPtr += 1;
}
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;
}
/*
@@ -2694,7 +2792,7 @@ EntryScanTo(
Entry *entryPtr, /* Information about widget. */
int x) /* X-coordinate to use for scan operation. */
{
- int newLeftIndex;
+ TkSizeT newLeftIndex;
/*
* Compute new leftIndex for entry by amplifying the difference between
@@ -2709,11 +2807,11 @@ EntryScanTo(
newLeftIndex = entryPtr->scanMarkIndex
- (10 * (x - entryPtr->scanMarkX)) / entryPtr->avgWidth;
- if (newLeftIndex >= entryPtr->numChars) {
+ if (newLeftIndex + 1 >= entryPtr->numChars + 1) {
newLeftIndex = entryPtr->scanMarkIndex = entryPtr->numChars - 1;
entryPtr->scanMarkX = x;
}
- if (newLeftIndex < 0) {
+ if (newLeftIndex == TCL_INDEX_NONE) {
newLeftIndex = entryPtr->scanMarkIndex = 0;
entryPtr->scanMarkX = x;
}
@@ -2750,10 +2848,10 @@ EntryScanTo(
static void
EntrySelectTo(
Entry *entryPtr, /* Information about widget. */
- int index) /* Character index of element that is to
+ TkSizeT index) /* Character index of element that is to
* become the "other" end of the selection. */
{
- int newFirst, newLast;
+ TkSizeT newFirst, newLast;
/*
* Grab the selection if we don't own it already.
@@ -2770,17 +2868,17 @@ EntrySelectTo(
* Pick new starting and ending points for the selection.
*/
- if (entryPtr->selectAnchor > entryPtr->numChars) {
+ if (entryPtr->selectAnchor + 1 > entryPtr->numChars + 1) {
entryPtr->selectAnchor = entryPtr->numChars;
}
- if (entryPtr->selectAnchor <= index) {
+ if (entryPtr->selectAnchor + 1 <= index + 1) {
newFirst = entryPtr->selectAnchor;
newLast = index;
} else {
newFirst = index;
newLast = entryPtr->selectAnchor;
- if (newLast < 0) {
- newFirst = newLast = -1;
+ if (newLast == TCL_INDEX_NONE) {
+ newFirst = newLast = TCL_INDEX_NONE;
}
}
if ((entryPtr->selectFirst == newFirst)
@@ -2813,36 +2911,36 @@ EntrySelectTo(
*----------------------------------------------------------------------
*/
-static int
+static TkSizeT
EntryFetchSelection(
ClientData clientData, /* Information about entry widget. */
- int offset, /* Byte offset within selection of first
+ TkSizeT 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,
+ TkSizeT maxBytes) /* Maximum number of bytes to place at buffer,
* not including terminating NUL character. */
{
- Entry *entryPtr = clientData;
- int byteCount;
+ Entry *entryPtr = (Entry *)clientData;
+ TkSizeT byteCount;
const char *string;
const char *selStart, *selEnd;
- if ((entryPtr->selectFirst < 0) || (!entryPtr->exportSelection)
+ if ((entryPtr->selectFirst == TCL_INDEX_NONE) || (!entryPtr->exportSelection)
|| Tcl_IsSafe(entryPtr->interp)) {
return -1;
}
string = entryPtr->displayString;
- selStart = TkUtfAtIndex(string, entryPtr->selectFirst);
- selEnd = TkUtfAtIndex(selStart,
+ selStart = Tcl_UtfAtIndex(string, entryPtr->selectFirst);
+ selEnd = Tcl_UtfAtIndex(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, (size_t) byteCount);
+ memcpy(buffer, selStart + offset, byteCount);
buffer[byteCount] = '\0';
return byteCount;
}
@@ -2869,7 +2967,7 @@ static void
EntryLostSelection(
ClientData clientData) /* Information about entry widget. */
{
- Entry *entryPtr = clientData;
+ Entry *entryPtr = (Entry *)clientData;
entryPtr->flags &= ~GOT_SELECTION;
@@ -2880,11 +2978,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);
}
}
@@ -2963,7 +3061,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;
@@ -3017,12 +3115,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(
@@ -3056,7 +3154,7 @@ static void
EntryBlinkProc(
ClientData clientData) /* Pointer to record describing entry. */
{
- Entry *entryPtr = clientData;
+ Entry *entryPtr = (Entry *)clientData;
if ((entryPtr->state == STATE_DISABLED) ||
(entryPtr->state == STATE_READONLY) ||
@@ -3142,7 +3240,6 @@ EntryFocusProc(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static char *
EntryTextVarProc(
ClientData clientData, /* Information about button. */
@@ -3151,8 +3248,10 @@ EntryTextVarProc(
const char *name2, /* Not used. */
int flags) /* Information about what happened. */
{
- Entry *entryPtr = clientData;
+ Entry *entryPtr = (Entry *)clientData;
const char *value;
+ (void)name1;
+ (void)name2;
if (entryPtr->flags & ENTRY_DELETED) {
/*
@@ -3234,14 +3333,14 @@ EntryTextVarProc(
static int
EntryValidate(
- register Entry *entryPtr, /* Entry that needs validation. */
- register char *cmd) /* Validation command (NULL-terminated
+ Entry *entryPtr, /* Entry that needs validation. */
+ char *cmd) /* Validation command (NULL-terminated
* string). */
{
- register Tcl_Interp *interp = entryPtr->interp;
+ 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
@@ -3294,11 +3393,11 @@ EntryValidate(
static int
EntryValidateChange(
- register Entry *entryPtr, /* Entry that needs validation. */
+ Entry *entryPtr, /* Entry that needs validation. */
const char *change, /* Characters to be added/deleted
* (NUL-terminated string). */
const char *newValue, /* Potential new value of entry string */
- int index, /* index of insert/delete, -1 otherwise */
+ TkSizeT index, /* index of insert/delete, -1 otherwise */
int type) /* forced, delete, insert, focusin or
* focusout */
{
@@ -3437,14 +3536,14 @@ EntryValidateChange(
static void
ExpandPercents(
- register Entry *entryPtr, /* Entry that needs validation. */
- register const char *before,
+ Entry *entryPtr, /* Entry that needs validation. */
+ const char *before,
/* Command containing percent expressions to
* be replaced. */
const char *change, /* Characters to added/deleted (NUL-terminated
* string). */
const char *newValue, /* Potential new value of entry string */
- int index, /* index of insert/delete */
+ TkSizeT index, /* index of insert/delete */
int type, /* INSERT or DELETE */
Tcl_DString *dsPtr) /* Dynamic string in which to append new
* command. */
@@ -3452,7 +3551,7 @@ ExpandPercents(
int spaceNeeded, cvtFlags; /* Used to substitute string as proper Tcl
* list element. */
int number, length;
- register const char *string;
+ const char *string;
int ch;
char numStorage[2*TCL_INTEGER_SPACE];
@@ -3533,7 +3632,7 @@ ExpandPercents(
string = numStorage;
break;
case 'i': /* index of insert/delete */
- sprintf(numStorage, "%d", index);
+ sprintf(numStorage, "%d", (int)index);
string = numStorage;
break;
case 'P': /* 'Peeked' new value of the string */
@@ -3602,16 +3701,17 @@ ExpandPercents(
int
Tk_SpinboxObjCmd(
- ClientData clientData, /* NULL. */
+ ClientData dummy, /* NULL. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register Entry *entryPtr;
- register Spinbox *sbPtr;
+ Entry *entryPtr;
+ Spinbox *sbPtr;
Tk_OptionTable optionTable;
Tk_Window tkwin;
char *tmp;
+ (void)dummy;
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "pathName ?-option value ...?");
@@ -3638,7 +3738,7 @@ Tk_SpinboxObjCmd(
* initialized as memset covers the rest.
*/
- sbPtr = ckalloc(sizeof(Spinbox));
+ sbPtr = (Spinbox *)ckalloc(sizeof(Spinbox));
entryPtr = (Entry *) sbPtr;
memset(sbPtr, 0, sizeof(Spinbox));
@@ -3650,11 +3750,11 @@ Tk_SpinboxObjCmd(
EntryCmdDeletedProc);
entryPtr->optionTable = optionTable;
entryPtr->type = TK_SPINBOX;
- tmp = ckalloc(1);
+ tmp = (char *)ckalloc(1);
tmp[0] = '\0';
entryPtr->string = tmp;
- entryPtr->selectFirst = -1;
- entryPtr->selectLast = -1;
+ entryPtr->selectFirst = TCL_INDEX_NONE;
+ entryPtr->selectLast = TCL_INDEX_NONE;
entryPtr->cursor = NULL;
entryPtr->exportSelection = 1;
@@ -3677,10 +3777,12 @@ Tk_SpinboxObjCmd(
sbPtr->fromValue = 0.0;
sbPtr->toValue = 100.0;
sbPtr->increment = 1.0;
- sbPtr->formatBuf = ckalloc(TCL_DOUBLE_SPACE);
+ sbPtr->formatBuf = (char *)ckalloc(TCL_DOUBLE_SPACE);
sbPtr->bdRelief = TK_RELIEF_FLAT;
sbPtr->buRelief = TK_RELIEF_FLAT;
+ 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.
@@ -3696,7 +3798,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;
@@ -3705,7 +3807,7 @@ Tk_SpinboxObjCmd(
goto error;
}
- Tcl_SetObjResult(interp, TkNewWindowObj(entryPtr->tkwin));
+ Tcl_SetObjResult(interp, Tk_NewWindowObj(entryPtr->tkwin));
return TCL_OK;
error:
@@ -3738,8 +3840,8 @@ SpinboxWidgetObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- Entry *entryPtr = clientData;
- Spinbox *sbPtr = clientData;
+ Entry *entryPtr = (Entry *)clientData;
+ Spinbox *sbPtr = (Spinbox *)clientData;
int cmdIndex, selIndex, result;
Tcl_Obj *objPtr;
@@ -3762,7 +3864,8 @@ SpinboxWidgetObjCmd(
Tcl_Preserve(entryPtr);
switch ((enum sbCmd) cmdIndex) {
case SB_CMD_BBOX: {
- int index, x, y, width, height;
+ TkSizeT index;
+ int x, y, width, height;
Tcl_Obj *bbox[4];
if (objc != 3) {
@@ -3773,14 +3876,14 @@ SpinboxWidgetObjCmd(
&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;
}
@@ -3791,7 +3894,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;
@@ -3801,7 +3904,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) {
@@ -3814,7 +3917,8 @@ SpinboxWidgetObjCmd(
break;
case SB_CMD_DELETE: {
- int first, last, code;
+ TkSizeT first, last;
+ int code;
if ((objc < 3) || (objc > 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "firstIndex ?lastIndex?");
@@ -3832,7 +3936,7 @@ SpinboxWidgetObjCmd(
goto error;
}
}
- if ((last >= first) && (entryPtr->state == STATE_NORMAL)) {
+ if ((last + 1 >= first + 1) && (entryPtr->state == STATE_NORMAL)) {
code = DeleteChars(entryPtr, first, last - first);
if (code != TCL_OK) {
goto error;
@@ -3881,7 +3985,7 @@ SpinboxWidgetObjCmd(
}
case SB_CMD_INDEX: {
- int index;
+ TkSizeT index;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "string");
@@ -3891,12 +3995,13 @@ SpinboxWidgetObjCmd(
&index) != TCL_OK) {
goto error;
}
- Tcl_SetObjResult(interp, Tcl_NewIntObj(index));
+ Tcl_SetObjResult(interp, TkNewIndexObj(index));
break;
}
case SB_CMD_INSERT: {
- int index, code;
+ TkSizeT index;
+ int code;
if (objc != 4) {
Tcl_WrongNumArgs(interp, 2, objv, "index text");
@@ -3964,7 +4069,7 @@ SpinboxWidgetObjCmd(
}
case SB_CMD_SELECTION: {
- int index, index2;
+ TkSizeT index, index2;
if (objc < 3) {
Tcl_WrongNumArgs(interp, 2, objv, "option ?index?");
@@ -4002,14 +4107,14 @@ SpinboxWidgetObjCmd(
objv[3], &index) != TCL_OK) {
goto error;
}
- if (entryPtr->selectFirst >= 0) {
- int half1, half2;
+ if (entryPtr->selectFirst != TCL_INDEX_NONE) {
+ TkSizeT half1, half2;
half1 = (entryPtr->selectFirst + entryPtr->selectLast)/2;
half2 = (entryPtr->selectFirst + entryPtr->selectLast + 1)/2;
- if (index < half1) {
+ if (index + 1 < half1 + 1) {
entryPtr->selectAnchor = entryPtr->selectLast;
- } else if (index > half2) {
+ } else if (index + 1 > half2 + 1) {
entryPtr->selectAnchor = entryPtr->selectFirst;
} else {
/*
@@ -4026,9 +4131,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;
@@ -4051,7 +4156,7 @@ SpinboxWidgetObjCmd(
goto error;
}
Tcl_SetObjResult(interp, Tcl_NewBooleanObj(
- entryPtr->selectFirst >= 0));
+ entryPtr->selectFirst != TCL_INDEX_NONE));
goto done;
case SB_SEL_RANGE:
@@ -4067,9 +4172,9 @@ SpinboxWidgetObjCmd(
objv[4],& index2) != TCL_OK) {
goto error;
}
- if (index >= index2) {
- entryPtr->selectFirst = -1;
- entryPtr->selectLast = -1;
+ if (index + 1 >= index2 + 1) {
+ entryPtr->selectFirst = TCL_INDEX_NONE;
+ entryPtr->selectLast = TCL_INDEX_NONE;
} else {
entryPtr->selectFirst = index;
entryPtr->selectLast = index2;
@@ -4158,7 +4263,7 @@ SpinboxWidgetObjCmd(
}
case SB_CMD_XVIEW: {
- int index;
+ TkSizeT index;
if (objc == 2) {
double first, last;
@@ -4184,7 +4289,7 @@ SpinboxWidgetObjCmd(
case TK_SCROLL_ERROR:
goto error;
case TK_SCROLL_MOVETO:
- index = (int) ((fraction * entryPtr->numChars) + 0.5);
+ index = ((fraction * entryPtr->numChars) + 0.5);
break;
case TK_SCROLL_PAGES: {
int charsPerPage;
@@ -4203,10 +4308,10 @@ SpinboxWidgetObjCmd(
break;
}
}
- if (index >= entryPtr->numChars) {
+ if (index + 1 >= entryPtr->numChars + 1) {
index = entryPtr->numChars - 1;
}
- if (index < 0) {
+ if (index == TCL_INDEX_NONE) {
index = 0;
}
entryPtr->leftIndex = index;
@@ -4285,8 +4390,8 @@ GetSpinboxElement(
static int
SpinboxInvoke(
- register Tcl_Interp *interp,/* Current interpreter. */
- register Spinbox *sbPtr, /* Spinbox to invoke. */
+ Tcl_Interp *interp,/* Current interpreter. */
+ Spinbox *sbPtr, /* Spinbox to invoke. */
int element) /* Element to invoke, either the "up" or
* "down" button. */
{
@@ -4321,16 +4426,17 @@ SpinboxInvoke(
* there. If not, move to the first element of the list.
*/
- int i, listc, elemLen, length = entryPtr->numChars;
+ int i, listc;
+ TkSizeT elemLen, length = entryPtr->numChars;
const char *bytes;
Tcl_Obj **listv;
Tcl_ListObjGetElements(interp, sbPtr->listObj, &listc, &listv);
for (i = 0; i < listc; i++) {
- bytes = Tcl_GetStringFromObj(listv[i], &elemLen);
+ bytes = TkGetStringFromObj(listv[i], &elemLen);
if ((length == elemLen) &&
(memcmp(bytes, entryPtr->string,
- (size_t) length) == 0)) {
+ length) == 0)) {
sbPtr->eIndex = i;
break;
}
diff --git a/generic/tkEntry.h b/generic/tkEntry.h
index 6b1bf87..293a9db 100644
--- a/generic/tkEntry.h
+++ b/generic/tkEntry.h
@@ -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
+ TkSizeT 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
+ TkSizeT selectFirst; /* Character index of first selected character
* (-1 means nothing selected. */
- int selectLast; /* Character index just after last selected
+ TkSizeT selectLast; /* Character index just after last selected
* character (-1 means nothing selected. */
- int selectAnchor; /* Fixed end of selection (i.e. "select to"
+ TkSizeT 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. */
+ TkSizeT 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
+ TkSizeT numBytes; /* Length of string in bytes. */
+ TkSizeT 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. */
+ TkSizeT 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
+ TkSizeT leftIndex; /* Character index of left-most character
* visible in window. */
Tcl_TimerToken insertBlinkHandler;
/* Timer handler used to blink cursor on and
diff --git a/generic/tkError.c b/generic/tkError.c
index 277d7f0..938afc3 100644
--- a/generic/tkError.c
+++ b/generic/tkError.c
@@ -107,7 +107,7 @@ Tk_CreateErrorHandler(
* Create the handler record.
*/
- errorPtr = ckalloc(sizeof(TkErrorHandler));
+ errorPtr = (TkErrorHandler *)ckalloc(sizeof(TkErrorHandler));
errorPtr->dispPtr = dispPtr;
errorPtr->firstRequest = NextRequest(display);
errorPtr->lastRequest = (unsigned) -1;
@@ -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 456b86d..07ce8e7 100644
--- a/generic/tkEvent.c
+++ b/generic/tkEvent.c
@@ -15,6 +15,14 @@
#include "tkInt.h"
+#ifdef _WIN32
+#include "tkWinInt.h"
+#elif defined(MAC_OSX_TK)
+#include "tkMacOSXInt.h"
+#else
+#include "tkUnixInt.h"
+#endif
+
/*
* There's a potential problem if a handler is deleted while it's current
* (i.e. its function is executing), since Tk_HandleEvent will need to read
@@ -205,9 +213,7 @@ static int RefreshKeyboardMappingIfNeeded(XEvent *eventPtr);
static int TkXErrorHandler(ClientData 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 +321,6 @@ InvokeMouseHandlers(
*----------------------------------------------------------------------
*/
-#ifdef TK_USE_INPUT_METHODS
static void
CreateXIC(
TkWindow *winPtr)
@@ -362,7 +367,6 @@ CreateXIC(
XSelectInput(winPtr->display, winPtr->window, winPtr->atts.event_mask);
}
}
-#endif
/*
*----------------------------------------------------------------------
@@ -509,7 +513,7 @@ RefreshKeyboardMappingIfNeeded(
/*
*----------------------------------------------------------------------
*
- * TkGetButtonMask --
+ * Tk_GetButtonMask --
*
* Return the proper Button${n}Mask for the button.
*
@@ -523,14 +527,15 @@ RefreshKeyboardMappingIfNeeded(
*/
static const unsigned buttonMasks[] = {
- 0, Button1Mask, Button2Mask, Button3Mask, Button4Mask, Button5Mask
+ 0, Button1Mask, Button2Mask, Button3Mask, Button4Mask, Button5Mask,
+ Button6Mask, Button7Mask, Button8Mask, Button9Mask
};
unsigned
-TkGetButtonMask(
+Tk_GetButtonMask(
unsigned button)
{
- return (button > Button5) ? 0 : buttonMasks[button];
+ return (button > Button9) ? 0 : buttonMasks[button];
}
/*
@@ -1132,14 +1137,6 @@ 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;
- }
-#endif
-
/*
* If the generic handler processed this event we are done and can return.
*/
@@ -1206,7 +1203,6 @@ Tk_HandleEvent(
* ever active for X11.
*/
-#ifdef TK_USE_INPUT_METHODS
/*
* If the XIC has been invalidated, it must be recreated.
*/
@@ -1228,7 +1224,6 @@ Tk_HandleEvent(
XSetICFocus(winPtr->inputContext);
}
}
-#endif /*TK_USE_INPUT_METHODS*/
/*
* For events where it hasn't already been done, update the current time
diff --git a/generic/tkFileFilter.c b/generic/tkFileFilter.c
index 8588d70..038129f 100644
--- a/generic/tkFileFilter.c
+++ b/generic/tkFileFilter.c
@@ -164,7 +164,7 @@ TkFreeFileFilters(
FileFilterClause *clausePtr;
GlobPattern *globPtr;
MacFileType *mfPtr;
- register void *toFree; /* A pointer that we are about to free. */
+ void *toFree; /* A pointer that we are about to free. */
for (filterPtr = flistPtr->filters; filterPtr != NULL; ) {
for (clausePtr = filterPtr->clauses; clausePtr != NULL; ) {
@@ -262,8 +262,8 @@ AddClause(
*/
for (i=0; i<ostypeCount; i++) {
- int len;
- const char *strType = Tcl_GetStringFromObj(ostypeList[i], &len);
+ TkSizeT len;
+ const char *strType = TkGetStringFromObj(ostypeList[i], &len);
/*
* If len is < 4, it is definitely an error. If equal or longer,
@@ -305,7 +305,7 @@ AddClause(
* Add the clause into the list of clauses
*/
- clausePtr = ckalloc(sizeof(FileFilterClause));
+ clausePtr = (FileFilterClause *)ckalloc(sizeof(FileFilterClause));
clausePtr->patterns = NULL;
clausePtr->patternsTail = NULL;
clausePtr->macTypes = NULL;
@@ -321,9 +321,9 @@ AddClause(
if (globCount > 0 && globList != NULL) {
for (i=0; i<globCount; i++) {
- GlobPattern *globPtr = ckalloc(sizeof(GlobPattern));
- int len;
- const char *str = Tcl_GetStringFromObj(globList[i], &len);
+ GlobPattern *globPtr = (GlobPattern *)ckalloc(sizeof(GlobPattern));
+ TkSizeT len;
+ const char *str = TkGetStringFromObj(globList[i], &len);
len = (len + 1) * sizeof(char);
if (str[0] && str[0] != '*') {
@@ -331,12 +331,12 @@ AddClause(
* Prepend a "*" to patterns that do not have a leading "*"
*/
- globPtr->pattern = ckalloc(len + 1);
+ globPtr->pattern = (char *)ckalloc(len + 1);
globPtr->pattern[0] = '*';
strcpy(globPtr->pattern+1, str);
} else if (isWindows) {
if (strcmp(str, "*") == 0) {
- globPtr->pattern = ckalloc(4);
+ globPtr->pattern = (char *)ckalloc(4);
strcpy(globPtr->pattern, "*.*");
} else if (strcmp(str, "") == 0) {
/*
@@ -345,14 +345,14 @@ AddClause(
* TODO: "*." actually matches with all files on Win95
*/
- globPtr->pattern = ckalloc(3);
+ globPtr->pattern = (char *)ckalloc(3);
strcpy(globPtr->pattern, "*.");
} else {
- globPtr->pattern = ckalloc(len);
+ globPtr->pattern = (char *)ckalloc(len);
strcpy(globPtr->pattern, str);
}
} else {
- globPtr->pattern = ckalloc(len);
+ globPtr->pattern = (char *)ckalloc(len);
strcpy(globPtr->pattern, str);
}
@@ -375,9 +375,9 @@ AddClause(
}
for (i=0; i<ostypeCount; i++) {
Tcl_DString osTypeDS;
- int len;
- MacFileType *mfPtr = ckalloc(sizeof(MacFileType));
- const char *strType = Tcl_GetStringFromObj(ostypeList[i], &len);
+ TkSizeT len;
+ MacFileType *mfPtr = (MacFileType *)ckalloc(sizeof(MacFileType));
+ const char *strType = TkGetStringFromObj(ostypeList[i], &len);
char *string;
/*
@@ -445,11 +445,11 @@ GetFilter(
}
}
- filterPtr = ckalloc(sizeof(FileFilter));
+ filterPtr = (FileFilter *)ckalloc(sizeof(FileFilter));
filterPtr->clauses = NULL;
filterPtr->clausesTail = NULL;
len = strlen(name) + 1;
- filterPtr->name = ckalloc(len);
+ filterPtr->name = (char *)ckalloc(len);
memcpy(filterPtr->name, name, len);
if (flistPtr->filters == NULL) {
diff --git a/generic/tkFileFilter.h b/generic/tkFileFilter.h
index 131e423..22db9e8 100644
--- a/generic/tkFileFilter.h
+++ b/generic/tkFileFilter.h
@@ -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 4d46e4b..f6afcd8 100644
--- a/generic/tkFocus.c
+++ b/generic/tkFocus.c
@@ -113,8 +113,8 @@ Tk_FocusObjCmd(
static const char *const focusOptions[] = {
"-displayof", "-force", "-lastfor", NULL
};
- Tk_Window tkwin = clientData;
- TkWindow *winPtr = clientData;
+ Tk_Window tkwin = (Tk_Window)clientData;
+ TkWindow *winPtr = (TkWindow *)clientData;
TkWindow *newPtr, *topLevelPtr;
ToplevelFocusInfo *tlFocusPtr;
const char *windowName;
@@ -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;
@@ -415,7 +415,7 @@ TkFocusFilterEvent(
}
}
if (tlFocusPtr == NULL) {
- tlFocusPtr = ckalloc(sizeof(ToplevelFocusInfo));
+ tlFocusPtr = (ToplevelFocusInfo *)ckalloc(sizeof(ToplevelFocusInfo));
tlFocusPtr->topLevelPtr = tlFocusPtr->focusWinPtr = winPtr;
tlFocusPtr->nextPtr = winPtr->mainPtr->tlFocusPtr;
winPtr->mainPtr->tlFocusPtr = tlFocusPtr;
@@ -622,7 +622,7 @@ TkSetFocusWin(
}
}
if (tlFocusPtr == NULL) {
- tlFocusPtr = ckalloc(sizeof(ToplevelFocusInfo));
+ tlFocusPtr = (ToplevelFocusInfo *)ckalloc(sizeof(ToplevelFocusInfo));
tlFocusPtr->topLevelPtr = topLevelPtr;
tlFocusPtr->nextPtr = winPtr->mainPtr->tlFocusPtr;
winPtr->mainPtr->tlFocusPtr = tlFocusPtr;
@@ -807,7 +807,7 @@ TkFocusKeyEvent(
void
TkFocusDeadWindow(
- register TkWindow *winPtr) /* Information about the window that is being
+ TkWindow *winPtr) /* Information about the window that is being
* deleted. */
{
ToplevelFocusInfo *tlFocusPtr, *prevPtr;
@@ -961,7 +961,7 @@ FocusMapProc(
ClientData clientData, /* Toplevel window. */
XEvent *eventPtr) /* Information about event. */
{
- TkWindow *winPtr = clientData;
+ TkWindow *winPtr = (TkWindow *)clientData;
DisplayFocusInfo *displayFocusPtr;
if (eventPtr->type == VisibilityNotify) {
@@ -1015,7 +1015,7 @@ FindDisplayFocusInfo(
* The record doesn't exist yet. Make a new one.
*/
- displayFocusPtr = ckalloc(sizeof(DisplayFocusInfo));
+ displayFocusPtr = (DisplayFocusInfo *)ckalloc(sizeof(DisplayFocusInfo));
displayFocusPtr->dispPtr = dispPtr;
displayFocusPtr->focusWinPtr = NULL;
displayFocusPtr->focusOnMapPtr = NULL;
@@ -1143,7 +1143,7 @@ TkFocusSplit(
* Move focus to new toplevel.
*/
- ToplevelFocusInfo *newTlFocusPtr = ckalloc(sizeof(ToplevelFocusInfo));
+ ToplevelFocusInfo *newTlFocusPtr = (ToplevelFocusInfo *)ckalloc(sizeof(ToplevelFocusInfo));
newTlFocusPtr->topLevelPtr = winPtr;
newTlFocusPtr->focusWinPtr = tlFocusPtr->focusWinPtr;
diff --git a/generic/tkFont.c b/generic/tkFont.c
index 3e4044f..79c8d54 100644
--- a/generic/tkFont.c
+++ b/generic/tkFont.c
@@ -44,7 +44,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. */
@@ -354,7 +354,7 @@ const Tcl_ObjType tkFontObjType = {
FreeFontObjProc, /* freeIntRepProc */
DupFontObjProc, /* dupIntRepProc */
NULL, /* updateStringProc */
- SetFontFromAny /* setFromAnyProc */
+ NULL /* setFromAnyProc */
};
/*
@@ -556,7 +556,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;
}
@@ -566,9 +566,9 @@ 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);
Tcl_AppendLimitedToObj(resultPtr, string,
@@ -715,7 +715,8 @@ Tk_FontObjCmd(
case FONT_MEASURE: {
const char *string;
Tk_Font tkfont;
- int length = 0, skip = 0;
+ TkSizeT length = 0;
+ int skip = 0;
if (objc > 4) {
skip = TkGetDisplayOf(interp, objc - 3, objv + 3, &tkwin);
@@ -732,8 +733,8 @@ Tk_FontObjCmd(
if (tkfont == NULL) {
return TCL_ERROR;
}
- string = Tcl_GetStringFromObj(objv[3 + skip], &length);
- Tcl_SetObjResult(interp, Tcl_NewIntObj(
+ string = TkGetStringFromObj(objv[3 + skip], &length);
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(
Tk_TextWidth(tkfont, string, length)));
Tk_FreeFont(tkfont);
break;
@@ -752,7 +753,7 @@ Tk_FontObjCmd(
}
if ((objc < 3) || ((objc - skip) > 4)) {
Tcl_WrongNumArgs(interp, 2, objv,
- "font ?-displayof window? ?option?");
+ "font ?-displayof window? ?-option?");
return TCL_ERROR;
}
tkfont = Tk_AllocFontFromObj(interp, tkwin, objv[2]);
@@ -780,7 +781,7 @@ Tk_FontObjCmd(
case 2: i = fmPtr->ascent + fmPtr->descent; break;
case 3: i = fmPtr->fixed; break;
}
- Tcl_SetObjResult(interp, Tcl_NewIntObj(i));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(i));
}
Tk_FreeFont(tkfont);
break;
@@ -1447,8 +1448,7 @@ Tk_FreeFont(
*/
nfPtr = (NamedFont *)Tcl_GetHashValue(fontPtr->namedHashPtr);
- nfPtr->refCount--;
- if ((nfPtr->refCount == 0) && nfPtr->deletePending) {
+ if ((nfPtr->refCount-- <= 1) && nfPtr->deletePending) {
Tcl_DeleteHashEntry(fontPtr->namedHashPtr);
ckfree(nfPtr);
}
@@ -1535,8 +1535,7 @@ FreeFontObj(
TkFont *fontPtr = (TkFont *)objPtr->internalRep.twoPtrValue.ptr1;
if (fontPtr != NULL) {
- fontPtr->objRefCount--;
- if ((fontPtr->resourceRefCount == 0) && (fontPtr->objRefCount == 0)) {
+ if ((fontPtr->objRefCount-- <= 1) && (fontPtr->resourceRefCount == 0)) {
ckfree(fontPtr);
}
objPtr->internalRep.twoPtrValue.ptr1 = NULL;
@@ -1728,15 +1727,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);
}
@@ -2006,7 +2001,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;
@@ -2021,7 +2016,7 @@ Tk_ComputeTextLayout(
curX = 0;
- endp = TkUtfAtIndex(string, numChars);
+ endp = Tcl_UtfAtIndex(string, numChars);
special = string;
flags &= TK_IGNORE_TABS | TK_IGNORE_NEWLINES;
@@ -2329,14 +2324,14 @@ Tk_DrawTextLayout(
firstChar = 0;
firstByte = chunkPtr->start;
} else {
- firstByte = TkUtfAtIndex(chunkPtr->start, firstChar);
+ firstByte = Tcl_UtfAtIndex(chunkPtr->start, firstChar);
Tk_MeasureChars(layoutPtr->tkfont, chunkPtr->start,
firstByte - chunkPtr->start, -1, 0, &drawX);
}
if (lastChar < numDisplayChars) {
numDisplayChars = lastChar;
}
- lastByte = TkUtfAtIndex(chunkPtr->start, numDisplayChars);
+ lastByte = Tcl_UtfAtIndex(chunkPtr->start, numDisplayChars);
#if TK_DRAW_IN_CONTEXT
TkpDrawCharsInContext(display, drawable, gc, layoutPtr->tkfont,
chunkPtr->start, chunkPtr->numBytes,
@@ -2399,14 +2394,14 @@ TkDrawAngledTextLayout(
firstChar = 0;
firstByte = chunkPtr->start;
} else {
- firstByte = TkUtfAtIndex(chunkPtr->start, firstChar);
+ firstByte = Tcl_UtfAtIndex(chunkPtr->start, firstChar);
Tk_MeasureChars(layoutPtr->tkfont, chunkPtr->start,
firstByte - chunkPtr->start, -1, 0, &drawX);
}
if (lastChar < numDisplayChars) {
numDisplayChars = lastChar;
}
- lastByte = TkUtfAtIndex(chunkPtr->start, numDisplayChars);
+ lastByte = Tcl_UtfAtIndex(chunkPtr->start, numDisplayChars);
#if TK_DRAW_IN_CONTEXT
dx = cosA * (chunkPtr->x) + sinA * (chunkPtr->y);
dy = -sinA * (chunkPtr->x) + cosA * (chunkPtr->y);
@@ -2742,7 +2737,7 @@ 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;
@@ -2752,7 +2747,6 @@ Tk_CharBbox(
return 0;
}
- chunkPtr = layoutPtr->chunks;
tkfont = layoutPtr->tkfont;
fontPtr = (TkFont *) tkfont;
@@ -2764,7 +2758,7 @@ Tk_CharBbox(
goto check;
}
} else if (index < chunkPtr->numChars) {
- end = TkUtfAtIndex(chunkPtr->start, index);
+ end = Tcl_UtfAtIndex(chunkPtr->start, index);
if (xPtr != NULL) {
Tk_MeasureChars(tkfont, chunkPtr->start,
end - chunkPtr->start, -1, 0, &x);
@@ -3291,7 +3285,8 @@ Tk_TextLayoutToPostscript(
LayoutChunk *chunkPtr = layoutPtr->chunks;
int baseline = chunkPtr->y;
Tcl_Obj *psObj = Tcl_NewObj();
- int i, j, len;
+ int i, j;
+ TkSizeT len;
const char *p, *glyphname;
char uindex[5], c, *ps;
int ch;
@@ -3349,7 +3344,7 @@ Tk_TextLayoutToPostscript(
sprintf(uindex, "%04X", ch); /* endianness? */
glyphname = Tcl_GetVar2(interp, "::tk::psglyphs", uindex, 0);
if (glyphname) {
- ps = Tcl_GetStringFromObj(psObj, &len);
+ ps = TkGetStringFromObj(psObj, &len);
if (ps[len-1] == '(') {
/*
* In-place edit. Ewww!
@@ -3404,7 +3399,7 @@ noMapping: ;
static int
ConfigAttributesObj(
Tcl_Interp *interp, /* Interp for error return. */
- TCL_UNUSED(Tk_Window), /* For display on which font will be used. */
+ TCL_UNUSED(Tk_Window), /* For display on which font will be used. */
int objc, /* Number of elements in argv. */
Tcl_Obj *const objv[], /* Command line options. */
TkFontAttributes *faPtr) /* Font attributes structure whose fields are
@@ -3540,9 +3535,9 @@ GetAttributeInfoObj(
case FONT_SIZE:
if (faPtr->size >= 0.0) {
- valuePtr = Tcl_NewIntObj((int)(faPtr->size + 0.5));
+ valuePtr = Tcl_NewWideIntObj((Tcl_WideInt)(faPtr->size + 0.5));
} else {
- valuePtr = Tcl_NewIntObj(-(int)(-faPtr->size + 0.5));
+ valuePtr = Tcl_NewWideIntObj(-(Tcl_WideInt)(-faPtr->size + 0.5));
}
break;
@@ -3579,6 +3574,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, -1));
+ }
+ if (faPtr->slant != TK_FS_ROMAN) {
+ str = TkFindStateString(slantMap, faPtr->slant);
+ Tcl_ListObjAppendElement(NULL, resultPtr, Tcl_NewStringObj(str, -1));
+ }
+ if (faPtr->underline) {
+ str = TkFindStateString(underlineMap, faPtr->underline);
+ Tcl_ListObjAppendElement(NULL, resultPtr, Tcl_NewStringObj(str, -1));
+ }
+ if (faPtr->overstrike) {
+ str = TkFindStateString(overstrikeMap, faPtr->overstrike);
+ Tcl_ListObjAppendElement(NULL, resultPtr, Tcl_NewStringObj(str, -1));
+ }
+ return resultPtr;
+}
+
+/*
+ *---------------------------------------------------------------------------
+ *
* ParseFontNameObj --
*
* Converts a object into a set of font attributes that can be used to
@@ -3779,8 +3825,8 @@ NewChunk(
maxChunks = *maxPtr;
if (layoutPtr->numChunks == maxChunks) {
maxChunks *= 2;
- s = Tk_Offset(TextLayout, chunks) + (maxChunks * sizeof(LayoutChunk));
- layoutPtr = ckrealloc(layoutPtr, s);
+ s = offsetof(TextLayout, chunks) + (maxChunks * sizeof(LayoutChunk));
+ layoutPtr = (TextLayout *)ckrealloc(layoutPtr, s);
*layoutPtrPtr = layoutPtr;
*maxPtr = maxChunks;
@@ -4250,9 +4296,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);
}
}
diff --git a/generic/tkFont.h b/generic/tkFont.h
index de479bf..ceabee3 100644
--- a/generic/tkFont.h
+++ b/generic/tkFont.h
@@ -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
+ TkSizeT 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
+ TkSizeT 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 1112f81..696d2f5 100644
--- a/generic/tkFrame.c
+++ b/generic/tkFrame.c
@@ -12,8 +12,8 @@
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
-#include "default.h"
#include "tkInt.h"
+#include "default.h"
/*
* The following enum is used to define the type of the frame.
@@ -94,6 +94,16 @@ typedef struct {
* pixels of extra space to leave above and
* below child area. */
int padY; /* Integer value corresponding to padYPtr. */
+ Tcl_Obj *bgimgPtr; /* Value of -backgroundimage option: specifies
+ * image to display on window's background, or
+ * NULL if none. */
+ Tk_Image bgimg; /* Derived from bgimgPtr by calling
+ * Tk_GetImage, or NULL if bgimgPtr is
+ * NULL. */
+ int tile; /* Whether to tile the bgimg. */
+#ifndef TK_NO_DOUBLE_BUFFERING
+ GC copyGC; /* GC for copying when double-buffering. */
+#endif /* TK_NO_DOUBLE_BUFFERING */
} Frame;
/*
@@ -174,80 +184,94 @@ static const char *const labelAnchorStrings[] = {
static const Tk_OptionSpec commonOptSpec[] = {
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_FRAME_BG_COLOR, -1, Tk_Offset(Frame, border),
+ DEF_FRAME_BG_COLOR, TCL_INDEX_NONE, offsetof(Frame, border),
TK_OPTION_NULL_OK, DEF_FRAME_BG_MONO, 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL,
- NULL, 0, -1, 0, "-background", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_STRING, "-colormap", "colormap", "Colormap",
- DEF_FRAME_COLORMAP, -1, Tk_Offset(Frame, colormapName),
+ DEF_FRAME_COLORMAP, TCL_INDEX_NONE, offsetof(Frame, colormapName),
TK_OPTION_NULL_OK, 0, 0},
/*
* Having -container is useless in a labelframe since a container has
* no border. It should be deprecated.
*/
{TK_OPTION_BOOLEAN, "-container", "container", "Container",
- DEF_FRAME_CONTAINER, -1, Tk_Offset(Frame, isContainer), 0, 0, 0},
+ DEF_FRAME_CONTAINER, TCL_INDEX_NONE, offsetof(Frame, isContainer), 0, 0, 0},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_FRAME_CURSOR, -1, Tk_Offset(Frame, cursor),
+ DEF_FRAME_CURSOR, TCL_INDEX_NONE, offsetof(Frame, cursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-height", "height", "Height",
- DEF_FRAME_HEIGHT, -1, Tk_Offset(Frame, height), 0, 0, 0},
+ DEF_FRAME_HEIGHT, TCL_INDEX_NONE, offsetof(Frame, height), 0, 0, 0},
{TK_OPTION_COLOR, "-highlightbackground", "highlightBackground",
- "HighlightBackground", DEF_FRAME_HIGHLIGHT_BG, -1,
- Tk_Offset(Frame, highlightBgColorPtr), 0, 0, 0},
+ "HighlightBackground", DEF_FRAME_HIGHLIGHT_BG, TCL_INDEX_NONE,
+ offsetof(Frame, highlightBgColorPtr), 0, 0, 0},
{TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_FRAME_HIGHLIGHT, -1, Tk_Offset(Frame, highlightColorPtr),
+ DEF_FRAME_HIGHLIGHT, TCL_INDEX_NONE, offsetof(Frame, highlightColorPtr),
0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
- "HighlightThickness", DEF_FRAME_HIGHLIGHT_WIDTH, -1,
- Tk_Offset(Frame, highlightWidth), 0, 0, 0},
+ "HighlightThickness", DEF_FRAME_HIGHLIGHT_WIDTH, TCL_INDEX_NONE,
+ offsetof(Frame, highlightWidth), 0, 0, 0},
{TK_OPTION_PIXELS, "-padx", "padX", "Pad",
- DEF_FRAME_PADX, Tk_Offset(Frame, padXPtr),
- Tk_Offset(Frame, padX), 0, 0, 0},
+ DEF_FRAME_PADX, offsetof(Frame, padXPtr),
+ offsetof(Frame, padX), 0, 0, 0},
{TK_OPTION_PIXELS, "-pady", "padY", "Pad",
- DEF_FRAME_PADY, Tk_Offset(Frame, padYPtr),
- Tk_Offset(Frame, padY), 0, 0, 0},
+ DEF_FRAME_PADY, offsetof(Frame, padYPtr),
+ offsetof(Frame, padY), 0, 0, 0},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_FRAME_TAKE_FOCUS, -1, Tk_Offset(Frame, takeFocus),
+ DEF_FRAME_TAKE_FOCUS, TCL_INDEX_NONE, offsetof(Frame, takeFocus),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-visual", "visual", "Visual",
- DEF_FRAME_VISUAL, -1, Tk_Offset(Frame, visualName),
+ DEF_FRAME_VISUAL, TCL_INDEX_NONE, offsetof(Frame, visualName),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-width", "width", "Width",
- DEF_FRAME_WIDTH, -1, Tk_Offset(Frame, width), 0, 0, 0},
+ DEF_FRAME_WIDTH, TCL_INDEX_NONE, offsetof(Frame, width), 0, 0, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0}
};
static const Tk_OptionSpec frameOptSpec[] = {
+ {TK_OPTION_STRING, "-backgroundimage", "backgroundImage", "BackgroundImage",
+ DEF_FRAME_BG_IMAGE, offsetof(Frame, bgimgPtr), TCL_INDEX_NONE,
+ TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
+ {TK_OPTION_SYNONYM, "-bgimg", NULL, NULL,
+ NULL, 0, TCL_INDEX_NONE, 0, "-backgroundimage", 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_FRAME_BORDER_WIDTH, -1, Tk_Offset(Frame, borderWidth), 0, 0, 0},
+ DEF_FRAME_BORDER_WIDTH, TCL_INDEX_NONE, offsetof(Frame, borderWidth), 0, 0, 0},
{TK_OPTION_STRING, "-class", "class", "Class",
- DEF_FRAME_CLASS, -1, Tk_Offset(Frame, className), 0, 0, 0},
+ DEF_FRAME_CLASS, TCL_INDEX_NONE, offsetof(Frame, className), 0, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_FRAME_RELIEF, -1, Tk_Offset(Frame, relief), 0, 0, 0},
+ DEF_FRAME_RELIEF, TCL_INDEX_NONE, offsetof(Frame, relief), 0, 0, 0},
+ {TK_OPTION_BOOLEAN, "-tile", "tile", "Tile",
+ DEF_FRAME_BG_TILE, TCL_INDEX_NONE, offsetof(Frame, tile), 0, 0, 0},
{TK_OPTION_END, NULL, NULL, NULL,
NULL, 0, 0, 0, commonOptSpec, 0}
};
static const Tk_OptionSpec toplevelOptSpec[] = {
+ {TK_OPTION_STRING, "-backgroundimage", "backgroundImage", "BackgroundImage",
+ DEF_FRAME_BG_IMAGE, offsetof(Frame, bgimgPtr), TCL_INDEX_NONE,
+ TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
+ {TK_OPTION_SYNONYM, "-bgimg", NULL, NULL,
+ NULL, 0, TCL_INDEX_NONE, 0, "-backgroundimage", 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_FRAME_BORDER_WIDTH, -1, Tk_Offset(Frame, borderWidth), 0, 0, 0},
+ DEF_FRAME_BORDER_WIDTH, TCL_INDEX_NONE, offsetof(Frame, borderWidth), 0, 0, 0},
{TK_OPTION_STRING, "-class", "class", "Class",
- DEF_TOPLEVEL_CLASS, -1, Tk_Offset(Frame, className), 0, 0, 0},
+ DEF_TOPLEVEL_CLASS, TCL_INDEX_NONE, offsetof(Frame, className), 0, 0, 0},
{TK_OPTION_STRING, "-menu", "menu", "Menu",
- DEF_TOPLEVEL_MENU, -1, Tk_Offset(Frame, menuName),
+ DEF_TOPLEVEL_MENU, TCL_INDEX_NONE, offsetof(Frame, menuName),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_FRAME_RELIEF, -1, Tk_Offset(Frame, relief), 0, 0, 0},
+ DEF_FRAME_RELIEF, TCL_INDEX_NONE, offsetof(Frame, relief), 0, 0, 0},
{TK_OPTION_STRING, "-screen", "screen", "Screen",
- DEF_TOPLEVEL_SCREEN, -1, Tk_Offset(Frame, screenName),
+ DEF_TOPLEVEL_SCREEN, TCL_INDEX_NONE, offsetof(Frame, screenName),
TK_OPTION_NULL_OK, 0, 0},
+ {TK_OPTION_BOOLEAN, "-tile", "tile", "Tile",
+ DEF_FRAME_BG_TILE, TCL_INDEX_NONE, offsetof(Frame, tile), 0, 0, 0},
{TK_OPTION_STRING, "-use", "use", "Use",
- DEF_TOPLEVEL_USE, -1, Tk_Offset(Frame, useThis),
+ DEF_TOPLEVEL_USE, TCL_INDEX_NONE, offsetof(Frame, useThis),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_END, NULL, NULL, NULL,
NULL, 0, 0, 0, commonOptSpec, 0}
@@ -255,27 +279,27 @@ static const Tk_OptionSpec toplevelOptSpec[] = {
static const Tk_OptionSpec labelframeOptSpec[] = {
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_LABELFRAME_BORDER_WIDTH, -1, Tk_Offset(Frame, borderWidth),
+ DEF_LABELFRAME_BORDER_WIDTH, TCL_INDEX_NONE, offsetof(Frame, borderWidth),
0, 0, 0},
{TK_OPTION_STRING, "-class", "class", "Class",
- DEF_LABELFRAME_CLASS, -1, Tk_Offset(Frame, className), 0, 0, 0},
+ DEF_LABELFRAME_CLASS, TCL_INDEX_NONE, offsetof(Frame, className), 0, 0, 0},
{TK_OPTION_SYNONYM, "-fg", "foreground", NULL,
- NULL, 0, -1, 0, "-foreground", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_LABELFRAME_FONT, -1, Tk_Offset(Labelframe, tkfont), 0, 0, 0},
+ DEF_LABELFRAME_FONT, TCL_INDEX_NONE, offsetof(Labelframe, tkfont), 0, 0, 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_LABELFRAME_FG, -1, Tk_Offset(Labelframe, textColorPtr), 0, 0, 0},
+ DEF_LABELFRAME_FG, TCL_INDEX_NONE, offsetof(Labelframe, textColorPtr), 0, 0, 0},
{TK_OPTION_STRING_TABLE, "-labelanchor", "labelAnchor", "LabelAnchor",
- DEF_LABELFRAME_LABELANCHOR, -1, Tk_Offset(Labelframe, labelAnchor),
+ DEF_LABELFRAME_LABELANCHOR, TCL_INDEX_NONE, offsetof(Labelframe, labelAnchor),
0, labelAnchorStrings, 0},
{TK_OPTION_WINDOW, "-labelwidget", "labelWidget", "LabelWidget",
- NULL, -1, Tk_Offset(Labelframe, labelWin), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(Labelframe, labelWin), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_LABELFRAME_RELIEF, -1, Tk_Offset(Frame, relief), 0, 0, 0},
+ DEF_LABELFRAME_RELIEF, TCL_INDEX_NONE, offsetof(Frame, relief), 0, 0, 0},
{TK_OPTION_STRING, "-text", "text", "Text",
- DEF_LABELFRAME_TEXT, Tk_Offset(Labelframe, textPtr), -1,
+ DEF_LABELFRAME_TEXT, offsetof(Labelframe, textPtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_END, NULL, NULL, NULL,
NULL, 0, 0, 0, commonOptSpec, 0}
@@ -311,6 +335,12 @@ static int CreateFrame(ClientData clientData, Tcl_Interp *interp,
static void DestroyFrame(void *memPtr);
static void DestroyFramePartly(Frame *framePtr);
static void DisplayFrame(ClientData clientData);
+static void DrawFrameBackground(Tk_Window tkwin, Pixmap pixmap,
+ int highlightWidth, int borderWidth,
+ Tk_Image bgimg, int bgtile);
+static void FrameBgImageProc(ClientData clientData,
+ int x, int y, int width, int height,
+ int imgWidth, int imgHeight);
static void FrameCmdDeletedProc(ClientData clientData);
static void FrameEventProc(ClientData clientData,
XEvent *eventPtr);
@@ -346,7 +376,7 @@ static const Tk_ClassProcs frameClass = {
static const Tk_GeomMgr frameGeomType = {
"labelframe", /* name */
FrameRequestProc, /* requestProc */
- FrameLostContentProc /* lostSlaveProc */
+ FrameLostContentProc /* lostContentProc */
};
/*
@@ -431,7 +461,7 @@ TkCreateFrame(
* application. */
{
int result, i;
- Tcl_Obj **objv = ckalloc((argc+1) * sizeof(Tcl_Obj **));
+ Tcl_Obj **objv = (Tcl_Obj **)ckalloc((argc+1) * sizeof(Tcl_Obj **));
for (i=0; i<argc; i++) {
objv[i] = Tcl_NewStringObj(argv[i], -1);
@@ -472,7 +502,7 @@ TkListCreateFrame(
static int
CreateFrame(
- ClientData clientData, /* NULL. */
+ ClientData dummy, /* NULL. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[], /* Argument objects. */
@@ -488,10 +518,12 @@ CreateFrame(
Tk_Window newWin;
const char *className, *screenName, *visualName, *colormapName;
const char *arg, *useOption;
- int i, length, depth;
+ int i, depth;
+ TkSizeT length;
unsigned int mask;
Colormap colormap;
Visual *visual;
+ (void)dummy;
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "pathName ?-option value ...?");
@@ -515,24 +547,24 @@ CreateFrame(
className = colormapName = screenName = visualName = useOption = NULL;
colormap = None;
for (i = 2; i < objc; i += 2) {
- arg = Tcl_GetStringFromObj(objv[i], &length);
+ arg = TkGetStringFromObj(objv[i], &length);
if (length < 2) {
continue;
}
if ((arg[1] == 'c') && (length >= 3)
- && (strncmp(arg, "-class", (unsigned) length) == 0)) {
+ && (strncmp(arg, "-class", length) == 0)) {
className = Tcl_GetString(objv[i+1]);
} else if ((arg[1] == 'c') && (length >= 3)
- && (strncmp(arg, "-colormap", (unsigned) length) == 0)) {
+ && (strncmp(arg, "-colormap", length) == 0)) {
colormapName = Tcl_GetString(objv[i+1]);
} else if ((arg[1] == 's') && (type == TYPE_TOPLEVEL)
- && (strncmp(arg, "-screen", (unsigned) length) == 0)) {
+ && (strncmp(arg, "-screen", length) == 0)) {
screenName = Tcl_GetString(objv[i+1]);
} else if ((arg[1] == 'u') && (type == TYPE_TOPLEVEL)
- && (strncmp(arg, "-use", (unsigned) length) == 0)) {
+ && (strncmp(arg, "-use", length) == 0)) {
useOption = Tcl_GetString(objv[i+1]);
} else if ((arg[1] == 'v')
- && (strncmp(arg, "-visual", (unsigned) length) == 0)) {
+ && (strncmp(arg, "-visual", length) == 0)) {
visualName = Tcl_GetString(objv[i+1]);
}
}
@@ -647,10 +679,10 @@ CreateFrame(
*/
if (type == TYPE_LABELFRAME) {
- framePtr = ckalloc(sizeof(Labelframe));
+ framePtr = (Frame *)ckalloc(sizeof(Labelframe));
memset(framePtr, 0, sizeof(Labelframe));
} else {
- framePtr = ckalloc(sizeof(Frame));
+ framePtr = (Frame *)ckalloc(sizeof(Frame));
memset(framePtr, 0, sizeof(Frame));
}
framePtr->tkwin = newWin;
@@ -682,7 +714,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;
@@ -700,7 +732,7 @@ CreateFrame(
if (type == TYPE_TOPLEVEL) {
Tcl_DoWhenIdle(MapFrame, framePtr);
}
- Tcl_SetObjResult(interp, TkNewWindowObj(newWin));
+ Tcl_SetObjResult(interp, Tk_NewWindowObj(newWin));
return TCL_OK;
error:
@@ -741,9 +773,10 @@ FrameWidgetObjCmd(
enum options {
FRAME_CGET, FRAME_CONFIGURE
};
- register Frame *framePtr = clientData;
+ Frame *framePtr = (Frame *)clientData;
int result = TCL_OK, index;
- int c, i, length;
+ int c, i;
+ TkSizeT length;
Tcl_Obj *objPtr;
if (objc < 2) {
@@ -762,7 +795,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;
@@ -772,7 +805,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) {
@@ -787,24 +820,24 @@ FrameWidgetObjCmd(
*/
for (i = 2; i < objc; i++) {
- const char *arg = Tcl_GetStringFromObj(objv[i], &length);
+ const char *arg = TkGetStringFromObj(objv[i], &length);
if (length < 2) {
continue;
}
c = arg[1];
if (((c == 'c') && (length >= 2)
- && (strncmp(arg, "-class", (unsigned)length) == 0))
+ && (strncmp(arg, "-class", length) == 0))
|| ((c == 'c') && (length >= 3)
- && (strncmp(arg, "-colormap", (unsigned)length) == 0))
+ && (strncmp(arg, "-colormap", length) == 0))
|| ((c == 'c') && (length >= 3)
- && (strncmp(arg, "-container", (unsigned)length) == 0))
+ && (strncmp(arg, "-container", length) == 0))
|| ((c == 's') && (framePtr->type == TYPE_TOPLEVEL)
- && (strncmp(arg, "-screen", (unsigned)length) == 0))
+ && (strncmp(arg, "-screen", length) == 0))
|| ((c == 'u') && (framePtr->type == TYPE_TOPLEVEL)
- && (strncmp(arg, "-use", (unsigned)length) == 0))
+ && (strncmp(arg, "-use", length) == 0))
|| ((c == 'v')
- && (strncmp(arg, "-visual", (unsigned)length) == 0))) {
+ && (strncmp(arg, "-visual", length) == 0))) {
#ifdef SUPPORT_CONFIG_EMBEDDED
if (c == 'u') {
@@ -859,8 +892,8 @@ static void
DestroyFrame(
void *memPtr) /* Info about frame widget. */
{
- register Frame *framePtr = memPtr;
- register Labelframe *labelframePtr = memPtr;
+ Frame *framePtr = (Frame *)memPtr;
+ Labelframe *labelframePtr = (Labelframe *)memPtr;
if (framePtr->type == TYPE_LABELFRAME) {
Tk_FreeTextLayout(labelframePtr->textLayout);
@@ -868,9 +901,17 @@ DestroyFrame(
Tk_FreeGC(framePtr->display, labelframePtr->textGC);
}
}
+#ifndef TK_NO_DOUBLE_BUFFERING
+ if (framePtr->copyGC != NULL) {
+ Tk_FreeGC(framePtr->display, framePtr->copyGC);
+ }
+#endif /* TK_NO_DOUBLE_BUFFERING */
if (framePtr->colormap != None) {
Tk_FreeColormap(framePtr->display, framePtr->colormap);
}
+ if (framePtr->bgimg) {
+ Tk_FreeImage(framePtr->bgimg);
+ }
ckfree(framePtr);
}
@@ -896,7 +937,7 @@ static void
DestroyFramePartly(
Frame *framePtr) /* Info about frame widget. */
{
- register Labelframe *labelframePtr = (Labelframe *) framePtr;
+ Labelframe *labelframePtr = (Labelframe *) framePtr;
if (framePtr->type == TYPE_LABELFRAME && labelframePtr->labelWin != NULL) {
Tk_DeleteEventHandler(labelframePtr->labelWin, StructureNotifyMask,
@@ -936,7 +977,7 @@ DestroyFramePartly(
static int
ConfigureFrame(
Tcl_Interp *interp, /* Used for error reporting. */
- register Frame *framePtr, /* Information about widget; may or may not
+ Frame *framePtr, /* Information about widget; may or may not
* already have values for some fields. */
int objc, /* Number of valid entries in objv. */
Tcl_Obj *const objv[]) /* Arguments. */
@@ -945,6 +986,7 @@ ConfigureFrame(
char *oldMenuName;
Tk_Window oldWindow = NULL;
Labelframe *labelframePtr = (Labelframe *) framePtr;
+ Tk_Image image = NULL;
/*
* Need the old menubar name for the menu code to delete it.
@@ -953,14 +995,14 @@ ConfigureFrame(
if (framePtr->menuName == NULL) {
oldMenuName = NULL;
} else {
- oldMenuName = ckalloc(strlen(framePtr->menuName) + 1);
+ oldMenuName = (char *)ckalloc(strlen(framePtr->menuName) + 1);
strcpy(oldMenuName, framePtr->menuName);
}
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) {
@@ -968,6 +1010,20 @@ ConfigureFrame(
}
return TCL_ERROR;
}
+
+ if (framePtr->bgimgPtr) {
+ image = Tk_GetImage(interp, framePtr->tkwin,
+ Tcl_GetString(framePtr->bgimgPtr), FrameBgImageProc, framePtr);
+ if (image == NULL) {
+ Tk_RestoreSavedOptions(&savedOptions);
+ return TCL_ERROR;
+ }
+ }
+ if (framePtr->bgimg) {
+ Tk_FreeImage(framePtr->bgimg);
+ }
+ framePtr->bgimg = image;
+
Tk_FreeSavedOptions(&savedOptions);
/*
@@ -1094,8 +1150,8 @@ static void
FrameWorldChanged(
ClientData instanceData) /* Information about widget. */
{
- Frame *framePtr = instanceData;
- Labelframe *labelframePtr = instanceData;
+ Frame *framePtr = (Frame *)instanceData;
+ Labelframe *labelframePtr = (Labelframe *)instanceData;
Tk_Window tkwin = framePtr->tkwin;
XGCValues gcValues;
GC gc;
@@ -1109,6 +1165,15 @@ FrameWorldChanged(
anyWindowLabel = (framePtr->type == TYPE_LABELFRAME) &&
(labelframePtr->labelWin != NULL);
+#ifndef TK_NO_DOUBLE_BUFFERING
+ gcValues.graphics_exposures = False;
+ gc = Tk_GetGC(tkwin, GCGraphicsExposures, &gcValues);
+ if (framePtr->copyGC != NULL) {
+ Tk_FreeGC(framePtr->display, framePtr->copyGC);
+ }
+ framePtr->copyGC = gc;
+#endif /* TK_NO_DOUBLE_BUFFERING */
+
if (framePtr->type == TYPE_LABELFRAME) {
/*
* The textGC is needed even in the labelWin case, so it's always
@@ -1263,7 +1328,7 @@ FrameWorldChanged(
static void
ComputeFrameGeometry(
- register Frame *framePtr) /* Information about widget. */
+ Frame *framePtr) /* Information about widget. */
{
int otherWidth, otherHeight, otherWidthT, otherHeightT, padding;
int maxWidth, maxHeight;
@@ -1412,8 +1477,8 @@ static void
DisplayFrame(
ClientData clientData) /* Information about widget. */
{
- register Frame *framePtr = clientData;
- register Tk_Window tkwin = framePtr->tkwin;
+ Frame *framePtr = (Frame *)clientData;
+ Tk_Window tkwin = framePtr->tkwin;
int bdX1, bdY1, bdX2, bdY2, hlWidth;
Pixmap pixmap;
TkRegion clipRegion = NULL;
@@ -1453,6 +1518,20 @@ DisplayFrame(
return;
}
+#ifndef TK_NO_DOUBLE_BUFFERING
+ /*
+ * In order to avoid screen flashes, this function redraws the frame into
+ * off-screen memory, then copies it back on-screen in a single operation.
+ * This means there's no point in time where the on-screen image has been
+ * cleared.
+ */
+
+ pixmap = Tk_GetPixmap(framePtr->display, Tk_WindowId(tkwin),
+ Tk_Width(tkwin), Tk_Height(tkwin), Tk_Depth(tkwin));
+#else
+ pixmap = Tk_WindowId(tkwin);
+#endif /* TK_NO_DOUBLE_BUFFERING */
+
if (framePtr->type != TYPE_LABELFRAME) {
/*
* Pass to platform specific draw function. In general, it just draws
@@ -1460,8 +1539,12 @@ DisplayFrame(
*/
noLabel:
- TkpDrawFrame(tkwin, framePtr->border, hlWidth,
+ TkpDrawFrameEx(tkwin, pixmap, framePtr->border, hlWidth,
framePtr->borderWidth, framePtr->relief);
+ if (framePtr->bgimg) {
+ DrawFrameBackground(tkwin, pixmap, hlWidth, framePtr->borderWidth,
+ framePtr->bgimg, framePtr->tile);
+ }
} else {
Labelframe *labelframePtr = (Labelframe *) framePtr;
@@ -1470,20 +1553,6 @@ DisplayFrame(
goto noLabel;
}
-#ifndef TK_NO_DOUBLE_BUFFERING
- /*
- * In order to avoid screen flashes, this function redraws the frame
- * into off-screen memory, then copies it back on-screen in a single
- * operation. This means there's no point in time where the on-screen
- * image has been cleared.
- */
-
- pixmap = Tk_GetPixmap(framePtr->display, Tk_WindowId(tkwin),
- Tk_Width(tkwin), Tk_Height(tkwin), Tk_Depth(tkwin));
-#else
- pixmap = Tk_WindowId(tkwin);
-#endif /* TK_NO_DOUBLE_BUFFERING */
-
/*
* Clear the pixmap.
*/
@@ -1595,22 +1664,54 @@ DisplayFrame(
labelframePtr->labelBox.height);
}
}
+ }
#ifndef TK_NO_DOUBLE_BUFFERING
- /*
- * Everything's been redisplayed; now copy the pixmap onto the screen
- * and free up the pixmap.
- */
+ /*
+ * Everything's been redisplayed; now copy the pixmap onto the screen and
+ * free up the pixmap.
+ */
- XCopyArea(framePtr->display, pixmap, Tk_WindowId(tkwin),
- labelframePtr->textGC, hlWidth, hlWidth,
- (unsigned) (Tk_Width(tkwin) - 2 * hlWidth),
- (unsigned) (Tk_Height(tkwin) - 2 * hlWidth),
- hlWidth, hlWidth);
- Tk_FreePixmap(framePtr->display, pixmap);
+ XCopyArea(framePtr->display, pixmap, Tk_WindowId(tkwin),
+ framePtr->copyGC, hlWidth, hlWidth,
+ (unsigned) (Tk_Width(tkwin) - 2 * hlWidth),
+ (unsigned) (Tk_Height(tkwin) - 2 * hlWidth),
+ hlWidth, hlWidth);
+ Tk_FreePixmap(framePtr->display, pixmap);
#endif /* TK_NO_DOUBLE_BUFFERING */
- }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TkpDrawFrame --
+ *
+ * This procedure draws the rectangular frame area.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Draws inside the tkwin area.
+ *
+ *----------------------------------------------------------------------
+ */
+
+void
+TkpDrawFrame(
+ Tk_Window tkwin,
+ Tk_3DBorder border,
+ int highlightWidth,
+ int borderWidth,
+ int relief)
+{
+ /*
+ * Legacy shim to allow for external callers. Internal ones use
+ * non-exposed TkpDrawFrameEx directly so they can use double-buffering.
+ */
+ TkpDrawFrameEx(tkwin, Tk_WindowId(tkwin), border,
+ highlightWidth, borderWidth, relief);
}
/*
@@ -1635,9 +1736,9 @@ DisplayFrame(
static void
FrameEventProc(
ClientData clientData, /* Information about window. */
- register XEvent *eventPtr) /* Information about event. */
+ XEvent *eventPtr) /* Information about event. */
{
- register Frame *framePtr = clientData;
+ Frame *framePtr = (Frame *)clientData;
if ((eventPtr->type == Expose) && (eventPtr->xexpose.count == 0)) {
goto redraw;
@@ -1729,7 +1830,7 @@ static void
FrameCmdDeletedProc(
ClientData clientData) /* Pointer to widget record for widget. */
{
- Frame *framePtr = clientData;
+ Frame *framePtr = (Frame *)clientData;
Tk_Window tkwin = framePtr->tkwin;
if (framePtr->menuName != NULL) {
@@ -1780,7 +1881,7 @@ static void
MapFrame(
ClientData clientData) /* Pointer to frame structure. */
{
- Frame *framePtr = clientData;
+ Frame *framePtr = (Frame *)clientData;
/*
* Wait for all other background events to be processed before mapping
@@ -1835,7 +1936,7 @@ TkInstallFrameMenu(
TkWindow *winPtr = (TkWindow *) tkwin;
if (winPtr->mainPtr != NULL) {
- Frame *framePtr = winPtr->instanceData;
+ Frame *framePtr = (Frame *)winPtr->instanceData;
if (framePtr == NULL) {
Tcl_Panic("TkInstallFrameMenu couldn't get frame pointer");
@@ -1868,7 +1969,7 @@ FrameStructureProc(
ClientData clientData, /* Pointer to record describing frame. */
XEvent *eventPtr) /* Describes what just happened. */
{
- Labelframe *labelframePtr = clientData;
+ Labelframe *labelframePtr = (Labelframe *)clientData;
if (eventPtr->type == DestroyNotify) {
/*
@@ -1906,7 +2007,8 @@ FrameRequestProc(
ClientData clientData, /* Pointer to record for frame. */
Tk_Window tkwin) /* Window that changed its desired size. */
{
- Frame *framePtr = clientData;
+ Frame *framePtr = (Frame *)clientData;
+ (void)tkwin;
FrameWorldChanged(framePtr);
}
@@ -1930,12 +2032,13 @@ FrameRequestProc(
static void
FrameLostContentProc(
- ClientData clientData, /* Frame structure for content window that was
+ ClientData clientData, /* Frame structure for content window window that was
* stolen away. */
- Tk_Window tkwin) /* Tk's handle for the content window. */
+ Tk_Window tkwin) /* Tk's handle for the content window window. */
{
- Frame *framePtr = clientData;
- Labelframe *labelframePtr = clientData;
+ Frame *framePtr = (Frame *)clientData;
+ Labelframe *labelframePtr = (Labelframe *)clientData;
+ (void)tkwin;
/*
* This should only happen in a labelframe but it doesn't hurt to be
@@ -1958,7 +2061,7 @@ void
TkMapTopFrame(
Tk_Window tkwin)
{
- Frame *framePtr = ((TkWindow *) tkwin)->instanceData;
+ Frame *framePtr = (Frame *)((TkWindow *) tkwin)->instanceData;
Tk_OptionTable optionTable;
if (Tk_IsTopLevel(tkwin) && framePtr->type == TYPE_FRAME) {
@@ -2022,7 +2125,7 @@ TkToplevelWindowForCommand(
if (cmdInfo.objProc != FrameWidgetObjCmd) {
return NULL;
}
- framePtr = cmdInfo.objClientData;
+ framePtr = (Frame *)cmdInfo.objClientData;
if (framePtr->type != TYPE_TOPLEVEL) {
return NULL;
}
@@ -2030,6 +2133,135 @@ TkToplevelWindowForCommand(
}
/*
+ *----------------------------------------------------------------------
+ *
+ * FrameBgImageProc --
+ *
+ * This function is invoked by the image code whenever the manager for an
+ * image does something that affects the size or contents of an image
+ * displayed on a frame's background.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Arranges for the button to get redisplayed.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+FrameBgImageProc(
+ ClientData clientData, /* Pointer to widget record. */
+ int x, int y, /* Upper left pixel (within image) that must
+ * be redisplayed. */
+ int width, int height, /* Dimensions of area to redisplay (might be
+ * <= 0). */
+ int imgWidth, int imgHeight)/* New dimensions of image. */
+{
+ Frame *framePtr = (Frame *)clientData;
+ (void)x;
+ (void)y;
+ (void)width;
+ (void)height;
+ (void)imgWidth;
+ (void)imgHeight;
+
+
+ /*
+ * Changing the background image never alters the dimensions of the frame.
+ */
+
+ if (framePtr->tkwin && Tk_IsMapped(framePtr->tkwin) &&
+ !(framePtr->flags & REDRAW_PENDING)) {
+ Tcl_DoWhenIdle(DisplayFrame, framePtr);
+ framePtr->flags |= REDRAW_PENDING;
+ }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * DrawFrameBackground --
+ *
+ * This function draws the background image of a rectangular frame area.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Draws inside the tkwin area.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+DrawFrameBackground(
+ Tk_Window tkwin,
+ Pixmap pixmap,
+ int highlightWidth,
+ int borderWidth,
+ Tk_Image bgimg,
+ int bgtile)
+{
+ int width, height; /* Area to paint on. */
+ int imageWidth, imageHeight; /* Dimensions of image. */
+ const int bw = highlightWidth + borderWidth;
+
+ Tk_SizeOfImage(bgimg, &imageWidth, &imageHeight);
+ width = Tk_Width(tkwin) - 2*bw;
+ height = Tk_Height(tkwin) - 2*bw;
+
+ if (bgtile) {
+ /*
+ * Draw the image tiled in the widget (inside the border).
+ */
+
+ int x, y;
+
+ for (x = bw; x - bw < width; x += imageWidth) {
+ int w = imageWidth;
+ if (x - bw + imageWidth > width) {
+ w = (width + bw) - x;
+ }
+ for (y = bw; y < height + bw; y += imageHeight) {
+ int h = imageHeight;
+ if (y - bw + imageHeight > height) {
+ h = (height + bw) - y;
+ }
+ Tk_RedrawImage(bgimg, 0, 0, w, h, pixmap, x, y);
+ }
+ }
+ } else {
+ /*
+ * Draw the image centred in the widget (inside the border).
+ */
+
+ int x, y, xOff, yOff, w, h;
+
+ if (width > imageWidth) {
+ x = 0;
+ xOff = (Tk_Width(tkwin) - imageWidth) / 2;
+ w = imageWidth;
+ } else {
+ x = (imageWidth - width) / 2;
+ xOff = bw;
+ w = width;
+ }
+ if (height > imageHeight) {
+ y = 0;
+ yOff = (Tk_Height(tkwin) - imageHeight) / 2;
+ h = imageHeight;
+ } else {
+ y = (imageHeight - height) / 2;
+ yOff = bw;
+ h = height;
+ }
+ Tk_RedrawImage(bgimg, x, y, w, h, pixmap, xOff, yOff);
+ }
+}
+
+/*
* Local Variables:
* mode: c
* c-basic-offset: 4
diff --git a/generic/tkGC.c b/generic/tkGC.c
index c424e30..47931a6 100644
--- a/generic/tkGC.c
+++ b/generic/tkGC.c
@@ -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;
@@ -66,17 +66,17 @@ static void GCInit(TkDisplay *dispPtr);
GC
Tk_GetGC(
Tk_Window tkwin, /* Window in which GC will be used. */
- register unsigned long valueMask,
+ unsigned long valueMask,
/* 1 bits correspond to values specified in
* *valuesPtr; other values are set from
* defaults. */
- register XGCValues *valuePtr)
+ XGCValues *valuePtr)
/* Values are specified here for bits set in
* valueMask. */
{
ValueKey valueKey;
Tcl_HashEntry *valueHashPtr, *idHashPtr;
- register TkGC *gcPtr;
+ TkGC *gcPtr;
int isNew;
Drawable d, freeDrawable;
TkDisplay *dispPtr = ((TkWindow *) tkwin)->dispPtr;
@@ -218,7 +218,7 @@ Tk_GetGC(
valueHashPtr = Tcl_CreateHashEntry(&dispPtr->gcValueTable,
(char *) &valueKey, &isNew);
if (!isNew) {
- gcPtr = Tcl_GetHashValue(valueHashPtr);
+ gcPtr = (TkGC *)Tcl_GetHashValue(valueHashPtr);
gcPtr->refCount++;
return gcPtr->gc;
}
@@ -228,7 +228,7 @@ Tk_GetGC(
* and add a new structure to the database.
*/
- gcPtr = ckalloc(sizeof(TkGC));
+ gcPtr = (TkGC *)ckalloc(sizeof(TkGC));
/*
* Find or make a drawable to use to specify the screen and depth of the
@@ -291,7 +291,7 @@ Tk_FreeGC(
GC gc) /* Graphics context to be released. */
{
Tcl_HashEntry *idHashPtr;
- register TkGC *gcPtr;
+ TkGC *gcPtr;
TkDisplay *dispPtr = TkGetDisplay(display);
if (!dispPtr->gcInit) {
@@ -307,13 +307,12 @@ 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");
}
- gcPtr = Tcl_GetHashValue(idHashPtr);
- gcPtr->refCount--;
- if (gcPtr->refCount == 0) {
+ gcPtr = (TkGC *)Tcl_GetHashValue(idHashPtr);
+ if (gcPtr->refCount-- <= 1) {
XFreeGC(gcPtr->display, gcPtr->gc);
Tcl_DeleteHashEntry(gcPtr->valueHashPtr);
Tcl_DeleteHashEntry(idHashPtr);
@@ -348,7 +347,7 @@ TkGCCleanup(
for (entryPtr = Tcl_FirstHashEntry(&dispPtr->gcIdTable, &search);
entryPtr != NULL; entryPtr = Tcl_NextHashEntry(&search)) {
- gcPtr = Tcl_GetHashValue(entryPtr);
+ gcPtr = (TkGC *)Tcl_GetHashValue(entryPtr);
XFreeGC(gcPtr->display, gcPtr->gc);
Tcl_DeleteHashEntry(gcPtr->valueHashPtr);
diff --git a/generic/tkGeometry.c b/generic/tkGeometry.c
index 013347b..cd2c2c0 100644
--- a/generic/tkGeometry.c
+++ b/generic/tkGeometry.c
@@ -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.
*
*--------------------------------------------------------------
*/
@@ -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,8 +333,8 @@ 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);
}
diff --git a/generic/tkGrab.c b/generic/tkGrab.c
index a1ff46c..db51c96 100644
--- a/generic/tkGrab.c
+++ b/generic/tkGrab.c
@@ -178,7 +178,7 @@ Tk_GrabObjCmd(
TkDisplay *dispPtr;
const char *arg;
int index;
- int len;
+ TkSizeT len;
static const char *const optionStrings[] = {
"current", "release", "set", "status", NULL
};
@@ -215,7 +215,7 @@ Tk_GrabObjCmd(
* First check for a window name or "-global" as the first argument.
*/
- arg = Tcl_GetStringFromObj(objv[1], &len);
+ arg = TkGetStringFromObj(objv[1], &len);
if (arg[0] == '.') {
/* [grab window] */
if (objc != 2) {
@@ -270,7 +270,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 {
@@ -279,7 +279,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));
}
}
@@ -666,6 +666,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
@@ -677,6 +680,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.
*
*----------------------------------------------------------------------
*/
@@ -773,10 +777,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
@@ -799,6 +817,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;
}
@@ -871,7 +896,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. */
}
}
diff --git a/generic/tkGrid.c b/generic/tkGrid.c
index 785bc7f..dc4db82 100644
--- a/generic/tkGrid.c
+++ b/generic/tkGrid.c
@@ -292,8 +292,8 @@ static void GridLostContentProc(ClientData clientData,
Tk_Window tkwin);
static void GridReqProc(ClientData 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 */
};
/*
@@ -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;
}
@@ -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;
}
@@ -740,15 +753,15 @@ GridInfoCommand(
infoObj = Tcl_NewObj();
Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-in", -1),
- TkNewWindowObj(contentPtr->containerPtr->tkwin));
+ Tk_NewWindowObj(contentPtr->containerPtr->tkwin));
Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-column", -1),
- Tcl_NewIntObj(contentPtr->column));
+ Tcl_NewWideIntObj(contentPtr->column));
Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-row", -1),
- Tcl_NewIntObj(contentPtr->row));
+ Tcl_NewWideIntObj(contentPtr->row));
Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-columnspan", -1),
- Tcl_NewIntObj(contentPtr->numCols));
+ Tcl_NewWideIntObj(contentPtr->numCols));
Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-rowspan", -1),
- Tcl_NewIntObj(contentPtr->numRows));
+ 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);
@@ -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;
}
@@ -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;
}
@@ -1056,17 +1069,17 @@ GridRowColumnConfigureCommand(
Tcl_ListObjAppendElement(interp, res,
Tcl_NewStringObj("-minsize", -1));
- Tcl_ListObjAppendElement(interp, res, Tcl_NewIntObj(minsize));
+ Tcl_ListObjAppendElement(interp, res, Tcl_NewWideIntObj(minsize));
Tcl_ListObjAppendElement(interp, res,
Tcl_NewStringObj("-pad", -1));
- Tcl_ListObjAppendElement(interp, res, Tcl_NewIntObj(pad));
+ Tcl_ListObjAppendElement(interp, res, Tcl_NewWideIntObj(pad));
Tcl_ListObjAppendElement(interp, res,
Tcl_NewStringObj("-uniform", -1));
Tcl_ListObjAppendElement(interp, res,
Tcl_NewStringObj(uniform == NULL ? "" : uniform, -1));
Tcl_ListObjAppendElement(interp, res,
Tcl_NewStringObj("-weight", -1));
- Tcl_ListObjAppendElement(interp, res, Tcl_NewIntObj(weight));
+ Tcl_ListObjAppendElement(interp, res, Tcl_NewWideIntObj(weight));
Tcl_SetObjResult(interp, res);
Tcl_DecrRefCount(listCopy);
return TCL_OK;
@@ -1083,10 +1096,10 @@ GridRowColumnConfigureCommand(
return TCL_ERROR;
}
if (index == ROWCOL_MINSIZE) {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(
(ok == TCL_OK) ? slotPtr[slot].minSize : 0));
} else if (index == ROWCOL_WEIGHT) {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(
(ok == TCL_OK) ? slotPtr[slot].weight : 0));
} else if (index == ROWCOL_UNIFORM) {
Tk_Uid value = (ok == TCL_OK) ? slotPtr[slot].uniform : "";
@@ -1094,7 +1107,7 @@ GridRowColumnConfigureCommand(
Tcl_SetObjResult(interp, Tcl_NewStringObj(
(value == NULL) ? "" : value, -1));
} else if (index == ROWCOL_PAD) {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(
(ok == TCL_OK) ? slotPtr[slot].pad : 0));
}
Tcl_DecrRefCount(listCopy);
@@ -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;
}
@@ -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;
@@ -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);
}
}
@@ -2882,7 +2899,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);
}
@@ -2966,10 +2983,10 @@ ConfigureContent(
firstChar = 0;
for (numWindows=0, i=0; i < objc; i++) {
- int length;
+ TkSizeT length;
char prevChar = firstChar;
- string = Tcl_GetStringFromObj(objv[i], &length);
+ string = TkGetStringFromObj(objv[i], &length);
firstChar = string[0];
if (firstChar == '.') {
@@ -3344,7 +3361,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);
@@ -3360,7 +3377,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);
@@ -3445,7 +3462,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", -1));
Tcl_SetErrorCode(interp, "TK", "GRID", "SHORTCUT_USAGE", NULL);
return TCL_ERROR;
}
@@ -3499,7 +3516,7 @@ ConfigureContent(
}
if (!match) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "can't find slave to extend with \"^\"", -1));
+ "can't find content to extend with \"^\"", -1));
Tcl_SetErrorCode(interp, "TK", "GRID", "SHORTCUT_USAGE", NULL);
return TCL_ERROR;
}
@@ -3507,7 +3524,7 @@ ConfigureContent(
if (containerPtr == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "can't determine master window", -1));
+ "can't determine container window", -1));
Tcl_SetErrorCode(interp, "TK", "GRID", "SHORTCUT_USAGE", NULL);
return TCL_ERROR;
}
@@ -3516,11 +3533,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;
@@ -3631,12 +3652,12 @@ StringToSticky(
static Tcl_Obj *
NewPairObj(
- int val1, int val2)
+ Tcl_WideInt val1, Tcl_WideInt val2)
{
Tcl_Obj *ary[2];
- ary[0] = Tcl_NewIntObj(val1);
- ary[1] = Tcl_NewIntObj(val2);
+ ary[0] = Tcl_NewWideIntObj(val1);
+ ary[1] = Tcl_NewWideIntObj(val2);
return Tcl_NewListObj(2, ary);
}
@@ -3658,14 +3679,14 @@ NewPairObj(
static Tcl_Obj *
NewQuadObj(
- int val1, int val2, int val3, int val4)
+ Tcl_WideInt val1, Tcl_WideInt val2, Tcl_WideInt val3, Tcl_WideInt val4)
{
Tcl_Obj *ary[4];
- ary[0] = Tcl_NewIntObj(val1);
- ary[1] = Tcl_NewIntObj(val2);
- ary[2] = Tcl_NewIntObj(val3);
- ary[3] = Tcl_NewIntObj(val4);
+ ary[0] = Tcl_NewWideIntObj(val1);
+ ary[1] = Tcl_NewWideIntObj(val2);
+ ary[2] = Tcl_NewWideIntObj(val3);
+ ary[3] = Tcl_NewWideIntObj(val4);
return Tcl_NewListObj(4, ary);
}
diff --git a/generic/tkImage.c b/generic/tkImage.c
index d42ed7d..97d0702 100644
--- a/generic/tkImage.c
+++ b/generic/tkImage.c
@@ -472,7 +472,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(
@@ -485,7 +485,7 @@ Tk_ImageObjCmd(
}
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");
diff --git a/generic/tkImgBmap.c b/generic/tkImgBmap.c
index 04027b0..4cc98b5 100644
--- a/generic/tkImgBmap.c
+++ b/generic/tkImgBmap.c
@@ -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
@@ -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}
};
@@ -169,7 +169,6 @@ static int NextBitmapWord(ParseInfo *parseInfoPtr);
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
static int
ImgBmapCreate(
Tcl_Interp *interp, /* Interpreter for application containing
@@ -179,12 +178,13 @@ ImgBmapCreate(
Tcl_Obj *const argv[], /* Argument objects for options (doesn't
* include image name or type). */
const Tk_ImageType *typePtr,/* Pointer to our type record (not used). */
- Tk_ImageModel model, /* Token for image, to be used by us in later
+ Tk_ImageModel model, /* Token for image, to be used by us in later
* callbacks. */
ClientData *clientDataPtr) /* Store manager's token for image here; it
* will be returned in later callbacks. */
{
- BitmapModel *modelPtr = ckalloc(sizeof(BitmapModel));
+ BitmapModel *modelPtr = (BitmapModel *)ckalloc(sizeof(BitmapModel));
+ (void)typePtr;
modelPtr->tkModel = model;
modelPtr->interp = interp;
@@ -239,7 +239,7 @@ ImgBmapConfigureModel(
{
BitmapInstance *instancePtr;
int maskWidth, maskHeight, dummy1, dummy2;
- const char **argv = ckalloc((objc+1) * sizeof(char *));
+ const char **argv = (const char **)ckalloc((objc+1) * sizeof(char *));
for (dummy1 = 0; dummy1 < objc; dummy1++) {
argv[dummy1] = Tcl_GetString(objv[dummy1]);
@@ -620,7 +620,7 @@ TkGetBitmapData(
goto error;
}
numBytes = ((width+7)/8) * height;
- data = ckalloc(numBytes);
+ data = (char *)ckalloc(numBytes);
for (p = data; numBytes > 0; p++, numBytes--) {
if (NextBitmapWord(&pi) != TCL_OK) {
goto error;
@@ -757,7 +757,7 @@ ImgBmapCmd(
Tcl_Obj *const objv[]) /* Argument objects. */
{
static const char *const bmapOptions[] = {"cget", "configure", NULL};
- BitmapModel *modelPtr = clientData;
+ BitmapModel *modelPtr = (BitmapModel *)clientData;
int index;
if (objc < 2) {
@@ -819,7 +819,7 @@ ImgBmapGet(
ClientData modelData) /* Pointer to our model structure for the
* image. */
{
- BitmapModel *modelPtr = modelData;
+ BitmapModel *modelPtr = (BitmapModel *)modelData;
BitmapInstance *instancePtr;
/*
@@ -840,7 +840,7 @@ ImgBmapGet(
* the image.
*/
- instancePtr = ckalloc(sizeof(BitmapInstance));
+ instancePtr = (BitmapInstance *)ckalloc(sizeof(BitmapInstance));
instancePtr->refCount = 1;
instancePtr->modelPtr = modelPtr;
instancePtr->tkwin = tkwin;
@@ -894,7 +894,7 @@ ImgBmapDisplay(
/* Coordinates within drawable that correspond
* to imageX and imageY. */
{
- BitmapInstance *instancePtr = clientData;
+ BitmapInstance *instancePtr = (BitmapInstance *)clientData;
int masking;
/*
@@ -948,11 +948,10 @@ ImgBmapFree(
* instance to be displayed. */
Display *display) /* Display containing window that used image. */
{
- BitmapInstance *instancePtr = clientData;
+ BitmapInstance *instancePtr = (BitmapInstance *)clientData;
BitmapInstance *prevPtr;
- instancePtr->refCount--;
- if (instancePtr->refCount > 0) {
+ if (instancePtr->refCount-- > 1) {
return;
}
@@ -1010,7 +1009,7 @@ ImgBmapDelete(
ClientData modelData) /* Pointer to BitmapModel structure for
* image. Must not have any more instances. */
{
- BitmapModel *modelPtr = modelData;
+ BitmapModel *modelPtr = (BitmapModel *)modelData;
if (modelPtr->instancePtr != NULL) {
Tcl_Panic("tried to delete bitmap image when instances still exist");
@@ -1051,7 +1050,7 @@ ImgBmapCmdDeletedProc(
ClientData clientData) /* Pointer to BitmapModel structure for
* image. */
{
- BitmapModel *modelPtr = clientData;
+ BitmapModel *modelPtr = (BitmapModel *)clientData;
modelPtr->imageCmd = NULL;
if (modelPtr->tkModel != NULL) {
@@ -1080,7 +1079,7 @@ GetByte(
Tcl_Channel chan) /* The channel we read from. */
{
char buffer;
- int size;
+ size_t size;
size = Tcl_Read(chan, &buffer, 1);
if (size != 1) {
@@ -1198,7 +1197,7 @@ ImgBmapPostscript(
int x, int y, int width, int height,
int prepass)
{
- BitmapModel *modelPtr = clientData;
+ BitmapModel *modelPtr = (BitmapModel *)clientData;
Tcl_InterpState interpState;
Tcl_Obj *psObj;
diff --git a/generic/tkImgGIF.c b/generic/tkImgGIF.c
index 76e48d4..cece744 100644
--- a/generic/tkImgGIF.c
+++ b/generic/tkImgGIF.c
@@ -55,7 +55,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 */
+ size_t length; /* Total amount of bytes in data */
} MFile;
/*
@@ -111,8 +111,8 @@ typedef struct {
* serializing in the GIF format.
*/
-typedef int (WriteBytesFunc) (ClientData clientData, const char *bytes,
- int byteCount);
+typedef size_t (WriteBytesFunc) (ClientData clientData, const char *bytes,
+ size_t byteCount);
/*
* The format record for the GIF file format:
@@ -187,14 +187,14 @@ static int ReadImage(GIFImageConfig *gifConfPtr,
* these are for the BASE64 image reader code only
*/
-static int Fread(GIFImageConfig *gifConfPtr, unsigned char *dst,
+static size_t 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 size_t Mread(unsigned char *dst, size_t size, size_t count,
MFile *handle);
static int Mgetc(MFile *handle);
static int char64(int c);
static void mInit(unsigned char *string, MFile *handle,
- int length);
+ size_t length);
/*
* Types, defines and variables needed to write and compress a GIF.
@@ -351,9 +351,12 @@ FileMatchGIF(
int *widthPtr, int *heightPtr,
/* The dimensions of the image are returned
* here if the file is a valid raw GIF file. */
- Tcl_Interp *interp) /* not used */
+ Tcl_Interp *dummy) /* not used */
{
GIFImageConfig gifConf;
+ (void)fileName;
+ (void)format;
+ (void)dummy;
memset(&gifConf, 0, sizeof(GIFImageConfig));
return ReadGIFHeader(&gifConf, chan, widthPtr, heightPtr);
@@ -597,7 +600,7 @@ FileReadGIF(
goto error;
}
nBytes = fileWidth * fileHeight * 3;
- trashBuffer = ckalloc(nBytes);
+ trashBuffer = (unsigned char *)ckalloc(nBytes);
if (trashBuffer) {
memset(trashBuffer, 0, nBytes);
}
@@ -692,7 +695,7 @@ FileReadGIF(
goto error;
}
nBytes = block.pitch * imageHeight;
- block.pixelPtr = ckalloc(nBytes);
+ block.pixelPtr = (unsigned char *)ckalloc(nBytes);
if (block.pixelPtr) {
memset(block.pixelPtr, 0, nBytes);
}
@@ -754,13 +757,15 @@ StringMatchGIF(
Tcl_Obj *format, /* the image format object, or NULL */
int *widthPtr, /* where to put the string width */
int *heightPtr, /* where to put the string height */
- Tcl_Interp *interp) /* not used */
+ Tcl_Interp *dummy) /* not used */
{
unsigned char *data, header[10];
- int got, length;
+ TkSizeT got, length;
MFile handle;
+ (void)format;
+ (void)dummy;
- data = Tcl_GetByteArrayFromObj(dataObj, &length);
+ data = TkGetByteArrayFromObj(dataObj, &length);
/*
* Header is a minimum of 10 bytes.
@@ -826,9 +831,9 @@ StringReadGIF(
int srcX, int srcY)
{
MFile handle, *hdlPtr = &handle;
- int length;
+ TkSizeT length;
const char *xferFormat;
- unsigned char *data = Tcl_GetByteArrayFromObj(dataObj, &length);
+ unsigned char *data = TkGetByteArrayFromObj(dataObj, &length);
mInit(data, hdlPtr, length);
@@ -917,7 +922,7 @@ ReadColorMap(
unsigned char rgb[3];
for (i = 0; i < number; ++i) {
- if (Fread(gifConfPtr, rgb, sizeof(rgb), 1, chan) <= 0) {
+ if (((size_t)Fread(gifConfPtr, rgb, sizeof(rgb), 1, chan) + 1) < 2) {
return 0;
}
@@ -983,11 +988,11 @@ GetDataBlock(
{
unsigned char count;
- if (Fread(gifConfPtr, &count, 1, 1, chan) <= 0) {
+ if (((size_t)Fread(gifConfPtr, &count, 1, 1, chan) + 1) < 2) {
return -1;
}
- if ((count != 0) && (Fread(gifConfPtr, buf, count, 1, chan) <= 0)) {
+ if ((count != 0) && (((size_t)Fread(gifConfPtr, buf, count, 1, chan) + 1) < 2)) {
return -1;
}
@@ -1035,21 +1040,23 @@ ReadImage(
{
unsigned char initialCodeSize;
int xpos = 0, ypos = 0, pass = 0, i, count;
- register unsigned char *pixelPtr;
+ unsigned char *pixelPtr;
static const int interlaceStep[] = { 8, 8, 4, 2 };
static const int interlaceStart[] = { 0, 4, 2, 1 };
unsigned short prefix[(1 << MAX_LWZ_BITS)];
unsigned char append[(1 << MAX_LWZ_BITS)];
unsigned char stack[(1 << MAX_LWZ_BITS)*2];
- register unsigned char *top;
+ unsigned char *top;
int codeSize, clearCode, inCode, endCode, oldCode, maxCode;
int code, firstCode, v;
+ (void)srcX;
+ (void)srcY;
/*
* Initialize the decoder
*/
- if (Fread(gifConfPtr, &initialCodeSize, 1, 1, chan) <= 0) {
+ if (((size_t)Fread(gifConfPtr, &initialCodeSize, 1, 1, chan) + 1) < 2) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"error reading GIF image: %s", Tcl_PosixError(interp)));
return TCL_ERROR;
@@ -1392,7 +1399,7 @@ static void
mInit(
unsigned char *string, /* string containing initial mmencoded data */
MFile *handle, /* mmdecode "file" handle */
- int length) /* Number of bytes in string */
+ size_t length) /* Number of bytes in string */
{
handle->data = string;
handle->state = 0;
@@ -1418,15 +1425,15 @@ mInit(
*----------------------------------------------------------------------
*/
-static int
+static size_t
Mread(
unsigned char *dst, /* where to put the result */
size_t chunkSize, /* size of each transfer */
size_t numChunks, /* number of chunks */
MFile *handle) /* mmdecode "file" handle */
{
- register int i, c;
- int count = chunkSize * numChunks;
+ int c;
+ size_t i, count = chunkSize * numChunks;
for (i=0; i<count && (c=Mgetc(handle)) != GIF_DONE; i++) {
*dst++ = c;
@@ -1567,7 +1574,7 @@ char64(
*----------------------------------------------------------------------
*/
-static int
+static size_t
Fread(
GIFImageConfig *gifConfPtr,
unsigned char *dst, /* where to put the result */
@@ -1581,20 +1588,20 @@ Fread(
if (gifConfPtr->fromData == INLINE_DATA_BINARY) {
MFile *handle = (MFile *) chan;
- if (handle->length <= 0 || (size_t) handle->length < hunk*count) {
- return -1;
+ if ((handle->length + 1 < 2) || (handle->length < hunk*count)) {
+ return (size_t)-1;
}
- memcpy(dst, handle->data, (size_t) (hunk * count));
+ memcpy(dst, handle->data, hunk * count);
handle->data += hunk * count;
handle->length -= hunk * count;
- return (int)(hunk * count);
+ return hunk * count;
}
/*
* Otherwise we've got a real file to read.
*/
- return Tcl_Read(chan, (char *) dst, (int) (hunk * count));
+ return Tcl_Read(chan, (char *) dst, hunk * count);
}
/*
@@ -1673,24 +1680,24 @@ StringWriteGIF(
return result;
}
-static int
+static size_t
WriteToChannel(
ClientData clientData,
const char *bytes,
- int byteCount)
+ size_t byteCount)
{
- Tcl_Channel handle = clientData;
+ Tcl_Channel handle = (Tcl_Channel)clientData;
return Tcl_Write(handle, bytes, byteCount);
}
-static int
+static size_t
WriteToByteArray(
ClientData clientData,
const char *bytes,
- int byteCount)
+ size_t byteCount)
{
- Tcl_Obj *objPtr = clientData;
+ Tcl_Obj *objPtr = (Tcl_Obj *)clientData;
Tcl_Obj *tmpObj = Tcl_NewByteArrayObj((unsigned char *) bytes, byteCount);
Tcl_IncrRefCount(tmpObj);
@@ -1712,6 +1719,7 @@ CommonWriteGIF(
long width, height, x;
unsigned char c;
unsigned int top, left;
+ (void)format;
top = 0;
left = 0;
@@ -2157,9 +2165,9 @@ ClearHashTable( /* Reset code table. */
GIFState_t *statePtr,
int hSize)
{
- register int *hashTablePtr = statePtr->hashTable + hSize;
- register long i;
- register long m1 = -1;
+ int *hashTablePtr = statePtr->hashTable + hSize;
+ long i;
+ long m1 = -1;
i = hSize - 16;
do { /* might use Sys V memset(3) here */
diff --git a/generic/tkImgListFormat.c b/generic/tkImgListFormat.c
new file mode 100644
index 0000000..70efc96
--- /dev/null
+++ b/generic/tkImgListFormat.c
@@ -0,0 +1,1145 @@
+/*
+ * 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 (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.
+ *
+ * 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"
+
+/*
+ * 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_CHARS 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,
+ int objc, Tcl_Obj *const objv[], int *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(Tcl_Interp *interp, const char *colorString,
+ int colorStrLen, 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 */
+ int objc, /* Number of elements in argv[] */
+ Tcl_Obj *const objv[], /* The arguments to parse */
+ int *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 */
+
+{
+ int index, optIndex, first;
+ enum ColorFormatType 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, (int *)&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 = 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", -1);
+ } else {
+ Tcl_AppendToObj(resObj, "must be ", -1);
+ 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, ", ", -1);
+ } else {
+ Tcl_AppendToObj(resObj, ", or ", -1);
+ }
+ }
+ Tcl_AppendToObj(resObj, formatOptionNames[i], -1);
+ }
+ 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_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 */
+ Tcl_Interp *interp) /* Error messages are left in this interpreter */
+{
+ int y, rowCount, colCount, curColCount;
+ unsigned char dummy;
+ Tcl_Obj **rowListPtr, *pixelData;
+ (void)formatString;
+
+ /*
+ * See if data can be parsed as a list, if every element is itself a valid
+ * 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 # %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;
+ }
+ if (Tcl_GetCharLength(pixelData) > TK_PHOTO_MAX_COLOR_CHARS) {
+ 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;
+ int objc;
+ unsigned char *curPixelPtr;
+ int x, y, rowCount, colCount, curColCount;
+ Tk_PhotoImageBlock srcBlock;
+ Display *display;
+ Colormap colormap;
+ struct FormatOptions opts;
+ int 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;
+ int 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:
+ sprintf(colorBuf, "#%02x%02x%02x ", pixelPtr[0],
+ pixelPtr[greenOffset], pixelPtr[blueOffset]);
+ Tcl_DStringAppend(&line, colorBuf, -1);
+ break;
+ case COLORFORMAT_RGBA2:
+ sprintf(colorBuf, "#%02x%02x%02x%02x ",
+ pixelPtr[0], pixelPtr[greenOffset],
+ pixelPtr[blueOffset], alphaVal);
+ Tcl_DStringAppend(&line, colorBuf, -1);
+ break;
+ case COLORFORMAT_LIST:
+ Tcl_DStringStartSublist(&line);
+ sprintf(colorBuf, "%d", pixelPtr[0]);
+ Tcl_DStringAppendElement(&line, colorBuf);
+ sprintf(colorBuf, "%d", pixelPtr[greenOffset]);
+ Tcl_DStringAppendElement(&line, colorBuf);
+ sprintf(colorBuf, "%d", pixelPtr[blueOffset]);
+ Tcl_DStringAppendElement(&line, colorBuf);
+ sprintf(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), -1);
+ 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;
+ TkSizeT charCount;
+
+ /*
+ * Find out which color format we have
+ */
+
+ specString = TkGetStringFromObj(specObj, &charCount);
+
+ if (charCount == 0) {
+ /* Empty string */
+ *redPtr = *greenPtr = *bluePtr = *alphaPtr = 0;
+ return TCL_OK;
+ }
+ if (charCount > TK_PHOTO_MAX_COLOR_CHARS) {
+ 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, charCount, display,
+ colormap, redPtr, greenPtr, bluePtr, alphaPtr);
+ }
+ if (ParseColorAsList(interp, specString, charCount,
+ 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, charCount, 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:
+ * Does *not* leave error messages in interp. The reason is that
+ * it is not always possible to tell if the list format was even
+ * intended and thus it is hard to return meaningful messages.
+ * A general error message from the caller is probably the best
+ * alternative.
+ *
+ *----------------------------------------------------------------------
+ */
+static int
+ParseColorAsList(
+ Tcl_Interp *dummy, /* not used */
+ const char *colorString, /* the color data to parse */
+ int colorStrLen, /* length of the color string */
+ unsigned char *redPtr, /* the result is written to these pointers */
+ 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;
+ (void)dummy;
+ (void)colorStrLen;
+
+ curPos = colorString;
+ i = 0;
+
+ /*
+ * strtol can give false positives with a sequence of space chars.
+ * To avoid that, avance 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_CHARS + 1];
+ char *tmpString;
+ double fracAlpha;
+ unsigned int suffixAlpha;
+ 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 '@':
+ fracAlpha = strtod(suffixString + 1, &tmpString);
+ if (*tmpString != '\0') {
+ 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 07b4f8b..0e0e59c 100644
--- a/generic/tkImgPNG.c
+++ b/generic/tkImgPNG.c
@@ -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. */
+ TkSizeT strDataLen; /* Length of source data. */
unsigned char *base64Data; /* base64 encoded string data. */
unsigned char base64Bits; /* Remaining bits from last base64 read. */
unsigned char base64State; /* Current state of base64 decoder. */
@@ -214,16 +214,16 @@ 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, size_t destSz,
unsigned long *crcPtr);
static int ReadByteArray(Tcl_Interp *interp, PNGImage *pngPtr,
- unsigned char *destPtr, int destSz,
+ unsigned char *destPtr, size_t destSz,
unsigned long *crcPtr);
static int ReadData(Tcl_Interp *interp, PNGImage *pngPtr,
- unsigned char *destPtr, int destSz,
+ unsigned char *destPtr, size_t destSz,
unsigned long *crcPtr);
static int ReadChunkHeader(Tcl_Interp *interp, PNGImage *pngPtr,
- int *sizePtr, unsigned long *typePtr,
+ size_t *sizePtr, unsigned long *typePtr,
unsigned long *crcPtr);
static int ReadIDAT(Tcl_Interp *interp, PNGImage *pngPtr,
int chunkSz, unsigned long crc);
@@ -250,9 +250,9 @@ 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, size_t dataSize);
static int WriteData(Tcl_Interp *interp, PNGImage *pngPtr,
- const unsigned char *srcPtr, int srcSz,
+ const unsigned char *srcPtr, size_t srcSz,
unsigned long *crcPtr);
static int WriteExtraChunks(Tcl_Interp *interp,
PNGImage *pngPtr);
@@ -319,7 +319,7 @@ InitPNGImage(
Tcl_IncrRefCount(objPtr);
pngPtr->objDataPtr = objPtr;
pngPtr->strDataBuf =
- Tcl_GetByteArrayFromObj(objPtr, &pngPtr->strDataLen);
+ TkGetByteArrayFromObj(objPtr, &pngPtr->strDataLen);
}
/*
@@ -430,7 +430,7 @@ ReadBase64(
Tcl_Interp *interp,
PNGImage *pngPtr,
unsigned char *destPtr,
- int destSz,
+ size_t destSz,
unsigned long *crcPtr)
{
static const unsigned char from64[] = {
@@ -555,14 +555,14 @@ ReadByteArray(
Tcl_Interp *interp,
PNGImage *pngPtr,
unsigned char *destPtr,
- int destSz,
+ size_t destSz,
unsigned long *crcPtr)
{
/*
* Check to make sure the number of requested bytes are available.
*/
- if (pngPtr->strDataLen < destSz) {
+ if ((size_t)pngPtr->strDataLen < destSz) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"unexpected end of image data", -1));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "EARLY_END", NULL);
@@ -570,7 +570,7 @@ ReadByteArray(
}
while (destSz) {
- int blockSz = PNG_MIN(destSz, PNG_BLOCK_SZ);
+ size_t blockSz = PNG_MIN(destSz, PNG_BLOCK_SZ);
memcpy(destPtr, pngPtr->strDataBuf, blockSz);
@@ -613,7 +613,7 @@ ReadData(
Tcl_Interp *interp,
PNGImage *pngPtr,
unsigned char *destPtr,
- int destSz,
+ size_t destSz,
unsigned long *crcPtr)
{
if (pngPtr->base64Data) {
@@ -623,10 +623,10 @@ ReadData(
}
while (destSz) {
- int blockSz = PNG_MIN(destSz, PNG_BLOCK_SZ);
+ TkSizeT 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)));
@@ -858,7 +858,7 @@ static int
ReadChunkHeader(
Tcl_Interp *interp,
PNGImage *pngPtr,
- int *sizePtr,
+ size_t *sizePtr,
unsigned long *typePtr,
unsigned long *crcPtr)
{
@@ -1239,7 +1239,7 @@ ReadIHDR(
{
unsigned char sigBuf[PNG_SIG_SZ];
unsigned long chunkType;
- int chunkSz;
+ size_t chunkSz;
unsigned long crc;
unsigned long width, height;
int mismatch;
@@ -1263,7 +1263,7 @@ ReadIHDR(
*/
if (mismatch && pngPtr->strDataBuf) {
- pngPtr->strDataBuf = Tcl_GetByteArrayFromObj(pngPtr->objDataPtr,
+ pngPtr->strDataBuf = TkGetByteArrayFromObj(pngPtr->objDataPtr,
&pngPtr->strDataLen);
pngPtr->base64Data = pngPtr->strDataBuf;
@@ -2097,7 +2097,7 @@ ReadIDAT(
*/
while (chunkSz && !Tcl_ZlibStreamEof(pngPtr->stream)) {
- int len1, len2;
+ TkSizeT len1, len2;
/*
* Read another block of input into the zlib stream if data remains.
@@ -2146,14 +2146,14 @@ ReadIDAT(
*/
getNextLine:
- Tcl_GetByteArrayFromObj(pngPtr->thisLineObj, &len1);
+ TkGetByteArrayFromObj(pngPtr->thisLineObj, &len1);
if (Tcl_ZlibStreamGet(pngPtr->stream, pngPtr->thisLineObj,
pngPtr->phaseSize - len1) == TCL_ERROR) {
return TCL_ERROR;
}
- Tcl_GetByteArrayFromObj(pngPtr->thisLineObj, &len2);
+ TkGetByteArrayFromObj(pngPtr->thisLineObj, &len2);
- if (len2 == pngPtr->phaseSize) {
+ if (len2 == (TkSizeT)pngPtr->phaseSize) {
if (pngPtr->phase > 7) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"extra data after final scan line of final phase",
@@ -2237,14 +2237,14 @@ ApplyAlpha(
PNGImage *pngPtr)
{
if (pngPtr->alpha != 1.0) {
- register unsigned char *p = pngPtr->block.pixelPtr;
+ unsigned char *p = pngPtr->block.pixelPtr;
unsigned char *endPtr = p + pngPtr->blockLen;
int offset = pngPtr->block.offset[3];
p += offset;
if (16 == pngPtr->bitDepth) {
- register unsigned int channel;
+ unsigned int channel;
while (p < endPtr) {
channel = (unsigned int)
@@ -2382,7 +2382,7 @@ DecodePNG(
int destY)
{
unsigned long chunkType;
- int chunkSz;
+ size_t chunkSz;
unsigned long crc;
/*
@@ -2520,7 +2520,7 @@ DecodePNG(
pngPtr->thisLineObj = Tcl_NewObj();
Tcl_IncrRefCount(pngPtr->thisLineObj);
- pngPtr->block.pixelPtr = attemptckalloc(pngPtr->blockLen);
+ pngPtr->block.pixelPtr = (unsigned char *)attemptckalloc(pngPtr->blockLen);
if (!pngPtr->block.pixelPtr) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"memory allocation failed", -1));
@@ -2676,6 +2676,8 @@ FileMatchPNG(
{
PNGImage png;
int match = 0;
+ (void)fileName;
+ (void)fmtObj;
InitPNGImage(NULL, &png, chan, NULL, TCL_ZLIB_STREAM_INFLATE);
@@ -2725,6 +2727,11 @@ FileReadPNG(
{
PNGImage png;
int result = TCL_ERROR;
+ (void)fileName;
+ (void)width;
+ (void)height;
+ (void)srcX;
+ (void)srcY;
result = InitPNGImage(interp, &png, chan, NULL, TCL_ZLIB_STREAM_INFLATE);
@@ -2764,10 +2771,11 @@ StringMatchPNG(
{
PNGImage png;
int match = 0;
+ (void)fmtObj;
InitPNGImage(NULL, &png, NULL, pObjData, TCL_ZLIB_STREAM_INFLATE);
- png.strDataBuf = Tcl_GetByteArrayFromObj(pObjData, &png.strDataLen);
+ png.strDataBuf = TkGetByteArrayFromObj(pObjData, &png.strDataLen);
if (ReadIHDR(interp, &png) == TCL_OK) {
*widthPtr = png.block.width;
@@ -2812,6 +2820,10 @@ StringReadPNG(
{
PNGImage png;
int result = TCL_ERROR;
+ (void)width;
+ (void)height;
+ (void)srcX;
+ (void)srcY;
result = InitPNGImage(interp, &png, NULL, pObjData,
TCL_ZLIB_STREAM_INFLATE);
@@ -2845,7 +2857,7 @@ WriteData(
Tcl_Interp *interp,
PNGImage *pngPtr,
const unsigned char *srcPtr,
- int srcSz,
+ size_t srcSz,
unsigned long *crcPtr)
{
if (!srcPtr || !srcSz) {
@@ -2862,12 +2874,12 @@ WriteData(
*/
if (pngPtr->objDataPtr) {
- int objSz;
+ TkSizeT objSz;
unsigned char *destPtr;
- Tcl_GetByteArrayFromObj(pngPtr->objDataPtr, &objSz);
+ TkGetByteArrayFromObj(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));
Tcl_SetErrorCode(interp, "TK", "IMAGE", "PNG", "TOO_LARGE", NULL);
@@ -2884,7 +2896,7 @@ WriteData(
}
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;
@@ -2960,7 +2972,7 @@ WriteChunk(
PNGImage *pngPtr,
unsigned long chunkType,
const unsigned char *dataPtr,
- int dataSize)
+ size_t dataSize)
{
unsigned long crc = Tcl_ZlibCRC32(0, NULL, 0);
int result = TCL_OK;
@@ -3131,9 +3143,10 @@ WriteIDAT(
PNGImage *pngPtr,
Tk_PhotoImageBlock *blockPtr)
{
- int rowNum, flush = TCL_ZLIB_NO_FLUSH, outputSize, result;
+ int rowNum, flush = TCL_ZLIB_NO_FLUSH, result;
Tcl_Obj *outputObj;
unsigned char *outputBytes;
+ TkSizeT outputSize;
/*
* Filter and compress each row one at a time.
@@ -3225,7 +3238,7 @@ WriteIDAT(
outputObj = Tcl_NewObj();
(void) Tcl_ZlibStreamGet(pngPtr->stream, outputObj, -1);
- outputBytes = Tcl_GetByteArrayFromObj(outputObj, &outputSize);
+ outputBytes = TkGetByteArrayFromObj(outputObj, &outputSize);
result = WriteChunk(interp, pngPtr, CHUNK_IDAT, outputBytes, outputSize);
Tcl_DecrRefCount(outputObj);
return result;
@@ -3458,6 +3471,7 @@ FileWritePNG(
Tcl_Channel chan;
PNGImage png;
int result = TCL_ERROR;
+ (void)fmtObj;
/*
* Open a Tcl file channel where the image data will be stored. Tk ought
@@ -3528,6 +3542,7 @@ StringWritePNG(
Tcl_Obj *resultObj = Tcl_NewObj();
PNGImage png;
int result = TCL_ERROR;
+ (void)fmtObj;
/*
* Initalize PNGImage instance for encoding.
diff --git a/generic/tkImgPPM.c b/generic/tkImgPPM.c
index fed1ca7..4a771ed 100644
--- a/generic/tkImgPPM.c
+++ b/generic/tkImgPPM.c
@@ -141,7 +141,8 @@ FileReadPPM(
* image being read. */
{
int fileWidth, fileHeight, maxIntensity;
- int nLines, nBytes, h, type, count, bytesPerChannel = 1;
+ int nLines, h, type, bytesPerChannel = 1;
+ size_t nBytes, count;
unsigned char *pixelPtr;
Tk_PhotoImageBlock block;
@@ -285,7 +286,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];
@@ -315,16 +317,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;
@@ -761,10 +763,11 @@ ReadPPMStringHeader(
{
#define BUFFER_SIZE 1000
char buffer[BUFFER_SIZE], c;
- int i, numFields, dataSize, type = 0;
+ int i, numFields, type = 0;
+ TkSizeT dataSize;
unsigned char *dataBuffer;
- dataBuffer = Tcl_GetByteArrayFromObj(dataPtr, &dataSize);
+ dataBuffer = TkGetByteArrayFromObj(dataPtr, &dataSize);
/*
* Read 4 space-separated fields from the string, ignoring comments (any
diff --git a/generic/tkImgPhInstance.c b/generic/tkImgPhInstance.c
index a40ee7f..11dc251 100644
--- a/generic/tkImgPhInstance.c
+++ b/generic/tkImgPhInstance.c
@@ -24,8 +24,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
@@ -77,7 +84,7 @@ void
TkImgPhotoConfigureInstance(
PhotoInstance *instancePtr) /* Instance to reconfigure. */
{
- PhotoModel *modelPtr = instancePtr->masterPtr;
+ PhotoModel *modelPtr = instancePtr->modelPtr;
XImage *imagePtr;
int bitsPerPixel;
ColorTable *colorTablePtr;
@@ -113,7 +120,7 @@ TkImgPhotoConfigureInstance(
*/
if (colorTablePtr != NULL) {
- colorTablePtr->liveRefCount -= 1;
+ colorTablePtr->liveRefCount--;
FreeColorTable(colorTablePtr, 0);
}
GetColorTable(instancePtr);
@@ -210,7 +217,7 @@ TkImgPhotoGet(
ClientData 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;
@@ -276,8 +283,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);
@@ -373,7 +380,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);
}
@@ -435,7 +442,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
@@ -492,7 +499,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];
@@ -535,7 +542,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];
@@ -606,7 +613,7 @@ TkImgPhotoDisplay(
int drawableX,int drawableY)/* Coordinates within drawable that correspond
* to imageX and imageY. */
{
- PhotoInstance *instancePtr = clientData;
+ PhotoInstance *instancePtr = (PhotoInstance *)clientData;
#ifndef TKPUTIMAGE_CAN_BLEND
XVisualInfo visInfo = instancePtr->visualInfo;
#endif
@@ -626,7 +633,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,
@@ -638,7 +645,7 @@ TkImgPhotoDisplay(
XDestroyImage(photo);
#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;
@@ -686,7 +693,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,
@@ -724,8 +731,9 @@ TkImgPhotoFree(
Display *display) /* Display containing window that used
* image. */
{
- PhotoInstance *instancePtr = clientData;
+ PhotoInstance *instancePtr = (PhotoInstance *)clientData;
ColorTable *colorPtr;
+ (void)display;
if (instancePtr->refCount-- > 1) {
return;
@@ -740,7 +748,7 @@ TkImgPhotoFree(
colorPtr = instancePtr->colorTablePtr;
if (colorPtr != NULL) {
- colorPtr->liveRefCount -= 1;
+ colorPtr->liveRefCount--;
}
Tcl_DoWhenIdle(TkImgDisposeInstance, instancePtr);
@@ -774,7 +782,7 @@ TkImgPhotoInstanceSetSize(
XRectangle validBox;
Pixmap newPixmap;
- modelPtr = instancePtr->masterPtr;
+ modelPtr = instancePtr->modelPtr;
TkClipBox(modelPtr->validRegion, &validBox);
if ((instancePtr->width != modelPtr->width)
@@ -824,7 +832,7 @@ TkImgPhotoInstanceSetSize(
* such possibility.
*/
- newError = ckalloc(modelPtr->height * modelPtr->width
+ newError = (schar *)ckalloc(modelPtr->height * modelPtr->width
* 3 * sizeof(schar));
/*
@@ -862,8 +870,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 +
@@ -1053,13 +1061,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
@@ -1123,8 +1131,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;
}
@@ -1221,7 +1228,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) {
@@ -1241,7 +1248,7 @@ AllocateColors(
*/
numColors = (mono) ? nRed: (nRed * nGreen * nBlue);
- colors = ckalloc(numColors * sizeof(XColor));
+ colors = (XColor *)ckalloc(numColors * sizeof(XColor));
if (!mono) {
/*
@@ -1285,7 +1292,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])) {
@@ -1445,7 +1452,7 @@ DisposeColorTable(
ClientData clientData) /* Pointer to the ColorTable whose
* colors are to be released. */
{
- ColorTable *colorPtr = clientData;
+ ColorTable *colorPtr = (ColorTable *)clientData;
Tcl_HashEntry *entry;
if (colorPtr->pixelMap != NULL) {
@@ -1457,7 +1464,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");
}
@@ -1505,7 +1512,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)
@@ -1534,7 +1541,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)
@@ -1579,7 +1586,7 @@ TkImgDisposeInstance(
ClientData clientData) /* Pointer to the instance whose resources are
* to be released. */
{
- PhotoInstance *instancePtr = clientData;
+ PhotoInstance *instancePtr = (PhotoInstance *)clientData;
PhotoInstance *prevPtr;
if (instancePtr->pixels != None) {
@@ -1598,10 +1605,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. */
}
@@ -1635,7 +1642,7 @@ 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;
@@ -1689,7 +1696,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;
@@ -1978,8 +1985,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 8f5295f..51083e6 100644
--- a/generic/tkImgPhoto.c
+++ b/generic/tkImgPhoto.c
@@ -48,6 +48,7 @@ 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.
@@ -56,18 +57,21 @@ struct SubcommandOptions {
* 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_SHRINK 0x40
+#define OPT_SUBSAMPLE 0x80
+#define OPT_TO 0x100
+#define OPT_WITHALPHA 0x200
+#define OPT_ZOOM 0x400
/*
* List of option names. The order here must match the order of declarations
@@ -75,6 +79,7 @@ struct SubcommandOptions {
*/
static const char *const optionNames[] = {
+ "-alpha",
"-background",
"-compositingrule",
"-format",
@@ -83,6 +88,7 @@ static const char *const optionNames[] = {
"-shrink",
"-subsample",
"-to",
+ "-withalpha",
"-zoom",
NULL
};
@@ -129,9 +135,11 @@ 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
int initialized; /* Set to 1 if we've initialized the
* structure. */
} ThreadSpecificData;
@@ -152,15 +160,15 @@ static Tcl_ThreadDataKey dataKey;
static const Tk_ConfigSpec configSpecs[] = {
{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_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_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}
};
@@ -182,9 +190,6 @@ static int ImgPhotoConfigureModel(Tcl_Interp *interp,
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);
@@ -222,11 +227,13 @@ PhotoFormatThreadExitProc(
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;
@@ -254,6 +261,7 @@ PhotoFormatThreadExitProc(
*----------------------------------------------------------------------
*/
+#if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
void
Tk_CreateOldPhotoImageFormat(
const Tk_PhotoImageFormat *formatPtr)
@@ -274,6 +282,7 @@ Tk_CreateOldPhotoImageFormat(
copyPtr->nextPtr = tsdPtr->oldFormatList;
tsdPtr->oldFormatList = copyPtr;
}
+#endif
void
Tk_CreatePhotoImageFormat(
@@ -292,10 +301,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);
@@ -331,7 +343,7 @@ ImgPhotoCreate(
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). */
- Tk_ImageModel model, /* Token for image, to be used by us in later
+ Tk_ImageModel model, /* Token for image, to be used by us in later
* callbacks. */
ClientData *clientDataPtr) /* Store manager's token for image here; it
* will be returned in later callbacks. */
@@ -344,7 +356,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);
@@ -401,15 +413,13 @@ ImgPhotoCmd(
PHOTO_WRITE
};
- PhotoModel *modelPtr = clientData;
- int result, index, x, y, width, height, dataWidth, dataHeight, listObjc;
+ PhotoModel *modelPtr = (PhotoModel *)clientData;
+ int result, index, x, y, width, height;
struct SubcommandOptions options;
- Tcl_Obj **listObjv, **srcObjv;
unsigned char *pixelPtr;
Tk_PhotoImageBlock block;
- Tk_Window tkwin;
Tk_PhotoImageFormat *imageFormat;
- size_t length;
+ TkSizeT length;
int imageWidth, imageHeight, matched, oldformat = 0;
Tcl_Channel chan;
Tk_PhotoHandle srcHandle;
@@ -447,8 +457,7 @@ ImgPhotoCmd(
Tcl_WrongNumArgs(interp, 2, objv, "option");
return TCL_ERROR;
}
- arg = Tcl_GetString(objv[2]);
- length = objv[2]->length;
+ arg = TkGetStringFromObj(objv[2], &length);
if (strncmp(arg,"-data", length) == 0) {
if (modelPtr->dataString) {
Tcl_SetObjResult(interp, modelPtr->dataString);
@@ -497,9 +506,8 @@ ImgPhotoCmd(
return TCL_OK;
} else if (objc == 3) {
- const char *arg = Tcl_GetString(objv[2]);
+ const char *arg = TkGetStringFromObj(objv[2], &length);
- length = objv[2]->length;
if (length > 1 && !strncmp(arg, "-data", length)) {
Tcl_AppendResult(interp, "-data {} {} {}", NULL);
if (modelPtr->dataString) {
@@ -660,7 +668,7 @@ ImgPhotoCmd(
return TCL_ERROR;
}
}
- Tk_ImageChanged(modelPtr->tkMaster, 0, 0, 0, 0,
+ Tk_ImageChanged(modelPtr->tkModel, 0, 0, 0, 0,
modelPtr->width, modelPtr->height);
if (options.background) {
Tk_FreeColor(options.background);
@@ -668,7 +676,8 @@ ImgPhotoCmd(
return result;
case PHOTO_DATA: {
- char *data;
+ char *data = NULL;
+ Tcl_Obj *freeObj = NULL;
/*
* photo data command - first parse and check any options given.
@@ -676,7 +685,7 @@ ImgPhotoCmd(
Tk_ImageStringWriteProc *stringWriteProc = NULL;
- index = 2;
+ index = 1;
memset(&options, 0, sizeof(options));
options.name = NULL;
options.format = NULL;
@@ -687,7 +696,7 @@ ImgPhotoCmd(
&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 ...?");
return TCL_ERROR;
}
@@ -709,50 +718,52 @@ ImgPhotoCmd(
options.fromX2 = modelPtr->width;
options.fromY2 = modelPtr->height;
}
+ if (!(options.options & OPT_FORMAT)) {
+ options.format = Tcl_NewStringObj("default", -1);
+ freeObj = options.format;
+ }
/*
* Search for an appropriate image string format handler.
*/
- if (options.options & OPT_FORMAT) {
- 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 (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;
- }
- }
- }
+ 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 (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);
- return TCL_ERROR;
+ }
+#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)) {
+ matched = 1;
+ if (imageFormat->stringWriteProc != NULL) {
+ stringWriteProc = imageFormat->stringWriteProc;
+ break;
+ }
+ }
}
- } else {
- stringWriteProc = ImgStringWrite;
+ }
+#endif
+ 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);
+ goto dataErrorExit;
}
/*
@@ -789,7 +800,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: {
@@ -797,12 +823,24 @@ ImgPhotoCmd(
* photo get command - first parse and check parameters.
*/
- Tcl_Obj *channels[3];
-
- if (objc != 4) {
- Tcl_WrongNumArgs(interp, 2, objv, "x y");
+ Tcl_Obj *channels[4];
+ int channelCount = 3;
+
+ 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;
@@ -822,21 +860,25 @@ 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));
+ channels[0] = Tcl_NewWideIntObj(pixelPtr[0]);
+ channels[1] = Tcl_NewWideIntObj(pixelPtr[1]);
+ channels[2] = Tcl_NewWideIntObj(pixelPtr[2]);
+ channels[3] = Tcl_NewWideIntObj(pixelPtr[3]);
+ Tcl_SetObjResult(interp, Tcl_NewListObj(channelCount, channels));
return TCL_OK;
}
- 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;
+ options.format = NULL;
if (ParseSubcommandOptions(&options, interp, OPT_TO|OPT_FORMAT,
&index, objc, objv) != TCL_OK) {
return TCL_ERROR;
@@ -846,174 +888,50 @@ 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, &imageFormat,
+ &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 (y < dataHeight || dataHeight == 0 || dataWidth == 0) {
- if (block.pixelPtr != NULL) {
- ckfree(block.pixelPtr);
- }
- if (y < dataHeight) {
- return TCL_ERROR;
+ 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);
}
- return TCL_OK;
+ data = (Tcl_Obj *) Tcl_GetString(data);
}
+ 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;
+ }
/*
- * 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;
@@ -1159,7 +1077,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);
}
@@ -1184,17 +1102,40 @@ ImgPhotoCmd(
switch ((enum transOptions) index) {
case PHOTO_TRANS_GET: {
- XRectangle testBox;
- TkRegion testRegion;
+ int boolMode;
- if (objc != 5) {
- Tcl_WrongNumArgs(interp, 3, objv, "x y");
+ /*
+ * 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",
+ 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(
@@ -1205,36 +1146,55 @@ ImgPhotoCmd(
return TCL_ERROR;
}
- testBox.x = x;
- testBox.y = y;
- testBox.width = 1;
- testBox.height = 1;
- /* What a way to do a test! */
- testRegion = TkCreateRegion();
- TkUnionRectWithRegion(&testBox, testRegion, testRegion);
- TkIntersectRegion(testRegion, modelPtr->validRegion, testRegion);
- TkClipBox(testRegion, &testBox);
- TkDestroyRegion(testRegion);
-
- Tcl_SetObjResult(interp, Tcl_NewBooleanObj(
- testBox.width==0 && testBox.height==0));
+ /*
+ * Extract and return the desired value
+ */
+ pixelPtr = modelPtr->pix32 + (y * modelPtr->width + x) * 4;
+ if (boolMode) {
+ Tcl_SetObjResult(interp, Tcl_NewBooleanObj( ! pixelPtr[3]));
+ } 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",
+ 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(
@@ -1245,45 +1205,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", 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;
@@ -1373,6 +1348,7 @@ ImgPhotoCmd(
}
}
}
+#if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
if (imageFormat == NULL) {
oldformat = 1;
for (imageFormat = tsdPtr->oldFormatList; imageFormat != NULL;
@@ -1387,6 +1363,7 @@ ImgPhotoCmd(
}
}
}
+#endif
if (usedExt && !matched) {
/*
* If we didn't find one and we're using file extensions as the
@@ -1478,13 +1455,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 and
+ * -withalpha.
+ * 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.
*
*----------------------------------------------------------------------
*/
@@ -1508,7 +1490,7 @@ ParseSubcommandOptions(
* TK_PHOTO_COMPOSITE_* constants. */
NULL
};
- size_t length;
+ TkSizeT length;
int index, c, bit, currentBit;
int values[4], numValues, maxValues, argIndex;
const char *option, *expandedOption, *needed;
@@ -1521,8 +1503,7 @@ ParseSubcommandOptions(
* optPtr->name.
*/
- expandedOption = option = Tcl_GetString(objv[index]);
- length = objv[index]->length;
+ expandedOption = option = TkGetStringFromObj(objv[index], &length);
if (option[0] != '-') {
if (optPtr->name == NULL) {
optPtr->name = objv[index];
@@ -1609,7 +1590,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;
@@ -1790,7 +1772,7 @@ ImgPhotoConfigureModel(
const char *oldFileString, *oldPaletteString;
Tcl_Obj *oldData, *data = NULL, *oldFormat, *format = NULL;
Tcl_Obj *tempdata, *tempformat;
- size_t length;
+ TkSizeT length;
int i, j, result, imageWidth, imageHeight, oldformat;
double oldGamma;
Tcl_Channel chan;
@@ -1799,8 +1781,7 @@ ImgPhotoConfigureModel(
args = (const char **)ckalloc((objc + 1) * sizeof(char *));
for (i = 0, j = 0; i < objc; i++,j++) {
- args[j] = Tcl_GetString(objv[i]);
- length = objv[i]->length;
+ args[j] = TkGetStringFromObj(objv[i], &length);
if ((length > 1) && (args[j][0] == '-')) {
if ((args[j][1] == 'd') &&
!strncmp(args[j], "-data", length)) {
@@ -1879,9 +1860,9 @@ ImgPhotoConfigureModel(
* Force into ByteArray format, which most (all) image handlers will
* use anyway. Empty length means ignore the -data option.
*/
- int bytesize;
+ TkSizeT bytesize;
- (void) Tcl_GetByteArrayFromObj(data, &bytesize);
+ (void) TkGetByteArrayFromObj(data, &bytesize);
if (bytesize) {
Tcl_IncrRefCount(data);
} else {
@@ -2045,7 +2026,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;
@@ -2148,7 +2129,7 @@ ImgPhotoDelete(
Tcl_CancelIdleCall(TkImgDisposeInstance, instancePtr);
TkImgDisposeInstance(instancePtr);
}
- modelPtr->tkMaster = NULL;
+ modelPtr->tkModel = NULL;
if (modelPtr->imageCmd != NULL) {
Tcl_DeleteCommandFromToken(modelPtr->interp, modelPtr->imageCmd);
}
@@ -2193,8 +2174,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));
}
}
@@ -2424,7 +2405,8 @@ MatchFileFormat(
* here. */
int *oldformat) /* Returns 1 if the old image API is used. */
{
- int matched = 0, useoldformat = 0;
+ int matched = 0;
+ int useoldformat = 0;
Tk_PhotoImageFormat *formatPtr;
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
@@ -2471,7 +2453,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) {
@@ -2505,6 +2488,7 @@ MatchFileFormat(
}
}
}
+#endif
if (formatPtr == NULL) {
if ((formatObj != NULL) && !matched) {
@@ -2565,7 +2549,7 @@ MatchStringFormat(
int *oldformat) /* Returns 1 if the old image API is used. */
{
int matched = 0, useoldformat = 0;
- Tk_PhotoImageFormat *formatPtr;
+ Tk_PhotoImageFormat *formatPtr, *defaultFormatPtr = NULL;
ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
const char *formatString = NULL;
@@ -2581,6 +2565,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) {
@@ -2596,6 +2590,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,
@@ -2604,6 +2608,7 @@ MatchStringFormat(
}
}
+#if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
if (formatPtr == NULL) {
useoldformat = 1;
for (formatPtr = tsdPtr->oldFormatList; formatPtr != NULL;
@@ -2633,23 +2638,56 @@ MatchStringFormat(
}
}
}
+#endif
+
if (formatPtr == NULL) {
- if ((formatObj != NULL) && !matched) {
+ /*
+ * 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, NULL);
+ return TCL_ERROR;
} else {
- Tcl_SetObjResult(interp, Tcl_NewStringObj(
- "couldn't recognize image data", -1));
- Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
- "UNRECOGNIZED_DATA", NULL);
+
+ /*
+ * Some lower level routine (stringMatchProc) may have already set
+ * a specific error message, so just return this. Otherwise return
+ * a generic image data error.
+ */
+
+ if (Tcl_GetString(Tcl_GetObjResult(interp))[0] == '\0') {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "couldn't recognize image data", -1));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "PHOTO",
+ "UNRECOGNIZED_DATA", NULL);
+ }
+ return TCL_ERROR;
}
- return TCL_ERROR;
}
*imageFormatPtr = formatPtr;
*oldformat = useoldformat;
+
+ /*
+ * Some stringMatchProc might have left error messages and error codes in
+ * interp. Clear them before return.
+ */
+ Tcl_ResetResult(interp);
return TCL_OK;
}
@@ -2681,7 +2719,7 @@ Tk_FindPhoto(
{
const Tk_ImageType *typePtr;
ClientData clientData =
- Tk_GetImageMasterData(interp, imageName, &typePtr);
+ Tk_GetImageModelData(interp, imageName, &typePtr);
if ((typePtr == NULL) || (typePtr->name != tkPhotoImageType.name)) {
return NULL;
@@ -3111,7 +3149,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);
@@ -3467,7 +3505,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);
@@ -3611,7 +3649,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);
}
@@ -3660,7 +3698,7 @@ Tk_PhotoExpand(
}
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;
@@ -3735,7 +3773,7 @@ Tk_PhotoSetSize(
}
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;
}
@@ -3965,57 +4003,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
@@ -4103,7 +4090,7 @@ ImgPhotoPostscript(
*
*----------------------------------------------------------------------
*/
-
+#if !defined(TK_NO_DEPRECATED) && TCL_MAJOR_VERSION < 9
void
Tk_PhotoPutBlock_NoComposite(
Tk_PhotoHandle handle,
@@ -4189,6 +4176,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..e65893f 100644
--- a/generic/tkImgPhoto.h
+++ b/generic/tkImgPhoto.h
@@ -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
@@ -94,10 +94,17 @@ 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. */
+#else
int flags; /* See below. */
- int refCount; /* Number of instances using this map. */
- int liveRefCount; /* Number of instances which are actually in
+ 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
@@ -141,8 +148,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. */
@@ -169,7 +176,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 +203,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
diff --git a/generic/tkImgSVGnano.c b/generic/tkImgSVGnano.c
new file mode 100644
index 0000000..c18b181
--- /dev/null
+++ b/generic/tkImgSVGnano.c
@@ -0,0 +1,810 @@
+/*
+ * tkImgSVGnano.c
+ *
+ * A photo file handler for SVG files.
+ *
+ * Copyright (c) 2013-14 Mikko Mononen memon@inside.org
+ * Copyright (c) 2018 Christian Gollwitzer auriocus@gmx.de
+ * Copyright (c) 2018 Christian Werner https://www.androwish.org/
+ * Copyright (c) 2018 Rene Zaumseil r.zaumseil@freenet.de
+ *
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ *
+ * This handler is build using the original nanosvg library files from
+ * https://github.com/memononen/nanosvg
+ *
+ */
+
+#include "tkInt.h"
+#define NANOSVG_malloc ckalloc
+#define NANOSVG_realloc ckrealloc
+#define NANOSVG_free ckfree
+#define NANOSVG_SCOPE MODULE_SCOPE
+#define NANOSVG_ALL_COLOR_KEYWORDS
+#define NANOSVG_IMPLEMENTATION
+#include "nanosvg.h"
+#define NANOSVGRAST_IMPLEMENTATION
+#include "nanosvgrast.h"
+
+/* Additional parameters to nsvgRasterize() */
+
+typedef struct {
+ double scale;
+ int scaleToHeight;
+ int scaleToWidth;
+} RastOpts;
+
+/*
+ * Per interp cache of last NSVGimage which was matched to
+ * be immediately rasterized after the match. This helps to
+ * eliminate double parsing of the SVG file/string.
+ */
+
+typedef struct {
+ /* A poiner to remember if it is the same svn image (data)
+ * It is a Tcl_Channel if image created by -file option
+ * or a Tcl_Obj, if image is created with the -data option
+ */
+ ClientData dataOrChan;
+ Tcl_DString formatString;
+ NSVGimage *nsvgImage;
+ RastOpts ropts;
+} NSVGcache;
+
+static int FileMatchSVG(Tcl_Channel chan, const char *fileName,
+ Tcl_Obj *format, int *widthPtr, int *heightPtr,
+ Tcl_Interp *interp);
+static int FileReadSVG(Tcl_Interp *interp, Tcl_Channel chan,
+ const char *fileName, Tcl_Obj *format,
+ Tk_PhotoHandle imageHandle, int destX, int destY,
+ int width, int height, int srcX, int srcY);
+static int StringMatchSVG(Tcl_Obj *dataObj, Tcl_Obj *format,
+ int *widthPtr, int *heightPtr, Tcl_Interp *interp);
+static int StringReadSVG(Tcl_Interp *interp, Tcl_Obj *dataObj,
+ Tcl_Obj *format, Tk_PhotoHandle imageHandle,
+ int destX, int destY, int width, int height,
+ int srcX, int srcY);
+static NSVGimage * ParseSVGWithOptions(Tcl_Interp *interp,
+ const char *input, TkSizeT length, Tcl_Obj *format,
+ RastOpts *ropts);
+static int RasterizeSVG(Tcl_Interp *interp,
+ Tk_PhotoHandle imageHandle, NSVGimage *nsvgImage,
+ int destX, int destY, int width, int height,
+ int srcX, int srcY, RastOpts *ropts);
+static double GetScaleFromParameters(NSVGimage *nsvgImage,
+ RastOpts *ropts, int *widthPtr, int *heightPtr);
+static NSVGcache * GetCachePtr(Tcl_Interp *interp);
+static int CacheSVG(Tcl_Interp *interp, ClientData dataOrChan,
+ Tcl_Obj *formatObj, NSVGimage *nsvgImage,
+ RastOpts *ropts);
+static NSVGimage * GetCachedSVG(Tcl_Interp *interp, ClientData dataOrChan,
+ Tcl_Obj *formatObj, RastOpts *ropts);
+static void CleanCache(Tcl_Interp *interp);
+static void FreeCache(ClientData clientData, Tcl_Interp *interp);
+
+/*
+ * The format record for the SVG nano file format:
+ */
+
+Tk_PhotoImageFormat tkImgFmtSVGnano = {
+ "svg", /* name */
+ FileMatchSVG, /* fileMatchProc */
+ StringMatchSVG, /* stringMatchProc */
+ FileReadSVG, /* fileReadProc */
+ StringReadSVG, /* stringReadProc */
+ NULL, /* fileWriteProc */
+ NULL, /* stringWriteProc */
+ NULL
+};
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * FileMatchSVG --
+ *
+ * This function is invoked by the photo image type to see if a file
+ * contains image data in SVG format.
+ *
+ * Results:
+ * The return value is >0 if the file can be successfully parsed,
+ * and 0 otherwise.
+ *
+ * Side effects:
+ * The file is saved in the internal cache for further use.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+FileMatchSVG(
+ Tcl_Channel chan,
+ const char *fileName,
+ Tcl_Obj *formatObj,
+ int *widthPtr, int *heightPtr,
+ Tcl_Interp *interp)
+{
+ TkSizeT length;
+ Tcl_Obj *dataObj = Tcl_NewObj();
+ const char *data;
+ RastOpts ropts;
+ NSVGimage *nsvgImage;
+ (void)fileName;
+
+ CleanCache(interp);
+ if (Tcl_ReadChars(chan, dataObj, -1, 0) == TCL_IO_FAILURE) {
+ /* in case of an error reading the file */
+ Tcl_DecrRefCount(dataObj);
+ return 0;
+ }
+ data = TkGetStringFromObj(dataObj, &length);
+ nsvgImage = ParseSVGWithOptions(interp, data, length, formatObj, &ropts);
+ Tcl_DecrRefCount(dataObj);
+ if (nsvgImage != NULL) {
+ GetScaleFromParameters(nsvgImage, &ropts, widthPtr, heightPtr);
+ if ((*widthPtr <= 0.0) || (*heightPtr <= 0.0)) {
+ nsvgDelete(nsvgImage);
+ return 0;
+ }
+ if (!CacheSVG(interp, chan, formatObj, nsvgImage, &ropts)) {
+ nsvgDelete(nsvgImage);
+ }
+ return 1;
+ }
+ return 0;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * FileReadSVG --
+ *
+ * This function is called by the photo image type to read SVG format
+ * data from a file and write it into a given photo image.
+ *
+ * Results:
+ * A standard TCL completion code. If TCL_ERROR is returned then an error
+ * message is left in the interp's result.
+ *
+ * Side effects:
+ * The access position in file f is changed, and new data is added to the
+ * image given by imageHandle.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+FileReadSVG(
+ Tcl_Interp *interp,
+ Tcl_Channel chan,
+ const char *fileName,
+ Tcl_Obj *formatObj,
+ Tk_PhotoHandle imageHandle,
+ int destX, int destY,
+ int width, int height,
+ int srcX, int srcY)
+{
+ TkSizeT length;
+ const char *data;
+ RastOpts ropts;
+ NSVGimage *nsvgImage = GetCachedSVG(interp, chan, formatObj, &ropts);
+ (void)fileName;
+
+ if (nsvgImage == NULL) {
+ Tcl_Obj *dataObj = Tcl_NewObj();
+
+ if (Tcl_ReadChars(chan, dataObj, -1, 0) == TCL_IO_FAILURE) {
+ /* in case of an error reading the file */
+ Tcl_DecrRefCount(dataObj);
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("read error", -1));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "READ_ERROR", NULL);
+ return TCL_ERROR;
+ }
+ data = TkGetStringFromObj(dataObj, &length);
+ nsvgImage = ParseSVGWithOptions(interp, data, length, formatObj,
+ &ropts);
+ Tcl_DecrRefCount(dataObj);
+ if (nsvgImage == NULL) {
+ return TCL_ERROR;
+ }
+ }
+ return RasterizeSVG(interp, imageHandle, nsvgImage, destX, destY,
+ width, height, srcX, srcY, &ropts);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * StringMatchSVG --
+ *
+ * This function is invoked by the photo image type to see if a string
+ * contains image data in SVG format.
+ *
+ * Results:
+ * The return value is >0 if the file can be successfully parsed,
+ * and 0 otherwise.
+ *
+ * Side effects:
+ * The file is saved in the internal cache for further use.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+StringMatchSVG(
+ Tcl_Obj *dataObj,
+ Tcl_Obj *formatObj,
+ int *widthPtr, int *heightPtr,
+ Tcl_Interp *interp)
+{
+ TkSizeT length;
+ const char *data;
+ RastOpts ropts;
+ NSVGimage *nsvgImage;
+
+ CleanCache(interp);
+ data = TkGetStringFromObj(dataObj, &length);
+ nsvgImage = ParseSVGWithOptions(interp, data, length, formatObj, &ropts);
+ if (nsvgImage != NULL) {
+ GetScaleFromParameters(nsvgImage, &ropts, widthPtr, heightPtr);
+ if ((*widthPtr <= 0.0) || (*heightPtr <= 0.0)) {
+ nsvgDelete(nsvgImage);
+ return 0;
+ }
+ if (!CacheSVG(interp, dataObj, formatObj, nsvgImage, &ropts)) {
+ nsvgDelete(nsvgImage);
+ }
+ return 1;
+ }
+ return 0;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * StringReadSVG --
+ *
+ * This function is called by the photo image type to read SVG format
+ * data from a string and write it into a given photo image.
+ *
+ * Results:
+ * A standard TCL completion code. If TCL_ERROR is returned then an error
+ * message is left in the interp's result.
+ *
+ * Side effects:
+ * New data is added to the image given by imageHandle.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+StringReadSVG(
+ Tcl_Interp *interp,
+ Tcl_Obj *dataObj,
+ Tcl_Obj *formatObj,
+ Tk_PhotoHandle imageHandle,
+ int destX, int destY,
+ int width, int height,
+ int srcX, int srcY)
+{
+ TkSizeT length;
+ const char *data;
+ RastOpts ropts;
+ NSVGimage *nsvgImage = GetCachedSVG(interp, dataObj, formatObj, &ropts);
+
+ if (nsvgImage == NULL) {
+ data = TkGetStringFromObj(dataObj, &length);
+ nsvgImage = ParseSVGWithOptions(interp, data, length, formatObj,
+ &ropts);
+ }
+ if (nsvgImage == NULL) {
+ return TCL_ERROR;
+ }
+ return RasterizeSVG(interp, imageHandle, nsvgImage, destX, destY,
+ width, height, srcX, srcY, &ropts);
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * ParseSVGWithOptions --
+ *
+ * This function is called to parse the given input string as SVG.
+ *
+ * Results:
+ * Return a newly create NSVGimage on success, and NULL otherwise.
+ *
+ * Side effects:
+ *
+ *----------------------------------------------------------------------
+ */
+
+static NSVGimage *
+ParseSVGWithOptions(
+ Tcl_Interp *interp,
+ const char *input,
+ TkSizeT length,
+ Tcl_Obj *formatObj,
+ RastOpts *ropts)
+{
+ Tcl_Obj **objv = NULL;
+ int objc = 0;
+ double dpi = 96.0;
+ char *inputCopy = NULL;
+ NSVGimage *nsvgImage;
+ int parameterScaleSeen = 0;
+ static const char *const fmtOptions[] = {
+ "-dpi", "-scale", "-scaletoheight", "-scaletowidth", NULL
+ };
+ enum fmtOptions {
+ OPT_DPI, OPT_SCALE, OPT_SCALE_TO_HEIGHT, OPT_SCALE_TO_WIDTH
+ };
+
+ /*
+ * The parser destroys the original input string,
+ * therefore first duplicate.
+ */
+
+ inputCopy = (char *)attemptckalloc(length+1);
+ if (inputCopy == NULL) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("cannot alloc data buffer", -1));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "OUT_OF_MEMORY", NULL);
+ goto error;
+ }
+ memcpy(inputCopy, input, length);
+ inputCopy[length] = '\0';
+
+ /*
+ * Process elements of format specification as a list.
+ */
+
+ ropts->scale = 1.0;
+ ropts->scaleToHeight = 0;
+ ropts->scaleToWidth = 0;
+ if ((formatObj != NULL) &&
+ Tcl_ListObjGetElements(interp, formatObj, &objc, &objv) != TCL_OK) {
+ goto error;
+ }
+ for (; objc > 0 ; objc--, objv++) {
+ int optIndex;
+
+ /*
+ * Ignore the "svg" part of the format specification.
+ */
+
+ if (!strcasecmp(Tcl_GetString(objv[0]), "svg")) {
+ continue;
+ }
+
+ if (Tcl_GetIndexFromObjStruct(interp, objv[0], fmtOptions,
+ sizeof(char *), "option", 0, &optIndex) == TCL_ERROR) {
+ goto error;
+ }
+
+ if (objc < 2) {
+ ckfree(inputCopy);
+ inputCopy = NULL;
+ Tcl_WrongNumArgs(interp, 1, objv, "value");
+ goto error;
+ }
+
+ objc--;
+ objv++;
+
+ /*
+ * check that only one scale option is given
+ */
+ switch ((enum fmtOptions) optIndex) {
+ case OPT_SCALE:
+ case OPT_SCALE_TO_HEIGHT:
+ case OPT_SCALE_TO_WIDTH:
+ if ( parameterScaleSeen ) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "only one of -scale, -scaletoheight, -scaletowidth may be given", -1));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "BAD_SCALE",
+ NULL);
+ goto error;
+ }
+ parameterScaleSeen = 1;
+ break;
+ default:
+ break;
+ }
+
+ /*
+ * Decode parameters
+ */
+ switch ((enum fmtOptions) optIndex) {
+ case OPT_DPI:
+ if (Tcl_GetDoubleFromObj(interp, objv[0], &dpi) == TCL_ERROR) {
+ goto error;
+ }
+ if (dpi < 0.0) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "-dpi value must be positive", -1));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "BAD_DPI",
+ NULL);
+ goto error;
+ }
+ break;
+ case OPT_SCALE:
+ if (Tcl_GetDoubleFromObj(interp, objv[0], &ropts->scale) ==
+ TCL_ERROR) {
+ goto error;
+ }
+ if (ropts->scale <= 0.0) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "-scale value must be positive", -1));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "BAD_SCALE",
+ NULL);
+ goto error;
+ }
+ break;
+ case OPT_SCALE_TO_HEIGHT:
+ if (Tcl_GetIntFromObj(interp, objv[0], &ropts->scaleToHeight) ==
+ TCL_ERROR) {
+ goto error;
+ }
+ if (ropts->scaleToHeight <= 0) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "-scaletoheight value must be positive", -1));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "BAD_SCALE",
+ NULL);
+ goto error;
+ }
+ break;
+ case OPT_SCALE_TO_WIDTH:
+ if (Tcl_GetIntFromObj(interp, objv[0], &ropts->scaleToWidth) ==
+ TCL_ERROR) {
+ goto error;
+ }
+ if (ropts->scaleToWidth <= 0) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj(
+ "-scaletowidth value must be positive", -1));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "BAD_SCALE",
+ NULL);
+ goto error;
+ }
+ break;
+ }
+ }
+
+ nsvgImage = nsvgParse(inputCopy, "px", (float) dpi);
+ if (nsvgImage == NULL) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("cannot parse SVG image", -1));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "PARSE_ERROR", NULL);
+ goto error;
+ }
+ ckfree(inputCopy);
+ return nsvgImage;
+
+error:
+ if (inputCopy != NULL) {
+ ckfree(inputCopy);
+ }
+ return NULL;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * RasterizeSVG --
+ *
+ * This function is called to rasterize the given nsvgImage and
+ * fill the imageHandle with data.
+ *
+ * Results:
+ * A standard TCL completion code. If TCL_ERROR is returned then an error
+ * message is left in the interp's result.
+ *
+ *
+ * Side effects:
+ * On error the given nsvgImage will be deleted.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+RasterizeSVG(
+ Tcl_Interp *interp,
+ Tk_PhotoHandle imageHandle,
+ NSVGimage *nsvgImage,
+ int destX, int destY,
+ int width, int height,
+ int srcX, int srcY,
+ RastOpts *ropts)
+{
+ int w, h, c;
+ NSVGrasterizer *rast;
+ unsigned char *imgData;
+ Tk_PhotoImageBlock svgblock;
+ double scale;
+ (void)srcX;
+ (void)srcY;
+
+ scale = GetScaleFromParameters(nsvgImage, ropts, &w, &h);
+
+ rast = nsvgCreateRasterizer();
+ if (rast == NULL) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("cannot initialize rasterizer", -1));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "RASTERIZER_ERROR",
+ NULL);
+ goto cleanAST;
+ }
+ imgData = (unsigned char *)attemptckalloc(w * h *4);
+ if (imgData == NULL) {
+ Tcl_SetObjResult(interp, Tcl_NewStringObj("cannot alloc image buffer", -1));
+ Tcl_SetErrorCode(interp, "TK", "IMAGE", "SVG", "OUT_OF_MEMORY", NULL);
+ goto cleanRAST;
+ }
+ nsvgRasterize(rast, nsvgImage, 0, 0,
+ (float) scale, imgData, w, h, w * 4);
+ /* transfer the data to a photo block */
+ svgblock.pixelPtr = imgData;
+ svgblock.width = w;
+ svgblock.height = h;
+ svgblock.pitch = w * 4;
+ svgblock.pixelSize = 4;
+ for (c = 0; c <= 3; c++) {
+ svgblock.offset[c] = c;
+ }
+ if (Tk_PhotoExpand(interp, imageHandle,
+ destX + width, destY + height) != TCL_OK) {
+ goto cleanRAST;
+ }
+ if (Tk_PhotoPutBlock(interp, imageHandle, &svgblock, destX, destY,
+ width, height, TK_PHOTO_COMPOSITE_SET) != TCL_OK) {
+ goto cleanimg;
+ }
+ ckfree(imgData);
+ nsvgDeleteRasterizer(rast);
+ nsvgDelete(nsvgImage);
+ return TCL_OK;
+
+cleanimg:
+ ckfree(imgData);
+
+cleanRAST:
+ nsvgDeleteRasterizer(rast);
+
+cleanAST:
+ nsvgDelete(nsvgImage);
+ return TCL_ERROR;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GetScaleFromParameters --
+ *
+ * Get the scale value from the already parsed parameters -scale,
+ * -scaletoheight and -scaletowidth.
+ *
+ * The image width and height is also returned.
+ *
+ * Results:
+ * The evaluated or configured scale value, or 0.0 on failure
+ *
+ * Side effects:
+ * heightPtr and widthPtr are set to height and width of the image.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static double
+GetScaleFromParameters(
+ NSVGimage *nsvgImage,
+ RastOpts *ropts,
+ int *widthPtr,
+ int *heightPtr)
+{
+ double scale;
+ int width, height;
+
+ if ((nsvgImage->width == 0.0) || (nsvgImage->height == 0.0)) {
+ width = height = 0;
+ scale = 1.0;
+ } else if (ropts->scaleToHeight > 0) {
+ /*
+ * Fixed height
+ */
+ height = ropts->scaleToHeight;
+ scale = height / nsvgImage->height;
+ width = (int) ceil(nsvgImage->width * scale);
+ } else if (ropts->scaleToWidth > 0) {
+ /*
+ * Fixed width
+ */
+ width = ropts->scaleToWidth;
+ scale = width / nsvgImage->width;
+ height = (int) ceil(nsvgImage->height * scale);
+ } else {
+ /*
+ * Scale factor
+ */
+ scale = ropts->scale;
+ width = (int) ceil(nsvgImage->width * scale);
+ height = (int) ceil(nsvgImage->height * scale);
+ }
+
+ *heightPtr = height;
+ *widthPtr = width;
+ return scale;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GetCachePtr --
+ *
+ * This function is called to get the per interpreter used
+ * svg image cache.
+ *
+ * Results:
+ * Return a pointer to the used cache.
+ *
+ * Side effects:
+ * Initialize the cache on the first call.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static NSVGcache *
+GetCachePtr(
+ Tcl_Interp *interp
+) {
+ NSVGcache *cachePtr = (NSVGcache *)Tcl_GetAssocData(interp, "tksvgnano", NULL);
+ if (cachePtr == NULL) {
+ cachePtr = (NSVGcache *)ckalloc(sizeof(NSVGcache));
+ cachePtr->dataOrChan = NULL;
+ Tcl_DStringInit(&cachePtr->formatString);
+ cachePtr->nsvgImage = NULL;
+ Tcl_SetAssocData(interp, "tksvgnano", FreeCache, cachePtr);
+ }
+ return cachePtr;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * CacheSVG --
+ *
+ * Add the given svg image informations to the cache for further usage.
+ *
+ * Results:
+ * Return 1 on success, and 0 otherwise.
+ *
+ * Side effects:
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+CacheSVG(
+ Tcl_Interp *interp,
+ ClientData dataOrChan,
+ Tcl_Obj *formatObj,
+ NSVGimage *nsvgImage,
+ RastOpts *ropts)
+{
+ TkSizeT length;
+ const char *data;
+ NSVGcache *cachePtr = GetCachePtr(interp);
+
+ if (cachePtr != NULL) {
+ cachePtr->dataOrChan = dataOrChan;
+ if (formatObj != NULL) {
+ data = TkGetStringFromObj(formatObj, &length);
+ Tcl_DStringAppend(&cachePtr->formatString, data, length);
+ }
+ cachePtr->nsvgImage = nsvgImage;
+ cachePtr->ropts = *ropts;
+ return 1;
+ }
+ return 0;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * GetCachedSVG --
+ *
+ * Try to get the NSVGimage from the internal cache.
+ *
+ * Results:
+ * Return the found NSVGimage on success, and NULL otherwise.
+ *
+ * Side effects:
+ * Calls the CleanCache() function.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static NSVGimage *
+GetCachedSVG(
+ Tcl_Interp *interp,
+ ClientData dataOrChan,
+ Tcl_Obj *formatObj,
+ RastOpts *ropts)
+{
+ TkSizeT length;
+ const char *data;
+ NSVGcache *cachePtr = GetCachePtr(interp);
+ NSVGimage *nsvgImage = NULL;
+
+ if ((cachePtr != NULL) && (cachePtr->nsvgImage != NULL) &&
+ (cachePtr->dataOrChan == dataOrChan)) {
+ if (formatObj != NULL) {
+ data = TkGetStringFromObj(formatObj, &length);
+ if (strcmp(data, Tcl_DStringValue(&cachePtr->formatString)) == 0) {
+ nsvgImage = cachePtr->nsvgImage;
+ *ropts = cachePtr->ropts;
+ cachePtr->nsvgImage = NULL;
+ }
+ } else if (Tcl_DStringLength(&cachePtr->formatString) == 0) {
+ nsvgImage = cachePtr->nsvgImage;
+ *ropts = cachePtr->ropts;
+ cachePtr->nsvgImage = NULL;
+ }
+ }
+ CleanCache(interp);
+ return nsvgImage;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * CleanCache --
+ *
+ * Reset the cache and delete the saved image in it.
+ *
+ * Results:
+ *
+ * Side effects:
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+CleanCache(Tcl_Interp *interp)
+{
+ NSVGcache *cachePtr = GetCachePtr(interp);
+
+ if (cachePtr != NULL) {
+ cachePtr->dataOrChan = NULL;
+ Tcl_DStringSetLength(&cachePtr->formatString, 0);
+ if (cachePtr->nsvgImage != NULL) {
+ nsvgDelete(cachePtr->nsvgImage);
+ cachePtr->nsvgImage = NULL;
+ }
+ }
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * FreeCache --
+ *
+ * This function is called to clean up the internal cache data.
+ *
+ * Results:
+ *
+ * Side effects:
+ * Existing image data in the cache and the cache will be deleted.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static void
+FreeCache(ClientData clientData, Tcl_Interp *interp)
+{
+ NSVGcache *cachePtr = (NSVGcache *)clientData;
+ (void)interp;
+
+ Tcl_DStringFree(&cachePtr->formatString);
+ if (cachePtr->nsvgImage != NULL) {
+ nsvgDelete(cachePtr->nsvgImage);
+ }
+ ckfree(cachePtr);
+}
+
diff --git a/generic/tkImgUtil.c b/generic/tkImgUtil.c
index 5487165..6a43fbe 100644
--- a/generic/tkImgUtil.c
+++ b/generic/tkImgUtil.c
@@ -55,7 +55,7 @@ TkAlignImageData(
dataWidth += (alignment - (dataWidth % alignment));
}
- data = ckalloc(dataWidth * image->height);
+ data = (char *)ckalloc(dataWidth * image->height);
destPtr = data;
for (i = 0; i < image->height; i++) {
diff --git a/generic/tkInt.decls b/generic/tkInt.decls
index 2faf410..7886355 100644
--- a/generic/tkInt.decls
+++ b/generic/tkInt.decls
@@ -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)
@@ -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[])
@@ -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)
@@ -389,7 +389,7 @@ 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)
@@ -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)
@@ -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)
@@ -538,7 +538,7 @@ declare 162 {
int byteIndex, struct TkTextIndex *indexPtr)
}
declare 163 {
- int TkTextPrintIndex(const struct TkText *textPtr,
+ TkSizeT TkTextPrintIndex(const struct TkText *textPtr,
const struct TkTextIndex *indexPtr, char *string)
}
declare 164 {
@@ -567,51 +567,51 @@ 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)
+ Tk_Window tkwin, const char *value, char *widgRec, TkSizeT offset)
}
declare 170 {
- CONST86 char *TkStatePrintProc(ClientData clientData, Tk_Window tkwin,
- char *widgRec, int offset, Tcl_FreeProc **freeProcPtr)
+ const char *TkStatePrintProc(ClientData clientData, Tk_Window tkwin,
+ char *widgRec, TkSizeT offset, Tcl_FreeProc **freeProcPtr)
}
declare 171 {
int TkCanvasDashParseProc(ClientData clientData, Tcl_Interp *interp,
- Tk_Window tkwin, const char *value, char *widgRec, int offset)
+ Tk_Window tkwin, const char *value, char *widgRec, TkSizeT offset)
}
declare 172 {
- CONST86 char *TkCanvasDashPrintProc(ClientData clientData, Tk_Window tkwin,
- char *widgRec, int offset, Tcl_FreeProc **freeProcPtr)
+ const char *TkCanvasDashPrintProc(ClientData clientData, Tk_Window tkwin,
+ char *widgRec, TkSizeT offset, Tcl_FreeProc **freeProcPtr)
}
declare 173 {
int TkOffsetParseProc(ClientData clientData, Tcl_Interp *interp,
- Tk_Window tkwin, const char *value, char *widgRec, int offset)
+ Tk_Window tkwin, const char *value, char *widgRec, TkSizeT offset)
}
declare 174 {
- CONST86 char *TkOffsetPrintProc(ClientData clientData, Tk_Window tkwin,
- char *widgRec, int offset, Tcl_FreeProc **freeProcPtr)
+ const char *TkOffsetPrintProc(ClientData clientData, Tk_Window tkwin,
+ char *widgRec, TkSizeT offset, Tcl_FreeProc **freeProcPtr)
}
declare 175 {
int TkPixelParseProc(ClientData clientData, Tcl_Interp *interp,
- Tk_Window tkwin, const char *value, char *widgRec, int offset)
+ Tk_Window tkwin, const char *value, char *widgRec, TkSizeT offset)
}
declare 176 {
- CONST86 char *TkPixelPrintProc(ClientData clientData, Tk_Window tkwin,
- char *widgRec, int offset, Tcl_FreeProc **freeProcPtr)
+ const char *TkPixelPrintProc(ClientData clientData, Tk_Window tkwin,
+ char *widgRec, TkSizeT offset, Tcl_FreeProc **freeProcPtr)
}
declare 177 {
int TkOrientParseProc(ClientData clientData, Tcl_Interp *interp,
- Tk_Window tkwin, const char *value, char *widgRec, int offset)
+ Tk_Window tkwin, const char *value, char *widgRec, TkSizeT offset)
}
declare 178 {
- CONST86 char *TkOrientPrintProc(ClientData clientData, Tk_Window tkwin,
- char *widgRec, int offset, Tcl_FreeProc **freeProcPtr)
+ const char *TkOrientPrintProc(ClientData clientData, Tk_Window tkwin,
+ char *widgRec, TkSizeT offset, Tcl_FreeProc **freeProcPtr)
}
declare 179 {
int TkSmoothParseProc(ClientData clientData, Tcl_Interp *interp,
- Tk_Window tkwin, const char *value, char *widgRec, int offset)
+ Tk_Window tkwin, const char *value, char *widgRec, TkSizeT offset)
}
declare 180 {
- CONST86 char *TkSmoothPrintProc(ClientData clientData, Tk_Window tkwin,
- char *widgRec, int offset, Tcl_FreeProc **freeProcPtr)
+ const char *TkSmoothPrintProc(ClientData clientData, Tk_Window tkwin,
+ char *widgRec, TkSizeT offset, Tcl_FreeProc **freeProcPtr)
}
# Angled text API, exposed for Emiliano Gavilán's RBC work.
@@ -643,6 +643,12 @@ declare 186 macosx {
int TkpWillDrawWidget(Tk_Window tkwin)
}
+# Debugging / testing functions for photo images
+declare 187 {
+ int TkDebugPhotoStringMatchDef(Tcl_Interp *inter, Tcl_Obj *data,
+ Tcl_Obj *formatString, int *widthPtr, int *heightPtr)
+}
+
##############################################################################
@@ -912,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)
}
@@ -986,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)
@@ -1020,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)
@@ -1499,386 +1506,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 129 aqua {
+declare 121 macosx {
+ int XUnionRegion(Region srca, Region srcb, Region dr_return)
+}
+declare 122 macosx {
+ Window XCreateWindow(Display *display, Window parent, int x, int y,
+ unsigned int width, unsigned int height,
+ unsigned int border_width, int depth, unsigned int clazz,
+ Visual *visual, unsigned long value_mask,
+ XSetWindowAttributes *attributes)
+}
+declare 129 macosx {
int XLowerWindow(Display *d, Window w)
}
-declare 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 b169ad6..10fa4e2 100644
--- a/generic/tkInt.h
+++ b/generic/tkInt.h
@@ -25,7 +25,6 @@
* Darwin (where configure runs only once for multiple architectures).
*/
-#include <stdio.h>
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
@@ -74,14 +73,19 @@
# 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
+#ifndef TkSizeT
+# if TCL_MAJOR_VERSION > 8
+# define TkSizeT size_t
+# else
+# define TkSizeT int
+# endif
+#endif
+
+#if (TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION < 7)
+# define Tcl_WCharToUtfDString ((char * (*)(const WCHAR *, int len, Tcl_DString *))Tcl_UniCharToUtfDString)
+# define Tcl_UtfToWCharDString ((WCHAR * (*)(const char *, int len, Tcl_DString *))Tcl_UtfToUniCharDString)
+# define Tcl_Char16ToUtfDString Tcl_UniCharToUtfDString
+# define Tcl_UtfToChar16DString Tcl_UtfToUniCharDString
#endif
#if defined(__GNUC__) && (__GNUC__ > 2)
@@ -90,7 +94,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
@@ -103,19 +107,19 @@
#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))
+# define PTR2INT(p) ((intptr_t)(p))
# else
# define INT2PTR(p) ((void*)(p))
-# define PTR2INT(p) ((int)(p))
+# define PTR2INT(p) ((long)(p))
# endif
#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))
+# define PTR2UINT(p) ((uintptr_t)(p))
# else
# define UINT2PTR(p) ((void*)(p))
-# define PTR2UINT(p) ((unsigned int)(p))
+# define PTR2UINT(p) ((unsigned long)(p))
# endif
#endif
@@ -137,7 +141,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;
@@ -152,7 +156,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
+ TkSizeT 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
@@ -161,7 +165,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
+ TkSizeT objRefCount; /* Number of Tcl objects that reference this
* structure.. */
Tcl_HashTable *otherTable; /* Second table (other than idTable) used to
* index this entry. */
@@ -196,6 +200,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. */
@@ -237,7 +243,7 @@ typedef struct TkDisplay {
unsigned int altModMask; /* Has one bit set to indicate the modifier
* corresponding to the "Meta" key. If no such
* modifier, then this is zero. */
- enum {LU_IGNORE, LU_CAPS, LU_SHIFT} lockUsage;
+ TkLockUsage lockUsage;
/* Indicates how to interpret lock
* modifier. */
int numModKeyCodes; /* Number of entries in modKeyCodes array
@@ -311,7 +317,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
+ TkSizeT deleteCount; /* Counts # of handlers deleted since last
* time inactive handlers were garbage-
* collected. When this number gets big,
* handlers get cleaned up. */
@@ -370,8 +376,6 @@ typedef struct TkDisplay {
#define TkGetContainer(tkwin) (((TkWindow *)tkwin)->maintainerPtr != NULL ? \
((TkWindow *)tkwin)->maintainerPtr : ((TkWindow *)tkwin)->parentPtr)
-#define TkGetGeomMaster(tkwin) (((TkWindow *)tkwin)->maintainerPtr != NULL ? \
- ((TkWindow *)tkwin)->maintainerPtr : ((TkWindow *)tkwin)->parentPtr)
/*
* Information used by tkGet.c only:
@@ -448,9 +452,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. */
/*
@@ -522,14 +526,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
+ TkSizeT 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. */
@@ -538,10 +542,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. */
@@ -559,8 +570,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;
@@ -572,15 +586,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
@@ -633,7 +643,7 @@ typedef struct TkEventHandler {
*/
typedef struct TkMainInfo {
- int refCount; /* Number of windows whose "mainPtr" fields
+ TkSizeT 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
@@ -644,7 +654,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. */
@@ -781,7 +795,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 */
@@ -862,7 +876,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. */
@@ -870,6 +884,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;
/*
@@ -889,7 +907,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
+ TkSizeT charValueLen; /* Length of string in charValuePtr when that
* is non-NULL. */
KeySym keysym; /* Key symbol computed after input methods
* have been invoked */
@@ -904,6 +922,15 @@ 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
+
/*
* The following structure is used with TkMakeEnsemble to create ensemble
* commands and optionally to create sub-ensembles.
@@ -935,7 +962,7 @@ typedef struct TkpClipMask {
int type; /* TKP_CLIP_PIXMAP or TKP_CLIP_REGION. */
union {
Pixmap pixmap;
- TkRegion region;
+ Region region;
} value;
} TkpClipMask;
@@ -984,17 +1011,36 @@ typedef struct TkpClipMask {
#define ALT_MASK (AnyModifier<<2)
#define EXTENDED_MASK (AnyModifier<<3)
+#ifndef Button8
+# define Button8 8
+#endif
+#ifndef Button9
+# define Button9 9
+#endif
+
+#ifndef Button6Mask
+# define Button6Mask (1<<13)
+#endif
+#ifndef Button7Mask
+# define Button7Mask (1<<14)
+#endif
+#ifndef Button8Mask
+# define Button8Mask (AnyModifier<<4)
+#endif
+#ifndef Button9Mask
+# define Button9Mask (AnyModifier<<5)
+#endif
+
/*
* Mask that selects any of the state bits corresponding to buttons, plus
* masks that select individual buttons' bits:
*/
#define ALL_BUTTONS \
- (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask)
+ (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:
@@ -1017,8 +1063,10 @@ MODULE_SCOPE const Tk_SmoothMethod tkBezierSmoothMethod;
MODULE_SCOPE Tk_ImageType tkBitmapImageType;
MODULE_SCOPE Tk_PhotoImageFormat tkImgFmtGIF;
MODULE_SCOPE void (*tkHandleEventProc) (XEvent* eventPtr);
+MODULE_SCOPE Tk_PhotoImageFormat tkImgFmtDefault;
MODULE_SCOPE Tk_PhotoImageFormat tkImgFmtPNG;
MODULE_SCOPE Tk_PhotoImageFormat tkImgFmtPPM;
+MODULE_SCOPE Tk_PhotoImageFormat tkImgFmtSVGnano;
MODULE_SCOPE TkMainInfo *tkMainWindowList;
MODULE_SCOPE Tk_ImageType tkPhotoImageType;
MODULE_SCOPE Tcl_HashTable tkPredefBitmapTable;
@@ -1224,13 +1272,8 @@ MODULE_SCOPE int Tk_WinfoObjCmd(ClientData clientData,
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 int TkSetGeometryContainer(Tcl_Interp *interp,
Tk_Window tkwin, const char *name);
-#define TkFreeGeometryContainer TkFreeGeometryMaster
MODULE_SCOPE void TkFreeGeometryContainer(Tk_Window tkwin,
const char *name);
@@ -1246,6 +1289,15 @@ MODULE_SCOPE int TkGetDoublePixels(Tcl_Interp *interp, Tk_Window tkwin,
MODULE_SCOPE int TkPostscriptImage(Tcl_Interp *interp, Tk_Window tkwin,
Tk_PostscriptInfo psInfo, XImage *ximage,
int x, int y, int width, int height);
+#if TCL_MAJOR_VERSION > 8
+MODULE_SCOPE int TkCanvasTagsParseProc(ClientData clientData, Tcl_Interp *interp,
+ Tk_Window tkwin, const char *value, char *widgRec, size_t offset);
+MODULE_SCOPE const char *TkCanvasTagsPrintProc(ClientData clientData, Tk_Window tkwin,
+ char *widgRec, size_t offset, Tcl_FreeProc **freeProcPtr);
+#else
+#define TkCanvasTagsParseProc Tk_CanvasTagsParseProc
+#define TkCanvasTagsPrintProc Tk_CanvasTagsPrintProc
+#endif
MODULE_SCOPE void TkMapTopFrame(Tk_Window tkwin);
MODULE_SCOPE XEvent * TkpGetBindingXEvent(Tcl_Interp *interp);
MODULE_SCOPE void TkCreateExitHandler(Tcl_ExitProc *proc,
@@ -1254,7 +1306,7 @@ MODULE_SCOPE void TkDeleteExitHandler(Tcl_ExitProc *proc,
ClientData clientData);
MODULE_SCOPE Tcl_ExitProc TkFinalize;
MODULE_SCOPE Tcl_ExitProc TkFinalizeThread;
-MODULE_SCOPE void TkpBuildRegionFromAlphaData(TkRegion region,
+MODULE_SCOPE void TkpBuildRegionFromAlphaData(Region region,
unsigned x, unsigned y, unsigned width,
unsigned height, unsigned char *dataPtr,
unsigned pixelStride, unsigned lineStride);
@@ -1265,7 +1317,6 @@ 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,
@@ -1284,7 +1335,9 @@ MODULE_SCOPE void TkUnderlineCharsInContext(Display *display,
int firstByte, int lastByte);
MODULE_SCOPE void TkpGetFontAttrsForChar(Tk_Window tkwin, Tk_Font tkfont,
int c, struct TkFontAttributes *faPtr);
-MODULE_SCOPE 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 void TkpMakeTransparentWindowExist(Tk_Window tkwin,
@@ -1294,8 +1347,6 @@ MODULE_SCOPE void TkpCreateBusy(Tk_FakeWin *winPtr, Tk_Window tkRef,
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);
MODULE_SCOPE Tcl_Command TkMakeEnsemble(Tcl_Interp *interp,
const char *nsname, const char *name,
ClientData clientData, const TkEnsemble *map);
@@ -1303,11 +1354,19 @@ MODULE_SCOPE int TkInitTkCmd(Tcl_Interp *interp,
ClientData clientData);
MODULE_SCOPE int TkInitFontchooser(Tcl_Interp *interp,
ClientData clientData);
+MODULE_SCOPE void TkInitEmbeddedConfigurationInformation(
+ Tcl_Interp *interp);
+MODULE_SCOPE void TkDoWarpWrtWin(TkDisplay *dispPtr);
MODULE_SCOPE void TkpWarpPointer(TkDisplay *dispPtr);
-MODULE_SCOPE void TkpCancelWarp(TkDisplay *dispPtr);
MODULE_SCOPE int TkListCreateFrame(ClientData clientData,
Tcl_Interp *interp, Tcl_Obj *listObj,
int toplevel, Tcl_Obj *nameObj);
+MODULE_SCOPE void TkRotatePoint(double originX, double originY,
+ double sine, double cosine, double *xPtr,
+ double *yPtr);
+MODULE_SCOPE int TkGetIntForIndex(Tcl_Obj *, TkSizeT, int lastOK, TkSizeT*);
+
+#define TkNewIndexObj(value) Tcl_NewWideIntObj((Tcl_WideInt)(value + 1) - 1)
#ifdef _WIN32
#define TkParseColor XParseColor
@@ -1316,8 +1375,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
#if !defined(__cplusplus) && !defined(c_plusplus)
@@ -1325,15 +1406,24 @@ MODULE_SCOPE void TkUnixSetXftClipRegion(TkRegion clipRegion);
#endif
#if TCL_UTF_MAX > 4
-# define TkUtfToUniChar Tcl_UtfToUniChar
-# define TkUniCharToUtf Tcl_UniCharToUtf
+# define TkUtfToUniChar(src, ch) (size_t)(((int (*)(const char *, int *))Tcl_UtfToUniChar)(src, ch))
+# define TkUniCharToUtf(ch, src) (size_t)(((int (*)(int, char *))Tcl_UniCharToUtf)(ch, src))
# define TkUtfPrev Tcl_UtfPrev
-# define TkUtfAtIndex Tcl_UtfAtIndex
#else
- MODULE_SCOPE int TkUtfToUniChar(const char *, int *);
- MODULE_SCOPE int TkUniCharToUtf(int, char *);
+ MODULE_SCOPE size_t TkUtfToUniChar(const char *, int *);
+ MODULE_SCOPE size_t TkUniCharToUtf(int, char *);
MODULE_SCOPE const char *TkUtfPrev(const char *, const char *);
- MODULE_SCOPE const char *TkUtfAtIndex(const char *src, int index);
+#endif
+
+#if TCL_MAJOR_VERSION > 8
+#define TkGetStringFromObj(objPtr, lenPtr) \
+ (((objPtr)->bytes ? 0 : Tcl_GetString(objPtr)), \
+ *(lenPtr) = (objPtr)->length, (objPtr)->bytes)
+MODULE_SCOPE unsigned char *TkGetByteArrayFromObj(Tcl_Obj *objPtr,
+ size_t *lengthPtr);
+#else
+#define TkGetStringFromObj Tcl_GetStringFromObj
+#define TkGetByteArrayFromObj Tcl_GetByteArrayFromObj
#endif
/*
diff --git a/generic/tkIntDecls.h b/generic/tkIntDecls.h
index 7057411..6741704 100644
--- a/generic/tkIntDecls.h
+++ b/generic/tkIntDecls.h
@@ -15,6 +15,8 @@
#ifndef _TKINTDECLS
#define _TKINTDECLS
+#include "X11/Xutil.h"
+
#ifdef BUILD_tk
#undef TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS DLLEXPORT
@@ -104,7 +106,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);
@@ -167,7 +169,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[]);
@@ -254,7 +256,7 @@ EXTERN int TkReadBitmapFile(Display *display, Drawable d,
/* 79 */
EXTERN int TkScrollWindow(Tk_Window tkwin, GC gc, int x, int y,
int width, int height, int dx, int dy,
- TkRegion damageRgn);
+ Region damageRgn);
/* 80 */
EXTERN void TkSelDeadWindow(TkWindow *winPtr);
/* 81 */
@@ -324,7 +326,7 @@ 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);
@@ -334,22 +336,22 @@ EXTERN Tcl_Obj * TkpGetSystemDefault(Tk_Window tkwin,
/* 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 */
@@ -390,7 +392,7 @@ EXTERN KeySym TkpGetKeySym(TkDisplay *dispPtr, XEvent *eventPtr);
/* 139 */
EXTERN void TkpInitKeymapInfo(TkDisplay *dispPtr);
/* 140 */
-EXTERN TkRegion TkPhotoGetValidRegion(Tk_PhotoHandle handle);
+EXTERN Region TkPhotoGetValidRegion(Tk_PhotoHandle handle);
/* 141 */
EXTERN TkWindow ** TkWmStackorderToplevel(TkWindow *parentPtr);
/* 142 */
@@ -400,8 +402,8 @@ EXTERN void TkClipCleanup(TkDisplay *dispPtr);
/* 144 */
EXTERN void TkGCCleanup(TkDisplay *dispPtr);
/* 145 */
-EXTERN 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 */
@@ -459,7 +461,7 @@ EXTERN struct TkTextIndex * TkTextMakeByteIndex(TkTextBTree tree,
const struct TkText *textPtr, int lineIndex,
int byteIndex, struct TkTextIndex *indexPtr);
/* 163 */
-EXTERN int TkTextPrintIndex(const struct TkText *textPtr,
+EXTERN TkSizeT TkTextPrintIndex(const struct TkText *textPtr,
const struct TkTextIndex *indexPtr,
char *string);
/* 164 */
@@ -486,51 +488,57 @@ EXTERN void TkTextInsertDisplayProc(struct TkText *textPtr,
/* 169 */
EXTERN int TkStateParseProc(ClientData clientData,
Tcl_Interp *interp, Tk_Window tkwin,
- const char *value, char *widgRec, int offset);
+ const char *value, char *widgRec,
+ TkSizeT offset);
/* 170 */
-EXTERN CONST86 char * TkStatePrintProc(ClientData clientData,
- Tk_Window tkwin, char *widgRec, int offset,
- Tcl_FreeProc **freeProcPtr);
+EXTERN const char * TkStatePrintProc(ClientData clientData,
+ Tk_Window tkwin, char *widgRec,
+ TkSizeT offset, Tcl_FreeProc **freeProcPtr);
/* 171 */
EXTERN int TkCanvasDashParseProc(ClientData clientData,
Tcl_Interp *interp, Tk_Window tkwin,
- const char *value, char *widgRec, int offset);
+ const char *value, char *widgRec,
+ TkSizeT offset);
/* 172 */
-EXTERN CONST86 char * TkCanvasDashPrintProc(ClientData clientData,
- Tk_Window tkwin, char *widgRec, int offset,
- Tcl_FreeProc **freeProcPtr);
+EXTERN const char * TkCanvasDashPrintProc(ClientData clientData,
+ Tk_Window tkwin, char *widgRec,
+ TkSizeT offset, Tcl_FreeProc **freeProcPtr);
/* 173 */
EXTERN int TkOffsetParseProc(ClientData clientData,
Tcl_Interp *interp, Tk_Window tkwin,
- const char *value, char *widgRec, int offset);
+ const char *value, char *widgRec,
+ TkSizeT offset);
/* 174 */
-EXTERN CONST86 char * TkOffsetPrintProc(ClientData clientData,
- Tk_Window tkwin, char *widgRec, int offset,
- Tcl_FreeProc **freeProcPtr);
+EXTERN const char * TkOffsetPrintProc(ClientData clientData,
+ Tk_Window tkwin, char *widgRec,
+ TkSizeT offset, Tcl_FreeProc **freeProcPtr);
/* 175 */
EXTERN int TkPixelParseProc(ClientData clientData,
Tcl_Interp *interp, Tk_Window tkwin,
- const char *value, char *widgRec, int offset);
+ const char *value, char *widgRec,
+ TkSizeT offset);
/* 176 */
-EXTERN CONST86 char * TkPixelPrintProc(ClientData clientData,
- Tk_Window tkwin, char *widgRec, int offset,
- Tcl_FreeProc **freeProcPtr);
+EXTERN const char * TkPixelPrintProc(ClientData clientData,
+ Tk_Window tkwin, char *widgRec,
+ TkSizeT offset, Tcl_FreeProc **freeProcPtr);
/* 177 */
EXTERN int TkOrientParseProc(ClientData clientData,
Tcl_Interp *interp, Tk_Window tkwin,
- const char *value, char *widgRec, int offset);
+ const char *value, char *widgRec,
+ TkSizeT offset);
/* 178 */
-EXTERN CONST86 char * TkOrientPrintProc(ClientData clientData,
- Tk_Window tkwin, char *widgRec, int offset,
- Tcl_FreeProc **freeProcPtr);
+EXTERN const char * TkOrientPrintProc(ClientData clientData,
+ Tk_Window tkwin, char *widgRec,
+ TkSizeT offset, Tcl_FreeProc **freeProcPtr);
/* 179 */
EXTERN int TkSmoothParseProc(ClientData clientData,
Tcl_Interp *interp, Tk_Window tkwin,
- const char *value, char *widgRec, int offset);
+ const char *value, char *widgRec,
+ TkSizeT offset);
/* 180 */
-EXTERN CONST86 char * TkSmoothPrintProc(ClientData clientData,
- Tk_Window tkwin, char *widgRec, int offset,
- Tcl_FreeProc **freeProcPtr);
+EXTERN const char * TkSmoothPrintProc(ClientData clientData,
+ Tk_Window tkwin, char *widgRec,
+ TkSizeT offset, Tcl_FreeProc **freeProcPtr);
/* 181 */
EXTERN void TkDrawAngledTextLayout(Display *display,
Drawable drawable, GC gc,
@@ -558,6 +566,10 @@ EXTERN void TkpRedrawWidget(Tk_Window tkwin);
/* 186 */
EXTERN int TkpWillDrawWidget(Tk_Window tkwin);
#endif /* MACOSX */
+/* 187 */
+EXTERN int TkDebugPhotoStringMatchDef(Tcl_Interp *inter,
+ Tcl_Obj *data, Tcl_Obj *formatString,
+ int *widthPtr, int *heightPtr);
typedef struct TkIntStubs {
int magic;
@@ -585,7 +597,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 */
@@ -609,7 +621,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 */
@@ -642,7 +654,7 @@ typedef struct TkIntStubs {
void (*reserved76)(void);
void (*tkQueueEventForAllChildren) (TkWindow *winPtr, XEvent *eventPtr); /* 77 */
int (*tkReadBitmapFile) (Display *display, Drawable d, const char *filename, unsigned int *width_return, unsigned int *height_return, Pixmap *bitmap_return, int *x_hot_return, int *y_hot_return); /* 78 */
- int (*tkScrollWindow) (Tk_Window tkwin, GC gc, int x, int y, int width, int height, int dx, int dy, TkRegion damageRgn); /* 79 */
+ int (*tkScrollWindow) (Tk_Window tkwin, GC gc, int x, int y, int width, int height, int dx, int dy, Region damageRgn); /* 79 */
void (*tkSelDeadWindow) (TkWindow *winPtr); /* 80 */
void (*tkSelEventProc) (Tk_Window tkwin, XEvent *eventPtr); /* 81 */
void (*tkSelInit) (Tk_Window tkwin); /* 82 */
@@ -672,17 +684,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 */
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);
@@ -730,12 +742,12 @@ typedef struct TkIntStubs {
void (*tkpSetKeycodeAndState) (Tk_Window tkwin, KeySym keySym, XEvent *eventPtr); /* 137 */
KeySym (*tkpGetKeySym) (TkDisplay *dispPtr, XEvent *eventPtr); /* 138 */
void (*tkpInitKeymapInfo) (TkDisplay *dispPtr); /* 139 */
- TkRegion (*tkPhotoGetValidRegion) (Tk_PhotoHandle handle); /* 140 */
+ Region (*tkPhotoGetValidRegion) (Tk_PhotoHandle handle); /* 140 */
TkWindow ** (*tkWmStackorderToplevel) (TkWindow *parentPtr); /* 141 */
void (*tkFocusFree) (TkMainInfo *mainPtr); /* 142 */
void (*tkClipCleanup) (TkDisplay *dispPtr); /* 143 */
void (*tkGCCleanup) (TkDisplay *dispPtr); /* 144 */
- 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 */
@@ -753,24 +765,24 @@ typedef struct TkIntStubs {
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 */
+ TkSizeT (*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 */
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 */
+ int (*tkStateParseProc) (ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, TkSizeT offset); /* 169 */
+ const char * (*tkStatePrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, TkSizeT offset, Tcl_FreeProc **freeProcPtr); /* 170 */
+ int (*tkCanvasDashParseProc) (ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, TkSizeT offset); /* 171 */
+ const char * (*tkCanvasDashPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, TkSizeT offset, Tcl_FreeProc **freeProcPtr); /* 172 */
+ int (*tkOffsetParseProc) (ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, TkSizeT offset); /* 173 */
+ const char * (*tkOffsetPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, TkSizeT offset, Tcl_FreeProc **freeProcPtr); /* 174 */
+ int (*tkPixelParseProc) (ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, TkSizeT offset); /* 175 */
+ const char * (*tkPixelPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, TkSizeT offset, Tcl_FreeProc **freeProcPtr); /* 176 */
+ int (*tkOrientParseProc) (ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, TkSizeT offset); /* 177 */
+ const char * (*tkOrientPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, TkSizeT offset, Tcl_FreeProc **freeProcPtr); /* 178 */
+ int (*tkSmoothParseProc) (ClientData clientData, Tcl_Interp *interp, Tk_Window tkwin, const char *value, char *widgRec, TkSizeT offset); /* 179 */
+ const char * (*tkSmoothPrintProc) (ClientData clientData, Tk_Window tkwin, char *widgRec, TkSizeT 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 */
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 */
@@ -793,6 +805,7 @@ typedef struct TkIntStubs {
#ifdef MAC_OSX_TCL /* MACOSX */
int (*tkpWillDrawWidget) (Tk_Window tkwin); /* 186 */
#endif /* MACOSX */
+ int (*tkDebugPhotoStringMatchDef) (Tcl_Interp *inter, Tcl_Obj *data, Tcl_Obj *formatString, int *widthPtr, int *heightPtr); /* 187 */
} TkIntStubs;
extern const TkIntStubs *tkIntStubsPtr;
@@ -1028,20 +1041,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 \
@@ -1086,8 +1099,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 \
@@ -1173,6 +1186,8 @@ extern const TkIntStubs *tkIntStubsPtr;
#define TkpWillDrawWidget \
(tkIntStubsPtr->tkpWillDrawWidget) /* 186 */
#endif /* MACOSX */
+#define TkDebugPhotoStringMatchDef \
+ (tkIntStubsPtr->tkDebugPhotoStringMatchDef) /* 187 */
#endif /* defined(USE_TK_STUBS) */
@@ -1181,19 +1196,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_
@@ -1203,20 +1205,6 @@ extern const TkIntStubs *tkIntStubsPtr;
#undef TkSendCleanup_
#undef TkpTestsendCmd_
-#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(MAC_OSX_TK)
# undef TkpWillDrawWidget
# undef TkpRedrawWidget
@@ -1225,4 +1213,3 @@ extern const TkIntStubs *tkIntStubsPtr;
#endif
#endif /* _TKINTDECLS */
-
diff --git a/generic/tkIntPlatDecls.h b/generic/tkIntPlatDecls.h
index e9b3a65..348868b 100644
--- a/generic/tkIntPlatDecls.h
+++ b/generic/tkIntPlatDecls.h
@@ -170,8 +170,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 +215,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 +241,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);
@@ -402,7 +401,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 +425,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 +437,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 */
@@ -628,8 +627,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 +691,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 \
@@ -793,10 +791,12 @@ extern const TkIntPlatStubs *tkIntPlatStubsPtr;
#undef TkSendCleanup_
#undef TkpTestsendCmd_
#undef TkGenerateActivateEvents_
-
-#define TkMacOSXGetContainer TkGetTransientMaster
+#undef TkMacOSXSetUpClippingRgn
#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 9d4200a..fe11c09 100644
--- a/generic/tkIntXlibDecls.h
+++ b/generic/tkIntXlibDecls.h
@@ -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 temporarly. */
-#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 */
@@ -413,30 +419,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);
@@ -460,7 +497,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 */
@@ -699,20 +736,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,
@@ -729,7 +785,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 */
@@ -738,9 +796,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 */
@@ -749,23 +816,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 */
@@ -776,22 +857,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;
@@ -936,29 +1040,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 */
@@ -967,7 +1071,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 */
@@ -1051,20 +1155,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 */
@@ -1072,16 +1176,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);
@@ -1089,36 +1193,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;
@@ -1398,30 +1502,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 \
@@ -1606,20 +1727,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 \
@@ -1634,7 +1769,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 */
@@ -1644,8 +1780,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 */
@@ -1654,50 +1792,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 514b349..7bca20e 100644
--- a/generic/tkListbox.c
+++ b/generic/tkListbox.c
@@ -12,8 +12,8 @@
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
-#include "default.h"
#include "tkInt.h"
+#include "default.h"
#ifdef _WIN32
#include "tkWinInt.h"
@@ -239,80 +239,80 @@ static const char *const activeStyleStrings[] = {
static const Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_STRING_TABLE, "-activestyle", "activeStyle", "ActiveStyle",
- DEF_LISTBOX_ACTIVE_STYLE, -1, Tk_Offset(Listbox, activeStyle),
+ DEF_LISTBOX_ACTIVE_STYLE, TCL_INDEX_NONE, offsetof(Listbox, activeStyle),
0, activeStyleStrings, 0},
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_LISTBOX_BG_COLOR, -1, Tk_Offset(Listbox, normalBorder),
+ DEF_LISTBOX_BG_COLOR, TCL_INDEX_NONE, offsetof(Listbox, normalBorder),
0, DEF_LISTBOX_BG_MONO, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL,
- NULL, 0, -1, 0, "-background", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_LISTBOX_BORDER_WIDTH, -1, Tk_Offset(Listbox, borderWidth),
+ DEF_LISTBOX_BORDER_WIDTH, TCL_INDEX_NONE, offsetof(Listbox, borderWidth),
0, 0, 0},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_LISTBOX_CURSOR, -1, Tk_Offset(Listbox, cursor),
+ DEF_LISTBOX_CURSOR, TCL_INDEX_NONE, offsetof(Listbox, cursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_COLOR, "-disabledforeground", "disabledForeground",
- "DisabledForeground", DEF_LISTBOX_DISABLED_FG, -1,
- Tk_Offset(Listbox, dfgColorPtr), TK_OPTION_NULL_OK, 0, 0},
+ "DisabledForeground", DEF_LISTBOX_DISABLED_FG, TCL_INDEX_NONE,
+ offsetof(Listbox, dfgColorPtr), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_BOOLEAN, "-exportselection", "exportSelection",
- "ExportSelection", DEF_LISTBOX_EXPORT_SELECTION, -1,
- Tk_Offset(Listbox, exportSelection), 0, 0, 0},
+ "ExportSelection", DEF_LISTBOX_EXPORT_SELECTION, TCL_INDEX_NONE,
+ offsetof(Listbox, exportSelection), 0, 0, 0},
{TK_OPTION_SYNONYM, "-fg", "foreground", NULL,
- NULL, 0, -1, 0, "-foreground", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_LISTBOX_FONT, -1, Tk_Offset(Listbox, tkfont), 0, 0, 0},
+ DEF_LISTBOX_FONT, TCL_INDEX_NONE, offsetof(Listbox, tkfont), 0, 0, 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_LISTBOX_FG, -1, Tk_Offset(Listbox, fgColorPtr), 0, 0, 0},
+ DEF_LISTBOX_FG, TCL_INDEX_NONE, offsetof(Listbox, fgColorPtr), 0, 0, 0},
{TK_OPTION_INT, "-height", "height", "Height",
- DEF_LISTBOX_HEIGHT, -1, Tk_Offset(Listbox, height), 0, 0, 0},
+ DEF_LISTBOX_HEIGHT, TCL_INDEX_NONE, offsetof(Listbox, height), 0, 0, 0},
{TK_OPTION_COLOR, "-highlightbackground", "highlightBackground",
- "HighlightBackground", DEF_LISTBOX_HIGHLIGHT_BG, -1,
- Tk_Offset(Listbox, highlightBgColorPtr), 0, 0, 0},
+ "HighlightBackground", DEF_LISTBOX_HIGHLIGHT_BG, TCL_INDEX_NONE,
+ offsetof(Listbox, highlightBgColorPtr), 0, 0, 0},
{TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_LISTBOX_HIGHLIGHT, -1, Tk_Offset(Listbox, highlightColorPtr),
+ DEF_LISTBOX_HIGHLIGHT, TCL_INDEX_NONE, offsetof(Listbox, highlightColorPtr),
0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
- "HighlightThickness", DEF_LISTBOX_HIGHLIGHT_WIDTH, -1,
- Tk_Offset(Listbox, highlightWidth), 0, 0, 0},
+ "HighlightThickness", DEF_LISTBOX_HIGHLIGHT_WIDTH, TCL_INDEX_NONE,
+ offsetof(Listbox, highlightWidth), 0, 0, 0},
{TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
- DEF_LISTBOX_JUSTIFY, -1, Tk_Offset(Listbox, justify), 0, 0, 0},
+ DEF_LISTBOX_JUSTIFY, TCL_INDEX_NONE, offsetof(Listbox, justify), 0, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_LISTBOX_RELIEF, -1, Tk_Offset(Listbox, relief), 0, 0, 0},
+ DEF_LISTBOX_RELIEF, TCL_INDEX_NONE, offsetof(Listbox, relief), 0, 0, 0},
{TK_OPTION_BORDER, "-selectbackground", "selectBackground", "Foreground",
- DEF_LISTBOX_SELECT_COLOR, -1, Tk_Offset(Listbox, selBorder),
+ DEF_LISTBOX_SELECT_COLOR, TCL_INDEX_NONE, offsetof(Listbox, selBorder),
0, DEF_LISTBOX_SELECT_MONO, 0},
{TK_OPTION_PIXELS, "-selectborderwidth", "selectBorderWidth",
- "BorderWidth", DEF_LISTBOX_SELECT_BD, -1,
- Tk_Offset(Listbox, selBorderWidth), 0, 0, 0},
+ "BorderWidth", DEF_LISTBOX_SELECT_BD, TCL_INDEX_NONE,
+ offsetof(Listbox, selBorderWidth), 0, 0, 0},
{TK_OPTION_COLOR, "-selectforeground", "selectForeground", "Background",
- DEF_LISTBOX_SELECT_FG_COLOR, -1, Tk_Offset(Listbox, selFgColorPtr),
+ DEF_LISTBOX_SELECT_FG_COLOR, TCL_INDEX_NONE, offsetof(Listbox, selFgColorPtr),
TK_OPTION_NULL_OK, DEF_LISTBOX_SELECT_FG_MONO, 0},
{TK_OPTION_STRING, "-selectmode", "selectMode", "SelectMode",
- DEF_LISTBOX_SELECT_MODE, -1, Tk_Offset(Listbox, selectMode),
+ DEF_LISTBOX_SELECT_MODE, TCL_INDEX_NONE, offsetof(Listbox, selectMode),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_BOOLEAN, "-setgrid", "setGrid", "SetGrid",
- DEF_LISTBOX_SET_GRID, -1, Tk_Offset(Listbox, setGrid), 0, 0, 0},
+ DEF_LISTBOX_SET_GRID, TCL_INDEX_NONE, offsetof(Listbox, setGrid), 0, 0, 0},
{TK_OPTION_STRING_TABLE, "-state", "state", "State",
- DEF_LISTBOX_STATE, -1, Tk_Offset(Listbox, state),
+ DEF_LISTBOX_STATE, TCL_INDEX_NONE, offsetof(Listbox, state),
0, stateStrings, 0},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_LISTBOX_TAKE_FOCUS, -1, Tk_Offset(Listbox, takeFocus),
+ DEF_LISTBOX_TAKE_FOCUS, TCL_INDEX_NONE, offsetof(Listbox, takeFocus),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_INT, "-width", "width", "Width",
- DEF_LISTBOX_WIDTH, -1, Tk_Offset(Listbox, width), 0, 0, 0},
+ DEF_LISTBOX_WIDTH, TCL_INDEX_NONE, offsetof(Listbox, width), 0, 0, 0},
{TK_OPTION_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand",
- DEF_LISTBOX_SCROLL_COMMAND, -1, Tk_Offset(Listbox, xScrollCmd),
+ DEF_LISTBOX_SCROLL_COMMAND, TCL_INDEX_NONE, offsetof(Listbox, xScrollCmd),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-yscrollcommand", "yScrollCommand", "ScrollCommand",
- DEF_LISTBOX_SCROLL_COMMAND, -1, Tk_Offset(Listbox, yScrollCmd),
+ DEF_LISTBOX_SCROLL_COMMAND, TCL_INDEX_NONE, offsetof(Listbox, yScrollCmd),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-listvariable", "listVariable", "Variable",
- DEF_LISTBOX_LIST_VARIABLE, -1, Tk_Offset(Listbox, listVarName),
+ DEF_LISTBOX_LIST_VARIABLE, TCL_INDEX_NONE, offsetof(Listbox, listVarName),
TK_OPTION_NULL_OK, 0, 0},
- {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0}
+ {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0}
};
/*
@@ -322,25 +322,25 @@ static const Tk_OptionSpec optionSpecs[] = {
static const Tk_OptionSpec itemAttrOptionSpecs[] = {
{TK_OPTION_BORDER, "-background", "background", "Background",
- NULL, -1, Tk_Offset(ItemAttr, border),
+ NULL, TCL_INDEX_NONE, offsetof(ItemAttr, border),
TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT,
DEF_LISTBOX_BG_MONO, 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL,
- NULL, 0, -1, 0, "-background", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_SYNONYM, "-fg", "foreground", NULL,
- NULL, 0, -1, 0, "-foreground", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- NULL, -1, Tk_Offset(ItemAttr, fgColor),
+ NULL, TCL_INDEX_NONE, offsetof(ItemAttr, fgColor),
TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT, 0, 0},
{TK_OPTION_BORDER, "-selectbackground", "selectBackground", "Foreground",
- NULL, -1, Tk_Offset(ItemAttr, selBorder),
+ NULL, TCL_INDEX_NONE, offsetof(ItemAttr, selBorder),
TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT,
DEF_LISTBOX_SELECT_MONO, 0},
{TK_OPTION_COLOR, "-selectforeground", "selectForeground", "Background",
- NULL, -1, Tk_Offset(ItemAttr, selFgColor),
+ NULL, TCL_INDEX_NONE, offsetof(ItemAttr, selFgColor),
TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT,
DEF_LISTBOX_SELECT_FG_MONO, 0},
- {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0}
+ {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0}
};
/*
@@ -377,10 +377,10 @@ enum scancommand {
};
static const char *const indexNames[] = {
- "active", "anchor", "end", NULL
+ "active", "anchor", NULL
};
enum indices {
- INDEX_ACTIVE, INDEX_ANCHOR, INDEX_END
+ INDEX_ACTIVE, INDEX_ANCHOR
};
/*
@@ -409,8 +409,8 @@ static void ListboxComputeGeometry(Listbox *listPtr,
int fontChanged, int maxIsStale, int updateGrid);
static void ListboxEventProc(ClientData clientData,
XEvent *eventPtr);
-static int ListboxFetchSelection(ClientData clientData,
- int offset, char *buffer, int maxBytes);
+static TkSizeT ListboxFetchSelection(ClientData clientData,
+ TkSizeT offset, char *buffer, TkSizeT maxBytes);
static void ListboxLostSelection(ClientData clientData);
static void GenerateListboxSelectEvent(Listbox *listPtr);
static void EventuallyRedrawRange(Listbox *listPtr,
@@ -473,14 +473,15 @@ static const Tk_ClassProcs listboxClass = {
int
Tk_ListboxObjCmd(
- ClientData clientData, /* NULL. */
+ ClientData dummy, /* NULL. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register Listbox *listPtr;
+ Listbox *listPtr;
Tk_Window tkwin;
ListboxOptionTables *optionTables;
+ (void)dummy;
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "pathName ?-option value ...?");
@@ -493,7 +494,7 @@ Tk_ListboxObjCmd(
return TCL_ERROR;
}
- optionTables = Tcl_GetAssocData(interp, "ListboxOptionTables", NULL);
+ optionTables = (ListboxOptionTables *)Tcl_GetAssocData(interp, "ListboxOptionTables", NULL);
if (optionTables == NULL) {
/*
* We haven't created the option tables for this widget class yet. Do
@@ -501,7 +502,7 @@ Tk_ListboxObjCmd(
* command, so future invocations will have access to it.
*/
- optionTables = ckalloc(sizeof(ListboxOptionTables));
+ optionTables = (ListboxOptionTables *)ckalloc(sizeof(ListboxOptionTables));
/*
* Set up an exit handler to free the optionTables struct.
@@ -526,7 +527,7 @@ Tk_ListboxObjCmd(
* already (e.g. resource pointers).
*/
- listPtr = ckalloc(sizeof(Listbox));
+ listPtr = (Listbox *)ckalloc(sizeof(Listbox));
memset(listPtr, 0, sizeof(Listbox));
listPtr->tkwin = tkwin;
@@ -537,9 +538,9 @@ Tk_ListboxObjCmd(
ListboxCmdDeletedProc);
listPtr->optionTable = optionTables->listboxOptionTable;
listPtr->itemAttrOptionTable = optionTables->itemAttrOptionTable;
- listPtr->selection = ckalloc(sizeof(Tcl_HashTable));
+ listPtr->selection = (Tcl_HashTable *)ckalloc(sizeof(Tcl_HashTable));
Tcl_InitHashTable(listPtr->selection, TCL_ONE_WORD_KEYS);
- listPtr->itemAttrTable = ckalloc(sizeof(Tcl_HashTable));
+ listPtr->itemAttrTable = (Tcl_HashTable *)ckalloc(sizeof(Tcl_HashTable));
Tcl_InitHashTable(listPtr->itemAttrTable, TCL_ONE_WORD_KEYS);
listPtr->relief = TK_RELIEF_RAISED;
listPtr->textGC = NULL;
@@ -567,7 +568,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;
@@ -578,7 +579,7 @@ Tk_ListboxObjCmd(
return TCL_ERROR;
}
- Tcl_SetObjResult(interp, TkNewWindowObj(listPtr->tkwin));
+ Tcl_SetObjResult(interp, Tk_NewWindowObj(listPtr->tkwin));
return TCL_OK;
}
@@ -607,7 +608,7 @@ ListboxWidgetObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Arguments as Tcl_Obj's. */
{
- register Listbox *listPtr = clientData;
+ Listbox *listPtr = (Listbox *)clientData;
int cmdIndex, index;
int result = TCL_OK;
Tcl_Obj *objPtr;
@@ -682,7 +683,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;
@@ -694,7 +695,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) {
@@ -728,7 +729,7 @@ ListboxWidgetObjCmd(
objPtr = Tcl_NewObj();
for (i = 0; i < listPtr->nElements; i++) {
if (Tcl_FindHashEntry(listPtr->selection, KEY(i))) {
- Tcl_ListObjAppendElement(NULL, objPtr, Tcl_NewIntObj(i));
+ Tcl_ListObjAppendElement(NULL, objPtr, Tcl_NewWideIntObj(i));
}
}
Tcl_SetObjResult(interp, objPtr);
@@ -841,7 +842,7 @@ ListboxWidgetObjCmd(
if (result != TCL_OK) {
break;
}
- Tcl_SetObjResult(interp, Tcl_NewIntObj(index));
+ Tcl_SetObjResult(interp, TkNewIndexObj(index));
result = TCL_OK;
break;
@@ -905,7 +906,7 @@ ListboxWidgetObjCmd(
if (objc < 3) {
Tcl_WrongNumArgs(interp, 2, objv,
- "index ?-option? ?value? ?-option value ...?");
+ "index ?-option value ...?");
result = TCL_ERROR;
break;
}
@@ -926,7 +927,7 @@ ListboxWidgetObjCmd(
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) {
@@ -956,7 +957,7 @@ ListboxWidgetObjCmd(
break;
}
index = NearestListboxElement(listPtr, y);
- Tcl_SetObjResult(interp, Tcl_NewIntObj(index));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(index));
result = TCL_OK;
break;
}
@@ -1044,7 +1045,7 @@ ListboxWidgetObjCmd(
result = TCL_ERROR;
break;
}
- Tcl_SetObjResult(interp, Tcl_NewIntObj(listPtr->nElements));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(listPtr->nElements));
result = TCL_OK;
break;
case COMMAND_XVIEW:
@@ -1082,7 +1083,7 @@ ListboxBboxSubCmd(
Listbox *listPtr, /* Information about the listbox */
int index) /* Index of the element to get bbox info on */
{
- register Tk_Window tkwin = listPtr->tkwin;
+ Tk_Window tkwin = listPtr->tkwin;
int lastVisibleIndex;
/*
@@ -1102,7 +1103,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;
+ TkSizeT stringLen;
Tk_FontMetrics fm;
/*
@@ -1114,7 +1116,7 @@ ListboxBboxSubCmd(
return result;
}
- stringRep = Tcl_GetStringFromObj(el, &stringLen);
+ stringRep = TkGetStringFromObj(el, &stringLen);
Tk_GetFontMetrics(listPtr->tkfont, &fm);
pixelWidth = Tk_TextWidth(listPtr->tkfont, stringRep, stringLen);
@@ -1129,10 +1131,10 @@ ListboxBboxSubCmd(
}
y = ((index - listPtr->topIndex)*listPtr->lineHeight)
+ listPtr->inset + listPtr->selBorderWidth;
- results[0] = Tcl_NewIntObj(x);
- results[1] = Tcl_NewIntObj(y);
- results[2] = Tcl_NewIntObj(pixelWidth);
- results[3] = Tcl_NewIntObj(fm.linespace);
+ results[0] = Tcl_NewWideIntObj(x);
+ results[1] = Tcl_NewWideIntObj(y);
+ results[2] = Tcl_NewWideIntObj(pixelWidth);
+ results[3] = Tcl_NewWideIntObj(fm.linespace);
Tcl_SetObjResult(interp, Tcl_NewListObj(4, results));
}
return TCL_OK;
@@ -1410,16 +1412,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;
}
@@ -1446,7 +1448,7 @@ static void
DestroyListbox(
void *memPtr) /* Info about listbox widget. */
{
- register Listbox *listPtr = memPtr;
+ Listbox *listPtr = (Listbox *)memPtr;
Tcl_HashEntry *entry;
Tcl_HashSearch search;
@@ -1526,8 +1528,10 @@ DestroyListbox(
static void
DestroyListboxOptionTables(
ClientData clientData, /* Pointer to the OptionTables struct */
- Tcl_Interp *interp) /* Pointer to the calling interp */
+ Tcl_Interp *dummy) /* Pointer to the calling interp */
{
+ (void)dummy;
+
ckfree(clientData);
return;
}
@@ -1555,7 +1559,7 @@ DestroyListboxOptionTables(
static int
ConfigureListbox(
Tcl_Interp *interp, /* Used for error reporting. */
- register Listbox *listPtr, /* Information about widget; may or may not
+ Listbox *listPtr, /* Information about widget; may or may not
* already have values for some fields. */
int objc, /* Number of valid entries in argv. */
Tcl_Obj *const objv[]) /* Arguments. */
@@ -1578,7 +1582,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;
@@ -1715,7 +1719,7 @@ ConfigureListbox(
static int
ConfigureListboxItem(
Tcl_Interp *interp, /* Used for error reporting. */
- register Listbox *listPtr, /* Information about widget; may or may not
+ Listbox *listPtr, /* Information about widget; may or may not
* already have values for some fields. */
ItemAttr *attrs, /* Information about the item to configure */
int objc, /* Number of valid entries in argv. */
@@ -1724,7 +1728,7 @@ ConfigureListboxItem(
{
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);
@@ -1766,7 +1770,7 @@ ListboxWorldChanged(
XGCValues gcValues;
GC gc;
unsigned long mask;
- Listbox *listPtr = instanceData;
+ Listbox *listPtr = (Listbox *)instanceData;
if (listPtr->state & STATE_NORMAL) {
gcValues.foreground = listPtr->fgColorPtr->pixel;
@@ -1837,10 +1841,11 @@ static void
DisplayListbox(
ClientData clientData) /* Information about window. */
{
- register Listbox *listPtr = clientData;
- register Tk_Window tkwin = listPtr->tkwin;
+ Listbox *listPtr = (Listbox *)clientData;
+ Tk_Window tkwin = listPtr->tkwin;
GC gc;
- int i, limit, x, y, prevSelected, freeGC, stringLen;
+ int i, limit, x, y, prevSelected, freeGC;
+ TkSizeT stringLen;
Tk_FontMetrics fm;
Tcl_Obj *curElement;
Tcl_HashEntry *entry;
@@ -1956,7 +1961,7 @@ DisplayListbox(
*/
if (entry != NULL) {
- attrs = Tcl_GetHashValue(entry);
+ attrs = (ItemAttr *)Tcl_GetHashValue(entry);
/*
* Default GC has the values from the widget at large.
@@ -2037,7 +2042,7 @@ DisplayListbox(
*/
if (entry != NULL) {
- attrs = Tcl_GetHashValue(entry);
+ attrs = (ItemAttr *)Tcl_GetHashValue(entry);
gcValues.foreground = listPtr->fgColorPtr->pixel;
gcValues.font = Tk_FontId(listPtr->tkfont);
gcValues.graphics_exposures = False;
@@ -2074,7 +2079,7 @@ DisplayListbox(
*/
Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i, &curElement);
- stringRep = Tcl_GetStringFromObj(curElement, &stringLen);
+ stringRep = TkGetStringFromObj(curElement, &stringLen);
textWidth = Tk_TextWidth(listPtr->tkfont, stringRep, stringLen);
Tk_GetFontMetrics(listPtr->tkfont, &fm);
@@ -2236,7 +2241,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;
+ TkSizeT textLength;
Tk_FontMetrics fm;
Tcl_Obj *element;
const char *text;
@@ -2257,7 +2263,7 @@ ListboxComputeGeometry(
if (result != TCL_OK) {
continue;
}
- text = Tcl_GetStringFromObj(element, &textLength);
+ text = TkGetStringFromObj(element, &textLength);
Tk_GetFontMetrics(listPtr->tkfont, &fm);
pixelWidth = Tk_TextWidth(listPtr->tkfont, text, textLength);
if (pixelWidth > listPtr->maxWidth) {
@@ -2317,13 +2323,14 @@ ListboxComputeGeometry(
static int
ListboxInsertSubCmd(
- register Listbox *listPtr, /* Listbox that is to get the new elements. */
+ Listbox *listPtr, /* Listbox that is to get the new elements. */
int index, /* Add the new elements before this
* element. */
int objc, /* Number of new elements to add. */
Tcl_Obj *const objv[]) /* New elements (one per entry). */
{
- int i, oldMaxWidth, pixelWidth, result, length;
+ int i, oldMaxWidth, pixelWidth, result;
+ TkSizeT length;
Tcl_Obj *newListObj;
const char *stringRep;
@@ -2334,7 +2341,7 @@ ListboxInsertSubCmd(
* if so, update our notion of "widest."
*/
- stringRep = Tcl_GetStringFromObj(objv[i], &length);
+ stringRep = TkGetStringFromObj(objv[i], &length);
pixelWidth = Tk_TextWidth(listPtr->tkfont, stringRep, length);
if (pixelWidth > listPtr->maxWidth) {
listPtr->maxWidth = pixelWidth;
@@ -2433,11 +2440,12 @@ ListboxInsertSubCmd(
static int
ListboxDeleteSubCmd(
- register Listbox *listPtr, /* Listbox widget to modify. */
+ Listbox *listPtr, /* Listbox widget to modify. */
int first, /* Index of first element to delete. */
int last) /* Index of last element to delete. */
{
- int count, i, widthChanged, length, result, pixelWidth;
+ int count, i, widthChanged, result, pixelWidth;
+ TkSizeT length;
Tcl_Obj *newListObj, *element;
const char *stringRep;
Tcl_HashEntry *entry;
@@ -2492,7 +2500,7 @@ ListboxDeleteSubCmd(
if (widthChanged == 0) {
Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i, &element);
- stringRep = Tcl_GetStringFromObj(element, &length);
+ stringRep = TkGetStringFromObj(element, &length);
pixelWidth = Tk_TextWidth(listPtr->tkfont, stringRep, length);
if (pixelWidth == listPtr->maxWidth) {
widthChanged = 1;
@@ -2610,7 +2618,7 @@ ListboxEventProc(
ClientData clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
- Listbox *listPtr = clientData;
+ Listbox *listPtr = (Listbox *)clientData;
if (eventPtr->type == Expose) {
EventuallyRedrawRange(listPtr,
@@ -2685,7 +2693,7 @@ static void
ListboxCmdDeletedProc(
ClientData clientData) /* Pointer to widget record for widget. */
{
- Listbox *listPtr = clientData;
+ Listbox *listPtr = (Listbox *)clientData;
/*
* This procedure could be invoked either because the window was destroyed
@@ -2723,14 +2731,24 @@ GetListboxIndex(
Listbox *listPtr, /* Listbox for which the index is being
* specified. */
Tcl_Obj *indexObj, /* Specifies an element in the listbox. */
- int endIsSize, /* If 1, "end" refers to the number of entries
+ int lastOK, /* If 1, "end" refers to the number of entries
* in the listbox. If 0, "end" refers to 1
* less than the number of entries. */
int *indexPtr) /* Where to store converted index. */
{
int result, index;
+ TkSizeT idx;
const char *stringRep;
+ result = TkGetIntForIndex(indexObj, listPtr->nElements - 1, lastOK, &idx);
+ if (result == TCL_OK) {
+ if ((idx != TCL_INDEX_NONE) && (idx > (TkSizeT)listPtr->nElements)) {
+ idx = listPtr->nElements;
+ }
+ *indexPtr = (int)idx;
+ return TCL_OK;
+ }
+
/*
* First see if the index is one of the named indices.
*/
@@ -2746,14 +2764,6 @@ GetListboxIndex(
/* "anchor" index */
*indexPtr = listPtr->selectAnchor;
break;
- case INDEX_END:
- /* "end" index */
- if (endIsSize) {
- *indexPtr = listPtr->nElements;
- } else {
- *indexPtr = listPtr->nElements - 1;
- }
- break;
}
return TCL_OK;
}
@@ -2788,14 +2798,6 @@ GetListboxIndex(
}
/*
- * Maybe the index is just an integer.
- */
-
- if (Tcl_GetIntFromObj(interp, indexObj, indexPtr) == TCL_OK) {
- return TCL_OK;
- }
-
- /*
* Everything failed, nothing matched. Throw up an error message.
*/
@@ -2828,7 +2830,7 @@ GetListboxIndex(
static void
ChangeListboxView(
- register Listbox *listPtr, /* Information about widget. */
+ Listbox *listPtr, /* Information about widget. */
int index) /* Index of element in listPtr that should now
* appear at the top of the listbox. */
{
@@ -2863,7 +2865,7 @@ ChangeListboxView(
static void
ChangeListboxOffset(
- register Listbox *listPtr, /* Information about widget. */
+ Listbox *listPtr, /* Information about widget. */
int offset) /* Desired new "xOffset" for listbox. */
{
int maxOffset;
@@ -2911,7 +2913,7 @@ ChangeListboxOffset(
static void
ListboxScanTo(
- register Listbox *listPtr, /* Information about widget. */
+ Listbox *listPtr, /* Information about widget. */
int x, /* X-coordinate to use for scan operation. */
int y) /* Y-coordinate to use for scan operation. */
{
@@ -2978,7 +2980,7 @@ ListboxScanTo(
static int
NearestListboxElement(
- register Listbox *listPtr, /* Information about widget. */
+ Listbox *listPtr, /* Information about widget. */
int y) /* Y-coordinate in listPtr's window. */
{
int index;
@@ -3019,7 +3021,7 @@ NearestListboxElement(
static int
ListboxSelect(
- register Listbox *listPtr, /* Information about widget. */
+ Listbox *listPtr, /* Information about widget. */
int first, /* Index of first element to select or
* deselect. */
int last, /* Index of last element to select or
@@ -3110,19 +3112,20 @@ ListboxSelect(
*----------------------------------------------------------------------
*/
-static int
+static TkSizeT
ListboxFetchSelection(
ClientData clientData, /* Information about listbox widget. */
- int offset, /* Offset within selection of first byte to be
+ TkSizeT 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,
+ TkSizeT maxBytes) /* Maximum number of bytes to place at buffer,
* not including terminating NULL
* character. */
{
- register Listbox *listPtr = clientData;
+ Listbox *listPtr = (Listbox *)clientData;
Tcl_DString selection;
- int length, count, needNewline, stringLen, i;
+ int count, needNewline, i;
+ TkSizeT length, stringLen;
Tcl_Obj *curElement;
const char *stringRep;
Tcl_HashEntry *entry;
@@ -3145,7 +3148,7 @@ ListboxFetchSelection(
}
Tcl_ListObjIndex(listPtr->interp, listPtr->listObj, i,
&curElement);
- stringRep = Tcl_GetStringFromObj(curElement, &stringLen);
+ stringRep = TkGetStringFromObj(curElement, &stringLen);
Tcl_DStringAppend(&selection, stringRep, stringLen);
needNewline = 1;
}
@@ -3160,14 +3163,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);
@@ -3196,7 +3199,7 @@ static void
ListboxLostSelection(
ClientData clientData) /* Information about listbox widget. */
{
- register Listbox *listPtr = clientData;
+ Listbox *listPtr = (Listbox *)clientData;
if ((listPtr->exportSelection) && (!Tcl_IsSafe(listPtr->interp))
&& (listPtr->nElements > 0)) {
@@ -3226,7 +3229,7 @@ static void
GenerateListboxSelectEvent(
Listbox *listPtr) /* Information about widget. */
{
- TkSendVirtualEvent(listPtr->tkwin, "ListboxSelect", NULL);
+ Tk_SendVirtualEvent(listPtr->tkwin, "ListboxSelect", NULL);
}
/*
@@ -3248,13 +3251,16 @@ GenerateListboxSelectEvent(
static void
EventuallyRedrawRange(
- register Listbox *listPtr, /* Information about widget. */
+ Listbox *listPtr, /* Information about widget. */
int first, /* Index of first element in list that needs
* to be redrawn. */
int last) /* Index of last element in list that needs to
* be redrawn. May be less than first; these
* just bracket a range. */
{
+ (void)first;
+ (void)last;
+
/*
* We don't have to register a redraw callback if one is already pending,
* or if the window doesn't exist, or if the window isn't mapped.
@@ -3291,7 +3297,7 @@ EventuallyRedrawRange(
static void
ListboxUpdateVScrollbar(
- register Listbox *listPtr) /* Information about widget. */
+ Listbox *listPtr) /* Information about widget. */
{
char firstStr[TCL_DOUBLE_SPACE], lastStr[TCL_DOUBLE_SPACE];
double first, last;
@@ -3361,7 +3367,7 @@ ListboxUpdateVScrollbar(
static void
ListboxUpdateHScrollbar(
- register Listbox *listPtr) /* Information about widget. */
+ Listbox *listPtr) /* Information about widget. */
{
char firstStr[TCL_DOUBLE_SPACE], lastStr[TCL_DOUBLE_SPACE];
int result, windowWidth;
@@ -3435,10 +3441,12 @@ ListboxListVarProc(
const char *name2, /* Not used. */
int flags) /* Information about what happened. */
{
- Listbox *listPtr = clientData;
+ Listbox *listPtr = (Listbox *)clientData;
Tcl_Obj *oldListObj, *varListObj;
int oldLength, i;
Tcl_HashEntry *entry;
+ (void)name1;
+ (void)name2;
/*
* Bwah hahahaha! Puny mortal, you can't unset a -listvar'd variable!
@@ -3642,7 +3650,7 @@ MigrateHashEntries(
*----------------------------------------------------------------------
*/
static int GetMaxOffset(
- register Listbox *listPtr)
+ Listbox *listPtr)
{
int maxOffset;
diff --git a/generic/tkMacWinMenu.c b/generic/tkMacWinMenu.c
index ab92fec..40a5ea8 100644
--- a/generic/tkMacWinMenu.c
+++ b/generic/tkMacWinMenu.c
@@ -43,7 +43,7 @@ PreprocessMenu(
TkMenu *menuPtr)
{
int index, result, finished;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
Tcl_Preserve(menuPtr);
@@ -66,8 +66,8 @@ PreprocessMenu(
do {
finished = 1;
- for (index = 0; index < menuPtr->numEntries; index++) {
- register TkMenuEntry *entryPtr = menuPtr->entries[index];
+ for (index = 0; index < (int)menuPtr->numEntries; index++) {
+ TkMenuEntry *entryPtr = menuPtr->entries[index];
if ((entryPtr->type == CASCADE_ENTRY)
&& (entryPtr->namePtr != NULL)
@@ -129,7 +129,7 @@ int
TkPreprocessMenu(
TkMenu *menuPtr)
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
tsdPtr->postCommandGeneration++;
diff --git a/generic/tkMain.c b/generic/tkMain.c
index 32006b3..eae10cf 100644
--- a/generic/tkMain.c
+++ b/generic/tkMain.c
@@ -15,14 +15,6 @@
*/
#include "tkInt.h"
-#include <ctype.h>
-#include <stdio.h>
-#include <string.h>
-#ifdef NO_STDLIB_H
-# include "../compat/stdlib.h"
-#else
-# include <stdlib.h>
-#endif
extern int TkCygwinMainEx(int, char **, Tcl_AppInitProc *, Tcl_Interp *);
@@ -46,7 +38,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 */
@@ -76,7 +68,7 @@ NewNativeObj(
Tcl_Obj *obj;
Tcl_DString ds;
-#if defined(_WIN32) && defined(UNICODE)
+#ifdef UNICODE
Tcl_DStringInit(&ds);
Tcl_WCharToUtfDString(string, wcslen(string), &ds);
#else
@@ -187,7 +179,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 {
@@ -288,7 +280,7 @@ Tk_MainEx(
argc--;
argv++;
- Tcl_SetVar2Ex(interp, "argc", NULL, Tcl_NewIntObj(argc), TCL_GLOBAL_ONLY);
+ Tcl_SetVar2Ex(interp, "argc", NULL, Tcl_NewWideIntObj(argc), TCL_GLOBAL_ONLY);
argvPtr = Tcl_NewListObj(0, NULL);
while (argc--) {
@@ -315,7 +307,7 @@ Tk_MainEx(
}
#endif
Tcl_SetVar2Ex(interp, "tcl_interactive", NULL,
- Tcl_NewIntObj(!path && (is.tty || nullStdin)), TCL_GLOBAL_ONLY);
+ Tcl_NewWideIntObj(!path && (is.tty || nullStdin)), TCL_GLOBAL_ONLY);
/*
* Invoke application-specific initialization.
@@ -415,7 +407,7 @@ StdinProc(
{
char *cmd;
int code;
- int count;
+ TkSizeT count;
InteractiveState *isPtr = (InteractiveState *)clientData;
Tcl_Channel chan = isPtr->input;
Tcl_Interp *interp = isPtr->interp;
@@ -423,7 +415,7 @@ StdinProc(
count = Tcl_Gets(chan, &isPtr->line);
- if ((count == -1) && !isPtr->gotPartial) {
+ if ((count == TCL_IO_FAILURE) && !isPtr->gotPartial) {
if (isPtr->tty) {
Tcl_Exit(0);
} else {
diff --git a/generic/tkMenu.c b/generic/tkMenu.c
index 1cd7a16..a67be21 100644
--- a/generic/tkMenu.c
+++ b/generic/tkMenu.c
@@ -38,7 +38,7 @@
* implemented using menu clones. Menu clones are full menus in their own
* right; they have a Tk window and pathname associated with them; they have a
* TkMenu structure and array of entries. However, they are linked with the
- * original menu that they were cloned from. The reflect the attributes of the
+ * original menu that they were cloned from. They reflect the attributes of the
* original, or "main", menu. So if an item is added to a menu, and that
* menu has clones, then the item must be added to all of its clones also.
* Menus are cloned when a menu is torn-off or when a menu is assigned as a
@@ -118,117 +118,117 @@ static const char *const compoundStrings[] = {
static const Tk_OptionSpec tkBasicMenuEntryConfigSpecs[] = {
{TK_OPTION_BORDER, "-activebackground", NULL, NULL,
- DEF_MENU_ENTRY_ACTIVE_BG, Tk_Offset(TkMenuEntry, activeBorderPtr), -1,
+ DEF_MENU_ENTRY_ACTIVE_BG, offsetof(TkMenuEntry, activeBorderPtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_COLOR, "-activeforeground", NULL, NULL,
DEF_MENU_ENTRY_ACTIVE_FG,
- Tk_Offset(TkMenuEntry, activeFgPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, activeFgPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_STRING, "-accelerator", NULL, NULL,
DEF_MENU_ENTRY_ACCELERATOR,
- Tk_Offset(TkMenuEntry, accelPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, accelPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_BORDER, "-background", NULL, NULL,
DEF_MENU_ENTRY_BG,
- Tk_Offset(TkMenuEntry, borderPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, borderPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_BITMAP, "-bitmap", NULL, NULL,
DEF_MENU_ENTRY_BITMAP,
- Tk_Offset(TkMenuEntry, bitmapPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, bitmapPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_BOOLEAN, "-columnbreak", NULL, NULL,
DEF_MENU_ENTRY_COLUMN_BREAK,
- -1, Tk_Offset(TkMenuEntry, columnBreak), 0, NULL, 0},
+ TCL_INDEX_NONE, offsetof(TkMenuEntry, columnBreak), 0, NULL, 0},
{TK_OPTION_STRING, "-command", NULL, NULL,
DEF_MENU_ENTRY_COMMAND,
- Tk_Offset(TkMenuEntry, commandPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, commandPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound",
- DEF_MENU_ENTRY_COMPOUND, -1, Tk_Offset(TkMenuEntry, compound), 0,
+ DEF_MENU_ENTRY_COMPOUND, TCL_INDEX_NONE, offsetof(TkMenuEntry, compound), 0,
(ClientData) compoundStrings, 0},
{TK_OPTION_FONT, "-font", NULL, NULL,
DEF_MENU_ENTRY_FONT,
- Tk_Offset(TkMenuEntry, fontPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, fontPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_COLOR, "-foreground", NULL, NULL,
DEF_MENU_ENTRY_FG,
- Tk_Offset(TkMenuEntry, fgPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, fgPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_BOOLEAN, "-hidemargin", NULL, NULL,
DEF_MENU_ENTRY_HIDE_MARGIN,
- -1, Tk_Offset(TkMenuEntry, hideMargin), 0, NULL, 0},
+ TCL_INDEX_NONE, offsetof(TkMenuEntry, hideMargin), 0, NULL, 0},
{TK_OPTION_STRING, "-image", NULL, NULL,
DEF_MENU_ENTRY_IMAGE,
- Tk_Offset(TkMenuEntry, imagePtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, imagePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_STRING, "-label", NULL, NULL,
DEF_MENU_ENTRY_LABEL,
- Tk_Offset(TkMenuEntry, labelPtr), -1, 0, NULL, 0},
+ offsetof(TkMenuEntry, labelPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_STRING_TABLE, "-state", NULL, NULL,
DEF_MENU_ENTRY_STATE,
- -1, Tk_Offset(TkMenuEntry, state), 0,
+ TCL_INDEX_NONE, offsetof(TkMenuEntry, state), 0,
(ClientData) menuStateStrings, 0},
{TK_OPTION_INT, "-underline", NULL, NULL,
- DEF_MENU_ENTRY_UNDERLINE, -1, Tk_Offset(TkMenuEntry, underline), 0, NULL, 0},
+ DEF_MENU_ENTRY_UNDERLINE, TCL_INDEX_NONE, offsetof(TkMenuEntry, underline), 0, NULL, 0},
{TK_OPTION_END, NULL, NULL, NULL, 0, 0, 0, 0, NULL, 0}
};
static const Tk_OptionSpec tkSeparatorEntryConfigSpecs[] = {
{TK_OPTION_BORDER, "-background", NULL, NULL,
DEF_MENU_ENTRY_BG,
- Tk_Offset(TkMenuEntry, borderPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, borderPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_END, NULL, NULL, NULL, 0, 0, 0, 0, NULL, 0}
};
static const Tk_OptionSpec tkCheckButtonEntryConfigSpecs[] = {
{TK_OPTION_BOOLEAN, "-indicatoron", NULL, NULL,
DEF_MENU_ENTRY_INDICATOR,
- -1, Tk_Offset(TkMenuEntry, indicatorOn), 0, NULL, 0},
+ TCL_INDEX_NONE, offsetof(TkMenuEntry, indicatorOn), 0, NULL, 0},
{TK_OPTION_STRING, "-offvalue", NULL, NULL,
DEF_MENU_ENTRY_OFF_VALUE,
- Tk_Offset(TkMenuEntry, offValuePtr), -1, 0, NULL, 0},
+ offsetof(TkMenuEntry, offValuePtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_STRING, "-onvalue", NULL, NULL,
DEF_MENU_ENTRY_ON_VALUE,
- Tk_Offset(TkMenuEntry, onValuePtr), -1, 0, NULL, 0},
+ offsetof(TkMenuEntry, onValuePtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_COLOR, "-selectcolor", NULL, NULL,
DEF_MENU_ENTRY_SELECT,
- Tk_Offset(TkMenuEntry, indicatorFgPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, indicatorFgPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_STRING, "-selectimage", NULL, NULL,
DEF_MENU_ENTRY_SELECT_IMAGE,
- Tk_Offset(TkMenuEntry, selectImagePtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, selectImagePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_STRING, "-variable", NULL, NULL,
DEF_MENU_ENTRY_CHECK_VARIABLE,
- Tk_Offset(TkMenuEntry, namePtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, namePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_END, NULL, NULL, NULL,
- NULL, 0, -1, 0, tkBasicMenuEntryConfigSpecs, 0}
+ NULL, 0, TCL_INDEX_NONE, 0, tkBasicMenuEntryConfigSpecs, 0}
};
static const Tk_OptionSpec tkRadioButtonEntryConfigSpecs[] = {
{TK_OPTION_BOOLEAN, "-indicatoron", NULL, NULL,
DEF_MENU_ENTRY_INDICATOR,
- -1, Tk_Offset(TkMenuEntry, indicatorOn), 0, NULL, 0},
+ TCL_INDEX_NONE, offsetof(TkMenuEntry, indicatorOn), 0, NULL, 0},
{TK_OPTION_COLOR, "-selectcolor", NULL, NULL,
DEF_MENU_ENTRY_SELECT,
- Tk_Offset(TkMenuEntry, indicatorFgPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, indicatorFgPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_STRING, "-selectimage", NULL, NULL,
DEF_MENU_ENTRY_SELECT_IMAGE,
- Tk_Offset(TkMenuEntry, selectImagePtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, selectImagePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_STRING, "-value", NULL, NULL,
DEF_MENU_ENTRY_VALUE,
- Tk_Offset(TkMenuEntry, onValuePtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, onValuePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_STRING, "-variable", NULL, NULL,
DEF_MENU_ENTRY_RADIO_VARIABLE,
- Tk_Offset(TkMenuEntry, namePtr), -1, 0, NULL, 0},
+ offsetof(TkMenuEntry, namePtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_END, NULL, NULL, NULL,
- NULL, 0, -1, 0, tkBasicMenuEntryConfigSpecs, 0}
+ NULL, 0, TCL_INDEX_NONE, 0, tkBasicMenuEntryConfigSpecs, 0}
};
static const Tk_OptionSpec tkCascadeEntryConfigSpecs[] = {
{TK_OPTION_STRING, "-menu", NULL, NULL,
DEF_MENU_ENTRY_MENU,
- Tk_Offset(TkMenuEntry, namePtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, namePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_END, NULL, NULL, NULL,
- NULL, 0, -1, 0, tkBasicMenuEntryConfigSpecs, 0}
+ NULL, 0, TCL_INDEX_NONE, 0, tkBasicMenuEntryConfigSpecs, 0}
};
static const Tk_OptionSpec tkTearoffEntryConfigSpecs[] = {
{TK_OPTION_BORDER, "-background", NULL, NULL,
DEF_MENU_ENTRY_BG,
- Tk_Offset(TkMenuEntry, borderPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenuEntry, borderPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_STRING_TABLE, "-state", NULL, NULL,
- DEF_MENU_ENTRY_STATE, -1, Tk_Offset(TkMenuEntry, state), 0,
+ DEF_MENU_ENTRY_STATE, TCL_INDEX_NONE, offsetof(TkMenuEntry, state), 0,
(ClientData) menuStateStrings, 0},
{TK_OPTION_END, NULL, NULL, NULL, 0, 0, 0, 0, NULL, 0}
};
@@ -250,59 +250,62 @@ static const char *const menuTypeStrings[] = {
static const Tk_OptionSpec tkMenuConfigSpecs[] = {
{TK_OPTION_BORDER, "-activebackground", "activeBackground",
"Foreground", DEF_MENU_ACTIVE_BG_COLOR,
- Tk_Offset(TkMenu, activeBorderPtr), -1, 0,
+ offsetof(TkMenu, activeBorderPtr), TCL_INDEX_NONE, 0,
(ClientData) DEF_MENU_ACTIVE_BG_MONO, 0},
{TK_OPTION_PIXELS, "-activeborderwidth", "activeBorderWidth",
"BorderWidth", DEF_MENU_ACTIVE_BORDER_WIDTH,
- Tk_Offset(TkMenu, activeBorderWidthPtr), -1, 0, NULL, 0},
+ offsetof(TkMenu, activeBorderWidthPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_COLOR, "-activeforeground", "activeForeground",
"Background", DEF_MENU_ACTIVE_FG_COLOR,
- Tk_Offset(TkMenu, activeFgPtr), -1, 0,
+ offsetof(TkMenu, activeFgPtr), TCL_INDEX_NONE, 0,
(ClientData) DEF_MENU_ACTIVE_FG_MONO, 0},
+ {TK_OPTION_RELIEF, "-activerelief", "activeRelief", "Relief",
+ DEF_MENU_ACTIVE_RELIEF, offsetof(TkMenu, activeReliefPtr),
+ TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_MENU_BG_COLOR, Tk_Offset(TkMenu, borderPtr), -1, 0,
+ DEF_MENU_BG_COLOR, offsetof(TkMenu, borderPtr), TCL_INDEX_NONE, 0,
(ClientData) DEF_MENU_BG_MONO, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL,
- NULL, 0, -1, 0, "-background", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
DEF_MENU_BORDER_WIDTH,
- Tk_Offset(TkMenu, borderWidthPtr), -1, 0, NULL, 0},
+ offsetof(TkMenu, borderWidthPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
DEF_MENU_CURSOR,
- Tk_Offset(TkMenu, cursorPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenu, cursorPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_COLOR, "-disabledforeground", "disabledForeground",
"DisabledForeground", DEF_MENU_DISABLED_FG_COLOR,
- Tk_Offset(TkMenu, disabledFgPtr), -1, TK_OPTION_NULL_OK,
+ offsetof(TkMenu, disabledFgPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK,
(ClientData) DEF_MENU_DISABLED_FG_MONO, 0},
{TK_OPTION_SYNONYM, "-fg", NULL, NULL,
- NULL, 0, -1, 0, "-foreground", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_MENU_FONT, Tk_Offset(TkMenu, fontPtr), -1, 0, NULL, 0},
+ DEF_MENU_FONT, offsetof(TkMenu, fontPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_MENU_FG, Tk_Offset(TkMenu, fgPtr), -1, 0, NULL, 0},
+ DEF_MENU_FG, offsetof(TkMenu, fgPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_STRING, "-postcommand", "postCommand", "Command",
DEF_MENU_POST_COMMAND,
- Tk_Offset(TkMenu, postCommandPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenu, postCommandPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_MENU_RELIEF, Tk_Offset(TkMenu, reliefPtr), -1, 0, NULL, 0},
+ DEF_MENU_RELIEF, offsetof(TkMenu, reliefPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_COLOR, "-selectcolor", "selectColor", "Background",
- DEF_MENU_SELECT_COLOR, Tk_Offset(TkMenu, indicatorFgPtr), -1, 0,
+ DEF_MENU_SELECT_COLOR, offsetof(TkMenu, indicatorFgPtr), TCL_INDEX_NONE, 0,
(ClientData) DEF_MENU_SELECT_MONO, 0},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
DEF_MENU_TAKE_FOCUS,
- Tk_Offset(TkMenu, takeFocusPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenu, takeFocusPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_BOOLEAN, "-tearoff", "tearOff", "TearOff",
- DEF_MENU_TEAROFF, -1, Tk_Offset(TkMenu, tearoff), 0, NULL, 0},
+ DEF_MENU_TEAROFF, TCL_INDEX_NONE, offsetof(TkMenu, tearoff), 0, NULL, 0},
{TK_OPTION_STRING, "-tearoffcommand", "tearOffCommand",
"TearOffCommand", DEF_MENU_TEAROFF_CMD,
- Tk_Offset(TkMenu, tearoffCommandPtr), -1, TK_OPTION_NULL_OK, NULL, 0},
+ offsetof(TkMenu, tearoffCommandPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_STRING, "-title", "title", "Title",
- DEF_MENU_TITLE, Tk_Offset(TkMenu, titlePtr), -1,
+ DEF_MENU_TITLE, offsetof(TkMenu, titlePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, NULL, 0},
{TK_OPTION_STRING_TABLE, "-type", "type", "Type",
- DEF_MENU_TYPE, Tk_Offset(TkMenu, menuTypePtr), -1, TK_OPTION_NULL_OK,
+ DEF_MENU_TYPE, offsetof(TkMenu, menuTypePtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK,
(ClientData) menuTypeStrings, 0},
{TK_OPTION_END, NULL, NULL, NULL, 0, 0, 0, 0, NULL, 0}
};
@@ -343,9 +346,9 @@ static void DestroyMenuHashTable(ClientData clientData,
Tcl_Interp *interp);
static void DestroyMenuInstance(TkMenu *menuPtr);
static void DestroyMenuEntry(void *memPtr);
-static int GetIndexFromCoords(Tcl_Interp *interp,
+static TkSizeT GetIndexFromCoords(Tcl_Interp *interp,
TkMenu *menuPtr, const char *string,
- int *indexPtr);
+ TkSizeT *indexPtr);
static int MenuDoYPosition(Tcl_Interp *interp,
TkMenu *menuPtr, Tcl_Obj *objPtr);
static int MenuDoXPosition(Tcl_Interp *interp,
@@ -354,7 +357,7 @@ static int MenuAddOrInsert(Tcl_Interp *interp,
TkMenu *menuPtr, Tcl_Obj *indexPtr, int objc,
Tcl_Obj *const objv[]);
static void MenuCmdDeletedProc(ClientData clientData);
-static TkMenuEntry * MenuNewEntry(TkMenu *menuPtr, int index, int type);
+static TkMenuEntry * MenuNewEntry(TkMenu *menuPtr, TkSizeT index, int type);
static char * MenuVarProc(ClientData clientData,
Tcl_Interp *interp, const char *name1,
const char *name2, int flags);
@@ -365,7 +368,9 @@ static void MenuWorldChanged(ClientData instanceData);
static int PostProcessEntry(TkMenuEntry *mePtr);
static void RecursivelyDeleteMenu(TkMenu *menuPtr);
static void UnhookCascadeEntry(TkMenuEntry *mePtr);
-static void TkMenuCleanup(ClientData unused);
+static void MenuCleanup(ClientData unused);
+static int GetMenuIndex(Tcl_Interp *interp, TkMenu *menuPtr,
+ Tcl_Obj *objPtr, int lastOK, TkSizeT *indexPtr);
/*
* The structure below is a list of procs that respond to certain window
@@ -404,14 +409,14 @@ Tk_MenuObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
{
- Tk_Window tkwin = clientData;
+ Tk_Window tkwin = (Tk_Window)clientData;
Tk_Window newWin;
- register TkMenu *menuPtr;
+ TkMenu *menuPtr;
TkMenuReferences *menuRefPtr;
int i, index, toplevel;
const char *windowName;
static const char *const typeStringList[] = {"-type", NULL};
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (objc < 2) {
@@ -446,7 +451,7 @@ Tk_MenuObjCmd(
* Tcl_EventuallyFree is called.
*/
- menuPtr = ckalloc(sizeof(TkMenu));
+ menuPtr = (TkMenu *)ckalloc(sizeof(TkMenu));
memset(menuPtr, 0, sizeof(TkMenu));
menuPtr->tkwin = newWin;
menuPtr->display = Tk_Display(newWin);
@@ -454,9 +459,9 @@ 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;
TkMenuInitializeDrawingFields(menuPtr);
@@ -465,7 +470,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);
@@ -521,9 +526,9 @@ 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[1] = Tcl_NewStringObj(Tk_PathName(menuPtr->tkwin),-1);
@@ -588,7 +593,7 @@ Tk_MenuObjCmd(
}
}
- Tcl_SetObjResult(interp, TkNewWindowObj(menuPtr->tkwin));
+ Tcl_SetObjResult(interp, Tk_NewWindowObj(menuPtr->tkwin));
return TCL_OK;
}
@@ -617,11 +622,11 @@ MenuWidgetObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
{
- register TkMenu *menuPtr = clientData;
- register TkMenuEntry *mePtr;
+ TkMenu *menuPtr = (TkMenu *)clientData;
+ TkMenuEntry *mePtr;
int result = TCL_OK;
int option;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (objc < 2) {
@@ -636,21 +641,21 @@ MenuWidgetObjCmd(
switch ((enum options) option) {
case MENU_ACTIVATE: {
- int index;
+ TkSizeT index;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "index");
goto error;
}
- if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
+ if (GetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
goto error;
}
if (menuPtr->active == index) {
goto done;
}
- if ((index >= 0) && ((menuPtr->entries[index]->type==SEPARATOR_ENTRY)
+ if ((index != TCL_INDEX_NONE) && ((menuPtr->entries[index]->type==SEPARATOR_ENTRY)
|| (menuPtr->entries[index]->state == ENTRY_DISABLED))) {
- index = -1;
+ index = TCL_INDEX_NONE;
}
result = TkActivateMenuEntry(menuPtr, index);
break;
@@ -672,7 +677,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) {
@@ -692,7 +697,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) {
@@ -702,7 +707,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) {
@@ -720,7 +725,8 @@ MenuWidgetObjCmd(
break;
}
case MENU_DELETE: {
- int first, last;
+ TkSizeT first, last;
+ Tcl_WideInt w;
if ((objc != 3) && (objc != 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "first ?last?");
@@ -733,16 +739,17 @@ MenuWidgetObjCmd(
*/
if (isdigit(UCHAR(Tcl_GetString(objv[2])[0]))
- && Tcl_GetIntFromObj(NULL, objv[2], &first) == TCL_OK) {
+ && Tcl_GetWideIntFromObj(NULL, objv[2], &w) == TCL_OK) {
+ first = w;
if (first >= menuPtr->numEntries) {
goto done;
}
- } else if (TkGetMenuIndex(interp,menuPtr,objv[2],0,&first) != TCL_OK){
+ } else if (GetMenuIndex(interp,menuPtr,objv[2],0,&first) != TCL_OK){
goto error;
}
if (objc == 3) {
last = first;
- } else if (TkGetMenuIndex(interp,menuPtr,objv[3],0,&last) != TCL_OK) {
+ } else if (GetMenuIndex(interp,menuPtr,objv[3],0,&last) != TCL_OK) {
goto error;
}
@@ -754,29 +761,29 @@ MenuWidgetObjCmd(
first = 1;
}
- if ((first == -1) || (last < first)) {
+ if ((first == TCL_INDEX_NONE) || (last < first)) {
goto done;
}
DeleteMenuCloneEntries(menuPtr, first, last);
break;
}
case MENU_ENTRYCGET: {
- int index;
+ TkSizeT index;
Tcl_Obj *resultPtr;
if (objc != 4) {
Tcl_WrongNumArgs(interp, 2, objv, "index option");
goto error;
}
- if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
+ if (GetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
goto error;
}
- if (index < 0) {
+ if (index == TCL_INDEX_NONE) {
goto done;
}
mePtr = menuPtr->entries[index];
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) {
@@ -786,23 +793,23 @@ MenuWidgetObjCmd(
break;
}
case MENU_ENTRYCONFIGURE: {
- int index;
+ TkSizeT index;
Tcl_Obj *resultPtr;
if (objc < 3) {
Tcl_WrongNumArgs(interp, 2, objv, "index ?-option value ...?");
goto error;
}
- if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
+ if (GetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
goto error;
}
- if (index < 0) {
+ if (index == TCL_INDEX_NONE) {
goto done;
}
mePtr = menuPtr->entries[index];
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;
@@ -811,7 +818,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;
@@ -827,20 +834,19 @@ MenuWidgetObjCmd(
break;
}
case MENU_INDEX: {
- int index;
+ TkSizeT index;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "string");
goto error;
}
- if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
+ if (GetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
goto error;
}
- if (index < 0) {
+ if (index == TCL_INDEX_NONE) {
Tcl_SetObjResult(interp, Tcl_NewStringObj("none", -1));
- } else {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(index));
- }
+ } else
+ Tcl_SetObjResult(interp, TkNewIndexObj(index));
break;
}
case MENU_INSERT:
@@ -854,23 +860,24 @@ MenuWidgetObjCmd(
}
break;
case MENU_INVOKE: {
- int index;
+ TkSizeT index;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "index");
goto error;
}
- if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
+ if (GetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
goto error;
}
- if (index < 0) {
+ if (index == TCL_INDEX_NONE) {
goto done;
}
result = TkInvokeMenu(interp, menuPtr, index);
break;
}
case MENU_POST: {
- int x, y, index = -1;
+ int x, y;
+ TkSizeT index = TCL_INDEX_NONE;
if (objc != 4 && objc != 5) {
Tcl_WrongNumArgs(interp, 2, objv, "x y ?index?");
@@ -881,7 +888,7 @@ MenuWidgetObjCmd(
goto error;
}
if (objc == 5) {
- if (TkGetMenuIndex(interp, menuPtr, objv[4], 0, &index) != TCL_OK) {
+ if (GetMenuIndex(interp, menuPtr, objv[4], 0, &index) != TCL_OK) {
goto error;
}
}
@@ -905,17 +912,17 @@ MenuWidgetObjCmd(
break;
}
case MENU_POSTCASCADE: {
- int index;
+ TkSizeT index;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "index");
goto error;
}
- if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
+ if (GetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
goto error;
}
- if ((index < 0) || (menuPtr->entries[index]->type != CASCADE_ENTRY)) {
+ if ((index == TCL_INDEX_NONE) || (menuPtr->entries[index]->type != CASCADE_ENTRY)) {
result = TkPostSubmenu(interp, menuPtr, NULL);
} else {
result = TkPostSubmenu(interp, menuPtr, menuPtr->entries[index]);
@@ -923,17 +930,17 @@ MenuWidgetObjCmd(
break;
}
case MENU_TYPE: {
- int index;
+ TkSizeT index;
const char *typeStr;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "index");
goto error;
}
- if (TkGetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
+ if (GetMenuIndex(interp, menuPtr, objv[2], 0, &index) != TCL_OK) {
goto error;
}
- if (index < 0) {
+ if (index == TCL_INDEX_NONE) {
goto done;
}
if (menuPtr->entries[index]->type == TEAROFF_ENTRY) {
@@ -998,13 +1005,13 @@ int
TkInvokeMenu(
Tcl_Interp *interp, /* The interp that the menu lives in. */
TkMenu *menuPtr, /* The menu we are invoking. */
- int index) /* The zero based index of the item we are
+ TkSizeT index) /* The zero based index of the item we are
* invoking. */
{
int result = TCL_OK;
TkMenuEntry *mePtr;
- if (index < 0) {
+ if (index == TCL_INDEX_NONE) {
goto done;
}
mePtr = menuPtr->entries[index];
@@ -1102,7 +1109,7 @@ DestroyMenuInstance(
Tcl_Obj *newObjv[2];
TkMenu *parentMainMenuPtr;
TkMenuEntry *parentMainEntryPtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -1132,10 +1139,10 @@ DestroyMenuInstance(
for (; cascadePtr != NULL; cascadePtr = nextCascadePtr) {
nextCascadePtr = cascadePtr->nextCascadePtr;
- if (menuPtr->masterMenuPtr != menuPtr) {
+ if (menuPtr->mainMenuPtr != menuPtr) {
Tcl_Obj *menuNamePtr = Tcl_NewStringObj("-menu", -1);
- parentMainMenuPtr = cascadePtr->menuPtr->masterMenuPtr;
+ parentMainMenuPtr = cascadePtr->menuPtr->mainMenuPtr;
parentMainEntryPtr =
parentMainMenuPtr->entries[cascadePtr->index];
newObjv[0] = menuNamePtr;
@@ -1158,8 +1165,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) {
@@ -1256,7 +1263,7 @@ TkDestroyMenu(
topLevelListPtr = nextTopLevelPtr;
}
}
- if (menuPtr->masterMenuPtr == menuPtr) {
+ if (menuPtr->mainMenuPtr == menuPtr) {
while (menuPtr->nextInstancePtr != NULL) {
menuInstancePtr = menuPtr->nextInstancePtr;
menuPtr->nextInstancePtr = menuInstancePtr->nextInstancePtr;
@@ -1385,7 +1392,7 @@ static void
DestroyMenuEntry(
void *memPtr) /* Pointer to entry to be freed. */
{
- register TkMenuEntry *mePtr = memPtr;
+ TkMenuEntry *mePtr = (TkMenuEntry *)memPtr;
TkMenu *menuPtr = mePtr->menuPtr;
if (menuPtr->postedCascade == mePtr) {
@@ -1404,7 +1411,7 @@ DestroyMenuEntry(
*/
if (mePtr->type == CASCADE_ENTRY) {
- if (menuPtr->masterMenuPtr != menuPtr) {
+ if (menuPtr->mainMenuPtr != menuPtr) {
TkMenu *destroyThis = NULL;
TkMenuReferences *menuRefPtr = mePtr->childMenuRefPtr;
@@ -1424,7 +1431,7 @@ DestroyMenuEntry(
*/
if ((destroyThis != NULL)
- && (destroyThis->masterMenuPtr == destroyThis)) {
+ && (destroyThis->mainMenuPtr == destroyThis)) {
destroyThis = NULL;
}
}
@@ -1485,8 +1492,8 @@ static void
MenuWorldChanged(
ClientData instanceData) /* Information about widget. */
{
- TkMenu *menuPtr = instanceData;
- int i;
+ TkMenu *menuPtr = (TkMenu *)instanceData;
+ TkSizeT i;
TkMenuConfigureDrawOptions(menuPtr);
for (i = 0; i < menuPtr->numEntries; i++) {
@@ -1519,7 +1526,7 @@ MenuWorldChanged(
static int
ConfigureMenu(
Tcl_Interp *interp, /* Used for error reporting. */
- register TkMenu *menuPtr, /* Information about widget; may or may not
+ TkMenu *menuPtr, /* Information about widget; may or may not
* already have values for some fields. */
int objc, /* Number of valid entries in argv. */
Tcl_Obj *const objv[]) /* Arguments. */
@@ -1527,17 +1534,17 @@ ConfigureMenu(
int i;
TkMenu *menuListPtr, *cleanupPtr;
int result;
- ThreadSpecificData *tsdPtr =
+ 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 = ckalloc(sizeof(Tk_SavedOptions));
- result = Tk_SetOptions(interp, (char *) menuListPtr,
+ menuListPtr->errorStructPtr = (Tk_SavedOptions *)ckalloc(sizeof(Tk_SavedOptions));
+ 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);
@@ -1606,7 +1613,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);
@@ -1626,12 +1633,11 @@ ConfigureMenu(
Tcl_EventuallyFree(menuListPtr->entries[0], (Tcl_FreeProc *) DestroyMenuEntry);
- for (i = 0; i < menuListPtr->numEntries - 1; i++) {
+ for (i = 0; i < (int)menuListPtr->numEntries - 1; i++) {
menuListPtr->entries[i] = menuListPtr->entries[i + 1];
menuListPtr->entries[i]->index = i;
}
- menuListPtr->numEntries--;
- if (menuListPtr->numEntries == 0) {
+ if (--menuListPtr->numEntries == 0) {
ckfree(menuListPtr->entries);
menuListPtr->entries = NULL;
}
@@ -1646,7 +1652,7 @@ ConfigureMenu(
* parent.
*/
- for (i = 0; i < menuListPtr->numEntries; i++) {
+ for (i = 0; i < (int)menuListPtr->numEntries; i++) {
TkMenuEntry *mePtr;
mePtr = menuListPtr->entries[i];
@@ -1656,7 +1662,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);
@@ -1704,12 +1710,12 @@ PostProcessEntry(
if (mePtr->labelPtr == NULL) {
mePtr->labelLength = 0;
} else {
- Tcl_GetStringFromObj(mePtr->labelPtr, &mePtr->labelLength);
+ (void)TkGetStringFromObj(mePtr->labelPtr, &mePtr->labelLength);
}
if (mePtr->accelPtr == NULL) {
mePtr->accelLength = 0;
} else {
- Tcl_GetStringFromObj(mePtr->accelPtr, &mePtr->accelLength);
+ (void)TkGetStringFromObj(mePtr->accelPtr, &mePtr->accelLength);
}
/*
@@ -1736,7 +1742,7 @@ PostProcessEntry(
name = Tcl_GetString(mePtr->namePtr);
if (mePtr->childMenuRefPtr != NULL) {
- oldHashKey = Tcl_GetHashKey(TkGetMenuHashTable(menuPtr->interp),
+ oldHashKey = (char *)Tcl_GetHashKey(TkGetMenuHashTable(menuPtr->interp),
mePtr->childMenuRefPtr->hashEntryPtr);
if (strcmp(oldHashKey, name) != 0) {
UnhookCascadeEntry(mePtr);
@@ -1901,7 +1907,7 @@ PostProcessEntry(
static int
ConfigureMenuEntry(
- register TkMenuEntry *mePtr,/* Information about menu entry; may or may
+ TkMenuEntry *mePtr,/* Information about menu entry; may or may
* not already have values for some fields. */
int objc, /* Number of valid entries in argv. */
Tcl_Obj *const objv[]) /* Arguments. */
@@ -1927,7 +1933,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;
@@ -1965,7 +1971,7 @@ ConfigureMenuEntry(
static int
ConfigureMenuCloneEntries(
- Tcl_Interp *interp, /* Used for error reporting. */
+ Tcl_Interp *dummy, /* Used for error reporting. */
TkMenu *menuPtr, /* Information about whole menu. */
int index, /* Index of mePtr within menuPtr's entries. */
int objc, /* Number of valid entries in argv. */
@@ -1977,6 +1983,7 @@ ConfigureMenuCloneEntries(
TkMenuReferences *oldCascadeMenuRefPtr, *cascadeMenuRefPtr = NULL;
Tcl_Obj *oldCascadePtr = NULL;
const char *newCascadeName;
+ (void)dummy;
/*
* Cascades are kind of tricky here. This is special case #3 in the
@@ -1987,7 +1994,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) {
@@ -2032,7 +2039,7 @@ ConfigureMenuCloneEntries(
}
}
- for (menuListPtr = menuPtr->masterMenuPtr->nextInstancePtr;
+ for (menuListPtr = menuPtr->mainMenuPtr->nextInstancePtr;
menuListPtr != NULL;
menuListPtr = menuListPtr->nextInstancePtr) {
@@ -2087,7 +2094,7 @@ ConfigureMenuCloneEntries(
/*
*--------------------------------------------------------------
*
- * TkGetMenuIndex --
+ * GetMenuIndex --
*
* Parse a textual index into a menu and return the numerical index of
* the indicated entry.
@@ -2105,7 +2112,7 @@ ConfigureMenuCloneEntries(
*/
int
-TkGetMenuIndex(
+GetMenuIndex(
Tcl_Interp *interp, /* For error messages. */
TkMenu *menuPtr, /* Menu for which the index is being
* specified. */
@@ -2113,52 +2120,46 @@ TkGetMenuIndex(
* manual entry for valid .*/
int lastOK, /* Non-zero means its OK to return index just
* *after* last entry. */
- int *indexPtr) /* Where to store converted index. */
+ TkSizeT *indexPtr) /* Where to store converted index. */
{
int i;
- const char *string = Tcl_GetString(objPtr);
+ const char *string;
+
+ if (TkGetIntForIndex(objPtr, menuPtr->numEntries - 1, lastOK, indexPtr) == TCL_OK) {
+ /* TCL_INDEX_NONE is only accepted if it does not result from a negative number */
+ if (*indexPtr != TCL_INDEX_NONE || 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;
goto success;
}
- if (((string[0] == 'l') && (strcmp(string, "last") == 0))
- || ((string[0] == 'e') && (strcmp(string, "end") == 0))) {
+ if ((string[0] == 'l') && (strcmp(string, "last") == 0)) {
*indexPtr = menuPtr->numEntries - ((lastOK) ? 0 : 1);
goto success;
}
if ((string[0] == 'n') && (strcmp(string, "none") == 0)) {
- *indexPtr = -1;
+ *indexPtr = TCL_INDEX_NONE;
goto success;
}
if (string[0] == '@') {
- if (GetIndexFromCoords(interp, menuPtr, string, indexPtr)
+ if (GetIndexFromCoords(NULL, menuPtr, string, indexPtr)
== TCL_OK) {
goto success;
}
}
- if (isdigit(UCHAR(string[0]))) {
- if (Tcl_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;
- goto success;
- }
- Tcl_ResetResult(interp);
- }
-
- for (i = 0; i < menuPtr->numEntries; i++) {
+ for (i = 0; i < (int)menuPtr->numEntries; i++) {
Tcl_Obj *labelPtr = menuPtr->entries[i]->labelPtr;
const char *label = (labelPtr == NULL) ? NULL : Tcl_GetString(labelPtr);
@@ -2199,7 +2200,7 @@ static void
MenuCmdDeletedProc(
ClientData clientData) /* Pointer to widget record for widget. */
{
- TkMenu *menuPtr = clientData;
+ TkMenu *menuPtr = (TkMenu *)clientData;
Tk_Window tkwin = menuPtr->tkwin;
/*
@@ -2241,21 +2242,21 @@ MenuCmdDeletedProc(
static TkMenuEntry *
MenuNewEntry(
TkMenu *menuPtr, /* Menu that will hold the new entry. */
- int index, /* Where in the menu the new entry is to
+ TkSizeT index, /* Where in the menu the new entry is to
* go. */
int type) /* The type of the new entry. */
{
TkMenuEntry *mePtr;
TkMenuEntry **newEntries;
- int i;
- ThreadSpecificData *tsdPtr =
+ TkSizeT i;
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
* Create a new array of entries with an empty slot for the new entry.
*/
- newEntries = ckalloc((menuPtr->numEntries+1) * sizeof(TkMenuEntry *));
+ newEntries = (TkMenuEntry **)ckalloc((menuPtr->numEntries+1) * sizeof(TkMenuEntry *));
for (i = 0; i < index; i++) {
newEntries[i] = menuPtr->entries[i];
}
@@ -2268,7 +2269,7 @@ MenuNewEntry(
}
menuPtr->entries = newEntries;
menuPtr->numEntries++;
- mePtr = ckalloc(sizeof(TkMenuEntry));
+ mePtr = (TkMenuEntry *)ckalloc(sizeof(TkMenuEntry));
menuPtr->entries[index] = mePtr;
mePtr->type = type;
mePtr->optionTable = tsdPtr->entryOptionTables[type];
@@ -2301,7 +2302,7 @@ 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;
@@ -2344,20 +2345,21 @@ MenuAddOrInsert(
Tcl_Obj *const objv[]) /* Arguments to command: first arg is type of
* entry, others are config options. */
{
- int type, index;
+ int type;
+ TkSizeT index;
TkMenuEntry *mePtr;
TkMenu *menuListPtr;
if (indexPtr != NULL) {
- if (TkGetMenuIndex(interp, menuPtr, indexPtr, 1, &index) != TCL_OK) {
+ if (GetMenuIndex(interp, menuPtr, indexPtr, 1, &index) != TCL_OK) {
return TCL_ERROR;
}
} else {
index = menuPtr->numEntries;
}
- if (index < 0) {
+ if (index == TCL_INDEX_NONE) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "bad index \"%s\"", Tcl_GetString(indexPtr)));
+ "bad menu entry index \"%s\"", Tcl_GetString(indexPtr)));
Tcl_SetErrorCode(interp, "TK", "MENU", "INDEX", NULL);
return TCL_ERROR;
}
@@ -2378,7 +2380,7 @@ MenuAddOrInsert(
* Now we have to add an entry for every instance related to this menu.
*/
- for (menuListPtr = menuPtr->masterMenuPtr; menuListPtr != NULL;
+ for (menuListPtr = menuPtr->mainMenuPtr; menuListPtr != NULL;
menuListPtr = menuListPtr->nextInstancePtr) {
mePtr = MenuNewEntry(menuListPtr, index, type);
@@ -2387,9 +2389,9 @@ MenuAddOrInsert(
}
if (ConfigureMenuEntry(mePtr, objc - 1, objv + 1) != TCL_OK) {
TkMenu *errorMenuPtr;
- int i;
+ TkSizeT i;
- for (errorMenuPtr = menuPtr->masterMenuPtr;
+ for (errorMenuPtr = menuPtr->mainMenuPtr;
errorMenuPtr != NULL;
errorMenuPtr = errorMenuPtr->nextInstancePtr) {
Tcl_EventuallyFree(errorMenuPtr->entries[index],
@@ -2398,8 +2400,7 @@ MenuAddOrInsert(
errorMenuPtr->entries[i] = errorMenuPtr->entries[i + 1];
errorMenuPtr->entries[i]->index = i;
}
- errorMenuPtr->numEntries--;
- if (errorMenuPtr->numEntries == 0) {
+ if (--errorMenuPtr->numEntries == 0) {
ckfree(errorMenuPtr->entries);
errorMenuPtr->entries = NULL;
}
@@ -2423,7 +2424,7 @@ 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 *windowNamePtr =
@@ -2484,10 +2485,12 @@ MenuVarProc(
const char *name2, /* Second part of variable's name. */
int flags) /* Describes what just happened. */
{
- TkMenuEntry *mePtr = clientData;
+ TkMenuEntry *mePtr = (TkMenuEntry *)clientData;
TkMenu *menuPtr;
const char *value;
const char *name, *onValue;
+ (void)name1;
+ (void)name2;
if (Tcl_InterpDeleted(interp) || (mePtr->namePtr == NULL)) {
/*
@@ -2589,14 +2592,14 @@ MenuVarProc(
int
TkActivateMenuEntry(
- register TkMenu *menuPtr, /* Menu in which to activate. */
- int index) /* Index of entry to activate, or -1 to
- * deactivate all entries. */
+ TkMenu *menuPtr, /* Menu in which to activate. */
+ TkSizeT index) /* Index of entry to activate, or
+ * TCL_INDEX_NONE to deactivate all entries. */
{
- register TkMenuEntry *mePtr;
+ TkMenuEntry *mePtr;
int result = TCL_OK;
- if (menuPtr->active >= 0) {
+ if (menuPtr->active != TCL_INDEX_NONE) {
mePtr = menuPtr->entries[menuPtr->active];
/*
@@ -2610,7 +2613,7 @@ TkActivateMenuEntry(
TkEventuallyRedrawMenu(menuPtr, menuPtr->entries[menuPtr->active]);
}
menuPtr->active = index;
- if (index >= 0) {
+ if (index != TCL_INDEX_NONE) {
mePtr = menuPtr->entries[index];
mePtr->state = ENTRY_ACTIVE;
TkEventuallyRedrawMenu(menuPtr, mePtr);
@@ -2739,14 +2742,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;
}
/*
@@ -2776,7 +2779,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), -1);
/*
* The newElementPtr will have its refCount incremented
@@ -2801,7 +2804,7 @@ CloneMenu(
* Clone all of the cascade menus that this menu points to.
*/
- for (i = 0; i < menuPtr->numEntries; i++) {
+ for (i = 0; i < (int)menuPtr->numEntries; i++) {
TkMenuReferences *cascadeRefPtr;
TkMenu *oldCascadePtr;
@@ -2865,17 +2868,17 @@ MenuDoXPosition(
TkMenu *menuPtr,
Tcl_Obj *objPtr)
{
- int index;
+ TkSizeT index;
TkRecomputeMenu(menuPtr);
- if (TkGetMenuIndex(interp, menuPtr, objPtr, 0, &index) != TCL_OK) {
+ if (GetMenuIndex(interp, menuPtr, objPtr, 0, &index) != TCL_OK) {
return TCL_ERROR;
}
Tcl_ResetResult(interp);
- if (index < 0) {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(0));
+ if (index == TCL_INDEX_NONE) {
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(0));
} else {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(menuPtr->entries[index]->x));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(menuPtr->entries[index]->x));
}
return TCL_OK;
}
@@ -2902,17 +2905,17 @@ MenuDoYPosition(
TkMenu *menuPtr,
Tcl_Obj *objPtr)
{
- int index;
+ TkSizeT index;
TkRecomputeMenu(menuPtr);
- if (TkGetMenuIndex(interp, menuPtr, objPtr, 0, &index) != TCL_OK) {
+ if (GetMenuIndex(interp, menuPtr, objPtr, 0, &index) != TCL_OK) {
goto error;
}
Tcl_ResetResult(interp);
- if (index < 0) {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(0));
+ if (index == TCL_INDEX_NONE) {
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(0));
} else {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(menuPtr->entries[index]->y));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(menuPtr->entries[index]->y));
}
return TCL_OK;
@@ -2940,12 +2943,12 @@ MenuDoYPosition(
*----------------------------------------------------------------------
*/
-static int
+static TkSizeT
GetIndexFromCoords(
Tcl_Interp *interp, /* Interpreter of menu. */
TkMenu *menuPtr, /* The menu we are searching. */
const char *string, /* The @string we are parsing. */
- int *indexPtr) /* The index of the item that matches. */
+ TkSizeT *indexPtr) /* The index of the item that matches. */
{
int x, y, i;
const char *p;
@@ -2980,7 +2983,7 @@ GetIndexFromCoords(
? Tk_Width(menuPtr->tkwin) : Tk_ReqWidth(menuPtr->tkwin);
max -= borderwidth;
- for (i = 0; i < menuPtr->numEntries; i++) {
+ for (i = 0; i < (int)menuPtr->numEntries; i++) {
if (menuPtr->entries[i]->entryFlags & ENTRY_LAST_COLUMN) {
x2 = max;
} else {
@@ -3023,7 +3026,7 @@ static void
RecursivelyDeleteMenu(
TkMenu *menuPtr) /* The menubar instance we are deleting. */
{
- int i;
+ TkSizeT i;
TkMenuEntry *mePtr;
/*
@@ -3110,7 +3113,7 @@ TkNewMenuName(
Tcl_AppendToObj(resultPtr, ".", -1);
}
Tcl_AppendObjToObj(resultPtr, childPtr);
- intPtr = Tcl_NewIntObj(i);
+ intPtr = Tcl_NewWideIntObj(i);
Tcl_AppendObjToObj(resultPtr, intPtr);
Tcl_DecrRefCount(intPtr);
}
@@ -3176,7 +3179,7 @@ TkSetWindowMenuBar(
menuPtr = menuRefPtr->menuPtr;
- for (instancePtr = menuPtr->masterMenuPtr;
+ for (instancePtr = menuPtr->mainMenuPtr;
instancePtr != NULL;
instancePtr = instancePtr->nextInstancePtr) {
if (instancePtr->menuType == MENUBAR
@@ -3279,7 +3282,7 @@ TkSetWindowMenuBar(
* menu.
*/
- topLevelListPtr = ckalloc(sizeof(TkMenuTopLevelList));
+ topLevelListPtr = (TkMenuTopLevelList *)ckalloc(sizeof(TkMenuTopLevelList));
topLevelListPtr->tkwin = tkwin;
topLevelListPtr->nextPtr = menuRefPtr->topLevelListPtr;
menuRefPtr->topLevelListPtr = topLevelListPtr;
@@ -3309,9 +3312,11 @@ TkSetWindowMenuBar(
static void
DestroyMenuHashTable(
ClientData clientData, /* The menu hash table we are destroying. */
- Tcl_Interp *interp) /* The interpreter we are destroying. */
+ Tcl_Interp *dummy) /* The interpreter we are destroying. */
{
- Tcl_DeleteHashTable(clientData);
+ (void)dummy;
+
+ Tcl_DeleteHashTable((Tcl_HashTable *)clientData);
ckfree(clientData);
}
@@ -3337,11 +3342,11 @@ Tcl_HashTable *
TkGetMenuHashTable(
Tcl_Interp *interp) /* The interp we need the hash table in.*/
{
- Tcl_HashTable *menuTablePtr =
+ Tcl_HashTable *menuTablePtr = (Tcl_HashTable *)
Tcl_GetAssocData(interp, MENU_HASH_KEY, NULL);
if (menuTablePtr == NULL) {
- menuTablePtr = ckalloc(sizeof(Tcl_HashTable));
+ menuTablePtr = (Tcl_HashTable *)ckalloc(sizeof(Tcl_HashTable));
Tcl_InitHashTable(menuTablePtr, TCL_STRING_KEYS);
Tcl_SetAssocData(interp, MENU_HASH_KEY, DestroyMenuHashTable,
menuTablePtr);
@@ -3382,14 +3387,14 @@ TkCreateMenuReferences(
hashEntryPtr = Tcl_CreateHashEntry(menuTablePtr, pathName, &newEntry);
if (newEntry) {
- menuRefPtr = ckalloc(sizeof(TkMenuReferences));
+ menuRefPtr = (TkMenuReferences *)ckalloc(sizeof(TkMenuReferences));
menuRefPtr->menuPtr = NULL;
menuRefPtr->topLevelListPtr = NULL;
menuRefPtr->parentEntryPtr = NULL;
menuRefPtr->hashEntryPtr = hashEntryPtr;
Tcl_SetHashValue(hashEntryPtr, menuRefPtr);
} else {
- menuRefPtr = Tcl_GetHashValue(hashEntryPtr);
+ menuRefPtr = (TkMenuReferences *)Tcl_GetHashValue(hashEntryPtr);
}
return menuRefPtr;
}
@@ -3426,7 +3431,7 @@ TkFindMenuReferences(
menuTablePtr = TkGetMenuHashTable(interp);
hashEntryPtr = Tcl_FindHashEntry(menuTablePtr, pathName);
if (hashEntryPtr != NULL) {
- menuRefPtr = Tcl_GetHashValue(hashEntryPtr);
+ menuRefPtr = (TkMenuReferences *)Tcl_GetHashValue(hashEntryPtr);
}
return menuRefPtr;
}
@@ -3522,12 +3527,12 @@ DeleteMenuCloneEntries(
int 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], (Tcl_FreeProc *) DestroyMenuEntry);
}
- for (i = last + 1; i < menuListPtr->numEntries; i++) {
+ for (i = last + 1; i < (int)menuListPtr->numEntries; i++) {
j = i - numDeleted;
menuListPtr->entries[j] = menuListPtr->entries[i];
menuListPtr->entries[j]->index = j;
@@ -3537,10 +3542,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);
@@ -3550,7 +3555,7 @@ DeleteMenuCloneEntries(
/*
*----------------------------------------------------------------------
*
- * TkMenuCleanup --
+ * MenuCleanup --
*
* Resets menusInitialized to allow Tk to be finalized and reused without
* the DLL being unloaded.
@@ -3565,9 +3570,11 @@ DeleteMenuCloneEntries(
*/
static void
-TkMenuCleanup(
- ClientData unused)
+MenuCleanup(
+ ClientData dummy)
{
+ (void)dummy;
+
menusInitialized = 0;
}
@@ -3591,7 +3598,7 @@ TkMenuCleanup(
void
TkMenuInit(void)
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (!menusInitialized) {
@@ -3605,7 +3612,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 386b204..ee7405a 100644
--- a/generic/tkMenu.h
+++ b/generic/tkMenu.h
@@ -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. */
+ TkSizeT 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
+ TkSizeT 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
@@ -263,9 +263,9 @@ typedef struct TkMenu {
Tcl_Command widgetCmd; /* Token for menu's widget command. */
TkMenuEntry **entries; /* Array of pointers to all the entries in the
* menu. NULL means no entries. */
- int numEntries; /* Number of elements in entries. */
- int active; /* Index of active entry. -1 means nothing
- * active. */
+ TkSizeT numEntries; /* Number of elements in entries. */
+ TkSizeT active; /* Index of active entry. TCL_INDEX_NONE means
+ * nothing active. */
int menuType; /* MAIN_MENU, TEAROFF_MENU, or MENUBAR. See
* below for definitions. */
Tcl_Obj *menuTypePtr; /* Used to control whether created tkwin is a
@@ -351,7 +351,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 +378,7 @@ 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. */
} TkMenu;
/*
@@ -461,7 +462,6 @@ typedef struct TkMenuReferences {
#define UNKNOWN_TYPE -1
#define MAIN_MENU 0
-#define MASTER_MENU 0
#define TEAROFF_MENU 1
#define MENUBAR 2
@@ -478,7 +478,7 @@ typedef struct TkMenuReferences {
* the outside world:
*/
-MODULE_SCOPE int TkActivateMenuEntry(TkMenu *menuPtr, int index);
+MODULE_SCOPE int TkActivateMenuEntry(TkMenu *menuPtr, TkSizeT index);
MODULE_SCOPE void TkBindMenu(Tk_Window tkwin, TkMenu *menuPtr);
MODULE_SCOPE TkMenuReferences*TkCreateMenuReferences(Tcl_Interp *interp,
const char *name);
@@ -491,15 +491,13 @@ MODULE_SCOPE TkMenuReferences*TkFindMenuReferencesObj(Tcl_Interp *interp,
Tcl_Obj *namePtr);
MODULE_SCOPE int TkFreeMenuReferences(TkMenuReferences *menuRefPtr);
MODULE_SCOPE Tcl_HashTable *TkGetMenuHashTable(Tcl_Interp *interp);
-MODULE_SCOPE int TkGetMenuIndex(Tcl_Interp *interp, TkMenu *menuPtr,
- Tcl_Obj *objPtr, int lastOK, int *indexPtr);
MODULE_SCOPE void TkMenuInitializeDrawingFields(TkMenu *menuPtr);
MODULE_SCOPE void TkMenuInitializeEntryDrawingFields(TkMenuEntry *mePtr);
MODULE_SCOPE int TkInvokeMenu(Tcl_Interp *interp, TkMenu *menuPtr,
- int index);
+ TkSizeT index);
MODULE_SCOPE void TkMenuConfigureDrawOptions(TkMenu *menuPtr);
MODULE_SCOPE int TkMenuConfigureEntryDrawOptions(
- TkMenuEntry *mePtr, int index);
+ TkMenuEntry *mePtr, TkSizeT index);
MODULE_SCOPE void TkMenuFreeDrawOptions(TkMenu *menuPtr);
MODULE_SCOPE void TkMenuEntryFreeDrawOptions(TkMenuEntry *mePtr);
MODULE_SCOPE void TkMenuEventProc(ClientData clientData,
diff --git a/generic/tkMenuDraw.c b/generic/tkMenuDraw.c
index 89f4a2b..2512f7c 100644
--- a/generic/tkMenuDraw.c
+++ b/generic/tkMenuDraw.c
@@ -298,7 +298,7 @@ TkMenuConfigureDrawOptions(
int
TkMenuConfigureEntryDrawOptions(
TkMenuEntry *mePtr,
- int index)
+ TkSizeT index)
{
XGCValues gcValues;
GC newGC, newActiveGC, newDisabledGC, newIndicatorGC;
@@ -483,11 +483,11 @@ TkRecomputeMenu(
void
TkEventuallyRedrawMenu(
- register TkMenu *menuPtr, /* Information about menu to redraw. */
- register TkMenuEntry *mePtr)/* Entry to redraw. NULL means redraw all the
+ TkMenu *menuPtr, /* Information about menu to redraw. */
+ TkMenuEntry *mePtr)/* Entry to redraw. NULL means redraw all the
* entries in the menu. */
{
- int i;
+ TkSizeT i;
if (menuPtr->tkwin == NULL) {
return;
@@ -530,7 +530,7 @@ static void
ComputeMenuGeometry(
ClientData clientData) /* Structure describing menu. */
{
- TkMenu *menuPtr = clientData;
+ TkMenu *menuPtr = (TkMenu *)clientData;
if (menuPtr->tkwin == NULL) {
return;
@@ -586,7 +586,13 @@ TkMenuSelectImageProc(
* <=0). */
int imgWidth, int imgHeight)/* New dimensions of image. */
{
- register TkMenuEntry *mePtr = clientData;
+ TkMenuEntry *mePtr = (TkMenuEntry *)clientData;
+ (void)x;
+ (void)y;
+ (void)width;
+ (void)height;
+ (void)imgWidth;
+ (void)imgHeight;
if ((mePtr->entryFlags & ENTRY_SELECTED)
&& !(mePtr->menuPtr->menuFlags & REDRAW_PENDING)) {
@@ -615,10 +621,11 @@ static void
DisplayMenu(
ClientData clientData) /* Information about widget. */
{
- register TkMenu *menuPtr = clientData;
- register TkMenuEntry *mePtr;
- register Tk_Window tkwin = menuPtr->tkwin;
- int index, strictMotif;
+ TkMenu *menuPtr = (TkMenu *)clientData;
+ TkMenuEntry *mePtr;
+ Tk_Window tkwin = menuPtr->tkwin;
+ TkSizeT index;
+ int strictMotif;
Tk_Font tkfont;
Tk_FontMetrics menuMetrics;
int width;
@@ -759,7 +766,7 @@ TkMenuEventProc(
ClientData clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
- TkMenu *menuPtr = clientData;
+ TkMenu *menuPtr = (TkMenu *)clientData;
if ((eventPtr->type == Expose) && (eventPtr->xexpose.count == 0)) {
TkEventuallyRedrawMenu(menuPtr, NULL);
@@ -824,7 +831,13 @@ TkMenuImageProc(
* <=0). */
int imgWidth, int imgHeight)/* New dimensions of image. */
{
- register TkMenu *menuPtr = ((TkMenuEntry *) clientData)->menuPtr;
+ TkMenu *menuPtr = (TkMenu *)((TkMenuEntry *) clientData)->menuPtr;
+ (void)x;
+ (void)y;
+ (void)width;
+ (void)height;
+ (void)imgWidth;
+ (void)imgHeight;
if ((menuPtr->tkwin != NULL) && !(menuPtr->menuFlags & RESIZE_PENDING)) {
menuPtr->menuFlags |= RESIZE_PENDING;
@@ -882,8 +895,8 @@ int
TkPostSubmenu(
Tcl_Interp *interp, /* Used for invoking sub-commands and
* reporting errors. */
- register TkMenu *menuPtr, /* Information about menu as a whole. */
- register TkMenuEntry *mePtr)/* Info about submenu that is to be posted.
+ TkMenu *menuPtr, /* Information about menu as a whole. */
+ TkMenuEntry *mePtr)/* Info about submenu that is to be posted.
* NULL means make sure that no submenu is
* posted. */
{
@@ -941,8 +954,8 @@ TkPostSubmenu(
menuPtr->postedCascade = mePtr;
subary[0] = mePtr->namePtr;
subary[1] = Tcl_NewStringObj("post", -1);
- subary[2] = Tcl_NewIntObj(x);
- subary[3] = Tcl_NewIntObj(y);
+ subary[2] = Tcl_NewWideIntObj(x);
+ subary[3] = Tcl_NewWideIntObj(y);
Tcl_IncrRefCount(subary[1]);
Tcl_IncrRefCount(subary[2]);
Tcl_IncrRefCount(subary[3]);
diff --git a/generic/tkMenubutton.c b/generic/tkMenubutton.c
index 2228a2e..b12e0eb 100644
--- a/generic/tkMenubutton.c
+++ b/generic/tkMenubutton.c
@@ -13,7 +13,6 @@
#include "tkInt.h"
#include "tkMenubutton.h"
-#include "default.h"
/*
* The structure below defines menubutton class behavior by means of
@@ -60,99 +59,99 @@ static const char *const compoundStrings[] = {
static const Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_BORDER, "-activebackground", "activeBackground", "Foreground",
- DEF_MENUBUTTON_ACTIVE_BG_COLOR, -1,
- Tk_Offset(TkMenuButton, activeBorder), 0,
+ DEF_MENUBUTTON_ACTIVE_BG_COLOR, TCL_INDEX_NONE,
+ offsetof(TkMenuButton, activeBorder), 0,
(ClientData) DEF_MENUBUTTON_ACTIVE_BG_MONO, 0},
{TK_OPTION_COLOR, "-activeforeground", "activeForeground", "Background",
- DEF_MENUBUTTON_ACTIVE_FG_COLOR, -1,
- Tk_Offset(TkMenuButton, activeFg),
+ DEF_MENUBUTTON_ACTIVE_FG_COLOR, TCL_INDEX_NONE,
+ offsetof(TkMenuButton, activeFg),
0, DEF_MENUBUTTON_ACTIVE_FG_MONO, 0},
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
- DEF_MENUBUTTON_ANCHOR, -1,
- Tk_Offset(TkMenuButton, anchor), 0, 0, 0},
+ DEF_MENUBUTTON_ANCHOR, TCL_INDEX_NONE,
+ offsetof(TkMenuButton, anchor), 0, 0, 0},
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_MENUBUTTON_BG_COLOR, -1, Tk_Offset(TkMenuButton, normalBorder),
+ DEF_MENUBUTTON_BG_COLOR, TCL_INDEX_NONE, offsetof(TkMenuButton, normalBorder),
0, DEF_MENUBUTTON_BG_MONO, 0},
- {TK_OPTION_SYNONYM, "-bd", NULL, NULL, NULL, 0, -1, 0,
+ {TK_OPTION_SYNONYM, "-bd", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0,
(ClientData) "-borderwidth", 0},
- {TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, 0, -1, 0,
+ {TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0,
(ClientData) "-background", 0},
{TK_OPTION_BITMAP, "-bitmap", "bitmap", "Bitmap",
- DEF_MENUBUTTON_BITMAP, -1, Tk_Offset(TkMenuButton, bitmap),
+ DEF_MENUBUTTON_BITMAP, TCL_INDEX_NONE, offsetof(TkMenuButton, bitmap),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_MENUBUTTON_BORDER_WIDTH, -1,
- Tk_Offset(TkMenuButton, borderWidth), 0, 0, 0},
+ DEF_MENUBUTTON_BORDER_WIDTH, TCL_INDEX_NONE,
+ offsetof(TkMenuButton, borderWidth), 0, 0, 0},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_MENUBUTTON_CURSOR, -1, Tk_Offset(TkMenuButton, cursor),
+ DEF_MENUBUTTON_CURSOR, TCL_INDEX_NONE, offsetof(TkMenuButton, cursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING_TABLE, "-direction", "direction", "Direction",
- DEF_MENUBUTTON_DIRECTION, -1, Tk_Offset(TkMenuButton, direction),
+ DEF_MENUBUTTON_DIRECTION, TCL_INDEX_NONE, offsetof(TkMenuButton, direction),
0, directionStrings, 0},
{TK_OPTION_COLOR, "-disabledforeground", "disabledForeground",
"DisabledForeground", DEF_MENUBUTTON_DISABLED_FG_COLOR,
- -1, Tk_Offset(TkMenuButton, disabledFg), TK_OPTION_NULL_OK,
+ TCL_INDEX_NONE, offsetof(TkMenuButton, disabledFg), TK_OPTION_NULL_OK,
(ClientData) DEF_MENUBUTTON_DISABLED_FG_MONO, 0},
- {TK_OPTION_SYNONYM, "-fg", "foreground", NULL, NULL, 0, -1, 0,
+ {TK_OPTION_SYNONYM, "-fg", "foreground", NULL, NULL, 0, TCL_INDEX_NONE, 0,
(ClientData) "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_MENUBUTTON_FONT, -1, Tk_Offset(TkMenuButton, tkfont), 0, 0, 0},
+ DEF_MENUBUTTON_FONT, TCL_INDEX_NONE, offsetof(TkMenuButton, tkfont), 0, 0, 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_MENUBUTTON_FG, -1, Tk_Offset(TkMenuButton, normalFg), 0, 0, 0},
+ DEF_MENUBUTTON_FG, TCL_INDEX_NONE, offsetof(TkMenuButton, normalFg), 0, 0, 0},
{TK_OPTION_STRING, "-height", "height", "Height",
- DEF_MENUBUTTON_HEIGHT, -1, Tk_Offset(TkMenuButton, heightString),
+ DEF_MENUBUTTON_HEIGHT, TCL_INDEX_NONE, offsetof(TkMenuButton, heightString),
0, 0, 0},
{TK_OPTION_COLOR, "-highlightbackground", "highlightBackground",
"HighlightBackground", DEF_MENUBUTTON_HIGHLIGHT_BG_COLOR,
- -1, Tk_Offset(TkMenuButton, highlightBgColorPtr), 0, 0, 0},
+ TCL_INDEX_NONE, offsetof(TkMenuButton, highlightBgColorPtr), 0, 0, 0},
{TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_MENUBUTTON_HIGHLIGHT, -1,
- Tk_Offset(TkMenuButton, highlightColorPtr), 0, 0, 0},
+ DEF_MENUBUTTON_HIGHLIGHT, TCL_INDEX_NONE,
+ offsetof(TkMenuButton, highlightColorPtr), 0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
"HighlightThickness", DEF_MENUBUTTON_HIGHLIGHT_WIDTH,
- -1, Tk_Offset(TkMenuButton, highlightWidth), 0, 0, 0},
+ TCL_INDEX_NONE, offsetof(TkMenuButton, highlightWidth), 0, 0, 0},
{TK_OPTION_STRING, "-image", "image", "Image",
- DEF_MENUBUTTON_IMAGE, -1, Tk_Offset(TkMenuButton, imageString),
+ DEF_MENUBUTTON_IMAGE, TCL_INDEX_NONE, offsetof(TkMenuButton, imageString),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_BOOLEAN, "-indicatoron", "indicatorOn", "IndicatorOn",
- DEF_MENUBUTTON_INDICATOR, -1, Tk_Offset(TkMenuButton, indicatorOn),
+ DEF_MENUBUTTON_INDICATOR, TCL_INDEX_NONE, offsetof(TkMenuButton, indicatorOn),
0, 0, 0},
{TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
- DEF_MENUBUTTON_JUSTIFY, -1, Tk_Offset(TkMenuButton, justify), 0, 0, 0},
+ DEF_MENUBUTTON_JUSTIFY, TCL_INDEX_NONE, offsetof(TkMenuButton, justify), 0, 0, 0},
{TK_OPTION_STRING, "-menu", "menu", "Menu",
- DEF_MENUBUTTON_MENU, -1, Tk_Offset(TkMenuButton, menuName),
+ DEF_MENUBUTTON_MENU, TCL_INDEX_NONE, offsetof(TkMenuButton, menuName),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-padx", "padX", "Pad",
- DEF_MENUBUTTON_PADX, -1, Tk_Offset(TkMenuButton, padX),
+ DEF_MENUBUTTON_PADX, TCL_INDEX_NONE, offsetof(TkMenuButton, padX),
0, 0, 0},
{TK_OPTION_PIXELS, "-pady", "padY", "Pad",
- DEF_MENUBUTTON_PADY, -1, Tk_Offset(TkMenuButton, padY),
+ DEF_MENUBUTTON_PADY, TCL_INDEX_NONE, offsetof(TkMenuButton, padY),
0, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_MENUBUTTON_RELIEF, -1, Tk_Offset(TkMenuButton, relief),
+ DEF_MENUBUTTON_RELIEF, TCL_INDEX_NONE, offsetof(TkMenuButton, relief),
0, 0, 0},
{TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound",
- DEF_BUTTON_COMPOUND, -1, Tk_Offset(TkMenuButton, compound), 0,
+ DEF_BUTTON_COMPOUND, TCL_INDEX_NONE, offsetof(TkMenuButton, compound), 0,
compoundStrings, 0},
{TK_OPTION_STRING_TABLE, "-state", "state", "State",
- DEF_MENUBUTTON_STATE, -1, Tk_Offset(TkMenuButton, state),
+ DEF_MENUBUTTON_STATE, TCL_INDEX_NONE, offsetof(TkMenuButton, state),
0, stateStrings, 0},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_MENUBUTTON_TAKE_FOCUS, -1,
- Tk_Offset(TkMenuButton, takeFocus), TK_OPTION_NULL_OK, 0, 0},
+ DEF_MENUBUTTON_TAKE_FOCUS, TCL_INDEX_NONE,
+ offsetof(TkMenuButton, takeFocus), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-text", "text", "Text",
- DEF_MENUBUTTON_TEXT, -1, Tk_Offset(TkMenuButton, text), 0, 0, 0},
+ DEF_MENUBUTTON_TEXT, TCL_INDEX_NONE, offsetof(TkMenuButton, text), 0, 0, 0},
{TK_OPTION_STRING, "-textvariable", "textVariable", "Variable",
- DEF_MENUBUTTON_TEXT_VARIABLE, -1,
- Tk_Offset(TkMenuButton, textVarName), TK_OPTION_NULL_OK, 0, 0},
+ DEF_MENUBUTTON_TEXT_VARIABLE, TCL_INDEX_NONE,
+ offsetof(TkMenuButton, textVarName), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_INT, "-underline", "underline", "Underline",
- DEF_MENUBUTTON_UNDERLINE, -1, Tk_Offset(TkMenuButton, underline),
+ DEF_MENUBUTTON_UNDERLINE, TCL_INDEX_NONE, offsetof(TkMenuButton, underline),
0, 0, 0},
{TK_OPTION_STRING, "-width", "width", "Width",
- DEF_MENUBUTTON_WIDTH, -1, Tk_Offset(TkMenuButton, widthString),
+ DEF_MENUBUTTON_WIDTH, TCL_INDEX_NONE, offsetof(TkMenuButton, widthString),
0, 0, 0},
{TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength",
- DEF_MENUBUTTON_WRAP_LENGTH, -1, Tk_Offset(TkMenuButton, wrapLength),
+ DEF_MENUBUTTON_WRAP_LENGTH, TCL_INDEX_NONE, offsetof(TkMenuButton, wrapLength),
0, 0, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0}
};
@@ -212,14 +211,15 @@ static void DestroyMenuButton(char *memPtr);
int
Tk_MenubuttonObjCmd(
- ClientData clientData, /* NULL. */
+ ClientData dummy, /* NULL. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register TkMenuButton *mbPtr;
+ TkMenuButton *mbPtr;
Tk_OptionTable optionTable;
Tk_Window tkwin;
+ (void)dummy;
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "pathName ?-option value ...?");
@@ -308,7 +308,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;
}
@@ -318,7 +318,7 @@ Tk_MenubuttonObjCmd(
return TCL_ERROR;
}
- Tcl_SetObjResult(interp, TkNewWindowObj(mbPtr->tkwin));
+ Tcl_SetObjResult(interp, Tk_NewWindowObj(mbPtr->tkwin));
return TCL_OK;
}
@@ -347,7 +347,7 @@ MenuButtonWidgetObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
- register TkMenuButton *mbPtr = clientData;
+ TkMenuButton *mbPtr = (TkMenuButton *)clientData;
int result, index;
Tcl_Obj *objPtr;
@@ -369,7 +369,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;
@@ -379,7 +379,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) {
@@ -422,7 +422,7 @@ static void
DestroyMenuButton(
char *memPtr) /* Info about button widget. */
{
- register TkMenuButton *mbPtr = (TkMenuButton *) memPtr;
+ TkMenuButton *mbPtr = (TkMenuButton *) memPtr;
TkpDestroyMenuButton(mbPtr);
if (mbPtr->flags & REDRAW_PENDING) {
@@ -490,7 +490,7 @@ DestroyMenuButton(
static int
ConfigureMenuButton(
Tcl_Interp *interp, /* Used for error reporting. */
- register TkMenuButton *mbPtr,
+ TkMenuButton *mbPtr,
/* Information about widget; may or may not
* already have values for some fields. */
int objc, /* Number of valid entries in objv. */
@@ -524,7 +524,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;
@@ -633,7 +633,7 @@ ConfigureMenuButton(
if (mbPtr->text != NULL) {
ckfree(mbPtr->text);
}
- mbPtr->text = ckalloc(strlen(value) + 1);
+ mbPtr->text = (char *)ckalloc(strlen(value) + 1);
strcpy(mbPtr->text, value);
}
Tcl_TraceVar2(interp, mbPtr->textVarName, NULL,
@@ -675,7 +675,7 @@ TkMenuButtonWorldChanged(
XGCValues gcValues;
GC gc;
unsigned long mask;
- TkMenuButton *mbPtr = instanceData;
+ TkMenuButton *mbPtr = (TkMenuButton *)instanceData;
gcValues.font = Tk_FontId(mbPtr->tkfont);
gcValues.foreground = mbPtr->normalFg->pixel;
@@ -776,7 +776,7 @@ MenuButtonEventProc(
ClientData clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
- TkMenuButton *mbPtr = clientData;
+ TkMenuButton *mbPtr = (TkMenuButton *)clientData;
if ((eventPtr->type == Expose) && (eventPtr->xexpose.count == 0)) {
goto redraw;
@@ -835,7 +835,7 @@ static void
MenuButtonCmdDeletedProc(
ClientData clientData) /* Pointer to widget record for widget. */
{
- TkMenuButton *mbPtr = clientData;
+ TkMenuButton *mbPtr = (TkMenuButton *)clientData;
Tk_Window tkwin = mbPtr->tkwin;
/*
@@ -868,7 +868,6 @@ MenuButtonCmdDeletedProc(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static char *
MenuButtonTextVarProc(
ClientData clientData, /* Information about button. */
@@ -877,9 +876,11 @@ MenuButtonTextVarProc(
const char *name2, /* Second part of variable name. */
int flags) /* Information about what happened. */
{
- register TkMenuButton *mbPtr = clientData;
+ TkMenuButton *mbPtr = (TkMenuButton *)clientData;
const char *value;
- unsigned len;
+ size_t len;
+ (void)name1;
+ (void)name2;
/*
* If the variable is unset, then immediately recreate it unless the whole
@@ -924,8 +925,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);
@@ -964,7 +965,13 @@ MenuButtonImageProc(
* 0). */
int imgWidth, int imgHeight)/* New dimensions of image. */
{
- register TkMenuButton *mbPtr = clientData;
+ TkMenuButton *mbPtr = (TkMenuButton *)clientData;
+ (void)x;
+ (void)y;
+ (void)width;
+ (void)height;
+ (void)imgWidth;
+ (void)imgHeight;
if (mbPtr->tkwin != NULL) {
TkpComputeMenuButtonGeometry(mbPtr);
diff --git a/generic/tkMessage.c b/generic/tkMessage.c
index 1a3c6de..8bd8573 100644
--- a/generic/tkMessage.c
+++ b/generic/tkMessage.c
@@ -13,8 +13,8 @@
* 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
@@ -109,57 +109,57 @@ typedef struct {
static const Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", DEF_MESSAGE_ANCHOR,
- -1, Tk_Offset(Message, anchor), 0, 0, 0},
+ TCL_INDEX_NONE, offsetof(Message, anchor), 0, 0, 0},
{TK_OPTION_INT, "-aspect", "aspect", "Aspect", DEF_MESSAGE_ASPECT,
- -1, Tk_Offset(Message, aspect), 0, 0, 0},
+ TCL_INDEX_NONE, offsetof(Message, aspect), 0, 0, 0},
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_MESSAGE_BG_COLOR, -1, Tk_Offset(Message, border), 0,
+ DEF_MESSAGE_BG_COLOR, TCL_INDEX_NONE, offsetof(Message, border), 0,
DEF_MESSAGE_BG_MONO, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL, NULL,
- 0, -1, 0, "-borderwidth", 0},
+ 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL,
- 0, -1, 0, "-background", 0},
+ 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_MESSAGE_BORDER_WIDTH, -1,
- Tk_Offset(Message, borderWidth), 0, 0, 0},
+ DEF_MESSAGE_BORDER_WIDTH, TCL_INDEX_NONE,
+ offsetof(Message, borderWidth), 0, 0, 0},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_MESSAGE_CURSOR, -1, Tk_Offset(Message, cursor),
+ DEF_MESSAGE_CURSOR, TCL_INDEX_NONE, offsetof(Message, cursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_SYNONYM, "-fg", NULL, NULL, NULL,
- 0, -1, 0, "-foreground", 0},
+ 0, TCL_INDEX_NONE, 0, "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_MESSAGE_FONT, -1, Tk_Offset(Message, tkfont), 0, 0, 0},
+ DEF_MESSAGE_FONT, TCL_INDEX_NONE, offsetof(Message, tkfont), 0, 0, 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_MESSAGE_FG, -1, Tk_Offset(Message, fgColorPtr), 0, 0, 0},
+ DEF_MESSAGE_FG, TCL_INDEX_NONE, offsetof(Message, fgColorPtr), 0, 0, 0},
{TK_OPTION_COLOR, "-highlightbackground", "highlightBackground",
- "HighlightBackground", DEF_MESSAGE_HIGHLIGHT_BG, -1,
- Tk_Offset(Message, highlightBgColorPtr), 0, 0, 0},
+ "HighlightBackground", DEF_MESSAGE_HIGHLIGHT_BG, TCL_INDEX_NONE,
+ offsetof(Message, highlightBgColorPtr), 0, 0, 0},
{TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_MESSAGE_HIGHLIGHT, -1, Tk_Offset(Message, highlightColorPtr),
+ DEF_MESSAGE_HIGHLIGHT, TCL_INDEX_NONE, offsetof(Message, highlightColorPtr),
0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
- "HighlightThickness", DEF_MESSAGE_HIGHLIGHT_WIDTH, -1,
- Tk_Offset(Message, highlightWidth), 0, 0, 0},
+ "HighlightThickness", DEF_MESSAGE_HIGHLIGHT_WIDTH, TCL_INDEX_NONE,
+ offsetof(Message, highlightWidth), 0, 0, 0},
{TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
- DEF_MESSAGE_JUSTIFY, -1, Tk_Offset(Message, justify), 0, 0, 0},
+ DEF_MESSAGE_JUSTIFY, TCL_INDEX_NONE, offsetof(Message, justify), 0, 0, 0},
{TK_OPTION_PIXELS, "-padx", "padX", "Pad",
- DEF_MESSAGE_PADX, Tk_Offset(Message, padXPtr),
- Tk_Offset(Message, padX), 0, 0, 0},
+ DEF_MESSAGE_PADX, offsetof(Message, padXPtr),
+ offsetof(Message, padX), 0, 0, 0},
{TK_OPTION_PIXELS, "-pady", "padY", "Pad",
- DEF_MESSAGE_PADY, Tk_Offset(Message, padYPtr),
- Tk_Offset(Message, padY), 0, 0, 0},
+ DEF_MESSAGE_PADY, offsetof(Message, padYPtr),
+ offsetof(Message, padY), 0, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_MESSAGE_RELIEF, -1, Tk_Offset(Message, relief), 0, 0, 0},
+ DEF_MESSAGE_RELIEF, TCL_INDEX_NONE, offsetof(Message, relief), 0, 0, 0},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_MESSAGE_TAKE_FOCUS, -1, Tk_Offset(Message, takeFocus),
+ DEF_MESSAGE_TAKE_FOCUS, TCL_INDEX_NONE, offsetof(Message, takeFocus),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-text", "text", "Text",
- DEF_MESSAGE_TEXT, -1, Tk_Offset(Message, string), 0, 0, 0},
+ DEF_MESSAGE_TEXT, TCL_INDEX_NONE, offsetof(Message, string), 0, 0, 0},
{TK_OPTION_STRING, "-textvariable", "textVariable", "Variable",
- DEF_MESSAGE_TEXT_VARIABLE, -1, Tk_Offset(Message, textVarName),
+ DEF_MESSAGE_TEXT_VARIABLE, TCL_INDEX_NONE, offsetof(Message, textVarName),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-width", "width", "Width",
- DEF_MESSAGE_WIDTH, -1, Tk_Offset(Message, width), 0, 0 ,0},
+ DEF_MESSAGE_WIDTH, TCL_INDEX_NONE, offsetof(Message, width), 0, 0 ,0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0}
};
@@ -180,7 +180,7 @@ static void MessageWorldChanged(ClientData instanceData);
static void ComputeMessageGeometry(Message *msgPtr);
static int ConfigureMessage(Tcl_Interp *interp, Message *msgPtr,
int objc, Tcl_Obj *const objv[], int flags);
-static void DestroyMessage(char *memPtr);
+static void DestroyMessage(void *memPtr);
static void DisplayMessage(ClientData clientData);
/*
@@ -214,14 +214,15 @@ static const Tk_ClassProcs messageClass = {
int
Tk_MessageObjCmd(
- ClientData clientData, /* NULL. */
+ ClientData dummy, /* NULL. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
{
- register Message *msgPtr;
+ Message *msgPtr;
Tk_OptionTable optionTable;
Tk_Window tkwin;
+ (void)dummy;
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "pathName ?-option value ...?");
@@ -241,8 +242,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 +268,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 +278,7 @@ Tk_MessageObjCmd(
return TCL_ERROR;
}
- Tcl_SetObjResult(interp, TkNewWindowObj(msgPtr->tkwin));
+ Tcl_SetObjResult(interp, Tk_NewWindowObj(msgPtr->tkwin));
return TCL_OK;
}
@@ -306,7 +307,7 @@ MessageWidgetObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
{
- register Message *msgPtr = clientData;
+ Message *msgPtr = (Message *)clientData;
static const char *const optionStrings[] = { "cget", "configure", NULL };
enum options { MESSAGE_CGET, MESSAGE_CONFIGURE };
int index;
@@ -331,7 +332,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 +344,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,9 +383,9 @@ MessageWidgetObjCmd(
static void
DestroyMessage(
- char *memPtr) /* Info about message widget. */
+ void *memPtr) /* Info about message widget. */
{
- register Message *msgPtr = (Message *) memPtr;
+ Message *msgPtr = (Message *) memPtr;
msgPtr->flags |= MESSAGE_DELETED;
@@ -437,13 +438,14 @@ DestroyMessage(
static int
ConfigureMessage(
Tcl_Interp *interp, /* Used for error reporting. */
- register Message *msgPtr, /* Information about widget; may or may not
+ Message *msgPtr, /* Information about widget; may or may not
* already have values for some fields. */
int objc, /* Number of valid entries in argv. */
Tcl_Obj *const objv[], /* Arguments. */
int flags) /* Flags to pass to Tk_ConfigureWidget. */
{
Tk_SavedOptions savedOptions;
+ (void)flags;
/*
* Eliminate any existing trace on a variable monitored by the message.
@@ -455,7 +457,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 +480,7 @@ ConfigureMessage(
if (msgPtr->string != NULL) {
ckfree(msgPtr->string);
}
- msgPtr->string = strcpy(ckalloc(strlen(value) + 1), value);
+ msgPtr->string = strcpy((char *)ckalloc(strlen(value) + 1), value);
}
Tcl_TraceVar2(interp, msgPtr->textVarName, NULL,
TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS,
@@ -527,7 +529,7 @@ MessageWorldChanged(
XGCValues gcValues;
GC gc = NULL;
Tk_FontMetrics fm;
- Message *msgPtr = instanceData;
+ Message *msgPtr = (Message *)instanceData;
if (msgPtr->border != NULL) {
Tk_SetBackgroundFromBorder(msgPtr->tkwin, msgPtr->border);
@@ -582,7 +584,7 @@ MessageWorldChanged(
static void
ComputeMessageGeometry(
- register Message *msgPtr) /* Information about window. */
+ Message *msgPtr) /* Information about window. */
{
int width, inc, height;
int thisWidth, thisHeight, maxWidth;
@@ -666,8 +668,8 @@ static void
DisplayMessage(
ClientData clientData) /* Information about window. */
{
- register Message *msgPtr = clientData;
- register Tk_Window tkwin = msgPtr->tkwin;
+ Message *msgPtr = (Message *)clientData;
+ Tk_Window tkwin = msgPtr->tkwin;
int x, y;
int borderWidth = msgPtr->highlightWidth;
@@ -742,7 +744,7 @@ MessageEventProc(
ClientData clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
- Message *msgPtr = clientData;
+ Message *msgPtr = (Message *)clientData;
if (((eventPtr->type == Expose) && (eventPtr->xexpose.count == 0))
|| (eventPtr->type == ConfigureNotify)) {
@@ -795,7 +797,7 @@ static void
MessageCmdDeletedProc(
ClientData clientData) /* Pointer to widget record for widget. */
{
- Message *msgPtr = clientData;
+ Message *msgPtr = (Message *)clientData;
/*
* This function could be invoked either because the window was destroyed
@@ -826,7 +828,6 @@ MessageCmdDeletedProc(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static char *
MessageTextVarProc(
ClientData clientData, /* Information about message. */
@@ -835,8 +836,10 @@ MessageTextVarProc(
const char *name2, /* Second part of variable name. */
int flags) /* Information about what happened. */
{
- register Message *msgPtr = clientData;
+ Message *msgPtr = (Message *)clientData;
const char *value;
+ (void)name1;
+ (void)name2;
/*
* If the variable is unset, then immediately recreate it unless the whole
@@ -882,7 +885,7 @@ MessageTextVarProc(
ckfree(msgPtr->string);
}
msgPtr->numChars = Tcl_NumUtfChars(value, -1);
- msgPtr->string = ckalloc(strlen(value) + 1);
+ msgPtr->string = (char *)ckalloc(strlen(value) + 1);
strcpy(msgPtr->string, value);
ComputeMessageGeometry(msgPtr);
diff --git a/generic/tkObj.c b/generic/tkObj.c
index 716c7e1..3f623f6 100644
--- a/generic/tkObj.c
+++ b/generic/tkObj.c
@@ -50,6 +50,7 @@ typedef struct PixelRep {
typedef struct {
const Tcl_ObjType *doubleTypePtr;
const Tcl_ObjType *intTypePtr;
+ const Tcl_ObjType *endTypePtr;
} ThreadSpecificData;
static Tcl_ThreadDataKey dataKey;
@@ -73,8 +74,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;
/*
@@ -93,6 +98,29 @@ static int SetMMFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr);
static int SetPixelFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr);
static int SetWindowFromAny(Tcl_Interp *interp, Tcl_Obj *objPtr);
+#if TCL_MAJOR_VERSION < 9
+#if defined(USE_TCL_STUBS)
+/* Little hack to eliminate the need for "tclInt.h" here:
+ Just copy a small portion of TclIntStubs, just
+ enough to make it work */
+typedef struct TclIntStubs {
+ int magic;
+ void *hooks;
+ void (*dummy[34]) (void); /* dummy entries 0-33, not used */
+ int (*tclGetIntForIndex) (Tcl_Interp *interp, Tcl_Obj *objPtr, int endValue, int *indexPtr); /* 34 */
+} TclIntStubs;
+extern const struct TclIntStubs *tclIntStubsPtr;
+
+# undef Tcl_GetIntForIndex
+# define Tcl_GetIntForIndex(interp, obj, max, ptr) ((tclIntStubsPtr->tclGetIntForIndex == NULL)? \
+ ((int (*)(Tcl_Interp*, Tcl_Obj *, int, int*))(void *)((&(tclStubsPtr->tcl_PkgProvideEx))[645]))((interp), (obj), (max), (ptr)): \
+ tclIntStubsPtr->tclGetIntForIndex((interp), (obj), (max), (ptr)))
+#elif TCL_MINOR_VERSION < 7
+extern int TclGetIntForIndex(Tcl_Interp*, Tcl_Obj *, int, int*);
+# define Tcl_GetIntForIndex(interp, obj, max, ptr) TclGetIntForIndex(interp, obj, max, ptr)
+#endif
+#endif
+
/*
* The following structure defines the implementation of the "pixel" Tcl
* object, used for measuring distances. The pixel object remembers its
@@ -104,7 +132,7 @@ static const Tcl_ObjType pixelObjType = {
FreePixelInternalRep, /* freeIntRepProc */
DupPixelInternalRep, /* dupIntRepProc */
NULL, /* updateStringProc */
- SetPixelFromAny /* setFromAnyProc */
+ NULL /* setFromAnyProc */
};
/*
@@ -118,7 +146,7 @@ static const Tcl_ObjType mmObjType = {
FreeMMInternalRep, /* freeIntRepProc */
DupMMInternalRep, /* dupIntRepProc */
UpdateStringOfMM, /* updateStringProc */
- SetMMFromAny /* setFromAnyProc */
+ NULL /* setFromAnyProc */
};
/*
@@ -131,7 +159,7 @@ static const Tcl_ObjType windowObjType = {
FreeWindowInternalRep, /* freeIntRepProc */
DupWindowInternalRep, /* dupIntRepProc */
NULL, /* updateStringProc */
- SetWindowFromAny /* setFromAnyProc */
+ NULL /* setFromAnyProc */
};
/*
@@ -156,12 +184,17 @@ GetTypeCache(void)
/* Smart initialization of doubleTypePtr/intTypePtr without
* hash-table lookup or creating complete Tcl_Obj's */
Tcl_Obj obj;
+ obj.bytes = (char *)"end";
obj.length = 3;
+ obj.typePtr = NULL;
+ Tcl_GetIntForIndex(NULL, &obj, TCL_INDEX_NONE, (TkSizeT *)&obj.internalRep.doubleValue);
+ tsdPtr->endTypePtr = obj.typePtr;
obj.bytes = (char *)"0.0";
+ obj.length = 3;
obj.typePtr = NULL;
Tcl_GetDoubleFromObj(NULL, &obj, &obj.internalRep.doubleValue);
tsdPtr->doubleTypePtr = obj.typePtr;
- obj.bytes += 2;
+ obj.bytes = (char *)"0";
obj.length = 1;
obj.typePtr = NULL;
Tcl_GetLongFromObj(NULL, &obj, &obj.internalRep.longValue);
@@ -173,6 +206,56 @@ GetTypeCache(void)
/*
*----------------------------------------------------------------------
*
+ * TkGetIntForIndex --
+ *
+ * Almost the same as Tcl_GetIntForIndex, but it return an int, and it is
+ * more restricted. For example it only accepts "end", not "end-1", and
+ * only "2", not "1+1"
+ *
+ * Results:
+ * The return value is a standard Tcl object result.
+ *
+ * Side effects:
+ * None
+ *
+ *----------------------------------------------------------------------
+ */
+
+int
+TkGetIntForIndex(
+ Tcl_Obj *indexObj,
+ TkSizeT end,
+ int lastOK,
+ TkSizeT *indexPtr)
+{
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
+ Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+
+ if (Tcl_GetIntForIndex(NULL, indexObj, end + lastOK, indexPtr) != TCL_OK) {
+ return TCL_ERROR;
+ }
+ if (indexObj->typePtr == tsdPtr->endTypePtr) {
+ /* check for "end", but not "end-??" or "end+??" */
+ return (*indexPtr == (end + lastOK)) ? TCL_OK : TCL_ERROR;
+ }
+ if (indexObj->typePtr != tsdPtr->intTypePtr) {
+ /* Neither do we accept "??-??" or "??+??" */
+ return TCL_ERROR;
+ }
+#if TCL_MAJOR_VERSION < 9
+ if ((*indexPtr < -1) || (end < -1)) {
+ return TCL_ERROR;
+ }
+#endif
+ if ((*indexPtr + 1) > (end + 1)) {
+ *indexPtr = end + 1;
+ }
+ return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* GetPixelsFromObjEx --
*
* Attempt to return a pixel value from the Tcl object "objPtr". If the
@@ -668,7 +751,7 @@ UpdateStringOfMM(
{
MMRep *mmPtr;
char buffer[TCL_DOUBLE_SPACE];
- size_t len;
+ TkSizeT len;
mmPtr = (MMRep *)objPtr->internalRep.twoPtrValue.ptr1;
/* assert( mmPtr->units == -1 && objPtr->bytes == NULL ); */
@@ -929,13 +1012,13 @@ SetWindowFromAny(
static void
DupWindowInternalRep(
- register Tcl_Obj *srcPtr,
- register Tcl_Obj *copyPtr)
+ Tcl_Obj *srcPtr,
+ Tcl_Obj *copyPtr)
{
- register WindowRep *oldPtr, *newPtr;
+ WindowRep *oldPtr, *newPtr;
- oldPtr = srcPtr->internalRep.twoPtrValue.ptr1;
- newPtr = ckalloc(sizeof(WindowRep));
+ oldPtr = (WindowRep *)srcPtr->internalRep.twoPtrValue.ptr1;
+ newPtr = (WindowRep *)ckalloc(sizeof(WindowRep));
newPtr->tkwin = oldPtr->tkwin;
newPtr->mainPtr = oldPtr->mainPtr;
newPtr->epoch = oldPtr->epoch;
@@ -973,7 +1056,7 @@ FreeWindowInternalRep(
/*
*----------------------------------------------------------------------
*
- * TkNewWindowObj --
+ * Tk_NewWindowObj --
*
* This function allocates a new Tcl_Obj that refers to a particular to a
* particular Tk window.
@@ -988,7 +1071,7 @@ FreeWindowInternalRep(
*/
Tcl_Obj *
-TkNewWindowObj(
+Tk_NewWindowObj(
Tk_Window tkwin)
{
Tcl_Obj *objPtr = Tcl_NewStringObj(Tk_PathName(tkwin), -1);
@@ -997,7 +1080,7 @@ TkNewWindowObj(
SetWindowFromAny(NULL, objPtr);
- winPtr = objPtr->internalRep.twoPtrValue.ptr1;
+ winPtr = (WindowRep *)objPtr->internalRep.twoPtrValue.ptr1;
winPtr->tkwin = tkwin;
winPtr->mainPtr = mainPtr;
winPtr->epoch = mainPtr->deletionEpoch;
diff --git a/generic/tkOldConfig.c b/generic/tkOldConfig.c
index 7bb02b4..49c576a 100644
--- a/generic/tkOldConfig.c
+++ b/generic/tkOldConfig.c
@@ -25,20 +25,24 @@
#define INIT 0x20
+#ifndef TK_CONFIG_OPTION_SPECIFIED
+# define TK_CONFIG_OPTION_SPECIFIED (1 << 4)
+#endif
+
/*
* Forward declarations for functions defined later in this file:
*/
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);
@@ -340,10 +344,10 @@ 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;
@@ -353,7 +357,7 @@ DoConfig(
}
do {
- 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) {
@@ -546,7 +550,7 @@ DoConfig(
}
case TK_CONFIG_CUSTOM:
if (specPtr->customPtr->parseProc(specPtr->customPtr->clientData,
- interp, tkwin, value, widgRec, specPtr->offset)!=TCL_OK) {
+ interp, tkwin, value, (char *)widgRec, specPtr->offset)!=TCL_OK) {
return TCL_ERROR;
}
break;
@@ -689,7 +693,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];
@@ -755,7 +759,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. */
@@ -763,35 +767,36 @@ FormatConfigValue(
* function to free the result, or NULL if
* result is static. */
{
- const char *ptr, *result;
+ void *ptr;
+ const char *result;
*freeProcPtr = NULL;
- ptr = widgRec + specPtr->offset;
+ ptr = (char *)widgRec + specPtr->offset;
result = "";
switch (specPtr->type) {
case TK_CONFIG_BOOLEAN:
- if (*((int *) ptr) == 0) {
+ if (*((int *)ptr) == 0) {
result = "0";
} else {
result = "1";
}
break;
case TK_CONFIG_INT:
- sprintf(buffer, "%d", *((int *) ptr));
+ sprintf(buffer, "%d", *((int *)ptr));
result = buffer;
break;
case TK_CONFIG_DOUBLE:
- Tcl_PrintDouble(interp, *((double *) ptr), buffer);
+ Tcl_PrintDouble(interp, *((double *)ptr), buffer);
result = buffer;
break;
case TK_CONFIG_STRING:
- result = (*(char **) ptr);
+ result = (*(char **)ptr);
if (result == NULL) {
result = "";
}
break;
case TK_CONFIG_UID: {
- Tk_Uid uid = *((Tk_Uid *) ptr);
+ Tk_Uid uid = *((Tk_Uid *)ptr);
if (uid != NULL) {
result = uid;
@@ -799,7 +804,7 @@ FormatConfigValue(
break;
}
case TK_CONFIG_COLOR: {
- XColor *colorPtr = *((XColor **) ptr);
+ XColor *colorPtr = *((XColor **)ptr);
if (colorPtr != NULL) {
result = Tk_NameOfColor(colorPtr);
@@ -807,7 +812,7 @@ FormatConfigValue(
break;
}
case TK_CONFIG_FONT: {
- Tk_Font tkfont = *((Tk_Font *) ptr);
+ Tk_Font tkfont = *((Tk_Font *)ptr);
if (tkfont != NULL) {
result = Tk_NameOfFont(tkfont);
@@ -815,7 +820,7 @@ FormatConfigValue(
break;
}
case TK_CONFIG_BITMAP: {
- Pixmap pixmap = *((Pixmap *) ptr);
+ Pixmap pixmap = *((Pixmap *)ptr);
if (pixmap != None) {
result = Tk_NameOfBitmap(Tk_Display(tkwin), pixmap);
@@ -823,7 +828,7 @@ FormatConfigValue(
break;
}
case TK_CONFIG_BORDER: {
- Tk_3DBorder border = *((Tk_3DBorder *) ptr);
+ Tk_3DBorder border = *((Tk_3DBorder *)ptr);
if (border != NULL) {
result = Tk_NameOf3DBorder(border);
@@ -831,11 +836,11 @@ FormatConfigValue(
break;
}
case TK_CONFIG_RELIEF:
- result = Tk_NameOfRelief(*((int *) ptr));
+ result = Tk_NameOfRelief(*((int *)ptr));
break;
case TK_CONFIG_CURSOR:
case TK_CONFIG_ACTIVE_CURSOR: {
- Tk_Cursor cursor = *((Tk_Cursor *) ptr);
+ Tk_Cursor cursor = *((Tk_Cursor *)ptr);
if (cursor != NULL) {
result = Tk_NameOfCursor(Tk_Display(tkwin), cursor);
@@ -843,27 +848,27 @@ FormatConfigValue(
break;
}
case TK_CONFIG_JUSTIFY:
- result = Tk_NameOfJustify(*((Tk_Justify *) ptr));
+ result = Tk_NameOfJustify(*((Tk_Justify *)ptr));
break;
case TK_CONFIG_ANCHOR:
- result = Tk_NameOfAnchor(*((Tk_Anchor *) ptr));
+ result = Tk_NameOfAnchor(*((Tk_Anchor *)ptr));
break;
case TK_CONFIG_CAP_STYLE:
- result = Tk_NameOfCapStyle(*((int *) ptr));
+ result = Tk_NameOfCapStyle(*((int *)ptr));
break;
case TK_CONFIG_JOIN_STYLE:
- result = Tk_NameOfJoinStyle(*((int *) ptr));
+ result = Tk_NameOfJoinStyle(*((int *)ptr));
break;
case TK_CONFIG_PIXELS:
- sprintf(buffer, "%d", *((int *) ptr));
+ sprintf(buffer, "%d", *((int *)ptr));
result = buffer;
break;
case TK_CONFIG_MM:
- Tcl_PrintDouble(interp, *((double *) ptr), buffer);
+ Tcl_PrintDouble(interp, *((double *)ptr), buffer);
result = buffer;
break;
case TK_CONFIG_WINDOW: {
- tkwin = *((Tk_Window *) ptr);
+ tkwin = *((Tk_Window *)ptr);
if (tkwin != NULL) {
result = Tk_PathName(tkwin);
}
@@ -871,7 +876,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 ??";
diff --git a/generic/tkOldTest.c b/generic/tkOldTest.c
index 8996f31..22522d8 100644
--- a/generic/tkOldTest.c
+++ b/generic/tkOldTest.c
@@ -24,6 +24,7 @@
#endif
#include "tkInt.h"
+#if !defined(TK_NO_DEPRECATED) && (TCL_MAJOR_VERSION < 9)
/*
* The following data structure represents the model for a test image:
*/
@@ -84,7 +85,7 @@ static Tk_ImageType imageType = {
static int ImageObjCmd(ClientData dummy,
Tcl_Interp *interp, int objc,
Tcl_Obj * const objv[]);
-
+#endif
/*
*----------------------------------------------------------------------
@@ -106,13 +107,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;
}
@@ -132,8 +136,7 @@ TkOldTestInit(
*
*----------------------------------------------------------------------
*/
-
- /* ARGSUSED */
+#if !defined(TK_NO_DEPRECATED) && (TCL_MAJOR_VERSION < 9)
static int
ImageCreate(
Tcl_Interp *interp, /* Interpreter for application containing
@@ -151,6 +154,7 @@ ImageCreate(
TImageModel *timPtr;
const char *varName;
int i;
+ (void)typePtr;
varName = "log";
for (i = 0; i < argc; i += 2) {
@@ -167,14 +171,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;
@@ -199,7 +203,6 @@ ImageCreate(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
static int
ImageObjCmd(
ClientData clientData, /* Main window for application. */
@@ -207,7 +210,7 @@ ImageObjCmd(
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) {
@@ -262,7 +265,7 @@ ImageGet(
* used. */
ClientData clientData) /* Pointer to TImageModel for image. */
{
- TImageModel *timPtr = clientData;
+ TImageModel *timPtr = (TImageModel *)clientData;
TImageInstance *instPtr;
char buffer[100];
XGCValues gcValues;
@@ -271,7 +274,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;
@@ -309,7 +312,7 @@ ImageDisplay(
/* Coordinates in drawable corresponding to
* imageX and imageY. */
{
- TImageInstance *instPtr = clientData;
+ TImageInstance *instPtr = (TImageInstance *)clientData;
char buffer[200 + TCL_INTEGER_SPACE * 6];
sprintf(buffer, "%s display %d %d %d %d %d %d",
@@ -354,7 +357,7 @@ ImageFree(
ClientData clientData, /* Pointer to TImageInstance for instance. */
Display *display) /* Display where image was to be drawn. */
{
- TImageInstance *instPtr = clientData;
+ TImageInstance *instPtr = (TImageInstance *)clientData;
char buffer[200];
sprintf(buffer, "%s free", instPtr->modelPtr->imageName);
@@ -388,7 +391,7 @@ ImageDelete(
* this function is called, no more instances
* exist. */
{
- TImageModel *timPtr = clientData;
+ TImageModel *timPtr = (TImageModel *)clientData;
char buffer[100];
sprintf(buffer, "%s delete", timPtr->imageName);
@@ -400,6 +403,7 @@ ImageDelete(
ckfree(timPtr->varName);
ckfree(timPtr);
}
+#endif
/*
* Local Variables:
diff --git a/generic/tkOption.c b/generic/tkOption.c
index 15fc405..a8c9f62 100644
--- a/generic/tkOption.c
+++ b/generic/tkOption.c
@@ -521,7 +521,7 @@ Tk_GetOption(
if (masqName != NULL) {
char *masqClass;
Tk_Uid nodeId, winClassId, winNameId;
- size_t classNameLength;
+ TkSizeT 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';
@@ -1084,7 +1084,8 @@ ReadOptionFile(
{
const char *realName;
Tcl_Obj *buffer;
- int result, bufferSize;
+ int result;
+ TkSizeT bufferSize;
Tcl_Channel chan;
Tcl_DString newName;
@@ -1115,7 +1116,7 @@ ReadOptionFile(
Tcl_IncrRefCount(buffer);
Tcl_SetChannelOption(NULL, chan, "-encoding", "utf-8");
bufferSize = Tcl_ReadChars(chan, buffer, -1, 0);
- if (bufferSize == -1) {
+ if (bufferSize == TCL_IO_FAILURE) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"error reading file \"%s\": %s",
fileName, Tcl_PosixError(interp)));
diff --git a/generic/tkPack.c b/generic/tkPack.c
index 67267e7..239b00a 100644
--- a/generic/tkPack.c
+++ b/generic/tkPack.c
@@ -20,7 +20,7 @@ static const char *const sideNames[] = {
/*
* For each window that the packer cares about (either because the window is
- * managed by the packer or because the window has content managed by
+ * managed by the packer or because the window has content that are managed by
* the packer), there is a structure of the following type:
*/
@@ -122,8 +122,10 @@ static int ConfigureContent(Tcl_Interp *interp, Tk_Window tkwin,
int objc, Tcl_Obj *const objv[]);
static void DestroyPacker(void *memPtr);
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[]);
+#endif /* !TK_NO_DEPRECATED */
static void PackStructureProc(ClientData clientData,
XEvent *eventPtr);
static void Unlink(Packer *packPtr);
@@ -161,10 +163,10 @@ TkAppendPadAmount(
if (halfSpace*2 == allSpace) {
Tcl_DictObjPut(NULL, bufferObj, Tcl_NewStringObj(switchName, -1),
- Tcl_NewIntObj(halfSpace));
+ Tcl_NewWideIntObj(halfSpace));
} else {
- padding[0] = Tcl_NewIntObj(halfSpace);
- padding[1] = Tcl_NewIntObj(allSpace - halfSpace);
+ padding[0] = Tcl_NewWideIntObj(halfSpace);
+ padding[1] = Tcl_NewWideIntObj(allSpace - halfSpace);
Tcl_DictObjPut(NULL, bufferObj, Tcl_NewStringObj(switchName, -1),
Tcl_NewListObj(2, padding));
}
@@ -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) {
@@ -217,7 +224,7 @@ Tk_PackObjCmd(
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
@@ -225,14 +232,14 @@ Tk_PackObjCmd(
* deprecated and new options.
*/
- Tcl_ResetResult(interp);
- Tcl_GetIndexFromObjStruct(interp, objv[1], &optionStrings[4],
+ Tcl_GetIndexFromObjStruct(interp, objv[1], optionStringsNoDep,
sizeof(char *), "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;
@@ -297,6 +304,7 @@ 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(
@@ -349,7 +357,7 @@ Tk_PackObjCmd(
infoObj = Tcl_NewObj();
Tcl_DictObjPut(NULL, infoObj, Tcl_NewStringObj("-in", -1),
- TkNewWindowObj(contentPtr->containerPtr->tkwin));
+ Tk_NewWindowObj(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),
@@ -436,8 +444,8 @@ Tk_PackObjCmd(
}
break;
}
- case PACK_CONTENT:
- case PACK_SLAVES: {
+ case PACK_SLAVES:
+ case PACK_CONTENT: {
Tk_Window container;
Packer *containerPtr, *contentPtr;
Tcl_Obj *resultObj;
@@ -454,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;
@@ -482,6 +491,7 @@ Tk_PackObjCmd(
}
break;
}
+#endif /* !TK_NO_DEPRECATED */
}
return TCL_OK;
@@ -598,7 +608,7 @@ ArrangePacking(
containerPtr->flags &= ~REQUESTED_REPACK;
/*
- * If the container has no content anymore, then leave the container size as-is.
+ * If the container has no content anymore, then leave the container's size as-is.
* Otherwise there is no way to "relinquish" control over the container
* so another geometry manager can take over.
*/
@@ -1087,6 +1097,7 @@ GetPacker(
*------------------------------------------------------------------------
*/
+#ifndef TK_NO_DEPRECATED
static int
PackAfter(
Tcl_Interp *interp, /* Interpreter for error reporting. */
@@ -1138,7 +1149,7 @@ 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);
return TCL_ERROR;
@@ -1169,8 +1180,8 @@ PackAfter(
packPtr->flags |= OLD_STYLE;
for (index = 0 ; index < optionCount; index++) {
Tcl_Obj *curOptPtr = options[index];
- int length;
- const char *curOpt = Tcl_GetStringFromObj(curOptPtr, &length);
+ TkSizeT length;
+ const char *curOpt = TkGetStringFromObj(curOptPtr, &length);
c = curOpt[0];
@@ -1307,6 +1318,7 @@ PackAfter(
}
return TCL_OK;
}
+#endif /* !TK_NO_DEPRECATED */
/*
*----------------------------------------------------------------------
@@ -1360,11 +1372,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);
}
}
@@ -1456,7 +1472,7 @@ PackStructureProc(
if (packPtr->tkwin != NULL) {
TkDisplay *dispPtr = ((TkWindow *) packPtr->tkwin)->dispPtr;
Tcl_DeleteHashEntry(Tcl_FindHashEntry(&dispPtr->packerHashTable,
- (void *)packPtr->tkwin));
+ packPtr->tkwin));
}
if (packPtr->flags & REQUESTED_REPACK) {
@@ -1786,7 +1802,7 @@ 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);
return TCL_ERROR;
@@ -1794,7 +1810,7 @@ ConfigureContent(
}
if (content == containerPtr->tkwin) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "can't pack %s inside itself", Tcl_GetString(objv[j])));
+ "can't pack \"%s\" inside itself", Tcl_GetString(objv[j])));
Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "SELF", NULL);
return TCL_ERROR;
}
@@ -1807,7 +1823,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);
return TCL_ERROR;
diff --git a/generic/tkPanedWindow.c b/generic/tkPanedWindow.c
index 06a42d4..c15236d 100644
--- a/generic/tkPanedWindow.c
+++ b/generic/tkPanedWindow.c
@@ -225,10 +225,10 @@ static void DestroyOptionTables(ClientData clientData,
Tcl_Interp *interp);
static int SetSticky(ClientData clientData, Tcl_Interp *interp,
Tk_Window tkwin, Tcl_Obj **value, char *recordPtr,
- int internalOffset, char *oldInternalPtr,
+ TkSizeT internalOffset, char *oldInternalPtr,
int flags);
static Tcl_Obj * GetSticky(ClientData clientData, Tk_Window tkwin,
- char *recordPtr, int internalOffset);
+ char *recordPtr, TkSizeT internalOffset);
static void RestoreSticky(ClientData clientData, Tk_Window tkwin,
char *internalPtr, char *oldInternalPtr);
static void AdjustForSticky(int sticky, int cavityWidth,
@@ -236,7 +236,7 @@ static void AdjustForSticky(int sticky, int cavityWidth,
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, TkSizeT offset);
static int PanedWindowIdentifyCoords(PanedWindow *pwPtr,
Tcl_Interp *interp, int x, int y);
@@ -275,92 +275,92 @@ static const Tk_ObjCustomOption stickyOption = {
static const Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_PANEDWINDOW_BG_COLOR, -1, Tk_Offset(PanedWindow, background), 0,
+ DEF_PANEDWINDOW_BG_COLOR, TCL_INDEX_NONE, offsetof(PanedWindow, background), 0,
DEF_PANEDWINDOW_BG_MONO, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL,
- NULL, 0, -1, 0, "-background", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_PANEDWINDOW_BORDERWIDTH, -1, Tk_Offset(PanedWindow, borderWidth),
+ DEF_PANEDWINDOW_BORDERWIDTH, TCL_INDEX_NONE, offsetof(PanedWindow, borderWidth),
0, 0, GEOMETRY},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_PANEDWINDOW_CURSOR, -1, Tk_Offset(PanedWindow, cursor),
+ DEF_PANEDWINDOW_CURSOR, TCL_INDEX_NONE, offsetof(PanedWindow, cursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-handlepad", "handlePad", "HandlePad",
- DEF_PANEDWINDOW_HANDLEPAD, -1, Tk_Offset(PanedWindow, handlePad),
+ DEF_PANEDWINDOW_HANDLEPAD, TCL_INDEX_NONE, offsetof(PanedWindow, handlePad),
0, 0, GEOMETRY},
{TK_OPTION_PIXELS, "-handlesize", "handleSize", "HandleSize",
- DEF_PANEDWINDOW_HANDLESIZE, Tk_Offset(PanedWindow, handleSizePtr),
- Tk_Offset(PanedWindow, handleSize), 0, 0, GEOMETRY},
+ DEF_PANEDWINDOW_HANDLESIZE, offsetof(PanedWindow, handleSizePtr),
+ offsetof(PanedWindow, handleSize), 0, 0, GEOMETRY},
{TK_OPTION_PIXELS, "-height", "height", "Height",
- DEF_PANEDWINDOW_HEIGHT, Tk_Offset(PanedWindow, heightPtr),
- Tk_Offset(PanedWindow, height), TK_OPTION_NULL_OK, 0, GEOMETRY},
+ DEF_PANEDWINDOW_HEIGHT, offsetof(PanedWindow, heightPtr),
+ offsetof(PanedWindow, height), TK_OPTION_NULL_OK, 0, GEOMETRY},
{TK_OPTION_BOOLEAN, "-opaqueresize", "opaqueResize", "OpaqueResize",
- DEF_PANEDWINDOW_OPAQUERESIZE, -1,
- Tk_Offset(PanedWindow, resizeOpaque), 0, 0, 0},
+ DEF_PANEDWINDOW_OPAQUERESIZE, TCL_INDEX_NONE,
+ offsetof(PanedWindow, resizeOpaque), 0, 0, 0},
{TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient",
- DEF_PANEDWINDOW_ORIENT, -1, Tk_Offset(PanedWindow, orient),
+ DEF_PANEDWINDOW_ORIENT, TCL_INDEX_NONE, offsetof(PanedWindow, orient),
0, orientStrings, GEOMETRY},
{TK_OPTION_BORDER, "-proxybackground", "proxyBackground", "ProxyBackground",
- 0, -1, Tk_Offset(PanedWindow, proxyBackground), TK_OPTION_NULL_OK,
+ 0, TCL_INDEX_NONE, offsetof(PanedWindow, proxyBackground), TK_OPTION_NULL_OK,
(ClientData) DEF_PANEDWINDOW_BG_MONO, 0},
{TK_OPTION_PIXELS, "-proxyborderwidth", "proxyBorderWidth", "ProxyBorderWidth",
- DEF_PANEDWINDOW_PROXYBORDER, Tk_Offset(PanedWindow, proxyBorderWidthPtr),
- Tk_Offset(PanedWindow, proxyBorderWidth), 0, 0, GEOMETRY},
+ DEF_PANEDWINDOW_PROXYBORDER, offsetof(PanedWindow, proxyBorderWidthPtr),
+ offsetof(PanedWindow, proxyBorderWidth), 0, 0, GEOMETRY},
{TK_OPTION_RELIEF, "-proxyrelief", "proxyRelief", "Relief",
- 0, -1, Tk_Offset(PanedWindow, proxyRelief),
+ 0, TCL_INDEX_NONE, offsetof(PanedWindow, proxyRelief),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_PANEDWINDOW_RELIEF, -1, Tk_Offset(PanedWindow, relief), 0, 0, 0},
+ DEF_PANEDWINDOW_RELIEF, TCL_INDEX_NONE, offsetof(PanedWindow, relief), 0, 0, 0},
{TK_OPTION_CURSOR, "-sashcursor", "sashCursor", "Cursor",
- DEF_PANEDWINDOW_SASHCURSOR, -1, Tk_Offset(PanedWindow, sashCursor),
+ DEF_PANEDWINDOW_SASHCURSOR, TCL_INDEX_NONE, offsetof(PanedWindow, sashCursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-sashpad", "sashPad", "SashPad",
- DEF_PANEDWINDOW_SASHPAD, -1, Tk_Offset(PanedWindow, sashPad),
+ DEF_PANEDWINDOW_SASHPAD, TCL_INDEX_NONE, offsetof(PanedWindow, sashPad),
0, 0, GEOMETRY},
{TK_OPTION_RELIEF, "-sashrelief", "sashRelief", "Relief",
- DEF_PANEDWINDOW_SASHRELIEF, -1, Tk_Offset(PanedWindow, sashRelief),
+ DEF_PANEDWINDOW_SASHRELIEF, TCL_INDEX_NONE, offsetof(PanedWindow, sashRelief),
0, 0, 0},
{TK_OPTION_PIXELS, "-sashwidth", "sashWidth", "Width",
- DEF_PANEDWINDOW_SASHWIDTH, Tk_Offset(PanedWindow, sashWidthPtr),
- Tk_Offset(PanedWindow, sashWidth), 0, 0, GEOMETRY},
+ DEF_PANEDWINDOW_SASHWIDTH, offsetof(PanedWindow, sashWidthPtr),
+ offsetof(PanedWindow, sashWidth), 0, 0, GEOMETRY},
{TK_OPTION_BOOLEAN, "-showhandle", "showHandle", "ShowHandle",
- DEF_PANEDWINDOW_SHOWHANDLE, -1, Tk_Offset(PanedWindow, showHandle),
+ DEF_PANEDWINDOW_SHOWHANDLE, TCL_INDEX_NONE, offsetof(PanedWindow, showHandle),
0, 0, GEOMETRY},
{TK_OPTION_PIXELS, "-width", "width", "Width",
- DEF_PANEDWINDOW_WIDTH, Tk_Offset(PanedWindow, widthPtr),
- Tk_Offset(PanedWindow, width), TK_OPTION_NULL_OK, 0, GEOMETRY},
+ DEF_PANEDWINDOW_WIDTH, offsetof(PanedWindow, widthPtr),
+ offsetof(PanedWindow, width), TK_OPTION_NULL_OK, 0, GEOMETRY},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0}
};
static const Tk_OptionSpec 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, heightPtr),
+ 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), 0,
+ 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), 0,
+ DEF_PANEDWINDOW_PANE_STRETCH, TCL_INDEX_NONE, offsetof(Pane, stretch), 0,
(ClientData) 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, widthPtr),
+ offsetof(Pane, width), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0}
};
@@ -414,7 +414,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 +459,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 +506,7 @@ Tk_PanedWindowObjCmd(
return TCL_ERROR;
}
- Tcl_SetObjResult(interp, TkNewWindowObj(pwPtr->tkwin));
+ Tcl_SetObjResult(interp, Tk_NewWindowObj(pwPtr->tkwin));
return TCL_OK;
}
@@ -551,7 +551,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 +578,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 +590,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,7 +668,7 @@ 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);
}
}
@@ -688,7 +688,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;
}
@@ -708,7 +708,7 @@ PanedWindowWidgetObjCmd(
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 +728,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;
@@ -847,7 +847,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;
@@ -924,7 +924,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 +971,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;
@@ -1131,8 +1131,8 @@ PanedWindowSashCommand(
}
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;
@@ -1165,8 +1165,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;
@@ -1248,7 +1248,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;
@@ -2396,7 +2396,7 @@ GetSticky(
TCL_UNUSED(void *),
TCL_UNUSED(Tk_Window),
char *recordPtr, /* Pointer to widget record. */
- int internalOffset) /* Offset within *recordPtr containing the
+ TkSizeT internalOffset) /* Offset within *recordPtr containing the
* sticky value. */
{
int sticky = *(int *)(recordPtr + internalOffset);
@@ -2448,13 +2448,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
+ TkSizeT 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);
@@ -2875,8 +2876,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;
@@ -3018,13 +3019,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. */
+ TkSizeT 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;
}
@@ -3140,7 +3141,7 @@ PanedWindowIdentifyCoords(
if (found != -1) {
Tcl_Obj *list[2];
- list[0] = Tcl_NewIntObj(found);
+ list[0] = Tcl_NewWideIntObj(found);
list[1] = Tcl_NewStringObj((isHandle ? "handle" : "sash"), -1);
Tcl_SetObjResult(interp, Tcl_NewListObj(2, list));
}
diff --git a/generic/tkPkgConfig.c b/generic/tkPkgConfig.c
new file mode 100644
index 0000000..ed8fb0b
--- /dev/null
+++ b/generic/tkPkgConfig.c
@@ -0,0 +1,169 @@
+/*
+ * tkPkgConfig.c --
+ *
+ * This file contains the configuration information to embed into the tcl
+ * binary library.
+ *
+ * Copyright (c) 2002 Andreas Kupries <andreas_kupries@users.sourceforge.net>
+ * Copyright (c) 2017 Stuart Cassoff <stwo@users.sourceforge.net>
+ *
+ * See the file "license.terms" for information on usage and redistribution of
+ * this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ */
+
+/* Note, the definitions in this module are influenced by the following C
+ * preprocessor macros:
+ *
+ * OSCMa = shortcut for "old style configuration macro activates"
+ * NSCMdt = shortcut for "new style configuration macro declares that"
+ *
+ * - TCL_THREADS OSCMa compilation as threaded.
+ * - TCL_MEM_DEBUG OSCMa memory debugging.
+ *
+ * - TCL_CFG_DO64BIT NSCMdt tk is compiled for a 64bit system.
+ * - NDEBUG NSCMdt tk is compiled with symbol info off.
+ * - TCL_CFG_OPTIMIZED NSCMdt tk is compiled with cc optimizations on
+ * - TCL_CFG_PROFILED NSCMdt tk is compiled with profiling info.
+ *
+ * - _WIN32 || __CYGWIN__ The value for the fontsytem key will be
+ * MAC_OSX_TK chosen based on these macros/defines.
+ * HAVE_XFT NSCMdt xft font support was requested.
+ *
+ * - CFG_RUNTIME_* Paths to various stuff at runtime.
+ * - CFG_INSTALL_* Paths to various stuff at installation time.
+ *
+ * - TCL_CFGVAL_ENCODING string containing the encoding used for the
+ * configuration values.
+ */
+
+#include "tkInt.h"
+
+
+#ifndef TCL_CFGVAL_ENCODING
+#define TCL_CFGVAL_ENCODING "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[] = {
+ {"debug", CFG_DEBUG},
+ {"threaded", CFG_THREADED},
+ {"profiled", CFG_PROFILED},
+ {"64bit", CFG_64},
+ {"optimized", CFG_OPTIMIZED},
+#ifdef TK_NO_DEPRECATED
+ {"nodeprecated", "1"},
+#endif
+ {"mem_debug", CFG_MEMDEBUG},
+ {"fontsystem", CFG_FONTSYSTEM},
+
+ /* Runtime paths to various stuff */
+
+#ifdef CFG_RUNTIME_LIBDIR
+ {"libdir,runtime", CFG_RUNTIME_LIBDIR},
+#endif
+#ifdef CFG_RUNTIME_BINDIR
+ {"bindir,runtime", CFG_RUNTIME_BINDIR},
+#endif
+#ifdef CFG_RUNTIME_SCRDIR
+ {"scriptdir,runtime", CFG_RUNTIME_SCRDIR},
+#endif
+#ifdef CFG_RUNTIME_INCDIR
+ {"includedir,runtime", CFG_RUNTIME_INCDIR},
+#endif
+#ifdef CFG_RUNTIME_DOCDIR
+ {"docdir,runtime", CFG_RUNTIME_DOCDIR},
+#endif
+#ifdef CFG_RUNTIME_DEMODIR
+ {"demodir,runtime", CFG_RUNTIME_DEMODIR},
+#endif
+
+ /* Installation paths to various stuff */
+
+#ifdef CFG_INSTALL_LIBDIR
+ {"libdir,install", CFG_INSTALL_LIBDIR},
+#endif
+#ifdef CFG_INSTALL_BINDIR
+ {"bindir,install", CFG_INSTALL_BINDIR},
+#endif
+#ifdef CFG_INSTALL_SCRDIR
+ {"scriptdir,install", CFG_INSTALL_SCRDIR},
+#endif
+#ifdef CFG_INSTALL_INCDIR
+ {"includedir,install", CFG_INSTALL_INCDIR},
+#endif
+#ifdef CFG_INSTALL_DOCDIR
+ {"docdir,install", CFG_INSTALL_DOCDIR},
+#endif
+#ifdef CFG_INSTALL_DEMODIR
+ {"demodir,install", CFG_INSTALL_DEMODIR},
+#endif
+
+ /* Last entry, closes the array */
+ {NULL, NULL}
+};
+
+void
+TkInitEmbeddedConfigurationInformation(
+ Tcl_Interp *interp) /* Interpreter the configuration command is
+ * registered in. */
+{
+ Tcl_RegisterConfig(interp, "tk", cfg, TCL_CFGVAL_ENCODING);
+}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */
diff --git a/generic/tkPlace.c b/generic/tkPlace.c
index 47ceee2..8d6b87e 100644
--- a/generic/tkPlace.c
+++ b/generic/tkPlace.c
@@ -81,31 +81,31 @@ 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), 0, 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),
+ {TK_OPTION_ANCHOR, "-anchor", NULL, NULL, "nw", TCL_INDEX_NONE,
+ offsetof(Content, anchor), 0, 0, 0},
+ {TK_OPTION_STRING_TABLE, "-bordermode", NULL, NULL, "inside", TCL_INDEX_NONE,
+ offsetof(Content, borderMode), 0, borderModeStrings, 0},
+ {TK_OPTION_PIXELS, "-height", NULL, NULL, "", offsetof(Content, heightPtr),
+ 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, "",
- Tk_Offset(Content, relHeightPtr), Tk_Offset(Content, relHeight),
+ offsetof(Content, relHeightPtr), offsetof(Content, relHeight),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_DOUBLE, "-relwidth", NULL, NULL, "",
- Tk_Offset(Content, relWidthPtr), Tk_Offset(Content, relWidth),
+ offsetof(Content, relWidthPtr), offsetof(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_DOUBLE, "-relx", NULL, NULL, "0", TCL_INDEX_NONE,
+ offsetof(Content, relX), 0, 0, 0},
+ {TK_OPTION_DOUBLE, "-rely", NULL, NULL, "0", TCL_INDEX_NONE,
+ offsetof(Content, relY), 0, 0, 0},
+ {TK_OPTION_PIXELS, "-width", NULL, NULL, "", offsetof(Content, widthPtr),
+ offsetof(Content, width), TK_OPTION_NULL_OK, 0, 0},
+ {TK_OPTION_PIXELS, "-x", NULL, NULL, "0", offsetof(Content, xPtr),
+ offsetof(Content, x), TK_OPTION_NULL_OK, 0, 0},
+ {TK_OPTION_PIXELS, "-y", NULL, NULL, "0", offsetof(Content, yPtr),
+ offsetof(Content, y), TK_OPTION_NULL_OK, 0, 0},
+ {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0}
};
/*
@@ -129,7 +129,7 @@ static const Tk_OptionSpec optionSpecs[] = {
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
@@ -216,6 +216,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 +250,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 +274,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_GetIndexFromObjStruct(interp, 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;
}
@@ -290,7 +301,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 +325,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);
@@ -330,8 +341,8 @@ Tk_PlaceObjCmd(
}
return PlaceInfoCommand(interp, tkwin);
- case PLACE_CONTENT:
- case PLACE_SLAVES: {
+ case PLACE_SLAVES:
+ case PLACE_CONTENT: {
Container *containerPtr;
if (objc != 3) {
@@ -345,7 +356,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 +394,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);
}
@@ -456,7 +467,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;
}
@@ -468,7 +479,7 @@ FindContent(
*
* UnlinkContent --
*
- * This function removes a content window from the chain of content in its
+ * This function removes a content window from the chain of content windows in its
* container.
*
* Results:
@@ -496,7 +507,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;
@@ -537,7 +548,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;
@@ -579,7 +590,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;
}
@@ -630,7 +641,7 @@ ConfigureContent(
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;
}
@@ -673,7 +684,7 @@ ConfigureContent(
/*
* Make sure that the new container is either the logical parent of the
- * content or a descendant of that window, and that the container and content
+ * content window or a descendant of that window, and that the container and content
* aren't the same.
*/
@@ -683,7 +694,7 @@ 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);
goto error;
@@ -691,7 +702,7 @@ ConfigureContent(
}
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);
goto error;
@@ -705,7 +716,7 @@ 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",
+ "can't put \"%s\" inside \"%s\": would cause management loop",
Tk_PathName(contentPtr->tkwin), Tk_PathName(win)));
Tcl_SetErrorCode(interp, "TK", "GEOMETRY", "LOOP", NULL);
goto error;
@@ -807,7 +818,7 @@ PlaceInfoCommand(
if (contentPtr->containerPtr != NULL) {
Tcl_AppendToObj(infoObj, "-in", -1);
Tcl_ListObjAppendElement(NULL, infoObj,
- TkNewWindowObj(contentPtr->containerPtr->tkwin));
+ Tk_NewWindowObj(contentPtr->containerPtr->tkwin));
Tcl_AppendToObj(infoObj, " ", -1);
}
Tcl_AppendPrintfToObj(infoObj,
@@ -888,7 +899,7 @@ RecomputePlacement(
Tcl_Preserve(containerPtr);
/*
- * Iterate over all the content for the container. Each content's geometry can
+ * Iterate over all the content windows for the container. Each content's geometry can
* be computed independently of the other content. Changes to the window's
* structure could cause almost anything to happen, including deleting the
* parent or child. If this happens, we'll be told to abort.
@@ -1104,8 +1115,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);
}
@@ -1171,8 +1182,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);
}
}
@@ -1254,8 +1265,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 bad633f..902e73d 100644
--- a/generic/tkPlatDecls.h
+++ b/generic/tkPlatDecls.h
@@ -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 cc67401..addfd0e 100644
--- a/generic/tkPointer.c
+++ b/generic/tkPointer.c
@@ -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;
display->request++;
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;
display->request++;
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/tkRectOval.c b/generic/tkRectOval.c
index 87114c1..76bf03b 100644
--- a/generic/tkRectOval.c
+++ b/generic/tkRectOval.c
@@ -47,7 +47,7 @@ static const Tk_CustomOption stateOption = {
TkStateParseProc, TkStatePrintProc, INT2PTR(2)
};
static const Tk_CustomOption tagsOption = {
- Tk_CanvasTagsParseProc, Tk_CanvasTagsPrintProc, NULL
+ TkCanvasTagsParseProc, TkCanvasTagsPrintProc, NULL
};
static const Tk_CustomOption dashOption = {
TkCanvasDashParseProc, TkCanvasDashPrintProc, NULL
@@ -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_PIXELS, "-disabledwidth", NULL, NULL,
- "0.0", Tk_Offset(RectOvalItem, outline.disabledWidth),
+ "0.0", offsetof(RectOvalItem, outline.disabledWidth),
TK_CONFIG_DONT_SET_DEFAULT, &pixelOption},
{TK_CONFIG_COLOR, "-fill", NULL, NULL,
- NULL, Tk_Offset(RectOvalItem, fillColor), TK_CONFIG_NULL_OK, NULL},
+ NULL, offsetof(RectOvalItem, fillColor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_CUSTOM, "-offset", NULL, NULL,
- "0,0", Tk_Offset(RectOvalItem, tsoffset),
+ "0,0", offsetof(RectOvalItem, tsoffset),
TK_CONFIG_DONT_SET_DEFAULT, &offsetOption},
{TK_CONFIG_COLOR, "-outline", NULL, NULL,
- 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}
};
@@ -149,6 +149,8 @@ static int RectToArea(Tk_Canvas canvas, Tk_Item *itemPtr,
double *areaPtr);
static double RectToPoint(Tk_Canvas canvas, Tk_Item *itemPtr,
double *pointPtr);
+static void RotateRectOval(Tk_Canvas canvas, Tk_Item *itemPtr,
+ double originX, double originY, double angleRad);
static void ScaleRectOval(Tk_Canvas canvas, Tk_Item *itemPtr,
double originX, double originY,
double scaleX, double scaleY);
@@ -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
};
/*
@@ -575,6 +579,7 @@ DeleteRectOval(
Display *display) /* Display containing window for canvas. */
{
RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr;
+ (void)canvas;
Tk_DeleteOutline(display, &(rectOvalPtr->outline));
if (rectOvalPtr->fillColor != NULL) {
@@ -617,7 +622,6 @@ DeleteRectOval(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static void
ComputeRectOvalBbox(
Tk_Canvas canvas, /* Canvas that contains item. */
@@ -748,6 +752,10 @@ DisplayRectOval(
short x1, y1, x2, y2;
Pixmap fillStipple;
Tk_State state = itemPtr->state;
+ (void)x;
+ (void)y;
+ (void)width;
+ (void)height;
/*
* Compute the screen coordinates of the bounding box for the item. Make
@@ -957,7 +965,6 @@ DisplayRectOval(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static double
RectToPoint(
Tk_Canvas canvas, /* Canvas containing item. */
@@ -1077,7 +1084,6 @@ RectToPoint(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static double
OvalToPoint(
Tk_Canvas canvas, /* Canvas containing item. */
@@ -1132,7 +1138,6 @@ OvalToPoint(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static int
RectToArea(
Tk_Canvas canvas, /* Canvas containing item. */
@@ -1206,7 +1211,6 @@ RectToArea(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
static int
OvalToArea(
Tk_Canvas canvas, /* Canvas containing item. */
@@ -1286,6 +1290,57 @@ OvalToArea(
/*
*--------------------------------------------------------------
*
+ * RotateRectOval --
+ *
+ * This function is invoked to rotate a rectangle or oval item's
+ * coordinates. It works by rotating a computed point in the centre of
+ * the bounding box, NOT by rotating the corners of the bounding box.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * The position of the rectangle or oval is rotated by angleRad about
+ * (originX, originY), and the bounding box is updated in the generic
+ * part of the item structure.
+ *
+ *--------------------------------------------------------------
+ */
+
+static void
+RotateRectOval(
+ Tk_Canvas canvas, /* Canvas containing rectangle. */
+ Tk_Item *itemPtr, /* Rectangle to be scaled. */
+ double originX, double originY,
+ /* Origin about which to rotate rect. */
+ double angleRad) /* Amount to scale in X direction. */
+{
+ RectOvalItem *rectOvalPtr = (RectOvalItem *) itemPtr;
+ double newX, newY, oldX, oldY;
+
+ /*
+ * Compute the centre of the box, then rotate that about the origin.
+ */
+
+ newX = oldX = (rectOvalPtr->bbox[0] + rectOvalPtr->bbox[2]) / 2.0;
+ newY = oldY = (rectOvalPtr->bbox[1] + rectOvalPtr->bbox[3]) / 2.0;
+ TkRotatePoint(originX, originY, sin(angleRad), cos(angleRad),
+ &newX, &newY);
+
+ /*
+ * Apply the translation to the box.
+ */
+
+ rectOvalPtr->bbox[0] += newX - oldX;
+ rectOvalPtr->bbox[1] += newY - oldY;
+ rectOvalPtr->bbox[2] += newX - oldX;
+ rectOvalPtr->bbox[3] += newY - oldY;
+ ComputeRectOvalBbox(canvas, rectOvalPtr);
+}
+
+/*
+ *--------------------------------------------------------------
+ *
* ScaleRectOval --
*
* This function is invoked to rescale a rectangle or oval item.
@@ -1391,6 +1446,7 @@ RectOvalToPostscript(
Pixmap fillStipple;
Tk_State state = itemPtr->state;
Tcl_InterpState interpState;
+ (void)prepass;
y1 = Tk_CanvasPsY(canvas, rectOvalPtr->bbox[1]);
y2 = Tk_CanvasPsY(canvas, rectOvalPtr->bbox[3]);
@@ -1465,18 +1521,14 @@ RectOvalToPostscript(
Tcl_AppendObjToObj(psObj, pathObj);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsColor(interp, canvas, fillColor) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsColor(interp, canvas, fillColor);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (fillStipple != None) {
Tcl_AppendToObj(psObj, "clip ", -1);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsStipple(interp, canvas, fillStipple) != TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsStipple(interp, canvas, fillStipple);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
if (color != NULL) {
Tcl_AppendToObj(psObj, "grestore gsave\n", -1);
@@ -1495,10 +1547,7 @@ RectOvalToPostscript(
Tcl_AppendToObj(psObj, "0 setlinejoin 2 setlinecap\n", -1);
Tcl_ResetResult(interp);
- if (Tk_CanvasPsOutline(canvas, itemPtr,
- &rectOvalPtr->outline)!= TCL_OK) {
- goto error;
- }
+ Tk_CanvasPsOutline(canvas, itemPtr, &rectOvalPtr->outline);
Tcl_AppendObjToObj(psObj, Tcl_GetObjResult(interp));
}
@@ -1511,12 +1560,6 @@ RectOvalToPostscript(
Tcl_DecrRefCount(psObj);
Tcl_DecrRefCount(pathObj);
return TCL_OK;
-
- error:
- Tcl_DiscardInterpState(interpState);
- Tcl_DecrRefCount(psObj);
- Tcl_DecrRefCount(pathObj);
- return TCL_ERROR;
}
/*
diff --git a/generic/tkScale.c b/generic/tkScale.c
index 825f661..f1e2cec 100644
--- a/generic/tkScale.c
+++ b/generic/tkScale.c
@@ -17,9 +17,9 @@
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
-#include "default.h"
#include "tkInt.h"
#include "tkScale.h"
+#include "default.h"
#if defined(_WIN32)
#define snprintf _snprintf
@@ -45,97 +45,97 @@ static const char *const stateStrings[] = {
static const Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_BORDER, "-activebackground", "activeBackground", "Foreground",
- DEF_SCALE_ACTIVE_BG_COLOR, -1, Tk_Offset(TkScale, activeBorder),
+ DEF_SCALE_ACTIVE_BG_COLOR, TCL_INDEX_NONE, offsetof(TkScale, activeBorder),
0, DEF_SCALE_ACTIVE_BG_MONO, 0},
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_SCALE_BG_COLOR, -1, Tk_Offset(TkScale, bgBorder),
+ DEF_SCALE_BG_COLOR, TCL_INDEX_NONE, offsetof(TkScale, bgBorder),
0, DEF_SCALE_BG_MONO, 0},
{TK_OPTION_DOUBLE, "-bigincrement", "bigIncrement", "BigIncrement",
- DEF_SCALE_BIG_INCREMENT, -1, Tk_Offset(TkScale, bigIncrement),
+ DEF_SCALE_BIG_INCREMENT, TCL_INDEX_NONE, offsetof(TkScale, bigIncrement),
0, 0, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth", 0},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL,
- NULL, 0, -1, 0, "-background", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_SCALE_BORDER_WIDTH, -1, Tk_Offset(TkScale, borderWidth),
+ DEF_SCALE_BORDER_WIDTH, TCL_INDEX_NONE, offsetof(TkScale, borderWidth),
0, 0, 0},
{TK_OPTION_STRING, "-command", "command", "Command",
- DEF_SCALE_COMMAND, -1, Tk_Offset(TkScale, command),
+ DEF_SCALE_COMMAND, TCL_INDEX_NONE, offsetof(TkScale, command),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_SCALE_CURSOR, -1, Tk_Offset(TkScale, cursor),
+ DEF_SCALE_CURSOR, TCL_INDEX_NONE, offsetof(TkScale, cursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_INT, "-digits", "digits", "Digits",
- DEF_SCALE_DIGITS, -1, Tk_Offset(TkScale, digits),
+ DEF_SCALE_DIGITS, TCL_INDEX_NONE, offsetof(TkScale, digits),
0, 0, 0},
{TK_OPTION_SYNONYM, "-fg", "foreground", NULL,
- NULL, 0, -1, 0, "-foreground", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_SCALE_FONT, -1, Tk_Offset(TkScale, tkfont), 0, 0, 0},
+ DEF_SCALE_FONT, TCL_INDEX_NONE, offsetof(TkScale, tkfont), 0, 0, 0},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_SCALE_FG_COLOR, -1, Tk_Offset(TkScale, textColorPtr), 0,
+ DEF_SCALE_FG_COLOR, TCL_INDEX_NONE, offsetof(TkScale, textColorPtr), 0,
(ClientData) DEF_SCALE_FG_MONO, 0},
- {TK_OPTION_DOUBLE, "-from", "from", "From", DEF_SCALE_FROM, -1,
- Tk_Offset(TkScale, fromValue), 0, 0, 0},
+ {TK_OPTION_DOUBLE, "-from", "from", "From", DEF_SCALE_FROM, TCL_INDEX_NONE,
+ offsetof(TkScale, fromValue), 0, 0, 0},
{TK_OPTION_BORDER, "-highlightbackground", "highlightBackground",
"HighlightBackground", DEF_SCALE_HIGHLIGHT_BG_COLOR,
- -1, Tk_Offset(TkScale, highlightBorder),
+ TCL_INDEX_NONE, offsetof(TkScale, highlightBorder),
0, DEF_SCALE_HIGHLIGHT_BG_MONO, 0},
{TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_SCALE_HIGHLIGHT, -1, Tk_Offset(TkScale, highlightColorPtr),
+ DEF_SCALE_HIGHLIGHT, TCL_INDEX_NONE, offsetof(TkScale, highlightColorPtr),
0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
- "HighlightThickness", DEF_SCALE_HIGHLIGHT_WIDTH, -1,
- Tk_Offset(TkScale, highlightWidth), 0, 0, 0},
+ "HighlightThickness", DEF_SCALE_HIGHLIGHT_WIDTH, TCL_INDEX_NONE,
+ offsetof(TkScale, highlightWidth), 0, 0, 0},
{TK_OPTION_STRING, "-label", "label", "Label",
- DEF_SCALE_LABEL, -1, Tk_Offset(TkScale, label),
+ DEF_SCALE_LABEL, TCL_INDEX_NONE, offsetof(TkScale, label),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-length", "length", "Length",
- DEF_SCALE_LENGTH, -1, Tk_Offset(TkScale, length), 0, 0, 0},
+ DEF_SCALE_LENGTH, TCL_INDEX_NONE, offsetof(TkScale, length), 0, 0, 0},
{TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient",
- DEF_SCALE_ORIENT, -1, Tk_Offset(TkScale, orient),
+ DEF_SCALE_ORIENT, TCL_INDEX_NONE, offsetof(TkScale, orient),
0, orientStrings, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_SCALE_RELIEF, -1, Tk_Offset(TkScale, relief), 0, 0, 0},
+ DEF_SCALE_RELIEF, TCL_INDEX_NONE, offsetof(TkScale, relief), 0, 0, 0},
{TK_OPTION_INT, "-repeatdelay", "repeatDelay", "RepeatDelay",
- DEF_SCALE_REPEAT_DELAY, -1, Tk_Offset(TkScale, repeatDelay),
+ DEF_SCALE_REPEAT_DELAY, TCL_INDEX_NONE, offsetof(TkScale, repeatDelay),
0, 0, 0},
{TK_OPTION_INT, "-repeatinterval", "repeatInterval", "RepeatInterval",
- DEF_SCALE_REPEAT_INTERVAL, -1, Tk_Offset(TkScale, repeatInterval),
+ DEF_SCALE_REPEAT_INTERVAL, TCL_INDEX_NONE, offsetof(TkScale, repeatInterval),
0, 0, 0},
{TK_OPTION_DOUBLE, "-resolution", "resolution", "Resolution",
- DEF_SCALE_RESOLUTION, -1, Tk_Offset(TkScale, resolution),
+ DEF_SCALE_RESOLUTION, TCL_INDEX_NONE, offsetof(TkScale, resolution),
0, 0, 0},
{TK_OPTION_BOOLEAN, "-showvalue", "showValue", "ShowValue",
- DEF_SCALE_SHOW_VALUE, -1, Tk_Offset(TkScale, showValue),
+ DEF_SCALE_SHOW_VALUE, TCL_INDEX_NONE, offsetof(TkScale, showValue),
0, 0, 0},
{TK_OPTION_PIXELS, "-sliderlength", "sliderLength", "SliderLength",
- DEF_SCALE_SLIDER_LENGTH, -1, Tk_Offset(TkScale, sliderLength),
+ DEF_SCALE_SLIDER_LENGTH, TCL_INDEX_NONE, offsetof(TkScale, sliderLength),
0, 0, 0},
{TK_OPTION_RELIEF, "-sliderrelief", "sliderRelief", "SliderRelief",
- DEF_SCALE_SLIDER_RELIEF, -1, Tk_Offset(TkScale, sliderRelief),
+ DEF_SCALE_SLIDER_RELIEF, TCL_INDEX_NONE, offsetof(TkScale, sliderRelief),
0, 0, 0},
{TK_OPTION_STRING_TABLE, "-state", "state", "State",
- DEF_SCALE_STATE, -1, Tk_Offset(TkScale, state),
+ DEF_SCALE_STATE, TCL_INDEX_NONE, offsetof(TkScale, state),
0, stateStrings, 0},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_SCALE_TAKE_FOCUS, Tk_Offset(TkScale, takeFocusPtr), -1,
+ DEF_SCALE_TAKE_FOCUS, offsetof(TkScale, takeFocusPtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_DOUBLE, "-tickinterval", "tickInterval", "TickInterval",
- DEF_SCALE_TICK_INTERVAL, -1, Tk_Offset(TkScale, tickInterval),
+ DEF_SCALE_TICK_INTERVAL, TCL_INDEX_NONE, offsetof(TkScale, tickInterval),
0, 0, 0},
{TK_OPTION_DOUBLE, "-to", "to", "To",
- DEF_SCALE_TO, -1, Tk_Offset(TkScale, toValue), 0, 0, 0},
+ DEF_SCALE_TO, TCL_INDEX_NONE, offsetof(TkScale, toValue), 0, 0, 0},
{TK_OPTION_COLOR, "-troughcolor", "troughColor", "Background",
- DEF_SCALE_TROUGH_COLOR, -1, Tk_Offset(TkScale, troughColorPtr),
+ DEF_SCALE_TROUGH_COLOR, TCL_INDEX_NONE, offsetof(TkScale, troughColorPtr),
0, DEF_SCALE_TROUGH_MONO, 0},
{TK_OPTION_STRING, "-variable", "variable", "Variable",
- DEF_SCALE_VARIABLE, Tk_Offset(TkScale, varNamePtr), -1,
+ DEF_SCALE_VARIABLE, offsetof(TkScale, varNamePtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-width", "width", "Width",
- DEF_SCALE_WIDTH, -1, Tk_Offset(TkScale, width), 0, 0, 0},
- {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, -1, 0, 0, 0}
+ DEF_SCALE_WIDTH, TCL_INDEX_NONE, offsetof(TkScale, width), 0, 0, 0},
+ {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0, 0, 0}
};
/*
@@ -161,7 +161,7 @@ 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);
@@ -248,14 +248,15 @@ ScaleRound(
int
Tk_ScaleObjCmd(
- ClientData clientData, /* NULL. */
+ ClientData dummy, /* NULL. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument values. */
{
- register TkScale *scalePtr;
+ TkScale *scalePtr;
Tk_OptionTable optionTable;
Tk_Window tkwin;
+ (void)dummy;
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "pathName ?-option value ...?");
@@ -343,7 +344,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);
@@ -356,7 +357,7 @@ Tk_ScaleObjCmd(
scalePtr->flags &= ~INVOKE_COMMAND;
- Tcl_SetObjResult(interp, TkNewWindowObj(scalePtr->tkwin));
+ Tcl_SetObjResult(interp, Tk_NewWindowObj(scalePtr->tkwin));
return TCL_OK;
}
@@ -385,7 +386,7 @@ ScaleWidgetObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument strings. */
{
- TkScale *scalePtr = clientData;
+ TkScale *scalePtr = (TkScale *)clientData;
Tcl_Obj *objPtr;
int index, result;
@@ -406,7 +407,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;
@@ -415,7 +416,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) {
@@ -451,8 +452,8 @@ ScaleWidgetObjCmd(
y = scalePtr->horizTroughY + scalePtr->width/2
+ scalePtr->borderWidth;
}
- coords[0] = Tcl_NewIntObj(x);
- coords[1] = Tcl_NewIntObj(y);
+ coords[0] = Tcl_NewWideIntObj(x);
+ coords[1] = Tcl_NewWideIntObj(y);
Tcl_SetObjResult(interp, Tcl_NewListObj(2, coords));
break;
}
@@ -540,9 +541,9 @@ ScaleWidgetObjCmd(
static void
DestroyScale(
- char *memPtr) /* Info about scale widget. */
+ void *memPtr) /* Info about scale widget. */
{
- register TkScale *scalePtr = (TkScale *) memPtr;
+ TkScale *scalePtr = (TkScale *) memPtr;
scalePtr->flags |= SCALE_DELETED;
@@ -599,7 +600,7 @@ DestroyScale(
static int
ConfigureScale(
Tcl_Interp *interp, /* Used for error reporting. */
- register TkScale *scalePtr, /* Information about widget; may or may not
+ TkScale *scalePtr, /* Information about widget; may or may not
* already have values for some fields. */
int objc, /* Number of valid entries in objv. */
Tcl_Obj *const objv[]) /* Argument values. */
@@ -625,7 +626,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;
@@ -680,7 +681,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);
@@ -767,7 +768,7 @@ ScaleWorldChanged(
{
XGCValues gcValues;
GC gc;
- TkScale *scalePtr = instanceData;
+ TkScale *scalePtr = (TkScale *)instanceData;
gcValues.foreground = scalePtr->troughColorPtr->pixel;
gc = Tk_GetGC(scalePtr->tkwin, GCForeground, &gcValues);
@@ -1017,7 +1018,7 @@ ComputeFormat(
static void
ComputeScaleGeometry(
- register TkScale *scalePtr) /* Information about widget. */
+ TkScale *scalePtr) /* Information about widget. */
{
char valueString[TCL_DOUBLE_SPACE];
int tmp, valuePixels, tickPixels, x, y, extraSpace;
@@ -1161,7 +1162,7 @@ ScaleEventProc(
ClientData clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
- TkScale *scalePtr = clientData;
+ TkScale *scalePtr = (TkScale *)clientData;
if ((eventPtr->type == Expose) && (eventPtr->xexpose.count == 0)) {
TkEventuallyRedrawScale(scalePtr, REDRAW_ALL);
@@ -1209,7 +1210,7 @@ static void
ScaleCmdDeletedProc(
ClientData clientData) /* Pointer to widget record for widget. */
{
- TkScale *scalePtr = clientData;
+ TkScale *scalePtr = (TkScale *)clientData;
Tk_Window tkwin = scalePtr->tkwin;
/*
@@ -1246,7 +1247,7 @@ ScaleCmdDeletedProc(
void
TkEventuallyRedrawScale(
- register TkScale *scalePtr, /* Information about widget. */
+ TkScale *scalePtr, /* Information about widget. */
int what) /* What to redraw: REDRAW_SLIDER or
* REDRAW_ALL. */
{
@@ -1335,7 +1336,6 @@ TkRoundIntervalToResolution(
*----------------------------------------------------------------------
*/
- /* ARGSUSED */
static char *
ScaleVarProc(
ClientData clientData, /* Information about button. */
@@ -1344,11 +1344,13 @@ ScaleVarProc(
const char *name2, /* Second part of variable name. */
int flags) /* Information about what happened. */
{
- register TkScale *scalePtr = clientData;
+ TkScale *scalePtr = (TkScale *)clientData;
const char *resultStr;
double value;
Tcl_Obj *valuePtr;
int result;
+ (void)name1;
+ (void)name2;
/*
* If the variable is unset, then immediately recreate it unless the whole
@@ -1439,7 +1441,7 @@ ScaleVarProc(
void
TkScaleSetValue(
- register TkScale *scalePtr, /* Info about widget. */
+ TkScale *scalePtr, /* Info about widget. */
double value, /* New value for scale. Gets adjusted if it's
* off the scale. */
int setVar, /* Non-zero means reflect new value through to
@@ -1497,7 +1499,7 @@ TkScaleSetValue(
static void
ScaleSetVariable(
- register TkScale *scalePtr) /* Info about widget. */
+ TkScale *scalePtr) /* Info about widget. */
{
if (scalePtr->varNamePtr != NULL) {
char string[TCL_DOUBLE_SPACE];
@@ -1533,7 +1535,7 @@ ScaleSetVariable(
double
TkScalePixelToValue(
- register TkScale *scalePtr, /* Information about widget. */
+ TkScale *scalePtr, /* Information about widget. */
int x, int y) /* Coordinates of point within window. */
{
double value, pixelRange;
@@ -1591,7 +1593,7 @@ TkScalePixelToValue(
int
TkScaleValueToPixel(
- register TkScale *scalePtr, /* Information about widget. */
+ TkScale *scalePtr, /* Information about widget. */
double value) /* Reading of the widget. */
{
int y, pixelRange;
diff --git a/generic/tkScale.h b/generic/tkScale.h
index e68b786..4e4a3e7 100644
--- a/generic/tkScale.h
+++ b/generic/tkScale.h
@@ -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. */
+ TkSizeT 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. */
diff --git a/generic/tkScrollbar.c b/generic/tkScrollbar.c
index 8c80846..86ec25a 100644
--- a/generic/tkScrollbar.c
+++ b/generic/tkScrollbar.c
@@ -33,62 +33,62 @@ char tkDefScrollbarWidth[TCL_INTEGER_SPACE] = DEF_SCROLLBAR_WIDTH;
static const Tk_ConfigSpec configSpecs[] = {
{TK_CONFIG_BORDER, "-activebackground", "activeBackground", "Foreground",
- DEF_SCROLLBAR_ACTIVE_BG_COLOR, Tk_Offset(TkScrollbar, activeBorder),
+ DEF_SCROLLBAR_ACTIVE_BG_COLOR, offsetof(TkScrollbar, activeBorder),
TK_CONFIG_COLOR_ONLY, NULL},
{TK_CONFIG_BORDER, "-activebackground", "activeBackground", "Foreground",
- DEF_SCROLLBAR_ACTIVE_BG_MONO, Tk_Offset(TkScrollbar, activeBorder),
+ DEF_SCROLLBAR_ACTIVE_BG_MONO, offsetof(TkScrollbar, activeBorder),
TK_CONFIG_MONO_ONLY, NULL},
{TK_CONFIG_RELIEF, "-activerelief", "activeRelief", "Relief",
- DEF_SCROLLBAR_ACTIVE_RELIEF, Tk_Offset(TkScrollbar, activeRelief), 0, NULL},
+ DEF_SCROLLBAR_ACTIVE_RELIEF, offsetof(TkScrollbar, activeRelief), 0, NULL},
{TK_CONFIG_BORDER, "-background", "background", "Background",
- DEF_SCROLLBAR_BG_COLOR, Tk_Offset(TkScrollbar, bgBorder),
+ DEF_SCROLLBAR_BG_COLOR, offsetof(TkScrollbar, bgBorder),
TK_CONFIG_COLOR_ONLY, NULL},
{TK_CONFIG_BORDER, "-background", "background", "Background",
- DEF_SCROLLBAR_BG_MONO, Tk_Offset(TkScrollbar, bgBorder),
+ DEF_SCROLLBAR_BG_MONO, offsetof(TkScrollbar, bgBorder),
TK_CONFIG_MONO_ONLY, NULL},
{TK_CONFIG_SYNONYM, "-bd", "borderWidth", NULL, NULL, 0, 0, NULL},
{TK_CONFIG_SYNONYM, "-bg", "background", NULL, NULL, 0, 0, NULL},
{TK_CONFIG_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_SCROLLBAR_BORDER_WIDTH, Tk_Offset(TkScrollbar, borderWidth), 0, NULL},
+ DEF_SCROLLBAR_BORDER_WIDTH, offsetof(TkScrollbar, borderWidth), 0, NULL},
{TK_CONFIG_STRING, "-command", "command", "Command",
- DEF_SCROLLBAR_COMMAND, Tk_Offset(TkScrollbar, command),
+ DEF_SCROLLBAR_COMMAND, offsetof(TkScrollbar, command),
TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_ACTIVE_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_SCROLLBAR_CURSOR, Tk_Offset(TkScrollbar, cursor), TK_CONFIG_NULL_OK, NULL},
+ DEF_SCROLLBAR_CURSOR, offsetof(TkScrollbar, cursor), TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_PIXELS, "-elementborderwidth", "elementBorderWidth",
"BorderWidth", DEF_SCROLLBAR_EL_BORDER_WIDTH,
- Tk_Offset(TkScrollbar, elementBorderWidth), 0, NULL},
+ offsetof(TkScrollbar, elementBorderWidth), 0, NULL},
{TK_CONFIG_COLOR, "-highlightbackground", "highlightBackground",
"HighlightBackground", DEF_SCROLLBAR_HIGHLIGHT_BG,
- Tk_Offset(TkScrollbar, highlightBgColorPtr), 0, NULL},
+ offsetof(TkScrollbar, highlightBgColorPtr), 0, NULL},
{TK_CONFIG_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
DEF_SCROLLBAR_HIGHLIGHT,
- Tk_Offset(TkScrollbar, highlightColorPtr), 0, NULL},
+ offsetof(TkScrollbar, highlightColorPtr), 0, NULL},
{TK_CONFIG_PIXELS, "-highlightthickness", "highlightThickness",
"HighlightThickness",
- DEF_SCROLLBAR_HIGHLIGHT_WIDTH, Tk_Offset(TkScrollbar, highlightWidth), 0, NULL},
+ DEF_SCROLLBAR_HIGHLIGHT_WIDTH, offsetof(TkScrollbar, highlightWidth), 0, NULL},
{TK_CONFIG_BOOLEAN, "-jump", "jump", "Jump",
- DEF_SCROLLBAR_JUMP, Tk_Offset(TkScrollbar, jump), 0, NULL},
+ DEF_SCROLLBAR_JUMP, offsetof(TkScrollbar, jump), 0, NULL},
{TK_CONFIG_CUSTOM, "-orient", "orient", "Orient",
- DEF_SCROLLBAR_ORIENT, Tk_Offset(TkScrollbar, vertical), 0,
+ DEF_SCROLLBAR_ORIENT, offsetof(TkScrollbar, vertical), 0,
&orientOption},
{TK_CONFIG_RELIEF, "-relief", "relief", "Relief",
- DEF_SCROLLBAR_RELIEF, Tk_Offset(TkScrollbar, relief), 0, NULL},
+ DEF_SCROLLBAR_RELIEF, offsetof(TkScrollbar, relief), 0, NULL},
{TK_CONFIG_INT, "-repeatdelay", "repeatDelay", "RepeatDelay",
- DEF_SCROLLBAR_REPEAT_DELAY, Tk_Offset(TkScrollbar, repeatDelay), 0, NULL},
+ DEF_SCROLLBAR_REPEAT_DELAY, offsetof(TkScrollbar, repeatDelay), 0, NULL},
{TK_CONFIG_INT, "-repeatinterval", "repeatInterval", "RepeatInterval",
- DEF_SCROLLBAR_REPEAT_INTERVAL, Tk_Offset(TkScrollbar, repeatInterval), 0, NULL},
+ DEF_SCROLLBAR_REPEAT_INTERVAL, offsetof(TkScrollbar, repeatInterval), 0, NULL},
{TK_CONFIG_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_SCROLLBAR_TAKE_FOCUS, Tk_Offset(TkScrollbar, takeFocus),
+ DEF_SCROLLBAR_TAKE_FOCUS, offsetof(TkScrollbar, takeFocus),
TK_CONFIG_NULL_OK, NULL},
{TK_CONFIG_COLOR, "-troughcolor", "troughColor", "Background",
- DEF_SCROLLBAR_TROUGH_COLOR, Tk_Offset(TkScrollbar, troughColorPtr),
+ DEF_SCROLLBAR_TROUGH_COLOR, offsetof(TkScrollbar, troughColorPtr),
TK_CONFIG_COLOR_ONLY, NULL},
{TK_CONFIG_COLOR, "-troughcolor", "troughColor", "Background",
- DEF_SCROLLBAR_TROUGH_MONO, Tk_Offset(TkScrollbar, troughColorPtr),
+ DEF_SCROLLBAR_TROUGH_MONO, offsetof(TkScrollbar, troughColorPtr),
TK_CONFIG_MONO_ONLY, NULL},
{TK_CONFIG_PIXELS, "-width", "width", "Width",
- tkDefScrollbarWidth, Tk_Offset(TkScrollbar, width), 0, NULL},
+ tkDefScrollbarWidth, offsetof(TkScrollbar, width), 0, NULL},
{TK_CONFIG_END, NULL, NULL, NULL, NULL, 0, 0, NULL}
};
@@ -179,10 +179,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 +196,7 @@ Tk_ScrollbarObjCmd(
return TCL_ERROR;
}
- Tcl_SetObjResult(interp, TkNewWindowObj(scrollPtr->tkwin));
+ Tcl_SetObjResult(interp, Tk_NewWindowObj(scrollPtr->tkwin));
return TCL_OK;
}
@@ -224,8 +226,8 @@ ScrollbarWidgetObjCmd(
Tcl_Obj *const objv[]) /* Argument strings. */
{
TkScrollbar *scrollPtr = (TkScrollbar *)clientData;
- int result = TCL_OK;
- int length, cmdIndex;
+ int result = TCL_OK, cmdIndex;
+ TkSizeT length;
static const char *const commandNames[] = {
"activate", "cget", "configure", "delta", "fraction",
"get", "identify", "set", NULL
@@ -269,7 +271,7 @@ ScrollbarWidgetObjCmd(
Tcl_WrongNumArgs(interp, 1, objv, "activate element");
goto error;
}
- c = Tcl_GetStringFromObj(objv[2], &length)[0];
+ c = TkGetStringFromObj(objv[2], &length)[0];
oldActiveField = scrollPtr->activeField;
if ((c == 'a') && (strcmp(Tcl_GetString(objv[2]), "arrow1") == 0)) {
scrollPtr->activeField = TOP_ARROW;
@@ -377,17 +379,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: {
@@ -413,8 +417,6 @@ ScrollbarWidgetObjCmd(
break;
}
case COMMAND_SET: {
- int totalUnits, windowUnits, firstUnit, lastUnit;
-
if (objc == 4) {
double first, last;
@@ -438,8 +440,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 +480,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);
diff --git a/generic/tkScrollbar.h b/generic/tkScrollbar.h
index 2d521ae..f7c39c8 100644
--- a/generic/tkScrollbar.h
+++ b/generic/tkScrollbar.h
@@ -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
/*
diff --git a/generic/tkSelect.c b/generic/tkSelect.c
index 9584be4..7cf62c2 100644
--- a/generic/tkSelect.c
+++ b/generic/tkSelect.c
@@ -26,7 +26,7 @@ typedef struct {
int charOffset; /* The offset of the next char to retrieve. */
int 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
@@ -59,8 +59,8 @@ static Tcl_ThreadDataKey dataKey;
* Forward declarations for functions defined in this file:
*/
-static int HandleTclCommand(ClientData clientData,
- int offset, char *buffer, int maxBytes);
+static TkSizeT HandleTclCommand(ClientData clientData,
+ TkSizeT offset, char *buffer, TkSizeT maxBytes);
static void LostSelection(ClientData clientData);
static int SelGetProc(ClientData clientData,
Tcl_Interp *interp, const char *portion);
@@ -190,7 +190,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);
@@ -357,7 +357,7 @@ Tk_OwnSelection(
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) {
@@ -466,7 +466,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) {
@@ -831,7 +831,7 @@ Tk_SelectionObjCmd(
const char *targetName = NULL;
const char *formatName = NULL;
CommandInfo *cmdInfoPtr;
- int cmdLength;
+ TkSizeT cmdLength;
static const char *const handleOptionStrings[] = {
"-format", "-selection", "-type", NULL
};
@@ -900,11 +900,11 @@ Tk_SelectionObjCmd(
} else {
format = XA_STRING;
}
- string = Tcl_GetStringFromObj(objs[1], &cmdLength);
+ string = TkGetStringFromObj(objs[1], &cmdLength);
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;
@@ -992,7 +992,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;
}
@@ -1246,7 +1246,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 {
@@ -1317,15 +1317,15 @@ SelGetProc(
*----------------------------------------------------------------------
*/
-static int
+static TkSizeT
HandleTclCommand(
ClientData clientData, /* Information about command to execute. */
- int offset, /* Return selection bytes starting at this
+ TkSizeT offset, /* Return selection bytes starting at this
* offset. */
char *buffer, /* Place to store converted selection. */
- int maxBytes) /* Maximum # of bytes to store at buffer. */
+ TkSizeT maxBytes) /* Maximum # of bytes to store at buffer. */
{
- CommandInfo *cmdInfoPtr = clientData;
+ CommandInfo *cmdInfoPtr = (CommandInfo *)clientData;
int length;
Tcl_Obj *command;
const char *string;
@@ -1347,7 +1347,7 @@ HandleTclCommand(
* character.
*/
- if (offset == cmdInfoPtr->byteOffset) {
+ if ((int)offset == cmdInfoPtr->byteOffset) {
charOffset = cmdInfoPtr->charOffset;
extraBytes = strlen(cmdInfoPtr->buffer);
if (extraBytes > 0) {
@@ -1368,7 +1368,7 @@ HandleTclCommand(
*/
command = Tcl_ObjPrintf("%s %d %d",
- cmdInfoPtr->command, charOffset, maxBytes);
+ cmdInfoPtr->command, charOffset, (int)maxBytes);
Tcl_IncrRefCount(command);
/*
@@ -1385,8 +1385,8 @@ HandleTclCommand(
*/
string = Tcl_GetStringFromObj(Tcl_GetObjResult(interp), &length);
- count = (length > maxBytes) ? maxBytes : length;
- memcpy(buffer, string, (size_t) count);
+ count = (length > (int)maxBytes) ? (int)maxBytes : length;
+ memcpy(buffer, string, count);
buffer[count] = '\0';
/*
@@ -1395,7 +1395,7 @@ HandleTclCommand(
*/
if (cmdInfoPtr->interp != NULL) {
- if (length <= maxBytes) {
+ if (length <= (int)maxBytes) {
cmdInfoPtr->charOffset += Tcl_NumUtfChars(string, -1);
cmdInfoPtr->buffer[0] = '\0';
} else {
diff --git a/generic/tkSelect.h b/generic/tkSelect.h
index 74326d0..c2d153b 100644
--- a/generic/tkSelect.h
+++ b/generic/tkSelect.h
@@ -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. */
+ TkSizeT size; /* Size of units returned by proc (8 for
* STRING, 32 for almost anything else). */
struct TkSelHandler *nextPtr;
/* Next selection handler associated with same
@@ -103,7 +107,7 @@ typedef struct TkSelRetrievalInfo {
typedef struct TkClipboardBuffer {
char *buffer; /* Null terminated data buffer. */
- long length; /* Length of string in buffer. */
+ TkSizeT length; /* Length of string in buffer. */
struct TkClipboardBuffer *nextPtr;
/* Next in list of buffers. NULL means end of
* list . */
diff --git a/generic/tkSquare.c b/generic/tkSquare.c
index e92c03c..04c51fa 100644
--- a/generic/tkSquare.c
+++ b/generic/tkSquare.c
@@ -66,29 +66,29 @@ typedef struct {
static const Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_BORDER, "-background", "background", "Background",
- "#d9d9d9", Tk_Offset(Square, bgBorderPtr), -1, 0,
+ "#d9d9d9", offsetof(Square, bgBorderPtr), TCL_INDEX_NONE, 0,
"white", 0},
- {TK_OPTION_SYNONYM, "-bd", NULL, NULL, NULL, 0, -1, 0,
+ {TK_OPTION_SYNONYM, "-bd", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0,
"-borderwidth", 0},
- {TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, 0, -1, 0,
+ {TK_OPTION_SYNONYM, "-bg", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0,
"-background", 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- "2", Tk_Offset(Square, borderWidthPtr), -1, 0, NULL, 0},
+ "2", offsetof(Square, borderWidthPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_BOOLEAN, "-dbl", "doubleBuffer", "DoubleBuffer",
- "1", Tk_Offset(Square, doubleBufferPtr), -1, 0 , NULL, 0},
- {TK_OPTION_SYNONYM, "-fg", NULL, NULL, NULL, 0, -1, 0,
+ "1", offsetof(Square, doubleBufferPtr), TCL_INDEX_NONE, 0 , NULL, 0},
+ {TK_OPTION_SYNONYM, "-fg", NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0,
"-foreground", 0},
{TK_OPTION_BORDER, "-foreground", "foreground", "Foreground",
- "#b03060", Tk_Offset(Square, fgBorderPtr), -1, 0,
+ "#b03060", offsetof(Square, fgBorderPtr), TCL_INDEX_NONE, 0,
"black", 0},
{TK_OPTION_PIXELS, "-posx", "posx", "PosX", "0",
- Tk_Offset(Square, xPtr), -1, 0, NULL, 0},
+ offsetof(Square, xPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_PIXELS, "-posy", "posy", "PosY", "0",
- Tk_Offset(Square, yPtr), -1, 0, NULL, 0},
+ offsetof(Square, yPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- "raised", Tk_Offset(Square, reliefPtr), -1, 0, NULL, 0},
+ "raised", offsetof(Square, reliefPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_PIXELS, "-size", "size", "Size", "20",
- Tk_Offset(Square, sizeObjPtr), -1, 0, NULL, 0},
+ offsetof(Square, sizeObjPtr), TCL_INDEX_NONE, 0, NULL, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0}
};
@@ -125,7 +125,7 @@ static int SquareWidgetObjCmd(ClientData clientData,
int
SquareObjCmd(
- ClientData clientData, /* NULL. */
+ ClientData dummy, /* NULL. */
Tcl_Interp *interp, /* Current interpreter. */
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
@@ -133,6 +133,7 @@ SquareObjCmd(
Square *squarePtr;
Tk_Window tkwin;
Tk_OptionTable optionTable;
+ (void)dummy;
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "pathName ?-option value ...?");
@@ -160,7 +161,7 @@ SquareObjCmd(
* just the non-NULL/0 items.
*/
- squarePtr = ckalloc(sizeof(Square));
+ squarePtr = (Square *)ckalloc(sizeof(Square));
memset(squarePtr, 0, sizeof(Square));
squarePtr->tkwin = tkwin;
@@ -172,7 +173,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);
@@ -181,7 +182,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;
}
@@ -223,7 +224,7 @@ SquareWidgetObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj * const objv[]) /* Argument objects. */
{
- Square *squarePtr = clientData;
+ Square *squarePtr = (Square *)clientData;
int result = TCL_OK;
static const char *const squareOptions[] = {"cget", "configure", NULL};
enum {
@@ -233,7 +234,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;
}
@@ -250,7 +251,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;
@@ -261,19 +262,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) {
@@ -318,12 +319,13 @@ SquareWidgetObjCmd(
static int
SquareConfigure(
- Tcl_Interp *interp, /* Used for error reporting. */
+ Tcl_Interp *dummy, /* Used for error reporting. */
Square *squarePtr) /* Information about widget. */
{
int borderWidth;
Tk_3DBorder bgBorder;
int doubleBuffer;
+ (void)dummy;
/*
* Set the background for the window and create a graphics context for use
@@ -383,7 +385,7 @@ SquareObjEventProc(
ClientData clientData, /* Information about window. */
XEvent *eventPtr) /* Information about event. */
{
- Square *squarePtr = clientData;
+ Square *squarePtr = (Square *)clientData;
if (eventPtr->type == Expose) {
if (!squarePtr->updatePending) {
@@ -436,7 +438,7 @@ static void
SquareDeletedProc(
ClientData clientData) /* Pointer to widget record for widget. */
{
- Square *squarePtr = clientData;
+ Square *squarePtr = (Square *)clientData;
Tk_Window tkwin = squarePtr->tkwin;
/*
@@ -473,7 +475,7 @@ static void
SquareDisplay(
ClientData clientData) /* Information about window. */
{
- Square *squarePtr = clientData;
+ Square *squarePtr = (Square *)clientData;
Tk_Window tkwin = squarePtr->tkwin;
Pixmap pm = None;
Drawable d;
@@ -556,7 +558,7 @@ static void
SquareDestroy(
void *memPtr) /* Info about square widget. */
{
- Square *squarePtr = memPtr;
+ Square *squarePtr = (Square *)memPtr;
ckfree(squarePtr);
}
@@ -581,7 +583,7 @@ SquareDestroy(
static void
KeepInWindow(
- register Square *squarePtr) /* Pointer to widget record. */
+ Square *squarePtr) /* Pointer to widget record. */
{
int i, bd, relief;
int borderWidth, size;
diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c
index e637f8e..f459fbd 100644
--- a/generic/tkStubInit.c
+++ b/generic/tkStubInit.c
@@ -31,7 +31,6 @@
#include "tkPlatDecls.h"
#include "tkIntXlibDecls.h"
-static const TkIntStubs tkIntStubs;
MODULE_SCOPE const TkStubs tkStubs;
/*
@@ -39,14 +38,56 @@ MODULE_SCOPE const TkStubs tkStubs;
*/
#undef Tk_MainEx
-#undef XVisualIDFromVisual
-#undef XSynchronize
-#undef XUngrabServer
-#undef XNoOp
-#undef XGrabServer
-#undef XFree
-#undef XFlush
-#define TkUnusedStubEntry 0
+#undef Tk_FreeXId
+#undef Tk_FreeStyleFromObj
+#undef Tk_GetStyleFromObj
+#undef TkWinGetPlatformId
+#undef TkPutImage
+#undef XPutImage
+#define TkMacOSXSetUpClippingRgn (void (*)(Drawable))(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
+
+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
@@ -58,39 +99,36 @@ MODULE_SCOPE const TkStubs tkStubs;
#define TkpTestsendCmd_ TkpTestsendCmd
#define TkGenWMConfigureEvent_ TkGenWMConfigureEvent
#define TkGenerateActivateEvents_ TkGenerateActivateEvents
+#define TkMacOSXDrawable Tk_MacOSXGetNSWindowForDrawable
+#define Tk_CanvasTagsParseProc \
+ (int (*) (void *, Tcl_Interp *,Tk_Window, const char *, char *, \
+ int offset))(void *)TkCanvasTagsParseProc
+#define Tk_CanvasTagsPrintProc \
+ (const char *(*) (void *,Tk_Window, char *, int, \
+ Tcl_FreeProc **))(void *)TkCanvasTagsPrintProc
#if !defined(MAC_OSX_TK) && defined(MAC_OSX_TCL)
# 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 */
}
@@ -103,11 +141,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 */
@@ -126,22 +161,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
@@ -167,55 +201,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);
-}
-
-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);
-}
+ (void)colors;
+ (void)ncolors;
-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
@@ -244,33 +239,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
@@ -403,13 +402,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 */
@@ -462,7 +461,7 @@ static const TkIntStubs tkIntStubs = {
TkFocusFree, /* 142 */
TkClipCleanup, /* 143 */
TkGCCleanup, /* 144 */
- TkSubtractRegion, /* 145 */
+ XSubtractRegion, /* 145 */
TkStylePkgInit, /* 146 */
TkStylePkgFree, /* 147 */
TkToplevelWindowForCommand, /* 148 */
@@ -520,6 +519,7 @@ static const TkIntStubs tkIntStubs = {
#ifdef MAC_OSX_TCL /* MACOSX */
TkpWillDrawWidget, /* 186 */
#endif /* MACOSX */
+ TkDebugPhotoStringMatchDef, /* 187 */
};
static const TkIntPlatStubs tkIntPlatStubs = {
@@ -587,7 +587,7 @@ static const TkIntPlatStubs tkIntPlatStubs = {
TkMacOSXButtonKeyState, /* 8 */
TkMacOSXClearMenubarActive, /* 9 */
TkMacOSXDispatchMenuEvent, /* 10 */
- TkMacOSXInstallCursor, /* 11 */
+ 0, /* 11 */
TkMacOSXHandleTearoffMenu, /* 12 */
0, /* 13 */
TkMacOSXDoHLEvent, /* 14 */
@@ -623,9 +623,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 */
@@ -825,29 +825,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 */
@@ -940,20 +940,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 */
@@ -961,7 +961,7 @@ static const TkIntXlibStubs tkIntXlibStubs = {
XFree, /* 110 */
XNoOp, /* 111 */
XSynchronize, /* 112 */
- 0, /* 113 */
+ XLookupColor, /* 113 */
XVisualIDFromVisual, /* 114 */
0, /* 115 */
0, /* 116 */
@@ -969,8 +969,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 */
@@ -978,36 +978,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 = {
@@ -1022,14 +1022,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 */
@@ -1038,7 +1038,7 @@ static const TkPlatStubs tkPlatStubs = {
Tk_MacOSXGetNSWindowForDrawable, /* 13 */
0, /* 14 */
0, /* 15 */
- TkGenWMConfigureEvent_, /* 16 */
+ TkGenWMConfigureEvent, /* 16 */
#endif /* AQUA */
};
@@ -1150,7 +1150,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 */
@@ -1326,13 +1326,25 @@ const TkStubs tkStubs = {
Tk_Interp, /* 271 */
Tk_CreateOldImageType, /* 272 */
Tk_CreateOldPhotoImageFormat, /* 273 */
- 0, /* 274 */
- 0, /* 275 */
- 0, /* 276 */
- 0, /* 277 */
- 0, /* 278 */
- 0, /* 279 */
- TkUnusedStubEntry, /* 280 */
+ Tk_AlwaysShowSelection, /* 274 */
+ Tk_GetButtonMask, /* 275 */
+ Tk_GetDoublePixelsFromObj, /* 276 */
+ Tk_NewWindowObj, /* 277 */
+ Tk_SendVirtualEvent, /* 278 */
+ Tk_FontGetDescription, /* 279 */
};
/* !END!: Do not edit above this line. */
+
+
+#ifdef __CYGWIN__
+void *Tk_GetHINSTANCE(void)
+{
+ void *hInstance = NULL;
+
+ GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
+ (const char *) &tkIntStubs, &hInstance);
+ return hInstance;
+}
+#endif
+
diff --git a/generic/tkStubLib.c b/generic/tkStubLib.c
index ea48894..aed0b80 100644
--- a/generic/tkStubLib.c
+++ b/generic/tkStubLib.c
@@ -77,10 +77,10 @@ Tk_InitStubs(
{
const char *packageName = "Tk";
const char *errMsg = NULL;
- ClientData clientData = NULL;
+ void *clientData = NULL;
const char *actualVersion = tclStubsPtr->tcl_PkgRequireEx(interp,
packageName, version, 0, &clientData);
- const TkStubs *stubsPtr = clientData;
+ const TkStubs *stubsPtr = (const TkStubs *)clientData;
if (actualVersion == NULL) {
return NULL;
diff --git a/generic/tkStyle.c b/generic/tkStyle.c
index 1289f14..e845ad8 100644
--- a/generic/tkStyle.c
+++ b/generic/tkStyle.c
@@ -155,7 +155,7 @@ static const Tcl_ObjType styleObjType = {
FreeStyleObjProc, /* freeIntRepProc */
DupStyleObjProc, /* dupIntRepProc */
NULL, /* updateStringProc */
- SetStyleFromAny /* setFromAnyProc */
+ NULL /* setFromAnyProc */
};
/*
@@ -1076,7 +1076,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 +1090,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 +1117,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 +1133,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 +1159,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 +1190,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 +1201,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);
}
@@ -1402,59 +1402,12 @@ Tk_AllocStyleFromObj(
Tcl_Obj *objPtr) /* Object containing name of the style to
* retrieve. */
{
- Style *stylePtr;
-
- if (objPtr->typePtr != &styleObjType) {
- SetStyleFromAny(interp, objPtr);
- }
- stylePtr = objPtr->internalRep.twoPtrValue.ptr1;
-
- return (Tk_Style) stylePtr;
-}
-
-/*
- *----------------------------------------------------------------------
- *
- * Tk_GetStyleFromObj --
- *
- * Find the style that corresponds to a given object. The style must have
- * already been created by Tk_CreateStyle.
- *
- * Results:
- * The return value is a token for the style that matches objPtr, or NULL
- * if none found.
- *
- * Side effects:
- * If the object is not already a style ref, the conversion will free any
- * old internal representation.
- *
- *----------------------------------------------------------------------
- */
-
-Tk_Style
-Tk_GetStyleFromObj(
- Tcl_Obj *objPtr) /* The object from which to get the style. */
-{
if (objPtr->typePtr != &styleObjType) {
- SetStyleFromAny(NULL, objPtr);
+ if (SetStyleFromAny(interp, objPtr) != TCL_OK) {
+ return NULL;
+ }
}
-
- return objPtr->internalRep.twoPtrValue.ptr1;
-}
-
-/*
- *---------------------------------------------------------------------------
- *
- * Tk_FreeStyleFromObj --
- *
- * No-op. Present only for stubs compatibility.
- *
- *---------------------------------------------------------------------------
- */
-void
-Tk_FreeStyleFromObj(
- TCL_UNUSED(Tcl_Obj *))
-{
+ return (Tk_Style)objPtr->internalRep.twoPtrValue.ptr1;
}
/*
@@ -1466,8 +1419,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.
@@ -1482,6 +1435,7 @@ SetStyleFromAny(
{
const Tcl_ObjType *typePtr;
const char *name;
+ Tk_Style style;
/*
* Free the old internalRep before setting the new one.
@@ -1493,8 +1447,12 @@ SetStyleFromAny(
typePtr->freeIntRepProc(objPtr);
}
+ style = Tk_GetStyle(interp, name);
+ if (style == NULL) {
+ return TCL_ERROR;
+ }
objPtr->typePtr = &styleObjType;
- objPtr->internalRep.twoPtrValue.ptr1 = Tk_GetStyle(interp, name);
+ objPtr->internalRep.twoPtrValue.ptr1 = style;
return TCL_OK;
}
diff --git a/generic/tkTest.c b/generic/tkTest.c
index 1fa821c..125a9c2 100644
--- a/generic/tkTest.c
+++ b/generic/tkTest.c
@@ -48,7 +48,14 @@
#undef TCL_STORAGE_CLASS
#define TCL_STORAGE_CLASS DLLEXPORT
+#ifdef __cplusplus
+extern "C" {
+#endif
EXTERN int Tktest_Init(Tcl_Interp *interp);
+#ifdef __cplusplus
+}
+#endif
+
/*
* The following data structure represents the model for a test image:
*/
@@ -181,22 +188,16 @@ static int TestmetricsObjCmd(ClientData dummy,
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 Tk_CustomOptionSetProc CustomOptionSet;
+static Tk_CustomOptionGetProc CustomOptionGet;
+static Tk_CustomOptionRestoreProc CustomOptionRestore;
+static Tk_CustomOptionFreeProc CustomOptionFree;
static int TestpropObjCmd(ClientData dummy,
Tcl_Interp *interp, int objc,
Tcl_Obj * const objv[]);
+static int TestprintfObjCmd(ClientData dummy,
+ Tcl_Interp *interp, int objc,
+ Tcl_Obj * const objv[]);
#if !(defined(_WIN32) || defined(MAC_OSX_TK) || defined(__CYGWIN__))
static int TestwrapperObjCmd(ClientData dummy,
Tcl_Interp *interp, int objc,
@@ -208,6 +209,9 @@ static int TrivialConfigObjCmd(ClientData dummy,
Tcl_Obj * const objv[]);
static void TrivialEventProc(ClientData clientData,
XEvent *eventPtr);
+static int TestPhotoStringMatchCmd(ClientData dummy,
+ Tcl_Interp *interp, int objc,
+ Tcl_Obj * const objv[]);
/*
*----------------------------------------------------------------------
@@ -232,7 +236,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) {
@@ -268,8 +272,12 @@ Tktest_Init(
(ClientData) Tk_MainWindow(interp), NULL);
Tcl_CreateObjCommand(interp, "testprop", TestpropObjCmd,
(ClientData) Tk_MainWindow(interp), NULL);
+ Tcl_CreateObjCommand(interp, "testprintf", TestprintfObjCmd, NULL, NULL);
Tcl_CreateObjCommand(interp, "testtext", TkpTesttextCmd,
(ClientData) Tk_MainWindow(interp), NULL);
+ Tcl_CreateObjCommand(interp, "testphotostringmatch",
+ TestPhotoStringMatchCmd, (ClientData) Tk_MainWindow(interp),
+ NULL);
#if defined(_WIN32)
Tcl_CreateObjCommand(interp, "testmetrics", TestmetricsObjCmd,
@@ -331,7 +339,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;
@@ -365,7 +372,6 @@ TestborderObjCmd(
int objc, /* Number of arguments. */
Tcl_Obj *const objv[]) /* Argument objects. */
{
-
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "border");
return TCL_ERROR;
@@ -523,7 +529,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;
@@ -542,9 +548,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}
};
@@ -586,57 +592,57 @@ TestobjconfigObjCmd(
};
static const Tk_OptionSpec typesSpecs[] = {
{TK_OPTION_BOOLEAN, "-boolean", "boolean", "Boolean", "1",
- Tk_Offset(TypesRecord, booleanPtr), -1, 0, 0, 0x1},
+ offsetof(TypesRecord, booleanPtr), TCL_INDEX_NONE, 0, 0, 0x1},
{TK_OPTION_INT, "-integer", "integer", "Integer", "7",
- Tk_Offset(TypesRecord, integerPtr), -1, 0, 0, 0x2},
+ offsetof(TypesRecord, integerPtr), TCL_INDEX_NONE, 0, 0, 0x2},
{TK_OPTION_DOUBLE, "-double", "double", "Double", "3.14159",
- Tk_Offset(TypesRecord, doublePtr), -1, 0, 0, 0x4},
+ offsetof(TypesRecord, doublePtr), TCL_INDEX_NONE, 0, 0, 0x4},
{TK_OPTION_STRING, "-string", "string", "String",
- "foo", Tk_Offset(TypesRecord, stringPtr), -1,
+ "foo", offsetof(TypesRecord, stringPtr), TCL_INDEX_NONE,
TK_CONFIG_NULL_OK, 0, 0x8},
{TK_OPTION_STRING_TABLE,
"-stringtable", "StringTable", "stringTable",
- "one", Tk_Offset(TypesRecord, stringTablePtr), -1,
+ "one", offsetof(TypesRecord, stringTablePtr), TCL_INDEX_NONE,
TK_CONFIG_NULL_OK, stringTable, 0x10},
{TK_OPTION_COLOR, "-color", "color", "Color",
- "red", Tk_Offset(TypesRecord, colorPtr), -1,
+ "red", offsetof(TypesRecord, colorPtr), TCL_INDEX_NONE,
TK_CONFIG_NULL_OK, "black", 0x20},
{TK_OPTION_FONT, "-font", "font", "Font", "Helvetica 12",
- Tk_Offset(TypesRecord, fontPtr), -1,
+ offsetof(TypesRecord, fontPtr), TCL_INDEX_NONE,
TK_CONFIG_NULL_OK, 0, 0x40},
{TK_OPTION_BITMAP, "-bitmap", "bitmap", "Bitmap", "gray50",
- Tk_Offset(TypesRecord, bitmapPtr), -1,
+ offsetof(TypesRecord, bitmapPtr), TCL_INDEX_NONE,
TK_CONFIG_NULL_OK, 0, 0x80},
{TK_OPTION_BORDER, "-border", "border", "Border",
- "blue", Tk_Offset(TypesRecord, borderPtr), -1,
+ "blue", offsetof(TypesRecord, borderPtr), TCL_INDEX_NONE,
TK_CONFIG_NULL_OK, "white", 0x100},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief", "raised",
- Tk_Offset(TypesRecord, reliefPtr), -1,
+ offsetof(TypesRecord, reliefPtr), TCL_INDEX_NONE,
TK_CONFIG_NULL_OK, 0, 0x200},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", "xterm",
- Tk_Offset(TypesRecord, cursorPtr), -1,
+ offsetof(TypesRecord, cursorPtr), TCL_INDEX_NONE,
TK_CONFIG_NULL_OK, 0, 0x400},
{TK_OPTION_JUSTIFY, "-justify", NULL, NULL, "left",
- Tk_Offset(TypesRecord, justifyPtr), -1,
+ offsetof(TypesRecord, justifyPtr), TCL_INDEX_NONE,
TK_CONFIG_NULL_OK, 0, 0x800},
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", NULL,
- Tk_Offset(TypesRecord, anchorPtr), -1,
+ offsetof(TypesRecord, anchorPtr), TCL_INDEX_NONE,
TK_CONFIG_NULL_OK, 0, 0x1000},
{TK_OPTION_PIXELS, "-pixel", "pixel", "Pixel",
- "1", Tk_Offset(TypesRecord, pixelPtr), -1,
+ "1", offsetof(TypesRecord, pixelPtr), TCL_INDEX_NONE,
TK_CONFIG_NULL_OK, 0, 0x2000},
{TK_OPTION_CUSTOM, "-custom", NULL, NULL,
- "", Tk_Offset(TypesRecord, customPtr), -1,
+ "", offsetof(TypesRecord, customPtr), TCL_INDEX_NONE,
TK_CONFIG_NULL_OK, &CustomOption, 0x4000},
{TK_OPTION_SYNONYM, "-synonym", NULL, NULL,
- NULL, 0, -1, 0, "-color", 0x8000},
+ NULL, 0, TCL_INDEX_NONE, 0, "-color", 0x8000},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0}
};
Tk_OptionTable optionTable;
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;
@@ -663,7 +669,7 @@ TestobjconfigObjCmd(
recordPtr->mmPtr = NULL;
recordPtr->stringTablePtr = 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,
@@ -671,7 +677,7 @@ TestobjconfigObjCmd(
(ClientData) recordPtr, TrivialCmdDeletedProc);
Tk_CreateEventHandler(tkwin, StructureNotifyMask,
TrivialEventProc, (ClientData) 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);
@@ -690,7 +696,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;
@@ -705,12 +711,12 @@ 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) {
@@ -729,20 +735,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,
+ offsetof(ExtensionWidgetRecord, extension5ObjPtr), TCL_INDEX_NONE, 0, NULL, 0},
+ {TK_OPTION_END, NULL, NULL, NULL, NULL, 0, TCL_INDEX_NONE, 0,
(ClientData) baseSpecs, 0}
};
Tk_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;
@@ -758,9 +764,9 @@ 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);
@@ -784,7 +790,7 @@ TestobjconfigObjCmd(
ErrorWidgetRecord widgetRecord;
static const Tk_OptionSpec errorSpecs[] = {
{TK_OPTION_INT, "-int", "integer", "Integer", "bogus",
- Tk_Offset(ErrorWidgetRecord, intPtr), 0, 0, NULL, 0},
+ offsetof(ErrorWidgetRecord, intPtr), 0, 0, NULL, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0}
};
Tk_OptionTable optionTable;
@@ -792,7 +798,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);
}
@@ -858,67 +864,67 @@ TestobjconfigObjCmd(
};
static const Tk_OptionSpec internalSpecs[] = {
{TK_OPTION_BOOLEAN, "-boolean", "boolean", "Boolean", "1",
- -1, Tk_Offset(InternalRecord, boolean), 0, 0, 0x1},
+ TCL_INDEX_NONE, offsetof(InternalRecord, boolean), 0, 0, 0x1},
{TK_OPTION_INT, "-integer", "integer", "Integer", "148962237",
- -1, Tk_Offset(InternalRecord, integer), 0, 0, 0x2},
+ TCL_INDEX_NONE, offsetof(InternalRecord, integer), 0, 0, 0x2},
{TK_OPTION_DOUBLE, "-double", "double", "Double", "3.14159",
- -1, Tk_Offset(InternalRecord, doubleValue), 0, 0, 0x4},
+ TCL_INDEX_NONE, offsetof(InternalRecord, doubleValue), 0, 0, 0x4},
{TK_OPTION_STRING, "-string", "string", "String", "foo",
- -1, Tk_Offset(InternalRecord, string),
+ TCL_INDEX_NONE, offsetof(InternalRecord, string),
TK_CONFIG_NULL_OK, 0, 0x8},
{TK_OPTION_STRING_TABLE,
"-stringtable", "StringTable", "stringTable", "one",
- -1, Tk_Offset(InternalRecord, index),
+ TCL_INDEX_NONE, offsetof(InternalRecord, index),
TK_CONFIG_NULL_OK, internalStringTable, 0x10},
{TK_OPTION_COLOR, "-color", "color", "Color", "red",
- -1, Tk_Offset(InternalRecord, colorPtr),
+ TCL_INDEX_NONE, offsetof(InternalRecord, colorPtr),
TK_CONFIG_NULL_OK, "black", 0x20},
{TK_OPTION_FONT, "-font", "font", "Font", "Helvetica 12",
- -1, Tk_Offset(InternalRecord, tkfont),
+ TCL_INDEX_NONE, offsetof(InternalRecord, tkfont),
TK_CONFIG_NULL_OK, 0, 0x40},
{TK_OPTION_BITMAP, "-bitmap", "bitmap", "Bitmap", "gray50",
- -1, Tk_Offset(InternalRecord, bitmap),
+ TCL_INDEX_NONE, offsetof(InternalRecord, bitmap),
TK_CONFIG_NULL_OK, 0, 0x80},
{TK_OPTION_BORDER, "-border", "border", "Border", "blue",
- -1, Tk_Offset(InternalRecord, border),
+ TCL_INDEX_NONE, offsetof(InternalRecord, border),
TK_CONFIG_NULL_OK, "white", 0x100},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief", "raised",
- -1, Tk_Offset(InternalRecord, relief),
+ TCL_INDEX_NONE, offsetof(InternalRecord, relief),
TK_CONFIG_NULL_OK, 0, 0x200},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", "xterm",
- -1, Tk_Offset(InternalRecord, cursor),
+ TCL_INDEX_NONE, offsetof(InternalRecord, cursor),
TK_CONFIG_NULL_OK, 0, 0x400},
{TK_OPTION_JUSTIFY, "-justify", NULL, NULL, "left",
- -1, Tk_Offset(InternalRecord, justify),
+ TCL_INDEX_NONE, offsetof(InternalRecord, justify),
TK_CONFIG_NULL_OK, 0, 0x800},
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor", NULL,
- -1, Tk_Offset(InternalRecord, anchor),
+ TCL_INDEX_NONE, offsetof(InternalRecord, anchor),
TK_CONFIG_NULL_OK, 0, 0x1000},
{TK_OPTION_PIXELS, "-pixel", "pixel", "Pixel", "1",
- -1, Tk_Offset(InternalRecord, pixels),
+ TCL_INDEX_NONE, offsetof(InternalRecord, pixels),
TK_CONFIG_NULL_OK, 0, 0x2000},
{TK_OPTION_WINDOW, "-window", "window", "Window", NULL,
- -1, Tk_Offset(InternalRecord, tkwin),
+ TCL_INDEX_NONE, offsetof(InternalRecord, tkwin),
TK_CONFIG_NULL_OK, 0, 0},
{TK_OPTION_CUSTOM, "-custom", NULL, NULL, "",
- -1, Tk_Offset(InternalRecord, custom),
+ TCL_INDEX_NONE, offsetof(InternalRecord, custom),
TK_CONFIG_NULL_OK, &CustomOption, 0x4000},
{TK_OPTION_SYNONYM, "-synonym", NULL, NULL,
- NULL, -1, -1, 0, "-color", 0x8000},
+ NULL, TCL_INDEX_NONE, TCL_INDEX_NONE, 0, "-color", 0x8000},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0}
};
Tk_OptionTable optionTable;
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;
@@ -939,7 +945,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,
@@ -947,7 +953,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);
@@ -974,15 +980,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}
};
@@ -991,7 +997,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);
@@ -1000,10 +1006,10 @@ 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) {
@@ -1011,7 +1017,7 @@ TestobjconfigObjCmd(
Tcl_GetString(objv[2]), TrivialConfigObjCmd,
(ClientData) recordPtr, TrivialCmdDeletedProc);
} else {
- Tk_FreeConfigOptions((char *) recordPtr,
+ Tk_FreeConfigOptions(recordPtr,
recordPtr->header.optionTable, (Tk_Window) NULL);
}
}
@@ -1028,7 +1034,7 @@ TestobjconfigObjCmd(
NotEnoughRecord record;
static const Tk_OptionSpec errorSpecs[] = {
{TK_OPTION_INT, "-foo", "foo", "Foo", "0",
- Tk_Offset(NotEnoughRecord, fooObjPtr), 0, 0, NULL, 0},
+ offsetof(NotEnoughRecord, fooObjPtr), 0, 0, NULL, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, NULL, 0}
};
Tcl_Obj *newObjPtr = Tcl_NewStringObj("-foo", -1);
@@ -1040,8 +1046,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;
}
@@ -1059,11 +1065,11 @@ TestobjconfigObjCmd(
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;
@@ -1078,10 +1084,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) {
@@ -1092,7 +1098,7 @@ TestobjconfigObjCmd(
TrivialEventProc, recordPtr);
Tcl_SetObjResult(interp, objv[2]);
} else {
- Tk_FreeConfigOptions((char *) recordPtr,
+ Tk_FreeConfigOptions(recordPtr,
recordPtr->header.optionTable, tkwin);
}
}
@@ -1139,12 +1145,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;
}
@@ -1162,7 +1168,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);
@@ -1173,7 +1179,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;
@@ -1181,7 +1187,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;
@@ -1189,21 +1195,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;
}
@@ -1246,7 +1252,7 @@ TrivialCmdDeletedProc(
* here.
*/
- Tk_FreeConfigOptions((char *)clientData,
+ Tk_FreeConfigOptions(clientData,
headerPtr->optionTable, NULL);
Tcl_EventuallyFree(clientData, TCL_DYNAMIC);
}
@@ -1277,7 +1283,7 @@ TrivialEventProc(
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;
@@ -1381,6 +1387,7 @@ ImageCreate(
TImageModel *timPtr;
const char *varName;
int i;
+ (void)typePtr;
varName = "log";
for (i = 0; i < objc; i += 2) {
@@ -1901,6 +1908,60 @@ 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(
+ ClientData dummy, /* Not used */
+ Tcl_Interp *interp, /* Current interpreter. */
+ int objc, /* Number of arguments. */
+ Tcl_Obj *const objv[]) /* Argument strings. */
+{
+ char buffer[256];
+ Tcl_WideInt wideInt;
+#ifdef _WIN32
+ __int64 longLongInt;
+#else
+ long long longLongInt;
+#endif
+ (void)dummy;
+
+ 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 sprintf. 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.
+ */
+ sprintf(buffer, "%s%s%s%s%s%s%s%s%" TCL_LL_MODIFIER "d %"
+ TCL_LL_MODIFIER "u", "", "", "", "", "", "", "", "",
+ (Tcl_WideInt)longLongInt, (Tcl_WideUInt)longLongInt);
+ Tcl_AppendResult(interp, buffer, NULL);
+ return TCL_OK;
+}
+
#if !(defined(_WIN32) || defined(MAC_OSX_TK) || defined(__CYGWIN__))
/*
*----------------------------------------------------------------------
@@ -1984,7 +2045,7 @@ CustomOptionSet(
TCL_UNUSED(Tk_Window),
Tcl_Obj **value,
char *recordPtr,
- int internalOffset,
+ TkSizeT internalOffset,
char *saveInternalPtr,
int flags)
{
@@ -1993,7 +2054,7 @@ CustomOptionSet(
objEmpty = 0;
- if (internalOffset >= 0) {
+ if (internalOffset != TCL_INDEX_NONE) {
internalPtr = recordPtr + internalOffset;
} else {
internalPtr = NULL;
@@ -2043,32 +2104,86 @@ CustomOptionGet(
TCL_UNUSED(void *),
TCL_UNUSED(Tk_Window),
char *recordPtr,
- int internalOffset)
+ TkSizeT internalOffset)
{
return (Tcl_NewStringObj(*(char **)(recordPtr + internalOffset), -1));
}
static void
CustomOptionRestore(
- ClientData clientData,
+ ClientData dummy,
Tk_Window tkwin,
char *internalPtr,
char *saveInternalPtr)
{
+ (void)dummy;
+ (void)tkwin;
+
*(char **)internalPtr = *(char **)saveInternalPtr;
return;
}
static void
CustomOptionFree(
- ClientData clientData,
+ ClientData dummy,
Tk_Window tkwin,
char *internalPtr)
{
+ (void)dummy;
+ (void)tkwin;
+
if (*(char **)internalPtr != NULL) {
ckfree(*(char **)internalPtr);
}
}
+/*
+ *----------------------------------------------------------------------
+ *
+ * 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(
+ ClientData clientData, /* 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;
+ (void)clientData;
+
+ if (objc != 2) {
+ Tcl_WrongNumArgs(interp, 1, objv, "imageData");
+ return TCL_ERROR;
+ }
+ if (TkDebugPhotoStringMatchDef(interp, objv[1], dummy, &width, &height)) {
+ resultObj[0] = Tcl_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 c41fc67..ce4f976 100644
--- a/generic/tkText.c
+++ b/generic/tkText.c
@@ -96,11 +96,11 @@ static const char *const insertUnfocussedStrings[] = {
static int SetLineStartEnd(ClientData clientData,
Tcl_Interp *interp, Tk_Window tkwin,
Tcl_Obj **value, char *recordPtr,
- int internalOffset, char *oldInternalPtr,
+ TkSizeT internalOffset, char *oldInternalPtr,
int flags);
static Tcl_Obj * GetLineStartEnd(ClientData clientData,
Tk_Window tkwin, char *recordPtr,
- int internalOffset);
+ TkSizeT internalOffset);
static void RestoreLineStartEnd(ClientData clientData,
Tk_Window tkwin, char *internalPtr,
char *oldInternalPtr);
@@ -121,139 +121,139 @@ static const Tk_ObjCustomOption lineOption = {
static const Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_BOOLEAN, "-autoseparators", "autoSeparators",
- "AutoSeparators", DEF_TEXT_AUTO_SEPARATORS, -1,
- Tk_Offset(TkText, autoSeparators),
+ "AutoSeparators", DEF_TEXT_AUTO_SEPARATORS, TCL_INDEX_NONE,
+ offsetof(TkText, autoSeparators),
TK_OPTION_DONT_SET_DEFAULT, 0, 0},
{TK_OPTION_BORDER, "-background", "background", "Background",
- DEF_TEXT_BG_COLOR, -1, Tk_Offset(TkText, border),
+ DEF_TEXT_BG_COLOR, TCL_INDEX_NONE, offsetof(TkText, border),
0, DEF_TEXT_BG_MONO, 0},
{TK_OPTION_SYNONYM, "-bd", NULL, NULL,
- NULL, 0, -1, 0, "-borderwidth",
+ NULL, 0, TCL_INDEX_NONE, 0, "-borderwidth",
TK_TEXT_LINE_GEOMETRY},
{TK_OPTION_SYNONYM, "-bg", NULL, NULL,
- NULL, 0, -1, 0, "-background", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-background", 0},
{TK_OPTION_BOOLEAN, "-blockcursor", "blockCursor",
- "BlockCursor", DEF_TEXT_BLOCK_CURSOR, -1,
- Tk_Offset(TkText, insertCursorType), 0, 0, 0},
+ "BlockCursor", DEF_TEXT_BLOCK_CURSOR, TCL_INDEX_NONE,
+ offsetof(TkText, insertCursorType), 0, 0, 0},
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEF_TEXT_BORDER_WIDTH, -1, Tk_Offset(TkText, borderWidth),
+ DEF_TEXT_BORDER_WIDTH, TCL_INDEX_NONE, offsetof(TkText, borderWidth),
0, 0, TK_TEXT_LINE_GEOMETRY},
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor",
- DEF_TEXT_CURSOR, -1, Tk_Offset(TkText, cursor),
+ DEF_TEXT_CURSOR, TCL_INDEX_NONE, offsetof(TkText, cursor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_CUSTOM, "-endline", NULL, NULL,
- NULL, -1, Tk_Offset(TkText, end), TK_OPTION_NULL_OK,
+ NULL, TCL_INDEX_NONE, offsetof(TkText, end), TK_OPTION_NULL_OK,
&lineOption, TK_TEXT_LINE_RANGE},
{TK_OPTION_BOOLEAN, "-exportselection", "exportSelection",
- "ExportSelection", DEF_TEXT_EXPORT_SELECTION, -1,
- Tk_Offset(TkText, exportSelection), 0, 0, 0},
+ "ExportSelection", DEF_TEXT_EXPORT_SELECTION, TCL_INDEX_NONE,
+ offsetof(TkText, exportSelection), 0, 0, 0},
{TK_OPTION_SYNONYM, "-fg", "foreground", NULL,
- NULL, 0, -1, 0, "-foreground", 0},
+ NULL, 0, TCL_INDEX_NONE, 0, "-foreground", 0},
{TK_OPTION_FONT, "-font", "font", "Font",
- DEF_TEXT_FONT, -1, Tk_Offset(TkText, tkfont), 0, 0,
+ DEF_TEXT_FONT, TCL_INDEX_NONE, offsetof(TkText, tkfont), 0, 0,
TK_TEXT_LINE_GEOMETRY},
{TK_OPTION_COLOR, "-foreground", "foreground", "Foreground",
- DEF_TEXT_FG, -1, Tk_Offset(TkText, fgColor), 0,
+ DEF_TEXT_FG, TCL_INDEX_NONE, offsetof(TkText, fgColor), 0,
0, 0},
{TK_OPTION_PIXELS, "-height", "height", "Height",
- DEF_TEXT_HEIGHT, -1, Tk_Offset(TkText, height), 0, 0, 0},
+ DEF_TEXT_HEIGHT, TCL_INDEX_NONE, offsetof(TkText, height), 0, 0, 0},
{TK_OPTION_COLOR, "-highlightbackground", "highlightBackground",
"HighlightBackground", DEF_TEXT_HIGHLIGHT_BG,
- -1, Tk_Offset(TkText, highlightBgColorPtr),
+ TCL_INDEX_NONE, offsetof(TkText, highlightBgColorPtr),
0, 0, 0},
{TK_OPTION_COLOR, "-highlightcolor", "highlightColor", "HighlightColor",
- DEF_TEXT_HIGHLIGHT, -1, Tk_Offset(TkText, highlightColorPtr),
+ DEF_TEXT_HIGHLIGHT, TCL_INDEX_NONE, offsetof(TkText, highlightColorPtr),
0, 0, 0},
{TK_OPTION_PIXELS, "-highlightthickness", "highlightThickness",
- "HighlightThickness", DEF_TEXT_HIGHLIGHT_WIDTH, -1,
- Tk_Offset(TkText, highlightWidth), 0, 0, TK_TEXT_LINE_GEOMETRY},
+ "HighlightThickness", DEF_TEXT_HIGHLIGHT_WIDTH, TCL_INDEX_NONE,
+ offsetof(TkText, highlightWidth), 0, 0, TK_TEXT_LINE_GEOMETRY},
{TK_OPTION_BORDER, "-inactiveselectbackground","inactiveSelectBackground",
"Foreground",
DEF_TEXT_INACTIVE_SELECT_COLOR,
- -1, Tk_Offset(TkText, inactiveSelBorder),
+ TCL_INDEX_NONE, offsetof(TkText, inactiveSelBorder),
TK_OPTION_NULL_OK, DEF_TEXT_SELECT_MONO, 0},
{TK_OPTION_BORDER, "-insertbackground", "insertBackground", "Foreground",
DEF_TEXT_INSERT_BG,
- -1, Tk_Offset(TkText, insertBorder),
+ TCL_INDEX_NONE, offsetof(TkText, insertBorder),
0, 0, 0},
{TK_OPTION_PIXELS, "-insertborderwidth", "insertBorderWidth",
- "BorderWidth", DEF_TEXT_INSERT_BD_COLOR, -1,
- Tk_Offset(TkText, insertBorderWidth), 0,
+ "BorderWidth", DEF_TEXT_INSERT_BD_COLOR, TCL_INDEX_NONE,
+ offsetof(TkText, insertBorderWidth), 0,
(ClientData) DEF_TEXT_INSERT_BD_MONO, 0},
{TK_OPTION_INT, "-insertofftime", "insertOffTime", "OffTime",
- DEF_TEXT_INSERT_OFF_TIME, -1, Tk_Offset(TkText, insertOffTime),
+ DEF_TEXT_INSERT_OFF_TIME, TCL_INDEX_NONE, offsetof(TkText, insertOffTime),
0, 0, 0},
{TK_OPTION_INT, "-insertontime", "insertOnTime", "OnTime",
- DEF_TEXT_INSERT_ON_TIME, -1, Tk_Offset(TkText, insertOnTime),
+ DEF_TEXT_INSERT_ON_TIME, TCL_INDEX_NONE, offsetof(TkText, insertOnTime),
0, 0, 0},
{TK_OPTION_STRING_TABLE,
"-insertunfocussed", "insertUnfocussed", "InsertUnfocussed",
- DEF_TEXT_INSERT_UNFOCUSSED, -1, Tk_Offset(TkText, insertUnfocussed),
+ DEF_TEXT_INSERT_UNFOCUSSED, TCL_INDEX_NONE, offsetof(TkText, insertUnfocussed),
0, insertUnfocussedStrings, 0},
{TK_OPTION_PIXELS, "-insertwidth", "insertWidth", "InsertWidth",
- DEF_TEXT_INSERT_WIDTH, -1, Tk_Offset(TkText, insertWidth),
+ DEF_TEXT_INSERT_WIDTH, TCL_INDEX_NONE, offsetof(TkText, insertWidth),
0, 0, 0},
{TK_OPTION_INT, "-maxundo", "maxUndo", "MaxUndo",
- DEF_TEXT_MAX_UNDO, -1, Tk_Offset(TkText, maxUndo),
+ DEF_TEXT_MAX_UNDO, TCL_INDEX_NONE, offsetof(TkText, maxUndo),
TK_OPTION_DONT_SET_DEFAULT, 0, 0},
{TK_OPTION_PIXELS, "-padx", "padX", "Pad",
- DEF_TEXT_PADX, -1, Tk_Offset(TkText, padX), 0, 0,
+ DEF_TEXT_PADX, TCL_INDEX_NONE, offsetof(TkText, padX), 0, 0,
TK_TEXT_LINE_GEOMETRY},
{TK_OPTION_PIXELS, "-pady", "padY", "Pad",
- DEF_TEXT_PADY, -1, Tk_Offset(TkText, padY), 0, 0, 0},
+ DEF_TEXT_PADY, TCL_INDEX_NONE, offsetof(TkText, padY), 0, 0, 0},
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- DEF_TEXT_RELIEF, -1, Tk_Offset(TkText, relief), 0, 0, 0},
+ DEF_TEXT_RELIEF, TCL_INDEX_NONE, offsetof(TkText, relief), 0, 0, 0},
{TK_OPTION_BORDER, "-selectbackground", "selectBackground", "Foreground",
- DEF_TEXT_SELECT_COLOR, -1, Tk_Offset(TkText, selBorder),
+ DEF_TEXT_SELECT_COLOR, TCL_INDEX_NONE, offsetof(TkText, selBorder),
0, DEF_TEXT_SELECT_MONO, 0},
{TK_OPTION_PIXELS, "-selectborderwidth", "selectBorderWidth",
"BorderWidth", DEF_TEXT_SELECT_BD_COLOR,
- Tk_Offset(TkText, selBorderWidthPtr),
- Tk_Offset(TkText, selBorderWidth),
+ offsetof(TkText, selBorderWidthPtr),
+ offsetof(TkText, selBorderWidth),
TK_OPTION_NULL_OK, DEF_TEXT_SELECT_BD_MONO, 0},
{TK_OPTION_COLOR, "-selectforeground", "selectForeground", "Background",
- DEF_TEXT_SELECT_FG_COLOR, -1, Tk_Offset(TkText, selFgColorPtr),
+ DEF_TEXT_SELECT_FG_COLOR, TCL_INDEX_NONE, offsetof(TkText, selFgColorPtr),
TK_OPTION_NULL_OK, DEF_TEXT_SELECT_FG_MONO, 0},
{TK_OPTION_BOOLEAN, "-setgrid", "setGrid", "SetGrid",
- DEF_TEXT_SET_GRID, -1, Tk_Offset(TkText, setGrid), 0, 0, 0},
+ DEF_TEXT_SET_GRID, TCL_INDEX_NONE, offsetof(TkText, setGrid), 0, 0, 0},
{TK_OPTION_PIXELS, "-spacing1", "spacing1", "Spacing",
- DEF_TEXT_SPACING1, -1, Tk_Offset(TkText, spacing1),
+ DEF_TEXT_SPACING1, TCL_INDEX_NONE, offsetof(TkText, spacing1),
0, 0 , TK_TEXT_LINE_GEOMETRY },
{TK_OPTION_PIXELS, "-spacing2", "spacing2", "Spacing",
- DEF_TEXT_SPACING2, -1, Tk_Offset(TkText, spacing2),
+ DEF_TEXT_SPACING2, TCL_INDEX_NONE, offsetof(TkText, spacing2),
0, 0 , TK_TEXT_LINE_GEOMETRY },
{TK_OPTION_PIXELS, "-spacing3", "spacing3", "Spacing",
- DEF_TEXT_SPACING3, -1, Tk_Offset(TkText, spacing3),
+ DEF_TEXT_SPACING3, TCL_INDEX_NONE, offsetof(TkText, spacing3),
0, 0 , TK_TEXT_LINE_GEOMETRY },
{TK_OPTION_CUSTOM, "-startline", NULL, NULL,
- NULL, -1, Tk_Offset(TkText, start), TK_OPTION_NULL_OK,
+ NULL, TCL_INDEX_NONE, offsetof(TkText, start), TK_OPTION_NULL_OK,
&lineOption, TK_TEXT_LINE_RANGE},
{TK_OPTION_STRING_TABLE, "-state", "state", "State",
- DEF_TEXT_STATE, -1, Tk_Offset(TkText, state),
+ DEF_TEXT_STATE, TCL_INDEX_NONE, offsetof(TkText, state),
0, stateStrings, 0},
{TK_OPTION_STRING, "-tabs", "tabs", "Tabs",
- DEF_TEXT_TABS, Tk_Offset(TkText, tabOptionPtr), -1,
+ DEF_TEXT_TABS, offsetof(TkText, tabOptionPtr), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, TK_TEXT_LINE_GEOMETRY},
{TK_OPTION_STRING_TABLE, "-tabstyle", "tabStyle", "TabStyle",
- DEF_TEXT_TABSTYLE, -1, Tk_Offset(TkText, tabStyle),
+ DEF_TEXT_TABSTYLE, TCL_INDEX_NONE, offsetof(TkText, tabStyle),
0, tabStyleStrings, TK_TEXT_LINE_GEOMETRY},
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
- DEF_TEXT_TAKE_FOCUS, -1, Tk_Offset(TkText, takeFocus),
+ DEF_TEXT_TAKE_FOCUS, TCL_INDEX_NONE, offsetof(TkText, takeFocus),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_BOOLEAN, "-undo", "undo", "Undo",
- DEF_TEXT_UNDO, -1, Tk_Offset(TkText, undo),
+ DEF_TEXT_UNDO, TCL_INDEX_NONE, offsetof(TkText, undo),
TK_OPTION_DONT_SET_DEFAULT, 0 , 0},
{TK_OPTION_INT, "-width", "width", "Width",
- DEF_TEXT_WIDTH, -1, Tk_Offset(TkText, width), 0, 0,
+ DEF_TEXT_WIDTH, TCL_INDEX_NONE, offsetof(TkText, width), 0, 0,
TK_TEXT_LINE_GEOMETRY},
{TK_OPTION_STRING_TABLE, "-wrap", "wrap", "Wrap",
- DEF_TEXT_WRAP, -1, Tk_Offset(TkText, wrapMode),
+ DEF_TEXT_WRAP, TCL_INDEX_NONE, offsetof(TkText, wrapMode),
0, wrapStrings, TK_TEXT_LINE_GEOMETRY},
{TK_OPTION_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand",
- DEF_TEXT_XSCROLL_COMMAND, -1, Tk_Offset(TkText, xScrollCmd),
+ DEF_TEXT_XSCROLL_COMMAND, TCL_INDEX_NONE, offsetof(TkText, xScrollCmd),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-yscrollcommand", "yScrollCommand", "ScrollCommand",
- DEF_TEXT_YSCROLL_COMMAND, -1, Tk_Offset(TkText, yScrollCmd),
+ DEF_TEXT_YSCROLL_COMMAND, TCL_INDEX_NONE, offsetof(TkText, yScrollCmd),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_END, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0}
};
@@ -279,10 +279,10 @@ typedef ClientData SearchAddLineProc(int lineNum,
typedef int SearchMatchProc(int lineNum,
struct SearchSpec *searchSpecPtr,
ClientData clientData, Tcl_Obj *theLine,
- int matchOffset, int matchLength);
+ TkSizeT matchOffset, TkSizeT matchLength);
typedef int SearchLineIndexProc(Tcl_Interp *interp,
Tcl_Obj *objPtr, struct SearchSpec *searchSpecPtr,
- int *linePosPtr, int *offsetPosPtr);
+ int *linePosPtr, TkSizeT *offsetPosPtr);
typedef struct SearchSpec {
int exact; /* Whether search is exact or regexp. */
@@ -298,10 +298,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. */
+ TkSizeT 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
+ TkSizeT stopOffset; /* Index to stop at, provided stopLine is not
* -1. */
int numLines; /* Total lines which are available. */
int backwards; /* Searching forwards or backwards. */
@@ -365,8 +365,8 @@ static int CreateWidget(TkSharedText *sharedPtr, Tk_Window tkwin,
int objc, Tcl_Obj *const objv[]);
static void TextEventProc(ClientData clientData,
XEvent *eventPtr);
-static int TextFetchSelection(ClientData clientData, int offset,
- char *buffer, int maxBytes);
+static TkSizeT TextFetchSelection(ClientData clientData, TkSizeT offset,
+ char *buffer, TkSizeT maxBytes);
static int TextIndexSortProc(const void *first,
const void *second);
static int TextInsertCmd(TkSharedText *sharedTextPtr,
@@ -410,8 +410,8 @@ 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 TkSizeT TextSearchIndexInLine(const SearchSpec *searchSpecPtr,
+ TkTextLine *linePtr, TkSizeT byteIndex);
static int TextPeerCmd(TkText *textPtr, Tcl_Interp *interp,
int objc, Tcl_Obj *const objv[]);
static TkUndoProc TextUndoRedoCallback;
@@ -660,7 +660,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;
@@ -670,7 +670,7 @@ CreateWidget(
return TCL_ERROR;
}
- Tcl_SetObjResult(interp, TkNewWindowObj(textPtr->tkwin));
+ Tcl_SetObjResult(interp, Tk_NewWindowObj(textPtr->tkwin));
return TCL_OK;
}
@@ -748,10 +748,10 @@ TextWidgetObjCmd(
NULL) == 0) {
Tcl_Obj *listObj = Tcl_NewListObj(0, NULL);
- Tcl_ListObjAppendElement(interp, listObj, Tcl_NewIntObj(x));
- Tcl_ListObjAppendElement(interp, listObj, Tcl_NewIntObj(y));
- Tcl_ListObjAppendElement(interp, listObj, Tcl_NewIntObj(width));
- Tcl_ListObjAppendElement(interp, listObj, Tcl_NewIntObj(height));
+ Tcl_ListObjAppendElement(interp, listObj, Tcl_NewWideIntObj(x));
+ Tcl_ListObjAppendElement(interp, listObj, Tcl_NewWideIntObj(y));
+ Tcl_ListObjAppendElement(interp, listObj, Tcl_NewWideIntObj(width));
+ Tcl_ListObjAppendElement(interp, listObj, Tcl_NewWideIntObj(height));
Tcl_SetObjResult(interp, listObj);
}
@@ -763,7 +763,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) {
@@ -826,7 +826,7 @@ TextWidgetObjCmd(
}
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);
@@ -864,8 +864,8 @@ TextWidgetObjCmd(
for (i = 2; i < objc-2; i++) {
int value;
- int length;
- const char *option = Tcl_GetStringFromObj(objv[i], &length);
+ TkSizeT length;
+ const char *option = TkGetStringFromObj(objv[i], &length);
char c;
if (length < 2 || option[0] != '-') {
@@ -1019,7 +1019,7 @@ TextWidgetObjCmd(
countDone:
found++;
if (found == 1) {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(value));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(value));
} else {
if (found == 2) {
/*
@@ -1031,7 +1031,7 @@ TextWidgetObjCmd(
Tcl_ListObjAppendElement(NULL, objPtr,
Tcl_GetObjResult(interp));
}
- Tcl_ListObjAppendElement(NULL, objPtr, Tcl_NewIntObj(value));
+ Tcl_ListObjAppendElement(NULL, objPtr, Tcl_NewWideIntObj(value));
}
}
@@ -1043,7 +1043,7 @@ TextWidgetObjCmd(
int value = CountIndices(textPtr, indexFromPtr, indexToPtr,
COUNT_INDICES);
- Tcl_SetObjResult(interp, Tcl_NewIntObj(value));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(value));
} else if (found > 1) {
Tcl_SetObjResult(interp, objPtr);
}
@@ -1051,7 +1051,7 @@ 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);
@@ -1239,11 +1239,11 @@ TextWidgetObjCmd(
&base) == 0) {
Tcl_Obj *listObj = Tcl_NewListObj(0, NULL);
- Tcl_ListObjAppendElement(interp, listObj, Tcl_NewIntObj(x));
- Tcl_ListObjAppendElement(interp, listObj, Tcl_NewIntObj(y));
- Tcl_ListObjAppendElement(interp, listObj, Tcl_NewIntObj(width));
- Tcl_ListObjAppendElement(interp, listObj, Tcl_NewIntObj(height));
- Tcl_ListObjAppendElement(interp, listObj, Tcl_NewIntObj(base));
+ Tcl_ListObjAppendElement(interp, listObj, Tcl_NewWideIntObj(x));
+ Tcl_ListObjAppendElement(interp, listObj, Tcl_NewWideIntObj(y));
+ Tcl_ListObjAppendElement(interp, listObj, Tcl_NewWideIntObj(width));
+ Tcl_ListObjAppendElement(interp, listObj, Tcl_NewWideIntObj(height));
+ Tcl_ListObjAppendElement(interp, listObj, Tcl_NewWideIntObj(base));
Tcl_SetObjResult(interp, listObj);
}
@@ -1259,7 +1259,7 @@ TextWidgetObjCmd(
Tcl_Obj *objPtr = NULL;
int i, found = 0, visible = 0;
const char *name;
- int length;
+ TkSizeT length;
if (objc < 3) {
Tcl_WrongNumArgs(interp, 2, objv,
@@ -1275,12 +1275,12 @@ TextWidgetObjCmd(
i = 2;
if (objc > 3) {
- name = Tcl_GetStringFromObj(objv[i], &length);
+ name = TkGetStringFromObj(objv[i], &length);
if (length > 1 && name[0] == '-') {
if (strncmp("-displaychars", name, length) == 0) {
i++;
visible = 1;
- name = Tcl_GetStringFromObj(objv[i], &length);
+ name = TkGetStringFromObj(objv[i], &length);
}
if ((i < objc-1) && (length == 2) && !strcmp("--", name)) {
i++;
@@ -1753,7 +1753,7 @@ TextPeerCmd(
while (tPtr != NULL) {
if (tPtr != textPtr) {
Tcl_ListObjAppendElement(NULL, peersObj,
- TkNewWindowObj(tPtr->tkwin));
+ Tk_NewWindowObj(tPtr->tkwin));
}
tPtr = tPtr->next;
}
@@ -2631,12 +2631,12 @@ InsertChars(
int viewUpdate) /* Update the view if set. */
{
int lineIndex;
- int length;
+ TkSizeT length;
TkText *tPtr;
int *lineAndByteIndex;
int resetViewCount;
int pixels[2*PIXEL_CLIENTS];
- const char *string = Tcl_GetStringFromObj(stringPtr, &length);
+ const char *string = TkGetStringFromObj(stringPtr, &length);
if (sharedTextPtr == NULL) {
sharedTextPtr = textPtr->sharedTextPtr;
@@ -2778,6 +2778,9 @@ TextPushUndoAction(
{
TkUndoSubAtom *iAtom, *dAtom;
int canUndo, canRedo;
+ char lMarkName[20] = "tk::undoMarkL";
+ char rMarkName[20] = "tk::undoMarkR";
+ char stringUndoMarkId[16] = "";
/*
* Create the helpers.
@@ -2788,6 +2791,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.
@@ -2837,6 +2844,40 @@ TextPushUndoAction(
Tcl_ListObjAppendElement(NULL, deleteCmdObj, index1Obj);
Tcl_ListObjAppendElement(NULL, deleteCmdObj, index2Obj);
+ Tcl_ListObjAppendElement(NULL, markSetLUndoMarkCmdObj,
+ Tcl_NewStringObj(Tk_PathName(textPtr->tkwin), -1));
+ Tcl_ListObjAppendElement(NULL, markSetLUndoMarkCmdObj,
+ Tcl_NewStringObj("mark", 4));
+ Tcl_ListObjAppendElement(NULL, markSetLUndoMarkCmdObj,
+ Tcl_NewStringObj("set", 3));
+ markSetRUndoMarkCmdObj = Tcl_DuplicateObj(markSetLUndoMarkCmdObj);
+ textPtr->sharedTextPtr->undoMarkId++;
+ sprintf(stringUndoMarkId, "%d", textPtr->sharedTextPtr->undoMarkId);
+ strcat(lMarkName, stringUndoMarkId);
+ strcat(rMarkName, stringUndoMarkId);
+ Tcl_ListObjAppendElement(NULL, markSetLUndoMarkCmdObj,
+ Tcl_NewStringObj(lMarkName, -1));
+ Tcl_ListObjAppendElement(NULL, markSetRUndoMarkCmdObj,
+ Tcl_NewStringObj(rMarkName, -1));
+ Tcl_ListObjAppendElement(NULL, markSetLUndoMarkCmdObj, index1Obj);
+ Tcl_ListObjAppendElement(NULL, markSetRUndoMarkCmdObj, index2Obj);
+
+ Tcl_ListObjAppendElement(NULL, markGravityLUndoMarkCmdObj,
+ Tcl_NewStringObj(Tk_PathName(textPtr->tkwin), -1));
+ 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, -1));
+ Tcl_ListObjAppendElement(NULL, markGravityRUndoMarkCmdObj,
+ Tcl_NewStringObj(rMarkName, -1));
+ 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
@@ -2854,11 +2895,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);
@@ -3364,19 +3413,20 @@ DeleteIndexRange(
*----------------------------------------------------------------------
*/
-static int
+static TkSizeT
TextFetchSelection(
ClientData clientData, /* Information about text widget. */
- int offset, /* Offset within selection of first character
+ TkSizeT 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,
+ TkSizeT maxBytes) /* Maximum number of bytes to place at buffer,
* not including terminating NULL
* character. */
{
TkText *textPtr = (TkText *)clientData;
TkTextIndex eof;
- int count, chunkSize, offsetInSeg;
+ int count, chunkSize;
+ TkSizeT offsetInSeg;
TkTextSearch search;
TkTextSegment *segPtr;
@@ -3440,8 +3490,8 @@ 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;
@@ -3507,7 +3557,7 @@ TkTextLostSelection(
{
TkText *textPtr = (TkText *)clientData;
- if (TkpAlwaysShowSelection(textPtr->tkwin)) {
+ if (Tk_AlwaysShowSelection(textPtr->tkwin)) {
TkTextIndex start, end;
if ((!textPtr->exportSelection) || Tcl_IsSafe(textPtr->interp)) {
@@ -3565,7 +3615,7 @@ TkTextSelectionEvent(
* event generate $textWidget <<Selection>>
*/
- TkSendVirtualEvent(textPtr->tkwin, "Selection", NULL);
+ Tk_SendVirtualEvent(textPtr->tkwin, "Selection", NULL);
}
/*
@@ -3965,7 +4015,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
+ TkSizeT *offsetPosPtr) /* For returning the text offset in the
* line. */
{
const TkTextIndex *indexPtr;
@@ -4025,28 +4075,29 @@ TextSearchGetLineIndex(
*----------------------------------------------------------------------
*/
-static int
+static TkSizeT
TextSearchIndexInLine(
const SearchSpec *searchSpecPtr,
/* Search parameters. */
TkTextLine *linePtr, /* The line we're looking at. */
- int byteIndex) /* Index into the line. */
+ TkSizeT byteIndex) /* Index into the line. */
{
TkTextSegment *segPtr;
TkTextIndex curIndex;
- int index, leftToScan;
+ TkSizeT index;
+ int leftToScan;
TkText *textPtr = (TkText *)searchSpecPtr->clientData;
index = 0;
curIndex.tree = textPtr->sharedTextPtr->tree;
curIndex.linePtr = linePtr; curIndex.byteIndex = 0;
for (segPtr = linePtr->segPtr, leftToScan = byteIndex;
- leftToScan > 0;
+ leftToScan + 1 > 1;
curIndex.byteIndex += segPtr->size, segPtr = segPtr->nextPtr) {
if ((segPtr->typePtr == &tkTextCharType) &&
(searchSpecPtr->searchElide
|| !TkTextIsElided(textPtr, &curIndex, NULL))) {
- if (leftToScan < segPtr->size) {
+ if (leftToScan + 1 < (int)segPtr->size + 1) {
if (searchSpecPtr->exact) {
index += leftToScan;
} else {
@@ -4217,12 +4268,12 @@ TextSearchFoundMatch(
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
+ TkSizeT 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
+ TkSizeT matchLength) /* Length also in bytes/chars as per search
* type. */
{
- int numChars;
+ TkSizeT numChars;
int leftToScan;
TkTextIndex curIndex, foundIndex;
TkTextSegment *segPtr;
@@ -4237,7 +4288,7 @@ TextSearchFoundMatch(
*/
if (searchSpecPtr->backwards ^
- (matchOffset >= searchSpecPtr->stopOffset)) {
+ (matchOffset + 1 >= searchSpecPtr->stopOffset + 1)) {
return 0;
}
}
@@ -4262,7 +4313,7 @@ TextSearchFoundMatch(
if (searchSpecPtr->strictLimits && lineNum == searchSpecPtr->stopLine) {
if (searchSpecPtr->backwards ^
- ((matchOffset + numChars) > searchSpecPtr->stopOffset)) {
+ ((matchOffset + numChars + 1) > searchSpecPtr->stopOffset + 1)) {
return 0;
}
}
@@ -4313,7 +4364,7 @@ TextSearchFoundMatch(
}
} else {
if (searchSpecPtr->exact) {
- leftToScan -= segPtr->size;
+ leftToScan -= (int)segPtr->size;
} else {
leftToScan -= Tcl_NumUtfChars(segPtr->body.chars, -1);
}
@@ -4415,7 +4466,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();
@@ -4488,7 +4539,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;
@@ -4702,13 +4753,13 @@ TextDumpCmd(
if (objc == arg) {
TkTextIndexForwChars(NULL, &index1, 1, &index2, COUNT_INDICES);
} else {
- int length;
+ TkSizeT length;
const char *str;
if (TkTextGetObjIndex(interp, textPtr, objv[arg], &index2) != TCL_OK) {
return TCL_ERROR;
}
- str = Tcl_GetStringFromObj(objv[arg], &length);
+ str = TkGetStringFromObj(objv[arg], &length);
if (strncmp(str, "end", length) == 0) {
atEnd = 1;
}
@@ -5024,7 +5075,7 @@ DumpSegment(
Tcl_DecrRefCount(tuple);
return 0;
} else {
- int oldStateEpoch = TkBTreeEpoch(textPtr->sharedTextPtr->tree);
+ TkSizeT oldStateEpoch = TkBTreeEpoch(textPtr->sharedTextPtr->tree);
Tcl_DString buf;
int code;
@@ -5067,6 +5118,8 @@ TextEditUndo(
TkText *textPtr) /* Overall information about text widget. */
{
int status;
+ Tcl_Obj *cmdObj;
+ int code;
if (!textPtr->sharedTextPtr->undo) {
return TCL_OK;
@@ -5090,6 +5143,22 @@ TextEditUndo(
}
textPtr->sharedTextPtr->undo = 1;
+ /*
+ * 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;
}
@@ -5115,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;
@@ -5137,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;
}
@@ -5346,7 +5434,7 @@ TextGetText(
if (TkTextIndexCmp(indexPtr1, indexPtr2) < 0) {
while (1) {
- int offset;
+ TkSizeT offset;
TkTextSegment *segPtr = TkTextIndexToSeg(&tmpIndex, &offset);
int last = segPtr->size, last2;
@@ -5401,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);
}
}
@@ -5431,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);
}
}
@@ -5529,7 +5617,7 @@ TkTextRunAfterSyncCmd(
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_DecrRefCount(textPtr->afterSyncCmd);
@@ -5667,7 +5755,7 @@ SearchCore(
*/
int firstOffset, lastOffset;
- int matchOffset, matchLength;
+ TkSizeT matchOffset, matchLength;
int passes;
int lineNum = searchSpecPtr->startLine;
int code = TCL_OK;
@@ -5688,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;
+ TkSizeT smArray[2 * LOTS_OF_MATCHES];
+ TkSizeT *storeMatch = smArray;
+ TkSizeT *storeLength = smArray + LOTS_OF_MATCHES;
int lastBackwardsLineMatch = -1;
int lastBackwardsMatchOffset = -1;
@@ -5740,7 +5828,7 @@ SearchCore(
* it has dual purpose.
*/
- pattern = Tcl_GetStringFromObj(patObj, &matchLength);
+ pattern = TkGetStringFromObj(patObj, &matchLength);
nl = strchr(pattern, '\n');
/*
@@ -5839,7 +5927,7 @@ SearchCore(
* Only use the last part of the line.
*/
- if (searchSpecPtr->startOffset > firstOffset) {
+ if (searchSpecPtr->startOffset + 1 > (TkSizeT)firstOffset + 1) {
firstOffset = searchSpecPtr->startOffset;
}
if ((firstOffset >= lastOffset)
@@ -5851,7 +5939,7 @@ SearchCore(
* Use only the first part of the line.
*/
- if (searchSpecPtr->startOffset < lastOffset) {
+ if (searchSpecPtr->startOffset + 1 < (TkSizeT)lastOffset + 1) {
lastOffset = searchSpecPtr->startOffset;
}
}
@@ -5865,7 +5953,7 @@ SearchCore(
* begin.
*/
- matchOffset = -1;
+ matchOffset = TCL_INDEX_NONE;
if (searchSpecPtr->exact) {
int maxExtraLines = 0;
@@ -5875,11 +5963,11 @@ SearchCore(
do {
int ch;
const char *p;
- int lastFullLine = lastOffset;
+ TkSizeT lastFullLine = lastOffset;
if (firstNewLine == -1) {
if (searchSpecPtr->strictLimits
- && (firstOffset + matchLength > lastOffset)) {
+ && (firstOffset + matchLength + 1 > (TkSizeT)lastOffset + 1)) {
/*
* Not enough characters to match.
*/
@@ -5997,7 +6085,7 @@ SearchCore(
* exact searches.
*/
- if ((lastTotal - skipFirst) >= matchLength) {
+ if ((TkSizeT)lastTotal - skipFirst + 1 >= matchLength + 1) {
/*
* We now have enough text to match, so we
* make a final test and break whatever the
@@ -6079,7 +6167,7 @@ SearchCore(
}
} else {
firstOffset = matchLength ? p - startOfLine + matchLength
- : p - startOfLine + 1;
+ : p - startOfLine + (TkSizeT)1;
if (firstOffset >= lastOffset) {
/*
* Now, we have to be careful not to find
@@ -6119,7 +6207,7 @@ SearchCore(
do {
Tcl_RegExpInfo info;
int match;
- int lastFullLine = lastOffset;
+ TkSizeT lastFullLine = lastOffset;
match = Tcl_RegExpExecObj(interp, regexp, theLine,
firstOffset, 1, (firstOffset>0 ? TCL_REG_NOTBOL : 0));
@@ -6137,9 +6225,9 @@ SearchCore(
if (!match ||
((info.extendStart == info.matches[0].start)
- && (info.matches[0].end == lastOffset-firstOffset))) {
+ && (info.matches[0].end == (TkSizeT) (lastOffset - firstOffset)))) {
int extraLines = 0;
- int prevFullLine;
+ TkSizeT prevFullLine;
/*
* If we find a match that overlaps more than one line, we
@@ -6155,7 +6243,7 @@ SearchCore(
lastNonOverlap = lastTotal;
}
- if (info.extendStart < 0) {
+ if (info.extendStart == TCL_INDEX_NONE) {
/*
* No multi-line match is possible.
*/
@@ -6252,9 +6340,9 @@ SearchCore(
*/
if ((match &&
- firstOffset + info.matches[0].end != lastTotal &&
- firstOffset + info.matches[0].end < prevFullLine)
- || info.extendStart < 0) {
+ firstOffset + info.matches[0].end != (TkSizeT) lastTotal &&
+ firstOffset + info.matches[0].end + 1 < prevFullLine + 1)
+ || info.extendStart == TCL_INDEX_NONE) {
break;
}
@@ -6265,7 +6353,7 @@ SearchCore(
* that line.
*/
- if (match && (info.matches[0].start >= lastOffset)) {
+ if (match && (info.matches[0].start + 1 >= (TkSizeT) lastOffset + 1)) {
break;
}
if (match && ((firstOffset + info.matches[0].end)
@@ -6322,8 +6410,8 @@ SearchCore(
* Possible overlap or enclosure.
*/
- if (thisOffset - lastNonOverlap >=
- lastBackwardsMatchOffset + matchLength){
+ if ((TkSizeT)thisOffset - lastNonOverlap >=
+ lastBackwardsMatchOffset + matchLength + 1){
/*
* Totally encloses previous match, so
* forget the previous match.
@@ -6404,12 +6492,12 @@ SearchCore(
* previous match.
*/
- if (matchOffset == -1 ||
+ if (matchOffset == TCL_INDEX_NONE ||
((searchSpecPtr->all || searchSpecPtr->backwards)
- && ((firstOffset < matchOffset)
+ && (((TkSizeT)firstOffset + 1 < matchOffset + 1)
|| ((firstOffset + info.matches[0].end
- info.matches[0].start)
- > (matchOffset + matchLength))))) {
+ > matchOffset + matchLength)))) {
matchOffset = firstOffset;
matchLength = info.matches[0].end - info.matches[0].start;
@@ -6427,11 +6515,11 @@ SearchCore(
* matches on the heap.
*/
- int *newArray = (int *)
- ckalloc(4 * matchNum * sizeof(int));
- memcpy(newArray, storeMatch, matchNum*sizeof(int));
+ TkSizeT *newArray = (TkSizeT *)
+ ckalloc(4 * matchNum * sizeof(TkSizeT));
+ memcpy(newArray, storeMatch, matchNum*sizeof(TkSizeT));
memcpy(newArray + 2*matchNum, storeLength,
- matchNum * sizeof(int));
+ matchNum * sizeof(TkSizeT));
if (storeMatch != smArray) {
ckfree(storeMatch);
}
@@ -6466,7 +6554,7 @@ SearchCore(
* explicitly disallow overlapping matches.
*/
- if (matchLength > 0 && !searchSpecPtr->overlap
+ if (matchLength + 1 > 1 && !searchSpecPtr->overlap
&& !searchSpecPtr->backwards) {
firstOffset += matchLength;
if (firstOffset >= lastOffset) {
@@ -6523,8 +6611,8 @@ SearchCore(
* found which would exercise such a problem.
*/
}
- if (storeMatch[matches] + storeLength[matches]
- >= matchOffset + matchLength) {
+ if (storeMatch[matches] + storeLength[matches] + 1
+ >= matchOffset + matchLength + 1) {
/*
* The new match totally encloses the previous one, so
* we overwrite the previous one.
@@ -6572,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);
@@ -6691,7 +6779,7 @@ GetLineStartEnd(
TCL_UNUSED(void *),
TCL_UNUSED(Tk_Window),
char *recordPtr, /* Pointer to widget record. */
- int internalOffset) /* Offset within *recordPtr containing the
+ TkSizeT internalOffset) /* Offset within *recordPtr containing the
* line value. */
{
TkTextLine *linePtr = *(TkTextLine **)(recordPtr + internalOffset);
@@ -6699,7 +6787,7 @@ GetLineStartEnd(
if (linePtr == NULL) {
return Tcl_NewObj();
}
- return Tcl_NewIntObj(1 + TkBTreeLinesTo(NULL, linePtr));
+ return Tcl_NewWideIntObj(1 + TkBTreeLinesTo(NULL, linePtr));
}
/*
@@ -6730,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
+ TkSizeT 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. */
@@ -6739,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;
}
diff --git a/generic/tkText.h b/generic/tkText.h
index 9a9495a..e9e6303 100644
--- a/generic/tkText.h
+++ b/generic/tkText.h
@@ -165,7 +165,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
+ TkSizeT size; /* Size of this segment (# of bytes of index
* space it occupies). */
union {
char chars[TKFLEXARRAY]; /* Characters that make up character info.
@@ -532,8 +532,16 @@ typedef enum {
* that are peers.
*/
+#ifndef TkSizeT
+# if TCL_MAJOR_VERSION > 8
+# define TkSizeT size_t
+# else
+# define TkSizeT int
+# endif
+#endif
+
typedef struct TkSharedText {
- int refCount; /* Reference count this shared object. */
+ TkSizeT 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
@@ -562,7 +570,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
+ TkSizeT 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
@@ -580,6 +588,8 @@ typedef struct TkSharedText {
* statements. */
int autoSeparators; /* Non-zero means the separators will be
* inserted automatically. */
+ int undoMarkId; /* Counts undo marks temporarily used during
+ undo and redo operations. */
int isDirty; /* Flag indicating the 'dirtyness' of the
* text widget. If the flag is not zero,
* unsaved modifications have been applied to
@@ -781,7 +791,7 @@ typedef struct TkText {
* definitions. */
Tk_OptionTable optionTable; /* Token representing the configuration
* specifications. */
- int refCount; /* Number of cached TkTextIndex objects
+ TkSizeT refCount; /* Number of cached TkTextIndex objects
* refering to us. */
int insertCursorType; /* 0 = standard insertion cursor, 1 = block
* cursor. */
@@ -837,7 +847,7 @@ typedef struct TkText {
*/
typedef TkTextSegment * Tk_SegSplitProc(struct TkTextSegment *segPtr,
- int index);
+ TkSizeT index);
typedef int Tk_SegDeleteProc(struct TkTextSegment *segPtr,
TkTextLine *linePtr, int treeGone);
typedef TkTextSegment * Tk_SegCleanupProc(struct TkTextSegment *segPtr,
@@ -846,8 +856,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, TkSizeT offset, int maxX,
+ TkSizeT maxChars, int noCharsYet, TkWrapMode wrapMode,
struct TkTextDispChunk *chunkPtr);
typedef void Tk_SegCheckProc(TkTextSegment *segPtr,
TkTextLine *linePtr);
@@ -1007,7 +1017,7 @@ 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 TkSizeT TkBTreeEpoch(TkTextBTree tree);
MODULE_SCOPE TkTextLine *TkBTreeFindLine(TkTextBTree tree,
const TkText *textPtr, int line);
MODULE_SCOPE TkTextLine *TkBTreeFindPixelLine(TkTextBTree tree,
@@ -1050,7 +1060,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,
+ TkSizeT offset, int maxX, TkSizeT maxChars, int noBreakYet,
TkWrapMode wrapMode, TkTextDispChunk *chunkPtr);
MODULE_SCOPE void TkTextCreateDInfo(TkText *textPtr);
MODULE_SCOPE int TkTextDLineInfo(TkText *textPtr,
@@ -1096,7 +1106,7 @@ 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);
+ TkSizeT *offsetPtr);
MODULE_SCOPE void TkTextLostSelection(ClientData clientData);
MODULE_SCOPE TkTextIndex *TkTextMakeCharIndex(TkTextBTree tree, TkText *textPtr,
int lineIndex, int charIndex,
diff --git a/generic/tkTextBTree.c b/generic/tkTextBTree.c
index 7832992..8feb2a2 100644
--- a/generic/tkTextBTree.c
+++ b/generic/tkTextBTree.c
@@ -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
+ TkSizeT 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:
@@ -161,7 +161,7 @@ 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, TkSizeT index);
static void CheckNodeConsistency(Node *nodePtr, int references);
static void CleanupLine(TkTextLine *linePtr);
static void DeleteSummaries(Summary *tagPtr);
@@ -501,7 +501,7 @@ TkBTreeDestroy(
*----------------------------------------------------------------------
*/
-int
+TkSizeT
TkBTreeEpoch(
TkTextBTree tree) /* Tree to get epoch for. */
{
@@ -1021,7 +1021,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
@@ -1190,14 +1190,14 @@ SplitSeg(
{
TkTextSegment *prevPtr, *segPtr;
TkTextLine *linePtr;
- int count = indexPtr->byteIndex;
+ TkSizeT count = indexPtr->byteIndex;
linePtr = indexPtr->linePtr;
prevPtr = NULL;
segPtr = linePtr->segPtr;
while (segPtr != NULL) {
- if (segPtr->size > count) {
+ if (segPtr->size + 1 > count + 1) {
if (count == 0) {
return prevPtr;
}
@@ -2654,7 +2654,7 @@ TkBTreeStartSearch(
/* Where to store information about search's
* progress. */
{
- int offset;
+ TkSizeT offset;
TkTextIndex index0; /* First index of the tag. */
TkTextSegment *seg0Ptr; /* First segment of the tag. */
@@ -2750,7 +2750,7 @@ TkBTreeStartSearchBack(
/* Where to store information about search's
* progress. */
{
- int offset;
+ TkSizeT offset;
TkTextIndex index0; /* Last index of the tag. */
TkTextIndex backOne; /* One character before starting index. */
TkTextSegment *seg0Ptr; /* Last segment of the tag. */
@@ -3244,7 +3244,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))
@@ -3364,7 +3364,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);
@@ -3528,7 +3528,7 @@ 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;
@@ -3865,7 +3865,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",
@@ -4545,7 +4545,7 @@ TkBTreeNumPixels(
static TkTextSegment *
CharSplitProc(
TkTextSegment *segPtr, /* Pointer to segment to split. */
- int index) /* Position within segment at which to
+ TkSizeT index) /* Position within segment at which to
* split. */
{
TkTextSegment *newPtr1, *newPtr2;
@@ -4665,7 +4665,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 a02544d..b1c5e17 100644
--- a/generic/tkTextDisp.c
+++ b/generic/tkTextDisp.c
@@ -171,7 +171,7 @@ typedef struct StyleValues {
*/
typedef struct TextStyle {
- int refCount; /* Number of times this structure is
+ TkSizeT refCount; /* Number of times this structure is
* referenced in Chunks. */
GC bgGC; /* Graphics context for background. None means
* use widget background. */
@@ -418,7 +418,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
+ TkSizeT 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
@@ -1177,7 +1177,8 @@ LayoutDLine(
/* 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;
+ TkSizeT byteOffset;
+ int ascent, descent, code, elide, elidesize;
StyleValues *sValuePtr;
TkTextElideInfo info; /* Keep track of elide state. */
@@ -1217,7 +1218,7 @@ LayoutDLine(
if (elide && indexPtr->byteIndex == 0) {
maxBytes = 0;
for (segPtr = info.segPtr; segPtr != NULL; segPtr = segPtr->nextPtr) {
- if (segPtr->size > 0) {
+ if (segPtr->size + 1 > 1) {
if (elide == 0) {
/*
* We toggled a tag and the elide state changed to
@@ -1338,7 +1339,7 @@ LayoutDLine(
connectNextLogicalLine:
byteOffset = curIndex.byteIndex;
segPtr = curIndex.linePtr->segPtr;
- while ((byteOffset > 0) && (byteOffset >= segPtr->size)) {
+ while ((byteOffset + 1 > 1) && (byteOffset + 1 >= segPtr->size + 1)) {
byteOffset -= segPtr->size;
segPtr = segPtr->nextPtr;
@@ -1378,7 +1379,7 @@ LayoutDLine(
if (elide && (lastChunkPtr != NULL)
&& (lastChunkPtr->displayProc == NULL /*ElideDisplayProc*/)) {
elidesize = segPtr->size - byteOffset;
- if (elidesize > 0) {
+ if (segPtr->size + 1 > byteOffset + 1) {
curIndex.byteIndex += elidesize;
lastChunkPtr->numBytes += elidesize;
breakByteOffset = lastChunkPtr->breakIndex
@@ -3063,7 +3064,7 @@ AsyncUpdateLineMetrics(
* and we've reached the last line, then we're done.
*/
- if (dInfoPtr->metricEpoch == -1
+ if (dInfoPtr->metricEpoch == TCL_INDEX_NONE
&& lineNum == dInfoPtr->lastMetricUpdateLine) {
/*
* We have looped over all lines, so we're done. We must release our
@@ -3081,7 +3082,7 @@ AsyncUpdateLineMetrics(
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_DecrRefCount(textPtr->afterSyncCmd);
@@ -3163,7 +3164,7 @@ GenerateWidgetViewSyncEvent(
} else {
textPtr->dInfoPtr->flags |= OUT_OF_SYNC;
}
- TkSendVirtualEvent(textPtr->tkwin, "WidgetViewSync",
+ Tk_SendVirtualEvent(textPtr->tkwin, "WidgetViewSync",
Tcl_NewBooleanObj(NewSyncState));
}
}
@@ -3247,7 +3248,8 @@ TkTextUpdateLineMetrics(
* then we can't be done.
*/
- if (textPtr->dInfoPtr->metricEpoch == -1 && lineNum == endLine) {
+ if (textPtr->dInfoPtr->metricEpoch == TCL_INDEX_NONE && lineNum == endLine) {
+
/*
* We have looped over all lines, so we're done.
@@ -6160,7 +6162,7 @@ TkTextYviewCmd(
TextDInfo *dInfoPtr = textPtr->dInfoPtr;
int pickPlace, type;
int pixels, count;
- int switchLength;
+ TkSizeT switchLength;
double fraction;
TkTextIndex index;
@@ -6180,7 +6182,7 @@ TkTextYviewCmd(
pickPlace = 0;
if (Tcl_GetString(objv[2])[0] == '-') {
const char *switchStr =
- Tcl_GetStringFromObj(objv[2], &switchLength);
+ TkGetStringFromObj(objv[2], &switchLength);
if ((switchLength >= 2) && (strncmp(switchStr, "-pickplace",
(unsigned) switchLength) == 0)) {
@@ -7557,6 +7559,7 @@ ElideBboxProc(
int *heightPtr) /* Gets filled in with height of character, in
* pixels. */
{
+
*xPtr = chunkPtr->x;
*yPtr = y;
*widthPtr = *heightPtr = 0;
@@ -7602,11 +7605,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
+ TkSizeT 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
+ TkSizeT 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. */
@@ -7619,7 +7622,8 @@ TkTextCharLayoutProc(
* set by the caller. */
{
Tk_Font tkfont;
- int nextX, bytesThatFit, count;
+ int nextX, count;
+ TkSizeT bytesThatFit;
CharInfo *ciPtr;
char *p;
TkTextSegment *nextPtr;
@@ -7681,7 +7685,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);
@@ -7764,7 +7768,7 @@ TkTextCharLayoutProc(
chunkPtr->breakIndex = -1;
#if !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 */
@@ -8777,10 +8781,10 @@ TextGetScrollInfoObj(
VIEW_MOVETO, VIEW_SCROLL
};
static const char *const units[] = {
- "units", "pages", "pixels", NULL
+ "pages", "pixels", "units", NULL
};
enum viewUnits {
- VIEW_SCROLL_UNITS, VIEW_SCROLL_PAGES, VIEW_SCROLL_PIXELS
+ VIEW_SCROLL_PAGES, VIEW_SCROLL_PIXELS, VIEW_SCROLL_UNITS
};
int index;
@@ -8801,7 +8805,7 @@ TextGetScrollInfoObj(
return TKTEXT_SCROLL_MOVETO;
case VIEW_SCROLL:
if (objc != 5) {
- Tcl_WrongNumArgs(interp, 3, objv, "number units|pages|pixels");
+ Tcl_WrongNumArgs(interp, 3, objv, "number pages|pixels|units");
return TKTEXT_SCROLL_ERROR;
}
if (Tcl_GetIndexFromObjStruct(interp, objv[4], units,
diff --git a/generic/tkTextImage.c b/generic/tkTextImage.c
index bc0da0a..3657fa6 100644
--- a/generic/tkTextImage.c
+++ b/generic/tkTextImage.c
@@ -18,7 +18,7 @@
*/
#define EI_SEG_SIZE \
- ((unsigned)(Tk_Offset(TkTextSegment, body) + sizeof(TkTextEmbImage)))
+ (offsetof(TkTextSegment, body) + sizeof(TkTextEmbImage))
/*
* Prototypes for functions defined in this file:
@@ -43,7 +43,7 @@ static void EmbImageDisplayProc(TkText *textPtr,
Drawable dst, int screenY);
static int EmbImageLayoutProc(TkText *textPtr,
TkTextIndex *indexPtr, TkTextSegment *segPtr,
- int offset, int maxX, int maxChars,
+ TkSizeT offset, int maxX, TkSizeT maxChars,
int noCharsYet, TkWrapMode wrapMode,
TkTextDispChunk *chunkPtr);
static void EmbImageProc(ClientData clientData, int x, int y,
@@ -83,17 +83,17 @@ typedef enum {
static const Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_STRING_TABLE, "-align", NULL, NULL,
- "center", -1, Tk_Offset(TkTextEmbImage, align),
+ "center", TCL_INDEX_NONE, offsetof(TkTextEmbImage, align),
0, alignStrings, 0},
{TK_OPTION_PIXELS, "-padx", NULL, NULL,
- "0", -1, Tk_Offset(TkTextEmbImage, padX), 0, 0, 0},
+ "0", TCL_INDEX_NONE, offsetof(TkTextEmbImage, padX), 0, 0, 0},
{TK_OPTION_PIXELS, "-pady", NULL, NULL,
- "0", -1, Tk_Offset(TkTextEmbImage, padY), 0, 0, 0},
+ "0", TCL_INDEX_NONE, offsetof(TkTextEmbImage, padY), 0, 0, 0},
{TK_OPTION_STRING, "-image", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextEmbImage, imageString),
+ NULL, TCL_INDEX_NONE, offsetof(TkTextEmbImage, imageString),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-name", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextEmbImage, imageName),
+ NULL, TCL_INDEX_NONE, offsetof(TkTextEmbImage, imageName),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0}
};
@@ -161,7 +161,7 @@ TkTextImageCmd(
Tcl_SetErrorCode(interp, "TK", "TEXT", "NO_IMAGE", 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;
@@ -188,7 +188,7 @@ TkTextImageCmd(
}
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) {
@@ -279,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(
- 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");
@@ -336,7 +341,7 @@ EmbImageConfigure(
int conflict = 0; /* True if we have a name conflict */
size_t len; /* length of image name */
- 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;
@@ -530,11 +535,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
+ TkSizeT 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(TkSizeT), /* Chunk must not include more than this many
* characters. */
int noCharsYet, /* Non-zero means no characters have been
* assigned to this line yet. */
@@ -623,7 +628,7 @@ EmbImageCheckProc(
}
if (eiPtr->size != 1) {
Tcl_Panic("EmbImageCheckProc: embedded image has size %d",
- eiPtr->size);
+ (int)eiPtr->size);
}
}
diff --git a/generic/tkTextIndex.c b/generic/tkTextIndex.c
index 1628389..d9bf299 100644
--- a/generic/tkTextIndex.c
+++ b/generic/tkTextIndex.c
@@ -64,7 +64,7 @@ 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
@@ -104,7 +104,7 @@ DupTextIndexInternalRep(
Tcl_Obj *srcPtr, /* TextIndex obj with internal rep to copy. */
Tcl_Obj *copyPtr) /* TextIndex obj with internal rep to set. */
{
- int epoch;
+ TkSizeT epoch;
TkTextIndex *dupIndexPtr, *indexPtr;
dupIndexPtr = (TkTextIndex *)ckalloc(sizeof(TkTextIndex));
@@ -206,7 +206,7 @@ TkTextGetIndexFromObj(
int cache;
if (objPtr->typePtr == &tkTextIndexType) {
- int epoch;
+ TkSizeT epoch;
indexPtr = GET_TEXTINDEX(objPtr);
epoch = GET_INDEXEPOCH(objPtr);
@@ -425,7 +425,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)) {
/*
@@ -531,7 +531,7 @@ TkTextMakeCharIndex(
index += offset;
}
} else {
- if (charIndex < segPtr->size) {
+ if (charIndex < (int)segPtr->size) {
indexPtr->byteIndex = index;
break;
}
@@ -565,11 +565,11 @@ TkTextMakeCharIndex(
TkTextSegment *
TkTextIndexToSeg(
const TkTextIndex *indexPtr,/* Text index. */
- int *offsetPtr) /* Where to store offset within segment, or
+ TkSizeT *offsetPtr) /* Where to store offset within segment, or
* NULL if offset isn't wanted. */
{
TkTextSegment *segPtr;
- int offset;
+ TkSizeT offset;
for (offset = indexPtr->byteIndex, segPtr = indexPtr->linePtr->segPtr;
offset >= segPtr->size;
@@ -1024,7 +1024,7 @@ GetIndex(
*---------------------------------------------------------------------------
*/
-int
+TkSizeT
TkTextPrintIndex(
const TkText *textPtr,
const TkTextIndex *indexPtr,/* Pointer to index. */
@@ -1049,7 +1049,7 @@ TkTextPrintIndex(
linePtr = TkBTreeNextLine(NULL, linePtr);
segPtr = linePtr->segPtr;
}
- if (numBytes <= segPtr->size) {
+ if (numBytes <= (int)segPtr->size) {
break;
}
if (segPtr->typePtr == &tkTextCharType) {
@@ -1488,7 +1488,7 @@ TkTextIndexForwChars(
TkTextLine *linePtr;
TkTextSegment *segPtr;
TkTextElideInfo *infoPtr = NULL;
- int byteOffset;
+ TkSizeT byteOffset;
char *start, *end, *p;
int ch;
int elide = 0;
@@ -1676,7 +1676,7 @@ IndexCountBytesOrdered(
/* Index describing location of last character
* at which to stop the count. */
{
- int byteCount, offset;
+ TkSizeT byteCount, offset;
TkTextSegment *segPtr, *segPtr1;
TkTextLine *linePtr;
@@ -1753,7 +1753,8 @@ TkTextIndexCount(
TkTextLine *linePtr1;
TkTextSegment *segPtr, *seg2Ptr = NULL;
TkTextElideInfo *infoPtr = NULL;
- int byteOffset, maxBytes, count = 0, elide = 0;
+ TkSizeT byteOffset, maxBytes, count = 0;
+ int elide = 0;
int checkElided = (type & COUNT_DISPLAY);
/*
@@ -1843,10 +1844,10 @@ TkTextIndexCount(
}
if (segPtr->typePtr == &tkTextCharType) {
- int byteLen = segPtr->size - byteOffset;
+ TkSizeT byteLen = segPtr->size - byteOffset;
unsigned char *str = (unsigned char *)
segPtr->body.chars + byteOffset;
- int i;
+ TkSizeT i;
if (segPtr == seg2Ptr) {
if (byteLen + byteOffset > maxBytes) {
@@ -1876,7 +1877,7 @@ TkTextIndexCount(
}
} else {
if (type & COUNT_INDICES) {
- int byteLen = segPtr->size - byteOffset;
+ TkSizeT byteLen = segPtr->size - byteOffset;
if (segPtr == seg2Ptr) {
if (byteLen + byteOffset > maxBytes) {
@@ -2055,7 +2056,7 @@ TkTextIndexBackChars(
linePtr = TkBTreeNextLine(NULL, linePtr);
segPtr = linePtr->segPtr;
}
- if (segSize <= segPtr->size) {
+ if (segSize <= (int)segPtr->size) {
break;
}
segSize -= segPtr->size;
@@ -2296,7 +2297,7 @@ StartEnd(
} else if ((*string == 'w') && (strncmp(string, "wordend", length) == 0)
&& (length >= 5)) {
int firstChar = 1;
- int offset;
+ TkSizeT offset;
/*
* If the current character isn't part of a word then just move
@@ -2339,7 +2340,7 @@ StartEnd(
} else if ((*string == 'w') && (strncmp(string, "wordstart", length) == 0)
&& (length >= 5)) {
int firstChar = 1;
- int offset;
+ TkSizeT offset;
if (modifier == TKINDEX_DISPLAY) {
TkTextIndexForwChars(textPtr, indexPtr, 0, indexPtr,
@@ -2364,7 +2365,7 @@ StartEnd(
if (!Tcl_UniCharIsWordChar(ch)) {
break;
}
- if (offset > 0) {
+ if (offset + 1 > 1) {
chSize = (segPtr->body.chars + offset
- TkUtfPrev(segPtr->body.chars + offset,
segPtr->body.chars));
@@ -2383,7 +2384,7 @@ StartEnd(
indexPtr->byteIndex -= chSize;
}
offset -= chSize;
- if (offset < 0) {
+ if ((int)offset < 0) {
if (indexPtr->byteIndex == 0) {
goto done;
}
diff --git a/generic/tkTextMark.c b/generic/tkTextMark.c
index dcd7008..141e2e5 100644
--- a/generic/tkTextMark.c
+++ b/generic/tkTextMark.c
@@ -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, TkSizeT offset, int maxX,
+ TkSizeT maxChars, int noCharsYet, TkWrapMode wrapMode,
TkTextDispChunk *chunkPtr);
static int MarkFindNext(Tcl_Interp *interp,
TkText *textPtr, Tcl_Obj *markName);
@@ -126,14 +126,14 @@ TkTextMarkCmd(
switch ((enum markOptions) optionIndex) {
case MARK_GRAVITY: {
char c;
- int length;
+ TkSizeT length;
const char *str;
if (objc < 4 || objc > 5) {
Tcl_WrongNumArgs(interp, 3, objv, "markName ?gravity?");
return TCL_ERROR;
}
- str = Tcl_GetStringFromObj(objv[3], &length);
+ str = TkGetStringFromObj(objv[3], &length);
if (length == 6 && !strcmp(str, "insert")) {
markPtr = textPtr->insertMarkPtr;
} else if (length == 7 && !strcmp(str, "current")) {
@@ -160,7 +160,7 @@ TkTextMarkCmd(
Tcl_SetObjResult(interp, Tcl_NewStringObj(typeStr, -1));
return TCL_OK;
}
- str = Tcl_GetStringFromObj(objv[4],&length);
+ str = TkGetStringFromObj(objv[4],&length);
c = str[0];
if ((c == 'l') && (strncmp(str, "left", length) == 0)) {
newTypePtr = &tkTextLeftMarkType;
@@ -560,11 +560,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(TkSizeT), /* 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(TkSizeT), /* Chunk must not include more than this many
* characters. */
TCL_UNUSED(int), /* Non-zero means no characters have been
* assigned to this line yet. */
diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c
index c15773e..2bd321d 100644
--- a/generic/tkTextTag.c
+++ b/generic/tkTextTag.c
@@ -40,66 +40,66 @@ static const char *const tabStyleStrings[] = {
static const Tk_OptionSpec tagOptionSpecs[] = {
{TK_OPTION_BORDER, "-background", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, border), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, border), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_BITMAP, "-bgstipple", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, bgStipple), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, bgStipple), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-borderwidth", NULL, NULL,
- NULL, Tk_Offset(TkTextTag, borderWidthPtr), Tk_Offset(TkTextTag, borderWidth),
+ NULL, offsetof(TkTextTag, borderWidthPtr), offsetof(TkTextTag, borderWidth),
TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT, 0, 0},
{TK_OPTION_STRING, "-elide", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, elideString),
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, elideString),
TK_OPTION_NULL_OK|TK_OPTION_DONT_SET_DEFAULT, 0, 0},
{TK_OPTION_BITMAP, "-fgstipple", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, fgStipple), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, fgStipple), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_FONT, "-font", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, tkfont), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, tkfont), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_COLOR, "-foreground", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, fgColor), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, fgColor), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-justify", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, justifyString), TK_OPTION_NULL_OK, 0,0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, justifyString), TK_OPTION_NULL_OK, 0,0},
{TK_OPTION_STRING, "-lmargin1", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, lMargin1String), TK_OPTION_NULL_OK,0,0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, lMargin1String), TK_OPTION_NULL_OK,0,0},
{TK_OPTION_STRING, "-lmargin2", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, lMargin2String), TK_OPTION_NULL_OK,0,0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, lMargin2String), TK_OPTION_NULL_OK,0,0},
{TK_OPTION_BORDER, "-lmargincolor", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, lMarginColor), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, lMarginColor), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-offset", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, offsetString), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, offsetString), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-overstrike", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, overstrikeString),
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, overstrikeString),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_COLOR, "-overstrikefg", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, overstrikeColor),
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, overstrikeColor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-relief", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, reliefString), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, reliefString), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-rmargin", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, rMarginString), TK_OPTION_NULL_OK, 0,0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, rMarginString), TK_OPTION_NULL_OK, 0,0},
{TK_OPTION_BORDER, "-rmargincolor", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, rMarginColor), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, rMarginColor), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_BORDER, "-selectbackground", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, selBorder), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, selBorder), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_COLOR, "-selectforeground", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, selFgColor), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, selFgColor), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING, "-spacing1", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, spacing1String), TK_OPTION_NULL_OK,0,0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, spacing1String), TK_OPTION_NULL_OK,0,0},
{TK_OPTION_STRING, "-spacing2", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, spacing2String), TK_OPTION_NULL_OK,0,0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, spacing2String), TK_OPTION_NULL_OK,0,0},
{TK_OPTION_STRING, "-spacing3", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, spacing3String), TK_OPTION_NULL_OK,0,0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, spacing3String), TK_OPTION_NULL_OK,0,0},
{TK_OPTION_STRING, "-tabs", NULL, NULL,
- NULL, Tk_Offset(TkTextTag, tabStringPtr), -1, TK_OPTION_NULL_OK, 0, 0},
+ NULL, offsetof(TkTextTag, tabStringPtr), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING_TABLE, "-tabstyle", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, tabStyle),
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, tabStyle),
TK_OPTION_NULL_OK, tabStyleStrings, 0},
{TK_OPTION_STRING, "-underline", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, underlineString),
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, underlineString),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_COLOR, "-underlinefg", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, underlineColor),
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, underlineColor),
TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_STRING_TABLE, "-wrap", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextTag, wrapMode),
+ NULL, TCL_INDEX_NONE, offsetof(TkTextTag, wrapMode),
TK_OPTION_NULL_OK, wrapStrings, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0}
};
@@ -343,7 +343,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;
@@ -357,12 +357,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);
@@ -374,7 +374,7 @@ TkTextTagCmd(
} else {
int result = TCL_OK;
- 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;
}
@@ -1108,10 +1108,10 @@ FindTag(
Tcl_Obj *tagName) /* Name of desired tag. */
{
Tcl_HashEntry *hPtr;
- int len;
+ TkSizeT len;
const char *str;
- str = Tcl_GetStringFromObj(tagName, &len);
+ str = TkGetStringFromObj(tagName, &len);
if (len == 3 && !strcmp(str, "sel")) {
return textPtr->selTagPtr;
}
@@ -1457,9 +1457,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;
@@ -1540,7 +1540,8 @@ TkTextPickCurrent(
TkTextTag **copyArrayPtr = NULL;
/* Initialization needed to prevent compiler
* warning. */
- int numOldTags, numNewTags, i, j, size, nearby;
+ int numOldTags, numNewTags, i, j, nearby;
+ size_t size;
XEvent event;
/*
diff --git a/generic/tkTextWind.c b/generic/tkTextWind.c
index c9f34e4..89f7f2a 100644
--- a/generic/tkTextWind.c
+++ b/generic/tkTextWind.c
@@ -28,15 +28,15 @@ static void EmbWinLostContentProc(ClientData clientData,
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:
@@ -57,7 +57,7 @@ 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,
+ TkSizeT offset, int maxX, TkSizeT maxChars,int noCharsYet,
TkWrapMode wrapMode, TkTextDispChunk *chunkPtr);
static void EmbWinStructureProc(ClientData clientData,
XEvent *eventPtr);
@@ -99,18 +99,18 @@ typedef enum {
static const Tk_OptionSpec optionSpecs[] = {
{TK_OPTION_STRING_TABLE, "-align", NULL, NULL,
- "center", -1, Tk_Offset(TkTextEmbWindow, align),
+ "center", TCL_INDEX_NONE, offsetof(TkTextEmbWindow, align),
0, alignStrings, 0},
{TK_OPTION_STRING, "-create", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextEmbWindow, create), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextEmbWindow, create), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_PIXELS, "-padx", NULL, NULL,
- "0", -1, Tk_Offset(TkTextEmbWindow, padX), 0, 0, 0},
+ "0", TCL_INDEX_NONE, offsetof(TkTextEmbWindow, padX), 0, 0, 0},
{TK_OPTION_PIXELS, "-pady", NULL, NULL,
- "0", -1, Tk_Offset(TkTextEmbWindow, padY), 0, 0, 0},
+ "0", TCL_INDEX_NONE, offsetof(TkTextEmbWindow, padY), 0, 0, 0},
{TK_OPTION_BOOLEAN, "-stretch", NULL, NULL,
- "0", -1, Tk_Offset(TkTextEmbWindow, stretch), 0, 0, 0},
+ "0", TCL_INDEX_NONE, offsetof(TkTextEmbWindow, stretch), 0, 0, 0},
{TK_OPTION_WINDOW, "-window", NULL, NULL,
- NULL, -1, Tk_Offset(TkTextEmbWindow, tkwin), TK_OPTION_NULL_OK, 0, 0},
+ NULL, TCL_INDEX_NONE, offsetof(TkTextEmbWindow, tkwin), TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0}
};
@@ -190,7 +190,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;
@@ -231,7 +231,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) {
@@ -401,7 +401,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;
@@ -817,11 +817,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
+ TkSizeT 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(TkSizeT), /* Chunk must not include more than this many
* characters. */
int noCharsYet, /* Non-zero means no characters have been
* assigned to this line yet. */
@@ -1053,7 +1053,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 %d", (int)ewPtr->size);
}
}
diff --git a/generic/tkTrig.c b/generic/tkTrig.c
index a2bf456..c0691a5 100644
--- a/generic/tkTrig.c
+++ b/generic/tkTrig.c
@@ -282,7 +282,6 @@ TkLineToArea(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
int
TkThickPolyLineToArea(
double *coordPtr, /* Points to an array of coordinates for the
@@ -440,7 +439,7 @@ TkPolygonToPoint(
* intersect a ray extending vertically
* upwards from the point to infinity. */
int count;
- register double *pPtr;
+ double *pPtr;
/*
* Iterate through all of the edges in the polygon, updating bestDist and
@@ -588,7 +587,7 @@ TkPolygonToArea(
* polygon: x0, y0, x1, y1, ... The polygon
* may be self-intersecting. */
int numPoints, /* Total number of points at *polyPtr. */
- register double *rectPtr) /* Points to coords for rectangle, in the
+ double *rectPtr) /* Points to coords for rectangle, in the
* order x1, y1, x2, y2. X1 and y1 must be
* lower-left corner. */
{
@@ -596,7 +595,7 @@ TkPolygonToArea(
* outside, 1 means inside, won't ever be
* 0). */
int count;
- register double *pPtr;
+ double *pPtr;
/*
* Iterate over all of the edges of the polygon and test them against the
@@ -652,7 +651,6 @@ TkPolygonToArea(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
double
TkOvalToPoint(
double ovalPtr[4], /* Pointer to array of four coordinates (x1,
@@ -751,11 +749,11 @@ TkOvalToPoint(
int
TkOvalToArea(
- register double *ovalPtr, /* Points to coordinates defining the
+ double *ovalPtr, /* Points to coordinates defining the
* bounding rectangle for the oval: x1, y1,
* x2, y2. X1 must be less than x2 and y1 less
* than y2. */
- register double *rectPtr) /* Points to coords for rectangle, in the
+ double *rectPtr) /* Points to coords for rectangle, in the
* order x1, y1, x2, y2. X1 and y1 must be
* lower-left corner. */
{
@@ -867,10 +865,9 @@ TkOvalToArea(
*--------------------------------------------------------------
*/
- /* ARGSUSED */
void
TkIncludePoint(
- register Tk_Item *itemPtr, /* Item whose bounding box is being
+ Tk_Item *itemPtr, /* Item whose bounding box is being
* calculated. */
double *pointPtr) /* Address of two doubles giving x and y
* coordinates of point. */
@@ -919,7 +916,7 @@ TkBezierScreenPoints(
double control[], /* Array of coordinates for four control
* points: x0, y0, x1, y1, ... x3 y3. */
int numSteps, /* Number of curve points to generate. */
- register XPoint *xPointPtr) /* Where to put new points. */
+ XPoint *xPointPtr) /* Where to put new points. */
{
int i;
double u, u2, u3, t, t2, t3;
@@ -965,7 +962,7 @@ TkBezierPoints(
double control[], /* Array of coordinates for four control
* points: x0, y0, x1, y1, ... x3 y3. */
int numSteps, /* Number of curve points to generate. */
- register double *coordPtr) /* Where to put new points. */
+ double *coordPtr) /* Where to put new points. */
{
int i;
double u, u2, u3, t, t2, t3;
diff --git a/generic/tkUndo.c b/generic/tkUndo.c
index c66905d..7494332 100644
--- a/generic/tkUndo.c
+++ b/generic/tkUndo.c
@@ -94,7 +94,7 @@ TkUndoInsertSeparator(
TkUndoAtom *separator;
if (*stack!=NULL && (*stack)->type!=TK_UNDO_SEPARATOR) {
- separator = ckalloc(sizeof(TkUndoAtom));
+ separator = (TkUndoAtom *)ckalloc(sizeof(TkUndoAtom));
separator->type = TK_UNDO_SEPARATOR;
TkUndoPushStack(stack,separator);
return 1;
@@ -181,7 +181,7 @@ TkUndoPushAction(
{
TkUndoAtom *atom;
- atom = ckalloc(sizeof(TkUndoAtom));
+ atom = (TkUndoAtom *)ckalloc(sizeof(TkUndoAtom));
atom->type = TK_UNDO_ACTION;
atom->apply = apply;
atom->revert = revert;
@@ -237,7 +237,7 @@ TkUndoMakeCmdSubAtom(
Tcl_Panic("NULL command and actionScript in TkUndoMakeCmdSubAtom");
}
- atom = ckalloc(sizeof(TkUndoSubAtom));
+ atom = (TkUndoSubAtom *)ckalloc(sizeof(TkUndoSubAtom));
atom->command = command;
atom->funcPtr = NULL;
atom->clientData = NULL;
@@ -299,7 +299,7 @@ TkUndoMakeSubAtom(
Tcl_Panic("NULL funcPtr in TkUndoMakeSubAtom");
}
- atom = ckalloc(sizeof(TkUndoSubAtom));
+ atom = (TkUndoSubAtom *)ckalloc(sizeof(TkUndoSubAtom));
atom->command = NULL;
atom->funcPtr = funcPtr;
atom->clientData = clientData;
@@ -341,7 +341,7 @@ TkUndoInitStack(
{
TkUndoRedoStack *stack; /* An Undo/Redo stack */
- stack = ckalloc(sizeof(TkUndoRedoStack));
+ stack = (TkUndoRedoStack *)ckalloc(sizeof(TkUndoRedoStack));
stack->undoStack = NULL;
stack->redoStack = NULL;
stack->interp = interp;
diff --git a/generic/tkUtil.c b/generic/tkUtil.c
index 00ac7be..0541830 100644
--- a/generic/tkUtil.c
+++ b/generic/tkUtil.c
@@ -48,17 +48,16 @@ int
TkStateParseProc(
ClientData clientData, /* some flags.*/
Tcl_Interp *interp, /* Used for reporting errors. */
- Tk_Window tkwin, /* Window containing canvas widget. */
+ TCL_UNUSED(Tk_Window), /* Window containing canvas widget. */
const char *value, /* Value of option. */
char *widgRec, /* Pointer to record for item. */
- int offset) /* Offset into item. */
+ TkSizeT offset) /* Offset into item. */
{
int c;
int flags = PTR2INT(clientData);
size_t length;
Tcl_Obj *msgObj;
-
- register Tk_State *statePtr = (Tk_State *) (widgRec + offset);
+ Tk_State *statePtr = (Tk_State *) (widgRec + offset);
if (value == NULL || *value == 0) {
*statePtr = TK_STATE_NULL;
@@ -126,15 +125,15 @@ TkStateParseProc(
const char *
TkStatePrintProc(
- ClientData clientData, /* Ignored. */
- Tk_Window tkwin, /* Window containing canvas widget. */
+ TCL_UNUSED(void *), /* Ignored. */
+ TCL_UNUSED(Tk_Window), /* Window containing canvas widget. */
char *widgRec, /* Pointer to record for item. */
- int offset, /* Offset into item. */
- Tcl_FreeProc **freeProcPtr) /* Pointer to variable to fill in with
+ TkSizeT offset, /* Offset into item. */
+ TCL_UNUSED(Tcl_FreeProc **)) /* Pointer to variable to fill in with
* information about how to reclaim storage
* for return string. */
{
- register Tk_State *statePtr = (Tk_State *) (widgRec + offset);
+ Tk_State *statePtr = (Tk_State *) (widgRec + offset);
switch (*statePtr) {
case TK_STATE_NORMAL:
@@ -170,17 +169,16 @@ TkStatePrintProc(
int
TkOrientParseProc(
- ClientData clientData, /* some flags.*/
+ TCL_UNUSED(void *), /* some flags.*/
Tcl_Interp *interp, /* Used for reporting errors. */
- Tk_Window tkwin, /* Window containing canvas widget. */
+ TCL_UNUSED(Tk_Window), /* Window containing canvas widget. */
const char *value, /* Value of option. */
char *widgRec, /* Pointer to record for item. */
- int offset) /* Offset into item. */
+ TkSizeT offset) /* Offset into item. */
{
int c;
size_t length;
-
- register int *orientPtr = (int *) (widgRec + offset);
+ int *orientPtr = (int *) (widgRec + offset);
if (value == NULL || *value == 0) {
*orientPtr = 0;
@@ -229,15 +227,15 @@ TkOrientParseProc(
const char *
TkOrientPrintProc(
- ClientData clientData, /* Ignored. */
- Tk_Window tkwin, /* Window containing canvas widget. */
+ TCL_UNUSED(void *), /* Ignored. */
+ TCL_UNUSED(Tk_Window), /* Window containing canvas widget. */
char *widgRec, /* Pointer to record for item. */
- int offset, /* Offset into item. */
- Tcl_FreeProc **freeProcPtr) /* Pointer to variable to fill in with
+ TkSizeT offset, /* Offset into item. */
+ TCL_UNUSED(Tcl_FreeProc **)) /* Pointer to variable to fill in with
* information about how to reclaim storage
* for return string. */
{
- register int *statePtr = (int *) (widgRec + offset);
+ int *statePtr = (int *) (widgRec + offset);
if (*statePtr) {
return "vertical";
@@ -264,7 +262,7 @@ TkOffsetParseProc(
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 */
+ TkSizeT offset) /* Offset of tile in record */
{
Tk_TSOffset *offsetPtr = (Tk_TSOffset *) (widgRec + offset);
Tk_TSOffset tsoffset;
@@ -411,10 +409,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 */
+ TkSizeT offset, /* Offset of tile in record */
Tcl_FreeProc **freeProcPtr) /* not used */
{
Tk_TSOffset *offsetPtr = (Tk_TSOffset *) (widgRec + offset);
@@ -424,7 +422,7 @@ TkOffsetPrintProc(
if (offsetPtr->flags >= INT_MAX) {
return "end";
}
- p = ckalloc(32);
+ p = (char *)ckalloc(32);
sprintf(p, "%d", offsetPtr->flags & ~TK_OFFSET_INDEX);
*freeProcPtr = TCL_DYNAMIC;
return p;
@@ -454,7 +452,7 @@ TkOffsetPrintProc(
return "se";
}
}
- q = p = ckalloc(32);
+ q = p = (char *)ckalloc(32);
if (offsetPtr->flags & TK_OFFSET_RELATIVE) {
*q++ = '#';
}
@@ -481,7 +479,7 @@ TkPixelParseProc(
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 */
+ TkSizeT offset) /* Offset of tile in record */
{
double *doublePtr = (double *) (widgRec + offset);
int result;
@@ -512,14 +510,14 @@ TkPixelParseProc(
const char *
TkPixelPrintProc(
- ClientData clientData, /* not used */
- Tk_Window tkwin, /* not used */
+ TCL_UNUSED(void *), /* not used */
+ TCL_UNUSED(Tk_Window), /* not used */
char *widgRec, /* Widget structure record */
- int offset, /* Offset of tile in record */
+ TkSizeT offset, /* Offset of tile in record */
Tcl_FreeProc **freeProcPtr) /* not used */
{
double *doublePtr = (double *) (widgRec + offset);
- char *p = ckalloc(24);
+ char *p = (char *)ckalloc(24);
Tcl_PrintDouble(NULL, *doublePtr, p);
*freeProcPtr = TCL_DYNAMIC;
@@ -669,7 +667,7 @@ Tk_GetScrollInfo(
if (argc != 5) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"wrong # args: should be \"%s %s %s\"",
- argv[0], argv[1], "scroll number units|pages"));
+ argv[0], argv[1], "scroll number pages|units"));
Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL);
return TK_SCROLL_ERROR;
}
@@ -685,7 +683,7 @@ Tk_GetScrollInfo(
}
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "bad argument \"%s\": must be units or pages", argv[4]));
+ "bad argument \"%s\": must be pages or units", argv[4]));
Tcl_SetErrorCode(interp, "TK", "VALUE", "SCROLL_UNITS", NULL);
return TK_SCROLL_ERROR;
}
@@ -730,8 +728,8 @@ Tk_GetScrollInfoObj(
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;
+ TkSizeT length;
+ const char *arg = TkGetStringFromObj(objv[2], &length);
#define ArgPfxEq(str) \
((arg[0] == str[0]) && !strncmp(arg, str, length))
@@ -747,15 +745,14 @@ Tk_GetScrollInfoObj(
return TK_SCROLL_MOVETO;
} else if (ArgPfxEq("scroll")) {
if (objc != 5) {
- Tcl_WrongNumArgs(interp, 2, objv, "scroll number units|pages");
+ Tcl_WrongNumArgs(interp, 2, objv, "scroll number pages|units");
return TK_SCROLL_ERROR;
}
if (Tcl_GetIntFromObj(interp, objv[3], intPtr) != TCL_OK) {
return TK_SCROLL_ERROR;
}
- arg = Tcl_GetString(objv[4]);
- length = objv[4]->length;
+ arg = TkGetStringFromObj(objv[4], &length);
if (ArgPfxEq("pages")) {
return TK_SCROLL_PAGES;
} else if (ArgPfxEq("units")) {
@@ -763,7 +760,7 @@ Tk_GetScrollInfoObj(
}
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "bad argument \"%s\": must be units or pages", arg));
+ "bad argument \"%s\": must be pages or units", arg));
Tcl_SetErrorCode(interp, "TK", "VALUE", "SCROLL_UNITS", NULL);
return TK_SCROLL_ERROR;
}
@@ -1088,7 +1085,7 @@ TkBackgroundEvalObjv(
Tcl_Command
TkMakeEnsemble(
Tcl_Interp *interp,
- const char *namespace,
+ const char *namesp,
const char *name,
ClientData clientData,
const TkEnsemble map[])
@@ -1105,11 +1102,11 @@ TkMakeEnsemble(
Tcl_DStringInit(&ds);
- namespacePtr = Tcl_FindNamespace(interp, namespace, NULL, 0);
+ namespacePtr = Tcl_FindNamespace(interp, namesp, NULL, 0);
if (namespacePtr == NULL) {
- namespacePtr = Tcl_CreateNamespace(interp, namespace, NULL, NULL);
+ namespacePtr = Tcl_CreateNamespace(interp, namesp, NULL, NULL);
if (namespacePtr == NULL) {
- Tcl_Panic("failed to create namespace \"%s\"", namespace);
+ Tcl_Panic("failed to create namespace \"%s\"", namesp);
}
}
@@ -1125,8 +1122,8 @@ TkMakeEnsemble(
}
Tcl_DStringSetLength(&ds, 0);
- Tcl_DStringAppend(&ds, namespace, -1);
- if (!(strlen(namespace) == 2 && namespace[1] == ':')) {
+ Tcl_DStringAppend(&ds, namesp, -1);
+ if (!(strlen(namesp) == 2 && namesp[1] == ':')) {
Tcl_DStringAppend(&ds, "::", -1);
}
Tcl_DStringAppend(&ds, name, -1);
@@ -1160,7 +1157,7 @@ TkMakeEnsemble(
/*
*----------------------------------------------------------------------
*
- * TkSendVirtualEvent --
+ * Tk_SendVirtualEvent --
*
* Send a virtual event notification to the specified target window.
* Equivalent to:
@@ -1173,7 +1170,7 @@ TkMakeEnsemble(
*/
void
-TkSendVirtualEvent(
+Tk_SendVirtualEvent(
Tk_Window target,
const char *eventName,
Tcl_Obj *detail)
@@ -1212,7 +1209,7 @@ TkSendVirtualEvent(
*---------------------------------------------------------------------------
*/
-int
+size_t
TkUtfToUniChar(
const char *src, /* The UTF-8 string. */
int *chPtr) /* Filled with the Unicode value represented by
@@ -1220,12 +1217,17 @@ TkUtfToUniChar(
{
Tcl_UniChar uniChar = 0;
- int len = Tcl_UtfToUniChar(src, &uniChar);
- if ((sizeof(Tcl_UniChar) == 2) && ((uniChar & 0xFC00) == 0xD800)) {
+ size_t len = Tcl_UtfToUniChar(src, &uniChar);
+ if ((sizeof(Tcl_UniChar) == 2)
+ && ((uniChar & 0xFC00) == 0xD800)
+#if TCL_MAJOR_VERSION > 8
+ && (len == 1)
+#endif
+ ) {
Tcl_UniChar low = uniChar;
/* This can only happen if Tcl is compiled with TCL_UTF_MAX=4,
* or when a high surrogate character is detected in UTF-8 form */
- int len2 = Tcl_UtfToUniChar(src+len, &low);
+ size_t len2 = Tcl_UtfToUniChar(src+len, &low);
if ((low & 0xFC00) == 0xDC00) {
*chPtr = (((uniChar & 0x3FF) << 10) | (low & 0x3FF)) + 0x10000;
return len + len2;
@@ -1254,7 +1256,7 @@ TkUtfToUniChar(
*---------------------------------------------------------------------------
*/
-int TkUniCharToUtf(int ch, char *buf)
+size_t TkUniCharToUtf(int ch, char *buf)
{
if ((sizeof(Tcl_UniChar) == 2) && (((unsigned)(ch - 0x10000) <= 0xFFFFF))) {
/* Spit out a 4-byte UTF-8 character or 2 x 3-byte UTF-8 characters, depending on Tcl
@@ -1302,37 +1304,19 @@ TkUtfPrev(
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.
- *
- *---------------------------------------------------------------------------
- */
+#endif
-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;
+#if TCL_MAJOR_VERSION > 8
+unsigned char *
+TkGetByteArrayFromObj(
+ Tcl_Obj *objPtr,
+ size_t *lengthPtr
+) {
+ unsigned char *result = Tcl_GetByteArrayFromObj(objPtr, NULL);
+ *lengthPtr = *(size_t *) objPtr->internalRep.twoPtrValue.ptr1;
+ return result;
}
-#endif
+#endif /* TCL_MAJOR_VERSION > 8 */
/*
* Local Variables:
diff --git a/generic/tkVisual.c b/generic/tkVisual.c
index 567c552..04afcbc 100644
--- a/generic/tkVisual.c
+++ b/generic/tkVisual.c
@@ -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
@@ -96,10 +96,10 @@ Tk_GetVisual(
* Tk_FreeColormap. */
{
Tk_Window tkwin2;
- XVisualInfo template, *visInfoList, *bestPtr;
+ XVisualInfo templ, *visInfoList, *bestPtr;
long mask;
Visual *visual;
- ptrdiff_t length;
+ size_t length;
int c, numVisuals, prio, bestPrio, i;
const char *p;
const VisualDictionary *dictPtr;
@@ -137,20 +137,20 @@ Tk_GetVisual(
for (cmapPtr = dispPtr->cmapPtr; cmapPtr != NULL;
cmapPtr = cmapPtr->nextPtr) {
if (cmapPtr->colormap == *colormapPtr) {
- cmapPtr->refCount += 1;
+ cmapPtr->refCount++;
break;
}
}
}
return visual;
}
- template.depth = Tk_Depth(tkwin2);
- template.c_class = visual->c_class;
- template.red_mask = visual->red_mask;
- template.green_mask = visual->green_mask;
- template.blue_mask = visual->blue_mask;
- template.colormap_size = visual->map_entries;
- template.bits_per_rgb = visual->bits_per_rgb;
+ templ.depth = Tk_Depth(tkwin2);
+ templ.c_class = visual->c_class;
+ templ.red_mask = visual->red_mask;
+ templ.green_mask = visual->green_mask;
+ templ.blue_mask = visual->blue_mask;
+ templ.colormap_size = visual->map_entries;
+ templ.bits_per_rgb = visual->bits_per_rgb;
mask = VisualDepthMask|VisualClassMask|VisualRedMaskMask
|VisualGreenMaskMask|VisualBlueMaskMask|VisualColormapSizeMask
|VisualBitsPerRGBMask;
@@ -178,7 +178,7 @@ Tk_GetVisual(
Tcl_SetErrorCode(interp, "TK", "VALUE", "VISUALID", NULL);
return NULL;
}
- template.visualid = visualId;
+ templ.visualid = visualId;
mask = VisualIDMask;
} else {
/*
@@ -192,21 +192,20 @@ Tk_GetVisual(
}
}
length = p - string;
- template.c_class = -1;
- for (dictPtr = visualNames; dictPtr->name != NULL; dictPtr++) {
+ templ.c_class = -1;
+ for (dictPtr = visualNames; dictPtr->minLength; dictPtr++) {
if ((dictPtr->name[0] == c) && (length >= dictPtr->minLength)
- && (strncmp(string, dictPtr->name,
- (size_t) length) == 0)) {
- template.c_class = dictPtr->c_class;
+ && (strncmp(string, dictPtr->name, length) == 0)) {
+ templ.c_class = dictPtr->c_class;
break;
}
}
- if (template.c_class == -1) {
+ if (templ.c_class == -1) {
Tcl_Obj *msgObj = Tcl_ObjPrintf(
"unknown or ambiguous visual name \"%s\": class must be ",
string);
- for (dictPtr = visualNames; dictPtr->name != NULL; dictPtr++) {
+ for (dictPtr = visualNames; dictPtr->minLength; dictPtr++) {
Tcl_AppendPrintfToObj(msgObj, "%s, ", dictPtr->name);
}
Tcl_AppendToObj(msgObj, "or default", -1);
@@ -218,8 +217,8 @@ Tk_GetVisual(
p++;
}
if (*p == 0) {
- template.depth = 10000;
- } else if (Tcl_GetInt(interp, p, &template.depth) != TCL_OK) {
+ templ.depth = 10000;
+ } else if (Tcl_GetInt(interp, p, &templ.depth) != TCL_OK) {
return NULL;
}
if (c == 'b') {
@@ -234,9 +233,9 @@ Tk_GetVisual(
* an error if there are none that match.
*/
- template.screen = Tk_ScreenNumber(tkwin);
+ templ.screen = Tk_ScreenNumber(tkwin);
mask |= VisualScreenMask;
- visInfoList = XGetVisualInfo(Tk_Display(tkwin), mask, &template,
+ visInfoList = XGetVisualInfo(Tk_Display(tkwin), mask, &templ,
&numVisuals);
if (visInfoList == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
@@ -286,11 +285,11 @@ Tk_GetVisual(
goto newBest;
}
if (visInfoList[i].depth < bestPtr->depth) {
- if (visInfoList[i].depth >= template.depth) {
+ if (visInfoList[i].depth >= templ.depth) {
goto newBest;
}
} else if (visInfoList[i].depth > bestPtr->depth) {
- if (bestPtr->depth < template.depth) {
+ if (bestPtr->depth < templ.depth) {
goto newBest;
}
} else {
@@ -324,11 +323,11 @@ Tk_GetVisual(
cmapPtr = cmapPtr->nextPtr) {
if (cmapPtr->shareable && (cmapPtr->visual == visual)) {
*colormapPtr = cmapPtr->colormap;
- cmapPtr->refCount += 1;
+ cmapPtr->refCount++;
goto done;
}
}
- cmapPtr = ckalloc(sizeof(TkColormap));
+ cmapPtr = (TkColormap *)ckalloc(sizeof(TkColormap));
cmapPtr->colormap = XCreateColormap(Tk_Display(tkwin),
RootWindowOfScreen(Tk_Screen(tkwin)), visual,
AllocNone);
@@ -383,7 +382,7 @@ Tk_GetColormap(
*/
if (strcmp(string, "new") == 0) {
- cmapPtr = ckalloc(sizeof(TkColormap));
+ cmapPtr = (TkColormap *)ckalloc(sizeof(TkColormap));
cmapPtr->colormap = XCreateColormap(Tk_Display(tkwin),
RootWindowOfScreen(Tk_Screen(tkwin)), Tk_Visual(tkwin),
AllocNone);
@@ -427,7 +426,7 @@ Tk_GetColormap(
for (cmapPtr = dispPtr->cmapPtr; cmapPtr != NULL;
cmapPtr = cmapPtr->nextPtr) {
if (cmapPtr->colormap == colormap) {
- cmapPtr->refCount += 1;
+ cmapPtr->refCount++;
}
}
return colormap;
@@ -476,8 +475,7 @@ Tk_FreeColormap(
for (prevPtr = NULL, cmapPtr = dispPtr->cmapPtr; cmapPtr != NULL;
prevPtr = cmapPtr, cmapPtr = cmapPtr->nextPtr) {
if (cmapPtr->colormap == colormap) {
- cmapPtr->refCount -= 1;
- if (cmapPtr->refCount == 0) {
+ if (cmapPtr->refCount-- <= 1) {
XFreeColormap(display, colormap);
if (prevPtr == NULL) {
dispPtr->cmapPtr = cmapPtr->nextPtr;
@@ -534,7 +532,7 @@ Tk_PreserveColormap(
for (cmapPtr = dispPtr->cmapPtr; cmapPtr != NULL;
cmapPtr = cmapPtr->nextPtr) {
if (cmapPtr->colormap == colormap) {
- cmapPtr->refCount += 1;
+ cmapPtr->refCount++;
return;
}
}
diff --git a/generic/tkWindow.c b/generic/tkWindow.c
index 92c4018..eb8e928 100644
--- a/generic/tkWindow.c
+++ b/generic/tkWindow.c
@@ -239,8 +239,6 @@ TkCloseDisplay(
{
TkClipCleanup(dispPtr);
- TkpCancelWarp(dispPtr);
-
if (dispPtr->name != NULL) {
ckfree(dispPtr->name);
}
@@ -316,10 +314,10 @@ CreateTopLevelWindow(
* parent. */
unsigned int flags) /* Additional flags to set on the window. */
{
- register TkWindow *winPtr;
- register TkDisplay *dispPtr;
+ TkWindow *winPtr;
+ TkDisplay *dispPtr;
int screenId;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (!tsdPtr->initialized) {
@@ -336,9 +334,11 @@ CreateTopLevelWindow(
* Create built-in photo image formats.
*/
+ Tk_CreatePhotoImageFormat(&tkImgFmtDefault);
Tk_CreatePhotoImageFormat(&tkImgFmtGIF);
Tk_CreatePhotoImageFormat(&tkImgFmtPNG);
Tk_CreatePhotoImageFormat(&tkImgFmtPPM);
+ Tk_CreatePhotoImageFormat(&tkImgFmtSVGnano);
}
if ((parent != NULL) && (screenName != NULL) && (screenName[0] == '\0')) {
@@ -357,9 +357,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;
/*
@@ -419,11 +417,11 @@ GetScreen(
* DISPLAY envariable. */
int *screenPtr) /* Where to store screen number. */
{
- register TkDisplay *dispPtr;
+ TkDisplay *dispPtr;
const char *p;
int screenId;
size_t length;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -487,7 +485,7 @@ GetScreen(
Tcl_InitHashTable(&dispPtr->winTable, TCL_ONE_WORD_KEYS);
- dispPtr->name = ckalloc(length + 1);
+ dispPtr->name = (char *)ckalloc(length + 1);
strncpy(dispPtr->name, screenName, length);
dispPtr->name[length] = '\0';
break;
@@ -530,7 +528,7 @@ TkGetDisplay(
Display *display) /* X's display pointer */
{
TkDisplay *dispPtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
for (dispPtr = tsdPtr->displayList; dispPtr != NULL;
@@ -563,7 +561,7 @@ TkGetDisplay(
TkDisplay *
TkGetDisplayList(void)
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
return tsdPtr->displayList;
@@ -590,7 +588,7 @@ TkGetDisplayList(void)
TkMainInfo *
TkGetMainInfoList(void)
{
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
return tsdPtr->mainWindowList;
@@ -620,7 +618,7 @@ TkAllocWindow(
* inherit visual information. NULL means use
* screen defaults instead of inheriting. */
{
- register TkWindow *winPtr = ckalloc(sizeof(TkWindow));
+ TkWindow *winPtr = (TkWindow *)ckalloc(sizeof(TkWindow));
winPtr->display = dispPtr->display;
winPtr->dispPtr = dispPtr;
@@ -654,10 +652,8 @@ 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;
@@ -701,7 +697,7 @@ TkAllocWindow(
static int
NameWindow(
Tcl_Interp *interp, /* Interpreter to use for error reporting. */
- register TkWindow *winPtr, /* Window that is to be named and inserted. */
+ TkWindow *winPtr, /* Window that is to be named and inserted. */
TkWindow *parentPtr, /* Pointer to logical parent for winPtr (used
* for naming, options, etc.). */
const char *name) /* Name for winPtr; must be unique among
@@ -771,7 +767,7 @@ NameWindow(
if ((length1 + length2 + 2) <= FIXED_SIZE) {
pathName = staticSpace;
} else {
- pathName = ckalloc(length1 + length2 + 2);
+ pathName = (char *)ckalloc(length1 + length2 + 2);
}
if (length1 == 1) {
pathName[0] = '.';
@@ -793,7 +789,7 @@ NameWindow(
return TCL_ERROR;
}
Tcl_SetHashValue(hPtr, winPtr);
- winPtr->pathName = Tcl_GetHashKey(&parentPtr->mainPtr->nameTable, hPtr);
+ winPtr->pathName = (char *)Tcl_GetHashKey(&parentPtr->mainPtr->nameTable, hPtr);
return TCL_OK;
}
@@ -832,11 +828,11 @@ TkCreateMainWindow(
Tk_Window tkwin;
int dummy, isSafe;
Tcl_HashEntry *hPtr;
- register TkMainInfo *mainPtr;
- register TkWindow *winPtr;
- register const TkCmd *cmdPtr;
+ TkMainInfo *mainPtr;
+ TkWindow *winPtr;
+ const TkCmd *cmdPtr;
ClientData clientData;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
@@ -864,7 +860,7 @@ TkCreateMainWindow(
*/
winPtr = (TkWindow *) tkwin;
- mainPtr = ckalloc(sizeof(TkMainInfo));
+ mainPtr = (TkMainInfo *)ckalloc(sizeof(TkMainInfo));
mainPtr->winPtr = winPtr;
mainPtr->refCount = 1;
mainPtr->interp = interp;
@@ -897,7 +893,7 @@ TkCreateMainWindow(
winPtr->mainPtr = mainPtr;
hPtr = Tcl_CreateHashEntry(&mainPtr->nameTable, ".", &dummy);
Tcl_SetHashValue(hPtr, winPtr);
- winPtr->pathName = Tcl_GetHashKey(&mainPtr->nameTable, hPtr);
+ winPtr->pathName = (char *)Tcl_GetHashKey(&mainPtr->nameTable, hPtr);
Tcl_InitHashTable(&mainPtr->busyTable, TCL_ONE_WORD_KEYS);
/*
@@ -950,7 +946,7 @@ TkCreateMainWindow(
}
/*
- * Set variables for the intepreter.
+ * Set variables for the interpreter.
*/
Tcl_SetVar2(interp, "tk_patchLevel", NULL, TK_PATCH_LEVEL, TCL_GLOBAL_ONLY);
@@ -1136,7 +1132,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
@@ -1146,16 +1142,16 @@ Tk_CreateWindowFromPath(
* the situation where the parent is ".".
*/
- p = strrchr(pathName, '.');
+ p = (char *)strrchr(pathName, '.');
if (p == NULL) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"bad window path name \"%s\"", pathName));
Tcl_SetErrorCode(interp, "TK", "VALUE", "WINDOW_PATH", NULL);
return NULL;
}
- numChars = (int) (p-pathName);
+ numChars = p-pathName;
if (numChars > FIXED_SPACE) {
- p = ckalloc(numChars + 1);
+ p = (char *)ckalloc(numChars + 1);
} else {
p = fixedSpace;
}
@@ -1163,7 +1159,7 @@ Tk_CreateWindowFromPath(
*p = '.';
p[1] = '\0';
} else {
- strncpy(p, pathName, (size_t) numChars);
+ strncpy(p, pathName, numChars);
p[numChars] = '\0';
}
@@ -1240,7 +1236,7 @@ Tk_DestroyWindow(
TkDisplay *dispPtr = winPtr->dispPtr;
XEvent event;
TkHalfdeadWindow *halfdeadPtr, *prev_halfdeadPtr;
- ThreadSpecificData *tsdPtr =
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
if (winPtr->flags & TK_ALREADY_DEAD) {
@@ -1263,7 +1259,7 @@ Tk_DestroyWindow(
(tsdPtr->halfdeadWindowList->winPtr == winPtr)) {
halfdeadPtr = tsdPtr->halfdeadWindowList;
} else {
- halfdeadPtr = ckalloc(sizeof(TkHalfdeadWindow));
+ halfdeadPtr = (TkHalfdeadWindow *)ckalloc(sizeof(TkHalfdeadWindow));
halfdeadPtr->flags = 0;
halfdeadPtr->winPtr = winPtr;
halfdeadPtr->nextPtr = tsdPtr->halfdeadWindowList;
@@ -1443,18 +1439,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);
}
@@ -1488,7 +1482,7 @@ Tk_DestroyWindow(
winPtr->mainPtr->deletionEpoch++;
}
if (winPtr->mainPtr->refCount-- <= 1) {
- register const TkCmd *cmdPtr;
+ const TkCmd *cmdPtr;
/*
* We just deleted the last window in the application. Delete the
@@ -1675,7 +1669,7 @@ void
Tk_MakeWindowExist(
Tk_Window tkwin) /* Token for window. */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
TkWindow *winPtr2;
Window parent;
Tcl_HashEntry *hPtr;
@@ -1784,7 +1778,7 @@ void
Tk_UnmapWindow(
Tk_Window tkwin) /* Token for window to unmap. */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
if (!(winPtr->flags & TK_MAPPED) || (winPtr->flags & TK_ALREADY_DEAD)) {
return;
@@ -1821,7 +1815,7 @@ Tk_ConfigureWindow(
* are to be used. */
XWindowChanges *valuePtr) /* New values. */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
if (valueMask & CWX) {
winPtr->changes.x = valuePtr->x;
@@ -1857,7 +1851,7 @@ Tk_MoveWindow(
Tk_Window tkwin, /* Window to move. */
int x, int y) /* New location for window (within parent). */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
winPtr->changes.x = x;
winPtr->changes.y = y;
@@ -1875,7 +1869,7 @@ Tk_ResizeWindow(
Tk_Window tkwin, /* Window to resize. */
int width, int height) /* New dimensions for window. */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
winPtr->changes.width = (unsigned) width;
winPtr->changes.height = (unsigned) height;
@@ -1895,7 +1889,7 @@ Tk_MoveResizeWindow(
int x, int y, /* New location for window (within parent). */
int width, int height) /* New dimensions for window. */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
winPtr->changes.x = x;
winPtr->changes.y = y;
@@ -1916,7 +1910,7 @@ Tk_SetWindowBorderWidth(
Tk_Window tkwin, /* Window to modify. */
int width) /* New border width for window. */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
winPtr->changes.border_width = width;
if (winPtr->window != None) {
@@ -1934,10 +1928,10 @@ Tk_ChangeWindowAttributes(
Tk_Window tkwin, /* Window to manipulate. */
unsigned long valueMask, /* OR'ed combination of bits, indicating which
* fields of *attsPtr are to be used. */
- register XSetWindowAttributes *attsPtr)
+ XSetWindowAttributes *attsPtr)
/* New values for some attributes. */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
if (valueMask & CWBackPixmap) {
winPtr->atts.background_pixmap = attsPtr->background_pixmap;
@@ -2000,7 +1994,7 @@ Tk_SetWindowBackground(
unsigned long pixel) /* Pixel value to use for window's
* background. */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
winPtr->atts.background_pixel = pixel;
@@ -2017,7 +2011,7 @@ Tk_SetWindowBackgroundPixmap(
Tk_Window tkwin, /* Window to manipulate. */
Pixmap pixmap) /* Pixmap to use for window's background. */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
winPtr->atts.background_pixmap = pixmap;
@@ -2035,7 +2029,7 @@ Tk_SetWindowBorder(
Tk_Window tkwin, /* Window to manipulate. */
unsigned long pixel) /* Pixel value to use for window's border. */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
winPtr->atts.border_pixel = pixel;
@@ -2052,7 +2046,7 @@ Tk_SetWindowBorderPixmap(
Tk_Window tkwin, /* Window to manipulate. */
Pixmap pixmap) /* Pixmap to use for window's border. */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
winPtr->atts.border_pixmap = pixmap;
@@ -2070,13 +2064,9 @@ Tk_DefineCursor(
Tk_Window tkwin, /* Window to manipulate. */
Tk_Cursor cursor) /* Cursor to use for window (may be None). */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
-#if defined(MAC_OSX_TK)
- winPtr->atts.cursor = (XCursor) cursor;
-#else
winPtr->atts.cursor = (Cursor) cursor;
-#endif
if (winPtr->window != None) {
XDefineCursor(winPtr->display, winPtr->window, winPtr->atts.cursor);
@@ -2097,7 +2087,7 @@ Tk_SetWindowColormap(
Tk_Window tkwin, /* Window to manipulate. */
Colormap colormap) /* Colormap to use for window. */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
winPtr->atts.colormap = colormap;
@@ -2139,7 +2129,7 @@ Tk_SetWindowVisual(
int depth, /* New depth for window. */
Colormap colormap) /* An appropriate colormap for the visual. */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
if (winPtr->window != None) {
/* Too late! */
@@ -2182,7 +2172,7 @@ Tk_SetWindowVisual(
void
TkDoConfigureNotify(
- register TkWindow *winPtr) /* Window whose configuration was just
+ TkWindow *winPtr) /* Window whose configuration was just
* changed. */
{
XEvent event;
@@ -2228,7 +2218,7 @@ Tk_SetClass(
Tk_Window tkwin, /* Token for window to assign class. */
const char *className) /* New class for tkwin. */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
winPtr->classUid = Tk_GetUid(className);
if (winPtr->flags & TK_WIN_MANAGED) {
@@ -2261,7 +2251,7 @@ Tk_SetClassProcs(
const Tk_ClassProcs *procs, /* Class procs structure. */
ClientData instanceData) /* Data to be passed to class functions. */
{
- register TkWindow *winPtr = (TkWindow *) tkwin;
+ TkWindow *winPtr = (TkWindow *) tkwin;
winPtr->classProcsPtr = procs;
winPtr->instanceData = instanceData;
@@ -2320,7 +2310,7 @@ Tk_NameToWindow(
}
return NULL;
}
- return Tcl_GetHashValue(hPtr);
+ return (Tk_Window)Tcl_GetHashValue(hPtr);
}
/*
@@ -2362,11 +2352,11 @@ Tk_IdToWindow(
return NULL;
}
- hPtr = Tcl_FindHashEntry(&dispPtr->winTable, (char *) window);
+ hPtr = Tcl_FindHashEntry(&dispPtr->winTable, window);
if (hPtr == NULL) {
return NULL;
}
- return Tcl_GetHashValue(hPtr);
+ return (Tk_Window)Tcl_GetHashValue(hPtr);
}
/*
@@ -2624,7 +2614,7 @@ Tk_MainWindow(
return NULL;
}
#endif
- tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ tsdPtr = (ThreadSpecificData *)Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
for (mainPtr = tsdPtr->mainWindowList; mainPtr != NULL;
mainPtr = mainPtr->nextPtr) {
@@ -2694,7 +2684,7 @@ Tk_GetNumMainWindows(void)
}
#endif
- tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ tsdPtr = (ThreadSpecificData *)Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
return tsdPtr->numMainWindows;
}
@@ -2702,7 +2692,7 @@ Tk_GetNumMainWindows(void)
/*
*----------------------------------------------------------------------
*
- * TkpAlwaysShowSelection --
+ * Tk_AlwaysShowSelection --
*
* Indicates whether text/entry widgets should always display
* their selection, regardless of window focus.
@@ -2720,7 +2710,7 @@ Tk_GetNumMainWindows(void)
*/
int
-TkpAlwaysShowSelection(
+Tk_AlwaysShowSelection(
Tk_Window tkwin) /* Window whose application is to be
* checked. */
{
@@ -2752,7 +2742,7 @@ DeleteWindowsExitProc(
{
TkDisplay *dispPtr, *nextPtr;
Tcl_Interp *interp;
- ThreadSpecificData *tsdPtr = clientData;
+ ThreadSpecificData *tsdPtr = (ThreadSpecificData *)clientData;
if (tsdPtr == NULL) {
return;
@@ -2834,7 +2824,7 @@ static HMODULE tkcygwindll = NULL;
/*
* Run Tk_MainEx from libtk8.?.dll
*
- * This function is only ever called from wish8.4.exe, the cygwin port of Tcl.
+ * This function is only ever called from wish8.?.exe, the cygwin port of Tcl.
* This means that the system encoding is utf-8, so we don't have to do any
* encoding conversions.
*/
@@ -2850,7 +2840,7 @@ TkCygwinMainEx(
Tcl_Interp *interp)
{
WCHAR name[MAX_PATH];
- int len;
+ size_t len;
void (*tkmainex)(int, char **, Tcl_AppInitProc *, Tcl_Interp *);
/* construct "<path>/libtk8.?.dll", from "<path>/tk8?.dll" */
@@ -3015,6 +3005,8 @@ CopyValue(
Tcl_Obj *objPtr,
void *dstPtr)
{
+ (void)dummy;
+
*(Tcl_Obj **)dstPtr = objPtr;
return 1;
}
@@ -3041,17 +3033,17 @@ Initialize(
const Tcl_ArgvInfo table[] = {
{TCL_ARGV_CONSTANT, "-sync", INT2PTR(1), &sync,
"Use synchronous mode for display server", NULL},
- {TCL_ARGV_FUNC, "-colormap", CopyValue, &colorMapObj,
+ {TCL_ARGV_FUNC, "-colormap", (void *)CopyValue, &colorMapObj,
"Colormap for main window", NULL},
- {TCL_ARGV_FUNC, "-display", CopyValue, &displayObj,
+ {TCL_ARGV_FUNC, "-display", (void *)CopyValue, &displayObj,
"Display to use", NULL},
- {TCL_ARGV_FUNC, "-geometry", CopyValue, &geometryObj,
+ {TCL_ARGV_FUNC, "-geometry", (void *)CopyValue, &geometryObj,
"Initial geometry for window", NULL},
- {TCL_ARGV_FUNC, "-name", CopyValue, &nameObj,
+ {TCL_ARGV_FUNC, "-name", (void *)CopyValue, &nameObj,
"Name to use for application", NULL},
- {TCL_ARGV_FUNC, "-visual", CopyValue, &visualObj,
+ {TCL_ARGV_FUNC, "-visual", (void *)CopyValue, &visualObj,
"Visual for main window", NULL},
- {TCL_ARGV_FUNC, "-use", CopyValue, &useObj,
+ {TCL_ARGV_FUNC, "-use", (void *)CopyValue, &useObj,
"Id of window in which to embed application", NULL},
TCL_ARGV_AUTO_REST, TCL_ARGV_AUTO_HELP, TCL_ARGV_TABLE_END
};
@@ -3060,17 +3052,23 @@ 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.
*/
TkRegisterObjTypes();
- tsdPtr = Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
+ tsdPtr = (ThreadSpecificData *)Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData));
/*
* We start by resetting the result because it might not be clean.
@@ -3098,7 +3096,7 @@ Initialize(
if (parent == NULL) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"no controlling parent interpreter", -1));
- Tcl_SetErrorCode(interp, "TK", "SAFE", "NO_MASTER", NULL);
+ Tcl_SetErrorCode(interp, "TK", "SAFE", "NO_PARENT", NULL);
return TCL_ERROR;
}
}
@@ -3170,7 +3168,7 @@ Initialize(
Tcl_SetVar2Ex(interp, "argv", NULL,
Tcl_NewListObj(objc-1, rest+1), TCL_GLOBAL_ONLY);
Tcl_SetVar2Ex(interp, "argc", NULL,
- Tcl_NewIntObj(objc-1), TCL_GLOBAL_ONLY);
+ Tcl_NewWideIntObj(objc-1), TCL_GLOBAL_ONLY);
ckfree(rest);
}
Tcl_DecrRefCount(parseList);
@@ -3202,8 +3200,8 @@ Initialize(
*/
{
- int numBytes;
- const char *bytes = Tcl_GetStringFromObj(nameObj, &numBytes);
+ TkSizeT numBytes;
+ const char *bytes = TkGetStringFromObj(nameObj, &numBytes);
classObj = Tcl_NewStringObj(bytes, numBytes);
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..fc48af9 100644
--- a/generic/ttk/ttkBlink.c
+++ b/generic/ttk/ttkBlink.c
@@ -34,9 +34,11 @@ typedef struct
/* CursorManagerDeleteProc --
* InterpDeleteProc for cursor manager.
*/
-static void CursorManagerDeleteProc(ClientData clientData, Tcl_Interp *interp)
+static void CursorManagerDeleteProc(ClientData clientData, Tcl_Interp *dummy)
{
CursorManager *cm = (CursorManager*)clientData;
+ (void)dummy;
+
if (cm->timer) {
Tcl_DeleteTimerHandler(cm->timer);
}
@@ -49,10 +51,10 @@ static void CursorManagerDeleteProc(ClientData clientData, Tcl_Interp *interp)
static CursorManager *GetCursorManager(Tcl_Interp *interp)
{
static const char *cm_key = "ttk::CursorManager";
- CursorManager *cm = Tcl_GetAssocData(interp, cm_key,0);
+ CursorManager *cm = (CursorManager *)Tcl_GetAssocData(interp, cm_key,0);
if (!cm) {
- cm = ckalloc(sizeof(*cm));
+ cm = (CursorManager *)ckalloc(sizeof(*cm));
cm->timer = 0;
cm->owner = 0;
cm->onTime = DEF_CURSOR_ON_TIME;
@@ -68,7 +70,7 @@ static CursorManager *GetCursorManager(Tcl_Interp *interp)
static void
CursorBlinkProc(ClientData clientData)
{
- CursorManager *cm = (CursorManager*)clientData;
+ CursorManager *cm = (CursorManager *)clientData;
int blinkTime;
if (cm->owner->flags & CURSOR_ON) {
diff --git a/generic/ttk/ttkButton.c b/generic/ttk/ttkButton.c
index f4ef7bc..e179a7f 100644
--- a/generic/ttk/ttkButton.c
+++ b/generic/ttk/ttkButton.c
@@ -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,48 @@ 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,
+ "-1", offsetof(Base,base.underlineObj), TCL_INDEX_NONE,
0,0,0 },
/* SB: OPTION_INT, see <<NOTE-NULLOPTIONS>> */
{TK_OPTION_STRING, "-width", "width", "Width",
- NULL, Tk_Offset(Base,base.widthObj), -1,
+ NULL, offsetof(Base,base.widthObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
/*
* Image options
*/
{TK_OPTION_STRING, "-image", "image", "Image", NULL/*default*/,
- Tk_Offset(Base,base.imageObj), -1,
+ offsetof(Base,base.imageObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
/*
* Compound base/image options
*/
{TK_OPTION_STRING_TABLE, "-compound", "compound", "Compound",
- NULL, Tk_Offset(Base,base.compoundObj), -1,
- TK_OPTION_NULL_OK, (void *)ttkCompoundStrings,
- GEOMETRY_CHANGED },
+ NULL, offsetof(Base,base.compoundObj), TCL_INDEX_NONE,
+ TK_OPTION_NULL_OK, (void *)ttkCompoundStrings,
+ GEOMETRY_CHANGED },
{TK_OPTION_STRING, "-padding", "padding", "Pad",
- NULL, Tk_Offset(Base,base.paddingObj), -1,
+ NULL, offsetof(Base,base.paddingObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED},
/*
* Compatibility/legacy options
*/
{TK_OPTION_STRING, "-state", "state", "State",
- "normal", Tk_Offset(Base,base.stateObj), -1,
+ "normal", offsetof(Base,base.stateObj), TCL_INDEX_NONE,
0,0,STATE_CHANGED },
WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
@@ -237,31 +241,31 @@ typedef struct
LabelPart label;
} Label;
-static Tk_OptionSpec LabelOptionSpecs[] =
+static const Tk_OptionSpec LabelOptionSpecs[] =
{
{TK_OPTION_BORDER, "-background", "frameColor", "FrameColor",
- NULL, Tk_Offset(Label,label.backgroundObj), -1,
+ NULL, offsetof(Label,label.backgroundObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,0 },
{TK_OPTION_COLOR, "-foreground", "textColor", "TextColor",
- NULL, Tk_Offset(Label,label.foregroundObj), -1,
+ NULL, offsetof(Label,label.foregroundObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,0 },
{TK_OPTION_FONT, "-font", "font", "Font",
- NULL, Tk_Offset(Label,label.fontObj), -1,
+ NULL, offsetof(Label,label.fontObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- NULL, Tk_Offset(Label,label.borderWidthObj), -1,
+ NULL, offsetof(Label,label.borderWidthObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- NULL, Tk_Offset(Label,label.reliefObj), -1,
+ NULL, offsetof(Label,label.reliefObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
- NULL, Tk_Offset(Label,label.anchorObj), -1,
+ NULL, offsetof(Label,label.anchorObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, GEOMETRY_CHANGED},
{TK_OPTION_JUSTIFY, "-justify", "justify", "Justify",
- NULL, Tk_Offset(Label, label.justifyObj), -1,
+ NULL, offsetof(Label, label.justifyObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
{TK_OPTION_PIXELS, "-wraplength", "wrapLength", "WrapLength",
- NULL, Tk_Offset(Label, label.wrapLengthObj), -1,
+ NULL, offsetof(Label, label.wrapLengthObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED /*SB: SIZE_CHANGED*/ },
WIDGET_TAKEFOCUS_FALSE,
@@ -277,7 +281,7 @@ static const Ttk_Ensemble LabelCommands[] = {
{ 0,0,0 }
};
-static WidgetSpec LabelWidgetSpec =
+static const WidgetSpec LabelWidgetSpec =
{
"TLabel", /* className */
sizeof(Label), /* recordSize */
@@ -320,12 +324,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, (void *)ttkDefaultStrings, DEFAULTSTATE_CHANGED},
WIDGET_TAKEFOCUS_TRUE,
@@ -343,7 +347,7 @@ static int ButtonConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
/* Handle "-default" option:
*/
if (mask & DEFAULTSTATE_CHANGED) {
- int defaultState = TTK_BUTTON_DEFAULT_DISABLED;
+ Ttk_ButtonDefaultState defaultState = TTK_BUTTON_DEFAULT_DISABLED;
Ttk_GetButtonDefaultStateFromObj(
NULL, buttonPtr->button.defaultStateObj, &defaultState);
if (defaultState == TTK_BUTTON_DEFAULT_ACTIVE) {
@@ -383,7 +387,7 @@ static const Ttk_Ensemble ButtonCommands[] = {
{ 0,0,0 }
};
-static WidgetSpec ButtonWidgetSpec =
+static const WidgetSpec ButtonWidgetSpec =
{
"TButton", /* className */
sizeof(Button), /* recordSize */
@@ -430,19 +434,19 @@ typedef struct
/*
* Option specifications:
*/
-static Tk_OptionSpec CheckbuttonOptionSpecs[] =
+static const Tk_OptionSpec CheckbuttonOptionSpecs[] =
{
{TK_OPTION_STRING, "-variable", "variable", "Variable",
- NULL, Tk_Offset(Checkbutton, checkbutton.variableObj), -1,
+ NULL, offsetof(Checkbutton, checkbutton.variableObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,0},
{TK_OPTION_STRING, "-onvalue", "onValue", "OnValue",
- "1", Tk_Offset(Checkbutton, checkbutton.onValueObj), -1,
+ "1", offsetof(Checkbutton, checkbutton.onValueObj), TCL_INDEX_NONE,
0,0,0},
{TK_OPTION_STRING, "-offvalue", "offValue", "OffValue",
- "0", Tk_Offset(Checkbutton, checkbutton.offValueObj), -1,
+ "0", offsetof(Checkbutton, checkbutton.offValueObj), TCL_INDEX_NONE,
0,0,0},
{TK_OPTION_STRING, "-command", "command", "Command",
- "", Tk_Offset(Checkbutton, checkbutton.commandObj), -1,
+ "", offsetof(Checkbutton, checkbutton.commandObj), TCL_INDEX_NONE,
0,0,0},
WIDGET_TAKEFOCUS_TRUE,
@@ -591,7 +595,7 @@ static const Ttk_Ensemble CheckbuttonCommands[] = {
{ 0,0,0 }
};
-static WidgetSpec CheckbuttonWidgetSpec =
+static const WidgetSpec CheckbuttonWidgetSpec =
{
"TCheckbutton", /* className */
sizeof(Checkbutton), /* recordSize */
@@ -638,16 +642,16 @@ typedef struct
/*
* Option specifications:
*/
-static Tk_OptionSpec RadiobuttonOptionSpecs[] =
+static const Tk_OptionSpec RadiobuttonOptionSpecs[] =
{
{TK_OPTION_STRING, "-variable", "variable", "Variable",
- "::selectedButton", Tk_Offset(Radiobutton, radiobutton.variableObj),-1,
+ "::selectedButton", offsetof(Radiobutton, radiobutton.variableObj),TCL_INDEX_NONE,
0,0,0},
{TK_OPTION_STRING, "-value", "Value", "Value",
- "1", Tk_Offset(Radiobutton, radiobutton.valueObj), -1,
+ "1", offsetof(Radiobutton, radiobutton.valueObj), TCL_INDEX_NONE,
0,0,0},
{TK_OPTION_STRING, "-command", "command", "Command",
- "", Tk_Offset(Radiobutton, radiobutton.commandObj), -1,
+ "", offsetof(Radiobutton, radiobutton.commandObj), TCL_INDEX_NONE,
0,0,0},
WIDGET_TAKEFOCUS_TRUE,
@@ -767,7 +771,7 @@ static const Ttk_Ensemble RadiobuttonCommands[] = {
{ 0,0,0 }
};
-static WidgetSpec RadiobuttonWidgetSpec =
+static const WidgetSpec RadiobuttonWidgetSpec =
{
"TRadiobutton", /* className */
sizeof(Radiobutton), /* recordSize */
@@ -813,12 +817,12 @@ typedef struct
static const char *const directionStrings[] = {
"above", "below", "left", "right", "flush", NULL
};
-static Tk_OptionSpec MenubuttonOptionSpecs[] =
+static const Tk_OptionSpec MenubuttonOptionSpecs[] =
{
{TK_OPTION_STRING, "-menu", "menu", "Menu",
- "", Tk_Offset(Menubutton, menubutton.menuObj), -1, 0,0,0},
+ "", offsetof(Menubutton, menubutton.menuObj), TCL_INDEX_NONE, 0,0,0},
{TK_OPTION_STRING_TABLE, "-direction", "direction", "Direction",
- "below", Tk_Offset(Menubutton, menubutton.directionObj), -1,
+ "below", offsetof(Menubutton, menubutton.directionObj), TCL_INDEX_NONE,
0, (void *)directionStrings, GEOMETRY_CHANGED},
WIDGET_TAKEFOCUS_TRUE,
@@ -834,7 +838,7 @@ static const Ttk_Ensemble MenubuttonCommands[] = {
{ 0,0,0 }
};
-static WidgetSpec MenubuttonWidgetSpec =
+static const WidgetSpec MenubuttonWidgetSpec =
{
"TMenubutton", /* className */
sizeof(Menubutton), /* recordSize */
diff --git a/generic/ttk/ttkCache.c b/generic/ttk/ttkCache.c
index e7f885f..9059c55 100644
--- a/generic/ttk/ttkCache.c
+++ b/generic/ttk/ttkCache.c
@@ -28,7 +28,6 @@
* but this will be a transient effect.
*/
-#include <stdio.h> /* for sprintf */
#include "tkInt.h"
#include "ttkTheme.h"
@@ -49,7 +48,7 @@ struct Ttk_ResourceCache_ {
*/
Ttk_ResourceCache Ttk_CreateResourceCache(Tcl_Interp *interp)
{
- Ttk_ResourceCache cache = ckalloc(sizeof(*cache));
+ Ttk_ResourceCache cache = (Ttk_ResourceCache)ckalloc(sizeof(*cache));
cache->tkwin = NULL; /* initialized later */
cache->interp = interp;
@@ -76,7 +75,7 @@ static void Ttk_ClearCache(Ttk_ResourceCache cache)
*/
entryPtr = Tcl_FirstHashEntry(&cache->fontTable, &search);
while (entryPtr != NULL) {
- Tcl_Obj *fontObj = Tcl_GetHashValue(entryPtr);
+ Tcl_Obj *fontObj = (Tcl_Obj *)Tcl_GetHashValue(entryPtr);
if (fontObj) {
Tk_FreeFontFromObj(cache->tkwin, fontObj);
Tcl_DecrRefCount(fontObj);
@@ -91,7 +90,7 @@ static void Ttk_ClearCache(Ttk_ResourceCache cache)
*/
entryPtr = Tcl_FirstHashEntry(&cache->colorTable, &search);
while (entryPtr != NULL) {
- Tcl_Obj *colorObj = Tcl_GetHashValue(entryPtr);
+ Tcl_Obj *colorObj = (Tcl_Obj *)Tcl_GetHashValue(entryPtr);
if (colorObj) {
Tk_FreeColorFromObj(cache->tkwin, colorObj);
Tcl_DecrRefCount(colorObj);
@@ -106,7 +105,7 @@ static void Ttk_ClearCache(Ttk_ResourceCache cache)
*/
entryPtr = Tcl_FirstHashEntry(&cache->borderTable, &search);
while (entryPtr != NULL) {
- Tcl_Obj *borderObj = Tcl_GetHashValue(entryPtr);
+ Tcl_Obj *borderObj = (Tcl_Obj *)Tcl_GetHashValue(entryPtr);
if (borderObj) {
Tk_Free3DBorderFromObj(cache->tkwin, borderObj);
Tcl_DecrRefCount(borderObj);
@@ -121,7 +120,7 @@ static void Ttk_ClearCache(Ttk_ResourceCache cache)
*/
entryPtr = Tcl_FirstHashEntry(&cache->imageTable, &search);
while (entryPtr != NULL) {
- Tk_Image image = Tcl_GetHashValue(entryPtr);
+ Tk_Image image = (Tk_Image)Tcl_GetHashValue(entryPtr);
if (image) {
Tk_FreeImage(image);
}
@@ -154,7 +153,7 @@ void Ttk_FreeResourceCache(Ttk_ResourceCache cache)
*/
entryPtr = Tcl_FirstHashEntry(&cache->namedColors, &search);
while (entryPtr != NULL) {
- Tcl_Obj *colorNameObj = Tcl_GetHashValue(entryPtr);
+ Tcl_Obj *colorNameObj = (Tcl_Obj *)Tcl_GetHashValue(entryPtr);
Tcl_DecrRefCount(colorNameObj);
entryPtr = Tcl_NextHashEntry(&search);
}
@@ -169,7 +168,7 @@ void Ttk_FreeResourceCache(Ttk_ResourceCache cache)
*/
static void CacheWinEventHandler(ClientData clientData, XEvent *eventPtr)
{
- Ttk_ResourceCache cache = clientData;
+ Ttk_ResourceCache cache = (Ttk_ResourceCache)clientData;
if (eventPtr->type != DestroyNotify) {
return;
@@ -217,7 +216,7 @@ void Ttk_RegisterNamedColor(
entryPtr = Tcl_CreateHashEntry(&cache->namedColors, colorName, &newEntry);
if (!newEntry) {
- Tcl_Obj *oldColor = Tcl_GetHashValue(entryPtr);
+ Tcl_Obj *oldColor = (Tcl_Obj *)Tcl_GetHashValue(entryPtr);
Tcl_DecrRefCount(oldColor);
}
@@ -235,7 +234,7 @@ static Tcl_Obj *CheckNamedColor(Ttk_ResourceCache cache, Tcl_Obj *objPtr)
Tcl_HashEntry *entryPtr =
Tcl_FindHashEntry(&cache->namedColors, Tcl_GetString(objPtr));
if (entryPtr) { /* Use named color instead */
- objPtr = Tcl_GetHashValue(entryPtr);
+ objPtr = (Tcl_Obj *)Tcl_GetHashValue(entryPtr);
}
return objPtr;
}
@@ -258,7 +257,7 @@ static Tcl_Obj *Ttk_Use(
Tcl_Obj *cacheObj;
if (!newEntry) {
- return Tcl_GetHashValue(entryPtr);
+ return (Tcl_Obj *)Tcl_GetHashValue(entryPtr);
}
cacheObj = Tcl_DuplicateObj(objPtr);
@@ -315,9 +314,17 @@ Tcl_Obj *Ttk_UseBorder(
* Tk_ImageChangedProc for Ttk_UseImage
*/
-static void NullImageChanged(ClientData clientData,
+static void NullImageChanged(ClientData dummy,
int x, int y, int width, int height, int imageWidth, int imageHeight)
-{ /* No-op */ }
+{ /* No-op */
+ (void)dummy;
+ (void)x;
+ (void)y;
+ (void)width;
+ (void)height;
+ (void)imageWidth;
+ (void)imageHeight;
+}
/*
* Ttk_UseImage --
@@ -334,7 +341,7 @@ Tk_Image Ttk_UseImage(Ttk_ResourceCache cache, Tk_Window tkwin, Tcl_Obj *objPtr)
InitCacheWindow(cache, tkwin);
if (!newEntry) {
- return Tcl_GetHashValue(entryPtr);
+ return (Tk_Image)Tcl_GetHashValue(entryPtr);
}
image = Tk_GetImage(cache->interp, tkwin, imageName, NullImageChanged,0);
diff --git a/generic/ttk/ttkClamTheme.c b/generic/ttk/ttkClamTheme.c
index 733a391..035cabc 100644
--- a/generic/ttk/ttkClamTheme.c
+++ b/generic/ttk/ttkClamTheme.c
@@ -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 }
};
@@ -183,7 +183,7 @@ static void BorderElementDraw(
DrawSmoothBorder(tkwin, d, b, outer, upper, lower);
}
-static Ttk_ElementSpec BorderElementSpec = {
+static const Ttk_ElementSpec BorderElementSpec = {
TK_STYLE_VERSION_2,
sizeof(BorderElement),
BorderElementOptions,
@@ -202,15 +202,15 @@ typedef struct {
Tcl_Obj *backgroundObj;
} FieldElement;
-static Ttk_ElementOptionSpec FieldElementOptions[] = {
+static const Ttk_ElementOptionSpec FieldElementOptions[] = {
{ "-bordercolor", TK_OPTION_COLOR,
- Tk_Offset(FieldElement,borderColorObj), DARKEST_COLOR },
+ offsetof(FieldElement,borderColorObj), DARKEST_COLOR },
{ "-lightcolor", TK_OPTION_COLOR,
- Tk_Offset(FieldElement,lightColorObj), LIGHT_COLOR },
+ offsetof(FieldElement,lightColorObj), LIGHT_COLOR },
{ "-darkcolor", TK_OPTION_COLOR,
- Tk_Offset(FieldElement,darkColorObj), DARK_COLOR },
+ offsetof(FieldElement,darkColorObj), DARK_COLOR },
{ "-fieldbackground", TK_OPTION_BORDER,
- Tk_Offset(FieldElement,backgroundObj), "white" },
+ 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,
@@ -292,19 +292,19 @@ typedef struct {
Tcl_Obj *lowerColorObj;
} IndicatorElement;
-static Ttk_ElementOptionSpec IndicatorElementOptions[] = {
+static const Ttk_ElementOptionSpec IndicatorElementOptions[] = {
{ "-indicatorsize", TK_OPTION_PIXELS,
- Tk_Offset(IndicatorElement,sizeObj), "10" },
+ offsetof(IndicatorElement,sizeObj), "10" },
{ "-indicatormargin", TK_OPTION_STRING,
- Tk_Offset(IndicatorElement,marginObj), "1" },
+ offsetof(IndicatorElement,marginObj), "1" },
{ "-indicatorbackground", TK_OPTION_COLOR,
- Tk_Offset(IndicatorElement,backgroundObj), "white" },
+ offsetof(IndicatorElement,backgroundObj), "white" },
{ "-indicatorforeground", TK_OPTION_COLOR,
- Tk_Offset(IndicatorElement,foregroundObj), "black" },
+ offsetof(IndicatorElement,foregroundObj), "black" },
{ "-upperbordercolor", TK_OPTION_COLOR,
- Tk_Offset(IndicatorElement,upperColorObj), DARKEST_COLOR },
+ offsetof(IndicatorElement,upperColorObj), DARKEST_COLOR },
{ "-lowerbordercolor", TK_OPTION_COLOR,
- Tk_Offset(IndicatorElement,lowerColorObj), DARK_COLOR },
+ offsetof(IndicatorElement,lowerColorObj), DARK_COLOR },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -395,7 +395,7 @@ static void CheckIndicatorElementDraw(
}
}
-static Ttk_ElementSpec RadioIndicatorElementSpec = {
+static const Ttk_ElementSpec RadioIndicatorElementSpec = {
TK_STYLE_VERSION_2,
sizeof(IndicatorElement),
IndicatorElementOptions,
@@ -403,7 +403,7 @@ static Ttk_ElementSpec RadioIndicatorElementSpec = {
RadioIndicatorElementDraw
};
-static Ttk_ElementSpec CheckIndicatorElementSpec = {
+static const Ttk_ElementSpec CheckIndicatorElementSpec = {
TK_STYLE_VERSION_2,
sizeof(IndicatorElement),
IndicatorElementOptions,
@@ -419,16 +419,16 @@ typedef struct {
Tcl_Obj *paddingObj;
} MenuIndicatorElement;
-static Ttk_ElementOptionSpec MenuIndicatorElementOptions[] =
+static const Ttk_ElementOptionSpec MenuIndicatorElementOptions[] =
{
{ "-arrowsize", TK_OPTION_PIXELS,
- Tk_Offset(MenuIndicatorElement,sizeObj),
+ offsetof(MenuIndicatorElement,sizeObj),
STR(MENUBUTTON_ARROW_SIZE)},
{ "-arrowcolor",TK_OPTION_COLOR,
- Tk_Offset(MenuIndicatorElement,colorObj),
+ offsetof(MenuIndicatorElement,colorObj),
"black" },
{ "-arrowpadding",TK_OPTION_STRING,
- Tk_Offset(MenuIndicatorElement,paddingObj),
+ offsetof(MenuIndicatorElement,paddingObj),
"3" },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -469,7 +469,7 @@ static void MenuIndicatorElementDraw(
TtkFillArrow(Tk_Display(tkwin), d, gc, b, ARROW_DOWN);
}
-static Ttk_ElementSpec MenuIndicatorElementSpec =
+static const Ttk_ElementSpec MenuIndicatorElementSpec =
{
TK_STYLE_VERSION_2,
sizeof(MenuIndicatorElement),
@@ -484,23 +484,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_INT,
- Tk_Offset(GripElement,gripCountObj), "5" },
+ offsetof(GripElement,gripCountObj), "5" },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -508,14 +504,14 @@ static void GripElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- int horizontal = *((Ttk_Orient*)clientData) == TTK_ORIENT_HORIZONTAL;
+ Ttk_Orient orient = (Ttk_Orient)PTR2INT(clientData);
GripElement *grip = (GripElement *)elementRecord;
int gripCount = 0;
(void)tkwin;
(void)paddingPtr;
Tcl_GetIntFromObj(NULL, grip->gripCountObj, &gripCount);
- if (horizontal) {
+ if (orient == TTK_ORIENT_HORIZONTAL) {
*widthPtr = 2*gripCount;
} else {
*heightPtr = 2*gripCount;
@@ -527,16 +523,17 @@ static void GripElementDraw(
Drawable d, Ttk_Box b, unsigned state)
{
const int w = WIN32_XDRAWLINE_HACK;
- int horizontal = *((Ttk_Orient*)clientData) == TTK_ORIENT_HORIZONTAL;
+ Ttk_Orient orient = (Ttk_Orient)PTR2INT(clientData);
GripElement *grip = (GripElement *)elementRecord;
GC lightGC = Ttk_GCForColor(tkwin,grip->lightColorObj,d);
GC darkGC = Ttk_GCForColor(tkwin,grip->borderColorObj,d);
int gripPad = 1, gripCount = 0;
int i;
+ (void)state;
Tcl_GetIntFromObj(NULL, grip->gripCountObj, &gripCount);
- if (horizontal) {
+ if (orient == TTK_ORIENT_HORIZONTAL) {
int x = b.x + b.width / 2 - gripCount;
int y1 = b.y + gripPad, y2 = b.y + b.height - gripPad - 1 + w;
for (i=0; i<gripCount; ++i) {
@@ -553,7 +550,7 @@ static void GripElementDraw(
}
}
-static Ttk_ElementSpec GripElementSpec = {
+static const Ttk_ElementSpec GripElementSpec = {
TK_STYLE_VERSION_2,
sizeof(GripElement),
GripElementOptions,
@@ -581,27 +578,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_INT,
- Tk_Offset(ScrollbarElement,gripCountObj), "5" },
+ offsetof(ScrollbarElement,gripCountObj), "5" },
{ "-sliderlength", TK_OPTION_INT,
- Tk_Offset(ScrollbarElement,sliderlengthObj), "30" },
+ offsetof(ScrollbarElement,sliderlengthObj), "30" },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -619,7 +616,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,
@@ -647,7 +644,7 @@ static void ThumbElementDraw(
{
ScrollbarElement *sb = (ScrollbarElement *)elementRecord;
int gripCount = 0;
- int orient = TTK_ORIENT_HORIZONTAL;
+ Ttk_Orient orient = TTK_ORIENT_HORIZONTAL;
GC lightGC, darkGC;
int x1, y1, x2, y2, dx, dy, i;
const int w = WIN32_XDRAWLINE_HACK;
@@ -663,7 +660,7 @@ static void ThumbElementDraw(
/*
* Draw grip:
*/
- Ttk_GetOrientFromObj(NULL, sb->orientObj, &orient);
+ TtkGetOrientFromObj(NULL, sb->orientObj, &orient);
Tcl_GetIntFromObj(NULL, sb->gripCountObj, &gripCount);
lightGC = Ttk_GCForColor(tkwin,sb->lightColorObj,d);
darkGC = Ttk_GCForColor(tkwin,sb->borderColorObj,d);
@@ -688,7 +685,7 @@ static void ThumbElementDraw(
}
}
-static Ttk_ElementSpec ThumbElementSpec = {
+static const Ttk_ElementSpec ThumbElementSpec = {
TK_STYLE_VERSION_2,
sizeof(ScrollbarElement),
ScrollbarElementOptions,
@@ -705,12 +702,12 @@ static void SliderElementSize(
{
ScrollbarElement *sb = (ScrollbarElement *)elementRecord;
int length, thickness;
- int orient;
+ Ttk_Orient orient;
(void)dummy;
(void)paddingPtr;
length = thickness = SCROLLBAR_THICKNESS;
- Ttk_GetOrientFromObj(NULL, sb->orientObj, &orient);
+ TtkGetOrientFromObj(NULL, sb->orientObj, &orient);
Tcl_GetIntFromObj(NULL, sb->arrowSizeObj, &thickness);
Tk_GetPixelsFromObj(NULL, tkwin, sb->sliderlengthObj, &length);
if (orient == TTK_ORIENT_VERTICAL) {
@@ -723,7 +720,7 @@ static void SliderElementSize(
}
-static Ttk_ElementSpec SliderElementSpec = {
+static const Ttk_ElementSpec SliderElementSpec = {
TK_STYLE_VERSION_2,
sizeof(ScrollbarElement),
ScrollbarElementOptions,
@@ -763,7 +760,7 @@ static void PbarElementDraw(
}
}
-static Ttk_ElementSpec PbarElementSpec = {
+static const Ttk_ElementSpec PbarElementSpec = {
TK_STYLE_VERSION_2,
sizeof(ScrollbarElement),
ScrollbarElementOptions,
@@ -775,8 +772,6 @@ static Ttk_ElementSpec PbarElementSpec = {
/*------------------------------------------------------------------------
* +++ Scrollbar arrows.
*/
-static int ArrowElements[] = { ARROW_UP, ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT };
-
static void ArrowElementSize(
void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
@@ -795,10 +790,11 @@ static void ArrowElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned state)
{
- ArrowDirection direction = *(ArrowDirection*)clientData;
+ ArrowDirection direction = (ArrowDirection)PTR2INT(clientData);
ScrollbarElement *sb = (ScrollbarElement *)elementRecord;
GC gc = Ttk_GCForColor(tkwin,sb->arrowColorObj, d);
int h, cx, cy;
+ (void)state;
DrawSmoothBorder(tkwin, d, b,
sb->borderColorObj, sb->lightColorObj, sb->darkColorObj);
@@ -815,7 +811,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,
@@ -838,15 +834,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 }
};
@@ -903,7 +899,7 @@ static void TabElementDraw(
XDrawLine(display,d,gc, x1+1,y1+1, x2-1+w,y1+1);
}
-static Ttk_ElementSpec TabElementSpec =
+static const Ttk_ElementSpec TabElementSpec =
{
TK_STYLE_VERSION_2,
sizeof(NotebookElement),
@@ -942,7 +938,7 @@ static void ClientElementDraw(
ce->borderColorObj, ce->lightColorObj, ce->darkColorObj);
}
-static Ttk_ElementSpec ClientElementSpec =
+static const Ttk_ElementSpec ClientElementSpec =
{
TK_STYLE_VERSION_2,
sizeof(NotebookElement),
@@ -997,13 +993,13 @@ TtkClamTheme_Init(Tcl_Interp *interp)
Ttk_RegisterElement(interp,
theme, "thumb", &ThumbElementSpec, NULL);
Ttk_RegisterElement(interp,
- theme, "uparrow", &ArrowElementSpec, &ArrowElements[0]);
+ theme, "uparrow", &ArrowElementSpec, INT2PTR(ARROW_UP));
Ttk_RegisterElement(interp,
- theme, "downarrow", &ArrowElementSpec, &ArrowElements[1]);
+ theme, "downarrow", &ArrowElementSpec, INT2PTR(ARROW_DOWN));
Ttk_RegisterElement(interp,
- theme, "leftarrow", &ArrowElementSpec, &ArrowElements[2]);
+ theme, "leftarrow", &ArrowElementSpec, INT2PTR(ARROW_LEFT));
Ttk_RegisterElement(interp,
- theme, "rightarrow", &ArrowElementSpec, &ArrowElements[3]);
+ theme, "rightarrow", &ArrowElementSpec, INT2PTR(ARROW_RIGHT));
Ttk_RegisterElement(interp,
theme, "Radiobutton.indicator", &RadioIndicatorElementSpec, NULL);
@@ -1020,9 +1016,9 @@ TtkClamTheme_Init(Tcl_Interp *interp)
Ttk_RegisterElement(interp, theme, "pbar", &PbarElementSpec, NULL);
Ttk_RegisterElement(interp, theme, "hgrip",
- &GripElementSpec, &GripClientData[0]);
+ &GripElementSpec, INT2PTR(TTK_ORIENT_HORIZONTAL));
Ttk_RegisterElement(interp, theme, "vgrip",
- &GripElementSpec, &GripClientData[1]);
+ &GripElementSpec, INT2PTR(TTK_ORIENT_VERTICAL));
Ttk_RegisterLayouts(theme, LayoutTable);
diff --git a/generic/ttk/ttkClassicTheme.c b/generic/ttk/ttkClassicTheme.c
index 8436aec..be7d74b 100644
--- a/generic/ttk/ttkClassicTheme.c
+++ b/generic/ttk/ttkClassicTheme.c
@@ -21,11 +21,11 @@ typedef struct {
Tcl_Obj *highlightThicknessObj;
} HighlightElement;
-static Ttk_ElementOptionSpec HighlightElementOptions[] = {
+static const Ttk_ElementOptionSpec HighlightElementOptions[] = {
{ "-highlightcolor",TK_OPTION_COLOR,
- Tk_Offset(HighlightElement,highlightColorObj), DEFAULT_BACKGROUND },
+ offsetof(HighlightElement,highlightColorObj), DEFAULT_BACKGROUND },
{ "-highlightthickness",TK_OPTION_PIXELS,
- Tk_Offset(HighlightElement,highlightThicknessObj), "0" },
+ offsetof(HighlightElement,highlightThicknessObj), "0" },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -62,7 +62,7 @@ static void HighlightElementDraw(
}
}
-static Ttk_ElementSpec HighlightElementSpec =
+static const Ttk_ElementSpec HighlightElementSpec =
{
TK_STYLE_VERSION_2,
sizeof(HighlightElement),
@@ -88,16 +88,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 }
};
@@ -106,7 +106,7 @@ static void ButtonBorderElementSize(
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
ButtonBorderElement *bd = (ButtonBorderElement *)elementRecord;
- int defaultState = TTK_BUTTON_DEFAULT_DISABLED;
+ Ttk_ButtonDefaultState defaultState = TTK_BUTTON_DEFAULT_DISABLED;
int borderWidth = 0;
(void)dummy;
(void)tkwin;
@@ -134,7 +134,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;
(void)dummy;
(void)state;
@@ -183,7 +183,7 @@ static void ButtonBorderElementDraw(
}
}
-static Ttk_ElementSpec ButtonBorderElementSpec =
+static const Ttk_ElementSpec ButtonBorderElementSpec =
{
TK_STYLE_VERSION_2,
sizeof(ButtonBorderElement),
@@ -199,7 +199,6 @@ static Ttk_ElementSpec ButtonBorderElementSpec =
* clientData is an enum ArrowDirection pointer.
*/
-static int ArrowElements[] = { ARROW_UP, ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT };
typedef struct
{
Tcl_Obj *sizeObj;
@@ -208,15 +207,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 }
};
@@ -237,7 +236,7 @@ static void ArrowElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int 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;
@@ -282,7 +281,7 @@ static void ArrowElementDraw(
Tk_Fill3DPolygon(tkwin, d, border, points, 3, borderWidth, relief);
}
-static Ttk_ElementSpec ArrowElementSpec =
+static const Ttk_ElementSpec ArrowElementSpec =
{
TK_STYLE_VERSION_2,
sizeof(ArrowElement),
@@ -306,10 +305,6 @@ static Ttk_ElementSpec ArrowElementSpec =
* -sashrelief raised, but that looks wrong to me.
*/
-static Ttk_Orient SashClientData[] = {
- TTK_ORIENT_HORIZONTAL, TTK_ORIENT_VERTICAL
-};
-
typedef struct {
Tcl_Obj *borderObj; /* background color */
Tcl_Obj *sashReliefObj; /* sash relief */
@@ -319,19 +314,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 }
};
@@ -341,7 +336,8 @@ 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);
+ (void)paddingPtr;
(void)paddingPtr;
Tk_GetPixelsFromObj(NULL, tkwin, sash->sashThicknessObj, &sashThickness);
@@ -351,7 +347,7 @@ static void SashElementSize(
if (sashThickness < handleSize + 2*sashPad)
sashThickness = handleSize + 2*sashPad;
- if (horizontal)
+ if (orient == TTK_ORIENT_HORIZONTAL)
*heightPtr = sashThickness;
else
*widthPtr = sashThickness;
@@ -366,7 +362,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;
(void)state;
@@ -394,7 +390,7 @@ static void SashElementDraw(
/* Draw sash line:
*/
- if (horizontal) {
+ if (orient == TTK_ORIENT_HORIZONTAL) {
int y = b.y + b.height/2 - 1;
XDrawLine(Tk_Display(tkwin), d, gc1, b.x, y, b.x+b.width, y); ++y;
XDrawLine(Tk_Display(tkwin), d, gc2, b.x, y, b.x+b.width, y);
@@ -407,7 +403,7 @@ static void SashElementDraw(
/* Draw handle:
*/
if (handleSize >= 0) {
- if (horizontal) {
+ if (orient == TTK_ORIENT_HORIZONTAL) {
hb = Ttk_StickBox(b, handleSize, handleSize, TTK_STICK_W);
hb.x += handlePad;
} else {
@@ -419,7 +415,7 @@ static void SashElementDraw(
}
}
-static Ttk_ElementSpec SashElementSpec = {
+static const Ttk_ElementSpec SashElementSpec = {
TK_STYLE_VERSION_2,
sizeof(SashElement),
SashOptions,
@@ -501,20 +497,20 @@ MODULE_SCOPE int TtkClassicTheme_Init(Tcl_Interp *interp)
&ButtonBorderElementSpec, NULL);
Ttk_RegisterElement(interp, theme, "uparrow",
- &ArrowElementSpec, &ArrowElements[0]);
+ &ArrowElementSpec, INT2PTR(ARROW_UP));
Ttk_RegisterElement(interp, theme, "downarrow",
- &ArrowElementSpec, &ArrowElements[1]);
+ &ArrowElementSpec, INT2PTR(ARROW_DOWN));
Ttk_RegisterElement(interp, theme, "leftarrow",
- &ArrowElementSpec, &ArrowElements[2]);
+ &ArrowElementSpec, INT2PTR(ARROW_LEFT));
Ttk_RegisterElement(interp, theme, "rightarrow",
- &ArrowElementSpec, &ArrowElements[3]);
+ &ArrowElementSpec, INT2PTR(ARROW_RIGHT));
Ttk_RegisterElement(interp, theme, "arrow",
- &ArrowElementSpec, &ArrowElements[0]);
+ &ArrowElementSpec, INT2PTR(ARROW_UP));
Ttk_RegisterElement(interp, theme, "hsash",
- &SashElementSpec, &SashClientData[0]);
+ &SashElementSpec, INT2PTR(TTK_ORIENT_HORIZONTAL));
Ttk_RegisterElement(interp, theme, "vsash",
- &SashElementSpec, &SashClientData[1]);
+ &SashElementSpec, INT2PTR(TTK_ORIENT_VERTICAL));
/*
* Register layouts:
diff --git a/generic/ttk/ttkDecls.h b/generic/ttk/ttkDecls.h
index 6701724..5f76634 100644
--- a/generic/ttk/ttkDecls.h
+++ b/generic/ttk/ttkDecls.h
@@ -17,6 +17,15 @@ extern const char *TtkInitializeStubs(
#endif
+#if !defined(BUILD_tk)
+# define TTK_DEPRECATED(msg) TTKAPI TCL_DEPRECATED_API(msg)
+#elif defined(TK_NO_DEPRECATED)
+# define TTK_DEPRECATED(msg) MODULE_SCOPE
+#else
+# define TTK_DEPRECATED(msg) TTKAPI
+#endif
+
+
/* !BEGIN!: Do not edit below this line. */
@@ -47,12 +56,12 @@ TTKAPI void Ttk_RegisterCleanup(Tcl_Interp *interp,
/* 5 */
TTKAPI int Ttk_RegisterElementSpec(Ttk_Theme theme,
const char *elementName,
- Ttk_ElementSpec *elementSpec,
+ const Ttk_ElementSpec *elementSpec,
void *clientData);
/* 6 */
TTKAPI Ttk_ElementClass * Ttk_RegisterElement(Tcl_Interp *interp,
Ttk_Theme theme, const char *elementName,
- Ttk_ElementSpec *elementSpec,
+ const Ttk_ElementSpec *elementSpec,
void *clientData);
/* 7 */
TTKAPI int Ttk_RegisterElementFactory(Tcl_Interp *interp,
@@ -77,7 +86,7 @@ TTKAPI Ttk_StateMap Ttk_GetStateMapFromObj(Tcl_Interp *interp,
TTKAPI Tcl_Obj * Ttk_StateMapLookup(Tcl_Interp *interp,
Ttk_StateMap map, Ttk_State state);
/* 14 */
-TTKAPI int Ttk_StateTableLookup(Ttk_StateTable map[],
+TTKAPI int Ttk_StateTableLookup(const Ttk_StateTable *map,
Ttk_State state);
/* Slot 15 is reserved */
/* Slot 16 is reserved */
@@ -130,7 +139,8 @@ TTKAPI Tcl_Obj * Ttk_NewBoxObj(Ttk_Box box);
/* Slot 38 is reserved */
/* Slot 39 is reserved */
/* 40 */
-TTKAPI int Ttk_GetOrientFromObj(Tcl_Interp *interp,
+TTK_DEPRECATED("")
+int Ttk_GetOrientFromObj(Tcl_Interp *interp,
Tcl_Obj *objPtr, int *orient);
typedef struct TtkStubs {
@@ -144,8 +154,8 @@ typedef struct TtkStubs {
Ttk_Theme (*ttk_GetCurrentTheme) (Tcl_Interp *interp); /* 2 */
Ttk_Theme (*ttk_CreateTheme) (Tcl_Interp *interp, const char *name, Ttk_Theme parent); /* 3 */
void (*ttk_RegisterCleanup) (Tcl_Interp *interp, void *deleteData, Ttk_CleanupProc *cleanupProc); /* 4 */
- int (*ttk_RegisterElementSpec) (Ttk_Theme theme, const char *elementName, Ttk_ElementSpec *elementSpec, void *clientData); /* 5 */
- Ttk_ElementClass * (*ttk_RegisterElement) (Tcl_Interp *interp, Ttk_Theme theme, const char *elementName, Ttk_ElementSpec *elementSpec, void *clientData); /* 6 */
+ int (*ttk_RegisterElementSpec) (Ttk_Theme theme, const char *elementName, const Ttk_ElementSpec *elementSpec, void *clientData); /* 5 */
+ Ttk_ElementClass * (*ttk_RegisterElement) (Tcl_Interp *interp, Ttk_Theme theme, const char *elementName, const Ttk_ElementSpec *elementSpec, void *clientData); /* 6 */
int (*ttk_RegisterElementFactory) (Tcl_Interp *interp, const char *name, Ttk_ElementFactory factoryProc, void *clientData); /* 7 */
void (*ttk_RegisterLayout) (Ttk_Theme theme, const char *className, Ttk_LayoutSpec layoutSpec); /* 8 */
void (*reserved9)(void);
@@ -153,7 +163,7 @@ typedef struct TtkStubs {
Tcl_Obj * (*ttk_NewStateSpecObj) (unsigned int onbits, unsigned int offbits); /* 11 */
Ttk_StateMap (*ttk_GetStateMapFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr); /* 12 */
Tcl_Obj * (*ttk_StateMapLookup) (Tcl_Interp *interp, Ttk_StateMap map, Ttk_State state); /* 13 */
- int (*ttk_StateTableLookup) (Ttk_StateTable map[], Ttk_State state); /* 14 */
+ int (*ttk_StateTableLookup) (const Ttk_StateTable *map, Ttk_State state); /* 14 */
void (*reserved15)(void);
void (*reserved16)(void);
void (*reserved17)(void);
@@ -179,7 +189,7 @@ typedef struct TtkStubs {
void (*reserved37)(void);
void (*reserved38)(void);
void (*reserved39)(void);
- int (*ttk_GetOrientFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, int *orient); /* 40 */
+ TCL_DEPRECATED_API("") int (*ttk_GetOrientFromObj) (Tcl_Interp *interp, Tcl_Obj *objPtr, int *orient); /* 40 */
} TtkStubs;
extern const TtkStubs *ttkStubsPtr;
diff --git a/generic/ttk/ttkDefaultTheme.c b/generic/ttk/ttkDefaultTheme.c
index 89bf028..a614894 100644
--- a/generic/ttk/ttkDefaultTheme.c
+++ b/generic/ttk/ttkDefaultTheme.c
@@ -37,7 +37,7 @@ static const int WIN32_XDRAWLINE_HACK = 0;
enum BorderColor { FLAT = 1, LITE = 2, DARK = 3, BRDR = 4 };
/* top-left outer, top-left inner, bottom-right inner, bottom-right outer */
-static int const shadowColors[6][4] = {
+static const enum BorderColor shadowColors[6][4] = {
{ FLAT, FLAT, FLAT, FLAT }, /* TK_RELIEF_FLAT = 0*/
{ DARK, LITE, DARK, LITE }, /* TK_RELIEF_GROOVE = 1*/
{ LITE, FLAT, DARK, BRDR }, /* TK_RELIEF_RAISED = 2*/
@@ -47,7 +47,7 @@ static int const shadowColors[6][4] = {
};
/* top-left, bottom-right */
-static int const thinShadowColors[6][4] = {
+static const enum BorderColor thinShadowColors[6][4] = {
{ FLAT, FLAT }, /* TK_RELIEF_FLAT = 0*/
{ DARK, LITE }, /* TK_RELIEF_GROOVE = 1*/
{ LITE, DARK }, /* TK_RELIEF_RAISED = 2*/
@@ -116,21 +116,19 @@ static void DrawBorder(
/* Alternate shadow colors for entry fields:
* NOTE: FLAT color is normally white, and the LITE color is a darker shade.
*/
-static int fieldShadowColors[4] = { DARK, BRDR, LITE, FLAT };
-
static void DrawFieldBorder(
Tk_Window tkwin, Drawable d, Tk_3DBorder border, XColor *borderColor,
Ttk_Box b)
{
GC borderGC = Tk_GCForColor(borderColor, d);
DrawCorner(tkwin, d, border, borderGC,
- b.x, b.y, b.width, b.height, 0,fieldShadowColors[0]);
+ b.x, b.y, b.width, b.height, 0, DARK);
DrawCorner(tkwin, d, border, borderGC,
- b.x+1, b.y+1, b.width-2, b.height-2, 0,fieldShadowColors[1]);
+ b.x+1, b.y+1, b.width-2, b.height-2, 0, BRDR);
DrawCorner(tkwin, d, border, borderGC,
- b.x+1, b.y+1, b.width-2, b.height-2, 1,fieldShadowColors[2]);
+ b.x+1, b.y+1, b.width-2, b.height-2, 1, LITE);
DrawCorner(tkwin, d, border, borderGC,
- b.x, b.y, b.width, b.height, 1,fieldShadowColors[3]);
+ b.x, b.y, b.width, b.height, 1, FLAT);
return;
}
@@ -138,11 +136,11 @@ static void DrawFieldBorder(
* ArrowPoints --
* Compute points of arrow polygon.
*/
-static void ArrowPoints(Ttk_Box b, ArrowDirection dir, XPoint points[4])
+static void ArrowPoints(Ttk_Box b, ArrowDirection direction, XPoint points[4])
{
int cx, cy, h;
- switch (dir) {
+ switch (direction) {
case ARROW_UP:
h = (b.width - 1)/2;
cx = b.x + h;
@@ -186,9 +184,9 @@ static void ArrowPoints(Ttk_Box b, ArrowDirection dir, XPoint points[4])
}
/*public*/
-void TtkArrowSize(int h, ArrowDirection dir, int *widthPtr, int *heightPtr)
+void TtkArrowSize(int h, ArrowDirection direction, int *widthPtr, int *heightPtr)
{
- switch (dir) {
+ switch (direction) {
case ARROW_UP:
case ARROW_DOWN: *widthPtr = 2*h+1; *heightPtr = h+1; break;
case ARROW_LEFT:
@@ -202,10 +200,10 @@ void TtkArrowSize(int h, ArrowDirection dir, int *widthPtr, int *heightPtr)
*/
/*public*/
void TtkFillArrow(
- Display *display, Drawable d, GC gc, Ttk_Box b, ArrowDirection dir)
+ Display *display, Drawable d, GC gc, Ttk_Box b, ArrowDirection direction)
{
XPoint points[4];
- ArrowPoints(b, dir, points);
+ ArrowPoints(b, direction, points);
XFillPolygon(display, d, gc, points, 3, Convex, CoordModeOrigin);
XDrawLines(display, d, gc, points, 4, CoordModeOrigin);
@@ -215,10 +213,10 @@ void TtkFillArrow(
/*public*/
void TtkDrawArrow(
- Display *display, Drawable d, GC gc, Ttk_Box b, ArrowDirection dir)
+ Display *display, Drawable d, GC gc, Ttk_Box b, ArrowDirection direction)
{
XPoint points[4];
- ArrowPoints(b, dir, points);
+ ArrowPoints(b, direction, points);
XDrawLines(display, d, gc, points, 4, CoordModeOrigin);
/* Work around bug [77527326e5] - ttk artifacts on Ubuntu */
@@ -244,27 +242,31 @@ typedef struct {
Tcl_Obj *defaultStateObj; /* for buttons */
} BorderElement;
-static Ttk_ElementOptionSpec BorderElementOptions[] = {
- { "-background", TK_OPTION_BORDER, Tk_Offset(BorderElement,borderObj),
+static const Ttk_ElementOptionSpec BorderElementOptions[] = {
+ { "-background", TK_OPTION_BORDER, offsetof(BorderElement,borderObj),
DEFAULT_BACKGROUND },
{ "-bordercolor",TK_OPTION_COLOR,
- Tk_Offset(BorderElement,borderColorObj), "black" },
- { "-default", TK_OPTION_ANY, Tk_Offset(BorderElement,defaultStateObj),
+ offsetof(BorderElement,borderColorObj), "black" },
+ { "-default", TK_OPTION_ANY, offsetof(BorderElement,defaultStateObj),
"disabled" },
- { "-borderwidth",TK_OPTION_PIXELS,Tk_Offset(BorderElement,borderWidthObj),
+ { "-borderwidth",TK_OPTION_PIXELS, offsetof(BorderElement,borderWidthObj),
STRINGIFY(BORDERWIDTH) },
- { "-relief", TK_OPTION_RELIEF, Tk_Offset(BorderElement,reliefObj),
+ { "-relief", TK_OPTION_RELIEF, offsetof(BorderElement,reliefObj),
"flat" },
- { NULL, 0, 0, NULL }
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void BorderElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- BorderElement *bd = elementRecord;
+ BorderElement *bd = (BorderElement *)elementRecord;
int borderWidth = 0;
- int defaultState = TTK_BUTTON_DEFAULT_DISABLED;
+ Ttk_ButtonDefaultState defaultState = TTK_BUTTON_DEFAULT_DISABLED;
+ (void)dummy;
+ (void)tkwin;
+ (void)widthPtr;
+ (void)heightPtr;
Tcl_GetIntFromObj(NULL, bd->borderWidthObj, &borderWidth);
Ttk_GetButtonDefaultStateFromObj(NULL, bd->defaultStateObj, &defaultState);
@@ -277,15 +279,17 @@ static void BorderElementSize(
}
static void BorderElementDraw(
- void *clientData, void *elementRecord,
+ void *dummy, void *elementRecord,
Tk_Window tkwin, Drawable d, Ttk_Box b, unsigned int state)
{
- BorderElement *bd = elementRecord;
+ BorderElement *bd = (BorderElement *)elementRecord;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, bd->borderObj);
XColor *borderColor = Tk_GetColorFromObj(tkwin, bd->borderColorObj);
int borderWidth = 2;
int relief = TK_RELIEF_FLAT;
- int defaultState = TTK_BUTTON_DEFAULT_DISABLED;
+ Ttk_ButtonDefaultState defaultState = TTK_BUTTON_DEFAULT_DISABLED;
+ (void)dummy;
+ (void)state;
/*
* Get option values.
@@ -307,7 +311,7 @@ static void BorderElementDraw(
DrawBorder(tkwin, d, border, borderColor, b, borderWidth, relief);
}
-static Ttk_ElementSpec BorderElementSpec = {
+static const Ttk_ElementSpec BorderElementSpec = {
TK_STYLE_VERSION_2,
sizeof(BorderElement),
BorderElementOptions,
@@ -324,35 +328,43 @@ typedef struct {
Tcl_Obj *borderColorObj; /* Extra border color */
} FieldElement;
-static Ttk_ElementOptionSpec FieldElementOptions[] = {
- { "-fieldbackground", TK_OPTION_BORDER, Tk_Offset(FieldElement,borderObj),
+static const Ttk_ElementOptionSpec FieldElementOptions[] = {
+ { "-fieldbackground", TK_OPTION_BORDER, offsetof(FieldElement,borderObj),
"white" },
- { "-bordercolor",TK_OPTION_COLOR, Tk_Offset(FieldElement,borderColorObj),
+ { "-bordercolor",TK_OPTION_COLOR, offsetof(FieldElement,borderColorObj),
"black" },
- { NULL, 0, 0, NULL }
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void FieldElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
+ (void)dummy;
+ (void)elementRecord;
+ (void)tkwin;
+ (void)widthPtr;
+ (void)heightPtr;
+
*paddingPtr = Ttk_UniformPadding(2);
}
static void FieldElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- FieldElement *field = elementRecord;
+ FieldElement *field = (FieldElement *)elementRecord;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, field->borderObj);
XColor *borderColor = Tk_GetColorFromObj(tkwin, field->borderColorObj);
+ (void)dummy;
+ (void)state;
Tk_Fill3DRectangle(
tkwin, d, border, b.x, b.y, b.width, b.height, 0, TK_RELIEF_SUNKEN);
DrawFieldBorder(tkwin, d, border, borderColor, b);
}
-static Ttk_ElementSpec FieldElementSpec = {
+static const Ttk_ElementSpec FieldElementSpec = {
TK_STYLE_VERSION_2,
sizeof(FieldElement),
FieldElementOptions,
@@ -375,7 +387,7 @@ typedef struct {
int height; /* Height of each image */
int nimages; /* #images / row */
const char *const *pixels; /* array[height] of char[width*nimage] */
- Ttk_StateTable *map;/* used to look up image index by state */
+ const Ttk_StateTable *map;/* used to look up image index by state */
} IndicatorSpec;
#if 0
@@ -395,7 +407,7 @@ static const char *const button_images[] = {
};
#endif
-static Ttk_StateTable checkbutton_states[] = {
+static const Ttk_StateTable checkbutton_states[] = {
{ 0, 0, TTK_STATE_SELECTED|TTK_STATE_DISABLED },
{ 1, TTK_STATE_SELECTED, TTK_STATE_DISABLED },
{ 2, TTK_STATE_DISABLED, TTK_STATE_SELECTED },
@@ -425,7 +437,7 @@ static IndicatorSpec checkbutton_spec = {
checkbutton_states
};
-static Ttk_StateTable radiobutton_states[] = {
+static const Ttk_StateTable radiobutton_states[] = {
{ 0, 0, TTK_STATE_SELECTED|TTK_STATE_DISABLED },
{ 1, TTK_STATE_SELECTED, TTK_STATE_DISABLED },
{ 2, TTK_STATE_DISABLED, TTK_STATE_SELECTED },
@@ -465,31 +477,33 @@ typedef struct {
Tcl_Obj *marginObj;
} IndicatorElement;
-static Ttk_ElementOptionSpec IndicatorElementOptions[] = {
+static const Ttk_ElementOptionSpec IndicatorElementOptions[] = {
{ "-background", TK_OPTION_COLOR,
- Tk_Offset(IndicatorElement,backgroundObj), DEFAULT_BACKGROUND },
+ offsetof(IndicatorElement,backgroundObj), DEFAULT_BACKGROUND },
{ "-foreground", TK_OPTION_COLOR,
- Tk_Offset(IndicatorElement,foregroundObj), DEFAULT_FOREGROUND },
+ offsetof(IndicatorElement,foregroundObj), DEFAULT_FOREGROUND },
{ "-indicatorcolor", TK_OPTION_COLOR,
- Tk_Offset(IndicatorElement,colorObj), "#FFFFFF" },
+ offsetof(IndicatorElement,colorObj), "#FFFFFF" },
{ "-lightcolor", TK_OPTION_COLOR,
- Tk_Offset(IndicatorElement,lightColorObj), "#DDDDDD" },
+ offsetof(IndicatorElement,lightColorObj), "#DDDDDD" },
{ "-shadecolor", TK_OPTION_COLOR,
- Tk_Offset(IndicatorElement,shadeColorObj), "#888888" },
+ offsetof(IndicatorElement,shadeColorObj), "#888888" },
{ "-bordercolor", TK_OPTION_COLOR,
- Tk_Offset(IndicatorElement,borderColorObj), "black" },
+ offsetof(IndicatorElement,borderColorObj), "black" },
{ "-indicatormargin", TK_OPTION_STRING,
- Tk_Offset(IndicatorElement,marginObj), "0 2 4 2" },
- { NULL, 0, 0, NULL }
+ offsetof(IndicatorElement,marginObj), "0 2 4 2" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void IndicatorElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- IndicatorSpec *spec = clientData;
- IndicatorElement *indicator = elementRecord;
+ IndicatorSpec *spec = (IndicatorSpec *)clientData;
+ IndicatorElement *indicator = (IndicatorElement *)elementRecord;
Ttk_Padding margins;
+ (void)paddingPtr;
+
Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &margins);
*widthPtr = spec->width + Ttk_PaddingWidth(margins);
*heightPtr = spec->height + Ttk_PaddingHeight(margins);
@@ -499,8 +513,8 @@ static void IndicatorElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- IndicatorSpec *spec = clientData;
- IndicatorElement *indicator = elementRecord;
+ IndicatorSpec *spec = (IndicatorSpec *)clientData;
+ IndicatorElement *indicator = (IndicatorElement *)elementRecord;
Display *display = Tk_Display(tkwin);
Ttk_Padding padding;
XColor *fgColor, *frameColor, *shadeColor, *indicatorColor, *borderColor;
@@ -579,7 +593,7 @@ static void IndicatorElementDraw(
#if defined(IGNORES_VISUAL)
- img->data = ckalloc(img->bytes_per_line * img->height);
+ img->data = (char *)ckalloc(img->bytes_per_line * img->height);
if (img->data == NULL) {
XDestroyImage(img);
return;
@@ -628,7 +642,7 @@ static void IndicatorElementDraw(
XDestroyImage(img);
}
-static Ttk_ElementSpec IndicatorElementSpec = {
+static const Ttk_ElementSpec IndicatorElementSpec = {
TK_STYLE_VERSION_2,
sizeof(IndicatorElement),
IndicatorElementOptions,
@@ -643,7 +657,6 @@ static Ttk_ElementSpec IndicatorElementSpec = {
* clientData is an enum ArrowDirection pointer.
*/
-static int ArrowElements[] = { ARROW_UP, ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT };
typedef struct {
Tcl_Obj *sizeObj;
Tcl_Obj *borderObj;
@@ -652,18 +665,18 @@ typedef struct {
Tcl_Obj *colorObj; /* Arrow color */
} ArrowElement;
-static Ttk_ElementOptionSpec ArrowElementOptions[] = {
+static const Ttk_ElementOptionSpec ArrowElementOptions[] = {
{ "-arrowsize", TK_OPTION_PIXELS,
- Tk_Offset(ArrowElement,sizeObj), STRINGIFY(SCROLLBAR_WIDTH) },
+ offsetof(ArrowElement,sizeObj), STRINGIFY(SCROLLBAR_WIDTH) },
{ "-background", TK_OPTION_BORDER,
- Tk_Offset(ArrowElement,borderObj), DEFAULT_BACKGROUND },
+ offsetof(ArrowElement,borderObj), DEFAULT_BACKGROUND },
{ "-bordercolor", TK_OPTION_COLOR,
- Tk_Offset(ArrowElement,borderColorObj), "black" },
+ offsetof(ArrowElement,borderColorObj), "black" },
{ "-relief", TK_OPTION_RELIEF,
- Tk_Offset(ArrowElement,reliefObj),"raised"},
+ offsetof(ArrowElement,reliefObj),"raised"},
{ "-arrowcolor", TK_OPTION_COLOR,
- Tk_Offset(ArrowElement,colorObj),"black"},
- { NULL, 0, 0, NULL }
+ offsetof(ArrowElement,colorObj),"black"},
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
/*
@@ -671,15 +684,16 @@ static Ttk_ElementOptionSpec ArrowElementOptions[] = {
* top/left padding is 1 less than bottom/right,
* since in this theme 2-pixel borders are asymmetric.
*/
-static Ttk_Padding ArrowPadding = { 3,3,4,4 };
+static const Ttk_Padding ArrowPadding = { 3,3,4,4 };
static void ArrowElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- ArrowElement *arrow = elementRecord;
- int direction = *(int *)clientData;
+ ArrowElement *arrow = (ArrowElement *)elementRecord;
+ ArrowDirection direction = (ArrowDirection)PTR2INT(clientData);
int width = SCROLLBAR_WIDTH;
+ (void)paddingPtr;
Tk_GetPixelsFromObj(NULL, tkwin, arrow->sizeObj, &width);
width -= Ttk_PaddingWidth(ArrowPadding);
@@ -692,13 +706,14 @@ static void ArrowElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- int direction = *(int *)clientData;
- ArrowElement *arrow = elementRecord;
+ ArrowDirection direction = (ArrowDirection)PTR2INT(clientData);
+ ArrowElement *arrow = (ArrowElement *)elementRecord;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, arrow->borderObj);
XColor *borderColor = Tk_GetColorFromObj(tkwin, arrow->borderColorObj);
XColor *arrowColor = Tk_GetColorFromObj(tkwin, arrow->colorObj);
int relief = TK_RELIEF_RAISED;
int borderWidth = 2;
+ (void)state;
Tk_GetReliefFromObj(NULL, arrow->reliefObj, &relief);
@@ -710,7 +725,7 @@ static void ArrowElementDraw(
Ttk_PadBox(b, ArrowPadding), direction);
}
-static Ttk_ElementSpec ArrowElementSpec = {
+static const Ttk_ElementSpec ArrowElementSpec = {
TK_STYLE_VERSION_2,
sizeof(ArrowElement),
ArrowElementOptions,
@@ -731,29 +746,32 @@ typedef struct {
Tcl_Obj *colorObj;
} MenubuttonArrowElement;
-static const char *directionStrings[] = { /* See also: button.c */
+static const char *const directionStrings[] = { /* See also: button.c */
"above", "below", "left", "right", "flush", NULL
};
enum { POST_ABOVE, POST_BELOW, POST_LEFT, POST_RIGHT, POST_FLUSH };
-static Ttk_ElementOptionSpec MenubuttonArrowElementOptions[] = {
+static const Ttk_ElementOptionSpec MenubuttonArrowElementOptions[] = {
{ "-direction", TK_OPTION_STRING,
- Tk_Offset(MenubuttonArrowElement,directionObj), "below" },
+ offsetof(MenubuttonArrowElement,directionObj), "below" },
{ "-arrowsize", TK_OPTION_PIXELS,
- Tk_Offset(MenubuttonArrowElement,sizeObj), STRINGIFY(MENUBUTTON_ARROW_SIZE)},
+ offsetof(MenubuttonArrowElement,sizeObj), STRINGIFY(MENUBUTTON_ARROW_SIZE)},
{ "-arrowcolor",TK_OPTION_COLOR,
- Tk_Offset(MenubuttonArrowElement,colorObj), "black"},
- { NULL, 0, 0, NULL }
+ offsetof(MenubuttonArrowElement,colorObj), "black"},
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
-static Ttk_Padding MenubuttonArrowPadding = { 3, 0, 3, 0 };
+static const Ttk_Padding MenubuttonArrowPadding = { 3, 0, 3, 0 };
static void MenubuttonArrowElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- MenubuttonArrowElement *arrow = elementRecord;
+ MenubuttonArrowElement *arrow = (MenubuttonArrowElement *)elementRecord;
int size = MENUBUTTON_ARROW_SIZE;
+ (void)dummy;
+ (void)paddingPtr;
+
Tk_GetPixelsFromObj(NULL, tkwin, arrow->sizeObj, &size);
*widthPtr = *heightPtr = 2 * size + 1;
*widthPtr += Ttk_PaddingWidth(MenubuttonArrowPadding);
@@ -761,16 +779,18 @@ static void MenubuttonArrowElementSize(
}
static void MenubuttonArrowElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- MenubuttonArrowElement *arrow = elementRecord;
+ MenubuttonArrowElement *arrow = (MenubuttonArrowElement *)elementRecord;
XColor *arrowColor = Tk_GetColorFromObj(tkwin, arrow->colorObj);
GC gc = Tk_GCForColor(arrowColor, d);
int size = MENUBUTTON_ARROW_SIZE;
int postDirection = POST_BELOW;
ArrowDirection arrowDirection = ARROW_DOWN;
int width = 0, height = 0;
+ (void)dummy;
+ (void)state;
Tk_GetPixelsFromObj(NULL, tkwin, arrow->sizeObj, &size);
Tcl_GetIndexFromObjStruct(NULL, arrow->directionObj, directionStrings,
@@ -791,7 +811,7 @@ static void MenubuttonArrowElementDraw(
TtkFillArrow(Tk_Display(tkwin), d, gc, b, arrowDirection);
}
-static Ttk_ElementSpec MenubuttonArrowElementSpec = {
+static const Ttk_ElementSpec MenubuttonArrowElementSpec = {
TK_STYLE_VERSION_2,
sizeof(MenubuttonArrowElement),
MenubuttonArrowElementOptions,
@@ -820,26 +840,29 @@ typedef struct {
Tcl_Obj *orientObj;
} TroughElement;
-static Ttk_ElementOptionSpec TroughElementOptions[] = {
+static const Ttk_ElementOptionSpec TroughElementOptions[] = {
{ "-orient", TK_OPTION_ANY,
- Tk_Offset(TroughElement, orientObj), "horizontal" },
+ offsetof(TroughElement, orientObj), "horizontal" },
{ "-troughborderwidth", TK_OPTION_PIXELS,
- Tk_Offset(TroughElement,borderWidthObj), "1" },
+ offsetof(TroughElement,borderWidthObj), "1" },
{ "-troughcolor", TK_OPTION_BORDER,
- Tk_Offset(TroughElement,colorObj), DEFAULT_BACKGROUND },
+ offsetof(TroughElement,colorObj), DEFAULT_BACKGROUND },
{ "-troughrelief",TK_OPTION_RELIEF,
- Tk_Offset(TroughElement,reliefObj), "sunken" },
+ offsetof(TroughElement,reliefObj), "sunken" },
{ "-groovewidth", TK_OPTION_PIXELS,
- Tk_Offset(TroughElement,grooveWidthObj), "-1" },
- { NULL, 0, 0, NULL }
+ offsetof(TroughElement,grooveWidthObj), "-1" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void TroughElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- TroughElement *troughPtr = elementRecord;
+ TroughElement *troughPtr = (TroughElement *)elementRecord;
int borderWidth = 2, grooveWidth = 0;
+ (void)dummy;
+ (void)widthPtr;
+ (void)heightPtr;
Tk_GetPixelsFromObj(NULL, tkwin, troughPtr->borderWidthObj, &borderWidth);
Tk_GetPixelsFromObj(NULL, tkwin, troughPtr->grooveWidthObj, &grooveWidth);
@@ -850,15 +873,18 @@ static void TroughElementSize(
}
static void TroughElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- TroughElement *troughPtr = elementRecord;
+ TroughElement *troughPtr = (TroughElement *)elementRecord;
Tk_3DBorder border = NULL;
- int borderWidth = 2, relief = TK_RELIEF_SUNKEN, groove = -1, orient;
+ int borderWidth = 2, relief = TK_RELIEF_SUNKEN, groove = -1;
+ Ttk_Orient orient;
+ (void)dummy;
+ (void)state;
border = Tk_Get3DBorderFromObj(tkwin, troughPtr->colorObj);
- Ttk_GetOrientFromObj(NULL, troughPtr->orientObj, &orient);
+ TtkGetOrientFromObj(NULL, troughPtr->orientObj, &orient);
Tk_GetReliefFromObj(NULL, troughPtr->reliefObj, &relief);
Tk_GetPixelsFromObj(NULL, tkwin, troughPtr->borderWidthObj, &borderWidth);
Tk_GetPixelsFromObj(NULL, tkwin, troughPtr->grooveWidthObj, &groove);
@@ -877,7 +903,7 @@ static void TroughElementDraw(
borderWidth, relief);
}
-static Ttk_ElementSpec TroughElementSpec = {
+static const Ttk_ElementSpec TroughElementSpec = {
TK_STYLE_VERSION_2,
sizeof(TroughElement),
TroughElementOptions,
@@ -900,26 +926,30 @@ typedef struct {
Tcl_Obj *orientObj;
} ThumbElement;
-static Ttk_ElementOptionSpec ThumbElementOptions[] = {
- { "-width", TK_OPTION_PIXELS, Tk_Offset(ThumbElement,sizeObj),
+static const Ttk_ElementOptionSpec ThumbElementOptions[] = {
+ { "-width", TK_OPTION_PIXELS, offsetof(ThumbElement,sizeObj),
STRINGIFY(SCROLLBAR_WIDTH) },
- { "-background", TK_OPTION_BORDER, Tk_Offset(ThumbElement,borderObj),
+ { "-background", TK_OPTION_BORDER, offsetof(ThumbElement,borderObj),
DEFAULT_BACKGROUND },
- { "-bordercolor", TK_OPTION_COLOR, Tk_Offset(ThumbElement,borderColorObj),
+ { "-bordercolor", TK_OPTION_COLOR, offsetof(ThumbElement,borderColorObj),
"black" },
- { "-relief", TK_OPTION_RELIEF,Tk_Offset(ThumbElement,reliefObj),"raised" },
- { "-orient", TK_OPTION_ANY,Tk_Offset(ThumbElement,orientObj),"horizontal"},
- { NULL, 0, 0, NULL }
+ { "-relief", TK_OPTION_RELIEF, offsetof(ThumbElement,reliefObj),"raised" },
+ { "-orient", TK_OPTION_ANY, offsetof(ThumbElement,orientObj),"horizontal"},
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void ThumbElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- ThumbElement *thumb = elementRecord;
- int orient, size;
+ ThumbElement *thumb = (ThumbElement *)elementRecord;
+ Ttk_Orient orient;
+ int size;
+ (void)dummy;
+ (void)paddingPtr;
+
Tk_GetPixelsFromObj(NULL, tkwin, thumb->sizeObj, &size);
- Ttk_GetOrientFromObj(NULL, thumb->orientObj, &orient);
+ TtkGetOrientFromObj(NULL, thumb->orientObj, &orient);
if (orient == TTK_ORIENT_VERTICAL) {
*widthPtr = size;
@@ -931,14 +961,16 @@ static void ThumbElementSize(
}
static void ThumbElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- ThumbElement *thumb = elementRecord;
+ ThumbElement *thumb = (ThumbElement *)elementRecord;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, thumb->borderObj);
XColor *borderColor = Tk_GetColorFromObj(tkwin, thumb->borderColorObj);
int relief = TK_RELIEF_RAISED;
int borderWidth = 2;
+ (void)dummy;
+ (void)state;
/*
* Don't draw the thumb if we are disabled.
@@ -954,7 +986,7 @@ static void ThumbElementDraw(
DrawBorder(tkwin, d, border, borderColor, b, borderWidth, relief);
}
-static Ttk_ElementSpec ThumbElementSpec = {
+static const Ttk_ElementSpec ThumbElementSpec = {
TK_STYLE_VERSION_2,
sizeof(ThumbElement),
ThumbElementOptions,
@@ -983,32 +1015,35 @@ typedef struct {
Tcl_Obj *orientObj; /* Orientation of overall slider */
} SliderElement;
-static Ttk_ElementOptionSpec SliderElementOptions[] = {
- { "-sliderlength", TK_OPTION_PIXELS, Tk_Offset(SliderElement,lengthObj),
+static const Ttk_ElementOptionSpec SliderElementOptions[] = {
+ { "-sliderlength", TK_OPTION_PIXELS, offsetof(SliderElement,lengthObj),
"15" },
- { "-sliderthickness",TK_OPTION_PIXELS,Tk_Offset(SliderElement,thicknessObj),
+ { "-sliderthickness",TK_OPTION_PIXELS, offsetof(SliderElement,thicknessObj),
"15" },
- { "-sliderrelief", TK_OPTION_RELIEF, Tk_Offset(SliderElement,reliefObj),
+ { "-sliderrelief", TK_OPTION_RELIEF, offsetof(SliderElement,reliefObj),
"raised" },
- { "-borderwidth", TK_OPTION_PIXELS, Tk_Offset(SliderElement,borderWidthObj),
+ { "-borderwidth", TK_OPTION_PIXELS, offsetof(SliderElement,borderWidthObj),
STRINGIFY(BORDERWIDTH) },
- { "-background", TK_OPTION_BORDER, Tk_Offset(SliderElement,borderObj),
+ { "-background", TK_OPTION_BORDER, offsetof(SliderElement,borderObj),
DEFAULT_BACKGROUND },
- { "-bordercolor", TK_OPTION_COLOR, Tk_Offset(ThumbElement,borderColorObj),
+ { "-bordercolor", TK_OPTION_COLOR, offsetof(ThumbElement,borderColorObj),
"black" },
- { "-orient", TK_OPTION_ANY, Tk_Offset(SliderElement,orientObj),
+ { "-orient", TK_OPTION_ANY, offsetof(SliderElement,orientObj),
"horizontal" },
- { NULL, 0, 0, NULL }
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void SliderElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- SliderElement *slider = elementRecord;
- int orient, length, thickness, borderWidth;
+ SliderElement *slider = (SliderElement *)elementRecord;
+ Ttk_Orient orient;
+ int length, thickness, borderWidth;
+ (void)dummy;
+ (void)paddingPtr;
- Ttk_GetOrientFromObj(NULL, slider->orientObj, &orient);
+ TtkGetOrientFromObj(NULL, slider->orientObj, &orient);
Tk_GetPixelsFromObj(NULL, tkwin, slider->borderWidthObj, &borderWidth);
Tk_GetPixelsFromObj(NULL, tkwin, slider->lengthObj, &length);
Tk_GetPixelsFromObj(NULL, tkwin, slider->thicknessObj, &thickness);
@@ -1027,13 +1062,15 @@ static void SliderElementSize(
}
static void SliderElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- SliderElement *slider = elementRecord;
+ SliderElement *slider = (SliderElement *)elementRecord;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, slider->borderObj);
XColor *borderColor = Tk_GetColorFromObj(tkwin, slider->borderColorObj);
int relief = TK_RELIEF_RAISED, borderWidth = 2;
+ (void)dummy;
+ (void)state;
Tk_GetPixelsFromObj(NULL, tkwin, slider->borderWidthObj, &borderWidth);
Tk_GetReliefFromObj(NULL, slider->reliefObj, &relief);
@@ -1044,7 +1081,7 @@ static void SliderElementDraw(
DrawBorder(tkwin, d, border, borderColor, b, borderWidth, relief);
}
-static Ttk_ElementSpec SliderElementSpec = {
+static const Ttk_ElementSpec SliderElementSpec = {
TK_STYLE_VERSION_2,
sizeof(SliderElement),
SliderElementOptions,
@@ -1065,23 +1102,25 @@ typedef struct {
Tcl_Obj *diameterObj;
} TreeitemIndicator;
-static Ttk_ElementOptionSpec TreeitemIndicatorOptions[] = {
+static const Ttk_ElementOptionSpec TreeitemIndicatorOptions[] = {
{ "-foreground", TK_OPTION_COLOR,
- Tk_Offset(TreeitemIndicator,colorObj), DEFAULT_FOREGROUND },
+ offsetof(TreeitemIndicator,colorObj), DEFAULT_FOREGROUND },
{ "-diameter", TK_OPTION_PIXELS,
- Tk_Offset(TreeitemIndicator,diameterObj), "9" },
+ offsetof(TreeitemIndicator,diameterObj), "9" },
{ "-indicatormargins", TK_OPTION_STRING,
- Tk_Offset(TreeitemIndicator,marginObj), "2 2 4 2" },
- { NULL, 0, 0, NULL }
+ offsetof(TreeitemIndicator,marginObj), "2 2 4 2" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void TreeitemIndicatorSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- TreeitemIndicator *indicator = elementRecord;
+ TreeitemIndicator *indicator = (TreeitemIndicator *)elementRecord;
int diameter = 0;
Ttk_Padding margins;
+ (void)dummy;
+ (void)paddingPtr;
Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &margins);
Tk_GetPixelsFromObj(NULL, tkwin, indicator->diameterObj, &diameter);
@@ -1090,15 +1129,16 @@ static void TreeitemIndicatorSize(
}
static void TreeitemIndicatorDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, Ttk_State state)
{
- TreeitemIndicator *indicator = elementRecord;
+ TreeitemIndicator *indicator = (TreeitemIndicator *)elementRecord;
XColor *color = Tk_GetColorFromObj(tkwin, indicator->colorObj);
GC gc = Tk_GCForColor(color, d);
Ttk_Padding padding = Ttk_UniformPadding(0);
int w = WIN32_XDRAWLINE_HACK;
int cx, cy;
+ (void)dummy;
if (state & TTK_STATE_LEAF) {
/* don't draw anything ... */
@@ -1121,7 +1161,7 @@ static void TreeitemIndicatorDraw(
}
}
-static Ttk_ElementSpec TreeitemIndicatorElementSpec = {
+static const Ttk_ElementSpec TreeitemIndicatorElementSpec = {
TK_STYLE_VERSION_2,
sizeof(TreeitemIndicator),
TreeitemIndicatorOptions,
@@ -1157,18 +1197,15 @@ MODULE_SCOPE int TtkAltTheme_Init(Tcl_Interp *interp)
Ttk_RegisterElement(interp, theme, "slider", &SliderElementSpec, NULL);
Ttk_RegisterElement(interp, theme, "uparrow",
- &ArrowElementSpec, &ArrowElements[0]);
+ &ArrowElementSpec, INT2PTR(ARROW_UP));
Ttk_RegisterElement(interp, theme, "downarrow",
- &ArrowElementSpec, &ArrowElements[1]);
+ &ArrowElementSpec, INT2PTR(ARROW_DOWN));
Ttk_RegisterElement(interp, theme, "leftarrow",
- &ArrowElementSpec, &ArrowElements[2]);
+ &ArrowElementSpec, INT2PTR(ARROW_LEFT));
Ttk_RegisterElement(interp, theme, "rightarrow",
- &ArrowElementSpec, &ArrowElements[3]);
- Ttk_RegisterElement(interp, theme, "arrow",
- &ArrowElementSpec, &ArrowElements[0]);
-
+ &ArrowElementSpec, INT2PTR(ARROW_RIGHT));
Ttk_RegisterElement(interp, theme, "arrow",
- &ArrowElementSpec, &ArrowElements[0]);
+ &ArrowElementSpec, INT2PTR(ARROW_UP));
Ttk_RegisterElement(interp, theme, "Treeitem.indicator",
&TreeitemIndicatorElementSpec, 0);
diff --git a/generic/ttk/ttkElements.c b/generic/ttk/ttkElements.c
index c4469dc..a1cac4d 100644
--- a/generic/ttk/ttkElements.c
+++ b/generic/ttk/ttkElements.c
@@ -6,7 +6,6 @@
*/
#include "tkInt.h"
-#include <string.h>
#include "ttkTheme.h"
#include "ttkWidget.h"
@@ -20,20 +19,32 @@
* and may be used in other engines.
*/
-/* public */ Ttk_ElementOptionSpec TtkNullElementOptions[] = { { NULL, 0, 0, NULL } };
+/* public */ const Ttk_ElementOptionSpec TtkNullElementOptions[] = { { NULL, TK_OPTION_BOOLEAN, 0, NULL } };
/* public */ void
TtkNullElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
+ (void)dummy;
+ (void)elementRecord;
+ (void)tkwin;
+ (void)widthPtr;
+ (void)heightPtr;
+ (void)paddingPtr;
}
/* public */ void
TtkNullElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
+ (void)dummy;
+ (void)elementRecord;
+ (void)tkwin;
+ (void)d;
+ (void)b;
+ (void)state;
}
/* public */ Ttk_ElementSpec ttkNullElementSpec = {
@@ -57,18 +68,20 @@ typedef struct {
Tcl_Obj *backgroundObj;
} BackgroundElement;
-static Ttk_ElementOptionSpec BackgroundElementOptions[] = {
+static const Ttk_ElementOptionSpec BackgroundElementOptions[] = {
{ "-background", TK_OPTION_BORDER,
- Tk_Offset(BackgroundElement,backgroundObj), DEFAULT_BACKGROUND },
- { NULL, 0, 0, NULL }
+ offsetof(BackgroundElement,backgroundObj), DEFAULT_BACKGROUND },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void FillElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- BackgroundElement *bg = elementRecord;
+ BackgroundElement *bg = (BackgroundElement *)elementRecord;
Tk_3DBorder backgroundPtr = Tk_Get3DBorderFromObj(tkwin,bg->backgroundObj);
+ (void)dummy;
+ (void)state;
XFillRectangle(Tk_Display(tkwin), d,
Tk_3DBorderGC(tkwin, backgroundPtr, TK_3D_FLAT_GC),
@@ -79,12 +92,14 @@ static void BackgroundElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
+ (void)b;
+
FillElementDraw(
clientData, elementRecord, tkwin,
d, Ttk_WinBox(tkwin), state);
}
-static Ttk_ElementSpec FillElementSpec = {
+static const Ttk_ElementSpec FillElementSpec = {
TK_STYLE_VERSION_2,
sizeof(BackgroundElement),
BackgroundElementOptions,
@@ -92,7 +107,7 @@ static Ttk_ElementSpec FillElementSpec = {
FillElementDraw
};
-static Ttk_ElementSpec BackgroundElementSpec = {
+static const Ttk_ElementSpec BackgroundElementSpec = {
TK_STYLE_VERSION_2,
sizeof(BackgroundElement),
BackgroundElementOptions,
@@ -110,33 +125,40 @@ typedef struct {
Tcl_Obj *reliefObj;
} BorderElement;
-static Ttk_ElementOptionSpec BorderElementOptions[] = {
+static const Ttk_ElementOptionSpec BorderElementOptions[] = {
{ "-background", TK_OPTION_BORDER,
- Tk_Offset(BorderElement,borderObj), DEFAULT_BACKGROUND },
+ offsetof(BorderElement,borderObj), DEFAULT_BACKGROUND },
{ "-borderwidth", TK_OPTION_PIXELS,
- Tk_Offset(BorderElement,borderWidthObj), DEFAULT_BORDERWIDTH },
+ offsetof(BorderElement,borderWidthObj), DEFAULT_BORDERWIDTH },
{ "-relief", TK_OPTION_RELIEF,
- Tk_Offset(BorderElement,reliefObj), "flat" },
- { NULL, 0, 0, NULL }
+ offsetof(BorderElement,reliefObj), "flat" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void BorderElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- BorderElement *bd = elementRecord;
+ BorderElement *bd = (BorderElement *)elementRecord;
int borderWidth = 0;
+ (void)dummy;
+ (void)tkwin;
+ (void)widthPtr;
+ (void)heightPtr;
+
Tcl_GetIntFromObj(NULL, bd->borderWidthObj, &borderWidth);
*paddingPtr = Ttk_UniformPadding((short)borderWidth);
}
static void BorderElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- BorderElement *bd = elementRecord;
+ BorderElement *bd = (BorderElement *)elementRecord;
Tk_3DBorder border = NULL;
int borderWidth = 1, relief = TK_RELIEF_FLAT;
+ (void)dummy;
+ (void)state;
border = Tk_Get3DBorderFromObj(tkwin, bd->borderObj);
Tcl_GetIntFromObj(NULL, bd->borderWidthObj, &borderWidth);
@@ -148,7 +170,7 @@ static void BorderElementDraw(
}
}
-static Ttk_ElementSpec BorderElementSpec = {
+static const Ttk_ElementSpec BorderElementSpec = {
TK_STYLE_VERSION_2,
sizeof(BorderElement),
BorderElementOptions,
@@ -165,38 +187,44 @@ typedef struct {
Tcl_Obj *borderWidthObj;
} FieldElement;
-static Ttk_ElementOptionSpec FieldElementOptions[] = {
+static const Ttk_ElementOptionSpec FieldElementOptions[] = {
{ "-fieldbackground", TK_OPTION_BORDER,
- Tk_Offset(FieldElement,borderObj), "white" },
+ offsetof(FieldElement,borderObj), "white" },
{ "-borderwidth", TK_OPTION_PIXELS,
- Tk_Offset(FieldElement,borderWidthObj), "2" },
- { NULL, 0, 0, NULL }
+ offsetof(FieldElement,borderWidthObj), "2" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void FieldElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- FieldElement *field = elementRecord;
+ FieldElement *field = (FieldElement *)elementRecord;
int borderWidth = 2;
+ (void)dummy;
+ (void)widthPtr;
+ (void)heightPtr;
+
Tk_GetPixelsFromObj(NULL, tkwin, field->borderWidthObj, &borderWidth);
*paddingPtr = Ttk_UniformPadding((short)borderWidth);
}
static void FieldElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- FieldElement *field = elementRecord;
+ FieldElement *field = (FieldElement *)elementRecord;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, field->borderObj);
int borderWidth = 2;
+ (void)dummy;
+ (void)state;
Tk_GetPixelsFromObj(NULL, tkwin, field->borderWidthObj, &borderWidth);
Tk_Fill3DRectangle(tkwin, d, border,
b.x, b.y, b.width, b.height, borderWidth, TK_RELIEF_SUNKEN);
}
-static Ttk_ElementSpec FieldElementSpec = {
+static const Ttk_ElementSpec FieldElementSpec = {
TK_STYLE_VERSION_2,
sizeof(FieldElement),
FieldElementOptions,
@@ -221,24 +249,27 @@ typedef struct {
Tcl_Obj *shiftreliefObj;
} PaddingElement;
-static Ttk_ElementOptionSpec PaddingElementOptions[] = {
+static const Ttk_ElementOptionSpec PaddingElementOptions[] = {
{ "-padding", TK_OPTION_STRING,
- Tk_Offset(PaddingElement,paddingObj), "0" },
+ offsetof(PaddingElement,paddingObj), "0" },
{ "-relief", TK_OPTION_RELIEF,
- Tk_Offset(PaddingElement,reliefObj), "flat" },
+ offsetof(PaddingElement,reliefObj), "flat" },
{ "-shiftrelief", TK_OPTION_INT,
- Tk_Offset(PaddingElement,shiftreliefObj), "0" },
- { NULL, 0, 0, NULL }
+ offsetof(PaddingElement,shiftreliefObj), "0" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void PaddingElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- PaddingElement *padding = elementRecord;
+ PaddingElement *padding = (PaddingElement *)elementRecord;
int shiftRelief = 0;
int relief = TK_RELIEF_FLAT;
Ttk_Padding pad;
+ (void)dummy;
+ (void)widthPtr;
+ (void)heightPtr;
Tk_GetReliefFromObj(NULL, padding->reliefObj, &relief);
Tcl_GetIntFromObj(NULL, padding->shiftreliefObj, &shiftRelief);
@@ -246,7 +277,7 @@ static void PaddingElementSize(
*paddingPtr = Ttk_RelievePadding(pad, relief, shiftRelief);
}
-static Ttk_ElementSpec PaddingElementSpec = {
+static const Ttk_ElementSpec PaddingElementSpec = {
TK_STYLE_VERSION_2,
sizeof(PaddingElement),
PaddingElementOptions,
@@ -287,31 +318,36 @@ static void DrawFocusRing(
Tk_FreeGC(Tk_Display(tkwin), gc);
}
-static Ttk_ElementOptionSpec FocusElementOptions[] = {
+static const Ttk_ElementOptionSpec FocusElementOptions[] = {
{ "-focuscolor",TK_OPTION_COLOR,
- Tk_Offset(FocusElement,focusColorObj), "black" },
+ offsetof(FocusElement,focusColorObj), "black" },
{ "-focusthickness",TK_OPTION_PIXELS,
- Tk_Offset(FocusElement,focusThicknessObj), "1" },
- { NULL, 0, 0, NULL }
+ offsetof(FocusElement,focusThicknessObj), "1" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void FocusElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- FocusElement *focus = elementRecord;
+ FocusElement *focus = (FocusElement *)elementRecord;
int focusThickness = 0;
+ (void)dummy;
+ (void)tkwin;
+ (void)widthPtr;
+ (void)heightPtr;
Tcl_GetIntFromObj(NULL, focus->focusThicknessObj, &focusThickness);
*paddingPtr = Ttk_UniformPadding((short)focusThickness);
}
static void FocusElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- FocusElement *focus = elementRecord;
+ FocusElement *focus = (FocusElement *)elementRecord;
int focusThickness = 0;
+ (void)dummy;
if (state & TTK_STATE_FOCUS) {
Tcl_GetIntFromObj(NULL,focus->focusThicknessObj,&focusThickness);
@@ -319,7 +355,7 @@ static void FocusElementDraw(
}
}
-static Ttk_ElementSpec FocusElementSpec = {
+static const Ttk_ElementSpec FocusElementSpec = {
TK_STYLE_VERSION_2,
sizeof(FocusElement),
FocusElementOptions,
@@ -339,42 +375,51 @@ typedef struct {
Tcl_Obj *borderObj;
} SeparatorElement;
-static Ttk_ElementOptionSpec SeparatorElementOptions[] = {
+static const Ttk_ElementOptionSpec SeparatorElementOptions[] = {
{ "-orient", TK_OPTION_ANY,
- Tk_Offset(SeparatorElement, orientObj), "horizontal" },
+ offsetof(SeparatorElement, orientObj), "horizontal" },
{ "-background", TK_OPTION_BORDER,
- Tk_Offset(SeparatorElement,borderObj), DEFAULT_BACKGROUND },
- { NULL, 0, 0, NULL }
+ offsetof(SeparatorElement,borderObj), DEFAULT_BACKGROUND },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void SeparatorElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
+ (void)dummy;
+ (void)elementRecord;
+ (void)tkwin;
+ (void)paddingPtr;
+
*widthPtr = *heightPtr = 2;
}
static void HorizontalSeparatorElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- SeparatorElement *separator = elementRecord;
+ SeparatorElement *separator = (SeparatorElement *)elementRecord;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, separator->borderObj);
GC lightGC = Tk_3DBorderGC(tkwin, border, TK_3D_LIGHT_GC);
GC darkGC = Tk_3DBorderGC(tkwin, border, TK_3D_DARK_GC);
+ (void)dummy;
+ (void)state;
XDrawLine(Tk_Display(tkwin), d, darkGC, b.x, b.y, b.x + b.width, b.y);
XDrawLine(Tk_Display(tkwin), d, lightGC, b.x, b.y+1, b.x + b.width, b.y+1);
}
static void VerticalSeparatorElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- SeparatorElement *separator = elementRecord;
+ SeparatorElement *separator = (SeparatorElement *)elementRecord;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, separator->borderObj);
GC lightGC = Tk_3DBorderGC(tkwin, border, TK_3D_LIGHT_GC);
GC darkGC = Tk_3DBorderGC(tkwin, border, TK_3D_DARK_GC);
+ (void)dummy;
+ (void)state;
XDrawLine(Tk_Display(tkwin), d, darkGC, b.x, b.y, b.x, b.y + b.height);
XDrawLine(Tk_Display(tkwin), d, lightGC, b.x+1, b.y, b.x+1, b.y+b.height);
@@ -384,9 +429,10 @@ static void GeneralSeparatorElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- SeparatorElement *separator = elementRecord;
- int orient;
- Ttk_GetOrientFromObj(NULL, separator->orientObj, &orient);
+ SeparatorElement *separator = (SeparatorElement *)elementRecord;
+ Ttk_Orient orient;
+
+ TtkGetOrientFromObj(NULL, separator->orientObj, &orient);
switch (orient) {
case TTK_ORIENT_HORIZONTAL:
HorizontalSeparatorElementDraw(
@@ -399,7 +445,7 @@ static void GeneralSeparatorElementDraw(
}
}
-static Ttk_ElementSpec HorizontalSeparatorElementSpec = {
+static const Ttk_ElementSpec HorizontalSeparatorElementSpec = {
TK_STYLE_VERSION_2,
sizeof(SeparatorElement),
SeparatorElementOptions,
@@ -407,7 +453,7 @@ static Ttk_ElementSpec HorizontalSeparatorElementSpec = {
HorizontalSeparatorElementDraw
};
-static Ttk_ElementSpec VerticalSeparatorElementSpec = {
+static const Ttk_ElementSpec VerticalSeparatorElementSpec = {
TK_STYLE_VERSION_2,
sizeof(SeparatorElement),
SeparatorElementOptions,
@@ -415,7 +461,7 @@ static Ttk_ElementSpec VerticalSeparatorElementSpec = {
HorizontalSeparatorElementDraw
};
-static Ttk_ElementSpec SeparatorElementSpec = {
+static const Ttk_ElementSpec SeparatorElementSpec = {
TK_STYLE_VERSION_2,
sizeof(SeparatorElement),
SeparatorElementOptions,
@@ -431,30 +477,37 @@ typedef struct {
Tcl_Obj *backgroundObj;
} SizegripElement;
-static Ttk_ElementOptionSpec SizegripOptions[] = {
+static const Ttk_ElementOptionSpec SizegripOptions[] = {
{ "-background", TK_OPTION_BORDER,
- Tk_Offset(SizegripElement,backgroundObj), DEFAULT_BACKGROUND },
- {0,0,0,0}
+ offsetof(SizegripElement,backgroundObj), DEFAULT_BACKGROUND },
+ {0,TK_OPTION_BOOLEAN,0,0}
};
static void SizegripSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
int gripCount = 3, gripSpace = 2, gripThickness = 3;
+ (void)dummy;
+ (void)elementRecord;
+ (void)tkwin;
+ (void)paddingPtr;
+
*widthPtr = *heightPtr = gripCount * (gripSpace + gripThickness);
}
static void SizegripDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, Ttk_State state)
{
- SizegripElement *grip = elementRecord;
+ SizegripElement *grip = (SizegripElement *)elementRecord;
int gripCount = 3, gripSpace = 2;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, grip->backgroundObj);
GC lightGC = Tk_3DBorderGC(tkwin, border, TK_3D_LIGHT_GC);
GC darkGC = Tk_3DBorderGC(tkwin, border, TK_3D_DARK_GC);
int x1 = b.x + b.width-1, y1 = b.y + b.height-1, x2 = x1, y2 = y1;
+ (void)dummy;
+ (void)state;
while (gripCount--) {
x1 -= gripSpace; y2 -= gripSpace;
@@ -464,7 +517,7 @@ static void SizegripDraw(
}
}
-static Ttk_ElementSpec SizegripElementSpec = {
+static const Ttk_ElementSpec SizegripElementSpec = {
TK_STYLE_VERSION_2,
sizeof(SizegripElement),
SizegripOptions,
@@ -492,32 +545,35 @@ typedef struct {
Tcl_Obj *borderWidthObj;
} IndicatorElement;
-static Ttk_ElementOptionSpec IndicatorElementOptions[] = {
+static const Ttk_ElementOptionSpec IndicatorElementOptions[] = {
{ "-background", TK_OPTION_BORDER,
- Tk_Offset(IndicatorElement,backgroundObj), DEFAULT_BACKGROUND },
+ offsetof(IndicatorElement,backgroundObj), DEFAULT_BACKGROUND },
{ "-indicatorcolor", TK_OPTION_BORDER,
- Tk_Offset(IndicatorElement,colorObj), DEFAULT_BACKGROUND },
+ offsetof(IndicatorElement,colorObj), DEFAULT_BACKGROUND },
{ "-indicatorrelief", TK_OPTION_RELIEF,
- Tk_Offset(IndicatorElement,reliefObj), "raised" },
+ offsetof(IndicatorElement,reliefObj), "raised" },
{ "-indicatordiameter", TK_OPTION_PIXELS,
- Tk_Offset(IndicatorElement,diameterObj), "12" },
+ offsetof(IndicatorElement,diameterObj), "12" },
{ "-indicatormargin", TK_OPTION_STRING,
- Tk_Offset(IndicatorElement,marginObj), "0 2 4 2" },
+ offsetof(IndicatorElement,marginObj), "0 2 4 2" },
{ "-borderwidth", TK_OPTION_PIXELS,
- Tk_Offset(IndicatorElement,borderWidthObj), DEFAULT_BORDERWIDTH },
- { NULL, 0, 0, NULL }
+ offsetof(IndicatorElement,borderWidthObj), DEFAULT_BORDERWIDTH },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
/*
* Checkbutton indicators (default): 3-D square.
*/
static void SquareIndicatorElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- IndicatorElement *indicator = elementRecord;
+ IndicatorElement *indicator = (IndicatorElement *)elementRecord;
Ttk_Padding margins;
int diameter = 0;
+ (void)dummy;
+ (void)paddingPtr;
+
Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &margins);
Tk_GetPixelsFromObj(NULL, tkwin, indicator->diameterObj, &diameter);
*widthPtr = diameter + Ttk_PaddingWidth(margins);
@@ -525,15 +581,17 @@ static void SquareIndicatorElementSize(
}
static void SquareIndicatorElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- IndicatorElement *indicator = elementRecord;
+ IndicatorElement *indicator = (IndicatorElement *)elementRecord;
Tk_3DBorder border = 0, interior = 0;
int relief = TK_RELIEF_RAISED;
Ttk_Padding padding;
int borderWidth = 2;
int diameter;
+ (void)dummy;
+ (void)state;
interior = Tk_Get3DBorderFromObj(tkwin, indicator->colorObj);
border = Tk_Get3DBorderFromObj(tkwin, indicator->backgroundObj);
@@ -554,12 +612,15 @@ static void SquareIndicatorElementDraw(
* Radiobutton indicators: 3-D diamond.
*/
static void DiamondIndicatorElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- IndicatorElement *indicator = elementRecord;
+ IndicatorElement *indicator = (IndicatorElement *)elementRecord;
Ttk_Padding margins;
int diameter = 0;
+ (void)dummy;
+ (void)paddingPtr;
+
Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &margins);
Tk_GetPixelsFromObj(NULL, tkwin, indicator->diameterObj, &diameter);
*widthPtr = diameter + 3 + Ttk_PaddingWidth(margins);
@@ -567,16 +628,18 @@ static void DiamondIndicatorElementSize(
}
static void DiamondIndicatorElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- IndicatorElement *indicator = elementRecord;
+ IndicatorElement *indicator = (IndicatorElement *)elementRecord;
Tk_3DBorder border = 0, interior = 0;
int borderWidth = 2;
int relief = TK_RELIEF_RAISED;
int diameter, radius;
XPoint points[4];
Ttk_Padding padding;
+ (void)dummy;
+ (void)state;
interior = Tk_Get3DBorderFromObj(tkwin, indicator->colorObj);
border = Tk_Get3DBorderFromObj(tkwin, indicator->backgroundObj);
@@ -602,7 +665,7 @@ static void DiamondIndicatorElementDraw(
Tk_Draw3DPolygon(tkwin,d,border,points,4,borderWidth,relief);
}
-static Ttk_ElementSpec CheckbuttonIndicatorElementSpec = {
+static const Ttk_ElementSpec CheckbuttonIndicatorElementSpec = {
TK_STYLE_VERSION_2,
sizeof(IndicatorElement),
IndicatorElementOptions,
@@ -610,7 +673,7 @@ static Ttk_ElementSpec CheckbuttonIndicatorElementSpec = {
SquareIndicatorElementDraw
};
-static Ttk_ElementSpec RadiobuttonIndicatorElementSpec = {
+static const Ttk_ElementSpec RadiobuttonIndicatorElementSpec = {
TK_STYLE_VERSION_2,
sizeof(IndicatorElement),
IndicatorElementOptions,
@@ -638,28 +701,31 @@ typedef struct {
Tcl_Obj *marginObj;
} MenuIndicatorElement;
-static Ttk_ElementOptionSpec MenuIndicatorElementOptions[] = {
+static const Ttk_ElementOptionSpec MenuIndicatorElementOptions[] = {
{ "-background", TK_OPTION_BORDER,
- Tk_Offset(MenuIndicatorElement,backgroundObj), DEFAULT_BACKGROUND },
+ offsetof(MenuIndicatorElement,backgroundObj), DEFAULT_BACKGROUND },
{ "-indicatorwidth", TK_OPTION_PIXELS,
- Tk_Offset(MenuIndicatorElement,widthObj), "4.0m" },
+ offsetof(MenuIndicatorElement,widthObj), "4.0m" },
{ "-indicatorheight", TK_OPTION_PIXELS,
- Tk_Offset(MenuIndicatorElement,heightObj), "1.7m" },
+ offsetof(MenuIndicatorElement,heightObj), "1.7m" },
{ "-borderwidth", TK_OPTION_PIXELS,
- Tk_Offset(MenuIndicatorElement,borderWidthObj), DEFAULT_BORDERWIDTH },
+ offsetof(MenuIndicatorElement,borderWidthObj), DEFAULT_BORDERWIDTH },
{ "-indicatorrelief", TK_OPTION_RELIEF,
- Tk_Offset(MenuIndicatorElement,reliefObj),"raised" },
+ offsetof(MenuIndicatorElement,reliefObj),"raised" },
{ "-indicatormargin", TK_OPTION_STRING,
- Tk_Offset(MenuIndicatorElement,marginObj), "5 0" },
- { NULL, 0, 0, NULL }
+ offsetof(MenuIndicatorElement,marginObj), "5 0" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void MenuIndicatorElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- MenuIndicatorElement *mi = elementRecord;
+ MenuIndicatorElement *mi = (MenuIndicatorElement *)elementRecord;
Ttk_Padding margins;
+ (void)dummy;
+ (void)paddingPtr;
+
Tk_GetPixelsFromObj(NULL, tkwin, mi->widthObj, widthPtr);
Tk_GetPixelsFromObj(NULL, tkwin, mi->heightObj, heightPtr);
Ttk_GetPaddingFromObj(NULL,tkwin,mi->marginObj, &margins);
@@ -668,13 +734,15 @@ static void MenuIndicatorElementSize(
}
static void MenuIndicatorElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- MenuIndicatorElement *mi = elementRecord;
+ MenuIndicatorElement *mi = (MenuIndicatorElement *)elementRecord;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, mi->backgroundObj);
Ttk_Padding margins;
int borderWidth = 2;
+ (void)dummy;
+ (void)state;
Ttk_GetPaddingFromObj(NULL,tkwin,mi->marginObj,&margins);
b = Ttk_PadBox(b, margins);
@@ -683,7 +751,7 @@ static void MenuIndicatorElementDraw(
borderWidth, TK_RELIEF_RAISED);
}
-static Ttk_ElementSpec MenuIndicatorElementSpec = {
+static const Ttk_ElementSpec MenuIndicatorElementSpec = {
TK_STYLE_VERSION_2,
sizeof(MenuIndicatorElement),
MenuIndicatorElementOptions,
@@ -698,7 +766,6 @@ static Ttk_ElementSpec MenuIndicatorElementSpec = {
* clientData is an enum ArrowDirection pointer.
*/
-static int ArrowElements[] = { ARROW_UP, ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT };
typedef struct {
Tcl_Obj *borderObj;
Tcl_Obj *borderWidthObj;
@@ -707,29 +774,30 @@ typedef struct {
Tcl_Obj *colorObj;
} ArrowElement;
-static Ttk_ElementOptionSpec ArrowElementOptions[] = {
+static const Ttk_ElementOptionSpec ArrowElementOptions[] = {
{ "-background", TK_OPTION_BORDER,
- Tk_Offset(ArrowElement,borderObj), DEFAULT_BACKGROUND },
+ offsetof(ArrowElement,borderObj), DEFAULT_BACKGROUND },
{ "-relief",TK_OPTION_RELIEF,
- Tk_Offset(ArrowElement,reliefObj),"raised"},
+ offsetof(ArrowElement,reliefObj),"raised"},
{ "-borderwidth", TK_OPTION_PIXELS,
- Tk_Offset(ArrowElement,borderWidthObj), "1" },
+ offsetof(ArrowElement,borderWidthObj), "1" },
{ "-arrowcolor",TK_OPTION_COLOR,
- Tk_Offset(ArrowElement,colorObj),"black"},
+ offsetof(ArrowElement,colorObj),"black"},
{ "-arrowsize", TK_OPTION_PIXELS,
- Tk_Offset(ArrowElement,sizeObj), "14" },
- { NULL, 0, 0, NULL }
+ offsetof(ArrowElement,sizeObj), "14" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
-static Ttk_Padding ArrowMargins = { 3,3,3,3 };
+static const Ttk_Padding ArrowMargins = { 3,3,3,3 };
static void ArrowElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- ArrowElement *arrow = elementRecord;
- int direction = *(int *)clientData;
+ ArrowElement *arrow = (ArrowElement *)elementRecord;
+ ArrowDirection direction = (ArrowDirection)PTR2INT(clientData);
int width = 14;
+ (void)paddingPtr;
Tk_GetPixelsFromObj(NULL, tkwin, arrow->sizeObj, &width);
width -= Ttk_PaddingWidth(ArrowMargins);
@@ -742,23 +810,24 @@ static void ArrowElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- int direction = *(int *)clientData;
- ArrowElement *arrow = elementRecord;
+ ArrowDirection direction = (ArrowDirection)PTR2INT(clientData);
+ ArrowElement *arrow = (ArrowElement *)elementRecord;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, arrow->borderObj);
XColor *arrowColor = Tk_GetColorFromObj(tkwin, arrow->colorObj);
int relief = TK_RELIEF_RAISED;
int borderWidth = 1;
+ (void)state;
Tk_GetReliefFromObj(NULL, arrow->reliefObj, &relief);
- Tk_Fill3DRectangle(
- tkwin, d, border, b.x, b.y, b.width, b.height, borderWidth, relief);
+ Tk_Fill3DRectangle( tkwin, d, border, b.x, b.y, b.width, b.height,
+ borderWidth, relief);
TtkFillArrow(Tk_Display(tkwin), d, Tk_GCForColor(arrowColor, d),
- Ttk_PadBox(b, ArrowMargins), direction);
+ Ttk_PadBox(b, ArrowMargins), direction);
}
-static Ttk_ElementSpec ArrowElementSpec = {
+static const Ttk_ElementSpec ArrowElementSpec = {
TK_STYLE_VERSION_2,
sizeof(ArrowElement),
ArrowElementOptions,
@@ -778,34 +847,39 @@ typedef struct {
Tcl_Obj *reliefObj;
} TroughElement;
-static Ttk_ElementOptionSpec TroughElementOptions[] = {
+static const Ttk_ElementOptionSpec TroughElementOptions[] = {
{ "-borderwidth", TK_OPTION_PIXELS,
- Tk_Offset(TroughElement,borderWidthObj), DEFAULT_BORDERWIDTH },
+ offsetof(TroughElement,borderWidthObj), DEFAULT_BORDERWIDTH },
{ "-troughcolor", TK_OPTION_BORDER,
- Tk_Offset(TroughElement,colorObj), DEFAULT_BACKGROUND },
+ offsetof(TroughElement,colorObj), DEFAULT_BACKGROUND },
{ "-troughrelief",TK_OPTION_RELIEF,
- Tk_Offset(TroughElement,reliefObj), "sunken" },
- { NULL, 0, 0, NULL }
+ offsetof(TroughElement,reliefObj), "sunken" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void TroughElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- TroughElement *troughPtr = elementRecord;
+ TroughElement *troughPtr = (TroughElement *)elementRecord;
int borderWidth = 2;
+ (void)dummy;
+ (void)widthPtr;
+ (void)heightPtr;
Tk_GetPixelsFromObj(NULL, tkwin, troughPtr->borderWidthObj, &borderWidth);
*paddingPtr = Ttk_UniformPadding((short)borderWidth);
}
static void TroughElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- TroughElement *troughPtr = elementRecord;
+ TroughElement *troughPtr = (TroughElement *)elementRecord;
Tk_3DBorder border = NULL;
int borderWidth = 2, relief = TK_RELIEF_SUNKEN;
+ (void)dummy;
+ (void)state;
border = Tk_Get3DBorderFromObj(tkwin, troughPtr->colorObj);
Tk_GetReliefFromObj(NULL, troughPtr->reliefObj, &relief);
@@ -815,7 +889,7 @@ static void TroughElementDraw(
borderWidth, relief);
}
-static Ttk_ElementSpec TroughElementSpec = {
+static const Ttk_ElementSpec TroughElementSpec = {
TK_STYLE_VERSION_2,
sizeof(TroughElement),
TroughElementOptions,
@@ -838,29 +912,32 @@ typedef struct {
Tcl_Obj *borderWidthObj;
} ThumbElement;
-static Ttk_ElementOptionSpec ThumbElementOptions[] = {
+static const Ttk_ElementOptionSpec ThumbElementOptions[] = {
{ "-orient", TK_OPTION_ANY,
- Tk_Offset(ThumbElement, orientObj), "horizontal" },
+ offsetof(ThumbElement, orientObj), "horizontal" },
{ "-width", TK_OPTION_PIXELS,
- Tk_Offset(ThumbElement,thicknessObj), DEFAULT_ARROW_SIZE },
+ offsetof(ThumbElement,thicknessObj), DEFAULT_ARROW_SIZE },
{ "-relief", TK_OPTION_RELIEF,
- Tk_Offset(ThumbElement,reliefObj), "raised" },
+ offsetof(ThumbElement,reliefObj), "raised" },
{ "-background", TK_OPTION_BORDER,
- Tk_Offset(ThumbElement,borderObj), DEFAULT_BACKGROUND },
+ offsetof(ThumbElement,borderObj), DEFAULT_BACKGROUND },
{ "-borderwidth", TK_OPTION_PIXELS,
- Tk_Offset(ThumbElement,borderWidthObj), DEFAULT_BORDERWIDTH },
- { NULL, 0, 0, NULL }
+ offsetof(ThumbElement,borderWidthObj), DEFAULT_BORDERWIDTH },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void ThumbElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- ThumbElement *thumb = elementRecord;
- int orient, thickness;
+ ThumbElement *thumb = (ThumbElement *)elementRecord;
+ Ttk_Orient orient;
+ int thickness;
+ (void)dummy;
+ (void)paddingPtr;
Tk_GetPixelsFromObj(NULL, tkwin, thumb->thicknessObj, &thickness);
- Ttk_GetOrientFromObj(NULL, thumb->orientObj, &orient);
+ TtkGetOrientFromObj(NULL, thumb->orientObj, &orient);
if (orient == TTK_ORIENT_VERTICAL) {
*widthPtr = thickness;
@@ -872,12 +949,14 @@ static void ThumbElementSize(
}
static void ThumbElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- ThumbElement *thumb = elementRecord;
+ ThumbElement *thumb = (ThumbElement *)elementRecord;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, thumb->borderObj);
int borderWidth = 2, relief = TK_RELIEF_RAISED;
+ (void)dummy;
+ (void)state;
Tk_GetPixelsFromObj(NULL, tkwin, thumb->borderWidthObj, &borderWidth);
Tk_GetReliefFromObj(NULL, thumb->reliefObj, &relief);
@@ -885,7 +964,7 @@ static void ThumbElementDraw(
borderWidth, relief);
}
-static Ttk_ElementSpec ThumbElementSpec = {
+static const Ttk_ElementSpec ThumbElementSpec = {
TK_STYLE_VERSION_2,
sizeof(ThumbElement),
ThumbElementOptions,
@@ -909,30 +988,33 @@ typedef struct {
Tcl_Obj *borderWidthObj; /* the size of the border */
} SliderElement;
-static Ttk_ElementOptionSpec SliderElementOptions[] = {
- { "-sliderlength", TK_OPTION_PIXELS, Tk_Offset(SliderElement,lengthObj),
+static const Ttk_ElementOptionSpec SliderElementOptions[] = {
+ { "-sliderlength", TK_OPTION_PIXELS, offsetof(SliderElement,lengthObj),
"30" },
- { "-sliderthickness",TK_OPTION_PIXELS,Tk_Offset(SliderElement,thicknessObj),
+ { "-sliderthickness",TK_OPTION_PIXELS, offsetof(SliderElement,thicknessObj),
"15" },
- { "-sliderrelief", TK_OPTION_RELIEF, Tk_Offset(SliderElement,reliefObj),
+ { "-sliderrelief", TK_OPTION_RELIEF, offsetof(SliderElement,reliefObj),
"raised" },
- { "-borderwidth", TK_OPTION_PIXELS, Tk_Offset(SliderElement,borderWidthObj),
+ { "-borderwidth", TK_OPTION_PIXELS, offsetof(SliderElement,borderWidthObj),
DEFAULT_BORDERWIDTH },
- { "-background", TK_OPTION_BORDER, Tk_Offset(SliderElement,borderObj),
+ { "-background", TK_OPTION_BORDER, offsetof(SliderElement,borderObj),
DEFAULT_BACKGROUND },
- { "-orient", TK_OPTION_ANY, Tk_Offset(SliderElement,orientObj),
+ { "-orient", TK_OPTION_ANY, offsetof(SliderElement,orientObj),
"horizontal" },
- { NULL, 0, 0, NULL }
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void SliderElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- SliderElement *slider = elementRecord;
- int orient, length, thickness;
+ SliderElement *slider = (SliderElement *)elementRecord;
+ Ttk_Orient orient;
+ int length, thickness;
+ (void)dummy;
+ (void)paddingPtr;
- Ttk_GetOrientFromObj(NULL, slider->orientObj, &orient);
+ TtkGetOrientFromObj(NULL, slider->orientObj, &orient);
Tk_GetPixelsFromObj(NULL, tkwin, slider->lengthObj, &length);
Tk_GetPixelsFromObj(NULL, tkwin, slider->thicknessObj, &thickness);
@@ -950,15 +1032,18 @@ static void SliderElementSize(
}
static void SliderElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- SliderElement *slider = elementRecord;
+ SliderElement *slider = (SliderElement *)elementRecord;
Tk_3DBorder border = NULL;
- int relief = TK_RELIEF_RAISED, borderWidth = 2, orient;
+ int relief = TK_RELIEF_RAISED, borderWidth = 2;
+ Ttk_Orient orient;
+ (void)dummy;
+ (void)state;
border = Tk_Get3DBorderFromObj(tkwin, slider->borderObj);
- Ttk_GetOrientFromObj(NULL, slider->orientObj, &orient);
+ TtkGetOrientFromObj(NULL, slider->orientObj, &orient);
Tk_GetPixelsFromObj(NULL, tkwin, slider->borderWidthObj, &borderWidth);
Tk_GetReliefFromObj(NULL, slider->reliefObj, &relief);
@@ -991,7 +1076,7 @@ static void SliderElementDraw(
}
}
-static Ttk_ElementSpec SliderElementSpec = {
+static const Ttk_ElementSpec SliderElementSpec = {
TK_STYLE_VERSION_2,
sizeof(SliderElement),
SliderElementOptions,
@@ -1020,30 +1105,33 @@ typedef struct {
Tcl_Obj *borderWidthObj; /* thickness of the border */
} PbarElement;
-static Ttk_ElementOptionSpec PbarElementOptions[] = {
- { "-orient", TK_OPTION_ANY, Tk_Offset(PbarElement,orientObj),
+static const Ttk_ElementOptionSpec PbarElementOptions[] = {
+ { "-orient", TK_OPTION_ANY, offsetof(PbarElement,orientObj),
"horizontal" },
- { "-thickness", TK_OPTION_PIXELS, Tk_Offset(PbarElement,thicknessObj),
+ { "-thickness", TK_OPTION_PIXELS, offsetof(PbarElement,thicknessObj),
DEFAULT_PBAR_THICKNESS },
- { "-barsize", TK_OPTION_PIXELS, Tk_Offset(PbarElement,lengthObj),
+ { "-barsize", TK_OPTION_PIXELS, offsetof(PbarElement,lengthObj),
DEFAULT_PBAR_LENGTH },
- { "-pbarrelief", TK_OPTION_RELIEF, Tk_Offset(PbarElement,reliefObj),
+ { "-pbarrelief", TK_OPTION_RELIEF, offsetof(PbarElement,reliefObj),
"raised" },
- { "-borderwidth", TK_OPTION_PIXELS, Tk_Offset(PbarElement,borderWidthObj),
+ { "-borderwidth", TK_OPTION_PIXELS, offsetof(PbarElement,borderWidthObj),
DEFAULT_BORDERWIDTH },
- { "-background", TK_OPTION_BORDER, Tk_Offset(PbarElement,borderObj),
+ { "-background", TK_OPTION_BORDER, offsetof(PbarElement,borderObj),
DEFAULT_BACKGROUND },
- { NULL, 0, 0, NULL }
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void PbarElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- PbarElement *pbar = elementRecord;
- int orient, thickness = 15, length = 30, borderWidth = 2;
+ PbarElement *pbar = (PbarElement *)elementRecord;
+ Ttk_Orient orient;
+ int thickness = 15, length = 30, borderWidth = 2;
+ (void)dummy;
+ (void)paddingPtr;
- Ttk_GetOrientFromObj(NULL, pbar->orientObj, &orient);
+ TtkGetOrientFromObj(NULL, pbar->orientObj, &orient);
Tk_GetPixelsFromObj(NULL, tkwin, pbar->thicknessObj, &thickness);
Tk_GetPixelsFromObj(NULL, tkwin, pbar->lengthObj, &length);
Tk_GetPixelsFromObj(NULL, tkwin, pbar->borderWidthObj, &borderWidth);
@@ -1061,12 +1149,14 @@ static void PbarElementSize(
}
static void PbarElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, Ttk_State state)
{
- PbarElement *pbar = elementRecord;
+ PbarElement *pbar = (PbarElement *)elementRecord;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, pbar->borderObj);
int relief = TK_RELIEF_RAISED, borderWidth = 2;
+ (void)dummy;
+ (void)state;
Tk_GetPixelsFromObj(NULL, tkwin, pbar->borderWidthObj, &borderWidth);
Tk_GetReliefFromObj(NULL, pbar->reliefObj, &relief);
@@ -1076,7 +1166,7 @@ static void PbarElementDraw(
borderWidth, relief);
}
-static Ttk_ElementSpec PbarElementSpec = {
+static const Ttk_ElementSpec PbarElementSpec = {
TK_STYLE_VERSION_2,
sizeof(PbarElement),
PbarElementOptions,
@@ -1093,35 +1183,40 @@ typedef struct {
Tcl_Obj *backgroundObj;
} TabElement;
-static Ttk_ElementOptionSpec TabElementOptions[] = {
+static const Ttk_ElementOptionSpec TabElementOptions[] = {
{ "-borderwidth", TK_OPTION_PIXELS,
- Tk_Offset(TabElement,borderWidthObj),"1" },
+ offsetof(TabElement,borderWidthObj),"1" },
{ "-background", TK_OPTION_BORDER,
- Tk_Offset(TabElement,backgroundObj), DEFAULT_BACKGROUND },
- {0,0,0,0}
+ offsetof(TabElement,backgroundObj), DEFAULT_BACKGROUND },
+ {0,TK_OPTION_BOOLEAN,0,0}
};
static void TabElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- TabElement *tab = elementRecord;
+ TabElement *tab = (TabElement *)elementRecord;
int borderWidth = 1;
+ (void)dummy;
+ (void)widthPtr;
+ (void)heightPtr;
+
Tk_GetPixelsFromObj(0, tkwin, tab->borderWidthObj, &borderWidth);
paddingPtr->top = paddingPtr->left = paddingPtr->right = borderWidth;
paddingPtr->bottom = 0;
}
static void TabElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- TabElement *tab = elementRecord;
+ TabElement *tab = (TabElement *)elementRecord;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, tab->backgroundObj);
int borderWidth = 1;
int cut = 2;
XPoint pts[6];
int n = 0;
+ (void)dummy;
Tcl_GetIntFromObj(NULL, tab->borderWidthObj, &borderWidth);
@@ -1164,7 +1259,7 @@ static void TabElementDraw(
}
-static Ttk_ElementSpec TabElementSpec = {
+static const Ttk_ElementSpec TabElementSpec = {
TK_STYLE_VERSION_2,
sizeof(TabElement),
TabElementOptions,
@@ -1180,12 +1275,14 @@ typedef TabElement ClientElement;
#define ClientElementOptions TabElementOptions
static void ClientElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- ClientElement *ce = elementRecord;
+ ClientElement *ce = (ClientElement *)elementRecord;
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, ce->backgroundObj);
int borderWidth = 1;
+ (void)dummy;
+ (void)state;
Tcl_GetIntFromObj(NULL, ce->borderWidthObj, &borderWidth);
@@ -1194,16 +1291,20 @@ static void ClientElementDraw(
}
static void ClientElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- ClientElement *ce = elementRecord;
+ ClientElement *ce = (ClientElement *)elementRecord;
int borderWidth = 1;
+ (void)dummy;
+ (void)widthPtr;
+ (void)heightPtr;
+
Tk_GetPixelsFromObj(0, tkwin, ce->borderWidthObj, &borderWidth);
*paddingPtr = Ttk_UniformPadding((short)borderWidth);
}
-static Ttk_ElementSpec ClientElementSpec = {
+static const Ttk_ElementSpec ClientElementSpec = {
TK_STYLE_VERSION_2,
sizeof(ClientElement),
ClientElementOptions,
@@ -1244,15 +1345,15 @@ void TtkElements_Init(Tcl_Interp *interp)
Ttk_RegisterElement(interp, theme, "indicator", &ttkNullElementSpec,NULL);
Ttk_RegisterElement(interp, theme, "uparrow",
- &ArrowElementSpec, &ArrowElements[0]);
+ &ArrowElementSpec, INT2PTR(ARROW_UP));
Ttk_RegisterElement(interp, theme, "downarrow",
- &ArrowElementSpec, &ArrowElements[1]);
+ &ArrowElementSpec, INT2PTR(ARROW_DOWN));
Ttk_RegisterElement(interp, theme, "leftarrow",
- &ArrowElementSpec, &ArrowElements[2]);
+ &ArrowElementSpec, INT2PTR(ARROW_LEFT));
Ttk_RegisterElement(interp, theme, "rightarrow",
- &ArrowElementSpec, &ArrowElements[3]);
+ &ArrowElementSpec, INT2PTR(ARROW_RIGHT));
Ttk_RegisterElement(interp, theme, "arrow",
- &ArrowElementSpec, &ArrowElements[0]);
+ &ArrowElementSpec, INT2PTR(ARROW_UP));
Ttk_RegisterElement(interp, theme, "trough", &TroughElementSpec, NULL);
Ttk_RegisterElement(interp, theme, "thumb", &ThumbElementSpec, NULL);
diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c
index 1d8137b..946b7fc 100644
--- a/generic/ttk/ttkEntry.c
+++ b/generic/ttk/ttkEntry.c
@@ -69,6 +69,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 */
@@ -83,12 +84,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. */
+ TkSizeT numBytes; /* Length of string in bytes. */
+ TkSizeT 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 */
+ TkSizeT insertPos; /* Insert index */
+ TkSizeT selectFirst; /* Index of start of selection, or TCL_INDEX_NONE */
+ TkSizeT selectLast; /* Index of end of selection, or TCL_INDEX_NONE */
Scrollable xscroll; /* Current scroll position */
ScrollHandle xscrollHandle;
@@ -114,6 +115,8 @@ typedef struct {
Tcl_Obj *stateObj; /* Compatibility option -- see CheckStateObj */
+ Tcl_Obj *placeholderObj; /* Text to display for placeholder text */
+
/*
* Derived resources:
*/
@@ -143,55 +146,63 @@ typedef struct {
/*
* Default option values:
*/
-#define DEF_SELECT_BG "#000000"
-#define DEF_SELECT_FG "#ffffff"
-#define DEF_INSERT_BG "black"
-#define DEF_ENTRY_WIDTH "20"
-#define DEF_ENTRY_FONT "TkTextFont"
-#define DEF_LIST_HEIGHT "10"
+#define DEF_SELECT_BG "#000000"
+#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),
+ "left", TCL_INDEX_NONE, offsetof(Entry, entry.justify),
0, 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),
- 0, (ClientData) validateStrings, 0},
+ "none", TCL_INDEX_NONE, offsetof(Entry, entry.validate),
+ 0, (void *) 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,
@@ -212,6 +223,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)
@@ -223,6 +235,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);
@@ -249,6 +262,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")
@@ -259,6 +273,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);
@@ -283,7 +298,7 @@ static char *EntryDisplayString(const char *showChar, int numChars)
TkUtfToUniChar(showChar, &ch);
size = TkUniCharToUtf(ch, buf);
- p = displayString = ckalloc(numChars * size + 1);
+ p = displayString = (char *)ckalloc(numChars * size + 1);
while (numChars--) {
memcpy(p, buf, size);
@@ -300,12 +315,23 @@ static char *EntryDisplayString(const char *showChar, int numChars)
*/
static void EntryUpdateTextLayout(Entry *entryPtr)
{
+ TkSizeT 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 = TkGetStringFromObj(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 --
@@ -324,32 +350,32 @@ EntryEditable(Entry *entryPtr)
/* EntryFetchSelection --
* Selection handler for entry widgets.
*/
-static int
+static TkSizeT
EntryFetchSelection(
- ClientData clientData, int offset, char *buffer, int maxBytes)
+ ClientData clientData, TkSizeT offset, char *buffer, TkSizeT maxBytes)
{
- Entry *entryPtr = (Entry *) clientData;
- int byteCount;
+ Entry *entryPtr = (Entry *)clientData;
+ TkSizeT byteCount;
const char *string;
const char *selStart, *selEnd;
- if (entryPtr->entry.selectFirst < 0 || (!entryPtr->entry.exportSelection)
+ if (entryPtr->entry.selectFirst == TCL_INDEX_NONE || (!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,
+ selStart = Tcl_UtfAtIndex(string, entryPtr->entry.selectFirst);
+ selEnd = Tcl_UtfAtIndex(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;
@@ -361,9 +387,9 @@ EntryFetchSelection(
*/
static void EntryLostSelection(ClientData clientData)
{
- Entry *entryPtr = (Entry *) 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);
}
@@ -377,7 +403,7 @@ static void EntryOwnSelection(Entry *entryPtr)
&& (!Tcl_IsSafe(entryPtr->core.interp))
&& !(entryPtr->core.flags & GOT_SELECTION)) {
Tk_OwnSelection(entryPtr->core.tkwin, XA_PRIMARY, EntryLostSelection,
- (ClientData) entryPtr);
+ entryPtr);
entryPtr->core.flags |= GOT_SELECTION;
}
}
@@ -393,9 +419,9 @@ static void EntryOwnSelection(Entry *entryPtr)
static void
ExpandPercents(
Entry *entryPtr, /* Entry that needs validation. */
- const char *template, /* Script template */
- const char *new, /* Potential new value of entry string */
- int index, /* index of insert/delete */
+ const char *templ, /* Script template */
+ const char *newValue, /* Potential new value of entry string */
+ TkSizeT index, /* index of insert/delete */
int count, /* #changed characters */
VREASON reason, /* Reason for change */
Tcl_DString *dsPtr) /* Result of %-substitutions */
@@ -407,28 +433,28 @@ ExpandPercents(
int ch;
char numStorage[2*TCL_INTEGER_SPACE];
- while (*template) {
+ while (*templ) {
/* Find everything up to the next % character and append it
* to the result string.
*/
- string = Tcl_UtfFindFirst(template, '%');
+ string = Tcl_UtfFindFirst(templ, '%');
if (string == NULL) {
/* No more %-sequences to expand.
* Copy the rest of the template.
*/
- Tcl_DStringAppend(dsPtr, template, -1);
+ Tcl_DStringAppend(dsPtr, templ, -1);
return;
}
- if (string != template) {
- Tcl_DStringAppend(dsPtr, template, string - template);
- template = string;
+ if (string != templ) {
+ Tcl_DStringAppend(dsPtr, templ, string - templ);
+ templ = string;
}
/* There's a percent sequence here. Process it.
*/
- ++template; /* skip over % */
- if (*template != '\0') {
- template += TkUtfToUniChar(template, &ch);
+ ++templ; /* skip over % */
+ if (*templ != '\0') {
+ templ += TkUtfToUniChar(templ, &ch);
} else {
ch = '%';
}
@@ -447,22 +473,22 @@ ExpandPercents(
string = numStorage;
break;
case 'i': /* index of insert/delete */
- sprintf(numStorage, "%d", index);
+ sprintf(numStorage, "%d", (int)index);
string = numStorage;
break;
case 'P': /* 'Peeked' new value of the string */
- string = new;
+ string = newValue;
break;
case 's': /* Current string value */
string = entryPtr->entry.string;
break;
case 'S': /* string to be inserted/deleted, if any */
if (reason == VALIDATE_INSERT) {
- string = TkUtfAtIndex(new, index);
- stringLength = TkUtfAtIndex(string, count) - string;
+ string = Tcl_UtfAtIndex(newValue, index);
+ stringLength = Tcl_UtfAtIndex(string, count) - string;
} else if (reason == VALIDATE_DELETE) {
- string = TkUtfAtIndex(entryPtr->entry.string, index);
- stringLength = TkUtfAtIndex(string, count) - string;
+ string = Tcl_UtfAtIndex(entryPtr->entry.string, index);
+ stringLength = Tcl_UtfAtIndex(string, count) - string;
} else {
string = "";
stringLength = 0;
@@ -502,18 +528,18 @@ ExpandPercents(
static int RunValidationScript(
Tcl_Interp *interp, /* Interpreter to use */
Entry *entryPtr, /* Entry being validated */
- const char *template, /* Script template */
+ const char *templ, /* Script template */
const char *optionName, /* "-validatecommand", "-invalidcommand" */
- const char *new, /* Potential new value of entry string */
- int index, /* index of insert/delete */
- int count, /* #changed characters */
+ const char *newValue, /* Potential new value of entry string */
+ TkSizeT index, /* index of insert/delete */
+ TkSizeT count, /* #changed characters */
VREASON reason) /* Reason for change */
{
Tcl_DString script;
int code;
Tcl_DStringInit(&script);
- ExpandPercents(entryPtr, template, new, index, count, reason, &script);
+ ExpandPercents(entryPtr, templ, newValue, index, count, reason, &script);
code = Tcl_EvalEx(interp,
Tcl_DStringValue(&script), Tcl_DStringLength(&script),
TCL_EVAL_GLOBAL);
@@ -557,7 +583,7 @@ static int EntryNeedsValidation(VMODE vmode, VREASON reason)
* Returns:
* TCL_OK if the change is accepted
* TCL_BREAK if the change is rejected
- * TCL_ERROR if any errors occurred
+ * TCL_ERROR if any errors occurred
*
* The change will be rejected if -validatecommand returns 0,
* or if -validatecommand or -invalidcommand modifies the value.
@@ -566,17 +592,17 @@ 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 */
+ TkSizeT index, /* index of insert/delete, TCL_INDEX_NONE otherwise */
+ TkSizeT count, /* #changed characters */
VREASON reason) /* Reason for change */
{
Tcl_Interp *interp = entryPtr->core.interp;
VMODE vmode = entryPtr->entry.validate;
int code, change_ok;
- if ( (entryPtr->entry.validateCmd == NULL)
+ if ((entryPtr->entry.validateCmd == NULL)
|| (entryPtr->core.flags & VALIDATING)
- || !EntryNeedsValidation(vmode, reason) )
+ || !EntryNeedsValidation(vmode, reason))
{
return TCL_OK;
}
@@ -630,10 +656,11 @@ done:
* Returns:
* TCL_OK if valid, TCL_BREAK if invalid, TCL_ERROR on error.
*/
-static int EntryRevalidate(Tcl_Interp *interp, Entry *entryPtr, VREASON reason)
+static int EntryRevalidate(Tcl_Interp *dummy, Entry *entryPtr, VREASON reason)
{
int code = EntryValidateChange(
entryPtr, entryPtr->entry.string, -1,0, reason);
+ (void)dummy;
if (code == TCL_BREAK) {
TtkWidgetChangeState(&entryPtr->core, TTK_STATE_INVALID, 0);
@@ -693,8 +720,8 @@ static void AdjustIndices(Entry *entryPtr, int index, int nChars)
e->selectLast = AdjustIndex(e->selectLast, index+g, nChars);
e->xscroll.first= AdjustIndex(e->xscroll.first, index+g, nChars);
- if (e->selectLast <= e->selectFirst)
- e->selectFirst = e->selectLast = -1;
+ if (e->selectLast + 1 <= e->selectFirst + 1)
+ e->selectFirst = e->selectLast = TCL_INDEX_NONE;
}
/* EntryStoreValue --
@@ -707,7 +734,7 @@ static void
EntryStoreValue(Entry *entryPtr, const char *value)
{
size_t numBytes = strlen(value);
- int numChars = Tcl_NumUtfChars(value, numBytes);
+ TkSizeT numChars = Tcl_NumUtfChars(value, numBytes);
if (entryPtr->core.flags & VALIDATING)
entryPtr->core.flags |= VALIDATION_SET_VALUE;
@@ -725,7 +752,7 @@ EntryStoreValue(Entry *entryPtr, const char *value)
/* Store new value:
*/
- entryPtr->entry.string = ckalloc(numBytes + 1);
+ entryPtr->entry.string = (char *)ckalloc(numBytes + 1);
strcpy(entryPtr->entry.string, value);
entryPtr->entry.numBytes = numBytes;
entryPtr->entry.numChars = numChars;
@@ -782,7 +809,7 @@ static int EntrySetValue(Entry *entryPtr, const char *value)
*/
static void EntryTextVariableTrace(void *recordPtr, const char *value)
{
- Entry *entryPtr = recordPtr;
+ Entry *entryPtr = (Entry *)recordPtr;
if (WidgetDestroyed(&entryPtr->core)) {
return;
@@ -808,37 +835,37 @@ 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 */
+ TkSizeT 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 byteIndex = Tcl_UtfAtIndex(string, index) - string;
size_t byteCount = strlen(value);
int charsAdded = Tcl_NumUtfChars(value, byteCount);
size_t newByteCount = entryPtr->entry.numBytes + byteCount + 1;
- char *new;
+ char *newBytes;
int code;
if (byteCount == 0) {
return TCL_OK;
}
- new = ckalloc(newByteCount);
- memcpy(new, string, byteIndex);
- strcpy(new + byteIndex, value);
- strcpy(new + byteIndex + byteCount, string + byteIndex);
+ newBytes = (char *)ckalloc(newByteCount);
+ memcpy(newBytes, string, byteIndex);
+ strcpy(newBytes + byteIndex, value);
+ strcpy(newBytes + byteIndex + byteCount, string + byteIndex);
code = EntryValidateChange(
- entryPtr, new, index, charsAdded, VALIDATE_INSERT);
+ entryPtr, newBytes, index, charsAdded, VALIDATE_INSERT);
if (code == TCL_OK) {
AdjustIndices(entryPtr, index, charsAdded);
- code = EntrySetValue(entryPtr, new);
+ code = EntrySetValue(entryPtr, newBytes);
} else if (code == TCL_BREAK) {
code = TCL_OK;
}
- ckfree(new);
+ ckfree(newBytes);
return code;
}
@@ -848,42 +875,42 @@ 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. */
+ TkSizeT index, /* Index of first character to delete. */
+ TkSizeT count) /* How many characters to delete. */
{
char *string = entryPtr->entry.string;
size_t byteIndex, byteCount, newByteCount;
- char *new;
+ char *newBytes;
int code;
- if (index < 0) {
+ if (index == TCL_INDEX_NONE) {
index = 0;
}
- if (count > entryPtr->entry.numChars - index) {
+ if (count + index + 1 > entryPtr->entry.numChars + 1) {
count = entryPtr->entry.numChars - index;
}
- if (count <= 0) {
+ if (count + 1 <= 1) {
return TCL_OK;
}
- byteIndex = TkUtfAtIndex(string, index) - string;
- byteCount = TkUtfAtIndex(string+byteIndex, count) - (string+byteIndex);
+ byteIndex = Tcl_UtfAtIndex(string, index) - string;
+ byteCount = Tcl_UtfAtIndex(string+byteIndex, count) - (string+byteIndex);
newByteCount = entryPtr->entry.numBytes + 1 - byteCount;
- new = ckalloc(newByteCount);
- memcpy(new, string, byteIndex);
- strcpy(new + byteIndex, string + byteIndex + byteCount);
+ newBytes = (char *)ckalloc(newByteCount);
+ memcpy(newBytes, string, byteIndex);
+ strcpy(newBytes + byteIndex, string + byteIndex + byteCount);
code = EntryValidateChange(
- entryPtr, new, index, count, VALIDATE_DELETE);
+ entryPtr, newBytes, index, count, VALIDATE_DELETE);
if (code == TCL_OK) {
AdjustIndices(entryPtr, index, -count);
- code = EntrySetValue(entryPtr, new);
+ code = EntrySetValue(entryPtr, newBytes);
} else if (code == TCL_BREAK) {
code = TCL_OK;
}
- ckfree(new);
+ ckfree(newBytes);
return code;
}
@@ -900,7 +927,7 @@ DeleteChars(
static void
EntryEventProc(ClientData clientData, XEvent *eventPtr)
{
- Entry *entryPtr = (Entry *) clientData;
+ Entry *entryPtr = (Entry *)clientData;
Tcl_Preserve(clientData);
switch (eventPtr->type) {
@@ -923,17 +950,18 @@ EntryEventProc(ClientData clientData, XEvent *eventPtr)
*/
static void
-EntryInitialize(Tcl_Interp *interp, void *recordPtr)
+EntryInitialize(Tcl_Interp *dummy, void *recordPtr)
{
- Entry *entryPtr = recordPtr;
+ Entry *entryPtr = (Entry *)recordPtr;
+ (void)dummy;
Tk_CreateEventHandler(
entryPtr->core.tkwin, EntryEventMask, EntryEventProc, entryPtr);
Tk_CreateSelHandler(entryPtr->core.tkwin, XA_PRIMARY, XA_STRING,
- EntryFetchSelection, (ClientData) entryPtr, XA_STRING);
+ EntryFetchSelection, entryPtr, XA_STRING);
TtkBlinkCursor(&entryPtr->core);
- entryPtr->entry.string = ckalloc(1);
+ entryPtr->entry.string = (char *)ckalloc(1);
*entryPtr->entry.string = '\0';
entryPtr->entry.displayString = entryPtr->entry.string;
entryPtr->entry.textVariableTrace = 0;
@@ -945,14 +973,14 @@ EntryInitialize(Tcl_Interp *interp, void *recordPtr)
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
EntryCleanup(void *recordPtr)
{
- Entry *entryPtr = recordPtr;
+ Entry *entryPtr = (Entry *)recordPtr;
if (entryPtr->entry.textVariableTrace)
Ttk_UntraceVariable(entryPtr->entry.textVariableTrace);
@@ -974,7 +1002,7 @@ EntryCleanup(void *recordPtr)
*/
static int EntryConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
{
- Entry *entryPtr = recordPtr;
+ Entry *entryPtr = (Entry *)recordPtr;
Tcl_Obj *textVarName = entryPtr->entry.textVariableObj;
Ttk_TraceHandle *vt = 0;
@@ -1001,7 +1029,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 != TCL_INDEX_NONE)
&& (!Tcl_IsSafe(entryPtr->core.interp))) {
EntryOwnSelection(entryPtr);
}
@@ -1038,10 +1066,11 @@ static int EntryConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
/* EntryPostConfigure --
* Post-configuration hook for entry widgets.
*/
-static int EntryPostConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
+static int EntryPostConfigure(Tcl_Interp *dummy, void *recordPtr, int mask)
{
- Entry *entryPtr = recordPtr;
+ Entry *entryPtr = (Entry *)recordPtr;
int status = TCL_OK;
+ (void)dummy;
if ((mask & TEXTVAR_CHANGED) && entryPtr->entry.textVariableTrace != NULL) {
status = Ttk_FireTrace(entryPtr->entry.textVariableTrace);
@@ -1059,7 +1088,7 @@ static int EntryPostConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
* Precondition: textLayout and layoutX up-to-date.
*/
static int
-EntryCharPosition(Entry *entryPtr, int index)
+EntryCharPosition(Entry *entryPtr, TkSizeT index)
{
int xPos;
Tk_CharBbox(entryPtr->entry.textLayout, index, &xPos, NULL, NULL, NULL);
@@ -1079,7 +1108,7 @@ EntryCharPosition(Entry *entryPtr, int index)
static void
EntryDoLayout(void *recordPtr)
{
- Entry *entryPtr = recordPtr;
+ Entry *entryPtr = (Entry *)recordPtr;
WidgetCore *corePtr = &entryPtr->core;
Tk_TextLayout textLayout = entryPtr->entry.textLayout;
int leftIndex = entryPtr->entry.xscroll.first;
@@ -1166,9 +1195,9 @@ static GC EntryGetGC(Entry *entryPtr, Tcl_Obj *colorObj, TkRegion clip)
*/
static void EntryDisplay(void *clientData, Drawable d)
{
- Entry *entryPtr = clientData;
+ Entry *entryPtr = (Entry *)clientData;
Tk_Window tkwin = entryPtr->core.tkwin;
- int leftIndex = entryPtr->entry.xscroll.first,
+ TkSizeT leftIndex = entryPtr->entry.xscroll.first,
rightIndex = entryPtr->entry.xscroll.last + 1,
selFirst = entryPtr->entry.selectFirst,
selLast = entryPtr->entry.selectLast;
@@ -1178,6 +1207,7 @@ static void EntryDisplay(void *clientData, Drawable d)
Ttk_Box textarea;
TkRegion clipRegion;
XRectangle rect;
+ Tcl_Obj *foregroundObj;
EntryInitStyleData(entryPtr, &es);
@@ -1185,22 +1215,21 @@ static void EntryDisplay(void *clientData, Drawable d)
showCursor =
(entryPtr->core.flags & CURSOR_ON)
&& EntryEditable(entryPtr)
- && entryPtr->entry.insertPos >= leftIndex
- && entryPtr->entry.insertPos <= rightIndex
+ && entryPtr->entry.insertPos + 1 >= leftIndex + 1
+ && entryPtr->entry.insertPos + 1 <= rightIndex + 1
;
showSelection =
!(entryPtr->core.state & TTK_STATE_DISABLED)
- && selFirst > -1
- && selLast > leftIndex
- && selFirst <= rightIndex
- ;
+ && selFirst != TCL_INDEX_NONE
+ && selLast + 1 > leftIndex + 1
+ && selFirst + 1 <= rightIndex + 1;
/* Adjust selection range to keep in display bounds.
*/
if (showSelection) {
- if (selFirst < leftIndex)
+ if (selFirst + 1 < leftIndex + 1)
selFirst = leftIndex;
- if (selLast > rightIndex)
+ if (selLast + 1 > rightIndex + 1)
selLast = rightIndex;
}
@@ -1273,7 +1302,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 (Tcl_GetCharLength(es.placeholderForegroundObj) > 0) {
+ foregroundObj = es.placeholderForegroundObj;
+ } else {
+ foregroundObj = es.foregroundObj;
+ }
+ /* Use placeholder text width */
+ leftIndex = 0;
+ (void)TkGetStringFromObj(entryPtr->entry.placeholderObj, &rightIndex);
+ } else {
+ foregroundObj = es.foregroundObj;
+ }
+ gc = EntryGetGC(entryPtr, foregroundObj, clipRegion);
if (showSelection) {
/* Draw the selected and unselected portions separately.
@@ -1343,22 +1386,30 @@ EntryIndex(
Tcl_Interp *interp, /* For error messages. */
Entry *entryPtr, /* Entry widget to query */
Tcl_Obj *indexObj, /* Symbolic index name */
- int *indexPtr) /* Return value */
+ TkSizeT *indexPtr) /* Return value */
{
# define EntryWidth(e) (Tk_Width(entryPtr->core.tkwin)) /* Not Right */
- const char *string = Tcl_GetString(indexObj);
- size_t length = indexObj->length;
+ TkSizeT length, idx;
+ const char *string;
+
+ if (TCL_OK == TkGetIntForIndex(indexObj, entryPtr->entry.numChars - 1, 1, &idx)) {
+ if ((idx != TCL_INDEX_NONE) && (idx > entryPtr->entry.numChars)) {
+ idx = entryPtr->entry.numChars;
+ }
+ *indexPtr = idx;
+ return TCL_OK;
+ }
+
+ string = TkGetStringFromObj(indexObj, &length);
- if (strncmp(string, "end", length) == 0) {
- *indexPtr = entryPtr->entry.numChars;
- } else if (strncmp(string, "insert", length) == 0) {
+ if (strncmp(string, "insert", length) == 0) {
*indexPtr = entryPtr->entry.insertPos;
} else if (strncmp(string, "left", length) == 0) { /* for debugging */
*indexPtr = entryPtr->entry.xscroll.first;
} else if (strncmp(string, "right", length) == 0) { /* for debugging */
*indexPtr = entryPtr->entry.xscroll.last;
} else if (strncmp(string, "sel.", 4) == 0) {
- if (entryPtr->entry.selectFirst < 0) {
+ if (entryPtr->entry.selectFirst == TCL_INDEX_NONE) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"selection isn't in widget %s",
Tk_PathName(entryPtr->core.tkwin)));
@@ -1388,7 +1439,7 @@ EntryIndex(
x - entryPtr->entry.layoutX, 0);
TtkUpdateScrollInfo(entryPtr->entry.xscrollHandle);
- if (*indexPtr < entryPtr->entry.xscroll.first) {
+ if (*indexPtr + 1 < (TkSizeT)entryPtr->entry.xscroll.first + 1) {
*indexPtr = entryPtr->entry.xscroll.first;
}
@@ -1399,18 +1450,11 @@ EntryIndex(
* last character to be selected, for example.
*/
- if (roundUp && (*indexPtr < entryPtr->entry.numChars)) {
+ if (roundUp && ((TkSizeT)*indexPtr + 1 < entryPtr->entry.numChars + 1 )) {
*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;
@@ -1428,9 +1472,9 @@ static int
EntryBBoxCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Entry *entryPtr = recordPtr;
+ Entry *entryPtr = (Entry *)recordPtr;
Ttk_Box b;
- int index;
+ TkSizeT index;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "index");
@@ -1439,7 +1483,7 @@ EntryBBoxCommand(
if (EntryIndex(interp, entryPtr, objv[2], &index) != TCL_OK) {
return TCL_ERROR;
}
- if ((index == entryPtr->entry.numChars) && (index > 0)) {
+ if ((index == entryPtr->entry.numChars) && (index + 1 > 1)) {
index--;
}
Tk_CharBbox(entryPtr->entry.textLayout, index,
@@ -1458,8 +1502,8 @@ static int
EntryDeleteCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Entry *entryPtr = recordPtr;
- int first, last;
+ Entry *entryPtr = (Entry *)recordPtr;
+ TkSizeT first, last;
if ((objc < 3) || (objc > 4)) {
Tcl_WrongNumArgs(interp, 2, objv, "firstIndex ?lastIndex?");
@@ -1474,7 +1518,7 @@ EntryDeleteCommand(
return TCL_ERROR;
}
- if (last >= first && EntryEditable(entryPtr)) {
+ if (last + 1 >= first + 1 && EntryEditable(entryPtr)) {
return DeleteChars(entryPtr, first, last - first);
}
return TCL_OK;
@@ -1487,7 +1531,7 @@ static int
EntryGetCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Entry *entryPtr = recordPtr;
+ Entry *entryPtr = (Entry *)recordPtr;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 2, objv, NULL);
return TCL_ERROR;
@@ -1503,7 +1547,7 @@ static int
EntryICursorCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Entry *entryPtr = recordPtr;
+ Entry *entryPtr = (Entry *)recordPtr;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "pos");
return TCL_ERROR;
@@ -1523,8 +1567,8 @@ static int
EntryIndexCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Entry *entryPtr = recordPtr;
- int index;
+ Entry *entryPtr = (Entry *)recordPtr;
+ TkSizeT index;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "string");
@@ -1533,7 +1577,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;
}
@@ -1545,8 +1589,8 @@ static int
EntryInsertCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Entry *entryPtr = recordPtr;
- int index;
+ Entry *entryPtr = (Entry *)recordPtr;
+ TkSizeT index;
if (objc != 4) {
Tcl_WrongNumArgs(interp, 2, objv, "index text");
@@ -1567,13 +1611,13 @@ EntryInsertCommand(
static int EntrySelectionClearCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Entry *entryPtr = recordPtr;
+ Entry *entryPtr = (Entry *)recordPtr;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 3, objv, NULL);
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;
}
@@ -1584,13 +1628,13 @@ static int EntrySelectionClearCommand(
static int EntrySelectionPresentCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Entry *entryPtr = recordPtr;
+ Entry *entryPtr = (Entry *)recordPtr;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 3, objv, NULL);
return TCL_ERROR;
}
Tcl_SetObjResult(interp,
- Tcl_NewBooleanObj(entryPtr->entry.selectFirst >= 0));
+ Tcl_NewWideIntObj(entryPtr->entry.selectFirst != TCL_INDEX_NONE));
return TCL_OK;
}
@@ -1600,13 +1644,13 @@ static int EntrySelectionPresentCommand(
static int EntrySelectionRangeCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Entry *entryPtr = recordPtr;
- int start, end;
+ Entry *entryPtr = (Entry *)recordPtr;
+ TkSizeT start, end;
if (objc != 5) {
Tcl_WrongNumArgs(interp, 3, objv, "start end");
return TCL_ERROR;
}
- if ( EntryIndex(interp, entryPtr, objv[3], &start) != TCL_OK
+ if (EntryIndex(interp, entryPtr, objv[3], &start) != TCL_OK
|| EntryIndex(interp, entryPtr, objv[4], &end) != TCL_OK) {
return TCL_ERROR;
}
@@ -1614,8 +1658,8 @@ static int EntrySelectionRangeCommand(
return TCL_OK;
}
- if (start >= end) {
- entryPtr->entry.selectFirst = entryPtr->entry.selectLast = -1;
+ if (start + 1 >= end + 1 ) {
+ entryPtr->entry.selectFirst = entryPtr->entry.selectLast = TCL_INDEX_NONE;
} else {
entryPtr->entry.selectFirst = start;
entryPtr->entry.selectLast = end;
@@ -1638,7 +1682,7 @@ static const Ttk_Ensemble EntrySelectionCommands[] = {
static int EntrySetCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Entry *entryPtr = recordPtr;
+ Entry *entryPtr = (Entry *)recordPtr;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "value");
return TCL_ERROR;
@@ -1654,7 +1698,7 @@ static int EntrySetCommand(
static int EntryValidateCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Entry *entryPtr = recordPtr;
+ Entry *entryPtr = (Entry *)recordPtr;
int code;
if (objc != 2) {
@@ -1676,9 +1720,9 @@ static int EntryValidateCommand(
static int EntryXViewCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Entry *entryPtr = recordPtr;
+ Entry *entryPtr = (Entry *)recordPtr;
if (objc == 3) {
- int newFirst;
+ TkSizeT newFirst;
if (EntryIndex(interp, entryPtr, objv[2], &newFirst) != TCL_OK) {
return TCL_ERROR;
}
@@ -1710,7 +1754,7 @@ static const Ttk_Ensemble EntryCommands[] = {
* +++ Entry widget definition.
*/
-static WidgetSpec EntryWidgetSpec = {
+static const WidgetSpec EntryWidgetSpec = {
"TEntry", /* className */
sizeof(Entry), /* recordSize */
EntryOptionSpecs, /* optionSpecs */
@@ -1726,16 +1770,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.
*/
@@ -1743,7 +1777,7 @@ typedef struct {
Tcl_Obj *postCommandObj;
Tcl_Obj *valuesObj;
Tcl_Obj *heightObj;
- int currentIndex;
+ TkSizeT currentIndex;
} ComboboxPart;
typedef struct {
@@ -1752,15 +1786,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)
};
@@ -1771,9 +1805,9 @@ static Tk_OptionSpec ComboboxOptionSpecs[] = {
static void
ComboboxInitialize(Tcl_Interp *interp, void *recordPtr)
{
- Combobox *cb = recordPtr;
+ Combobox *cb = (Combobox *)recordPtr;
- cb->combobox.currentIndex = -1;
+ cb->combobox.currentIndex = TCL_INDEX_NONE;
TtkTrackElementState(&cb->core);
EntryInitialize(interp, recordPtr);
}
@@ -1784,7 +1818,7 @@ ComboboxInitialize(Tcl_Interp *interp, void *recordPtr)
static int
ComboboxConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
{
- Combobox *cbPtr = recordPtr;
+ Combobox *cbPtr = (Combobox *)recordPtr;
int unused;
/* Make sure -values is a valid list:
@@ -1804,78 +1838,58 @@ ComboboxConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
static int ComboboxCurrentCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Combobox *cbPtr = recordPtr;
- int currentIndex = cbPtr->combobox.currentIndex;
+ Combobox *cbPtr = (Combobox *)recordPtr;
+ TkSizeT currentIndex = cbPtr->combobox.currentIndex;
const char *currentValue = cbPtr->entry.string;
int nValues;
Tcl_Obj **values;
- Tcl_ListObjGetElements(interp,cbPtr->combobox.valuesObj,&nValues,&values);
+ Tcl_ListObjGetElements(interp, cbPtr->combobox.valuesObj, &nValues, &values);
if (objc == 2) {
/* Check if currentIndex still valid:
*/
- if ( currentIndex < 0
- || currentIndex >= nValues
+ if (currentIndex == TCL_INDEX_NONE
+ || currentIndex >= (TkSizeT)nValues
|| strcmp(currentValue,Tcl_GetString(values[currentIndex]))
)
{
/* Not valid. Check current value against each element in -values:
*/
- for (currentIndex = 0; currentIndex < nValues; ++currentIndex) {
+ for (currentIndex = 0; currentIndex < (TkSizeT)nValues; ++currentIndex) {
if (!strcmp(currentValue,Tcl_GetString(values[currentIndex]))) {
break;
}
}
- if (currentIndex >= nValues) {
+ if (currentIndex >= (TkSizeT)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.
- */
+ TkSizeT idx;
- switch (index) {
- case INDEX_END:
- /* "end" index */
- currentIndex = nValues - 1;
- break;
- }
- } else {
-
- /*
- * 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 == TCL_INDEX_NONE || idx > (TkSizeT)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(
+ "Incorrect index %s", Tcl_GetString(objv[2])));
+ Tcl_SetErrorCode(interp, "TTK", "COMBOBOX", "IDX_VALUE", NULL);
+ return TCL_ERROR;
+ }
cbPtr->combobox.currentIndex = currentIndex;
- return EntrySetValue(recordPtr, Tcl_GetString(values[currentIndex]));
+ return EntrySetValue((Entry *)recordPtr, Tcl_GetString(values[currentIndex]));
} else {
Tcl_WrongNumArgs(interp, 2, objv, "?newIndex?");
return TCL_ERROR;
@@ -1906,7 +1920,7 @@ static const Ttk_Ensemble ComboboxCommands[] = {
{ 0,0,0 }
};
-static WidgetSpec ComboboxWidgetSpec = {
+static const WidgetSpec ComboboxWidgetSpec = {
"TCombobox", /* className */
sizeof(Combobox), /* recordSize */
ComboboxOptionSpecs, /* optionSpecs */
@@ -1943,29 +1957,29 @@ typedef struct {
SpinboxPart spinbox;
} Spinbox;
-static Tk_OptionSpec SpinboxOptionSpecs[] = {
+static const Tk_OptionSpec SpinboxOptionSpecs[] = {
{TK_OPTION_STRING, "-values", "values", "Values",
- "", Tk_Offset(Spinbox, spinbox.valuesObj), -1,
+ "", offsetof(Spinbox, spinbox.valuesObj), TCL_INDEX_NONE,
0,0,0 },
{TK_OPTION_DOUBLE, "-from", "from", "From",
- "0", Tk_Offset(Spinbox,spinbox.fromObj), -1,
+ "0", offsetof(Spinbox,spinbox.fromObj), TCL_INDEX_NONE,
0,0,0 },
{TK_OPTION_DOUBLE, "-to", "to", "To",
- "0", Tk_Offset(Spinbox,spinbox.toObj), -1,
+ "0", offsetof(Spinbox,spinbox.toObj), TCL_INDEX_NONE,
0,0,0 },
{TK_OPTION_DOUBLE, "-increment", "increment", "Increment",
- "1", Tk_Offset(Spinbox,spinbox.incrementObj), -1,
+ "1", offsetof(Spinbox,spinbox.incrementObj), TCL_INDEX_NONE,
0,0,0 },
{TK_OPTION_STRING, "-format", "format", "Format",
- "", Tk_Offset(Spinbox, spinbox.formatObj), -1,
+ "", offsetof(Spinbox, spinbox.formatObj), TCL_INDEX_NONE,
0,0,0 },
{TK_OPTION_STRING, "-command", "command", "Command",
- "", Tk_Offset(Spinbox, spinbox.commandObj), -1,
+ "", offsetof(Spinbox, spinbox.commandObj), TCL_INDEX_NONE,
0,0,0 },
{TK_OPTION_BOOLEAN, "-wrap", "wrap", "Wrap",
- "0", Tk_Offset(Spinbox,spinbox.wrapObj), -1,
+ "0", offsetof(Spinbox,spinbox.wrapObj), TCL_INDEX_NONE,
0,0,0 },
WIDGET_INHERIT_OPTIONS(EntryOptionSpecs)
@@ -1977,7 +1991,7 @@ static Tk_OptionSpec SpinboxOptionSpecs[] = {
static void
SpinboxInitialize(Tcl_Interp *interp, void *recordPtr)
{
- Spinbox *sb = recordPtr;
+ Spinbox *sb = (Spinbox *)recordPtr;
TtkTrackElementState(&sb->core);
EntryInitialize(interp, recordPtr);
}
@@ -1988,7 +2002,7 @@ SpinboxInitialize(Tcl_Interp *interp, void *recordPtr)
static int
SpinboxConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
{
- Spinbox *sb = recordPtr;
+ Spinbox *sb = (Spinbox *)recordPtr;
int unused;
/* Make sure -values is a valid list:
@@ -2018,7 +2032,7 @@ static const Ttk_Ensemble SpinboxCommands[] = {
{ 0,0,0 }
};
-static WidgetSpec SpinboxWidgetSpec = {
+static const WidgetSpec SpinboxWidgetSpec = {
"TSpinbox", /* className */
sizeof(Spinbox), /* recordSize */
SpinboxOptionSpecs, /* optionSpecs */
@@ -2045,23 +2059,25 @@ typedef struct {
Tcl_Obj *widthObj;
} TextareaElement;
-static Ttk_ElementOptionSpec TextareaElementOptions[] = {
+static const Ttk_ElementOptionSpec TextareaElementOptions[] = {
{ "-font", TK_OPTION_FONT,
- Tk_Offset(TextareaElement,fontObj), DEF_ENTRY_FONT },
+ offsetof(TextareaElement,fontObj), DEF_ENTRY_FONT },
{ "-width", TK_OPTION_INT,
- Tk_Offset(TextareaElement,widthObj), "20" },
- { NULL, 0, 0, NULL }
+ offsetof(TextareaElement,widthObj), "20" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void TextareaElementSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- TextareaElement *textarea = elementRecord;
+ TextareaElement *textarea = (TextareaElement *)elementRecord;
Tk_Font font = Tk_GetFontFromObj(tkwin, textarea->fontObj);
int avgWidth = Tk_TextWidth(font, "0", 1);
Tk_FontMetrics fm;
int prefWidth = 1;
+ (void)dummy;
+ (void)paddingPtr;
Tk_GetFontMetrics(font, &fm);
Tcl_GetIntFromObj(NULL, textarea->widthObj, &prefWidth);
@@ -2072,7 +2088,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 b8b3477..d7563a0 100644
--- a/generic/ttk/ttkFrame.c
+++ b/generic/ttk/ttkFrame.c
@@ -26,21 +26,21 @@ typedef struct {
FramePart frame;
} Frame;
-static Tk_OptionSpec FrameOptionSpecs[] = {
+static const Tk_OptionSpec FrameOptionSpecs[] = {
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth", NULL,
- Tk_Offset(Frame,frame.borderWidthObj), -1,
+ offsetof(Frame,frame.borderWidthObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
{TK_OPTION_STRING, "-padding", "padding", "Pad", NULL,
- Tk_Offset(Frame,frame.paddingObj), -1,
+ offsetof(Frame,frame.paddingObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
{TK_OPTION_RELIEF, "-relief", "relief", "Relief", NULL,
- Tk_Offset(Frame,frame.reliefObj), -1,
+ offsetof(Frame,frame.reliefObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,0 },
{TK_OPTION_PIXELS, "-width", "width", "Width", "0",
- Tk_Offset(Frame,frame.widthObj), -1,
+ offsetof(Frame,frame.widthObj), TCL_INDEX_NONE,
0,0,GEOMETRY_CHANGED },
{TK_OPTION_PIXELS, "-height", "height", "Height", "0",
- Tk_Offset(Frame,frame.heightObj), -1,
+ offsetof(Frame,frame.heightObj), TCL_INDEX_NONE,
0,0,GEOMETRY_CHANGED },
WIDGET_TAKEFOCUS_FALSE,
@@ -148,7 +148,7 @@ static int FrameConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
return TtkCoreConfigure(interp, recordPtr, mask);
}
-static WidgetSpec FrameWidgetSpec = {
+static const WidgetSpec FrameWidgetSpec = {
"TFrame", /* className */
sizeof(Frame), /* recordSize */
FrameOptionSpecs, /* optionSpecs */
@@ -250,18 +250,18 @@ typedef struct {
#define LABELWIDGET_CHANGED 0x100
-static Tk_OptionSpec LabelframeOptionSpecs[] = {
+static const Tk_OptionSpec LabelframeOptionSpecs[] = {
{TK_OPTION_STRING, "-labelanchor", "labelAnchor", "LabelAnchor",
- "nw", Tk_Offset(Labelframe, label.labelAnchorObj),-1,
+ "nw", offsetof(Labelframe, label.labelAnchorObj),TCL_INDEX_NONE,
0,0,GEOMETRY_CHANGED},
{TK_OPTION_STRING, "-text", "text", "Text", "",
- Tk_Offset(Labelframe,label.textObj), -1,
+ offsetof(Labelframe,label.textObj), TCL_INDEX_NONE,
0,0,GEOMETRY_CHANGED },
{TK_OPTION_INT, "-underline", "underline", "Underline",
- "-1", Tk_Offset(Labelframe,label.underlineObj), -1,
+ "-1", offsetof(Labelframe,label.underlineObj), TCL_INDEX_NONE,
0,0,0 },
{TK_OPTION_WINDOW, "-labelwidget", "labelWidget", "LabelWidget", NULL,
- -1, Tk_Offset(Labelframe,label.labelWidget),
+ TCL_INDEX_NONE, offsetof(Labelframe,label.labelWidget),
TK_OPTION_NULL_OK,0,LABELWIDGET_CHANGED|GEOMETRY_CHANGED },
WIDGET_INHERIT_OPTIONS(FrameOptionSpecs)
@@ -495,7 +495,7 @@ static void LabelframePlaceContent(void *recordPtr)
static int LabelRequest(
TCL_UNUSED(void *),
- TCL_UNUSED(int),
+ TCL_UNUSED(TkSizeT),
TCL_UNUSED(int),
TCL_UNUSED(int))
{
@@ -511,7 +511,7 @@ static int LabelRequest(
*/
static void LabelRemoved(
void *managerData,
- TCL_UNUSED(int))
+ TCL_UNUSED(TkSizeT))
{
Labelframe *lframe = (Labelframe *)managerData;
@@ -626,7 +626,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 6aabd61..0000000
--- a/generic/ttk/ttkGenStubs.tcl
+++ /dev/null
@@ -1,1008 +0,0 @@
-# ttkGenStubs.tcl --
-#
-# This script generates a set of stub files for a given
-# interface.
-#
-#
-# Copyright (c) 1998-1999 by 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]
- set out [open ${file}.new w]
- fconfigure $out -translation lf
-
- 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 $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 5c2a55f..e6ad27d 100644
--- a/generic/ttk/ttkImage.c
+++ b/generic/ttk/ttkImage.c
@@ -10,7 +10,6 @@
* [style map].
*/
-#include <string.h>
#include "tkInt.h"
#include "ttkTheme.h"
@@ -32,9 +31,17 @@ struct TtkImageSpec {
/* NullImageChanged --
* Do-nothing Tk_ImageChangedProc.
*/
-static void NullImageChanged(ClientData clientData,
+static void NullImageChanged(ClientData dummy,
int x, int y, int width, int height, int imageWidth, int imageHeight)
-{ /* No-op */ }
+{ /* No-op */
+ (void)dummy;
+ (void)x;
+ (void)y;
+ (void)width;
+ (void)height;
+ (void)imageWidth;
+ (void)imageHeight;
+}
/* ImageSpecImageChanged --
* Image changes should trigger a repaint.
@@ -75,7 +82,7 @@ TtkGetImageSpecEx(Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr,
int i = 0, n = 0, objc;
Tcl_Obj **objv;
- imageSpec = ckalloc(sizeof(*imageSpec));
+ imageSpec = (Ttk_ImageSpec *)ckalloc(sizeof(*imageSpec));
imageSpec->baseImage = 0;
imageSpec->mapCount = 0;
imageSpec->states = 0;
@@ -98,8 +105,8 @@ TtkGetImageSpecEx(Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr,
}
n = (objc - 1) / 2;
- imageSpec->states = ckalloc(n * sizeof(Ttk_StateSpec));
- imageSpec->images = ckalloc(n * sizeof(Tk_Image *));
+ imageSpec->states = (Ttk_StateSpec *)ckalloc(n * sizeof(Ttk_StateSpec));
+ imageSpec->images = (Tk_Image *)ckalloc(n * sizeof(Tk_Image));
/* Get base image:
*/
@@ -206,6 +213,7 @@ static void Ttk_Fill(
int dr = dst.x + dst.width;
int db = dst.y + dst.height;
int x,y;
+ (void)tkwin;
if (!(src.width && src.height && dst.width && dst.height))
return;
@@ -263,7 +271,7 @@ typedef struct { /* ClientData for image elements */
static void FreeImageData(void *clientData)
{
- ImageData *imageData = clientData;
+ ImageData *imageData = (ImageData *)clientData;
if (imageData->imageSpec) { TtkFreeImageSpec(imageData->imageSpec); }
#if TILE_07_COMPAT
if (imageData->imageMap) { Tcl_DecrRefCount(imageData->imageMap); }
@@ -275,8 +283,10 @@ static void ImageElementSize(
void *clientData, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- ImageData *imageData = clientData;
+ ImageData *imageData = (ImageData *)clientData;
Tk_Image image = imageData->imageSpec->baseImage;
+ (void)elementRecord;
+ (void)tkwin;
if (image) {
Tk_SizeOfImage(image, widthPtr, heightPtr);
@@ -295,10 +305,11 @@ static void ImageElementDraw(
void *clientData, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, unsigned int state)
{
- ImageData *imageData = clientData;
+ ImageData *imageData = (ImageData *)clientData;
Tk_Image image = 0;
int imgWidth, imgHeight;
Ttk_Box src, dst;
+ (void)elementRecord;
#if TILE_07_COMPAT
if (imageData->imageMap) {
@@ -325,7 +336,7 @@ static void ImageElementDraw(
Ttk_Tile(tkwin, d, image, src, dst, imageData->border);
}
-static Ttk_ElementSpec ImageElementSpec =
+static const Ttk_ElementSpec ImageElementSpec =
{
TK_STYLE_VERSION_2,
sizeof(NullElement),
@@ -340,12 +351,12 @@ static Ttk_ElementSpec ImageElementSpec =
static int
Ttk_CreateImageElement(
Tcl_Interp *interp,
- void *clientData,
+ void *dummy,
Ttk_Theme theme,
const char *elementName,
int objc, Tcl_Obj *const objv[])
{
- static const char *optionStrings[] =
+ static const char *const optionStrings[] =
{ "-border","-height","-padding","-sticky","-width",NULL };
enum { O_BORDER, O_HEIGHT, O_PADDING, O_STICKY, O_WIDTH };
@@ -353,6 +364,7 @@ Ttk_CreateImageElement(
ImageData *imageData = 0;
int padding_specified = 0;
int i;
+ (void)dummy;
if (objc <= 0) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
@@ -366,7 +378,7 @@ Ttk_CreateImageElement(
return TCL_ERROR;
}
- imageData = ckalloc(sizeof(*imageData));
+ imageData = (ImageData *)ckalloc(sizeof(*imageData));
imageData->imageSpec = imageSpec;
imageData->minWidth = imageData->minHeight = -1;
imageData->sticky = TTK_FILL_BOTH;
diff --git a/generic/ttk/ttkInit.c b/generic/ttk/ttkInit.c
index f1b6e26..4a43253 100644
--- a/generic/ttk/ttkInit.c
+++ b/generic/ttk/ttkInit.c
@@ -4,7 +4,6 @@
* Ttk package: initialization routine and miscellaneous utilities.
*/
-#include <string.h>
#include "tkInt.h"
#include "ttkTheme.h"
#include "ttkWidget.h"
@@ -13,43 +12,50 @@
* Legal values for the button -default option.
* See also: enum Ttk_ButtonDefaultState.
*/
-const char *ttkDefaultStrings[] = {
+const char *const ttkDefaultStrings[] = {
"normal", "active", "disabled", NULL
};
int Ttk_GetButtonDefaultStateFromObj(
- Tcl_Interp *interp, Tcl_Obj *objPtr, int *statePtr)
+ Tcl_Interp *interp, Tcl_Obj *objPtr, Ttk_ButtonDefaultState *statePtr)
{
- *statePtr = TTK_BUTTON_DEFAULT_DISABLED;
- return Tcl_GetIndexFromObjStruct(interp, objPtr, ttkDefaultStrings,
- sizeof(char *), "default state", 0, statePtr);
+ int state = (int)TTK_BUTTON_DEFAULT_DISABLED;
+ int result = Tcl_GetIndexFromObjStruct(interp, objPtr, ttkDefaultStrings,
+ sizeof(char *), "default state", 0, &state);
+
+ *statePtr = (Ttk_ButtonDefaultState)state;
+ return result;
}
/*
* Legal values for the -compound option.
* See also: enum Ttk_Compound.
*/
-const char *ttkCompoundStrings[] = {
+const char *const ttkCompoundStrings[] = {
"none", "text", "image", "center",
"top", "bottom", "left", "right", NULL
};
int Ttk_GetCompoundFromObj(
- Tcl_Interp *interp, Tcl_Obj *objPtr, int *statePtr)
+ Tcl_Interp *interp, Tcl_Obj *objPtr, Ttk_Compound *compoundPtr)
{
- *statePtr = TTK_COMPOUND_NONE;
- return Tcl_GetIndexFromObjStruct(interp, objPtr, ttkCompoundStrings,
- sizeof(char *), "compound layout", 0, statePtr);
+ int compound = (int)TTK_COMPOUND_NONE;
+ int result = Tcl_GetIndexFromObjStruct(interp, objPtr, ttkCompoundStrings,
+ sizeof(char *), "compound layout", 0, &compound);
+
+ *compoundPtr = (Ttk_Compound)compound;
+ return result;
}
/*
* Legal values for the -orient option.
* See also: enum Ttk_Orient.
*/
-const char *ttkOrientStrings[] = {
+const char *const ttkOrientStrings[] = {
"horizontal", "vertical", NULL
};
+#if !defined(TK_NO_DEPRECATED) && TK_MAJOR_VERSION < 9
int Ttk_GetOrientFromObj(
Tcl_Interp *interp, Tcl_Obj *objPtr, int *resultPtr)
{
@@ -57,12 +63,24 @@ int Ttk_GetOrientFromObj(
return Tcl_GetIndexFromObjStruct(interp, objPtr, ttkOrientStrings,
sizeof(char *), "orientation", 0, resultPtr);
}
+#endif
+
+int TtkGetOrientFromObj(
+ Tcl_Interp *interp, Tcl_Obj *objPtr, Ttk_Orient *resultPtr)
+{
+ int orient = (int)TTK_ORIENT_HORIZONTAL;
+ int result = Tcl_GetIndexFromObjStruct(interp, objPtr, ttkOrientStrings,
+ sizeof(char *), "orientation", 0, &orient);
+
+ *resultPtr = (Ttk_Orient)orient;
+ return result;
+}
/*
* Recognized values for the -state compatibility option.
* Other options are accepted and interpreted as synonyms for "normal".
*/
-static const char *ttkStateStrings[] = {
+static const char *const ttkStateStrings[] = {
"normal", "readonly", "disabled", "active", NULL
};
enum {
@@ -106,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>>"
- *
- * 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.
*/
@@ -149,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);
@@ -176,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}
};
diff --git a/generic/ttk/ttkLabel.c b/generic/ttk/ttkLabel.c
index 6f32299..a4dbf96 100644
--- a/generic/ttk/ttkLabel.c
+++ b/generic/ttk/ttkLabel.c
@@ -46,25 +46,25 @@ typedef struct {
/* Text element options table.
* NB: Keep in sync with label element option table.
*/
-static Ttk_ElementOptionSpec TextElementOptions[] = {
+static const Ttk_ElementOptionSpec TextElementOptions[] = {
{ "-text", TK_OPTION_STRING,
- Tk_Offset(TextElement,textObj), "" },
+ offsetof(TextElement,textObj), "" },
{ "-font", TK_OPTION_FONT,
- Tk_Offset(TextElement,fontObj), DEFAULT_FONT },
+ offsetof(TextElement,fontObj), DEFAULT_FONT },
{ "-foreground", TK_OPTION_COLOR,
- Tk_Offset(TextElement,foregroundObj), "black" },
+ offsetof(TextElement,foregroundObj), "black" },
{ "-underline", TK_OPTION_INT,
- Tk_Offset(TextElement,underlineObj), "-1"},
+ offsetof(TextElement,underlineObj), "-1"},
{ "-width", TK_OPTION_INT,
- Tk_Offset(TextElement,widthObj), "-1"},
+ offsetof(TextElement,widthObj), "-1"},
{ "-anchor", TK_OPTION_ANCHOR,
- Tk_Offset(TextElement,anchorObj), "w"},
+ offsetof(TextElement,anchorObj), "w"},
{ "-justify", TK_OPTION_JUSTIFY,
- Tk_Offset(TextElement,justifyObj), "left" },
+ offsetof(TextElement,justifyObj), "left" },
{ "-wraplength", TK_OPTION_PIXELS,
- Tk_Offset(TextElement,wrapLengthObj), "0" },
+ offsetof(TextElement,wrapLengthObj), "0" },
{ "-embossed", TK_OPTION_INT,
- Tk_Offset(TextElement,embossedObj), "0"},
+ offsetof(TextElement,embossedObj), "0"},
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -225,7 +225,7 @@ static void TextElementDraw(
}
}
-static Ttk_ElementSpec TextElementSpec = {
+static const Ttk_ElementSpec TextElementSpec = {
TK_STYLE_VERSION_2,
sizeof(TextElement),
TextElementOptions,
@@ -251,13 +251,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 }
};
@@ -392,7 +392,7 @@ static void ImageElementDraw(
}
}
-static Ttk_ElementSpec ImageElementSpec = {
+static const Ttk_ElementSpec ImageElementSpec = {
TK_STYLE_VERSION_2,
sizeof(ImageElement),
ImageElementOptions,
@@ -448,43 +448,43 @@ typedef struct {
int totalWidth, totalHeight;
} LabelElement;
-static Ttk_ElementOptionSpec LabelElementOptions[] = {
+static const Ttk_ElementOptionSpec LabelElementOptions[] = {
{ "-compound", TK_OPTION_ANY,
- Tk_Offset(LabelElement,compoundObj), "none" },
+ offsetof(LabelElement,compoundObj), "none" },
{ "-space", TK_OPTION_PIXELS,
- Tk_Offset(LabelElement,spaceObj), "4" },
+ offsetof(LabelElement,spaceObj), "4" },
/* Text element part:
* NB: Keep in sync with TextElementOptions.
*/
{ "-text", TK_OPTION_STRING,
- Tk_Offset(LabelElement,text.textObj), "" },
+ offsetof(LabelElement,text.textObj), "" },
{ "-font", TK_OPTION_FONT,
- Tk_Offset(LabelElement,text.fontObj), DEFAULT_FONT },
+ offsetof(LabelElement,text.fontObj), DEFAULT_FONT },
{ "-foreground", TK_OPTION_COLOR,
- Tk_Offset(LabelElement,text.foregroundObj), "black" },
+ offsetof(LabelElement,text.foregroundObj), "black" },
{ "-underline", TK_OPTION_INT,
- Tk_Offset(LabelElement,text.underlineObj), "-1"},
+ offsetof(LabelElement,text.underlineObj), "-1"},
{ "-width", TK_OPTION_INT,
- Tk_Offset(LabelElement,text.widthObj), ""},
+ offsetof(LabelElement,text.widthObj), ""},
{ "-anchor", TK_OPTION_ANCHOR,
- Tk_Offset(LabelElement,text.anchorObj), "w"},
+ offsetof(LabelElement,text.anchorObj), "w"},
{ "-justify", TK_OPTION_JUSTIFY,
- Tk_Offset(LabelElement,text.justifyObj), "left" },
+ offsetof(LabelElement,text.justifyObj), "left" },
{ "-wraplength", TK_OPTION_PIXELS,
- Tk_Offset(LabelElement,text.wrapLengthObj), "0" },
+ offsetof(LabelElement,text.wrapLengthObj), "0" },
{ "-embossed", TK_OPTION_INT,
- Tk_Offset(LabelElement,text.embossedObj), "0"},
+ offsetof(LabelElement,text.embossedObj), "0"},
/* Image element part:
* NB: Keep in sync with ImageElementOptions.
*/
{ "-image", TK_OPTION_STRING,
- Tk_Offset(LabelElement,image.imageObj), "" },
+ offsetof(LabelElement,image.imageObj), "" },
{ "-stipple", TK_OPTION_STRING, /* Really: TK_OPTION_BITMAP */
- Tk_Offset(LabelElement,image.stippleObj), "gray50" },
+ offsetof(LabelElement,image.stippleObj), "gray50" },
{ "-background", TK_OPTION_COLOR,
- Tk_Offset(LabelElement,image.backgroundObj), DEFAULT_BACKGROUND },
+ offsetof(LabelElement,image.backgroundObj), DEFAULT_BACKGROUND },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -503,7 +503,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.
@@ -617,7 +617,7 @@ static void LabelElementSize(
*/
static void DrawCompound(
LabelElement *l, Ttk_Box b, Tk_Window tkwin, Drawable d, Ttk_State state,
- int imageSide, int textSide)
+ Ttk_Side imageSide, Ttk_Side textSide)
{
Ttk_Box imageBox =
Ttk_PlaceBox(&b, l->image.width, l->image.height, imageSide, 0);
@@ -684,7 +684,7 @@ static void LabelElementDraw(
LabelCleanup(l);
}
-static Ttk_ElementSpec LabelElementSpec = {
+static const Ttk_ElementSpec LabelElementSpec = {
TK_STYLE_VERSION_2,
sizeof(LabelElement),
LabelElementOptions,
diff --git a/generic/ttk/ttkLayout.c b/generic/ttk/ttkLayout.c
index fdbeacf..a971d23 100644
--- a/generic/ttk/ttkLayout.c
+++ b/generic/ttk/ttkLayout.c
@@ -6,7 +6,6 @@
* Copyright (c) 2003 Joe English. Freely redistributable.
*/
-#include <string.h>
#include "tkInt.h"
#include "ttkThemeInt.h"
@@ -37,10 +36,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);
}
@@ -525,7 +524,7 @@ struct Ttk_LayoutNode_
static Ttk_LayoutNode *Ttk_NewLayoutNode(
unsigned flags, Ttk_ElementClass *elementClass)
{
- Ttk_LayoutNode *node = ckalloc(sizeof(*node));
+ Ttk_LayoutNode *node = (Ttk_LayoutNode *)ckalloc(sizeof(*node));
node->flags = flags;
node->eclass = elementClass;
@@ -558,8 +557,8 @@ struct Ttk_TemplateNode_ {
static Ttk_TemplateNode *Ttk_NewTemplateNode(const char *name, unsigned flags)
{
- Ttk_TemplateNode *op = ckalloc(sizeof(*op));
- op->name = ckalloc(strlen(name) + 1); strcpy(op->name, name);
+ Ttk_TemplateNode *op = (Ttk_TemplateNode *)ckalloc(sizeof(*op));
+ op->name = (char *)ckalloc(strlen(name) + 1); strcpy(op->name, name);
op->flags = flags;
op->next = op->child = 0;
return op;
@@ -604,13 +603,13 @@ Ttk_InstantiateLayout(Ttk_Theme theme, Ttk_TemplateNode *op)
*/
/* NB: This must match bit definitions TTK_PACK_LEFT etc. */
-static const char *packSideStrings[] =
+static const char *const packSideStrings[] =
{ "left", "right", "top", "bottom", NULL };
Ttk_LayoutTemplate Ttk_ParseLayoutTemplate(Tcl_Interp *interp, Tcl_Obj *objPtr)
{
enum { OP_SIDE, OP_STICKY, OP_EXPAND, OP_BORDER, OP_UNIT, OP_CHILDREN };
- static const char *optStrings[] = {
+ static const char *const optStrings[] = {
"-side", "-sticky", "-expand", "-border", "-unit", "-children", 0 };
int i = 0, objc;
@@ -844,7 +843,7 @@ static Ttk_Layout TTKNewLayout(
void *recordPtr,Tk_OptionTable optionTable, Tk_Window tkwin,
Ttk_LayoutNode *root)
{
- Ttk_Layout layout = ckalloc(sizeof(*layout));
+ Ttk_Layout layout = (Ttk_Layout)ckalloc(sizeof(*layout));
layout->style = style;
layout->recordPtr = recordPtr;
layout->optionTable = optionTable;
diff --git a/generic/ttk/ttkManager.c b/generic/ttk/ttkManager.c
index 8cad58c..0d41d21 100644
--- a/generic/ttk/ttkManager.c
+++ b/generic/ttk/ttkManager.c
@@ -4,7 +4,6 @@
* Support routines for geometry managers.
*/
-#include <string.h>
#include "tkInt.h"
#include "ttkManager.h"
@@ -35,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.
*/
@@ -62,7 +61,7 @@ struct TtkManager_
void *managerData;
Tk_Window window;
unsigned flags;
- int nContent;
+ TkSizeT nContent;
Ttk_Content **content;
};
@@ -107,7 +106,7 @@ 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;
}
@@ -143,7 +142,7 @@ static const int ManagerEventMask = StructureNotifyMask;
static void ManagerEventHandler(ClientData clientData, XEvent *eventPtr)
{
Ttk_Manager *mgr = (Ttk_Manager *)clientData;
- int i;
+ TkSizeT i;
switch (eventPtr->type)
{
@@ -175,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);
}
}
@@ -248,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, TkSizeT index)
{
- int endIndex = mgr->nContent++;
+ TkSizeT endIndex = mgr->nContent++;
mgr->content = (Ttk_Content **)ckrealloc(mgr->content, mgr->nContent * sizeof(Ttk_Content *));
while (endIndex > index) {
@@ -277,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, TkSizeT index)
{
Ttk_Content *content = mgr->content[index];
- int i;
+ TkSizeT i;
/* Notify manager:
*/
- mgr->managerSpec->SlaveRemoved(mgr->managerData, index);
+ mgr->managerSpec->ContentRemoved(mgr->managerData, index);
/* Remove from array:
*/
@@ -314,11 +313,11 @@ static void RemoveContent(Ttk_Manager *mgr, int index)
void Ttk_GeometryRequestProc(ClientData clientData, Tk_Window window)
{
Ttk_Manager *mgr = (Ttk_Manager *)clientData;
- int index = Ttk_ContentIndex(mgr, window);
+ TkSizeT index = Ttk_ContentIndex(mgr, window);
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);
@@ -328,7 +327,7 @@ void Ttk_GeometryRequestProc(ClientData clientData, Tk_Window window)
void Ttk_LostContentProc(ClientData clientData, Tk_Window window)
{
Ttk_Manager *mgr = (Ttk_Manager *)clientData;
- int index = Ttk_ContentIndex(mgr, window);
+ TkSizeT index = Ttk_ContentIndex(mgr, window);
/* ASSERT: index >= 0 */
RemoveContent(mgr, index);
@@ -342,7 +341,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, TkSizeT index, Tk_Window tkwin, void *data)
{
Ttk_Content *content = NewContent(mgr, tkwin, data);
InsertContent(mgr, content, index);
@@ -351,7 +350,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, TkSizeT index)
{
Tk_Window window = mgr->content[index]->window;
RemoveContent(mgr, index);
@@ -366,7 +365,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, TkSizeT 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 +378,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, TkSizeT index)
{
Ttk_Content *content = mgr->content[index];
Tk_UnmaintainGeometry(content->window, mgr->window);
@@ -405,15 +404,15 @@ void Ttk_ManagerSizeChanged(Ttk_Manager *mgr)
/* +++ Accessors.
*/
-int Ttk_NumberContent(Ttk_Manager *mgr)
+TkSizeT Ttk_NumberContent(Ttk_Manager *mgr)
{
return mgr->nContent;
}
-void *Ttk_ContentData(Ttk_Manager *mgr, int index)
+void *Ttk_ContentData(Ttk_Manager *mgr, TkSizeT index)
{
return mgr->content[index]->data;
}
-Tk_Window Ttk_ContentWindow(Ttk_Manager *mgr, int index)
+Tk_Window Ttk_ContentWindow(Ttk_Manager *mgr, TkSizeT index)
{
return mgr->content[index]->window;
}
@@ -425,13 +424,13 @@ Tk_Window Ttk_ContentWindow(Ttk_Manager *mgr, int index)
/* ++ Ttk_ContentIndex --
* Returns the index of specified content window, -1 if not found.
*/
-int Ttk_ContentIndex(Ttk_Manager *mgr, Tk_Window window)
+TkSizeT Ttk_ContentIndex(Ttk_Manager *mgr, Tk_Window window)
{
- int index;
+ TkSizeT index;
for (index = 0; index < mgr->nContent; ++index)
if (mgr->content[index]->window == window)
return index;
- return -1;
+ return TCL_INDEX_NONE;
}
/* ++ Ttk_GetContentIndexFromObj(interp, mgr, objPtr, indexPtr) --
@@ -444,19 +443,19 @@ int Ttk_ContentIndex(Ttk_Manager *mgr, Tk_Window window)
*/
int Ttk_GetContentIndexFromObj(
- Tcl_Interp *interp, Ttk_Manager *mgr, Tcl_Obj *objPtr, int *indexPtr)
+ Tcl_Interp *interp, Ttk_Manager *mgr, Tcl_Obj *objPtr, TkSizeT *indexPtr)
{
const char *string = Tcl_GetString(objPtr);
- int index = 0;
+ TkSizeT 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, 1, &index) == TCL_OK) {
+ if (index + 1 > mgr->nContent + 1) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
- "Slave index %d out of bounds", index));
- Tcl_SetErrorCode(interp, "TTK", "SLAVE", "INDEX", NULL);
+ "Managed window index %d out of bounds", (int)index));
+ Tcl_SetErrorCode(interp, "TTK", "MANAGED", "INDEX", NULL);
return TCL_ERROR;
}
*indexPtr = index;
@@ -468,11 +467,11 @@ int Ttk_GetContentIndexFromObj(
if ((*string == '.') &&
(tkwin = Tk_NameToWindow(interp, string, mgr->window))) {
index = Ttk_ContentIndex(mgr, tkwin);
- if (index < 0) {
+ if (index == TCL_INDEX_NONE) {
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 +479,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, TkSizeT fromIndex, TkSizeT toIndex)
{
Ttk_Content *moved = mgr->content[fromIndex];
@@ -540,7 +539,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..07b0ade 100644
--- a/generic/ttk/ttkManager.h
+++ b/generic/ttk/ttkManager.h
@@ -16,29 +16,29 @@ 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, TkSizeT index, int w, int h);
+ void (*ContentRemoved)(void *managerData, TkSizeT index);
} Ttk_ManagerSpec;
/*
* Default implementations for Tk_GeomMgr hooks:
*/
-#define Ttk_LostContentProc Ttk_LostSlaveProc
+#define Ttk_LostSlaveProc Ttk_LostContentProc
MODULE_SCOPE void Ttk_GeometryRequestProc(ClientData, Tk_Window window);
MODULE_SCOPE void Ttk_LostContentProc(ClientData, Tk_Window window);
@@ -49,24 +49,24 @@ MODULE_SCOPE Ttk_Manager *Ttk_CreateManager(
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 *, TkSizeT 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 *, TkSizeT 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 *, TkSizeT fromIndex, TkSizeT 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 *, TkSizeT 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 *, TkSizeT 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 TkSizeT 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 *, TkSizeT *indexPtr);
/* Accessor functions:
*/
-#define Ttk_NumberContent Ttk_NumberSlaves
-MODULE_SCOPE int Ttk_NumberContent(Ttk_Manager *);
+#define Ttk_NumberSlaves Ttk_NumberContent
+MODULE_SCOPE TkSizeT 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 *, TkSizeT 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 *, TkSizeT 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 83075bc..26eab6b 100644
--- a/generic/ttk/ttkNotebook.c
+++ b/generic/ttk/ttkNotebook.c
@@ -3,10 +3,6 @@
*/
#include "tkInt.h"
-#include <string.h>
-#include <ctype.h>
-#include <stdio.h>
-
#include "ttkTheme.h"
#include "ttkWidget.h"
#include "ttkManager.h"
@@ -57,31 +53,31 @@ typedef struct
* relevant to the tab.
*
* PaneOptionSpecs includes additional options for child window placement
- * and is used to configure the content window.
+ * 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),
0, (void *)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,
- TK_OPTION_NULL_OK, (void *)ttkCompoundStrings, GEOMETRY_CHANGED },
+ NULL, offsetof(Tab,compoundObj), TCL_INDEX_NONE,
+ TK_OPTION_NULL_OK,(void *)ttkCompoundStrings,GEOMETRY_CHANGED },
{TK_OPTION_INT, "-underline", "underline", "Underline", "-1",
- Tk_Offset(Tab,underlineObj), -1, 0,0,GEOMETRY_CHANGED },
+ offsetof(Tab,underlineObj), TCL_INDEX_NONE, 0, 0, GEOMETRY_CHANGED },
{TK_OPTION_END, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0 }
};
-static Tk_OptionSpec PaneOptionSpecs[] =
+static const Tk_OptionSpec PaneOptionSpecs[] =
{
{TK_OPTION_STRING, "-padding", "padding", "Padding", "0",
- Tk_Offset(Tab,paddingObj), -1, 0,0,GEOMETRY_CHANGED },
+ offsetof(Tab,paddingObj), TCL_INDEX_NONE, 0, 0, GEOMETRY_CHANGED },
{TK_OPTION_STRING, "-sticky", "sticky", "Sticky", "nsew",
- Tk_Offset(Tab,stickyObj), -1, 0,0,GEOMETRY_CHANGED },
+ offsetof(Tab,stickyObj), TCL_INDEX_NONE, 0, 0, GEOMETRY_CHANGED },
WIDGET_INHERIT_OPTIONS(TabOptionSpecs)
};
@@ -98,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 */
+ TkSizeT currentIndex; /* index of currently selected tab */
+ TkSizeT 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
@@ -111,16 +107,16 @@ typedef struct
NotebookPart notebook;
} Notebook;
-static Tk_OptionSpec NotebookOptionSpecs[] =
+static const Tk_OptionSpec NotebookOptionSpecs[] =
{
{TK_OPTION_INT, "-width", "width", "Width", "0",
- Tk_Offset(Notebook,notebook.widthObj),-1,
+ offsetof(Notebook,notebook.widthObj),TCL_INDEX_NONE,
0,0,GEOMETRY_CHANGED },
{TK_OPTION_INT, "-height", "height", "Height", "0",
- Tk_Offset(Notebook,notebook.heightObj),-1,
+ offsetof(Notebook,notebook.heightObj),TCL_INDEX_NONE,
0,0,GEOMETRY_CHANGED },
{TK_OPTION_STRING, "-padding", "padding", "Padding", NULL,
- Tk_Offset(Notebook,notebook.paddingObj),-1,
+ offsetof(Notebook,notebook.paddingObj),TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
WIDGET_TAKEFOCUS_TRUE,
@@ -197,7 +193,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;
}
@@ -221,7 +217,7 @@ static int ConfigureTab(
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;
@@ -258,9 +254,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 TkSizeT IdentifyTab(Notebook *nb, int x, int y)
{
- int index;
+ TkSizeT 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
@@ -269,14 +265,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, TkSizeT index)
{
if (index != nb->notebook.activeIndex) {
nb->notebook.activeIndex = index;
@@ -291,11 +287,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, TkSizeT index)
{
Ttk_State state = nb->core.state;
Tab *itab = (Tab *)Ttk_ContentData(nb->notebook.mgr, index);
- int i = 0;
+ TkSizeT i = 0;
if (index == nb->notebook.currentIndex) {
state |= TTK_STATE_SELECTED;
@@ -316,7 +312,7 @@ static Ttk_State TabState(Notebook *nb, int index)
}
break;
}
- for (i = Ttk_NumberContent(nb->notebook.mgr) - 1; i != -1; --i) {
+ for (i = Ttk_NumberContent(nb->notebook.mgr) - 1; i != TCL_INDEX_NONE; --i) {
Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, i);
if (tab->state == TAB_STATE_HIDDEN) {
continue;
@@ -355,7 +351,7 @@ static void TabrowSize(
{
Ttk_Layout tabLayout = nb->notebook.tabLayout;
int tabrowWidth = 0, tabrowHeight = 0;
- int i;
+ TkSizeT i;
for (i = 0; i < Ttk_NumberContent(nb->notebook.mgr); ++i) {
Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, i);
@@ -395,7 +391,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;
+ TkSizeT i;
NotebookStyleOptions(nb, &nbstyle);
@@ -575,7 +571,7 @@ static void NotebookDoLayout(void *recordPtr)
* 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, TkSizeT index)
{
Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, index);
Tk_Window window = Ttk_ContentWindow(nb->notebook.mgr, index);
@@ -593,8 +589,8 @@ static void NotebookPlaceContent(Notebook *nb, int index)
static void NotebookPlaceContents(void *recordPtr)
{
Notebook *nb = (Notebook *)recordPtr;
- int currentIndex = nb->notebook.currentIndex;
- if (currentIndex >= 0) {
+ TkSizeT currentIndex = nb->notebook.currentIndex;
+ if (currentIndex != TCL_INDEX_NONE) {
NotebookDoLayout(nb);
NotebookPlaceContent(nb, currentIndex);
}
@@ -604,10 +600,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, TkSizeT index)
{
Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, index);
- int currentIndex = nb->notebook.currentIndex;
+ TkSizeT currentIndex = nb->notebook.currentIndex;
if (index == currentIndex) {
return;
@@ -623,7 +619,7 @@ static void SelectTab(Notebook *nb, int index)
tab->state = TAB_STATE_NORMAL;
}
- if (currentIndex >= 0) {
+ if (currentIndex != TCL_INDEX_NONE) {
Ttk_UnmapContent(nb->notebook.mgr, currentIndex);
}
@@ -635,7 +631,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 --
@@ -645,12 +641,12 @@ static void SelectTab(Notebook *nb, int index)
*/
static int NextTab(Notebook *nb, int index)
{
- int nTabs = Ttk_NumberContent(nb->notebook.mgr);
- int nextIndex;
+ TkSizeT nTabs = Ttk_NumberContent(nb->notebook.mgr);
+ TkSizeT nextIndex;
/* Scan forward for following usable tab:
*/
- for (nextIndex = index + 1; nextIndex < nTabs; ++nextIndex) {
+ for (nextIndex = index + 1; nextIndex + 1 < nTabs + 1; ++nextIndex) {
Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, nextIndex);
if (tab->state == TAB_STATE_NORMAL) {
return nextIndex;
@@ -659,7 +655,7 @@ static int NextTab(Notebook *nb, int index)
/* Not found -- scan backwards.
*/
- for (nextIndex = index - 1; nextIndex >= 0; --nextIndex) {
+ for (nextIndex = index - 1; nextIndex != TCL_INDEX_NONE; --nextIndex) {
Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, nextIndex);
if (tab->state == TAB_STATE_NORMAL) {
return nextIndex;
@@ -680,14 +676,14 @@ static int NextTab(Notebook *nb, int index)
*/
static void SelectNearestTab(Notebook *nb)
{
- int currentIndex = nb->notebook.currentIndex;
- int nextIndex = NextTab(nb, currentIndex);
+ TkSizeT currentIndex = nb->notebook.currentIndex;
+ TkSizeT nextIndex = NextTab(nb, currentIndex);
- if (currentIndex >= 0) {
+ if (currentIndex != TCL_INDEX_NONE) {
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;
@@ -699,7 +695,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, TkSizeT index)
{
Notebook *nb = (Notebook *)managerData;
Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, index);
@@ -708,7 +704,7 @@ static void TabRemoved(void *managerData, int index)
SelectNearestTab(nb);
}
- if (index < nb->notebook.currentIndex) {
+ if (index + 1 < nb->notebook.currentIndex + 1) {
--nb->notebook.currentIndex;
}
@@ -719,7 +715,7 @@ static void TabRemoved(void *managerData, int index)
static int TabRequest(
TCL_UNUSED(void *),
- TCL_UNUSED(int),
+ TCL_UNUSED(TkSizeT),
TCL_UNUSED(int),
TCL_UNUSED(int))
{
@@ -731,7 +727,7 @@ static int TabRequest(
*/
static int AddTab(
Tcl_Interp *interp, Notebook *nb,
- int destIndex, Tk_Window window,
+ TkSizeT destIndex, Tk_Window window,
int objc, Tcl_Obj *const objv[])
{
Tab *tab;
@@ -739,7 +735,7 @@ static int AddTab(
return TCL_ERROR;
}
#if 0 /* can't happen */
- if (Ttk_ContentIndex(nb->notebook.mgr, window) >= 0) {
+ if (Ttk_ContentIndex(nb->notebook.mgr, window) != TCL_INDEX_NONE) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf("%s already added",
Tk_PathName(window)));
Tcl_SetErrorCode(interp, "TTK", "NOTEBOOK", "PRESENT", NULL);
@@ -762,9 +758,9 @@ static int AddTab(
/* Adjust indices and/or autoselect first tab:
*/
- if (nb->notebook.currentIndex < 0) {
+ if (nb->notebook.currentIndex == TCL_INDEX_NONE) {
SelectTab(nb, destIndex);
- } else if (nb->notebook.currentIndex >= destIndex) {
+ } else if (nb->notebook.currentIndex + 1 >= destIndex + 1) {
++nb->notebook.currentIndex;
}
@@ -799,7 +795,7 @@ static void NotebookEventHandler(ClientData 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);
+ TkSizeT index = IdentifyTab(nb, eventPtr->xmotion.x, eventPtr->xmotion.y);
ActivateTab(nb, index);
} else if (eventPtr->type == LeaveNotify) {
ActivateTab(nb, -1);
@@ -827,12 +823,12 @@ static void NotebookEventHandler(ClientData 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, TkSizeT *index_rtn)
{
const char *string = Tcl_GetString(objPtr);
int x, y;
- *index_rtn = -1;
+ *index_rtn = TCL_INDEX_NONE;
/* Check for @x,y ...
*/
@@ -855,6 +851,12 @@ static int FindTabIndex(
{
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.
*/
@@ -867,11 +869,17 @@ 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, TkSizeT *index_rtn)
{
int status = FindTabIndex(interp, nb, objPtr, index_rtn);
+ if (status == TCL_OK && *index_rtn + 1 >= Ttk_NumberContent(nb->notebook.mgr) + 1) {
+ 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) {
+ if (status == TCL_OK && *index_rtn == TCL_INDEX_NONE) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"tab '%s' not found", Tcl_GetString(objPtr)));
Tcl_SetErrorCode(interp, "TTK", "NOTEBOOK", "TAB", NULL);
@@ -929,18 +937,16 @@ static int NotebookInsertCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
Notebook *nb = (Notebook *)recordPtr;
- int current = nb->notebook.currentIndex;
- int nContent = Ttk_NumberContent(nb->notebook.mgr);
- int srcIndex, destIndex;
+ TkSizeT current = nb->notebook.currentIndex;
+ TkSizeT nContent = Ttk_NumberContent(nb->notebook.mgr);
+ TkSizeT srcIndex, destIndex;
if (objc < 4) {
- Tcl_WrongNumArgs(interp, 2,objv, "index slave ?-option value ...?");
+ Tcl_WrongNumArgs(interp, 2,objv, "index window ?-option value ...?");
return TCL_ERROR;
}
- if (!strcmp(Tcl_GetString(objv[2]), "end")) {
- destIndex = Ttk_NumberContent(nb->notebook.mgr);
- } else if (TCL_OK != Ttk_GetContentIndexFromObj(
+ if (TCL_OK != Ttk_GetContentIndexFromObj(
interp, nb->notebook.mgr, objv[2], &destIndex)) {
return TCL_ERROR;
}
@@ -956,13 +962,15 @@ static int NotebookInsertCommand(
}
srcIndex = Ttk_ContentIndex(nb->notebook.mgr, window);
- if (srcIndex < 0) { /* New content window */
+ if (srcIndex == TCL_INDEX_NONE) { /* New content window */
return AddTab(interp, nb, destIndex, window, objc-4,objv+4);
}
} else if (Ttk_GetContentIndexFromObj(
interp, nb->notebook.mgr, objv[3], &srcIndex) != TCL_OK)
{
return TCL_ERROR;
+ } else if (srcIndex + 1 >= Ttk_NumberContent(nb->notebook.mgr) + 1) {
+ srcIndex = Ttk_NumberContent(nb->notebook.mgr) - 1;
}
/* Move existing content window:
@@ -975,19 +983,19 @@ static int NotebookInsertCommand(
return TCL_ERROR;
}
- if (destIndex >= nContent) {
+ if (destIndex + 1 >= nContent + 1) {
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) {
+ } else if (destIndex + 1 <= current + 1 && current + 1 < srcIndex + 1) {
++nb->notebook.currentIndex;
- } else if (srcIndex < current && current <= destIndex) {
+ } else if (srcIndex + 1 < current + 1 && current + 1 <= destIndex + 1) {
--nb->notebook.currentIndex;
}
@@ -1003,7 +1011,7 @@ static int NotebookForgetCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
Notebook *nb = (Notebook *)recordPtr;
- int index;
+ TkSizeT index;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "tab");
@@ -1027,7 +1035,7 @@ static int NotebookHideCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
Notebook *nb = (Notebook *)recordPtr;
- int index;
+ TkSizeT index;
Tab *tab;
if (objc != 3) {
@@ -1056,13 +1064,13 @@ static int NotebookHideCommand(
static int NotebookIdentifyCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- static const char *whatTable[] = { "element", "tab", NULL };
+ static const char *const whatTable[] = { "element", "tab", NULL };
enum { IDENTIFY_ELEMENT, IDENTIFY_TAB };
int what = IDENTIFY_ELEMENT;
Notebook *nb = (Notebook *)recordPtr;
Ttk_Element element = NULL;
int x, y;
- int tabIndex;
+ TkSizeT tabIndex;
if (objc < 4 || objc > 5) {
Tcl_WrongNumArgs(interp, 2,objv, "?what? x y");
@@ -1078,7 +1086,7 @@ static int NotebookIdentifyCommand(
}
tabIndex = IdentifyTab(nb, x, y);
- if (tabIndex >= 0) {
+ if (tabIndex != TCL_INDEX_NONE) {
Tab *tab = (Tab *)Ttk_ContentData(nb->notebook.mgr, tabIndex);
Ttk_State state = TabState(nb, tabIndex);
Ttk_Layout tabLayout = nb->notebook.tabLayout;
@@ -1098,9 +1106,8 @@ static int NotebookIdentifyCommand(
}
break;
case IDENTIFY_TAB:
- if (tabIndex >= 0) {
- Tcl_SetObjResult(interp, Tcl_NewIntObj(tabIndex));
- }
+ if (tabIndex != TCL_INDEX_NONE)
+ Tcl_SetObjResult(interp, TkNewIndexObj(tabIndex));
break;
}
return TCL_OK;
@@ -1115,7 +1122,7 @@ static int NotebookIndexCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
Notebook *nb = (Notebook *)recordPtr;
- int index;
+ TkSizeT index;
int status;
if (objc != 3) {
@@ -1123,18 +1130,10 @@ 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 (index != TCL_INDEX_NONE)
+ Tcl_SetObjResult(interp, TkNewIndexObj(index));
}
return status;
@@ -1150,14 +1149,15 @@ static int NotebookSelectCommand(
Notebook *nb = (Notebook *)recordPtr;
if (objc == 2) {
- if (nb->notebook.currentIndex >= 0) {
+ if (nb->notebook.currentIndex != TCL_INDEX_NONE) {
Tk_Window pane = Ttk_ContentWindow(
nb->notebook.mgr, nb->notebook.currentIndex);
Tcl_SetObjResult(interp, Tcl_NewStringObj(Tk_PathName(pane), -1));
}
return TCL_OK;
} else if (objc == 3) {
- int index, status = GetTabIndex(interp, nb, objv[2], &index);
+ TkSizeT index;
+ int status = GetTabIndex(interp, nb, objv[2], &index);
if (status == TCL_OK) {
SelectTab(nb, index);
}
@@ -1176,7 +1176,7 @@ static int NotebookTabsCommand(
Notebook *nb = (Notebook *)recordPtr;
Ttk_Manager *mgr = nb->notebook.mgr;
Tcl_Obj *result;
- int i;
+ TkSizeT i;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 2, objv, "");
@@ -1200,7 +1200,7 @@ static int NotebookTabCommand(
{
Notebook *nb = (Notebook *)recordPtr;
Ttk_Manager *mgr = nb->notebook.mgr;
- int index;
+ TkSizeT index;
Tk_Window window;
Tab *tab;
@@ -1271,8 +1271,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);
@@ -1357,8 +1357,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;
+ TkSizeT nContent = Ttk_NumberContent(nb->notebook.mgr);
+ TkSizeT index;
/* Draw notebook background (base layout):
*/
@@ -1372,7 +1372,7 @@ static void NotebookDisplay(void *clientData, Drawable d)
DisplayTab(nb, index, d);
}
}
- if (nb->notebook.currentIndex >= 0) {
+ if (nb->notebook.currentIndex != TCL_INDEX_NONE) {
DisplayTab(nb, nb->notebook.currentIndex, d);
}
}
@@ -1381,7 +1381,7 @@ static void NotebookDisplay(void *clientData, Drawable d)
* +++ Widget specification and layout definitions.
*/
-static WidgetSpec NotebookWidgetSpec =
+static const WidgetSpec NotebookWidgetSpec =
{
"TNotebook", /* className */
sizeof(Notebook), /* recordSize */
diff --git a/generic/ttk/ttkPanedwindow.c b/generic/ttk/ttkPanedwindow.c
index fa0d5c8..ae7bf11 100644
--- a/generic/ttk/ttkPanedwindow.c
+++ b/generic/ttk/ttkPanedwindow.c
@@ -6,7 +6,6 @@
* TODO: track active/pressed sash.
*/
-#include <string.h>
#include "tkInt.h"
#include "ttkManager.h"
#include "ttkTheme.h"
@@ -75,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, (void *)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,
@@ -99,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 --
@@ -148,7 +147,7 @@ static int ConfigurePane(
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;
@@ -207,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, TkSizeT i, int pos)
{
Pane *pane = (Pane *)Ttk_ContentData(pw->paned.mgr,i);
int sashThickness = pw->paned.sashThickness;
@@ -276,7 +275,7 @@ static void AdjustPanes(Paned *pw)
{
int sashThickness = pw->paned.sashThickness;
int pos = 0;
- int index;
+ TkSizeT index;
for (index = 0; index < Ttk_NumberContent(pw->paned.mgr); ++index) {
Pane *pane = (Pane *)Ttk_ContentData(pw->paned.mgr, index);
@@ -373,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;
+ TkSizeT index;
for (index = 0; index < Ttk_NumberContent(pw->paned.mgr); ++index) {
Pane *pane = (Pane *)Ttk_ContentData(pw->paned.mgr, index);
@@ -404,7 +403,7 @@ static void PanedPlaceContent(void *managerData)
PlacePanes(pw);
}
-static void PaneRemoved(void *managerData, int index)
+static void PaneRemoved(void *managerData, TkSizeT index)
{
Paned *pw = (Paned *)managerData;
Pane *pane = (Pane *)Ttk_ContentData(pw->paned.mgr, index);
@@ -420,7 +419,7 @@ static int AddPane(
if (!Ttk_Maintainable(interp, window, pw->core.tkwin)) {
return TCL_ERROR;
}
- if (Ttk_ContentIndex(pw->paned.mgr, window) >= 0) {
+ if (Ttk_ContentIndex(pw->paned.mgr, window) != TCL_INDEX_NONE) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"%s already added", Tk_PathName(window)));
Tcl_SetErrorCode(interp, "TTK", "PANE", "PRESENT", NULL);
@@ -446,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, TkSizeT index, int width, int height)
{
Paned *pw = (Paned *)managerData;
Pane *pane = (Pane *)Ttk_ContentData(pw->paned.mgr, index);
@@ -487,7 +486,7 @@ static void PanedEventProc(ClientData clientData, XEvent *eventPtr)
if ( eventPtr->type == LeaveNotify
&& eventPtr->xcrossing.detail == NotifyInferior)
{
- TtkSendVirtualEvent(corePtr->tkwin, "EnteredChild");
+ Tk_SendVirtualEvent(corePtr->tkwin, "EnteredChild", NULL);
}
}
@@ -607,11 +606,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;
+ TkSizeT 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);
}
}
@@ -650,12 +649,12 @@ static int PanedInsertCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
Paned *pw = (Paned *)recordPtr;
- int nContent = Ttk_NumberContent(pw->paned.mgr);
- int srcIndex, destIndex;
+ TkSizeT nContent = Ttk_NumberContent(pw->paned.mgr);
+ TkSizeT 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;
}
@@ -665,20 +664,18 @@ 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(
+ if (TCL_OK != Ttk_GetContentIndexFromObj(
interp,pw->paned.mgr, objv[2], &destIndex))
{
return TCL_ERROR;
}
srcIndex = Ttk_ContentIndex(pw->paned.mgr, window);
- if (srcIndex < 0) { /* New content: */
+ if (srcIndex == TCL_INDEX_NONE) { /* New content: */
return AddPane(interp, pw, destIndex, window, objc-4, objv+4);
} /* else -- move existing content: */
- if (destIndex >= nContent)
+ if (destIndex + 1 >= nContent + 1)
destIndex = nContent - 1;
Ttk_ReorderContent(pw->paned.mgr, srcIndex, destIndex);
@@ -695,7 +692,7 @@ static int PanedForgetCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
Paned *pw = (Paned *)recordPtr;
- int paneIndex;
+ TkSizeT paneIndex;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2,objv, "pane");
@@ -706,6 +703,8 @@ static int PanedForgetCommand(
interp, pw->paned.mgr, objv[2], &paneIndex))
{
return TCL_ERROR;
+ } else if (paneIndex + 1 >= Ttk_NumberContent(pw->paned.mgr) + 1) {
+ paneIndex = Ttk_NumberContent(pw->paned.mgr) - 1;
}
Ttk_ForgetContent(pw->paned.mgr, paneIndex);
@@ -718,7 +717,7 @@ static int PanedForgetCommand(
static int PanedIdentifyCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- static const char *whatTable[] = { "element", "sash", NULL };
+ static const char *const whatTable[] = { "element", "sash", NULL };
enum { IDENTIFY_ELEMENT, IDENTIFY_SASH };
int what = IDENTIFY_SASH;
Paned *pw = (Paned *)recordPtr;
@@ -747,7 +746,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:
{
@@ -773,7 +772,7 @@ static int PanedPaneCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
Paned *pw = (Paned *)recordPtr;
- int paneIndex;
+ TkSizeT paneIndex;
Tk_Window window;
Pane *pane;
@@ -786,6 +785,8 @@ static int PanedPaneCommand(
interp,pw->paned.mgr, objv[2], &paneIndex))
{
return TCL_ERROR;
+ } else if (paneIndex + 1 >= Ttk_NumberContent(pw->paned.mgr) + 1) {
+ paneIndex = Ttk_NumberContent(pw->paned.mgr) - 1;
}
pane = (Pane *)Ttk_ContentData(pw->paned.mgr, paneIndex);
@@ -812,7 +813,7 @@ static int PanedPanesCommand(
Paned *pw = (Paned *)recordPtr;
Ttk_Manager *mgr = pw->paned.mgr;
Tcl_Obj *panes;
- int i;
+ TkSizeT i;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 2, objv, "");
@@ -847,7 +848,7 @@ static int PanedSashposCommand(
if (Tcl_GetIntFromObj(interp, objv[2], &sashIndex) != TCL_OK) {
return TCL_ERROR;
}
- if (sashIndex < 0 || sashIndex >= Ttk_NumberContent(pw->paned.mgr) - 1) {
+ if (sashIndex < 0 || (TkSizeT)sashIndex + 1 >= Ttk_NumberContent(pw->paned.mgr)) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"sash index %d out of range", sashIndex));
Tcl_SetErrorCode(interp, "TTK", "PANE", "SASH_INDEX", NULL);
@@ -857,7 +858,7 @@ 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 */
@@ -875,7 +876,7 @@ static int PanedSashposCommand(
AdjustPanes(pw);
Ttk_ManagerLayoutChanged(pw->paned.mgr);
- Tcl_SetObjResult(interp, Tcl_NewIntObj(pane->sashPos));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(pane->sashPos));
return TCL_OK;
}
@@ -898,7 +899,7 @@ static const Ttk_Ensemble PanedCommands[] = {
* +++ Widget specification.
*/
-static WidgetSpec PanedWidgetSpec =
+static const WidgetSpec PanedWidgetSpec =
{
"TPanedwindow", /* className */
sizeof(Paned), /* recordSize */
@@ -924,9 +925,9 @@ typedef struct {
Tcl_Obj *thicknessObj;
} SashElement;
-static Ttk_ElementOptionSpec SashElementOptions[] = {
+static const Ttk_ElementOptionSpec SashElementOptions[] = {
{ "-sashthickness", TK_OPTION_INT,
- Tk_Offset(SashElement,thicknessObj), "5" },
+ offsetof(SashElement,thicknessObj), "5" },
{ NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
@@ -945,7 +946,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 ae945ae..a025885 100644
--- a/generic/ttk/ttkProgress.c
+++ b/generic/ttk/ttkProgress.c
@@ -4,7 +4,6 @@
* ttk::progressbar widget.
*/
-#include <math.h>
#include "tkInt.h"
#include "ttkTheme.h"
#include "ttkWidget.h"
@@ -22,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 */
@@ -43,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, (void *)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", 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, (void *)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, (void *)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 +137,7 @@ static void AnimateProgressProc(ClientData clientData)
if (pb->progress.maxPhase)
phase %= pb->progress.maxPhase;
Tcl_DecrRefCount(pb->progress.phaseObj);
- pb->progress.phaseObj = Tcl_NewIntObj(phase);
+ pb->progress.phaseObj = Tcl_NewWideIntObj(phase);
Tcl_IncrRefCount(pb->progress.phaseObj);
/*
@@ -271,14 +294,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;
@@ -342,7 +365,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));
@@ -351,7 +374,7 @@ static void ProgressbarDoLayout(void *recordPtr)
Tcl_GetDoubleFromObj(NULL, pb->progress.valueObj, &value);
Tcl_GetDoubleFromObj(NULL, pb->progress.maximumObj, &maximum);
- Ttk_GetOrientFromObj(NULL, pb->progress.orientObj, &orient);
+ TtkGetOrientFromObj(NULL, pb->progress.orientObj, &orient);
if (pbar) {
double fraction = value / maximum;
@@ -506,7 +529,7 @@ static const Ttk_Ensemble ProgressbarCommands[] = {
/*
* Widget specification:
*/
-static WidgetSpec ProgressbarWidgetSpec =
+static const WidgetSpec ProgressbarWidgetSpec =
{
"TProgressbar", /* className */
sizeof(Progressbar), /* recordSize */
@@ -532,7 +555,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.text", TTK_PACK_LEFT))
TTK_END_LAYOUT
/*
diff --git a/generic/ttk/ttkScale.c b/generic/ttk/ttkScale.c
index 4d05f97..9f27245 100644
--- a/generic/ttk/ttkScale.c
+++ b/generic/ttk/ttkScale.c
@@ -4,8 +4,7 @@
* ttk::scale widget.
*/
-#include <string.h>
-#include <stdio.h>
+#include "tkInt.h"
#include "tkInt.h"
#include "ttkTheme.h"
#include "ttkWidget.h"
@@ -52,32 +51,32 @@ 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,
- 0,0,0},
+ offsetof(Scale,scale.variableObj), TCL_INDEX_NONE,
+ 0, 0, 0},
{TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "horizontal",
- Tk_Offset(Scale,scale.orientObj),
- Tk_Offset(Scale,scale.orient), 0,
+ offsetof(Scale,scale.orientObj),
+ offsetof(Scale,scale.orient), 0,
(void *)ttkOrientStrings, STYLE_CHANGED },
{TK_OPTION_DOUBLE, "-from", "from", "From", "0",
- Tk_Offset(Scale,scale.fromObj), -1, 0, 0, 0},
+ offsetof(Scale,scale.fromObj), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_DOUBLE, "-to", "to", "To", "1.0",
- Tk_Offset(Scale,scale.toObj), -1, 0, 0, 0},
+ offsetof(Scale,scale.toObj), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_DOUBLE, "-value", "value", "Value", "0",
- Tk_Offset(Scale,scale.valueObj), -1, 0, 0, 0},
+ offsetof(Scale,scale.valueObj), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_PIXELS, "-length", "length", "Length",
- DEF_SCALE_LENGTH, Tk_Offset(Scale,scale.lengthObj), -1, 0, 0,
+ DEF_SCALE_LENGTH, offsetof(Scale,scale.lengthObj), TCL_INDEX_NONE, 0, 0,
GEOMETRY_CHANGED},
{TK_OPTION_STRING, "-state", "state", "State",
- "normal", Tk_Offset(Scale,scale.stateObj), -1,
- 0,0,STATE_CHANGED},
+ "normal", offsetof(Scale,scale.stateObj), TCL_INDEX_NONE,
+ 0, 0, STATE_CHANGED},
WIDGET_TAKEFOCUS_TRUE,
WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
@@ -378,8 +377,8 @@ ScaleCoordsCommand(
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;
@@ -494,7 +493,7 @@ static const Ttk_Ensemble ScaleCommands[] = {
{ 0,0,0 }
};
-static WidgetSpec ScaleWidgetSpec =
+static const WidgetSpec ScaleWidgetSpec =
{
"TScale", /* Class name */
sizeof(Scale), /* record size */
diff --git a/generic/ttk/ttkScroll.c b/generic/ttk/ttkScroll.c
index 9cf8eae..69370c9 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;
@@ -130,12 +130,12 @@ static void UpdateScrollbarBG(ClientData clientData)
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;
}
}
@@ -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 5ffd671..54923ff 100644
--- a/generic/ttk/ttkScrollbar.c
+++ b/generic/ttk/ttkScrollbar.c
@@ -31,14 +31,14 @@ typedef struct
ScrollbarPart scrollbar;
} Scrollbar;
-static Tk_OptionSpec ScrollbarOptionSpecs[] =
+static const Tk_OptionSpec ScrollbarOptionSpecs[] =
{
{TK_OPTION_STRING, "-command", "command", "Command", "",
- Tk_Offset(Scrollbar,scrollbar.commandObj), -1, 0,0,0},
+ offsetof(Scrollbar, scrollbar.commandObj), TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "vertical",
- Tk_Offset(Scrollbar,scrollbar.orientObj),
- Tk_Offset(Scrollbar,scrollbar.orient),
+ offsetof(Scrollbar, scrollbar.orientObj),
+ offsetof(Scrollbar, scrollbar.orient),
0, (void *)ttkOrientStrings, STYLE_CHANGED },
WIDGET_TAKEFOCUS_FALSE,
@@ -296,7 +296,7 @@ static const Ttk_Ensemble ScrollbarCommands[] = {
/*------------------------------------------------------------------------
* +++ Widget specification.
*/
-static WidgetSpec ScrollbarWidgetSpec =
+static const WidgetSpec ScrollbarWidgetSpec =
{
"TScrollbar", /* className */
sizeof(Scrollbar), /* recordSize */
diff --git a/generic/ttk/ttkSeparator.c b/generic/ttk/ttkSeparator.c
index a0ae596..e86ee5c 100644
--- a/generic/ttk/ttkSeparator.c
+++ b/generic/ttk/ttkSeparator.c
@@ -22,10 +22,10 @@ typedef struct
SeparatorPart separator;
} Separator;
-static Tk_OptionSpec SeparatorOptionSpecs[] = {
+static const Tk_OptionSpec SeparatorOptionSpecs[] = {
{TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "horizontal",
- Tk_Offset(Separator,separator.orientObj),
- Tk_Offset(Separator,separator.orient),
+ offsetof(Separator,separator.orientObj),
+ offsetof(Separator,separator.orient),
0, (void *)ttkOrientStrings, STYLE_CHANGED },
WIDGET_TAKEFOCUS_FALSE,
@@ -39,7 +39,7 @@ static Tk_OptionSpec SeparatorOptionSpecs[] = {
static Ttk_Layout SeparatorGetLayout(
Tcl_Interp *interp, Ttk_Theme theme, void *recordPtr)
{
- Separator *sep = recordPtr;
+ Separator *sep = (Separator *)recordPtr;
return TtkWidgetGetOrientedLayout(
interp, theme, recordPtr, sep->separator.orientObj);
}
@@ -59,7 +59,7 @@ static const Ttk_Ensemble SeparatorCommands[] = {
/*
* Widget specification:
*/
-static WidgetSpec SeparatorWidgetSpec =
+static const WidgetSpec SeparatorWidgetSpec =
{
"TSeparator", /* className */
sizeof(Separator), /* recordSize */
@@ -83,7 +83,7 @@ TTK_END_LAYOUT
* Has no options or methods other than the standard ones.
*/
-static Tk_OptionSpec SizegripOptionSpecs[] = {
+static const Tk_OptionSpec SizegripOptionSpecs[] = {
WIDGET_TAKEFOCUS_FALSE,
WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
};
@@ -97,7 +97,7 @@ static const Ttk_Ensemble SizegripCommands[] = {
{ 0,0,0 }
};
-static WidgetSpec SizegripWidgetSpec =
+static const WidgetSpec SizegripWidgetSpec =
{
"TSizegrip", /* className */
sizeof(WidgetCore), /* recordSize */
diff --git a/generic/ttk/ttkSquare.c b/generic/ttk/ttkSquare.c
index bd2a8c7..422afc3 100644
--- a/generic/ttk/ttkSquare.c
+++ b/generic/ttk/ttkSquare.c
@@ -48,31 +48,31 @@ typedef struct
* defined for all widgets.
*/
-static Tk_OptionSpec SquareOptionSpecs[] =
+static const Tk_OptionSpec SquareOptionSpecs[] =
{
{TK_OPTION_PIXELS, "-borderwidth", "borderWidth", "BorderWidth",
- DEFAULT_BORDERWIDTH, Tk_Offset(Square,square.borderWidthObj), -1,
+ DEFAULT_BORDERWIDTH, offsetof(Square,square.borderWidthObj), TCL_INDEX_NONE,
0,0,GEOMETRY_CHANGED },
{TK_OPTION_BORDER, "-foreground", "foreground", "Foreground",
- DEFAULT_BACKGROUND, Tk_Offset(Square,square.foregroundObj),
- -1, 0, 0, 0},
+ DEFAULT_BACKGROUND, offsetof(Square,square.foregroundObj),
+ TCL_INDEX_NONE, 0, 0, 0},
{TK_OPTION_PIXELS, "-width", "width", "Width",
- "50", Tk_Offset(Square,square.widthObj), -1, 0, 0,
+ "50", offsetof(Square,square.widthObj), TCL_INDEX_NONE, 0, 0,
GEOMETRY_CHANGED},
{TK_OPTION_PIXELS, "-height", "height", "Height",
- "50", Tk_Offset(Square,square.heightObj), -1, 0, 0,
+ "50", offsetof(Square,square.heightObj), TCL_INDEX_NONE, 0, 0,
GEOMETRY_CHANGED},
{TK_OPTION_STRING, "-padding", "padding", "Pad", NULL,
- Tk_Offset(Square,square.paddingObj), -1,
+ offsetof(Square,square.paddingObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
{TK_OPTION_RELIEF, "-relief", "relief", "Relief",
- NULL, Tk_Offset(Square,square.reliefObj), -1, TK_OPTION_NULL_OK, 0, 0},
+ NULL, offsetof(Square,square.reliefObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0},
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
- NULL, Tk_Offset(Square,square.anchorObj), -1, TK_OPTION_NULL_OK, 0, 0},
+ NULL, offsetof(Square,square.anchorObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK, 0, 0},
WIDGET_TAKEFOCUS_TRUE,
WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
@@ -143,7 +143,7 @@ static const Ttk_Ensemble SquareCommands[] = {
* with Tk in the package initialization code (see bottom).
*/
-static WidgetSpec SquareWidgetSpec =
+static const WidgetSpec SquareWidgetSpec =
{
"TSquare", /* className */
sizeof(Square), /* recordSize */
@@ -176,18 +176,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 }
};
@@ -233,7 +233,7 @@ static void SquareElementDraw(
b.x, b.y, b.width, b.height, borderWidth, relief);
}
-static Ttk_ElementSpec SquareElementSpec =
+static const Ttk_ElementSpec SquareElementSpec =
{
TK_STYLE_VERSION_2,
sizeof(SquareElement),
diff --git a/generic/ttk/ttkState.c b/generic/ttk/ttkState.c
index d37f7f6..a704fa4 100644
--- a/generic/ttk/ttkState.c
+++ b/generic/ttk/ttkState.c
@@ -5,7 +5,6 @@
*
*/
-#include <string.h>
#include "tkInt.h"
#include "ttkTheme.h"
@@ -146,14 +145,14 @@ static void StateSpecUpdateString(Tcl_Obj *objPtr)
len = Tcl_DStringLength(&result);
if (len) {
/* 'len' includes extra trailing ' ' */
- objPtr->bytes = ckalloc(len);
+ objPtr->bytes = (char *)ckalloc(len);
objPtr->length = len-1;
strncpy(objPtr->bytes, Tcl_DStringValue(&result), len-1);
objPtr->bytes[len-1] = '\0';
} else {
/* empty string */
objPtr->length = 0;
- objPtr->bytes = ckalloc(1);
+ objPtr->bytes = (char *)ckalloc(1);
*objPtr->bytes = '\0';
}
@@ -262,7 +261,7 @@ Ttk_StateMap Ttk_GetStateMapFromObj(
* Ttk_StateTableLooup --
* Look up an index from a statically allocated state table.
*/
-int Ttk_StateTableLookup(Ttk_StateTable *map, unsigned int state)
+int Ttk_StateTableLookup(const Ttk_StateTable *map, unsigned int state)
{
while ((state & map->onBits) != map->onBits
|| (~state & map->offBits) != map->offBits)
diff --git a/generic/ttk/ttkStubInit.c b/generic/ttk/ttkStubInit.c
index 0039585..dc11b4c 100644
--- a/generic/ttk/ttkStubInit.c
+++ b/generic/ttk/ttkStubInit.c
@@ -8,6 +8,18 @@
MODULE_SCOPE const TtkStubs ttkStubs;
+#if defined(TK_NO_DEPRECATED) || TCL_MAJOR_VERSION > 8
+#define Ttk_GetOrientFromObj 0
+#endif
+
+#ifdef __GNUC__
+/*
+ * The rest of this file shouldn't warn about deprecated functions; they're
+ * there because we intend them to be so and know that this file is OK to
+ * touch those fields.
+ */
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+#endif
/* !BEGIN!: Do not edit below this line. */
const TtkStubs ttkStubs = {
diff --git a/generic/ttk/ttkTagSet.c b/generic/ttk/ttkTagSet.c
index fc026cb..e99c76f 100644
--- a/generic/ttk/ttkTagSet.c
+++ b/generic/ttk/ttkTagSet.c
@@ -4,9 +4,7 @@
* Copyright (C) 2005, Joe English. Freely redistributable.
*/
-#include <string.h> /* for memset() */
#include "tkInt.h"
-
#include "ttkTheme.h"
#include "ttkWidget.h"
@@ -21,7 +19,7 @@ struct TtkTag {
struct TtkTagTable {
Tk_Window tkwin; /* owner window */
- Tk_OptionSpec *optionSpecs; /* ... */
+ const Tk_OptionSpec *optionSpecs; /* ... */
Tk_OptionTable optionTable; /* ... */
int recordSize; /* size of tag record */
int nTags; /* #tags defined so far */
@@ -55,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, int recordSize)
{
Ttk_TagTable tagTable = (Ttk_TagTable)ckalloc(sizeof(*tagTable));
tagTable->tkwin = tkwin;
@@ -82,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;
@@ -271,8 +280,8 @@ void Ttk_TagSetValues(Ttk_TagTable tagTable, Ttk_TagSet tagSet, void *record)
memset(record, 0, tagTable->recordSize);
for (i = 0; tagTable->optionSpecs[i].type != TK_OPTION_END; ++i) {
- Tk_OptionSpec *optionSpec = tagTable->optionSpecs + i;
- int offset = optionSpec->objOffset;
+ const Tk_OptionSpec *optionSpec = tagTable->optionSpecs + i;
+ TkSizeT offset = optionSpec->objOffset;
int prio = LOWEST_PRIORITY;
for (j = 0; j < tagSet->nTags; ++j) {
@@ -288,10 +297,10 @@ 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;
+ TkSizeT offset = optionSpec->objOffset;
const char *optionName = optionSpec->optionName;
Tcl_Obj *val = Ttk_StyleMap(style, optionName, state);
if (val) {
diff --git a/generic/ttk/ttkTheme.c b/generic/ttk/ttkTheme.c
index 00cb50b..eaea800 100644
--- a/generic/ttk/ttkTheme.c
+++ b/generic/ttk/ttkTheme.c
@@ -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 */
@@ -142,7 +142,7 @@ static const Tk_OptionSpec *TTKGetOptionSpec(
/* Make sure widget option has a Tcl_Obj* entry:
*/
- if (optionSpec->objOffset < 0) {
+ if (optionSpec->objOffset == TCL_INDEX_NONE) {
return 0;
}
@@ -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;
@@ -872,7 +872,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;
@@ -913,7 +913,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;
@@ -977,16 +977,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) {
@@ -1071,7 +1071,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 */
@@ -1101,7 +1101,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. */
@@ -1381,7 +1381,7 @@ static int StyleThemeCreateCmd(
ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
StylePackageData *pkgPtr = (StylePackageData *)clientData;
- static const char *optStrings[] =
+ static const char *const optStrings[] =
{ "-parent", "-settings", NULL };
enum { OP_PARENT, OP_SETTINGS };
Ttk_Theme parentTheme = pkgPtr->defaultTheme, newTheme;
@@ -1554,8 +1554,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) {
diff --git a/generic/ttk/ttkTheme.h b/generic/ttk/ttkTheme.h
index cf0a07c..7f9f6e9 100644
--- a/generic/ttk/ttkTheme.h
+++ b/generic/ttk/ttkTheme.h
@@ -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.
@@ -238,11 +203,19 @@ typedef void (Ttk_ElementSizeProc)(void *clientData, void *elementRecord,
typedef void (Ttk_ElementDrawProc)(void *clientData, void *elementRecord,
Tk_Window tkwin, Drawable d, Ttk_Box b, Ttk_State state);
+#ifndef TkSizeT
+# if TCL_MAJOR_VERSION > 8
+# define TkSizeT size_t
+# else
+# define TkSizeT int
+# endif
+#endif
+
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 */
+ TkSizeT offset; /* Offset of Tcl_Obj* field in element record */
const char *defaultValue; /* Default value to used if resource missing */
} Ttk_ElementOptionSpec;
@@ -251,22 +224,15 @@ typedef struct Ttk_ElementOptionSpec
typedef struct Ttk_ElementSpec {
enum TTKStyleVersion2 version; /* Version of the style support. */
size_t elementSize; /* Size of element record */
- Ttk_ElementOptionSpec *options; /* List of options, NULL-terminated */
+ const Ttk_ElementOptionSpec *options; /* List of options, NULL-terminated */
Ttk_ElementSizeProc *size; /* Compute min size and padding */
Ttk_ElementDrawProc *draw; /* Draw the element */
} Ttk_ElementSpec;
-TTKAPI Ttk_ElementClass *Ttk_RegisterElement(
- Tcl_Interp *interp, Ttk_Theme theme, const char *elementName,
- Ttk_ElementSpec *, void *clientData);
-
typedef int (*Ttk_ElementFactory)
(Tcl_Interp *, void *clientData,
Ttk_Theme, const char *elementName, int objc, Tcl_Obj *const objv[]);
-TTKAPI int Ttk_RegisterElementFactory(
- Tcl_Interp *, const char *name, Ttk_ElementFactory, void *clientData);
-
/*
* Null element implementation:
* has no geometry or layout; may be used as a stub or placeholder.
@@ -280,7 +246,7 @@ MODULE_SCOPE void TtkNullElementSize
(void *, void *, Tk_Window, int *, int *, Ttk_Padding *);
MODULE_SCOPE void TtkNullElementDraw
(void *, void *, Tk_Window, Drawable, Ttk_Box, Ttk_State);
-MODULE_SCOPE Ttk_ElementOptionSpec TtkNullElementOptions[];
+MODULE_SCOPE const Ttk_ElementOptionSpec TtkNullElementOptions[];
MODULE_SCOPE Ttk_ElementSpec ttkNullElementSpec;
/*------------------------------------------------------------------------
@@ -307,9 +273,6 @@ typedef struct {
#define TTK_BEGIN_LAYOUT(name) static TTKLayoutInstruction name[] = {
#define TTK_END_LAYOUT { 0, _TTK_LAYOUT_END } };
-TTKAPI void Ttk_RegisterLayout(
- Ttk_Theme theme, const char *className, Ttk_LayoutSpec layoutSpec);
-
TTKAPI void Ttk_RegisterLayouts(
Ttk_Theme theme, Ttk_LayoutSpec layoutTable);
@@ -392,7 +355,7 @@ typedef enum /* -default option values */
TTK_BUTTON_DEFAULT_DISABLED /* not defaultable */
} Ttk_ButtonDefaultState;
-TTKAPI int Ttk_GetButtonDefaultStateFromObj(Tcl_Interp *, Tcl_Obj *, int *);
+TTKAPI int Ttk_GetButtonDefaultStateFromObj(Tcl_Interp *, Tcl_Obj *, Ttk_ButtonDefaultState *);
typedef enum /* -compound option values */
{
@@ -406,13 +369,16 @@ typedef enum /* -compound option values */
TTK_COMPOUND_RIGHT /* image to right of text */
} Ttk_Compound;
-TTKAPI int Ttk_GetCompoundFromObj(Tcl_Interp *, Tcl_Obj *, int *);
+TTKAPI int Ttk_GetCompoundFromObj(Tcl_Interp *, Tcl_Obj *, Ttk_Compound *);
typedef enum { /* -orient option values */
TTK_ORIENT_HORIZONTAL,
TTK_ORIENT_VERTICAL
} Ttk_Orient;
+MODULE_SCOPE int TtkGetOrientFromObj(Tcl_Interp *interp,
+ Tcl_Obj *objPtr, Ttk_Orient *orient);
+
/*------------------------------------------------------------------------
* +++ Utilities.
*/
diff --git a/generic/ttk/ttkThemeInt.h b/generic/ttk/ttkThemeInt.h
index 3aaada8..25a5fdf 100644
--- a/generic/ttk/ttkThemeInt.h
+++ b/generic/ttk/ttkThemeInt.h
@@ -15,11 +15,11 @@ 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(
diff --git a/generic/ttk/ttkTrack.c b/generic/ttk/ttkTrack.c
index fa2a7e0..b9aa776 100644
--- a/generic/ttk/ttkTrack.c
+++ b/generic/ttk/ttkTrack.c
@@ -16,11 +16,11 @@
* and is normally set to the ACTIVE state unless another element
* is currently being pressed.
*
- * The active element becomes "pressed" on <ButtonPress> events,
+ * The active element becomes "pressed" on <Button> events,
* and remains "active" and "pressed" until the corresponding
* <ButtonRelease> event.
*
- * TODO: Handle "chords" properly (e.g., <B1-ButtonPress-2>)
+ * TODO: Handle "chords" properly (e.g., <B1-Button-2>)
*/
#include "tkInt.h"
@@ -118,7 +118,7 @@ static const unsigned ElementStateMask =
static void
ElementStateEventProc(ClientData clientData, XEvent *ev)
{
- ElementStateTracker *es = clientData;
+ ElementStateTracker *es = (ElementStateTracker *)clientData;
Ttk_Layout layout = es->corePtr->layout;
Ttk_Element element;
@@ -173,7 +173,7 @@ ElementStateEventProc(ClientData clientData, XEvent *ev)
void TtkTrackElementState(WidgetCore *corePtr)
{
- ElementStateTracker *es = ckalloc(sizeof(*es));
+ ElementStateTracker *es = (ElementStateTracker *)ckalloc(sizeof(*es));
es->corePtr = corePtr;
es->tracking = 0;
es->activeElement = es->pressedElement = 0;
diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c
index 0a156a5..4ea4c17 100644
--- a/generic/ttk/ttkTreeview.c
+++ b/generic/ttk/ttkTreeview.c
@@ -4,8 +4,6 @@
* ttk::treeview widget implementation.
*/
-#include <string.h>
-#include <stdio.h>
#include "tkInt.h"
#include "ttkTheme.h"
#include "ttkWidget.h"
@@ -61,32 +59,35 @@ struct TreeItemRec {
#define ITEM_OPTION_TAGS_CHANGED 0x100
#define ITEM_OPTION_IMAGE_CHANGED 0x200
-static Tk_OptionSpec ItemOptionSpecs[] = {
+static const Tk_OptionSpec ItemOptionSpecs[] = {
{TK_OPTION_STRING, "-text", "text", "Text",
- "", Tk_Offset(TreeItem,textObj), -1,
+ "", offsetof(TreeItem,textObj), TCL_INDEX_NONE,
0,0,0 },
{TK_OPTION_STRING, "-image", "image", "Image",
- NULL, Tk_Offset(TreeItem,imageObj), -1,
+ NULL, offsetof(TreeItem,imageObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,ITEM_OPTION_IMAGE_CHANGED },
{TK_OPTION_STRING, "-values", "values", "Values",
- NULL, Tk_Offset(TreeItem,valuesObj), -1,
+ NULL, offsetof(TreeItem,valuesObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,0 },
{TK_OPTION_BOOLEAN, "-open", "open", "Open",
- "0", Tk_Offset(TreeItem,openObj), -1,
+ "0", offsetof(TreeItem,openObj), TCL_INDEX_NONE,
0,0,0 },
{TK_OPTION_STRING, "-tags", "tags", "Tags",
- NULL, Tk_Offset(TreeItem,tagsObj), -1,
+ NULL, offsetof(TreeItem,tagsObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,ITEM_OPTION_TAGS_CHANGED },
- {TK_OPTION_END, 0,0,0, NULL, -1,-1, 0,0,0}
+ {TK_OPTION_END, 0,0,0, NULL, TCL_INDEX_NONE,TCL_INDEX_NONE, 0,0,0}
};
+/* Forward declaration */
+static void RemoveTag(TreeItem *, Ttk_Tag);
+
/* + NewItem --
* Allocate a new, uninitialized, unlinked item
*/
static TreeItem *NewItem(void)
{
- TreeItem *item = ckalloc(sizeof(*item));
+ TreeItem *item = (TreeItem *)ckalloc(sizeof(*item));
item->entryPtr = 0;
item->parent = item->children = item->next = item->prev = NULL;
@@ -121,7 +122,7 @@ static void FreeItem(TreeItem *item)
ckfree(item);
}
-static void FreeItemCB(void *clientData) { FreeItem(clientData); }
+static void FreeItemCB(void *clientData) { FreeItem((TreeItem *)clientData); }
/* + DetachItem --
* Unlink an item from the tree.
@@ -189,27 +190,27 @@ typedef struct {
Tcl_Obj *fontObj;
} DisplayItem;
-static Tk_OptionSpec TagOptionSpecs[] = {
+static const Tk_OptionSpec TagOptionSpecs[] = {
{TK_OPTION_STRING, "-text", "text", "Text",
- NULL, Tk_Offset(DisplayItem,textObj), -1,
+ NULL, offsetof(DisplayItem,textObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,0 },
{TK_OPTION_STRING, "-image", "image", "Image",
- NULL, Tk_Offset(DisplayItem,imageObj), -1,
+ NULL, offsetof(DisplayItem,imageObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,0 },
{TK_OPTION_ANCHOR, "-anchor", "anchor", "Anchor",
- NULL, Tk_Offset(DisplayItem,anchorObj), -1,
+ NULL, offsetof(DisplayItem,anchorObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK, 0, GEOMETRY_CHANGED}, /* <<NOTE-ANCHOR>> */
{TK_OPTION_COLOR, "-background", "windowColor", "WindowColor",
- NULL, Tk_Offset(DisplayItem,backgroundObj), -1,
+ NULL, offsetof(DisplayItem,backgroundObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,0 },
{TK_OPTION_COLOR, "-foreground", "textColor", "TextColor",
- NULL, Tk_Offset(DisplayItem,foregroundObj), -1,
+ NULL, offsetof(DisplayItem,foregroundObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,0 },
{TK_OPTION_FONT, "-font", "font", "Font",
- NULL, Tk_Offset(DisplayItem,fontObj), -1,
+ NULL, offsetof(DisplayItem,fontObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
- {TK_OPTION_END, 0,0,0, NULL, -1,-1, 0,0,0}
+ {TK_OPTION_END, 0,0,0, NULL, TCL_INDEX_NONE,TCL_INDEX_NONE, 0,0,0}
};
/*------------------------------------------------------------------------
@@ -273,42 +274,42 @@ static void FreeColumn(TreeColumn *column)
/* Don't touch column->data, it's scratch storage */
}
-static Tk_OptionSpec ColumnOptionSpecs[] = {
+static const Tk_OptionSpec ColumnOptionSpecs[] = {
{TK_OPTION_INT, "-width", "width", "Width",
- DEF_COLWIDTH, -1, Tk_Offset(TreeColumn,width),
+ DEF_COLWIDTH, TCL_INDEX_NONE, offsetof(TreeColumn,width),
0,0,GEOMETRY_CHANGED },
{TK_OPTION_INT, "-minwidth", "minWidth", "MinWidth",
- DEF_MINWIDTH, -1, Tk_Offset(TreeColumn,minWidth),
+ DEF_MINWIDTH, TCL_INDEX_NONE, offsetof(TreeColumn,minWidth),
0,0,0 },
{TK_OPTION_BOOLEAN, "-stretch", "stretch", "Stretch",
- "1", -1, Tk_Offset(TreeColumn,stretch),
+ "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}
};
/*------------------------------------------------------------------------
@@ -321,14 +322,14 @@ static Tk_OptionSpec HeadingOptionSpecs[] = {
#define DEFAULT_SHOW "tree headings"
-static const char *showStrings[] = {
+static const char *const showStrings[] = {
"tree", "headings", NULL
};
static int GetEnumSetFromObj(
Tcl_Interp *interp,
Tcl_Obj *objPtr,
- const char *table[],
+ const char *const table[],
unsigned *resultPtr)
{
unsigned result = 0;
@@ -435,35 +436,35 @@ typedef struct {
#define SCROLLCMD_CHANGED (USER_MASK<<2)
#define SHOW_CHANGED (USER_MASK<<3)
-static const char *SelectModeStrings[] = { "none", "browse", "extended", NULL };
+static const char *const SelectModeStrings[] = { "none", "browse", "extended", NULL };
-static Tk_OptionSpec TreeviewOptionSpecs[] = {
+static const Tk_OptionSpec TreeviewOptionSpecs[] = {
{TK_OPTION_STRING, "-columns", "columns", "Columns",
- "", Tk_Offset(Treeview,tree.columnsObj), -1,
- 0,0,COLUMNS_CHANGED | GEOMETRY_CHANGED /*| READONLY_OPTION*/ },
+ "", 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,
- 0,0,DCOLUMNS_CHANGED | GEOMETRY_CHANGED },
+ "#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,
- 0,0,SHOW_CHANGED | GEOMETRY_CHANGED },
+ 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,
- 0,(ClientData)SelectModeStrings,0 },
+ "extended", offsetof(Treeview,tree.selectModeObj), TCL_INDEX_NONE,
+ 0, (void *)SelectModeStrings, 0 },
{TK_OPTION_PIXELS, "-height", "height", "Height",
- DEF_TREE_ROWS, Tk_Offset(Treeview,tree.heightObj), -1,
- 0,0,GEOMETRY_CHANGED},
+ DEF_TREE_ROWS, offsetof(Treeview,tree.heightObj), TCL_INDEX_NONE,
+ 0, 0,GEOMETRY_CHANGED},
{TK_OPTION_STRING, "-padding", "padding", "Pad",
- NULL, Tk_Offset(Treeview,tree.paddingObj), -1,
+ NULL, offsetof(Treeview,tree.paddingObj), TCL_INDEX_NONE,
TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED },
{TK_OPTION_STRING, "-xscrollcommand", "xScrollCommand", "ScrollCommand",
- NULL, -1, Tk_Offset(Treeview, tree.xscroll.scrollCmd),
+ NULL, TCL_INDEX_NONE, offsetof(Treeview, tree.xscroll.scrollCmd),
TK_OPTION_NULL_OK, 0, SCROLLCMD_CHANGED},
{TK_OPTION_STRING, "-yscrollcommand", "yScrollCommand", "ScrollCommand",
- NULL, -1, Tk_Offset(Treeview, tree.yscroll.scrollCmd),
+ NULL, TCL_INDEX_NONE, offsetof(Treeview, tree.yscroll.scrollCmd),
TK_OPTION_NULL_OK, 0, SCROLLCMD_CHANGED},
WIDGET_TAKEFOCUS_TRUE,
@@ -527,7 +528,7 @@ static TreeColumn *GetColumn(
entryPtr = Tcl_FindHashEntry(
&tv->tree.columnNames, Tcl_GetString(columnIDObj));
if (entryPtr) {
- return Tcl_GetHashValue(entryPtr);
+ return (TreeColumn *)Tcl_GetHashValue(entryPtr);
}
/* Check for number:
@@ -588,7 +589,7 @@ static TreeItem *FindItem(
Tcl_SetErrorCode(interp, "TTK", "TREE", "ITEM", NULL);
return 0;
}
- return Tcl_GetHashValue(entryPtr);
+ return (TreeItem *)Tcl_GetHashValue(entryPtr);
}
/* + GetItemListFromObj --
@@ -609,7 +610,7 @@ static TreeItem **GetItemListFromObj(
return NULL;
}
- items = ckalloc((nElements + 1)*sizeof(TreeItem*));
+ items = (TreeItem **)ckalloc((nElements + 1)*sizeof(TreeItem*));
for (i = 0; i < nElements; ++i) {
items[i] = FindItem(interp, tv, elements[i]);
if (!items[i]) {
@@ -626,7 +627,7 @@ static TreeItem **GetItemListFromObj(
*/
static const char *ItemName(Treeview *tv, TreeItem *item)
{
- return Tcl_GetHashKey(&tv->tree.items, item->entryPtr);
+ return (const char *)Tcl_GetHashKey(&tv->tree.items, item->entryPtr);
}
/* + ItemID --
@@ -684,7 +685,7 @@ static int TreeviewInitColumns(Tcl_Interp *interp, Treeview *tv)
* Initialize columns array and columnNames hash table:
*/
tv->tree.nColumns = ncols;
- tv->tree.columns = ckalloc(tv->tree.nColumns * sizeof(TreeColumn));
+ tv->tree.columns = (TreeColumn *)ckalloc(tv->tree.nColumns * sizeof(TreeColumn));
for (i = 0; i < ncols; ++i) {
int isNew;
@@ -729,12 +730,12 @@ static int TreeviewInitDisplayColumns(Tcl_Interp *interp, Treeview *tv)
if (!strcmp(Tcl_GetString(tv->tree.displayColumnsObj), "#all")) {
ndcols = tv->tree.nColumns;
- displayColumns = ckalloc((ndcols+1) * sizeof(TreeColumn*));
+ displayColumns = (TreeColumn **)ckalloc((ndcols+1) * sizeof(TreeColumn*));
for (index = 0; index < ndcols; ++index) {
displayColumns[index+1] = tv->tree.columns + index;
}
} else {
- displayColumns = ckalloc((ndcols+1) * sizeof(TreeColumn*));
+ displayColumns = (TreeColumn **)ckalloc((ndcols+1) * sizeof(TreeColumn*));
for (index = 0; index < ndcols; ++index) {
displayColumns[index+1] = GetColumn(interp, tv, dcolumns[index]);
if (!displayColumns[index+1]) {
@@ -791,9 +792,8 @@ static int PickupSlack(Treeview *tv, int extra)
{
int newSlack = tv->tree.slack + extra;
- if ( (newSlack < 0 && 0 <= tv->tree.slack)
- || (newSlack > 0 && 0 >= tv->tree.slack))
- {
+ if ((newSlack < 0 && 0 <= tv->tree.slack)
+ || (newSlack > 0 && 0 >= tv->tree.slack)) {
tv->tree.slack = 0;
return newSlack;
} else {
@@ -932,7 +932,7 @@ static const unsigned long TreeviewBindEventMask =
static void TreeviewBindEventProc(void *clientData, XEvent *event)
{
- Treeview *tv = clientData;
+ Treeview *tv = (Treeview *)clientData;
TreeItem *item = NULL;
Ttk_TagSet tagset;
@@ -984,7 +984,7 @@ static void TreeviewBindEventProc(void *clientData, XEvent *event)
static void TreeviewInitialize(Tcl_Interp *interp, void *recordPtr)
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
int unused;
tv->tree.itemOptionTable =
@@ -1051,7 +1051,7 @@ static void TreeviewInitialize(Tcl_Interp *interp, void *recordPtr)
static void TreeviewCleanup(void *recordPtr)
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
Tk_DeleteEventHandler(tv->core.tkwin,
TreeviewBindEventMask, TreeviewBindEventProc, tv);
@@ -1084,7 +1084,7 @@ static void TreeviewCleanup(void *recordPtr)
static int
TreeviewConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
unsigned showFlags = tv->tree.showFlags;
if (mask & COLUMNS_CHANGED) {
@@ -1100,10 +1100,9 @@ TreeviewConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
TtkScrollbarUpdateRequired(tv->tree.xscrollHandle);
TtkScrollbarUpdateRequired(tv->tree.yscrollHandle);
}
- if ( (mask & SHOW_CHANGED)
- && GetEnumSetFromObj(
- interp,tv->tree.showObj,showStrings,&showFlags) != TCL_OK)
- {
+ if ((mask & SHOW_CHANGED)
+ && GetEnumSetFromObj(
+ interp,tv->tree.showObj,showStrings,&showFlags) != TCL_OK) {
return TCL_ERROR;
}
@@ -1131,7 +1130,7 @@ static int ConfigureItem(
Ttk_ImageSpec *newImageSpec = NULL;
Ttk_TagSet newTagSet = NULL;
- if (Tk_SetOptions(interp, (ClientData)item, tv->tree.itemOptionTable,
+ if (Tk_SetOptions(interp, item, tv->tree.itemOptionTable,
objc, objv, tv->core.tkwin, &savedOptions, &mask)
!= TCL_OK)
{
@@ -1211,7 +1210,7 @@ static int ConfigureColumn(
Tk_SavedOptions savedOptions;
int mask;
- if (Tk_SetOptions(interp, (ClientData)column,
+ if (Tk_SetOptions(interp, column,
tv->tree.columnOptionTable, objc, objv, tv->core.tkwin,
&savedOptions,&mask) != TCL_OK)
{
@@ -1257,7 +1256,7 @@ static int ConfigureHeading(
Tk_SavedOptions savedOptions;
int mask;
- if (Tk_SetOptions(interp, (ClientData)column,
+ if (Tk_SetOptions(interp, column,
tv->tree.headingOptionTable, objc, objv, tv->core.tkwin,
&savedOptions,&mask) != TCL_OK)
{
@@ -1503,7 +1502,7 @@ typedef enum {
REGION_CELL
} TreeRegion;
-static const char *regionStrings[] = {
+static const char *const regionStrings[] = {
"nothing", "heading", "separator", "tree", "cell", 0
};
@@ -1563,7 +1562,7 @@ static Ttk_Layout GetSublayout(
static Ttk_Layout TreeviewGetLayout(
Tcl_Interp *interp, Ttk_Theme themePtr, void *recordPtr)
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
Ttk_Layout treeLayout = TtkWidgetGetLayout(interp, themePtr, recordPtr);
Tcl_Obj *objPtr;
int unused;
@@ -1612,7 +1611,7 @@ static Ttk_Layout TreeviewGetLayout(
*/
static void TreeviewDoLayout(void *clientData)
{
- Treeview *tv = clientData;
+ Treeview *tv = (Treeview *)clientData;
int visibleRows;
Ttk_PlaceLayout(tv->core.layout,tv->core.state,Ttk_WinBox(tv->core.tkwin));
@@ -1646,7 +1645,7 @@ static void TreeviewDoLayout(void *clientData)
*/
static int TreeviewSize(void *clientData, int *widthPtr, int *heightPtr)
{
- Treeview *tv = clientData;
+ Treeview *tv = (Treeview *)clientData;
int nRows, padHeight, padWidth;
Ttk_LayoutSize(tv->core.layout, tv->core.state, &padWidth, &padHeight);
@@ -1834,7 +1833,7 @@ static int DrawForest(
*/
static void TreeviewDisplay(void *clientData, Drawable d)
{
- Treeview *tv = clientData;
+ Treeview *tv = (Treeview *)clientData;
Ttk_DrawLayout(tv->core.layout, tv->core.state, d);
if (tv->tree.showFlags & SHOW_HEADINGS) {
@@ -1948,7 +1947,7 @@ static TreeItem *DeleteItems(TreeItem *item, TreeItem *delq)
static int TreeviewChildrenCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
TreeItem *item;
Tcl_Obj *result;
@@ -2028,7 +2027,7 @@ static int TreeviewChildrenCommand(
static int TreeviewParentCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
TreeItem *item;
if (objc != 3) {
@@ -2056,7 +2055,7 @@ static int TreeviewParentCommand(
static int TreeviewNextCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
TreeItem *item;
if (objc != 3) {
@@ -2081,7 +2080,7 @@ static int TreeviewNextCommand(
static int TreeviewPrevCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
TreeItem *item;
if (objc != 3) {
@@ -2106,9 +2105,9 @@ static int TreeviewPrevCommand(
static int TreeviewIndexCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
TreeItem *item;
- int index = 0;
+ TkSizeT index = 0;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 2, objv, "item");
@@ -2124,7 +2123,7 @@ static int TreeviewIndexCommand(
item = item->prev;
}
- Tcl_SetObjResult(interp, Tcl_NewIntObj(index));
+ Tcl_SetObjResult(interp, TkNewIndexObj(index));
return TCL_OK;
}
@@ -2134,7 +2133,7 @@ static int TreeviewIndexCommand(
static int TreeviewExistsCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
Tcl_HashEntry *entryPtr;
if (objc != 3) {
@@ -2143,7 +2142,7 @@ static int TreeviewExistsCommand(
}
entryPtr = Tcl_FindHashEntry(&tv->tree.items, Tcl_GetString(objv[2]));
- Tcl_SetObjResult(interp, Tcl_NewBooleanObj(entryPtr != 0));
+ Tcl_SetObjResult(interp, Tcl_NewWideIntObj(entryPtr != 0));
return TCL_OK;
}
@@ -2153,7 +2152,7 @@ static int TreeviewExistsCommand(
static int TreeviewBBoxCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
TreeItem *item = 0;
TreeColumn *column = 0;
Ttk_Box bbox;
@@ -2196,12 +2195,12 @@ static int TreeviewHorribleIdentify(
int dColumnNumber;
char dcolbuf[16];
int x, y, x1;
+ (void)objc;
/* ASSERT: objc == 4 */
- if ( Tcl_GetIntFromObj(interp, objv[2], &x) != TCL_OK
- || Tcl_GetIntFromObj(interp, objv[3], &y) != TCL_OK
- ) {
+ if (Tcl_GetIntFromObj(interp, objv[2], &x) != TCL_OK
+ || Tcl_GetIntFromObj(interp, objv[3], &y) != TCL_OK) {
return TCL_ERROR;
}
@@ -2265,11 +2264,11 @@ done:
static int TreeviewIdentifyCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- static const char *submethodStrings[] =
+ static const char *const submethodStrings[] =
{ "region", "item", "column", "row", "element", NULL };
enum { I_REGION, I_ITEM, I_COLUMN, I_ROW, I_ELEMENT };
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
int submethod;
int x, y;
@@ -2371,11 +2370,11 @@ static int TreeviewIdentifyCommand(
static int TreeviewItemCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
TreeItem *item;
if (objc < 3) {
- 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]))) {
@@ -2399,7 +2398,7 @@ static int TreeviewItemCommand(
static int TreeviewColumnCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
TreeColumn *column;
if (objc < 3) {
@@ -2427,7 +2426,7 @@ static int TreeviewColumnCommand(
static int TreeviewHeadingCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
Tk_OptionTable optionTable = tv->tree.headingOptionTable;
Tk_Window tkwin = tv->core.tkwin;
TreeColumn *column;
@@ -2457,7 +2456,7 @@ static int TreeviewHeadingCommand(
static int TreeviewSetCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
TreeItem *item;
TreeColumn *column;
int columnNumber;
@@ -2551,7 +2550,7 @@ static int TreeviewSetCommand(
static int TreeviewInsertCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
TreeItem *parent, *sibling, *newItem;
Tcl_HashEntry *entryPtr;
int isNew;
@@ -2632,7 +2631,7 @@ static int TreeviewInsertCommand(
static int TreeviewDetachCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
TreeItem **items;
int i;
@@ -2679,7 +2678,7 @@ static int TreeviewDetachCommand(
static int TreeviewDeleteCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
TreeItem **items, *delq;
int i, selItemDeleted = 0;
@@ -2728,7 +2727,7 @@ static int TreeviewDeleteCommand(
ckfree(items);
if (selItemDeleted) {
- TtkSendVirtualEvent(tv->core.tkwin, "TreeviewSelect");
+ Tk_SendVirtualEvent(tv->core.tkwin, "TreeviewSelect", NULL);
}
TtkRedisplayWidget(&tv->core);
return TCL_OK;
@@ -2740,7 +2739,7 @@ static int TreeviewDeleteCommand(
static int TreeviewMoveCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
TreeItem *item, *parent;
TreeItem *sibling;
@@ -2748,9 +2747,8 @@ static int TreeviewMoveCommand(
Tcl_WrongNumArgs(interp, 2, objv, "item parent index");
return TCL_ERROR;
}
- if ( (item = FindItem(interp, tv, objv[2])) == 0
- || (parent = FindItem(interp, tv, objv[3])) == 0)
- {
+ if ((item = FindItem(interp, tv, objv[2])) == 0
+ || (parent = FindItem(interp, tv, objv[3])) == 0) {
return TCL_ERROR;
}
@@ -2803,14 +2801,14 @@ static int TreeviewMoveCommand(
static int TreeviewXViewCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
return TtkScrollviewCommand(interp, objc, objv, tv->tree.xscrollHandle);
}
static int TreeviewYViewCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
return TtkScrollviewCommand(interp, objc, objv, tv->tree.yscrollHandle);
}
@@ -2820,7 +2818,7 @@ static int TreeviewYViewCommand(
static int TreeviewSeeCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
TreeItem *item, *parent;
int rowNumber;
@@ -2866,7 +2864,7 @@ static int TreeviewSeeCommand(
static int TreeviewDragCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
int left = tv->tree.treeArea.x - tv->tree.xscroll.first;
int i = FirstColumn(tv);
TreeColumn *column;
@@ -2877,9 +2875,8 @@ static int TreeviewDragCommand(
return TCL_ERROR;
}
- if ( (column = FindColumn(interp, tv, objv[2])) == 0
- || Tcl_GetIntFromObj(interp, objv[3], &newx) != TCL_OK)
- {
+ if ((column = FindColumn(interp, tv, objv[2])) == 0
+ || Tcl_GetIntFromObj(interp, objv[3], &newx) != TCL_OK) {
return TCL_ERROR;
}
@@ -2903,7 +2900,7 @@ static int TreeviewDragCommand(
static int TreeviewDropCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
if (objc != 2) {
Tcl_WrongNumArgs(interp, 1, objv, "drop");
@@ -2923,7 +2920,7 @@ static int TreeviewDropCommand(
static int TreeviewFocusCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
if (objc == 2) {
if (tv->tree.focus) {
@@ -2951,17 +2948,17 @@ static int TreeviewSelectionCommand(
enum {
SELECTION_SET, SELECTION_ADD, SELECTION_REMOVE, SELECTION_TOGGLE
};
- static const char *selopStrings[] = {
+ static const char *const selopStrings[] = {
"set", "add", "remove", "toggle", NULL
};
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
int selop, i;
TreeItem *item, **items;
if (objc == 2) {
Tcl_Obj *result = Tcl_NewListObj(0,0);
- for (item = tv->tree.root->children; item; item=NextPreorder(item)) {
+ for (item = tv->tree.root->children; item; item = NextPreorder(item)) {
if (item->state & TTK_STATE_SELECTED)
Tcl_ListObjAppendElement(NULL, result, ItemID(tv, item));
}
@@ -2987,7 +2984,7 @@ static int TreeviewSelectionCommand(
switch (selop)
{
case SELECTION_SET:
- for (item=tv->tree.root; item; item=NextPreorder(item)) {
+ for (item=tv->tree.root; item; item = NextPreorder(item)) {
item->state &= ~TTK_STATE_SELECTED;
}
/*FALLTHRU*/
@@ -3009,7 +3006,7 @@ static int TreeviewSelectionCommand(
}
ckfree(items);
- TtkSendVirtualEvent(tv->core.tkwin, "TreeviewSelect");
+ Tk_SendVirtualEvent(tv->core.tkwin, "TreeviewSelect", NULL);
TtkRedisplayWidget(&tv->core);
return TCL_OK;
@@ -3024,7 +3021,7 @@ static int TreeviewSelectionCommand(
static int TreeviewTagBindCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
Ttk_TagTable tagTable = tv->tree.tagTable;
Tk_BindingTable bindingTable = tv->tree.bindingTable;
Ttk_Tag tag;
@@ -3077,7 +3074,7 @@ static int TreeviewTagBindCommand(
static int TreeviewTagConfigureCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
Ttk_TagTable tagTable = tv->tree.tagTable;
Ttk_Tag tag;
@@ -3103,12 +3100,40 @@ static int TreeviewTagConfigureCommand(
return Ttk_ConfigureTag(interp, tagTable, tag, objc - 4, objv + 4);
}
+/* + $tv tag delete $tag
+ */
+static int TreeviewTagDeleteCommand(
+ void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
+{
+ Treeview *tv = (Treeview *)recordPtr;
+ Ttk_TagTable tagTable = tv->tree.tagTable;
+ TreeItem *item = tv->tree.root;
+ Ttk_Tag tag;
+
+ if (objc != 4) {
+ Tcl_WrongNumArgs(interp, 3, objv, "tagName");
+ return TCL_ERROR;
+ }
+
+ tag = Ttk_GetTagFromObj(tagTable, objv[3]);
+ /* remove the tag from all items */
+ while (item) {
+ RemoveTag(item, tag);
+ item = NextPreorder(item);
+ }
+ /* then remove the tag from the tag table */
+ Ttk_DeleteTagFromTable(tagTable, tag);
+ TtkRedisplayWidget(&tv->core);
+
+ return TCL_OK;
+}
+
/* + $tv tag has $tag ?$item?
*/
static int TreeviewTagHasCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
if (objc == 4) { /* Return list of all items with tag */
Ttk_Tag tag = Ttk_GetTagFromObj(tv->tree.tagTable, objv[3]);
@@ -3131,7 +3156,7 @@ static int TreeviewTagHasCommand(
return TCL_ERROR;
}
Tcl_SetObjResult(interp,
- Tcl_NewBooleanObj(Ttk_TagSetContains(item->tagset, tag)));
+ Tcl_NewWideIntObj(Ttk_TagSetContains(item->tagset, tag)));
return TCL_OK;
} else {
Tcl_WrongNumArgs(interp, 3, objv, "tagName ?item?");
@@ -3144,7 +3169,7 @@ static int TreeviewTagHasCommand(
static int TreeviewTagNamesCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
if (objc != 3) {
Tcl_WrongNumArgs(interp, 3, objv, "");
@@ -3168,7 +3193,7 @@ static void AddTag(TreeItem *item, Ttk_Tag tag)
static int TreeviewTagAddCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
Ttk_Tag tag;
TreeItem **items;
int i;
@@ -3208,7 +3233,7 @@ static void RemoveTag(TreeItem *item, Ttk_Tag tag)
static int TreeviewTagRemoveCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- Treeview *tv = recordPtr;
+ Treeview *tv = (Treeview *)recordPtr;
Ttk_Tag tag;
if (objc < 4) {
@@ -3232,7 +3257,7 @@ static int TreeviewTagRemoveCommand(
TreeItem *item = tv->tree.root;
while (item) {
RemoveTag(item, tag);
- item=NextPreorder(item);
+ item = NextPreorder(item);
}
}
@@ -3245,6 +3270,7 @@ static const Ttk_Ensemble TreeviewTagCommands[] = {
{ "add", TreeviewTagAddCommand,0 },
{ "bind", TreeviewTagBindCommand,0 },
{ "configure", TreeviewTagConfigureCommand,0 },
+ { "delete", TreeviewTagDeleteCommand,0 },
{ "has", TreeviewTagHasCommand,0 },
{ "names", TreeviewTagNamesCommand,0 },
{ "remove", TreeviewTagRemoveCommand,0 },
@@ -3290,7 +3316,7 @@ static const Ttk_Ensemble TreeviewCommands[] = {
* +++ Widget definition.
*/
-static WidgetSpec TreeviewWidgetSpec = {
+static const WidgetSpec TreeviewWidgetSpec = {
"Treeview", /* className */
sizeof(Treeview), /* recordSize */
TreeviewOptionSpecs, /* optionSpecs */
@@ -3348,23 +3374,25 @@ typedef struct {
Tcl_Obj *marginsObj;
} TreeitemIndicator;
-static Ttk_ElementOptionSpec TreeitemIndicatorOptions[] = {
+static const Ttk_ElementOptionSpec TreeitemIndicatorOptions[] = {
{ "-foreground", TK_OPTION_COLOR,
- Tk_Offset(TreeitemIndicator,colorObj), DEFAULT_FOREGROUND },
+ offsetof(TreeitemIndicator,colorObj), DEFAULT_FOREGROUND },
{ "-indicatorsize", TK_OPTION_PIXELS,
- Tk_Offset(TreeitemIndicator,sizeObj), "12" },
+ offsetof(TreeitemIndicator,sizeObj), "12" },
{ "-indicatormargins", TK_OPTION_STRING,
- Tk_Offset(TreeitemIndicator,marginsObj), "2 2 4 2" },
- { NULL, 0, 0, NULL }
+ offsetof(TreeitemIndicator,marginsObj), "2 2 4 2" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void TreeitemIndicatorSize(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
{
- TreeitemIndicator *indicator = elementRecord;
+ TreeitemIndicator *indicator = (TreeitemIndicator *)elementRecord;
Ttk_Padding margins;
int size = 0;
+ (void)dummy;
+ (void)paddingPtr;
Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginsObj, &margins);
Tk_GetPixelsFromObj(NULL, tkwin, indicator->sizeObj, &size);
@@ -3374,15 +3402,16 @@ static void TreeitemIndicatorSize(
}
static void TreeitemIndicatorDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, Ttk_State state)
{
- TreeitemIndicator *indicator = elementRecord;
+ TreeitemIndicator *indicator = (TreeitemIndicator *)elementRecord;
ArrowDirection direction =
(state & TTK_STATE_OPEN) ? ARROW_DOWN : ARROW_RIGHT;
Ttk_Padding margins;
XColor *borderColor = Tk_GetColorFromObj(tkwin, indicator->colorObj);
XGCValues gcvalues; GC gc; unsigned mask;
+ (void)dummy;
if (state & TTK_STATE_LEAF) /* don't draw anything */
return;
@@ -3400,7 +3429,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,
@@ -3417,26 +3446,29 @@ typedef struct {
Tcl_Obj *rowNumberObj;
} RowElement;
-static Ttk_ElementOptionSpec RowElementOptions[] = {
+static const Ttk_ElementOptionSpec RowElementOptions[] = {
{ "-background", TK_OPTION_COLOR,
- Tk_Offset(RowElement,backgroundObj), DEFAULT_BACKGROUND },
+ offsetof(RowElement,backgroundObj), DEFAULT_BACKGROUND },
{ "-rownumber", TK_OPTION_INT,
- Tk_Offset(RowElement,rowNumberObj), "0" },
- { NULL, 0, 0, NULL }
+ offsetof(RowElement,rowNumberObj), "0" },
+ { NULL, TK_OPTION_BOOLEAN, 0, NULL }
};
static void RowElementDraw(
- void *clientData, void *elementRecord, Tk_Window tkwin,
+ void *dummy, void *elementRecord, Tk_Window tkwin,
Drawable d, Ttk_Box b, Ttk_State state)
{
- RowElement *row = elementRecord;
+ RowElement *row = (RowElement *)elementRecord;
XColor *color = Tk_GetColorFromObj(tkwin, row->backgroundObj);
GC gc = Tk_GCForColor(color, d);
+ (void)dummy;
+ (void)state;
+
XFillRectangle(Tk_Display(tkwin), d, gc,
b.x, b.y, b.width, b.height);
}
-static Ttk_ElementSpec RowElementSpec = {
+static const Ttk_ElementSpec RowElementSpec = {
TK_STYLE_VERSION_2,
sizeof(RowElement),
RowElementOptions,
diff --git a/generic/ttk/ttkWidget.c b/generic/ttk/ttkWidget.c
index 9992d27..6726e17 100644
--- a/generic/ttk/ttkWidget.c
+++ b/generic/ttk/ttkWidget.c
@@ -4,7 +4,6 @@
* Core widget utilities.
*/
-#include <string.h>
#include "tkInt.h"
#include "ttkTheme.h"
#include "ttkWidget.h"
@@ -86,7 +85,7 @@ static void EndDrawing(Tk_Window tkwin, Drawable d)
#else
/* No double-buffering: draw directly into the window. */
static Drawable BeginDrawing(Tk_Window tkwin) { return Tk_WindowId(tkwin); }
-static void EndDrawing(Tk_Window tkwin, Drawable d) { }
+static void EndDrawing(Tk_Window tkwin, Drawable d) { (void)tkwin; (void)d;}
#endif
/* DrawWidget --
@@ -94,7 +93,7 @@ static void EndDrawing(Tk_Window tkwin, Drawable d) { }
*/
static void DrawWidget(ClientData recordPtr)
{
- WidgetCore *corePtr = recordPtr;
+ WidgetCore *corePtr = (WidgetCore *)recordPtr;
corePtr->flags &= ~REDISPLAY_PENDING;
if (Tk_IsMapped(corePtr->tkwin)) {
@@ -153,7 +152,7 @@ static int
WidgetInstanceObjCmd(
ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- WidgetCore *corePtr = clientData;
+ WidgetCore *corePtr = (WidgetCore *)clientData;
const Ttk_Ensemble *commands = corePtr->widgetSpec->commands;
int status;
@@ -188,7 +187,7 @@ WidgetInstanceObjCmd(
static void
WidgetInstanceObjCmdDeleted(ClientData clientData)
{
- WidgetCore *corePtr = clientData;
+ WidgetCore *corePtr = (WidgetCore *)clientData;
corePtr->widgetCmd = NULL;
if (corePtr->tkwin != NULL)
Tk_DestroyWindow(corePtr->tkwin);
@@ -214,7 +213,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);
@@ -333,12 +332,12 @@ static void CoreEventProc(ClientData clientData, XEvent *eventPtr)
*/
static void WidgetWorldChanged(ClientData clientData)
{
- WidgetCore *corePtr = clientData;
+ WidgetCore *corePtr = (WidgetCore *)clientData;
SizeChanged(corePtr);
TtkRedisplayWidget(corePtr);
}
-static Tk_ClassProcs widgetClassProcs = {
+static const Tk_ClassProcs widgetClassProcs = {
sizeof(Tk_ClassProcs), /* size */
WidgetWorldChanged, /* worldChangedProc */
NULL, /* createProc */
@@ -353,7 +352,7 @@ static Tk_ClassProcs widgetClassProcs = {
int TtkWidgetConstructorObjCmd(
ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- WidgetSpec *widgetSpec = clientData;
+ WidgetSpec *widgetSpec = (WidgetSpec *)clientData;
const char *className = widgetSpec->className;
Tk_OptionTable optionTable =
Tk_CreateOptionTable(interp, widgetSpec->optionSpecs);
@@ -389,7 +388,7 @@ int TtkWidgetConstructorObjCmd(
*/
recordPtr = ckalloc(widgetSpec->recordSize);
memset(recordPtr, 0, widgetSpec->recordSize);
- corePtr = recordPtr;
+ corePtr = (WidgetCore *)recordPtr;
corePtr->tkwin = tkwin;
corePtr->interp = interp;
@@ -464,7 +463,7 @@ error:
Ttk_Layout TtkWidgetGetLayout(
Tcl_Interp *interp, Ttk_Theme themePtr, void *recordPtr)
{
- WidgetCore *corePtr = recordPtr;
+ WidgetCore *corePtr = (WidgetCore *)recordPtr;
const char *styleName = 0;
if (corePtr->styleObj)
@@ -486,17 +485,17 @@ Ttk_Layout TtkWidgetGetLayout(
Ttk_Layout TtkWidgetGetOrientedLayout(
Tcl_Interp *interp, Ttk_Theme themePtr, void *recordPtr, Tcl_Obj *orientObj)
{
- WidgetCore *corePtr = recordPtr;
+ WidgetCore *corePtr = (WidgetCore *)recordPtr;
const char *baseStyleName = 0;
Tcl_DString styleName;
- int orient = TTK_ORIENT_HORIZONTAL;
+ Ttk_Orient orient = TTK_ORIENT_HORIZONTAL;
Ttk_Layout layout;
Tcl_DStringInit(&styleName);
/* Prefix:
*/
- Ttk_GetOrientFromObj(NULL, orientObj, &orient);
+ TtkGetOrientFromObj(NULL, orientObj, &orient);
if (orient == TTK_ORIENT_HORIZONTAL)
Tcl_DStringAppend(&styleName, "Horizontal.", -1);
else
@@ -526,6 +525,8 @@ Ttk_Layout TtkWidgetGetOrientedLayout(
*/
void TtkNullInitialize(Tcl_Interp *interp, void *recordPtr)
{
+ (void)interp;
+ (void)recordPtr;
}
/* TtkNullPostConfigure --
@@ -533,6 +534,10 @@ void TtkNullInitialize(Tcl_Interp *interp, void *recordPtr)
*/
int TtkNullPostConfigure(Tcl_Interp *interp, void *clientData, int mask)
{
+ (void)interp;
+ (void)clientData;
+ (void)mask;
+
return TCL_OK;
}
@@ -542,7 +547,7 @@ int TtkNullPostConfigure(Tcl_Interp *interp, void *clientData, int mask)
*/
int TtkCoreConfigure(Tcl_Interp *interp, void *clientData, int mask)
{
- WidgetCore *corePtr = clientData;
+ WidgetCore *corePtr = (WidgetCore *)clientData;
int status = TCL_OK;
if (mask & STYLE_CHANGED) {
@@ -557,6 +562,7 @@ int TtkCoreConfigure(Tcl_Interp *interp, void *clientData, int mask)
*/
void TtkNullCleanup(void *recordPtr)
{
+ (void)recordPtr;
return;
}
@@ -565,7 +571,7 @@ void TtkNullCleanup(void *recordPtr)
*/
void TtkWidgetDoLayout(void *clientData)
{
- WidgetCore *corePtr = clientData;
+ WidgetCore *corePtr = (WidgetCore *)clientData;
Ttk_PlaceLayout(corePtr->layout,corePtr->state,Ttk_WinBox(corePtr->tkwin));
}
@@ -574,7 +580,7 @@ void TtkWidgetDoLayout(void *clientData)
*/
void TtkWidgetDisplay(void *recordPtr, Drawable d)
{
- WidgetCore *corePtr = recordPtr;
+ WidgetCore *corePtr = (WidgetCore *)recordPtr;
Ttk_DrawLayout(corePtr->layout, corePtr->state, d);
}
@@ -583,7 +589,7 @@ void TtkWidgetDisplay(void *recordPtr, Drawable d)
*/
int TtkWidgetSize(void *recordPtr, int *widthPtr, int *heightPtr)
{
- WidgetCore *corePtr = recordPtr;
+ WidgetCore *corePtr = (WidgetCore *)recordPtr;
Ttk_LayoutSize(corePtr->layout, corePtr->state, widthPtr, heightPtr);
return 1;
}
@@ -597,7 +603,7 @@ int TtkWidgetSize(void *recordPtr, int *widthPtr, int *heightPtr)
int TtkWidgetCgetCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- WidgetCore *corePtr = recordPtr;
+ WidgetCore *corePtr = (WidgetCore *)recordPtr;
Tcl_Obj *result;
if (objc != 3) {
@@ -617,7 +623,7 @@ int TtkWidgetCgetCommand(
int TtkWidgetConfigureCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- WidgetCore *corePtr = recordPtr;
+ WidgetCore *corePtr = (WidgetCore *)recordPtr;
Tcl_Obj *result;
if (objc == 2) {
@@ -687,7 +693,7 @@ int TtkWidgetConfigureCommand(
int TtkWidgetStateCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- WidgetCore *corePtr = recordPtr;
+ WidgetCore *corePtr = (WidgetCore *)recordPtr;
Ttk_StateSpec spec;
int status;
Ttk_State oldState, changed;
@@ -727,7 +733,7 @@ int TtkWidgetStateCommand(
int TtkWidgetInstateCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- WidgetCore *corePtr = recordPtr;
+ WidgetCore *corePtr = (WidgetCore *)recordPtr;
Ttk_State state = corePtr->state;
Ttk_StateSpec spec;
int status = TCL_OK;
@@ -742,7 +748,7 @@ int TtkWidgetInstateCommand(
if (objc == 3) {
Tcl_SetObjResult(interp,
- Tcl_NewBooleanObj(Ttk_StateMatches(state,&spec)));
+ Tcl_NewWideIntObj(Ttk_StateMatches(state,&spec)));
} else if (objc == 4) {
if (Ttk_StateMatches(state,&spec)) {
status = Tcl_EvalObjEx(interp, objv[3], 0);
@@ -758,9 +764,9 @@ int TtkWidgetInstateCommand(
int TtkWidgetIdentifyCommand(
void *recordPtr, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
- WidgetCore *corePtr = recordPtr;
+ WidgetCore *corePtr = (WidgetCore *)recordPtr;
Ttk_Element element;
- static const char *whatTable[] = { "element", NULL };
+ static const char *const whatTable[] = { "element", NULL };
int x, y, what;
if (objc < 4 || objc > 5) {
diff --git a/generic/ttk/ttkWidget.h b/generic/ttk/ttkWidget.h
index 6cd691b..2eeab4e 100644
--- a/generic/ttk/ttkWidget.h
+++ b/generic/ttk/ttkWidget.h
@@ -117,21 +117,21 @@ MODULE_SCOPE int TtkWidgetConstructorObjCmd(
*/
#define WIDGET_TAKEFOCUS_TRUE \
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus", \
- "ttk::takefocus", Tk_Offset(WidgetCore, takeFocusPtr), -1, 0,0,0 }
+ "ttk::takefocus", offsetof(WidgetCore, takeFocusPtr), TCL_INDEX_NONE, 0,0,0 }
#define WIDGET_TAKEFOCUS_FALSE \
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus", \
- "", Tk_Offset(WidgetCore, takeFocusPtr), -1, 0,0,0 }
+ "", offsetof(WidgetCore, takeFocusPtr), TCL_INDEX_NONE, 0,0,0 }
/* WIDGET_INHERIT_OPTIONS(baseOptionSpecs) --
* Add this at the end of an OptionSpecs table to inherit
* the options from 'baseOptionSpecs'.
*/
#define WIDGET_INHERIT_OPTIONS(baseOptionSpecs) \
- {TK_OPTION_END, 0,0,0, NULL, -1,-1, 0, (ClientData)baseOptionSpecs, 0}
+ {TK_OPTION_END, 0,0,0, NULL, TCL_INDEX_NONE,TCL_INDEX_NONE, 0, baseOptionSpecs, 0}
/* All widgets should inherit from ttkCoreOptionSpecs[].
*/
-MODULE_SCOPE Tk_OptionSpec ttkCoreOptionSpecs[];
+MODULE_SCOPE const Tk_OptionSpec ttkCoreOptionSpecs[];
/*
* Useful routines for use inside widget implementations:
@@ -165,11 +165,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(
@@ -212,7 +207,7 @@ typedef struct TtkTagSet { /* TODO: make opaque */
} *Ttk_TagSet;
MODULE_SCOPE Ttk_TagTable Ttk_CreateTagTable(
- Tcl_Interp *, Tk_Window tkwin, Tk_OptionSpec[], int recordSize);
+ Tcl_Interp *, Tk_Window tkwin, const Tk_OptionSpec *, int recordSize);
MODULE_SCOPE void Ttk_DeleteTagTable(Ttk_TagTable);
MODULE_SCOPE Ttk_Tag Ttk_GetTag(Ttk_TagTable, const char *tagName);
@@ -226,6 +221,8 @@ MODULE_SCOPE int Ttk_EnumerateTagOptions(
MODULE_SCOPE int Ttk_EnumerateTags(Tcl_Interp *, Ttk_TagTable);
+MODULE_SCOPE void Ttk_DeleteTagFromTable(Ttk_TagTable, Ttk_Tag);
+
MODULE_SCOPE int Ttk_ConfigureTag(
Tcl_Interp *interp, Ttk_TagTable tagTable, Ttk_Tag tag,
int objc, Tcl_Obj *const objv[]);
@@ -247,9 +244,9 @@ MODULE_SCOPE void Ttk_TagSetApplyStyle(Ttk_TagTable,Ttk_Style,Ttk_State,void*);
* String tables for widget resource specifications:
*/
-MODULE_SCOPE const char *ttkOrientStrings[];
-MODULE_SCOPE const char *ttkCompoundStrings[];
-MODULE_SCOPE const char *ttkDefaultStrings[];
+MODULE_SCOPE const char *const ttkOrientStrings[];
+MODULE_SCOPE const char *const ttkCompoundStrings[];
+MODULE_SCOPE const char *const ttkDefaultStrings[];
/*
* ... other option types...