diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-08-24 15:18:48 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-08-24 15:18:48 (GMT) |
commit | 761a48b10bad97319cf219ecdb64247df25fe8a8 (patch) | |
tree | 59de4db593b2d6b63b33aebcdada380a0424aac5 | |
parent | 7ff3d04b99965ac05c2b5356daf3a8ca08f1acbe (diff) | |
parent | 196c6c9af3eb4b96a9b0b94f7e41963167b534b8 (diff) | |
download | tk-761a48b10bad97319cf219ecdb64247df25fe8a8.zip tk-761a48b10bad97319cf219ecdb64247df25fe8a8.tar.gz tk-761a48b10bad97319cf219ecdb64247df25fe8a8.tar.bz2 |
Merge trunk
80 files changed, 648 insertions, 693 deletions
diff --git a/doc/colors.n b/doc/colors.n index 3747ee8..9d8d653 100644 --- a/doc/colors.n +++ b/doc/colors.n @@ -919,19 +919,20 @@ On Windows, the following additional system colors are available .RS .DS .ta 6c -system3dDarkShadow systemHighlight -system3dLight systemHighlightText -systemActiveBorder systemInactiveBorder -systemActiveCaption systemInactiveCaption -systemAppWorkspace systemInactiveCaptionText -systemBackground systemInfoBackground -systemButtonFace systemInfoText -systemButtonHighlight systemMenu -systemButtonShadow systemMenuText +system3dDarkShadow systemHighlightText +system3dLight systemInactiveBorder +systemActiveBorder systemInactiveCaption +systemActiveCaption systemInactiveCaptionText +systemAppWorkspace systemInfoBackground +systemBackground systemInfoText +systemButtonFace systemMenu +systemButtonHighlight systemMenuText +systemButtonShadow systemPlaceholderText systemButtonText systemScrollbar systemCaptionText systemWindow systemDisabledText systemWindowFrame systemGrayText systemWindowText +systemHighlight .DE .RE .SH "SEE ALSO" diff --git a/doc/options.n b/doc/options.n index 56e65dd..b1af80d 100644 --- a/doc/options.n +++ b/doc/options.n @@ -230,8 +230,7 @@ that is when the widget is empty. The placeholder text is displayed using the values of the \fB\-font\fR and \fB\-justify\fR options. .OP \-placeholderforeground placeholderForeground PlaceholderForeground Specifies the foreground color to use when the placeholder text is -displayed. If this option is the empty string, the default color gray70 -is used. +displayed. The default color is platform-specific. .OP \-relief relief Relief Specifies the 3-D effect desired for the widget. Acceptable values are \fBraised\fR, \fBsunken\fR, \fBflat\fR, \fBridge\fR, diff --git a/doc/ttk_Geometry.3 b/doc/ttk_Geometry.3 index 09d59e0..0f8a171 100644 --- a/doc/ttk_Geometry.3 +++ b/doc/ttk_Geometry.3 @@ -66,8 +66,9 @@ Extra padding (in pixels) to add uniformly to each side of a region. .AP short bottom in Extra padding (in pixels) to add to the bottom of a region. .AP Ttk_Box box in -.AP "Ttk_Box *" box_rtn out Specifies a rectangular region. +.AP "Ttk_Box *" box_rtn out +A rectangular region. .AP int height in The height in pixels of a region. .AP "Tcl_Interp *" interp in @@ -79,13 +80,14 @@ String value contains a symbolic name to be converted to an enumerated value or bitmask. Internal rep may be be modified to cache corresponding value. .AP Ttk_Padding padding in -.AP "Ttk_Padding *" padding_rtn out Extra padding to add on the inside of a region. +.AP "Ttk_Padding *" padding_rtn out +Padding present in the inside of a region. .AP Ttk_Box parcel in A rectangular region, allocated from a cavity. .AP int relief in One of the standard Tk relief options -(TK_RELIEF_RAISED, TK_RELIEF_SUNKEN, etc.). +(\fBTK_RELIEF_RAISED\fR, \fBTK_RELIEF_SUNKEN\fR, etc.). See \fBTk_GetReliefFromObj\fR. .AP short right in Extra padding (in pixels) to add to the right side of a region. @@ -95,13 +97,13 @@ One of \fBTTK_SIDE_LEFT\fR, \fBTTK_SIDE_TOP\fR, .AP unsigned sticky in A bitmask containing one or more of the bits \fBTTK_STICK_W\fR (west, or left), -\fBTTK_STICK_E\fR (east, or right, +\fBTTK_STICK_E\fR (east, or right), \fBTTK_STICK_N\fR (north, or top), and \fBTTK_STICK_S\fR (south, or bottom). -\fBTTK_FILL_X\fR is defined as a synonym for (TTK_STICK_W|TTK_STICK_E), -\fBTTK_FILL_Y\fR is a synonym for (TTK_STICK_N|TTK_STICK_S), -and \fBTTK_FILL_BOTH\fR and \fBTTK_STICK_ALL\fR -are synonyms for (TTK_FILL_X|TTK_FILL_Y). +\fBTTK_FILL_X\fR is defined as a synonym for (\fBTTK_STICK_W\fR|\fBTTK_STICK_E\fR), +\fBTTK_FILL_Y\fR is a synonym for (\fBTTK_STICK_N\fR|\fBTTK_STICK_S\fR), +and \fBTTK_FILL_BOTH\fR +is a synonym for (\fBTTK_FILL_X\fR|\fBTTK_FILL_Y\fR). See also: \fIgrid(n)\fR. .AP Tk_Window tkwin in Window whose screen geometry determines diff --git a/doc/ttk_combobox.n b/doc/ttk_combobox.n index 3ec3e77..3ece362 100644 --- a/doc/ttk_combobox.n +++ b/doc/ttk_combobox.n @@ -19,7 +19,7 @@ the user may select the value of the text field from among the values in the list. .SO ttk_widget \-class \-cursor \-takefocus -\-style \-placeholder +\-style \-placeholder \-placeholderforeground .SE .\" ALSO: Other entry widget options .SH "WIDGET-SPECIFIC OPTIONS" @@ -148,6 +148,8 @@ Can only be changed when using non-native and non-graphical themes. .br \fB\-padding\fP \fIpadding\fP .br +\fB\-placeholderforeground\fP \fIcolor\fP +.br \fB\-postoffset\fP \fIpadding\fP .br \fB\-selectbackground\fP \fIcolor\fP diff --git a/doc/ttk_entry.n b/doc/ttk_entry.n index 552700a..62b9951 100644 --- a/doc/ttk_entry.n +++ b/doc/ttk_entry.n @@ -26,7 +26,7 @@ standard \fB\-xscrollcommand\fR option and \fBxview\fR widget command. \-class \-cursor \-font \-foreground \-style -\-takefocus \-xscrollcommand \-placeholder +\-takefocus \-xscrollcommand \-placeholder \-placeholderforeground .SE .SH "WIDGET-SPECIFIC OPTIONS" .OP \-exportselection exportSelection ExportSelection @@ -454,6 +454,8 @@ Some themes use a graphical background and their field background colors cannot .br \fB\-padding\fP \fIpadding\fP .br +\fB\-placeholderforeground\fP \fIcolor\fP +.br \fB\-relief\fP \fIrelief\fP .br \fB\-selectbackground\fP \fIcolor\fP diff --git a/doc/ttk_intro.n b/doc/ttk_intro.n index 3b399ee..c146dd1 100644 --- a/doc/ttk_intro.n +++ b/doc/ttk_intro.n @@ -86,7 +86,7 @@ ttk::\fBstyle layout\fR Horizontal.TScrollbar { Scrollbar.trough \-children { Scrollbar.leftarrow \-side left \-sticky w Scrollbar.rightarrow \-side right \-sticky e - Scrollbar.thumb \-side left \-expand true \-sticky ew + Scrollbar.thumb \-sticky ew } } .CE diff --git a/doc/ttk_spinbox.n b/doc/ttk_spinbox.n index c18f987..b8f3ca2 100644 --- a/doc/ttk_spinbox.n +++ b/doc/ttk_spinbox.n @@ -22,7 +22,7 @@ of the \fBttk::entry\fR widget including support of the to a Tcl variable. .SO ttk_widget \-class \-cursor \-state \-style -\-takefocus \-xscrollcommand \-placeholder +\-takefocus \-xscrollcommand \-placeholder \-placeholderforeground .SE .SO ttk_entry \-validate \-validatecommand @@ -111,6 +111,8 @@ value is specified for \fB\-fieldbackground\fP. Otherwise it is ignored. .br \fB\-padding\fP \fIpadding\fP .br +\fB\-placeholderforeground\fP \fIcolor\fP +.br \fB\-selectbackground\fP \fIcolor\fP .br \fB\-selectforeground\fP \fIcolor\fP diff --git a/doc/ttk_style.n b/doc/ttk_style.n index db80d95..5d7b5d1 100644 --- a/doc/ttk_style.n +++ b/doc/ttk_style.n @@ -34,28 +34,8 @@ The \fBttk::style\fR command takes the following arguments: \fBttk::style configure \fIstyle\fR ?\fI\-option\fR ?\fIvalue option value...\fR? ? Sets the default value of the specified option(s) in \fIstyle\fR. .TP -\fBttk::style map \fIstyle\fR ?\fI\-option\fB { \fIstatespec value...\fB }\fR? -Sets dynamic values of the specified option(s) in \fIstyle\fR. -Each \fIstatespec / value\fR pair is examined in order; -the value corresponding to the first matching \fIstatespec\fR -is used. -.TP -\fBttk::style lookup \fIstyle\fR \fI\-option \fR?\fIstate \fR?\fIdefault\fR?? -Returns the value specified for \fI\-option\fR in style \fIstyle\fR -in state \fIstate\fR, using the standard lookup rules for element options. -\fIstate\fR is a list of state names; if omitted, -it defaults to all bits off (the -.QW normal -state). -If the \fIdefault\fR argument is present, it is used as a fallback -value in case no specification for \fI\-option\fR is found. -.\" Otherwise -- signal error? return empty string? Leave unspecified for now. -.TP -\fBttk::style layout \fIstyle\fR ?\fIlayoutSpec\fR? -Define the widget layout for style \fIstyle\fR. -See \fBLAYOUTS\fR below for the format of \fIlayoutSpec\fR. -If \fIlayoutSpec\fR is omitted, return the layout specification -for style \fIstyle\fR. +\fBttk::style element\fR \fIargs\fR +.RS .TP \fBttk::style element create\fR \fIelementName\fR \fItype\fR ?\fIargs...\fR? Creates a new element in the current theme of type \fItype\fR. @@ -70,6 +50,33 @@ Returns the list of elements defined in the current theme. .TP \fBttk::style element options \fIelement\fR Returns the list of \fIelement\fR's options. +.RE +.TP +\fBttk::style layout \fIstyle\fR ?\fIlayoutSpec\fR? +Define the widget layout for style \fIstyle\fR. +See \fBLAYOUTS\fR below for the format of \fIlayoutSpec\fR. +If \fIlayoutSpec\fR is omitted, return the layout specification +for style \fIstyle\fR. +.TP +\fBttk::style lookup \fIstyle\fR \fI\-option \fR?\fIstate \fR?\fIdefault\fR?? +Returns the value specified for \fI\-option\fR in style \fIstyle\fR +in state \fIstate\fR, using the standard lookup rules for element options. +\fIstate\fR is a list of state names; if omitted, +it defaults to all bits off (the +.QW normal +state). +If the \fIdefault\fR argument is present, it is used as a fallback +value in case no specification for \fI\-option\fR is found. +.\" Otherwise -- signal error? return empty string? Leave unspecified for now. +.TP +\fBttk::style map \fIstyle\fR ?\fI\-option\fB { \fIstatespec value...\fB }\fR? +Sets dynamic values of the specified option(s) in \fIstyle\fR. +Each \fIstatespec / value\fR pair is examined in order; +the value corresponding to the first matching \fIstatespec\fR +is used. +.TP +\fBttk::style theme\fR \fIargs\fR +.RS .TP \fBttk::style theme create\fR \fIthemeName\fR ?\fB\-parent \fIbasedon\fR? ?\fB\-settings \fIscript...\fR ? Creates a new theme. It is an error if \fIthemeName\fR already exists. @@ -78,19 +85,20 @@ styles, elements, and layouts from the parent theme \fIbasedon\fR. If \fB\-settings\fR is present, \fIscript\fR is evaluated in the context of the new theme as per \fBttk::style theme settings\fR. .TP +\fBttk::style theme names\fR +Returns a list of all known themes. +.TP \fBttk::style theme settings \fIthemeName\fR \fIscript\fR Temporarily sets the current theme to \fIthemeName\fR, evaluate \fIscript\fR, then restore the previous theme. Typically \fIscript\fR simply defines styles and elements, though arbitrary Tcl code may appear. .TP -\fBttk::style theme names\fR -Returns a list of all known themes. -.TP \fBttk::style theme use\fR ?\fIthemeName\fR? Without an argument the result is the name of the current theme. Otherwise this command sets the current theme to \fIthemeName\fR, and refreshes all widgets. +.RE .SH LAYOUTS .PP A \fIlayout\fR specifies a list of elements, each followed @@ -98,19 +106,40 @@ by one or more options specifying how to arrange the element. The layout mechanism uses a simplified version of the \fBpack\fR geometry manager: given an initial cavity, each element is allocated a parcel. +Then the parcel actually used by the element is adjusted within +the allocated parcel. Valid options are: +.\" -border should remain undocumented for now (dubious usefulness) +.\" .TP +.\" \fB\-border\fR \fIboolean\fR +.\" Specifies whether the element is drawn after its children. Defaults to 0. +.TP +\fB\-children { \fIsublayout...\fB }\fR +Specifies a list of elements to place inside the element. +.TP +\fB\-expand\fR \fIboolean\fR +Specifies whether the allocated parcel is the entire cavity. If so, +simultaneous specification of \fB\-side\fR is ignored. +Defaults to 0. .TP \fB\-side \fIside\fR Specifies which side of the cavity to place the element; one of \fBleft\fR, \fBright\fR, \fBtop\fR, or \fBbottom\fR. -If omitted, the element occupies the entire cavity. +For instance, \fB\-side top\fR allocates the parcel along the top of +the cavity having width and height respectively the width of the cavity +and the height of the element. +If omitted, the allocated parcel is the entire cavity (same effect +as \fB\-expand\fR 1). .TP \fB\-sticky\fR \fB[\fInswe\fB]\fR -Specifies where the element is placed inside its allocated parcel. -.TP -\fB\-children { \fIsublayout... \fB}\fR -Specifies a list of elements to place inside the element. -.\" Also: -border, -unit, -expand: may go away. +Specifies the actual parcel position and size inside the allocated parcel. +If specified as an empty string then the actual parcel is centered in +the allocated parcel. Default is \fBnswe\fR. +.\" -unit should remain undocumented for now (dubious usefulness) +.\" .TP +.\" \fB\-unit\fR \fIboolean\fR +.\" Specifies whether the element propagates its state to its children. +.\" Defaults to 0. .PP For example: .CS diff --git a/doc/ttk_widget.n b/doc/ttk_widget.n index 73affdd..17f1d88 100644 --- a/doc/ttk_widget.n +++ b/doc/ttk_widget.n @@ -152,13 +152,14 @@ to zero, then automatic wrapping is not performed; otherwise the text is split into lines such that no line is longer than the specified value. .SH "ENTRY OPTIONS" -The following option is supported by entry, spinbox and combobox: +The following options are supported by entry, spinbox and combobox: .OP \-placeholder placeHolder PlaceHolder Specifies a help text string to display if no text is otherwise displayed, that is when the widget is empty. The placeholder text is displayed using -the values of the \fB\-font\fR and \fB\-justify\fR options. The foreground -color of the placeholder text can be changed using the -\fB\-placeholderforeground\fR style option. +the values of the \fB\-font\fR, \fB\-justify\fR and +\fB\-placeholderforeground\fR options. +.OP \-placeholderforeground placeHolderForeground PlaceHolderForeground +Specifies the foreground color of the placeholder text. .SH "COMPATIBILITY OPTIONS" This option is only available for themed widgets that have .QW corresponding diff --git a/generic/tkCanvas.c b/generic/tkCanvas.c index 5322466..c3e8a7f 100644 --- a/generic/tkCanvas.c +++ b/generic/tkCanvas.c @@ -988,7 +988,7 @@ CanvasWidgetCmd( if (objc == 5) { int append = 0; - unsigned long mask; + unsigned int mask; const char *argv4 = Tcl_GetString(objv[4]); if (argv4[0] == 0) { @@ -1036,7 +1036,7 @@ CanvasWidgetCmd( result = TCL_ERROR; goto done; } - if (mask & ~(unsigned long)(ButtonMotionMask|Button1MotionMask + if (mask & ~(ButtonMotionMask|Button1MotionMask |Button2MotionMask|Button3MotionMask|Button4MotionMask |Button5MotionMask|ButtonPressMask|ButtonReleaseMask |EnterWindowMask|LeaveWindowMask|KeyPressMask @@ -2503,7 +2503,7 @@ CanvasWorldChanged( */ static void DecomposeMaskToShiftAndBits( - unsigned long mask, /* The pixel mask to examine */ + 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) */ { @@ -2849,7 +2849,7 @@ DrawCanvas( #endif for(x = 0; x < blockPtr.width; ++x) { - unsigned long pixel = 0; + unsigned int pixel = 0; switch (ximagePtr->bits_per_pixel) { @@ -2881,7 +2881,7 @@ DrawCanvas( */ case 32 : - pixel = *((unsigned long *)(ximagePtr->data + bytesPerPixel * x + 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)) @@ -5178,7 +5178,7 @@ PickCurrentItem( * ButtonRelease, or MotionNotify. */ { double coords[2]; - unsigned long buttonDown; + unsigned int buttonDown; Tk_Item *prevItemPtr; SearchUids *searchUids = GetStaticUids(); diff --git a/generic/tkEntry.c b/generic/tkEntry.c index 428b5c3..fbb7e29 100644 --- a/generic/tkEntry.c +++ b/generic/tkEntry.c @@ -737,7 +737,7 @@ EntryWidgetObjCmd( &index) != TCL_OK) { goto error; } - Tcl_SetObjResult(interp, Tcl_NewWideIntObj(index)); + Tcl_SetObjResult(interp, TkNewIndexObj(index)); break; } @@ -3995,7 +3995,7 @@ SpinboxWidgetObjCmd( &index) != TCL_OK) { goto error; } - Tcl_SetObjResult(interp, Tcl_NewWideIntObj((int)index)); + Tcl_SetObjResult(interp, TkNewIndexObj(index)); break; } diff --git a/generic/tkFont.c b/generic/tkFont.c index 6659025..67d0b36 100644 --- a/generic/tkFont.c +++ b/generic/tkFont.c @@ -2738,7 +2738,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; @@ -2748,7 +2748,6 @@ Tk_CharBbox( return 0; } - chunkPtr = layoutPtr->chunks; tkfont = layoutPtr->tkfont; fontPtr = (TkFont *) tkfont; diff --git a/generic/tkInt.decls b/generic/tkInt.decls index 7f3baaf..95d3802 100644 --- a/generic/tkInt.decls +++ b/generic/tkInt.decls @@ -1931,6 +1931,10 @@ declare 104 macosx { 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 macosx { int XFlush(Display *display) } diff --git a/generic/tkInt.h b/generic/tkInt.h index 57d7c69..7b36942 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -1356,6 +1356,7 @@ MODULE_SCOPE void TkRotatePoint(double originX, double originY, 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 diff --git a/generic/tkIntXlibDecls.h b/generic/tkIntXlibDecls.h index 774075d..ad5321c 100644 --- a/generic/tkIntXlibDecls.h +++ b/generic/tkIntXlibDecls.h @@ -765,7 +765,10 @@ EXTERN Status XIconifyWindow(Display *d, Window w, int i); EXTERN Status XWithdrawWindow(Display *d, Window w, int i); /* 105 */ EXTERN XHostAddress * XListHosts(Display *d, int *i, Bool *b); -/* Slot 106 is reserved */ +/* 106 */ +EXTERN int XSetClipRectangles(Display *display, GC gc, + int clip_x_origin, int clip_y_origin, + XRectangle rectangles[], int n, int ordering); /* 107 */ EXTERN int XFlush(Display *display); /* 108 */ @@ -1162,7 +1165,7 @@ typedef struct TkIntXlibStubs { Status (*xIconifyWindow) (Display *d, Window w, int i); /* 103 */ Status (*xWithdrawWindow) (Display *d, Window w, int i); /* 104 */ XHostAddress * (*xListHosts) (Display *d, int *i, Bool *b); /* 105 */ - void (*reserved106)(void); + int (*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 */ int (*xUngrabServer) (Display *display); /* 109 */ @@ -1748,7 +1751,8 @@ extern const TkIntXlibStubs *tkIntXlibStubsPtr; (tkIntXlibStubsPtr->xWithdrawWindow) /* 104 */ #define XListHosts \ (tkIntXlibStubsPtr->xListHosts) /* 105 */ -/* Slot 106 is reserved */ +#define XSetClipRectangles \ + (tkIntXlibStubsPtr->xSetClipRectangles) /* 106 */ #define XFlush \ (tkIntXlibStubsPtr->xFlush) /* 107 */ #define XGrabServer \ diff --git a/generic/tkListbox.c b/generic/tkListbox.c index d8ecdeb..d88bebb 100644 --- a/generic/tkListbox.c +++ b/generic/tkListbox.c @@ -842,7 +842,7 @@ ListboxWidgetObjCmd( if (result != TCL_OK) { break; } - Tcl_SetObjResult(interp, Tcl_NewWideIntObj(index)); + Tcl_SetObjResult(interp, TkNewIndexObj(index)); result = TCL_OK; break; @@ -2742,7 +2742,7 @@ GetListboxIndex( result = TkGetIntForIndex(indexObj, listPtr->nElements - 1, lastOK, &idx); if (result == TCL_OK) { - if (idx + 1 > (TkSizeT)listPtr->nElements + 1) { + if ((idx != TCL_INDEX_NONE) && (idx > (TkSizeT)listPtr->nElements)) { idx = listPtr->nElements; } *indexPtr = (int)idx; diff --git a/generic/tkMenu.c b/generic/tkMenu.c index 93fe09f..3b648ff 100644 --- a/generic/tkMenu.c +++ b/generic/tkMenu.c @@ -845,9 +845,8 @@ MenuWidgetObjCmd( } if (index == TCL_INDEX_NONE) { Tcl_SetObjResult(interp, Tcl_NewStringObj("none", -1)); - } else { - Tcl_SetObjResult(interp, Tcl_NewWideIntObj(index)); - } + } else + Tcl_SetObjResult(interp, TkNewIndexObj(index)); break; } case MENU_INSERT: diff --git a/generic/tkObj.c b/generic/tkObj.c index b47ca92..7f3b7ff 100644 --- a/generic/tkObj.c +++ b/generic/tkObj.c @@ -117,7 +117,7 @@ extern const struct TclIntStubs *tclIntStubsPtr; tclIntStubsPtr->tclGetIntForIndex((interp), (obj), (max), (ptr))) #elif TCL_MINOR_VERSION < 7 extern int TclGetIntForIndex(Tcl_Interp*, Tcl_Obj *, int, int*); -# define Tcl_GetIntForIndex TclGetIntForIndex +# define Tcl_GetIntForIndex(interp, obj, max, ptr) TclGetIntForIndex(interp, obj, max, ptr) #endif #endif diff --git a/generic/tkStubInit.c b/generic/tkStubInit.c index eb2dd47..299fefa 100644 --- a/generic/tkStubInit.c +++ b/generic/tkStubInit.c @@ -958,7 +958,7 @@ static const TkIntXlibStubs tkIntXlibStubs = { XIconifyWindow, /* 103 */ XWithdrawWindow, /* 104 */ XListHosts, /* 105 */ - 0, /* 106 */ + XSetClipRectangles, /* 106 */ XFlush, /* 107 */ XGrabServer, /* 108 */ XUngrabServer, /* 109 */ diff --git a/generic/ttk/ttkBlink.c b/generic/ttk/ttkBlink.c index dcd342c..fc48af9 100644 --- a/generic/ttk/ttkBlink.c +++ b/generic/ttk/ttkBlink.c @@ -59,7 +59,7 @@ static CursorManager *GetCursorManager(Tcl_Interp *interp) cm->owner = 0; cm->onTime = DEF_CURSOR_ON_TIME; cm->offTime = DEF_CURSOR_OFF_TIME; - Tcl_SetAssocData(interp,cm_key,CursorManagerDeleteProc,(ClientData)cm); + Tcl_SetAssocData(interp, cm_key, CursorManagerDeleteProc, cm); } return cm; } diff --git a/generic/ttk/ttkButton.c b/generic/ttk/ttkButton.c index 9712c66..919b4d4 100644 --- a/generic/ttk/ttkButton.c +++ b/generic/ttk/ttkButton.c @@ -823,7 +823,7 @@ static const Tk_OptionSpec MenubuttonOptionSpecs[] = "", offsetof(Menubutton, menubutton.menuObj), TCL_INDEX_NONE, 0,0,0}, {TK_OPTION_STRING_TABLE, "-direction", "direction", "Direction", "below", offsetof(Menubutton, menubutton.directionObj), TCL_INDEX_NONE, - 0,(ClientData)directionStrings,GEOMETRY_CHANGED}, + 0,(void *)directionStrings,GEOMETRY_CHANGED}, WIDGET_TAKEFOCUS_TRUE, WIDGET_INHERIT_OPTIONS(BaseOptionSpecs) @@ -858,7 +858,7 @@ TTK_BEGIN_LAYOUT(MenubuttonLayout) TTK_GROUP("Menubutton.border", TTK_FILL_BOTH, TTK_GROUP("Menubutton.focus", TTK_FILL_BOTH, TTK_NODE("Menubutton.indicator", TTK_PACK_RIGHT) - TTK_GROUP("Menubutton.padding", TTK_PACK_LEFT|TTK_EXPAND|TTK_FILL_X, + TTK_GROUP("Menubutton.padding", TTK_FILL_X, TTK_NODE("Menubutton.label", TTK_PACK_LEFT)))) TTK_END_LAYOUT diff --git a/generic/ttk/ttkClamTheme.c b/generic/ttk/ttkClamTheme.c index dae54e4..035cabc 100644 --- a/generic/ttk/ttkClamTheme.c +++ b/generic/ttk/ttkClamTheme.c @@ -955,7 +955,7 @@ TTK_BEGIN_LAYOUT_TABLE(LayoutTable) TTK_LAYOUT("TCombobox", TTK_NODE("Combobox.downarrow", TTK_PACK_RIGHT|TTK_FILL_Y) - TTK_GROUP("Combobox.field", TTK_PACK_LEFT|TTK_FILL_BOTH|TTK_EXPAND, + TTK_GROUP("Combobox.field", TTK_FILL_BOTH, TTK_GROUP("Combobox.padding", TTK_FILL_BOTH, TTK_NODE("Combobox.textarea", TTK_FILL_BOTH)))) diff --git a/generic/ttk/ttkClassicTheme.c b/generic/ttk/ttkClassicTheme.c index ec35480..be7d74b 100644 --- a/generic/ttk/ttkClassicTheme.c +++ b/generic/ttk/ttkClassicTheme.c @@ -453,7 +453,7 @@ TTK_LAYOUT("TMenubutton", TTK_GROUP("Menubutton.highlight", TTK_FILL_BOTH, TTK_GROUP("Menubutton.border", TTK_FILL_BOTH, TTK_NODE("Menubutton.indicator", TTK_PACK_RIGHT) - TTK_GROUP("Menubutton.padding", TTK_PACK_LEFT|TTK_EXPAND|TTK_FILL_X, + TTK_GROUP("Menubutton.padding", TTK_FILL_X, TTK_NODE("Menubutton.label", 0))))) /* "classic" entry, includes highlight border */ diff --git a/generic/ttk/ttkEntry.c b/generic/ttk/ttkEntry.c index 4314a83..946b7fc 100644 --- a/generic/ttk/ttkEntry.c +++ b/generic/ttk/ttkEntry.c @@ -181,7 +181,7 @@ static const Tk_OptionSpec EntryOptionSpecs[] = { TK_OPTION_NULL_OK,0,TEXTVAR_CHANGED}, {TK_OPTION_STRING_TABLE, "-validate", "validate", "Validate", "none", TCL_INDEX_NONE, offsetof(Entry, entry.validate), - 0, (ClientData) validateStrings, 0}, + 0, (void *) validateStrings, 0}, {TK_OPTION_STRING, "-validatecommand", "validateCommand", "ValidateCommand", NULL, TCL_INDEX_NONE, offsetof(Entry, entry.validateCmd), TK_OPTION_NULL_OK, 0, 0}, @@ -403,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; } } @@ -600,9 +600,9 @@ EntryValidateChange( 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; } @@ -958,7 +958,7 @@ EntryInitialize(Tcl_Interp *dummy, void *recordPtr) 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 = (char *)ckalloc(1); @@ -1393,7 +1393,7 @@ EntryIndex( const char *string; if (TCL_OK == TkGetIntForIndex(indexObj, entryPtr->entry.numChars - 1, 1, &idx)) { - if (idx + 1 > entryPtr->entry.numChars + 1) { + if ((idx != TCL_INDEX_NONE) && (idx > entryPtr->entry.numChars)) { idx = entryPtr->entry.numChars; } *indexPtr = idx; @@ -1577,7 +1577,7 @@ EntryIndexCommand( if (EntryIndex(interp, entryPtr, objv[2], &index) != TCL_OK) { return TCL_ERROR; } - Tcl_SetObjResult(interp, Tcl_NewWideIntObj(index)); + Tcl_SetObjResult(interp, TkNewIndexObj(index)); return TCL_OK; } @@ -1650,7 +1650,7 @@ static int EntrySelectionRangeCommand( 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; } @@ -1711,7 +1711,7 @@ static int EntryValidateCommand( if (code == TCL_ERROR) return code; - Tcl_SetObjResult(interp, Tcl_NewWideIntObj(code == TCL_OK)); + Tcl_SetObjResult(interp, Tcl_NewBooleanObj(code == TCL_OK)); return TCL_OK; } @@ -1849,7 +1849,7 @@ static int ComboboxCurrentCommand( if (objc == 2) { /* Check if currentIndex still valid: */ - if ( currentIndex == TCL_INDEX_NONE + if (currentIndex == TCL_INDEX_NONE || currentIndex >= (TkSizeT)nValues || strcmp(currentValue,Tcl_GetString(values[currentIndex])) ) @@ -1867,7 +1867,7 @@ static int ComboboxCurrentCommand( } } cbPtr->combobox.currentIndex = currentIndex; - Tcl_SetObjResult(interp, Tcl_NewWideIntObj((int)currentIndex)); + Tcl_SetObjResult(interp, TkNewIndexObj(currentIndex)); return TCL_OK; } else if (objc == 3) { TkSizeT idx; @@ -2109,7 +2109,7 @@ TTK_END_LAYOUT TTK_BEGIN_LAYOUT(ComboboxLayout) TTK_GROUP("Combobox.field", TTK_FILL_BOTH, TTK_NODE("Combobox.downarrow", TTK_PACK_RIGHT|TTK_FILL_Y) - TTK_GROUP("Combobox.padding", TTK_FILL_BOTH|TTK_PACK_LEFT|TTK_EXPAND, + TTK_GROUP("Combobox.padding", TTK_FILL_BOTH, TTK_NODE("Combobox.textarea", TTK_FILL_BOTH))) TTK_END_LAYOUT diff --git a/generic/ttk/ttkLayout.c b/generic/ttk/ttkLayout.c index a39ae2b..a971d23 100644 --- a/generic/ttk/ttkLayout.c +++ b/generic/ttk/ttkLayout.c @@ -809,7 +809,7 @@ Tcl_Obj *Ttk_UnparseLayoutTemplate(Ttk_TemplateNode *node) APPENDSTR("-sticky"); APPENDOBJ(Ttk_NewStickyObj(flags & _TTK_MASK_STICK)); - /* @@@ Check again: are these necessary? */ + /* @@@ Check again: are these necessary? Can't see any effect! */ if (flags & TTK_BORDER) { APPENDSTR("-border"); APPENDSTR("1"); } if (flags & TTK_UNIT) { APPENDSTR("-unit"); APPENDSTR("1"); } diff --git a/generic/ttk/ttkManager.c b/generic/ttk/ttkManager.c index 5fa9918..c01bc47 100644 --- a/generic/ttk/ttkManager.c +++ b/generic/ttk/ttkManager.c @@ -261,10 +261,10 @@ static void InsertSlave(Ttk_Manager *mgr, Ttk_Slave *slave, TkSizeT index) mgr->slaves[index] = slave; Tk_ManageGeometry(slave->slaveWindow, - &mgr->managerSpec->tkGeomMgr, (ClientData)mgr); + &mgr->managerSpec->tkGeomMgr, mgr); Tk_CreateEventHandler(slave->slaveWindow, - SlaveEventMask, SlaveEventHandler, (ClientData)slave); + SlaveEventMask, SlaveEventHandler, slave); ScheduleUpdate(mgr, MGR_RESIZE_REQUIRED); } diff --git a/generic/ttk/ttkNotebook.c b/generic/ttk/ttkNotebook.c index d0151f7..95125d3 100644 --- a/generic/ttk/ttkNotebook.c +++ b/generic/ttk/ttkNotebook.c @@ -59,25 +59,25 @@ static const Tk_OptionSpec TabOptionSpecs[] = { {TK_OPTION_STRING_TABLE, "-state", "", "", "normal", TCL_INDEX_NONE, offsetof(Tab,state), - 0,(ClientData)TabStateStrings,0 }, + 0, (void *)TabStateStrings, 0 }, {TK_OPTION_STRING, "-text", "text", "Text", "", - offsetof(Tab,textObj), TCL_INDEX_NONE, 0,0,GEOMETRY_CHANGED }, + offsetof(Tab,textObj), TCL_INDEX_NONE, 0, 0, GEOMETRY_CHANGED }, {TK_OPTION_STRING, "-image", "image", "Image", NULL/*default*/, - offsetof(Tab,imageObj), TCL_INDEX_NONE, 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, offsetof(Tab,compoundObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,(void *)ttkCompoundStrings,GEOMETRY_CHANGED }, {TK_OPTION_INT, "-underline", "underline", "Underline", "-1", - offsetof(Tab,underlineObj), TCL_INDEX_NONE, 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 const Tk_OptionSpec PaneOptionSpecs[] = { {TK_OPTION_STRING, "-padding", "padding", "Padding", "0", - offsetof(Tab,paddingObj), TCL_INDEX_NONE, 0,0,GEOMETRY_CHANGED }, + offsetof(Tab,paddingObj), TCL_INDEX_NONE, 0, 0, GEOMETRY_CHANGED }, {TK_OPTION_STRING, "-sticky", "sticky", "Sticky", "nsew", - offsetof(Tab,stickyObj), TCL_INDEX_NONE, 0,0,GEOMETRY_CHANGED }, + offsetof(Tab,stickyObj), TCL_INDEX_NONE, 0, 0, GEOMETRY_CHANGED }, WIDGET_INHERIT_OPTIONS(TabOptionSpecs) }; @@ -1079,7 +1079,7 @@ static int NotebookIdentifyCommand( return TCL_ERROR; } - if ( Tcl_GetIntFromObj(interp, objv[objc-2], &x) != TCL_OK + if (Tcl_GetIntFromObj(interp, objv[objc-2], &x) != TCL_OK || Tcl_GetIntFromObj(interp, objv[objc-1], &y) != TCL_OK || (objc == 5 && Tcl_GetIndexFromObjStruct(interp, objv[2], whatTable, sizeof(char *), "option", 0, &what) != TCL_OK) @@ -1108,9 +1108,8 @@ static int NotebookIdentifyCommand( } break; case IDENTIFY_TAB: - if (tabIndex != TCL_INDEX_NONE) { - Tcl_SetObjResult(interp, Tcl_NewWideIntObj(tabIndex)); - } + if (tabIndex != TCL_INDEX_NONE) + Tcl_SetObjResult(interp, TkNewIndexObj(tabIndex)); break; } return TCL_OK; @@ -1134,8 +1133,9 @@ static int NotebookIndexCommand( } status = FindTabIndex(interp, nb, objv[2], &index); - if (status == TCL_OK && index != TCL_INDEX_NONE) { - Tcl_SetObjResult(interp, Tcl_NewWideIntObj(index)); + if (status == TCL_OK) { + if (index != TCL_INDEX_NONE) + Tcl_SetObjResult(interp, TkNewIndexObj(index)); } return status; diff --git a/generic/ttk/ttkPanedwindow.c b/generic/ttk/ttkPanedwindow.c index 5d925de..09b633b 100644 --- a/generic/ttk/ttkPanedwindow.c +++ b/generic/ttk/ttkPanedwindow.c @@ -77,13 +77,13 @@ typedef struct { static const Tk_OptionSpec PanedOptionSpecs[] = { {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "vertical", offsetof(Paned,paned.orientObj), offsetof(Paned,paned.orient), - 0,(ClientData)ttkOrientStrings,READONLY_OPTION|STYLE_CHANGED }, + 0, (void *)ttkOrientStrings, READONLY_OPTION|STYLE_CHANGED }, {TK_OPTION_INT, "-width", "width", "Width", "0", - TCL_INDEX_NONE, offsetof(Paned,paned.width), - 0,0,GEOMETRY_CHANGED }, + TCL_INDEX_NONE, offsetof(Paned, paned.width), + 0, 0, GEOMETRY_CHANGED }, {TK_OPTION_INT, "-height", "height", "Height", "0", - TCL_INDEX_NONE, offsetof(Paned,paned.height), - 0,0,GEOMETRY_CHANGED }, + TCL_INDEX_NONE, offsetof(Paned, paned.height), + 0, 0, GEOMETRY_CHANGED }, WIDGET_TAKEFOCUS_FALSE, WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs) diff --git a/generic/ttk/ttkProgress.c b/generic/ttk/ttkProgress.c index 505748b..a025885 100644 --- a/generic/ttk/ttkProgress.c +++ b/generic/ttk/ttkProgress.c @@ -71,10 +71,10 @@ static const Tk_OptionSpec ProgressbarOptionSpecs[] = {TK_OPTION_STRING_TABLE, "-mode", "mode", "ProgressMode", "determinate", offsetof(Progressbar,progress.modeObj), offsetof(Progressbar,progress.mode), - 0, (ClientData)ProgressbarModeStrings, 0 }, + 0, (void *)ProgressbarModeStrings, 0 }, {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "horizontal", offsetof(Progressbar,progress.orientObj), TCL_INDEX_NONE, - 0, (ClientData)ttkOrientStrings, STYLE_CHANGED }, + 0, (void *)ttkOrientStrings, STYLE_CHANGED }, {TK_OPTION_INT, "-phase", "phase", "Phase", "0", offsetof(Progressbar,progress.phaseObj), TCL_INDEX_NONE, 0, 0, 0 }, diff --git a/generic/ttk/ttkScale.c b/generic/ttk/ttkScale.c index a2c5d59..6c9867a 100644 --- a/generic/ttk/ttkScale.c +++ b/generic/ttk/ttkScale.c @@ -57,11 +57,11 @@ static const Tk_OptionSpec ScaleOptionSpecs[] = TK_OPTION_NULL_OK,0,0}, {TK_OPTION_STRING, "-variable", "variable", "Variable", "", offsetof(Scale,scale.variableObj), TCL_INDEX_NONE, - 0,0,0}, + 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "horizontal", offsetof(Scale,scale.orientObj), offsetof(Scale,scale.orient), 0, - (ClientData)ttkOrientStrings, STYLE_CHANGED }, + (void *)ttkOrientStrings, STYLE_CHANGED }, {TK_OPTION_DOUBLE, "-from", "from", "From", "0", offsetof(Scale,scale.fromObj), TCL_INDEX_NONE, 0, 0, 0}, @@ -75,7 +75,7 @@ static const Tk_OptionSpec ScaleOptionSpecs[] = {TK_OPTION_STRING, "-state", "state", "State", "normal", offsetof(Scale,scale.stateObj), TCL_INDEX_NONE, - 0,0,STATE_CHANGED}, + 0, 0, STATE_CHANGED}, WIDGET_TAKEFOCUS_TRUE, WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs) diff --git a/generic/ttk/ttkScroll.c b/generic/ttk/ttkScroll.c index b031dc6..69370c9 100644 --- a/generic/ttk/ttkScroll.c +++ b/generic/ttk/ttkScroll.c @@ -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 1b915cc..54923ff 100644 --- a/generic/ttk/ttkScrollbar.c +++ b/generic/ttk/ttkScrollbar.c @@ -34,12 +34,12 @@ typedef struct static const Tk_OptionSpec ScrollbarOptionSpecs[] = { {TK_OPTION_STRING, "-command", "command", "Command", "", - offsetof(Scrollbar,scrollbar.commandObj), TCL_INDEX_NONE, 0,0,0}, + offsetof(Scrollbar, scrollbar.commandObj), TCL_INDEX_NONE, 0, 0, 0}, {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "vertical", - offsetof(Scrollbar,scrollbar.orientObj), - offsetof(Scrollbar,scrollbar.orient), - 0,(ClientData)ttkOrientStrings,STYLE_CHANGED }, + offsetof(Scrollbar, scrollbar.orientObj), + offsetof(Scrollbar, scrollbar.orient), + 0, (void *)ttkOrientStrings, STYLE_CHANGED }, WIDGET_TAKEFOCUS_FALSE, WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs) @@ -316,16 +316,14 @@ TTK_BEGIN_LAYOUT(VerticalScrollbarLayout) TTK_GROUP("Vertical.Scrollbar.trough", TTK_FILL_Y, TTK_NODE("Vertical.Scrollbar.uparrow", TTK_PACK_TOP) TTK_NODE("Vertical.Scrollbar.downarrow", TTK_PACK_BOTTOM) - TTK_NODE( - "Vertical.Scrollbar.thumb", TTK_PACK_TOP|TTK_EXPAND|TTK_FILL_BOTH)) + TTK_NODE("Vertical.Scrollbar.thumb", TTK_FILL_BOTH)) TTK_END_LAYOUT TTK_BEGIN_LAYOUT(HorizontalScrollbarLayout) TTK_GROUP("Horizontal.Scrollbar.trough", TTK_FILL_X, TTK_NODE("Horizontal.Scrollbar.leftarrow", TTK_PACK_LEFT) TTK_NODE("Horizontal.Scrollbar.rightarrow", TTK_PACK_RIGHT) - TTK_NODE( - "Horizontal.Scrollbar.thumb", TTK_PACK_LEFT|TTK_EXPAND|TTK_FILL_BOTH)) + TTK_NODE("Horizontal.Scrollbar.thumb", TTK_FILL_BOTH)) TTK_END_LAYOUT /*------------------------------------------------------------------------ diff --git a/generic/ttk/ttkSeparator.c b/generic/ttk/ttkSeparator.c index 00605dc..a3141da 100644 --- a/generic/ttk/ttkSeparator.c +++ b/generic/ttk/ttkSeparator.c @@ -26,7 +26,7 @@ static const Tk_OptionSpec SeparatorOptionSpecs[] = { {TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "horizontal", offsetof(Separator,separator.orientObj), offsetof(Separator,separator.orient), - 0,(ClientData)ttkOrientStrings,STYLE_CHANGED }, + 0, (void *)ttkOrientStrings,STYLE_CHANGED }, WIDGET_TAKEFOCUS_FALSE, WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs) diff --git a/generic/ttk/ttkTrace.c b/generic/ttk/ttkTrace.c index 7e02b58..d086c02 100644 --- a/generic/ttk/ttkTrace.c +++ b/generic/ttk/ttkTrace.c @@ -53,7 +53,7 @@ VarTraceProc( */ if (tracePtr->interp == NULL) { Tcl_DecrRefCount(tracePtr->varnameObj); - ckfree((ClientData)tracePtr); + ckfree(tracePtr); return NULL; } Tcl_TraceVar2(interp, name, NULL, @@ -98,7 +98,7 @@ Ttk_TraceHandle *Ttk_TraceVariable( status = Tcl_TraceVar2(interp, Tcl_GetString(varnameObj), NULL, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, - VarTraceProc, (ClientData)h); + VarTraceProc, h); if (status != TCL_OK) { Tcl_DecrRefCount(h->varnameObj); @@ -139,7 +139,7 @@ void Ttk_UntraceVariable(Ttk_TraceHandle *h) */ while ((cd = Tcl_VarTraceInfo(h->interp, Tcl_GetString(h->varnameObj), TCL_GLOBAL_ONLY, VarTraceProc, cd)) != NULL) { - if (cd == (ClientData) h) { + if (cd == h) { break; } } @@ -154,7 +154,7 @@ void Ttk_UntraceVariable(Ttk_TraceHandle *h) } Tcl_UntraceVar2(h->interp, Tcl_GetString(h->varnameObj), NULL, TCL_GLOBAL_ONLY|TCL_TRACE_WRITES|TCL_TRACE_UNSETS, - VarTraceProc, (ClientData)h); + VarTraceProc, h); Tcl_DecrRefCount(h->varnameObj); ckfree(h); } diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c index 699a10b..4ea4c17 100644 --- a/generic/ttk/ttkTreeview.c +++ b/generic/ttk/ttkTreeview.c @@ -441,21 +441,21 @@ static const char *const SelectModeStrings[] = { "none", "browse", "extended", N static const Tk_OptionSpec TreeviewOptionSpecs[] = { {TK_OPTION_STRING, "-columns", "columns", "Columns", "", offsetof(Treeview,tree.columnsObj), TCL_INDEX_NONE, - 0,0,COLUMNS_CHANGED | GEOMETRY_CHANGED /*| READONLY_OPTION*/ }, + 0, 0,COLUMNS_CHANGED | GEOMETRY_CHANGED /*| READONLY_OPTION*/ }, {TK_OPTION_STRING, "-displaycolumns","displayColumns","DisplayColumns", "#all", offsetof(Treeview,tree.displayColumnsObj), TCL_INDEX_NONE, - 0,0,DCOLUMNS_CHANGED | GEOMETRY_CHANGED }, + 0, 0,DCOLUMNS_CHANGED | GEOMETRY_CHANGED }, {TK_OPTION_STRING, "-show", "show", "Show", DEFAULT_SHOW, offsetof(Treeview,tree.showObj), TCL_INDEX_NONE, - 0,0,SHOW_CHANGED | GEOMETRY_CHANGED }, + 0, 0,SHOW_CHANGED | GEOMETRY_CHANGED }, {TK_OPTION_STRING_TABLE, "-selectmode", "selectMode", "SelectMode", "extended", offsetof(Treeview,tree.selectModeObj), TCL_INDEX_NONE, - 0,(ClientData)SelectModeStrings,0 }, + 0, (void *)SelectModeStrings, 0 }, {TK_OPTION_PIXELS, "-height", "height", "Height", DEF_TREE_ROWS, offsetof(Treeview,tree.heightObj), TCL_INDEX_NONE, - 0,0,GEOMETRY_CHANGED}, + 0, 0,GEOMETRY_CHANGED}, {TK_OPTION_STRING, "-padding", "padding", "Pad", NULL, offsetof(Treeview,tree.paddingObj), TCL_INDEX_NONE, TK_OPTION_NULL_OK,0,GEOMETRY_CHANGED }, @@ -792,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 { @@ -1101,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; } @@ -1780,7 +1778,7 @@ static void DrawItem( x+indent, y, colwidth-indent, rowHeight); if (item->textObj) { displayItem.textObj = item->textObj; } if (item->imageObj) { displayItem.imageObj = item->imageObj; } - /* ??? displayItem.anchorObj = 0; <<NOTE-ANCHOR>> */ + displayItem.anchorObj = tv->tree.column0.anchorObj; DisplayLayout(tv->tree.itemLayout, &displayItem, state, parcel, d); x += colwidth; } @@ -2109,7 +2107,7 @@ static int TreeviewIndexCommand( { Treeview *tv = (Treeview *)recordPtr; TreeItem *item; - int index = 0; + TkSizeT index = 0; if (objc != 3) { Tcl_WrongNumArgs(interp, 2, objv, "item"); @@ -2125,7 +2123,7 @@ static int TreeviewIndexCommand( item = item->prev; } - Tcl_SetObjResult(interp, Tcl_NewWideIntObj(index)); + Tcl_SetObjResult(interp, TkNewIndexObj(index)); return TCL_OK; } @@ -2201,9 +2199,8 @@ static int TreeviewHorribleIdentify( /* 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; } @@ -2750,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; } @@ -2879,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; } @@ -3351,8 +3346,7 @@ TTK_LAYOUT("Item", TTK_GROUP("Treeitem.padding", TTK_FILL_BOTH, TTK_NODE("Treeitem.indicator", TTK_PACK_LEFT) TTK_NODE("Treeitem.image", TTK_PACK_LEFT) - TTK_GROUP("Treeitem.focus", TTK_PACK_LEFT, - TTK_NODE("Treeitem.text", TTK_PACK_LEFT)))) + TTK_NODE("Treeitem.text", TTK_FILL_BOTH))) TTK_LAYOUT("Cell", TTK_GROUP("Treedata.padding", TTK_FILL_BOTH, diff --git a/generic/ttk/ttkWidget.c b/generic/ttk/ttkWidget.c index df6e6be..6726e17 100644 --- a/generic/ttk/ttkWidget.c +++ b/generic/ttk/ttkWidget.c @@ -213,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); diff --git a/library/ttk/scrollbar.tcl b/library/ttk/scrollbar.tcl index 7537491..fdba265 100644 --- a/library/ttk/scrollbar.tcl +++ b/library/ttk/scrollbar.tcl @@ -56,7 +56,7 @@ proc ttk::scrollbar::Press {w x y} { set State(yPress) $y switch -glob -- [$w identify $x $y] { - *uparrow - + *uparrow - *leftarrow { ttk::Repeatedly Scroll $w -1 units } @@ -64,6 +64,7 @@ proc ttk::scrollbar::Press {w x y} { *rightarrow { ttk::Repeatedly Scroll $w 1 units } + *grip - *thumb { set State(first) [lindex [$w get] 0] } @@ -109,6 +110,7 @@ proc ttk::scrollbar::Jump {w x y} { variable State switch -glob -- [$w identify $x $y] { + *grip - *thumb - *trough { set State(first) [$w fraction $x $y] diff --git a/library/ttk/vistaTheme.tcl b/library/ttk/vistaTheme.tcl index 165b496..d841962 100644 --- a/library/ttk/vistaTheme.tcl +++ b/library/ttk/vistaTheme.tcl @@ -69,9 +69,9 @@ namespace eval ttk::theme::vista { ttk::style layout TCombobox { Combobox.border -sticky nswe -border 0 -children { Combobox.rightdownarrow -side right -sticky ns - Combobox.padding -expand 1 -sticky nswe -children { + Combobox.padding -sticky nswe -children { Combobox.background -sticky nswe -children { - Combobox.focus -expand 1 -sticky nswe -children { + Combobox.focus -sticky nswe -children { Combobox.textarea -sticky nswe } } @@ -138,7 +138,7 @@ namespace eval ttk::theme::vista { Spinbox.background -sticky news -children { Spinbox.padding -sticky news -children { Spinbox.innerbg -sticky news -children { - Spinbox.textarea -expand 1 + Spinbox.textarea } } Spinbox.uparrow -side top -sticky ens @@ -203,8 +203,8 @@ namespace eval ttk::theme::vista { TRACKBAR 3 {disabled 5 focus 4 pressed 3 active 2 {} 1} \ -width 6 -height 12 ttk::style layout Horizontal.TScale { - Scale.focus -expand 1 -sticky nswe -children { - Horizontal.Scale.trough -expand 1 -sticky nswe -children { + Scale.focus -sticky nswe -children { + Horizontal.Scale.trough -sticky nswe -children { Horizontal.Scale.track -sticky we Horizontal.Scale.slider -side left -sticky {} } @@ -214,8 +214,8 @@ namespace eval ttk::theme::vista { TRACKBAR 6 {disabled 5 focus 4 pressed 3 active 2 {} 1} \ -width 12 -height 6 ttk::style layout Vertical.TScale { - Scale.focus -expand 1 -sticky nswe -children { - Vertical.Scale.trough -expand 1 -sticky nswe -children { + Scale.focus -sticky nswe -children { + Vertical.Scale.trough -sticky nswe -children { Vertical.Scale.track -sticky ns Vertical.Scale.slider -side top -sticky {} } diff --git a/macosx/README b/macosx/README index 9745d14..1c603df 100644 --- a/macosx/README +++ b/macosx/README @@ -272,20 +272,24 @@ appearance. Part of the implementation of the Dark Mode was to make some of the named NSColors have dynamic values. Apple calls these "semantic colors" because the name does not specify a specific color, but rather refers to the context in which the color should be used. -Tk now provides the following semantic colors as system colors: -systemTextColor, systemTextBackgroundColor, systemSelectedTextColor, -systemSelectedTextBackgroundColor, systemControlTextColor, -systemDisabledControlTextColor, systemLabelColor, systemLinkColor, and -systemControlAccentColor. All of these except the last three were -present in OSX 10.0 (and those three are simulated in systems where they -do not exist). The change in 10.14 was that the RGB color value of -these colors became dynamic, meaning that the color value can change -when the application appearance changes. In particular, when a user -selects Dark Mode in the system preferences these colors change -appearance. For example systemTextColor is dark in Aqua and light in -DarkAqua. One additional color, systemSelectedTabTextColor, does not -exist in macOS but is used by Tk to match the different colors used -for Notebook tab text in different OS versions. +In particular, when a user selects Dark Mode in the system preferences +these colors change appearance. For example systemTextColor is dark in +Aqua and light in DarkAqua. + +Tk now provides colors corresponding to all of the NSColors in Apple's System +ColorList. The convention for naming these colors is that the Tk name is +generated by capitalizing the macOS name and adding the prefix "system". The +System ColorList differs between releases of macOS and some colors, such as +systemLinkColor and systemControlAccentColor, are simulated on older systems +which did not provide them. The following colors are available on all +supported macOS releases, although newer systems will support additional +colors: systemControlAccentColor, systemControlTextColor, +systemDisabledControlTextColor, systemLabelColor, systemLinkColor, +systemPlaceholderTextColor, systemSelectedTextBackgroundColor, +systemSelectedTextColor, systemSeparatorColor, systemTextBackgroundColor, and +systemTextColor. One additional color, systemSelectedTabTextColor, does not +exist in macOS but is used by Tk to match the different colors used for +Notebook tab titles in different OS versions. The default background and foreground colors of most of the Tk widgets have been set to semantic colors, which means that the widgets will change diff --git a/macosx/tkMacOSXBitmap.c b/macosx/tkMacOSXBitmap.c index c1b325a..213d925 100644 --- a/macosx/tkMacOSXBitmap.c +++ b/macosx/tkMacOSXBitmap.c @@ -136,7 +136,7 @@ PixmapFromImage( Pixmap pixmap; pixmap = Tk_GetPixmap(display, None, size.width, size.height, 0); - if (TkMacOSXSetupDrawingContext(pixmap, NULL, 1, &dc)) { + if (TkMacOSXSetupDrawingContext(pixmap, NULL, &dc)) { if (dc.context) { CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1, .tx = 0, .ty = size.height}; diff --git a/macosx/tkMacOSXButton.c b/macosx/tkMacOSXButton.c index 9f60b91..857ce34 100644 --- a/macosx/tkMacOSXButton.c +++ b/macosx/tkMacOSXButton.c @@ -744,7 +744,7 @@ TkMacOSXDrawButton( ButtonBackgroundDrawCB(&cntrRect, mbPtr, 32, true); - if (!TkMacOSXSetupDrawingContext(pixmap, dpPtr->gc, 1, &dc)) { + if (!TkMacOSXSetupDrawingContext(pixmap, dpPtr->gc, &dc)) { return; } @@ -777,7 +777,7 @@ TkMacOSXDrawButton( ButtonContentDrawCB(&contHIRec, mbPtr->btnkind, &mbPtr->drawinfo, (MacButton *) mbPtr, 32, true); } else { - if (!TkMacOSXSetupDrawingContext(pixmap, dpPtr->gc, 1, &dc)) { + if (!TkMacOSXSetupDrawingContext(pixmap, dpPtr->gc, &dc)) { return; } diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index 537290e..ee333cf 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -23,6 +23,7 @@ static Tcl_HashTable systemColors; static int numSystemColors; static int rgbColorIndex; static int controlAccentIndex; +static int selectedTabTextIndex; static Bool useFakeAccentColor = NO; static SystemColorDatum **systemColorIndex; #if MAC_OS_X_VERSION_MAX_ALLOWED >= 101400 @@ -66,7 +67,7 @@ void initColorTable() if (![NSColor respondsToSelector:colorSelector]) { if ([colorName isEqualToString:@"controlAccentColor"]) { useFakeAccentColor = YES; - } else { + } else if (![colorName isEqualToString:@"selectedTabTextColor"]) { /* Uncomment to print all unsupported colors: */ /* printf("Unsupported color %s\n", colorName.UTF8String); */ continue; @@ -143,6 +144,9 @@ void initColorTable() hPtr = Tcl_FindHashEntry(&systemColors, "ControlAccentColor"); entry = (SystemColorDatum *) Tcl_GetHashValue(hPtr); controlAccentIndex = entry->index; + hPtr = Tcl_FindHashEntry(&systemColors, "SelectedTabTextColor"); + entry = (SystemColorDatum *) Tcl_GetHashValue(hPtr); + selectedTabTextIndex = entry->index; [pool drain]; } @@ -314,10 +318,19 @@ GetRGBA( #if MAC_OS_X_VERSION_MAX_ALLOWED < 101500 color = [[NSColor colorForControlTint: [NSColor currentControlTint]] colorUsingColorSpace:sRGB]; + [color getComponents: rgba]; #endif - } else { - color = [[NSColor valueForKey:entry->selector] colorUsingColorSpace:sRGB]; + break; + } + if (entry->index == selectedTabTextIndex) { + int OSVersion = [NSApp macOSVersion]; + if (OSVersion > 100600 && OSVersion < 110000) { + color = [NSColor whiteColor]; + [color getComponents: rgba]; + break; + } } + color = [[NSColor valueForKey:entry->selector] colorUsingColorSpace:sRGB]; [color getComponents: rgba]; break; case clearColor: diff --git a/macosx/tkMacOSXColor.h b/macosx/tkMacOSXColor.h index 58f8060..7449095 100644 --- a/macosx/tkMacOSXColor.h +++ b/macosx/tkMacOSXColor.h @@ -175,12 +175,8 @@ static SystemColorDatum systemColorData[] = { {"WindowBackgroundColor7", ttkBackground, 7, NULL, 0, NULL }, /* Apple's SecondaryLabelColor is the same as their LabelColor so we roll our own. */ {"SecondaryLabelColor", ttkBackground, 14, NULL, 0, NULL }, -/* Color to use for notebook tab labels. */ -#if MAC_OS_X_VERSION_MAX_ALLOWED > 1060 -{"SelectedTabTextColor", semantic, 0, "whiteColor", 0, NULL }, -#else -{"SelectedTabTextColor", semantic, 0, "blackColor", 0, NULL }, -#endif +/* Color to use for notebook tab labels -- depends on OS version. */ +{"SelectedTabTextColor", semantic, 0, "textColor", 0, NULL }, /* Semantic colors that we simulate on older systems which don't supoort them. */ {"SelectedMenuItemTextColor", semantic, 0, "selectedMenuItemTextColor", 0, NULL }, {"ControlAccentColor", semantic, 0, "controlAccentColor", 0, NULL }, diff --git a/macosx/tkMacOSXDefault.h b/macosx/tkMacOSXDefault.h index a71fbf2..8a6546f 100644 --- a/macosx/tkMacOSXDefault.h +++ b/macosx/tkMacOSXDefault.h @@ -193,7 +193,7 @@ #define DEF_ENTRY_INSERT_WIDTH "1" #define DEF_ENTRY_JUSTIFY "left" #define DEF_ENTRY_PLACEHOLDER "" -#define DEF_ENTRY_PLACEHOLDERFG "#b3b3b3" +#define DEF_ENTRY_PLACEHOLDERFG "systemPlaceholderTextColor" #define DEF_ENTRY_READONLY_BG_COLOR NORMAL_BG #define DEF_ENTRY_READONLY_BG_MONO WHITE #define DEF_ENTRY_RELIEF "sunken" diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c index 8bc949b..aabe103 100644 --- a/macosx/tkMacOSXDraw.c +++ b/macosx/tkMacOSXDraw.c @@ -250,7 +250,7 @@ XCopyArea( return BadDrawable; } - if (!TkMacOSXSetupDrawingContext(dst, gc, 1, &dc)) { + if (!TkMacOSXSetupDrawingContext(dst, gc, &dc)) { TkMacOSXDbgMsg("Failed to setup drawing context."); return BadDrawable; } @@ -332,7 +332,7 @@ XCopyPlane( Tcl_Panic("Unexpected plane specified for XCopyPlane"); } if (srcDraw->flags & TK_IS_PIXMAP) { - if (!TkMacOSXSetupDrawingContext(dst, gc, 1, &dc)) { + if (!TkMacOSXSetupDrawingContext(dst, gc, &dc)) { return BadDrawable; } @@ -753,7 +753,7 @@ XDrawLines( } display->request++; - if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { + if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) { return BadDrawable; } if (dc.context) { @@ -821,7 +821,7 @@ XDrawSegments( int i, lw = gc->line_width; display->request++; - if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { + if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) { return BadDrawable; } if (dc.context) { @@ -873,7 +873,7 @@ XFillPolygon( int i; display->request++; - if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { + if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) { return BadDrawable; } if (dc.context) { @@ -935,7 +935,7 @@ XDrawRectangle( } display->request++; - if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { + if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) { return BadDrawable; } if (dc.context) { @@ -978,18 +978,18 @@ XDrawRectangle( int XDrawRectangles( Display *display, - Drawable drawable, + Drawable d, GC gc, XRectangle *rectArr, int nRects) { - MacDrawable *macWin = (MacDrawable *) drawable; + MacDrawable *macWin = (MacDrawable *) d; TkMacOSXDrawingContext dc; XRectangle * rectPtr; int i, lw = gc->line_width; display->request++; - if (!TkMacOSXSetupDrawingContext(drawable, gc, 1, &dc)) { + if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) { return BadDrawable; } if (dc.context) { @@ -1041,7 +1041,7 @@ XFillRectangles( int i; display->request++; - if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { + if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) { return BadDrawable; } if (dc.context) { @@ -1094,7 +1094,7 @@ TkMacOSXDrawSolidBorder( TkMacOSXDrawingContext dc; CGRect outerRect, innerRect; - if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { + if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) { return; } if (dc.context) { @@ -1146,7 +1146,7 @@ XDrawArc( } display->request++; - if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { + if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) { return BadDrawable; } if (dc.context) { @@ -1216,7 +1216,7 @@ XDrawArcs( int i, lw = gc->line_width; display->request++; - if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { + if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) { return BadDrawable; } if (dc.context) { @@ -1297,7 +1297,7 @@ XFillArc( } display->request++; - if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { + if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) { return BadDrawable; } if (dc.context) { @@ -1370,7 +1370,7 @@ XFillArcs( int i, lw = gc->line_width; display->request++; - if (!TkMacOSXSetupDrawingContext(d, gc, 1, &dc)) { + if (!TkMacOSXSetupDrawingContext(d, gc, &dc)) { return BadDrawable; } if (dc.context) { @@ -1551,15 +1551,17 @@ TkMacOSXSetUpGraphicsPort( * * TkMacOSXSetUpDrawingContext -- * - * Set up a drawing context for the given drawable and GC. + * Set up a drawing context for the given drawable from an X GC. * * Results: - * Boolean indicating whether it is ok to draw; if false, drawing context - * was not setup, so do not attempt to draw and do not call + * Boolean indicating whether it is ok to draw; if false, the drawing + * context was not setup, so do not attempt to draw and do not call * TkMacOSXRestoreDrawingContext(). * * Side effects: - * None. + * May modify or create the drawable's graphics context. May expand the + * drawable's dirty rectangle. When the result is true The dcPtr + * parameter is set to reference the new or updated drawing context. * *---------------------------------------------------------------------- */ @@ -1568,26 +1570,28 @@ Bool TkMacOSXSetupDrawingContext( Drawable d, GC gc, - TCL_UNUSED(int), TkMacOSXDrawingContext *dcPtr) { MacDrawable *macDraw = (MacDrawable *) d; Bool canDraw = true; - NSWindow *win = NULL; + TKContentView *view = nil; TkMacOSXDrawingContext dc = {}; - CGRect clipBounds; /* - * If the drawable is not a pixmap and it has an associated NSWindow then - * we know we are drawing to a window. + * If the drawable is not a pixmap, get the associated NSView. */ if (!(macDraw->flags & TK_IS_PIXMAP)) { - win = TkMacOSXDrawableWindow(d); + view = (TKContentView *) TkMacOSXDrawableView(macDraw); + if (!view) { + Tcl_Panic("TkMacOSXSetupDrawingContext(): " + "no NSView to draw into !"); + } } /* - * Check that we have a non-empty clipping region. + * Intersect the drawable's clipping region with the region stored in the + * X GC. If the resulting region is empty, don't do any drawing. */ dc.clipRgn = TkMacOSXGetClipRgn(d); @@ -1598,173 +1602,158 @@ TkMacOSXSetupDrawingContext( } /* - * If we already have a CGContext, use it. Otherwise, if we are drawing to - * a window then we can get one from the window. + * If the drawable already has a CGContext, use it. Otherwise, we must be + * drawing to a window and we use the current context of its ContentView. */ dc.context = TkMacOSXGetCGContextForDrawable(d); if (dc.context) { - dc.portBounds = clipBounds = CGContextGetClipBoundingBox(dc.context); - } else if (win) { - TKContentView *view = (TKContentView *)TkMacOSXDrawableView(macDraw); + dc.portBounds = CGContextGetClipBoundingBox(dc.context); + } else { + NSRect drawingBounds, currentBounds; - if (!view) { - Tcl_Panic("TkMacOSXSetupDrawingContext(): " - "no NSView to draw into !"); - } + dc.view = view; + dc.context = GET_CGCONTEXT; + dc.portBounds = NSRectToCGRect([view bounds]); if (dc.clipRgn) { + CGRect clipBounds; CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1, .tx = 0, .ty = [view bounds].size.height}; HIShapeGetBounds(dc.clipRgn, &clipBounds); clipBounds = CGRectApplyAffineTransform(clipBounds, t); + drawingBounds = NSRectFromCGRect(clipBounds); + } else { + drawingBounds = [view bounds]; } - if (view != [NSView focusView]) { - /* - * We can only draw into the view when the current CGContext is - * valid and belongs to the view. Validity can only be guaranteed - * inside of a view's drawRect or setFrame methods. The isDrawing - * attribute tells us whether we are being called from drawRect. - * If the CGContext is not valid then we mark our view as needing - * display. - */ + /* + * We can only draw into the NSView which is the current focusView. + * When the current [NSView focusView] is nil, the CGContext for + * [NSGraphicsContext currentContext] is nil. Otherwise the current + * CGContext draws into the current focusView. An NSView is guaranteed + * to be the focusView when its drawRect or setFrame methods are + * running. Prior to OSX 10.14 it was also possible to call the + * lockFocus method to force an NSView to become the current focusView. + * But that method was deprecated in 10.14 and so is no longer used by + * Tk. Instead, if the view is not the current focusView then we add + * the drawing bounds to its dirty rectangle and return false. The + * part of the view inside the drawing bounds will get redrawn during + * the next call to its drawRect method. + */ - if (dc.clipRgn) { - [view addTkDirtyRect:NSRectFromCGRect(clipBounds)]; - } else { - [view addTkDirtyRect:[view bounds]]; - } + if (view != [NSView focusView]) { + [view addTkDirtyRect:drawingBounds]; canDraw = false; goto end; - } else if (dc.clipRgn) { - - /* - * Drawing will also fail if we are being called from drawRect but - * the clipping rectangle set by drawRect does not contain the - * clipping region of our drawing context. See bug [2a61eca3a8]. - * If we can't draw all of the clipping region of the drawing - * context then we draw whatever we can, but we also add a dirty - * rectangle so the entire widget will get redrawn in the next - * cycle. - */ - - CGRect currentClip = CGContextGetClipBoundingBox(GET_CGCONTEXT); - if (!NSContainsRect(currentClip, clipBounds)) { - [view addTkDirtyRect:clipBounds]; - } } - dc.view = view; - dc.context = GET_CGCONTEXT; - dc.portBounds = NSRectToCGRect([view bounds]); - if (dc.clipRgn) { - clipBounds = CGContextGetClipBoundingBox(dc.context); + /* + * Drawing will also fail when the view is the current focusView but + * the clipping rectangle set by drawRect does not contain the clipping + * region of our drawing context. (See bug [2a61eca3a8].) If part of + * the drawing bounds will be clipped then we draw whatever we can, but + * we also add the drawing bounds to the view's dirty rectangle so it + * will get redrawn in the next call to its drawRect method. + */ + + currentBounds = CGContextGetClipBoundingBox(dc.context); + if (!NSContainsRect(currentBounds, drawingBounds)) { + [view addTkDirtyRect:drawingBounds]; } - } else { - Tcl_Panic("TkMacOSXSetupDrawingContext(): " - "no context to draw into !"); } /* - * Configure the drawing context. + * Finish configuring the drawing context. */ - if (dc.context) { - CGAffineTransform t = { - .a = 1, .b = 0, - .c = 0, .d = -1, - .tx = 0, - .ty = dc.portBounds.size.height - }; + CGAffineTransform t = { + .a = 1, .b = 0, + .c = 0, .d = -1, + .tx = 0, + .ty = dc.portBounds.size.height + }; - dc.portBounds.origin.x += macDraw->xOff; - dc.portBounds.origin.y += macDraw->yOff; - CGContextSaveGState(dc.context); - CGContextSetTextDrawingMode(dc.context, kCGTextFill); - CGContextConcatCTM(dc.context, t); - if (dc.clipRgn) { + dc.portBounds.origin.x += macDraw->xOff; + dc.portBounds.origin.y += macDraw->yOff; + CGContextSaveGState(dc.context); + CGContextSetTextDrawingMode(dc.context, kCGTextFill); + CGContextConcatCTM(dc.context, t); + if (dc.clipRgn) { #ifdef TK_MAC_DEBUG_DRAWING - CGContextSaveGState(dc.context); - ChkErr(HIShapeReplacePathInCGContext, dc.clipRgn, dc.context); - CGContextSetRGBFillColor(dc.context, 1.0, 0.0, 0.0, 0.1); - CGContextEOFillPath(dc.context); - CGContextRestoreGState(dc.context); + CGContextSaveGState(dc.context); + ChkErr(HIShapeReplacePathInCGContext, dc.clipRgn, dc.context); + CGContextSetRGBFillColor(dc.context, 1.0, 0.0, 0.0, 0.1); + CGContextEOFillPath(dc.context); + CGContextRestoreGState(dc.context); #endif /* TK_MAC_DEBUG_DRAWING */ - CGRect r; + CGRect r; + CGRect b = CGRectApplyAffineTransform( + CGContextGetClipBoundingBox(dc.context), t); + if (!HIShapeIsRectangular(dc.clipRgn) || + !CGRectContainsRect(*HIShapeGetBounds(dc.clipRgn, &r), b)) { + ChkErr(HIShapeReplacePathInCGContext, dc.clipRgn, dc.context); + CGContextEOClip(dc.context); + } + } + if (gc) { + static const CGLineCap cgCap[] = { + [CapNotLast] = kCGLineCapButt, + [CapButt] = kCGLineCapButt, + [CapRound] = kCGLineCapRound, + [CapProjecting] = kCGLineCapSquare, + }; + static const CGLineJoin cgJoin[] = { + [JoinMiter] = kCGLineJoinMiter, + [JoinRound] = kCGLineJoinRound, + [JoinBevel] = kCGLineJoinBevel, + }; + bool shouldAntialias = !notAA(gc->line_width); + double w = gc->line_width; - if (!HIShapeIsRectangular(dc.clipRgn) || !CGRectContainsRect( - *HIShapeGetBounds(dc.clipRgn, &r), - CGRectApplyAffineTransform(clipBounds, t))) { - ChkErr(HIShapeReplacePathInCGContext, dc.clipRgn, dc.context); - CGContextEOClip(dc.context); - } + TkMacOSXSetColorInContext(gc, gc->foreground, dc.context); + if (view) { + CGContextSetPatternPhase(dc.context, CGSizeMake( + dc.portBounds.size.width, dc.portBounds.size.height)); } - if (gc) { - static const CGLineCap cgCap[] = { - [CapNotLast] = kCGLineCapButt, - [CapButt] = kCGLineCapButt, - [CapRound] = kCGLineCapRound, - [CapProjecting] = kCGLineCapSquare, - }; - static const CGLineJoin cgJoin[] = { - [JoinMiter] = kCGLineJoinMiter, - [JoinRound] = kCGLineJoinRound, - [JoinBevel] = kCGLineJoinBevel, - }; - bool shouldAntialias; - double w = gc->line_width; - - TkMacOSXSetColorInContext(gc, gc->foreground, dc.context); - if (win) { - CGContextSetPatternPhase(dc.context, CGSizeMake( - dc.portBounds.size.width, dc.portBounds.size.height)); - } - if (gc->function != GXcopy) { - TkMacOSXDbgMsg("Logical functions other than GXcopy are " - "not supported for CG drawing!"); - } + if (gc->function != GXcopy) { + TkMacOSXDbgMsg("Logical functions other than GXcopy are " + "not supported for CG drawing!"); + } + if (!shouldAntialias) { /* - * When should we antialias? + * Make non-antialiased CG drawing look more like X11. */ - shouldAntialias = !notAA(gc->line_width); - if (!shouldAntialias) { - /* - * Make non-antialiased CG drawing look more like X11. - */ - - w -= (gc->line_width ? NON_AA_CG_OFFSET : 0); - } - CGContextSetShouldAntialias(dc.context, shouldAntialias); - CGContextSetLineWidth(dc.context, w); - if (gc->line_style != LineSolid) { - int num = 0; - char *p = &gc->dashes; - CGFloat dashOffset = gc->dash_offset; - dashOffset -= (gc->line_width % 2) ? 0.5 : 0.0; - CGFloat lengths[10]; - - while (p[num] != '\0' && num < 10) { - lengths[num] = p[num]; - num++; - } - CGContextSetLineDash(dc.context, dashOffset, lengths, num); - } - if ((unsigned) gc->cap_style < sizeof(cgCap)/sizeof(CGLineCap)) { - CGContextSetLineCap(dc.context, - cgCap[(unsigned) gc->cap_style]); - } - if ((unsigned)gc->join_style < sizeof(cgJoin)/sizeof(CGLineJoin)) { - CGContextSetLineJoin(dc.context, - cgJoin[(unsigned) gc->join_style]); + w -= (gc->line_width ? NON_AA_CG_OFFSET : 0); + } + CGContextSetShouldAntialias(dc.context, shouldAntialias); + CGContextSetLineWidth(dc.context, w); + if (gc->line_style != LineSolid) { + int num = 0; + char *p = &gc->dashes; + CGFloat dashOffset = gc->dash_offset; + dashOffset -= (gc->line_width % 2) ? 0.5 : 0.0; + CGFloat lengths[10]; + + while (p[num] != '\0' && num < 10) { + lengths[num] = p[num]; + num++; } + CGContextSetLineDash(dc.context, dashOffset, lengths, num); + } + if ((unsigned) gc->cap_style < sizeof(cgCap)/sizeof(CGLineCap)) { + CGContextSetLineCap(dc.context, cgCap[(unsigned) gc->cap_style]); + } + if ((unsigned)gc->join_style < sizeof(cgJoin)/sizeof(CGLineJoin)) { + CGContextSetLineJoin(dc.context, cgJoin[(unsigned) gc->join_style]); } } end: + #ifdef TK_MAC_DEBUG_DRAWING if (!canDraw && win != NULL) { TkWindow *winPtr = TkMacOSXGetTkWindow(win); @@ -1775,6 +1764,7 @@ end: } } #endif + if (!canDraw && dc.clipRgn) { CFRelease(dc.clipRgn); dc.clipRgn = NULL; diff --git a/macosx/tkMacOSXEntry.c b/macosx/tkMacOSXEntry.c index 7915f6f..c6f4eea 100644 --- a/macosx/tkMacOSXEntry.c +++ b/macosx/tkMacOSXEntry.c @@ -155,7 +155,7 @@ TkpDrawEntryBorderAndFocus( bounds.origin.y = macDraw->yOff + MAC_OSX_FOCUS_WIDTH; bounds.size.width = Tk_Width(tkwin) - 2*MAC_OSX_FOCUS_WIDTH; bounds.size.height = Tk_Height(tkwin) - 2*MAC_OSX_FOCUS_WIDTH; - if (!TkMacOSXSetupDrawingContext(d, NULL, 1, &dc)) { + if (!TkMacOSXSetupDrawingContext(d, NULL, &dc)) { /* * No graphics context is available. If the widget is a Spinbox, we @@ -265,7 +265,7 @@ TkpDrawSpinboxButtons( rects[0].height = Tk_Height(tkwin); XFillRectangles(Tk_Display(tkwin), d, bgGC, rects, 1); - if (!TkMacOSXSetupDrawingContext(d, NULL, 1, &dc)) { + if (!TkMacOSXSetupDrawingContext(d, NULL, &dc)) { return 0; } ChkErr(HIThemeDrawButton, &bounds, &info, dc.context, HIOrientation, NULL); diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c index 0aab1cf..4ad9118 100644 --- a/macosx/tkMacOSXFont.c +++ b/macosx/tkMacOSXFont.c @@ -1204,7 +1204,7 @@ TkpDrawAngledCharsInContext( if (rangeStart < 0 || rangeLength <= 0 || rangeStart + rangeLength > numBytes || - !TkMacOSXSetupDrawingContext(drawable, gc, 1, &drawingContext)) { + !TkMacOSXSetupDrawingContext(drawable, gc, &drawingContext)) { return; } string = [[TKNSString alloc] initWithTclUtfBytes:source length:numBytes]; diff --git a/macosx/tkMacOSXHLEvents.c b/macosx/tkMacOSXHLEvents.c index e2ff0f1..3b65681 100644 --- a/macosx/tkMacOSXHLEvents.c +++ b/macosx/tkMacOSXHLEvents.c @@ -229,7 +229,7 @@ static const char* scriptTextProc = "::tk::mac::DoScriptText"; AEInfo->interp = _eventInterp; AEInfo->procedure = openDocumentProc; AEInfo->replyEvent = nil; - Tcl_DoWhenIdle(ProcessAppleEvent, (ClientData)AEInfo); + Tcl_DoWhenIdle(ProcessAppleEvent, AEInfo); } - (void) handlePrintDocumentsEvent: (NSAppleEventDescriptor *)event @@ -248,7 +248,7 @@ static const char* scriptTextProc = "::tk::mac::DoScriptText"; AEInfo->interp = _eventInterp; AEInfo->procedure = printDocProc; AEInfo->replyEvent = nil; - Tcl_DoWhenIdle(ProcessAppleEvent, (ClientData)AEInfo); + Tcl_DoWhenIdle(ProcessAppleEvent, AEInfo); } - (void) handleDoScriptEvent: (NSAppleEventDescriptor *)event @@ -309,7 +309,7 @@ static const char* scriptTextProc = "::tk::mac::DoScriptText"; AEInfo->interp = _eventInterp; AEInfo->procedure = scriptFileProc; AEInfo->replyEvent = nil; - Tcl_DoWhenIdle(ProcessAppleEvent, (ClientData)AEInfo); + Tcl_DoWhenIdle(ProcessAppleEvent, AEInfo); } } } else if (noErr == AEGetParamPtr(theDesc, keyDirectObject, typeUTF8Text, &type, @@ -334,10 +334,10 @@ static const char* scriptTextProc = "::tk::mac::DoScriptText"; AEInfo->procedure = scriptTextProc; if (Tcl_FindCommand(AEInfo->interp, AEInfo->procedure, NULL, 0)) { AEInfo->replyEvent = replyEvent; - ProcessAppleEvent((ClientData)AEInfo); + ProcessAppleEvent(AEInfo); } else { AEInfo->replyEvent = nil; - Tcl_DoWhenIdle(ProcessAppleEvent, (ClientData)AEInfo); + Tcl_DoWhenIdle(ProcessAppleEvent, AEInfo); } } } @@ -360,7 +360,7 @@ static const char* scriptTextProc = "::tk::mac::DoScriptText"; AEInfo->interp = _eventInterp; AEInfo->procedure = launchURLProc; AEInfo->replyEvent = nil; - Tcl_DoWhenIdle(ProcessAppleEvent, (ClientData)AEInfo); + Tcl_DoWhenIdle(ProcessAppleEvent, AEInfo); } @end diff --git a/macosx/tkMacOSXImage.c b/macosx/tkMacOSXImage.c index 5440d03..4aea52c 100644 --- a/macosx/tkMacOSXImage.c +++ b/macosx/tkMacOSXImage.c @@ -565,7 +565,7 @@ XPutImage( MacDrawable *macDraw = (MacDrawable *) drawable; display->request++; - if (!TkMacOSXSetupDrawingContext(drawable, gc, 1, &dc)) { + if (!TkMacOSXSetupDrawingContext(drawable, gc, &dc)) { return BadDrawable; } if (dc.context) { diff --git a/macosx/tkMacOSXMenubutton.c b/macosx/tkMacOSXMenubutton.c index 8eed4f0..2fad3cb 100644 --- a/macosx/tkMacOSXMenubutton.c +++ b/macosx/tkMacOSXMenubutton.c @@ -560,7 +560,7 @@ TkMacOSXDrawMenuButton( static HIThemeButtonDrawInfo hiinfo; MenuButtonBackgroundDrawCB(mbPtr, 32, true); - if (!TkMacOSXSetupDrawingContext(pixmap, dpPtr->gc, 1, &dc)) { + if (!TkMacOSXSetupDrawingContext(pixmap, dpPtr->gc, &dc)) { return; } @@ -591,7 +591,7 @@ TkMacOSXDrawMenuButton( MenuButtonContentDrawCB(mbPtr->btnkind, &mbPtr->drawinfo, mbPtr, 32, true); } else { - if (!TkMacOSXSetupDrawingContext(pixmap, dpPtr->gc, 1, &dc)) { + if (!TkMacOSXSetupDrawingContext(pixmap, dpPtr->gc, &dc)) { return; } TkMacOSXRestoreDrawingContext(&dc); @@ -703,7 +703,7 @@ MenuButtonEventProc( mbPtr->flags &= ~ACTIVE; } if ((buttonPtr->flags & REDRAW_PENDING) == 0) { - Tcl_DoWhenIdle(TkpDisplayMenuButton, (ClientData) buttonPtr); + Tcl_DoWhenIdle(TkpDisplayMenuButton, buttonPtr); buttonPtr->flags |= REDRAW_PENDING; } } diff --git a/macosx/tkMacOSXNotify.c b/macosx/tkMacOSXNotify.c index a4f971f..3247ade 100644 --- a/macosx/tkMacOSXNotify.c +++ b/macosx/tkMacOSXNotify.c @@ -13,10 +13,10 @@ * of this file, and for a DISCLAIMER OF ALL WARRANTIES. */ +#include <tclInt.h> #include "tkMacOSXPrivate.h" #include "tkMacOSXInt.h" #include "tkMacOSXConstants.h" -#include <tclInt.h> #import <objc/objc-auto.h> /* This is not used for anything at the moment. */ diff --git a/macosx/tkMacOSXPrivate.h b/macosx/tkMacOSXPrivate.h index 168ee22..711c3d4 100644 --- a/macosx/tkMacOSXPrivate.h +++ b/macosx/tkMacOSXPrivate.h @@ -263,7 +263,7 @@ MODULE_SCOPE void TkMacOSXDrawCGImage(Drawable d, GC gc, CGContextRef cont unsigned long imageBackground, CGRect imageBounds, CGRect srcBounds, CGRect dstBounds); MODULE_SCOPE int TkMacOSXSetupDrawingContext(Drawable d, GC gc, - int useCG, TkMacOSXDrawingContext *dcPtr); + TkMacOSXDrawingContext *dcPtr); MODULE_SCOPE void TkMacOSXRestoreDrawingContext( TkMacOSXDrawingContext *dcPtr); MODULE_SCOPE void TkMacOSXSetColorInContext(GC gc, unsigned long pixel, diff --git a/macosx/tkMacOSXRegion.c b/macosx/tkMacOSXRegion.c index 0a5ff6d..59eca6c 100644 --- a/macosx/tkMacOSXRegion.c +++ b/macosx/tkMacOSXRegion.c @@ -12,6 +12,16 @@ */ #include "tkMacOSXPrivate.h" +static void RetainRegion(TkRegion r); +static void ReleaseRegion(TkRegion r); + +#ifdef DEBUG +static int totalRegions = 0; +static int totalRegionRetainCount = 0; +#define DebugLog(msg, ...) fprintf(stderr, (msg), ##__VA_ARGS__) +#else +#define DebugLog(msg, ...) +#endif /* @@ -34,7 +44,10 @@ Region XCreateRegion(void) { - return (Region) HIShapeCreateMutable(); + Region region = (Region) HIShapeCreateMutable(); + DebugLog("Created region: total regions = %d\n", ++totalRegions); + RetainRegion(region); + return region; } /* @@ -59,7 +72,8 @@ XDestroyRegion( Region r) { if (r) { - CFRelease(r); + DebugLog("Destroyed region: total regions = %d\n", --totalRegions); + ReleaseRegion(r); } return Success; } @@ -320,7 +334,7 @@ TkpBuildRegionFromAlphaData( /* *---------------------------------------------------------------------- * - * TkpRetainRegion -- + * RetainRegion -- * * Increases reference count of region. * @@ -333,17 +347,18 @@ TkpBuildRegionFromAlphaData( *---------------------------------------------------------------------- */ -void -TkpRetainRegion( +static void +RetainRegion( Region r) { CFRetain(r); + DebugLog("Retained region: total count is %d\n", ++totalRegionRetainCount); } /* *---------------------------------------------------------------------- * - * TkpReleaseRegion -- + * ReleaseRegion -- * * Decreases reference count of region. * @@ -356,11 +371,12 @@ TkpRetainRegion( *---------------------------------------------------------------------- */ -void -TkpReleaseRegion( +static void +ReleaseRegion( Region r) { CFRelease(r); + DebugLog("Released region: total count is %d\n", --totalRegionRetainCount); } /* diff --git a/macosx/tkMacOSXScrlbr.c b/macosx/tkMacOSXScrlbr.c index 3f73b18..06e0402 100644 --- a/macosx/tkMacOSXScrlbr.c +++ b/macosx/tkMacOSXScrlbr.c @@ -263,7 +263,7 @@ TkpDisplayScrollbar( if ((view == NULL) || (macWin->flags & TK_DO_NOT_DRAW) - || !TkMacOSXSetupDrawingContext((Drawable) macWin, NULL, 1, &dc)) { + || !TkMacOSXSetupDrawingContext((Drawable) macWin, NULL, &dc)) { return; } diff --git a/macosx/tkMacOSXSubwindows.c b/macosx/tkMacOSXSubwindows.c index e1e57bb..41dea01 100644 --- a/macosx/tkMacOSXSubwindows.c +++ b/macosx/tkMacOSXSubwindows.c @@ -874,7 +874,7 @@ TkMacOSXUpdateClipRgn( visRgn = TkMacOSXGetNativeRegion(r); ChkErr(HIShapeIntersect, visRgn, rgn, rgn); CFRelease(visRgn); - TkpReleaseRegion(r); + TkDestroyRegion(r); } /* diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index 7c60418..cd2a5d3 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -737,7 +737,7 @@ TkWmNewWindow( * window manager. */ - Tk_ManageGeometry((Tk_Window) winPtr, &wmMgrType, (ClientData) 0); + Tk_ManageGeometry((Tk_Window) winPtr, &wmMgrType, NULL); } /* diff --git a/macosx/tkMacOSXXStubs.c b/macosx/tkMacOSXXStubs.c index f1ac020..6b18bfb 100644 --- a/macosx/tkMacOSXXStubs.c +++ b/macosx/tkMacOSXXStubs.c @@ -308,7 +308,6 @@ XkbOpenDisplay( return display; } - /* *---------------------------------------------------------------------- @@ -878,8 +877,7 @@ XForceScreenSaver( display->request++; return Success; } - -#if 0 + int XSetClipRectangles( Display *d, @@ -888,24 +886,22 @@ XSetClipRectangles( int clip_y_origin, XRectangle* rectangles, int n, - int ordering) + TCL_UNUSED(int)) { - Region clipRgn = XCreateRegion(); + TkRegion clipRgn = TkCreateRegion(); while (n--) { - XRectangle rect = *rectangles; + XRectangle rect = *rectangles; - rect.x += clip_x_origin; - rect.y += clip_y_origin; - XUnionRectWithRegion(&rect, clipRgn, clipRgn); - rectangles++; + rect.x += clip_x_origin; + rect.y += clip_y_origin; + TkUnionRectWithRegion(&rect, clipRgn, clipRgn); + rectangles++; } - XSetRegion(d, gc, clipRgn); - XDestroyRegion(clipRgn); + TkSetRegion(d, gc, clipRgn); + TkDestroyRegion(clipRgn); return 1; } -#endif - /* *---------------------------------------------------------------------- * diff --git a/macosx/ttkMacOSXTheme.c b/macosx/ttkMacOSXTheme.c index 2510575..a98e55e 100644 --- a/macosx/ttkMacOSXTheme.c +++ b/macosx/ttkMacOSXTheme.c @@ -39,7 +39,7 @@ #define BEGIN_DRAWING(d) { \ TkMacOSXDrawingContext dc; \ - if (!TkMacOSXSetupDrawingContext((d), NULL, 1, &dc)) {return;} + if (!TkMacOSXSetupDrawingContext((d), NULL, &dc)) {return;} #define END_DRAWING \ TkMacOSXRestoreDrawingContext(&dc);} @@ -1174,10 +1174,10 @@ static void DrawDarkListHeader( CGContextSetStrokeColorSpace(context, deviceRGB.CGColorSpace); CGFloat x = bounds.origin.x, y = bounds.origin.y; CGFloat w = bounds.size.width, h = bounds.size.height; - CGPoint top[2] = {{x, y}, {x + w, y}}; - CGPoint bottom[2] = {{x, y + h}, {x + w, y + h}}; - CGPoint separator[2] = {{x + w, y + 3}, {x + w, y + h - 3}}; + CGPoint top[2] = {{x, y + 1}, {x + w, y + 1}}; + CGPoint bottom[2] = {{x, y + h}, {x + w, y + h}}; + CGPoint separator[2] = {{x + w - 1, y + 3}, {x + w - 1, y + h - 3}}; CGContextSaveGState(context); CGContextSetShouldAntialias(context, false); stroke = [NSColor colorWithColorSpace: deviceRGB @@ -1702,7 +1702,7 @@ static Ttk_ElementOptionSpec EntryElementOptions[] = { offsetof(EntryElement, backgroundObj), ENTRY_DEFAULT_BACKGROUND}, {"-fieldbackground", TK_OPTION_BORDER, offsetof(EntryElement, fieldbackgroundObj), ENTRY_DEFAULT_BACKGROUND}, - {0} + {NULL, TK_OPTION_BOOLEAN, 0, NULL} }; static void EntryElementSize( @@ -2062,7 +2062,7 @@ static Ttk_ElementOptionSpec TrackElementOptions[] = { {"-to", TK_OPTION_DOUBLE, offsetof(TrackElement, toObj), NULL}, {"-value", TK_OPTION_DOUBLE, offsetof(TrackElement, valueObj), NULL}, {"-orient", TK_OPTION_STRING, offsetof(TrackElement, orientObj), NULL}, - {0, 0, 0, NULL} + {NULL, TK_OPTION_BOOLEAN, 0, NULL} }; static void TrackElementSize( void *clientData, @@ -2202,7 +2202,7 @@ static Ttk_ElementOptionSpec PbarElementOptions[] = { offsetof(PbarElement, phaseObj), "0"}, {"-mode", TK_OPTION_STRING, offsetof(PbarElement, modeObj), "determinate"}, - {0, 0, 0, 0} + {NULL, TK_OPTION_BOOLEAN, 0, NULL} }; static void PbarElementSize( TCL_UNUSED(void *), @@ -2292,7 +2292,7 @@ typedef struct static Ttk_ElementOptionSpec ScrollbarElementOptions[] = { {"-orient", TK_OPTION_STRING, offsetof(ScrollbarElement, orientObj), "horizontal"}, - {0, 0, 0, 0} + {NULL, TK_OPTION_BOOLEAN, 0, NULL} }; static void TroughElementSize( TCL_UNUSED(void *), @@ -2810,7 +2810,7 @@ typedef struct { static Ttk_ElementOptionSpec FieldElementOptions[] = { {"-fieldbackground", TK_OPTION_BORDER, offsetof(FieldElement, backgroundObj), "white"}, - {NULL, 0, 0, NULL} + {NULL, TK_OPTION_BOOLEAN, 0, NULL} }; static void FieldElementDraw( @@ -3050,20 +3050,20 @@ TTK_LAYOUT("TCombobox", /* Notebook tabs -- no focus ring */ TTK_LAYOUT("Tab", TTK_GROUP("Notebook.tab", TTK_FILL_BOTH, - TTK_GROUP("Notebook.padding", TTK_EXPAND | TTK_FILL_BOTH, - TTK_NODE("Notebook.label", TTK_EXPAND | TTK_FILL_BOTH)))) + TTK_GROUP("Notebook.padding", TTK_FILL_BOTH, + TTK_NODE("Notebook.label", TTK_FILL_BOTH)))) /* Spinbox -- buttons 2px to the right of the field. */ TTK_LAYOUT("TSpinbox", TTK_GROUP("Spinbox.buttons", TTK_PACK_RIGHT, TTK_NODE("Spinbox.uparrow", TTK_PACK_TOP | TTK_STICK_E) TTK_NODE("Spinbox.downarrow", TTK_PACK_BOTTOM | TTK_STICK_E)) - TTK_GROUP("Spinbox.field", TTK_EXPAND | TTK_FILL_X, - TTK_NODE("Spinbox.textarea", TTK_EXPAND | TTK_FILL_X))) + TTK_GROUP("Spinbox.field", TTK_FILL_X, + TTK_NODE("Spinbox.textarea", TTK_FILL_X))) /* Progress bars -- track only */ TTK_LAYOUT("TProgressbar", - TTK_NODE("Progressbar.track", TTK_EXPAND | TTK_FILL_BOTH)) + TTK_NODE("Progressbar.track", TTK_FILL_BOTH)) /* Treeview -- no border. */ TTK_LAYOUT("Treeview", @@ -3088,15 +3088,13 @@ TTK_LAYOUT("Item", TTK_LAYOUT("Vertical.TScrollbar", TTK_GROUP("Vertical.Scrollbar.trough", TTK_FILL_Y, - TTK_NODE("Vertical.Scrollbar.thumb", - TTK_PACK_TOP | TTK_EXPAND | TTK_FILL_BOTH) + TTK_NODE("Vertical.Scrollbar.thumb", TTK_FILL_BOTH) TTK_NODE("Vertical.Scrollbar.downarrow", TTK_PACK_BOTTOM) TTK_NODE("Vertical.Scrollbar.uparrow", TTK_PACK_BOTTOM))) TTK_LAYOUT("Horizontal.TScrollbar", TTK_GROUP("Horizontal.Scrollbar.trough", TTK_FILL_X, - TTK_NODE("Horizontal.Scrollbar.thumb", - TTK_PACK_LEFT | TTK_EXPAND | TTK_FILL_BOTH) + TTK_NODE("Horizontal.Scrollbar.thumb", TTK_FILL_BOTH) TTK_NODE("Horizontal.Scrollbar.rightarrow", TTK_PACK_RIGHT) TTK_NODE("Horizontal.Scrollbar.leftarrow", TTK_PACK_RIGHT))) diff --git a/tests/canvas.test b/tests/canvas.test index e5e5ac9..46c745a 100644 --- a/tests/canvas.test +++ b/tests/canvas.test @@ -354,6 +354,22 @@ test canvas-8.1 {canvas arc bbox} -setup { set arcSegBox [.c bbox arc4] list $arcBox $coordBox $pieBox $arcSegBox } -result {{48 21 100 94} {248 21 300 94} {398 21 500 112} {98 171 302 202}} +test canvas-8.2 {canvas very small arc} -setup { + catch {destroy .c} + canvas .c +} -body { + # no Inf or NaN must be generated even for very small arcs + .c create arc 0 100 0 100 -height 100 -style arc -outline "" -tags arc1 + set arcBox [.c bbox arc1] + .c create arc 0 100 0 100 -height 100 -style arc -outline blue -tags arc2 + set outlinedArcBox [.c bbox arc2] + set coords [.c coords arc1] + set start [.c itemcget arc1 -start] + set extent [.c itemcget arc1 -extent] + set width [.c itemcget arc1 -width] + set height [.c itemcget arc1 -height] + list $arcBox $outlinedArcBox $coords $start $extent $width $height +} -result {{-1 99 1 101} {-2 98 2 102} {0.0 100.0 0.0 100.0} 0.0 0.0 1.0 0.0} test canvas-9.1 {canvas id creation and deletion} -setup { catch {destroy .c} @@ -1004,112 +1020,6 @@ test canvas-20.3 {tag deletion - all tags match} -setup { destroy .c } -result {{tagA tagA tagA tagA tagA tagA} {}} -# Procedure used in test cases 20.1 20.2 20.3 -proc matchPixels {pixels expected} { - set matched 1 - foreach pline $pixels eline $expected { - foreach ppixel $pline epixel $eline { - if {$ppixel != $epixel} { - set matched 0 - break - } - } - } - return $matched -} - -test canvas-20.1 {canvas image} -setup { - canvas .c - image create photo testimage -} -body { - .c configure -background #c0c0c0 -scrollregion {0 0 9 9} - .c create rectangle 0 0 0 9 -fill #000080 -outline #000080 - .c image testimage - matchPixels [testimage data] { \ - {#000080 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ - {#000080 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ - {#000080 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ - {#000080 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ - {#000080 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ - {#000080 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ - {#000080 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ - {#000080 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ - {#000080 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ - {#000080 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0}} -} -cleanup { - destroy .c - image delete testimage -} -result 1 - -test canvas-20.2 {canvas image with subsample} -setup { - canvas .c - image create photo testimage -} -body { - .c configure -background #c0c0c0 -scrollregion {0 0 9 9} - .c create rectangle 0 0 1 9 -fill #008000 -outline #008000 - .c image testimage 2 - matchPixels [testimage data] { \ - {#008000 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ - {#008000 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ - {#008000 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ - {#008000 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ - {#008000 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0}} -} -cleanup { - destroy .c - image delete testimage -} -result 1 - -test canvas-20.3 {canvas image with subsample and zoom} -setup { - canvas .c - image create photo testimage -} -body { - .c configure -background #c0c0c0 -scrollregion {0 0 9 9} - .c create rectangle 0 0 9 0 -fill #800000 -outline #800000 - .c image testimage 1 2 - matchPixels [testimage data] { \ - {#800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000} \ - {#800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000} \ - {#c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ - {#c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ - {#c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ - {#c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ - {#c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ - {#c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ - {#c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ - {#c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ - {#c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ - {#c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ - {#c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ - {#c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ - {#c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ - {#c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ - {#c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ - {#c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ - {#c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ - {#c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0}} -} -cleanup { - destroy .c - image delete testimage -} -result 1 - -test canvas-21.1 {canvas very small arc} -setup { - catch {destroy .c} - canvas .c -} -body { - # no Inf or NaN must be generated even for very small arcs - .c create arc 0 100 0 100 -height 100 -style arc -outline "" -tags arc1 - set arcBox [.c bbox arc1] - .c create arc 0 100 0 100 -height 100 -style arc -outline blue -tags arc2 - set outlinedArcBox [.c bbox arc2] - set coords [.c coords arc1] - set start [.c itemcget arc1 -start] - set extent [.c itemcget arc1 -extent] - set width [.c itemcget arc1 -width] - set height [.c itemcget arc1 -height] - list $arcBox $outlinedArcBox $coords $start $extent $width $height -} -result {{-1 99 1 101} {-2 98 2 102} {0.0 100.0 0.0 100.0} 0.0 0.0 1.0 0.0} - - destroy .c test canvas-21.1 {canvas rotate} -setup { pack [canvas .c] @@ -1292,7 +1202,95 @@ test canvas-22.9 {canvas rotate: window item rotation behaviour} -setup { } -cleanup { destroy .c } -result {{50.00 150.00} {} {25 125 50 150}} - + +# Procedure used in test cases 23.1 23.2 23.3 +proc matchPixels {pixels expected} { + set matched 1 + foreach pline $pixels eline $expected { + foreach ppixel $pline epixel $eline { + if {$ppixel != $epixel} { + set matched 0 + break + } + } + } + return $matched +} + +test canvas-23.1 {canvas image} -setup { + canvas .c + image create photo testimage +} -body { + .c configure -background #c0c0c0 -scrollregion {0 0 9 9} + .c create rectangle 0 0 0 9 -fill #000080 -outline #000080 + .c image testimage + matchPixels [testimage data] { \ + {#000080 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ + {#000080 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ + {#000080 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ + {#000080 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ + {#000080 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ + {#000080 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ + {#000080 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ + {#000080 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ + {#000080 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ + {#000080 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0}} +} -cleanup { + destroy .c + image delete testimage +} -result 1 + +test canvas-23.2 {canvas image with subsample} -setup { + canvas .c + image create photo testimage +} -body { + .c configure -background #c0c0c0 -scrollregion {0 0 9 9} + .c create rectangle 0 0 1 9 -fill #008000 -outline #008000 + .c image testimage 2 + matchPixels [testimage data] { \ + {#008000 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ + {#008000 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ + {#008000 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ + {#008000 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ + {#008000 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0}} +} -cleanup { + destroy .c + image delete testimage +} -result 1 + +test canvas-23.3 {canvas image with subsample and zoom} -setup { + canvas .c + image create photo testimage +} -body { + .c configure -background #c0c0c0 -scrollregion {0 0 9 9} + .c create rectangle 0 0 9 0 -fill #800000 -outline #800000 + .c image testimage 1 2 + matchPixels [testimage data] { \ + {#800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000} \ + {#800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000 #800000} \ + {#c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ + {#c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ + {#c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ + {#c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ + {#c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ + {#c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ + {#c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ + {#c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ + {#c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ + {#c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ + {#c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ + {#c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ + {#c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ + {#c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ + {#c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ + {#c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ + {#c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0} \ + {#c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0 #c0c0c0}} +} -cleanup { + destroy .c + image delete testimage +} -result 1 + # cleanup imageCleanup cleanupTests diff --git a/tests/dialog.test b/tests/dialog.test index 3ca5146..692d928 100644 --- a/tests/dialog.test +++ b/tests/dialog.test @@ -60,7 +60,7 @@ test dialog-2.3 {tk_dialog operation} -body { return $res } -cleanup { destroy .b -} -result {-1} +} -result -1 cleanupTests return diff --git a/tests/font.test b/tests/font.test index aa7137a..28ac799 100644 --- a/tests/font.test +++ b/tests/font.test @@ -1681,14 +1681,14 @@ destroy .t.f pack [label .t.f] update test font-27.1 {Tk_UnderlineTextLayout procedure: no underline chosen} -body { - .t.f config -text "foo" -under -1 + .t.f config -text "foo" -underline -1 } -result {} test font-27.2 {Tk_UnderlineTextLayout procedure: underline not visible} -body { .t.f config -text "000 00000" -wrap [expr $ax*7] -under 10 } -result {} test font-27.3 {Tk_UnderlineTextLayout procedure: underline is visible} -body { .t.f config -text "000 00000" -wrap [expr $ax*7] -under 5 - .t.f config -wrap -1 -under -1 + .t.f config -wrap -1 -underline -1 } -result {} destroy .t.f diff --git a/tests/grab.test b/tests/grab.test index 653d756..0be5b61 100644 --- a/tests/grab.test +++ b/tests/grab.test @@ -107,7 +107,7 @@ test grab-2.1 {Tk_GrabObjCmd, grab status gives correct status} -body { grab status . } -cleanup { grab release . -} -result {none} +} -result none test grab-2.2 {Tk_GrabObjCmd, grab status gives correct status} -body { set curr [grab current .] if { [string length $curr] > 0 } { diff --git a/tests/imgPhoto.test b/tests/imgPhoto.test index 782a210..9c33738 100644 --- a/tests/imgPhoto.test +++ b/tests/imgPhoto.test @@ -951,7 +951,7 @@ test imgPhoto-4.75 {<photo> read command: filename starting with '-'} -constrain image delete photo1 file delete ./-teapotPhotoFile } -result {} -test imgPhoto-4.76 {ImgPhotoCmd procedure: copy to same image} -constraints { +test imgPhoto-4.75.1 {ImgPhotoCmd procedure: copy to same image} -constraints { hasTeapotPhoto } -setup { imageCleanup @@ -963,7 +963,7 @@ test imgPhoto-4.76 {ImgPhotoCmd procedure: copy to same image} -constraints { } -cleanup { imageCleanup } -result {} -test imgPhoto-4.76 {ImgPhotoCmd, transparancy get: too many options} -setup { +test imgPhoto-4.76 {ImgPhotoCmd, transparency get: too many options} -setup { image create photo photo1 } -body { photo1 put white -to 0 0 1 1 @@ -1941,9 +1941,9 @@ test imgPhoto-19.8 {MatchStirngFormat: invalid data for gif} -setup { } -returnCodes error -result {couldn't recognize image data} # Reject corrupted or truncated image [Bug b601ce3ab1]. -# WARNING - tests 18.1-18.9 will cause a segfault on 8.5.19 and lower, +# WARNING - tests 20.1-20.9 will cause a segfault on 8.5.19 and lower, # and on 8.6.6 and lower. -test imgPhoto-18.1 {Reject corrupted GIF (binary string)} -setup { +test imgPhoto-20.1 {Reject corrupted GIF (binary string)} -setup { set data [binary decode base64 { R0lGODlhAAQABP8zM/8z/zP/MzP/////M////yH5CiwheLrcLTBCd6Tv2qW16tdK4jhV 5qpraXIvM1JlNyAgOw== @@ -1953,7 +1953,7 @@ test imgPhoto-18.1 {Reject corrupted GIF (binary string)} -setup { } -cleanup { catch {image delete gif1} } -returnCodes error -result {error reading color map|not enough free memory for image buffer} -match regexp -test imgPhoto-18.2 {Reject corrupted GIF (base 64 string)} -setup { +test imgPhoto-20.2 {Reject corrupted GIF (base 64 string)} -setup { set data { R0lGODlhAAQABP8zM/8z/zP/MzP/////M////yH5CiwheLrcLTBCd6Tv2qW16tdK4jhV 5qpraXIvM1JlNyAgOw== @@ -1963,14 +1963,14 @@ test imgPhoto-18.2 {Reject corrupted GIF (base 64 string)} -setup { } -cleanup { catch {image delete gif1} } -returnCodes error -result {error reading color map|not enough free memory for image buffer} -match regexp -test imgPhoto-18.3 {Reject corrupted GIF (file)} -setup { +test imgPhoto-20.3 {Reject corrupted GIF (file)} -setup { set fileName [file join [file dirname [info script]] corruptMangled.gif] } -body { image create photo gif1 -file $fileName } -cleanup { catch {image delete gif1} } -returnCodes error -result {error reading color map|not enough free memory for image buffer} -match regexp -test imgPhoto-18.4 {Reject truncated GIF (binary string)} -setup { +test imgPhoto-20.4 {Reject truncated GIF (binary string)} -setup { set data [binary decode base64 { R0lGODlhEAAQAMIHAAAAADMz//8zM/8z/zP/MzP///8= }] @@ -1979,7 +1979,7 @@ test imgPhoto-18.4 {Reject truncated GIF (binary string)} -setup { } -cleanup { catch {image delete gif1} } -returnCodes error -result {error reading color map} -test imgPhoto-18.5 {Reject truncated GIF (base 64 string)} -setup { +test imgPhoto-20.5 {Reject truncated GIF (base 64 string)} -setup { set data { R0lGODlhEAAQAMIHAAAAADMz//8zM/8z/zP/MzP///8= } @@ -1988,14 +1988,14 @@ test imgPhoto-18.5 {Reject truncated GIF (base 64 string)} -setup { } -cleanup { catch {image delete gif1} } -returnCodes error -result {error reading color map} -test imgPhoto-18.6 {Reject truncated GIF (file)} -setup { +test imgPhoto-20.6 {Reject truncated GIF (file)} -setup { set fileName [file join [file dirname [info script]] corruptTruncated.gif] } -body { image create photo gif1 -file $fileName } -cleanup { catch {image delete gif1} } -returnCodes error -result {error reading color map} -test imgPhoto-18.7 {Reject corrupted GIF (> 4Gb) (binary string)} -constraints { +test imgPhoto-20.7 {Reject corrupted GIF (> 4Gb) (binary string)} -constraints { nonPortable } -setup { # About the non portability constraint of this test: see ticket [cc42cc18a5] @@ -2011,7 +2011,7 @@ test imgPhoto-18.7 {Reject corrupted GIF (> 4Gb) (binary string)} -constraints { } -cleanup { catch {image delete gif1} } -returnCodes error -result {error reading color map|not enough free memory for image buffer} -match regexp -test imgPhoto-18.8 {Reject corrupted GIF (> 4Gb) (base 64 string)} -constraints { +test imgPhoto-20.8 {Reject corrupted GIF (> 4Gb) (base 64 string)} -constraints { nonPortable } -setup { # About the non portability constraint of this test: see ticket [cc42cc18a5] @@ -2027,7 +2027,7 @@ test imgPhoto-18.8 {Reject corrupted GIF (> 4Gb) (base 64 string)} -constraints } -cleanup { catch {image delete gif1} } -returnCodes error -result {error reading color map|not enough free memory for image buffer} -match regexp -test imgPhoto-18.9 {Reject corrupted GIF (> 4Gb) (file)} -constraints { +test imgPhoto-20.9 {Reject corrupted GIF (> 4Gb) (file)} -constraints { nonPortable } -setup { # About the non portability constraint of this test: see ticket [cc42cc18a5] @@ -2040,10 +2040,10 @@ test imgPhoto-18.9 {Reject corrupted GIF (> 4Gb) (file)} -constraints { } -cleanup { catch {image delete gif1} } -returnCodes error -result {error reading color map|not enough free memory for image buffer} -match regexp -test imgPhoto-18.10 {Valid GIF (binary string)} -setup { +test imgPhoto-20.10 {Valid GIF (binary string)} -setup { # Test the binary string reader with a valid GIF. # This is not tested elsewhere. - # Tests 18.11, 18.12, with matching data, are included for completeness. + # Tests 20.11, 20.12, with matching data, are included for completeness. set data [binary decode base64 { R0lGODlhEAAQAMIHAAAAADMz//8zM/8z/zP/MzP/////M////yH5BAEKAAcALAAA AAAQABAAAAMheLrcLTBCd6QV79qlterXB0riOFXmmapraXIvM1IdZTcJADs= @@ -2053,7 +2053,7 @@ test imgPhoto-18.10 {Valid GIF (binary string)} -setup { } -cleanup { catch {image delete gif1} } -result gif1 -test imgPhoto-18.11 {Valid GIF (base 64 string)} -setup { +test imgPhoto-20.11 {Valid GIF (base 64 string)} -setup { set data { R0lGODlhEAAQAMIHAAAAADMz//8zM/8z/zP/MzP/////M////yH5BAEKAAcALAAA AAAQABAAAAMheLrcLTBCd6QV79qlterXB0riOFXmmapraXIvM1IdZTcJADs= @@ -2063,7 +2063,7 @@ test imgPhoto-18.11 {Valid GIF (base 64 string)} -setup { } -cleanup { catch {image delete gif1} } -result gif1 -test imgPhoto-18.12 {Valid GIF (file)} -setup { +test imgPhoto-20.12 {Valid GIF (file)} -setup { set fileName [file join [file dirname [info script]] red.gif] } -body { image create photo gif1 -file $fileName diff --git a/tests/listbox.test b/tests/listbox.test index 3520f99..9b667cd 100644 --- a/tests/listbox.test +++ b/tests/listbox.test @@ -718,7 +718,7 @@ test listbox-3.60 {ListboxWidgetCmd procedure, "index" option} -body { } -result 2 test listbox-3.61 {ListboxWidgetCmd procedure, "index" option} -body { .l index -1 -} -result {-1} +} -result -1 test listbox-3.62 {ListboxWidgetCmd procedure, "index" option} -body { .l index end } -result 18 @@ -2132,7 +2132,7 @@ test listbox-10.19 {GetListboxIndex procedure} -setup { .l index -1 } -cleanup { destroy .l -} -result -1 +} -result -1 test listbox-10.20 {GetListboxIndex procedure} -setup { destroy .l } -body { diff --git a/tests/menuDraw.test b/tests/menuDraw.test index 9382974..bf15f25 100644 --- a/tests/menuDraw.test +++ b/tests/menuDraw.test @@ -561,7 +561,7 @@ test menuDraw-15.2 {TkPostTearoffMenu - Deactivation} -setup { $tearoff index active } -cleanup { deleteWindows -} -result {none} +} -result none test menuDraw-15.3 {TkPostTearoffMenu - post command} -setup { deleteWindows } -body { diff --git a/tests/scale.test b/tests/scale.test index 2c3a8c2..18b78f8 100644 --- a/tests/scale.test +++ b/tests/scale.test @@ -1135,26 +1135,26 @@ test scale-14.5 {RoundValueToResolution procedure} -body { -orient horizontal -resolution 4.0 update .s get 84 152 -} -result {-28} +} -result -28 test scale-14.6 {RoundValueToResolution procedure} -body { .s configure -from -100 -to 0 -sliderlength 10 -length 114 -bd 2 \ -orient horizontal -resolution 4.0 update .s get 86 152 -} -result {-24} +} -result -24 test scale-14.7 {RoundValueToResolution procedure} -body { .s configure -from 0 -to -100 -sliderlength 10 -length 114 -bd 2 \ -orient horizontal -resolution 4.0 update .s get 84 152 -} -result {-72} +} -result -72 test scale-14.8 {RoundValueToResolution procedure} -body { .s configure -from 0 -to -100 -sliderlength 10 -length 114 -bd 2 \ -orient horizontal -resolution 4.0 update .s get 86 152 -} -result {-76} +} -result -76 test scale-14.9 {RoundValueToResolution procedure} -body { .s configure -from 0 -to 2.25 -sliderlength 10 -length 114 -bd 2 \ @@ -1226,7 +1226,7 @@ test scale-15.1 {ScaleVarProc procedure} -setup { scale .s -from 0 -to -200 -variable y -orient horizontal -length 150 pack .s return $y -} -result {-130} +} -result -130 test scale-15.2 {ScaleVarProc procedure} -setup { deleteWindows } -body { @@ -1235,7 +1235,7 @@ test scale-15.2 {ScaleVarProc procedure} -setup { pack .s set y -87 .s get -} -result {-87} +} -result -87 test scale-15.3 {ScaleVarProc procedure} -setup { deleteWindows } -body { @@ -1256,7 +1256,7 @@ test scale-15.4 {ScaleVarProc procedure} -setup { .s get } -cleanup { deleteWindows -} -result {-130} +} -result -130 test scale-15.5 {ScaleVarProc procedure} -setup { deleteWindows } -body { diff --git a/tests/scrollbar.test b/tests/scrollbar.test index 873e564..ea34f1d 100644 --- a/tests/scrollbar.test +++ b/tests/scrollbar.test @@ -341,7 +341,7 @@ test scrollbar-3.49 {ScrollbarWidgetCmd procedure, "identify" option} { test scrollbar-3.50.1 {ScrollbarWidgetCmd procedure, "identify" option} notAqua { .s identify 5 5 } {arrow1} -test scrollbar-3.50.1 {ScrollbarWidgetCmd procedure, "identify" option} aqua { +test scrollbar-3.50.2 {ScrollbarWidgetCmd procedure, "identify" option} aqua { # macOS scrollbars have no arrows nowadays .s identify 5 5 } {trough1} diff --git a/tests/spinbox.test b/tests/spinbox.test index e3c7009..070337d 100644 --- a/tests/spinbox.test +++ b/tests/spinbox.test @@ -714,7 +714,7 @@ test spinbox-1.61 {configuration option: "repeatinterval"} -setup { .e cget -repeatinterval } -cleanup { destroy .e -} -result {-500} +} -result -500 test spinbox-1.62 {configuration option: "repeatinterval" for spinbox} -setup { spinbox .e -borderwidth 2 -highlightthickness 2 -font {Helvetica -12} \ -relief sunken diff --git a/tests/text.test b/tests/text.test index b34f6dd..3802746 100644 --- a/tests/text.test +++ b/tests/text.test @@ -1252,7 +1252,7 @@ bOy GIrl .#@? x_yz Line 7" .t configure -state disabled .t delete 2.3 - .t g 2.0 2.end + .t get 2.0 2.end } -cleanup { destroy .t } -result {abcdefghijklm} @@ -2103,7 +2103,7 @@ Line 7" .t count 5.7 5.3 } -cleanup { destroy .t -} -result {-4} +} -result -4 test text-10.7 {TextWidgetCmd procedure, "count" option} -setup { text .t .t insert 1.0 "Line 1 @@ -2598,7 +2598,7 @@ test text-10.31 {TextWidgetCmd procedure, "count" option} -setup { .t count -lines end 1.0 } -cleanup { destroy .t -} -result {-3} +} -result -3 test text-10.32 {TextWidgetCmd procedure, "count" option} -setup { text .t } -body { @@ -2648,7 +2648,7 @@ test text-10.36 {TextWidgetCmd procedure, "count" option} -setup { .t count -lines 2.7 "1.0 lineend" } -cleanup { destroy .t -} -result {-1} +} -result -1 test text-10.37 {TextWidgetCmd procedure, "count" option} -setup { text .t } -body { @@ -2691,7 +2691,7 @@ test text-10.39 {TextWidgetCmd procedure, "count" option} -setup { } -cleanup { destroy .t } -result {2 6 1 5} -test text-9.2.45 {TextWidgetCmd procedure, "count" option} -setup { +test text-10.40 {TextWidgetCmd procedure, "count" option} -setup { text .t pack .t update @@ -2707,7 +2707,7 @@ test text-9.2.45 {TextWidgetCmd procedure, "count" option} -setup { } -cleanup { destroy .t } -result 0 -test text-9.2.46 {TextWidgetCmd procedure, "count" option} -setup { +test text-10.41 {TextWidgetCmd procedure, "count" option} -setup { toplevel .mytop pack [text .mytop.t -font TkFixedFont -bd 0 -padx 0 -wrap char] set spec [font measure TkFixedFont "Line 1+++Line 1---Li"] ; # 20 chars @@ -2729,7 +2729,7 @@ test text-9.2.46 {TextWidgetCmd procedure, "count" option} -setup { } -cleanup { destroy .mytop } -result {1 3} -test text-9.2.47 {TextWidgetCmd procedure, "count" option} -setup { +test text-10.42 {TextWidgetCmd procedure, "count" option} -setup { text .t pack .t update @@ -6759,7 +6759,7 @@ test text-27.15g {No <<Selection>> virtual event on <<Cut>> without widget selec destroy .t } -result {no_<<Selection>>_event_fired} test text-27.16 {-maxundo configuration option} -body { - text .t -undo 1 -autoseparators 1 -maxundo 2 + text .t -undo 1 -autoseparators 1 -maxundo 2 pack .t .t insert end "line 1\n" .t delete 1.4 1.6 @@ -7540,100 +7540,6 @@ test text-32.4 {peer widget -start, -endline and deletion (bug 1630262)} -setup destroy .pt .t } -result {5 11 8 10 5 8 6 8 22 27 38 44 55 60 57 57} -test text-32.2 {peer widget -start, -endline and deletion (bug 1630262)} -setup { - destroy .t .pt - set res {} -} -body { - text .t - .t peer create .pt - for {set i 1} {$i < 100} {incr i} { - .t insert end "Line $i\n" - } - .t configure -startline 5 - # none of the following delete shall crash - # (all did before fixing bug 1630262) - # 1. delete on the same line: line1 == line2 in DeleteIndexRange, - # and resetView is true neither for .t not for .pt - .pt delete 2.0 2.2 - # 2. delete just one line: line1 < line2 in DeleteIndexRange, - # and resetView is true only for .t, not for .pt - .pt delete 2.0 3.0 - # 3. delete several lines: line1 < line2 in DeleteIndexRange, - # and resetView is true only for .t, not for .pt - .pt delete 2.0 5.0 - # 4. delete to the end line: line1 < line2 in DeleteIndexRange, - # and resetView is true only for .t, not for .pt - .pt delete 2.0 end - # this test succeeds provided there is no crash - set res 1 -} -cleanup { - destroy .pt -} -result 1 - -test text-32.3 {peer widget -start, -endline and deletion (bug 1630262)} -setup { - destroy .t .pt - set res {} -} -body { - text .t - .t peer create .pt - for {set i 1} {$i < 100} {incr i} { - .t insert end "Line $i\n" - } - .t configure -startline 5 - .pt configure -startline 3 - # the following delete shall not crash - # (it did before fixing bug 1630262) - .pt delete 2.0 3.0 - # moreover -startline shall be correct - # (was wrong before fixing bug 1630262) - lappend res [.t cget -start] [.pt cget -start] -} -cleanup { - destroy .pt -} -result {4 3} - -test text-32.4 {peer widget -start, -endline and deletion (bug 1630262)} -setup { - destroy .t .pt - set res {} -} -body { - text .t - .t peer create .pt - for {set i 1} {$i < 100} {incr i} { - .t insert end "Line $i\n" - } - .t configure -startline 5 -endline 15 - .pt configure -startline 8 -endline 12 - # .pt now shows a range entirely inside the range of .pt - # from .t, delete lines located after [.pt cget -end] - .t delete 9.0 10.0 - # from .t, delete lines straddling [.pt cget -end] - .t delete 6.0 9.0 - lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] - .t configure -startline 5 -endline 12 - .pt configure -startline 8 -endline 12 - # .pt now shows again a range entirely inside the range of .pt - # from .t, delete lines located before [.pt cget -start] - .t delete 2.0 3.0 - # from .t, delete lines straddling [.pt cget -start] - .t delete 2.0 5.0 - lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] - .t configure -startline 22 -endline 31 - .pt configure -startline 42 -endline 51 - # .t now shows a range entirely before the range of .pt - # from .t, delete some lines, then do it from .pt - .t delete 2.0 3.0 - .t delete 2.0 5.0 - .pt delete 2.0 5.0 - lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] - .t configure -startline 55 -endline 75 - .pt configure -startline 60 -endline 70 - # .pt now shows a range entirely inside the range of .t - # from .t, delete a range straddling the entire range of .pt - .t delete 3.0 18.0 - lappend res [.t cget -start] [.t cget -end] [.pt cget -start] [.pt cget -end] -} -cleanup { - destroy .pt .t -} -result {5 11 8 10 5 8 6 8 22 27 38 44 55 60 57 57} - test text-33.1 {TextWidgetCmd procedure, "peer" option} -setup { text .t @@ -7652,7 +7558,7 @@ test text-33.2 {TextWidgetCmd procedure, "peer" option} -setup { test text-33.3 {TextWidgetCmd procedure, "peer" option} -setup { text .t } -body { - .t pee names + .t peer names } -cleanup { destroy .t } -returnCodes {ok} -result {} @@ -7768,7 +7674,6 @@ test text-34.1 {peer widget -start, -endline and selection} -setup { test text-35.1 {widget dump -command alters tags} -setup { proc Dumpy {key value index} { -#puts "KK: $key, $value" .t tag add $value [list $index linestart] [list $index lineend] } text .t @@ -7782,7 +7687,6 @@ test text-35.1 {widget dump -command alters tags} -setup { } -result {ok} test text-35.2 {widget dump -command makes massive changes} -setup { proc Dumpy {key value index} { -#puts "KK: $key, $value" .t delete 1.0 end } text .t @@ -7796,7 +7700,6 @@ test text-35.2 {widget dump -command makes massive changes} -setup { } -result {ok} test text-35.3 {widget dump -command destroys widget} -setup { proc Dumpy {key value index} { -#puts "KK: $key, $value" destroy .t } text .t diff --git a/tests/textDisp.test b/tests/textDisp.test index aeb1a70..b797715 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -1346,11 +1346,11 @@ test textDisp-9.10 {TkTextRedrawTag} { .t insert 1.0 "Line 1\nLine 2 is long enough to wrap\nLine 3 is also long enough to wrap\nLine 4" .t tag add big 1.0 2.0 updateText - set tk_textRedraw {none} + set tk_textRedraw none .t tag add big 1.3 1.5 updateText set tk_textRedraw -} {none} +} none test textDisp-9.11 {TkTextRedrawTag} { .t configure -wrap char .t delete 1.0 end @@ -2499,8 +2499,6 @@ test textDisp-18.8 {GetXView procedure} { catch {rename bgerror {}} catch {rename bogus {}} .t configure -xscrollcommand {} -yscrollcommand scroll - -.t configure -xscrollcommand {} -yscrollcommand scroll test textDisp-19.1 {GetYView procedure} { .t configure -wrap char .t delete 1.0 end @@ -3005,7 +3003,7 @@ set res [.tt.u count -displaylines 3.10 2.173] destroy .tt unset message set res -} {-1} +} -1 .t delete 1.0 end .t insert end "Line 1" diff --git a/tests/textWind.test b/tests/textWind.test index 82d3269..4da56e5 100644 --- a/tests/textWind.test +++ b/tests/textWind.test @@ -860,7 +860,7 @@ test textWind-10.10 {EmbWinLayoutProc procedure, doesn't fit on line} -setup { } -body { .t configure -wrap char .t insert 1.0 "Some sample text" - frame .f -width 125 -height 20 -bg $color -bd 2 -relief raised + frame .f -width [expr {($tWidth-12)*$fixedWidth-1}] -height 20 -bg $color -bd 2 -relief raised .t window create 1.12 -window .f list [.t bbox .f] [.t bbox 1.13] } -cleanup { @@ -875,7 +875,7 @@ test textWind-10.11 {EmbWinLayoutProc procedure, doesn't fit on line} -setup { } -body { .t configure -wrap char .t insert 1.0 "Some sample text" - frame .f -width 126 -height 20 -bg $color -bd 2 -relief raised + frame .f -width [expr {($tWidth-12)*$fixedWidth}] -height 20 -bg $color -bd 2 -relief raised .t window create 1.12 -window .f update list [.t bbox .f] [.t bbox 1.13] @@ -891,15 +891,15 @@ test textWind-10.12 {EmbWinLayoutProc procedure, doesn't fit on line} -setup { } -body { .t configure -wrap char .t insert 1.0 "Some sample text" - frame .f -width 127 -height 20 -bg $color -bd 2 -relief raised + frame .f -width [expr {($tWidth-12)*$fixedWidth+1}] -height 20 -bg $color -bd 2 -relief raised .t window create 1.12 -window .f update list [.t bbox .f] [.t bbox 1.13] } -cleanup { destroy .f } -result [list \ - [list $padx [expr {$pady+$fixedHeight}] 127 20] \ - [list [expr {$padx+127}] [expr {$pady+$fixedHeight+((20-$fixedHeight)/2)}] $fixedWidth $fixedHeight]] + [list $padx [expr {$pady+$fixedHeight}] [expr {($tWidth-12)*$fixedWidth+1}] 20] \ + [list [expr {$padx+($tWidth-12)*$fixedWidth+1}] [expr {$pady+$fixedHeight+((20-$fixedHeight)/2)}] $fixedWidth $fixedHeight]] test textWind-10.13 {EmbWinLayoutProc procedure, doesn't fit on line} -setup { .t delete 1.0 end @@ -907,7 +907,7 @@ test textWind-10.13 {EmbWinLayoutProc procedure, doesn't fit on line} -setup { } -body { .t configure -wrap none .t insert 1.0 "Some sample text" - frame .f -width 130 -height 20 -bg $color -bd 2 -relief raised + frame .f -width [expr {($tWidth-12)*$fixedWidth+5}] -height 20 -bg $color -bd 2 -relief raised .t window create 1.12 -window .f update list [.t bbox .f] [.t bbox 1.13] @@ -923,7 +923,7 @@ test textWind-10.14 {EmbWinLayoutProc procedure, doesn't fit on line} -setup { } -body { .t configure -wrap none .t insert 1.0 "Some sample text" - frame .f -width 130 -height 220 -bg $color -bd 2 -relief raised + frame .f -width [expr {($tWidth-12)*$fixedWidth+5}] -height 220 -bg $color -bd 2 -relief raised .t window create 1.12 -window .f update list [.t bbox .f] [.t bbox 1.13] diff --git a/tests/ttk/entry.test b/tests/ttk/entry.test index a2d6016..f3174ae 100644 --- a/tests/ttk/entry.test +++ b/tests/ttk/entry.test @@ -342,6 +342,18 @@ test entry-10.2 {configuration option: "-placeholderforeground"} -setup { destroy .e } -result {red} +test entry-10.3 {styling option: "-placeholderforeground"} -setup { + pack [ttk::entry .e] +} -body { + set current [ttk::style configure TEntry -placeholderforeground] + ttk::style configure TEntry -placeholderforeground blue + set res [ttk::style configure TEntry -placeholderforeground] + ttk::style configure TEntry -placeholderforeground $current + set res +} -cleanup { + destroy .e +} -result {blue} + test entry-11.1 {Bug [2830360fff] - Don't loose invalid at focus events} -setup { pack [ttk::entry .e] update diff --git a/tests/ttk/spinbox.test b/tests/ttk/spinbox.test index 4bdabee..b5a9ab5 100644 --- a/tests/ttk/spinbox.test +++ b/tests/ttk/spinbox.test @@ -126,7 +126,7 @@ test spinbox-1.8.2 "option -validate" -setup { .sb cget -validate } -cleanup { destroy .sb -} -result {none} +} -result none test spinbox-1.8.3 "option -validate" -setup { ttk::spinbox .sb -from 0 -to 100 diff --git a/unix/tkUnixDefault.h b/unix/tkUnixDefault.h index fa1f120..b59f7ae 100644 --- a/unix/tkUnixDefault.h +++ b/unix/tkUnixDefault.h @@ -22,6 +22,7 @@ * TROUGH - Background color for troughs in scales and scrollbars. * INDICATOR - Color for indicator when button is selected. * DISABLED - Foreground color when widget is disabled. + * PLACEHOLDER_FG - Foreground color for placeholder text. */ #define BLACK "#000000" @@ -33,6 +34,7 @@ #define TROUGH "#b3b3b3" #define INDICATOR WHITE #define DISABLED "#a3a3a3" +#define PLACEHOLDER_FG "#b3b3b3" /* grey70 */ /* * Defaults for labels, buttons, checkbuttons, and radiobuttons: @@ -153,7 +155,7 @@ #define DEF_ENTRY_INSERT_WIDTH "2" #define DEF_ENTRY_JUSTIFY "left" #define DEF_ENTRY_PLACEHOLDER "" -#define DEF_ENTRY_PLACEHOLDERFG "#b3b3b3" +#define DEF_ENTRY_PLACEHOLDERFG PLACEHOLDER_FG #define DEF_ENTRY_READONLY_BG_COLOR NORMAL_BG #define DEF_ENTRY_READONLY_BG_MONO WHITE #define DEF_ENTRY_RELIEF "sunken" diff --git a/win/tkWinColor.c b/win/tkWinColor.c index 78e3b6c..ab43304 100644 --- a/win/tkWinColor.c +++ b/win/tkWinColor.c @@ -58,6 +58,7 @@ static const SystemColorEntry sysColors[] = { {"InfoText", COLOR_INFOTEXT}, {"Menu", COLOR_MENU}, {"MenuText", COLOR_MENUTEXT}, + {"PlaceHolderText", COLOR_GRAYTEXT}, {"Scrollbar", COLOR_SCROLLBAR}, {"Window", COLOR_WINDOW}, {"WindowFrame", COLOR_WINDOWFRAME}, diff --git a/win/tkWinDefault.h b/win/tkWinDefault.h index 33756f8..eaceb42 100644 --- a/win/tkWinDefault.h +++ b/win/tkWinDefault.h @@ -158,7 +158,7 @@ #define DEF_ENTRY_INSERT_WIDTH "2" #define DEF_ENTRY_JUSTIFY "left" #define DEF_ENTRY_PLACEHOLDER "" -#define DEF_ENTRY_PLACEHOLDERFG "#b3b3b3" +#define DEF_ENTRY_PLACEHOLDERFG "SystemPlaceHolderText" #define DEF_ENTRY_READONLY_BG_COLOR "SystemButtonFace" #define DEF_ENTRY_READONLY_BG_MONO WHITE #define DEF_ENTRY_RELIEF "sunken" diff --git a/win/tkWinMenu.c b/win/tkWinMenu.c index c64bd9c..ee377e2 100644 --- a/win/tkWinMenu.c +++ b/win/tkWinMenu.c @@ -1252,7 +1252,8 @@ TkWinHandleMenuEvent( hashEntryPtr = Tcl_FindHashEntry(&tsdPtr->winMenuTable, *plParam); if (hashEntryPtr != NULL) { - TkSizeT i, len, underline; + TkSizeT i, len; + int underline; Tcl_Obj *labelPtr; WCHAR *wlabel; int menuChar; @@ -1270,7 +1271,7 @@ TkWinHandleMenuEvent( for (i = 0; i < menuPtr->numEntries; i++) { underline = menuPtr->entries[i]->underline; labelPtr = menuPtr->entries[i]->labelPtr; - if ((underline != TCL_INDEX_NONE) && (labelPtr != NULL)) { + if ((underline >= 0) && (labelPtr != NULL)) { /* * Ensure we don't exceed the label length, then check */ diff --git a/win/ttkWinTheme.c b/win/ttkWinTheme.c index d181f5d..aa4dc24 100644 --- a/win/ttkWinTheme.c +++ b/win/ttkWinTheme.c @@ -746,8 +746,8 @@ TTK_LAYOUT("TButton", TTK_LAYOUT("TCombobox", TTK_GROUP("Combobox.field", TTK_FILL_BOTH, TTK_NODE("Combobox.downarrow", TTK_PACK_RIGHT|TTK_FILL_Y) - TTK_GROUP("Combobox.padding", TTK_PACK_LEFT|TTK_EXPAND|TTK_FILL_BOTH, - TTK_GROUP("Combobox.focus", TTK_PACK_LEFT|TTK_EXPAND|TTK_FILL_BOTH, + TTK_GROUP("Combobox.padding", TTK_FILL_BOTH, + TTK_GROUP("Combobox.focus", TTK_FILL_BOTH, TTK_NODE("Combobox.textarea", TTK_FILL_BOTH))))) TTK_END_LAYOUT_TABLE diff --git a/win/ttkWinXPTheme.c b/win/ttkWinXPTheme.c index 26807f7..5ab1967 100644 --- a/win/ttkWinXPTheme.c +++ b/win/ttkWinXPTheme.c @@ -919,8 +919,8 @@ TTK_LAYOUT("TButton", TTK_LAYOUT("TMenubutton", TTK_NODE("Menubutton.dropdown", TTK_PACK_RIGHT|TTK_FILL_Y) - TTK_GROUP("Menubutton.button", TTK_PACK_RIGHT|TTK_EXPAND|TTK_FILL_BOTH, - TTK_GROUP("Menubutton.padding", TTK_PACK_LEFT|TTK_EXPAND|TTK_FILL_X, + TTK_GROUP("Menubutton.button", TTK_FILL_BOTH, + TTK_GROUP("Menubutton.padding", TTK_FILL_X, TTK_NODE("Menubutton.label", 0)))) TTK_LAYOUT("Horizontal.TScrollbar", @@ -938,14 +938,14 @@ TTK_LAYOUT("Vertical.TScrollbar", TTK_NODE("Vertical.Scrollbar.grip", 0)))) TTK_LAYOUT("Horizontal.TScale", - TTK_GROUP("Scale.focus", TTK_EXPAND|TTK_FILL_BOTH, - TTK_GROUP("Horizontal.Scale.trough", TTK_EXPAND|TTK_FILL_BOTH, + TTK_GROUP("Scale.focus", TTK_FILL_BOTH, + TTK_GROUP("Horizontal.Scale.trough", TTK_FILL_BOTH, TTK_NODE("Horizontal.Scale.track", TTK_FILL_X) TTK_NODE("Horizontal.Scale.slider", TTK_PACK_LEFT) ))) TTK_LAYOUT("Vertical.TScale", - TTK_GROUP("Scale.focus", TTK_EXPAND|TTK_FILL_BOTH, - TTK_GROUP("Vertical.Scale.trough", TTK_EXPAND|TTK_FILL_BOTH, + TTK_GROUP("Scale.focus", TTK_FILL_BOTH, + TTK_GROUP("Vertical.Scale.trough", TTK_FILL_BOTH, TTK_NODE("Vertical.Scale.track", TTK_FILL_Y) TTK_NODE("Vertical.Scale.slider", TTK_PACK_TOP) ))) @@ -50,10 +50,6 @@ static TkpClipMask *AllocClipMask(GC gc) { if (clip_mask == NULL) { clip_mask = (TkpClipMask *)ckalloc(sizeof(TkpClipMask)); gc->clip_mask = (Pixmap) clip_mask; -#ifdef MAC_OSX_TK - } else if (clip_mask->type == TKP_CLIP_REGION) { - TkpReleaseRegion(clip_mask->value.region); -#endif } return clip_mask; } @@ -76,11 +72,6 @@ static TkpClipMask *AllocClipMask(GC gc) { static void FreeClipMask(GC gc) { if (gc->clip_mask != None) { -#ifdef MAC_OSX_TK - if (((TkpClipMask*) gc->clip_mask)->type == TKP_CLIP_REGION) { - TkpReleaseRegion(((TkpClipMask*) gc->clip_mask)->value.region); - } -#endif ckfree((char *)gc->clip_mask); gc->clip_mask = None; } @@ -496,9 +487,6 @@ TkSetRegion( clip_mask->type = TKP_CLIP_REGION; clip_mask->value.region = r; -#ifdef MAC_OSX_TK - TkpRetainRegion(r); -#endif } return Success; } |