diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-07-30 20:47:42 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-07-30 20:47:42 (GMT) |
commit | 980cd21d76883f8f5f4b542bf993747097a3acda (patch) | |
tree | ac738884990358e67bfd75409d6da51b715809c9 | |
parent | 8acb512c92c1b619073eac7d604ab9791ef0e713 (diff) | |
parent | b50b9471ff522194c657fe4228da646eaa8e5698 (diff) | |
download | tk-980cd21d76883f8f5f4b542bf993747097a3acda.zip tk-980cd21d76883f8f5f4b542bf993747097a3acda.tar.gz tk-980cd21d76883f8f5f4b542bf993747097a3acda.tar.bz2 |
Merge trunk
58 files changed, 638 insertions, 833 deletions
diff --git a/compat/stdlib.h b/compat/stdlib.h deleted file mode 100644 index 2c64890..0000000 --- a/compat/stdlib.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * stdlib.h -- - * - * Declares facilities exported by the "stdlib" portion of the C library. - * This file isn't complete in the ANSI-C sense; it only declares things - * that are needed by Tk. This file is needed even on many systems with - * their own stdlib.h (e.g. SunOS) because not all stdlib.h files declare - * all the procedures needed here (such as strtod). - * - * Copyright (c) 1991 The Regents of the University of California. - * Copyright (c) 1994-1998 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution of - * this file, and for a DISCLAIMER OF ALL WARRANTIES. - */ - -#ifndef _STDLIB -#define _STDLIB - -#ifndef _TCL -# include <tcl.h> -#endif - -extern void abort(void); -extern double atof(const char *string); -extern int atoi(const char *string); -extern long atol(const char *string); -extern char * calloc(unsigned int numElements, unsigned int size); -extern void exit(int status); -extern int free(char *blockPtr); -extern char * getenv(const char *name); -extern char * malloc(unsigned int numBytes); -extern void qsort(void *base, int n, int size, int (*compar)( - const void *element1, const void *element2)); -extern char * realloc(char *ptr, unsigned int numBytes); -extern double strtod(const char *string, char **endPtr); -extern long strtol(const char *string, char **endPtr, int base); -extern unsigned long strtoul(const char *string, char **endPtr, int base); - -#endif /* _STDLIB */ diff --git a/compat/unistd.h b/compat/unistd.h deleted file mode 100644 index be966cc..0000000 --- a/compat/unistd.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * unistd.h -- - * - * Macros, constants and prototypes for Posix conformance. - * - * Copyright 1989 Regents of the University of California Permission to use, - * copy, modify, and distribute this software and its documentation for any - * purpose and without fee is hereby granted, provided that the above - * copyright notice appear in all copies. The University of California makes - * no representations about the suitability of this software for any purpose. - * It is provided "as is" without express or implied warranty. - */ - -#ifndef _UNISTD -#define _UNISTD - -#include <sys/types.h> -#ifndef _TCL -# include <tcl.h> -#endif - -#ifndef NULL -#define NULL 0 -#endif - -/* - * Strict POSIX stuff goes here. Extensions go down below, in the ifndef - * _POSIX_SOURCE section. - */ - -extern void _exit(int status); -extern int access(const char *path, int mode); -extern int chdir(const char *path); -extern int chown(const char *path, uid_t owner, gid_t group); -extern int close(int fd); -extern int dup(int oldfd); -extern int dup2(int oldfd, int newfd); -extern int execl(const char *path, ...); -extern int execle(const char *path, ...); -extern int execlp(const char *file, ...); -extern int execv(const char *path, char **argv); -extern int execve(const char *path, char **argv, char **envp); -extern int execvp(const char *file, char **argv); -extern pid_t fork(void); -extern char * getcwd(char *buf, size_t size); -extern gid_t getegid(void); -extern uid_t geteuid(void); -extern gid_t getgid(void); -extern int getgroups(int bufSize, int *buffer); -extern pid_t getpid(void); -extern uid_t getuid(void); -extern int isatty(int fd); -extern long lseek(int fd, long offset, int whence); -extern int pipe(int *fildes); -extern int read(int fd, char *buf, size_t size); -extern int setgid(gid_t group); -extern int setuid(uid_t user); -extern unsigned sleep(unsigned seconds); -extern char * ttyname(int fd); -extern int unlink(const char *path); -extern int write(int fd, const char *buf, size_t size); - -#ifndef _POSIX_SOURCE -extern char * crypt(const char *, const char *); -extern int fchown(int fd, uid_t owner, gid_t group); -extern int flock(int fd, int operation); -extern int ftruncate(int fd, unsigned long length); -extern int ioctl(int fd, int request, ...); -extern int readlink(const char *path, char *buf, int bufsize); -extern int setegid(gid_t group); -extern int seteuid(uid_t user); -extern int setreuid(int ruid, int euid); -extern int symlink(const char *, const char *); -extern int ttyslot(void); -extern int truncate(const char *path, unsigned long length); -extern int vfork(void); -#endif /* _POSIX_SOURCE */ - -#endif /* _UNISTD */ - diff --git a/doc/GetScroll.3 b/doc/GetScroll.3 index c0b302d..dd12cca 100644 --- a/doc/GetScroll.3 +++ b/doc/GetScroll.3 @@ -50,18 +50,18 @@ and parses the words starting with \fIobjv\fR[2]. The words starting with \fIobjv\fR[2] must have one of the following forms: .CS \fBmoveto \fIfraction\fR -\fBscroll \fInumber\fB units\fR \fBscroll \fInumber\fB pages\fR +\fBscroll \fInumber\fB units\fR .CE .LP -Any of the \fBmoveto\fR, \fBscroll\fR, \fBunits\fR, and \fBpages\fR +Any of the \fBmoveto\fR, \fBscroll\fR, \fBpages\fR, and \fBunits\fR keywords may be abbreviated. If \fIobjv\fR has the \fBmoveto\fR form, \fBTK_SCROLL_MOVETO\fR is returned as result and \fI*fractionPtr\fR is filled in with the \fIfraction\fR argument to the command, which must be a proper real value. -If \fIobjv\fR has the \fBscroll\fR form, \fBTK_SCROLL_UNITS\fR -or \fBTK_SCROLL_PAGES\fR is returned and \fI*stepsPtr\fR is filled +If \fIobjv\fR has the \fBscroll\fR form, \fBTK_SCROLL_PAGES\fR +or \fBTK_SCROLL_UNITS\fR is returned and \fI*stepsPtr\fR is filled in with the \fInumber\fR value, which must be a proper integer. If an error occurs in parsing the arguments, \fBTK_SCROLL_ERROR\fR is returned and an error message is left in interpreter diff --git a/doc/canvas.n b/doc/canvas.n index bad9113..ddaebcf 100644 --- a/doc/canvas.n +++ b/doc/canvas.n @@ -1147,16 +1147,16 @@ total width of the canvas is off-screen to the left. This command shifts the view in the window left or right according to \fInumber\fR and \fIwhat\fR. \fINumber\fR must be an integer. -\fIWhat\fR must be either \fBunits\fR or \fBpages\fR or an abbreviation +\fIWhat\fR must be either \fBpages\fR or \fBunits\fR or an abbreviation of one of these. -If \fIwhat\fR is \fBunits\fR, the view adjusts left or right in units -of the \fBxScrollIncrement\fR option, if it is greater than zero, -or in units of one-tenth the window's width otherwise. If \fIwhat is \fBpages\fR then the view adjusts in units of nine-tenths the window's width. If \fInumber\fR is negative then information farther to the left becomes visible; if it is positive then information farther to the right becomes visible. +If \fIwhat\fR is \fBunits\fR, the view adjusts left or right in units +of the \fBxScrollIncrement\fR option, if it is greater than zero, +or in units of one-tenth the window's width otherwise. .RE .TP \fIpathName \fByview \fI?args\fR? @@ -1188,15 +1188,15 @@ area is off-screen to the top. This command adjusts the view in the window up or down according to \fInumber\fR and \fIwhat\fR. \fINumber\fR must be an integer. -\fIWhat\fR must be either \fBunits\fR or \fBpages\fR. -If \fIwhat\fR is \fBunits\fR, the view adjusts up or down in units -of the \fByScrollIncrement\fR option, if it is greater than zero, -or in units of one-tenth the window's height otherwise. +\fIWhat\fR must be either \fBpages\fR or \fBunits\fR. If \fIwhat\fR is \fBpages\fR then the view adjusts in units of nine-tenths the window's height. If \fInumber\fR is negative then higher information becomes visible; if it is positive then lower information becomes visible. +If \fIwhat\fR is \fBunits\fR, the view adjusts up or down in units +of the \fByScrollIncrement\fR option, if it is greater than zero, +or in units of one-tenth the window's height otherwise. .RE .SH "OVERVIEW OF ITEM TYPES" .PP diff --git a/doc/entry.n b/doc/entry.n index abbf53d..4589af0 100644 --- a/doc/entry.n +++ b/doc/entry.n @@ -404,14 +404,14 @@ way through the text appears at the left edge of the window. This command shifts the view in the window left or right according to \fInumber\fR and \fIwhat\fR. \fINumber\fR must be an integer. -\fIWhat\fR must be either \fBunits\fR or \fBpages\fR or an abbreviation +\fIWhat\fR must be either \fBpages\fR or \fBunits\fR or an abbreviation of one of these. -If \fIwhat\fR is \fBunits\fR, the view adjusts left or right by -\fInumber\fR average-width characters on the display; if it is -\fBpages\fR then the view adjusts by \fInumber\fR screenfuls. -If \fInumber\fR is negative then characters farther to the left -become visible; if it is positive then characters farther to the right +If \fIwhat\fR is \fBpages\fR then the view adjusts by \fInumber\fR screenfuls. +If \fInumber\fR is negative then characters farther to the left become +visible; if it is positive then characters farther to the right become visible. +If \fIwhat\fR is \fBunits\fR, the view adjusts left or right by +\fInumber\fR average-width characters on the display. .RE .SH "DEFAULT BINDINGS" .PP diff --git a/doc/listbox.n b/doc/listbox.n index 66b75b9..ef3ae1c 100644 --- a/doc/listbox.n +++ b/doc/listbox.n @@ -384,15 +384,16 @@ total width of the listbox text is off-screen to the left. This command shifts the view in the window left or right according to \fInumber\fR and \fIwhat\fR. \fINumber\fR must be an integer. -\fIWhat\fR must be either \fBunits\fR or \fBpages\fR or an abbreviation +\fIWhat\fR must be either \fBpages\fR or \fBunits\fR or an abbreviation of one of these. -If \fIwhat\fR is \fBunits\fR, the view adjusts left or right by -\fInumber\fR character units (the width of the \fB0\fR character) -on the display; if it is \fBpages\fR then the view adjusts by +If \fIwhat\fR is \fBpages\fR then the view adjusts by \fInumber\fR screenfuls. If \fInumber\fR is negative then characters farther to the left become visible; if it is positive then characters farther to the right become visible. +If \fIwhat\fR is \fBunits\fR, the view adjusts left or right by +\fInumber\fR character units (the width of the \fB0\fR character) +on the display. .RE .TP \fIpathName \fByview \fR?\fIargs\fR? @@ -431,13 +432,14 @@ way through the listbox, and so on. This command adjusts the view in the window up or down according to \fInumber\fR and \fIwhat\fR. \fINumber\fR must be an integer. -\fIWhat\fR must be either \fBunits\fR or \fBpages\fR. -If \fIwhat\fR is \fBunits\fR, the view adjusts up or down by -\fInumber\fR lines; if it is \fBpages\fR then +\fIWhat\fR must be either \fBpages\fR or \fBunits\fR. +If \fIwhat\fR is \fBpages\fR then the view adjusts by \fInumber\fR screenfuls. If \fInumber\fR is negative then earlier elements become visible; if it is positive then later elements become visible. +If \fIwhat\fR is \fBunits\fR, the view adjusts up or down by +\fInumber\fR lines. .RE .SH "DEFAULT BINDINGS" .PP diff --git a/doc/scrollbar.n b/doc/scrollbar.n index 4b1d4ba..5a062ce 100644 --- a/doc/scrollbar.n +++ b/doc/scrollbar.n @@ -215,15 +215,6 @@ document. 1.0 refers to the end of the document, 0.333 refers to a point one-third of the way through the document, and so on. .TP -\fIprefix \fBscroll \fInumber \fBunits\fR -. -The widget should adjust its view by \fInumber\fR units. -The units are defined in whatever way makes sense for the widget, -such as characters or lines in a text widget. -\fINumber\fR is either 1, which means one unit should scroll off -the top or left of the window, or \-1, which means that one unit -should scroll off the bottom or right of the window. -.TP \fIprefix \fBscroll \fInumber \fBpages\fR . The widget should adjust its view by \fInumber\fR pages. @@ -233,6 +224,15 @@ is a slight overlap between the old and new views. \fINumber\fR is either 1, which means the next page should become visible, or \-1, which means that the previous page should become visible. +.TP +\fIprefix \fBscroll \fInumber \fBunits\fR +. +The widget should adjust its view by \fInumber\fR units. +The units are defined in whatever way makes sense for the widget, +such as characters or lines in a text widget. +\fINumber\fR is either 1, which means one unit should scroll off +the top or left of the window, or \-1, which means that one unit +should scroll off the bottom or right of the window. .SH "OLD COMMAND SYNTAX" .PP In versions of Tk before 4.0, the \fBset\fR and \fBget\fR widget diff --git a/doc/spinbox.n b/doc/spinbox.n index f2b1ff2..6719ca3 100644 --- a/doc/spinbox.n +++ b/doc/spinbox.n @@ -471,14 +471,14 @@ way through the text appears at the left edge of the window. This command shifts the view in the window left or right according to \fInumber\fR and \fIwhat\fR. \fINumber\fR must be an integer. -\fIWhat\fR must be either \fBunits\fR or \fBpages\fR or an abbreviation +\fIWhat\fR must be either \fBpages\fR or \fBunits\fR or an abbreviation of one of these. -If \fIwhat\fR is \fBunits\fR, the view adjusts left or right by -\fInumber\fR average-width characters on the display; if it is -\fBpages\fR then the view adjusts by \fInumber\fR screenfuls. -If \fInumber\fR is negative then characters farther to the left +If \fIwhat\fR is \fBpages\fR then the view adjusts by \fInumber\fR +screenfuls. If \fInumber\fR is negative then characters farther to the left become visible; if it is positive then characters farther to the right become visible. +If \fIwhat\fR is \fBunits\fR, the view adjusts left or right by +\fInumber\fR average-width characters on the display. .RE .SH "DEFAULT BINDINGS" .PP @@ -1930,18 +1930,18 @@ and 1. \fIpathName \fBxview scroll \fInumber what\fR . This command shifts the view in the window left or right according to -\fInumber\fR and \fIwhat\fR. \fIWhat\fR must be \fBunits\fR, \fBpages\fR or -\fBpixels\fR. If \fIwhat\fR is \fBunits\fR or \fBpages\fR then \fInumber\fR -must be an integer, otherwise number may be specified in any of the forms -acceptable to \fBTk_GetPixels\fR, such as +\fInumber\fR and \fIwhat\fR. \fIWhat\fR must be \fBpages\fR, +\fBpixels\fR, or \fBunits\fR. If \fIwhat\fR is \fBpages\fR or +\fBunits\fR then \fInumber\fR must be an integer, otherwise number may be +specified in any of the forms acceptable to \fBTk_GetPixels\fR, such as .QW 2.0c or .QW 1i (the result is rounded to the nearest integer value. If no units are given, -pixels are assumed). If \fIwhat\fR is \fBunits\fR, the view adjusts left or -right by \fInumber\fR average-width characters on the display; if it is -\fBpages\fR then the view adjusts by \fInumber\fR screenfuls; if it is -\fBpixels\fR then the view adjusts by \fInumber\fR pixels. If \fInumber\fR is +pixels are assumed). If \fIwhat\fR is \fBpages\fR then the view adjusts by +\fInumber\fR screenfuls; if it is \fBpixels\fR then the view adjusts by +\fInumber\fR pixels; if it is \fBunits\fR, the view adjusts left or +right by \fInumber\fR average-width characters on the display. If \fInumber\fR is negative then characters farther to the left become visible; if it is positive then characters farther to the right become visible. .RE @@ -1978,10 +1978,10 @@ the bottom of the window, and some other pixel is at the top. \fIpathName \fByview scroll \fInumber what\fR . This command adjust the view in the window up or down according to -\fInumber\fR and \fIwhat\fR. \fIWhat\fR must be \fBunits\fR, \fBpages\fR or -\fBpixels\fR. If \fIwhat\fR is \fBunits\fR or \fBpages\fR then \fInumber\fR -must be an integer, otherwise number may be specified in any of the forms -acceptable to \fBTk_GetPixels\fR, such as +\fInumber\fR and \fIwhat\fR. \fIWhat\fR must be \fBpages\fR, +\fBpixels\fR, or \fBunits\fR. If \fIwhat\fR is \fBunits\fR or \fBpages\fR then +\fInumber\fR must be an integer, otherwise number may be specified in any of +the forms acceptable to \fBTk_GetPixels\fR, such as .QW 2.0c or .QW 1i diff --git a/doc/ttk_scrollbar.n b/doc/ttk_scrollbar.n index bd80760..08c7f52 100644 --- a/doc/ttk_scrollbar.n +++ b/doc/ttk_scrollbar.n @@ -118,14 +118,6 @@ document. 1.0 refers to the end of the document, 0.333 refers to a point one-third of the way through the document, and so on. .TP -\fIprefix \fBscroll \fInumber \fBunits\fR -The widget should adjust its view by \fInumber\fR units. -The units are defined in whatever way makes sense for the widget, -such as characters or lines in a text widget. -\fINumber\fR is either 1, which means one unit should scroll off -the top or left of the window, or \-1, which means that one unit -should scroll off the bottom or right of the window. -.TP \fIprefix \fBscroll \fInumber \fBpages\fR The widget should adjust its view by \fInumber\fR pages. It is up to the widget to define the meaning of a page; typically @@ -134,6 +126,14 @@ is a slight overlap between the old and new views. \fINumber\fR is either 1, which means the next page should become visible, or \-1, which means that the previous page should become visible. +.TP +\fIprefix \fBscroll \fInumber \fBunits\fR +The widget should adjust its view by \fInumber\fR units. +The units are defined in whatever way makes sense for the widget, +such as characters or lines in a text widget. +\fINumber\fR is either 1, which means one unit should scroll off +the top or left of the window, or \-1, which means that one unit +should scroll off the bottom or right of the window. .SH "WIDGET STATES" .PP The scrollbar automatically sets the \fBdisabled\fR state bit. diff --git a/doc/ttk_widget.n b/doc/ttk_widget.n index b1c280d..2dca269 100644 --- a/doc/ttk_widget.n +++ b/doc/ttk_widget.n @@ -254,14 +254,15 @@ way through the content appears at the left edge of the window. This command shifts the view in the window left or right according to \fInumber\fR and \fIwhat\fR. \fINumber\fR must be an integer. -\fIWhat\fR must be either \fBunits\fR or \fBpages\fR. +\fIWhat\fR must be either \fBpages\fR or \fBunits\fR. '\" or an abbreviation of one of these, but we don't document that. -If \fIwhat\fR is \fBunits\fR, the view adjusts left or right by -\fInumber\fR average-width characters on the display; if it is +If \fIwhat\fR is \fBpages\fR then the view adjusts by \fInumber\fR screenfuls. If \fInumber\fR is negative then characters farther to the left become visible; if it is positive then characters farther to the right become visible. +If \fIwhat\fR is \fBunits\fR, the view adjusts left or right by +\fInumber\fR average-width characters on the display. .RE .TP \fIpathName \fByview \fIargs\fR @@ -293,14 +294,15 @@ way through the content appears at the top edge of the window. This command shifts the view in the window up or down according to \fInumber\fR and \fIwhat\fR. \fINumber\fR must be an integer. -\fIWhat\fR must be either \fBunits\fR or \fBpages\fR. +\fIWhat\fR must be either \fBpages\fR or \fBunits\fR. '\" or an abbreviation of one of these, but we don't document that. -If \fIwhat\fR is \fBunits\fR, the view adjusts up or down by -\fInumber\fR average-width characters on the display; if it is +If \fIwhat\fR is \fBpages\fR then the view adjusts by \fInumber\fR screenfuls. If \fInumber\fR is negative then items farther to the top become visible; if it is positive then items farther to the bottom become visible. +If \fIwhat\fR is \fBunits\fR, the view adjusts up or down by +\fInumber\fR average-width characters on the display. .RE .SH "WIDGET STATES" The widget state is a bitmap of independent state flags. diff --git a/generic/tkBind.c b/generic/tkBind.c index 953d936..c8fbe50 100644 --- a/generic/tkBind.c +++ b/generic/tkBind.c @@ -83,7 +83,7 @@ typedef union { * Apple NSEvent object. */ -#ifndef TK_MAC_OSX +#ifdef MAC_OSX_TK #define EVENT_BUFFER_SIZE 90 #else #define EVENT_BUFFER_SIZE 30 diff --git a/generic/tkCanvas.c b/generic/tkCanvas.c index 3a1cd2a..1c70055 100644 --- a/generic/tkCanvas.c +++ b/generic/tkCanvas.c @@ -613,7 +613,7 @@ DefaultRotateImplementation( if (ItemCoords(canvasPtr, itemPtr, 0, NULL) == TCL_OK && Tcl_ListObjGetElements(NULL, Tcl_GetObjResult(interp), &objc, &objv) == TCL_OK) { - coordv = (double *) Tcl_Alloc(sizeof(double) * objc); + coordv = (double *) ckalloc(sizeof(double) * objc); for (i=0 ; i<objc ; i++) { if (Tcl_GetDoubleFromObj(NULL, objv[i], &coordv[i]) != TCL_OK) { ok = 0; @@ -639,7 +639,7 @@ DefaultRotateImplementation( * Write the coordinates back into the item. */ - newObjv = (Tcl_Obj **) Tcl_Alloc(sizeof(Tcl_Obj *) * objc); + newObjv = (Tcl_Obj **) ckalloc(sizeof(Tcl_Obj *) * objc); for (i=0 ; i<objc ; i++) { newObjv[i] = Tcl_NewDoubleObj(coordv[i]); Tcl_IncrRefCount(newObjv[i]); @@ -648,9 +648,9 @@ DefaultRotateImplementation( for (i=0 ; i<objc ; i++) { Tcl_DecrRefCount(newObjv[i]); } - Tcl_Free((char *) newObjv); + ckfree((char *) newObjv); } - Tcl_Free((char *) coordv); + ckfree((char *) coordv); } /* @@ -2891,10 +2891,21 @@ DrawCanvas( * colours and place them in the photo block. Perhaps we could * just not bother with the alpha byte because we are using * TK_PHOTO_COMPOSITE_SET later? + * ***Windows: We have to swap the red and blue values. The + * XImage storage is B - G - R - A which becomes a 32bit ARGB + * quad. However the visual mask is a 32bit ABGR quad. And + * Tk_PhotoPutBlock() wants R-G-B-A which is a 32bit ABGR quad. + * If the visual mask was correct there would be no need to + * swap anything here. */ +#ifdef _WIN32 +#define R_OFFSET 2 +#define B_OFFSET 0 +#else #define R_OFFSET 0 #define B_OFFSET 2 +#endif blockPtr.pixelPtr[blockPtr.pitch * y + blockPtr.pixelSize * x + R_OFFSET] = (unsigned char)((pixel & visualPtr->red_mask) >> rshift); blockPtr.pixelPtr[blockPtr.pitch * y + blockPtr.pixelSize * x +1] = @@ -5068,7 +5079,7 @@ CanvasBindProc( XEvent *eventPtr) /* Pointer to X event that just happened. */ { TkCanvas *canvasPtr = clientData; - int mask; + unsigned int mask; Tcl_Preserve(canvasPtr); @@ -5081,26 +5092,7 @@ CanvasBindProc( switch (eventPtr->type) { case ButtonPress: case ButtonRelease: - switch (eventPtr->xbutton.button) { - case Button1: - mask = Button1Mask; - break; - case Button2: - mask = Button2Mask; - break; - case Button3: - mask = Button3Mask; - break; - case Button4: - mask = Button4Mask; - break; - case Button5: - mask = Button5Mask; - break; - default: - mask = 0; - break; - } + mask = TkGetButtonMask(eventPtr->xbutton.button); /* * For button press events, repick the current item using the button @@ -5183,7 +5175,7 @@ PickCurrentItem( * ButtonRelease, or MotionNotify. */ { double coords[2]; - int buttonDown; + unsigned int buttonDown; Tk_Item *prevItemPtr; SearchUids *searchUids = GetStaticUids(); @@ -5194,8 +5186,7 @@ PickCurrentItem( * for windows. */ - buttonDown = canvasPtr->state - & (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask); + buttonDown = canvasPtr->state & ALL_BUTTONS; /* * Save information about this event in the canvas. The event in the diff --git a/generic/tkCanvas.h b/generic/tkCanvas.h index e2221a8..fc0ac7a 100644 --- a/generic/tkCanvas.h +++ b/generic/tkCanvas.h @@ -147,7 +147,7 @@ typedef struct TkCanvas { * currentItem is based. Must be saved so that * if the currentItem is deleted, can pick * another. */ - int state; /* Last known modifier state. Used to defer + unsigned int state; /* Last known modifier state. Used to defer * picking a new current object while buttons * are down. */ diff --git a/generic/tkEvent.c b/generic/tkEvent.c index b36d5de..f86ac36 100644 --- a/generic/tkEvent.c +++ b/generic/tkEvent.c @@ -193,7 +193,6 @@ TCL_DECLARE_MUTEX(exitMutex) static void CleanUpTkEvent(XEvent *eventPtr); static void DelayedMotionProc(ClientData clientData); -static int GetButtonMask(unsigned int Button); static unsigned long GetEventMaskFromXEvent(XEvent *eventPtr); static TkWindow * GetTkWindowFromXEvent(XEvent *eventPtr); static void InvokeClientMessageHandlers(ThreadSpecificData *tsdPtr, @@ -524,7 +523,7 @@ RefreshKeyboardMappingIfNeeded( /* *---------------------------------------------------------------------- * - * GetButtonMask -- + * TkGetButtonMask -- * * Return the proper Button${n}Mask for the button. * @@ -537,23 +536,15 @@ RefreshKeyboardMappingIfNeeded( *---------------------------------------------------------------------- */ -static int -GetButtonMask( +static const unsigned int buttonMasks[] = { + 0, Button1Mask, Button2Mask, Button3Mask, Button4Mask, Button5Mask, Button6Mask, Button7Mask, Button8Mask, Button9Mask +}; + +unsigned int +TkGetButtonMask( unsigned int button) { - switch (button) { - case 1: - return Button1Mask; - case 2: - return Button2Mask; - case 3: - return Button3Mask; - case 4: - return Button4Mask; - case 5: - return Button5Mask; - } - return 0; + return (button > Button9) ? 0 : buttonMasks[button]; } /* @@ -582,8 +573,6 @@ UpdateButtonEventState( XEvent *eventPtr) { TkDisplay *dispPtr; - int allButtonsMask = Button1Mask | Button2Mask | Button3Mask - | Button4Mask | Button5Mask; switch (eventPtr->type) { case ButtonPress: @@ -591,19 +580,19 @@ UpdateButtonEventState( dispPtr->mouseButtonWindow = eventPtr->xbutton.window; eventPtr->xbutton.state |= dispPtr->mouseButtonState; - dispPtr->mouseButtonState |= GetButtonMask(eventPtr->xbutton.button); + dispPtr->mouseButtonState |= TkGetButtonMask(eventPtr->xbutton.button); break; case ButtonRelease: dispPtr = TkGetDisplay(eventPtr->xbutton.display); dispPtr->mouseButtonWindow = None; - dispPtr->mouseButtonState &= ~GetButtonMask(eventPtr->xbutton.button); + dispPtr->mouseButtonState &= ~TkGetButtonMask(eventPtr->xbutton.button); eventPtr->xbutton.state |= dispPtr->mouseButtonState; break; case MotionNotify: dispPtr = TkGetDisplay(eventPtr->xmotion.display); - if (dispPtr->mouseButtonState & allButtonsMask) { + if (dispPtr->mouseButtonState & ALL_BUTTONS) { if (eventPtr->xbutton.window != dispPtr->mouseButtonWindow) { /* * This motion event should not be interpreted as a button @@ -611,7 +600,7 @@ UpdateButtonEventState( * button was pressed down in. */ - dispPtr->mouseButtonState &= ~allButtonsMask; + dispPtr->mouseButtonState &= ~ALL_BUTTONS; dispPtr->mouseButtonWindow = None; } else { eventPtr->xmotion.state |= dispPtr->mouseButtonState; diff --git a/generic/tkGrab.c b/generic/tkGrab.c index 917ec69..6cab469 100644 --- a/generic/tkGrab.c +++ b/generic/tkGrab.c @@ -135,17 +135,6 @@ typedef struct NewGrabWinEvent { #define GENERATED_GRAB_EVENT_MAGIC ((Bool) 0x147321ac) /* - * Mask that selects any of the state bits corresponding to buttons, plus - * masks that select individual buttons' bits: - */ - -#define ALL_BUTTONS \ - (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask) -static const unsigned int buttonStates[] = { - Button1Mask, Button2Mask, Button3Mask, Button4Mask, Button5Mask -}; - -/* * Forward declarations for functions declared later in this file: */ @@ -883,7 +872,7 @@ TkPointerEvent( } else { if (eventPtr->xbutton.button != AnyButton && ((eventPtr->xbutton.state & ALL_BUTTONS) - == buttonStates[eventPtr->xbutton.button - Button1])) { + == TkGetButtonMask(eventPtr->xbutton.button))) { ReleaseButtonGrab(dispPtr); /* Note 4. */ } } diff --git a/generic/tkInt.h b/generic/tkInt.h index 77b7725..5796103 100644 --- a/generic/tkInt.h +++ b/generic/tkInt.h @@ -965,6 +965,37 @@ typedef struct TkpClipMask { #define ALT_MASK (AnyModifier<<2) #define EXTENDED_MASK (AnyModifier<<3) +#ifndef Button8 +# define Button8 8 +#endif +#ifndef Button9 +# define Button9 9 +#endif + +#ifndef Button6Mask +# define Button6Mask (1<<13) +#endif +#ifndef Button7Mask +# define Button7Mask (1<<14) +#endif +#ifndef Button8Mask +# define Button8Mask (AnyModifier<<4) +#endif +#ifndef Button9Mask +# define Button9Mask (AnyModifier<<5) +#endif + +/* + * Mask that selects any of the state bits corresponding to buttons, plus + * masks that select individual buttons' bits: + */ + +#define ALL_BUTTONS \ + (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask|Button6Mask|Button7Mask|Button8Mask|Button9Mask) + + +MODULE_SCOPE unsigned int TkGetButtonMask(unsigned int); + /* * Object types not declared in tkObj.c need to be mentioned here so they can * be properly registered with Tcl: diff --git a/generic/tkPointer.c b/generic/tkPointer.c index 6e87638..57680c3 100644 --- a/generic/tkPointer.c +++ b/generic/tkPointer.c @@ -23,18 +23,6 @@ #define Cursor XCursor #endif -/* - * Mask that selects any of the state bits corresponding to buttons, plus - * masks that select individual buttons' bits: - */ - -#define ALL_BUTTONS \ - (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask) -static const unsigned int buttonMasks[] = { - Button1Mask, Button2Mask, Button3Mask, Button4Mask, Button5Mask -}; -#define ButtonMask(b) (buttonMasks[(b)-Button1]) - typedef struct { TkWindow *grabWinPtr; /* Window that defines the top of the grab * tree in a global grab. */ @@ -266,8 +254,8 @@ Tk_UpdatePointer( * between the current button state and the last known button state. */ - for (b = Button1; b <= Button5; b++) { - mask = ButtonMask(b); + for (b = Button1; b <= Button9; b++) { + mask = TkGetButtonMask(b); if (changes & mask) { if (state & mask) { type = ButtonPress; diff --git a/generic/tkText.c b/generic/tkText.c index 7782521..f810010 100644 --- a/generic/tkText.c +++ b/generic/tkText.c @@ -5958,7 +5958,7 @@ SearchCore( * begin. */ - matchOffset = -1; + matchOffset = TCL_INDEX_NONE; if (searchSpecPtr->exact) { int maxExtraLines = 0; @@ -6230,7 +6230,7 @@ SearchCore( if (!match || ((info.extendStart == info.matches[0].start) - && ((TkSizeT) info.matches[0].end == (TkSizeT) lastOffset - firstOffset))) { + && (info.matches[0].end == (TkSizeT) (lastOffset - firstOffset)))) { int extraLines = 0; TkSizeT prevFullLine; @@ -6248,7 +6248,7 @@ SearchCore( lastNonOverlap = lastTotal; } - if ((TkSizeT) info.extendStart == TCL_AUTO_LENGTH) { + if (info.extendStart == TCL_INDEX_NONE) { /* * No multi-line match is possible. */ @@ -6345,9 +6345,9 @@ SearchCore( */ if ((match && - firstOffset + (TkSizeT) info.matches[0].end != (TkSizeT) lastTotal && - firstOffset + (TkSizeT) info.matches[0].end + 1 < prevFullLine + 1) - || (TkSizeT) info.extendStart == TCL_AUTO_LENGTH) { + firstOffset + info.matches[0].end != (TkSizeT) lastTotal && + firstOffset + info.matches[0].end + 1 < prevFullLine + 1) + || info.extendStart == TCL_INDEX_NONE) { break; } @@ -6358,10 +6358,10 @@ SearchCore( * that line. */ - if (match && ((TkSizeT) info.matches[0].start + 1 >= (TkSizeT) lastOffset + 1)) { + if (match && (info.matches[0].start + 1 >= (TkSizeT) lastOffset + 1)) { break; } - if (match && ((firstOffset + (TkSizeT) info.matches[0].end) + if (match && ((firstOffset + info.matches[0].end) >= prevFullLine)) { if (extraLines > 0) { extraLinesSearched = extraLines - 1; @@ -6497,11 +6497,11 @@ SearchCore( * previous match. */ - if (matchOffset == TCL_AUTO_LENGTH || + if (matchOffset == TCL_INDEX_NONE || ((searchSpecPtr->all || searchSpecPtr->backwards) - && (((TkSizeT)firstOffset + 1< matchOffset + 1) - || ((firstOffset + (TkSizeT) info.matches[0].end - - (TkSizeT) info.matches[0].start) + && (((TkSizeT)firstOffset + 1 < matchOffset + 1) + || ((firstOffset + info.matches[0].end + - info.matches[0].start) > matchOffset + matchLength)))) { matchOffset = firstOffset; @@ -6665,7 +6665,7 @@ SearchCore( * we are done. */ - if ((lastBackwardsLineMatch == -1) && (matchOffset != TCL_AUTO_LENGTH) + if ((lastBackwardsLineMatch == -1) && (matchOffset != TCL_INDEX_NONE) && !searchSpecPtr->all) { searchSpecPtr->foundMatchProc(lineNum, searchSpecPtr, lineInfo, theLine, matchOffset, matchLength); diff --git a/generic/tkTextDisp.c b/generic/tkTextDisp.c index d4f6b83..33b9720 100644 --- a/generic/tkTextDisp.c +++ b/generic/tkTextDisp.c @@ -8770,10 +8770,10 @@ TextGetScrollInfoObj( VIEW_MOVETO, VIEW_SCROLL }; static const char *const units[] = { - "units", "pages", "pixels", NULL + "pages", "pixels", "units", NULL }; enum viewUnits { - VIEW_SCROLL_UNITS, VIEW_SCROLL_PAGES, VIEW_SCROLL_PIXELS + VIEW_SCROLL_PAGES, VIEW_SCROLL_PIXELS, VIEW_SCROLL_UNITS }; int index; @@ -8794,7 +8794,7 @@ TextGetScrollInfoObj( return TKTEXT_SCROLL_MOVETO; case VIEW_SCROLL: if (objc != 5) { - Tcl_WrongNumArgs(interp, 3, objv, "number units|pages|pixels"); + Tcl_WrongNumArgs(interp, 3, objv, "number pages|pixels|units"); return TKTEXT_SCROLL_ERROR; } if (Tcl_GetIndexFromObjStruct(interp, objv[4], units, diff --git a/generic/tkTextTag.c b/generic/tkTextTag.c index cb0993b..bda315e 100644 --- a/generic/tkTextTag.c +++ b/generic/tkTextTag.c @@ -1446,9 +1446,6 @@ TkTextBindProc( TkText *textPtr = clientData; int repick = 0; -# define AnyButtonMask \ - (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask) - textPtr->refCount++; /* @@ -1460,35 +1457,16 @@ TkTextBindProc( if (eventPtr->type == ButtonPress) { textPtr->flags |= BUTTON_DOWN; } else if (eventPtr->type == ButtonRelease) { - int mask; + unsigned int mask; - switch (eventPtr->xbutton.button) { - case Button1: - mask = Button1Mask; - break; - case Button2: - mask = Button2Mask; - break; - case Button3: - mask = Button3Mask; - break; - case Button4: - mask = Button4Mask; - break; - case Button5: - mask = Button5Mask; - break; - default: - mask = 0; - break; - } - if ((eventPtr->xbutton.state & AnyButtonMask) == (unsigned) mask) { + mask = TkGetButtonMask(eventPtr->xbutton.button); + if ((eventPtr->xbutton.state & ALL_BUTTONS) == mask) { textPtr->flags &= ~BUTTON_DOWN; repick = 1; } } else if ((eventPtr->type == EnterNotify) || (eventPtr->type == LeaveNotify)) { - if (eventPtr->xcrossing.state & AnyButtonMask) { + if (eventPtr->xcrossing.state & ALL_BUTTONS) { textPtr->flags |= BUTTON_DOWN; } else { textPtr->flags &= ~BUTTON_DOWN; @@ -1496,7 +1474,7 @@ TkTextBindProc( TkTextPickCurrent(textPtr, eventPtr); goto done; } else if (eventPtr->type == MotionNotify) { - if (eventPtr->xmotion.state & AnyButtonMask) { + if (eventPtr->xmotion.state & ALL_BUTTONS) { textPtr->flags |= BUTTON_DOWN; } else { textPtr->flags &= ~BUTTON_DOWN; @@ -1513,8 +1491,7 @@ TkTextBindProc( unsigned int oldState; oldState = eventPtr->xbutton.state; - eventPtr->xbutton.state &= ~(Button1Mask|Button2Mask - |Button3Mask|Button4Mask|Button5Mask); + eventPtr->xbutton.state &= ~ALL_BUTTONS; if (!(textPtr->flags & DESTROYED)) { TkTextPickCurrent(textPtr, eventPtr); } diff --git a/generic/tkUtil.c b/generic/tkUtil.c index 2950fe0..4844bc2 100644 --- a/generic/tkUtil.c +++ b/generic/tkUtil.c @@ -668,7 +668,7 @@ Tk_GetScrollInfo( if (argc != 5) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "wrong # args: should be \"%s %s %s\"", - argv[0], argv[1], "scroll number units|pages")); + argv[0], argv[1], "scroll number pages|units")); Tcl_SetErrorCode(interp, "TCL", "WRONGARGS", NULL); return TK_SCROLL_ERROR; } @@ -684,7 +684,7 @@ Tk_GetScrollInfo( } Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "bad argument \"%s\": must be units or pages", argv[4])); + "bad argument \"%s\": must be pages or units", argv[4])); Tcl_SetErrorCode(interp, "TK", "VALUE", "SCROLL_UNITS", NULL); return TK_SCROLL_ERROR; } @@ -746,7 +746,7 @@ Tk_GetScrollInfoObj( return TK_SCROLL_MOVETO; } else if (ArgPfxEq("scroll")) { if (objc != 5) { - Tcl_WrongNumArgs(interp, 2, objv, "scroll number units|pages"); + Tcl_WrongNumArgs(interp, 2, objv, "scroll number pages|units"); return TK_SCROLL_ERROR; } if (Tcl_GetIntFromObj(interp, objv[3], intPtr) != TCL_OK) { @@ -761,7 +761,7 @@ Tk_GetScrollInfoObj( } Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "bad argument \"%s\": must be units or pages", arg)); + "bad argument \"%s\": must be pages or units", arg)); Tcl_SetErrorCode(interp, "TK", "VALUE", "SCROLL_UNITS", NULL); return TK_SCROLL_ERROR; } diff --git a/generic/ttk/ttkTreeview.c b/generic/ttk/ttkTreeview.c index cf7abe1..5b5375c 100644 --- a/generic/ttk/ttkTreeview.c +++ b/generic/ttk/ttkTreeview.c @@ -1064,7 +1064,7 @@ static void TreeviewCleanup(void *recordPtr) TreeviewFreeColumns(tv); if (tv->tree.displayColumns) - Tcl_Free((ClientData)tv->tree.displayColumns); + ckfree((ClientData)tv->tree.displayColumns); foreachHashEntry(&tv->tree.items, FreeItemCB); Tcl_DeleteHashTable(&tv->tree.items); diff --git a/library/demos/twind.tcl b/library/demos/twind.tcl index 39e5110..df879e3 100644 --- a/library/demos/twind.tcl +++ b/library/demos/twind.tcl @@ -9,6 +9,14 @@ if {![info exists widgetDemo]} { package require Tk +# Make an Aqua button's fill color match its parent's background +proc blend {bt} { + if {[tk windowingsystem] eq "aqua"} { + $bt configure -highlightbackground [[winfo parent $bt] cget -background] + } + return $bt +} + set w .twind catch {destroy $w} toplevel $w @@ -53,17 +61,19 @@ $t insert end "it. These are called \"embedded windows\", " $t insert end "and they can consist of arbitrary widgets. " $t insert end "For example, here are two embedded button " $t insert end "widgets. You can click on the first button to " -$t window create end -window $t.on +$t window create end -window [blend $t.on] $t insert end " horizontal scrolling, which also turns off " $t insert end "word wrapping. Or, you can click on the second " $t insert end "button to\n" -$t window create end -window $t.off +$t window create end -window [blend $t.off] $t insert end " horizontal scrolling and turn back on word wrapping.\n\n" $t insert end "Or, here is another example. If you " $t window create end -create { button %W.click -text "Click Here" -command "textWindPlot %W" \ - -cursor top_left_arrow} + -cursor top_left_arrow + blend %W.click +} $t insert end " a canvas displaying an x-y plot will appear right here." $t mark set plot insert @@ -72,7 +82,8 @@ $t insert end " You can drag the data points around with the mouse, " $t insert end "or you can click here to " $t window create end -create { button %W.delete -text "Delete" -command "textWindDel %W" \ - -cursor top_left_arrow + -cursor top_left_arrow + blend %W.delete } $t insert end " the plot again.\n\n" @@ -80,7 +91,8 @@ $t insert end "You can also create multiple text widgets each of which " $t insert end "display the same underlying text. Click this button to " $t window create end \ -create {button %W.peer -text "Make A Peer" -command "textMakePeer %W" \ - -cursor top_left_arrow} -padx 3 + -cursor top_left_arrow + blend %W.peer} -padx 3 $t insert end " widget. Notice how peer widgets can have different " $t insert end "font settings, and by default contain all the images " $t insert end "of the 'parent', but that the embedded windows, " @@ -92,7 +104,8 @@ $t insert end "designed to show up in all peers.) A good use of " $t insert end "peers is for " $t window create end \ -create {button %W.split -text "Split Windows" -command "textSplitWindow %W" \ - -cursor top_left_arrow} -padx 3 + -cursor top_left_arrow + blend %W.split} -padx 3 $t insert end " \n\n" $t insert end "Users of previous versions of Tk will also be interested " @@ -128,11 +141,11 @@ foreach color {AntiqueWhite3 Bisque1 Bisque2 Bisque3 Bisque4 DarkSlateGray1 Aquamarine2 DarkSeaGreen2 SeaGreen1 Yellow1 IndianRed1 IndianRed2 Tan1 Tan4} { button $t.color$i -text $color -cursor top_left_arrow -command \ - "$t configure -bg $color" - $t window create end -window $t.color$i -padx 3 -pady 2 + "changeBg $t $color" + $t window create end -window [blend $t.color$i] -padx 3 -pady 2 incr i } -$t tag add buttons $t.default end +$t tag add buttons [blend $t.default] end button $t.bigB -text "Big borders" -command "textWindBigB $t" \ -cursor top_left_arrow @@ -153,12 +166,12 @@ set text_normal(pad) [$t cget -padx] $t insert end "\nYou can also change the usual border width and " $t insert end "highlightthickness and padding.\n" -$t window create end -window $t.bigB -$t window create end -window $t.smallB -$t window create end -window $t.bigH -$t window create end -window $t.smallH -$t window create end -window $t.bigP -$t window create end -window $t.smallP +$t window create end -window [blend $t.bigB] +$t window create end -window [blend $t.smallB] +$t window create end -window [blend $t.bigH] +$t window create end -window [blend $t.smallH] +$t window create end -window [blend $t.bigP] +$t window create end -window [blend $t.smallP] $t insert end "\n\nFinally, images fit comfortably in text widgets too:" @@ -189,7 +202,6 @@ proc textWindSmallP w { $w configure -padx $::text_normal(pad) -pady $::text_normal(pad) } - proc textWindOn w { catch {destroy $w.scroll2} set t $w.f.text @@ -290,8 +302,20 @@ proc textWindDel t { } } +proc changeBg {t c} { + $t configure -background $c + if {[tk windowingsystem] eq "aqua"} { + foreach b [$t window names] { + if {[winfo class $b] eq "Button"} { + $b configure -highlightbackground $c + } + } + } +} + proc embDefBg t { - $t configure -background [lindex [$t configure -background] 3] + set bg [lindex [$t configure -background] 3] + changeBg $t $bg } proc textMakePeer {parent} { diff --git a/macosx/tkMacOSXBitmap.c b/macosx/tkMacOSXBitmap.c index 6ec4048..e8cb211 100644 --- a/macosx/tkMacOSXBitmap.c +++ b/macosx/tkMacOSXBitmap.c @@ -49,6 +49,9 @@ static BuiltInIcon builtInIcons[] = { #define builtInIconSize 32 +#define OSTYPE_TO_UTI(x) (NSString *)UTTypeCreatePreferredIdentifierForTag( \ + kUTTagClassOSType, UTCreateStringForOSType(x), nil) + static Tcl_HashTable iconBitmapTable = {}; typedef struct { int kind, width, height; @@ -107,14 +110,15 @@ TkpDefineNativeBitmaps(void) } } } + /* *---------------------------------------------------------------------- * - * GetBitmapForIcon -- + * PixmapFromImage -- * * Results: - * Bitmap for the given IconRef. + * Returns a Pixmap with an NSImage drawn into it. * * Side effects: * None. @@ -123,29 +127,33 @@ TkpDefineNativeBitmaps(void) */ static Pixmap -GetBitmapForIcon( +PixmapFromImage( Display *display, - IconRef icon, + NSImage* image, CGSize size) { TkMacOSXDrawingContext dc; Pixmap pixmap; - + pixmap = Tk_GetPixmap(display, None, size.width, size.height, 0); if (TkMacOSXSetupDrawingContext(pixmap, NULL, 1, &dc)) { if (dc.context) { - const CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1, - .tx = 0, .ty = size.height }; - const CGRect r = { .origin = { .x = 0, .y = 0 }, .size = size }; - + CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1, + .tx = 0, .ty = size.height}; CGContextConcatCTM(dc.context, t); - PlotIconRefInContext(dc.context, &r, kAlignAbsoluteCenter, - kTransformNone, NULL, kPlotIconRefNormalFlags, icon); + [NSGraphicsContext saveGraphicsState]; + [NSGraphicsContext setCurrentContext:[NSGraphicsContext + graphicsContextWithGraphicsPort:dc.context + flipped:NO]]; + [image drawAtPoint:NSZeroPoint fromRect:NSZeroRect + operation:NSCompositeCopy fraction:1.0]; + [NSGraphicsContext restoreGraphicsState]; } TkMacOSXRestoreDrawingContext(&dc); } return pixmap; } + /* *---------------------------------------------------------------------- @@ -168,22 +176,14 @@ TkpCreateNativeBitmap( Display *display, const void *source) /* Info about the icon to build. */ { - Pixmap pixmap; - IconRef icon; - OSErr err; - - err = ChkErr(GetIconRef, kOnSystemDisk, kSystemIconsCreator, - (unsigned int)PTR2UINT(source), &icon); - if (err == noErr) { - pixmap = GetBitmapForIcon(display, icon, CGSizeMake(builtInIconSize, - builtInIconSize)); - ReleaseIconRef(icon); - } else { - pixmap = Tk_GetPixmap(display, None, builtInIconSize, - builtInIconSize, 0); - } + NSString *iconUTI = OSTYPE_TO_UTI(PTR2UINT(source)); + NSImage *iconImage = [[NSWorkspace sharedWorkspace] + iconForFileType: iconUTI]; + CGSize size = CGSizeMake(builtInIconSize, builtInIconSize); + Pixmap pixmap = PixmapFromImage(display, iconImage, NSSizeToCGSize(size)); return pixmap; } + /* *---------------------------------------------------------------------- @@ -219,6 +219,7 @@ OSTypeFromString(const char *s, OSType *t) { Tcl_FreeEncoding(encoding); return result; } + /* *---------------------------------------------------------------------- @@ -309,50 +310,17 @@ TkpGetNativeAppBitmap( } } if (image) { - TkMacOSXDrawingContext dc; - int depth = 0; - -#ifdef MAC_OSX_TK_TODO - for (NSImageRep *r in [image representations]) { - NSInteger bitsPerSample = [r bitsPerSample]; - if (bitsPerSample && bitsPerSample > depth) { - depth = bitsPerSample; - }; - } - if (depth == 1) { - /* TODO: convert BW NSImage to CGImageMask */ - } -#endif - pixmap = Tk_GetPixmap(display, None, size.width, size.height, depth); *width = size.width; *height = size.height; - if (TkMacOSXSetupDrawingContext(pixmap, NULL, 1, &dc)) { - if (dc.context) { - CGAffineTransform t = { .a = 1, .b = 0, .c = 0, .d = -1, - .tx = 0, .ty = size.height}; - - CGContextConcatCTM(dc.context, t); - [NSGraphicsContext saveGraphicsState]; - [NSGraphicsContext setCurrentContext:[NSGraphicsContext - graphicsContextWithCGContext:dc.context flipped:NO]]; - [image drawAtPoint:NSZeroPoint fromRect:NSZeroRect - operation:NSCompositeCopy fraction:1.0]; - [NSGraphicsContext restoreGraphicsState]; - } - TkMacOSXRestoreDrawingContext(&dc); - } + pixmap = PixmapFromImage(display, image, NSSizeToCGSize(size)); } else if (name) { OSType iconType; if (OSTypeFromString(name, &iconType) == TCL_OK) { - IconRef icon; - OSErr err = ChkErr(GetIconRef, kOnSystemDisk, kSystemIconsCreator, - iconType, &icon); - if (err == noErr) { - pixmap = GetBitmapForIcon(display, icon, NSSizeToCGSize(size)); - *width = size.width; - *height = size.height; - ReleaseIconRef(icon); - } + NSString *iconUTI = OSTYPE_TO_UTI(iconType); + printf("Found image for UTI %s\n", iconUTI.UTF8String); + NSImage *iconImage = [[NSWorkspace sharedWorkspace] + iconForFileType: iconUTI]; + pixmap = PixmapFromImage(display, iconImage, NSSizeToCGSize(size)); } } return pixmap; diff --git a/macosx/tkMacOSXClipboard.c b/macosx/tkMacOSXClipboard.c index 2ae02e8..6cbcdf6 100644 --- a/macosx/tkMacOSXClipboard.c +++ b/macosx/tkMacOSXClipboard.c @@ -28,7 +28,7 @@ static Tk_Window clipboardOwner = NULL; NSMutableString *string = [NSMutableString new]; if (dispPtr && dispPtr->clipboardActive && - [type isEqualToString:NSPasteboardTypeString]) { + [type isEqualToString:NSStringPboardType]) { for (TkClipboardTarget *targetPtr = dispPtr->clipTargetPtr; targetPtr; targetPtr = targetPtr->nextPtr) { if (targetPtr->type == XA_STRING || @@ -55,7 +55,7 @@ static Tk_Window clipboardOwner = NULL; if (dispPtr && dispPtr->clipboardActive) { [self tkProvidePasteboard:dispPtr pasteboard:[NSPasteboard generalPasteboard] - provideDataForType:NSPasteboardTypeString]; + provideDataForType:NSStringPboardType]; } } @@ -132,7 +132,7 @@ TkSelGetSelection( NSString *string = nil; NSPasteboard *pb = [NSPasteboard generalPasteboard]; NSString *type = [pb availableTypeFromArray:[NSArray arrayWithObject: - NSPasteboardTypeString]]; + NSStringPboardType]]; if (type) { string = [pb stringForType:type]; @@ -236,7 +236,7 @@ TkSelUpdateClipboard( { NSPasteboard *pb = [NSPasteboard generalPasteboard]; - changeCount = [pb addTypes:[NSArray arrayWithObject:NSPasteboardTypeString] + changeCount = [pb addTypes:[NSArray arrayWithObject:NSStringPboardType] owner:NSApp]; } diff --git a/macosx/tkMacOSXColor.c b/macosx/tkMacOSXColor.c index f291289..015c164 100644 --- a/macosx/tkMacOSXColor.c +++ b/macosx/tkMacOSXColor.c @@ -339,11 +339,11 @@ SetCGColorComponents( color = [[NSColor selectedTextColor] colorUsingColorSpace: deviceRGB]; break; case 2: -#if MAC_OS_X_VERSION_MAX_ALLOWED >= 101000 - color = [[NSColor labelColor] colorUsingColorSpace: deviceRGB]; -#else - color = [[NSColor textColor] colorUsingColorSpace: deviceRGB]; -#endif + if ([NSApp macMinorVersion] > 9) { + color = [[NSColor labelColor] colorUsingColorSpace: deviceRGB]; + } else { + color = [[NSColor textColor] colorUsingColorSpace: deviceRGB]; + } break; case 3: color = [[NSColor controlTextColor] colorUsingColorSpace: diff --git a/macosx/tkMacOSXConstants.h b/macosx/tkMacOSXConstants.h index 388d619..8ef535c 100644 --- a/macosx/tkMacOSXConstants.h +++ b/macosx/tkMacOSXConstants.h @@ -25,23 +25,21 @@ * of constants. */ -#if MAC_OS_X_VERSION_MIN_REQUIRED < 1090 -#define kCTFontOrientationDefault kCTFontDefaultOrientation -#define kCTFontOrientationVertical kCTFontVerticalOrientation -#define NSModalResponseCancel NSCancelButton +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 +#define kCTFontDefaultOrientation kCTFontOrientationDefault +#define kCTFontVerticalOrientation kCTFontOrientationVertical #endif -#if MAC_OS_X_VERSION_MIN_REQUIRED < 101000 -#define NSModalResponseOK NSOKButton +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 101000 +#define NSOKButton NSModalResponseOK #endif -#if MAC_OS_X_VERSION_MIN_REQUIRED < 101100 -#define kCTFontUIFontUserFixedPitch kCTFontUserFixedPitchFontType +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 101100 +#define kCTFontUserFixedPitchFontType kCTFontUIFontUserFixedPitch #endif -#if MAC_OS_X_VERSION_MIN_REQUIRED < 101200 -#define NSEventTypeAppKitDefined NSAppKitDefined -#else +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 101200 +#define NSAppKitDefined NSEventTypeAppKitDefined #define NSApplicationDefined NSEventTypeApplicationDefined #define NSApplicationActivatedEventType NSEventSubtypeApplicationActivated #define NSApplicationDeactivatedEventType NSEventSubtypeApplicationDeactivated @@ -96,12 +94,12 @@ #define NSFullScreenWindowMask NSWindowStyleMaskFullScreen #endif -#if MAC_OS_X_VERSION_MIN_REQUIRED < 101400 -#define NSControlStateValueOn NSOnState -#define NSControlStateValueOff NSOffState -#define NSPasteboardTypeString NSStringPboardType +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 101400 +#define NSStringPboardType NSPasteboardTypeString +#define NSOnState NSControlStateValueOn +#define NSOffState NSControlStateValueOff // Now we are also changing names of methods! -#define graphicsContextWithCGContext graphicsContextWithGraphicsPort +#define graphicsContextWithGraphicsPort graphicsContextWithCGContext #endif diff --git a/macosx/tkMacOSXDefault.h b/macosx/tkMacOSXDefault.h index 6bc9bdc..4cdae53 100644 --- a/macosx/tkMacOSXDefault.h +++ b/macosx/tkMacOSXDefault.h @@ -35,9 +35,10 @@ #define BLACK "Black" #define WHITE "White" -#define NORMAL_BG "systemTextBackgroundColor" +#define NORMAL_BG "systemWindowBackgroundColor" +#define TEXT_BG "systemTextBackgroundColor" #define NORMAL_FG "systemTextColor" -#define ACTIVE_BG "systemTextBackgroundColor" +#define ACTIVE_BG "systemWindowBackgroundColor" #define ACTIVE_FG "systemTextColor" #define SELECT_BG "systemSelectedTextBackgroundColor" #define SELECT_FG "systemSelectedTextColor" @@ -171,7 +172,7 @@ #define MAC_OSX_ENTRY_RELIEF TK_RELIEF_SUNKEN #define MAC_OSX_ENTRY_SELECT_RELIEF TK_RELIEF_FLAT -#define DEF_ENTRY_BG_COLOR NORMAL_BG +#define DEF_ENTRY_BG_COLOR TEXT_BG #define DEF_ENTRY_BG_MONO WHITE #define DEF_ENTRY_BORDER_WIDTH "2" #define DEF_ENTRY_CURSOR "xterm" @@ -250,7 +251,7 @@ */ #define DEF_LISTBOX_ACTIVE_STYLE "dotbox" -#define DEF_LISTBOX_BG_COLOR NORMAL_BG +#define DEF_LISTBOX_BG_COLOR TEXT_BG #define DEF_LISTBOX_BG_MONO WHITE #define DEF_LISTBOX_BORDER_WIDTH "1" #define DEF_LISTBOX_CURSOR "" @@ -504,7 +505,7 @@ */ #define DEF_TEXT_AUTO_SEPARATORS "1" -#define DEF_TEXT_BG_COLOR NORMAL_BG +#define DEF_TEXT_BG_COLOR TEXT_BG #define DEF_TEXT_BG_MONO WHITE #define DEF_TEXT_BLOCK_CURSOR "0" #define DEF_TEXT_BORDER_WIDTH "0" diff --git a/macosx/tkMacOSXDialog.c b/macosx/tkMacOSXDialog.c index a149bca..ad952e8 100644 --- a/macosx/tkMacOSXDialog.c +++ b/macosx/tkMacOSXDialog.c @@ -16,6 +16,13 @@ #include "tkFileFilter.h" #include "tkMacOSXConstants.h" +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1090 +#define modalOK NSOKButton +#define modalCancel NSCancelButton +#else +#define modalOK NSModalResponseOK +#define modalCancel NSModalResponseCancel +#endif // MAC_OS_X_VERSION_MIN_REQUIRED < 1090 #define modalOther -1 #define modalError -2 @@ -195,7 +202,7 @@ getFileURL( { FilePanelCallbackInfo *callbackInfo = contextInfo; - if (returnCode == NSModalResponseOK) { + if (returnCode == modalOK) { Tcl_Obj *resultObj; if (callbackInfo->multiple) { @@ -223,7 +230,7 @@ getFileURL( } else { Tcl_SetObjResult(callbackInfo->interp, resultObj); } - } else if (returnCode == NSModalResponseCancel) { + } else if (returnCode == modalCancel) { Tcl_ResetResult(callbackInfo->interp); } if (panel == [NSApp modalWindow]) { @@ -404,7 +411,7 @@ Tk_ChooseColorObjCmd( [colorPanel setColor:initialColor]; } returnCode = [NSApp runModalForWindow:colorPanel]; - if (returnCode == NSModalResponseOK) { + if (returnCode == modalOK) { color = [[colorPanel color] colorUsingColorSpace: [NSColorSpace deviceRGBColorSpace]]; numberOfComponents = [color numberOfComponents]; @@ -803,7 +810,7 @@ Tk_GetOpenFileObjCmd( [parent makeKeyWindow]; } - if ((typeVariablePtr && (modalReturnCode == NSModalResponseOK)) + if ((typeVariablePtr && (modalReturnCode == NSOKButton)) && filterInfo.doFileTypes) { /* * The -typevariable must be set to the selected file type, if the @@ -1115,7 +1122,7 @@ Tk_GetSaveFileObjCmd( [parent makeKeyWindow]; } - if (typeVariablePtr && (modalReturnCode == NSModalResponseOK) + if (typeVariablePtr && (modalReturnCode == NSOKButton) && filterInfo.doFileTypes) { /* * The -typevariable must be set to the selected file type, if the diff --git a/macosx/tkMacOSXEvent.c b/macosx/tkMacOSXEvent.c index 6e778a4..b9c9b6a 100644 --- a/macosx/tkMacOSXEvent.c +++ b/macosx/tkMacOSXEvent.c @@ -34,7 +34,7 @@ enum { NSInteger subtype; switch ((NSInteger)type) { - case NSEventTypeAppKitDefined: + case NSAppKitDefined: subtype = [theEvent subtype]; switch (subtype) { diff --git a/macosx/tkMacOSXFont.c b/macosx/tkMacOSXFont.c index e4f7e82..ee2ddc4 100644 --- a/macosx/tkMacOSXFont.c +++ b/macosx/tkMacOSXFont.c @@ -16,6 +16,10 @@ #include "tkMacOSXFont.h" #include "tkMacOSXConstants.h" +#define defaultOrientation kCTFontDefaultOrientation +#define verticalOrientation kCTFontVerticalOrientation +#define fixedPitch kCTFontUserFixedPitchFontType + /* #ifdef TK_MAC_DEBUG #define TK_MAC_DEBUG_FONTS @@ -273,7 +277,7 @@ InitFont( fmPtr->fixed = [nsFont advancementForGlyph:glyphs[0]].width == [nsFont advancementForGlyph:glyphs[1]].width; bounds = NSRectFromCGRect(CTFontGetBoundingRectsForGlyphs((CTFontRef) - nsFont, kCTFontOrientationDefault, ch, boundingRects, nCh)); + nsFont, defaultOrientation, ch, boundingRects, nCh)); kern = [nsFont advancementForGlyph:glyphs[2]].width - [fontPtr->nsFont advancementForGlyph:glyphs[2]].width; } @@ -390,7 +394,7 @@ TkpFontPkgInit( systemFont++; } TkInitFontAttributes(&fa); - nsFont = (NSFont*) CTFontCreateUIFontForLanguage(kCTFontUIFontUserFixedPitch, 11, NULL); + nsFont = (NSFont*) CTFontCreateUIFontForLanguage(fixedPitch, 11, NULL); if (nsFont) { GetTkFontAttributesForNSFont(nsFont, &fa); CFRelease(nsFont); @@ -1105,7 +1109,7 @@ DrawCharsInContext( [attributes setObject:(id)fg forKey:(id)kCTForegroundColorAttributeName]; CFRelease(fg); nsFont = [attributes objectForKey:NSFontAttributeName]; - [nsFont setInContext:[NSGraphicsContext graphicsContextWithCGContext: + [nsFont setInContext:[NSGraphicsContext graphicsContextWithGraphicsPort: context flipped:NO]]; CGContextSetTextMatrix(context, CGAffineTransformIdentity); attributedString = [[NSAttributedString alloc] initWithString:string diff --git a/macosx/tkMacOSXMenu.c b/macosx/tkMacOSXMenu.c index b6fca79..790b6ff 100644 --- a/macosx/tkMacOSXMenu.c +++ b/macosx/tkMacOSXMenu.c @@ -662,7 +662,7 @@ TkpConfigureMenuEntry( [menuItem setEnabled:!(mePtr->state == ENTRY_DISABLED)]; [menuItem setState:((mePtr->type == CHECK_BUTTON_ENTRY || mePtr->type == RADIO_BUTTON_ENTRY) && mePtr->indicatorOn && - (mePtr->entryFlags & ENTRY_SELECTED) ? NSControlStateValueOn : NSControlStateValueOff)]; + (mePtr->entryFlags & ENTRY_SELECTED) ? NSOnState : NSOffState)]; if (mePtr->type != CASCADE_ENTRY && mePtr->accelPtr && mePtr->accelLength) { keyEquivalent = ParseAccelerator(Tcl_GetString(mePtr->accelPtr), &modifierMask); diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c index 2517769..4fc5fe4 100644 --- a/macosx/tkMacOSXMouseEvent.c +++ b/macosx/tkMacOSXMouseEvent.c @@ -178,22 +178,24 @@ enum { */ unsigned int state = 0; - NSInteger button = [theEvent buttonNumber]; + int button = [theEvent buttonNumber] + Button1; EventRef eventRef = (EventRef)[theEvent eventRef]; UInt32 buttons; OSStatus err = GetEventParameter(eventRef, kEventParamMouseChord, typeUInt32, NULL, sizeof(UInt32), NULL, &buttons); if (err == noErr) { - state |= (buttons & ((1<<5) - 1)) << 8; - } else if (button < 5) { + state |= (buttons & 0x7F) * Button1Mask; + /* Handle buttons 8/9 */ + state |= (buttons & 0x180) * (Button8Mask >> 7); + } else if (button <= Button9) { switch (eventType) { case NSLeftMouseDown: case NSRightMouseDown: case NSLeftMouseDragged: case NSRightMouseDragged: case NSOtherMouseDown: - state |= 1 << (button + 8); + state |= TkGetButtonMask(button); break; default: break; @@ -361,10 +363,12 @@ ButtonModifiers2State( unsigned int state; /* - * Tk supports at most 5 buttons. + * Tk on OSX supports at most 9 buttons. */ - state = (buttonState & ((1<<5) - 1)) << 8; + state = (buttonState & 0x7F) * Button1Mask; + /* Handle buttons 8/9 */ + state |= (buttonState & 0x180) * (Button8Mask >> 7); if (keyModifiers & alphaLock) { state |= LockMask; diff --git a/macosx/tkMacOSXWindowEvent.c b/macosx/tkMacOSXWindowEvent.c index 3703340..b8055e8 100644 --- a/macosx/tkMacOSXWindowEvent.c +++ b/macosx/tkMacOSXWindowEvent.c @@ -292,6 +292,22 @@ extern NSString *NSWindowDidOrderOffScreenNotification; TKLog(@"-[%@(%p) %s] %@", [self class], self, _cmd, notification); #endif [NSApp tkCheckPasteboard]; + + /* + * When the application is activated with Command-Tab it will create a + * zombie window for every Tk window which has been withdrawn. So iterate + * through the list of windows and order out any withdrawn window. + */ + + for (NSWindow *win in [NSApp windows]) { + TkWindow *winPtr = TkMacOSXGetTkWindow(win); + if (!winPtr || !winPtr->wmInfoPtr) { + continue; + } + if (winPtr->wmInfoPtr->hints.initial_state == WithdrawnState) { + [win orderOut:nil]; + } + } } - (void) applicationDeactivate: (NSNotification *) notification diff --git a/macosx/tkMacOSXWm.c b/macosx/tkMacOSXWm.c index b510d07..da1b002 100644 --- a/macosx/tkMacOSXWm.c +++ b/macosx/tkMacOSXWm.c @@ -5582,8 +5582,7 @@ TkUnsupported1ObjCmd( return TCL_ERROR; } if ((objc < 3) || (objc > 4)) { - Tcl_WrongNumArgs(interp, 2, objv, - "appearance window ?appearancename?"); + Tcl_WrongNumArgs(interp, 2, objv, "window ?appearancename?"); return TCL_ERROR; } if (objc == 4 && [NSApp macMinorVersion] < 14) { @@ -6879,10 +6878,11 @@ ApplyWindowAttributeFlagChanges( * height. This causes the window manager to refuse to * allow the window to be resized when it is a split * window. To work around this we make the max size equal - * to the screen size. + * to the screen size. (For 10.11 and up, only) */ - - [macWindow setMaxFullScreenContentSize:screenSize]; + if ([NSApp macMinorVersion] > 10) { + [macWindow setMaxFullScreenContentSize:screenSize]; + } } } #endif diff --git a/macosx/ttkMacOSXTheme.c b/macosx/ttkMacOSXTheme.c index c664cb1..870e784 100644 --- a/macosx/ttkMacOSXTheme.c +++ b/macosx/ttkMacOSXTheme.c @@ -1236,12 +1236,13 @@ static inline HIThemeButtonDrawInfo computeButtonDrawInfo( SInt32 HIThemeState; + HIThemeState = Ttk_StateTableLookup(ThemeStateTable, state); switch (params->kind) { case kThemePushButton: - HIThemeState = kThemeStateActive; + HIThemeState &= ~kThemeStateInactive; + HIThemeState |= kThemeStateActive; break; default: - HIThemeState = Ttk_StateTableLookup(ThemeStateTable, state); break; } diff --git a/tests/entry.test b/tests/entry.test index 75a5da8..6207c69 100644 --- a/tests/entry.test +++ b/tests/entry.test @@ -1435,7 +1435,7 @@ test entry-3.71 {EntryWidgetCmd procedure, "xview" widget command} -setup { .e xview scroll 24 } -cleanup { destroy .e -} -returnCodes error -result {wrong # args: should be ".e xview scroll number units|pages"} +} -returnCodes error -result {wrong # args: should be ".e xview scroll number pages|units"} test entry-3.72 {EntryWidgetCmd procedure, "xview" widget command} -setup { entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 pack .e @@ -1512,7 +1512,7 @@ test entry-3.77 {EntryWidgetCmd procedure, "xview" widget command} -setup { .e xview scroll 23 foobars } -cleanup { destroy .e -} -returnCodes error -result {bad argument "foobars": must be units or pages} +} -returnCodes error -result {bad argument "foobars": must be pages or units} test entry-3.78 {EntryWidgetCmd procedure, "xview" widget command} -setup { entry .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 pack .e diff --git a/tests/spinbox.test b/tests/spinbox.test index 28ebe68..efd5b63 100644 --- a/tests/spinbox.test +++ b/tests/spinbox.test @@ -1773,7 +1773,7 @@ test spinbox-3.71 {SpinboxWidgetCmd procedure, "xview" widget command} -setup { .e xview scroll 24 } -cleanup { destroy .e -} -returnCodes error -result {wrong # args: should be ".e xview scroll number units|pages"} +} -returnCodes error -result {wrong # args: should be ".e xview scroll number pages|units"} test spinbox-3.72 {SpinboxWidgetCmd procedure, "xview" widget command} -setup { spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 pack .e @@ -1850,7 +1850,7 @@ test spinbox-3.77 {SpinboxWidgetCmd procedure, "xview" widget command} -setup { .e xview scroll 23 foobars } -cleanup { destroy .e -} -returnCodes error -result {bad argument "foobars": must be units or pages} +} -returnCodes error -result {bad argument "foobars": must be pages or units} test spinbox-3.78 {SpinboxWidgetCmd procedure, "xview" widget command} -setup { spinbox .e -font {Courier -12} -borderwidth 2 -highlightthickness 2 pack .e diff --git a/tests/textDisp.test b/tests/textDisp.test index 5df5467..1b6f4c5 100644 --- a/tests/textDisp.test +++ b/tests/textDisp.test @@ -1867,10 +1867,10 @@ test textDisp-14.9 {TkTextXviewCmd procedure} { } [list [expr {9.0/14}] 1.0] test textDisp-14.10 {TkTextXviewCmd procedure} { list [catch {.t xview scroll a} msg] $msg -} {1 {wrong # args: should be ".t xview scroll number units|pages|pixels"}} +} {1 {wrong # args: should be ".t xview scroll number pages|pixels|units"}} test textDisp-14.11 {TkTextXviewCmd procedure} { list [catch {.t xview scroll a b c} msg] $msg -} {1 {wrong # args: should be ".t xview scroll number units|pages|pixels"}} +} {1 {wrong # args: should be ".t xview scroll number pages|pixels|units"}} test textDisp-14.12 {TkTextXviewCmd procedure} { list [catch {.t xview scroll gorp units} msg] $msg } {1 {expected integer but got "gorp"}} @@ -1904,7 +1904,7 @@ test textDisp-14.14 {TkTextXviewCmd procedure} { } {2.21 2.20 2.99 2.84} test textDisp-14.15 {TkTextXviewCmd procedure} { list [catch {.t xview scroll 14 globs} msg] $msg -} {1 {bad argument "globs": must be units, pages, or pixels}} +} {1 {bad argument "globs": must be pages, pixels, or units}} test textDisp-14.16 {TkTextXviewCmd procedure} { list [catch {.t xview flounder} msg] $msg } {1 {bad option "flounder": must be moveto or scroll}} @@ -2086,13 +2086,13 @@ test textDisp-16.18 {TkTextYviewCmd procedure, "moveto" roundoff} {textfonts} { } [list [expr {1.0/3}] [expr {5.0/6}]] test textDisp-16.19 {TkTextYviewCmd procedure, "scroll" option} { list [catch {.t yview scroll a} msg] $msg -} {1 {wrong # args: should be ".t yview scroll number units|pages|pixels"}} +} {1 {wrong # args: should be ".t yview scroll number pages|pixels|units"}} test textDisp-16.20 {TkTextYviewCmd procedure, "scroll" option} { list [catch {.t yview scroll a b c} msg] $msg -} {1 {wrong # args: should be ".t yview scroll number units|pages|pixels"}} +} {1 {wrong # args: should be ".t yview scroll number pages|pixels|units"}} test textDisp-16.21 {TkTextYviewCmd procedure, "scroll" option} { list [catch {.t yview scroll badInt bogus} msg] $msg -} {1 {bad argument "bogus": must be units, pages, or pixels}} +} {1 {bad argument "bogus": must be pages, pixels, or units}} test textDisp-16.21.2 {TkTextYviewCmd procedure, "scroll" option} { list [catch {.t yview scroll badInt units} msg] $msg } {1 {expected integer but got "badInt"}} @@ -2104,7 +2104,7 @@ test textDisp-16.22 {TkTextYviewCmd procedure, "scroll" option, back pages} { } {42.0} test textDisp-16.22.1 {TkTextYviewCmd procedure, "scroll" option, back pages} { list [catch {.t yview scroll -3 p} res] $res -} {1 {ambiguous argument "p": must be units, pages, or pixels}} +} {1 {ambiguous argument "p": must be pages, pixels, or units}} test textDisp-16.23 {TkTextYviewCmd procedure, "scroll" option, back pages} { .t yview 50.0 update @@ -2175,7 +2175,7 @@ test textDisp-16.31 {TkTextYviewCmd procedure, "scroll units" option} { } {151.40} test textDisp-16.32 {TkTextYviewCmd procedure} { list [catch {.t yview scroll 12 bogoids} msg] $msg -} {1 {bad argument "bogoids": must be units, pages, or pixels}} +} {1 {bad argument "bogoids": must be pages, pixels, or units}} test textDisp-16.33 {TkTextYviewCmd procedure} { list [catch {.t yview bad_arg 1 2} msg] $msg } {1 {bad option "bad_arg": must be moveto or scroll}} diff --git a/tests/unixEmbed.test b/tests/unixEmbed.test index c2dc073..7d26fbf 100644 --- a/tests/unixEmbed.test +++ b/tests/unixEmbed.test @@ -341,7 +341,7 @@ test unixEmbed-2.4 {EmbeddedEventProc procedure} -constraints { test unixEmbed-3.1 {ContainerEventProc procedure, detect creation} -constraints { - unix testembed notPortable + unix testembed nonPortable } -body { frame .f1 -container 1 -width 200 -height 50 pack .f1 diff --git a/tests/util.test b/tests/util.test index c1ec6a5..d457b50 100644 --- a/tests/util.test +++ b/tests/util.test @@ -28,10 +28,10 @@ test util-1.3 {Tk_GetScrollInfo procedure} -body { } -result {0.5 0.75} test util-1.4 {Tk_GetScrollInfo procedure} -body { .l yview scroll a -} -returnCodes error -result {wrong # args: should be ".l yview scroll number units|pages"} +} -returnCodes error -result {wrong # args: should be ".l yview scroll number pages|units"} test util-1.5 {Tk_GetScrollInfo procedure} -body { .l yview scroll a b c -} -returnCodes error -result {wrong # args: should be ".l yview scroll number units|pages"} +} -returnCodes error -result {wrong # args: should be ".l yview scroll number pages|units"} test util-1.6 {Tk_GetScrollInfo procedure} -body { .l yview scroll xyz units } -returnCodes error -result {expected integer but got "xyz"} @@ -57,7 +57,7 @@ test util-1.10 {Tk_GetScrollInfo procedure} -body { } -result {13} test util-1.11 {Tk_GetScrollInfo procedure} -body { .l yview scroll 3 zips -} -returnCodes error -result {bad argument "zips": must be units or pages} +} -returnCodes error -result {bad argument "zips": must be pages or units} test util-1.12 {Tk_GetScrollInfo procedure} -body { .l yview dropdead 3 times } -returnCodes error -result {unknown option "dropdead": must be moveto or scroll} diff --git a/unix/Makefile.in b/unix/Makefile.in index 1f5db9e..787a2aa 100644 --- a/unix/Makefile.in +++ b/unix/Makefile.in @@ -1645,9 +1645,7 @@ dist: $(UNIX_DIR)/configure $(UNIX_DIR)/tkConfig.h.in $(UNIX_DIR)/tk.pc.in $(MAC $(MAC_OSX_DIR)/Tk.xcodeproj/default.pbxuser \ $(DISTDIR)/macosx/Tk.xcodeproj $(INSTALL_DATA_DIR) $(DISTDIR)/compat - $(DIST_INSTALL_DATA) $(TOP_DIR)/license.terms $(TCLDIR)/compat/unistd.h \ - $(TCLDIR)/compat/stdlib.h \ - $(DISTDIR)/compat + $(DIST_INSTALL_DATA) $(TOP_DIR)/license.terms $(DISTDIR)/compat $(INSTALL_DATA_DIR) $(DISTDIR)/xlib $(DIST_INSTALL_DATA) $(XLIB_DIR)/*.[ch] $(DISTDIR)/xlib $(DIST_INSTALL_DATA) $(TOP_DIR)/license.terms $(DISTDIR)/xlib diff --git a/unix/configure b/unix/configure index 71bb0b4..5c46bac 100755 --- a/unix/configure +++ b/unix/configure @@ -694,13 +694,13 @@ PLAT_OBJS DL_OBJS DL_LIBS TCL_LIBS +EGREP +GREP +CPP LIBOBJS AR RANLIB SHARED_BUILD -EGREP -GREP -CPP OBJEXT EXEEXT ac_ct_CC @@ -1563,6 +1563,52 @@ fi } # ac_fn_c_try_compile +# ac_fn_c_try_link LINENO +# ----------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + test -x conftest$ac_exeext + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_link + # ac_fn_c_try_cpp LINENO # ---------------------- # Try to preprocess conftest.$ac_ext, and return whether this succeeded. @@ -1760,52 +1806,6 @@ $as_echo "$ac_res" >&6; } } # ac_fn_c_check_header_compile -# ac_fn_c_try_link LINENO -# ----------------------- -# Try to link conftest.$ac_ext, and return whether this succeeded. -ac_fn_c_try_link () -{ - as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - rm -f conftest.$ac_objext conftest$ac_exeext - if { { ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_link") 2>conftest.err - ac_status=$? - if test -s conftest.err; then - grep -v '^ *+' conftest.err >conftest.er1 - cat conftest.er1 >&5 - mv -f conftest.er1 conftest.err - fi - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - test -x conftest$ac_exeext - }; then : - ac_retval=0 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_retval=1 -fi - # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information - # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would - # interfere with the next link command; also delete a directory that is - # left behind by Apple's compiler. We do this before executing the actions. - rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno - as_fn_set_status $ac_retval - -} # ac_fn_c_try_link - # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly @@ -3462,11 +3462,201 @@ _ACEOF esac +#------------------------------------------------------------------------ +# If we're using GCC, see if the compiler understands -pipe. If so, use it. +# It makes compiling go faster. (This is only a performance feature.) +#------------------------------------------------------------------------ + +if test -z "$no_pipe" && test -n "$GCC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the compiler understands -pipe" >&5 +$as_echo_n "checking if the compiler understands -pipe... " >&6; } +if ${tcl_cv_cc_pipe+:} false; then : + $as_echo_n "(cached) " >&6 +else + + hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -pipe" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + tcl_cv_cc_pipe=yes +else + tcl_cv_cc_pipe=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + CFLAGS=$hold_cflags +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cc_pipe" >&5 +$as_echo "$tcl_cv_cc_pipe" >&6; } + if test $tcl_cv_cc_pipe = yes; then + CFLAGS="$CFLAGS -pipe" + fi +fi + +#------------------------------------------------------------------------ +# Embedded configuration information, encoding to use for the values, TIP #59 +#------------------------------------------------------------------------ + + + +# Check whether --with-encoding was given. +if test "${with_encoding+set}" = set; then : + withval=$with_encoding; with_tcencoding=${withval} +fi + + + if test x"${with_tcencoding}" != x ; then + +cat >>confdefs.h <<_ACEOF +#define TCL_CFGVAL_ENCODING "${with_tcencoding}" +_ACEOF + + else + +$as_echo "#define TCL_CFGVAL_ENCODING \"iso8859-1\"" >>confdefs.h + + fi + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to build libraries" >&5 +$as_echo_n "checking how to build libraries... " >&6; } + # Check whether --enable-shared was given. +if test "${enable_shared+set}" = set; then : + enableval=$enable_shared; tcl_ok=$enableval +else + tcl_ok=yes +fi + + + if test "${enable_shared+set}" = set; then + enableval="$enable_shared" + tcl_ok=$enableval + else + tcl_ok=yes + fi + + if test "$tcl_ok" = "yes" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: shared" >&5 +$as_echo "shared" >&6; } + SHARED_BUILD=1 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: static" >&5 +$as_echo "static" >&6; } + SHARED_BUILD=0 + +$as_echo "#define STATIC_BUILD 1" >>confdefs.h + + fi + + + #-------------------------------------------------------------------- -# Supply a substitute for stdlib.h if it doesn't define strtol, -# strtoul, or strtod (which it doesn't in some versions of SunOS). +# The statements below define a collection of compile flags. This +# macro depends on the value of SHARED_BUILD, and should be called +# after SC_ENABLE_SHARED checks the configure switches. #-------------------------------------------------------------------- +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ranlib; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_RANLIB+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +RANLIB=$ac_cv_prog_RANLIB +if test -n "$RANLIB"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 +$as_echo "$RANLIB" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_RANLIB"; then + ac_ct_RANLIB=$RANLIB + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_RANLIB"; then + ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_RANLIB="ranlib" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB +if test -n "$ac_ct_RANLIB"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 +$as_echo "$ac_ct_RANLIB" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_RANLIB" = x; then + RANLIB=":" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + RANLIB=$ac_ct_RANLIB + fi +else + RANLIB="$ac_cv_prog_RANLIB" +fi + ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' @@ -3864,254 +4054,6 @@ fi done -ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default" -if test "x$ac_cv_header_stdlib_h" = xyes; then : - tk_ok=1 -else - tk_ok=0 -fi - - -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <stdlib.h> - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "strtol" >/dev/null 2>&1; then : - -else - tk_ok=0 -fi -rm -f conftest* - -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <stdlib.h> - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "strtoul" >/dev/null 2>&1; then : - -else - tk_ok=0 -fi -rm -f conftest* - -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include <stdlib.h> - -_ACEOF -if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "strtod" >/dev/null 2>&1; then : - -else - tk_ok=0 -fi -rm -f conftest* - -if test $tk_ok = 0; then - -$as_echo "#define NO_STDLIB_H 1" >>confdefs.h - -fi - -#------------------------------------------------------------------------ -# If we're using GCC, see if the compiler understands -pipe. If so, use it. -# It makes compiling go faster. (This is only a performance feature.) -#------------------------------------------------------------------------ - -if test -z "$no_pipe" && test -n "$GCC"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the compiler understands -pipe" >&5 -$as_echo_n "checking if the compiler understands -pipe... " >&6; } -if ${tcl_cv_cc_pipe+:} false; then : - $as_echo_n "(cached) " >&6 -else - - hold_cflags=$CFLAGS; CFLAGS="$CFLAGS -pipe" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - tcl_cv_cc_pipe=yes -else - tcl_cv_cc_pipe=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS=$hold_cflags -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $tcl_cv_cc_pipe" >&5 -$as_echo "$tcl_cv_cc_pipe" >&6; } - if test $tcl_cv_cc_pipe = yes; then - CFLAGS="$CFLAGS -pipe" - fi -fi - -#------------------------------------------------------------------------ -# Embedded configuration information, encoding to use for the values, TIP #59 -#------------------------------------------------------------------------ - - - -# Check whether --with-encoding was given. -if test "${with_encoding+set}" = set; then : - withval=$with_encoding; with_tcencoding=${withval} -fi - - - if test x"${with_tcencoding}" != x ; then - -cat >>confdefs.h <<_ACEOF -#define TCL_CFGVAL_ENCODING "${with_tcencoding}" -_ACEOF - - else - -$as_echo "#define TCL_CFGVAL_ENCODING \"iso8859-1\"" >>confdefs.h - - fi - - - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to build libraries" >&5 -$as_echo_n "checking how to build libraries... " >&6; } - # Check whether --enable-shared was given. -if test "${enable_shared+set}" = set; then : - enableval=$enable_shared; tcl_ok=$enableval -else - tcl_ok=yes -fi - - - if test "${enable_shared+set}" = set; then - enableval="$enable_shared" - tcl_ok=$enableval - else - tcl_ok=yes - fi - - if test "$tcl_ok" = "yes" ; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: shared" >&5 -$as_echo "shared" >&6; } - SHARED_BUILD=1 - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: static" >&5 -$as_echo "static" >&6; } - SHARED_BUILD=0 - -$as_echo "#define STATIC_BUILD 1" >>confdefs.h - - fi - - - -#-------------------------------------------------------------------- -# The statements below define a collection of compile flags. This -# macro depends on the value of SHARED_BUILD, and should be called -# after SC_ENABLE_SHARED checks the configure switches. -#-------------------------------------------------------------------- - -if test -n "$ac_tool_prefix"; then - # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. -set dummy ${ac_tool_prefix}ranlib; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_RANLIB+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$RANLIB"; then - ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -RANLIB=$ac_cv_prog_RANLIB -if test -n "$RANLIB"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5 -$as_echo "$RANLIB" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - -fi -if test -z "$ac_cv_prog_RANLIB"; then - ac_ct_RANLIB=$RANLIB - # Extract the first word of "ranlib", so it can be a program name with args. -set dummy ranlib; ac_word=$2 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 -$as_echo_n "checking for $ac_word... " >&6; } -if ${ac_cv_prog_ac_ct_RANLIB+:} false; then : - $as_echo_n "(cached) " >&6 -else - if test -n "$ac_ct_RANLIB"; then - ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. -else -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then - ac_cv_prog_ac_ct_RANLIB="ranlib" - $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 - break 2 - fi -done - done -IFS=$as_save_IFS - -fi -fi -ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB -if test -n "$ac_ct_RANLIB"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5 -$as_echo "$ac_ct_RANLIB" >&6; } -else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } -fi - - if test "x$ac_ct_RANLIB" = x; then - RANLIB=":" - else - case $cross_compiling:$ac_tool_warned in -yes:) -{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 -$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} -ac_tool_warned=yes ;; -esac - RANLIB=$ac_ct_RANLIB - fi -else - RANLIB="$ac_cv_prog_RANLIB" -fi - # Step 0.a: Enable 64 bit support? @@ -5017,7 +4959,7 @@ fi fi # The combo of gcc + glibc has a bug related to inlining of - # functions like strtod(). The -fno-builtin flag should address + # functions like strtol()/strtoul(). The -fno-builtin flag should address # this problem but it does not work. The -fno-inline flag is kind # of overkill but it works. Disable inlining only when one of the # files in compat/*.c is being linked in. diff --git a/unix/configure.ac b/unix/configure.ac index f12d8de..c485652 100644 --- a/unix/configure.ac +++ b/unix/configure.ac @@ -83,19 +83,6 @@ fi AC_PROG_CC AC_C_INLINE -#-------------------------------------------------------------------- -# Supply a substitute for stdlib.h if it doesn't define strtol, -# strtoul, or strtod (which it doesn't in some versions of SunOS). -#-------------------------------------------------------------------- - -AC_CHECK_HEADER(stdlib.h, tk_ok=1, tk_ok=0) -AC_EGREP_HEADER(strtol, stdlib.h, , tk_ok=0) -AC_EGREP_HEADER(strtoul, stdlib.h, , tk_ok=0) -AC_EGREP_HEADER(strtod, stdlib.h, , tk_ok=0) -if test $tk_ok = 0; then - AC_DEFINE(NO_STDLIB_H, 1, [Do we have <stdlib.h>?]) -fi - #------------------------------------------------------------------------ # If we're using GCC, see if the compiler understands -pipe. If so, use it. # It makes compiling go faster. (This is only a performance feature.) diff --git a/unix/tcl.m4 b/unix/tcl.m4 index a206f26..70303cee 100644 --- a/unix/tcl.m4 +++ b/unix/tcl.m4 @@ -1311,7 +1311,7 @@ AC_DEFUN([SC_CONFIG_CFLAGS], [ ]) # The combo of gcc + glibc has a bug related to inlining of - # functions like strtod(). The -fno-builtin flag should address + # functions like strtol()/strtoul(). The -fno-builtin flag should address # this problem but it does not work. The -fno-inline flag is kind # of overkill but it works. Disable inlining only when one of the # files in compat/*.c is being linked in. @@ -1913,8 +1913,8 @@ dnl # preprocessing tests use only CPPFLAGS. # # Supply substitutes for missing POSIX header files. Special # notes: -# - stdlib.h doesn't define strtol, strtoul, or -# strtod insome versions of SunOS +# - stdlib.h doesn't define strtol or strtoul in some +# versions of SunOS # - some versions of string.h don't declare procedures such # as strstr # @@ -1965,7 +1965,6 @@ closedir(d); AC_CHECK_HEADER(stdlib.h, tcl_ok=1, tcl_ok=0) AC_EGREP_HEADER(strtol, stdlib.h, , tcl_ok=0) AC_EGREP_HEADER(strtoul, stdlib.h, , tcl_ok=0) - AC_EGREP_HEADER(strtod, stdlib.h, , tcl_ok=0) if test $tcl_ok = 0; then AC_DEFINE(NO_STDLIB_H, 1, [Do we have <stdlib.h>?]) fi diff --git a/unix/tkUnixPort.h b/unix/tkUnixPort.h index dbd5e09..f581719 100644 --- a/unix/tkUnixPort.h +++ b/unix/tkUnixPort.h @@ -23,11 +23,7 @@ #include <limits.h> #include <math.h> #include <pwd.h> -#ifdef NO_STDLIB_H -# include "../compat/stdlib.h" -#else -# include <stdlib.h> -#endif +#include <stdlib.h> #include <string.h> #include <sys/types.h> #include <sys/file.h> @@ -51,11 +47,7 @@ #if HAVE_INTTYPES_H # include <inttypes.h> #endif -#ifndef NO_UNISTD_H -# include <unistd.h> -#else -# include "../compat/unistd.h" -#endif +#include <unistd.h> #include <X11/Xlib.h> #include <X11/cursorfont.h> #include <X11/keysym.h> diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c index d06f38a..2edc809 100644 --- a/unix/tkUnixWm.c +++ b/unix/tkUnixWm.c @@ -2441,7 +2441,7 @@ WmIconphotoCmd( for (i = 3 + isDefault; i < objc; i++) { photo = Tk_FindPhoto(interp, Tcl_GetString(objv[i])); if (photo == NULL) { - Tcl_Free((char *) iconPropertyData); + ckfree((char *) iconPropertyData); return TCL_ERROR; } Tk_PhotoGetSize(photo, &width, &height); diff --git a/win/configure b/win/configure index 069f4e2..7e63a81 100755 --- a/win/configure +++ b/win/configure @@ -740,7 +740,6 @@ infodir docdir oldincludedir includedir -runstatedir localstatedir sharedstatedir sysconfdir @@ -817,7 +816,6 @@ datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' -runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE}' @@ -1070,15 +1068,6 @@ do | -silent | --silent | --silen | --sile | --sil) silent=yes ;; - -runstatedir | --runstatedir | --runstatedi | --runstated \ - | --runstate | --runstat | --runsta | --runst | --runs \ - | --run | --ru | --r) - ac_prev=runstatedir ;; - -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ - | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ - | --run=* | --ru=* | --r=*) - runstatedir=$ac_optarg ;; - -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ @@ -1216,7 +1205,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir runstatedir + libdir localedir mandir do eval ac_val=\$$ac_var # Remove trailing slashes. @@ -1369,7 +1358,6 @@ Fine tuning of the installation directories: --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] - --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] diff --git a/win/makefile.vc b/win/makefile.vc index 8380b90..f987f7c 100644 --- a/win/makefile.vc +++ b/win/makefile.vc @@ -313,7 +313,7 @@ BITMAPDIR = $(ROOT)\bitmaps PRJ_INCLUDES = -I"$(BITMAPDIR)" -I"$(XLIBDIR)"
CONFIG_DEFS =-DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 \
- -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 \
+ -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 \
-DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 \
-DSUPPORT_CONFIG_EMBEDDED \
!if $(HAVE_UXTHEME_H)
diff --git a/win/tkWinDialog.c b/win/tkWinDialog.c index 072a14c..b287691 100644 --- a/win/tkWinDialog.c +++ b/win/tkWinDialog.c @@ -790,7 +790,7 @@ Tk_ChooseColorObjCmd( chooseColor.Flags = CC_RGBINIT | CC_FULLOPEN | CC_ENABLEHOOK; chooseColor.lCustData = (LPARAM) NULL; chooseColor.lpfnHook = (LPOFNHOOKPROC) ColorDlgHookProc; - chooseColor.lpTemplateName = (LPTSTR) interp; + chooseColor.lpTemplateName = (LPWSTR) interp; for (i = 1; i < objc; i += 2) { int index; @@ -2504,7 +2504,7 @@ Tk_ChooseDirectoryObjCmd( if (ofnOpts.titleObj != NULL) { Tcl_DStringInit(&titleString); Tcl_UtfToUniCharDString(Tcl_GetString(ofnOpts.titleObj), -1, &titleString); - bInfo.lpszTitle = (LPTSTR) Tcl_DStringValue(&titleString); + bInfo.lpszTitle = (LPWSTR) Tcl_DStringValue(&titleString); } else { bInfo.lpszTitle = L"Please choose a directory, then select OK."; } diff --git a/win/tkWinDraw.c b/win/tkWinDraw.c index d3830e7..d053e78 100644 --- a/win/tkWinDraw.c +++ b/win/tkWinDraw.c @@ -519,7 +519,6 @@ TkPutImage( BITMAPINFO *infoPtr; HBITMAP bitmap; char *data; - Visual *visual; display->request++; @@ -557,7 +556,7 @@ TkPutImage( infoPtr = ckalloc(sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD)*ncolors); } else { - infoPtr = ckalloc(sizeof(BITMAPINFOHEADER) + sizeof(DWORD)*4); + infoPtr = ckalloc(sizeof(BITMAPINFOHEADER)); } infoPtr->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); @@ -565,13 +564,13 @@ TkPutImage( infoPtr->bmiHeader.biHeight = -image->height; /* Top-down order */ infoPtr->bmiHeader.biPlanes = 1; infoPtr->bmiHeader.biBitCount = image->bits_per_pixel; + infoPtr->bmiHeader.biCompression = BI_RGB; infoPtr->bmiHeader.biSizeImage = 0; infoPtr->bmiHeader.biXPelsPerMeter = 0; infoPtr->bmiHeader.biYPelsPerMeter = 0; infoPtr->bmiHeader.biClrImportant = 0; if (usePalette) { - infoPtr->bmiHeader.biCompression = BI_RGB; infoPtr->bmiHeader.biClrUsed = ncolors; for (i = 0; i < ncolors; i++) { infoPtr->bmiColors[i].rgbBlue = GetBValue(colors[i]); @@ -580,13 +579,7 @@ TkPutImage( infoPtr->bmiColors[i].rgbReserved = 0; } } else { - infoPtr->bmiHeader.biCompression = BI_BITFIELDS; - /* Modelled on XGetVisualInfo() in xutil.c. - * We want to get the rgb masks for the default visual for the given display. */ - visual = DefaultVisual(display,0); - *((DWORD *)((unsigned char *)infoPtr + sizeof(BITMAPINFOHEADER))) = visual->blue_mask; - *((DWORD *)((unsigned char *)infoPtr + sizeof(BITMAPINFOHEADER))+1) = visual->green_mask; - *((DWORD *)((unsigned char *)infoPtr + sizeof(BITMAPINFOHEADER))+2) = visual->red_mask; + infoPtr->bmiHeader.biClrUsed = 0; } bitmap = CreateDIBitmap(dc, &infoPtr->bmiHeader, CBM_INIT, image->data, infoPtr, DIB_RGB_COLORS); diff --git a/win/tkWinInit.c b/win/tkWinInit.c index f36a879..2b86876 100644 --- a/win/tkWinInit.c +++ b/win/tkWinInit.c @@ -178,14 +178,14 @@ Tcl_Obj* TkWin32ErrorObj( HRESULT hrError) { - LPTSTR lpBuffer = NULL, p = NULL; + LPWSTR lpBuffer = NULL, p = NULL; WCHAR sBuffer[30]; Tcl_Obj* errPtr = NULL; Tcl_DString ds; FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, (DWORD)hrError, - LANG_NEUTRAL, (LPTSTR)&lpBuffer, 0, NULL); + LANG_NEUTRAL, (LPWSTR)&lpBuffer, 0, NULL); if (lpBuffer == NULL) { lpBuffer = sBuffer; diff --git a/win/tkWinPixmap.c b/win/tkWinPixmap.c index 92b4f50..c5abf1d 100644 --- a/win/tkWinPixmap.c +++ b/win/tkWinPixmap.c @@ -105,7 +105,7 @@ Tk_GetPixmap( NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, NULL)) { - MessageBox(NULL, (LPTSTR) lpMsgBuf, + MessageBox(NULL, (LPWSTR) lpMsgBuf, L"Tk_GetPixmap: Error from CreateDIBSection", MB_OK | MB_ICONINFORMATION); LocalFree(lpMsgBuf); diff --git a/win/tkWinPointer.c b/win/tkWinPointer.c index 6f1f840..251b5b9 100644 --- a/win/tkWinPointer.c +++ b/win/tkWinPointer.c @@ -81,6 +81,12 @@ TkWinGetModifierState(void) if (GetKeyState(VK_RBUTTON) & 0x8000) { state |= Button3Mask; } + if (GetKeyState(VK_XBUTTON1) & 0x8000) { + state |= Button4Mask; + } + if (GetKeyState(VK_XBUTTON2) & 0x8000) { + state |= Button5Mask; + } return state; } diff --git a/win/tkWinPort.h b/win/tkWinPort.h index 254f44e..74cac15 100644 --- a/win/tkWinPort.h +++ b/win/tkWinPort.h @@ -64,6 +64,7 @@ typedef _TCHAR TCHAR; #endif +#include <unistd.h> #include <X11/Xlib.h> #include <X11/cursorfont.h> #include <X11/keysym.h> diff --git a/win/tkWinTest.c b/win/tkWinTest.c index f3ec298..098da63 100644 --- a/win/tkWinTest.c +++ b/win/tkWinTest.c @@ -288,6 +288,16 @@ TestwineventObjCmd( static const TkStateMap messageMap[] = { {WM_LBUTTONDOWN, "WM_LBUTTONDOWN"}, {WM_LBUTTONUP, "WM_LBUTTONUP"}, + {WM_LBUTTONDBLCLK, "WM_LBUTTONDBLCLK"}, + {WM_MBUTTONDOWN, "WM_MBUTTONDOWN"}, + {WM_MBUTTONUP, "WM_MBUTTONUP"}, + {WM_MBUTTONDBLCLK, "WM_MBUTTONDBLCLK"}, + {WM_RBUTTONDOWN, "WM_RBUTTONDOWN"}, + {WM_RBUTTONUP, "WM_RBUTTONUP"}, + {WM_RBUTTONDBLCLK, "WM_RBUTTONDBLCLK"}, + {WM_XBUTTONDOWN, "WM_XBUTTONDOWN"}, + {WM_XBUTTONUP, "WM_XBUTTONUP"}, + {WM_XBUTTONDBLCLK, "WM_XBUTTONDBLCLK"}, {WM_CHAR, "WM_CHAR"}, {WM_GETTEXT, "WM_GETTEXT"}, {WM_SETTEXT, "WM_SETTEXT"}, @@ -543,7 +553,7 @@ TestgetwindowinfoObjCmd( Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("id", 2), Tcl_NewWideIntObj(GetWindowLongPtr((HWND)(size_t)hwnd, GWL_ID))); - cch = GetWindowText((HWND)(size_t)hwnd, (LPTSTR)buf, cchBuf); + cch = GetWindowText((HWND)(size_t)hwnd, buf, cchBuf); Tcl_DStringInit(&ds); Tcl_UniCharToUtfDString(buf, cch, &ds); textObj = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds)); diff --git a/win/tkWinX.c b/win/tkWinX.c index d6487bb..14075c4 100644 --- a/win/tkWinX.c +++ b/win/tkWinX.c @@ -258,7 +258,7 @@ TkWinXInit( if (GetLocaleInfo(LANGIDFROMLCID(PTR2INT(GetKeyboardLayout(0))), LOCALE_IDEFAULTANSICODEPAGE | LOCALE_RETURN_NUMBER, - (LPTSTR) &lpCP, sizeof(lpCP)/sizeof(WCHAR)) + (LPWSTR) &lpCP, sizeof(lpCP)/sizeof(WCHAR)) && TranslateCharsetInfo(INT2PTR(lpCP), &lpCs, TCI_SRCCODEPAGE)) { UpdateInputLanguage((int) lpCs.ciCharset); } @@ -468,21 +468,21 @@ TkWinDisplayChanged( } else if (screen->root_depth == 12) { screen->root_visual->class = TrueColor; screen->root_visual->map_entries = 32; - screen->root_visual->red_mask = 0xf00000; + screen->root_visual->red_mask = 0xf0; screen->root_visual->green_mask = 0xf000; - screen->root_visual->blue_mask = 0xf0; + screen->root_visual->blue_mask = 0xf00000; } else if (screen->root_depth == 16) { screen->root_visual->class = TrueColor; screen->root_visual->map_entries = 64; - screen->root_visual->red_mask = 0xf80000; + screen->root_visual->red_mask = 0xf8; screen->root_visual->green_mask = 0xfc00; - screen->root_visual->blue_mask = 0xf8; + screen->root_visual->blue_mask = 0xf80000; } else if (screen->root_depth >= 24) { screen->root_visual->class = TrueColor; screen->root_visual->map_entries = 256; - screen->root_visual->red_mask = 0xff0000; + screen->root_visual->red_mask = 0xff; screen->root_visual->green_mask = 0xff00; - screen->root_visual->blue_mask = 0xff; + screen->root_visual->blue_mask = 0xff0000; } screen->root_visual->bits_per_rgb = screen->root_depth; ReleaseDC(NULL, dc); @@ -884,9 +884,12 @@ Tk_TranslateWinEvent( case WM_MBUTTONDBLCLK: case WM_RBUTTONDOWN: case WM_RBUTTONDBLCLK: + case WM_XBUTTONDOWN: + case WM_XBUTTONDBLCLK: case WM_LBUTTONUP: case WM_MBUTTONUP: case WM_RBUTTONUP: + case WM_XBUTTONUP: case WM_MOUSEMOVE: Tk_PointerEvent(hwnd, (short) LOWORD(lParam), (short) HIWORD(lParam)); return 1; @@ -1675,7 +1678,7 @@ HandleIMEComposition( * TkWinResendEvent -- * * This function converts an X event into a Windows event and invokes the - * specified windo function. + * specified window function. * * Results: * A standard Windows result. @@ -1713,6 +1716,14 @@ TkWinResendEvent( msg = WM_RBUTTONDOWN; wparam = MK_RBUTTON; break; + case Button4: + msg = WM_XBUTTONDOWN; + wparam = MAKEWPARAM(MK_XBUTTON1, XBUTTON1); + break; + case Button5: + msg = WM_XBUTTONDOWN; + wparam = MAKEWPARAM(MK_XBUTTON2, XBUTTON2); + break; default: return 0; } @@ -1726,6 +1737,12 @@ TkWinResendEvent( if (eventPtr->xbutton.state & Button3Mask) { wparam |= MK_RBUTTON; } + if (eventPtr->xbutton.state & Button4Mask) { + wparam |= MK_XBUTTON1; + } + if (eventPtr->xbutton.state & Button5Mask) { + wparam |= MK_XBUTTON2; + } if (eventPtr->xbutton.state & ShiftMask) { wparam |= MK_SHIFT; } |