From 7e1886554eaaffb141641625bb597ff69c58d6b7 Mon Sep 17 00:00:00 2001 From: wolfsuit Date: Tue, 11 Feb 2003 07:26:18 +0000 Subject: 2003-02-10 Jim Ingham * macosx/tkMacOSXCursor.c (TkMacOSXInstallCursor): Set all theme cursors using SetThemeCursor or SetAnimatedThemeCursors. (TkGetCursorByName): Use the theme cursors for arrow, ibeam, etc. Allow animatedCursor{NUM} form for an animated cursor with count. (TkpSetCursor): Don't reset the cursor if there is no change. * macosx/tkMacOSXMouseEvent.c (GeneratePollingEvents): Don't directly call TkMacOSXInstallCursor, it gets called by the call to Tk_UpdatePointer immediately above. --- ChangeLog | 7 ++- macosx/README | 26 ++++++++++- macosx/tkMacOSXCursor.c | 104 ++++++++++++++++++++++++++++++++------------ macosx/tkMacOSXMouseEvent.c | 5 +-- 4 files changed, 108 insertions(+), 34 deletions(-) diff --git a/ChangeLog b/ChangeLog index c1d4638..bc49e78 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,7 +3,12 @@ * macosx/tkMacOSXCursor.c (TkMacOSXInstallCursor): Set all theme cursors using SetThemeCursor or SetAnimatedThemeCursors. (TkGetCursorByName): Use the theme cursors for arrow, ibeam, etc. - + Allow animatedCursor{NUM} form for an animated cursor with count. + (TkpSetCursor): Don't reset the cursor if there is no change. + * macosx/tkMacOSXMouseEvent.c (GeneratePollingEvents): Don't + directly call TkMacOSXInstallCursor, it gets called by the call + to Tk_UpdatePointer immediately above. + 2003-02-05 Fred Fish * macosx/tkMacOSXWm.c (Tk_SetGrid): Fix precedence problem with diff --git a/macosx/README b/macosx/README index b354bd0..d84ec54 100644 --- a/macosx/README +++ b/macosx/README @@ -1,7 +1,7 @@ TclTkAqua README ---------------- -RCS: @(#) $Id: README,v 1.3 2002/10/29 00:51:12 das Exp $ +RCS: @(#) $Id: README,v 1.4 2003/02/11 07:26:18 wolfsuit Exp $ This is the README file for the Mac OS X native versions of Tcl & Tk. @@ -90,6 +90,30 @@ allows to dis/enable antialiasing on the fly from tcl (even for existing text). libraries (.dylib) and not MachO bundles, at present loading of MachO bundles is not supported. +- Scrollbars: There are two scrollbar variants in Aqua, normal & small. The +normal scrollbar has a small dimension of 16, the small variant 12. Access +to the small variant was added in Tk 8.4.3. + +- Cursors: You can now put up and spin the Classic MacOS spinner, and the +counting hands and watch cursor. The way this is done is each of the spinners +have a base name: + + spinning: The circular B&W circular spinner + countinguphand: The counting up hand + countingdownhand: The counting down hand + countingupanddownhand: The counting up then down hand + watch: The watch cursor + +Then to get the sequential variants, add an integer to the end of the base +name. So, for instance this code will spin the spinner: + +proc spinCursor {widget count} { + $widget configure -cursor spinning$count + after 100 spinCursor [incr count] +} + +This was added in Tk 8.4.3 + 3. Building TclTkAqua --------------------- diff --git a/macosx/tkMacOSXCursor.c b/macosx/tkMacOSXCursor.c index 681e895..8e72897 100644 --- a/macosx/tkMacOSXCursor.c +++ b/macosx/tkMacOSXCursor.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkMacOSXCursor.c,v 1.3 2003/02/10 22:03:23 wolfsuit Exp $ + * RCS: @(#) $Id: tkMacOSXCursor.c,v 1.4 2003/02/11 07:26:18 wolfsuit Exp $ */ #include "tkPort.h" @@ -23,9 +23,11 @@ * The default theme cursors (listed in cursorNames below), * color resource cursors, & normal cursors. */ - -#define COLOR 1 /* Cursors of type crsr. */ -#define NORMAL 2 /* Cursors of type CURS. */ + +#define THEME 0 /* Theme cursors */ +#define ANIMATED 1 /* Animated theme cursors */ +#define COLOR 2 /* Cursors of type crsr. */ +#define NORMAL 3 /* Cursors of type CURS. */ /* * The following data structure contains the system specific data @@ -39,6 +41,8 @@ typedef struct { int type; /* Type of Mac cursor: for theme cursors * this is the theme cursor constant, * otherwise one of crsr or CURS */ + unsigned int count; /* For animating cursors, the count for the + cursor. */ } TkMacOSXCursor; /* @@ -46,10 +50,12 @@ typedef struct { * to its resource identifier. */ -static struct CursorName { +struct CursorName { char *name; int id; -} cursorNames[] = { +}; + +static struct CursorName themeCursorNames[] = { {"ibeam", kThemeIBeamCursor}, {"text", kThemeIBeamCursor}, {"xterm", kThemeIBeamCursor}, @@ -57,11 +63,15 @@ static struct CursorName { {"crosshair", kThemeCrossCursor}, {"cross-hair", kThemeCrossCursor}, {"plus", kThemePlusCursor}, - {"watch", kThemeWatchCursor}, {"arrow", kThemeArrowCursor}, {"closedhand", kThemeClosedHandCursor}, {"openhand", kThemeOpenHandCursor}, {"pointinghand", kThemePointingHandCursor}, + {NULL, 0} +}; + +static struct CursorName animatedThemeCursorNames[] = { + {"watch", kThemeWatchCursor}, {"countinguphand", kThemeCountingUpHandCursor}, {"countingdownhand", kThemeCountingDownHandCursor}, {"countingupanddownhand", kThemeCountingUpAndDownHandCursor}, @@ -175,14 +185,15 @@ FindCursorByName( TkCursor * TkGetCursorByName( - Tcl_Interp *interp, /* Interpreter to use for error reporting. */ - Tk_Window tkwin, /* Window in which cursor will be used. */ - Tk_Uid string) /* Description of cursor. See manual entry - * for details on legal syntax. */ + Tcl_Interp *interp, /* Interpreter to use for error reporting. */ + Tk_Window tkwin, /* Window in which cursor will be used. */ + Tk_Uid string) /* Description of cursor. See manual entry + * for details on legal syntax. */ { struct CursorName *namePtr; TkMacOSXCursor *macCursorPtr; - + int count = -1; + macCursorPtr = (TkMacOSXCursor *) ckalloc(sizeof(TkMacOSXCursor)); macCursorPtr->info.cursor = (Tk_Cursor) macCursorPtr; @@ -192,17 +203,41 @@ TkGetCursorByName( * attempt to load the cursor as a named Mac resource. */ - for (namePtr = cursorNames; namePtr->name != NULL; namePtr++) { + for (namePtr = themeCursorNames; namePtr->name != NULL; namePtr++) { if (strcmp(namePtr->name, string) == 0) { + macCursorPtr->count = -1; + macCursorPtr->macCursor = (Handle) namePtr; + macCursorPtr->type = THEME; break; } } + if (namePtr->name == NULL) { + for (namePtr = animatedThemeCursorNames; + namePtr->name != NULL; namePtr++) { + int namelen = strlen (namePtr->name); + if (strncmp(namePtr->name, string, namelen) == 0) { + const char *numPtr = string + namelen; + if (*numPtr == '\0') { + count = -1; + } else { + int result; + result = Tcl_GetInt(NULL, numPtr, &count); + if (result != TCL_OK) { + continue; + } + } + macCursorPtr->macCursor = (Handle) namePtr; + macCursorPtr->type = ANIMATED; + macCursorPtr->count = count; + break; + } + } + } + - if (namePtr->name != NULL) { - macCursorPtr->macCursor = (Handle) -1; - macCursorPtr->type = namePtr->id; - } else { + + if (namePtr->name == NULL) { FindCursorByName(macCursorPtr, string); if (macCursorPtr->macCursor == NULL) { @@ -301,7 +336,6 @@ TkpFreeCursor( gCurrentCursor = NULL; } } - /* *---------------------------------------------------------------------- * @@ -342,17 +376,22 @@ TkMacOSXInstallCursor( } } else if (macCursorPtr == NULL) { SetThemeCursor(kThemeArrowCursor); - } else if (macCursorPtr->macCursor == (void *) -1) { - OSErr err = noErr; - - if (macCursorPtr->type >= kThemeWatchCursor) { - err = SetAnimatedThemeCursor(macCursorPtr->type, cursorStep++); - } - if (err != noErr) { - SetThemeCursor(macCursorPtr->type); - } } else { + struct CursorName *namePtr; switch (macCursorPtr->type) { + case THEME: + namePtr = (struct CursorName *) macCursorPtr->macCursor; + SetThemeCursor( + namePtr->id); + break; + case ANIMATED: + namePtr = (struct CursorName *) macCursorPtr->macCursor; + if (macCursorPtr->count == -1) { + SetAnimatedThemeCursor(namePtr->id, cursorStep++); + } else { + SetAnimatedThemeCursor(namePtr->id, macCursorPtr->count); + } + break; case COLOR: ccursor = (CCrsrHandle) macCursorPtr->macCursor; SetCCursor(ccursor); @@ -385,16 +424,25 @@ void TkpSetCursor( TkpCursor cursor) { + int cursorChanged = 1; + if (!gTkOwnsCursor) { return; } + if (cursor == None) { + if (gCurrentCursor == NULL) { + cursorChanged = 0; + } gCurrentCursor = NULL; } else { + if (gCurrentCursor == (TkMacOSXCursor *) cursor) { + cursorChanged = 0; + } gCurrentCursor = (TkMacOSXCursor *) cursor; } - if (Tk_MacOSXIsAppInFront()) { + if (Tk_MacOSXIsAppInFront() && cursorChanged) { TkMacOSXInstallCursor(gResizeOverride); } } diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c index 12bfc93..07c36c5 100644 --- a/macosx/tkMacOSXMouseEvent.c +++ b/macosx/tkMacOSXMouseEvent.c @@ -453,9 +453,6 @@ GeneratePollingEvents(MouseEventData * medPtr) Tk_UpdatePointer(tkwin, medPtr->global.h, medPtr->global.v, medPtr->state); - - TkMacOSXInstallCursor(0); - return true; } @@ -737,4 +734,4 @@ TkGenerateButtonEvent( Tk_UpdatePointer(tkwin, x, y, state); return true; -} \ No newline at end of file +} -- cgit v0.12